1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-02-24 12:03:21 +01:00

fixing some annoying bugs

git-svn-id: file:///svn/phpbb/trunk@8204 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2007-10-19 13:10:13 +00:00
parent 8963b032de
commit bc0898f55e
9 changed files with 100 additions and 51 deletions

View File

@ -85,6 +85,13 @@
<li>[Fix] Fixed MSSQL related bug in the update system</li> <li>[Fix] Fixed MSSQL related bug in the update system</li>
<li>[Fix] Display &quot;Return to&quot; links on unwritable forums (Bug #14824)</li> <li>[Fix] Display &quot;Return to&quot; links on unwritable forums (Bug #14824)</li>
<li>[Fix] Mitigating different realpath() handling between PHP versions (fixing confirm box redirects)</li> <li>[Fix] Mitigating different realpath() handling between PHP versions (fixing confirm box redirects)</li>
<li>[Fix] Fix signature editing - ability to remove signature (Bug #14820)</li>
<li>[Fix] Send correct activation key by forcing reactivation for inactive user (Bug #14819)</li>
<li>[Fix] Adding correct IP for private messages sent by issuing warnings (Bug #14781)</li>
<li>[Fix] Open private message notification (Bug #14773)</li>
<li>[Fix] Fixing false new private message indicator (Bug #14627)</li>
<li>[Fix] Let newly activated passwords work if users were converted (Bug #14787)</li>
<li>[Fix] Quote bbcode fixes. Letting parse quote=&quot;[&quot; and re-allowing whitelisted bbcodes within username portion (Bug #14770)</li>
</ul> </ul>
<a name="v30rc6"></a><h3>1.ii. Changes since 3.0.RC6</h3> <a name="v30rc6"></a><h3>1.ii. Changes since 3.0.RC6</h3>

View File

@ -322,6 +322,16 @@ class acp_users
WHERE user_id = $user_id"; WHERE user_id = $user_id";
$db->sql_query($sql); $db->sql_query($sql);
} }
else
{
// Grabbing the last confirm key - we only send a reminder
$sql = 'SELECT user_actkey
FROM ' . USERS_TABLE . '
WHERE user_id = ' . $user_id;
$result = $db->sql_query($sql);
$user_actkey = (string) $db->sql_fetchfield('user_actkey');
$db->sql_freeresult($result);
}
$messenger = new messenger(false); $messenger = new messenger(false);
@ -774,8 +784,9 @@ class acp_users
if ($update_password) if ($update_password)
{ {
$sql_ary += array( $sql_ary += array(
'user_password' => phpbb_hash($data['new_password']), 'user_password' => phpbb_hash($data['new_password']),
'user_passchg' => time(), 'user_passchg' => time(),
'user_pass_convert' => 0,
); );
$user->reset_login_keys($user_id); $user->reset_login_keys($user_id);

View File

@ -312,6 +312,50 @@ function check_rule(&$rules, &$rule_row, &$message_row, $user_id)
return false; return false;
} }
/**
* Fix user PM count
*/
function fix_pm_counts()
{
global $user, $db;
// Update unread count
$sql = 'SELECT COUNT(msg_id) as num_messages
FROM ' . PRIVMSGS_TO_TABLE . '
WHERE pm_unread = 1
AND folder_id <> ' . PRIVMSGS_OUTBOX . '
AND user_id = ' . $user->data['user_id'];
$result = $db->sql_query($sql);
$user->data['user_unread_privmsg'] = (int) $db->sql_fetchfield('num_messages');
$db->sql_freeresult($result);
// Update new pm count
$sql = 'SELECT COUNT(msg_id) as num_messages
FROM ' . PRIVMSGS_TO_TABLE . '
WHERE pm_new = 1
AND folder_id IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ')
AND user_id = ' . $user->data['user_id'];
$result = $db->sql_query($sql);
$user->data['user_new_privmsg'] = (int) $db->sql_fetchfield('num_messages');
$db->sql_freeresult($result);
$db->sql_query('UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array(
'user_unread_privmsg' => (int) $user->data['user_unread_privmsg'],
'user_new_privmsg' => (int) $user->data['user_new_privmsg'],
)) . ' WHERE user_id = ' . $user->data['user_id']);
// Ok, here we need to repair something, other boxes than privmsgs_no_box and privmsgs_hold_box should not carry the pm_new flag.
if (!$user->data['user_new_privmsg'])
{
$sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . '
SET pm_new = 0
WHERE pm_new = 1
AND folder_id NOT IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ')
AND user_id = ' . $user->data['user_id'];
$db->sql_query($sql);
}
}
/** /**
* Place new messages into appropriate folder * Place new messages into appropriate folder
*/ */
@ -344,42 +388,7 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
// We try to fix this on our way down... // We try to fix this on our way down...
if (!$db->sql_affectedrows()) if (!$db->sql_affectedrows())
{ {
// Update unread count fix_pm_counts();
$sql = 'SELECT COUNT(msg_id) as num_messages
FROM ' . PRIVMSGS_TO_TABLE . '
WHERE pm_unread = 1
AND folder_id <> ' . PRIVMSGS_OUTBOX . '
AND user_id = ' . $user_id;
$result = $db->sql_query($sql);
$num_messages = (int) $db->sql_fetchfield('num_messages');
$db->sql_freeresult($result);
$db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_unread_privmsg = ' . $num_messages . ' WHERE user_id = ' . $user_id);
$user->data['user_unread_privmsg'] = $num_messages;
// Update new pm count
$sql = 'SELECT COUNT(msg_id) as num_messages
FROM ' . PRIVMSGS_TO_TABLE . '
WHERE pm_new = 1
AND folder_id IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ')
AND user_id = ' . $user_id;
$result = $db->sql_query($sql);
$num_messages = (int) $db->sql_fetchfield('num_messages');
$db->sql_freeresult($result);
$db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_new_privmsg = ' . $num_messages . ' WHERE user_id = ' . $user_id);
$user->data['user_new_privmsg'] = $num_messages;
// Ok, here we need to repair something, other boxes than privmsgs_no_box and privmsgs_hold_box should not carry the pm_new flag.
if (!$num_messages)
{
$sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . '
SET pm_new = 0
WHERE pm_new = 1
AND folder_id NOT IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ')
AND user_id = ' . $user_id;
$db->sql_query($sql);
}
// The function needs this value to be up-to-date // The function needs this value to be up-to-date
$user_new_privmsg = (int) $user->data['user_new_privmsg']; $user_new_privmsg = (int) $user->data['user_new_privmsg'];
@ -413,7 +422,7 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
while ($row = $db->sql_fetchrow($result)) while ($row = $db->sql_fetchrow($result))
{ {
$action_ary[$row['msg_id']][] = array('action' => false); $action_ary[$row['msg_id']][] = array('action' => false);
$move_into_folder[PRIVMSGS_INBOX][] = $row['msg_id']; // $move_into_folder[PRIVMSGS_INBOX][] = $row['msg_id'];
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
} }
@ -501,7 +510,7 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
if (!$is_match) if (!$is_match)
{ {
$action_ary[$row['msg_id']][] = array('action' => false); $action_ary[$row['msg_id']][] = array('action' => false);
$move_into_folder[PRIVMSGS_INBOX][] = $row['msg_id']; // $move_into_folder[PRIVMSGS_INBOX][] = $row['msg_id'];
} }
} }
@ -688,7 +697,11 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
if ($full_folder_action == FULL_FOLDER_HOLD) if ($full_folder_action == FULL_FOLDER_HOLD)
{ {
$num_not_moved += sizeof($msg_ary); $num_not_moved += sizeof($msg_ary);
$num_new -= sizeof($msg_ary);
if ($num_new)
{
$num_new -= sizeof($msg_ary);
}
$sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . ' $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . '
SET folder_id = ' . PRIVMSGS_HOLD_BOX . ' SET folder_id = ' . PRIVMSGS_HOLD_BOX . '

View File

@ -418,7 +418,7 @@ function add_warning($user_row, $warning, $send_pm = true, $post_id = 0)
$pm_data = array( $pm_data = array(
'from_user_id' => $user->data['user_id'], 'from_user_id' => $user->data['user_id'],
'from_user_ip' => $user->data['user_ip'], 'from_user_ip' => $user->ip,
'from_username' => $user->data['username'], 'from_username' => $user->data['username'],
'enable_sig' => false, 'enable_sig' => false,
'enable_bbcode' => true, 'enable_bbcode' => true,

View File

@ -674,7 +674,11 @@ class bbcode_firstpass extends bbcode
/** /**
* If you change this code, make sure the cases described within the following reports are still working: * If you change this code, make sure the cases described within the following reports are still working:
* #3572, #14667 * #3572 - [quote="[test]test"]test [ test[/quote] - (correct: parsed)
* #14667 - [quote]test[/quote] test ] and [ test [quote]test[/quote] (correct: parsed)
* #14770 - [quote="["]test[/quote] (correct: parsed)
* [quote="[i]test[/i]"]test[/quote] (correct: parsed)
* [quote="[quote]test[/quote]"]test[/quote] (correct: NOT parsed)
*/ */
$in = str_replace("\r\n", "\n", str_replace('\"', '"', trim($in))); $in = str_replace("\r\n", "\n", str_replace('\"', '"', trim($in)));
@ -684,6 +688,9 @@ class bbcode_firstpass extends bbcode
return ''; return '';
} }
// To let the parser not catch tokens within quote_username quotes we encode them before we start this...
$in = preg_replace('#quote=&quot;(.*?)&quot;\]#ie', "'quote=&quot;' . str_replace(array('[', ']'), array('&#91;', '&#93;'), '\$1') . '&quot;]'", $in);
$tok = ']'; $tok = ']';
$out = '['; $out = '[';
@ -745,7 +752,9 @@ class bbcode_firstpass extends bbcode
if (isset($m[1]) && $m[1]) if (isset($m[1]) && $m[1])
{ {
$username = preg_replace('#\[(?!b|i|u|color|url|email|/b|/i|/u|/color|/url|/email)#iU', '&#91;$1', $m[1]); $username = str_replace(array('&#91;', '&#93;'), array('[', ']'), $m[1]);
$username = preg_replace('#\[(?!b|i|u|color|url|email|/b|/i|/u|/color|/url|/email)#iU', '&#91;$1', $username);
$end_tags = array(); $end_tags = array();
$error = false; $error = false;
@ -765,7 +774,7 @@ class bbcode_firstpass extends bbcode
if ($error) if ($error)
{ {
$username = str_replace('[', '&#91;', str_replace(']', '&#93;', $m[1])); $username = $m[1];
} }
$out .= 'quote=&quot;' . $username . '&quot;:' . $this->bbcode_uid . ']'; $out .= 'quote=&quot;' . $username . '&quot;:' . $this->bbcode_uid . ']';
@ -1073,7 +1082,7 @@ class parse_message extends bbcode_firstpass
} }
// Check for "empty" message // Check for "empty" message
if (!utf8_clean_string($this->message)) if ($mode !== 'sig' && !utf8_clean_string($this->message))
{ {
$this->warn_msg[] = $user->lang['TOO_FEW_CHARS']; $this->warn_msg[] = $user->lang['TOO_FEW_CHARS'];
return $this->warn_msg; return $this->warn_msg;

View File

@ -63,7 +63,8 @@ class ucp_activate
$sql_ary = array( $sql_ary = array(
'user_actkey' => '', 'user_actkey' => '',
'user_password' => $user_row['user_newpasswd'], 'user_password' => $user_row['user_newpasswd'],
'user_newpasswd' => '' 'user_newpasswd' => '',
'user_pass_convert' => 0,
); );
$sql = 'UPDATE ' . USERS_TABLE . ' $sql = 'UPDATE ' . USERS_TABLE . '

View File

@ -249,10 +249,11 @@ class ucp_pm
// If new messages arrived, place them into the appropriate folder // If new messages arrived, place them into the appropriate folder
$num_not_moved = $num_removed = 0; $num_not_moved = $num_removed = 0;
$release = request_var('release', 0);
if ($user->data['user_new_privmsg'] && $action == 'view_folder') if ($user->data['user_new_privmsg'] && $action == 'view_folder')
{ {
$return = place_pm_into_folder($global_privmsgs_rules, request_var('release', 0)); $return = place_pm_into_folder($global_privmsgs_rules, $release);
$num_not_moved = $return['not_moved']; $num_not_moved = $return['not_moved'];
// Make sure num_not_moved is valid. // Make sure num_not_moved is valid.
@ -270,6 +271,12 @@ class ucp_pm
$num_removed = $return['deleted']; $num_removed = $return['deleted'];
} }
// If user released the message, we will re-calculate the statistics (again)
if ($release)
{
fix_pm_counts();
}
if (!$msg_id && $folder_id == PRIVMSGS_NO_BOX) if (!$msg_id && $folder_id == PRIVMSGS_NO_BOX)
{ {
$folder_id = PRIVMSGS_INBOX; $folder_id = PRIVMSGS_INBOX;

View File

@ -38,7 +38,8 @@
<!-- IF S_USER_PM_POPUP --> <!-- IF S_USER_PM_POPUP -->
if ({S_NEW_PM}) if ({S_NEW_PM})
{ {
popup('{UA_POPUP_PM}', 400, 225, '_phpbbprivmsg'); var url = '{UA_POPUP_PM}';
window.open(url.replace(/&amp;/g, '&'), '_phpbbprivmsg', 'height=225,resizable=yes,scrollbars=yes, width=400');
} }
<!-- ENDIF --> <!-- ENDIF -->