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

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

0 Members and 1 Guest are viewing this topic.

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
Re: Showing time to next upload
« Reply #60 on: May 13, 2003, 09:10:52 PM »
Quote from: batz
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."

Seems you can do it now  :wink:

Replace the whole function function check_daily_picture_limit with this 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";
$result = $site_db->query($sql);
$row = $site_db->fetch_array($result);
$upload_limit = ($row['user_limit']);
$site_template->register_vars("upload_limit", $upload_limit);

$limit_cutoff = time() - 60 * 60 * 24;

$sql = "SELECT image_id, image_date FROM ".IMAGES_TABLE." WHERE user_id=$user_id AND image_date > $limit_cutoff ORDER BY image_date ASC";
$result = $site_db->query($sql);
$images_per_user = $site_db->get_numrows($result);
$row = $site_db->query_firstrow($sql);
$latest_image_date = ($row['image_date']);

$sql = "SELECT image_id, image_date FROM ".IMAGES_TEMP_TABLE." WHERE user_id=$user_id ORDER BY image_date ASC";
$result = $site_db->query($sql);
$tmp_images_per_user = $site_db->get_numrows($result);
$row = $site_db->query_firstrow($sql);
$latest_tmp_image_date = ($row['image_date']);
$images_per_user = $tmp_images_per_user + $images_per_user;

$latest_image_date = $latest_tmp_image_date > $latest_image_date ? $latest_tmp_image_date : $latest_image_date;
$time_to_go = gmstrftime("%H hrs %M min %S sec", 86400 - (time() - $latest_image_date));

$site_template->register_vars("images_per_user", $images_per_user);
$site_template->register_vars("time_to_go", $time_to_go);

if($images_per_user >= $upload_limit) {
return false;
} else {
return true;
}
}

Then insert {time_to_go} either directly into over_limits.html template or into into $lang['no_limits_text'] in the /lang/main.php. This is assuming that you're using 24 hrs limit, otherwise change 86400 to another figure

Offline batz

  • Newbie
  • *
  • Posts: 14
    • View Profile
[Mod] User upload limits
« Reply #61 on: May 13, 2003, 10:03:49 PM »
What can i say... man, you are the man  :D  This MOD, for me, now is completed. Absolutely great.

Many thanks

Offline Bomba

  • Full Member
  • ***
  • Posts: 202
    • View Profile
[Mod] User upload limits
« Reply #62 on: May 14, 2003, 12:19:10 AM »
GREAT!

just one little thing

