• [Mod] User upload limits 5 0 5 1
Currently:  

Author Topic: [Mod] User upload limits  (Read 238326 times)

0 Members and 1 Guest are viewing this topic.

Offline MrAndrew

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
    • Aviation PhotoBase
Re: [Mod] User upload limits
« Reply #195 on: June 05, 2010, 07:57:45 PM »
Vano, this give me error:

Code: [Select]
//-----------------------------------------------------
//--- end of UploadInfo v1.0 --------------------------
//-----------------------------------------------------
    }
    else {
      $action = "uploadform";
      $sendprocess = 1;
    }
  }
  else {
    $action = "uploadform";
    $sendprocess = 1;
  }
}

//-----------------------------------------------------
// --- Check User Limits ------------------------------
//-----------------------------------------------------

$user_id = $user_info['user_id'];

$clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'];
if ($cat_id && isset($cat_cache[$cat_id])) {
  $clickstream .= get_category_path($cat_id, 1).$config['category_separator'];
}
$clickstream .= $lang['file_upload_error']."</span>";

$site_template->register_vars(array(
"clickstream" => $clickstream,
"lang_no_limits" => $lang['no_limits'],
"lang_no_limits_text" => $lang['no_limits_text'],
"lang_already_loaded" => $lang['already_loaded'],
"lang_show_my_images" => $lang['show_my_images'],
"url_show_user_images" => $site_sess->url(ROOT_PATH."search.php?search_user=".$user_info['user_name'])
));


function check_daily_picture_limit($user_id) {
global $site_db, $site_template;

  $sql = "SELECT user_limit FROM ".USERS_TABLE." WHERE user_id = $user_id";
  $row = $site_db->query_firstrow($sql);
  $upload_limit = ($row['user_limit']);
  $site_template->register_vars("upload_limit", $upload_limit);
  
  $limit_cutoff = time() - 60 * 60 * 24;
  
  $sql = "SELECT COUNT(image_id) AS num_rows_all
  FROM ".IMAGES_TABLE."
  WHERE image_active = 1 AND user_id=$user_id AND image_date > $limit_cutoff";
  $row = $site_db->query_firstrow($sql);
  $images_per_user = $row['num_rows_all'];
  
  $site_template->register_vars("images_per_user", $images_per_user);

  return ($images_per_user < $upload_limit)
}

function check_picture_limit($user_id) {
global $site_db, $site_template;

  $sql = "SELECT user_limit FROM ".USERS_TABLE." WHERE user_id = $user_id";
  $row = $site_db->query_firstrow($sql);
  $upload_limit = ($row['user_limit']);
  
  $site_template->register_vars("upload_limit", $upload_limit);
  
  $sql = "SELECT COUNT(image_id) as num FROM ".IMAGES_TABLE." WHERE user_id=$user_id";
  $result = $site_db->query_firstrow($sql);
  $images_per_user = (int)$result['num'];
/*
  $sql = "SELECT image_id FROM ".IMAGES_TEMP_TABLE." WHERE user_id=$user_id";
  $result = $site_db->query($sql);
  $tmp_images_per_user = $site_db->get_numrows($result);
  $images_per_user = $tmp_images_per_user + $images_per_user;
*/
  // Uncomment above four lines (remove /* and */) if you also want to check uploaded but not yet validated images against the user limit
  
  $site_template->register_vars("images_per_user", $images_per_user);
  
  return ($images_per_user < $upload_limit)
}

