Related Topics


[Video CMS v4]Daily upload limit per user /How to limit daily uploads in PHPVibe  (Read 2544 times) Print

1 2 3 All B


ASDF  September 19, 2014, 08:56:47 PM

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... :) .

Logged


mihai  September 19, 2014, 11:33:34 PM

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)

Logged


ASDF  September 20, 2014, 09:43:26 AM

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.

Logged


ASDF  September 20, 2014, 09:40:26 PM

???

Logged


@Mario  September 20, 2014, 10:08:53 PM

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

Code
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.

Logged
Hello!
If you wish to learn how to start coding on the PHPVibe Video CMS head to the blog.

Please use the search before opening a new topic!


ASDF  September 20, 2014, 10:11:34 PM

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

Logged


@Mario  September 20, 2014, 10:16:06 PM

Always com/com_add.php for video uploads :)

Logged
Hello!
If you wish to learn how to start coding on the PHPVibe Video CMS head to the blog.

Please use the search before opening a new topic!


ASDF  September 20, 2014, 10:27:43 PM

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

Logged


ASDF  September 21, 2014, 03:51:08 PM

???

Logged


ASDF  September 22, 2014, 08:02:43 PM

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

Logged


@Mario  September 22, 2014, 08:43:56 PM

If you want to copy/paste it you'll just get that $uservids->nr is undefined :)

Logged
Hello!
If you wish to learn how to start coding on the PHPVibe Video CMS head to the blog.

Please use the search before opening a new topic!


