[ Video Sharing CMS v4 ] Daily upload limit per user /How to limit daily uploads in PHPVibe

Started by ASDF,

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ASDFTopic starter

Hi Mario...i don't want my users to upload, say (X)number of files per day, or let's just say that i want to limit number of uploads per user per day... :) .
  •  

mihai

I am curious about if is posible to don''t let them share the same file
ex(user:Alice shared the link x so user:Marius can"t share the link x anymore becouse is already shared)
  •  

ASDFTopic starter

Stopping users from sharing the same file....acc to me is impossible, and the rest depends on Mario, if he has some codes
If you are talking about,images, then you should make it mandatory for users to add a watermark, so that you can delete the multiple uploads, the same thing can be applied on videos too, if uploading is enabled for users, i don't think you will be able to stop them from sharing the same file via youtube link....but you can delete them by yourself. Another solution is,ask your user to search first if the file he is uploading,by tags and related search terms, if the file has been already uploaded by someone,then they should upload that again, or else we will delete the file, resulting in total waste of time and money/data. Repeating that might lead to termination of account or something like that.
  •  

ASDFTopic starter

  •  

Marius P.

Kinder garden questions :)
Query a count on the user's videos uploaded today , build your if on the upload page:)

if($uservids->nr > 5) {
echo "No more dude!"
} else {
//render normal upload page
}



Don't ask for true code today, is weekend, I'm on an tablet traveling.
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

ASDFTopic starter

No more dude.... :p :p :p, good one.
But dude, which file to edit?
  •  

Marius P.

Always com/com_add.php for video uploads :)
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

ASDFTopic starter

Hey Mario...can you tell me where to insert that code....is it possible for you?
  •  

ASDFTopic starter

  •  

ASDFTopic starter

 ;D....can you tell me where to insert the above code for limiting uploads by user.
  •  

Marius P.

If you want to copy/paste it you'll just get that $uservids->nr is undefined :)
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

ASDFTopic starter