if ($action == "uploadform") {
 if ($cat_id != 0 && (!isset($cat_cache[$cat_id]) || !check_permission("auth_upload", $cat_id))) {
  show_error_page($lang['no_permission']);
  exit;
 }

if (!check_picture_limit($user_id)) {
// if (!check_daily_picture_limit($user_id)) {

//
// Depending on your requirements, you can either check against global or daily limit. For global check leave it as it is now.
// For daily limit comment first line and uncomment second one.
//

  $site_template->print_template($site_template->parse_template("over_limit"));
  include(ROOT_PATH.'includes/page_footer.php');
  exit;
}

//-----------------------------------------------------

  $txt_clickstream = "";
  if ($cat_id && isset($cat_cache[$cat_id])) {
    $txt_clickstream .= get_category_path($cat_id, 1).$config['category_separator'];
  }
  $txt_clickstream .= $lang['user_upload'];

  if (!$sendprocess) {

This code with about 10 lines above and below...

Offline nameless

  • Full Member
  • ***
  • Posts: 147
    • View Profile
Re: [Mod] User upload limits
« Reply #196 on: August 06, 2010, 01:33:25 AM »
I have this error
i'm using v1.77

Parse error: syntax error, unexpected '}' in /home/???????/member.php on line 739

and this is the code

Code: [Select]
function check_daily_picture_limit($user_id) {
global $site_db, $site_template;

  $sql = "SELECT user_limit FROM ".USERS_TABLE." WHERE user_id = $user_id";
  $row = $site_db->query_firstrow($sql);
  $upload_limit = ($row['user_limit']);
  $site_template->register_vars("upload_limit", $upload_limit);
  
  $limit_cutoff = time() - 60 * 60 * 24;
  
  $sql = "SELECT COUNT(image_id) AS num_rows_all
  FROM ".IMAGES_TABLE."
  WHERE image_active = 1 AND user_id=$user_id AND image_date > $limit_cutoff";
  $row = $site_db->query_firstrow($sql);
  $images_per_user = $row['num_rows_all'];
  
  $site_template->register_vars("images_per_user", $images_per_user);

  return ($images_per_user < $upload_limit)
} >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>this is the line

function check_picture_limit($user_id) {
global $site_db, $site_template;

  $sql = "SELECT user_limit FROM ".USERS_TABLE." WHERE user_id = $user_id";
  $row = $site_db->query_firstrow($sql);
  $upload_limit = ($row['user_limit']);
  
  $site_template->register_vars("upload_limit", $upload_limit);
  
  $sql = "SELECT COUNT(image_id) as num FROM ".IMAGES_TABLE." WHERE user_id=$user_id";
  $result = $site_db->query_firstrow($sql);
  $images_per_user = (int)$result['num'];
/*
  $sql = "SELECT image_id FROM ".IMAGES_TEMP_TABLE." WHERE user_id=$user_id";
  $result = $site_db->query($sql);
  $tmp_images_per_user = $site_db->get_numrows($result);
  $images_per_user = $tmp_images_per_user + $images_per_user;
*/
  // Uncomment above four lines (remove /* and */) if you also want to check uploaded but not yet validated images against the user limit
  
  $site_template->register_vars("images_per_user", $images_per_user);
  
  return ($images_per_user < $upload_limit)
}

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [Mod] User upload limits
« Reply #197 on: August 06, 2010, 04:44:18 AM »
missing ; at the end of
  return ($images_per_user $upload_limit)


I've fixed the attachment.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline nameless

  • Full Member
  • ***
  • Posts: 147
    • View Profile
Re: [Mod] User upload limits
« Reply #198 on: August 06, 2010, 01:50:33 PM »
Thanks V@no

but there is something

  return ($images_per_user < $upload_limit)

there is 2 line and u fix one of them and it still error so i but ; at the end of the scoend line and it work

please fix it the attachment

Now let me tell u all i have found
i make the defoult limit upload is 10 image

1- when i add a new user from the admincp there is a new field called Maximum number of images to upload i put 5 in this field for this user

Now i go try to upload an image but it do't work it gave me over_limit.html i make another use and gave me the same i go to the admin cp try to edit Maximum number of images to upload for the user and i did't found this field it just Appears when you make a new user only but if u want to eidt the use it does't Appears

2- i go to the admincp to change in the seitting to change Maximum number of images to upload from 10 to 20 and i try to upload images to a user that reached this limit (10 image) and it does't work

3- i make this http://www.4homepages.de/forum/index.php?topic=3607.msg22301#msg22301
reset_limits.php and when i try it it gave me this erorr
Parse error: syntax error, unexpected '&', expecting T_PAAMAYIM_NEKUDOTAYIM in /home/??????/admin/plugins/reset_limits.php on line 5

will sorry to bother you

but i think this a great mod and i hope it work
« Last Edit: August 06, 2010, 04:13:16 PM by nameless »

Offline maranus

  • Pre-Newbie
  • Posts: 2
    • View Profile
Re: [Mod] User upload limits
« Reply #199 on: November 21, 2011, 02:14:03 PM »
i konw this is old, but i'm having a problem, after i install this MOD login and logout returned blank pages ....

any ideia why ?

thanks

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [Mod] User upload limits
« Reply #200 on: November 21, 2011, 02:29:42 PM »
Welcome to 4images forum.

I'd suspect when you edited .php files you added an extra space or new line after ?> or before <?php
Check lang/<your language>/main.php (and all others)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline maranus

  • Pre-Newbie
  • Posts: 2
    • View Profile
Re: [Mod] User upload limits
« Reply #201 on: November 21, 2011, 02:56:37 PM »
shame on me,  :oops:

i'm a PHP newbieeee sorry !!! thanks you re right !!!!  :P

sorry to bother again

DB Error: Bad SQL Query: UPDATE 4images_users SET user_level = 9, user_name = 'BMMaia', user_email = 'bmtcmaia@gmail.con', user_showemail = 0, user_allowemails = 1, user_invisible = 0, user_joindate = UNIX_TIMESTAMP('2011-11-21 15:25'), user_lastaction = UNIX_TIMESTAMP('2011-11-21 15:25'), user_homepage = '', user_icq = '', = '5', WHERE user_id = 4
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= '5', WHERE user_id = 4' at line 2
Error editando usuario

i'm having this error when editing a user, any solucion ? what could be wrong? i'm guessing something to do with declaring "user_limit" variable ....

thanks again
« Last Edit: November 21, 2011, 05:19:42 PM by maranus »

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [Mod] User upload limits
« Reply #202 on: November 21, 2011, 08:00:06 PM »
I assume you did the posted fix at first post, then the problem in that line, you missed some part of it.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline pwa

  • Pre-Newbie
  • Posts: 8
    • View Profile
Re: [Mod] User upload limits
« Reply #203 on: November 23, 2011, 01:08:25 PM »
Hi,
Very nice mod. i used it on version 1.7.10 with daily limit option.
I corrected this bug:

Quote
this mod is not working for unvalidated images.
User can upload many photos if there is a validation in that category. MOD only works for validated photos.
new version of check_daily_picture_limit function (file member.php):

function check_daily_picture_limit($user_id) {
	
global 
$site_db$site_template;
  
$sql "SELECT user_limit FROM ".USERS_TABLE." WHERE user_id = $user_id";
  
$row $site_db->query_firstrow($sql);
  
$upload_limit = ($row['user_limit']);
  
$site_template->register_vars("upload_limit"$upload_limit);
  
  
$limit_cutoff time() - 60 60 24;
  
  
$sql "SELECT COUNT(image_id) AS num_rows_all
  FROM "
.IMAGES_TABLE."
  WHERE user_id=
$user_id AND image_date > $limit_cutoff";
  
//WHERE image_active = 1 AND user_id=$user_id AND image_date > $limit_cutoff";
  
$row $site_db->query_firstrow($sql);
  
$images_per_user $row['num_rows_all'];
  
  
//look for unvalidated images too
  
$sql "SELECT COUNT(image_id) AS num_rows_all
  FROM "
.IMAGES_TEMP_TABLE."
  WHERE user_id=
$user_id  AND image_date > $limit_cutoff";
  
$row $site_db->query_firstrow($sql);
  
$images_per_user $images_per_user $row['num_rows_all'];  
  
  
$site_template->register_vars("images_per_user"$images_per_user);

  return (
$images_per_user <= $upload_limit);
}



On error page number of already uploaded images is not displayed - I corrected this too:
in lang file main.php:
$lang['show_my_images'] = "Number of submited images (accepted and awaiting for validation): ";

and in over_limit.html:
Code: [Select]
                 
<p>{lang_no_limits_text}</p>
{lang_show_my_images}{images_per_user}
look it is no way to show via search screen unvalidated images (I removed this link)


I used code from first post as base.




Offline Loda

  • Sr. Member
  • ****
  • Posts: 353
    • View Profile
    • Fotosucht Schweiz
Re: [Mod] User upload limits
« Reply #204 on: January 09, 2012, 10:05:05 AM »
another question:
i want to see the "time_to_go" tag in my profile or in userbox. any help for me?