forum.coppermine-gallery.net

Support => cpg1.5 plugins => cpg1.5.x Support => cpg1.5 plugin contributions => Topic started by: Αndré on July 06, 2010, 03:13:32 pm

Title: Limit upload plugin for cpg1.5.x
Post by: Αndré on July 06, 2010, 03:13:32 pm
This plugin allows you to limit the number of uploads for your users. You can choose a total number of files, or a certain amount of files for different periods of time.

Download: http://sourceforge.net/projects/coppermine/files/Plugins/1.5.x/cpg1.5.x_plugin_limit_upload_v1.0.zip/download
Title: Re: Limit upload plugin for cpg1.5.x
Post by: ThunderRed on July 07, 2010, 01:20:09 am
Thanks for the plugin. I just tried and it doesn't looks to work right.

I login like admin, and activated the plugin, and uploads a couple of pictures ( I guess that the restrictions doesn't affect the admin, which is cool). Then I log out and I log in with the test user, and I get the message that I already have reach the maximum of files. I get back to the admin and put a bigger number, and get back to the test user and tried again, with the same result.

I saw a interesting thing when I was saving the data like an admin, it's look like when you saving the maximum number, it doesn't matter which option did you select (total, day, month, year). It's always saving the total one.

If you need to check it out here:
http://focofijo2.webcindario.com/Galeria/
test user: red
test pass: nono

I saved 2 per 24 hours.... but, when I checked back in the configuration said 2 total.
Title: Re: Limit upload plugin for cpg1.5.x
Post by: Αndré on July 07, 2010, 07:27:04 am
The error message says
Quote
You've reached the upload limit of 2 files .
but it has to say something like
Quote
You've reached the upload limit of 2 files total/per hour/per day/etc. 
so I assume one value isn't stored in the config. I'll check that.
Title: Re: Limit upload plugin for cpg1.5.x
Post by: Αndré on July 07, 2010, 07:41:33 am
I renamed a language string and forgot to rename it in the code ::) Please try version 0.2 attached to initial post.
Title: Re: Limit upload plugin for cpg1.5.x
Post by: ThunderRed on July 07, 2010, 12:20:45 pm
Something is not working.

The drop menu is working now, and it save the configuration that you put it on. But, I just try with 4 pictures in 24h, and when I logged in with the test user, I get this message:

"Error
You've reached the upload limit of 4 files per day (24 hours).
You have to wait 144 hour(s) before uploading another file. "

The last file that the test user upload was July 1, and... the hours that you have to wait can't be right.  ::)

I made a new user

user:test
pass: test1

And I upload 4 new photos without problem, then I tried to upload the 5 one and I got:

"Error
You've reached the upload limit of 4 files per day (24 hours).
You have to wait 1 hour(s) before uploading another file. "


Title: Re: Limit upload plugin for cpg1.5.x
Post by: Αndré on July 15, 2010, 03:54:04 pm
Should be fixed in version 0.3 (attached to initial post).
Title: Re: Limit upload plugin for cpg1.5.x
Post by: ThunderRed on July 18, 2010, 05:21:48 pm
I just tried and isn't working now.

I logged in like the admin, set the plugin, set the limit to 1 per 24 hours, logged out, and logged in like the test user, upload a pictures without problem... and then another one.. and another one. I also tried with different setting like 1 total, or 1 per hours, with the same result.


By the way, I did translate to Spanish.
Title: Re: Limit upload plugin for cpg1.5.x
Post by: Αndré on July 18, 2010, 09:43:08 pm
Thanks for your contribution. It has been added to version 0.4. I also fixed the issue (I forgot to remove my debug stuff ::)). Please try again version 0.4 (attached to initial post).
Title: Re: Limit upload plugin for cpg1.5.x
Post by: ThunderRed on July 20, 2010, 05:13:31 am
Works great. Thank you!!  ;D
Title: Re: Limit upload plugin for cpg1.5.x
Post by: ThunderRed on July 29, 2010, 12:42:12 pm
Hi André,

