Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1] 2 3   Go Down

Author Topic: Limit upload plugin for cpg1.5.x  (Read 48127 times)

0 Members and 1 Guest are viewing this topic.

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Limit upload plugin for cpg1.5.x
« 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
« Last Edit: May 20, 2011, 03:23:46 pm by Αndré »
Logged

ThunderRed

  • Coppermine newbie
  • Offline Offline
  • Posts: 15
Re: Limit upload plugin for cpg1.5.x
« Reply #1 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.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Limit upload plugin for cpg1.5.x
« Reply #2 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.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Limit upload plugin for cpg1.5.x
« Reply #3 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.
Logged

ThunderRed

  • Coppermine newbie
  • Offline Offline
  • Posts: 15
Re: Limit upload plugin for cpg1.5.x
« Reply #4 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. "


Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Limit upload plugin for cpg1.5.x
« Reply #5 on: July 15, 2010, 03:54:04 pm »

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

ThunderRed

  • Coppermine newbie
  • Offline Offline
  • Posts: 15
Re: Limit upload plugin for cpg1.5.x
« Reply #6 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.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Limit upload plugin for cpg1.5.x
« Reply #7 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).
Logged

ThunderRed

  • Coppermine newbie
  • Offline Offline
  • Posts: 15
Re: Limit upload plugin for cpg1.5.x
« Reply #8 on: July 20, 2010, 05:13:31 am »

Works great. Thank you!!  ;D
Logged

ThunderRed

  • Coppermine newbie
  • Offline Offline
  • Posts: 15
Re: Limit upload plugin for cpg1.5.x
« Reply #9 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!!
Logged

hasiko

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Limit upload plugin for cpg1.5.x
« Reply #10 on: October 26, 2010, 01:50:05 am »

very nice plugin! thx!

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

Logged

hasiko

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Limit upload plugin for cpg1.5.x
« Reply #11 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


      
Logged

hasiko

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Limit upload plugin for cpg1.5.x
« Reply #12 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 :)

Logged

MISHA

  • Coppermine frequent poster
  • ***
  • Country: ru
  • Offline Offline
  • Gender: Male
  • Posts: 262
Re: Limit upload plugin for cpg1.5.x
« Reply #13 on: January 04, 2011, 01:18:56 pm »

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

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Limit upload plugin for cpg1.5.x
« Reply #14 on: January 21, 2011, 12:16:58 pm »

russian
Added in svn revision 8167. Thanks for your contribution.
Logged

radog

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Limit upload plugin for cpg1.5.x
« Reply #15 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).
Logged

radog

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Limit upload plugin for cpg1.5.x
« Reply #16 on: March 08, 2011, 04:10:26 pm »

Is not possible to eliminate this problem somehow?
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Limit upload plugin for cpg1.5.x
« Reply #17 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.
Logged

radog

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Limit upload plugin for cpg1.5.x
« Reply #18 on: March 09, 2011, 09:41:59 am »

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

guygar

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 26
Re: Limit upload plugin for cpg1.5.x
« Reply #19 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.
Logged
Pages: [1] 2 3   Go Up
 

Page created in 0.025 seconds with 20 queries.