forum.coppermine-gallery.net

Support => Older/other versions => cpg1.3.x Support => Topic started by: Chopper on March 15, 2005, 11:33:25 am

Title: Limiting uploads per day.
Post by: Chopper on March 15, 2005, 11:33:25 am
I just started my site and the way it works is that when users upload their animation and artwork, they are displayed on the front page (via CPG Fetch). The problem is that there are a few users uploading 10 images at a time and it pushes previous posts off the front page. As a result, the offending member posting 10 images/movies ends up dominating the front page, when I really want as many members as possible to get as much exposure time on the front page of the site as possible.

What would be really nice is if there were an option to limit the number of uploads a user can make within a 24 hour period (rather than just limiting the the disk quota). For example, each member can only post 2 images per day.

Is this something that is easy to add? I've found one other thread on the subject that dated back to early 2004 and it looks like it was developed by someone for CPG 1.2x

Is there a version of this modification for CPG 1.3x?
Title: Re: Limiting uploads per day.
Post by: Nibbler on March 15, 2005, 01:18:12 pm
That would be fairly simple. You'd need something like this at the top of upload.php

Code: [Select]
$query = db_query("SELECT * FROM {$CONFIG['TABLE_PICTURES']} WHERE owner_id = '$user_id' AND ctime > NOW() - (24*60*60)");
if ((mysql_num_rows($query) >= 2) {
cpg_die(INFORMATION, "You have reached your upload quota of 2 picture(s) per 24hr.");
}
Title: Re: Limiting uploads per day.
Post by: Chopper on March 15, 2005, 09:45:22 pm
Nibbler, I tried entering that code at the top of my upload.php, just below the initial <?php tag. After I upload the file and click on the upload link, I get a parse error.
Title: Re: Limiting uploads per day.
Post by: Joachim Müller on March 15, 2005, 11:09:00 pm
Nibbler, I tried entering that code at the top of my upload.php, just below the initial <?php tag. After I upload the file and click on the upload link, I get a parse error.
::)

Exact code snippet (line numbers!) and exact error message might help.

Joachim
Title: Re: Limiting uploads per day.
Post by: Chopper on March 15, 2005, 11:35:00 pm
This is the parse error that I get:
Parse error: parse error, unexpected '{' in /home/animati/public_html/studio/upload.php on line 5

Here's what I added to upload.php ( Nibblets code addition from lines 4 to line 8 )
I also tried adding the code after Line 48, got same parse error message.

