Limit Users to int number of uploads? Limit Users to int number of uploads?
 

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 Users to int number of uploads?

Started by maxxer, June 28, 2010, 03:53:45 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

maxxer

Hi,
   I've been searching the forums/docs but can't find this issue specificaly addressed (lot's of stuff about quotas!) so i apologize specificlaly to jaochim if its been covered before:

Any easy way to limit the number of user uploads? Basically, I'm trying to pervert coppermine into a photo contest style app (the contest plugin didn't work for me, by the way, in ver 1.4 or ver 1.5) and I would like to limit users to a 1 image upload limit. Any thoughts?

best
MAXX

Joachim Müller

Instead of apologizing you could have done as suggested per board rules. If you indeed have reviewed a lot of postings you should be aware that all invalid postings like yours get the same, stereotype reply "Board rules / Forum policies: Post Links". Do you really think that this is my idea of having fun: telling people again and again to respect the rules. That's not fun - that's frustrating. Don't be part of the problem, but be part of the solution instead.

maxxer

Hi Joachim,
  my install is on my local apache server. it is not even open to a wan.
Does that mean I am not allowed to ask questions in this forum?
Having rules, I thought,  is supposed to aid people (like me) seeking help in the community in an organized and efficient way.

For example, in this case - I was wondering if any of the devs or users out there could point me to the right place in the libs. Its not particualry relevant for you to have a look at my install as this is not a topic that would benefit from referring it. i don't really like wasting time either :)   

  Soooo - any thoughts on the  topic by any chance?

papukaija


maxxer

Hi!
  Thanks for that link. I did read that through - however, as this topic has nothing to do with installation or server setup/maintenance not sure that its relevant ;)
Anyway, I apologize  to the board. i should have respected board to  the letter  from the beginning: http://thesidedoor.ca/gallery/

So - I was wondering if anyone out there might point me to the right area for limiting the number of user uploaded photos?

cheers.
maxx






Joachim Müller

You're running cpg1.4.12 on that page. Do I have to say more?

maxxer

....thats an old install of coppermine. the site I'm working on is a dev site! It cannot go live until the code is in place...that's pretty standard practice, no?

I'm really not trying to be frustrating! Lesson here is, when you ask for help - be ready to play ball with the moderators :) 
alrighty then: here is a nice new install of coppermine 1.5:

http://toimoietbebe.com/concoursphoto2/

Joachim Müller

That's an outdated copy of the prorandom theme that you mustn't use. Try the curve theme for a start (http://toimoietbebe.com/concoursphoto2/?theme=curve).

You need to upgrade http://thesidedoor.ca/gallery/ immediately as per http://coppermine-gallery.net/demo/cpg14x/docs/index.htm#upgrade_why_reasons - you're running behind 15 versions. Coming up with all kinds of test galleries doesn't help, nor is the fact that you're considering to upgrade relevant in this aspect; the live-gallery is vulnerable and needs fixing. Maybe it's already corrupted. That should be your main focus.

Quote from: maxxer on June 28, 2010, 05:12:00 PM
So - I was wondering if anyone out there might point me to the right area for limiting the number of user uploaded photos?
The brute-force method would be editing upload.php, running a query against the database if the user is not an admin about the number of files he has uploaded so far (simple count query) and adding a cpg_die function call it's higher than a set limit. Not very elegant of course. If you want to apply this in a more elegant way, write a plugin and perform the steps I posted inside your plugin.

maxxer


maxxer

here is the quick and simple mod for limiting the number of nonadmin user photos...

// CHECK for previously uploaded file
if (!GALLERY_ADMIN_MODE) {

        $result = cpg_db_query("SELECT * FROM `cpg15x_pictures` WHERE owner_id ='" .USER_ID."'");

        if (mysql_num_rows($result) != 0) {
    cpg_die(ERROR, "You have already uploaded a photo! Please delete your current photo to upload a new one!", __FILE__, __LINE__);
            exit;
        }
}


I've put this on line 33 of upload.php
the error message should be a localization variable.
Also, I am merely checking  if any photos have been uploaded. To specify a different cap, you would change  "!= 0" to your custom limit.


-maxx

Joachim Müller

Performing a SELECT COUNT would be less resources intensive.

Αndré

Please see here for a plugin that accomplishes the same without modifying any core files.

maxxer

Hi Andre, thanks for that link. But I'm getting the same problem in 0.4 as thundered reports (can still upload unlimited files)
I think my comments on that plugin would be off-toptic for this thread. (I assume an ungraceful hack of my install is what is preventing it from working properly)

Thank you to the advice for performing select_count and also not hacking the core, I will try and perform mods in line with the coppermine guidlines before attempting to 'contribute' :)
in the future.

I would consider this topic closed/resolved but i cannot seem to be able to do that myself (moderators?)

Αndré


maxxer

I swear I had just read that exact rule before posting. *sigh*