diff options
| author | Paul S. Owen <psotfx@users.sourceforge.net> | 2004-02-26 18:14:18 +0000 |
|---|---|---|
| committer | Paul S. Owen <psotfx@users.sourceforge.net> | 2004-02-26 18:14:18 +0000 |
| commit | dbf93ce5aabdcbf3190e2d414cf54bbb57fc760a (patch) | |
| tree | ea5c1dacc1e723f17e5f31e29aac6994967001c5 | |
| parent | 114fa416d911a7970793e9c30e16114f6c46e75d (diff) | |
| download | forums-dbf93ce5aabdcbf3190e2d414cf54bbb57fc760a.tar forums-dbf93ce5aabdcbf3190e2d414cf54bbb57fc760a.tar.gz forums-dbf93ce5aabdcbf3190e2d414cf54bbb57fc760a.tar.bz2 forums-dbf93ce5aabdcbf3190e2d414cf54bbb57fc760a.tar.xz forums-dbf93ce5aabdcbf3190e2d414cf54bbb57fc760a.zip | |
Group and other updates
git-svn-id: file:///svn/phpbb/trunk@4841 89ea8834-ac86-4346-8a33-228a782c2dd0
| -rw-r--r-- | phpBB/adm/admin_users.php | 1918 |
1 files changed, 1047 insertions, 871 deletions
diff --git a/phpBB/adm/admin_users.php b/phpBB/adm/admin_users.php index 9cefdaeb78..cf5186c45b 100644 --- a/phpBB/adm/admin_users.php +++ b/phpBB/adm/admin_users.php @@ -34,11 +34,14 @@ include($phpbb_root_path.'includes/functions_profile_fields.'.$phpEx); // // Get and set basic vars // -$mode = request_var('mode', ''); -$action = request_var('action', 'overview'); -$start = request_var('start', 0); +$mode = request_var('mode', 'overview'); +$action = request_var('action', ''); + $username = request_var('username', ''); $user_id = request_var('u', 0); +$gid = request_var('g', 0); + +$start = request_var('start', 0); $ip = request_var('ip', ''); $start = request_var('start', 0); $delete = request_var('delete', ''); @@ -46,6 +49,10 @@ $deletetype = request_var('deletetype', ''); $marked = request_var('mark', 0); $quicktools = request_var('quicktools', ''); +$st = request_var('st', 0); +$sk = request_var('sk', 'a'); +$sd = request_var('sd', 'd'); + $submit = (isset($_POST['update'])) ? true : false; $confirm = (isset($_POST['confirm'])) ? true : false; $cancel = (isset($_POST['cancel'])) ? true : false; @@ -54,6 +61,7 @@ $deletemark = (isset($_POST['delmarked'])) ? true : false; $deleteall = (isset($_POST['delall'])) ? true : false; $error = array(); +$colspan = 0; // // Whois output @@ -100,7 +108,7 @@ if ($username || $user_id) { $session_time = 0; $sql_where = ($user_id) ? "user_id = $user_id" : "username = '" . $db->sql_escape($username) . "'"; - $sql = ($action == 'overview') ? 'SELECT u.*, s.session_time, s.session_page, s.session_ip FROM (' . USERS_TABLE . ' u LEFT JOIN ' . SESSIONS_TABLE . " s ON s.session_user_id = u.user_id) WHERE u.$sql_where ORDER BY s.session_time DESC LIMIT 1" : 'SELECT * FROM ' . USERS_TABLE . " WHERE $sql_where"; + $sql = ($action == 'overview') ? 'SELECT u.*, s.session_time, s.session_page, s.session_ip FROM (' . USERS_TABLE . ' u LEFT JOIN ' . SESSIONS_TABLE . " s ON s.session_user_id = u.user_id) WHERE u.$sql_where ORDER BY s.session_time DESC" : 'SELECT * FROM ' . USERS_TABLE . " WHERE $sql_where"; $result = $db->sql_query($sql); if (!extract($db->sql_fetchrow($result))) @@ -121,150 +129,223 @@ if ($username || $user_id) // Output page adm_page_header($user->lang['MANAGE']); + // -// User has submitted a form, process it +// Output forms // -if ($submit || $preview || $deleteall || $deletemark) + +// Begin program +if ($username || $user_id) { - switch ($action) + // Generate overall "header" for user admin + $form_options = ''; + $forms_ary = array('overview' => 'OVERVIEW', 'feedback' => 'FEEDBACK', 'profile' => 'PROFILE', 'prefs' => 'PREFS', 'avatar' => 'AVATAR', 'sig' => 'SIG', 'groups' => 'GROUP', 'perm' => 'PERM', 'attach' => 'ATTACH'); + + foreach ($forms_ary as $value => $lang) + { + $selected = ($mode == $value) ? ' selected="selected"' : ''; + $form_options .= '<option value="' . $value . '"' . $selected . '>' . $user->lang['USER_ADMIN_' . $lang] . '</option>'; + } + + $pagination = ''; + +?> + +<script language="javascript" type="text/javascript"> +<!-- + +var form_name = 'admin'; +var text_name = 'signature'; + +// Define the bbCode tags +bbcode = new Array(); +bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','[/code]','[list]','[/list]','[list=]','[/list]','[img]','[/img]','[url]','[/url]'); +imageTag = false; + +// Helpline messages +b_help = "<?php echo $user->lang['BBCODE_B_HELP']; ?>"; +i_help = "<?php echo $user->lang['BBCODE_I_HELP']; ?>"; +u_help = "<?php echo $user->lang['BBCODE_U_HELP']; ?>"; +q_help = "<?php echo $user->lang['BBCODE_Q_HELP']; ?>"; +c_help = "<?php echo $user->lang['BBCODE_C_HELP']; ?>"; +l_help = "<?php echo $user->lang['BBCODE_L_HELP']; ?>"; +o_help = "<?php echo $user->lang['BBCODE_O_HELP']; ?>"; +p_help = "<?php echo $user->lang['BBCODE_P_HELP']; ?>"; +w_help = "<?php echo $user->lang['BBCODE_W_HELP']; ?>"; +a_help = "<?php echo $user->lang['BBCODE_A_HELP']; ?>"; +s_help = "<?php echo $user->lang['BBCODE_S_HELP']; ?>"; +f_help = "<?php echo $user->lang['BBCODE_F_HELP']; ?>"; +e_help = "<?php echo $user->lang['BBCODE_E_HELP']; ?>"; + +//--> +</script> +<script language="javascript" type="text/javascript" src="editor.js"></script> + +<h1><?php echo $user->lang['USER_ADMIN']; ?></h1> + +<p><?php echo $user->lang['USER_ADMIN_EXPLAIN']; ?></p> + +<form method="post" name="admin" action="<?php echo "admin_users.$phpEx$SID&mode=$mode&u=$user_id"; ?>"<?php echo ($file_uploads) ? ' enctype="multipart/form-data"' : ''; ?>><table width="100%" cellspacing="2" cellpadding="0" border="0" align="center"> + <tr> + <td align="right"><?php echo $user->lang['SELECT_FORM']; ?>: <select name="mode" onchange="if (this.options[this.selectedIndex].value != '') this.form.submit();"><?php echo $form_options; ?></select></td> + </tr> + <tr> + <td><table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0"> +<?php + + if (sizeof($error)) + { + +?> + <tr> + <td class="row3" colspan="" align="center"><span class="error"><?php echo implode('<br />', $error); ?></span></td> + </tr> +<?php + + } + + + switch ($mode) { case 'overview': - if ($delete && $user_type != USER_FOUNDER) + if ($submit) { - if (!$auth->acl_get('a_userdel')) + if ($delete && $user_type != USER_FOUNDER) { - trigger_error($user->lang['NO_ADMIN']); - } + if (!$auth->acl_get('a_userdel')) + { + trigger_error($user->lang['NO_ADMIN']); + } - if (!$cancel && !$confirm) - { - adm_page_confirm($user->lang['CONFIRM'], $user->lang['CONFIRM_OPERATION']); - } - else if (!$cancel) - { - user_delete($deletetype, $user_id); + if (!$cancel && !$confirm) + { + adm_page_confirm($user->lang['CONFIRM'], $user->lang['CONFIRM_OPERATION']); + } + else if (!$cancel) + { + user_delete($deletetype, $user_id); - add_log('admin', 'LOG_USER_DELETED', $username); - trigger_error($user->lang['USER_DELETED']); + add_log('admin', 'LOG_USER_DELETED', $username); + trigger_error($user->lang['USER_DELETED']); + } } - } - // Handle quicktool actions - if ($quicktools && $user_type != USER_FOUNDER) - { - switch ($quicktools) + // Handle quicktool actions + if ($quicktools && $user_type != USER_FOUNDER) { - case 'banuser': - case 'banemail': - case 'banip': - $ban = array(); - - switch ($quicktools) - { - case 'banuser': - $ban[] = $username; - $reason = 'USER_ADMIN_BAN_NAME_REASON'; - $log = 'LOG_BAN_USERNAME_USER'; - break; - - case 'banemail': - $ban[] = $user_email; - $reason = 'USER_ADMIN_BAN_EMAIL_REASON'; - $log = 'LOG_BAN_EMAIL_USER'; - break; - - case 'banip': - $ban[] = $user_ip; - - $sql = 'SELECT DISTINCT poster_ip - FROM ' . POSTS_TABLE . " - WHERE poster_id = $user_id"; - $result = $db->sql_query($sql); + switch ($quicktools) + { + case 'banuser': + case 'banemail': + case 'banip': + $ban = array(); - while ($row = $db->sql_fetchrow($result)) - { - $ban[] = $row['poster_ip']; - } - $db->sql_freeresult($result); + switch ($quicktools) + { + case 'banuser': + $ban[] = $username; + $reason = 'USER_ADMIN_BAN_NAME_REASON'; + $log = 'LOG_BAN_USERNAME_USER'; + break; + + case 'banemail': + $ban[] = $user_email; + $reason = 'USER_ADMIN_BAN_EMAIL_REASON'; + $log = 'LOG_BAN_EMAIL_USER'; + break; + + case 'banip': + $ban[] = $user_ip; + + $sql = 'SELECT DISTINCT poster_ip + FROM ' . POSTS_TABLE . " + WHERE poster_id = $user_id"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $ban[] = $row['poster_ip']; + } + $db->sql_freeresult($result); - $reason = 'USER_ADMIN_BAN_IP_REASON'; - $log = 'LOG_BAN_IP_USER'; - break; - } + $reason = 'USER_ADMIN_BAN_IP_REASON'; + $log = 'LOG_BAN_IP_USER'; + break; + } - user_ban(substr($quicktools, 3), $ban, 0, 0, 0, $user->lang[$reason]); + user_ban(substr($quicktools, 3), $ban, 0, 0, 0, $user->lang[$reason]); - add_log('user', $user_id, $log); + add_log('user', $user_id, $log); - trigger_error($user->lang['BAN_UPDATE_SUCESSFUL']); + trigger_error($user->lang['BAN_UPDATE_SUCESSFUL']); - break; + break; - case 'reactivate': + case 'reactivate': - if ($config['email_enable']) - { - include_once($phpbb_root_path . 'includes/functions_messenger.'.$phpEx); + if ($config['email_enable']) + { + include_once($phpbb_root_path . 'includes/functions_messenger.'.$phpEx); - $user_actkey = gen_rand_string(10); - $key_len = 54 - (strlen($server_url)); - $key_len = ($key_len > 6) ? $key_len : 6; - $user_actkey = substr($user_actkey, 0, $key_len); + $user_actkey = gen_rand_string(10); + $key_len = 54 - (strlen($server_url)); + $key_len = ($key_len > 6) ? $key_len : 6; + $user_actkey = substr($user_actkey, 0, $key_len); - user_active_flip($user_id, $user_type, $user_actkey, $username); + user_active_flip($user_id, $user_type, $user_actkey, $username); - $messenger = new messenger(); + $messenger = new messenger(); - $messenger->template('user_welcome_inactive', $user_lang); - $messenger->subject(); + $messenger->template('user_welcome_inactive', $user_lang); + $messenger->subject(); - $messenger->replyto($config['board_contact']); - $messenger->to($user_email, $username); + $messenger->replyto($config['board_contact']); + $messenger->to($user_email, $username); - $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']); - $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']); - $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']); - $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip); + $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']); + $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']); + $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']); + $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip); - $messenger->assign_vars(array( - 'SITENAME' => $config['sitename'], - 'WELCOME_MSG' => sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename']), - 'USERNAME' => $username, - 'PASSWORD' => $password_confirm, - 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']), + $messenger->assign_vars(array( + 'SITENAME' => $config['sitename'], + 'WELCOME_MSG' => sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename']), + 'USERNAME' => $username, + 'PASSWORD' => $password_confirm, + 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']), - 'U_ACTIVATE' => generate_board_url() . "/ucp.$phpEx?mode=activate&u=$user_id&k=$user_actkey") - ); + 'U_ACTIVATE' => generate_board_url() . "/ucp.$phpEx?mode=activate&u=$user_id&k=$user_actkey") + ); - $messenger->send(NOTIFY_EMAIL); - $messenger->queue->save(); + $messenger->send(NOTIFY_EMAIL); + $messenger->queue->save(); - add_log('admin', 'LOG_USER_REACTIVATE', $username); - add_log('user', $user_id, 'LOG_USER_REACTIVATE_USER'); + add_log('admin', 'LOG_USER_REACTIVATE', $username); + add_log('user', $user_id, 'LOG_USER_REACTIVATE_USER'); - trigger_error($user->lang['USER_ADMIN_REACTIVATE']); - } + trigger_error($user->lang['USER_ADMIN_REACTIVATE']); + } - break; + break; - case 'active': + case 'active': - user_active_flip($user_id, $user_type, false, $username); + user_active_flip($user_id, $user_type, false, $username); - $message = ($user_type == USER_NORMAL) ? 'USER_ADMIN_INACTIVE' : 'USER_ADMIN_ACTIVE'; - $log = ($user_type == USER_NORMAL) ? 'LOG_USER_INACTIVE' : 'LOG_USER_ACTIVE'; + $message = ($user_type == USER_NORMAL) ? 'USER_ADMIN_INACTIVE' : 'USER_ADMIN_ACTIVE'; + $log = ($user_type == USER_NORMAL) ? 'LOG_USER_INACTIVE' : 'LOG_USER_ACTIVE'; - add_log('admin', $log, $username); - add_log('user', $user_id, $log . '_USER'); + add_log('admin', $log, $username); + add_log('user', $user_id, $log . '_USER'); - trigger_error($user->lang[$message]); - break; + trigger_error($user->lang[$message]); + break; - case 'moveposts': + case 'moveposts': - if (!($new_forum_id = request_var('new_f', 0))) - { + if (!($new_forum_id = request_var('new_f', 0))) + { ?> @@ -279,7 +360,7 @@ if ($submit || $preview || $deleteall || $deletemark) <tr> <td class="row2" align="center" valign="middle"><?php echo $user->lang['MOVE_POSTS_EXPLAIN']; ?><br /><br /><select name="new_f"><?php - echo make_forum_select(false, false, false, true); + echo make_forum_select(false, false, false, true); ?></select> </td> </tr> @@ -289,706 +370,230 @@ if ($submit || $preview || $deleteall || $deletemark) </table> <?php - adm_page_footer(); - } - else - { - // Two stage? - // Move topics comprising only posts from this user - $topic_id_ary = array(); - $forum_id_ary = array($new_forum_id); - - $sql = 'SELECT topic_id, COUNT(post_id) AS total_posts - FROM ' . POSTS_TABLE . " - WHERE poster_id = $user_id - AND forum_id <> $new_forum_id - GROUP BY topic_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $topic_id_ary[$row['topic_id']] = $row['total_posts']; + adm_page_footer(); } - $db->sql_freeresult($result); + else + { + // Two stage? + // Move topics comprising only posts from this user + $topic_id_ary = array(); + $forum_id_ary = array($new_forum_id); - $sql = 'SELECT topic_id, forum_id, topic_title, topic_replies, topic_replies_real - FROM ' . TOPICS_TABLE . ' - WHERE topic_id IN (' . implode(', ', array_keys($topic_id_ary)) . ')'; - $result = $db->sql_query($sql); + $sql = 'SELECT topic_id, COUNT(post_id) AS total_posts + FROM ' . POSTS_TABLE . " + WHERE poster_id = $user_id + AND forum_id <> $new_forum_id + GROUP BY topic_id"; + $result = $db->sql_query($sql); - $move_topic_ary = $move_post_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - if (max($row['topic_replies'], $row['topic_replies_real']) + 1 == $topic_id_ary[$row['topic_id']]) - { - $move_topic_ary[] = $row['topic_id']; - } - else + while ($row = $db->sql_fetchrow($result)) { - $move_post_ary[$row['topic_id']]['title'] = $row['topic_title']; - $move_post_ary[$row['topic_id']]['attach'] = ($row['attach']) ? 1 : 0; + $topic_id_ary[$row['topic_id']] = $row['total_posts']; } + $db->sql_freeresult($result); - $forum_id_ary[] = $row['forum_id']; - } - $db->sql_freeresult($result); - - // Entire topic comprises posts by this user, move these topics - if (sizeof($move_topic_ary)) - { - move_topics($move_topic_ary, $new_forum_id, false); - } + $sql = 'SELECT topic_id, forum_id, topic_title, topic_replies, topic_replies_real + FROM ' . TOPICS_TABLE . ' + WHERE topic_id IN (' . implode(', ', array_keys($topic_id_ary)) . ')'; + $result = $db->sql_query($sql); - if (sizeof($move_post_ary)) - { - // Create new topic - // Update post_ids, report_ids, attachment_ids - foreach ($move_post_ary as $topic_id => $post_ary) + $move_topic_ary = $move_post_ary = array(); + while ($row = $db->sql_fetchrow($result)) { - // Create new topic - $sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', array( - 'topic_poster' => $user_id, - 'topic_time' => time(), - 'forum_id' => $new_forum_id, - 'icon_id' => 0, - 'topic_approved' => 1, - 'topic_title' => $post_ary['title'], - 'topic_first_poster_name' => $username, - 'topic_type' => POST_NORMAL, - 'topic_time_limit' => 0, - 'topic_attachment' => $post_ary['attach'],) - ); - $db->sql_query($sql); - - $new_topic_id = $db->sql_nextid(); - - // Move posts - $sql = 'UPDATE ' . POSTS_TABLE . " - SET forum_id = $new_forum_id, topic_id = $new_topic_id - WHERE topic_id = $topic_id - AND poster_id = $user_id"; - $db->sql_query($sql); - - if ($post_ary['attach']) + if (max($row['topic_replies'], $row['topic_replies_real']) + 1 == $topic_id_ary[$row['topic_id']]) { - $sql = 'UPDATE ' . ATTACHMENTS_TABLE . " - SET topic_id = $new_topic_id - WHERE topic_id = $topic_id - AND poster_id = $user_id"; - $db->sql_query($sql); + $move_topic_ary[] = $row['topic_id']; + } + else + { + $move_post_ary[$row['topic_id']]['title'] = $row['topic_title']; + $move_post_ary[$row['topic_id']]['attach'] = ($row['attach']) ? 1 : 0; } - $new_topic_id_ary[] = $new_topic_id; + $forum_id_ary[] = $row['forum_id']; } - } - - $forum_id_ary = array_unique($forum_id_ary); - $topic_id_ary = array_unique(array_merge($topic_id_ary, $new_topic_id_ary)); + $db->sql_freeresult($result); - sync('reported', 'topic_id', $topic_id_ary); - sync('topic', 'topic_id', $topic_id_ary); - sync('forum', 'forum_id', $forum_id_ary); - } + // Entire topic comprises posts by this user, move these topics + if (sizeof($move_topic_ary)) + { + move_topics($move_topic_ary, $new_forum_id, false); + } - break; - } + if (sizeof($move_post_ary)) + { + // Create new topic + // Update post_ids, report_ids, attachment_ids + foreach ($move_post_ary as $topic_id => $post_ary) + { + // Create new topic + $sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', array( + 'topic_poster' => $user_id, + 'topic_time' => time(), + 'forum_id' => $new_forum_id, + 'icon_id' => 0, + 'topic_approved' => 1, + 'topic_title' => $post_ary['title'], + 'topic_first_poster_name' => $username, + 'topic_type' => POST_NORMAL, + 'topic_time_limit' => 0, + 'topic_attachment' => $post_ary['attach'],) + ); + $db->sql_query($sql); - $sql = 'SELECT forum_name - FROM ' . TOPICS_TABLE . " - WHERE topic_id = $new_forum_id"; - $result = $db->sql_query($sql); + $new_topic_id = $db->sql_nextid(); - extract($db->sql_fetchrow($result)); - $db->sql_freeresult($result); + // Move posts + $sql = 'UPDATE ' . POSTS_TABLE . " + SET forum_id = $new_forum_id, topic_id = $new_topic_id + WHERE topic_id = $topic_id + AND poster_id = $user_id"; + $db->sql_query($sql); - add_log('admin', 'LOG_USER_MOVE_POSTS', $forum_name, $username); - add_log('user', $user_id, 'LOG_USER_MOVE_POSTS_USER', $forum_name); + if ($post_ary['attach']) + { + $sql = 'UPDATE ' . ATTACHMENTS_TABLE . " + SET topic_id = $new_topic_id + WHERE topic_id = $topic_id + AND poster_id = $user_id"; + $db->sql_query($sql); + } - trigger_error($user->lang['USER_ADMIN_MOVE']); - } + $new_topic_id_ary[] = $new_topic_id; + } + } - // Handle registration info updates - $var_ary = array( - 'username' => (string) $username, - 'user_founder' => (int) $user_founder, - 'user_type' => (int) $user_type, - 'user_email' => (string) $user_email, - 'email_confirm' => (string) '', - 'user_password' => (string) '', - 'password_confirm' => (string) '', - 'user_warnings' => (int) $user_warnings, - ); - - foreach ($var_ary as $var => $default) - { - $data[$var] = request_var($var, $default); - } + $forum_id_ary = array_unique($forum_id_ary); + $topic_id_ary = array_unique(array_merge($topic_id_ary, $new_topic_id_ary)); - $var_ary = array( - 'password_confirm' => array('string', true, $config['min_pass_chars'], $config['max_pass_chars']), - 'user_password' => array('string', true, $config['min_pass_chars'], $config['max_pass_chars']), - 'user_email' => array( - array('string', false, 6, 60), - array('email', $email)), - 'email_confirm' => array('string', true, 6, 60), - 'user_warnings' => array('num', 0, $config['max_warnings']), - ); - - // Check username if altered - if ($username != $data['username']) - { - $var_ary += array( - 'username' => array( - array('string', false, $config['min_name_chars'], $config['max_name_chars']), - array('username', $username)), - ); - } + sync('reported', 'topic_id', $topic_id_ary); + sync('topic', 'topic_id', $topic_id_ary); + sync('forum', 'forum_id', $forum_id_ary); + } - $error = validate_data($data, $var_ary); + break; + } - if ($data['user_password'] && $data['password_confirm'] != $data['user_password']) - { - $error[] = 'NEW_PASSWORD_ERROR'; - } + $sql = 'SELECT forum_name + FROM ' . TOPICS_TABLE . " + WHERE topic_id = $new_forum_id"; + $result = $db->sql_query($sql); - if ($user_email != $data['user_email'] && $data['email_confirm'] != $data['user_email']) - { - $error[] = 'NEW_EMAIL_ERROR'; - } + extract($db->sql_fetchrow($result)); + $db->sql_freeresult($result); - // Which updates do we need to do? - $update_warning = ($user_warnings != $data['user_warnings']) ? true : false; - $update_username = ($username != $data['username']) ? $username : false; - $update_password = ($user_password != $data['user_password']) ? true : false; + add_log('admin', 'LOG_USER_MOVE_POSTS', $forum_name, $username); + add_log('user', $user_id, 'LOG_USER_MOVE_POSTS_USER', $forum_name); - extract($data); - unset($data); + trigger_error($user->lang['USER_ADMIN_MOVE']); + } - if (!sizeof($error)) - { - $sql_ary = array( - 'username' => $username, - 'user_founder' => $user_founder, - 'user_email' => $user_email, - 'user_email_hash' => crc32(strtolower($user_email)) . strlen($user_email), - 'user_warnings' => $user_warnings, + // Handle registration info updates + $var_ary = array( + 'username' => (string) $username, + 'user_founder' => (int) $user_founder, + 'user_type' => (int) $user_type, + 'user_email' => (string) $user_email, + 'email_confirm' => (string) '', + 'user_password' => (string) '', + 'password_confirm' => (string) '', + 'user_warnings' => (int) $user_warnings, ); - if ($update_password) + foreach ($var_ary as $var => $default) { - $sql_ary += array( - 'user_password' => md5($user_password), - 'user_passchg' => time(), - ); + $data[$var] = request_var($var, $default); } - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE user_id = ' . $user->data['user_id']; - $db->sql_query($sql); + $var_ary = array( + 'password_confirm' => array('string', true, $config['min_pass_chars'], $config['max_pass_chars']), + 'user_password' => array('string', true, $config['min_pass_chars'], $config['max_pass_chars']), + 'user_email' => array( + array('string', false, 6, 60), + array('email', $email)), + 'email_confirm' => array('string', true, 6, 60), + 'user_warnings' => array('num', 0, $config['max_warnings']), + ); - // TODO - if ($update_warning) + // Check username if altered + if ($username != $data['username']) { + $var_ary += array( + 'username' => array( + array('string', false, $config['min_name_chars'], $config['max_name_chars']), + array('username', $username)), + ); } - if ($update_username) - { - user_update_name($update_username, $username); - } + $error = validate_data($data, $var_ary); - trigger_error($user->lang['USER_OVERVIEW_UPDATED']); - } - - // Replace "error" strings with their real, localised form - $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); - - break; - - case 'feedback': - - if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs')) - { - $where_sql = ''; - if ($deletemark && $marked) + if ($data['user_password'] && $data['password_confirm'] != $data['user_password']) { - $sql_in = array(); - foreach ($marked as $mark) - { - $sql_in[] = $mark; - } - $where_sql = ' AND log_id IN (' . implode(', ', $sql_in) . ')'; - unset($sql_in); + $error[] = 'NEW_PASSWORD_ERROR'; } - $sql = 'DELETE FROM ' . LOG_TABLE . ' - WHERE log_type = ' . LOG_USERS . " - $where_sql"; - $db->sql_query($sql); - - add_log('admin', 'LOG_USERS_CLEAR'); - trigger_error(""); - } - - if ($message = request_var('message', '')) - { - add_log('admin', 'LOG_USER_FEEDBACK', $username); - add_log('user', $user_id, 'LOG_USER_GENERAL', $message); - - trigger_error($user->lang['USER_FEEDBACK_ADDED']); - } - - break; - - case 'profile': - - $var_ary = array( - 'icq' => (string) '', - 'aim' => (string) '', - 'msn' => (string) '', - 'yim' => (string) '', - 'jabber' => (string) '', - 'website' => (string) '', - 'location' => (string) '', - 'occupation' => (string) '', - 'interests' => (string) '', - 'bday_day' => 0, - 'bday_month' => 0, - 'bday_year' => 0, - ); - - foreach ($var_ary as $var => $default) - { - $data[$var] = request_var($var, $default); - } - - $var_ary = array( - 'icq' => array( - array('string', true, 3, 15), - array('match', true, '#^[0-9]+$#i')), - 'aim' => array('string', true, 5, 255), - 'msn' => array('string', true, 5, 255), - 'jabber' => array( - array('string', true, 5, 255), - array('match', true, '#^[a-z0-9\.\-_\+]+?@(.*?\.)*?[a-z0-9\-_]+?\.[a-z]{2,4}(/.*)?$#i')), - 'yim' => array('string', true, 5, 255), - 'website' => array( - array('string', true, 12, 255), - array('match', true, '#^http[s]?://(.*?\.)*?[a-z0-9\-]+\.[a-z]{2,4}#i')), - 'location' => array('string', true, 2, 255), - 'occupation' => array('string', true, 2, 500), - 'interests' => array('string', true, 2, 500), - 'bday_day' => array('num', true, 1, 31), - 'bday_month' => array('num', true, 1, 12), - 'bday_year' => array('num', true, 1901, gmdate('Y', time())), - ); - - $error = validate_data($data, $var_ary); - extract($data); - unset($data); - - // validate custom profile fields -// $cp->submit_cp_field('profile', $cp_data, $cp_error); - - if (!sizeof($error) && !sizeof($cp_error)) - { - $sql_ary = array( - 'user_icq' => $icq, - 'user_aim' => $aim, - 'user_msnm' => $msn, - 'user_yim' => $yim, - 'user_jabber' => $jabber, - 'user_website' => $website, - 'user_from' => $location, - 'user_occ' => $occupation, - 'user_interests'=> $interests, - 'user_birthday' => sprintf('%2d-%2d-%4d', $bday_day, $bday_month, $bday_year), - ); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " - WHERE user_id = $user_id"; - $db->sql_query($sql); - -/* - // Update Custom Fields - if (sizeof($cp_data)) + if ($user_email != $data['user_email'] && $data['email_confirm'] != $data['user_email']) { - $sql = 'UPDATE ' . CUSTOM_PROFILE_DATA . ' - SET ' . $db->sql_build_array('UPDATE', $cp_data) . " - WHERE user_id = $user_id"; - $db->sql_query($sql); - - if (!$db->sql_affectedrows()) - { - $cp_data['user_id'] = $user_id; - - $db->return_on_error = true; - - $sql = 'INSERT INTO ' . 'phpbb_profile_fields_data' . ' ' . $db->sql_build_array('INSERT', $cp_data); - $db->sql_query(); - - $db->return_on_error = false; - } + $error[] = 'NEW_EMAIL_ERROR'; } -*/ - trigger_error($user->lang['USER_PROFILE_UPDATED']); - } - - break; - - case 'prefs': - - $var_ary = array( - 'user_dateformat' => (string) $config['default_dateformat'], - 'user_lang' => (string) $config['default_lang'], - 'user_tz' => (float) $config['board_timezone'], - 'user_style' => (int) $config['default_style'], - 'user_dst' => (bool) $config['board_dst'], - 'user_allow_viewemail' => false, - 'user_allow_massemail' => true, - 'user_allow_viewonline' => true, - 'user_notify_type' => 0, - 'user_notify_pm' => true, - 'user_allow_pm' => true, - 'user_notify' => false, - 'user_min_karma' => (int) -5, - - 'sk' => (string) 't', - 'sd' => (string) 'd', - 'st' => 0, - - 'popuppm' => false, - 'viewimg' => true, - 'viewflash' => false, - 'viewsmilies' => true, - 'viewsigs' => true, - 'viewavatars' => true, - 'viewcensors' => false, - 'bbcode' => true, - 'html' => false, - 'smile' => true, - 'attachsig' => true, - ); - - foreach ($var_ary as $var => $default) - { - $data[$var] = request_var($var, $default); - } - - $var_ary = array( - 'user_dateformat' => array('string', false, 3, 15), - 'user_lang' => array('match', false, '#^[a-z_]{2,}$#i'), - 'user_tz' => array('num', false, -13, 13), - 'user_min_karma' => array('num', false, -5, 5), - - 'sk' => array('string', false, 1, 1), - 'sd' => array('string', false, 1, 1), - ); - - $error = validate_data($data, $var_ary); - extract($data); - unset($data); - - // Set the popuppm option - $user_options = $user->optionset('popuppm', $popuppm, $user_options); - $user_options = $user->optionset('viewimg', $viewimg, $user_options); - $user_options = $user->optionset('viewflash', $viewflash, $user_options); - $user_options = $user->optionset('viewsmilies', $viewsmilies, $user_options); - $user_options = $user->optionset('viewsigs', $viewsigs, $user_options); - $user_options = $user->optionset('viewavatars', $viewavatars, $user_options); - $user_options = $user->optionset('viewcensors', $viewcensors, $user_options); - $user_options = $user->optionset('bbcode', $bbcode, $user_options); - $user_options = $user->optionset('html', $html, $user_options); - $user_options = $user->optionset('smile', $smile, $user_options); - $user_options = $user->optionset('attachsig', $attachsig, $user_options); - - if (!sizeof($error)) - { - $sql_ary = array( - 'user_allow_pm' => $user_allow_pm, - 'user_allow_viewemail' => $user_allow_viewemail, - 'user_allow_massemail' => $user_allow_massemail, - 'user_allow_viewonline' => $user_allow_viewonline, - 'user_notify_type' => $user_notify_type, - 'user_notify_pm' => $user_notify_pm, - 'user_options' => $user_options, - 'user_notify' => $user_notify, - 'user_min_karma' => $user_min_karma, - 'user_dst' => $user_dst, - 'user_dateformat' => $user_dateformat, - 'user_lang' => $user_lang, - 'user_timezone' => $user_tz, - 'user_style' => $user_style, - 'user_sortby_type' => $sk, - 'user_sortby_dir' => $sd, - 'user_show_days' => $st, - ); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " - WHERE user_id = $user_id"; - $db->sql_query($sql); - trigger_error($user->lang['USER_PREFS_UPDATED']); - } - - $user_sortby_type = $sk; - $user_sortby_dir = $sd; - $user_show_days = $st; - break; - - case 'avatar': - - $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && is_writeable($phpbb_root_path . $config['avatar_path']) && $file_uploads) ? true : false; - - $var_ary = array( - 'uploadurl' => (string) '', - 'remotelink' => (string) '', - 'width' => (string) '', - 'height' => (string) '', - ); - - foreach ($var_ary as $var => $default) - { - $data[$var] = request_var($var, $default); - } + // Which updates do we need to do? + $update_warning = ($user_warnings != $data['user_warnings']) ? true : false; + $update_username = ($username != $data['username']) ? $username : false; + $update_password = ($user_password != $data['user_password']) ? true : false; - $var_ary = array( - 'uploadurl' => array('string', true, 5, 255), - 'remotelink' => array('string', true, 5, 255), - 'width' => array('string', true, 1, 3), - 'height' => array('string', true, 1, 3), - ); + extract($data); + unset($data); - $error = validate_data($data, $var_ary); - - if (!sizeof($error)) - { - $data['user_id'] = $user_id; - - if ((!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl']) && $can_upload) - { - list($type, $filename, $width, $height) = avatar_upload($data, $error); - } - else if ($data['remotelink']) - { - list($type, $filename, $width, $height) = avatar_remote($data, $error); - } - else if ($delete) - { - $type = $filename = $width = $height = ''; - } - } - - if (!sizeof($error)) - { - // Do we actually have any data to update? - if (sizeof($data)) + if (!sizeof($error)) { $sql_ary = array( - 'user_avatar' => $filename, - 'user_avatar_type' => $type, - 'user_avatar_width' => $width, - 'user_avatar_height' => $height, + 'username' => $username, + 'user_founder' => $user_founder, + 'user_email' => $user_email, + 'user_email_hash' => crc32(strtolower($user_email)) . strlen($user_email), + 'user_warnings' => $user_warnings, ); + if ($update_password) + { + $sql_ary += array( + 'user_password' => md5($user_password), + 'user_passchg' => time(), + ); + } + $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " - WHERE user_id = $user_id"; + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' + WHERE user_id = ' . $user->data['user_id']; $db->sql_query($sql); - // Delete old avatar if present - if ($user_avatar && $filename != $user_avatar) + // TODO + if ($update_warning) { - avatar_delete($user_avatar); } - } - - trigger_error($message); - } - - extract($data); - unset($data); - - break; - case 'sig': - - $var_ary = array( - 'enable_html' => (bool) $config['allow_html'], - 'enable_bbcode' => (bool) $config['allow_bbcode'], - 'enable_smilies' => (bool) $config['allow_smilies'], - 'enable_urls' => true, - 'signature' => (string) $user_sig, - - ); - - foreach ($var_ary as $var => $default) - { - $$var = request_var($var, $default); - } - - if (!$preview) - { - include($phpbb_root_path . 'includes/message_parser.'.$phpEx); - - $message_parser = new parse_message($signature); - $message_parser->parse($enable_html, $enable_bbcode, $enable_urls, $enable_smilies); - - $sql_ary = array( - 'user_sig' => (string) $message_parser->message, - 'user_sig_bbcode_uid' => (string) $message_parser->bbcode_uid, - 'user_sig_bbcode_bitfield' => (int) $message_parser->bbcode_bitfield - ); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " - WHERE user_id = $user_id"; - $db->sql_query($sql); - - $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], "<a href=\"admin_users.$phpEx$SID&mode=$mode&action=$action&u=$user_id\">", '</a>'); - trigger_error($message); - } - - break; - - case 'groups': - break; - - case 'permissions': - break; - - case 'attach': - - $delete_ids = isset($_REQUEST['attachment']) ? array_keys(array_map('intval', $_REQUEST['attachment'])) : array(); - - if ($deletemark && sizeof($delete_ids)) - { - if (!$cancel && !$confirm) - { - adm_page_confirm($user->lang['CONFIRM'], $user->lang['CONFIRM_OPERATION']); - } - else if (!$cancel) - { - $log_attachments = array(); - - $sql = 'SELECT real_filename - FROM ' . ATTACHMENTS_TABLE . ' - WHERE attach_id IN (' . implode(', ', $delete_ids) . ')'; - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) + if ($update_username) { - $log_attachments[] = $row['real_filename']; + user_update_name($update_username, $username); } - $db->sql_freeresult($result); - - delete_attachments('attach', $delete_ids); - add_log('admin', ((sizeof($delete_ids) == 1) ? 'ATTACHMENT_DELETED' : 'ATTACHMENTS_DELETED'), implode(', ', $log_attachments)); - $message = ((sizeof($delete_ids) == 1) ? $user->lang['ATTACHMENT_DELETED'] : $user->lang['ATTACHMENTS_DELETED']) . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], "<a href=\"admin_users.$phpEx$SID&mode=$mode&action=$action&u=$user_id\">", '</a>'); - trigger_error($message); + trigger_error($user->lang['USER_OVERVIEW_UPDATED']); } - } - - break; - } -} - -// -// Output forms -// - -// Begin program -if ($username || $user_id) -{ - // Generate overall "header" for user admin - $form_options = ''; - $forms_ary = array('overview' => 'OVERVIEW', 'feedback' => 'FEEDBACK', 'profile' => 'PROFILE', 'prefs' => 'PREFS', 'avatar' => 'AVATAR', 'sig' => 'SIG', 'groups' => 'GROUP', 'perm' => 'PERM', 'attach' => 'ATTACH'); - - foreach ($forms_ary as $value => $lang) - { - $selected = ($action == $value) ? ' selected="selected"' : ''; - $form_options .= '<option value="' . $value . '"' . $selected . '>' . $user->lang['USER_ADMIN_' . $lang] . '</option>'; - } - - $pagination = ''; - - $colspan = ($action == 'attach') ? '6' : '2'; - $show_bottom = ($action == 'attach') ? false : true; - -?> - -<script language="javascript" type="text/javascript"> -<!-- - -var form_name = 'admin'; -var text_name = 'signature'; - -// Define the bbCode tags -bbcode = new Array(); -bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','[/code]','[list]','[/list]','[list=]','[/list]','[img]','[/img]','[url]','[/url]'); -imageTag = false; - -// Helpline messages -b_help = "<?php echo $user->lang['BBCODE_B_HELP']; ?>"; -i_help = "<?php echo $user->lang['BBCODE_I_HELP']; ?>"; -u_help = "<?php echo $user->lang['BBCODE_U_HELP']; ?>"; -q_help = "<?php echo $user->lang['BBCODE_Q_HELP']; ?>"; -c_help = "<?php echo $user->lang['BBCODE_C_HELP']; ?>"; -l_help = "<?php echo $user->lang['BBCODE_L_HELP']; ?>"; -o_help = "<?php echo $user->lang['BBCODE_O_HELP']; ?>"; -p_help = "<?php echo $user->lang['BBCODE_P_HELP']; ?>"; -w_help = "<?php echo $user->lang['BBCODE_W_HELP']; ?>"; -a_help = "<?php echo $user->lang['BBCODE_A_HELP']; ?>"; -s_help = "<?php echo $user->lang['BBCODE_S_HELP']; ?>"; -f_help = "<?php echo $user->lang['BBCODE_F_HELP']; ?>"; -e_help = "<?php echo $user->lang['BBCODE_E_HELP']; ?>"; - -//--> -</script> -<script language="javascript" type="text/javascript" src="editor.js"></script> - -<h1><?php echo $user->lang['USER_ADMIN']; ?></h1> - -<p><?php echo $user->lang['USER_ADMIN_EXPLAIN']; ?></p> - -<form method="post" name="admin" action="<?php echo "admin_users.$phpEx$SID&mode=$mode&action=$action&u=$user_id"; ?>"<?php echo ($file_uploads) ? ' enctype="multipart/form-data"' : ''; ?>><table width="100%" cellspacing="2" cellpadding="0" border="0" align="center"> - <tr> - <td align="right"><?php echo $user->lang['SELECT_FORM']; ?>: <select name="action" onchange="if (this.options[this.selectedIndex].value != '') this.form.submit();"><?php echo $form_options; ?></select></td> - </tr> - <tr> - <td><table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0"> - <tr> - <th colspan="<?php echo $colspan; ?>"><?php echo $user->lang['USER_ADMIN_' . strtoupper($action)]; ?></th> - </tr> -<?php - - if (sizeof($error)) - { - -?> - <tr> - <td class="row3" colspan="<?php echo $colspan; ?>" align="center"><span class="error"><?php echo implode('<br />', $error); ?></span></td> - </tr> -<?php - - } + // Replace "error" strings with their real, localised form + $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); + } - switch ($action) - { - case 'overview': + $colspan = 2; $user_char_ary = array('.*' => 'USERNAME_CHARS_ANY', '[\w]+' => 'USERNAME_ALPHA_ONLY', '[\w_\+\. \-\[\]]+' => 'USERNAME_ALPHA_SPACERS'); - $quick_tool_ary = array('banuser' => 'BAN_USER', 'banemail' => 'BAN_EMAIL', 'banip' => 'BAN_IP', 'active' => (($user_type == USER_INACTIVE) ? 'ACTIVATE' : 'DEACTIVATE'), 'moveposts' => 'MOVE_POSTS'); + $quick_tool_ary = array('banuser' => 'BAN_USER', 'banemail' => 'BAN_EMAIL', 'banip' => 'BAN_IP', 'active' => (($user_type == USER_INACTIVE) ? 'ACTIVATE' : 'DEACTIVATE'), 'delsig' => 'DEL_SIG', 'delavatar' => 'DEL_AVATAR', 'moveposts' => 'MOVE_POSTS', 'delposts' => 'DEL_POSTS', 'delattach' => 'DEL_ATTACH'); if ($config['email_enable']) { $quick_tool_ary['reactivate'] = 'FORCE'; } - asort($quick_tool_ary); - $options = '<option class="sep" value="">' . $user->lang['SELECT_OPTION'] . '</option>'; foreach ($quick_tool_ary as $value => $lang) { @@ -1000,6 +605,9 @@ e_help = "<?php echo $user->lang['BBCODE_E_HELP']; ?>"; ?> <tr> + <th colspan="2"><?php echo $user->lang['USER_ADMIN_OVERVIEW']; ?></th> + </tr> + <tr> <td class="row1" width="40%"><?php echo $user->lang['USERNAME']; ?>: <br /><span class="gensmall"><?php echo sprintf($user->lang[$user_char_ary[str_replace('\\\\', '\\', $config['allow_name_chars'])] . '_EXPLAIN'], $config['min_name_chars'], $config['max_name_chars']); ?></span></td> <td class="row2"><input class="post" type="text" name="username" value="<?php echo $username; ?>" maxlength="60" /></td> </tr> @@ -1071,17 +679,55 @@ e_help = "<?php echo $user->lang['BBCODE_E_HELP']; ?>"; } +?> + <tr> + <td class="cat" colspan="2" align="center"><input class="btnmain" type="submit" name="update" value="<?php echo $user->lang['SUBMIT']; ?>" /> <input class="btnlite" type="reset" value="<?php echo $user->lang['RESET']; ?>" /></td> + </tr> +<?php + break; case 'feedback': - $st = request_var('st', 0); - $sk = request_var('sk', 't'); - $sd = request_var('sd', 'd'); + if ($submit) + { + if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs')) + { + $where_sql = ''; + if ($deletemark && $marked) + { + $sql_in = array(); + foreach ($marked as $mark) + { + $sql_in[] = $mark; + } + $where_sql = ' AND log_id IN (' . implode(', ', $sql_in) . ')'; + unset($sql_in); + } + + $sql = 'DELETE FROM ' . LOG_TABLE . ' + WHERE log_type = ' . LOG_USERS . " + $where_sql"; + $db->sql_query($sql); + + add_log('admin', 'LOG_USERS_CLEAR'); + trigger_error(""); + } + + if ($message = request_var('message', '')) + { + add_log('admin', 'LOG_USER_FEEDBACK', $username); + add_log('user', $user_id, 'LOG_USER_GENERAL', $message); + + trigger_error($user->lang['USER_FEEDBACK_ADDED']); + } + } + + $colspan = 2; $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 364 => $user->lang['1_YEAR']); - $sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']); - $sort_by_sql = array('u' => 'l.user_id', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation'); + $sort_by_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_DATE'], 'c' => $user->lang['SORT_IP'], 'd' => $user->lang['SORT_ACTION']); + $sort_by_sql = array('a' => 'l.user_id', 'b' => 'l.log_time', 'c' => 'l.log_ip', 'd' => 'l.log_operation'); $s_limit_days = $s_sort_key = $s_sort_dir = ''; gen_sort_selects($limit_days, $sort_by_text, $st, $sk, $sd, $s_limit_days, $s_sort_key, $s_sort_dir); @@ -1092,6 +738,9 @@ e_help = "<?php echo $user->lang['BBCODE_E_HELP']; ?>"; ?> <tr> + <th colspan="2"><?php echo $user->lang['USER_ADMIN_FEEDBACK']; ?></th> + </tr> + <tr> <td class="cat" colspan="2" align="center"><?php echo $user->lang['DISPLAY_LOG']; ?>: <?php echo $s_limit_days; ?> <?php echo $user->lang['SORT_BY']; ?>: <?php echo $s_sort_key; ?> <?php echo $s_sort_dir; ?> <input class="btnlite" type="submit" value="<?php echo $user->lang['GO']; ?>" name="sort" /></td> </tr> <?php @@ -1177,6 +826,9 @@ function marklist(match, status) <tr> <td class="row1" colspan="2" align="center"><textarea name="message" rows="10" cols="76"></textarea></td> </tr> + <tr> + <td class="cat" colspan="2" align="center"><input class="btnmain" type="submit" name="update" value="<?php echo $user->lang['SUBMIT']; ?>" /> <input class="btnlite" type="reset" value="<?php echo $user->lang['RESET']; ?>" /></td> + </tr> <?php @@ -1185,6 +837,104 @@ function marklist(match, status) case 'profile': + if ($submit) + { + $var_ary = array( + 'icq' => (string) '', + 'aim' => (string) '', + 'msn' => (string) '', + 'yim' => (string) '', + 'jabber' => (string) '', + 'website' => (string) '', + 'location' => (string) '', + 'occupation' => (string) '', + 'interests' => (string) '', + 'bday_day' => 0, + 'bday_month' => 0, + 'bday_year' => 0, + ); + + foreach ($var_ary as $var => $default) + { + $data[$var] = request_var($var, $default); + } + + $var_ary = array( + 'icq' => array( + array('string', true, 3, 15), + array('match', true, '#^[0-9]+$#i')), + 'aim' => array('string', true, 5, 255), + 'msn' => array('string', true, 5, 255), + 'jabber' => array( + array('string', true, 5, 255), + array('match', true, '#^[a-z0-9\.\-_\+]+?@(.*?\.)*?[a-z0-9\-_]+?\.[a-z]{2,4}(/.*)?$#i')), + 'yim' => array('string', true, 5, 255), + 'website' => array( + array('string', true, 12, 255), + array('match', true, '#^http[s]?://(.*?\.)*?[a-z0-9\-]+\.[a-z]{2,4}#i')), + 'location' => array('string', true, 2, 255), + 'occupation' => array('string', true, 2, 500), + 'interests' => array('string', true, 2, 500), + 'bday_day' => array('num', true, 1, 31), + 'bday_month' => array('num', true, 1, 12), + 'bday_year' => array('num', true, 1901, gmdate('Y', time())), + ); + + $error = validate_data($data, $var_ary); + extract($data); + unset($data); + + // validate custom profile fields + // $cp->submit_cp_field('profile', $cp_data, $cp_error); + + if (!sizeof($error) && !sizeof($cp_error)) + { + $sql_ary = array( + 'user_icq' => $icq, + 'user_aim' => $aim, + 'user_msnm' => $msn, + 'user_yim' => $yim, + 'user_jabber' => $jabber, + 'user_website' => $website, + 'user_from' => $location, + 'user_occ' => $occupation, + 'user_interests'=> $interests, + 'user_birthday' => sprintf('%2d-%2d-%4d', $bday_day, $bday_month, $bday_year), + ); + + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " + WHERE user_id = $user_id"; + $db->sql_query($sql); + + /* + // Update Custom Fields + if (sizeof($cp_data)) + { + $sql = 'UPDATE ' . CUSTOM_PROFILE_DATA . ' + SET ' . $db->sql_build_array('UPDATE', $cp_data) . " + WHERE user_id = $user_id"; + $db->sql_query($sql); + + if (!$db->sql_affectedrows()) + { + $cp_data['user_id'] = $user_id; + + $db->return_on_error = true; + + $sql = 'INSERT INTO ' . 'phpbb_profile_fields_data' . ' ' . $db->sql_build_array('INSERT', $cp_data); + $db->sql_query(); + + $db->return_on_error = false; + } + } + */ + trigger_error($user->lang['USER_PROFILE_UPDATED']); + } + } + + $colspan = 2; + $cp = new custom_profile(); $cp_data = $cp_error = array(); @@ -1224,6 +974,9 @@ function marklist(match, status) ?> + <tr> + <th colspan="2"><?php echo $user->lang['USER_ADMIN_SIG']; ?></th> + </tr> <tr> <td class="row1" width="40%"><b><?php echo $user->lang['UCP_ICQ']; ?>: </b></td> <td class="row2"><input class="post" type="text" name="icq" size="30" maxlength="15" value="<?php echo $user_icq; ?>" /></td> @@ -1264,6 +1017,9 @@ function marklist(match, status) <td class="row1"><b><?php echo $user->lang['BIRTHDAY']; ?>: </b><br /><span class="gensmall"><?php echo $user->lang['BIRTHDAY_EXPLAIN']; ?></span></td> <td class="row2"><span class="genmed"><?php echo $user->lang['DAY']; ?>:</span> <select name="bday_day"><?php echo $s_birthday_day_options; ?></select> <span class="genmed"><?php echo $user->lang['MONTH']; ?>:</span> <select name="bday_month"><?php echo $s_birthday_month_options; ?></select> <span class="genmed"><?php echo $user->lang['YEAR']; ?>:</span> <select name="bday_year"><?php echo $s_birthday_year_options; ?></select></td> </tr> + <tr> + <td class="cat" colspan="2" align="center"><input class="btnmain" type="submit" name="update" value="<?php echo $user->lang['SUBMIT']; ?>" /> <input class="btnlite" type="reset" value="<?php echo $user->lang['RESET']; ?>" /></td> + </tr> <?php break; @@ -1271,6 +1027,104 @@ function marklist(match, status) case 'prefs': + if ($submit) + { + $var_ary = array( + 'user_dateformat' => (string) $config['default_dateformat'], + 'user_lang' => (string) $config['default_lang'], + 'user_tz' => (float) $config['board_timezone'], + 'user_style' => (int) $config['default_style'], + 'user_dst' => (bool) $config['board_dst'], + 'user_allow_viewemail' => false, + 'user_allow_massemail' => true, + 'user_allow_viewonline' => true, + 'user_notify_type' => 0, + 'user_notify_pm' => true, + 'user_allow_pm' => true, + 'user_notify' => false, + 'user_min_karma' => (int) -5, + + 'sk' => (string) 't', + 'sd' => (string) 'd', + 'st' => 0, + + 'popuppm' => false, + 'viewimg' => true, + 'viewflash' => false, + 'viewsmilies' => true, + 'viewsigs' => true, + 'viewavatars' => true, + 'viewcensors' => false, + 'bbcode' => true, + 'html' => false, + 'smile' => true, + 'attachsig' => true, + ); + + foreach ($var_ary as $var => $default) + { + $data[$var] = request_var($var, $default); + } + + $var_ary = array( + 'user_dateformat' => array('string', false, 3, 15), + 'user_lang' => array('match', false, '#^[a-z_]{2,}$#i'), + 'user_tz' => array('num', false, -13, 13), + 'user_min_karma' => array('num', false, -5, 5), + + 'sk' => array('string', false, 1, 1), + 'sd' => array('string', false, 1, 1), + ); + + $error = validate_data($data, $var_ary); + extract($data); + unset($data); + + // Set the popuppm option + $option_ary = array('popuppm', 'viewimg', 'viewflash', 'viewsmilies', 'viewsigs', 'viewavatars', 'viewcensors', 'bbcode', 'html', 'smile', 'attachsig'); + + foreach ($option_ary as $option) + { + $user_options = $user->optionset($option, $$option, $user_options); + } + + if (!sizeof($error)) + { + $sql_ary = array( + 'user_allow_pm' => $user_allow_pm, + 'user_allow_viewemail' => $user_allow_viewemail, + 'user_allow_massemail' => $user_allow_massemail, + 'user_allow_viewonline' => $user_allow_viewonline, + 'user_notify_type' => $user_notify_type, + 'user_notify_pm' => $user_notify_pm, + 'user_options' => $user_options, + 'user_notify' => $user_notify, + 'user_min_karma' => $user_min_karma, + 'user_dst' => $user_dst, + 'user_dateformat' => $user_dateformat, + 'user_lang' => $user_lang, + 'user_timezone' => $user_tz, + 'user_style' => $user_style, + 'user_sortby_type' => $sk, + 'user_sortby_dir' => $sd, + 'user_show_days' => $st, + ); + + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " + WHERE user_id = $user_id"; + $db->sql_query($sql); + + trigger_error($user->lang['USER_PREFS_UPDATED']); + } + + $user_sortby_type = $sk; + $user_sortby_dir = $sd; + $user_show_days = $st; + } + + $colspan = 2; + $option_ary = array('user_allow_viewemail', 'user_allow_massemail', 'user_allow_pm', 'user_allow_viewonline', 'user_notify_pm', 'user_dst', 'user_notify', 'user_min_karma'); foreach ($option_ary as $option) @@ -1302,6 +1156,9 @@ function marklist(match, status) gen_sort_selects($limit_days, $sort_by_text, $user_show_days, $user_sortby_type, $user_sortby_dir, $s_limit_days, $s_sort_key, $s_sort_dir); ?> + <tr> + <th colspan="2"><?php echo $user->lang['USER_ADMIN_PREFS']; ?></th> + </tr> <tr> <td class="row1" width="40%"><b><?php echo $user->lang['VIEW_IMAGES']; ?>:</b></td> <td class="row2"><input type="radio" name="viewimg" value="1"<?php echo $viewimg_yes; ?> /><span class="gen"><?php echo $user->lang['YES']; ?></span> <input type="radio" name="viewimg" value="0"<?php echo $viewimg_no; ?> /><span class="gen"><?php echo $user->lang['NO']; ?></span></td> @@ -1416,13 +1273,90 @@ function marklist(match, status) <td class="row1"><b><?php echo $user->lang['BOARD_DATE_FORMAT']; ?>:</b><br /><span class="gensmall"><?php echo $user->lang['BOARD_DATE_FORMAT_EXPLAIN']; ?></span></td> <td class="row2"><input type="text" name="user_dateformat" value="<?php echo $user_dateformat; ?>" maxlength="14" class="post" /></td> </tr> + <tr> + <td class="cat" colspan="2" align="center"><input class="btnmain" type="submit" name="update" value="<?php echo $user->lang['SUBMIT']; ?>" /> <input class="btnlite" type="reset" value="<?php echo $user->lang['RESET']; ?>" /></td> + </tr> <?php break; - case 'avatar': - $can_upload = ($file_uploads && file_exists($phpbb_root_path . $config['avatar_path']) && is_writeable($phpbb_root_path . $config['avatar_path'])) ? true : false; + + $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && is_writeable($phpbb_root_path . $config['avatar_path']) && $file_uploads) ? true : false; + + if ($submit) + { + $var_ary = array( + 'uploadurl' => (string) '', + 'remotelink' => (string) '', + 'width' => (string) '', + 'height' => (string) '', + ); + + foreach ($var_ary as $var => $default) + { + $data[$var] = request_var($var, $default); + } + + $var_ary = array( + 'uploadurl' => array('string', true, 5, 255), + 'remotelink' => array('string', true, 5, 255), + 'width' => array('string', true, 1, 3), + 'height' => array('string', true, 1, 3), + ); + + $error = validate_data($data, $var_ary); + + if (!sizeof($error)) + { + $data['user_id'] = $user_id; + + if ((!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl']) && $can_upload) + { + list($type, $filename, $width, $height) = avatar_upload($data, $error); + } + else if ($data['remotelink']) + { + list($type, $filename, $width, $height) = avatar_remote($data, $error); + } + else if ($delete) + { + $type = $filename = $width = $height = ''; + } + } + + if (!sizeof($error)) + { + // Do we actually have any data to update? + if (sizeof($data)) + { + $sql_ary = array( + 'user_avatar' => $filename, + 'user_avatar_type' => $type, + 'user_avatar_width' => $width, + 'user_avatar_height' => $height, + ); + + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " + WHERE user_id = $user_id"; + $db->sql_query($sql); + + // Delete old avatar if present + if ($user_avatar && $filename != $user_avatar) + { + avatar_delete($user_avatar); + } + } + + trigger_error($message); + } + + extract($data); + unset($data); + } + + $colspan = 2; $display_gallery = (isset($_POST['displaygallery'])) ? true : false; $avatar_category = request_var('category', ''); @@ -1450,6 +1384,9 @@ function marklist(match, status) } ?> + <tr> + <th colspan="<?php echo $colspan; ?>"><?php echo $user->lang['USER_ADMIN_AVATAR']; ?></th> + </tr> <tr> <td class="row2" width="35%"><b><?php echo $user->lang['CURRENT_IMAGE']; ?>: </b><br /><span class="gensmall"><?php echo sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], round($config['avatar_filesize'] / 1024)); ?></span></td> <td class="row1" align="center"><br /><?php echo $avatar_img; ?><br /><br /><input type="checkbox" name="delete" /> <span class="gensmall"><?php echo $user->lang['DELETE_AVATAR']; ?></span></td> @@ -1529,10 +1466,57 @@ function marklist(match, status) } +?> + <tr> + <td class="cat" colspan="2" align="center"><input class="btnmain" type="submit" name="update" value="<?php echo $user->lang['SUBMIT']; ?>" /> <input class="btnlite" type="reset" value="<?php echo $user->lang['RESET']; ?>" /></td> + </tr> +<?php + break; case 'sig': + + if ($submit || $preview) + { + $var_ary = array( + 'enable_html' => (bool) $config['allow_html'], + 'enable_bbcode' => (bool) $config['allow_bbcode'], + 'enable_smilies' => (bool) $config['allow_smilies'], + 'enable_urls' => true, + 'signature' => (string) $user_sig, + + ); + + foreach ($var_ary as $var => $default) + { + $$var = request_var($var, $default); + } + + if (!$preview) + { + include($phpbb_root_path . 'includes/message_parser.'.$phpEx); + + $message_parser = new parse_message($signature); + $message_parser->parse($enable_html, $enable_bbcode, $enable_urls, $enable_smilies); + + $sql_ary = array( + 'user_sig' => (string) $message_parser->message, + 'user_sig_bbcode_uid' => (string) $message_parser->bbcode_uid, + 'user_sig_bbcode_bitfield' => (int) $message_parser->bbcode_bitfield + ); + + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " + WHERE user_id = $user_id"; + $db->sql_query($sql); + + trigger_error($user->lang['PROFILE_UPDATED']); + } + } + + $colspan = 2; + include($phpbb_root_path . 'includes/functions_posting.'.$phpEx); $signature_preview = ''; @@ -1560,94 +1544,91 @@ function marklist(match, status) $signature_preview = smilie_text($signature_preview, !$enable_smilies); // Replace naughty words such as farty pants -/* if (sizeof($censors)) - { - $signature_preview = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$censors['match'], \$censors['replace'], '\\0')", '>' . $signature_preview . '<'), 1, -1)); - }*/ - $signature_preview = str_replace("\n", '<br />', censor_text($signature_preview)); } decode_text($user_sig, $user_sig_bbcode_uid); - ?> - <tr> - <td class="row1" width="40%"><b class="genmed"><?php echo $user->lang['SIGNATURE']; ?>: </b></td> - <td class="row2"><table cellspacing="0" cellpadding="2" border="0"> - <tr align="center" valign="middle"> - <td><input class="btnlite" type="button" accesskey="b" name="addbbcode0" value=" B " style="font-weight:bold; width: 30px" onclick="bbstyle(0)" onmouseover="helpline('b')" /></td> - <td><input class="btnlite" type="button" accesskey="i" name="addbbcode2" value=" i " style="font-style:italic; width: 30px" onclick="bbstyle(2)" onmouseover="helpline('i')" /></td> - <td><input class="btnlite" type="button" accesskey="u" name="addbbcode4" value=" u " style="text-decoration: underline; width: 30px" onclick="bbstyle(4)" onmouseover="helpline('u')" /></td> - <td><input class="btnlite" type="button" accesskey="q" name="addbbcode6" value="Quote" style="width: 50px" onclick="bbstyle(6)" onmouseover="helpline('q')" /></td> - <td><input class="btnlite" type="button" accesskey="c" name="addbbcode8" value="Code" style="width: 40px" onclick="bbstyle(8)" onmouseover="helpline('c')" /></td> - <td><input class="btnlite" type="button" accesskey="l" name="addbbcode10" value="List" style="width: 40px" onclick="bbstyle(10)" onmouseover="helpline('l')" /></td> - <td><input class="btnlite" type="button" accesskey="o" name="addbbcode12" value="List=" style="width: 40px" onclick="bbstyle(12)" onmouseover="helpline('o')" /></td> - <td><input class="btnlite" type="button" accesskey="p" name="addbbcode14" value="Img" style="width: 40px" onclick="bbstyle(14)" onmouseover="helpline('p')" /></td> - <td><input class="btnlite" type="button" accesskey="w" name="addbbcode18" value="URL" style="text-decoration: underline; width: 40px" onclick="bbstyle(18)" onmouseover="helpline('w')" /></td> - </tr> <tr> - <td colspan="9"><table width="100%" cellspacing="0" cellpadding="0" border="0"> + <th colspan="<?php echo $colspan; ?>"><?php echo $user->lang['USER_ADMIN_SIG']; ?></th> + </tr> + <tr> + <td class="row1" width="40%"><b class="genmed"><?php echo $user->lang['SIGNATURE']; ?>: </b></td> + <td class="row2"><table cellspacing="0" cellpadding="2" border="0"> + <tr align="center" valign="middle"> + <td><input class="btnlite" type="button" accesskey="b" name="addbbcode0" value=" B " style="font-weight:bold; width: 30px" onclick="bbstyle(0)" onmouseover="helpline('b')" /></td> + <td><input class="btnlite" type="button" accesskey="i" name="addbbcode2" value=" i " style="font-style:italic; width: 30px" onclick="bbstyle(2)" onmouseover="helpline('i')" /></td> + <td><input class="btnlite" type="button" accesskey="u" name="addbbcode4" value=" u " style="text-decoration: underline; width: 30px" onclick="bbstyle(4)" onmouseover="helpline('u')" /></td> + <td><input class="btnlite" type="button" accesskey="q" name="addbbcode6" value="Quote" style="width: 50px" onclick="bbstyle(6)" onmouseover="helpline('q')" /></td> + <td><input class="btnlite" type="button" accesskey="c" name="addbbcode8" value="Code" style="width: 40px" onclick="bbstyle(8)" onmouseover="helpline('c')" /></td> + <td><input class="btnlite" type="button" accesskey="l" name="addbbcode10" value="List" style="width: 40px" onclick="bbstyle(10)" onmouseover="helpline('l')" /></td> + <td><input class="btnlite" type="button" accesskey="o" name="addbbcode12" value="List=" style="width: 40px" onclick="bbstyle(12)" onmouseover="helpline('o')" /></td> + <td><input class="btnlite" type="button" accesskey="p" name="addbbcode14" value="Img" style="width: 40px" onclick="bbstyle(14)" onmouseover="helpline('p')" /></td> + <td><input class="btnlite" type="button" accesskey="w" name="addbbcode18" value="URL" style="text-decoration: underline; width: 40px" onclick="bbstyle(18)" onmouseover="helpline('w')" /></td> + </tr> <tr> - <td><span class="genmed"> <?php echo $user->lang['FONT_SIZE']; ?>:</span> <select name="addbbcode20" onchange="bbfontstyle('[size=' + this.form.addbbcode20.options[this.form.addbbcode20.selectedIndex].value + ']', '[/size]');this.form.addbbcode20.selectedIndex = 2;" onmouseover="helpline('f')"> - <option value="7"><?php echo $user->lang['FONT_TINY']; ?></option> - <option value="9"><?php echo $user->lang['FONT_SMALL']; ?></option> - <option value="12" selected="selected"><?php echo $user->lang['FONT_NORMAL']; ?></option> - <option value="18"><?php echo $user->lang['FONT_LARGE']; ?></option> - <option value="24"><?php echo $user->lang['FONT_HUGE']; ?></option> - </select></td> - <td class="gensmall" nowrap="nowrap" align="right"><a href="javascript:bbstyle(-1)" onmouseover="helpline('a')"><?php echo $user->lang['CLOSE_TAGS']; ?></a></td> + <td colspan="9"><table width="100%" cellspacing="0" cellpadding="0" border="0"> + <tr> + <td><span class="genmed"> <?php echo $user->lang['FONT_SIZE']; ?>:</span> <select name="addbbcode20" onchange="bbfontstyle('[size=' + this.form.addbbcode20.options[this.form.addbbcode20.selectedIndex].value + ']', '[/size]');this.form.addbbcode20.selectedIndex = 2;" onmouseover="helpline('f')"> + <option value="7"><?php echo $user->lang['FONT_TINY']; ?></option> + <option value="9"><?php echo $user->lang['FONT_SMALL']; ?></option> + <option value="12" selected="selected"><?php echo $user->lang['FONT_NORMAL']; ?></option> + <option value="18"><?php echo $user->lang['FONT_LARGE']; ?></option> + <option value="24"><?php echo $user->lang['FONT_HUGE']; ?></option> + </select></td> + <td class="gensmall" nowrap="nowrap" align="right"><a href="javascript:bbstyle(-1)" onmouseover="helpline('a')"><?php echo $user->lang['CLOSE_TAGS']; ?></a></td> + </tr> + </table></td> + </tr> + <tr> + <td colspan="9"><input class="helpline" type="text" name="helpbox" size="45" maxlength="100" value="<?php echo $user->lang['STYLES_TIP']; ?>" /></td> + </tr> + <tr> + <td colspan="9"><textarea name="signature" rows="6" cols="60" tabindex="3" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);"><?php echo $user_sig; ?></textarea></td> </tr> - </table></td> - </tr> - <tr> - <td colspan="9"><input class="helpline" type="text" name="helpbox" size="45" maxlength="100" value="<?php echo $user->lang['STYLES_TIP']; ?>" /></td> - </tr> - <tr> - <td colspan="9"><textarea name="signature" rows="6" cols="60" tabindex="3" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);"><?php echo $user_sig; ?></textarea></td> - </tr> - <tr> - <td colspan="9"><table cellspacing="0" cellpadding="0" border="0"> <tr> - <td bgcolor="black"><script language="javascript" type="text/javascript"><!-- + <td colspan="9"><table cellspacing="0" cellpadding="0" border="0"> + <tr> + <td bgcolor="black"><script language="javascript" type="text/javascript"><!-- - colorPalette('h', 14, 5) + colorPalette('h', 14, 5) - //--></script></td> + //--></script></td> + </tr> + </table></td> </tr> </table></td> </tr> - </table></td> - </tr> - <tr> - <td class="row1" valign="top"><b class="genmed"><?php echo $user->lang['OPTIONS']; ?></b><br /><table cellspacing="2" cellpadding="0" border="0"> - <tr> - <td class="gensmall"><?php echo ($config['allow_html']) ? $user->lang['HTML_IS_ON'] : $user->lang['HTML_IS_OFF']; ?></td> - </tr> - <tr> - <td class="gensmall"><?php echo ($config['allow_bbcode']) ? sprintf($user->lang['BBCODE_IS_ON'], "<a href=\"../faq.$phpEx$SID&mode=bbcode\" target=\"_blank\">", '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], "<a href=\"../faq.$phpEx$SID&mode=bbcode\" target=\"_blank\">", '</a>'); ?></td> - </tr> - <tr> - <td class="gensmall"><?php echo ($config['allow_img']) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF']; ?></td> - </tr> <tr> - <td class="gensmall"><?php echo ($config['allow_flash']) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF']; ?></td> - </tr> - <tr> - <td class="gensmall"><?php echo ($config['allow_smilies']) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF']; ?></td> - </tr> - </table></td> - <td class="row2" valign="top"><table cellspacing="0" cellpadding="1" border="0"> + <td class="row1" valign="top"><b class="genmed"><?php echo $user->lang['OPTIONS']; ?></b><br /><table cellspacing="2" cellpadding="0" border="0"> + <tr> + <td class="gensmall"><?php echo ($config['allow_html']) ? $user->lang['HTML_IS_ON'] : $user->lang['HTML_IS_OFF']; ?></td> + </tr> + <tr> + <td class="gensmall"><?php echo ($config['allow_bbcode']) ? sprintf($user->lang['BBCODE_IS_ON'], "<a href=\"../faq.$phpEx$SID&mode=bbcode\" target=\"_blank\">", '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], "<a href=\"../faq.$phpEx$SID&mode=bbcode\" target=\"_blank\">", '</a>'); ?></td> + </tr> + <tr> + <td class="gensmall"><?php echo ($config['allow_img']) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF']; ?></td> + </tr> + <tr> + <td class="gensmall"><?php echo ($config['allow_flash']) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF']; ?></td> + </tr> + <tr> + <td class="gensmall"><?php echo ($config['allow_smilies']) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF']; ?></td> + </tr> + </table></td> + <td class="row2" valign="top"><table cellspacing="0" cellpadding="1" border="0"> <?php if ($config['allow_html']) { ?> - <tr> - <td><input type="checkbox" name="disable_html" /></td> - <td class="gen"><?php echo $user->lang['DISABLE_HTML']; ?></td> - </tr> + <tr> + <td><input type="checkbox" name="disable_html" /></td> + <td class="gen"><?php echo $user->lang['DISABLE_HTML']; ?></td> + </tr> <?php } @@ -1656,10 +1637,10 @@ function marklist(match, status) { ?> - <tr> - <td><input type="checkbox" name="disable_bbcode" /></td> - <td class="gen"><?php echo $user->lang['DISABLE_BBCODE']; ?></td> - </tr> + <tr> + <td><input type="checkbox" name="disable_bbcode" /></td> + <td class="gen"><?php echo $user->lang['DISABLE_BBCODE']; ?></td> + </tr> <?php } @@ -1668,33 +1649,36 @@ function marklist(match, status) { ?> - <tr> - <td><input type="checkbox" name="disable_smilies" /></td> - <td class="gen"><?php echo $user->lang['DISABLE_SMILIES']; ?></td> - </tr> + <tr> + <td><input type="checkbox" name="disable_smilies" /></td> + <td class="gen"><?php echo $user->lang['DISABLE_SMILIES']; ?></td> + </tr> <?php } ?> + <tr> + <td><input type="checkbox" name="disable_magic_url" /></td> + <td class="gen"><?php echo $user->lang['DISABLE_MAGIC_URL']; ?></td> + </tr> + </table></td> + </tr> <tr> - <td><input type="checkbox" name="disable_magic_url" /></td> - <td class="gen"><?php echo $user->lang['DISABLE_MAGIC_URL']; ?></td> + <td class="cat" colspan="2" align="center"><input class="btnlite" type="submit" name="preview" value="<?php echo $user->lang['PREVIEW']; ?>" /> <input class="btnmain" type="submit" name="update" value="<?php echo $user->lang['SUBMIT']; ?>" /> <input class="btnlite" type="reset" value="<?php echo $user->lang['RESET']; ?>" /></td> </tr> - </table></td> - </tr> <?php if ($signature_preview) { ?> - <tr> - <th colspan="2" valign="middle"><?php echo $user->lang['ADMIN_SIGNATURE_PREVIEW']; ?></th> - </tr> - <tr> - <td class="row1" colspan="2"><div class="postdetails" style="padding: 6px;"><?php echo $signature_preview; ?></div></td> - </tr> + <tr> + <th colspan="2" valign="middle"><?php echo $user->lang['ADMIN_SIGNATURE_PREVIEW']; ?></th> + </tr> + <tr> + <td class="row1" colspan="2"><div class="postdetails" style="padding: 6px;"><?php echo $signature_preview; ?></div></td> + </tr> <?php } @@ -1704,8 +1688,159 @@ function marklist(match, status) break; - case 'groups': + + switch ($action) + { + case 'demote': + case 'promote': + case 'default': + group_user_attributes($action, $gid, $user_id); + + if ($action == 'default') + { + $group_id = $gid; + } + break; + + case 'delete': + if (!$cancel && !$confirm) + { + adm_page_confirm($user->lang['CONFIRM'], $user->lang['CONFIRM_OPERATION']); + } + else if (!$cancel) + { + if (!$gid) + { + trigger_error($user->lang['NO_GROUP']); + } + + if ($error = group_user_del($gid, $user_id)) + { + trigger_error($user->lang[$error]); + } + } + break; + } + + // Add user to group? + if ($submit) + { + if (!$gid) + { + trigger_error($user->lang['NO_GROUP']); + } + + // Add user/s to group + if ($error = group_user_add($gid, $user_id)) + { + trigger_error($user->lang[$error]); + } + } + + $colspan = 4; + +?> + <tr> + <th colspan="4"><?php echo $user->lang['USER_ADMIN_GROUPS']; ?></th> + </tr> +<?php + + $sql = 'SELECT ug.group_leader, g.* + FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . " ug + WHERE ug.user_id = $user_id + AND g.group_id = ug.group_id + ORDER BY g.group_type DESC, ug.user_pending ASC, g.group_name"; + $result = $db->sql_query($sql); + + $i = 0; + $group_data = $id_ary = array(); + while ($row = $db->sql_fetchrow($result)) + { + $type = ($row['group_type'] == GROUP_SPECIAL) ? 'special' : (($row['user_pending']) ? 'pending' : 'normal'); + + $group_data[$type][$i]['group_id'] = $row['group_id']; + $group_data[$type][$i]['group_name'] = $row['group_name']; + $group_data[$type][$i]['group_leader'] = ($row['group_leader']) ? 1 : 0; + + $id_ary[] = $row['group_id']; + + $i++; + } + $db->sql_freeresult($result); + + // Select box for other groups + $sql = 'SELECT group_id, group_name, group_type + FROM ' . GROUPS_TABLE . ' + WHERE group_id NOT IN (' . implode(', ', $id_ary) . ') + ORDER BY group_type DESC, group_name ASC'; + $result = $db->sql_query($sql); + + $group_options = ''; + while ($row = $db->sql_fetchrow($result)) + { + $group_options .= '<option' . (($row['group_type'] == GROUP_SPECIAL) ? ' class="blue"' : '') . ' value="' . $row['group_id'] . '">' . (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>'; + } + $db->sql_freeresult($result); + + $current_type = ''; + foreach ($group_data as $group_type => $data_ary) + { + if ($current_type != $group_type) + { + +?> + <tr> + <td class="row3" colspan="4"><strong><?php echo $user->lang['USER_GROUP_' . strtoupper($group_type)]; ?></strong></td> + </tr> +<?php + + } + + foreach ($data_ary as $data) + { + $row_class = ($row_class == 'row1') ? 'row2' : 'row1'; + +?> + <tr> + <td class="<?php echo $row_class; ?>"><a href="<?php echo "admin_groups.$phpEx$SID&mode=manage&action=edit&g=" . $data['group_id']; ?>"><?php echo ($group_type == 'special') ? $user->lang['G_' . $data['group_name']] : $data['group_name']; ?></a></td> + <td class="<?php echo $row_class; ?>" width="10%" nowrap="nowrap"> <?php + + if ($group_id != $data['group_id']) + { + +?><a href="<?php echo "admin_users.$phpEx$SID&mode=$mode&action=default&u=$user_id&g=" . $data['group_id']; ?>"><?php echo $user->lang['GROUP_DEFAULT']; ?></a><?php + + } + else + { + echo $user->lang['GROUP_DEFAULT']; + } + +?> </td> + <td class="<?php echo $row_class; ?>" width="10%" nowrap="nowrap"> <?php + + if ($group_type != 'special') + { + +?><a href="<?php echo "admin_users.$phpEx$SID&mode=$mode&action=" . (($data['group_leader']) ? 'demote' : 'promote') . "&u=$user_id&g=" . $data['group_id']; ?>"><?php echo ($data['group_leader']) ? $user->lang['GROUP_DEMOTE'] : $user->lang['GROUP_PROMOTE']; ?></a> <?php + + } + +?></td> + <td class="<?php echo $row_class; ?>" width="10%" nowrap="nowrap"> <a href="<?php echo "admin_users.$phpEx$SID&mode=$mode&action=delete&u=$user_id&g=" . $data['group_id']; ?>"><?php echo $user->lang['GROUP_DELETE']; ?></a> </td> + </tr> +<?php + + } + } + +?> + <tr> + <td class="cat" colspan="4" align="right"><?php echo $user->lang['USER_GROUP_ADD']; ?>: <select name="g"><?php echo $group_options; ?></select> <input class="btnmain" type="submit" name="update" value="<?php echo $user->lang['SUBMIT']; ?>" /> </td> + </tr> +<?php + break; @@ -1714,37 +1849,67 @@ function marklist(match, status) case 'attach': + + if ($deletemark && $marked) + { + if (!$cancel && !$confirm) + { + adm_page_confirm($user->lang['CONFIRM'], $user->lang['CONFIRM_OPERATION']); + } + else if (!$cancel) + { + $sql = 'SELECT real_filename + FROM ' . ATTACHMENTS_TABLE . ' + WHERE attach_id IN (' . implode(', ', $marked) . ')'; + $result = $db->sql_query($sql); + + $log_attachments = array(); + while ($row = $db->sql_fetchrow($result)) + { + $log_attachments[] = $row['real_filename']; + } + $db->sql_freeresult($result); + + delete_attachments('attach', $marked); + + $log = (sizeof($delete_ids) == 1) ? 'ATTACHMENT_DELETED' : 'ATTACHMENTS_DELETED'; + $meesage = (sizeof($delete_ids) == 1) ? $user->lang['ATTACHMENT_DELETED'] : $user->lang['ATTACHMENTS_DELETED']; + + add_log('admin', $log, implode(', ', $log_attachments)); + trigger_error($message); + } + } + + $colspan = 6; $uri = "admin_users.$phpEx$SID&mode=$mode&action=$action&u=$user_id"; - $sort_key = request_var('sk', 'a'); - $sort_dir = request_var('sd', 'a'); + $sk_text = array('a' => $user->lang['SORT_FILENAME'], 'b' => $user->lang['SORT_COMMENT'], 'c' => $user->lang['SORT_EXTENSION'], 'd' => $user->lang['SORT_SIZE'], 'e' => $user->lang['SORT_DOWNLOADS'], 'f' => $user->lang['SORT_POST_TIME'], 'g' => $user->lang['SORT_TOPIC_TITLE']); + $sk_sql = array('a' => 'a.real_filename', 'b' => 'a.comment', 'c' => 'a.extension', 'd' => 'a.filesize', 'e' => 'a.download_count', 'f' => 'a.filetime', 'g' => 't.topic_title'); - $sort_key_text = array('a' => $user->lang['SORT_FILENAME'], 'b' => $user->lang['SORT_COMMENT'], 'c' => $user->lang['SORT_EXTENSION'], 'd' => $user->lang['SORT_SIZE'], 'e' => $user->lang['SORT_DOWNLOADS'], 'f' => $user->lang['SORT_POST_TIME'], 'g' => $user->lang['SORT_TOPIC_TITLE']); - $sort_key_sql = array('a' => 'a.real_filename', 'b' => 'a.comment', 'c' => 'a.extension', 'd' => 'a.filesize', 'e' => 'a.download_count', 'f' => 'a.filetime', 'g' => 't.topic_title'); - - $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); + $sd_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); $s_sort_key = ''; - foreach ($sort_key_text as $key => $value) + foreach ($sk_text as $key => $value) { - $selected = ($sort_key == $key) ? ' selected="selected"' : ''; + $selected = ($sk == $key) ? ' selected="selected"' : ''; $s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; } $s_sort_dir = ''; - foreach ($sort_dir_text as $key => $value) + foreach ($sd_text as $key => $value) { - $selected = ($sort_dir == $key) ? ' selected="selected"' : ''; + $selected = ($sd == $key) ? ' selected="selected"' : ''; $s_sort_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; } - $order_by = $sort_key_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC'); + $order_by = $sk_sql[$sk] . ' ' . (($sd == 'a') ? 'ASC' : 'DESC'); $sql = 'SELECT COUNT(*) as num_attachments FROM ' . ATTACHMENTS_TABLE . " WHERE poster_id = $user_id"; $result = $db->sql_query_limit($sql, 1); + $num_attachments = $db->sql_fetchfield('num_attachments', 0, $result); $db->sql_freeresult($result); @@ -1759,65 +1924,66 @@ function marklist(match, status) if ($row = $db->sql_fetchrow($result)) { $class = 'row2'; + ?> <tr> <th nowrap="nowrap">#</th> - <th nowrap="nowrap" width="15%"><a class="th" href="<?php echo $uri . '&sk=a&sd=' . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a'); ?>"><?php echo $user->lang['FILENAME']; ?></a></th> - <th nowrap="nowrap" width="5%"><a class="th" href="<?php echo $uri . '&sk=f&sd=' . (($sort_key == 'f' && $sort_dir == 'a') ? 'd' : 'a'); ?>"><?php echo $user->lang['POST_TIME']; ?></a></th> - <th nowrap="nowrap" width="5%"><a class="th" href="<?php echo $uri . '&sk=d&sd=' . (($sort_key == 'd' && $sort_dir == 'a') ? 'd' : 'a'); ?>"><?php echo $user->lang['FILESIZE']; ?></a></th> - <th nowrap="nowrap" width="5%"><a class="th" href="<?php echo $uri . '&sk=e&sd=' . (($sort_key == 'e' && $sort_dir == 'a') ? 'd' : 'a'); ?>"><?php echo $user->lang['DOWNLOADS']; ?></a></th> + <th nowrap="nowrap" width="15%"><a class="th" href="<?php echo "$uri&sk=a&sd=" . (($sk == 'a' && $sd == 'a') ? 'd' : 'a'); ?>"><?php echo $user->lang['FILENAME']; ?></a></th> + <th nowrap="nowrap" width="5%"><a class="th" href="<?php echo "$uri&sk=f&sd=" . (($sk == 'f' && $sd == 'a') ? 'd' : 'a'); ?>"><?php echo $user->lang['POST_TIME']; ?></a></th> + <th nowrap="nowrap" width="5%"><a class="th" href="<?php echo "$uri&sk=d&sd=" . (($sk == 'd' && $sd == 'a') ? 'd' : 'a'); ?>"><?php echo $user->lang['FILESIZE']; ?></a></th> + <th nowrap="nowrap" width="5%"><a class="th" href="<?php echo "$uri&sk=e&sd=" . (($sk == 'e' && $sd == 'a') ? 'd' : 'a'); ?>"><?php echo $user->lang['DOWNLOADS']; ?></a></th> <th width="2%" nowrap="nowrap"><?php echo $user->lang['DELETE']; ?></th> </tr> <?php + do { $view_topic = "{$phpbb_root_path}viewtopic.$phpEx$SID&t=" . $row['topic_id'] . '&p=' . $row['post_id'] . '#' . $row['post_id']; - $class = ($class == 'row1') ? 'row2' : 'row1'; + + $row_class = ($row_class == 'row1') ? 'row2' : 'row1'; + ?> - <tr class="<?php echo $class; ?>"> - <td class="gen" style="padding: 4px;" align="center" width="2%"> <?php echo $row_count++ + ($start + 1); ?> </td> - <td style="padding: 4px;"><a class="gen" href="<?php echo $phpbb_root_path . 'download.' . $phpEx . $SID . '&id=' . $row['attach_id']; ?>" target="file"><?php echo $row['real_filename']; ?></a><br /><span class="gensmall"><?php echo $user->lang['TOPIC']; ?>: <a href="<?php echo $view_topic; ?>" target="viewtopic"><?php echo $row['topic_title']; ?></a></span></td> - <td class="gensmall" style="padding: 4px;" align="center" valign="middle" nowrap="nowrap"> <?php echo $user->format_date($row['filetime'], $user->lang['DATE_FORMAT']); ?> </td> - <td class="gen" style="padding: 4px;" align="center" valign="middle" nowrap="nowrap"><?php echo ($row['filesize'] >= 1048576) ? (round($row['filesize'] / 1048576 * 100) / 100) . ' ' . $user->lang['MB'] : (($row['filesize'] >= 1024) ? (round($row['filesize'] / 1024 * 100) / 100) . ' ' . $user->lang['KB'] : $row['filesize'] . ' ' . $user->lang['BYTES']); ?></td> - <td class="gen" style="padding: 4px;" align="center"><?php echo $row['download_count']; ?></td> - <td style="padding: 4px;" align="center" valign="middle"><input type="checkbox" name="attachment[<?php echo $row['attach_id']; ?>]" value="1" /></td> + <tr> + <td class="<?php echo $row_class; ?>" style="padding: 4px;" width="2%" align="center"><span class="gen"> <?php echo $row_count + ($start + 1); ?> </span></td> + <td class="<?php echo $row_class; ?>" style="padding: 4px;"><a class="gen" href="<?php echo "{$phpbb_root_path}download.$phpEx$SID&id=" . $row['attach_id']; ?>" target="_blank"><?php echo $row['real_filename']; ?></a><br /><span class="gensmall"><?php echo $user->lang['TOPIC']; ?>: <a href="<?php echo $view_topic; ?>" target="_blank"><?php echo $row['topic_title']; ?></a></span></td> + <td class="<?php echo $row_class; ?>" class="gensmall" style="padding: 4px;" align="center" nowrap="nowrap"> <?php echo $user->format_date($row['filetime'], $user->lang['DATE_FORMAT']); ?> </td> + <td class="<?php echo $row_class; ?>" style="padding: 4px;" align="center" nowrap="nowrap"><span class="gen"><?php echo ($row['filesize'] >= 1048576) ? (round($row['filesize'] / 1048576 * 100) / 100) . ' ' . $user->lang['MB'] : (($row['filesize'] >= 1024) ? (round($row['filesize'] / 1024 * 100) / 100) . ' ' . $user->lang['KB'] : $row['filesize'] . ' ' . $user->lang['BYTES']); ?></span></td> + <td class="<?php echo $row_class; ?>" style="padding: 4px;" align="center"><span class="gen"><?php echo $row['download_count']; ?></span></td> + <td class="<?php echo $row_class; ?>" style="padding: 4px;" align="center"><input type="checkbox" name="mark[<?php echo $row['attach_id']; ?>]" value="1" /></td> </tr> <?php + + $row_count++; } while ($row = $db->sql_fetchrow($result)); } $db->sql_freeresult($result); - $pagination = generate_pagination($uri . "&sk=$sort_key&sd=$sort_dir", $num_attachments, $config['posts_per_page'], $start) + $pagination = generate_pagination("$uri&sk=$sk&sd=$sd", $num_attachments, $config['topics_per_page'], $start); + ?> - <tr> - <td class="cat" colspan="<?php echo $colspan; ?>"><table width="100%" cellspacing="0" cellpadding="0" border="0"> <tr> - <td width="100%" align="center"><span class="gensmall"><?php echo $user->lang['SORT_BY']; ?>: </span><select name="sk"><?php echo $s_sort_key; ?></select> <select name="sd"><?php echo $s_sort_dir; ?></select> <input class="btnlite" type="submit" name="sort" value="<?php echo $user->lang['SORT']; ?>" /></td> - <td align="right"><input class="btnlite" type="submit" name="delmarked" value="<?php echo $user->lang['DELETE_MARKED']; ?>" /> </td> + <td class="cat" colspan="<?php echo $colspan; ?>"><table width="100%" cellspacing="0" cellpadding="0" border="0"> + <tr> + <td width="100%" align="center"><span class="gensmall"><?php echo $user->lang['SORT_BY']; ?>: </span><select name="sk"><?php echo $s_sort_key; ?></select> <select name="sd"><?php echo $s_sort_dir; ?></select> <input class="btnlite" type="submit" name="sort" value="<?php echo $user->lang['SORT']; ?>" /></td> + <td align="right"><input class="btnlite" type="submit" name="delmarked" value="<?php echo $user->lang['DELETE_MARKED']; ?>" /> </td> + </tr> + </table></td> </tr> </table></td> </tr> - </table></td> - </tr> <?php break; } - if ($show_bottom) - { ?> - <tr> - <td class="cat" colspan="2" align="center"><?php echo ($action == 'sig') ? '<input class="btnlite" type="submit" name="preview" value="' . $user->lang['PREVIEW'] . '" /> ' : ''; ?><input class="btnmain" type="submit" name="update" value="<?php echo $user->lang['SUBMIT']; ?>" /> <input class="btnlite" type="reset" value="<?php echo $user->lang['RESET']; ?>" /></td> - </tr> </table></td> </tr> <?php - } if ($pagination) { @@ -1856,7 +2022,7 @@ if (!$auth->acl_get('a_user')) <th colspan="2"align="center"><?php echo $user->lang['SELECT_USER']; ?></th> </tr> <tr> - <td class="row1" width="40%"><b>Lookup existing user: </b><br /><span class="gensmall">[ <a href="<?php echo "../memberlist.$phpEx$SID&mode=searchuser&field=username"; ?>" onclick="window.open('<?php echo "../memberlist.$phpEx$SID&mode=searchuser&field=username"?>', '_phpbbsearch', 'HEIGHT=500,resizable=yes,scrollbars=yes,WIDTH=740');return false;"><?php echo $user->lang['FIND_USERNAME']; ?></a> ]</span></td> + <td class="row1" width="40%"><b><?php echo $user->lang['FIND_USERNAME']; ?>: </b><br /><span class="gensmall">[ <a href="<?php echo "../memberlist.$phpEx$SID&mode=searchuser&field=username"; ?>" onclick="window.open('<?php echo "../memberlist.$phpEx$SID&mode=searchuser&field=username"?>', '_phpbbsearch', 'HEIGHT=500,resizable=yes,scrollbars=yes,WIDTH=740');return false;"><?php echo $user->lang['FIND_USERNAME']; ?></a> ]</span></td> <td class="row2"><input type="text" class="post" name="username" maxlength="50" size="20" /></td> </tr> <tr> @@ -1868,4 +2034,14 @@ if (!$auth->acl_get('a_user')) adm_page_footer(); + +// Module class +class acp_admin_users extends module +{ + + + + +} + ?>
\ No newline at end of file |
