diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2006-12-21 10:37:50 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2006-12-21 10:37:50 +0000 |
commit | 515085a2a2d4b06989566a60b8add3fa4864f1e3 (patch) | |
tree | 9000d688dc33511560a9d08191b87d1340f70af3 /phpBB/includes | |
parent | 2e1eef2713f7891ce9d78736ceae6d2faf93fc4b (diff) | |
download | forums-515085a2a2d4b06989566a60b8add3fa4864f1e3.tar forums-515085a2a2d4b06989566a60b8add3fa4864f1e3.tar.gz forums-515085a2a2d4b06989566a60b8add3fa4864f1e3.tar.bz2 forums-515085a2a2d4b06989566a60b8add3fa4864f1e3.tar.xz forums-515085a2a2d4b06989566a60b8add3fa4864f1e3.zip |
- some fixes
- important bugfix for the mcp and determining allowed ids in general (if global announcements are included)
git-svn-id: file:///svn/phpbb/trunk@6787 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes')
-rw-r--r-- | phpBB/includes/acp/acp_users.php | 1 | ||||
-rw-r--r-- | phpBB/includes/functions_module.php | 8 | ||||
-rw-r--r-- | phpBB/includes/functions_posting.php | 2 | ||||
-rw-r--r-- | phpBB/includes/functions_upload.php | 75 | ||||
-rw-r--r-- | phpBB/includes/functions_user.php | 3 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_ban.php | 37 | ||||
-rwxr-xr-x | phpBB/includes/mcp/mcp_notes.php | 2 | ||||
-rwxr-xr-x | phpBB/includes/mcp/mcp_warn.php | 94 |
8 files changed, 137 insertions, 85 deletions
diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 28125df3ed..ae64fd37ed 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -941,6 +941,7 @@ class acp_users if ($submit && $message) { add_log('admin', 'LOG_USER_FEEDBACK', $user_row['username']); + add_log('mod', 0, 0, 'LOG_USER_FEEDBACK', $user_row['username']); add_log('user', $user_id, 'LOG_USER_GENERAL', $message); trigger_error($user->lang['USER_FEEDBACK_ADDED'] . adm_back_link($this->u_action . '&u=' . $user_id)); diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index 753e043c16..22312b8d76 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -166,7 +166,7 @@ class p_master $depth = sizeof($this->module_cache['parents'][$row['module_id']]); // We need to prefix the functions to not create a naming conflict - + // Function for building 'url_extra' $url_func = '_module_' . $row['module_basename'] . '_url'; @@ -191,7 +191,7 @@ class p_master 'mode' => (string) $row['module_mode'], 'display' => (int) $row['module_display'], - 'url_extra' => (function_exists($url_func)) ? $url_func($row['module_mode']) : '', + 'url_extra' => (function_exists($url_func)) ? $url_func($row['module_mode'], $row) : '', 'lang' => ($row['module_basename'] && function_exists($lang_func)) ? $lang_func($row['module_mode'], $row['module_langname']) : ((!empty($user->lang[$row['module_langname']])) ? $user->lang[$row['module_langname']] : $row['module_langname']), 'langname' => $row['module_langname'], @@ -578,7 +578,9 @@ class p_master } $u_title = $module_url . $delim . 'i=' . (($item_ary['cat']) ? $item_ary['id'] : $item_ary['name'] . (($item_ary['is_duplicate']) ? '&icat=' . $current_id : '') . '&mode=' . $item_ary['mode']); - $u_title .= (!$item_ary['cat'] && isset($item_ary['url_extra'])) ? $item_ary['url_extra'] : ''; + + // Was not allowed in categories before - /*!$item_ary['cat'] && */ + $u_title .= (isset($item_ary['url_extra'])) ? $item_ary['url_extra'] : ''; // Only output a categories items if it's currently selected if (!$depth || ($depth && (in_array($item_ary['parent'], array_values($this->module_cache['parents'])) || $item_ary['parent'] == $this->p_parent))) diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 51bcf2e583..5805e654c6 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -96,7 +96,7 @@ function generate_smilies($mode, $forum_id) } /** -* Update Post Information (First/Last Post in topic/forum) +* Update last post information * Should be used instead of sync() if only the last post information are out of sync... faster * * @param string $type Can be forum|topic diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php index ff32e4447d..e1cffaf710 100644 --- a/phpBB/includes/functions_upload.php +++ b/phpBB/includes/functions_upload.php @@ -214,10 +214,11 @@ class filespec * The phpbb_root_path variable will be applied to the destination path * * @param string $destination_path Destination path, for example $config['avatar_path'] + * @param bool $overwrite If set to true, an already existing file will be overwritten * @param octal $chmod Permission mask for chmodding the file after a successful move * @access public */ - function move_file($destination, $chmod = 0666) + function move_file($destination, $overwrite = false, $chmod = 0666) { global $user, $phpbb_root_path; @@ -241,62 +242,64 @@ class filespec $this->destination_file = $this->destination_path . '/' . basename($this->realname); // Check if the file already exist, else there is something wrong... - if (file_exists($this->destination_file)) + if (file_exists($this->destination_file) && !$overwrite) { @unlink($this->filename); - return false; } - - switch ($upload_mode) + else { - case 'copy': + if (file_exists($this->destination_file)) + { + @unlink($this->destination_file); + } + + switch ($upload_mode) + { + case 'copy': + + if (!@copy($this->filename, $this->destination_file)) + { + if (!@move_uploaded_file($this->filename, $this->destination_file)) + { + $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file); + return false; + } + } + + @unlink($this->filename); + + break; + + case 'move': - if (!@copy($this->filename, $this->destination_file)) - { if (!@move_uploaded_file($this->filename, $this->destination_file)) { - $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file); - return false; + if (!@copy($this->filename, $this->destination_file)) + { + $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file); + return false; + } } - } - else - { + @unlink($this->filename); - } - break; + break; - case 'move': + case 'local': - if (!@move_uploaded_file($this->filename, $this->destination_file)) - { if (!@copy($this->filename, $this->destination_file)) { $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file); return false; } - else - { - @unlink($this->filename); - } - } - - break; - - case 'local': + @unlink($this->filename); - if (!@copy($this->filename, $this->destination_file)) - { - $this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file); - return false; - } - @unlink($this->filename); + break; + } - break; + @chmod($this->destination_file, $chmod); } - @chmod($this->destination_file, $chmod); - // Try to get real filesize from destination folder $this->filesize = (@filesize($this->destination_file)) ? @filesize($this->destination_file) : $this->filesize; diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 6cd35bfd7f..55725b2cfd 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1409,7 +1409,8 @@ function avatar_upload($data, &$error) $destination = ''; } - $file->move_file($destination); + // Move file and overwrite any existing image + $file->move_file($destination, true); if (sizeof($file->error)) { diff --git a/phpBB/includes/mcp/mcp_ban.php b/phpBB/includes/mcp/mcp_ban.php index 510943aa45..5a7240143a 100644 --- a/phpBB/includes/mcp/mcp_ban.php +++ b/phpBB/includes/mcp/mcp_ban.php @@ -104,8 +104,41 @@ class mcp_ban 'U_ACTION' => $this->u_action, 'U_FIND_USER' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=mcp_ban&field=ban'), - ) - ); + )); + + if ($mode != 'user') + { + return; + } + + // As a "service" we will check if any post id is specified and populate the username of the poster id if given + $post_id = request_var('p', 0); + $user_id = request_var('u', 0); + $username = false; + + if ($user_id && $user_id <> ANONYMOUS) + { + $sql = 'SELECT username + FROM ' . USERS_TABLE . ' + WHERE user_id = ' . $user_id; + $result = $db->sql_query($sql); + $username = (string) $db->sql_fetchfield('username'); + $db->sql_freeresult($result); + } + else if ($post_id) + { + $post_info = get_post_data($post_id, 'm_ban'); + + if (sizeof($post_info) && !empty($post_info[$post_id])) + { + $username = $post_info[$post_id]['username']; + } + } + + if ($username) + { + $template->assign_var('USERNAMES', $username); + } } } diff --git a/phpBB/includes/mcp/mcp_notes.php b/phpBB/includes/mcp/mcp_notes.php index 96fe1f9bd0..415290d3c5 100755 --- a/phpBB/includes/mcp/mcp_notes.php +++ b/phpBB/includes/mcp/mcp_notes.php @@ -131,6 +131,8 @@ class mcp_notes if ($usernote && $action == 'add_feedback') { add_log('admin', 'LOG_USER_FEEDBACK', $userrow['username']); + add_log('mod', 0, 0, 'LOG_USER_FEEDBACK', $userrow['username']); + add_log('user', $user_id, 'LOG_USER_GENERAL', $usernote); $redirect = $this->u_action . '&u=' . $user_id; diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php index cce30833ff..cc670ed417 100755 --- a/phpBB/includes/mcp/mcp_warn.php +++ b/phpBB/includes/mcp/mcp_warn.php @@ -207,22 +207,22 @@ function mcp_warn_post_view($id, $mode, $action) WHERE post_id = $post_id AND u.user_id = p.poster_id"; $result = $db->sql_query($sql); - $userrow = $db->sql_fetchrow($result); + $user_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - if (!$userrow) + if (!$user_row) { trigger_error($user->lang['NO_POST']); } // There is no point issuing a warning to ignored users (ie anonymous and bots) - if ($userrow['user_type'] == USER_IGNORE) + if ($user_row['user_type'] == USER_IGNORE) { trigger_error($user->lang['CANNOT_WARN_ANONYMOUS']); } // Prevent someone from warning themselves - if ($userrow['user_id'] == $user->data['user_id']) + if ($user_row['user_id'] == $user->data['user_id']) { trigger_error($user->lang['CANNOT_WARN_SELF']); } @@ -241,11 +241,11 @@ function mcp_warn_post_view($id, $mode, $action) trigger_error($user->lang['ALREADY_WARNED']); } - $user_id = $userrow['user_id']; + $user_id = $user_row['user_id']; if ($warning && $action == 'add_warning') { - add_warning($userrow, $warning, $notify, $post_id); + add_warning($user_row, $warning, $notify, $post_id); $redirect = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=notes&mode=user_notes&u=$user_id"); meta_refresh(2, $redirect); @@ -256,16 +256,16 @@ function mcp_warn_post_view($id, $mode, $action) // We want to make the message available here as a reminder // Parse the message and subject - $message = $userrow['post_text']; + $message = $user_row['post_text']; $message = str_replace("\n", '<br />', censor_text($message)); // Second parse bbcode here - if ($userrow['bbcode_bitfield']) + if ($user_row['bbcode_bitfield']) { include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx); - $bbcode = new bbcode($userrow['bbcode_bitfield']); - $bbcode->bbcode_second_pass($message, $userrow['bbcode_uid'], $userrow['bbcode_bitfield']); + $bbcode = new bbcode($user_row['bbcode_bitfield']); + $bbcode->bbcode_second_pass($message, $user_row['bbcode_uid'], $user_row['bbcode_bitfield']); } // Always process smilies after parsing bbcodes @@ -273,13 +273,13 @@ function mcp_warn_post_view($id, $mode, $action) // Generate the appropriate user information for the user we are looking at $rank_title = $rank_img = ''; -// get_user_rank($userrow['user_rank'], $userrow['user_posts'], $rank_title, $rank_img); +// get_user_rank($user_row['user_rank'], $user_row['user_posts'], $rank_title, $rank_img); $avatar_img = ''; - if (!empty($userrow['user_avatar'])) + if (!empty($user_row['user_avatar'])) { - switch ($userrow['user_avatar_type']) + switch ($user_row['user_avatar_type']) { case AVATAR_UPLOAD: $avatar_img = $config['avatar_path'] . '/'; @@ -290,19 +290,19 @@ function mcp_warn_post_view($id, $mode, $action) break; } - $avatar_img .= $userrow['user_avatar']; - $avatar_img = '<img src="' . $avatar_img . '" width="' . $userrow['user_avatar_width'] . '" height="' . $userrow['user_avatar_height'] . '" alt="" />'; + $avatar_img .= $user_row['user_avatar']; + $avatar_img = '<img src="' . $avatar_img . '" width="' . $user_row['user_avatar_width'] . '" height="' . $user_row['user_avatar_height'] . '" alt="" />'; } $template->assign_vars(array( 'U_POST_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&mode=$mode&p=$post_id"), 'POST' => $message, - 'USERNAME' => $userrow['username'], - 'USER_COLOR' => (!empty($userrow['user_colour'])) ? $userrow['user_colour'] : '', + 'USERNAME' => $user_row['username'], + 'USER_COLOR' => (!empty($user_row['user_colour'])) ? $user_row['user_colour'] : '', 'RANK_TITLE' => $rank_title, - 'JOINED' => $user->format_date($userrow['user_regdate']), - 'POSTS' => ($userrow['user_posts']) ? $userrow['user_posts'] : 0, + 'JOINED' => $user->format_date($user_row['user_regdate']), + 'POSTS' => ($user_row['user_posts']) ? $user_row['user_posts'] : 0, 'AVATAR_IMG' => $avatar_img, 'RANK_IMG' => $rank_img, @@ -331,25 +331,25 @@ function mcp_warn_user_view($id, $mode, $action) FROM ' . USERS_TABLE . ' WHERE ' . $sql_where; $result = $db->sql_query($sql); - $userrow = $db->sql_fetchrow($result); + $user_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - if (!$userrow) + if (!$user_row) { trigger_error('NO_USER'); } // Prevent someone from warning themselves - if ($userrow['user_id'] == $user->data['user_id']) + if ($user_row['user_id'] == $user->data['user_id']) { trigger_error($user->lang['CANNOT_WARN_SELF']); } - $user_id = $userrow['user_id']; + $user_id = $user_row['user_id']; if ($warning && $action == 'add_warning') { - add_warning($userrow, $warning, $notify); + add_warning($user_row, $warning, $notify); $redirect = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=notes&mode=user_notes&u=$user_id"); meta_refresh(2, $redirect); @@ -358,13 +358,13 @@ function mcp_warn_user_view($id, $mode, $action) // Generate the appropriate user information for the user we are looking at $rank_title = $rank_img = ''; -// get_user_rank($userrow['user_rank'], $userrow['user_posts'], $rank_title, $rank_img); +// get_user_rank($user_row['user_rank'], $user_row['user_posts'], $rank_title, $rank_img); $avatar_img = ''; - if (!empty($userrow['user_avatar'])) + if (!empty($user_row['user_avatar'])) { - switch ($userrow['user_avatar_type']) + switch ($user_row['user_avatar_type']) { case AVATAR_UPLOAD: $avatar_img = $config['avatar_path'] . '/'; @@ -375,20 +375,20 @@ function mcp_warn_user_view($id, $mode, $action) break; } - $avatar_img .= $userrow['user_avatar']; - $avatar_img = '<img src="' . $avatar_img . '" width="' . $userrow['user_avatar_width'] . '" height="' . $userrow['user_avatar_height'] . '" alt="" />'; + $avatar_img .= $user_row['user_avatar']; + $avatar_img = '<img src="' . $avatar_img . '" width="' . $user_row['user_avatar_width'] . '" height="' . $user_row['user_avatar_height'] . '" alt="" />'; } // OK, they didn't submit a warning so lets build the page for them to do so $template->assign_vars(array( 'U_POST_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&mode=$mode&u=$user_id"), - 'USERNAME' => $userrow['username'], - 'USER_COLOR' => (!empty($userrow['user_colour'])) ? $userrow['user_colour'] : '', + 'USERNAME' => $user_row['username'], + 'USER_COLOR' => (!empty($user_row['user_colour'])) ? $user_row['user_colour'] : '', 'RANK_TITLE' => $rank_title, - 'JOINED' => $user->format_date($userrow['user_regdate']), - 'POSTS' => ($userrow['user_posts']) ? $userrow['user_posts'] : 0, - 'WARNINGS' => ($userrow['user_warnings']) ? $userrow['user_warnings'] : 0, + 'JOINED' => $user->format_date($user_row['user_regdate']), + 'POSTS' => ($user_row['user_posts']) ? $user_row['user_posts'] : 0, + 'WARNINGS' => ($user_row['user_warnings']) ? $user_row['user_warnings'] : 0, 'AVATAR_IMG' => $avatar_img, 'RANK_IMG' => $rank_img, @@ -399,7 +399,7 @@ function mcp_warn_user_view($id, $mode, $action) /** * Insert the warning into the database */ -function add_warning($userrow, $warning, $send_pm = true, $post_id = 0) +function add_warning($user_row, $warning, $send_pm = true, $post_id = 0) { global $phpEx, $phpbb_root_path, $config; global $template, $db, $user, $auth; @@ -409,8 +409,8 @@ function add_warning($userrow, $warning, $send_pm = true, $post_id = 0) include_once($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx); include_once($phpbb_root_path . 'includes/message_parser.' . $phpEx); - $userrow['user_lang'] = (file_exists($phpbb_root_path . 'language/' . $userrow['user_lang'] . "/mcp.$phpEx")) ? $userrow['user_lang'] : $config['default_lang']; - include($phpbb_root_path . 'language/' . basename($userrow['user_lang']) . "/mcp.$phpEx"); + $user_row['user_lang'] = (file_exists($phpbb_root_path . 'language/' . $user_row['user_lang'] . "/mcp.$phpEx")) ? $user_row['user_lang'] : $config['default_lang']; + include($phpbb_root_path . 'language/' . basename($user_row['user_lang']) . "/mcp.$phpEx"); $message_parser = new parse_message(); @@ -429,17 +429,17 @@ function add_warning($userrow, $warning, $send_pm = true, $post_id = 0) 'bbcode_bitfield' => $message_parser->bbcode_bitfield, 'bbcode_uid' => $message_parser->bbcode_uid, 'message' => $message_parser->message, - 'address_list' => array('u' => array($userrow['user_id'] => 'to')), + 'address_list' => array('u' => array($user_row['user_id'] => 'to')), ); submit_pm('post', $lang['WARNING_PM_SUBJECT'], $pm_data, false, false); } - add_log('admin', 'LOG_USER_WARNING', $userrow['username']); - $log_id = add_log('user', $userrow['user_id'], 'LOG_USER_WARNING_BODY', $warning); + add_log('admin', 'LOG_USER_WARNING', $user_row['username']); + $log_id = add_log('user', $user_row['user_id'], 'LOG_USER_WARNING_BODY', $warning); $sql_ary = array( - 'user_id' => $userrow['user_id'], + 'user_id' => $user_row['user_id'], 'post_id' => $post_id, 'log_id' => $log_id, 'warning_time' => time(), @@ -450,8 +450,18 @@ function add_warning($userrow, $warning, $send_pm = true, $post_id = 0) $sql = 'UPDATE ' . USERS_TABLE . ' SET user_warnings = user_warnings + 1, user_last_warning = ' . time() . ' - WHERE user_id = ' . $userrow['user_id']; + WHERE user_id = ' . $user_row['user_id']; $db->sql_query($sql); + + // We add this to the mod log too for moderators to see that a specific user got warned. + $sql = 'SELECT forum_id, topic_id + FROM ' . POSTS_TABLE . ' + WHERE post_id = ' . $post_id; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + add_log('mod', $row['forum_id'], $row['topic_id'], 'LOG_USER_WARNING', $user_row['username']); } ?>
\ No newline at end of file |