Some... fixes... laying around here.

git-svn-id: file:///svn/phpbb/trunk@6970 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2007-02-06 19:09:43 +00:00
parent 10f775cb1c
commit 333b3515ed
11 changed files with 115 additions and 88 deletions

View file

@ -54,7 +54,7 @@
<a href="{U_BACK}" style="float: right">&laquo; {L_BACK}</a> <a href="{U_BACK}" style="float: right">&laquo; {L_BACK}</a>
<h1>{L_USER_ADMIN}</h1> <h1>{L_USER_ADMIN} :: {MANAGED_USERNAME}</h1>
<p>{L_USER_ADMIN_EXPLAIN}</p> <p>{L_USER_ADMIN_EXPLAIN}</p>

View file

@ -265,21 +265,20 @@ function send_file_to_browser($attachment, $upload_dir, $category)
exit; exit;
} }
/* /**
* Get a browser friendly UTF-8 encoded filename * Get a browser friendly UTF-8 encoded filename
*/ */
function header_filename($file) function header_filename($file)
{ {
// There be dragons here... // There be dragons here...
// IE follows no RFC, follow the RFC for extended filename for the rest // IE and Safari follows no RFC.
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') !== false)
{ {
return "filename=" . rawurlencode($file); return "filename=" . rawurlencode($file);
} }
else
{ // follow the RFC for extended filename for the rest
return "filename*=UTF-8''" . rawurlencode($file); return "filename*=UTF-8''" . rawurlencode($file);
}
} }
/** /**

View file

@ -94,12 +94,15 @@ class acp_bots
WHERE bot_id $sql_id"; WHERE bot_id $sql_id";
$db->sql_query($sql); $db->sql_query($sql);
$_tables = array(USERS_TABLE, USER_GROUP_TABLE); if (sizeof($user_id_ary))
foreach ($_tables as $table)
{ {
$sql = "DELETE FROM $table $_tables = array(USERS_TABLE, USER_GROUP_TABLE);
WHERE " . $db->sql_in_set('user_id', $user_id_ary); foreach ($_tables as $table)
$db->sql_query($sql); {
$sql = "DELETE FROM $table
WHERE " . $db->sql_in_set('user_id', $user_id_ary);
$db->sql_query($sql);
}
} }
$db->sql_transaction('commit'); $db->sql_transaction('commit');

View file

@ -55,6 +55,7 @@ class acp_email
{ {
if ($usernames) if ($usernames)
{ {
// If giving usernames the admin is able to email inactive users too...
$sql = 'SELECT username, user_email, user_jabber, user_notify_type, user_lang $sql = 'SELECT username, user_email, user_jabber, user_notify_type, user_lang
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('username_clean', array_map('utf8_clean_string', explode("\n", $usernames))) . ' WHERE ' . $db->sql_in_set('username_clean', array_map('utf8_clean_string', explode("\n", $usernames))) . '
@ -66,18 +67,20 @@ class acp_email
if ($group_id) if ($group_id)
{ {
$sql = 'SELECT u.user_email, u.username, u.username_clean, u.user_lang, u.user_jabber, u.user_notify_type $sql = 'SELECT u.user_email, u.username, u.username_clean, u.user_lang, u.user_jabber, u.user_notify_type
FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . " ug FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . ' ug
WHERE ug.group_id = $group_id WHERE ug.group_id = ' . $group_id . '
AND ug.user_pending = 0 AND ug.user_pending = 0
AND u.user_id = ug.user_id AND u.user_id = ug.user_id
AND u.user_allow_massemail = 1 AND u.user_allow_massemail = 1
ORDER BY u.user_lang, u.user_notify_type"; AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')
ORDER BY u.user_lang, u.user_notify_type';
} }
else else
{ {
$sql = 'SELECT username, username_clean, user_email, user_jabber, user_notify_type, user_lang $sql = 'SELECT username, username_clean, user_email, user_jabber, user_notify_type, user_lang
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE user_allow_massemail = 1 WHERE user_allow_massemail = 1
AND user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')
ORDER BY user_lang, user_notify_type'; ORDER BY user_lang, user_notify_type';
} }
} }
@ -172,17 +175,25 @@ class acp_email
$messenger->save_queue(); $messenger->save_queue();
if ($group_id) if ($usernames)
{ {
$group_name = get_group_name($group_id); $usernames = explode("\n", $usernames);
add_log('admin', 'LOG_MASS_EMAIL', implode(', ', $usernames));
} }
else else
{ {
// Not great but the logging routine doesn't cope well with localising on the fly if ($group_id)
$group_name = $user->lang['ALL_USERS']; {
} $group_name = get_group_name($group_id);
}
else
{
// Not great but the logging routine doesn't cope well with localising on the fly
$group_name = $user->lang['ALL_USERS'];
}
add_log('admin', 'LOG_MASS_EMAIL', $group_name); add_log('admin', 'LOG_MASS_EMAIL', $group_name);
}
if (!$errored) if (!$errored)
{ {

View file

@ -355,7 +355,10 @@ class acp_permissions
case 'usergroup': case 'usergroup':
case 'usergroup_view': case 'usergroup_view':
if (sizeof($user_id) || sizeof($group_id)) $all_users = (isset($_POST['all_users'])) ? true : false;
$all_groups = (isset($_POST['all_groups'])) ? true : false;
if ((sizeof($user_id) && !$all_users) || (sizeof($group_id) && !$all_groups))
{ {
if (sizeof($user_id)) if (sizeof($user_id))
{ {
@ -370,11 +373,8 @@ class acp_permissions
continue 2; continue 2;
} }
$items = $this->retrieve_defined_user_groups($permission_scope, $forum_id, $permission_type);
// Now we check the users... because the "all"-selection is different here (all defined users/groups) // Now we check the users... because the "all"-selection is different here (all defined users/groups)
$all_users = (isset($_POST['all_users'])) ? true : false; $items = $this->retrieve_defined_user_groups($permission_scope, $forum_id, $permission_type);
$all_groups = (isset($_POST['all_groups'])) ? true : false;
if ($all_users && sizeof($items['user_ids'])) if ($all_users && sizeof($items['user_ids']))
{ {
@ -565,17 +565,20 @@ class acp_permissions
break; break;
} }
$sql = "SELECT $sql_id if (sizeof($ids))
FROM $table
WHERE " . $db->sql_in_set($sql_id, $ids);
$result = $db->sql_query($sql);
$ids = array();
while ($row = $db->sql_fetchrow($result))
{ {
$ids[] = $row[$sql_id]; $sql = "SELECT $sql_id
FROM $table
WHERE " . $db->sql_in_set($sql_id, $ids);
$result = $db->sql_query($sql);
$ids = array();
while ($row = $db->sql_fetchrow($result))
{
$ids[] = $row[$sql_id];
}
$db->sql_freeresult($result);
} }
$db->sql_freeresult($result);
if (!sizeof($ids)) if (!sizeof($ids))
{ {

View file

@ -134,7 +134,8 @@ class acp_users
'U_BACK' => $this->u_action, 'U_BACK' => $this->u_action,
'U_MODE_SELECT' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=$id&amp;u=$user_id"), 'U_MODE_SELECT' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=$id&amp;u=$user_id"),
'U_ACTION' => $this->u_action . '&amp;u=' . $user_id, 'U_ACTION' => $this->u_action . '&amp;u=' . $user_id,
'S_FORM_OPTIONS' => $s_form_options) 'S_FORM_OPTIONS' => $s_form_options,
'MANAGED_USERNAME' => $user_row['username'])
); );
// Prevent normal users/admins change/view founders if they are not a founder by themselves // Prevent normal users/admins change/view founders if they are not a founder by themselves
@ -398,44 +399,6 @@ class acp_users
if (confirm_box(true)) if (confirm_box(true))
{ {
$sql = 'SELECT topic_id, COUNT(post_id) AS total_posts
FROM ' . POSTS_TABLE . "
WHERE poster_id = $user_id
GROUP BY topic_id";
$result = $db->sql_query($sql);
$topic_id_ary = array();
while ($row = $db->sql_fetchrow($result))
{
$topic_id_ary[$row['topic_id']] = $row['total_posts'];
}
$db->sql_freeresult($result);
if (sizeof($topic_id_ary))
{
$sql = 'SELECT topic_id, topic_replies, topic_replies_real
FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', array_keys($topic_id_ary));
$result = $db->sql_query($sql);
$del_topic_ary = array();
while ($row = $db->sql_fetchrow($result))
{
if (max($row['topic_replies'], $row['topic_replies_real']) + 1 == $topic_id_ary[$row['topic_id']])
{
$del_topic_ary[] = $row['topic_id'];
}
}
$db->sql_freeresult($result);
if (sizeof($del_topic_ary))
{
$sql = 'DELETE FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', $del_topic_ary);
$db->sql_query($sql);
}
}
// Delete posts, attachments, etc. // Delete posts, attachments, etc.
delete_posts('poster_id', $user_id); delete_posts('poster_id', $user_id);

View file

@ -598,7 +598,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
} }
$approved_posts = 0; $approved_posts = 0;
$post_ids = $topic_ids = $forum_ids = $post_counts = array(); $post_ids = $topic_ids = $forum_ids = $post_counts = $remove_topics = array();
$sql = 'SELECT post_id, poster_id, post_approved, post_postcount, topic_id, forum_id $sql = 'SELECT post_id, poster_id, post_approved, post_postcount, topic_id, forum_id
FROM ' . POSTS_TABLE . ' FROM ' . POSTS_TABLE . '
@ -653,6 +653,25 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
} }
} }
// Remove topics now having no posts?
if (sizeof($topic_ids))
{
$sql = 'SELECT topic_id
FROM ' . POSTS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . '
GROUP BY topic_id';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$remove_topics[] = $row['topic_id'];
}
$db->sql_freeresult($result);
// Actually, those not within remove_topics should be removed. ;)
$remove_topics = array_diff($topic_ids, $remove_topics);
}
// Remove the message from the search index // Remove the message from the search index
$search_type = basename($config['search_type']); $search_type = basename($config['search_type']);
@ -695,6 +714,12 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
set_config('num_posts', $config['num_posts'] - $approved_posts, true); set_config('num_posts', $config['num_posts'] - $approved_posts, true);
} }
// We actually remove topics now to not be inconsistent (the delete_topics function calls this function too)
if (sizeof($remove_topics))
{
delete_topics('topic_id', $remove_topics);
}
return sizeof($post_ids); return sizeof($post_ids);
} }

View file

@ -308,6 +308,13 @@ function decode_ip($int_ip)
} }
$hexipbang = explode('.', chunk_split($int_ip, 2, '.')); $hexipbang = explode('.', chunk_split($int_ip, 2, '.'));
// Any mod changing the way ips are stored? Then we are not able to convert.
if (sizeof($hexipbang) != 4)
{
return '';
}
return hexdec($hexipbang[0]). '.' . hexdec($hexipbang[1]) . '.' . hexdec($hexipbang[2]) . '.' . hexdec($hexipbang[3]); return hexdec($hexipbang[0]). '.' . hexdec($hexipbang[1]) . '.' . hexdec($hexipbang[2]) . '.' . hexdec($hexipbang[3]);
} }

View file

@ -117,6 +117,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info)
ORDER BY t.topic_type DESC, $sort_order_sql"; ORDER BY t.topic_type DESC, $sort_order_sql";
$result = $db->sql_query_limit($sql, $topics_per_page, $start); $result = $db->sql_query_limit($sql, $topics_per_page, $start);
$topic_list = $topic_tracking_info = array();
while ($row = $db->sql_fetchrow($result)) while ($row = $db->sql_fetchrow($result))
{ {
$topic_rows[$row['topic_id']] = $row; $topic_rows[$row['topic_id']] = $row;
@ -124,15 +125,23 @@ function mcp_forum_view($id, $mode, $action, $forum_info)
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
$topic_tracking_info = array(); // If there is more than one page, but we have no topic list, then the start parameter is... erm... out of sync
// Get topic tracking info if (!sizeof($topic_list) && $forum_topics && $start > 0)
if ($config['load_db_lastread'])
{ {
$topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $topic_rows, array($forum_id => $forum_info['mark_time']), array()); redirect($url . "&amp;i=$id&amp;action=$action&amp;mode=$mode");
} }
else
// Get topic tracking info
if (sizeof($topic_list))
{ {
$topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list, array()); if ($config['load_db_lastread'])
{
$topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $topic_rows, array($forum_id => $forum_info['mark_time']), array());
}
else
{
$topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list, array());
}
} }
foreach ($topic_rows as $topic_id => $row) foreach ($topic_rows as $topic_id => $row)

View file

@ -192,7 +192,7 @@ class mcp_reports
$forum_info = array(); $forum_info = array();
$forum_list_reports = get_forum_list('m_report', false, true); $forum_list_reports = get_forum_list('m_report', false, true);
if ($topic_id) if ($topic_id && $forum_id)
{ {
$topic_info = get_topic_data(array($topic_id)); $topic_info = get_topic_data(array($topic_id));
@ -204,6 +204,10 @@ class mcp_reports
$topic_info = $topic_info[$topic_id]; $topic_info = $topic_info[$topic_id];
$forum_id = $topic_info['forum_id']; $forum_id = $topic_info['forum_id'];
} }
else if ($topic_id && !$forum_id)
{
$topic_id = 0;
}
$forum_list = array(); $forum_list = array();

View file

@ -1354,12 +1354,15 @@ function add_bots()
WHERE bot_id $sql_id"; WHERE bot_id $sql_id";
$db->sql_query($sql); $db->sql_query($sql);
$_tables = array(USERS_TABLE, USER_GROUP_TABLE); if (sizeof($user_id_ary))
foreach ($_tables as $table)
{ {
$sql = "DELETE FROM $table $_tables = array(USERS_TABLE, USER_GROUP_TABLE);
WHERE " . $db->sql_in_set('user_id', $user_id_ary); foreach ($_tables as $table)
$db->sql_query($sql); {
$sql = "DELETE FROM $table
WHERE " . $db->sql_in_set('user_id', $user_id_ary);
$db->sql_query($sql);
}
} }
} }
else else