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

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

0 Members and 1 Guest are viewing this topic.

Offline lakeside

  • Full Member
  • ***
  • Posts: 123
    • View Profile
Re: Small problem with this mod
« Reply #45 on: March 28, 2003, 03:14:07 PM »
Quote from: SLL
Quote from: lakeside
Is there a way around this, besides turning off admin validation?


this came out of my logic when i've made this mod - you don't know if image will be validated or deleted, so it doesn't make much sense to add uploaded image to the user account and check the number of images against this user limits before validation


Okay, I can understand that logic, I guess Im not using the mod for what it was intended for.  Im only trying to use it as a way to limit people, because the larger you get the more obnoxious people you get who will upload every image on their hard drive to share, but at the same time you dont know what they are uploading, could be child porn, so validation is the way to go with a public system, but you also dont want them to be able to upload every photo they have to your server.

People respect what you write on a web page, so even if you tell them they are limited to 10 images, but have validation, they will continue to upload many more than 10 images, then you've got the chore of "choosing" which of their images to keep, and which to delete.

Hopefully someone can add onto this mod to incorporate the admin validation feature too.

Thanks for the great mod though.

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
[Mod] User upload limits
« Reply #46 on: March 28, 2003, 03:38:12 PM »
well, well, if you're such in trouble  :wink: ...

then do the following:

in member.php find code:
Code: [Select]
$sql = "SELECT image_id FROM ".IMAGES_TABLE." WHERE user_id=$user_id";
$result = $site_db->query($sql);
$images_per_user = $site_db->get_numrows($result);


after add:
Code: [Select]
$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;

this is assuming that you've added original mod already

Offline lakeside

  • Full Member
  • ***
  • Posts: 123
    • View Profile
THANK YOU!
« Reply #47 on: March 28, 2003, 04:23:27 PM »
Thank you, works perfectly.  Im not in any trouble yet, but Im more pre-emptively taking care of it before it crops its ugly head.

Great mod made even better!

Offline batz

  • Newbie
  • *
  • Posts: 14
    • View Profile
[Mod] User upload limits
« Reply #48 on: April 19, 2003, 03:54:59 AM »
This MOD works great. But i have one question:

I can't find were i can change individual user limits. In the general settings there is a field to change the limits for all users, when i create a new user there also is a field to change the limits, but for a registred user, when i'm going to edit their settings the limit field doesn't show up.
Any sugestions?

Best Regards
Paulo

Offline lakeside

  • Full Member
  • ***
  • Posts: 123
    • View Profile
[Mod] User upload limits
« Reply #49 on: April 19, 2003, 04:13:50 AM »
Sorry, misread the post, I've removed my post as it didnt answer the question properly.

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
[Mod] User upload limits
« Reply #50 on: April 19, 2003, 09:00:38 AM »
Quote from: batz
but for a registred user, when i'm going to edit their settings the limit field doesn't show up.

it seems you've missed some mod installation steps. you should see "limits" field in "edit user" form.

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
[Mod] User upload limits
« Reply #51 on: April 19, 2003, 09:07:24 AM »
Maybe someone using this mod is missing the tool below (as I did), so I publish it here. This plugin just resetting all users limits to the default gallery setting. You'd need it, for example, if one day you decide to decrease global limit, and doesn't want to edit every existing user afterwards.

Save this code as /admin/plugins/reset_limits.php
Code: [Select]
<?php // PLUGIN_TITLE&#58; Reset User Limits

define&#40;'IN_CP', 1&#41;;
$root_path = &#40;eregi&#40;"\/plugins\/", $PHP_SELF&#41;&#41; ? "./../../" &#58; "./../";
define&#40;'ROOT_PATH', $root_path&#41;;
require&#40;ROOT_PATH.'admin/admin_global.php'&#41;;

if &#40; $action == ""&#41; &#123;
  
$action "modifysettings";
&
#125;

show_admin_header&#40;&#41;;

if &#40;$action == "showsettings"&#41; &#123;

