From b224e95c84b421de52b817cb694209497828d21a Mon Sep 17 00:00:00 2001 From: nanosimbiot Date: Tue, 16 Aug 2011 21:11:04 +0000 Subject: [PATCH] r221 git-svn-id: https://torrentpier2.googlecode.com/svn/trunk@221 a8ac35ab-4ca4-ca47-4c2d-a49a94f06293 --- upload/includes/functions.php | 26 +++++++++++++++++++++----- upload/includes/functions_validate.php | 2 +- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/upload/includes/functions.php b/upload/includes/functions.php index 159014289..44ee11dbb 100644 --- a/upload/includes/functions.php +++ b/upload/includes/functions.php @@ -2770,22 +2770,38 @@ function get_path_from_id ($id, $ext_id, $base_path, $first_div, $sec_div) return ($base_path ? "$base_path/" : '') . ($id % $sec_div) .'/'. $id . ($ext ? ".$ext" : ''); } -function send_pm($user_id, $subject, $message) -{ global $userdata; +function send_pm($user_id, $subject, $message, $poster_id = false) +{ + global $userdata; $subject = DB()->escape($subject); $message = DB()->escape($message); + if($poster_id == BOT_UID) + { + $poster_ip = '7f000001'; + } + else if($row = DB()->fetch_row("SELECT user_reg_ip ". BB_USERS ." WHERE user_id = $poster_id")) + { + $poster_ip = $row['user_reg_ip']; + } + else + { + $poster_id = $userdata['user_id']; + $poster_ip = USER_IP; + } + DB()->sql_query("INSERT INTO ". BB_PRIVMSGS ." (privmsgs_type, privmsgs_subject, privmsgs_from_userid, privmsgs_to_userid, privmsgs_date, privmsgs_ip) - VALUES (". PRIVMSGS_NEW_MAIL .", '$subject', {$userdata['user_id']}, $user_id, ". TIMENOW .", '". USER_IP ."')"); + VALUES (". PRIVMSGS_NEW_MAIL .", '$subject', {$poster_id}, $user_id, ". TIMENOW .", '$poster_ip')"); $pm_id = DB()->sql_nextid(); DB()->sql_query("INSERT INTO " . BB_PRIVMSGS_TEXT . " (privmsgs_text_id, privmsgs_text) - VALUES ($privmsg_sent_id, '$message')"); + VALUES ($pm_id, '$message')"); DB()->sql_query("UPDATE ". BB_USERS ." SET user_new_privmsg = user_new_privmsg + 1, user_last_privmsg = ". TIMENOW .", user_newest_pm_id = $pm_id WHERE user_id = $user_id"); -} \ No newline at end of file +} + diff --git a/upload/includes/functions_validate.php b/upload/includes/functions_validate.php index 7af9ac095..bb4d60e4d 100644 --- a/upload/includes/functions_validate.php +++ b/upload/includes/functions_validate.php @@ -5,7 +5,7 @@ if (!defined('BB_ROOT')) die(basename(__FILE__)); // !!! $username должен быть предварительно обработан clean_username() !!! function validate_username ($username, $check_ban_and_taken = true) { - global $userdata; + global $userdata, $lang; static $name_chars = 'a-z0-9а-яё_@$%^&;(){}\#\-\'.:+ ';