|
From: FlorinCB <ory...@us...> - 2009-11-11 10:10:43
|
Update of /cvsroot/mxbb/core/includes In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv26947 Modified Files: mx_functions_tools.php Log Message: fix Index: mx_functions_tools.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/mx_functions_tools.php,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** mx_functions_tools.php 8 Oct 2009 17:01:06 -0000 1.57 --- mx_functions_tools.php 11 Nov 2009 10:10:05 -0000 1.58 *************** *** 1894,1951 **** function _insert_pm() { ! global $db, $lang, $user_ip, $board_config, $userdata, $phpbb_root_path, $phpEx, $mx_bbcode; ! ! // ! // get varibles ready ! // ! $msg_time = time(); ! $attach_sig = $userdata['user_attachsig']; ! // ! //get 'to user's info ! // ! $sql = "SELECT user_id, user_email FROM " . USERS_TABLE . " WHERE user_id = '" . $this->to_id . "' AND user_id <> " . ANONYMOUS; ! if ( !($result = $db->sql_query($sql)) ) ! { ! $error = TRUE; ! $error_msg = $lang['No_such_user']; ! } ! $to_userdata = $db->sql_fetchrow($result); ! $privmsg_subject = trim(strip_tags($this->subject)); ! if ( empty($privmsg_subject) ) ! { ! $error = TRUE; ! $error_msg .= ( ( !empty($error_msg) ) ? '<br />' : '' ) . $lang['Empty_subject']; ! } ! if ( !empty($this->message) ) ! { ! if ( !$error ) ! { ! if ( $this->bbcode_on ) ! { ! $bbcode_uid = $mx_bbcode->make_bbcode_uid(); ! } ! $privmsg_message = prepare_message(addslashes($this->message), $this->html_on, $this->bbcode_on, $this->smilies_on, $bbcode_uid); ! $privmsg_message = str_replace('\\\n', '\n', $privmsg_message); ! } ! } ! else ! { ! $error = TRUE; ! $error_msg .= ( ( !empty($error_msg) ) ? '<br />' : '' ) . $lang['Empty_message']; ! } ! // ! // See if recipient is at their inbox limit ! // ! $sql = "SELECT COUNT(privmsgs_id) AS inbox_items, MIN(privmsgs_date) AS oldest_post_time FROM " . PRIVMSGS_TABLE . " WHERE ( privmsgs_type = " . PRIVMSGS_NEW_MAIL . " --- 1894,1956 ---- function _insert_pm() { ! global $db, $lang, $user_ip, $board_config, $userdata, $phpbb_root_path, $phpEx, $mx_bbcode; ! // ! // get varibles ready ! // ! $msg_time = time(); ! $attach_sig = $userdata['user_attachsig']; ! ! $is_admin = ( $userdata['user_level'] == ADMIN && $userdata['session_logged_in'] ) ? TRUE : 0; ! ! // ! //get 'to user's info ! /* ! $sql = "SELECT user_id, user_email FROM " . USERS_TABLE . " WHERE user_id = '" . $this->to_id . "' AND user_id <> " . ANONYMOUS; ! if ( !($result = $db->sql_query($sql)) ) ! { ! $error = TRUE; ! $error_msg = $lang['No_such_user']; ! } ! $to_userdata = $db->sql_fetchrow($result); ! */ ! $to_userdata = mx_get_userdata($this->to_id); ! $privmsg_subject = trim(strip_tags($this->subject)); ! if ( empty($privmsg_subject) ) ! { ! $error = TRUE; ! $error_msg .= ( ( !empty($error_msg) ) ? '<br />' : '' ) . $lang['Empty_subject']; ! } ! if ( !empty($this->message) ) ! { ! if ( !$error ) ! { ! if ( $this->bbcode_on ) ! { ! $bbcode_uid = $mx_bbcode->make_bbcode_uid(); ! } ! $privmsg_message = prepare_message(addslashes($this->message), $this->html_on, $this->bbcode_on, $this->smilies_on, $bbcode_uid); ! $privmsg_message = str_replace('\\\n', '\n', $privmsg_message); ! } ! } ! else ! { ! $error = TRUE; ! $error_msg .= ( ( !empty($error_msg) ) ? '<br />' : '' ) . $lang['Empty_message']; ! } ! ! // ! // See if recipient is at their inbox limit ! // ! $sql = "SELECT COUNT(privmsgs_id) AS inbox_items, MIN(privmsgs_date) AS oldest_post_time FROM " . PRIVMSGS_TABLE . " WHERE ( privmsgs_type = " . PRIVMSGS_NEW_MAIL . " *************** *** 1954,2010 **** AND privmsgs_to_userid = " . $to_userdata['user_id']; ! if ( !($result = $db->sql_query($sql)) ) ! { ! mx_message_die(GENERAL_MESSAGE, $lang['No_such_user']); ! } ! $sql_priority = ( SQL_LAYER == 'mysql' ) ? 'LOW_PRIORITY' : ''; ! if ( $inbox_info = $db->sql_fetchrow($result) ) ! { ! if ( $inbox_info['inbox_items'] >= $board_config['max_inbox_privmsgs'] ) ! { ! $sql = "SELECT privmsgs_id FROM " . PRIVMSGS_TABLE . " ! WHERE ( privmsgs_type = " . PRIVMSGS_NEW_MAIL . " OR privmsgs_type = " . PRIVMSGS_READ_MAIL . " OR privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . " ) ! AND privmsgs_date = " . $inbox_info['oldest_post_time'] . " ! AND privmsgs_to_userid = " . $to_userdata['user_id']; ! if ( !$result = $db->sql_query($sql) ) ! { ! mx_message_die(GENERAL_ERROR, 'Could not find oldest privmsgs (inbox)', '', __LINE__, __FILE__, $sql); ! } ! $old_privmsgs_id = $db->sql_fetchrow($result); ! $old_privmsgs_id = $old_privmsgs_id['privmsgs_id']; ! $sql = "DELETE $sql_priority FROM " . PRIVMSGS_TABLE . " ! WHERE privmsgs_id = $old_privmsgs_id"; ! if ( !$db->sql_query($sql) ) ! { ! mx_message_die(GENERAL_ERROR, 'Could not delete oldest privmsgs (inbox)'.$sql, '', __LINE__, __FILE__, $sql); ! } ! $sql = "DELETE $sql_priority FROM " . PRIVMSGS_TEXT_TABLE . " ! WHERE privmsgs_text_id = $old_privmsgs_id"; ! if ( !$db->sql_query($sql) ) ! { ! mx_message_die(GENERAL_ERROR, 'Could not delete oldest privmsgs text (inbox)', '', __LINE__, __FILE__, $sql); ! } ! } ! } ! $sql_info = "INSERT INTO " . PRIVMSGS_TABLE . " (privmsgs_type, privmsgs_subject, privmsgs_from_userid, privmsgs_to_userid, privmsgs_date, privmsgs_ip, privmsgs_enable_html, privmsgs_enable_bbcode, privmsgs_enable_smilies, privmsgs_attach_sig) ! VALUES (" . PRIVMSGS_NEW_MAIL . ", '" . str_replace("\'", "''", $privmsg_subject) . "', " . $this->from_id . ", " . $to_userdata['user_id'] . ", $msg_time, '$user_ip', $this->html_on, $this->bbcode_on, $this->smilies_on, $attach_sig)"; ! if ( !($result = $db->sql_query($sql_info)) ) ! { ! mx_message_die(GENERAL_ERROR, "Could not insert/update private message sent info.", "", __LINE__, __FILE__, $sql_info); ! } ! $privmsg_sent_id = $db->sql_nextid(); $sql = "INSERT INTO " . PRIVMSGS_TEXT_TABLE . " (privmsgs_text_id, privmsgs_bbcode_uid, privmsgs_text) --- 1959,2015 ---- AND privmsgs_to_userid = " . $to_userdata['user_id']; ! if ( !($result = $db->sql_query($sql)) ) ! { ! mx_message_die(GENERAL_MESSAGE, $lang['No_such_user']); ! } ! $sql_priority = ( SQL_LAYER == 'mysql' ) ? 'LOW_PRIORITY' : ''; ! if ( $inbox_info = $db->sql_fetchrow($result) ) ! { ! if ( $inbox_info['inbox_items'] >= $board_config['max_inbox_privmsgs'] ) ! { ! $sql = "SELECT privmsgs_id FROM " . PRIVMSGS_TABLE . " ! WHERE ( privmsgs_type = " . PRIVMSGS_NEW_MAIL . " OR privmsgs_type = " . PRIVMSGS_READ_MAIL . " OR privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . " ) ! AND privmsgs_date = " . $inbox_info['oldest_post_time'] . " ! AND privmsgs_to_userid = " . $to_userdata['user_id']; ! if ( !$result = $db->sql_query($sql) ) ! { ! mx_message_die(GENERAL_ERROR, 'Could not find oldest privmsgs (inbox)', '', __LINE__, __FILE__, $sql); ! } ! $old_privmsgs_id = $db->sql_fetchrow($result); ! $old_privmsgs_id = $old_privmsgs_id['privmsgs_id']; ! $sql = "DELETE $sql_priority FROM " . PRIVMSGS_TABLE . " ! WHERE privmsgs_id = $old_privmsgs_id"; ! if ( !$db->sql_query($sql) ) ! { ! mx_message_die(GENERAL_ERROR, 'Could not delete oldest privmsgs (inbox)'.$sql, '', __LINE__, __FILE__, $sql); ! } ! $sql = "DELETE $sql_priority FROM " . PRIVMSGS_TEXT_TABLE . " ! WHERE privmsgs_text_id = $old_privmsgs_id"; ! if ( !$db->sql_query($sql) ) ! { ! mx_message_die(GENERAL_ERROR, 'Could not delete oldest privmsgs text (inbox)', '', __LINE__, __FILE__, $sql); ! } ! } ! } ! $sql_info = "INSERT INTO " . PRIVMSGS_TABLE . " (privmsgs_type, privmsgs_subject, privmsgs_from_userid, privmsgs_to_userid, privmsgs_date, privmsgs_ip, privmsgs_enable_html, privmsgs_enable_bbcode, privmsgs_enable_smilies, privmsgs_attach_sig) ! VALUES (" . PRIVMSGS_NEW_MAIL . ", '" . str_replace("\'", "''", $privmsg_subject) . "', " . $this->from_id . ", " . $to_userdata['user_id'] . ", $msg_time, '$user_ip', $this->html_on, $this->bbcode_on, $this->smilies_on, $attach_sig)"; ! if ( !($result = $db->sql_query($sql_info)) ) ! { ! mx_message_die(GENERAL_ERROR, "Could not insert/update private message sent info.", "", __LINE__, __FILE__, $sql_info); ! } ! $privmsg_sent_id = $db->sql_nextid(); $sql = "INSERT INTO " . PRIVMSGS_TEXT_TABLE . " (privmsgs_text_id, privmsgs_bbcode_uid, privmsgs_text) |