Sorry bro, i don't know if it's the same, but i have to limit the users by from uploading (X) number of photos....sorry,i only mentioned the uploads earlier and not the type.
You said for video related things, i should always look into com_add.php.....but what about the photos.
Com_image.php? and can it be done. Sorry again.
Please please help me with this one.
This is a must for me right now. :( :( :(.
  •  

ASDFTopic starter

  •  

Marius P.

#13
Here is the sql query examples returning what you need.

For videos:
SELECT COUNT( * ) 
FROM `vibe_videos` 
WHERE `user_id` =1
AND DATE( DATE ) = DATE( NOW( ) ) 
AND media = '1'



For pictures:


SELECT COUNT( * ) 
FROM `vibe_videos` 
WHERE `user_id` =1
AND DATE( DATE ) = DATE( NOW( ) ) 
AND media = '3'



Now that you know the logic query here is how it goes in PHPVibe:


$uservids = $db->get_row("Select count(*) as nr from ".DB_PREFIX."videos WHERE `user_id` = '".user_id()."' AND DATE( DATE ) = DATE( NOW( ) ) AND media = '1' ");



now


$uservids->nr


and you can easily do an if:


if($uservids->nr > 4){
echo "You have reached the daily number of 5 videos.";

}

Holds the number of videos uploaded today by the current user.


Same for pictures, just media is 3 in that case, for music is 2.

Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

Marius P.

Quote from: ASDF on
Please Mario.... :( :-\ :-\.

You saw me typing here and you decided I need a push? :)
I was anyways answering you.
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

ASDFTopic starter

  •  

ASDFTopic starter

Hey Mario...your this line...Holds the number of videos uploaded today by the current user.
Has confused me totally, the above code is for limiting the user from uploading the X number of images (media 3 )?
If, yes...then where am i supposed to insert that code now and where in the particular file....com_add.php or com_images.php?
:p.
  •  

Marius P.

Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

ASDFTopic starter

In which file for limiting image uploads....com_add.php or com_image.php and where.....i know bro you will literally beat the hell out of me if i show you up, as you are pissed, but i even know a minor mistake in coding can bring the whole website down.
  •  

Marius P.

Do you read what your are asking? Or think about it for a second? I've already told you before com_add is for video, com_image is for images (it has 'image' in it  ??? )
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

Marius P.

I'm not pissed, I know I'm not all sugar, pretty hard to be when you eyes and head hurt 24/7.
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

ASDFTopic starter

Sorry mate  :p...getting different types of errors, that's why i have given you the codes ^-^ :) :).
  •  

Marius P.

Want me to make you an paid subscription for coding lessons?  :p


All you need is this area:


if((get_option('uploadrule') == 1) ||  is_moderator()) {    
add_filter( 'the_defaults', 'modify_content' );
} else {
add_filter( 'the_defaults', _lang("Uploading is disabled") );
}



like:



/* New line */ if(($uservids->nr > 4) && !is_moderator()){
if((get_option('uploadrule') == 1) ||  is_moderator()) {   
add_filter( 'the_defaults', 'modify_content' );
} else {
add_filter( 'the_defaults', _lang("Uploading is disabled") );
}

/* New condition */
} else {
add_filter( 'the_defaults', _lang("You have passed your daily limit of X videos/images/music bla bla") );
}



Don't forget to place the actual query right before this code :)
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

ASDFTopic starter

  •  

ASDFTopic starter

  •  

ASDFTopic starter

  •  

Marius P.

Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

ASDFTopic starter

  •  

Marius P.

Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

Marius P.

I've even clearly explained you how to put the querys in PHPVibe

Quote from: @Mario on

Now that you know the logic query here is how it goes in PHPVibe:

$uservids = $db->get_row("Select count(*) as nr from ".DB_PREFIX."videos WHERE `user_id` = '".user_id()."' AND DATE( DATE ) = DATE( NOW( ) ) AND media = '1' ");


Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

ASDFTopic starter

  •  

Marius P.

Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

ASDFTopic starter

Bro.... i am tired too.... :-\ :-\ :-\....thinking to shut this topic......
line 143.... ...from 'vibe_videos' line.
  •  

ASDFTopic starter

From line 142....i have copied and pasted the codes as you have told....
I believe this will simplify the things....you can now see and tell me what's wrong......or the whole thing id fked up?
  •  

Marius P.

OMG! You are still pasting raw sql in the file even if I've given you it with the php wrapper!
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

ASDFTopic starter

 :eek: :eek: :eek:...  :-[..
Bro, i have told you that i don' code and knows nothing.
  •  

Marius P.

Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

ASDFTopic starter

Hey Mario.....honestly, you have helped me a lot, no complaints, from you and community.
Sorry from my side....m not a coder, but still requesting you,if possible for you to just give me the code i should copy and paste, also, if you think it's impossible or you can't do it anymore, you can remove the topic.... :).
  •  

Marius P.


For images

$uservids = $db->get_row("Select count(*) as nr from ".DB_PREFIX."videos WHERE `user_id` = '".user_id()."' AND DATE( DATE ) = DATE( NOW( ) ) AND media = '3' ");

if(($uservids->nr > 4) && !is_moderator()){
if((get_option('uploadrule') == 1) ||  is_moderator()) {   
add_filter( 'the_defaults', 'modify_content' );
} else {
add_filter( 'the_defaults', _lang("Uploading is disabled") );
}

} else {
add_filter( 'the_defaults', _lang("You have passed your daily limit of X images") );
}



For videos


$uservids = $db->get_row("Select count(*) as nr from ".DB_PREFIX."videos WHERE `user_id` = '".user_id()."' AND DATE( DATE ) = DATE( NOW( ) ) AND media = '1' ");
if(($uservids->nr > 4) && !is_moderator()){if((get_option('uploadrule') == 1) ||  is_moderator()) {   add_filter( 'the_defaults', 'modify_content' );} else {add_filter( 'the_defaults', _lang("Uploading is disabled") );}} else {add_filter( 'the_defaults', _lang("You have passed your daily limit of X videos") );}


I'm surprised you could not understand a simple to very simple thing.
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

ASDFTopic starter

Getting these errors after adding the code....
One pic contains the error....and the second one,shows the actual place where error is, line 142.
  •  

ASDFTopic starter

  •  

Marius P.

Hmm, I don't have that, but, here is a solution.

Change:

add_filter( 'the_defaults', _lang("You have passed your daily limit of X videos/images/music bla bla") );



to
function limr() {
return _lang("You have passed your daily limit of X videos/images/music bla bla") ;
}
add_filter( 'the_defaults','limr' );
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

ASDFTopic starter

Hey Mario, not errors but this is what i am getting when trying to upload, in the pic.
If this is because i haven't created the cron job....then what will be the command/path......as i have seen on youtube and examples......will it be......public_html/com_com.images.php, :p :-\ :-\.
Also, am i supposed to enter the timing of ...once a day...
  •  

ASDFTopic starter

  •  

Marius P.

What cron job man?  ;D  There is no cron job in PHPVibe except for the youtube importer's one!  ::)
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

Marius P.

Show me all the code you have placed there (only the new/changed code).

Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

ASDFTopic starter

 :o....But i read a conversation/topic by ollipoust (a user) and Alexander on the same topic, and alexander did advised about him for some cron stuff.ok, leave it, Alexander isn't here :p.
  •  

Marius P.

Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

ASDFTopic starter

Quote$uservids = $db->get_row("Select count(*) as nr from ".DB_PREFIX."videos WHERE `user_id` = '".user_id()."' AND DATE( DATE ) = DATE( NOW( ) ) AND media = '3' ");

if(($uservids->nr > 4) && !is_moderator()){
if((get_option('uploadrule') == 1) ||  is_moderator()) {   
add_filter( 'the_defaults', 'modify_content' );
} else {
add_filter( 'the_defaults', _lang("Uploading is disabled") );
}

} else {
function limr() {
return _lang("You have reached the daily upload limits, no more uploads for today.") ;
}
add_filter( 'the_defaults','limr' );
}
  •  

ASDFTopic starter

$uservids = $db->get_row("Select count(*) as nr from ".DB_PREFIX."videos WHERE `user_id` = '".user_id()."' AND DATE( DATE ) = DATE( NOW( ) ) AND media = '3' ");

if(($uservids->nr > 4) && !is_moderator()){
if((get_option('uploadrule') == 1) ||  is_moderator()) {   
add_filter( 'the_defaults', 'modify_content' );
} else {
add_filter( 'the_defaults', _lang("Uploading is disabled") );
}

} else {
function limr() {
return _lang("You have reached the daily upload limits, no more uploads for today.") ;
} 
add_filter( 'the_defaults','limr' );
}
  •  

Marius P.

Sorry,
I've accidentally inverted it (to much work in parallel).

Here you go:

if(($uservids->nr > 4) && !is_moderator()){



should be


if(($uservids->nr < 6) || is_moderator()){



This for 5 limit (else add limit + 1 instead of 6).
Moderators and Admins will not be restricted to this limit.
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

ASDFTopic starter

 :) :) :)....but bro, can't we restrict moderator only, and not the admin. :p :( :(.
  •  

ASDFTopic starter

Hey Mario....for mods and admins, it's showing the same thing, you have reached the daily upload limits, and for member only, it is showing a warning kind of message, and gives a error.
The image uploading form is not displayable in bot the situations.
  •  

ASDFTopic starter

And now i can die in peace.....long live Mario. :) :) ^-^ :P.
The code is working....Thank you and sorry bro. :p.
But bro, do let me know if i can limit my moderators too.


Hail Mario... ;D :D :P.
Your sincerely (Brain eater)
Zombie/ASDF.
  •  

Marius P.

Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

Similar topics (7)