I would love if you can add one more thing to this plugin.

Another factor to control the upload could be, that you can't upload anything until you make a X comment (in the last 24 hours) to other user's pictures.

In that way, if we set the number on two, you will need to write two comments in other pictures everyday in order to upload a picture.

And it will be great if we can combine the two different options, and be able to get a result like this:

You need to write 2 comments in other user's pictures (in the last 24 hours), in order to upload a picture, to the maximum of 2 upload pictures every 24 hours.


And you maybe asking yourself "Why?" I believe that in order for some users to participate and help to other users, sometimes you must have then to do it, or at the end they are going to forget about other users and only upload theirs pictures and wait for everyone to comment theirs.

Thank you!!
Title: Re: Limit upload plugin for cpg1.5.x
Post by: hasiko on October 26, 2010, 01:50:05 am
very nice plugin! thx!

would be really cool if you could change the limits per usergroup :)

Title: Re: Limit upload plugin for cpg1.5.x
Post by: hasiko on October 26, 2010, 02:28:32 am
ok fixed that for my vbulletin bridge . perhaps someone needs it

1. I edited the codebase.php and removed the switch($CONFIG['limit_upload_time_limit'])

2. getting the usergroupid from my vbulletin table

Code: [Select]
        $usergroupid = mysql_result(cpg_db_query("SELECT usergroupid FROM user WHERE userid = ".USER_ID), 0);
3. build a new switch based on the $usergroupid


Code: [Select]
    switch($usergroupid) {
            case '6':
                $multiplicator = 24;
                break;
            case '7':
                $multiplicator = 1;
                break;
            default: $multiplicator = false; break;
           
        }

now I have different timelimits for my usergroups


      
Title: Re: Limit upload plugin for cpg1.5.x
Post by: hasiko on October 26, 2010, 02:47:48 am
Can't edit the post above. Hope I am not spamming :(

so here is my complete solution

Code: [Select]
        // get the vbulletinusergroupid for that user
        $usergroupid = mysql_result(cpg_db_query("SELECT usergroupid FROM user WHERE userid = ".USER_ID), 0);
       
        switch($usergroupid) {
            case 2:
                $multiplicator = 24; // Time
                $uploadlimit   = 1; // Uploadlimit for this usergroup
                break;
            case 6:
                $multiplicator = 24;
                $uploadlimit   = 2;
                break;
            case 5:
            case 6:
            case 7:
                $multiplicator = 1;
                $uploadlimit   = 2;
                break;
            default: $multiplicator = false; break;
        }


every usergroup has a different timemultiplicator and a different uploadlimit

and I had to change

