1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-03-13 20:28:44 +01:00

- 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
This commit is contained in:
Meik Sievertsen 2006-12-21 10:37:50 +00:00
parent 2e1eef2713
commit 515085a2a2
11 changed files with 155 additions and 92 deletions

View File

@ -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));

View File

@ -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)))

View File

@ -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

View File

@ -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);
}
}
@unlink($this->filename);
break;
break;
}
case 'local':
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;
@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;

View File

@ -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))
{

View File

@ -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);
}
}
}

View File

@ -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 . '&amp;u=' . $user_id;

View File

@ -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&amp;mode=user_notes&amp;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&amp;mode=$mode&amp;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&amp;mode=user_notes&amp;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&amp;mode=$mode&amp;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']);
}
?>

View File

@ -449,7 +449,7 @@ $lang = array_merge($lang, array(
'LOG_FORK' => '<strong>Copied topic</strong><br />» from %s',
'LOG_LOCK' => '<strong>Locked topic</strong><br />» %s',
'LOG_LOCK_POST' => '<strong>Locked post</strong><br />» %s',
'LOG_MERGE' => '<strong>Merged posts</strong> into topic<br />»%s',
'LOG_MERGE' => '<strong>Merged posts</strong> into topic<br />» %s',
'LOG_MOVE' => '<strong>Moved topic</strong><br />» from %s',
'LOG_TOPIC_DELETED' => '<strong>Deleted topic</strong><br />» %s',
'LOG_TOPIC_RESYNC' => '<strong>Resynchronised topic counters</strong><br />» %s',
@ -622,8 +622,8 @@ $lang = array_merge($lang, array(
'LOG_USER_MOVE_POSTS_USER' => '<strong>Moved all posts to forum "%s"</strong>',
'LOG_USER_REACTIVATE_USER' => '<strong>Forced user account re-activation</strong>',
'LOG_USER_UNLOCK' => '<strong>User unlocked own topic</strong><br />» %s',
'LOG_USER_WARNING' => '<strong>Added user warning</strong><br />»%s',
'LOG_USER_WARNING_BODY' => '<strong>The following warning was issued to this user</strong><br />»%s',
'LOG_USER_WARNING' => '<strong>Added user warning</strong><br />» %s',
'LOG_USER_WARNING_BODY' => '<strong>The following warning was issued to this user</strong><br />» %s',
'LOG_USER_GROUP_CHANGE' => '<strong>User changed default group</strong><br />» %s',
'LOG_USER_GROUP_DEMOTE' => '<strong>User demoted as leaders from usergroup</strong><br />» %s',

View File

@ -227,24 +227,35 @@ $module->display($module->get_page_title(), false);
/**
* Functions used to generate additional URL paramters
*/
function _module_main_url($mode)
function _module__url($mode, &$module_row)
{
return extra_url();
}
function _module_logs_url($mode)
function _module_main_url($mode, &$module_row)
{
return extra_url();
}
function _module_logs_url($mode, &$module_row)
{
return extra_url();
}
function _module_ban_url($mode, &$module_row)
{
return extra_url();
}
function extra_url()
{
global $forum_id, $topic_id, $post_id;
global $forum_id, $topic_id, $post_id, $user_id;
$url_extra = '';
$url_extra .= ($forum_id) ? "&amp;f=$forum_id" : '';
$url_extra .= ($topic_id) ? "&amp;t=$topic_id" : '';
$url_extra .= ($post_id) ? "&amp;p=$post_id" : '';
$url_extra .= ($user_id) ? "&amp;u=$user_id" : '';
return $url_extra;
}

View File

@ -43,7 +43,7 @@
<tr>
<td class="row1" width="45%" valign="top"><b>{L_BAN_CELL}:</b></td>
<td class="row2">
<textarea name="ban" id="ban" cols="40" rows="3" class="post"></textarea>
<textarea name="ban" id="ban" cols="40" rows="3" class="post">{USERNAMES}</textarea>
<!-- IF S_USERNAME_BAN --><br />[ <a href="#" onclick="window.open('{U_FIND_USER}', '_phpbbsearch', 'height=500, resizable=yes, scrollbars=yes, width=740'); return false;">{L_FIND_USERNAME}</a> ]<!-- ENDIF -->
</td>
</tr>