ASDF  September 23, 2014, 09:34:39 AM

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. :( :( :(.

Logged


ASDF  September 23, 2014, 12:59:09 PM

Please Mario.... :( :-\ :-\.

Logged


@Mario  September 23, 2014, 01:03:42 PM

Here is the sql query examples returning what you need.

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


For pictures:


Code
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:


Code
$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


Code
$uservids->nr

and you can easily do an if:


Code
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.


Logged
Hello!
If you wish to learn how to start coding on the PHPVibe Video CMS head to the blog.

Please use the search before opening a new topic!


@Mario  September 23, 2014, 01:12:08 PM

Please Mario.... :( :-\ :-\.

You saw me typing here and you decided I need a push? :)
I was anyways answering you.

Logged
Hello!
If you wish to learn how to start coding on the PHPVibe Video CMS head to the blog.

Please use the search before opening a new topic!


ASDF  September 23, 2014, 02:01:15 PM

Hahaha.... ;D.

Logged


ASDF  September 23, 2014, 02:26:35 PM

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.

Logged


@Mario  September 23, 2014, 03:11:12 PM

I've even code exampled you how to limit...

Logged
Hello!
If you wish to learn how to start coding on the PHPVibe Video CMS head to the blog.

Please use the search before opening a new topic!


ASDF  September 23, 2014, 03:23:04 PM

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.

Logged


@Mario  September 23, 2014, 03:35:51 PM

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  ??? )

Logged
Hello!
If you wish to learn how to start coding on the PHPVibe Video CMS head to the blog.

Please use the search before opening a new topic!


@Mario  September 23, 2014, 03:36:41 PM

I'm not pissed, I know I'm not all sugar, pretty hard to be when you eyes and head hurt 24/7.

Logged
Hello!
If you wish to learn how to start coding on the PHPVibe Video CMS head to the blog.

Please use the search before opening a new topic!


ASDF  September 23, 2014, 06:51:25 PM

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

Logged


@Mario  September 23, 2014, 07:47:37 PM

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


All you need is this area:


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


like:



Code

/* 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 :)

Logged
Hello!
If you wish to learn how to start coding on the PHPVibe Video CMS head to the blog.

Please use the search before opening a new topic!


ASDF  September 23, 2014, 08:27:53 PM

Hahaha....honestly bro, i am interested in learning it from you. :) :P :P.

Logged


ASDF  September 23, 2014, 08:50:24 PM

Getting error on line 142... :(.

Logged


ASDF  September 23, 2014, 08:52:27 PM

sorry sent you the wrong pic..... :( :( :p.

Logged


@Mario  September 23, 2014, 08:52:35 PM

And line 142 is...?

Logged
Hello!
If you wish to learn how to start coding on the PHPVibe Video CMS head to the blog.

Please use the search before opening a new topic!


ASDF  September 23, 2014, 08:57:30 PM

In the previous message, in picture.

Logged


@Mario  September 23, 2014, 09:00:21 PM

You must be kidding me!

Logged
Hello!
If you wish to learn how to start coding on the PHPVibe Video CMS head to the blog.

Please use the search before opening a new topic!


@Mario  September 23, 2014, 09:01:27 PM

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


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

Code
$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' ");


Logged
Hello!
If you wish to learn how to start coding on the PHPVibe Video CMS head to the blog.

Please use the search before opening a new topic!


ASDF  September 23, 2014, 09:23:16 PM

Getting this error on line 143...in pic.
 :-\ :-[ :-[.....

Logged


@Mario  September 23, 2014, 09:27:48 PM

What is on line 143?
You really wanna do this till tomorrow?

Logged
Hello!
If you wish to learn how to start coding on the PHPVibe Video CMS head to the blog.

Please use the search before opening a new topic!


ASDF  September 23, 2014, 09:35:26 PM

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

Logged


ASDF  September 23, 2014, 09:43:43 PM

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?

Logged


@Mario  September 23, 2014, 10:07:11 PM

OMG! You are still pasting raw sql in the file even if I've given you it with the php wrapper!

Logged
Hello!
If you wish to learn how to start coding on the PHPVibe Video CMS head to the blog.

Please use the search before opening a new topic!


ASDF  September 24, 2014, 05:09:00 AM

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

Logged


@Mario  September 24, 2014, 12:36:02 PM

Read reply #29

Logged
Hello!
If you wish to learn how to start coding on the PHPVibe Video CMS head to the blog.

Please use the search before opening a new topic!


ASDF  September 24, 2014, 09:28:58 PM

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.... :).

Logged


@Mario  September 24, 2014, 09:56:59 PM


For images

Code
$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


Code
$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.

Logged
Hello!
If you wish to learn how to start coding on the PHPVibe Video CMS head to the blog.

Please use the search before opening a new topic!


ASDF  September 25, 2014, 06:43:40 AM

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.

Logged


ASDF  September 25, 2014, 06:45:04 AM

type of error...

Logged


@Mario  September 25, 2014, 09:23:12 PM

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

Change:

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


to
Code
function limr() {
return _lang("You have passed your daily limit of X videos/images/music bla bla") ;
}
add_filter( 'the_defaults','limr' );

Logged
Hello!
If you wish to learn how to start coding on the PHPVibe Video CMS head to the blog.

Please use the search before opening a new topic!


ASDF  September 26, 2014, 01:14:37 PM

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...

Logged


ASDF  September 26, 2014, 01:21:42 PM

Picture

Logged


@Mario  September 26, 2014, 01:23:58 PM

What cron job man?  ;D  There is no cron job in PHPVibe except for the youtube importer's one!  ::)

Logged
Hello!
If you wish to learn how to start coding on the PHPVibe Video CMS head to the blog.

Please use the search before opening a new topic!


@Mario  September 26, 2014, 01:24:59 PM

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


Logged
Hello!
If you wish to learn how to start coding on the PHPVibe Video CMS head to the blog.

Please use the search before opening a new topic!


ASDF  September 26, 2014, 01:31:54 PM

 :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.

Logged


@Mario  September 26, 2014, 01:34:13 PM

Paste the code so I can test it. Not picture it.

Logged
Hello!
If you wish to learn how to start coding on the PHPVibe Video CMS head to the blog.

Please use the search before opening a new topic!


ASDF  September 26, 2014, 01:36:31 PM

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' );
}

Logged


ASDF  September 26, 2014, 01:37:38 PM

Code
$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' );
}

Logged


@Mario  September 26, 2014, 01:44:16 PM

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

Here you go:

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


should be


Code
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.

Logged
Hello!
If you wish to learn how to start coding on the PHPVibe Video CMS head to the blog.

Please use the search before opening a new topic!


ASDF  September 26, 2014, 01:48:20 PM

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

Logged


ASDF  September 26, 2014, 02:00:14 PM

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.

Logged


ASDF  September 26, 2014, 10:34:11 PM

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.

Logged


@Mario  September 27, 2014, 02:52:08 PM

If you change is_moderator() with is_admin() you limit them to :)

Logged
Hello!
If you wish to learn how to start coding on the PHPVibe Video CMS head to the blog.

Please use the search before opening a new topic!