$fldname "user_limit";
$default_limit $config['default_upload_limit'&#93;;

$sql "UPDATE ".USERS_TABLE."
     SET 
$fldname = $default_limit";
    
$site_db->query&#40;$sql&#41;;

  
if &#40;$HTTP_POST_VARS['setting_item'&#93;['language_dir'&#93; != $config['language_dir'&#93;&#41; &#123;
    
printf&#40;"<b>%s</b><p>", $lang['save_settings_success'&#93;&#41;;
    
show_admin_footer&#40;&#41;;
  
&#125;
  
else &#123;
    
$msg sprintf&#40;"<b>%s</b><p>", $lang['save_settings_success'&#93;&#41;;
    
$action "modifysettings";
  &
#125;
&#125;

if &#40;$action == "modifysettings"&#41; &#123;
  
if &#40;isset&#40;$HTTP_GET_VARS['settings_msg'&#93;&#41;&#41; &#123;
    
printf&#40;"<b>%s</b><p>", urldecode&#40;$HTTP_GET_VARS['settings_msg'&#93;&#41;&#41;;
  
&#125;
  
elseif &#40;!empty&#40;$msg&#41;&#41; &#123;
    
echo $msg;
  &
#125;

  
$sql "SELECT setting_name, setting_value
          FROM "
.SETTINGS_TABLE;
  
$result $site_db->query&#40;$sql&#41;;
  
$config = array&#40;&#41;;
  
while &#40;$row = $site_db->fetch_array&#40;$result&#41;&#41; &#123;
    
$config[$row['setting_name'&#93;&#93; = $row['setting_value'&#93;;
  
&#125;

  
show_form_header&#40;"$PHP_SELF", "showsettings"&#41;;
  
show_table_header&#40;"Reset all users upload limit to the default value"&#41;;
  
echo "<tr class=\"tablerow\"><td colspan=\"2\">";
  echo 
"<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\"><tr valign=\"top\">\n";
  echo 
"</tr></table>\n";
  echo 
"<tr class=\"".get_row_bg&#40;&#41;."\">\n<td valign=\"top\"><p class=\"rowtitle\">Default upload limit from Gallery config</p></td>\n";
  
echo "<td>".$config['default_upload_limit'&#93;."<p>";
  
echo "</p></td>\n</tr>\n";

  
show_form_footer&#40;$lang['save_changes'&#93;, "", 2&#41;;
&#125;

show_admin_footer&#40;&#41;;
?>

Offline lakeside

  • Full Member
  • ***
  • Posts: 123
    • View Profile
[Mod] User upload limits
« Reply #52 on: April 27, 2003, 11:28:04 PM »
Okay,
Im now wondering if we can't tweak this great mod a bit more..... I know I ask for so much.... And your work is so appreciated.

I have it set to allow each registered user on my site to upload 25 photos (max photo size is 150kb)  But I'd like to offer them unlimited amounts of uploads if they use the url instead of uploading the images to my server.

So, 25 upload images, and unlimited url images.  Do you think this would be possible somehow?

Thanks again for a great mod.  Wish I had the talent to do it myself.  :oops:

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
[Mod] User upload limits
« Reply #53 on: April 28, 2003, 11:26:13 AM »
Quote from: lakeside
So, 25 upload images, and unlimited url images.  Do you think this would be possible somehow?

Replace this query:
Quote
$sql = "SELECT image_id FROM ".IMAGES_TABLE." WHERE user_id=$user_id";

With this one:
Quote
$sql = "SELECT image_id, image_media_file FROM ".IMAGES_TABLE." WHERE user_id=$user_id AND image_media_file NOT LIKE '%://%'";

.... then remote images (http, ftp) won't be checked. I believe, this is what you wanted.

Offline batz

  • Newbie
  • *
  • Posts: 14
    • View Profile
Showing time to next upload
« Reply #54 on: May 08, 2003, 05:30:33 PM »
Hi there,

Another great MOD from SSL. Now  :D  is working perfectly.

There is any chance if a user try to upload a photo before 24 hours, if that was the case, and with the warnig message showing a text like this: "You will be able to upload you next photo within xx:xx hours."

This is a request from almost all my users   :)

Thanks again.

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
[Mod] User upload limits
« Reply #55 on: May 08, 2003, 06:18:21 PM »
hmm.... sorry, no way for the moment. just edit $lang['no_limits_text'] and write there "... within next 24 hours"  :wink:

Offline Bomba

  • Full Member
  • ***
  • Posts: 202
    • View Profile
[Mod] User upload limits
« Reply #56 on: May 08, 2003, 06:57:17 PM »
im using this mod to limit user uploads per day, only x images in every 24 hours.

i would like to know if it's possible to show on the "reached limit message" how many time left to end the 24 hours limit for that user.

thanks

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
[Mod] User upload limits
« Reply #57 on: May 08, 2003, 07:06:48 PM »
bomba, you're asking exactly the same question as batz one message above  :roll:

Offline Bomba

  • Full Member
  • ***
  • Posts: 202
    • View Profile
[Mod] User upload limits
« Reply #58 on: May 08, 2003, 07:08:09 PM »
oops... you're right... i guess i jumped that last message... sorry.

Offline batz

  • Newbie
  • *
  • Posts: 14
    • View Profile
[Mod] User upload limits
« Reply #59 on: May 08, 2003, 10:13:58 PM »
Thanks anyway SLL.  :)

Bomba: I came first  :P