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

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

0 Members and 1 Guest are viewing this topic.

Offline Bomba

  • Full Member
  • ***
  • Posts: 202
    • View Profile
[Mod] User upload limits
« Reply #30 on: February 23, 2003, 08:53:00 PM »
well i put that code after
Code: [Select]
<?php  in the install_user_limits, is that correct?

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
[Mod] User upload limits
« Reply #31 on: February 23, 2003, 09:05:46 PM »
no, it's not correct  :lol:

open the original mod installation instructions, find there function check_picture_limit and replace it with the function i gave you.

Offline Bomba

  • Full Member
  • ***
  • Posts: 202
    • View Profile
[Mod] User upload limits
« Reply #32 on: February 23, 2003, 09:19:04 PM »
i've changed that but now when i try to upload something it says "please choose image file!"

the code of my member.php is
Code: [Select]
));
      $media = $site_template->parse_template("media/".$file_extension);
      $content .= "<table border=\"0\" align=\"center\">\n<tr>\n<td>\n".$media."\n</td>\n</tr>\n</table>\n";
    }
    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_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;
   }
}

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 ($cat_id != 0 && (!isset($cat_cache[$cat_id]) || !check_picture_limit($user_id))) {
$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'];

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
[Mod] User upload limits
« Reply #33 on: February 23, 2003, 09:35:49 PM »
this part seems to be ok. check if all other mod steps has been done right way.

Offline Bomba

  • Full Member
  • ***
  • Posts: 202
    • View Profile
[Mod] User upload limits
« Reply #34 on: February 23, 2003, 10:04:27 PM »
maybe the problem is that i already have installed once the install_user_limit.php and now if i try to do it for the second time it shows:
Code: [Select]
DB Error: Bad SQL Query: INSERT INTO 4images_settings () VALUES ('default_upload_limit', 5)
Duplicate entry 'default_upload_limit' for key 1

DB Error: Bad SQL Query: ALTER TABLE 4images_users ADD user_limit SMALLINT(3) DEFAULT 5 NOT NULL
Duplicate column name 'user_limit'
 
 


i know that the mod instructions say that we shouldn't do it twice. so what should i do?


here are the rest of the changed codes

register php:
Code: [Select]
$current_time = time();
    $user_level = ($config['account_activation'] == 0) ? USER : USER_AWAITING;
    $user_limit= $config['default_upload_limit'];
    $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', '".md5($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.")";
    $result = $site_db->query($sql);


admin/users:
Code: [Select]
 show_input_row($lang['field_icq'], "user_icq", $user_row['user_icq'], $textinput_size);
  show_input_row($lang['field_limit'], "user_limit", $user_row['user_limit']);


admin/settings:
Code: [Select]
 show_setting_row("max_media_size");
  show_setting_row("default_upload_limit");


and the rest were the lang files.
thanks

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
[Mod] User upload limits
« Reply #35 on: February 23, 2003, 10:35:45 PM »
Quote from: Bomba
i know that the mod instructions say that we shouldn't do it twice. so what should i do?

no, this couldn't be a reason... you just get this error message, but nothing done with the database, even if you run it twice.

i really don't know what's wrong with your code, the only thing you can be sure - this mod has been installed by number of people sucessfully. so, please try once again with clean backup files.

Offline Bomba

  • Full Member
  • ***
  • Posts: 202
    • View Profile
[Mod] User upload limits
« Reply #36 on: February 23, 2003, 11:11:23 PM »
:( did all the changes again and nothing :(
it keeps saying "choose image file"

do i have to chmod any files or something?
you can see this running in http://www.web-fxdesigns.com/4images/index.php it's in portuguese.

i will really need this mod :(
thanks for all your help

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
[Mod] User upload limits
« Reply #37 on: February 23, 2003, 11:28:14 PM »
no, you don't have to chmod anything. just the steps described in mod.

i just checked it once again, on fresh 4images installation (now as a daily limit) - it works just fine... so, keep trying  :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 #38 on: February 23, 2003, 11:28:52 PM »
did it actualy worked before "time limit" changes?
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 Bomba

  • Full Member
  • ***
  • Posts: 202
    • View Profile
[Mod] User upload limits
« Reply #39 on: February 23, 2003, 11:37:31 PM »
yes, before this i and the other members were able to upload the pics.

when will it be out the fresh 4images?

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
[Mod] User upload limits
« Reply #40 on: February 23, 2003, 11:41:26 PM »
Quote from: Bomba
when will it be out the fresh 4images?

fresh means 4images without any mod applied - i have almost all mods installed on my testsystem, so if something goes wrong, you never know what was the reason  :)

Offline labbishiva

  • Pre-Newbie
  • Posts: 6
    • View Profile
    • http://www.chaosgang-hundeforum.de/fotos/index.php
[Mod] User upload limits
« Reply #41 on: February 27, 2003, 11:49:08 AM »
Ich bekomme schon beim ausführen der "install_user_limits.php" folgende Fehlermeldung:

Quote
DB Error: Bad SQL Query: INSERT INTO 4images_settings () VALUES ('default_upload_limit', 7)
You have an error in your SQL syntax near ') VALUES ('default_upload_limit', 7)' at line 2

DB Error: Bad SQL Query: ALTER TABLE 4images_users ADD user_limit SMALLINT(3) DEFAULT 7 NOT NULL
Duplicate column name 'user_limit'


Da ich weder in Englisch noch in PHP über viel Erfahrung verfüge, bringen mir die vorherigen Beiträge nicht so viel  :cry: - vielleicht findet sich ja einer, der es mir au deutsch idiotensicher erklären kann. Wäre super

LG
Nicole

Ach ja über PHPMyAdmin erhalte ich die selber Fehlermeldung, wenn ich den Befehl manuell eingeben will.

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
[Mod] User upload limits
« Reply #42 on: February 27, 2003, 12:57:17 PM »
just ignore this error message, it won't influence anything

Offline lakeside

  • Full Member
  • ***
  • Posts: 123
    • View Profile
Small problem with this mod
« Reply #43 on: March 28, 2003, 04:22:03 AM »
The problem comes in when you have the admin settings to validate each image.

Thats the way I've got it setup, and when a user is set to 1 image, and admin validates ever image, they can continue to upload images all day long.  Until the admin validates one of the images.

Is there a way around this, besides turning off admin validation?

Thanks

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
Re: Small problem with this mod
« Reply #44 on: March 28, 2003, 08:14:10 AM »
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