Code: [Select]
        if ($count >= $CONFIG['limit_upload_upload_limit']) {
to my new $uploadlimit:

Code: [Select]
        if ($count >= $uploadlimit) {
and the errormessage for the user

from
Code: [Select]
            $error = sprintf($lang_plugin_limit_upload['limit_reached_x'], $CONFIG['limit_upload_upload_limit'], $lang_plugin_limit_upload['upload_limit_values'][$CONFIG['limit_upload_time_limit']]);

to the new uploadlimit

Code: [Select]
            $error = sprintf($lang_plugin_limit_upload['limit_reached_x'], $uploadlimit, $lang_plugin_limit_upload['upload_limit_values'][$CONFIG['limit_upload_time_limit']]);

it's not a good clean solution, because the values shouldn't be hardcoded, but it works for now :)

Title: Re: Limit upload plugin for cpg1.5.x
Post by: MISHA on January 04, 2011, 01:18:56 pm
russian
Title: Re: Limit upload plugin for cpg1.5.x
Post by: Αndré on January 21, 2011, 12:16:58 pm
russian
Added in svn revision 8167. Thanks for your contribution.
Title: Re: Limit upload plugin for cpg1.5.x
Post by: radog on March 02, 2011, 06:59:48 pm
Hi I installed upload limit 0.4 set to 3 photos for 7 days. When, however, exceed the limit I can not even add comments to photos: (

writes me: You've reached the upload limit of 3 files per week (7 days).
Title: Re: Limit upload plugin for cpg1.5.x
Post by: radog on March 08, 2011, 04:10:26 pm
Is not possible to eliminate this problem somehow?
Title: Re: Limit upload plugin for cpg1.5.x
Post by: Αndré on March 08, 2011, 04:36:31 pm
When, however, exceed the limit I can not even add comments to photos

Open codebase.php, find
Code: [Select]
    if (!GALLERY_ADMIN_MODE && $CONFIG['limit_upload_upload_limit'] >= 0) {and replace with
Code: [Select]
    $superCage = Inspekt::makeSuperCage();
    if ($matches = $superCage->post->getMatched('event', '/^[a-z_]+$/')) {
        $event = $matches[0];
    } elseif ($matches = $superCage->get->getMatched('event', '/^[a-z_]+$/')) {
        $event = $matches[0];
    } else {
        $event = '';
    }
    $allowed_events = array('comment_update', 'comment', 'album_update', 'album_reset');
    if (!GALLERY_ADMIN_MODE && $CONFIG['limit_upload_upload_limit'] >= 0 && !in_array($event, $allowed_events)) {


Please confirm if that works, then I'll release a new version.
Title: Re: Limit upload plugin for cpg1.5.x
Post by: radog on March 09, 2011, 09:41:59 am
Yes thank you it works without any problems .. Thank you again for your time :)
Title: Re: Limit upload plugin for cpg1.5.x
Post by: guygar on April 06, 2011, 04:46:23 pm
This is a great script but I need to change it to 1 upload every 3 days or 72 hours.

How would I go about modifying this please?

I have no knowledge of PHP but eager to learn as I am good with JavaScript and C# and Java.

Thanks.
Title: Re: Limit upload plugin for cpg1.5.x
Post by: Αndré on April 06, 2011, 04:52:49 pm
I haven't tested that, but it should work if you set the multiplier
Code: [Select]
        switch($CONFIG['limit_upload_time_limit']) {
            // TODO: determine beginning of current hour/day/week/month/year and adjust the calculation
            case 'total': $multiplicator = -1; break;
            case 'hour': $multiplicator = 1; break;
            case 'day': $multiplicator = 24; break;
            case 'week': $multiplicator = 7*24; break;
            case 'month': $multiplicator = 30*24; break;
            case 'year': $multiplicator = 365*24; break;
            default: $multiplicator = false; break;
        }
to 3*24 or 72:
Code: [Select]
$multiplicator = 3*24;in codebase.php.
Title: Re: Limit upload plugin for cpg1.5.x
Post by: guygar on April 06, 2011, 05:30:58 pm
ok! I have modified and installed the plugin.

Now I have to wait 3 days to see if it is working.

Cannot happen sooner as I need to test it against the time period.

Thanks.
Title: Re: Limit upload plugin for cpg1.5.x
Post by: jmcreis on May 17, 2011, 12:22:32 am
I think there is a problem.
The plugin adds the uploads to the comments made ​​by the same user.
So if the max upload is set at 4 per day and the user has two comments, he can only send two photos that day (24 hours)
Sorry for my bad English but I think you will understand what i say
Title: Re: Limit upload plugin for cpg1.5.x
Post by: jmcreis on May 17, 2011, 12:29:22 am
Here is the portuguese lang for the plugin
Title: Re: Limit upload plugin for cpg1.5.x
Post by: Αndré on May 17, 2011, 10:18:32 am
Portuguese language file has been added in svn revision 8203. Thanks for your contribution.
Title: Re: Limit upload plugin for cpg1.5.x
Post by: jmcreis on May 19, 2011, 01:55:18 pm
The problem i reported is solved. Was my fault. Sorry guys.
Title: Re: Limit upload plugin for cpg1.5.x
Post by: jmcreis on May 20, 2011, 11:33:29 am
Well here I am again. And I´m very sorry. Please excuse me my friend André.
Thats the story:
First of all I instaled the plugin and asked users to test. They report a problem between number of files uploaded and comments, so that was the reason of my first topic reply.
Then I tryed miself and all was fine for me. Then my second reply saying that problem was solved. I forgot I had administrator premissions.  :-[ Sorry fellows !!
But the reports from users continue and i tryed it myself again, now without administrator power.
This is what I did:
1 - I made a lot of comments in user's pics without any problem.
2 - Then I uploaded my own files till the limit (till I received the error message: You\'ve reached the upload limit...)
3 - After this I tried to comment another pic and I received the same error message again (You\'ve reached the upload limit...) and I couldn't make more comments.
Can anybody try the same way i did ?
Title: Re: Limit upload plugin for cpg1.5.x
Post by: Αndré on May 20, 2011, 11:58:33 am
Try that solution: http://forum.coppermine-gallery.net/index.php/topic,65868.msg346746.html#msg346746
Title: Re: Limit upload plugin for cpg1.5.x
Post by: jmcreis on May 20, 2011, 12:03:58 pm
Thanks André.
Do you mean I must use the plugin and the mod at same time ?
Title: Re: Limit upload plugin for cpg1.5.x
Post by: jmcreis on May 20, 2011, 12:20:37 pm
WOW
Sorry again André
I made the mod in codebase.php.
I'll give feedback later. Thanks once more
Title: Re: Limit upload plugin for cpg1.5.x
Post by: Αndré on May 20, 2011, 03:25:10 pm
Version 1.0 (attached to initial post) contains the suggested fix.
Title: Re: Limit upload plugin for cpg1.5.x
Post by: NoDigital on March 19, 2012, 01:05:39 am
Hello everybody.
In attachment the italian translation for this very useful plugin.
I'd like to use it to manage an on-line contest with 2 themes: I created 2 public galleries - one per each theme - and I need to limit the upload to 4 images per each gallery.
How/where to modify this plugi to obtain it?

Thanks in advance, any help is appreciated.
Title: Re: Limit upload plugin for cpg1.5.x
Post by: Αndré on March 19, 2012, 09:46:22 am
In attachment the italian translation for this very useful plugin.
Thank you for your contribution. Added Italian language file (with some fixes) in SVN revision 8341.


I need to limit the upload to 4 images per each gallery.
How/where to modify this plugi to obtain it?
You don't need to modify the plugin, just set it accordingly in the plugin config.
Title: Limit UPload plugin
Post by: heavensportal on March 02, 2014, 03:40:29 am
I am using this to limit my members to 5 images a day. I have not really had admins tell me they can not do more than 5 a day since I am the only one to do so thus far--via ftp

But is there a way to either make a group in SMF (bridged) that will allow the member of that group to not be limited or in gallery to have the group not be limited.

It would be only that  member that uploads images of our winners which are more than 5 and her own images also.

I will ask at SMF also about the "special" group.
Title: Re: Limit UPload plugin
Post by: heavensportal on March 03, 2014, 03:42:42 am
well got word from SMF that there is no way to make an admin clone group so, Is there anyway to adjust the modification (plugin in) to disallow the global admins group or a different specific group?
Title: Re: Limit UPload plugin
Post by: Αndré on March 03, 2014, 09:27:11 am
It would be only that  member that uploads images of our winners which are more than 5 and her own images also.

If it's only one (or a few) users, you could also add a simple check like
Code: [Select]
if (USER_ID == 123) return;to the top of the function limit_upload_page_start in codebase.php. This way you don't need to add those user(s) to a separate group, as you just check the user ID.
Title: Re: Limit upload plugin for cpg1.5.x
Post by: heavensportal on March 03, 2014, 11:49:36 pm
thank you so very much with your help to these little things I ask for.

Will give it a try and hope I put it in the right spot.
Title: Re: Limit upload plugin for cpg1.5.x
Post by: heavensportal on March 04, 2014, 02:26:34 am
ok I did as you said--providing I put it in the right spot

this is the code as it appears in that file:

if (defined('DB_INPUT_PHP')) {
    $thisplugin->add_action('page_start', 'limit_upload_page_start') ;
if (USER_ID == 1080) return;
}
Title: Re: Limit upload plugin for cpg1.5.x
Post by: Αndré on March 04, 2014, 08:53:29 am
Unfortunately that's the wrong place. Please undo your last change, instead search for
Code: [Select]
function limit_upload_page_start() {and add the code below that line.
Title: Re: Limit upload plugin for cpg1.5.x
Post by: PavvelB on December 07, 2014, 04:41:29 pm
Hi.
I have some question about this plugin. Is it possible to apply the limit only for some galleries? My situation looks (or will look, I'm testing cpg on my local computer :) ) like this: there are some categories like Nature, Portrait available for all users, and I would like to limit the file numbers added in preiod of time to this categories. Every user has his personal gallery and could have possibility to add more pictures at once without waiting. But on the other hand I would like to limit all personal galleries to, for example, 40 pictures. Is it possible with your plugin?
As a small "gift" polish version :)
Title: Re: Limit upload plugin for cpg1.5.x
Post by: Αndré on December 17, 2014, 02:41:18 pm
It's probably possible, but I've currently no spare time to investigate that further or create the corresponding code.

Thank you for your contribution, I'll add it as soon as possible.
Title: Re: Limit upload plugin for cpg1.5.x
Post by: lurkalot on November 17, 2018, 01:38:53 pm
I use this plugin on my 1.5.x gallery, and really need it now I'm about to upgrade to 1.6.x anyone know if it's compatible with this version? If not any chance it could be updated please.
Title: Re: Re: Limit upload plugin for cpg1.5.x
Post by: gmc on November 17, 2018, 03:30:31 pm
I use this plugin on my 1.5.x gallery, and really need it now I'm about to upgrade to 1.6.x anyone know if it's compatible with this version? If not any chance it could be updated please.
Quick look it needs minor tweaks to remove direct mysql calls...
It's André's plugin - so I'll give him the first shot to update it.
Title: Re: Re: Re: Limit upload plugin for cpg1.5.x
Post by: lurkalot on November 17, 2018, 03:54:39 pm
Quick look it needs minor tweaks to remove direct mysql calls...
It's André's plugin - so I'll give him the first shot to update it.

Thank you.  ;)

I did leave it installed when I upgraded didn't break the page or anything.  I guess it won't work though if it needs those tweaks.
Title: Re: Limit upload plugin for cpg1.5.x
Post by: Αndré on November 17, 2018, 06:28:07 pm
I'll have a look as soon as possible. When we're talking about cpg1.6.x compatibility we usually also mean PHP7 compatibility. If it works as expected with cpg1.6.x but contains direct mysql calls, it will stop to work as soon as your server is upgraded to PHP7. So if you're running cpg1.6.x with PHP5 there's a high chance it will work as expected. I'll make it compatible with PHP7 anyway.
Title: Re: Re: Limit upload plugin for cpg1.5.x
Post by: lurkalot on November 17, 2018, 07:54:11 pm
I'll have a look as soon as possible. When we're talking about cpg1.6.x compatibility we usually also mean PHP7 compatibility. If it works as expected with cpg1.6.x but contains direct mysql calls, it will stop to work as soon as your server is upgraded to PHP7. So if you're running cpg1.6.x with PHP5 there's a high chance it will work as expected. I'll make it compatible with PHP7 anyway.

Thanks Andre.   I'm running on php 5.6 currently, but making the move to php 7.+ soon as 5.6 is EOL at the end of the year, and  Php 7 is end of life in a few days.  So probably will be moving to 7.2
Title: Re: Limit upload plugin for cpg1.5.x
Post by: Αndré on November 27, 2018, 05:03:31 pm
PHP7 compatible version can be found here: http://forum.coppermine-gallery.net/index.php/topic,79547.0.html