i don't have
Code: [Select]
function check_daily_picture_limit($user_id) {


what i have is
Code: [Select]
function check_picture_limit($user_id) {

should i copy this new code exactly like u told or should i change it to
Code: [Select]
function check_picture_limit($user_id) { ?

thanks

Offline batz

  • Newbie
  • *
  • Posts: 14
    • View Profile
[Mod] User upload limits
« Reply #63 on: May 14, 2003, 03:02:22 AM »
This is strange, but SLL could tell you better  :wink:
The question is: If you don't have the
Code: [Select]
function check_daily_picture_limit($user_id) { how are you using the User limits MOD?

Search that function above the
Code: [Select]
function check_picture_limit($user_id) {

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
[Mod] User upload limits
« Reply #64 on: May 14, 2003, 08:07:53 AM »
Quote from: Bomba
just one little thing
i don't have
Code: [Select]
function check_daily_picture_limit($user_id) {

that means you're using the first version of this mod. you should download the new one and reinstall it.

Offline Bomba

  • Full Member
  • ***
  • Posts: 202
    • View Profile
[Mod] User upload limits
« Reply #65 on: May 15, 2003, 01:03:43 AM »
but it works perfectly with daily limit
you told me what should i change to put this daily limit working in page 3 of this topic i think.

what's the difference in this new version?

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
[Mod] User upload limits
« Reply #66 on: May 15, 2003, 08:27:41 AM »
Quote from: Bomba
what's the difference in this new version?

Current version has two functions, for both global and daily limits, so you can choose which one to use.

Offline Bomba

  • Full Member
  • ***
  • Posts: 202
    • View Profile
[Mod] User upload limits
« Reply #67 on: May 19, 2003, 05:37:47 PM »
do u think that is there any problem if i change my code:

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

$sql = "SELECT user_limit FROM ".USERS_TABLE." WHERE user_id = $user_id";
$result = $site_db->query($sql);
$row = $site_db->fetch_array($result);
$upload_limit = ($row['user_limit']);
$site_template->register_vars("upload_limit", $upload_limit);

$limit_cutoff = time() - 60 * 60 * 24;

$sql = "SELECT COUNT(*) 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);

if($images_per_user >= $upload_limit) {
return false;
} else {
return true;
   }
}



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

$sql = "SELECT user_limit FROM ".USERS_TABLE." WHERE user_id = $user_id";
$result = $site_db->query($sql);
$row = $site_db->fetch_array($result);
$upload_limit = ($row['user_limit']);
$site_template->register_vars("upload_limit", $upload_limit);

$limit_cutoff = time() - 60 * 60 * 24;

$sql = "SELECT image_id, image_date FROM ".IMAGES_TABLE." WHERE user_id=$user_id AND image_date > $limit_cutoff ORDER BY image_date ASC";
$result = $site_db->query($sql);
$images_per_user = $site_db->get_numrows($result);
$row = $site_db->query_firstrow($sql);
$latest_image_date = ($row['image_date']);

$sql = "SELECT image_id, image_date FROM ".IMAGES_TEMP_TABLE." WHERE user_id=$user_id ORDER BY image_date ASC";
$result = $site_db->query($sql);
$tmp_images_per_user = $site_db->get_numrows($result);
$row = $site_db->query_firstrow($sql);
$latest_tmp_image_date = ($row['image_date']);
$images_per_user = $tmp_images_per_user + $images_per_user;

$latest_image_date = $latest_tmp_image_date > $latest_image_date ? $latest_tmp_image_date : $latest_image_date;
$time_to_go = gmstrftime("%H hrs %M min %S sec", 86400 - (time() - $latest_image_date));

$site_template->register_vars("images_per_user", $images_per_user);
$site_template->register_vars("time_to_go", $time_to_go);

if($images_per_user >= $upload_limit) {
return false;
} else {
return true;
    }
}


i use my current code to limit updates by time and it works perfectly, but i would like to add this "how many time to next upload" code in my current mod.
will this work?

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
[Mod] User upload limits
« Reply #68 on: May 19, 2003, 05:44:23 PM »
Quote from: Bomba
but i would like to add this "how many time to next upload" code in my current mod.  will this work?

why don't you just try?  :lol:

Offline Bomba

  • Full Member
  • ***
  • Posts: 202
    • View Profile
[Mod] User upload limits
« Reply #69 on: May 19, 2003, 05:45:41 PM »
cause im affraid of making some "fatal error" and then i can't solv it  :roll:

 :wink:

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
[Mod] User upload limits
« Reply #70 on: May 19, 2003, 05:48:21 PM »
Quote from: Bomba
cause im affraid of making some "fatal error" and then i can't solv it  :roll:

 :wink:
that's why u should do always backup before do any changes... :wink:
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 bloodhard

  • Pre-Newbie
  • Posts: 6
    • View Profile
[Mod] User upload limits
« Reply #71 on: May 29, 2003, 09:56:52 AM »
hello guys...
i install the mod and followed those steps..
however, when i try to add new user  i got this message..and was unable to add a new user...

i check the code for insert into database ....but i don't have and experience with php connecting mysql ...

andone can help me with this???

thank you so much



DB Error: Bad SQL Query: INSERT INTO 4images_users (user_id, user_level, user_name, user_password, user_email, user_showemail, user_allowemails, user_invisible, user_joindate, user_activationkey, user_lastaction, user_lastvisit, user_comments, user_homepage, user_icq, user_limit) VALUES (8, 2, '123123', '4297f44b13955235245b2497399d7a93', '123123@123.123', 1, 1, 0, 1054193927, '97d77f8fce9b56ea6ca5c3df3c0c54a1', 1054193927, 1054193927, 0, '', '', )


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 ')' at line 4

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
[Mod] User upload limits
« Reply #72 on: May 29, 2003, 10:07:04 AM »
seems you didn't run the installer, so the neccessary fields were not added to your db

Offline bloodhard

  • Pre-Newbie
  • Posts: 6
    • View Profile
[Mod] User upload limits
« Reply #73 on: May 29, 2003, 10:15:25 AM »
i run the install file....

whcih will add.....a limit field into users table right??
i checked~


or should i run it again~?

Offline Lord Nite

  • Newbie
  • *
  • Posts: 43
    • View Profile
[Mod] User upload limits
« Reply #74 on: June 17, 2003, 10:03:20 AM »
Problem found!

change
Code: [Select]
$sql = "INSERT INTO ".USERS_TABLE."
             (".get_user_table_field("", "user_id").get_user_table_field(", ", "user_level").get_user_table_field(", ", "user_name").get_user_table_field(", ", "user_password").get_user_table_field(", ", "user_email").get_user_table_field(", ", "user_showemail").get_user_table_field(", ", "user_allowemails").get_user_table_field(", ", "user_invisible").get_user_table_field(", ", "user_joindate").get_user_table_field(", ", "user_activationkey").get_user_table_field(", ", "user_lastaction").get_user_table_field(", ", "user_lastvisit").get_user_table_field(", ", "user_comments").get_user_table_field(", ", "user_homepage").get_user_table_field(", ", "user_icq").(", user_limit").$additional_field_sql.")
                 VALUES
              ($user_id, $user_level, '$user_name', '$user_password', '$user_email', $user_showemail, $user_allowemails, $user_invisible, $current_time, '$activationkey', $current_time, $current_time, 0, '$user_homepage', '$user_icq', $user_limit".$additional_value_sql.")";

to this:
Code: [Select]
$sql = "INSERT INTO ".USERS_TABLE."
             (".get_user_table_field("", "user_id").get_user_table_field(", ", "user_level").get_user_table_field(", ", "user_name").get_user_table_field(", ", "user_password").get_user_table_field(", ", "user_email").get_user_table_field(", ", "user_showemail").get_user_table_field(", ", "user_allowemails").get_user_table_field(", ", "user_invisible").get_user_table_field(", ", "user_joindate").get_user_table_field(", ", "user_activationkey").get_user_table_field(", ", "user_lastaction").get_user_table_field(", ", "user_lastvisit").get_user_table_field(", ", "user_comments").get_user_table_field(", ", "user_homepage").get_user_table_field(", ", "user_icq").(", user_limit").$additional_field_sql.")
                 VALUES
              ($user_id, $user_level, '$user_name', '$user_password', '$user_email', $user_showemail, $user_allowemails, $user_invisible, $current_time, '$activationkey', $current_time, $current_time, 0, '$user_homepage', '$user_icq', '$user_limit'".$additional_value_sql.")";


Notice the ' around the $user_limit string.  It wasn't there before, and that would cause the errors.  I just discovered this fix by testing on my own live board.

Ah, the joy one gets when he figures out the problem all on his own with absolutely no PHP knowledge.  :P