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]   Go Down

Author Topic: Limiting uploads per day.  (Read 65307 times)

0 Members and 1 Guest are viewing this topic.

Chopper

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 52
    • The Animation Corner
Limiting uploads per day.
« 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?
« Last Edit: October 30, 2005, 11:40:58 am by GauGau »
Logged

Nibbler

  • Guest
Re: Limiting uploads per day.
« Reply #1 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.");
}
Logged

Chopper

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 52
    • The Animation Corner
Re: Limiting uploads per day.
« Reply #2 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.
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: Limiting uploads per day.
« Reply #3 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
Logged

Chopper

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 52
    • The Animation Corner
Re: Limiting uploads per day.
« Reply #4 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   }


« Last Edit: March 15, 2005, 11:40:12 pm by Chopper »
Logged

kegobeer

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 4637
  • Beer - it does a body good!
    • The Kazebeer Family Website
Re: Limiting uploads per day.
« Reply #5 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) {
Logged
Do not send me a private message unless I ask for one.  Make your post public so everyone can benefit.

There are no stupid questions
But there are a LOT of inquisitive idiots

Nibbler

  • Guest
Re: Limiting uploads per day.
« Reply #6 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.
« Last Edit: October 25, 2005, 10:51:41 pm by Nibbler »
Logged

RedFalcon

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 21
Re: Limiting uploads per day.
« Reply #7 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
  ************************

Nibbler

  • Guest
Re: Limiting uploads per day.
« Reply #8 on: October 25, 2005, 10:50:54 pm »

It needs to go under

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

RedFalcon

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 21
Re: Limiting uploads per day.
« Reply #9 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.

RedFalcon

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 21
Re: Limiting uploads per day.
« Reply #10 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

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Limiting uploads per day.
« Reply #11 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()."
« Last Edit: October 29, 2005, 04:08:28 am by Stramm »
Logged

RedFalcon

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 21
Re: Limiting uploads per day.
« Reply #12 on: October 29, 2005, 04:23:58 am »

I tested and  it's work!!
Very thanks Stramm  :)
Regards

angeldevil

  • Translator
  • Coppermine frequent poster
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 107
Re: Limiting uploads per day.
« Reply #13 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?
Logged
a

Nibbler

  • Guest
Re: Limiting uploads per day.
« Reply #14 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.
Logged
Pages: [1]   Go Up
 

Page created in 0.03 seconds with 20 queries.