Limit upload plugin for cpg1.5.x Limit upload plugin for cpg1.5.x
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Limit upload plugin for cpg1.5.x

Started by Αndré, July 06, 2010, 03:13:32 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Αndré

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

ThunderRed

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.

Αndré

The error message says
QuoteYou've reached the upload limit of 2 files .
but it has to say something like
QuoteYou'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.

Αndré

I renamed a language string and forgot to rename it in the code ::) Please try version 0.2 attached to initial post.

ThunderRed

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



Αndré

Should be fixed in version 0.3 (attached to initial post).

ThunderRed

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.

Αndré

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

ThunderRed


ThunderRed

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

hasiko

very nice plugin! thx!

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


hasiko

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

        $usergroupid = mysql_result(cpg_db_query("SELECT usergroupid FROM user WHERE userid = ".USER_ID), 0);

3. build a new switch based on the $usergroupid


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


now I have different timelimits for my usergroups


      

hasiko

Can't edit the post above. Hope I am not spamming :(

so here is my complete solution

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

        if ($count >= $CONFIG['limit_upload_upload_limit']) {

to my new $uploadlimit:

        if ($count >= $uploadlimit) {

and the errormessage for the user

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

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


MISHA

Что бы Ктулху не воскрес, подпишись на RSS

Αndré


radog

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

radog

Is not possible to eliminate this problem somehow?

Αndré

Quote from: radog on March 02, 2011, 06:59:48 PM
When, however, exceed the limit I can not even add comments to photos

Open codebase.php, find
    if (!GALLERY_ADMIN_MODE && $CONFIG['limit_upload_upload_limit'] >= 0) {
and replace with
    $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.

radog

Yes thank you it works without any problems .. Thank you again for your time :)

guygar

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.