Code: [Select]
1    <?php
2
3
4    
//Limit the number of uploads per user in 24 hour period.
5    $query db_query("SELECT * FROM {$CONFIG['TABLE_PICTURES']} WHERE owner_id = '$user_id' AND ctime > NOW() - (24*60*60)");
6    if ((mysql_num_rows($query) >= 2) {
7                 cpg_die(INFORMATION"You have reached your upload quota of 2 picture(s) per 24hr.");
8    }
9
10   
// ------------------------------------------------------------------------- //
11   // Coppermine Photo Gallery 1.3.2                                            //
12   // ------------------------------------------------------------------------- //
13   // Copyright (C) 2002-2004 Gregory DEMAR                                     //
14   // http://www.chezgreg.net/coppermine/                                       //
15   // ------------------------------------------------------------------------- //
16   // Updated by the Coppermine Dev Team                                        //
17   // (http://coppermine.sf.net/team/)                                          //
18   // see /docs/credits.html for details                                        //
19   // ------------------------------------------------------------------------- //
20   // This program is free software; you can redistribute it and/or modify      //
21   // it under the terms of the GNU General Public License as published by      //
22   // the Free Software Foundation; either version 2 of the License, or         //
23   // (at your option) any later version.                                       //
24   // ------------------------------------------------------------------------- //
25   // CVS version: $Id: upload.php,v 1.9 2004/07/28 08:25:25 gaugau Exp $
26   // ------------------------------------------------------------------------- //
27
28
29   
// Confirm we are in Coppermine and set the language blocks.
30   define('IN_COPPERMINE'true);
31   define('UPLOAD_PHP'true);
32   define('DB_INPUT_PHP'true);
33   define('CONFIG_PHP'true);
34
35   
// Call basic functions, etc.
36   require('include/init.inc.php');
37   require('include/picmgmt.inc.php');
38
39   
// Some placeholders.
40   $customize CUSTOMIZE_UPLOAD_FORM;
41   $user_form USER_UPLOAD_FORM;
42   $allowed_URI_boxes NUM_URI_BOXES;
43   $allowed_file_boxes NUM_FILE_BOXES;
44
45   
// Check to see if user can upload pictures.  Quit with an error if he cannot.
46   if (!USER_CAN_UPLOAD_PICTURES) {
47       cpg_die(ERROR$lang_errors['perm_denied'], __FILE____LINE__);
48   }


Title: Re: Limiting uploads per day.
Post by: kegobeer on March 16, 2005, 03:58:49 am
Change

Code: [Select]
if ((mysql_num_rows($query) >= 2) {
to

Code: [Select]
if (mysql_num_rows($query) >= 2) {
Title: Re: Limiting uploads per day.
Post by: Nibbler on March 16, 2005, 11:59:13 am
It needs to go under

Code: [Select]
require('include/init.inc.php');


Also that was just sample code I have no idea if it works or not.
Title: Re: Limiting uploads per day.
Post by: RedFalcon on October 25, 2005, 10:15:46 pm
Hello

I tried this but i have a error msg:
 Fatal error: Call to undefined function: db_query() in /home/hijole4/public_html/foto/upload.php on line 3

What I made wrong?
Can you help me?

<?php
//Limit the number of uploads per user in 24 hour period.
     $query = db_query("SELECT * FROM {$CONFIG['TABLE_PICTURES']} WHERE owner_id = '$user_id' AND ctime > NOW() - (24*60*60)");
     if (mysql_num_rows($query) >= 1) {
                cpg_die(INFORMATION, "You have reached your upload quota of 1 picture per 24hr.");
            }
/*************************
  Coppermine Photo Gallery
  ************************
Title: Re: Limiting uploads per day.
Post by: Nibbler on October 25, 2005, 10:50:54 pm
It needs to go under

Code: [Select]
require('include/init.inc.php');
Title: Re: Limiting uploads per day.
Post by: RedFalcon on October 25, 2005, 11:05:31 pm
Already I made the correction, tks.
Sorry, but i dont understand, because i continue  to put more than a one file.
Title: Re: Limiting uploads per day.
Post by: RedFalcon on October 29, 2005, 03:38:54 am
Hi again

I tried during some days, but this alteration not work with my cpg.
I have upload.php revision 1.17  2005/09/24.
I know that it was not tested 
Code: [Select]
Also that was just sample code I have no idea if it works or not.,  but you have some idea of that it can be, or have another idea for “Limiting uploads for day”?  It will be possible?

http://www.foto.hijole.net

if you want: account: testuser
                        pass: testuser

Thanks in advance
Regards
Title: Re: Limiting uploads per day.
Post by: Stramm on October 29, 2005, 04:01:27 am
Code: [Select]
$query = db_query("SELECT * FROM {$CONFIG['TABLE_PICTURES']} WHERE owner_id = ".USER_ID." AND ctime > ".time()." - (24*60*60)");
if (mysql_num_rows($query) > 0) {
cpg_die(INFORMATION, "You have reached your upload quota of 1 picture per 24hr.");
}

or if you like that more .... UNIX_TIMESTAMP(NOW()) instead of ".time()."
Title: Re: Limiting uploads per day.
Post by: RedFalcon on October 29, 2005, 04:23:58 am
I tested and  it's work!!
Very thanks Stramm  :)
Regards
Title: Re: Limiting uploads per day.
Post by: angeldevil on August 12, 2006, 11:57:27 am
Code: [Select]
$query = db_query("SELECT * FROM {$CONFIG['TABLE_PICTURES']} WHERE owner_id = ".USER_ID." AND ctime > ".time()." - (24*60*60)");
if (mysql_num_rows($query) > 0) {
cpg_die(INFORMATION, "You have reached your upload quota of 1 picture per 24hr.");
}

or if you like that more .... UNIX_TIMESTAMP(NOW()) instead of ".time()."

Hi, I've try it in cpg 1.4 :

Code: [Select]
//Limit the number of uploads per user in 24 hour period.
$query = db_query("SELECT * FROM {$CONFIG['TABLE_PICTURES']} WHERE owner_id = ".USER_ID." AND ctime > ".time()." - (24*60*60)");
if (mysql_num_rows($query) > 0) {
cpg_die(INFORMATION, "You have reached your upload quota of 1 pictures per 24hr.");
}

but I receive this error message:

Fatal error: Call to undefined function: db_query() in /.../.../.../upload.php on line 4

what wrong?
Title: Re: Limiting uploads per day.
Post by: Nibbler on August 12, 2006, 12:42:47 pm
If you have 1.4 then don't apply code changes posted to the 1.3 board unless you are a coder and can understand the changes between Coppermine  versions.