/** * @return array */ public function get_all($select_id = false, $ignore_id = false, $ignore_acl = true, $ignore_nonpost = false, $ignore_emptycat = true, $only_acl_post = false) { $forumlist = make_forum_select($select_id, $ignore_id, $ignore_acl, $ignore_nonpost, $ignore_emptycat, $only_acl_post, true); $forum_options = array('' => 'ALL'); foreach ($forumlist as $row) { $forum_options[$row['forum_id']] = $row['padding'] . $row['forum_name']; } return $forum_options; }
public function select_forums($value, $key) { $forum_list = make_forum_select(false, false, true, true, true, false, true); $selected = array(); if (isset($this->config[$key]) && strlen($this->config[$key]) > 0) { $selected = explode(',', $this->config[$key]); } // Build forum options $s_forum_options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">'; foreach ($forum_list as $f_id => $f_row) { $s_forum_options .= '<option value="' . $f_id . '"' . (in_array($f_id, $selected) ? ' selected="selected"' : '') . ($f_row['disabled'] ? ' disabled="disabled" class="disabled-option"' : '') . '>' . $f_row['padding'] . $f_row['forum_name'] . '</option>'; } $s_forum_options .= '</select>'; return $s_forum_options; }
/** * Event: core.acp_manage_forums_display_form * * @param Event $event */ public function acp_manage_forums_display_form($event) { $this->user->add_lang_ext('kasimi/movetopicswhenlocked', 'acp_forum_settings'); $is_edit = $event['action'] == 'edit'; $forum_data = $event['forum_data']; $template_vars = array('MOVE_TOPICS_WHEN_LOCKED_VERSION' => $this->config['kasimi.movetopicswhenlocked.version'], 'S_MOVE_TOPICS' => $is_edit ? $forum_data['move_topics_when_locked'] : false, 'S_MOVE_TOPICS_TO_OPTIONS' => make_forum_select($is_edit ? $forum_data['move_topics_when_locked_to'] : false, false, false, true)); $topic_solved_extension = $this->user->lang('MOVE_TOPICS_SOLVED_EXTENSION'); if ($this->extension_manager->is_enabled(self::EXT_TOPIC_SOLVED_NAME)) { $metadata = $this->extension_manager->create_extension_metadata_manager(self::EXT_TOPIC_SOLVED_NAME, $this->template)->get_metadata(); $is_valid_version = phpbb_version_compare($metadata['version'], self::EXT_TOPIC_SOLVED_MIN_VERSION, '>='); $template_vars = array_merge($template_vars, array('S_MOVE_TOPICS_SOLVED' => $is_edit ? $forum_data['move_topics_when_locked_solved'] : false, 'MOVE_TOPICS_SOLVED_ENABLED' => $is_valid_version ? $this->user->lang('MOVE_TOPICS_SOLVED_ENABLED', $topic_solved_extension) : false, 'MOVE_TOPICS_SOLVED_VERSION' => $is_valid_version ? false : $this->user->lang('MOVE_TOPICS_SOLVED_VERSION', self::EXT_TOPIC_SOLVED_MIN_VERSION, $topic_solved_extension))); } else { $template_vars['MOVE_TOPICS_SOLVED_DISABLED'] = $this->user->lang('EXTENSION_DISABLED', $topic_solved_extension); } $this->template->assign_vars($template_vars); }
public function main($id, $mode) { global $config, $user, $template, $request; $user->add_lang_ext('tas2580/socialbuttons', 'common'); $this->tpl_name = 'acp_socialbuttons_body'; $this->page_title = $user->lang('ACP_SOCIALBUTTONS_TITLE'); add_form_key('acp_socialbuttons'); // Form is submitted if ($request->is_set_post('submit')) { if (!check_form_key('acp_socialbuttons')) { trigger_error($user->lang('FORM_INVALID') . adm_back_link($this->u_action), E_USER_WARNING); } $forums = implode(',', $request->variable('enable_f', array(0))); $desc_forums = implode(',', $request->variable('enable_og_desc_f', array(0))); // Set the new settings to config $config->set('socialbuttons_position', $request->variable('position', 0)); $config->set('socialbuttons_enable_forums', $forums); $config->set('socialbuttons_display_on_index', $request->variable('display_on_index', 0)); $config->set('socialbuttons_enable', $request->variable('enable', 0)); $config->set('socialbuttons_cachetime', $request->variable('cachetime', 0)); $config->set('socialbuttons_multiplicator', $request->variable('multiplicator', 1)); $config->set('socialbuttons_facebook', $request->variable('facebook', 0)); $config->set('socialbuttons_twitter', $request->variable('twitter', 0)); $config->set('socialbuttons_google', $request->variable('google', 0)); $config->set('socialbuttons_linkedin', $request->variable('linkedin', 0)); $config->set('socialbuttons_style', $request->variable('style', 1)); $config->set('socialbuttons_showshares', $request->variable('showshares', 0)); $config->set('socialbuttons_use_seo_urls', $request->variable('use_seo_urls', '')); $config->set('socialbuttons_enable_og', $request->variable('enable_og', 0)); $config->set('socialbuttons_enable_og_title', $request->variable('enable_og_title', 0)); $config->set('socialbuttons_enable_og_desc', $request->variable('enable_og_desc', 0)); $config->set('socialbuttons_og_image', $request->variable('og_image', '')); $config->set('socialbuttons_enable_og_desc_forums', $desc_forums); trigger_error($user->lang('ACP_SAVED') . adm_back_link($this->u_action)); } // Send the curent settings to template $position = isset($config['socialbuttons_position']) ? $config['socialbuttons_position'] : false; $multiplicator = isset($config['socialbuttons_multiplicator']) ? $config['socialbuttons_multiplicator'] : true; $style = isset($config['socialbuttons_style']) ? $config['socialbuttons_style'] : true; $desc_forums = isset($config['socialbuttons_enable_og_desc_forums']) ? explode(',', $config['socialbuttons_enable_og_desc_forums']) : array(); $forums = isset($config['socialbuttons_enable_forums']) ? explode(',', $config['socialbuttons_enable_forums']) : array(); $template->assign_vars(array('U_ACTION' => $this->u_action, 'POSITION_OPTIONS' => $this->position_select($position), 'MULTIPLICATOR_OPTIONS' => $this->multiplicator_select($multiplicator), 'BUTTON_STYLES' => $this->button_style($style), 'S_ENABLE' => isset($config['socialbuttons_enable']) ? $config['socialbuttons_enable'] : false, 'S_DISPLAY_ON_INDEX' => isset($config['socialbuttons_display_on_index']) ? $config['socialbuttons_display_on_index'] : false, 'S_USE_SEO_URLS' => isset($config['socialbuttons_use_seo_urls']) ? $config['socialbuttons_use_seo_urls'] : false, 'S_SHOWSHARES' => isset($config['socialbuttons_showshares']) ? $config['socialbuttons_showshares'] : false, 'CACHETIME' => isset($config['socialbuttons_cachetime']) ? $config['socialbuttons_cachetime'] : false, 'S_FACEBOOK' => isset($config['socialbuttons_facebook']) ? $config['socialbuttons_facebook'] : '', 'S_TWITTER' => isset($config['socialbuttons_twitter']) ? $config['socialbuttons_twitter'] : '', 'S_GOOGLE' => isset($config['socialbuttons_google']) ? $config['socialbuttons_google'] : '', 'S_LINKEDIN' => isset($config['socialbuttons_linkedin']) ? $config['socialbuttons_linkedin'] : '', 'S_ENABLE_OG' => isset($config['socialbuttons_enable_og']) ? $config['socialbuttons_enable_og'] : '', 'S_ENABLE_OG_TITLE' => isset($config['socialbuttons_enable_og_title']) ? $config['socialbuttons_enable_og_title'] : '', 'S_ENABLE_OG_DESC' => isset($config['socialbuttons_enable_og_desc']) ? $config['socialbuttons_enable_og_desc'] : '', 'OG_IMAGE' => isset($config['socialbuttons_og_image']) ? $config['socialbuttons_og_image'] : '', 'FORUM_DESC_SELECT' => make_forum_select($desc_forums, false, false, true), 'FORUM_ENABLE_SELECT' => make_forum_select($forums, false, false, true))); }
function main($id, $mode) { global $db, $user, $auth, $template, $cache, $request; global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; $this->db = $db; $this->config = $config; $this->request = $request; $this->tpl_name = 'acp_maps'; $this->page_title = $user->lang('ACP_MAPS'); add_form_key('saturnZ/maps'); if ($request->is_set_post('submit')) { if (!check_form_key('saturnZ/maps')) { trigger_error('FORM_INVALID'); } $config->set('maps_center', $request->variable('center', '57.16565146, 65.54499550')); $config->set('maps_title', $request->variable('title', 'Яндекс Карта', true)); $config->set('maps_group', implode(',', $request->variable('maps_group', array(0)))); $config->set('maps_group_edit', implode(',', $request->variable('maps_group_edit', array(0)))); $config->set('maps_group_delete', implode(',', $request->variable('maps_group_delete', array(0)))); $config->set('maps_posts_forum', $request->variable('maps_posts_forum', 1)); $config->set('maps_Placemark_posts', $request->variable('Placemark', 0)); $config->set('maps_post', $request->variable('maps_post', 1)); $config->set('maps_reputation', $request->variable('reputation', 1)); $config->set('maps_bounds', $request->variable('bounds', 1)); trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action)); } $groups_ary = explode(',', $this->config['maps_group']); $groups_edit_ary = explode(',', $this->config['maps_group_edit']); $groups_delete_ary = explode(',', $this->config['maps_group_delete']); // get group info from database and assign the block vars $sql = 'SELECT group_id, group_name FROM ' . GROUPS_TABLE . ' ORDER BY group_id ASC'; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { $template->assign_block_vars('group_setting', array('SELECTED' => in_array($row['group_id'], $groups_ary) ? true : false, 'GROUP_NAME' => isset($user->lang['G_' . $row['group_name']]) ? $user->lang['G_' . $row['group_name']] : $row['group_name'], 'GROUP_ID' => $row['group_id'])); $template->assign_block_vars('group_edit_setting', array('SELECTED' => in_array($row['group_id'], $groups_edit_ary) ? true : false, 'GROUP_NAME' => isset($user->lang['G_' . $row['group_name']]) ? $user->lang['G_' . $row['group_name']] : $row['group_name'], 'GROUP_ID' => $row['group_id'])); $template->assign_block_vars('group_delete_setting', array('SELECTED' => in_array($row['group_id'], $groups_delete_ary) ? true : false, 'GROUP_NAME' => isset($user->lang['G_' . $row['group_name']]) ? $user->lang['G_' . $row['group_name']] : $row['group_name'], 'GROUP_ID' => $row['group_id'])); } $template->assign_vars(array('U_ACTION' => $this->u_action, 'CENTER' => isset($config['maps_center']) ? $config['maps_center'] : '57.16565146, 65.54499550', 'TITLE' => isset($config['maps_title']) ? $config['maps_title'] : 'Яндекс Карта', 'POSTS_FORUM' => make_forum_select(isset($config['maps_posts_forum']) ? $config['maps_posts_forum'] : 1, false, false, true), 'PLACEMARK' => isset($this->config['maps_Placemark_posts']) ? $this->config['maps_Placemark_posts'] : 0, 'MAPS_POST' => isset($this->config['maps_post']) ? $this->config['maps_post'] : 1, 'REPUTATION' => isset($this->config['maps_reputation']) ? $this->config['maps_reputation'] : 1, 'BOUNDS' => isset($this->config['maps_bounds']) ? $this->config['maps_bounds'] : 1)); }
/** * Display permission mask (assign to template) */ function display_mask($mode, $permission_type, &$hold_ary, $user_mode = 'user', $local = false, $group_display = true) { global $template, $user, $db, $phpbb_container; /* @var $phpbb_permissions \phpbb\permissions */ $phpbb_permissions = $phpbb_container->get('acl.permissions'); /** @var \phpbb\group\helper $group_helper */ $group_helper = $phpbb_container->get('group_helper'); // Define names for template loops, might be able to be set $tpl_pmask = 'p_mask'; $tpl_fmask = 'f_mask'; $tpl_category = 'category'; $tpl_mask = 'mask'; $l_acl_type = $phpbb_permissions->get_type_lang($permission_type, $local ? 'local' : 'global'); // Allow trace for viewing permissions and in user mode $show_trace = $mode == 'view' && $user_mode == 'user' ? true : false; // Get names if ($user_mode == 'user') { $sql = 'SELECT user_id as ug_id, username as ug_name FROM ' . USERS_TABLE . ' WHERE ' . $db->sql_in_set('user_id', array_keys($hold_ary)) . ' ORDER BY username_clean ASC'; } else { $sql = 'SELECT group_id as ug_id, group_name as ug_name, group_type FROM ' . GROUPS_TABLE . ' WHERE ' . $db->sql_in_set('group_id', array_keys($hold_ary)) . ' ORDER BY group_type DESC, group_name ASC'; } $result = $db->sql_query($sql); $ug_names_ary = array(); while ($row = $db->sql_fetchrow($result)) { $ug_names_ary[$row['ug_id']] = $user_mode == 'user' ? $row['ug_name'] : $group_helper->get_name($row['ug_name']); } $db->sql_freeresult($result); // Get used forums $forum_ids = array(); foreach ($hold_ary as $ug_id => $row) { $forum_ids = array_merge($forum_ids, array_keys($row)); } $forum_ids = array_unique($forum_ids); $forum_names_ary = array(); if ($local) { $forum_names_ary = make_forum_select(false, false, true, false, false, false, true); // Remove the disabled ones, since we do not create an option field here... foreach ($forum_names_ary as $key => $value) { if (!$value['disabled']) { continue; } unset($forum_names_ary[$key]); } } else { $forum_names_ary[0] = $l_acl_type; } // Get available roles $sql = 'SELECT * FROM ' . ACL_ROLES_TABLE . "\n\t\t\tWHERE role_type = '" . $db->sql_escape($permission_type) . "'\n\t\t\tORDER BY role_order ASC"; $result = $db->sql_query($sql); $roles = array(); while ($row = $db->sql_fetchrow($result)) { $roles[$row['role_id']] = $row; } $db->sql_freeresult($result); $cur_roles = $this->acl_role_data($user_mode, $permission_type, array_keys($hold_ary)); // Build js roles array (role data assignments) $s_role_js_array = ''; if (sizeof($roles)) { $s_role_js_array = array(); // Make sure every role (even if empty) has its array defined foreach ($roles as $_role_id => $null) { $s_role_js_array[$_role_id] = "\n" . 'role_options[' . $_role_id . '] = new Array();' . "\n"; } $sql = 'SELECT r.role_id, o.auth_option, r.auth_setting FROM ' . ACL_ROLES_DATA_TABLE . ' r, ' . ACL_OPTIONS_TABLE . ' o WHERE o.auth_option_id = r.auth_option_id AND ' . $db->sql_in_set('r.role_id', array_keys($roles)); $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $flag = substr($row['auth_option'], 0, strpos($row['auth_option'], '_') + 1); if ($flag == $row['auth_option']) { continue; } $s_role_js_array[$row['role_id']] .= 'role_options[' . $row['role_id'] . '][\'' . addslashes($row['auth_option']) . '\'] = ' . $row['auth_setting'] . '; '; } $db->sql_freeresult($result); $s_role_js_array = implode('', $s_role_js_array); } $template->assign_var('S_ROLE_JS_ARRAY', $s_role_js_array); unset($s_role_js_array); // Now obtain memberships $user_groups_default = $user_groups_custom = array(); if ($user_mode == 'user' && $group_display) { $sql = 'SELECT group_id, group_name, group_type FROM ' . GROUPS_TABLE . ' ORDER BY group_type DESC, group_name ASC'; $result = $db->sql_query($sql); $groups = array(); while ($row = $db->sql_fetchrow($result)) { $groups[$row['group_id']] = $row; } $db->sql_freeresult($result); $memberships = group_memberships(false, array_keys($hold_ary), false); // User is not a member of any group? Bad admin, bad bad admin... if ($memberships) { foreach ($memberships as $row) { $user_groups_default[$row['user_id']][] = $group_helper->get_name($groups[$row['group_id']]['group_name']); } } unset($memberships, $groups); } // If we only have one forum id to display or being in local mode and more than one user/group to display, // we switch the complete interface to group by user/usergroup instead of grouping by forum // To achieve this, we need to switch the array a bit if (sizeof($forum_ids) == 1 || $local && sizeof($ug_names_ary) > 1) { $hold_ary_temp = $hold_ary; $hold_ary = array(); foreach ($hold_ary_temp as $ug_id => $row) { foreach ($forum_names_ary as $forum_id => $forum_row) { if (isset($row[$forum_id])) { $hold_ary[$forum_id][$ug_id] = $row[$forum_id]; } } } unset($hold_ary_temp); foreach ($hold_ary as $forum_id => $forum_array) { $content_array = $categories = array(); $this->build_permission_array($hold_ary[$forum_id], $content_array, $categories, array_keys($ug_names_ary)); $template->assign_block_vars($tpl_pmask, array('NAME' => $forum_id == 0 ? $forum_names_ary[0] : $forum_names_ary[$forum_id]['forum_name'], 'PADDING' => $forum_id == 0 ? '' : $forum_names_ary[$forum_id]['padding'], 'CATEGORIES' => implode('</th><th>', $categories), 'L_ACL_TYPE' => $l_acl_type, 'S_LOCAL' => $local ? true : false, 'S_GLOBAL' => !$local ? true : false, 'S_NUM_CATS' => sizeof($categories), 'S_VIEW' => $mode == 'view' ? true : false, 'S_NUM_OBJECTS' => sizeof($content_array), 'S_USER_MODE' => $user_mode == 'user' ? true : false, 'S_GROUP_MODE' => $user_mode == 'group' ? true : false)); @reset($content_array); while (list($ug_id, $ug_array) = each($content_array)) { // Build role dropdown options $current_role_id = isset($cur_roles[$ug_id][$forum_id]) ? $cur_roles[$ug_id][$forum_id] : 0; // Output current role id to template $template->assign_var('S_ROLE_ID', $current_role_id); @reset($roles); while (list($role_id, $role_row) = each($roles)) { $role_description = !empty($user->lang[$role_row['role_description']]) ? $user->lang[$role_row['role_description']] : nl2br($role_row['role_description']); $role_name = !empty($user->lang[$role_row['role_name']]) ? $user->lang[$role_row['role_name']] : $role_row['role_name']; $template->assign_block_vars('role_options', array('ID' => $role_id, 'ROLE_NAME' => $role_name, 'TITLE' => $role_description, 'SELECTED' => $role_id == $current_role_id)); } if (!$current_role_id && $mode != 'view') { $s_custom_permissions = false; foreach ($ug_array as $key => $value) { if ($value['S_NEVER'] || $value['S_YES']) { $s_custom_permissions = true; break; } } } else { $s_custom_permissions = false; } $template->assign_block_vars($tpl_pmask . '.' . $tpl_fmask, array('NAME' => $ug_names_ary[$ug_id], 'UG_ID' => $ug_id, 'S_CUSTOM' => $s_custom_permissions, 'FORUM_ID' => $forum_id)); $this->assign_cat_array($ug_array, $tpl_pmask . '.' . $tpl_fmask . '.' . $tpl_category, $tpl_mask, $ug_id, $forum_id, $mode == 'view', $show_trace); unset($content_array[$ug_id]); } unset($hold_ary[$forum_id]); } } else { foreach ($ug_names_ary as $ug_id => $ug_name) { if (!isset($hold_ary[$ug_id])) { continue; } $content_array = $categories = array(); $this->build_permission_array($hold_ary[$ug_id], $content_array, $categories, array_keys($forum_names_ary)); $template->assign_block_vars($tpl_pmask, array('NAME' => $ug_name, 'CATEGORIES' => implode('</th><th>', $categories), 'USER_GROUPS_DEFAULT' => $user_mode == 'user' && isset($user_groups_default[$ug_id]) && sizeof($user_groups_default[$ug_id]) ? implode($user->lang['COMMA_SEPARATOR'], $user_groups_default[$ug_id]) : '', 'USER_GROUPS_CUSTOM' => $user_mode == 'user' && isset($user_groups_custom[$ug_id]) && sizeof($user_groups_custom[$ug_id]) ? implode($user->lang['COMMA_SEPARATOR'], $user_groups_custom[$ug_id]) : '', 'L_ACL_TYPE' => $l_acl_type, 'S_LOCAL' => $local ? true : false, 'S_GLOBAL' => !$local ? true : false, 'S_NUM_CATS' => sizeof($categories), 'S_VIEW' => $mode == 'view' ? true : false, 'S_NUM_OBJECTS' => sizeof($content_array), 'S_USER_MODE' => $user_mode == 'user' ? true : false, 'S_GROUP_MODE' => $user_mode == 'group' ? true : false)); @reset($content_array); while (list($forum_id, $forum_array) = each($content_array)) { // Build role dropdown options $current_role_id = isset($cur_roles[$ug_id][$forum_id]) ? $cur_roles[$ug_id][$forum_id] : 0; // Output current role id to template $template->assign_var('S_ROLE_ID', $current_role_id); @reset($roles); while (list($role_id, $role_row) = each($roles)) { $role_description = !empty($user->lang[$role_row['role_description']]) ? $user->lang[$role_row['role_description']] : nl2br($role_row['role_description']); $role_name = !empty($user->lang[$role_row['role_name']]) ? $user->lang[$role_row['role_name']] : $role_row['role_name']; $template->assign_block_vars('role_options', array('ID' => $role_id, 'ROLE_NAME' => $role_name, 'TITLE' => $role_description, 'SELECTED' => $role_id == $current_role_id)); } if (!$current_role_id && $mode != 'view') { $s_custom_permissions = false; foreach ($forum_array as $key => $value) { if ($value['S_NEVER'] || $value['S_YES']) { $s_custom_permissions = true; break; } } } else { $s_custom_permissions = false; } $template->assign_block_vars($tpl_pmask . '.' . $tpl_fmask, array('NAME' => $forum_id == 0 ? $forum_names_ary[0] : $forum_names_ary[$forum_id]['forum_name'], 'PADDING' => $forum_id == 0 ? '' : $forum_names_ary[$forum_id]['padding'], 'S_CUSTOM' => $s_custom_permissions, 'UG_ID' => $ug_id, 'FORUM_ID' => $forum_id)); $this->assign_cat_array($forum_array, $tpl_pmask . '.' . $tpl_fmask . '.' . $tpl_category, $tpl_mask, $ug_id, $forum_id, $mode == 'view', $show_trace); } unset($hold_ary[$ug_id], $ug_names_ary[$ug_id]); } } }
if ($row && !$row['forum_id'] && $row['topic_type'] == POST_GLOBAL) { $to_forum_id = request_var('to_forum_id', 0); if ($to_forum_id) { $sql = 'SELECT forum_type FROM ' . FORUMS_TABLE . ' WHERE forum_id = ' . $to_forum_id; $result = $db->sql_query($sql); $forum_type = (int) $db->sql_fetchfield('forum_type'); $db->sql_freeresult($result); if ($forum_type != FORUM_POST || !$auth->acl_get('f_post', $to_forum_id) || !$auth->acl_get('f_noapprove', $to_forum_id)) { $to_forum_id = 0; } } if (!$to_forum_id) { include_once $phpbb_root_path . 'includes/functions_admin.' . $phpEx; $template->assign_vars(array('S_FORUM_SELECT' => make_forum_select(false, false, false, true, true, true), 'S_UNGLOBALISE' => true)); $submit = false; $refresh = true; } else { if (!$auth->acl_get('f_post', $to_forum_id)) { // This will only be triggered if the user tried to trick the forum. trigger_error('NOT_AUTHORISED'); } $forum_id = $to_forum_id; } } } if ($submit) { // Lock/Unlock Topic $change_topic_status = $post_data['topic_status']; $perm_lock_unlock = $auth->acl_get('m_lock', $forum_id) || $auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && !empty($post_data['topic_poster']) && $user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED ? true : false;
/** * Fork Topic */ function mcp_fork_topic($topic_ids) { global $auth, $user, $db, $template, $config; global $phpEx, $phpbb_root_path, $phpbb_log, $request, $phpbb_dispatcher; if (!phpbb_check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_'))) { return; } $to_forum_id = $request->variable('to_forum_id', 0); $forum_id = $request->variable('f', 0); $redirect = $request->variable('redirect', build_url(array('action', 'quickmod'))); $additional_msg = $success_msg = ''; $counter = array(); $s_hidden_fields = build_hidden_fields(array('topic_id_list' => $topic_ids, 'f' => $forum_id, 'action' => 'fork', 'redirect' => $redirect)); if ($to_forum_id) { $forum_data = phpbb_get_forum_data($to_forum_id, 'f_post'); if (!sizeof($topic_ids)) { $additional_msg = $user->lang['NO_TOPIC_SELECTED']; } else { if (!sizeof($forum_data)) { $additional_msg = $user->lang['FORUM_NOT_EXIST']; } else { $forum_data = $forum_data[$to_forum_id]; if ($forum_data['forum_type'] != FORUM_POST) { $additional_msg = $user->lang['FORUM_NOT_POSTABLE']; } else { if (!$auth->acl_get('f_post', $to_forum_id)) { $additional_msg = $user->lang['USER_CANNOT_POST']; } } } } } else { if (isset($_POST['confirm'])) { $additional_msg = $user->lang['FORUM_NOT_EXIST']; } } if ($additional_msg) { $request->overwrite('confirm', null, \phpbb\request\request_interface::POST); $request->overwrite('confirm_key', null); } if (confirm_box(true)) { $topic_data = phpbb_get_topic_data($topic_ids, 'f_post'); $total_topics = $total_topics_unapproved = $total_topics_softdeleted = 0; $total_posts = $total_posts_unapproved = $total_posts_softdeleted = 0; $new_topic_id_list = array(); foreach ($topic_data as $topic_id => $topic_row) { if (!isset($search_type) && $topic_row['enable_indexing']) { // Select the search method and do some additional checks to ensure it can actually be utilised $search_type = $config['search_type']; if (!class_exists($search_type)) { trigger_error('NO_SUCH_SEARCH_MODULE'); } $error = false; $search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher); $search_mode = 'post'; if ($error) { trigger_error($error); } } else { if (!isset($search_type) && !$topic_row['enable_indexing']) { $search_type = false; } } $sql_ary = array('forum_id' => (int) $to_forum_id, 'icon_id' => (int) $topic_row['icon_id'], 'topic_attachment' => (int) $topic_row['topic_attachment'], 'topic_visibility' => (int) $topic_row['topic_visibility'], 'topic_reported' => 0, 'topic_title' => (string) $topic_row['topic_title'], 'topic_poster' => (int) $topic_row['topic_poster'], 'topic_time' => (int) $topic_row['topic_time'], 'topic_posts_approved' => (int) $topic_row['topic_posts_approved'], 'topic_posts_unapproved' => (int) $topic_row['topic_posts_unapproved'], 'topic_posts_softdeleted' => (int) $topic_row['topic_posts_softdeleted'], 'topic_status' => (int) $topic_row['topic_status'], 'topic_type' => (int) $topic_row['topic_type'], 'topic_first_poster_name' => (string) $topic_row['topic_first_poster_name'], 'topic_last_poster_id' => (int) $topic_row['topic_last_poster_id'], 'topic_last_poster_name' => (string) $topic_row['topic_last_poster_name'], 'topic_last_post_time' => (int) $topic_row['topic_last_post_time'], 'topic_last_view_time' => (int) $topic_row['topic_last_view_time'], 'topic_bumped' => (int) $topic_row['topic_bumped'], 'topic_bumper' => (int) $topic_row['topic_bumper'], 'poll_title' => (string) $topic_row['poll_title'], 'poll_start' => (int) $topic_row['poll_start'], 'poll_length' => (int) $topic_row['poll_length'], 'poll_max_options' => (int) $topic_row['poll_max_options'], 'poll_vote_change' => (int) $topic_row['poll_vote_change']); $db->sql_query('INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); $new_topic_id = $db->sql_nextid(); $new_topic_id_list[$topic_id] = $new_topic_id; switch ($topic_row['topic_visibility']) { case ITEM_APPROVED: $total_topics++; break; case ITEM_UNAPPROVED: case ITEM_REAPPROVE: $total_topics_unapproved++; break; case ITEM_DELETED: $total_topics_softdeleted++; break; } if ($topic_row['poll_start']) { $poll_rows = array(); $sql = 'SELECT * FROM ' . POLL_OPTIONS_TABLE . "\n\t\t\t\t\tWHERE topic_id = {$topic_id}"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $sql_ary = array('poll_option_id' => (int) $row['poll_option_id'], 'topic_id' => (int) $new_topic_id, 'poll_option_text' => (string) $row['poll_option_text'], 'poll_option_total' => 0); $db->sql_query('INSERT INTO ' . POLL_OPTIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); } $db->sql_freeresult($result); } $sql = 'SELECT * FROM ' . POSTS_TABLE . "\n\t\t\t\tWHERE topic_id = {$topic_id}\n\t\t\t\tORDER BY post_time ASC, post_id ASC"; $result = $db->sql_query($sql); $post_rows = array(); while ($row = $db->sql_fetchrow($result)) { $post_rows[] = $row; } $db->sql_freeresult($result); if (!sizeof($post_rows)) { continue; } foreach ($post_rows as $row) { $sql_ary = array('topic_id' => (int) $new_topic_id, 'forum_id' => (int) $to_forum_id, 'poster_id' => (int) $row['poster_id'], 'icon_id' => (int) $row['icon_id'], 'poster_ip' => (string) $row['poster_ip'], 'post_time' => (int) $row['post_time'], 'post_visibility' => (int) $row['post_visibility'], 'post_reported' => 0, 'enable_bbcode' => (int) $row['enable_bbcode'], 'enable_smilies' => (int) $row['enable_smilies'], 'enable_magic_url' => (int) $row['enable_magic_url'], 'enable_sig' => (int) $row['enable_sig'], 'post_username' => (string) $row['post_username'], 'post_subject' => (string) $row['post_subject'], 'post_text' => (string) $row['post_text'], 'post_edit_reason' => (string) $row['post_edit_reason'], 'post_edit_user' => (int) $row['post_edit_user'], 'post_checksum' => (string) $row['post_checksum'], 'post_attachment' => (int) $row['post_attachment'], 'bbcode_bitfield' => $row['bbcode_bitfield'], 'bbcode_uid' => (string) $row['bbcode_uid'], 'post_edit_time' => (int) $row['post_edit_time'], 'post_edit_count' => (int) $row['post_edit_count'], 'post_edit_locked' => (int) $row['post_edit_locked'], 'post_postcount' => $row['post_postcount']); // Adjust post count only if the post can be incremented to the user counter if ($row['post_postcount']) { if (isset($counter[$row['poster_id']])) { ++$counter[$row['poster_id']]; } else { $counter[$row['poster_id']] = 1; } } $db->sql_query('INSERT INTO ' . POSTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); $new_post_id = $db->sql_nextid(); switch ($row['post_visibility']) { case ITEM_APPROVED: $total_posts++; break; case ITEM_UNAPPROVED: case ITEM_REAPPROVE: $total_posts_unapproved++; break; case ITEM_DELETED: $total_posts_softdeleted++; break; } // Copy whether the topic is dotted markread('post', $to_forum_id, $new_topic_id, 0, $row['poster_id']); if (!empty($search_type)) { $search->index($search_mode, $new_post_id, $sql_ary['post_text'], $sql_ary['post_subject'], $sql_ary['poster_id'], $topic_row['topic_type'] == POST_GLOBAL ? 0 : $to_forum_id); $search_mode = 'reply'; // After one we index replies } // Copy Attachments if ($row['post_attachment']) { $sql = 'SELECT * FROM ' . ATTACHMENTS_TABLE . "\n\t\t\t\t\t\tWHERE post_msg_id = {$row['post_id']}\n\t\t\t\t\t\t\tAND topic_id = {$topic_id}\n\t\t\t\t\t\t\tAND in_message = 0"; $result = $db->sql_query($sql); $sql_ary = array(); while ($attach_row = $db->sql_fetchrow($result)) { $sql_ary[] = array('post_msg_id' => (int) $new_post_id, 'topic_id' => (int) $new_topic_id, 'in_message' => 0, 'is_orphan' => (int) $attach_row['is_orphan'], 'poster_id' => (int) $attach_row['poster_id'], 'physical_filename' => (string) utf8_basename($attach_row['physical_filename']), 'real_filename' => (string) utf8_basename($attach_row['real_filename']), 'download_count' => (int) $attach_row['download_count'], 'attach_comment' => (string) $attach_row['attach_comment'], 'extension' => (string) $attach_row['extension'], 'mimetype' => (string) $attach_row['mimetype'], 'filesize' => (int) $attach_row['filesize'], 'filetime' => (int) $attach_row['filetime'], 'thumbnail' => (int) $attach_row['thumbnail']); } $db->sql_freeresult($result); if (sizeof($sql_ary)) { $db->sql_multi_insert(ATTACHMENTS_TABLE, $sql_ary); } } } // Copy topic subscriptions to new topic $sql = 'SELECT user_id, notify_status FROM ' . TOPICS_WATCH_TABLE . ' WHERE topic_id = ' . $topic_id; $result = $db->sql_query($sql); $sql_ary = array(); while ($row = $db->sql_fetchrow($result)) { $sql_ary[] = array('topic_id' => (int) $new_topic_id, 'user_id' => (int) $row['user_id'], 'notify_status' => (int) $row['notify_status']); } $db->sql_freeresult($result); if (sizeof($sql_ary)) { $db->sql_multi_insert(TOPICS_WATCH_TABLE, $sql_ary); } // Copy bookmarks to new topic $sql = 'SELECT user_id FROM ' . BOOKMARKS_TABLE . ' WHERE topic_id = ' . $topic_id; $result = $db->sql_query($sql); $sql_ary = array(); while ($row = $db->sql_fetchrow($result)) { $sql_ary[] = array('topic_id' => (int) $new_topic_id, 'user_id' => (int) $row['user_id']); } $db->sql_freeresult($result); if (sizeof($sql_ary)) { $db->sql_multi_insert(BOOKMARKS_TABLE, $sql_ary); } } // Sync new topics, parent forums and board stats $sql = 'UPDATE ' . FORUMS_TABLE . ' SET forum_posts_approved = forum_posts_approved + ' . $total_posts . ', forum_posts_unapproved = forum_posts_unapproved + ' . $total_posts_unapproved . ', forum_posts_softdeleted = forum_posts_softdeleted + ' . $total_posts_softdeleted . ', forum_topics_approved = forum_topics_approved + ' . $total_topics . ', forum_topics_unapproved = forum_topics_unapproved + ' . $total_topics_unapproved . ', forum_topics_softdeleted = forum_topics_softdeleted + ' . $total_topics_softdeleted . ' WHERE forum_id = ' . $to_forum_id; $db->sql_query($sql); if (!empty($counter)) { // Do only one query per user and not a query per post. foreach ($counter as $user_id => $count) { $sql = 'UPDATE ' . USERS_TABLE . ' SET user_posts = user_posts + ' . (int) $count . ' WHERE user_id = ' . (int) $user_id; $db->sql_query($sql); } } sync('topic', 'topic_id', $new_topic_id_list); sync('forum', 'forum_id', $to_forum_id); $config->increment('num_topics', sizeof($new_topic_id_list), false); $config->increment('num_posts', $total_posts, false); foreach ($new_topic_id_list as $topic_id => $new_topic_id) { $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_FORK', false, array('forum_id' => $to_forum_id, 'topic_id' => $new_topic_id, $topic_row['forum_name'])); } $success_msg = sizeof($topic_ids) == 1 ? 'TOPIC_FORKED_SUCCESS' : 'TOPICS_FORKED_SUCCESS'; } else { $template->assign_vars(array('S_FORUM_SELECT' => make_forum_select($to_forum_id, false, false, true, true, true), 'S_CAN_LEAVE_SHADOW' => false, 'ADDITIONAL_MSG' => $additional_msg)); confirm_box(false, 'FORK_TOPIC' . (sizeof($topic_ids) == 1 ? '' : 'S'), $s_hidden_fields, 'mcp_move.html'); } $redirect = $request->variable('redirect', "index.{$phpEx}"); $redirect = reapply_sid($redirect); if (!$success_msg) { redirect($redirect); } else { $redirect_url = append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $forum_id); meta_refresh(3, $redirect_url); $return_link = sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect_url . '">', '</a>'); if ($forum_id != $to_forum_id) { $return_link .= '<br /><br />' . sprintf($user->lang['RETURN_NEW_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $to_forum_id) . '">', '</a>'); } trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link); } }
function main($id, $mode) { global $db, $user, $auth, $template; global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; //More Complicated Parts of Script switch ($mode) { case 'index': case 'view': $this->page_title = 'View Website Settings'; $this->tpl_name = 'acp_rcms_settings'; $sql = "SELECT * FROM " . SITE_SETTINGS; $result = $db->sql_query($sql); $site_settings = array(); while ($row = $db->sql_fetchrow($result)) { $site_settings[$row['setting_name']]['value'] = $row['setting_value']; $site_settings[$row['setting_name']]['type'] = $row['setting_type']; } $site_settings['welcome_text']['value'] = generate_text_for_display($site_settings['welcome_text']['value'], $site_settings['welcome_bbcode_uid']['value'], $site_settings['welcome_bbcode_bitfield']['value'], $site_settings['site_bbcode_options']['value']); $db->sql_freeresult($result); $keys = array_keys($site_settings); foreach ($keys as $key) { $template->assign_vars(array(strtoupper($key) => $site_settings[$key]['type'] == 'BOOL' ? $site_settings[$key]['value'] ? true : false : $site_settings[$key]['value'])); } $db->sql_freeresult($result); break; case 'edit': $this->page_title = 'Edit Website Settings'; $this->tpl_name = 'acp_rcms_settings_edit'; $sql = "SELECT * FROM " . SITE_SETTINGS; $result = $db->sql_query($sql); $site_settings = array(); $vars = array(); while ($row = $db->sql_fetchrow($result)) { $site_settings[$row['setting_name']] = array('setting_value' => $row['setting_value'], 'setting_type' => $row['setting_type']); $vars[strtoupper($row['setting_name'])] = $row['setting_value']; } $db->sql_freeresult($result); $forum_list = make_forum_select(false, false, true, true, true, false, true); // Build forum options $s_forum_options = '<select name="news_forum">'; foreach ($forum_list as $f_id => $f_row) { $f_row['selected'] = $site_settings['news_forum']['setting_value'] == $f_id ? true : false; $s_forum_options .= '<option value="' . $f_id . '"' . ($f_row['selected'] ? ' selected="selected"' : '') . ($f_row['disabled'] ? ' disabled="disabled" class="disabled-option"' : '') . '>' . $f_row['padding'] . $f_row['forum_name'] . '</option>'; } $s_forum_options .= '</select>'; decode_message($site_settings['welcome_text']['setting_value'], $site_settings['welcome_bbcode_uid']['setting_value']); $vars['WELCOME_TEXT'] = $site_settings['welcome_text']['setting_value']; $vars += array("FORM_ACTION" => $this->u_action, "U_BACK" => append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=rayth_cms'), "NEWS_FORUM_SELECT" => $s_forum_options); $template->assign_vars($vars); $db->sql_freeresult($result); $update = isset($_POST['save_settings']) ? true : false; if ($update) { $welcome_text = request_var('welcome_text', 'Some Text Here'); $news_forum = request_var('news_forum', 2); $news_post_count = request_var('news_post_count', 0); $welcome_text = utf8_normalize_nfc($welcome_text); $uid = $bitfield = $options = ''; // will be modified by generate_text_for_storage $allow_bbcode = $allow_urls = $allow_smilies = true; $display_sidebar = request_var('display_sidebar', 0); $sidebar_recent_reply_count = request_var('sidebar_recent_reply_count', 0); generate_text_for_storage($welcome_text, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies); $db->sql_query("UPDATE " . SITE_SETTINGS . " SET setting_value='{$uid}' WHERE setting_name='welcome_bbcode_uid';"); $db->sql_query("UPDATE " . SITE_SETTINGS . " SET setting_value='{$bitfield}' WHERE setting_name='welcome_bbcode_bitfield';"); $db->sql_query("UPDATE " . SITE_SETTINGS . " SET setting_value=\"{$welcome_text}\" WHERE setting_name='welcome_text';"); $site_settings['welcome_text']['setting_value'] = $welcome_text; $db->sql_query("UPDATE " . SITE_SETTINGS . " SET setting_value=\"{$news_forum}\" WHERE setting_name='news_forum';"); $site_settings['news_forum']['setting_value'] = $news_forum; $db->sql_query("UPDATE " . SITE_SETTINGS . " SET setting_value=\"{$news_post_count}\" WHERE setting_name='news_post_count';"); $site_settings['news_post_count']['setting_value'] = $news_post_count; $db->sql_query("UPDATE " . SITE_SETTINGS . " SET setting_value=\"{$display_sidebar}\" WHERE setting_name='display_sidebar';"); $site_settings['display_sidebar']['setting_value'] = $display_sidebar; $db->sql_query("UPDATE " . SITE_SETTINGS . " SET setting_value=\"{$sidebar_recent_reply_count}\" WHERE setting_name='sidebar_recent_reply_count';"); $site_settings['sidebar_recent_reply_count']['setting_value'] = $sidebar_recent_reply_count; $message = "Site Settings have been Updated."; $message .= '<br /><br />'; trigger_error($message . adm_back_link(append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=rayth_cms'))); } break; case 'pages': $this->page_title = 'Manage Pages'; $this->tpl_name = 'acp_rcms_page_list'; $sql = "SELECT * FROM " . SITE_PAGES . " WHERE parent=0 ORDER BY page_name ASC"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $sql = "SELECT * FROM " . SITE_PAGES . " WHERE parent={$row['page_id']}"; $sub_page_result = $db->sql_query($sql); $sql = "SELECT COUNT(*) as total_subs FROM " . SITE_PAGES . " WHERE parent={$row['page_id']}"; $sub_page_count_row = $db->sql_fetchrow($db->sql_query($sql)); $subpage_count = $sub_page_count_row['total_subs']; if ($subpage_count > 0) { $subpages = "<table cellspacing=\"1\">"; $subpages .= "<col class=\"col1\"/><col class=\"col2\"/><col class=\"col1\"/><col class=\"col2\"/><col class=\"col1\"/>"; $subpages .= "<th>Page Name</th><th>Identifier</th><th>Last Updated</th><th>Edit</th><th>Delete</th>"; while ($sub_row = $db->sql_fetchrow($sub_page_result)) { $subpages .= "<tr>"; $subpages .= "<td>{$sub_row['page_name']}</td>"; $subpages .= "<td style=\"text-align: center;\">{$sub_row['page_identifier']}</td>"; $subpages .= "<td style=\"text-align: center;\">" . date($user->data['user_dateformat'], $sub_row['last_updated']) . "</td>"; $subpages .= "<td style=\"text-align: center;\"><a href=\"" . append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=rayth_cms&mode=pagemanage&act=edit&id={$sub_row['page_id']}") . "\">Edit</a></td>"; $subpages .= "<td style=\"text-align: center;\"><a href=\"" . append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=rayth_cms&mode=pagemanage&act=del&id={$sub_row['page_id']}") . "\">Delete</a></td>"; $subpages .= "</tr>"; } $subpages .= "</table>"; } else { $subpages = null; } $db->sql_freeresult($sub_page_result); $navbar = $row['in_navbar'] ? true : false; $template->assign_block_vars('page', array('NAME' => $row['page_name'], 'IDENTIFIER' => $row['page_identifier'], 'LAST_UPDATE' => date($user->data['user_dateformat'], $row['last_updated']), 'NAVBAR' => $navbar, 'SUBPAGES' => $subpages, 'EDIT_URL' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=rayth_cms&mode=pagemanage&act=edit&id={$row['page_id']}"), 'DEL_URL' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=rayth_cms&mode=pagemanage&act=del&id={$row['page_id']}"))); } $db->sql_freeresult($result); break; case 'pagemanage': $this->page_title = 'Managing Page'; $this->tpl_name = 'acp_rcms_page_manage'; $page_id = request_var('id', 0); $act = request_var('act', 'add'); $confirm = false; if (!confirm_box(true)) { switch ($act) { case 'del': $confirm = true; $confirm_lang = "Are you sure you want to delete this page and all sub-pages?"; } if ($confirm) { confirm_box(false, $confirm_lang, build_hidden_fields(array('id' => $page_id, 'mode' => $mode, 'act' => $act))); } } else { switch ($act) { case 'del': $sql = "DELETE FROM " . SITE_PAGES . " WHERE page_id={$page_id};"; $db->sql_query($sql); $sql = "DELETE FROM " . SITE_PAGES . " WHERE parent={$page_id};"; $db->sql_query($sql); $message = "Page, and sub-pages deleted successfully."; trigger_error($message . adm_back_link(append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=rayth_cms&mode=pages'))); } } if ($act == 'add' || $act == 'edit' && $page_id > 0) { if (isset($_POST[$act . '_save_btn'])) { $array = array(); $array['page_text'] = request_var('page_text', 'None specified'); $array['page_name'] = request_var('page_name', ''); $array['desc_parse_bbcode'] = request_var('desc_parse_bbcode', false); $array['desc_parse_urls'] = request_var('desc_parse_urls', false); $array['desc_parse_smilies'] = request_var('desc_parse_smilies', false); $array['page_identifier'] = request_var('page_identifier', ''); $array['in_navbar'] = request_var('in_navbar', 0); $array['parent'] = request_var('parent', 0); $bitfield = $uid = $options = ''; $allow_bbcode = $array['desc_parse_bbcode'] ? true : false; $allow_urls = $array['desc_parse_urls'] ? true : false; $allow_smilies = $array['desc_parse_smilies'] ? true : false; $array['page_text'] = utf8_normalize_nfc($array['page_text']); generate_text_for_storage($array['page_text'], $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies); $array['bbcode_bitfield'] = $bitfield; $array['bbcode_uid'] = $uid; $array['last_updated'] = time(); $array['page_name'] = utf8_normalize_nfc(htmlentities($array['page_name'])); //$array['page_identifier'] = $array['page_identifier']; $allow_bbcode = $array['desc_parse_bbcode'] ? 1 : 0; $allow_urls = $array['desc_parse_urls'] ? 1 : 0; $allow_smilies = $array['desc_parse_smilies'] ? 1 : 0; if ($act == 'add') { $sql = "INSERT INTO " . SITE_PAGES . " (page_name,parent,page_identifier,page_text,in_navbar,bbcode_bitfield,bbcode_uid,last_updated,enable_bbcode,enable_smilies,enable_magic_url) " . "VALUES (\"{$array['page_name']}\",{$array['parent']},'{$array['page_identifier']}',\"{$array['page_text']}\",{$array['in_navbar']},'{$bitfield}','{$uid}'," . time() . ",{$allow_bbcode},{$allow_smilies},{$allow_urls});"; } if ($act == 'edit') { $sql = "UPDATE " . SITE_PAGES . " SET page_identifier='{$array['page_identifier']}'," . " page_name=\"{$array['page_name']}\", parent={$array['parent']}, page_text=\"{$array['page_text']}\", in_navbar={$array['in_navbar']}," . " enable_bbcode={$allow_bbcode}, enable_smilies={$allow_smilies}, enable_magic_url={$allow_urls}," . " bbcode_bitfield='{$bitfield}', bbcode_uid='{$uid}', last_updated=" . time() . " WHERE page_id={$page_id};"; } $db->sql_query($sql); $message = "Page Saved Successfully."; trigger_error($message . adm_back_link(append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=rayth_cms&mode=pages'))); } else { if ($act == 'edit') { $sql = "SELECT * FROM " . SITE_PAGES . " WHERE page_id={$page_id};"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); if (!$row['page_id']) { $message = "The page you have selected does not exist."; trigger_error($message . adm_back_link(append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=rayth_cms&mode=pages'))); } decode_message($row['page_text'], $row['bbcode_uid']); $parent_select = $this->generate_parent_select($row['parent']); $template->assign_vars(array('TITLE' => 'Editing Page :: ' . $row['page_name'], 'DESC_LANG' => 'Edit the information below', 'NAME' => $row['page_name'], 'IDENTIFIER' => $row['page_identifier'], 'NAVBAR' => $row['in_navbar'], 'ALLOW_BBCODE' => $row['enable_bbcode'], 'PARSE_URLS' => $row['enable_magic_url'], 'ALLOW_SMILIES' => $row['enable_smilies'], 'TEXT' => $row['page_text'], 'PARENT_SELECT' => $parent_select, 'SAVE_BTN_NAME' => $act . '_save_btn', 'FORM_ACTION' => append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=rayth_cms&mode=pagemanage&act=' . $act . '&id=' . $page_id))); $db->sql_freeresult($result); } if ($act == 'add') { $parent_select = $this->generate_parent_select(); $template->assign_vars(array('TITLE' => 'Adding Page', 'DESC_LANG' => 'Fill in the information below', 'NAME' => '', 'IDENTIFIER' => '', 'NAVBAR' => false, 'TEXT' => '', 'PARENT_SELECT' => $parent_select, 'SAVE_BTN_NAME' => "{$act}_save_btn", 'FORM_ACTION' => append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=rayth_cms&mode=pagemanage&act=' . $act))); } } } else { $message = "You failed to select a page to edit."; trigger_error($message . adm_back_link(append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=rayth_cms&mode=pages'))); } break; } }
/** * Handles copying permissions from one forum to others */ function copy_forum_permissions() { global $db, $auth, $cache, $template, $user, $request; $user->add_lang('acp/forums'); $submit = isset($_POST['submit']) ? true : false; if ($submit) { $src = $request->variable('src_forum_id', 0); $dest = $request->variable('dest_forum_ids', array(0)); if (confirm_box(true)) { if (copy_forum_permissions($src, $dest)) { phpbb_cache_moderators($db, $cache, $auth); $auth->acl_clear_prefetch(); $cache->destroy('sql', FORUMS_TABLE); trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action)); } else { trigger_error($user->lang['SELECTED_FORUM_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING); } } else { $s_hidden_fields = array('submit' => $submit, 'src_forum_id' => $src, 'dest_forum_ids' => $dest); $s_hidden_fields = build_hidden_fields($s_hidden_fields); confirm_box(false, $user->lang['COPY_PERMISSIONS_CONFIRM'], $s_hidden_fields); } } $template->assign_vars(array('S_FORUM_OPTIONS' => make_forum_select(false, false, false, false, false))); }
$result = $db->sql_query($sql); $forum_type = (int) $db->sql_fetchfield('forum_type'); $db->sql_freeresult($result); if ($forum_type != FORUM_POST || !$auth->acl_get('f_post', $to_forum_id) || (!$auth->acl_get('m_approve', $to_forum_id) && !$auth->acl_get('f_noapprove', $to_forum_id))) { $to_forum_id = 0; } } if (!$to_forum_id) { include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx); $template->assign_vars(array( 'S_FORUM_SELECT' => make_forum_select(false, false, false, true, true, true), 'S_UNGLOBALISE' => true) ); $submit = false; $refresh = true; } else { if (!$auth->acl_get('f_post', $to_forum_id)) { // This will only be triggered if the user tried to trick the forum. trigger_error('NOT_AUTHORISED'); } $forum_id = $to_forum_id;
} if (sizeof($message_parser->warn_msg)) { $error[] = implode('<br />', $message_parser->warn_msg); } // Store message, sync counters if (empty($error) && $submit) { // Check if we want to de-globalize the topic... and ask for new forum if ($posting_data['topic_type'] != POST_GLOBAL) { $sql = 'SELECT topic_type, forum_id FROM ' . FORUMS_TOPICS_TABLE . "\n\t\t\t\tWHERE topic_id = {$topic_id}"; $result = $_CLASS['core_db']->query_limit($sql, 1); $row = $_CLASS['core_db']->fetch_row_assoc($result); if ($row && !$row['forum_id'] && $row['topic_type'] == POST_GLOBAL) { $to_forum_id = request_var('to_forum_id', 0); if (!$to_forum_id) { $_CLASS['core_template']->assign_array(array('S_FORUM_SELECT' => make_forum_select(false, false, false, true, true), 'S_UNGLOBALISE' => true)); $submit = false; $refresh = true; } else { $forum_id = $to_forum_id; } } } if ($submit) { // Lock/Unlock Topic $change_topic_status = $posting_data['topic_status']; $perm_lock_unlock = $_CLASS['auth']->acl_get('m_lock', $forum_id) || $_CLASS['auth']->acl_get('f_user_lock', $forum_id) && $_CLASS['core_user']->is_user && $_CLASS['core_user']->data['user_id'] == $topic_poster; if ($posting_data['topic_status'] == ITEM_LOCKED && !$topic_lock && $perm_lock_unlock) { $change_topic_status = ITEM_UNLOCKED; } else { if ($posting_data['topic_status'] == ITEM_UNLOCKED && $topic_lock && $perm_lock_unlock) {
/** * Display permission mask (assign to template) */ function display_mask($mode, $permission_type, &$hold_ary, $user_mode = 'user', $local = false, $group_display = true) { global $template, $user, $db, $phpbb_root_path, $phpEx; // Define names for template loops, might be able to be set $tpl_pmask = 'p_mask'; $tpl_fmask = 'f_mask'; $tpl_category = 'category'; $tpl_mask = 'mask'; $l_acl_type = isset($user->lang['ACL_TYPE_' . ($local ? 'LOCAL' : 'GLOBAL') . '_' . strtoupper($permission_type)]) ? $user->lang['ACL_TYPE_' . ($local ? 'LOCAL' : 'GLOBAL') . '_' . strtoupper($permission_type)] : 'ACL_TYPE_' . ($local ? 'LOCAL' : 'GLOBAL') . '_' . strtoupper($permission_type); // Allow trace for viewing permissions and in user mode $show_trace = $mode == 'view' && $user_mode == 'user' ? true : false; // Get names if ($user_mode == 'user') { $sql = 'SELECT user_id as ug_id, username as ug_name FROM ' . USERS_TABLE . ' WHERE user_id IN (' . implode(', ', array_keys($hold_ary)) . ') ORDER BY username ASC'; } else { $sql = 'SELECT group_id as ug_id, group_name as ug_name, group_type FROM ' . GROUPS_TABLE . ' WHERE group_id IN (' . implode(', ', array_keys($hold_ary)) . ') ORDER BY group_type DESC, group_name ASC'; } $result = $db->sql_query($sql); $ug_names_ary = array(); while ($row = $db->sql_fetchrow($result)) { $ug_names_ary[$row['ug_id']] = $user_mode == 'user' ? $row['ug_name'] : ($row['group_type'] == GROUP_SPECIAL ? $user->lang['G_' . $row['ug_name']] : $row['ug_name']); } $db->sql_freeresult($result); // Get used forums $forum_ids = array(); foreach ($hold_ary as $ug_id => $row) { $forum_ids = array_merge($forum_ids, array_keys($row)); } $forum_ids = array_unique($forum_ids); $forum_names_ary = array(); if ($local) { $forum_names_ary = make_forum_select(false, false, true, false, false, true); } else { $forum_names_ary[0] = $l_acl_type; } // Get available roles $sql = 'SELECT * FROM ' . ACL_ROLES_TABLE . "\n\t\t\tWHERE role_type = '" . $db->sql_escape($permission_type) . "'\n\t\t\tORDER BY role_order ASC"; $result = $db->sql_query($sql); $roles = array(); while ($row = $db->sql_fetchrow($result)) { $roles[$row['role_id']] = $row; } $db->sql_freeresult($result); $cur_roles = $this->acl_role_data($user_mode, $permission_type, array_keys($hold_ary)); // Build js roles array (role data assignments) $s_role_js_array = ''; if (sizeof($roles)) { $s_role_js_array = array(); // Make sure every role (even if empty) has its array defined foreach ($roles as $_role_id => $null) { $s_role_js_array[$_role_id] = "\n" . 'role_options[' . $_role_id . '] = new Array();' . "\n"; } $sql = 'SELECT r.role_id, o.auth_option, r.auth_setting FROM ' . ACL_ROLES_DATA_TABLE . ' r, ' . ACL_OPTIONS_TABLE . ' o WHERE o.auth_option_id = r.auth_option_id AND r.role_id IN (' . implode(', ', array_keys($roles)) . ')'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $flag = substr($row['auth_option'], 0, strpos($row['auth_option'], '_') + 1); if ($flag == $row['auth_option']) { continue; } $s_role_js_array[$row['role_id']] .= 'role_options[' . $row['role_id'] . '][\'' . $row['auth_option'] . '\'] = ' . $row['auth_setting'] . '; '; } $db->sql_freeresult($result); $s_role_js_array = implode('', $s_role_js_array); } $template->assign_var('S_ROLE_JS_ARRAY', $s_role_js_array); // Now obtain memberships $user_groups_default = $user_groups_custom = array(); if ($user_mode == 'user' && $group_display) { $sql = 'SELECT group_id, group_name, group_type FROM ' . GROUPS_TABLE . ' ORDER BY group_type DESC, group_name ASC'; $result = $db->sql_query($sql); $groups = array(); while ($row = $db->sql_fetchrow($result)) { $groups[$row['group_id']] = $row; } $db->sql_freeresult($result); $memberships = group_memberships(false, array_keys($hold_ary), false); // User is not a member of any group? Bad admin, bad bad admin... if ($memberships) { foreach ($memberships as $row) { if ($groups[$row['group_id']]['group_type'] == GROUP_SPECIAL) { $user_groups_default[$row['user_id']][] = $user->lang['G_' . $groups[$row['group_id']]['group_name']]; } else { $user_groups_custom[$row['user_id']][] = $groups[$row['group_id']]['group_name']; } } } unset($memberships, $groups); } // If we only have one forum id to display or being in local mode and more than one user/group to display, // we switch the complete interface to group by user/usergroup instead of grouping by forum // To achive this, we need to switch the array a bit if (sizeof($forum_ids) == 1 || $local && sizeof($ug_names_ary) > 1) { $hold_ary_temp = $hold_ary; $hold_ary = array(); foreach ($hold_ary_temp as $ug_id => $row) { foreach ($row as $forum_id => $auth_row) { $hold_ary[$forum_id][$ug_id] = $auth_row; } } unset($hold_ary_temp); foreach ($hold_ary as $forum_id => $forum_array) { $content_array = $categories = array(); $this->build_permission_array($hold_ary[$forum_id], $content_array, $categories, array_keys($ug_names_ary)); $template->assign_block_vars($tpl_pmask, array('NAME' => $forum_id == 0 ? $forum_names_ary[0] : $forum_names_ary[$forum_id]['forum_name'], 'CATEGORIES' => implode('</th><th>', $categories), 'L_ACL_TYPE' => $l_acl_type, 'S_LOCAL' => $local ? true : false, 'S_GLOBAL' => !$local ? true : false, 'S_NUM_CATS' => sizeof($categories), 'S_VIEW' => $mode == 'view' ? true : false, 'S_NUM_OBJECTS' => sizeof($content_array), 'S_USER_MODE' => $user_mode == 'user' ? true : false, 'S_GROUP_MODE' => $user_mode == 'group' ? true : false)); foreach ($content_array as $ug_id => $ug_array) { // Build role dropdown options $current_role_id = isset($cur_roles[$ug_id][$forum_id]) ? $cur_roles[$ug_id][$forum_id] : 0; $s_role_options = ''; foreach ($roles as $role_id => $role_row) { $role_description = !empty($user->lang[$role_row['role_description']]) ? $user->lang[$role_row['role_description']] : nl2br($role_row['role_description']); $title = $role_description ? ' title="' . $role_description . '"' : ''; $s_role_options .= '<option value="' . $role_id . '"' . ($role_id == $current_role_id ? ' selected="selected"' : '') . $title . '>' . $role_row['role_name'] . '</option>'; } if ($s_role_options) { $s_role_options = '<option value="0"' . (!$current_role_id ? ' selected="selected"' : '') . ' title="' . htmlspecialchars($user->lang['NO_ROLE_ASSIGNED_EXPLAIN']) . '">' . $user->lang['NO_ROLE_ASSIGNED'] . '</option>' . $s_role_options; } $template->assign_block_vars($tpl_pmask . '.' . $tpl_fmask, array('NAME' => $ug_names_ary[$ug_id], 'S_ROLE_OPTIONS' => $s_role_options, 'UG_ID' => $ug_id, 'FORUM_ID' => $forum_id)); $this->assign_cat_array($ug_array, $tpl_pmask . '.' . $tpl_fmask . '.' . $tpl_category, $tpl_mask, $ug_id, $forum_id, $show_trace); } } } else { foreach ($ug_names_ary as $ug_id => $ug_name) { if (!isset($hold_ary[$ug_id])) { continue; } $content_array = $categories = array(); $this->build_permission_array($hold_ary[$ug_id], $content_array, $categories, array_keys($forum_names_ary)); $template->assign_block_vars($tpl_pmask, array('NAME' => $ug_name, 'CATEGORIES' => implode('</th><th>', $categories), 'USER_GROUPS_DEFAULT' => $user_mode == 'user' && isset($user_groups_default[$ug_id]) && sizeof($user_groups_default[$ug_id]) ? implode(', ', $user_groups_default[$ug_id]) : '', 'USER_GROUPS_CUSTOM' => $user_mode == 'user' && isset($user_groups_custom[$ug_id]) && sizeof($user_groups_custom[$ug_id]) ? implode(', ', $user_groups_custom[$ug_id]) : '', 'L_ACL_TYPE' => $l_acl_type, 'S_LOCAL' => $local ? true : false, 'S_GLOBAL' => !$local ? true : false, 'S_NUM_CATS' => sizeof($categories), 'S_VIEW' => $mode == 'view' ? true : false, 'S_NUM_OBJECTS' => sizeof($content_array), 'S_USER_MODE' => $user_mode == 'user' ? true : false, 'S_GROUP_MODE' => $user_mode == 'group' ? true : false)); foreach ($content_array as $forum_id => $forum_array) { // Build role dropdown options $current_role_id = isset($cur_roles[$ug_id][$forum_id]) ? $cur_roles[$ug_id][$forum_id] : 0; $s_role_options = ''; foreach ($roles as $role_id => $role_row) { $role_description = !empty($user->lang[$role_row['role_description']]) ? $user->lang[$role_row['role_description']] : nl2br($role_row['role_description']); $title = $role_description ? ' title="' . $role_description . '"' : ''; $s_role_options .= '<option value="' . $role_id . '"' . ($role_id == $current_role_id ? ' selected="selected"' : '') . $title . '>' . $role_row['role_name'] . '</option>'; } if ($s_role_options) { $s_role_options = '<option value="0"' . (!$current_role_id ? ' selected="selected"' : '') . ' title="' . htmlspecialchars($user->lang['NO_ROLE_ASSIGNED_EXPLAIN']) . '">' . $user->lang['NO_ROLE_ASSIGNED'] . '</option>' . $s_role_options; } if (!$forum_id) { $folder_image = ''; } else { if ($forum_names_ary[$forum_id]['forum_status'] == ITEM_LOCKED) { $folder_image = '<img src="images/icon_folder_lock_small.gif" width="19" height="18" alt="' . $user->lang['FORUM_LOCKED'] . '" />'; } else { switch ($forum_names_ary[$forum_id]['forum_type']) { case FORUM_LINK: $folder_image = '<img src="images/icon_folder_link_small.gif" width="22" height="18" alt="' . $user->lang['FORUM_LINK'] . '" />'; break; default: $folder_image = $forum_names_ary[$forum_id]['left_id'] + 1 != $forum_names_ary[$forum_id]['right_id'] ? '<img src="images/icon_folder_sub_small.gif" width="22" height="18" alt="' . $user->lang['SUBFORUM'] . '" />' : '<img src="images/icon_folder_small.gif" width="19" height="18" alt="' . $user->lang['FOLDER'] . '" />'; break; } } } $template->assign_block_vars($tpl_pmask . '.' . $tpl_fmask, array('NAME' => $forum_id == 0 ? $forum_names_ary[0] : $forum_names_ary[$forum_id]['forum_name'], 'PADDING' => $forum_id == 0 ? '' : $forum_names_ary[$forum_id]['padding'], 'FOLDER_IMAGE' => $folder_image, 'S_ROLE_OPTIONS' => $s_role_options, 'UG_ID' => $ug_id, 'FORUM_ID' => $forum_id)); $this->assign_cat_array($forum_array, $tpl_pmask . '.' . $tpl_fmask . '.' . $tpl_category, $tpl_mask, $ug_id, $forum_id, $show_trace); } } } }
/** * forum_select() // custom forum select setup */ function forum_select($ignore_acl = true, $ignore_nonpost = false, $ignore_emptycat = false, $only_acl_post = false) { $select_ary = make_forum_select(false, false, $ignore_acl, $ignore_nonpost, $ignore_emptycat, $only_acl_post, true); foreach ($select_ary as $f_id => $f_data) { $select_ary[$f_id] = array('title' => $f_data['padding'] . $f_data['forum_name'], 'disabled' => $f_data['disabled']); } return $select_ary; }
function main($id, $mode) { global $db, $user, $auth, $template, $cache; global $config, $phpbb_admin_path, $phpbb_root_path, $phpEx; $user->add_lang('acp/forums'); $user->add_lang('acp/site'); $this->tpl_name = 'acp_bugs'; $this->page_title = 'ACP_BUG_TRACKER'; /** * Projects (also creating forums) */ if ($mode == 'projects') { $this->parent_id = BUGS_FORUM_ID; $action = request_var('action', ''); $update = isset($_POST['update']) ? true : false; $forum_id = request_var('f', 0); // This is just a shame copy of acp_forums, use acp_forus whenever possible (for functions) include "{$phpbb_root_path}includes/acp/acp_forums.{$phpEx}"; $this->parent = new acp_forums(); $forum_data = $errors = array(); // Check additional permissions /*switch ($action) { case 'delete': if (!$auth->acl_get('a_forumdel')) { trigger_error($user->lang['NO_PERMISSION_FORUM_DELETE'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); } break; case 'add': if (!$auth->acl_get('a_forumadd')) { trigger_error($user->lang['NO_PERMISSION_FORUM_ADD'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); } break; }*/ // Major routines if ($update) { switch ($action) { case 'delete': $action_subforums = request_var('action_subforums', ''); $subforums_to_id = request_var('subforums_to_id', 0); $action_posts = request_var('action_posts', ''); $posts_to_id = request_var('posts_to_id', 0); $errors = $this->delete_forum($forum_id, $action_posts, $action_subforums, $posts_to_id, $subforums_to_id); if (sizeof($errors)) { break; } $auth->acl_clear_prefetch(); $cache->destroy('sql', FORUMS_TABLE); trigger_error($user->lang['PROJECT_DELETED'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); break; case 'edit': $forum_data = array('forum_id' => $forum_id); // No break here // No break here case 'add': $forum_data += array('parent_id' => BUGS_FORUM_ID, 'forum_type' => FORUM_POST, 'type_action' => request_var('type_action', ''), 'forum_status' => request_var('forum_status', ITEM_UNLOCKED), 'forum_parents' => '', 'forum_name' => utf8_normalize_nfc(request_var('forum_name', '', true)), 'project_idname' => request_var('project_idname', ''), 'forum_link' => '', 'forum_link_track' => false, 'forum_desc' => utf8_normalize_nfc(request_var('forum_desc', '', true)), 'forum_desc_uid' => '', 'forum_desc_options' => 7, 'forum_desc_bitfield' => '', 'forum_rules' => utf8_normalize_nfc(request_var('forum_rules', '', true)), 'forum_rules_uid' => '', 'forum_rules_options' => 7, 'forum_rules_bitfield' => '', 'forum_rules_link' => request_var('forum_rules_link', ''), 'forum_image' => request_var('forum_image', ''), 'forum_style' => request_var('forum_style', 0), 'display_on_index' => request_var('display_on_index', false), 'forum_topics_per_page' => request_var('topics_per_page', 0), 'enable_indexing' => request_var('enable_indexing', true), 'enable_icons' => request_var('enable_icons', false), 'enable_prune' => request_var('enable_prune', false), 'enable_post_review' => request_var('enable_post_review', true), 'prune_days' => request_var('prune_days', 7), 'prune_viewed' => request_var('prune_viewed', 7), 'prune_freq' => request_var('prune_freq', 1), 'prune_old_polls' => request_var('prune_old_polls', false), 'prune_announce' => request_var('prune_announce', false), 'prune_sticky' => request_var('prune_sticky', false), 'forum_password' => request_var('forum_password', '', true), 'forum_password_confirm' => request_var('forum_password_confirm', '', true)); $forum_data['show_active'] = $forum_data['forum_type'] == FORUM_POST ? request_var('display_recent', false) : request_var('display_active', false); // Get data for forum rules if specified... if ($forum_data['forum_rules']) { generate_text_for_storage($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_bitfield'], $forum_data['forum_rules_options'], request_var('rules_parse_bbcode', false), request_var('rules_parse_urls', false), request_var('rules_parse_smilies', false)); } // Get data for forum description if specified if ($forum_data['forum_desc']) { generate_text_for_storage($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_bitfield'], $forum_data['forum_desc_options'], request_var('desc_parse_bbcode', false), request_var('desc_parse_urls', false), request_var('desc_parse_smilies', false)); } $errors = $this->update_forum_data($forum_data); if (!sizeof($errors)) { $forum_perm_from = request_var('forum_perm_from', 0); // Copy permissions? if ($forum_perm_from && !empty($forum_perm_from) && $forum_perm_from != $forum_data['forum_id']) { // if we edit a forum delete current permissions first if ($action == 'edit') { $sql = 'DELETE FROM ' . ACL_USERS_TABLE . ' WHERE forum_id = ' . (int) $forum_data['forum_id']; $db->sql_query($sql); $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' WHERE forum_id = ' . (int) $forum_data['forum_id']; $db->sql_query($sql); } // From the mysql documentation: // Prior to MySQL 4.0.14, the target table of the INSERT statement cannot appear in the FROM clause of the SELECT part of the query. This limitation is lifted in 4.0.14. // Due to this we stay on the safe side if we do the insertion "the manual way" // Copy permisisons from/to the acl users table (only forum_id gets changed) $sql = 'SELECT user_id, auth_option_id, auth_role_id, auth_setting FROM ' . ACL_USERS_TABLE . ' WHERE forum_id = ' . $forum_perm_from; $result = $db->sql_query($sql); $users_sql_ary = array(); while ($row = $db->sql_fetchrow($result)) { $users_sql_ary[] = array('user_id' => (int) $row['user_id'], 'forum_id' => (int) $forum_data['forum_id'], 'auth_option_id' => (int) $row['auth_option_id'], 'auth_role_id' => (int) $row['auth_role_id'], 'auth_setting' => (int) $row['auth_setting']); } $db->sql_freeresult($result); // Copy permisisons from/to the acl groups table (only forum_id gets changed) $sql = 'SELECT group_id, auth_option_id, auth_role_id, auth_setting FROM ' . ACL_GROUPS_TABLE . ' WHERE forum_id = ' . $forum_perm_from; $result = $db->sql_query($sql); $groups_sql_ary = array(); while ($row = $db->sql_fetchrow($result)) { $groups_sql_ary[] = array('group_id' => (int) $row['group_id'], 'forum_id' => (int) $forum_data['forum_id'], 'auth_option_id' => (int) $row['auth_option_id'], 'auth_role_id' => (int) $row['auth_role_id'], 'auth_setting' => (int) $row['auth_setting']); } $db->sql_freeresult($result); // Now insert the data $db->sql_multi_insert(ACL_USERS_TABLE, $users_sql_ary); $db->sql_multi_insert(ACL_GROUPS_TABLE, $groups_sql_ary); } $auth->acl_clear_prefetch(); $cache->destroy('sql', FORUMS_TABLE); $acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_data['forum_id']; $message = $action == 'add' ? $user->lang['PROJECT_CREATED'] : $user->lang['PROJECT_UPDATED']; // Redirect to permissions if ($auth->acl_get('a_fauth')) { $message .= '<br /><br />' . sprintf($user->lang['REDIRECT_ACL'], '<a href="' . append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=permissions' . $acl_url) . '">', '</a>'); } // redirect directly to permission settings screen if authed if ($action == 'add' && !$forum_perm_from && $auth->acl_get('a_fauth')) { meta_refresh(4, append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=permissions' . $acl_url)); } trigger_error($message . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); } break; } } switch ($action) { case 'move_up': case 'move_down': if (!$forum_id) { trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); } $sql = 'SELECT * FROM ' . FORUMS_TABLE . "\n\t\t\t\t\t\tWHERE forum_id = {$forum_id}"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$row) { trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); } $move_forum_name = $this->parent->move_forum_by($row, $action, 1); if ($move_forum_name !== false) { add_log('admin', 'LOG_FORUM_' . strtoupper($action), $row['forum_name'], $move_forum_name); $cache->destroy('sql', FORUMS_TABLE); } break; case 'add': case 'edit': if ($update) { $forum_data['forum_flags'] = 0; $forum_data['forum_flags'] += request_var('forum_link_track', false) ? FORUM_FLAG_LINK_TRACK : 0; $forum_data['forum_flags'] += request_var('prune_old_polls', false) ? FORUM_FLAG_PRUNE_POLL : 0; $forum_data['forum_flags'] += request_var('prune_announce', false) ? FORUM_FLAG_PRUNE_ANNOUNCE : 0; $forum_data['forum_flags'] += request_var('prune_sticky', false) ? FORUM_FLAG_PRUNE_STICKY : 0; $forum_data['forum_flags'] += $forum_data['show_active'] ? FORUM_FLAG_ACTIVE_TOPICS : 0; $forum_data['forum_flags'] += request_var('enable_post_review', true) ? FORUM_FLAG_POST_REVIEW : 0; } // Show form to create/modify a forum if ($action == 'edit') { $this->page_title = 'EDIT_PROJECT'; $row = $this->parent->get_forum_info($forum_id); $old_forum_type = $row['forum_type']; // Get the project's id name $sql = 'SELECT project_name FROM ' . BUGS_PROJECTS_TABLE . "\n\t\t\t\t\t\t\tWHERE forum_id = {$forum_id}"; $result = $db->sql_query($sql); $row['project_idname'] = $db->sql_fetchfield('project_name', false, $result); $db->sql_freeresult($result); if (!$update) { $forum_data = $row; } else { $forum_data['left_id'] = $row['left_id']; $forum_data['right_id'] = $row['right_id']; } // Make sure no direct child forums are able to be selected as parents. $exclude_forums = array(); foreach (get_forum_branch($forum_id, 'children') as $row) { $exclude_forums[] = $row['forum_id']; } $parents_list = make_forum_select($forum_data['parent_id'], $exclude_forums, false, false, false); $forum_data['forum_password_confirm'] = $forum_data['forum_password']; } else { $this->page_title = 'CREATE_PROJECT'; $forum_id = BUGS_FORUM_ID; // Fill forum data with default values if (!$update) { $forum_data = array('parent_id' => BUGS_FORUM_ID, 'forum_type' => FORUM_POST, 'forum_status' => ITEM_UNLOCKED, 'forum_name' => utf8_normalize_nfc(request_var('forum_name', '', true)), 'project_idname' => '', 'forum_link' => '', 'forum_link_track' => false, 'forum_desc' => '', 'forum_rules' => '', 'forum_rules_link' => '', 'forum_image' => '', 'forum_style' => 0, 'display_on_index' => false, 'forum_topics_per_page' => 0, 'enable_indexing' => true, 'enable_icons' => false, 'enable_prune' => false, 'prune_days' => 7, 'prune_viewed' => 7, 'prune_freq' => 1, 'forum_flags' => FORUM_FLAG_POST_REVIEW, 'forum_password' => '', 'forum_password_confirm' => ''); } } $forum_rules_data = array('text' => $forum_data['forum_rules'], 'allow_bbcode' => true, 'allow_smilies' => true, 'allow_urls' => true); $forum_desc_data = array('text' => $forum_data['forum_desc'], 'allow_bbcode' => true, 'allow_smilies' => true, 'allow_urls' => true); $forum_rules_preview = ''; // Parse rules if specified if ($forum_data['forum_rules']) { if (!isset($forum_data['forum_rules_uid'])) { // Before we are able to display the preview and plane text, we need to parse our request_var()'d value... $forum_data['forum_rules_uid'] = ''; $forum_data['forum_rules_bitfield'] = ''; $forum_data['forum_rules_options'] = 0; generate_text_for_storage($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_bitfield'], $forum_data['forum_rules_options'], request_var('rules_allow_bbcode', false), request_var('rules_allow_urls', false), request_var('rules_allow_smilies', false)); } // Generate preview content $forum_rules_preview = generate_text_for_display($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_bitfield'], $forum_data['forum_rules_options']); // decode... $forum_rules_data = generate_text_for_edit($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_options']); } // Parse desciption if specified if ($forum_data['forum_desc']) { if (!isset($forum_data['forum_desc_uid'])) { // Before we are able to display the preview and plane text, we need to parse our request_var()'d value... $forum_data['forum_desc_uid'] = ''; $forum_data['forum_desc_bitfield'] = ''; $forum_data['forum_desc_options'] = 0; generate_text_for_storage($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_bitfield'], $forum_data['forum_desc_options'], request_var('desc_allow_bbcode', false), request_var('desc_allow_urls', false), request_var('desc_allow_smilies', false)); } // decode... $forum_desc_data = generate_text_for_edit($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_options']); } $styles_list = style_select($forum_data['forum_style'], true); $statuslist = '<option value="' . ITEM_UNLOCKED . '"' . ($forum_data['forum_status'] == ITEM_UNLOCKED ? ' selected="selected"' : '') . '>' . $user->lang['UNLOCKED'] . '</option><option value="' . ITEM_LOCKED . '"' . ($forum_data['forum_status'] == ITEM_LOCKED ? ' selected="selected"' : '') . '>' . $user->lang['LOCKED'] . '</option>'; $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . ' WHERE forum_type = ' . FORUM_POST . "\n\t\t\t\t\t\t\tAND forum_id <> {$forum_id}"; $result = $db->sql_query($sql); if ($db->sql_fetchrow($result)) { $template->assign_vars(array('S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $forum_id, false, true, false))); } $db->sql_freeresult($result); // Subforum move options if ($action == 'edit' && $forum_data['forum_type'] == FORUM_CAT) { $subforums_id = array(); $subforums = get_forum_branch($forum_id, 'children'); foreach ($subforums as $row) { $subforums_id[] = $row['forum_id']; } $forums_list = make_forum_select($forum_data['parent_id'], $subforums_id); $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . ' WHERE forum_type = ' . FORUM_POST . "\n\t\t\t\t\t\t\t\tAND forum_id <> {$forum_id}"; $result = $db->sql_query($sql); if ($db->sql_fetchrow($result)) { $template->assign_vars(array('S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $subforums_id))); } $db->sql_freeresult($result); $template->assign_vars(array('S_HAS_SUBFORUMS' => $forum_data['right_id'] - $forum_data['left_id'] > 1 ? true : false, 'S_FORUMS_LIST' => $forums_list)); } $s_show_display_on_index = false; if ($forum_data['parent_id'] > 0) { // if this forum is a subforum put the "display on index" checkbox if ($parent_info = $this->parent->get_forum_info($forum_data['parent_id'])) { if ($parent_info['parent_id'] > 0 || $parent_info['forum_type'] == FORUM_CAT) { $s_show_display_on_index = true; } } } $template->assign_vars(array('S_EDIT_FORUM' => true, 'S_ERROR' => sizeof($errors) ? true : false, 'S_PARENT_ID' => BUGS_FORUM_ID, 'S_FORUM_PARENT_ID' => $forum_data['parent_id'], 'S_ADD_ACTION' => $action == 'add' ? true : false, 'U_BACK' => $this->u_action . '&parent_id=' . $this->parent_id, 'U_EDIT_ACTION' => $this->u_action . "&parent_id={$this->parent_id}&action={$action}&f={$forum_id}", 'L_COPY_PERMISSIONS_EXPLAIN' => $user->lang['COPY_PERMISSIONS_' . strtoupper($action) . '_EXPLAIN'], 'L_TITLE' => $user->lang[$this->page_title], 'ERROR_MSG' => sizeof($errors) ? implode('<br />', $errors) : '', 'FORUM_NAME' => $forum_data['forum_name'], 'PROJECT_IDNAME' => $forum_data['project_idname'], 'FORUM_DATA_LINK' => $forum_data['forum_link'], 'FORUM_IMAGE' => $forum_data['forum_image'], 'FORUM_IMAGE_SRC' => $forum_data['forum_image'] ? $phpbb_root_path . $forum_data['forum_image'] : '', 'FORUM_POST' => FORUM_POST, 'FORUM_LINK' => FORUM_LINK, 'FORUM_CAT' => FORUM_CAT, 'PRUNE_FREQ' => $forum_data['prune_freq'], 'PRUNE_DAYS' => $forum_data['prune_days'], 'PRUNE_VIEWED' => $forum_data['prune_viewed'], 'TOPICS_PER_PAGE' => $forum_data['forum_topics_per_page'], 'FORUM_PASSWORD' => $forum_data['forum_password'], 'FORUM_PASSWORD_CONFIRM' => $forum_data['forum_password_confirm'], 'FORUM_RULES_LINK' => $forum_data['forum_rules_link'], 'FORUM_RULES' => $forum_data['forum_rules'], 'FORUM_RULES_PREVIEW' => $forum_rules_preview, 'FORUM_RULES_PLAIN' => $forum_rules_data['text'], 'S_BBCODE_CHECKED' => $forum_rules_data['allow_bbcode'] ? true : false, 'S_SMILIES_CHECKED' => $forum_rules_data['allow_smilies'] ? true : false, 'S_URLS_CHECKED' => $forum_rules_data['allow_urls'] ? true : false, 'FORUM_DESC' => $forum_desc_data['text'], 'S_DESC_BBCODE_CHECKED' => $forum_desc_data['allow_bbcode'] ? true : false, 'S_DESC_SMILIES_CHECKED' => $forum_desc_data['allow_smilies'] ? true : false, 'S_DESC_URLS_CHECKED' => $forum_desc_data['allow_urls'] ? true : false, 'S_STATUS_OPTIONS' => $statuslist, 'S_STYLES_OPTIONS' => $styles_list, 'S_FORUM_OPTIONS' => make_forum_select($action == 'add' ? $forum_data['parent_id'] : false, $action == 'edit' ? $forum_data['forum_id'] : false, false, false, false), 'S_SHOW_DISPLAY_ON_INDEX' => $s_show_display_on_index, 'S_FORUM_POST' => $forum_data['forum_type'] == FORUM_POST ? true : false, 'S_FORUM_ORIG_POST' => isset($old_forum_type) && $old_forum_type == FORUM_POST ? true : false, 'S_FORUM_ORIG_CAT' => isset($old_forum_type) && $old_forum_type == FORUM_CAT ? true : false, 'S_FORUM_ORIG_LINK' => isset($old_forum_type) && $old_forum_type == FORUM_LINK ? true : false, 'S_FORUM_LINK' => $forum_data['forum_type'] == FORUM_LINK ? true : false, 'S_FORUM_CAT' => $forum_data['forum_type'] == FORUM_CAT ? true : false, 'S_ENABLE_INDEXING' => $forum_data['enable_indexing'] ? true : false, 'S_TOPIC_ICONS' => $forum_data['enable_icons'] ? true : false, 'S_DISPLAY_ON_INDEX' => $forum_data['display_on_index'] ? true : false, 'S_PRUNE_ENABLE' => $forum_data['enable_prune'] ? true : false, 'S_FORUM_LINK_TRACK' => $forum_data['forum_flags'] & FORUM_FLAG_LINK_TRACK ? true : false, 'S_PRUNE_OLD_POLLS' => $forum_data['forum_flags'] & FORUM_FLAG_PRUNE_POLL ? true : false, 'S_PRUNE_ANNOUNCE' => $forum_data['forum_flags'] & FORUM_FLAG_PRUNE_ANNOUNCE ? true : false, 'S_PRUNE_STICKY' => $forum_data['forum_flags'] & FORUM_FLAG_PRUNE_STICKY ? true : false, 'S_DISPLAY_ACTIVE_TOPICS' => $forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS ? true : false, 'S_ENABLE_POST_REVIEW' => $forum_data['forum_flags'] & FORUM_FLAG_POST_REVIEW ? true : false)); return; break; case 'delete': if (!$forum_id) { trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); } $forum_data = $this->parent->get_forum_info($forum_id); $subforums_id = array(); $subforums = get_forum_branch($forum_id, 'children'); foreach ($subforums as $row) { $subforums_id[] = $row['forum_id']; } $forums_list = make_forum_select($forum_data['parent_id'], $subforums_id); $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . ' WHERE forum_type = ' . FORUM_POST . "\n\t\t\t\t\t\t\tAND forum_id <> {$forum_id}"; $result = $db->sql_query($sql); if ($db->sql_fetchrow($result)) { $template->assign_vars(array('S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $subforums_id, false, true))); } $db->sql_freeresult($result); $parent_id = $this->parent_id == $forum_id ? 0 : $this->parent_id; $template->assign_vars(array('S_DELETE_FORUM' => true, 'U_ACTION' => $this->u_action . "&parent_id={$parent_id}&action=delete&f={$forum_id}", 'U_BACK' => $this->u_action . '&parent_id=' . $this->parent_id, 'FORUM_NAME' => $forum_data['forum_name'], 'S_FORUM_POST' => $forum_data['forum_type'] == FORUM_POST ? true : false, 'S_FORUM_LINK' => $forum_data['forum_type'] == FORUM_LINK ? true : false, 'S_HAS_SUBFORUMS' => $forum_data['right_id'] - $forum_data['left_id'] > 1 ? true : false, 'S_FORUMS_LIST' => $forums_list, 'S_ERROR' => sizeof($errors) ? true : false, 'ERROR_MSG' => sizeof($errors) ? implode('<br />', $errors) : '')); return; break; } $navigation = $user->lang['BUG_TRACKER']; $this->page_title = 'BUG_TRACKER_PROJECTS'; $sql = 'SELECT bp.*, f.* FROM ' . BUGS_PROJECTS_TABLE . " bp,\n\t\t\t\t\t" . FORUMS_TABLE . " f \n\t\t\t\tWHERE bp.forum_id = f.forum_id\n\t\t\t\tORDER BY f.left_id"; $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) { do { $url = $this->u_action . "&parent_id={$this->parent_id}&f={$row['forum_id']}"; $template->assign_block_vars('projects', array('FOLDER_IMAGE' => '<img src="images/icon_folder.gif" alt="' . $user->lang['FOLDER'] . '" />', 'PROJECT_IMAGE' => $row['forum_image'] ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="" />' : '', 'PROJECT_IMAGE_SRC' => $row['forum_image'] ? $phpbb_root_path . $row['forum_image'] : '', 'PROJECT_NAME' => $row['forum_name'], 'PROJECT_DESCRIPTION' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']), 'PROJECT_TOPICS' => $row['forum_topics'], 'PROJECT_POSTS' => $row['forum_posts'], 'U_PROJECT' => $this->u_action . '&parent_id=' . $row['forum_id'], 'U_MOVE_UP' => $url . '&action=move_up', 'U_MOVE_DOWN' => $url . '&action=move_down', 'U_EDIT' => $url . '&action=edit', 'U_DELETE' => $url . '&action=delete')); } while ($row = $db->sql_fetchrow($result)); } $db->sql_freeresult($result); $template->assign_vars(array('ERROR_MSG' => sizeof($errors) ? implode('<br />', $errors) : '', 'NAVIGATION' => $navigation, 'U_SEL_ACTION' => $this->u_action, 'U_ACTION' => $this->u_action . '&parent_id=' . $this->parent_id)); } elseif ($mode == 'statuses') { $action = request_var('action', ''); $update = isset($_POST['update']) ? true : false; $status_id = request_var('st', 0); if ($action == 'add' || $action == 'edit') { $errors = array(); $status_data = array('status_title' => utf8_normalize_nfc(request_var('status_title', '', true)), 'status_closed' => intval((bool) request_var('status_closed', 0))); if ($action == 'add') { $this->page_title = 'ADD_STATUS'; if ($update) { $sql = 'INSERT INTO ' . BUGS_STATUSES_TABLE . ' ' . $db->sql_build_array('INSERT', $status_data); $db->sql_query($sql); trigger_error($user->lang['STATUS_ADDED'] . adm_back_link($this->u_action)); } } elseif ($action == 'edit') { $this->page_title = 'EDIT_STATUS'; if ($update) { $sql = 'UPDATE ' . BUGS_STATUSES_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $status_data) . ' WHERE status_id = ' . $status_id; $result = $db->sql_query($sql); trigger_error($user->lang['STATUS_EDITED'] . adm_back_link($this->u_action)); } else { // Query the status details $sql = 'SELECT * FROM ' . BUGS_STATUSES_TABLE . " WHERE status_id = '{$status_id}'"; $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) { $status_data['status_closed'] = $row['status_closed']; $status_data['status_title'] = $row['status_title']; } else { trigger_error($user->lang['NO_STATUS'] . adm_back_link($this->u_action), E_USER_WARNING); } } } $template->assign_vars(array('S_EDIT_STATUS' => true, 'S_ERROR' => sizeof($errors) ? true : false, 'S_ADD_ACTION' => $action == 'add' ? true : false, 'U_BACK' => $this->u_action, 'U_EDIT_ACTION' => $this->u_action . "&action={$action}&st={$status_id}", 'L_TITLE' => $user->lang[$this->page_title], 'ERROR_MSG' => sizeof($errors) ? implode('<br />', $errors) : '', 'STATUS_TITLE' => $status_data['status_title'], 'S_STATUS_CLOSED' => $status_data['status_closed'] ? true : false)); return; } switch ($action) { case 'add': $template->assign_vars(array('S_STATUS_ADD' => true, 'U_ACTION' => $this->u_action)); return; break; case 'edit': $template->assign_vars(array('S_STATUS_EDIT' => true, 'U_ACTION' => $this->u_action)); return; break; } if ($action == 'delete') { // Make sure the status exists $sql = 'SELECT status_id FROM ' . BUGS_STATUSES_TABLE . ' WHERE status_id = ' . $status_id; $result = $db->sql_query($sql); if (!$db->sql_fetchrow($result)) { trigger_error('NO_STATUS', E_USER_WARNING); } if (confirm_box(true)) { // Bugs having this status assigned will have a status id of 1 $sql = 'UPDATE ' . BUGS_REPORTS_TABLE . " \n\t\t\t\t\t\tSET report_status = '1'\n\t\t\t\t\t\tWHERE report_status = '{$status_id}'"; $result = $db->sql_query($sql); // Now, remove the status $sql = 'DELETE FROM ' . BUGS_STATUSES_TABLE . " \n\t\t\t\t\t\tWHERE status_id = '{$status_id}'"; $result = $db->sql_query($sql); trigger_error($user->lang['STATUS_DELETED'] . adm_back_link($this->u_action)); } else { confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('st' => $status_id, 'mode' => $mode, 'action' => $action))); } } $this->page_title = 'BUG_TRACKER_STATUSES'; // Query the statuses $sql = 'SELECT * FROM ' . BUGS_STATUSES_TABLE . ' ORDER BY status_closed ASC, status_title ASC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $url = $this->u_action . '&st=' . $row['status_id']; $template->assign_block_vars('statuses', array('STATUS_TITLE' => $row['status_title'], 'STATUS_CLOSED' => $row['status_closed'] ? $user->lang['STATUS_CLOSED'] : $user->lang['STATUS_OPEN'], 'U_EDIT' => $url . '&action=edit', 'U_DELETE' => $url . '&action=delete')); } $template->assign_vars(array('S_STATUSES' => true, 'U_ACTION' => $this->u_action)); } elseif ($mode == 'versions') { $action = request_var('action', ''); $update = isset($_POST['update']) ? true : false; $version_id = request_var('v', 0); if ($action == 'add' || $action == 'edit') { $errors = array(); $version_data = array('project_id' => request_var('project_id', 0), 'version_title' => utf8_normalize_nfc(request_var('version_title', '', true)), 'accept_new' => intval((bool) request_var('accept_new', 1))); if ($action == 'add') { $this->page_title = 'ADD_VERSION'; if ($update) { // Validate project $sql = 'SELECT project_id FROM ' . BUGS_PROJECTS_TABLE . ' WHERE project_id = ' . $version_data['project_id']; $result = $db->sql_query($sql); if (!$db->sql_fetchrow($result)) { trigger_error($user->lang['NO_PROJECT'] . adm_back_link($this->u_action)); } $sql = 'INSERT INTO ' . BUGS_VERSIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $version_data); $db->sql_query($sql); trigger_error($user->lang['VERSION_ADDED'] . adm_back_link($this->u_action)); } } elseif ($action == 'edit') { $this->page_title = 'EDIT_VERSION'; if ($update) { unset($version_data['project_id']); // Do not update that - versions cannot be transferred to other projects $sql = 'UPDATE ' . BUGS_VERSIONS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $version_data) . ' WHERE version_id = ' . $version_id; $result = $db->sql_query($sql); trigger_error($user->lang['VERSION_EDITED'] . adm_back_link($this->u_action)); } else { // Query the version details $sql = 'SELECT v.*, p.project_title FROM ' . BUGS_VERSIONS_TABLE . ' v LEFT JOIN ' . BUGS_PROJECTS_TABLE . " p ON v.project_id = p.project_id\n\t\t\t\t\t\t\tWHERE version_id = '{$version_id}'"; $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) { $version_data['version_title'] = $row['version_title']; $version_data['project_id'] = $row['project_id']; $version_data['project_title'] = $row['project_title']; $version_data['accept_new'] = $row['accept_new']; } else { trigger_error($user->lang['NO_VERSION'] . adm_back_link($this->u_action), E_USER_WARNING); } } } $projects_list = ''; $sql = 'SELECT project_id, project_title FROM ' . BUGS_PROJECTS_TABLE . ' ORDER BY project_title'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $projects_list .= '<option value="' . $row['project_id'] . '" ' . ($row['project_id'] == $version_data['project_id'] ? ' selected="selected"' : '') . '>' . $row['project_title'] . '</option>'; } $template->assign_vars(array('S_EDIT_VERSION' => true, 'S_ERROR' => sizeof($errors) ? true : false, 'S_ADD_ACTION' => $action == 'add' ? true : false, 'U_BACK' => $this->u_action, 'U_EDIT_ACTION' => $this->u_action . "&action={$action}&v={$version_id}", 'L_TITLE' => $user->lang[$this->page_title], 'ERROR_MSG' => sizeof($errors) ? implode('<br />', $errors) : '', 'VERSION_TITLE' => $version_data['version_title'], 'S_PROJECT_OPTIONS' => $projects_list, 'S_ACCEPT_NEW' => $version_data['accept_new'] ? true : false)); } switch ($action) { case 'add': $template->assign_vars(array('S_VERSION_ADD' => true, 'U_ACTION' => $this->u_action)); return; break; case 'edit': $template->assign_vars(array('PROJECT_TITLE' => $version_data['project_title'], 'S_VERSION_EDIT' => true, 'U_ACTION' => $this->u_action)); return; break; } if ($action == 'delete') { // Make sure the version exists $sql = 'SELECT version_id FROM ' . BUGS_VERSIONS_TABLE . ' WHERE version_id = ' . $version_id; $result = $db->sql_query($sql); if (!$db->sql_fetchrow($result)) { trigger_error('NO_VERSION', E_USER_WARNING); } if (confirm_box(true)) { // Bugs having this version assigned will have a version id of 1 $sql = 'UPDATE ' . BUGS_REPORTS_TABLE . " \n\t\t\t\t\t\tSET report_version = 1\n\t\t\t\t\t\tWHERE report_version = '{$version_id}'"; $result = $db->sql_query($sql); // Now, remove the version $sql = 'DELETE FROM ' . BUGS_VERSIONS_TABLE . " \n\t\t\t\t\t\tWHERE version_id = '{$version_id}'"; $result = $db->sql_query($sql); if (!$result) { trigger_error('NO_VERSION', E_USER_WARNING); } trigger_error($user->lang['VERSION_DELETED'] . adm_back_link($this->u_action)); } else { confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('v' => $version_id, 'mode' => $mode, 'action' => $action))); } } $this->page_title = 'BUG_TRACKER_VERSIONS'; $sql = $db->sql_build_query('SELECT', array('SELECT' => 'v.*, p.project_title', 'FROM' => array(BUGS_VERSIONS_TABLE => 'v'), 'LEFT_JOIN' => array(array('FROM' => array(BUGS_PROJECTS_TABLE => 'p'), 'ON' => 'v.project_id = p.project_id')), 'ORDER_BY' => 'p.project_title, v.version_id')); $result = $db->sql_query($sql); $cur_project = 0; while ($row = $db->sql_fetchrow($result)) { if ($row['project_id'] != $cur_project) { $template->assign_block_vars('projects', array('PROJECT_TITLE' => sprintf($user->lang['PROJECT_NAMED'], $row['project_title']))); $cur_project = $row['project_id']; } $url = $this->u_action . '&v=' . $row['version_id']; $template->assign_block_vars('projects.versions', array('VERSION_TITLE' => $row['version_title'], 'VERSION_ACCEPT_NEW' => $row['accept_new'] ? $user->lang['YES'] : $user->lang['NO'], 'U_EDIT' => $url . '&action=edit', 'U_DELETE' => $url . '&action=delete')); } $template->assign_vars(array('S_VERSIONS' => true, 'U_ACTION' => $this->u_action)); } elseif ($mode == 'components') { $action = request_var('action', ''); $update = isset($_POST['update']) ? true : false; $component_id = request_var('c', 0); if ($action == 'add' || $action == 'edit') { $errors = array(); $component_data = array('project_id' => request_var('project_id', 0), 'component_title' => utf8_normalize_nfc(request_var('component_title', '', true))); if ($action == 'add') { $this->page_title = 'ADD_COMPONENT'; if ($update) { // Validate project $sql = 'SELECT project_id FROM ' . BUGS_PROJECTS_TABLE . ' WHERE project_id = ' . $component_data['project_id']; $result = $db->sql_query($sql); if (!$db->sql_fetchrow($result)) { trigger_error($user->lang['NO_PROJECT'] . adm_back_link($this->u_action)); } $sql = 'INSERT INTO ' . BUGS_COMPONENTS_TABLE . ' ' . $db->sql_build_array('INSERT', $component_data); $db->sql_query($sql); trigger_error($user->lang['COMPONENT_ADDED'] . adm_back_link($this->u_action)); } } elseif ($action == 'edit') { $this->page_title = 'EDIT_COMPONENT'; if ($update) { unset($component_data['project_id']); // Do not update that - components cannot be transferred to other projects $sql = 'UPDATE ' . BUGS_COMPONENTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $component_data) . ' WHERE component_id = ' . $component_id; $result = $db->sql_query($sql); trigger_error($user->lang['COMPONENT_EDITED'] . adm_back_link($this->u_action)); } else { // Query the component details $sql = 'SELECT c.*, p.project_title FROM ' . BUGS_COMPONENTS_TABLE . ' c LEFT JOIN ' . BUGS_PROJECTS_TABLE . " p ON c.project_id = p.project_id\n\t\t\t\t\t\t\tWHERE component_id = '{$component_id}'"; $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) { $component_data['component_title'] = $row['component_title']; $component_data['project_id'] = $row['project_id']; $component_data['project_title'] = $row['project_title']; } else { trigger_error($user->lang['NO_COMPONENT'] . adm_back_link($this->u_action), E_USER_WARNING); } } } $projects_list = ''; $sql = 'SELECT project_id, project_title FROM ' . BUGS_PROJECTS_TABLE . ' ORDER BY project_title'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $projects_list .= '<option value="' . $row['project_id'] . '" ' . ($row['project_id'] == $component_data['project_id'] ? ' selected="selected"' : '') . '>' . $row['project_title'] . '</option>'; } $template->assign_vars(array('S_EDIT_COMPONENT' => true, 'S_ERROR' => sizeof($errors) ? true : false, 'S_ADD_ACTION' => $action == 'add' ? true : false, 'U_BACK' => $this->u_action, 'U_EDIT_ACTION' => $this->u_action . "&action={$action}&c={$component_id}", 'L_TITLE' => $user->lang[$this->page_title], 'ERROR_MSG' => sizeof($errors) ? implode('<br />', $errors) : '', 'COMPONENT_TITLE' => $component_data['component_title'], 'S_PROJECT_OPTIONS' => $projects_list)); } switch ($action) { case 'add': $template->assign_vars(array('S_COMPONENT_ADD' => true, 'U_ACTION' => $this->u_action)); return; break; case 'edit': $template->assign_vars(array('PROJECT_TITLE' => $component_data['project_title'], 'S_COMPONENT_EDIT' => true, 'U_ACTION' => $this->u_action)); return; break; } if ($action == 'delete') { // Make sure the component exists $sql = 'SELECT component_id FROM ' . BUGS_COMPONENTS_TABLE . ' WHERE component_id = ' . $component_id; $result = $db->sql_query($sql); if (!$db->sql_fetchrow($result)) { trigger_error('NO_COMPONENT', E_USER_WARNING); } if (confirm_box(true)) { // Bugs having this component assigned will have a component id of 1 $sql = 'UPDATE ' . BUGS_REPORTS_TABLE . " \n\t\t\t\t\t\tSET report_component = 1\n\t\t\t\t\t\tWHERE report_component = '{$component_id}'"; $result = $db->sql_query($sql); // Now, remove the version $sql = 'DELETE FROM ' . BUGS_COMPONENTS_TABLE . " \n\t\t\t\t\t\tWHERE component_id = '{$component_id}'"; $result = $db->sql_query($sql); if (!$result) { trigger_error('NO_COMPONENT', E_USER_WARNING); } trigger_error($user->lang['COMPONENT_DELETED'] . adm_back_link($this->u_action)); } else { confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('c' => $component_id, 'mode' => $mode, 'action' => $action))); } } $this->page_title = 'BUG_TRACKER_COMPONENTS'; $sql = $db->sql_build_query('SELECT', array('SELECT' => 'c.*, p.project_title', 'FROM' => array(BUGS_COMPONENTS_TABLE => 'c'), 'LEFT_JOIN' => array(array('FROM' => array(BUGS_PROJECTS_TABLE => 'p'), 'ON' => 'c.project_id = p.project_id')), 'ORDER_BY' => 'p.project_title, c.component_title')); $result = $db->sql_query($sql); $cur_project = 0; while ($row = $db->sql_fetchrow($result)) { if ($row['project_id'] != $cur_project) { $template->assign_block_vars('projects', array('PROJECT_TITLE' => sprintf($user->lang['PROJECT_NAMED'], $row['project_title']))); $cur_project = $row['project_id']; } $url = $this->u_action . '&c=' . $row['component_id']; $template->assign_block_vars('projects.components', array('COMPONENT_TITLE' => $row['component_title'], 'U_EDIT' => $url . '&action=edit', 'U_DELETE' => $url . '&action=delete')); } $template->assign_vars(array('S_COMPONENTS' => true, 'U_ACTION' => $this->u_action)); } }
if (!$forum_id) { ?> <form method="post" action="<?php echo generate_link('Forums&file=admin_prune', array('admin' => true)); ?> "><table class="tablebg" width="100%" cellspacing="1" cellpadding="4" border="0" align="center"> <tr> <th align="center"><?php echo $_CLASS['core_user']->lang['SELECT_FORUM']; ?> </th> </tr> <tr> <td class="row1" align="center"><select style="width:280px" name="f[]" multiple="true" size="5"><?php echo make_forum_select(false, false, false); ?> </select></td> </tr> <tr> <td class="cat" align="center"><input class="btnmain" type="submit" value="<?php echo $_CLASS['core_user']->lang['LOOK_UP_FORUM']; ?> " /> <input type="reset" value="<?php echo $_CLASS['core_user']->lang['RESET']; ?> " class="btnlite" /></td> </tr> </table></form> <?php
function main($id, $mode) { global $db, $user, $auth, $template, $cache; global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; $user->add_lang('mcp'); // Set up general vars $action = request_var('action', ''); $forum_id = request_var('f', 0); $start = request_var('start', 0); $deletemark = !empty($_POST['delmarked']) ? true : false; $deleteall = !empty($_POST['delall']) ? true : false; $marked = request_var('mark', array(0)); // Sort keys $sort_days = request_var('st', 0); $sort_key = request_var('sk', 't'); $sort_dir = request_var('sd', 'd'); $this->tpl_name = 'acp_logs'; $this->log_type = constant('LOG_' . strtoupper($mode)); // Delete entries if requested and able if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs')) { if (confirm_box(true)) { $where_sql = ''; if ($deletemark && sizeof($marked)) { $sql_in = array(); foreach ($marked as $mark) { $sql_in[] = $mark; } $where_sql = ' AND ' . $db->sql_in_set('log_id', $sql_in); unset($sql_in); } if ($where_sql || $deleteall) { $sql = 'DELETE FROM ' . LOG_TABLE . "\n\t\t\t\t\t\tWHERE log_type = {$this->log_type}\n\t\t\t\t\t\t{$where_sql}"; $db->sql_query($sql); add_log('admin', 'LOG_CLEAR_' . strtoupper($mode)); } } else { confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('f' => $forum_id, 'start' => $start, 'delmarked' => $deletemark, 'delall' => $deleteall, 'mark' => $marked, 'st' => $sort_days, 'sk' => $sort_key, 'sd' => $sort_dir, 'i' => $id, 'mode' => $mode, 'action' => $action))); } } // Sorting $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'], 365 => $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' => 'u.username_clean', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation'); $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); // Define where and sort sql for use in displaying logs $sql_where = $sort_days ? time() - $sort_days * 86400 : 0; $sql_sort = $sort_by_sql[$sort_key] . ' ' . ($sort_dir == 'd' ? 'DESC' : 'ASC'); $l_title = $user->lang['ACP_' . strtoupper($mode) . '_LOGS']; $l_title_explain = $user->lang['ACP_' . strtoupper($mode) . '_LOGS_EXPLAIN']; $this->page_title = $l_title; // Define forum list if we're looking @ mod logs if ($mode == 'mod') { $forum_box = '<option value="0">' . $user->lang['ALL_FORUMS'] . '</option>' . make_forum_select($forum_id); $template->assign_vars(array('S_SHOW_FORUMS' => true, 'S_FORUM_BOX' => $forum_box)); } // Grab log data $log_data = array(); $log_count = 0; view_log($mode, $log_data, $log_count, $config['topics_per_page'], $start, $forum_id, 0, 0, $sql_where, $sql_sort); $template->assign_vars(array('L_TITLE' => $l_title, 'L_EXPLAIN' => $l_title_explain, 'U_ACTION' => $this->u_action, 'S_ON_PAGE' => on_page($log_count, $config['topics_per_page'], $start), 'PAGINATION' => generate_pagination($this->u_action . "&{$u_sort_param}", $log_count, $config['topics_per_page'], $start, true), 'S_LIMIT_DAYS' => $s_limit_days, 'S_SORT_KEY' => $s_sort_key, 'S_SORT_DIR' => $s_sort_dir, 'S_CLEARLOGS' => $auth->acl_get('a_clearlogs'))); foreach ($log_data as $row) { $data = array(); $checks = array('viewtopic', 'viewlogs', 'viewforum'); foreach ($checks as $check) { if (isset($row[$check]) && $row[$check]) { $data[] = '<a href="' . $row[$check] . '">' . $user->lang['LOGVIEW_' . strtoupper($check)] . '</a>'; } } $template->assign_block_vars('log', array('USERNAME' => $row['username_full'], 'REPORTEE_USERNAME' => $row['reportee_username'] && $row['user_id'] != $row['reportee_id'] ? $row['reportee_username_full'] : '', 'IP' => $row['ip'], 'DATE' => $user->format_date($row['time']), 'ACTION' => $row['action'], 'DATA' => sizeof($data) ? implode(' | ', $data) : '', 'ID' => $row['id'])); } }
/** * @return array */ private function _get_forum_options() { if (!function_exists('make_forum_select')) { include $this->phpbb_root_path . 'includes/functions_admin.' . $this->php_ext; } $forumlist = make_forum_select(false, false, true, false, false, false, true); $forum_options = array('' => 'ALL'); foreach ($forumlist as $row) { $forum_options[$row['forum_id']] = $row['padding'] . $row['forum_name']; } return $forum_options; }
function select_exclude_forums($value, $key) { global $user, $config; $forum_list = make_forum_select(false, false, true, true, true, false, true); // Build forum options $s_forum_options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">'; foreach ($forum_list as $f_id => $f_row) { $f_row['selected'] = phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $f_row['forum_options']); $s_forum_options .= '<option value="' . $f_id . '"' . ($f_row['selected'] ? ' selected="selected"' : '') . ($f_row['disabled'] ? ' disabled="disabled" class="disabled-option"' : '') . '>' . $f_row['padding'] . $f_row['forum_name'] . '</option>'; } $s_forum_options .= '</select>'; return $s_forum_options; }
/** * Display copy permission page * Not used at the moment - we will have a look at it for 3.0.7 */ function copy_permission_page($forum_data) { global $phpEx, $phpbb_admin_path, $template, $user; $acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_data['forum_id']; $action = append_sid($this->u_action . "&parent_id={$this->parent_id}&f={$forum_data['forum_id']}&action=copy_perm"); $l_acl = sprintf($user->lang['COPY_TO_ACL'], '<a href="' . append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=permissions' . $acl_url) . '">', '</a>'); $this->tpl_name = 'acp_forums_copy_perm'; $template->assign_vars(array('U_ACL' => append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=permissions' . $acl_url), 'L_ACL_LINK' => $l_acl, 'L_BACK_LINK' => adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), 'S_COPY_ACTION' => $action, 'S_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $forum_data['forum_id'], false, false, false))); }
/** * Generate forum select box * * @param string $value Value of select box * @param string $key Key of select box * * @return string HTML code of select box * @access public */ public function generate_forum_select($value, $key) { $forum_list = make_forum_select(false, false, true, true, true, false, true); $selected_options = $select_ary = array(); if (isset($this->config[$key]) && strlen($this->config[$key]) > 0) { $selected_options = explode(',', $this->config[$key]); } // Build forum options foreach ($forum_list as $f_id => $f_row) { $select_ary[] = array('value' => $f_id, 'title' => $f_row['padding'] . $f_row['forum_name'], 'disabled' => $f_row['disabled']); } return $this->generate_select_box($key, $select_ary, $selected_options, true); }
$message = $lang['Topic_split'] . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . "viewtopic.{$phpEx}?" . POST_TOPIC_URL . "={$topic_id}&sid=" . $userdata['session_id'] . '">', '</a>'); message_die(GENERAL_MESSAGE, $message); } } else { // // Set template files // $template->set_filenames(array('split_body' => 'modcp_split.tpl')); $sql = "SELECT u.username, p.*, pt.post_text, pt.bbcode_uid, pt.post_subject, p.post_username\n\t\t\t\tFROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt\n\t\t\t\tWHERE p.topic_id = {$topic_id}\n\t\t\t\t\tAND p.poster_id = u.user_id\n\t\t\t\t\tAND p.post_id = pt.post_id\n\t\t\t\tORDER BY p.post_time ASC"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not get topic/post information', '', __LINE__, __FILE__, $sql); } $s_hidden_fields = '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" /><input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" /><input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '" /><input type="hidden" name="mode" value="split" />'; if (($total_posts = $db->sql_numrows($result)) > 0) { $postrow = $db->sql_fetchrowset($result); $template->assign_vars(array('L_SPLIT_TOPIC' => $lang['Split_Topic'], 'L_SPLIT_TOPIC_EXPLAIN' => $lang['Split_Topic_explain'], 'L_AUTHOR' => $lang['Author'], 'L_MESSAGE' => $lang['Message'], 'L_SELECT' => $lang['Select'], 'L_SPLIT_SUBJECT' => $lang['Split_title'], 'L_SPLIT_FORUM' => $lang['Split_forum'], 'L_POSTED' => $lang['Posted'], 'L_SPLIT_POSTS' => $lang['Split_posts'], 'L_SUBMIT' => $lang['Submit'], 'L_SPLIT_AFTER' => $lang['Split_after'], 'L_POST_SUBJECT' => $lang['Post_subject'], 'L_MARK_ALL' => $lang['Mark_all'], 'L_UNMARK_ALL' => $lang['Unmark_all'], 'L_POST' => $lang['Post'], 'FORUM_NAME' => $forum_name, 'U_VIEW_FORUM' => append_sid("viewforum.{$phpEx}?" . POST_FORUM_URL . "={$forum_id}"), 'S_SPLIT_ACTION' => append_sid("modcp.{$phpEx}"), 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_FORUM_SELECT' => make_forum_select("new_forum_id", false, $forum_id))); // // Define censored word matches // $orig_word = array(); $replacement_word = array(); obtain_word_list($orig_word, $replacement_word); for ($i = 0; $i < $total_posts; $i++) { $post_id = $postrow[$i]['post_id']; $poster_id = $postrow[$i]['poster_id']; $poster = $postrow[$i]['username']; $post_date = create_date($board_config['default_dateformat'], $postrow[$i]['post_time'], $board_config['board_timezone']); $bbcode_uid = $postrow[$i]['bbcode_uid']; $message = $postrow[$i]['post_text']; $post_subject = $postrow[$i]['post_subject'] != '' ? $postrow[$i]['post_subject'] : $topic_title; //
function main($id, $mode) { global $config, $db, $user, $auth, $template, $cache; global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $file_uploads; $user->add_lang(array('posting', 'ucp', 'acp/users')); $this->tpl_name = 'acp_users'; $this->page_title = 'ACP_USER_' . strtoupper($mode); include $phpbb_root_path . 'includes/functions_user.' . $phpEx; include $phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx; $error = array(); $username = request_var('username', '', true); $user_id = request_var('u', 0); $action = request_var('action', ''); $submit = isset($_POST['update']) ? true : false; // Whois (special case) if ($action == 'whois') { $this->page_title = 'WHOIS'; $this->tpl_name = 'simple_body'; $user_ip = request_var('user_ip', ''); $domain = gethostbyaddr($user_ip); $ipwhois = ''; if ($ipwhois = user_ipwhois($user_ip)) { $ipwhois = preg_replace('#(\\s)([\\w\\-\\._\\+]+@[\\w\\-\\.]+)(\\s)#', '\\1<a href="mailto:\\2">\\2</a>\\3', $ipwhois); $ipwhois = preg_replace('#(\\s)(http:/{2}[^\\s]*)(\\s)#', '\\1<a href="\\2" target="_blank">\\2</a>\\3', $ipwhois); } $template->assign_vars(array('MESSAGE_TITLE' => sprintf($user->lang['IP_WHOIS_FOR'], $domain), 'MESSAGE_TEXT' => nl2br($ipwhois))); return; } // Show user selection mask if (!$username && !$user_id) { $this->page_title = 'SELECT_USER'; $template->assign_vars(array('U_ACTION' => $this->u_action, 'ANONYMOUS_USER_ID' => ANONYMOUS, 'S_SELECT_USER' => true, 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=searchuser&form=select_user&field=username'))); return; } if (!$user_id) { $sql = 'SELECT user_id FROM ' . USERS_TABLE . "\n\t\t\t\tWHERE username = '******'"; $result = $db->sql_query($sql); $user_id = (int) $db->sql_fetchfield('user_id'); $db->sql_freeresult($result); if (!$user_id) { trigger_error($user->lang['NO_USER'] . adm_back_link($this->u_action)); } } // Generate content for all modes $sql = 'SELECT u.*, s.* FROM ' . USERS_TABLE . ' u LEFT JOIN ' . SESSIONS_TABLE . ' s ON (s.session_user_id = u.user_id) WHERE u.user_id = ' . $user_id . ' ORDER BY s.session_time DESC'; $result = $db->sql_query($sql); $user_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$user_row) { trigger_error($user->lang['NO_USER'] . adm_back_link($this->u_action)); } // Generate overall "header" for user admin $s_form_options = ''; // Include info file... include_once $phpbb_root_path . 'includes/acp/info/acp_users.' . $phpEx; $forms_ary = acp_users_info::module(); foreach ($forms_ary['modes'] as $value => $ary) { if (!$this->is_authed($ary['auth'])) { continue; } $selected = $mode == $value ? ' selected="selected"' : ''; $s_form_options .= '<option value="' . $value . '"' . $selected . '>' . $user->lang['ACP_USER_' . strtoupper($value)] . '</option>'; } $template->assign_vars(array('U_BACK' => $this->u_action, 'U_MODE_SELECT' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i={$id}&u={$user_id}"), 'U_ACTION' => $this->u_action . '&u=' . $user_id, 'S_FORM_OPTIONS' => $s_form_options)); // Prevent normal users/admins change/view founders if they are not a founder by themselves if ($user->data['user_type'] != USER_FOUNDER && $user_row['user_type'] == USER_FOUNDER) { trigger_error($user->lang['NOT_MANAGE_FOUNDER'] . adm_back_link($this->u_action)); } switch ($mode) { case 'overview': $delete = request_var('delete', 0); $delete_type = request_var('delete_type', ''); $ip = request_var('ip', 'ip'); if ($submit) { // You can't delete the founder if ($delete && $user_row['user_type'] != USER_FOUNDER) { if (!$auth->acl_get('a_userdel')) { trigger_error($user->lang['NO_ADMIN'] . adm_back_link($this->u_action . '&u=' . $user_id)); } // Check if the user wants to remove himself or the guest user account if ($user_id == ANONYMOUS) { trigger_error($user->lang['CANNOT_REMOVE_ANONYMOUS'] . adm_back_link($this->u_action . '&u=' . $user_id)); } if ($user_id == $user->data['user_id']) { trigger_error($user->lang['CANNOT_REMOVE_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id)); } if (confirm_box(true)) { user_delete($delete_type, $user_id); add_log('admin', 'LOG_USER_DELETED', $user_row['username']); trigger_error($user->lang['USER_DELETED'] . adm_back_link($this->u_action)); } else { confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'update' => true, 'delete' => 1, 'delete_type' => $delete_type))); } } // Handle quicktool actions switch ($action) { case 'banuser': case 'banemail': case 'banip': $ban = array(); switch ($action) { case 'banuser': $ban[] = $user_row['username']; $reason = 'USER_ADMIN_BAN_NAME_REASON'; $log = 'LOG_USER_BAN_USER'; break; case 'banemail': $ban[] = $user_row['user_email']; $reason = 'USER_ADMIN_BAN_EMAIL_REASON'; $log = 'LOG_USER_BAN_EMAIL'; break; case 'banip': $ban[] = $user_row['user_ip']; $sql = 'SELECT DISTINCT poster_ip FROM ' . POSTS_TABLE . "\n\t\t\t\t\t\t\t\t\t\tWHERE 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_USER_BAN_IP'; break; } user_ban(substr($action, 3), $ban, 0, 0, 0, $user->lang[$reason]); add_log('admin', $log, $user->lang[$reason]); add_log('user', $user_id, $log, $user->lang[$reason]); trigger_error($user->lang['BAN_SUCCESSFUL'] . adm_back_link($this->u_action . '&u=' . $user_id)); break; case 'reactivate': if ($config['email_enable']) { include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx; $server_url = generate_board_url(); $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); if ($user_row['user_type'] != USER_INACTIVE) { user_active_flip($user_id, $user_row['user_type'], $user_actkey, $user_row['username']); } $messenger = new messenger(false); $messenger->template('user_resend_inactive', $user_row['user_lang']); $messenger->replyto($config['board_contact']); $messenger->to($user_row['user_email'], $user_row['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->assign_vars(array('SITENAME' => $config['sitename'], 'WELCOME_MSG' => sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename']), 'USERNAME' => html_entity_decode($user_row['username']), 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']), 'U_ACTIVATE' => "{$server_url}/ucp.{$phpEx}?mode=activate&u={$user_row['user_id']}&k={$user_actkey}")); $messenger->send(NOTIFY_EMAIL); add_log('admin', 'LOG_USER_REACTIVATE', $user_row['username']); add_log('user', $user_id, 'LOG_USER_REACTIVATE_USER'); trigger_error($user->lang['FORCE_REACTIVATION_SUCCESS'] . adm_back_link($this->u_action . '&u=' . $user_id)); } break; case 'active': user_active_flip($user_id, $user_row['user_type'], false, $user_row['username']); $message = $user_row['user_type'] == USER_INACTIVE ? 'USER_ADMIN_ACTIVATED' : 'USER_ADMIN_DEACTIVED'; $log = $user_row['user_type'] == USER_INACTIVE ? 'LOG_USER_ACTIVE' : 'LOG_USER_INACTIVE'; add_log('user', $user_id, $log . '_USER'); if ($user_row['user_type'] == USER_INACTIVE) { set_config('num_users', $config['num_users'] + 1, true); } else { set_config('num_users', $config['num_users'] - 1, true); } // Update latest username update_last_username(); trigger_error($user->lang[$message] . adm_back_link($this->u_action . '&u=' . $user_id)); break; case 'delsig': $sql_ary = array('user_sig' => '', 'user_sig_bbcode_uid' => '', 'user_sig_bbcode_bitfield' => 0); $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\t\t\t\t\tWHERE user_id = {$user_id}"; $db->sql_query($sql); add_log('admin', 'LOG_USER_DEL_SIG', $user_row['username']); add_log('user', $user_id, 'LOG_USER_DEL_SIG_USER'); trigger_error($user->lang['USER_ADMIN_SIG_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id)); break; case 'delavatar': $sql_ary = array('user_avatar' => '', 'user_avatar_type' => 0, 'user_avatar_width' => 0, 'user_avatar_height' => 0); $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\t\t\t\t\tWHERE user_id = {$user_id}"; $db->sql_query($sql); // Delete old avatar if present if ($user_row['user_avatar'] && $user_row['user_avatar_type'] != AVATAR_GALLERY) { avatar_delete($user_row['user_avatar']); } add_log('admin', 'LOG_USER_DEL_AVATAR', $user_row['username']); add_log('user', $user_id, 'LOG_USER_DEL_AVATAR_USER'); trigger_error($user->lang['USER_ADMIN_AVATAR_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id)); break; case 'delposts': if (confirm_box(true)) { $sql = 'SELECT topic_id, COUNT(post_id) AS total_posts FROM ' . POSTS_TABLE . "\n\t\t\t\t\t\t\t\t\tWHERE poster_id = {$user_id}\n\t\t\t\t\t\t\t\t\tGROUP BY topic_id"; $result = $db->sql_query($sql); $topic_id_ary = array(); while ($row = $db->sql_fetchrow($result)) { $topic_id_ary[$row['topic_id']] = $row['total_posts']; } $db->sql_freeresult($result); if (sizeof($topic_id_ary)) { $sql = 'SELECT topic_id, topic_replies, topic_replies_real FROM ' . TOPICS_TABLE . ' WHERE topic_id IN (' . implode(', ', array_keys($topic_id_ary)) . ')'; $result = $db->sql_query($sql); $del_topic_ary = array(); while ($row = $db->sql_fetchrow($result)) { if (max($row['topic_replies'], $row['topic_replies_real']) + 1 == $topic_id_ary[$row['topic_id']]) { $del_topic_ary[] = $row['topic_id']; } } $db->sql_freeresult($result); if (sizeof($del_topic_ary)) { $sql = 'DELETE FROM ' . TOPICS_TABLE . ' WHERE topic_id IN (' . implode(', ', $del_topic_ary) . ')'; $db->sql_query($sql); } } // Delete posts, attachments, etc. delete_posts('poster_id', $user_id); add_log('admin', 'LOG_USER_DEL_POSTS', $user_row['username']); trigger_error($user->lang['USER_POSTS_DELETED'] . adm_back_link($this->u_action . '&u=' . $user_id)); } else { confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'update' => true))); } break; case 'delattach': if (confirm_box(true)) { delete_attachments('user', $user_id); add_log('admin', 'LOG_USER_DEL_ATTACH', $user_row['username']); trigger_error($user->lang['USER_ATTACHMENTS_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id)); } else { confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'update' => true))); } break; case 'moveposts': $new_forum_id = request_var('new_f', 0); if (!$new_forum_id) { $this->page_title = 'USER_ADMIN_MOVE_POSTS'; $template->assign_vars(array('S_SELECT_FORUM' => true, 'U_ACTION' => $this->u_action . "&action={$action}&u={$user_id}", 'U_BACK' => $this->u_action . "&u={$user_id}", 'S_FORUM_OPTIONS' => make_forum_select(false, false, false, true))); return; } // Two stage? // Move topics comprising only posts from this user $topic_id_ary = $move_topic_ary = $move_post_ary = $new_topic_id_ary = array(); $forum_id_ary = array($new_forum_id); $sql = 'SELECT topic_id, COUNT(post_id) AS total_posts FROM ' . POSTS_TABLE . "\n\t\t\t\t\t\t\t\tWHERE poster_id = {$user_id}\n\t\t\t\t\t\t\t\t\tAND forum_id <> {$new_forum_id}\n\t\t\t\t\t\t\t\tGROUP BY topic_id"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $topic_id_ary[$row['topic_id']] = $row['total_posts']; } $db->sql_freeresult($result); if (sizeof($topic_id_ary)) { $sql = 'SELECT topic_id, 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); 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 { $move_post_ary[$row['topic_id']]['title'] = $row['topic_title']; $move_post_ary[$row['topic_id']]['attach'] = $row['attach'] ? 1 : 0; } $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); } 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' => $user_row['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 . "\n\t\t\t\t\t\t\t\t\t\tSET forum_id = {$new_forum_id}, topic_id = {$new_topic_id}\n\t\t\t\t\t\t\t\t\t\tWHERE topic_id = {$topic_id}\n\t\t\t\t\t\t\t\t\t\t\tAND poster_id = {$user_id}"; $db->sql_query($sql); if ($post_ary['attach']) { $sql = 'UPDATE ' . ATTACHMENTS_TABLE . "\n\t\t\t\t\t\t\t\t\t\t\tSET topic_id = {$new_topic_id}\n\t\t\t\t\t\t\t\t\t\t\tWHERE topic_id = {$topic_id}\n\t\t\t\t\t\t\t\t\t\t\t\tAND poster_id = {$user_id}"; $db->sql_query($sql); } $new_topic_id_ary[] = $new_topic_id; } } $forum_id_ary = array_unique($forum_id_ary); $topic_id_ary = array_unique(array_merge($topic_id_ary, $new_topic_id_ary)); if (sizeof($topic_id_ary)) { sync('reported', 'topic_id', $topic_id_ary); sync('topic', 'topic_id', $topic_id_ary); } if (sizeof($forum_id_ary)) { sync('forum', 'forum_id', $forum_id_ary); } $sql = 'SELECT forum_name FROM ' . FORUMS_TABLE . "\n\t\t\t\t\t\t\t\tWHERE forum_id = {$new_forum_id}"; $result = $db->sql_query($sql, 3600); $forum_info = $db->sql_fetchrow($result); $db->sql_freeresult($result); add_log('admin', 'LOG_USER_MOVE_POSTS', $user_row['username'], $forum_info['forum_name']); add_log('user', $user_id, 'LOG_USER_MOVE_POSTS_USER', $forum_info['forum_name']); trigger_error($user->lang['USER_POSTS_MOVED'] . adm_back_link($this->u_action . '&u=' . $user_id)); break; } $data = array(); // Handle registration info updates $var_ary = array('user' => (string) $user_row['username'], 'user_founder' => (int) ($user_row['user_type'] == USER_FOUNDER ? 1 : 0), 'user_email' => (string) $user_row['user_email'], 'email_confirm' => (string) '', 'user_password' => (string) '', 'password_confirm' => (string) '', 'warnings' => (int) $user_row['user_warnings']); // Get the data from the form. Use data from the database if no info is provided foreach ($var_ary as $var => $default) { $data[$var] = request_var($var, $default); } // We use user within the form to circumvent auto filling $data['username'] = $data['user']; unset($data['user']); // Validation data $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']), 'warnings' => array('num')); // Check username if altered if ($data['username'] != $user_row['username']) { $var_ary += array('username' => array(array('string', false, $config['min_name_chars'], $config['max_name_chars']), array('username', $user_row['username']))); } // Check email if altered if ($data['user_email'] != $user_row['user_email']) { $var_ary += array('user_email' => array(array('string', false, 6, 60), array('email', $user_row['user_email'])), 'email_confirm' => array('string', true, 6, 60)); } $error = validate_data($data, $var_ary); if ($data['user_password'] && $data['password_confirm'] != $data['user_password']) { $error[] = 'NEW_PASSWORD_ERROR'; } if ($data['user_email'] != $user_row['user_email'] && $data['email_confirm'] != $data['user_email']) { $error[] = 'NEW_EMAIL_ERROR'; } // Which updates do we need to do? $update_warning = $user_row['user_warnings'] != $data['warnings'] ? true : false; $update_username = $user_row['username'] != $data['username'] ? $data['username'] : false; $update_password = $data['user_password'] && $user_row['user_password'] != md5($data['user_password']) ? true : false; $update_email = $data['user_email'] != $user_row['user_email'] ? $data['user_email'] : false; if (!sizeof($error)) { $sql_ary = array(); if ($user_row['user_type'] != USER_FOUNDER || $user->data['user_type'] == USER_FOUNDER) { if ($update_warning) { $sql_ary['user_warnings'] = $data['warnings']; } if ($user_row['user_type'] == USER_FOUNDER && !$data['user_founder'] || $user_row['user_type'] != USER_FOUNDER && $data['user_founder']) { $sql_ary['user_type'] = $data['user_founder'] ? USER_FOUNDER : USER_NORMAL; } } if ($update_username !== false) { $sql_ary['username'] = $update_username; add_log('user', $user_id, 'LOG_USER_UPDATE_NAME', $user_row['username'], $update_username); } if ($update_email !== false) { $sql_ary += array('user_email' => $update_email, 'user_email_hash' => crc32(strtolower($update_email)) . strlen($update_email)); add_log('user', $user_id, 'LOG_USER_UPDATE_EMAIL', $user_row['username'], $user_row['user_email'], $update_email); } if ($update_password) { $sql_ary += array('user_password' => md5($data['user_password']), 'user_passchg' => time()); $user->reset_login_keys($user_id); add_log('user', $user_id, 'LOG_USER_NEW_PASSWORD', $user_row['username']); } if (sizeof($sql_ary)) { $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $user_id; $db->sql_query($sql); } /** * @todo adjust every data based in the number of user warnings */ if ($update_warning) { } if ($update_username) { user_update_name($user_row['username'], $update_username); } add_log('admin', 'LOG_USER_USER_UPDATE', $data['username']); trigger_error($user->lang['USER_OVERVIEW_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); } // Replace "error" strings with their real, localised form $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); } $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_row['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'; } $s_action_options = '<option class="sep" value="">' . $user->lang['SELECT_OPTION'] . '</option>'; foreach ($quick_tool_ary as $value => $lang) { $s_action_options .= '<option value="' . $value . '">' . $user->lang['USER_ADMIN_' . $lang] . '</option>'; } $template->assign_vars(array('L_NAME_CHARS_EXPLAIN' => sprintf($user->lang[$user_char_ary[$config['allow_name_chars']] . '_EXPLAIN'], $config['min_name_chars'], $config['max_name_chars']), 'L_CHANGE_PASSWORD_EXPLAIN' => sprintf($user->lang['CHANGE_PASSWORD_EXPLAIN'], $config['min_pass_chars'], $config['max_pass_chars']), 'S_FOUNDER' => $user->data['user_type'] == USER_FOUNDER ? true : false, 'S_OVERVIEW' => true, 'S_USER_IP' => $user_row['user_ip'] ? true : false, 'S_USER_FOUNDER' => $user_row['user_type'] == USER_FOUNDER ? true : false, 'S_ACTION_OPTIONS' => $s_action_options, 'U_SHOW_IP' => $this->u_action . "&u={$user_id}&ip=" . ($ip == 'ip' ? 'hostname' : 'ip'), 'U_WHOIS' => $this->u_action . "&action=whois&user_ip={$user_row['user_ip']}", 'U_SWITCH_PERMISSIONS' => $auth->acl_get('a_switchperm') && $user->data['user_id'] != $user_row['user_id'] ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", "mode=switch_perm&u={$user_row['user_id']}") : '', 'USER' => $user_row['username'], 'USER_REGISTERED' => $user->format_date($user_row['user_regdate']), 'REGISTERED_IP' => $ip == 'hostname' ? gethostbyaddr($user_row['user_ip']) : $user_row['user_ip'], 'USER_LASTACTIVE' => $user_row['user_lastvisit'] ? $user->format_date($user_row['user_lastvisit']) : ' - ', 'USER_EMAIL' => $user_row['user_email'], 'USER_WARNINGS' => $user_row['user_warnings'])); break; case 'feedback': $user->add_lang('mcp'); // Set up general vars $start = request_var('start', 0); $deletemark = isset($_POST['delmarked']) ? true : false; $deleteall = isset($_POST['delall']) ? true : false; $marked = request_var('mark', array(0)); $message = request_var('message', '', true); // Sort keys $sort_days = request_var('st', 0); $sort_key = request_var('sk', 't'); $sort_dir = request_var('sd', 'd'); // Delete entries if requested and able 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); } if ($where_sql || $deleteall) { $sql = 'DELETE FROM ' . LOG_TABLE . ' WHERE log_type = ' . LOG_USERS . "\n\t\t\t\t\t\t\t{$where_sql}"; $db->sql_query($sql); add_log('admin', 'LOG_CLEAR_USER', $user_row['username']); } } if ($submit && $message) { add_log('admin', '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)); } // Sorting $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'], 365 => $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'); $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); // Define where and sort sql for use in displaying logs $sql_where = $sort_days ? time() - $sort_days * 86400 : 0; $sql_sort = $sort_by_sql[$sort_key] . ' ' . ($sort_dir == 'd' ? 'DESC' : 'ASC'); // Grab log data $log_data = array(); $log_count = 0; view_log('user', $log_data, $log_count, $config['topics_per_page'], $start, 0, 0, $user_id, $sql_where, $sql_sort); $template->assign_vars(array('S_FEEDBACK' => true, 'S_ON_PAGE' => on_page($log_count, $config['topics_per_page'], $start), 'PAGINATION' => generate_pagination($this->u_action . "&u={$user_id}&{$u_sort_param}", $log_count, $config['topics_per_page'], $start, true), 'S_LIMIT_DAYS' => $s_limit_days, 'S_SORT_KEY' => $s_sort_key, 'S_SORT_DIR' => $s_sort_dir, 'S_CLEARLOGS' => $auth->acl_get('a_clearlogs'))); foreach ($log_data as $row) { $template->assign_block_vars('log', array('USERNAME' => $row['username'], 'IP' => $row['ip'], 'DATE' => $user->format_date($row['time']), 'ACTION' => nl2br($row['action']), 'ID' => $row['id'])); } break; case 'profile': $cp = new custom_profile(); $cp_data = $cp_error = array(); $data = array(); $sql = 'SELECT lang_id FROM ' . LANG_TABLE . "\n\t\t\t\t\tWHERE lang_iso = '" . $db->sql_escape($user_row['user_lang']) . "'"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); $user_row['iso_lang_id'] = $row['lang_id']; 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] = in_array($var, array('location', 'occupation', 'interests')) ? request_var($var, $default, true) : ($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, 3, 17), '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); // validate custom profile fields $cp->submit_cp_field('profile', $user_row['iso_lang_id'], $cp_data, $cp_error); if (sizeof($cp_error)) { $error = array_merge($error, $cp_error); } if (!sizeof($error)) { $sql_ary = array('user_icq' => $data['icq'], 'user_aim' => $data['aim'], 'user_msnm' => $data['msn'], 'user_yim' => $data['yim'], 'user_jabber' => $data['jabber'], 'user_website' => $data['website'], 'user_from' => $data['location'], 'user_occ' => $data['occupation'], 'user_interests' => $data['interests'], 'user_birthday' => sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['bday_year'])); $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\t\t\t\tWHERE user_id = {$user_id}"; $db->sql_query($sql); // Update Custom Fields if (sizeof($cp_data)) { $sql = 'UPDATE ' . PROFILE_FIELDS_DATA_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $cp_data) . "\n\t\t\t\t\t\t\t\tWHERE user_id = {$user_id}"; $db->sql_query($sql); if (!$db->sql_affectedrows()) { $cp_data['user_id'] = (int) $user_id; $db->return_on_error = true; $sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $cp_data); $db->sql_query($sql); $db->return_on_error = false; } } trigger_error($user->lang['USER_PROFILE_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); } // Replace "error" strings with their real, localised form $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); } if (!isset($data['bday_day'])) { if ($user_row['user_birthday']) { list($data['bday_day'], $data['bday_month'], $data['bday_year']) = explode('-', $user_row['user_birthday']); } else { $data['bday_day'] = $data['bday_month'] = $data['bday_year'] = 0; } } $s_birthday_day_options = '<option value="0"' . (!$data['bday_day'] ? ' selected="selected"' : '') . '>--</option>'; for ($i = 1; $i < 32; $i++) { $selected = $i == $data['bday_day'] ? ' selected="selected"' : ''; $s_birthday_day_options .= "<option value=\"{$i}\"{$selected}>{$i}</option>"; } $s_birthday_month_options = '<option value="0"' . (!$data['bday_month'] ? ' selected="selected"' : '') . '>--</option>'; for ($i = 1; $i < 13; $i++) { $selected = $i == $data['bday_month'] ? ' selected="selected"' : ''; $s_birthday_month_options .= "<option value=\"{$i}\"{$selected}>{$i}</option>"; } $s_birthday_year_options = ''; $now = getdate(); $s_birthday_year_options = '<option value="0"' . (!$data['bday_year'] ? ' selected="selected"' : '') . '>--</option>'; for ($i = $now['year'] - 100; $i < $now['year']; $i++) { $selected = $i == $data['bday_year'] ? ' selected="selected"' : ''; $s_birthday_year_options .= "<option value=\"{$i}\"{$selected}>{$i}</option>"; } unset($now); $template->assign_vars(array('ICQ' => isset($data['icq']) ? $data['icq'] : $user_row['user_icq'], 'YIM' => isset($data['yim']) ? $data['yim'] : $user_row['user_yim'], 'AIM' => isset($data['aim']) ? $data['aim'] : $user_row['user_aim'], 'MSN' => isset($data['msn']) ? $data['msn'] : $user_row['user_msnm'], 'JABBER' => isset($data['jabber']) ? $data['jabber'] : $user_row['user_jabber'], 'WEBSITE' => isset($data['website']) ? $data['website'] : $user_row['user_website'], 'LOCATION' => isset($data['location']) ? $data['location'] : $user_row['user_from'], 'OCCUPATION' => isset($data['occupation']) ? $data['occupation'] : $user_row['user_occ'], 'INTERESTS' => isset($data['interests']) ? $data['interests'] : $user_row['user_interests'], 'S_BIRTHDAY_DAY_OPTIONS' => $s_birthday_day_options, 'S_BIRTHDAY_MONTH_OPTIONS' => $s_birthday_month_options, 'S_BIRTHDAY_YEAR_OPTIONS' => $s_birthday_year_options, 'S_PROFILE' => true)); // Get additional profile fields and assign them to the template block var 'profile_fields' $user->get_profile_fields($user_id); $cp->generate_profile_fields('profile', $user_row['iso_lang_id']); break; case 'prefs': $data = array(); if ($submit) { $var_ary = array('dateformat' => (string) $config['default_dateformat'], 'lang' => (string) $config['default_lang'], 'tz' => (double) $config['board_timezone'], 'style' => (int) $config['default_style'], 'dst' => (bool) $config['board_dst'], 'viewemail' => false, 'massemail' => true, 'hideonline' => false, 'notifymethod' => 0, 'notifypm' => true, 'popuppm' => false, 'allowpm' => true, 'topic_sk' => (string) 't', 'topic_sd' => (string) 'd', 'topic_st' => 0, 'post_sk' => (string) 't', 'post_sd' => (string) 'a', 'post_st' => 0, 'view_images' => true, 'view_flash' => false, 'view_smilies' => true, 'view_sigs' => true, 'view_avatars' => true, 'view_wordcensor' => false, 'bbcode' => true, 'smilies' => true, 'sig' => true, 'notify' => false); foreach ($var_ary as $var => $default) { $data[$var] = request_var($var, $default); } $var_ary = array('dateformat' => array('string', false, 3, 30), 'lang' => array('match', false, '#^[a-z_]{2,}$#i'), 'tz' => array('num', false, -14, 14), 'topic_sk' => array('string', false, 1, 1), 'topic_sd' => array('string', false, 1, 1), 'post_sk' => array('string', false, 1, 1), 'post_sd' => array('string', false, 1, 1)); $error = validate_data($data, $var_ary); if (!sizeof($error)) { $this->optionset($user_row, 'popuppm', $data['popuppm']); $this->optionset($user_row, 'viewimg', $data['view_images']); $this->optionset($user_row, 'viewflash', $data['view_flash']); $this->optionset($user_row, 'viewsmilies', $data['view_smilies']); $this->optionset($user_row, 'viewsigs', $data['view_sigs']); $this->optionset($user_row, 'viewavatars', $data['view_avatars']); $this->optionset($user_row, 'viewcensors', $data['view_wordcensor']); $this->optionset($user_row, 'bbcode', $data['bbcode']); $this->optionset($user_row, 'smilies', $data['smilies']); $this->optionset($user_row, 'attachsig', $data['sig']); $sql_ary = array('user_options' => $user_row['user_options'], 'user_allow_pm' => $data['allowpm'], 'user_allow_viewemail' => $data['viewemail'], 'user_allow_massemail' => $data['massemail'], 'user_allow_viewonline' => !$data['hideonline'], 'user_notify_type' => $data['notifymethod'], 'user_notify_pm' => $data['notifypm'], 'user_dst' => $data['dst'], 'user_dateformat' => $data['dateformat'], 'user_lang' => $data['lang'], 'user_timezone' => $data['tz'], 'user_style' => $data['style'], 'user_topic_sortby_type' => $data['topic_sk'], 'user_post_sortby_type' => $data['post_sk'], 'user_topic_sortby_dir' => $data['topic_sd'], 'user_post_sortby_dir' => $data['post_sd'], 'user_topic_show_days' => $data['topic_st'], 'user_post_show_days' => $data['post_st'], 'user_notify' => $data['notify']); $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\t\t\t\tWHERE user_id = {$user_id}"; $db->sql_query($sql); trigger_error($user->lang['USER_PREFS_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); } // Replace "error" strings with their real, localised form $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); } $notify_method = isset($data['notifymethod']) ? $data['notifymethod'] : $user_row['user_notify_type']; $dateformat = isset($data['dateformat']) ? $data['dateformat'] : $user_row['user_dateformat']; $lang = isset($data['lang']) ? $data['lang'] : $user_row['user_lang']; $style = isset($data['style']) ? $data['style'] : $user_row['user_style']; $tz = isset($data['tz']) ? $data['tz'] : $user_row['user_timezone']; $dateformat_options = ''; foreach ($user->lang['dateformats'] as $format => $null) { $dateformat_options .= '<option value="' . $format . '"' . ($format == $dateformat ? ' selected="selected"' : '') . '>'; $dateformat_options .= $user->format_date(time(), $format, true) . (strpos($format, '|') !== false ? ' [' . $user->lang['RELATIVE_DAYS'] . ']' : ''); $dateformat_options .= '</option>'; } $s_custom = false; $dateformat_options .= '<option value="custom"'; if (!in_array($dateformat, array_keys($user->lang['dateformats']))) { $dateformat_options .= ' selected="selected"'; $s_custom = true; } $dateformat_options .= '>' . $user->lang['CUSTOM_DATEFORMAT'] . '</option>'; $topic_sk = isset($data['topic_sk']) ? $data['topic_sk'] : ($user_row['user_topic_sortby_type'] ? $user_row['user_topic_sortby_type'] : 't'); $post_sk = isset($data['post_sk']) ? $data['post_sk'] : ($user_row['user_post_sortby_type'] ? $user_row['user_post_sortby_type'] : 't'); $topic_sd = isset($data['topic_sd']) ? $data['topic_sd'] : ($user_row['user_topic_sortby_dir'] ? $user_row['user_topic_sortby_dir'] : 'd'); $post_sd = isset($data['post_sd']) ? $data['post_sd'] : ($user_row['user_post_sortby_dir'] ? $user_row['user_post_sortby_dir'] : 'd'); $topic_st = isset($data['topic_st']) ? $data['topic_st'] : ($user_row['user_topic_show_days'] ? $user_row['user_topic_show_days'] : 0); $post_st = isset($data['post_st']) ? $data['post_st'] : ($user_row['user_post_show_days'] ? $user_row['user_post_show_days'] : 0); $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); // Topic ordering options $limit_topic_days = array(0 => $user->lang['ALL_TOPICS'], 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'], 365 => $user->lang['1_YEAR']); $sort_by_topic_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 'r' => $user->lang['REPLIES'], 's' => $user->lang['SUBJECT'], 'v' => $user->lang['VIEWS']); // Post ordering options $limit_post_days = array(0 => $user->lang['ALL_POSTS'], 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'], 365 => $user->lang['1_YEAR']); $sort_by_post_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']); $_options = array('topic', 'post'); foreach ($_options as $sort_option) { ${'s_limit_' . $sort_option . '_days'} = '<select name="' . $sort_option . '_st">'; foreach (${'limit_' . $sort_option . '_days'} as $day => $text) { $selected = ${$sort_option . '_st'} == $day ? ' selected="selected"' : ''; ${'s_limit_' . $sort_option . '_days'} .= '<option value="' . $day . '"' . $selected . '>' . $text . '</option>'; } ${'s_limit_' . $sort_option . '_days'} .= '</select>'; ${'s_sort_' . $sort_option . '_key'} = '<select name="' . $sort_option . '_sk">'; foreach (${'sort_by_' . $sort_option . '_text'} as $key => $text) { $selected = ${$sort_option . '_sk'} == $key ? ' selected="selected"' : ''; ${'s_sort_' . $sort_option . '_key'} .= '<option value="' . $key . '"' . $selected . '>' . $text . '</option>'; } ${'s_sort_' . $sort_option . '_key'} .= '</select>'; ${'s_sort_' . $sort_option . '_dir'} = '<select name="' . $sort_option . '_sd">'; foreach ($sort_dir_text as $key => $value) { $selected = ${$sort_option . '_sd'} == $key ? ' selected="selected"' : ''; ${'s_sort_' . $sort_option . '_dir'} .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; } ${'s_sort_' . $sort_option . '_dir'} .= '</select>'; } $template->assign_vars(array('S_PREFS' => true, 'S_JABBER_DISABLED' => $config['jab_enable'] && $user->data['user_jabber'] && @extension_loaded('xml') ? false : true, 'VIEW_EMAIL' => isset($data['viewemail']) ? $data['viewemail'] : $user_row['user_allow_viewemail'], 'MASS_EMAIL' => isset($data['massemail']) ? $data['massemail'] : $user_row['user_allow_massemail'], 'ALLOW_PM' => isset($data['allowpm']) ? $data['allowpm'] : $user_row['user_allow_pm'], 'HIDE_ONLINE' => isset($data['hideonline']) ? $data['hideonline'] : !$user_row['user_allow_viewonline'], 'NOTIFY_EMAIL' => $notify_method == NOTIFY_EMAIL ? true : false, 'NOTIFY_IM' => $notify_method == NOTIFY_IM ? true : false, 'NOTIFY_BOTH' => $notify_method == NOTIFY_BOTH ? true : false, 'NOTIFY_PM' => isset($data['notifypm']) ? $data['notifypm'] : $user_row['user_notify_pm'], 'POPUP_PM' => isset($data['popuppm']) ? $data['popuppm'] : $this->optionget($user_row, 'popuppm'), 'DST' => isset($data['dst']) ? $data['dst'] : $user_row['user_dst'], 'BBCODE' => isset($data['bbcode']) ? $data['bbcode'] : $this->optionget($user_row, 'bbcode'), 'SMILIES' => isset($data['smilies']) ? $data['smilies'] : $this->optionget($user_row, 'smilies'), 'ATTACH_SIG' => isset($data['sig']) ? $data['sig'] : $this->optionget($user_row, 'attachsig'), 'NOTIFY' => isset($data['notify']) ? $data['notify'] : $user_row['user_notify'], 'VIEW_IMAGES' => isset($data['view_images']) ? $data['view_images'] : $this->optionget($user_row, 'viewimg'), 'VIEW_FLASH' => isset($data['view_flash']) ? $data['view_flash'] : $this->optionget($user_row, 'viewflash'), 'VIEW_SMILIES' => isset($data['view_smilies']) ? $data['view_smilies'] : $this->optionget($user_row, 'viewsmilies'), 'VIEW_SIGS' => isset($data['view_sigs']) ? $data['view_sigs'] : $this->optionget($user_row, 'viewsigs'), 'VIEW_AVATARS' => isset($data['view_avatars']) ? $data['view_avatars'] : $this->optionget($user_row, 'viewavatars'), 'VIEW_WORDCENSOR' => isset($data['view_wordcensor']) ? $data['view_wordcensor'] : $this->optionget($user_row, 'viewcensors'), 'S_TOPIC_SORT_DAYS' => $s_limit_topic_days, 'S_TOPIC_SORT_KEY' => $s_sort_topic_key, 'S_TOPIC_SORT_DIR' => $s_sort_topic_dir, 'S_POST_SORT_DAYS' => $s_limit_post_days, 'S_POST_SORT_KEY' => $s_sort_post_key, 'S_POST_SORT_DIR' => $s_sort_post_dir, 'DATE_FORMAT' => $dateformat, 'S_DATEFORMAT_OPTIONS' => $dateformat_options, 'S_CUSTOM_DATEFORMAT' => $s_custom, 'DEFAULT_DATEFORMAT' => $config['default_dateformat'], 'A_DEFAULT_DATEFORMAT' => addslashes($config['default_dateformat']), 'S_LANG_OPTIONS' => language_select($lang), 'S_STYLE_OPTIONS' => style_select($style), 'S_TZ_OPTIONS' => tz_select($tz))); break; case 'avatar': $avatar_select = basename(request_var('avatar_select', '')); $category = basename(request_var('category', '')); $can_upload = file_exists($phpbb_root_path . $config['avatar_path']) && is_writeable($phpbb_root_path . $config['avatar_path']) && $file_uploads ? true : false; $data = array(); if ($submit) { $delete = request_var('delete', ''); $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']['name']) || $data['uploadurl']) && $can_upload && $config['allow_avatar_upload']) { list($type, $filename, $width, $height) = avatar_upload($data, $error); } else { if ($data['remotelink'] && $config['allow_avatar_remote']) { list($type, $filename, $width, $height) = avatar_remote($data, $error); } else { if ($avatar_select && $config['allow_avatar_local']) { $type = AVATAR_GALLERY; $filename = $avatar_select; // check avatar gallery if (!is_dir($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category)) { $type = $width = $height = 0; $filename = ''; } else { list($width, $height) = getimagesize($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category . '/' . $filename); $filename = $category . '/' . $filename; } } else { if ($delete) { $filename = ''; $type = $width = $height = 0; } else { $data = array(); } } } } } 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_row['user_avatar'] && $filename != $user_row['user_avatar'] && $user_row['user_avatar_type'] != AVATAR_GALLERY) { avatar_delete($user_row['user_avatar']); } } trigger_error($user->lang['USER_AVATAR_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); } // Replace "error" strings with their real, localised form $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); } // Generate users avatar if ($user_row['user_avatar']) { $avatar_img = ''; switch ($user_row['user_avatar_type']) { case AVATAR_UPLOAD: $avatar_img = $phpbb_root_path . $config['avatar_path'] . '/'; break; case AVATAR_GALLERY: $avatar_img = $phpbb_root_path . $config['avatar_gallery_path'] . '/'; break; } $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="" />'; } else { $avatar_img = '<img src="' . $phpbb_admin_path . 'images/no_avatar.gif" alt="" />'; } $display_gallery = isset($_POST['display_gallery']) ? true : false; if ($config['allow_avatar_local'] && $display_gallery) { avatar_gallery($category, $avatar_select, 4); } $template->assign_vars(array('S_AVATAR' => true, 'S_CAN_UPLOAD' => $can_upload && $config['allow_avatar_upload'] ? true : false, 'S_ALLOW_REMOTE' => $config['allow_avatar_remote'] ? true : false, 'S_DISPLAY_GALLERY' => $config['allow_avatar_local'] && !$display_gallery ? true : false, 'S_IN_GALLERY' => $config['allow_avatar_local'] && $display_gallery ? true : false, 'AVATAR_IMAGE' => $avatar_img, 'AVATAR_MAX_FILESIZE' => $config['avatar_filesize'], 'USER_AVATAR_WIDTH' => $user_row['user_avatar_width'], 'USER_AVATAR_HEIGHT' => $user_row['user_avatar_height'], 'L_AVATAR_EXPLAIN' => sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], round($config['avatar_filesize'] / 1024)))); break; case 'rank': if ($submit) { $rank_id = request_var('user_rank', 0); $sql = 'UPDATE ' . USERS_TABLE . "\n\t\t\t\t\t\tSET user_rank = {$rank_id}\n\t\t\t\t\t\tWHERE user_id = {$user_id}"; $db->sql_query($sql); trigger_error($user->lang['USER_RANK_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); } $sql = 'SELECT * FROM ' . RANKS_TABLE . ' WHERE rank_special = 1 ORDER BY rank_title'; $result = $db->sql_query($sql); $s_rank_options = '<option value="0"' . (!$user_row['user_rank'] ? ' selected="selected"' : '') . '>' . $user->lang['NO_SPECIAL_RANK'] . '</option>'; while ($row = $db->sql_fetchrow($result)) { $selected = $user_row['user_rank'] && $row['rank_id'] == $user_row['user_rank'] ? ' selected="selected"' : ''; $s_rank_options .= '<option value="' . $row['rank_id'] . '"' . $selected . '>' . $row['rank_title'] . '</option>'; } $db->sql_freeresult($result); $template->assign_vars(array('S_RANK' => true, 'S_RANK_OPTIONS' => $s_rank_options)); break; case 'sig': include_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx; $enable_bbcode = $config['allow_sig_bbcode'] ? request_var('enable_bbcode', $this->optionget($user_row, 'bbcode')) : false; $enable_smilies = $config['allow_sig_smilies'] ? request_var('enable_smilies', $this->optionget($user_row, 'smilies')) : false; $enable_urls = request_var('enable_urls', true); $signature = request_var('signature', $user_row['user_sig'], true); $preview = isset($_POST['preview']) ? true : false; if ($submit || $preview) { include_once $phpbb_root_path . 'includes/message_parser.' . $phpEx; $message_parser = new parse_message($signature); // Allowing Quote BBCode $message_parser->parse($enable_bbcode, $enable_urls, $enable_smilies, $config['allow_sig_img'], $config['allow_sig_flash'], true, true, 'sig'); if (sizeof($message_parser->warn_msg)) { $error[] = implode('<br />', $message_parser->warn_msg); } if (!sizeof($error) && $submit) { $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['USER_SIG_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); } // Replace "error" strings with their real, localised form $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); } $signature_preview = ''; if ($preview) { // Now parse it for displaying $signature_preview = $message_parser->format_display($enable_bbcode, $enable_urls, $enable_smilies, false); unset($message_parser); } decode_message($signature, $user_row['user_sig_bbcode_uid']); $template->assign_vars(array('S_SIGNATURE' => true, 'SIGNATURE' => $signature, 'SIGNATURE_PREVIEW' => $signature_preview, 'S_BBCODE_CHECKED' => !$enable_bbcode ? 'checked="checked"' : '', 'S_SMILIES_CHECKED' => !$enable_smilies ? 'checked="checked"' : '', 'S_MAGIC_URL_CHECKED' => !$enable_urls ? 'checked="checked"' : '', 'BBCODE_STATUS' => $config['allow_sig_bbcode'] ? sprintf($user->lang['BBCODE_IS_ON'], '<a href="' . append_sid("{$phpbb_root_path}faq.{$phpEx}", 'mode=bbcode') . '" onclick="target=\'_phpbbcode\';">', '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], '<a href="' . append_sid("{$phpbb_root_path}faq.{$phpEx}", 'mode=bbcode') . '" onclick="target=\'_phpbbcode\';">', '</a>'), 'SMILIES_STATUS' => $config['allow_sig_smilies'] ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], 'IMG_STATUS' => $config['allow_sig_img'] ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'], 'FLASH_STATUS' => $config['allow_sig_flash'] ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'], 'L_SIGNATURE_EXPLAIN' => sprintf($user->lang['SIGNATURE_EXPLAIN'], $config['max_sig_chars']), 'S_BBCODE_ALLOWED' => $config['allow_sig_bbcode'], 'S_SMILIES_ALLOWED' => $config['allow_sig_smilies'])); break; case 'attach': $start = request_var('start', 0); $deletemark = isset($_POST['delmarked']) ? true : false; $marked = request_var('mark', array(0)); // Sort keys $sort_key = request_var('sk', 'a'); $sort_dir = request_var('sd', 'd'); if ($deletemark && sizeof($marked)) { if (confirm_box(true)) { $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($log_attachments) == 1 ? 'ATTACHMENT_DELETED' : 'ATTACHMENTS_DELETED'; $message = sizeof($log_attachments) == 1 ? $user->lang['ATTACHMENT_DELETED'] : $user->lang['ATTACHMENTS_DELETED']; add_log('admin', $log, implode(', ', $log_attachments)); trigger_error($message . adm_back_link($this->u_action . '&u=' . $user_id)); } else { confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'deletemark' => true, 'mark' => $marked))); } } $sk_text = array('a' => $user->lang['SORT_FILENAME'], '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', 'c' => 'a.extension', 'd' => 'a.filesize', 'e' => 'a.download_count', 'f' => 'a.filetime', 'g' => 't.topic_title'); $sd_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); $s_sort_key = ''; foreach ($sk_text as $key => $value) { $selected = $sort_key == $key ? ' selected="selected"' : ''; $s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; } $s_sort_dir = ''; foreach ($sd_text as $key => $value) { $selected = $sort_dir == $key ? ' selected="selected"' : ''; $s_sort_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; } $order_by = $sk_sql[$sort_key] . ' ' . ($sort_dir == 'a' ? 'ASC' : 'DESC'); $sql = 'SELECT COUNT(attach_id) as num_attachments FROM ' . ATTACHMENTS_TABLE . "\n\t\t\t\t\tWHERE poster_id = {$user_id}"; $result = $db->sql_query_limit($sql, 1); $num_attachments = (int) $db->sql_fetchfield('num_attachments'); $db->sql_freeresult($result); $sql = 'SELECT a.*, t.topic_title, p.message_subject as message_title FROM ' . ATTACHMENTS_TABLE . ' a LEFT JOIN ' . TOPICS_TABLE . ' t ON (a.topic_id = t.topic_id AND a.in_message = 0) LEFT JOIN ' . PRIVMSGS_TABLE . ' p ON (a.post_msg_id = p.msg_id AND a.in_message = 1) WHERE a.poster_id = ' . $user_id . "\n\t\t\t\t\tORDER BY {$order_by}"; $result = $db->sql_query_limit($sql, $config['posts_per_page'], $start); while ($row = $db->sql_fetchrow($result)) { if ($row['in_message']) { $view_topic = append_sid("{$phpbb_root_path}ucp.{$phpEx}", "i=pm&p={$row['post_msg_id']}"); } else { $view_topic = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "t={$row['topic_id']}&p={$row['post_msg_id']}#{$row['post_msg_id']}"); } $template->assign_block_vars('attach', array('REAL_FILENAME' => $row['real_filename'], 'COMMENT' => nl2br($row['comment']), 'EXTENSION' => $row['extension'], 'SIZE' => $row['filesize'] >= 1048576 ? ($row['filesize'] >> 20) . ' ' . $user->lang['MB'] : ($row['filesize'] >= 1024 ? ($row['filesize'] >> 10) . ' ' . $user->lang['KB'] : $row['filesize'] . ' ' . $user->lang['BYTES']), 'DOWNLOAD_COUNT' => $row['download_count'], 'POST_TIME' => $user->format_date($row['filetime']), 'TOPIC_TITLE' => $row['in_message'] ? $row['message_title'] : $row['topic_title'], 'ATTACH_ID' => $row['attach_id'], 'POST_ID' => $row['post_msg_id'], 'TOPIC_ID' => $row['topic_id'], 'S_IN_MESSAGE' => $row['in_message'], 'U_DOWNLOAD' => append_sid("{$phpbb_root_path}download.{$phpEx}", 'id=' . $row['attach_id']), 'U_VIEW_TOPIC' => $view_topic)); } $db->sql_freeresult($result); $template->assign_vars(array('S_ATTACHMENTS' => true, 'S_ON_PAGE' => on_page($num_attachments, $config['topics_per_page'], $start), 'S_SORT_KEY' => $s_sort_key, 'S_SORT_DIR' => $s_sort_dir, 'PAGINATION' => generate_pagination($this->u_action . "&sk={$sort_key}&sd={$sort_dir}", $num_attachments, $config['topics_per_page'], $start, true))); break; case 'groups': $user->add_lang(array('groups', 'acp/groups')); $group_id = request_var('g', 0); switch ($action) { case 'demote': case 'promote': case 'default': group_user_attributes($action, $group_id, $user_id); if ($action == 'default') { $user_row['group_id'] = $group_id; } break; case 'delete': if (confirm_box(true)) { if (!$group_id) { trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id)); } if ($error = group_user_del($group_id, $user_id)) { trigger_error($user->lang[$error] . adm_back_link($this->u_action . '&u=' . $user_id)); } $error = array(); } else { confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'g' => $group_id))); } break; } // Add user to group? if ($submit) { if (!$group_id) { trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id)); } // Add user/s to group if ($error = group_user_add($group_id, $user_id)) { trigger_error($user->lang[$error] . adm_back_link($this->u_action . '&u=' . $user_id)); } $error = array(); } $sql = 'SELECT ug.*, g.* FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . " ug\n\t\t\t\t\tWHERE ug.user_id = {$user_id}\n\t\t\t\t\t\tAND g.group_id = ug.group_id\n\t\t\t\t\tORDER 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 . ' ' . (sizeof($id_ary) ? 'WHERE group_id NOT IN (' . implode(', ', $id_ary) . ')' : '') . ' ORDER BY group_type DESC, group_name ASC'; $result = $db->sql_query($sql); $s_group_options = ''; while ($row = $db->sql_fetchrow($result)) { if ($config['coppa_hide_groups'] && in_array($row['group_name'], array('INACTIVE_COPPA', 'REGISTERED_COPPA'))) { continue; } $s_group_options .= '<option' . ($row['group_type'] == GROUP_SPECIAL ? ' class="sep"' : '') . ' 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) { $template->assign_block_vars('group', array('S_NEW_GROUP_TYPE' => true, 'GROUP_TYPE' => $user->lang['USER_GROUP_' . strtoupper($group_type)])); } foreach ($data_ary as $data) { $template->assign_block_vars('group', array('U_EDIT_GROUP' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=groups&mode=manage&action=edit&u={$user_id}&g={$data['group_id']}&back_link=acp_users_groups"), 'U_DEFAULT' => $this->u_action . "&action=default&u={$user_id}&g=" . $data['group_id'], 'U_DEMOTE_PROMOTE' => $this->u_action . '&action=' . ($data['group_leader'] ? 'demote' : 'promote') . "&u={$user_id}&g=" . $data['group_id'], 'U_DELETE' => $this->u_action . "&action=delete&u={$user_id}&g=" . $data['group_id'], 'GROUP_NAME' => $group_type == 'special' ? $user->lang['G_' . $data['group_name']] : $data['group_name'], 'L_DEMOTE_PROMOTE' => $data['group_leader'] ? $user->lang['GROUP_DEMOTE'] : $user->lang['GROUP_PROMOTE'], 'S_NO_DEFAULT' => $user_row['group_id'] != $data['group_id'] ? true : false, 'S_SPECIAL_GROUP' => $group_type == 'special' ? true : false)); } } $template->assign_vars(array('S_GROUPS' => true, 'S_GROUP_OPTIONS' => $s_group_options)); break; case 'perm': include_once $phpbb_root_path . 'includes/acp/auth.' . $phpEx; $auth_admin = new auth_admin(); $user->add_lang('acp/permissions'); $user->add_lang('acp/permissions_phpbb'); // Select auth options $sql = 'SELECT auth_option, is_local, is_global FROM ' . ACL_OPTIONS_TABLE . "\n\t\t\t\t\tWHERE auth_option LIKE '%\\_'\n\t\t\t\t\t\tAND is_global = 1\n\t\t\t\t\tORDER BY auth_option"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $hold_ary = $auth_admin->get_mask('view', $user_id, false, false, $row['auth_option'], 'global', ACL_NO); $auth_admin->display_mask('view', $row['auth_option'], $hold_ary, 'user', false, false); } $db->sql_freeresult($result); $sql = 'SELECT auth_option, is_local, is_global FROM ' . ACL_OPTIONS_TABLE . "\n\t\t\t\t\tWHERE auth_option LIKE '%\\_'\n\t\t\t\t\t\tAND is_local = 1\n\t\t\t\t\tORDER BY is_global DESC, auth_option"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $hold_ary = $auth_admin->get_mask('view', $user_id, false, false, $row['auth_option'], 'local', ACL_NO); $auth_admin->display_mask('view', $row['auth_option'], $hold_ary, 'user', true, false); } $db->sql_freeresult($result); $template->assign_vars(array('S_PERMISSIONS' => true, 'U_USER_PERMISSIONS' => append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=permissions&mode=setting_user_global&user_id[]=' . $user_id), 'U_USER_FORUM_PERMISSIONS' => append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=permissions&mode=setting_user_local&user_id[]=' . $user_id))); break; } // Assign general variables $template->assign_vars(array('S_ERROR' => sizeof($error) ? true : false, 'ERROR_MSG' => sizeof($error) ? implode('<br />', $error) : '')); }
function main($id, $mode) { global $config, $db, $user, $auth, $template, $cache; global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $file_uploads; $user->add_lang(array('posting', 'ucp', 'acp/users')); $this->tpl_name = 'acp_users'; $this->page_title = 'ACP_USER_' . strtoupper($mode); $error = array(); $username = utf8_normalize_nfc(request_var('username', '', true)); $user_id = request_var('u', 0); $action = request_var('action', ''); $submit = (isset($_POST['update']) && !isset($_POST['cancel'])) ? true : false; $form_name = 'acp_users'; add_form_key($form_name); // Whois (special case) if ($action == 'whois') { include($phpbb_root_path . 'includes/functions_user.' . $phpEx); $this->page_title = 'WHOIS'; $this->tpl_name = 'simple_body'; $user_ip = request_var('user_ip', ''); $domain = gethostbyaddr($user_ip); $ipwhois = user_ipwhois($user_ip); $template->assign_vars(array( 'MESSAGE_TITLE' => sprintf($user->lang['IP_WHOIS_FOR'], $domain), 'MESSAGE_TEXT' => nl2br($ipwhois)) ); return; } // Show user selection mask if (!$username && !$user_id) { $this->page_title = 'SELECT_USER'; $template->assign_vars(array( 'U_ACTION' => $this->u_action, 'ANONYMOUS_USER_ID' => ANONYMOUS, 'S_SELECT_USER' => true, 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=select_user&field=username&select_single=true'), )); return; } if (!$user_id) { $sql = 'SELECT user_id FROM ' . USERS_TABLE . " WHERE username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'"; $result = $db->sql_query($sql); $user_id = (int) $db->sql_fetchfield('user_id'); $db->sql_freeresult($result); if (!$user_id) { trigger_error($user->lang['NO_USER'] . adm_back_link($this->u_action), E_USER_WARNING); } } // Generate content for all modes $sql = 'SELECT u.*, s.* FROM ' . USERS_TABLE . ' u LEFT JOIN ' . SESSIONS_TABLE . ' s ON (s.session_user_id = u.user_id) WHERE u.user_id = ' . $user_id . ' ORDER BY s.session_time DESC'; $result = $db->sql_query($sql); $user_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$user_row) { trigger_error($user->lang['NO_USER'] . adm_back_link($this->u_action), E_USER_WARNING); } // Generate overall "header" for user admin $s_form_options = ''; // Build modes dropdown list $sql = 'SELECT module_mode, module_auth FROM ' . MODULES_TABLE . " WHERE module_basename = 'users' AND module_enabled = 1 AND module_class = 'acp' ORDER BY left_id, module_mode"; $result = $db->sql_query($sql); $dropdown_modes = array(); while ($row = $db->sql_fetchrow($result)) { if (!$this->p_master->module_auth($row['module_auth'])) { continue; } $dropdown_modes[$row['module_mode']] = true; } $db->sql_freeresult($result); foreach ($dropdown_modes as $module_mode => $null) { $selected = ($mode == $module_mode) ? ' selected="selected"' : ''; $s_form_options .= '<option value="' . $module_mode . '"' . $selected . '>' . $user->lang['ACP_USER_' . strtoupper($module_mode)] . '</option>'; } $template->assign_vars(array( 'U_BACK' => $this->u_action, 'U_MODE_SELECT' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=$id&u=$user_id"), 'U_ACTION' => $this->u_action . '&u=' . $user_id, 'S_FORM_OPTIONS' => $s_form_options, 'MANAGED_USERNAME' => $user_row['username']) ); // Prevent normal users/admins change/view founders if they are not a founder by themselves if ($user->data['user_type'] != USER_FOUNDER && $user_row['user_type'] == USER_FOUNDER) { trigger_error($user->lang['NOT_MANAGE_FOUNDER'] . adm_back_link($this->u_action), E_USER_WARNING); } switch ($mode) { case 'overview': include($phpbb_root_path . 'includes/functions_user.' . $phpEx); $user->add_lang('acp/ban'); $delete = request_var('delete', 0); $delete_type = request_var('delete_type', ''); $ip = request_var('ip', 'ip'); if ($submit) { // You can't delete the founder if ($delete && $user_row['user_type'] != USER_FOUNDER) { if (!$auth->acl_get('a_userdel')) { trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } // Check if the user wants to remove himself or the guest user account if ($user_id == ANONYMOUS) { trigger_error($user->lang['CANNOT_REMOVE_ANONYMOUS'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if ($user_id == $user->data['user_id']) { trigger_error($user->lang['CANNOT_REMOVE_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if (confirm_box(true)) { user_delete($delete_type, $user_id, $user_row['username']); add_log('admin', 'LOG_USER_DELETED', $user_row['username']); trigger_error($user->lang['USER_DELETED'] . adm_back_link($this->u_action)); } else { confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( 'u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'update' => true, 'delete' => 1, 'delete_type' => $delete_type)) ); } } // Handle quicktool actions switch ($action) { case 'banuser': case 'banemail': case 'banip': if ($user_id == $user->data['user_id']) { trigger_error($user->lang['CANNOT_BAN_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if ($user_row['user_type'] == USER_FOUNDER) { trigger_error($user->lang['CANNOT_BAN_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if (!check_form_key($form_name)) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } $ban = array(); switch ($action) { case 'banuser': $ban[] = $user_row['username']; $reason = 'USER_ADMIN_BAN_NAME_REASON'; $log = 'LOG_USER_BAN_USER'; break; case 'banemail': $ban[] = $user_row['user_email']; $reason = 'USER_ADMIN_BAN_EMAIL_REASON'; $log = 'LOG_USER_BAN_EMAIL'; break; case 'banip': $ban[] = $user_row['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_USER_BAN_IP'; break; } $ban_reason = utf8_normalize_nfc(request_var('ban_reason', $user->lang[$reason], true)); $ban_give_reason = utf8_normalize_nfc(request_var('ban_give_reason', '', true)); // Log not used at the moment, we simply utilize the ban function. $result = user_ban(substr($action, 3), $ban, 0, 0, 0, $ban_reason, $ban_give_reason); trigger_error((($result === false) ? $user->lang['BAN_ALREADY_ENTERED'] : $user->lang['BAN_SUCCESSFUL']) . adm_back_link($this->u_action . '&u=' . $user_id)); break; case 'reactivate': if ($user_id == $user->data['user_id']) { trigger_error($user->lang['CANNOT_FORCE_REACT_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if (!check_form_key($form_name)) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if ($user_row['user_type'] == USER_FOUNDER) { trigger_error($user->lang['CANNOT_FORCE_REACT_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if ($user_row['user_type'] == USER_IGNORE) { trigger_error($user->lang['CANNOT_FORCE_REACT_BOT'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if ($config['email_enable']) { include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); $server_url = generate_board_url(); $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); $email_template = ($user_row['user_type'] == USER_NORMAL) ? 'user_reactivate_account' : 'user_resend_inactive'; if ($user_row['user_type'] == USER_NORMAL) { user_active_flip('deactivate', $user_id, INACTIVE_REMIND); $sql = 'UPDATE ' . USERS_TABLE . " SET user_actkey = '" . $db->sql_escape($user_actkey) . "' WHERE user_id = $user_id"; $db->sql_query($sql); } else { // Grabbing the last confirm key - we only send a reminder $sql = 'SELECT user_actkey FROM ' . USERS_TABLE . ' WHERE user_id = ' . $user_id; $result = $db->sql_query($sql); $user_actkey = (string) $db->sql_fetchfield('user_actkey'); $db->sql_freeresult($result); } $messenger = new messenger(false); $messenger->template($email_template, $user_row['user_lang']); $messenger->to($user_row['user_email'], $user_row['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->assign_vars(array( 'WELCOME_MSG' => htmlspecialchars_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename'])), 'USERNAME' => htmlspecialchars_decode($user_row['username']), 'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k=$user_actkey") ); $messenger->send(NOTIFY_EMAIL); add_log('admin', 'LOG_USER_REACTIVATE', $user_row['username']); add_log('user', $user_id, 'LOG_USER_REACTIVATE_USER'); trigger_error($user->lang['FORCE_REACTIVATION_SUCCESS'] . adm_back_link($this->u_action . '&u=' . $user_id)); } break; case 'active': if ($user_id == $user->data['user_id']) { // It is only deactivation since the user is already activated (else he would not have reached this page) trigger_error($user->lang['CANNOT_DEACTIVATE_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if (!check_form_key($form_name)) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if ($user_row['user_type'] == USER_FOUNDER) { trigger_error($user->lang['CANNOT_DEACTIVATE_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if ($user_row['user_type'] == USER_IGNORE) { trigger_error($user->lang['CANNOT_DEACTIVATE_BOT'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } user_active_flip('flip', $user_id); $message = ($user_row['user_type'] == USER_INACTIVE) ? 'USER_ADMIN_ACTIVATED' : 'USER_ADMIN_DEACTIVED'; $log = ($user_row['user_type'] == USER_INACTIVE) ? 'LOG_USER_ACTIVE' : 'LOG_USER_INACTIVE'; add_log('admin', $log, $user_row['username']); add_log('user', $user_id, $log . '_USER'); trigger_error($user->lang[$message] . adm_back_link($this->u_action . '&u=' . $user_id)); break; case 'delsig': if (!check_form_key($form_name)) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } $sql_ary = array( 'user_sig' => '', 'user_sig_bbcode_uid' => '', 'user_sig_bbcode_bitfield' => '' ); $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " WHERE user_id = $user_id"; $db->sql_query($sql); add_log('admin', 'LOG_USER_DEL_SIG', $user_row['username']); add_log('user', $user_id, 'LOG_USER_DEL_SIG_USER'); trigger_error($user->lang['USER_ADMIN_SIG_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id)); break; case 'delavatar': if (!check_form_key($form_name)) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } $sql_ary = array( 'user_avatar' => '', 'user_avatar_type' => 0, 'user_avatar_width' => 0, 'user_avatar_height' => 0, ); $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_row['user_avatar'] && $user_row['user_avatar_type'] != AVATAR_GALLERY) { avatar_delete('user', $user_row); } add_log('admin', 'LOG_USER_DEL_AVATAR', $user_row['username']); add_log('user', $user_id, 'LOG_USER_DEL_AVATAR_USER'); trigger_error($user->lang['USER_ADMIN_AVATAR_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id)); break; case 'delposts': if (confirm_box(true)) { // Delete posts, attachments, etc. delete_posts('poster_id', $user_id); add_log('admin', 'LOG_USER_DEL_POSTS', $user_row['username']); trigger_error($user->lang['USER_POSTS_DELETED'] . adm_back_link($this->u_action . '&u=' . $user_id)); } else { confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( 'u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'update' => true)) ); } break; case 'delattach': if (confirm_box(true)) { delete_attachments('user', $user_id); add_log('admin', 'LOG_USER_DEL_ATTACH', $user_row['username']); trigger_error($user->lang['USER_ATTACHMENTS_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id)); } else { confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( 'u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'update' => true)) ); } break; case 'moveposts': if (!check_form_key($form_name)) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } $user->add_lang('acp/forums'); $new_forum_id = request_var('new_f', 0); if (!$new_forum_id) { $this->page_title = 'USER_ADMIN_MOVE_POSTS'; $template->assign_vars(array( 'S_SELECT_FORUM' => true, 'U_ACTION' => $this->u_action . "&action=$action&u=$user_id", 'U_BACK' => $this->u_action . "&u=$user_id", 'S_FORUM_OPTIONS' => make_forum_select(false, false, false, true)) ); return; } // Is the new forum postable to? $sql = 'SELECT forum_name, forum_type FROM ' . FORUMS_TABLE . " WHERE forum_id = $new_forum_id"; $result = $db->sql_query($sql); $forum_info = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$forum_info) { trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if ($forum_info['forum_type'] != FORUM_POST) { trigger_error($user->lang['MOVE_POSTS_NO_POSTABLE_FORUM'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } // Two stage? // Move topics comprising only posts from this user $topic_id_ary = $move_topic_ary = $move_post_ary = $new_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']; } $db->sql_freeresult($result); if (sizeof($topic_id_ary)) { $sql = 'SELECT topic_id, forum_id, topic_title, topic_replies, topic_replies_real, topic_attachment FROM ' . TOPICS_TABLE . ' WHERE ' . $db->sql_in_set('topic_id', array_keys($topic_id_ary)); $result = $db->sql_query($sql); 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 { $move_post_ary[$row['topic_id']]['title'] = $row['topic_title']; $move_post_ary[$row['topic_id']]['attach'] = ($row['topic_attachment']) ? 1 : 0; } $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); } 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' => $user_row['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']) { $sql = 'UPDATE ' . ATTACHMENTS_TABLE . " SET topic_id = $new_topic_id WHERE topic_id = $topic_id AND poster_id = $user_id"; $db->sql_query($sql); } $new_topic_id_ary[] = $new_topic_id; } } $forum_id_ary = array_unique($forum_id_ary); $topic_id_ary = array_unique(array_merge($topic_id_ary, $new_topic_id_ary)); if (sizeof($topic_id_ary)) { sync('reported', 'topic_id', $topic_id_ary); sync('topic', 'topic_id', $topic_id_ary); } if (sizeof($forum_id_ary)) { sync('forum', 'forum_id', $forum_id_ary, false, true); } add_log('admin', 'LOG_USER_MOVE_POSTS', $user_row['username'], $forum_info['forum_name']); add_log('user', $user_id, 'LOG_USER_MOVE_POSTS_USER', $forum_info['forum_name']); trigger_error($user->lang['USER_POSTS_MOVED'] . adm_back_link($this->u_action . '&u=' . $user_id)); break; } // Handle registration info updates $data = array( 'username' => utf8_normalize_nfc(request_var('user', $user_row['username'], true)), 'user_founder' => request_var('user_founder', ($user_row['user_type'] == USER_FOUNDER) ? 1 : 0), 'email' => strtolower(request_var('user_email', $user_row['user_email'])), 'email_confirm' => strtolower(request_var('email_confirm', '')), 'new_password' => request_var('new_password', '', true), 'password_confirm' => request_var('password_confirm', '', true), ); // Validation data - we do not check the password complexity setting here $check_ary = array( 'new_password' => array( array('string', true, $config['min_pass_chars'], $config['max_pass_chars']), array('password')), 'password_confirm' => array('string', true, $config['min_pass_chars'], $config['max_pass_chars']), ); // Check username if altered if ($data['username'] != $user_row['username']) { $check_ary += array( 'username' => array( array('string', false, $config['min_name_chars'], $config['max_name_chars']), array('username', $user_row['username']) ), ); } // Check email if altered if ($data['email'] != $user_row['user_email']) { $check_ary += array( 'email' => array( array('string', false, 6, 60), array('email', $user_row['user_email']) ), 'email_confirm' => array('string', true, 6, 60) ); } $error = validate_data($data, $check_ary); if ($data['new_password'] && $data['password_confirm'] != $data['new_password']) { $error[] = 'NEW_PASSWORD_ERROR'; } if ($data['email'] != $user_row['user_email'] && $data['email_confirm'] != $data['email']) { $error[] = 'NEW_EMAIL_ERROR'; } if (!check_form_key($form_name)) { $error[] = 'FORM_INVALID'; } // Which updates do we need to do? $update_username = ($user_row['username'] != $data['username']) ? $data['username'] : false; $update_password = ($data['new_password'] && !phpbb_check_hash($user_row['user_password'], $data['new_password'])) ? true : false; $update_email = ($data['email'] != $user_row['user_email']) ? $data['email'] : false; if (!sizeof($error)) { $sql_ary = array(); if ($user_row['user_type'] != USER_FOUNDER || $user->data['user_type'] == USER_FOUNDER) { // Only allow founders updating the founder status... if ($user->data['user_type'] == USER_FOUNDER) { // Setting a normal member to be a founder if ($data['user_founder'] && $user_row['user_type'] != USER_FOUNDER) { // Make sure the user is not setting an Inactive or ignored user to be a founder if ($user_row['user_type'] == USER_IGNORE) { trigger_error($user->lang['CANNOT_SET_FOUNDER_IGNORED'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if ($user_row['user_type'] == USER_INACTIVE) { trigger_error($user->lang['CANNOT_SET_FOUNDER_INACTIVE'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } $sql_ary['user_type'] = USER_FOUNDER; } else if (!$data['user_founder'] && $user_row['user_type'] == USER_FOUNDER) { // Check if at least one founder is present $sql = 'SELECT user_id FROM ' . USERS_TABLE . ' WHERE user_type = ' . USER_FOUNDER . ' AND user_id <> ' . $user_id; $result = $db->sql_query_limit($sql, 1); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if ($row) { $sql_ary['user_type'] = USER_NORMAL; } else { trigger_error($user->lang['AT_LEAST_ONE_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } } } } if ($update_username !== false) { $sql_ary['username'] = $update_username; $sql_ary['username_clean'] = utf8_clean_string($update_username); add_log('user', $user_id, 'LOG_USER_UPDATE_NAME', $user_row['username'], $update_username); } if ($update_email !== false) { $sql_ary += array( 'user_email' => $update_email, 'user_email_hash' => crc32($update_email) . strlen($update_email) ); add_log('user', $user_id, 'LOG_USER_UPDATE_EMAIL', $user_row['username'], $user_row['user_email'], $update_email); } if ($update_password) { $sql_ary += array( 'user_password' => phpbb_hash($data['new_password']), 'user_passchg' => time(), 'user_pass_convert' => 0, ); $user->reset_login_keys($user_id); add_log('user', $user_id, 'LOG_USER_NEW_PASSWORD', $user_row['username']); } if (sizeof($sql_ary)) { $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $user_id; $db->sql_query($sql); } if ($update_username) { user_update_name($user_row['username'], $update_username); } // Let the users permissions being updated $auth->acl_clear_prefetch($user_id); add_log('admin', 'LOG_USER_USER_UPDATE', $data['username']); trigger_error($user->lang['USER_OVERVIEW_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); } // Replace "error" strings with their real, localised form $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); } if ($user_id == $user->data['user_id']) { $quick_tool_ary = array('delsig' => 'DEL_SIG', 'delavatar' => 'DEL_AVATAR', 'moveposts' => 'MOVE_POSTS', 'delposts' => 'DEL_POSTS', 'delattach' => 'DEL_ATTACH'); } else { $quick_tool_ary = array(); if ($user_row['user_type'] != USER_FOUNDER) { $quick_tool_ary += array('banuser' => 'BAN_USER', 'banemail' => 'BAN_EMAIL', 'banip' => 'BAN_IP'); } if ($user_row['user_type'] != USER_FOUNDER && $user_row['user_type'] != USER_IGNORE) { $quick_tool_ary += array('active' => (($user_row['user_type'] == USER_INACTIVE) ? 'ACTIVATE' : 'DEACTIVATE')); } $quick_tool_ary += array('delsig' => 'DEL_SIG', 'delavatar' => 'DEL_AVATAR', 'moveposts' => 'MOVE_POSTS', 'delposts' => 'DEL_POSTS', 'delattach' => 'DEL_ATTACH'); if ($config['email_enable'] && ($user_row['user_type'] == USER_NORMAL || $user_row['user_type'] == USER_INACTIVE)) { $quick_tool_ary['reactivate'] = 'FORCE'; } } $s_action_options = '<option class="sep" value="">' . $user->lang['SELECT_OPTION'] . '</option>'; foreach ($quick_tool_ary as $value => $lang) { $s_action_options .= '<option value="' . $value . '">' . $user->lang['USER_ADMIN_' . $lang] . '</option>'; } if ($config['load_onlinetrack']) { $sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline FROM ' . SESSIONS_TABLE . " WHERE session_user_id = $user_id"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); $user_row['session_time'] = (isset($row['session_time'])) ? $row['session_time'] : 0; $user_row['session_viewonline'] = (isset($row['session_viewonline'])) ? $row['session_viewonline'] : 0; unset($row); } $last_visit = (!empty($user_row['session_time'])) ? $user_row['session_time'] : $user_row['user_lastvisit']; $inactive_reason = ''; if ($user_row['user_type'] == USER_INACTIVE) { $inactive_reason = $user->lang['INACTIVE_REASON_UNKNOWN']; switch ($user_row['user_inactive_reason']) { case INACTIVE_REGISTER: $inactive_reason = $user->lang['INACTIVE_REASON_REGISTER']; break; case INACTIVE_PROFILE: $inactive_reason = $user->lang['INACTIVE_REASON_PROFILE']; break; case INACTIVE_MANUAL: $inactive_reason = $user->lang['INACTIVE_REASON_MANUAL']; break; case INACTIVE_REMIND: $inactive_reason = $user->lang['INACTIVE_REASON_REMIND']; break; } } $template->assign_vars(array( 'L_NAME_CHARS_EXPLAIN' => sprintf($user->lang[$config['allow_name_chars'] . '_EXPLAIN'], $config['min_name_chars'], $config['max_name_chars']), 'L_CHANGE_PASSWORD_EXPLAIN' => sprintf($user->lang[$config['pass_complex'] . '_EXPLAIN'], $config['min_pass_chars'], $config['max_pass_chars']), 'S_FOUNDER' => ($user->data['user_type'] == USER_FOUNDER) ? true : false, 'S_OVERVIEW' => true, 'S_USER_IP' => ($user_row['user_ip']) ? true : false, 'S_USER_FOUNDER' => ($user_row['user_type'] == USER_FOUNDER) ? true : false, 'S_ACTION_OPTIONS' => $s_action_options, 'S_OWN_ACCOUNT' => ($user_id == $user->data['user_id']) ? true : false, 'S_USER_INACTIVE' => ($user_row['user_type'] == USER_INACTIVE) ? true : false, 'U_SHOW_IP' => $this->u_action . "&u=$user_id&ip=" . (($ip == 'ip') ? 'hostname' : 'ip'), 'U_WHOIS' => $this->u_action . "&action=whois&user_ip={$user_row['user_ip']}", 'U_SWITCH_PERMISSIONS' => ($auth->acl_get('a_switchperm') && $user->data['user_id'] != $user_row['user_id']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", "mode=switch_perm&u={$user_row['user_id']}") : '', 'USER' => $user_row['username'], 'USER_REGISTERED' => $user->format_date($user_row['user_regdate']), 'REGISTERED_IP' => ($ip == 'hostname') ? gethostbyaddr($user_row['user_ip']) : $user_row['user_ip'], 'USER_LASTACTIVE' => ($last_visit) ? $user->format_date($last_visit) : ' - ', 'USER_EMAIL' => $user_row['user_email'], 'USER_WARNINGS' => $user_row['user_warnings'], 'USER_POSTS' => $user_row['user_posts'], 'USER_INACTIVE_REASON' => $inactive_reason, )); break; case 'feedback': $user->add_lang('mcp'); // Set up general vars $start = request_var('start', 0); $deletemark = (isset($_POST['delmarked'])) ? true : false; $deleteall = (isset($_POST['delall'])) ? true : false; $marked = request_var('mark', array(0)); $message = utf8_normalize_nfc(request_var('message', '', true)); // Sort keys $sort_days = request_var('st', 0); $sort_key = request_var('sk', 't'); $sort_dir = request_var('sd', 'd'); // Delete entries if requested and able if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs')) { if (!check_form_key($form_name)) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } $where_sql = ''; if ($deletemark && $marked) { $sql_in = array(); foreach ($marked as $mark) { $sql_in[] = $mark; } $where_sql = ' AND ' . $db->sql_in_set('log_id', $sql_in); unset($sql_in); } if ($where_sql || $deleteall) { $sql = 'DELETE FROM ' . LOG_TABLE . ' WHERE log_type = ' . LOG_USERS . " $where_sql"; $db->sql_query($sql); add_log('admin', 'LOG_CLEAR_USER', $user_row['username']); } } if ($submit && $message) { if (!check_form_key($form_name)) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } 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)); } // Sorting $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'], 365 => $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' => 'u.username_clean', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation'); $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); // Define where and sort sql for use in displaying logs $sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0; $sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); // Grab log data $log_data = array(); $log_count = 0; view_log('user', $log_data, $log_count, $config['topics_per_page'], $start, 0, 0, $user_id, $sql_where, $sql_sort); $template->assign_vars(array( 'S_FEEDBACK' => true, 'S_ON_PAGE' => on_page($log_count, $config['topics_per_page'], $start), 'PAGINATION' => generate_pagination($this->u_action . "&u=$user_id&$u_sort_param", $log_count, $config['topics_per_page'], $start, true), 'S_LIMIT_DAYS' => $s_limit_days, 'S_SORT_KEY' => $s_sort_key, 'S_SORT_DIR' => $s_sort_dir, 'S_CLEARLOGS' => $auth->acl_get('a_clearlogs')) ); foreach ($log_data as $row) { $template->assign_block_vars('log', array( 'USERNAME' => $row['username_full'], 'IP' => $row['ip'], 'DATE' => $user->format_date($row['time']), 'ACTION' => nl2br($row['action']), 'ID' => $row['id']) ); } break; case 'profile': include($phpbb_root_path . 'includes/functions_user.' . $phpEx); include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx); $cp = new custom_profile(); $cp_data = $cp_error = array(); $sql = 'SELECT lang_id FROM ' . LANG_TABLE . " WHERE lang_iso = '" . $db->sql_escape($user->data['user_lang']) . "'"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); $user_row['iso_lang_id'] = $row['lang_id']; $data = array( 'icq' => request_var('icq', $user_row['user_icq']), 'aim' => request_var('aim', $user_row['user_aim']), 'msn' => request_var('msn', $user_row['user_msnm']), 'yim' => request_var('yim', $user_row['user_yim']), 'jabber' => utf8_normalize_nfc(request_var('jabber', $user_row['user_jabber'], true)), 'website' => request_var('website', $user_row['user_website']), 'location' => utf8_normalize_nfc(request_var('location', $user_row['user_from'], true)), 'occupation' => utf8_normalize_nfc(request_var('occupation', $user_row['user_occ'], true)), 'interests' => utf8_normalize_nfc(request_var('interests', $user_row['user_interests'], true)), 'bday_day' => 0, 'bday_month' => 0, 'bday_year' => 0, ); if ($user_row['user_birthday']) { list($data['bday_day'], $data['bday_month'], $data['bday_year']) = explode('-', $user_row['user_birthday']); } $data['bday_day'] = request_var('bday_day', $data['bday_day']); $data['bday_month'] = request_var('bday_month', $data['bday_month']); $data['bday_year'] = request_var('bday_year', $data['bday_year']); if ($submit) { $error = validate_data($data, array( 'icq' => array( array('string', true, 3, 15), array('match', true, '#^[0-9]+$#i')), 'aim' => array('string', true, 3, 255), 'msn' => array('string', true, 5, 255), 'jabber' => array( array('string', true, 5, 255), array('jabber')), '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())), )); // validate custom profile fields $cp->submit_cp_field('profile', $user_row['iso_lang_id'], $cp_data, $cp_error); if (sizeof($cp_error)) { $error = array_merge($error, $cp_error); } if (!check_form_key($form_name)) { $error[] = 'FORM_INVALID'; } if (!sizeof($error)) { $sql_ary = array( 'user_icq' => $data['icq'], 'user_aim' => $data['aim'], 'user_msnm' => $data['msn'], 'user_yim' => $data['yim'], 'user_jabber' => $data['jabber'], 'user_website' => $data['website'], 'user_from' => $data['location'], 'user_occ' => $data['occupation'], 'user_interests'=> $data['interests'], 'user_birthday' => sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['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)) { switch ($db->sql_layer) { case 'oracle': case 'firebird': case 'postgres': $right_delim = $left_delim = '"'; break; case 'sqlite': case 'mssql': case 'mssql_odbc': $right_delim = ']'; $left_delim = '['; break; case 'mysql': case 'mysql4': case 'mysqli': $right_delim = $left_delim = '`'; break; } foreach ($cp_data as $key => $value) { $cp_data[$left_delim . $key . $right_delim] = $value; unset($cp_data[$key]); } $sql = 'UPDATE ' . PROFILE_FIELDS_DATA_TABLE . ' 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'] = (int) $user_id; $db->sql_return_on_error(true); $sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $cp_data); $db->sql_query($sql); $db->sql_return_on_error(false); } } trigger_error($user->lang['USER_PROFILE_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); } // Replace "error" strings with their real, localised form $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); } $s_birthday_day_options = '<option value="0"' . ((!$data['bday_day']) ? ' selected="selected"' : '') . '>--</option>'; for ($i = 1; $i < 32; $i++) { $selected = ($i == $data['bday_day']) ? ' selected="selected"' : ''; $s_birthday_day_options .= "<option value=\"$i\"$selected>$i</option>"; } $s_birthday_month_options = '<option value="0"' . ((!$data['bday_month']) ? ' selected="selected"' : '') . '>--</option>'; for ($i = 1; $i < 13; $i++) { $selected = ($i == $data['bday_month']) ? ' selected="selected"' : ''; $s_birthday_month_options .= "<option value=\"$i\"$selected>$i</option>"; } $s_birthday_year_options = ''; $now = getdate(); $s_birthday_year_options = '<option value="0"' . ((!$data['bday_year']) ? ' selected="selected"' : '') . '>--</option>'; for ($i = $now['year'] - 100; $i < $now['year']; $i++) { $selected = ($i == $data['bday_year']) ? ' selected="selected"' : ''; $s_birthday_year_options .= "<option value=\"$i\"$selected>$i</option>"; } unset($now); $template->assign_vars(array( 'ICQ' => $data['icq'], 'YIM' => $data['yim'], 'AIM' => $data['aim'], 'MSN' => $data['msn'], 'JABBER' => $data['jabber'], 'WEBSITE' => $data['website'], 'LOCATION' => $data['location'], 'OCCUPATION' => $data['occupation'], 'INTERESTS' => $data['interests'], 'S_BIRTHDAY_DAY_OPTIONS' => $s_birthday_day_options, 'S_BIRTHDAY_MONTH_OPTIONS' => $s_birthday_month_options, 'S_BIRTHDAY_YEAR_OPTIONS' => $s_birthday_year_options, 'S_PROFILE' => true) ); // Get additional profile fields and assign them to the template block var 'profile_fields' $user->get_profile_fields($user_id); $cp->generate_profile_fields('profile', $user_row['iso_lang_id']); break; case 'prefs': include($phpbb_root_path . 'includes/functions_user.' . $phpEx); $data = array( 'dateformat' => utf8_normalize_nfc(request_var('dateformat', $user_row['user_dateformat'], true)), 'lang' => basename(request_var('lang', $user_row['user_lang'])), 'tz' => request_var('tz', (float) $user_row['user_timezone']), 'style' => request_var('style', $user_row['user_style']), 'dst' => request_var('dst', $user_row['user_dst']), 'viewemail' => request_var('viewemail', $user_row['user_allow_viewemail']), 'massemail' => request_var('massemail', $user_row['user_allow_massemail']), 'hideonline' => request_var('hideonline', !$user_row['user_allow_viewonline']), 'notifymethod' => request_var('notifymethod', $user_row['user_notify_type']), 'notifypm' => request_var('notifypm', $user_row['user_notify_pm']), 'popuppm' => request_var('popuppm', $this->optionget($user_row, 'popuppm')), 'allowpm' => request_var('allowpm', $user_row['user_allow_pm']), 'topic_sk' => request_var('topic_sk', ($user_row['user_topic_sortby_type']) ? $user_row['user_topic_sortby_type'] : 't'), 'topic_sd' => request_var('topic_sd', ($user_row['user_topic_sortby_dir']) ? $user_row['user_topic_sortby_dir'] : 'd'), 'topic_st' => request_var('topic_st', ($user_row['user_topic_show_days']) ? $user_row['user_topic_show_days'] : 0), 'post_sk' => request_var('post_sk', ($user_row['user_post_sortby_type']) ? $user_row['user_post_sortby_type'] : 't'), 'post_sd' => request_var('post_sd', ($user_row['user_post_sortby_dir']) ? $user_row['user_post_sortby_dir'] : 'a'), 'post_st' => request_var('post_st', ($user_row['user_post_show_days']) ? $user_row['user_post_show_days'] : 0), 'view_images' => request_var('view_images', $this->optionget($user_row, 'viewimg')), 'view_flash' => request_var('view_flash', $this->optionget($user_row, 'viewflash')), 'view_smilies' => request_var('view_smilies', $this->optionget($user_row, 'viewsmilies')), 'view_sigs' => request_var('view_sigs', $this->optionget($user_row, 'viewsigs')), 'view_avatars' => request_var('view_avatars', $this->optionget($user_row, 'viewavatars')), 'view_wordcensor' => request_var('view_wordcensor', $this->optionget($user_row, 'viewcensors')), 'bbcode' => request_var('bbcode', $this->optionget($user_row, 'bbcode')), 'smilies' => request_var('smilies', $this->optionget($user_row, 'smilies')), 'sig' => request_var('sig', $this->optionget($user_row, 'attachsig')), 'notify' => request_var('notify', $user_row['user_notify']), ); if ($submit) { $error = validate_data($data, array( 'dateformat' => array('string', false, 1, 30), 'lang' => array('match', false, '#^[a-z_\-]{2,}$#i'), 'tz' => array('num', false, -14, 14), 'topic_sk' => array('string', false, 1, 1), 'topic_sd' => array('string', false, 1, 1), 'post_sk' => array('string', false, 1, 1), 'post_sd' => array('string', false, 1, 1), )); if (!check_form_key($form_name)) { $error[] = 'FORM_INVALID'; } if (!sizeof($error)) { $this->optionset($user_row, 'popuppm', $data['popuppm']); $this->optionset($user_row, 'viewimg', $data['view_images']); $this->optionset($user_row, 'viewflash', $data['view_flash']); $this->optionset($user_row, 'viewsmilies', $data['view_smilies']); $this->optionset($user_row, 'viewsigs', $data['view_sigs']); $this->optionset($user_row, 'viewavatars', $data['view_avatars']); $this->optionset($user_row, 'viewcensors', $data['view_wordcensor']); $this->optionset($user_row, 'bbcode', $data['bbcode']); $this->optionset($user_row, 'smilies', $data['smilies']); $this->optionset($user_row, 'attachsig', $data['sig']); $sql_ary = array( 'user_options' => $user_row['user_options'], 'user_allow_pm' => $data['allowpm'], 'user_allow_viewemail' => $data['viewemail'], 'user_allow_massemail' => $data['massemail'], 'user_allow_viewonline' => !$data['hideonline'], 'user_notify_type' => $data['notifymethod'], 'user_notify_pm' => $data['notifypm'], 'user_dst' => $data['dst'], 'user_dateformat' => $data['dateformat'], 'user_lang' => $data['lang'], 'user_timezone' => $data['tz'], 'user_style' => $data['style'], 'user_topic_sortby_type' => $data['topic_sk'], 'user_post_sortby_type' => $data['post_sk'], 'user_topic_sortby_dir' => $data['topic_sd'], 'user_post_sortby_dir' => $data['post_sd'], 'user_topic_show_days' => $data['topic_st'], 'user_post_show_days' => $data['post_st'], 'user_notify' => $data['notify'], ); $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'] . adm_back_link($this->u_action . '&u=' . $user_id)); } // Replace "error" strings with their real, localised form $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); } $dateformat_options = ''; foreach ($user->lang['dateformats'] as $format => $null) { $dateformat_options .= '<option value="' . $format . '"' . (($format == $data['dateformat']) ? ' selected="selected"' : '') . '>'; $dateformat_options .= $user->format_date(time(), $format, false) . ((strpos($format, '|') !== false) ? $user->lang['VARIANT_DATE_SEPARATOR'] . $user->format_date(time(), $format, true) : ''); $dateformat_options .= '</option>'; } $s_custom = false; $dateformat_options .= '<option value="custom"'; if (!in_array($data['dateformat'], array_keys($user->lang['dateformats']))) { $dateformat_options .= ' selected="selected"'; $s_custom = true; } $dateformat_options .= '>' . $user->lang['CUSTOM_DATEFORMAT'] . '</option>'; $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); // Topic ordering options $limit_topic_days = array(0 => $user->lang['ALL_TOPICS'], 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'], 365 => $user->lang['1_YEAR']); $sort_by_topic_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 'r' => $user->lang['REPLIES'], 's' => $user->lang['SUBJECT'], 'v' => $user->lang['VIEWS']); // Post ordering options $limit_post_days = array(0 => $user->lang['ALL_POSTS'], 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'], 365 => $user->lang['1_YEAR']); $sort_by_post_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']); $_options = array('topic', 'post'); foreach ($_options as $sort_option) { ${'s_limit_' . $sort_option . '_days'} = '<select name="' . $sort_option . '_st">'; foreach (${'limit_' . $sort_option . '_days'} as $day => $text) { $selected = ($data[$sort_option . '_st'] == $day) ? ' selected="selected"' : ''; ${'s_limit_' . $sort_option . '_days'} .= '<option value="' . $day . '"' . $selected . '>' . $text . '</option>'; } ${'s_limit_' . $sort_option . '_days'} .= '</select>'; ${'s_sort_' . $sort_option . '_key'} = '<select name="' . $sort_option . '_sk">'; foreach (${'sort_by_' . $sort_option . '_text'} as $key => $text) { $selected = ($data[$sort_option . '_sk'] == $key) ? ' selected="selected"' : ''; ${'s_sort_' . $sort_option . '_key'} .= '<option value="' . $key . '"' . $selected . '>' . $text . '</option>'; } ${'s_sort_' . $sort_option . '_key'} .= '</select>'; ${'s_sort_' . $sort_option . '_dir'} = '<select name="' . $sort_option . '_sd">'; foreach ($sort_dir_text as $key => $value) { $selected = ($data[$sort_option . '_sd'] == $key) ? ' selected="selected"' : ''; ${'s_sort_' . $sort_option . '_dir'} .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; } ${'s_sort_' . $sort_option . '_dir'} .= '</select>'; } $template->assign_vars(array( 'S_PREFS' => true, 'S_JABBER_DISABLED' => ($config['jab_enable'] && $user_row['user_jabber'] && @extension_loaded('xml')) ? false : true, 'VIEW_EMAIL' => $data['viewemail'], 'MASS_EMAIL' => $data['massemail'], 'ALLOW_PM' => $data['allowpm'], 'HIDE_ONLINE' => $data['hideonline'], 'NOTIFY_EMAIL' => ($data['notifymethod'] == NOTIFY_EMAIL) ? true : false, 'NOTIFY_IM' => ($data['notifymethod'] == NOTIFY_IM) ? true : false, 'NOTIFY_BOTH' => ($data['notifymethod'] == NOTIFY_BOTH) ? true : false, 'NOTIFY_PM' => $data['notifypm'], 'POPUP_PM' => $data['popuppm'], 'DST' => $data['dst'], 'BBCODE' => $data['bbcode'], 'SMILIES' => $data['smilies'], 'ATTACH_SIG' => $data['sig'], 'NOTIFY' => $data['notify'], 'VIEW_IMAGES' => $data['view_images'], 'VIEW_FLASH' => $data['view_flash'], 'VIEW_SMILIES' => $data['view_smilies'], 'VIEW_SIGS' => $data['view_sigs'], 'VIEW_AVATARS' => $data['view_avatars'], 'VIEW_WORDCENSOR' => $data['view_wordcensor'], 'S_TOPIC_SORT_DAYS' => $s_limit_topic_days, 'S_TOPIC_SORT_KEY' => $s_sort_topic_key, 'S_TOPIC_SORT_DIR' => $s_sort_topic_dir, 'S_POST_SORT_DAYS' => $s_limit_post_days, 'S_POST_SORT_KEY' => $s_sort_post_key, 'S_POST_SORT_DIR' => $s_sort_post_dir, 'DATE_FORMAT' => $data['dateformat'], 'S_DATEFORMAT_OPTIONS' => $dateformat_options, 'S_CUSTOM_DATEFORMAT' => $s_custom, 'DEFAULT_DATEFORMAT' => $config['default_dateformat'], 'A_DEFAULT_DATEFORMAT' => addslashes($config['default_dateformat']), 'S_LANG_OPTIONS' => language_select($data['lang']), 'S_STYLE_OPTIONS' => style_select($data['style']), 'S_TZ_OPTIONS' => tz_select($data['tz'], true), ) ); break; case 'avatar': include($phpbb_root_path . 'includes/functions_display.' . $phpEx); include($phpbb_root_path . 'includes/functions_user.' . $phpEx); $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && @is_writable($phpbb_root_path . $config['avatar_path']) && $file_uploads) ? true : false; if ($submit) { if (!check_form_key($form_name)) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if (avatar_process_user($error, $user_row)) { trigger_error($user->lang['USER_AVATAR_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_row['user_id'])); } // Replace "error" strings with their real, localised form $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); } // Generate users avatar $avatar_img = ($user_row['user_avatar']) ? get_user_avatar($user_row['user_avatar'], $user_row['user_avatar_type'], $user_row['user_avatar_width'], $user_row['user_avatar_height']) : '<img src="' . $phpbb_admin_path . 'images/no_avatar.gif" alt="" />'; $display_gallery = (isset($_POST['display_gallery'])) ? true : false; $avatar_select = basename(request_var('avatar_select', '')); $category = basename(request_var('category', '')); if ($config['allow_avatar_local'] && $display_gallery) { avatar_gallery($category, $avatar_select, 4); } $template->assign_vars(array( 'S_AVATAR' => true, 'S_CAN_UPLOAD' => ($can_upload && $config['allow_avatar_upload']) ? true : false, 'S_ALLOW_REMOTE' => ($config['allow_avatar_remote']) ? true : false, 'S_DISPLAY_GALLERY' => ($config['allow_avatar_local'] && !$display_gallery) ? true : false, 'S_IN_GALLERY' => ($config['allow_avatar_local'] && $display_gallery) ? true : false, 'AVATAR_IMAGE' => $avatar_img, 'AVATAR_MAX_FILESIZE' => $config['avatar_filesize'], 'USER_AVATAR_WIDTH' => $user_row['user_avatar_width'], 'USER_AVATAR_HEIGHT' => $user_row['user_avatar_height'], 'L_AVATAR_EXPLAIN' => sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], round($config['avatar_filesize'] / 1024))) ); break; case 'rank': if ($submit) { if (!check_form_key($form_name)) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } $rank_id = request_var('user_rank', 0); $sql = 'UPDATE ' . USERS_TABLE . " SET user_rank = $rank_id WHERE user_id = $user_id"; $db->sql_query($sql); trigger_error($user->lang['USER_RANK_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); } $sql = 'SELECT * FROM ' . RANKS_TABLE . ' WHERE rank_special = 1 ORDER BY rank_title'; $result = $db->sql_query($sql); $s_rank_options = '<option value="0"' . ((!$user_row['user_rank']) ? ' selected="selected"' : '') . '>' . $user->lang['NO_SPECIAL_RANK'] . '</option>'; while ($row = $db->sql_fetchrow($result)) { $selected = ($user_row['user_rank'] && $row['rank_id'] == $user_row['user_rank']) ? ' selected="selected"' : ''; $s_rank_options .= '<option value="' . $row['rank_id'] . '"' . $selected . '>' . $row['rank_title'] . '</option>'; } $db->sql_freeresult($result); $template->assign_vars(array( 'S_RANK' => true, 'S_RANK_OPTIONS' => $s_rank_options) ); break; case 'sig': include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx); $enable_bbcode = ($config['allow_sig_bbcode']) ? ((request_var('disable_bbcode', !$user->optionget('bbcode'))) ? false : true) : false; $enable_smilies = ($config['allow_sig_smilies']) ? ((request_var('disable_smilies', !$user->optionget('smilies'))) ? false : true) : false; $enable_urls = ($config['allow_sig_links']) ? ((request_var('disable_magic_url', false)) ? false : true) : false; $signature = utf8_normalize_nfc(request_var('signature', (string) $user_row['user_sig'], true)); $preview = (isset($_POST['preview'])) ? true : false; if ($submit || $preview) { include_once($phpbb_root_path . 'includes/message_parser.' . $phpEx); $message_parser = new parse_message($signature); // Allowing Quote BBCode $message_parser->parse($enable_bbcode, $enable_urls, $enable_smilies, $config['allow_sig_img'], $config['allow_sig_flash'], true, $config['allow_sig_links'], true, 'sig'); if (sizeof($message_parser->warn_msg)) { $error[] = implode('<br />', $message_parser->warn_msg); } if (!check_form_key($form_name)) { $error = 'FORM_INVALID'; } if (!sizeof($error) && $submit) { $sql_ary = array( 'user_sig' => (string) $message_parser->message, 'user_sig_bbcode_uid' => (string) $message_parser->bbcode_uid, 'user_sig_bbcode_bitfield' => (string) $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['USER_SIG_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); } // Replace "error" strings with their real, localised form $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); } $signature_preview = ''; if ($preview) { // Now parse it for displaying $signature_preview = $message_parser->format_display($enable_bbcode, $enable_urls, $enable_smilies, false); unset($message_parser); } decode_message($signature, $user_row['user_sig_bbcode_uid']); $template->assign_vars(array( 'S_SIGNATURE' => true, 'SIGNATURE' => $signature, 'SIGNATURE_PREVIEW' => $signature_preview, 'S_BBCODE_CHECKED' => (!$enable_bbcode) ? ' checked="checked"' : '', 'S_SMILIES_CHECKED' => (!$enable_smilies) ? ' checked="checked"' : '', 'S_MAGIC_URL_CHECKED' => (!$enable_urls) ? ' checked="checked"' : '', 'BBCODE_STATUS' => ($config['allow_sig_bbcode']) ? sprintf($user->lang['BBCODE_IS_ON'], '<a href="' . append_sid("{$phpbb_root_path}faq.$phpEx", 'mode=bbcode') . '">', '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], '<a href="' . append_sid("{$phpbb_root_path}faq.$phpEx", 'mode=bbcode') . '">', '</a>'), 'SMILIES_STATUS' => ($config['allow_sig_smilies']) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], 'IMG_STATUS' => ($config['allow_sig_img']) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'], 'FLASH_STATUS' => ($config['allow_sig_flash']) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'], 'URL_STATUS' => ($config['allow_sig_links']) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'], 'L_SIGNATURE_EXPLAIN' => sprintf($user->lang['SIGNATURE_EXPLAIN'], $config['max_sig_chars']), 'S_BBCODE_ALLOWED' => $config['allow_sig_bbcode'], 'S_SMILIES_ALLOWED' => $config['allow_sig_smilies'], 'S_BBCODE_IMG' => ($config['allow_sig_img']) ? true : false, 'S_BBCODE_FLASH' => ($config['allow_sig_flash']) ? true : false, 'S_LINKS_ALLOWED' => ($config['allow_sig_links']) ? true : false) ); // Assigning custom bbcodes display_custom_bbcodes(); break; case 'attach': $start = request_var('start', 0); $deletemark = (isset($_POST['delmarked'])) ? true : false; $marked = request_var('mark', array(0)); // Sort keys $sort_key = request_var('sk', 'a'); $sort_dir = request_var('sd', 'd'); if ($deletemark && sizeof($marked)) { $sql = 'SELECT attach_id FROM ' . ATTACHMENTS_TABLE . ' WHERE poster_id = ' . $user_id . ' AND is_orphan = 0 AND ' . $db->sql_in_set('attach_id', $marked); $result = $db->sql_query($sql); $marked = array(); while ($row = $db->sql_fetchrow($result)) { $marked[] = $row['attach_id']; } $db->sql_freeresult($result); } if ($deletemark && sizeof($marked)) { if (confirm_box(true)) { $sql = 'SELECT real_filename FROM ' . ATTACHMENTS_TABLE . ' WHERE ' . $db->sql_in_set('attach_id', $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); $message = (sizeof($log_attachments) == 1) ? $user->lang['ATTACHMENT_DELETED'] : $user->lang['ATTACHMENTS_DELETED']; add_log('admin', 'LOG_ATTACHMENTS_DELETED', implode(', ', $log_attachments)); trigger_error($message . adm_back_link($this->u_action . '&u=' . $user_id)); } else { confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( 'u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'delmarked' => true, 'mark' => $marked)) ); } } $sk_text = array('a' => $user->lang['SORT_FILENAME'], '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', 'c' => 'a.extension', 'd' => 'a.filesize', 'e' => 'a.download_count', 'f' => 'a.filetime', 'g' => 't.topic_title'); $sd_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); $s_sort_key = ''; foreach ($sk_text as $key => $value) { $selected = ($sort_key == $key) ? ' selected="selected"' : ''; $s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; } $s_sort_dir = ''; foreach ($sd_text as $key => $value) { $selected = ($sort_dir == $key) ? ' selected="selected"' : ''; $s_sort_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; } if (!isset($sk_sql[$sort_key])) { $sort_key = 'a'; } $order_by = $sk_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC'); $sql = 'SELECT COUNT(attach_id) as num_attachments FROM ' . ATTACHMENTS_TABLE . " WHERE poster_id = $user_id AND is_orphan = 0"; $result = $db->sql_query_limit($sql, 1); $num_attachments = (int) $db->sql_fetchfield('num_attachments'); $db->sql_freeresult($result); $sql = 'SELECT a.*, t.topic_title, p.message_subject as message_title FROM ' . ATTACHMENTS_TABLE . ' a LEFT JOIN ' . TOPICS_TABLE . ' t ON (a.topic_id = t.topic_id AND a.in_message = 0) LEFT JOIN ' . PRIVMSGS_TABLE . ' p ON (a.post_msg_id = p.msg_id AND a.in_message = 1) WHERE a.poster_id = ' . $user_id . " AND a.is_orphan = 0 ORDER BY $order_by"; $result = $db->sql_query_limit($sql, $config['posts_per_page'], $start); while ($row = $db->sql_fetchrow($result)) { if ($row['in_message']) { $view_topic = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&p={$row['post_msg_id']}"); } else { $view_topic = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t={$row['topic_id']}&p={$row['post_msg_id']}") . '#p' . $row['post_msg_id']; } $template->assign_block_vars('attach', array( 'REAL_FILENAME' => $row['real_filename'], 'COMMENT' => nl2br($row['attach_comment']), 'EXTENSION' => $row['extension'], 'SIZE' => ($row['filesize'] >= 1048576) ? ($row['filesize'] >> 20) . ' ' . $user->lang['MB'] : (($row['filesize'] >= 1024) ? ($row['filesize'] >> 10) . ' ' . $user->lang['KB'] : $row['filesize'] . ' ' . $user->lang['BYTES']), 'DOWNLOAD_COUNT' => $row['download_count'], 'POST_TIME' => $user->format_date($row['filetime']), 'TOPIC_TITLE' => ($row['in_message']) ? $row['message_title'] : $row['topic_title'], 'ATTACH_ID' => $row['attach_id'], 'POST_ID' => $row['post_msg_id'], 'TOPIC_ID' => $row['topic_id'], 'S_IN_MESSAGE' => $row['in_message'], 'U_DOWNLOAD' => append_sid("{$phpbb_root_path}download/file.$phpEx", 'mode=view&id=' . $row['attach_id']), 'U_VIEW_TOPIC' => $view_topic) ); } $db->sql_freeresult($result); $template->assign_vars(array( 'S_ATTACHMENTS' => true, 'S_ON_PAGE' => on_page($num_attachments, $config['topics_per_page'], $start), 'S_SORT_KEY' => $s_sort_key, 'S_SORT_DIR' => $s_sort_dir, 'PAGINATION' => generate_pagination($this->u_action . "&u=$user_id&sk=$sort_key&sd=$sort_dir", $num_attachments, $config['topics_per_page'], $start, true)) ); break; case 'groups': include($phpbb_root_path . 'includes/functions_user.' . $phpEx); $user->add_lang(array('groups', 'acp/groups')); $group_id = request_var('g', 0); if ($group_id) { // Check the founder only entry for this group to make sure everything is well $sql = 'SELECT group_founder_manage FROM ' . GROUPS_TABLE . ' WHERE group_id = ' . $group_id; $result = $db->sql_query($sql); $founder_manage = (int) $db->sql_fetchfield('group_founder_manage'); $db->sql_freeresult($result); if ($user->data['user_type'] != USER_FOUNDER && $founder_manage) { trigger_error($user->lang['NOT_ALLOWED_MANAGE_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } } else { $founder_manage = 0; } switch ($action) { case 'demote': case 'promote': case 'default': if (!$group_id) { trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } group_user_attributes($action, $group_id, $user_id); if ($action == 'default') { $user_row['group_id'] = $group_id; } break; case 'delete': if (confirm_box(true)) { if (!$group_id) { trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if ($error = group_user_del($group_id, $user_id)) { trigger_error($user->lang[$error] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } $error = array(); } else { confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( 'u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'g' => $group_id)) ); } break; } // Add user to group? if ($submit) { if (!check_form_key($form_name)) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if (!$group_id) { trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } // Add user/s to group if ($error = group_user_add($group_id, $user_id)) { trigger_error($user->lang[$error] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } $error = array(); } $sql = 'SELECT ug.*, 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, group_founder_manage FROM ' . GROUPS_TABLE . ' ' . ((sizeof($id_ary)) ? 'WHERE ' . $db->sql_in_set('group_id', $id_ary, true) : '') . ' ORDER BY group_type DESC, group_name ASC'; $result = $db->sql_query($sql); $s_group_options = ''; while ($row = $db->sql_fetchrow($result)) { if (!$config['coppa_enable'] && $row['group_name'] == 'REGISTERED_COPPA') { continue; } // Do not display those groups not allowed to be managed if ($user->data['user_type'] != USER_FOUNDER && $row['group_founder_manage']) { continue; } $s_group_options .= '<option' . (($row['group_type'] == GROUP_SPECIAL) ? ' class="sep"' : '') . ' 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) { $template->assign_block_vars('group', array( 'S_NEW_GROUP_TYPE' => true, 'GROUP_TYPE' => $user->lang['USER_GROUP_' . strtoupper($group_type)]) ); } foreach ($data_ary as $data) { $template->assign_block_vars('group', array( 'U_EDIT_GROUP' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=groups&mode=manage&action=edit&u=$user_id&g={$data['group_id']}&back_link=acp_users_groups"), 'U_DEFAULT' => $this->u_action . "&action=default&u=$user_id&g=" . $data['group_id'], 'U_DEMOTE_PROMOTE' => $this->u_action . '&action=' . (($data['group_leader']) ? 'demote' : 'promote') . "&u=$user_id&g=" . $data['group_id'], 'U_DELETE' => $this->u_action . "&action=delete&u=$user_id&g=" . $data['group_id'], 'GROUP_NAME' => ($group_type == 'special') ? $user->lang['G_' . $data['group_name']] : $data['group_name'], 'L_DEMOTE_PROMOTE' => ($data['group_leader']) ? $user->lang['GROUP_DEMOTE'] : $user->lang['GROUP_PROMOTE'], 'S_NO_DEFAULT' => ($user_row['group_id'] != $data['group_id']) ? true : false, 'S_SPECIAL_GROUP' => ($group_type == 'special') ? true : false, ) ); } } $template->assign_vars(array( 'S_GROUPS' => true, 'S_GROUP_OPTIONS' => $s_group_options) ); break; case 'perm': include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); $auth_admin = new auth_admin(); $user->add_lang('acp/permissions'); add_permission_language(); $forum_id = request_var('f', 0); // Global Permissions if (!$forum_id) { // Select auth options $sql = 'SELECT auth_option, is_local, is_global FROM ' . ACL_OPTIONS_TABLE . ' WHERE auth_option ' . $db->sql_like_expression($db->any_char . '_') . ' AND is_global = 1 ORDER BY auth_option'; $result = $db->sql_query($sql); $hold_ary = array(); while ($row = $db->sql_fetchrow($result)) { $hold_ary = $auth_admin->get_mask('view', $user_id, false, false, $row['auth_option'], 'global', ACL_NEVER); $auth_admin->display_mask('view', $row['auth_option'], $hold_ary, 'user', false, false); } $db->sql_freeresult($result); unset($hold_ary); } else { $sql = 'SELECT auth_option, is_local, is_global FROM ' . ACL_OPTIONS_TABLE . " WHERE auth_option " . $db->sql_like_expression($db->any_char . '_') . " AND is_local = 1 ORDER BY is_global DESC, auth_option"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $hold_ary = $auth_admin->get_mask('view', $user_id, false, $forum_id, $row['auth_option'], 'local', ACL_NEVER); $auth_admin->display_mask('view', $row['auth_option'], $hold_ary, 'user', true, false); } $db->sql_freeresult($result); } $s_forum_options = '<option value="0"' . ((!$forum_id) ? ' selected="selected"' : '') . '>' . $user->lang['VIEW_GLOBAL_PERMS'] . '</option>'; $s_forum_options .= make_forum_select($forum_id, false, true, false, false, false); $template->assign_vars(array( 'S_PERMISSIONS' => true, 'S_GLOBAL' => (!$forum_id) ? true : false, 'S_FORUM_OPTIONS' => $s_forum_options, 'U_ACTION' => $this->u_action . '&u=' . $user_id, 'U_USER_PERMISSIONS' => append_sid("{$phpbb_admin_path}index.$phpEx" ,'i=permissions&mode=setting_user_global&user_id[]=' . $user_id), 'U_USER_FORUM_PERMISSIONS' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions&mode=setting_user_local&user_id[]=' . $user_id)) ); break; } // Assign general variables $template->assign_vars(array( 'S_ERROR' => (sizeof($error)) ? true : false, 'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '') ); }
/** * View topic in MCP */ function mcp_topic_view($id, $mode, $action) { global $phpEx, $phpbb_root_path, $config; global $template, $db, $user, $auth, $cache; $url = append_sid("{$phpbb_root_path}mcp.{$phpEx}?" . extra_url()); $user->add_lang('viewtopic'); $topic_id = request_var('t', 0); $topic_info = get_topic_data(array($topic_id), false, true); if (!sizeof($topic_info)) { trigger_error('TOPIC_NOT_EXIST'); } $topic_info = $topic_info[$topic_id]; // Set up some vars $icon_id = request_var('icon', 0); $subject = utf8_normalize_nfc(request_var('subject', '', true)); $start = request_var('start', 0); $sort_days_old = request_var('st_old', 0); $forum_id = request_var('f', 0); $to_topic_id = request_var('to_topic_id', 0); $to_forum_id = request_var('to_forum_id', 0); $sort = isset($_POST['sort']) ? true : false; $submitted_id_list = request_var('post_ids', array(0)); $checked_ids = $post_id_list = request_var('post_id_list', array(0)); // Resync Topic? if ($action == 'resync') { if (!function_exists('mcp_resync_topics')) { include $phpbb_root_path . 'includes/mcp/mcp_forum.' . $phpEx; } mcp_resync_topics(array($topic_id)); } // Split Topic? if ($action == 'split_all' || $action == 'split_beyond') { if (!$sort) { split_topic($action, $topic_id, $to_forum_id, $subject); } $action = 'split'; } // Merge Posts? if ($action == 'merge_posts') { if (!$sort) { merge_posts($topic_id, $to_topic_id); } $action = 'merge'; } if ($action == 'split' && !$subject) { $subject = $topic_info['topic_title']; } // Approve posts? if ($action == 'approve' && $auth->acl_get('m_approve', $topic_info['forum_id'])) { include $phpbb_root_path . 'includes/mcp/mcp_queue.' . $phpEx; include_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx; include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx; if (!sizeof($post_id_list)) { trigger_error('NO_POST_SELECTED'); } if (!$sort) { approve_post($post_id_list, $id, $mode); } } // Jumpbox, sort selects and that kind of things make_jumpbox($url . "&i={$id}&mode=forum_view", $topic_info['forum_id'], false, 'm_', true); $where_sql = $action == 'reports' ? 'WHERE post_reported = 1 AND ' : 'WHERE'; $sort_days = $total = 0; $sort_key = $sort_dir = ''; $sort_by_sql = $sort_order_sql = array(); mcp_sorting('viewtopic', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $topic_info['forum_id'], $topic_id, $where_sql); $limit_time_sql = $sort_days ? 'AND p.post_time >= ' . (time() - $sort_days * 86400) : ''; if ($total == -1) { if ($auth->acl_get('m_approve', $topic_info['forum_id'])) { $total = $topic_info['topic_replies_real'] + 1; } else { $total = $topic_info['topic_replies'] + 1; } } $posts_per_page = max(0, request_var('posts_per_page', intval($config['posts_per_page']))); if ($posts_per_page == 0) { $posts_per_page = $total; } if (!empty($sort_days_old) && $sort_days_old != $sort_days || $total <= $posts_per_page) { $start = 0; } // Make sure $start is set to the last page if it exceeds the amount if ($start < 0 || $start >= $total) { $start = $start < 0 ? 0 : floor(($total - 1) / $posts_per_page) * $posts_per_page; } $sql = 'SELECT u.username, u.username_clean, u.user_colour, p.* FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u WHERE ' . ($action == 'reports' ? 'p.post_reported = 1 AND ' : '') . ' p.topic_id = ' . $topic_id . ' ' . (!$auth->acl_get('m_approve', $topic_info['forum_id']) ? ' AND p.post_approved = 1 ' : '') . ' AND p.poster_id = u.user_id ' . $limit_time_sql . ' ORDER BY ' . $sort_order_sql; $result = $db->sql_query_limit($sql, $posts_per_page, $start); $rowset = $post_id_list = array(); $bbcode_bitfield = ''; while ($row = $db->sql_fetchrow($result)) { $rowset[] = $row; $post_id_list[] = $row['post_id']; $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']); } $db->sql_freeresult($result); if ($bbcode_bitfield !== '') { include_once $phpbb_root_path . 'includes/bbcode.' . $phpEx; $bbcode = new bbcode(base64_encode($bbcode_bitfield)); } $topic_tracking_info = array(); // Get topic tracking info if ($config['load_db_lastread']) { $tmp_topic_data = array($topic_id => $topic_info); $topic_tracking_info = get_topic_tracking($topic_info['forum_id'], $topic_id, $tmp_topic_data, array($topic_info['forum_id'] => $topic_info['forum_mark_time'])); unset($tmp_topic_data); } else { $topic_tracking_info = get_complete_topic_tracking($topic_info['forum_id'], $topic_id); } $has_unapproved_posts = false; // Grab extensions $extensions = $attachments = array(); if ($topic_info['topic_attachment'] && sizeof($post_id_list)) { $extensions = $cache->obtain_attach_extensions($topic_info['forum_id']); // Get attachments... if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $topic_info['forum_id'])) { $sql = 'SELECT * FROM ' . ATTACHMENTS_TABLE . ' WHERE ' . $db->sql_in_set('post_msg_id', $post_id_list) . ' AND in_message = 0 ORDER BY filetime DESC, post_msg_id ASC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $attachments[$row['post_msg_id']][] = $row; } $db->sql_freeresult($result); } } foreach ($rowset as $i => $row) { $message = $row['post_text']; $post_subject = $row['post_subject'] != '' ? $row['post_subject'] : $topic_info['topic_title']; if ($row['bbcode_bitfield']) { $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']); } $message = bbcode_nl2br($message); $message = smiley_text($message); if (!empty($attachments[$row['post_id']])) { $update_count = array(); parse_attachments($topic_info['forum_id'], $message, $attachments[$row['post_id']], $update_count); } if (!$row['post_approved']) { $has_unapproved_posts = true; } $post_unread = isset($topic_tracking_info[$topic_id]) && $row['post_time'] > $topic_tracking_info[$topic_id] ? true : false; $template->assign_block_vars('postrow', array('POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_DATE' => $user->format_date($row['post_time']), 'POST_SUBJECT' => $post_subject, 'MESSAGE' => $message, 'POST_ID' => $row['post_id'], 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 't=' . $topic_id) . '">', '</a>'), 'MINI_POST_IMG' => $post_unread ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), 'S_POST_REPORTED' => $row['post_reported'] && $auth->acl_get('m_report', $topic_info['forum_id']), 'S_POST_UNAPPROVED' => !$row['post_approved'] && $auth->acl_get('m_approve', $topic_info['forum_id']), 'S_CHECKED' => $submitted_id_list && !in_array(intval($row['post_id']), $submitted_id_list) || in_array(intval($row['post_id']), $checked_ids) ? true : false, 'S_HAS_ATTACHMENTS' => !empty($attachments[$row['post_id']]) ? true : false, 'U_POST_DETAILS' => "{$url}&i={$id}&p={$row['post_id']}&mode=post_details" . ($forum_id ? "&f={$forum_id}" : ''), 'U_MCP_APPROVE' => $auth->acl_get('m_approve', $topic_info['forum_id']) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&mode=approve_details&f=' . $topic_info['forum_id'] . '&p=' . $row['post_id']) : '', 'U_MCP_REPORT' => $auth->acl_get('m_report', $topic_info['forum_id']) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports&mode=report_details&f=' . $topic_info['forum_id'] . '&p=' . $row['post_id']) : '')); // Display not already displayed Attachments for this post, we already parsed them. ;) if (!empty($attachments[$row['post_id']])) { foreach ($attachments[$row['post_id']] as $attachment) { $template->assign_block_vars('postrow.attachment', array('DISPLAY_ATTACHMENT' => $attachment)); } } unset($rowset[$i]); } // Display topic icons for split topic $s_topic_icons = false; if ($auth->acl_gets('m_split', 'm_merge', (int) $topic_info['forum_id'])) { include_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx; $s_topic_icons = posting_gen_topic_icons('', $icon_id); // Has the user selected a topic for merge? if ($to_topic_id) { $to_topic_info = get_topic_data(array($to_topic_id), 'm_merge'); if (!sizeof($to_topic_info)) { $to_topic_id = 0; } else { $to_topic_info = $to_topic_info[$to_topic_id]; if (!$to_topic_info['enable_icons'] || $auth->acl_get('!f_icons', $topic_info['forum_id'])) { $s_topic_icons = false; } } } } $s_hidden_fields = build_hidden_fields(array('st_old' => $sort_days, 'post_ids' => $post_id_list)); $template->assign_vars(array('TOPIC_TITLE' => $topic_info['topic_title'], 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $topic_info['forum_id'] . '&t=' . $topic_info['topic_id']), 'TO_TOPIC_ID' => $to_topic_id, 'TO_TOPIC_INFO' => $to_topic_id ? sprintf($user->lang['YOU_SELECTED_TOPIC'], $to_topic_id, '<a href="' . append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $to_topic_info['forum_id'] . '&t=' . $to_topic_id) . '">' . $to_topic_info['topic_title'] . '</a>') : '', 'SPLIT_SUBJECT' => $subject, 'POSTS_PER_PAGE' => $posts_per_page, 'ACTION' => $action, 'REPORTED_IMG' => $user->img('icon_topic_reported', 'POST_REPORTED'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'), 'INFO_IMG' => $user->img('icon_post_info', 'VIEW_INFO'), 'S_MCP_ACTION' => "{$url}&i={$id}&mode={$mode}&action={$action}&start={$start}", 'S_FORUM_SELECT' => $to_forum_id ? make_forum_select($to_forum_id, false, false, true, true, true) : make_forum_select($topic_info['forum_id'], false, false, true, true, true), 'S_CAN_SPLIT' => $auth->acl_get('m_split', $topic_info['forum_id']) ? true : false, 'S_CAN_MERGE' => $auth->acl_get('m_merge', $topic_info['forum_id']) ? true : false, 'S_CAN_DELETE' => $auth->acl_get('m_delete', $topic_info['forum_id']) ? true : false, 'S_CAN_APPROVE' => $has_unapproved_posts && $auth->acl_get('m_approve', $topic_info['forum_id']) ? true : false, 'S_CAN_LOCK' => $auth->acl_get('m_lock', $topic_info['forum_id']) ? true : false, 'S_CAN_REPORT' => $auth->acl_get('m_report', $topic_info['forum_id']) ? true : false, 'S_CAN_SYNC' => $auth->acl_get('m_', $topic_info['forum_id']), 'S_REPORT_VIEW' => $action == 'reports' ? true : false, 'S_MERGE_VIEW' => $action == 'merge' ? true : false, 'S_SPLIT_VIEW' => $action == 'split' ? true : false, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_SHOW_TOPIC_ICONS' => $s_topic_icons, 'S_TOPIC_ICON' => $icon_id, 'U_SELECT_TOPIC' => "{$url}&i={$id}&mode=forum_view&action=merge_select" . ($forum_id ? "&f={$forum_id}" : ''), 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$topic_info['forum_id']}&t={$topic_info['topic_id']}&start={$start}") . '">', '</a>'), 'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.{$phpEx}", "f={$topic_info['forum_id']}&start={$start}") . '">', '</a>'), 'PAGE_NUMBER' => on_page($total, $posts_per_page, $start), 'PAGINATION' => !$posts_per_page ? '' : generate_pagination(append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i={$id}&t={$topic_info['topic_id']}&mode={$mode}&action={$action}&to_topic_id={$to_topic_id}&posts_per_page={$posts_per_page}&st={$sort_days}&sk={$sort_key}&sd={$sort_dir}"), $total, $posts_per_page, $start), 'TOTAL_POSTS' => $total == 1 ? $user->lang['VIEW_TOPIC_POST'] : sprintf($user->lang['VIEW_TOPIC_POSTS'], $total))); }
function main($id, $mode) { global $user, $template, $request, $config, $phpbb_container; $this->page_title = $user->lang('ACP_SUB_PREFIX'); $this->tpl_name = 'acp_sub_prfx_body'; $config_text = $phpbb_container->get('config_text'); $prefixes = $config_text->get('sub_prfx'); $prefixes = $prefixes ? explode(',', $prefixes) : array(); $prefixes_second = $config_text->get('sub_prfx_second'); $prefixes_second = $prefixes_second ? explode(',', $prefixes_second) : array(); $forums = explode(',', $config['sub_prfx_forums']); $exclude_forums = $request->variable('forum_id', $forums); $action = $request->variable('action', ''); $prefixes_ary = $request->variable('prefixes', $prefixes, true); $prefixes_second_ary = $request->variable('prefixes_second', $prefixes_second, true); $prefix_name = $request->variable('prefix_name', '', true); $prefix_second_name = $request->variable('prefix_name_second', '', true); $delete = $request->variable('del', 0); if ($action == 'delete') { unset($prefixes[$delete]); $prefixes = implode(',', $prefixes); $config_text->set('sub_prfx', $prefixes); meta_refresh(3, append_sid($this->u_action)); trigger_error($user->lang['UPDATE_CONFIG_SUCCESS'] . adm_back_link($this->u_action)); } if ($action == 'delete_second') { unset($prefixes_second[$delete]); $prefixes_second = implode(',', $prefixes_second); $config_text->set('sub_prfx_second', $prefixes_second); meta_refresh(3, append_sid($this->u_action)); trigger_error($user->lang['UPDATE_CONFIG_SUCCESS'] . adm_back_link($this->u_action)); } $forum_list = make_forum_select(false, false, true, true, true, false, true); $s_forum_options = ''; foreach ($forum_list as $key => $value) { $selected = in_array($value['forum_id'], $forums) ? true : false; $s_forum_options .= '<option value="' . $value['forum_id'] . '"' . ($selected ? ' selected="selected"' : '') . ($value['disabled'] ? ' disabled="disabled" class="disabled-option"' : '') . '>' . $value['padding'] . $value['forum_name'] . '</option>'; } $template->assign_vars(array('S_SELECT_FORUM' => true, 'S_FORUM_OPTIONS' => $s_forum_options, 'PREFIX_NAME' => $prefix_name)); foreach ($prefixes as $key => $value) { $template->assign_block_vars('prefixes', array('KEY' => $key, 'PREFIX' => $value, 'U_DELETE' => $this->u_action . '&action=delete&del=' . $key . '')); } foreach ($prefixes_second as $key => $value) { $template->assign_block_vars('prefixes_second', array('KEY' => $key, 'PREFIX' => $value, 'U_DELETE' => $this->u_action . '&action=delete_second&del=' . $key . '')); } add_form_key('sheer/sub_prfx'); if ($request->is_set_post('submit')) { if (!check_form_key('sheer/sub_prfx')) { trigger_error('FORM_INVALID'); } $config->set('sub_prfx_forums', implode(',', $exclude_forums)); $prefixes_ary = implode(',', $prefixes_ary); if ($prefix_name) { if ($prefixes_ary) { $prefixes_ary .= ',' . $prefix_name; } else { $prefixes_ary = $prefix_name; } } $prefixes_second_ary = implode(',', $prefixes_second_ary); if ($prefix_second_name) { if ($prefixes_second_ary) { $prefixes_second_ary .= ',' . $prefix_second_name; } else { $prefixes_second_ary = $prefix_second_name; } } $config_text->set('sub_prfx', $prefixes_ary); $config_text->set('sub_prfx_second', $prefixes_second_ary); meta_refresh(3, append_sid($this->u_action)); trigger_error($user->lang['UPDATE_CONFIG_SUCCESS'] . adm_back_link($this->u_action)); } }
/** * main Settings function * * @param int $id * @param String $mode */ function main($id, $mode) { global $db, $user, $template, $cache, $config, $phpbb_admin_path, $phpEx; $link = '<br /><a href="' . append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp&mode=mainpage") . '"><h3>' . $user->lang['RETURN_DKPINDEX'] . '</h3></a>'; switch ($mode) { /** * MAINPAGE */ case 'mainpage': $sql = 'SELECT count(*) as member_count FROM ' . MEMBER_LIST_TABLE . " WHERE member_status='0'"; $result = $db->sql_query($sql); $total_members_inactive = (int) $db->sql_fetchfield('member_count'); $sql = 'SELECT count(*) as member_count FROM ' . MEMBER_LIST_TABLE . " WHERE member_status='1'"; $result = $db->sql_query($sql); $total_members_active = (int) $db->sql_fetchfield('member_count'); $total_members = $total_members_active . ' / ' . $total_members_inactive; $sql = 'SELECT count(*) as dkp_count FROM ' . MEMBER_DKP_TABLE; $result = $db->sql_query($sql); $total_dkpcount = (int) $db->sql_fetchfield('dkp_count'); $sql = 'SELECT count(*) as pool_count FROM ' . DKPSYS_TABLE; $result = $db->sql_query($sql); $total_poolcount = (int) $db->sql_fetchfield('pool_count'); $sql = 'SELECT count(*) as adjustment_count FROM ' . ADJUSTMENTS_TABLE; $result = $db->sql_query($sql); $total_adjustmentcount = (int) $db->sql_fetchfield('adjustment_count'); $sql = 'SELECT count(*) as event_count FROM ' . EVENTS_TABLE; $result = $db->sql_query($sql); $total_eventcount = (int) $db->sql_fetchfield('event_count'); $sql = 'SELECT count(*) as guild_count FROM ' . GUILD_TABLE; $result = $db->sql_query($sql); $total_guildcount = (int) $db->sql_fetchfield('guild_count'); $total_raids = 0; $sql = 'SELECT count(*) as raid_count FROM ' . RAIDS_TABLE; $result = $db->sql_query($sql); $total_raids = (int) $db->sql_fetchfield('raid_count'); $days = (time() - $config['bbdkp_eqdkp_start']) / 86400; $raids_per_day = sprintf("%.2f", $total_raids / $days); $sql = 'SELECT count(*) as item_count FROM ' . RAID_ITEMS_TABLE; if ($raids_per_day > $total_raids) { $raids_per_day = $total_raids; } $total_items = (int) $db->sql_fetchfield('item_count'); $db->sql_freeresult($result); $items_per_day = sprintf("%.2f", $total_items / $days); if ($items_per_day > $total_items) { $items_per_day = $total_items; } if ($config['bbdkp_eqdkp_start'] != 0) { $bbdkp_started = date($config['bbdkp_date_format'], $config['bbdkp_eqdkp_start']); } else { $bbdkp_started = ''; } // read verbose log $logs = \bbdkp\admin\log::Instance(); $listlogs = $logs->read_log('', false, true, '', ''); if (isset($listlogs)) { foreach ($listlogs as $key => $log) { $template->assign_block_vars('actions_row', array('U_VIEW_LOG' => append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=dkp&mode=dkp_logs&' . URI_LOG . '=' . $log['log_id']), 'LOGDATE' => $log['datestamp'], 'ACTION' => $log['log_line'])); } } $latest_version_info = false; if (($latest_version_info = parent::get_productversion('bbdkp', request_var('versioncheck_force', false))) === false) { $template->assign_var('S_VERSIONCHECK_FAIL', true); } else { if (phpbb_version_compare($latest_version_info, $config['bbdkp_version'], '<=')) { $template->assign_vars(array('S_VERSION_UP_TO_DATE' => true)); } else { // you have an old version $template->assign_vars(array('BBDKP_NOT_UP_TO_DATE_TITLE' => sprintf($user->lang['NOT_UP_TO_DATE_TITLE'], 'bbDKP'), 'BBDKP_LATESTVERSION' => $latest_version_info[0], 'BBDKPVERSION' => $user->lang['BBDKP_YOURVERSION'] . $config['bbdkp_version'], 'UPDATEINSTR' => $user->lang['BBDKP_LATESTVERSION'] . $latest_version_info[0] . ', <a href="' . $user->lang['WEBURL'] . '">' . $user->lang['DOWNLOAD'] . '</a>')); } } //LOOP PLUGINS TABLE $plugin_versioninfo = (array) parent::get_plugin_info(request_var('versioncheck_force', false)); foreach ($plugin_versioninfo as $pname => $pdetails) { $a = phpbb_version_compare(trim($pdetails['latest']), $pdetails['version'], '<='); $template->assign_block_vars('plugin_row', array('PLUGINNAME' => ucwords($pdetails['name']), 'VERSION' => $pdetails['version'], 'ISUPTODATE' => phpbb_version_compare(trim($pdetails['latest']), $pdetails['version'], '<='), 'LATESTVERSION' => $pdetails['latest'], 'UPDATEINSTR' => '<a href="' . BBDKP_PLUGINURL . '">' . $user->lang['DOWNLOAD_LATEST_PLUGINS'] . $pdetails['latest'] . '</a>', 'INSTALLDATE' => $pdetails['installdate'])); } $template->assign_vars(array('GLYPH' => "{$phpbb_admin_path}/images/glyphs/view.gif", 'NUMBER_OF_MEMBERS' => $total_members, 'NUMBER_OF_RAIDS' => $total_raids, 'NUMBER_OF_ITEMS' => $total_items, 'NUMBER_OF_MEMBERDKP' => $total_dkpcount, 'NUMBER_OF_DKPSYS' => $total_poolcount, 'NUMBER_OF_GUILDS' => $total_guildcount, 'NUMBER_OF_EVENTS' => $total_eventcount, 'NUMBER_OF_ADJUSTMENTS' => $total_adjustmentcount, 'RAIDS_PER_DAY' => $raids_per_day, 'ITEMS_PER_DAY' => $items_per_day, 'BBDKP_STARTED' => $bbdkp_started, 'BBDKP_VERSION' => $config['bbdkp_version'], 'U_VERSIONCHECK_FORCE' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp&mode=mainpage&versioncheck_force=1"), 'GAMES_INSTALLED' => count($this->games) > 0 ? implode(", ", $this->games) : $user->lang['NA'])); $this->page_title = 'ACP_DKP_MAINPAGE'; $this->tpl_name = 'dkp/acp_mainpage'; break; /** * * DKP CONFIG */ /** * * DKP CONFIG */ case 'dkp_config': $action = request_var('action', ''); switch ($action) { case 'addconfig': if (!check_form_key('acp_dkp')) { trigger_error($user->lang['FV_FORMVALIDATION'], E_USER_WARNING); } $day = request_var('bbdkp_start_dd', 0); $month = request_var('bbdkp_start_mm', 0); $year = request_var('bbdkp_start_yy', 0); $bbdkp_start = mktime(0, 0, 0, $month, $day, $year); $settings = array('bbdkp_default_realm' => utf8_normalize_nfc(request_var('realm', '', true)), 'bbdkp_default_region' => utf8_normalize_nfc(request_var('region', '', true)), 'bbdkp_dkp_name' => utf8_normalize_nfc(request_var('dkp_name', '', true)), 'bbdkp_eqdkp_start' => $bbdkp_start, 'bbdkp_user_nlimit' => request_var('bbdkp_user_nlimit', 0), 'bbdkp_date_format' => request_var('date_format', ''), 'bbdkp_date_format' => request_var('date_format', ''), 'bbdkp_lang' => request_var('language', 'en'), 'bbdkp_maxchars' => request_var('maxchars', 2), 'bbdkp_minrosterlvl' => request_var('bbdkp_minrosterlvl', 0), 'bbdkp_roster_layout' => request_var('rosterlayout', 0), 'bbdkp_show_achiev' => request_var('showachievement', 0), 'bbdkp_hide_inactive' => isset($_POST['hide_inactive']) ? request_var('hide_inactive', '') : '0', 'bbdkp_inactive_period' => request_var('inactive_period', 0), 'bbdkp_list_p1' => request_var('list_p1', 0), 'bbdkp_list_p2' => request_var('list_p2', 0), 'bbdkp_list_p3' => request_var('list_p3', 0), 'bbdkp_user_llimit' => request_var('bbdkp_user_llimit', 0), 'bbdkp_user_elimit' => request_var('bbdkp_user_elimit', 0), 'bbdkp_event_viewall' => isset($_POST['event_viewall']) ? request_var('event_viewall', '') : '0', 'bbdkp_user_elimit' => request_var('bbdkp_user_elimit', 0), 'bbdkp_user_alimit' => request_var('bbdkp_user_alimit', 0), 'bbdkp_active_point_adj' => request_var('bbdkp_active_point_adj', 0.0), 'bbdkp_inactive_point_adj' => request_var('bbdkp_inactive_point_adj', 0.0), 'bbdkp_starting_dkp' => request_var('starting_dkp', 0.0), 'bbdkp_user_ilimit' => request_var('bbdkp_user_ilimit', 0), 'bbdkp_user_rlimit' => request_var('bbdkp_user_rlimit', 0)); set_config('bbdkp_default_realm', $settings['bbdkp_default_realm'], true); set_config('bbdkp_default_region', $settings['bbdkp_default_region'], true); set_config('bbdkp_dkp_name', $settings['bbdkp_dkp_name'], true); set_config('bbdkp_eqdkp_start', $settings['bbdkp_eqdkp_start'], true); set_config('bbdkp_user_nlimit', $settings['bbdkp_user_nlimit'], true); set_config('bbdkp_date_format', $settings['bbdkp_date_format'], true); set_config('bbdkp_lang', $settings['bbdkp_lang'], true); set_config('bbdkp_maxchars', $settings['bbdkp_maxchars'], true); //roster set_config('bbdkp_minrosterlvl', $settings['bbdkp_minrosterlvl'], true); set_config('bbdkp_roster_layout', $settings['bbdkp_roster_layout'], true); set_config('bbdkp_show_achiev', $settings['bbdkp_show_achiev'], true); //standings set_config('bbdkp_hide_inactive', $settings['bbdkp_hide_inactive'], true); set_config('bbdkp_inactive_period', $settings['bbdkp_inactive_period'], true); set_config('bbdkp_list_p1', $settings['bbdkp_list_p1'], true); set_config('bbdkp_list_p2', $settings['bbdkp_list_p2'], true); set_config('bbdkp_list_p3', $settings['bbdkp_list_p3'], true); set_config('bbdkp_user_llimit', $settings['bbdkp_user_llimit'], true); //events set_config('bbdkp_user_elimit', $settings['bbdkp_user_elimit'], true); set_config('bbdkp_event_viewall', $settings['bbdkp_event_viewall'], true); //adjustments set_config('bbdkp_user_alimit', $settings['bbdkp_user_alimit'], true); set_config('bbdkp_active_point_adj', $settings['bbdkp_active_point_adj'], true); set_config('bbdkp_inactive_point_adj', $settings['bbdkp_inactive_point_adj'], true); set_config('bbdkp_starting_dkp', $settings['bbdkp_starting_dkp'], true); //items set_config('bbdkp_user_ilimit', $settings['bbdkp_user_ilimit'], true); //raids set_config('bbdkp_user_rlimit', $settings['bbdkp_user_rlimit'], true); // reg id set_config('bbdkp_regid', 1, true); $cache->destroy('config'); // // Logging // $log_action = array('header' => 'L_ACTION_SETTINGS_CHANGED', 'L_SETTINGS' => json_encode($settings)); $this->log_insert(array('log_type' => 'L_ACTION_SETTINGS_CHANGED', 'log_action' => $log_action)); trigger_error($user->lang['ACTION_SETTINGS_CHANGED'] . $link, E_USER_NOTICE); break; case 'register': $regdata = array('domainname' => request_var('domainname', ''), 'phpbbversion' => request_var('phpbbversion', ''), 'bbdkpversion' => request_var('bbdkpversion', '')); $this->post_register_request($regdata); } $s_lang_options = ''; foreach ($this->languagecodes as $lang => $langname) { $selected = $config['bbdkp_lang'] == $lang ? ' selected="selected"' : ''; $s_lang_options .= '<option value="' . $lang . '" ' . $selected . '> ' . $langname . '</option>'; } $template->assign_block_vars('hide_row', array('VALUE' => "YES", 'SELECTED' => $config['bbdkp_hide_inactive'] == 1 ? ' selected="selected"' : '', 'OPTION' => "YES")); $template->assign_block_vars('hide_row', array('VALUE' => "NO", 'SELECTED' => $config['bbdkp_hide_inactive'] == 0 ? ' selected="selected"' : '', 'OPTION' => "NO")); // Default Region foreach ($this->regions as $regionid => $regionvalue) { $template->assign_block_vars('region_row', array('VALUE' => $regionid, 'SELECTED' => $regionid == $config['bbdkp_default_region'] ? ' selected="selected"' : '', 'OPTION' => $regionvalue)); } //roster layout $rosterlayoutlist = array(0 => $user->lang['ARM_STAND'], 1 => $user->lang['ARM_CLASS']); foreach ($rosterlayoutlist as $lid => $lname) { $template->assign_block_vars('rosterlayout_row', array('VALUE' => $lid, 'SELECTED' => $lid == $config['bbdkp_roster_layout'] ? ' selected="selected"' : '', 'OPTION' => $lname)); } $template->assign_vars(array('S_LANG_OPTIONS' => $s_lang_options, 'REALM' => $config['bbdkp_default_realm'], 'EQDKP_START_DD' => date('d', $config['bbdkp_eqdkp_start']), 'EQDKP_START_MM' => date('m', $config['bbdkp_eqdkp_start']), 'EQDKP_START_YY' => date('Y', $config['bbdkp_eqdkp_start']), 'DATE_FORMAT' => $config['bbdkp_date_format'], 'DKP_NAME' => $config['bbdkp_dkp_name'], 'DEFAULT_GAME' => count($this->games) > 0 ? implode(", ", $this->games) : $user->lang['NA'], 'HIDE_INACTIVE_YES_CHECKED' => $config['bbdkp_hide_inactive'] == '1' ? ' checked="checked"' : '', 'HIDE_INACTIVE_NO_CHECKED' => $config['bbdkp_hide_inactive'] == '0' ? ' checked="checked"' : '', 'USER_ELIMIT' => $config['bbdkp_user_elimit'], 'EVENT_VIEWALL_YES_CHECKED' => $config['bbdkp_event_viewall'] == '1' ? ' checked="checked"' : '', 'EVENT_VIEWALL_NO_CHECKED' => $config['bbdkp_event_viewall'] == '0' ? ' checked="checked"' : '', 'USER_NLIMIT' => $config['bbdkp_user_nlimit'], 'INACTIVE_PERIOD' => $config['bbdkp_inactive_period'], 'LIST_P1' => $config['bbdkp_list_p1'], 'LIST_P2' => $config['bbdkp_list_p2'], 'LIST_P3' => $config['bbdkp_list_p3'], 'F_SHOWACHIEV' => $config['bbdkp_show_achiev'], 'USER_ALIMIT' => $config['bbdkp_user_alimit'], 'STARTING_DKP' => $config['bbdkp_starting_dkp'], 'INACTIVE_POINT' => $config['bbdkp_inactive_point_adj'], 'ACTIVE_POINT' => $config['bbdkp_active_point_adj'], 'USER_ILIMIT' => $config['bbdkp_user_ilimit'], 'USER_RLIMIT' => $config['bbdkp_user_rlimit'], 'MAXCHARS' => $config['bbdkp_maxchars'], 'USER_LLIMIT' => $config['bbdkp_user_llimit'], 'MINLEVEL' => $config['bbdkp_minrosterlvl'], 'U_REGISTER' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp&mode=dkp_config&action=register"), 'U_ADDCONFIG' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp&mode=dkp_config&action=addconfig"), 'DOMAINNAME' => $_SERVER['HTTP_HOST'], 'PHPBBVER' => $config['version'], 'BBDKPVER' => $config['bbdkp_version'], 'REGID' => isset($config['bbdkp_regid']) ? $config['bbdkp_regid'] : '', 'S_BBDKPREGISTERED' => isset($config['bbdkp_regid']) ? $config['bbdkp_regid'] : '')); add_form_key('acp_dkp'); $this->page_title = 'ACP_DKP_CONFIG'; $this->tpl_name = 'dkp/acp_' . $mode; break; /** * PORTAL CONFIG */ /** * PORTAL CONFIG */ case 'dkp_indexpageconfig': $submit = isset($_POST['update']) ? true : false; if ($submit) { if (!check_form_key('acp_dkp_portal')) { trigger_error($user->lang['FV_FORMVALIDATION'], E_USER_WARNING); } if (isset($config['bbdkp_gameworld_version'])) { set_config('bbdkp_portal_bossprogress', request_var('show_bosspblock', 0), true); } set_config('bbdkp_news_forumid', request_var('news_id', 0), true); set_config('bbdkp_n_news', request_var('n_news', 0), true); set_config('bbdkp_n_items', request_var('n_items', 0), true); set_config('bbdkp_recruitment', request_var('bbdkp_recruitment', 0), true); set_config('bbdkp_portal_loot', request_var('show_lootblock', 0), true); set_config('bbdkp_portal_recruitment', request_var('show_recrblock', 0), true); set_config('bbdkp_portal_links', request_var('show_linkblock', 0), true); set_config('bbdkp_portal_menu', request_var('show_menublock', 0), true); set_config('bbdkp_portal_welcomemsg', request_var('show_welcomeblock', 0), true); set_config('bbdkp_portal_recent', request_var('show_recenttopics', 0), true); set_config('bbdkp_portal_rtlen', request_var('n_rclength', 0), true); set_config('bbdkp_portal_rtno', request_var('n_rcno', 0), true); set_config('bbdkp_portal_newmembers', request_var('show_newmembers', 0), true); set_config('bbdkp_portal_maxnewmembers', request_var('num_newmembers', 0), true); set_config('bbdkp_portal_whoisonline', request_var('show_onlineblock', 0), true); set_config('bbdkp_portal_onlineblockposition', request_var('onlineblockposition', 0), true); $cache->destroy('config'); $welcometext = utf8_normalize_nfc(request_var('welcome_message', '', true)); $uid = $bitfield = $options = ''; // will be modified by generate_text_for_storage $allow_bbcode = $allow_urls = $allow_smilies = true; generate_text_for_storage($welcometext, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies); $sql = 'UPDATE ' . WELCOME_MSG_TABLE . " SET\n\t\t\t\t\t\t\twelcome_msg = '" . (string) $db->sql_escape($welcometext) . "' ,\n\t\t\t\t\t\t\twelcome_timestamp = " . (int) time() . " ,\n\t\t\t\t\t\t\tbbcode_bitfield = \t'" . (string) $bitfield . "' ,\n\t\t\t\t\t\t\tbbcode_uid = \t\t'" . (string) $uid . "'\n\t\t\t\t\t\t\tWHERE welcome_id = 1"; $db->sql_query($sql); trigger_error($user->lang['ADMIN_PORTAL_SETTINGS_SAVED'] . $link, E_USER_NOTICE); } // get welcome msg $sql = 'SELECT welcome_msg, bbcode_bitfield, bbcode_uid FROM ' . WELCOME_MSG_TABLE; $db->sql_query($sql); $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $welcometext = $row['welcome_msg']; $bitfield = $row['bbcode_bitfield']; $uid = $row['bbcode_uid']; } $textarr = generate_text_for_edit($welcometext, $uid, $bitfield, 7); // number of news and items to show on front page $n_news = $config['bbdkp_n_news']; $n_items = $config['bbdkp_n_items']; add_form_key('acp_dkp_portal'); if (isset($config['bbdkp_gameworld_version'])) { $template->assign_vars(array('S_BP_SHOW' => true, 'SHOW_BOSS_YES_CHECKED' => $config['bbdkp_portal_bossprogress'] == '1' ? ' checked="checked"' : '', 'SHOW_BOSS_NO_CHECKED' => $config['bbdkp_portal_bossprogress'] == '0' ? ' checked="checked"' : '')); } else { $template->assign_var('S_BP_SHOW', false); } $template->assign_vars(array('WELCOME_MESSAGE' => $textarr['text'], 'N_NEWS' => $n_news, 'FORUM_NEWS_OPTIONS' => make_forum_select($config['bbdkp_news_forumid'], false, false, true), 'SHOW_WELCOME_YES_CHECKED' => $config['bbdkp_portal_welcomemsg'] == '1' ? 'checked="checked"' : '', 'SHOW_WELCOME_NO_CHECKED' => $config['bbdkp_portal_welcomemsg'] == '0' ? 'checked="checked"' : '', 'SHOW_ONLINE_YES_CHECKED' => $config['bbdkp_portal_whoisonline'] == '1' ? 'checked="checked"' : '', 'SHOW_ONLINE_NO_CHECKED' => $config['bbdkp_portal_whoisonline'] == '0' ? 'checked="checked"' : '', 'SHOW_ONLINE_BOTTOM_CHECKED' => $config['bbdkp_portal_onlineblockposition'] == '1' ? 'checked="checked"' : '', 'SHOW_ONLINE_SIDE_CHECKED' => $config['bbdkp_portal_onlineblockposition'] == '0' ? 'checked="checked"' : '', 'SHOW_REC_YES_CHECKED' => $config['bbdkp_portal_recruitment'] == '1' ? ' checked="checked"' : '', 'SHOW_REC_NO_CHECKED' => $config['bbdkp_portal_recruitment'] == '0' ? ' checked="checked"' : '', 'SHOW_LOOT_YES_CHECKED' => $config['bbdkp_portal_loot'] == '1' ? ' checked="checked"' : '', 'SHOW_LOOT_NO_CHECKED' => $config['bbdkp_portal_loot'] == '0' ? ' checked="checked"' : '', 'N_ITEMS' => $n_items, 'N_RTNO' => $config['bbdkp_portal_rtno'], 'N_RTLENGTH' => $config['bbdkp_portal_rtlen'], 'SHOW_RT_YES_CHECKED' => $config['bbdkp_portal_recent'] == '1' ? ' checked="checked"' : '', 'SHOW_RT_NO_CHECKED' => $config['bbdkp_portal_recent'] == '0' ? ' checked="checked"' : '', 'SHOW_LINK_YES_CHECKED' => $config['bbdkp_portal_links'] == '1' ? ' checked="checked"' : '', 'SHOW_LINK_NO_CHECKED' => $config['bbdkp_portal_links'] == '0' ? ' checked="checked"' : '', 'SHOW_MENU_YES_CHECKED' => $config['bbdkp_portal_menu'] == '1' ? ' checked="checked"' : '', 'SHOW_MENU_NO_CHECKED' => $config['bbdkp_portal_menu'] == '0' ? ' checked="checked"' : '', 'SHOW_NEWM_YES_CHECKED' => $config['bbdkp_portal_newmembers'] == '1' ? ' checked="checked"' : '', 'SHOW_NEWM_NO_CHECKED' => $config['bbdkp_portal_newmembers'] == '0' ? ' checked="checked"' : '', 'N_NUMNEWM' => $config['bbdkp_portal_maxnewmembers'])); $this->page_title = $user->lang['ACP_INDEXPAGE']; $this->tpl_name = 'dkp/acp_' . $mode; break; /** * DKP LOGS * **/ /** * DKP LOGS * **/ case 'dkp_logs': $this->page_title = 'ACP_DKP_LOGS'; $this->tpl_name = 'dkp/acp_' . $mode; $logs = \bbdkp\admin\log::Instance(); $log_id = isset($_GET[URI_LOG]) ? request_var(URI_LOG, 0) : false; $search = isset($_GET['search']) ? true : false; if ($log_id) { $action = 'view'; } else { $action = 'list'; } switch ($action) { case 'list': $deletemark = isset($_POST['delmarked']) ? true : false; $marked = request_var('mark', array(0)); $search_term = request_var('search', ''); $start = request_var('start', 0); if ($deletemark) { global $db, $user, $phpEx; //if marked array isnt empty if (sizeof($marked) && is_array($marked)) { if (confirm_box(true)) { $marked = request_var('mark', array(0)); $logs = \bbdkp\admin\log::Instance(); $log_action = array('header' => 'L_ACTION_LOG_DELETED', 'L_ADDED_BY' => $user->data['username'], 'L_LOG_ID' => implode(",", $logs->delete_log($marked))); $this->log_insert(array('log_type' => $log_action['header'], 'log_action' => $log_action)); //redirect to listing $meta_info = append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp&mode=dkp_logs"); meta_refresh(3, $meta_info); $message = '<a href="' . append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp&mode=dkp_logs") . '">' . $user->lang['RETURN_LOG'] . '</a><br />' . sprintf($user->lang['ADMIN_LOG_DELETE_SUCCESS'], implode($marked)); trigger_error($message, E_USER_WARNING); } else { // display confirmation confirm_box(false, $user->lang['CONFIRM_DELETE_BBDKPLOG'], build_hidden_fields(array('delmarked' => true, 'mark' => $marked))); } // they hit no $message = '<a href="' . append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp&mode=dkp_logs") . '">' . $user->lang['RETURN_LOG'] . '</a><br />' . sprintf($user->lang['ADMIN_LOG_DELETE_FAIL'], implode($marked)); trigger_error($message, E_USER_WARNING); } } $sort_order = array(0 => array('log_id desc', 'log_id'), 1 => array('log_date desc', 'log_date'), 2 => array('log_type', 'log_type desc'), 3 => array('username', 'username dsec'), 4 => array('log_ipaddress', 'log_ipaddress desc'), 5 => array('log_result', 'log_result desc')); $current_order = $this->switch_order($sort_order); $verbose = true; $listlogs = $logs->read_log($current_order['sql'], $search, $verbose, $search_term, $start); foreach ($listlogs as $key => $log) { $template->assign_block_vars('logs_row', array('ID' => $log['log_id'], 'DATE' => $log['datestamp'], 'TYPE' => $log['log_type'], 'U_VIEW_LOG' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp&mode=dkp_logs&" . URI_LOG . '=' . $log['log_id'] . '&search=' . $search_term . '&start=' . $start . '&'), 'VERBOSE' => $verbose, 'USER' => $log['username'], 'ACTION' => $log['log_line'], 'IP' => $log['log_ipaddress'], 'RESULT' => $log['log_result'], 'C_RESULT' => $log['cssresult'], 'ENCODED_TYPE' => urlencode($log['log_type']), 'ENCODED_USER' => urlencode($log['username']), 'ENCODED_IP' => urlencode($log['log_ipaddress']))); } $logcount = $logs->getTotalLogs(); $template->assign_vars(array('S_LIST' => true, 'L_TITLE' => $user->lang['ACP_DKP_LOGS'], 'L_EXPLAIN' => $user->lang['ACP_DKP_LOGS_EXPLAIN'], 'O_DATE' => $current_order['uri'][0], 'O_TYPE' => $current_order['uri'][1], 'O_USER' => $current_order['uri'][2], 'O_IP' => $current_order['uri'][3], 'O_RESULT' => $current_order['uri'][4], 'U_LOGS' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp&mode=dkp_logs&") . '&search=' . $search_term . '&start=' . $start . '&', 'U_LOGS_SEARCH' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp&mode=dkp_logs"), 'CURRENT_ORDER' => $current_order['uri']['current'], 'START' => $start, 'VIEWLOGS_FOOTCOUNT' => sprintf($user->lang['VIEWLOGS_FOOTCOUNT'], $logcount, USER_LLIMIT), 'VIEWLOGS_PAGINATION' => generate_pagination(append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp&mode=dkp_logs&") . '&search=' . $search_term . '&o=' . $current_order['uri']['current'], $logcount, USER_LLIMIT, $start))); break; case 'view': $viewlog = $logs->get_logentry($log_id); $log_actionxml = $viewlog['log_action']; $search_term = request_var('search', ''); $start = request_var('start', 0); $log_action = (array) simplexml_load_string($log_actionxml); // loop the action elements and fill template foreach ($log_action as $key => $value) { switch (strtolower($key)) { case 'usercolour': case 'id': break; case 'header': if (in_array($log_action['header'], $logs::$valid_action_types)) { $log_actionstr = $logs->getLogMessage($log_action['header'], false); } break; default: $template->assign_block_vars('logaction_row', array('KEY' => isset($user->lang[$key]) ? $user->lang[$key] . ': ' : $key, 'VALUE' => $value)); } } // fill constant template elements $template->assign_vars(array('S_LIST' => false, 'L_TITLE' => $user->lang['ACP_DKP_LOGS'], 'L_EXPLAIN' => $user->lang['ACP_DKP_LOGS_EXPLAIN'], 'LOG_DATE' => !empty($viewlog['log_date']) ? $user->format_date($viewlog['log_date']) : ' ', 'LOG_USERNAME' => $viewlog['colouruser'], 'LOG_IP_ADDRESS' => $viewlog['log_ipaddress'], 'LOG_SESSION_ID' => $viewlog['log_sid'], 'LOG_RESULT' => $viewlog['log_result'], 'LOG_ACTION' => $log_actionstr)); break; } $template->assign_vars(array('U_BACK' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp&mode=dkp_logs&") . '&search=' . $search_term . '&start=' . $start . '&')); break; } }
function main($id, $mode) { global $db, $user, $auth, $template, $cache; global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; include_once $phpbb_root_path . 'includes/functions_user.' . $phpEx; include_once $phpbb_root_path . 'includes/acp/auth.' . $phpEx; $auth_admin = new auth_admin(); $user->add_lang('acp/permissions'); add_permission_language(); $this->tpl_name = 'acp_permissions'; // Trace has other vars if ($mode == 'trace') { $user_id = request_var('u', 0); $forum_id = request_var('f', 0); $permission = request_var('auth', ''); $this->tpl_name = 'permission_trace'; if ($user_id && isset($auth_admin->acl_options['id'][$permission]) && $auth->acl_get('a_viewauth')) { $this->page_title = sprintf($user->lang['TRACE_PERMISSION'], $user->lang['acl_' . $permission]['lang']); $this->permission_trace($user_id, $forum_id, $permission); return; } trigger_error('NO_MODE', E_USER_ERROR); } // Set some vars $action = request_var('action', array('' => 0)); $action = key($action); $action = isset($_POST['psubmit']) ? 'apply_permissions' : $action; $all_forums = request_var('all_forums', 0); $subforum_id = request_var('subforum_id', 0); $forum_id = request_var('forum_id', array(0)); $username = request_var('username', array(''), true); $usernames = request_var('usernames', '', true); $user_id = request_var('user_id', array(0)); $group_id = request_var('group_id', array(0)); $select_all_groups = request_var('select_all_groups', 0); $form_name = 'acp_permissions'; add_form_key($form_name); // If select all groups is set, we pre-build the group id array (this option is used for other screens to link to the permission settings screen) if ($select_all_groups) { // Add default groups to selection $sql_and = !$config['coppa_enable'] ? " AND group_name <> 'REGISTERED_COPPA'" : ''; $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . ' WHERE group_type = ' . GROUP_SPECIAL . "\n\t\t\t\t{$sql_and}"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $group_id[] = $row['group_id']; } $db->sql_freeresult($result); } // Map usernames to ids and vice versa if ($usernames) { $username = explode("\n", $usernames); } unset($usernames); if (sizeof($username) && !sizeof($user_id)) { user_get_id_name($user_id, $username); if (!sizeof($user_id)) { trigger_error($user->lang['SELECTED_USER_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING); } } unset($username); // Build forum ids (of all forums are checked or subforum listing used) if ($all_forums) { $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . ' ORDER BY left_id'; $result = $db->sql_query($sql); $forum_id = array(); while ($row = $db->sql_fetchrow($result)) { $forum_id[] = (int) $row['forum_id']; } $db->sql_freeresult($result); } else { if ($subforum_id) { $forum_id = array(); foreach (get_forum_branch($subforum_id, 'children') as $row) { $forum_id[] = (int) $row['forum_id']; } } } // Define some common variables for every mode $error = array(); $permission_scope = strpos($mode, '_global') !== false ? 'global' : 'local'; // Showing introductionary page? if ($mode == 'intro') { $this->page_title = 'ACP_PERMISSIONS'; $template->assign_vars(array('S_INTRO' => true)); return; } switch ($mode) { case 'setting_user_global': case 'setting_group_global': $this->permission_dropdown = array('u_', 'm_', 'a_'); $permission_victim = $mode == 'setting_user_global' ? array('user') : array('group'); $this->page_title = $mode == 'setting_user_global' ? 'ACP_USERS_PERMISSIONS' : 'ACP_GROUPS_PERMISSIONS'; break; case 'setting_user_local': case 'setting_group_local': $this->permission_dropdown = array('f_', 'm_'); $permission_victim = $mode == 'setting_user_local' ? array('user', 'forums') : array('group', 'forums'); $this->page_title = $mode == 'setting_user_local' ? 'ACP_USERS_FORUM_PERMISSIONS' : 'ACP_GROUPS_FORUM_PERMISSIONS'; break; case 'setting_admin_global': case 'setting_mod_global': $this->permission_dropdown = strpos($mode, '_admin_') !== false ? array('a_') : array('m_'); $permission_victim = array('usergroup'); $this->page_title = $mode == 'setting_admin_global' ? 'ACP_ADMINISTRATORS' : 'ACP_GLOBAL_MODERATORS'; break; case 'setting_mod_local': case 'setting_forum_local': $this->permission_dropdown = $mode == 'setting_mod_local' ? array('m_') : array('f_'); $permission_victim = array('forums', 'usergroup'); $this->page_title = $mode == 'setting_mod_local' ? 'ACP_FORUM_MODERATORS' : 'ACP_FORUM_PERMISSIONS'; break; case 'view_admin_global': case 'view_user_global': case 'view_mod_global': $this->permission_dropdown = $mode == 'view_admin_global' ? array('a_') : ($mode == 'view_user_global' ? array('u_') : array('m_')); $permission_victim = array('usergroup_view'); $this->page_title = $mode == 'view_admin_global' ? 'ACP_VIEW_ADMIN_PERMISSIONS' : ($mode == 'view_user_global' ? 'ACP_VIEW_USER_PERMISSIONS' : 'ACP_VIEW_GLOBAL_MOD_PERMISSIONS'); break; case 'view_mod_local': case 'view_forum_local': $this->permission_dropdown = $mode == 'view_mod_local' ? array('m_') : array('f_'); $permission_victim = array('forums', 'usergroup_view'); $this->page_title = $mode == 'view_mod_local' ? 'ACP_VIEW_FORUM_MOD_PERMISSIONS' : 'ACP_VIEW_FORUM_PERMISSIONS'; break; default: trigger_error('NO_MODE', E_USER_ERROR); break; } $template->assign_vars(array('L_TITLE' => $user->lang[$this->page_title], 'L_EXPLAIN' => $user->lang[$this->page_title . '_EXPLAIN'])); // Get permission type $permission_type = request_var('type', $this->permission_dropdown[0]); if (!in_array($permission_type, $this->permission_dropdown)) { trigger_error($user->lang['WRONG_PERMISSION_TYPE'] . adm_back_link($this->u_action), E_USER_WARNING); } // Handle actions if (strpos($mode, 'setting_') === 0 && $action) { switch ($action) { case 'delete': if (!check_form_key($form_name)) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); } // All users/groups selected? $all_users = isset($_POST['all_users']) ? true : false; $all_groups = isset($_POST['all_groups']) ? true : false; if ($all_users || $all_groups) { $items = $this->retrieve_defined_user_groups($permission_scope, $forum_id, $permission_type); if ($all_users && sizeof($items['user_ids'])) { $user_id = $items['user_ids']; } else { if ($all_groups && sizeof($items['group_ids'])) { $group_id = $items['group_ids']; } } } if (sizeof($user_id) || sizeof($group_id)) { $this->remove_permissions($mode, $permission_type, $auth_admin, $user_id, $group_id, $forum_id); } else { trigger_error($user->lang['NO_USER_GROUP_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING); } break; case 'apply_permissions': if (!isset($_POST['setting'])) { trigger_error($user->lang['NO_AUTH_SETTING_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); } if (!check_form_key($form_name)) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); } $this->set_permissions($mode, $permission_type, $auth_admin, $user_id, $group_id); break; case 'apply_all_permissions': if (!isset($_POST['setting'])) { trigger_error($user->lang['NO_AUTH_SETTING_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); } if (!check_form_key($form_name)) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); } $this->set_all_permissions($mode, $permission_type, $auth_admin, $user_id, $group_id); break; } } // Setting permissions screen $s_hidden_fields = build_hidden_fields(array('user_id' => $user_id, 'group_id' => $group_id, 'forum_id' => $forum_id, 'type' => $permission_type)); // Go through the screens/options needed and present them in correct order foreach ($permission_victim as $victim) { switch ($victim) { case 'forum_dropdown': if (sizeof($forum_id)) { $this->check_existence('forum', $forum_id); continue 2; } $template->assign_vars(array('S_SELECT_FORUM' => true, 'S_FORUM_OPTIONS' => make_forum_select(false, false, true, false, false))); break; case 'forums': if (sizeof($forum_id)) { $this->check_existence('forum', $forum_id); continue 2; } $forum_list = make_forum_select(false, false, true, false, false, false, true); // Build forum options $s_forum_options = ''; foreach ($forum_list as $f_id => $f_row) { $s_forum_options .= '<option value="' . $f_id . '"' . ($f_row['selected'] ? ' selected="selected"' : '') . ($f_row['disabled'] ? ' disabled="disabled" class="disabled-option"' : '') . '>' . $f_row['padding'] . $f_row['forum_name'] . '</option>'; } // Build subforum options $s_subforum_options = $this->build_subforum_options($forum_list); $template->assign_vars(array('S_SELECT_FORUM' => true, 'S_FORUM_OPTIONS' => $s_forum_options, 'S_SUBFORUM_OPTIONS' => $s_subforum_options, 'S_FORUM_ALL' => true, 'S_FORUM_MULTIPLE' => true)); break; case 'user': if (sizeof($user_id)) { $this->check_existence('user', $user_id); continue 2; } $template->assign_vars(array('S_SELECT_USER' => true, 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=searchuser&form=select_victim&field=username&select_single=true'))); break; case 'group': if (sizeof($group_id)) { $this->check_existence('group', $group_id); continue 2; } $template->assign_vars(array('S_SELECT_GROUP' => true, 'S_GROUP_OPTIONS' => group_select_options(false, false, false))); break; case 'usergroup': case 'usergroup_view': $all_users = isset($_POST['all_users']) ? true : false; $all_groups = isset($_POST['all_groups']) ? true : false; if (sizeof($user_id) && !$all_users || sizeof($group_id) && !$all_groups) { if (sizeof($user_id)) { $this->check_existence('user', $user_id); } if (sizeof($group_id)) { $this->check_existence('group', $group_id); } continue 2; } // Now we check the users... because the "all"-selection is different here (all defined users/groups) $items = $this->retrieve_defined_user_groups($permission_scope, $forum_id, $permission_type); if ($all_users && sizeof($items['user_ids'])) { $user_id = $items['user_ids']; continue 2; } if ($all_groups && sizeof($items['group_ids'])) { $group_id = $items['group_ids']; continue 2; } $template->assign_vars(array('S_SELECT_USERGROUP' => $victim == 'usergroup' ? true : false, 'S_SELECT_USERGROUP_VIEW' => $victim == 'usergroup_view' ? true : false, 'S_DEFINED_USER_OPTIONS' => $items['user_ids_options'], 'S_DEFINED_GROUP_OPTIONS' => $items['group_ids_options'], 'S_ADD_GROUP_OPTIONS' => group_select_options(false, $items['group_ids'], false), 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=searchuser&form=add_user&field=username&select_single=true'))); break; } // The S_ALLOW_SELECT parameter below is a measure to lower memory usage. // If there are more than 5 forums selected the admin is not able to select all users/groups too. // We need to see if the number of forums can be increased or need to be decreased. $template->assign_vars(array('U_ACTION' => $this->u_action, 'ANONYMOUS_USER_ID' => ANONYMOUS, 'S_SELECT_VICTIM' => true, 'S_ALLOW_ALL_SELECT' => sizeof($forum_id) > 5 ? false : true, 'S_CAN_SELECT_USER' => $auth->acl_get('a_authusers') ? true : false, 'S_CAN_SELECT_GROUP' => $auth->acl_get('a_authgroups') ? true : false, 'S_HIDDEN_FIELDS' => $s_hidden_fields)); // Let the forum names being displayed if (sizeof($forum_id)) { $sql = 'SELECT forum_name FROM ' . FORUMS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_id) . ' ORDER BY left_id ASC'; $result = $db->sql_query($sql); $forum_names = array(); while ($row = $db->sql_fetchrow($result)) { $forum_names[] = $row['forum_name']; } $db->sql_freeresult($result); $template->assign_vars(array('S_FORUM_NAMES' => sizeof($forum_names) ? true : false, 'FORUM_NAMES' => implode(', ', $forum_names))); } return; } // Do not allow forum_ids being set and no other setting defined (will bog down the server too much) if (sizeof($forum_id) && !sizeof($user_id) && !sizeof($group_id)) { trigger_error($user->lang['ONLY_FORUM_DEFINED'] . adm_back_link($this->u_action), E_USER_WARNING); } $template->assign_vars(array('S_PERMISSION_DROPDOWN' => sizeof($this->permission_dropdown) > 1 ? $this->build_permission_dropdown($this->permission_dropdown, $permission_type, $permission_scope) : false, 'L_PERMISSION_TYPE' => $user->lang['ACL_TYPE_' . strtoupper($permission_type)], 'U_ACTION' => $this->u_action, 'S_HIDDEN_FIELDS' => $s_hidden_fields)); if (strpos($mode, 'setting_') === 0) { $template->assign_vars(array('S_SETTING_PERMISSIONS' => true)); $hold_ary = $auth_admin->get_mask('set', sizeof($user_id) ? $user_id : false, sizeof($group_id) ? $group_id : false, sizeof($forum_id) ? $forum_id : false, $permission_type, $permission_scope, ACL_NO); $auth_admin->display_mask('set', $permission_type, $hold_ary, sizeof($user_id) ? 'user' : 'group', $permission_scope == 'local' ? true : false); } else { $template->assign_vars(array('S_VIEWING_PERMISSIONS' => true)); $hold_ary = $auth_admin->get_mask('view', sizeof($user_id) ? $user_id : false, sizeof($group_id) ? $group_id : false, sizeof($forum_id) ? $forum_id : false, $permission_type, $permission_scope, ACL_NEVER); $auth_admin->display_mask('view', $permission_type, $hold_ary, sizeof($user_id) ? 'user' : 'group', $permission_scope == 'local' ? true : false); } }
function main($id, $mode) { global $config, $db, $user, $auth, $template; global $phpbb_root_path, $phpbb_admin_path, $phpEx; global $phpbb_dispatcher, $request; global $phpbb_container, $phpbb_log; $user->add_lang(array('posting', 'ucp', 'acp/users')); $this->tpl_name = 'acp_users'; $error = array(); $username = $request->variable('username', '', true); $user_id = $request->variable('u', 0); $action = $request->variable('action', ''); // Get referer to redirect user to the appropriate page after delete action $redirect = $request->variable('redirect', ''); $redirect_tag = "redirect={$redirect}"; $redirect_url = append_sid("{$phpbb_admin_path}index.{$phpEx}", "i={$redirect}"); $submit = isset($_POST['update']) && !isset($_POST['cancel']) ? true : false; $form_name = 'acp_users'; add_form_key($form_name); // Whois (special case) if ($action == 'whois') { if (!function_exists('user_get_id_name')) { include $phpbb_root_path . 'includes/functions_user.' . $phpEx; } $this->page_title = 'WHOIS'; $this->tpl_name = 'simple_body'; $user_ip = phpbb_ip_normalise($request->variable('user_ip', '')); $domain = gethostbyaddr($user_ip); $ipwhois = user_ipwhois($user_ip); $template->assign_vars(array('MESSAGE_TITLE' => sprintf($user->lang['IP_WHOIS_FOR'], $domain), 'MESSAGE_TEXT' => nl2br($ipwhois))); return; } // Show user selection mask if (!$username && !$user_id) { $this->page_title = 'SELECT_USER'; $template->assign_vars(array('U_ACTION' => $this->u_action, 'ANONYMOUS_USER_ID' => ANONYMOUS, 'S_SELECT_USER' => true, 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=searchuser&form=select_user&field=username&select_single=true'))); return; } if (!$user_id) { $sql = 'SELECT user_id FROM ' . USERS_TABLE . "\n\t\t\t\tWHERE username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'"; $result = $db->sql_query($sql); $user_id = (int) $db->sql_fetchfield('user_id'); $db->sql_freeresult($result); if (!$user_id) { trigger_error($user->lang['NO_USER'] . adm_back_link($this->u_action), E_USER_WARNING); } } // Generate content for all modes $sql = 'SELECT u.*, s.* FROM ' . USERS_TABLE . ' u LEFT JOIN ' . SESSIONS_TABLE . ' s ON (s.session_user_id = u.user_id) WHERE u.user_id = ' . $user_id . ' ORDER BY s.session_time DESC'; $result = $db->sql_query_limit($sql, 1); $user_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$user_row) { trigger_error($user->lang['NO_USER'] . adm_back_link($this->u_action), E_USER_WARNING); } // Generate overall "header" for user admin $s_form_options = ''; // Build modes dropdown list $sql = 'SELECT module_mode, module_auth FROM ' . MODULES_TABLE . "\n\t\t\tWHERE module_basename = 'acp_users'\n\t\t\t\tAND module_enabled = 1\n\t\t\t\tAND module_class = 'acp'\n\t\t\tORDER BY left_id, module_mode"; $result = $db->sql_query($sql); $dropdown_modes = array(); while ($row = $db->sql_fetchrow($result)) { if (!$this->p_master->module_auth_self($row['module_auth'])) { continue; } $dropdown_modes[$row['module_mode']] = true; } $db->sql_freeresult($result); foreach ($dropdown_modes as $module_mode => $null) { $selected = $mode == $module_mode ? ' selected="selected"' : ''; $s_form_options .= '<option value="' . $module_mode . '"' . $selected . '>' . $user->lang['ACP_USER_' . strtoupper($module_mode)] . '</option>'; } $template->assign_vars(array('U_BACK' => empty($redirect) ? $this->u_action : $redirect_url, 'U_MODE_SELECT' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i={$id}&u={$user_id}"), 'U_ACTION' => $this->u_action . '&u=' . $user_id . (empty($redirect) ? '' : '&' . $redirect_tag), 'S_FORM_OPTIONS' => $s_form_options, 'MANAGED_USERNAME' => $user_row['username'])); // Prevent normal users/admins change/view founders if they are not a founder by themselves if ($user->data['user_type'] != USER_FOUNDER && $user_row['user_type'] == USER_FOUNDER) { trigger_error($user->lang['NOT_MANAGE_FOUNDER'] . adm_back_link($this->u_action), E_USER_WARNING); } $this->page_title = $user_row['username'] . ' :: ' . $user->lang('ACP_USER_' . strtoupper($mode)); switch ($mode) { case 'overview': if (!function_exists('user_get_id_name')) { include $phpbb_root_path . 'includes/functions_user.' . $phpEx; } $user->add_lang('acp/ban'); $delete = $request->variable('delete', 0); $delete_type = $request->variable('delete_type', ''); $ip = $request->variable('ip', 'ip'); /** * Run code at beginning of ACP users overview * * @event core.acp_users_overview_before * @var array user_row Current user data * @var string mode Active module * @var string action Module that should be run * @var bool submit Do we display the form only * or did the user press submit * @var array error Array holding error messages * @since 3.1.3-RC1 */ $vars = array('user_row', 'mode', 'action', 'submit', 'error'); extract($phpbb_dispatcher->trigger_event('core.acp_users_overview_before', compact($vars))); if ($submit) { if ($delete) { if (!$auth->acl_get('a_userdel')) { send_status_line(403, 'Forbidden'); trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } // Check if the user wants to remove himself or the guest user account if ($user_id == ANONYMOUS) { trigger_error($user->lang['CANNOT_REMOVE_ANONYMOUS'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } // Founders can not be deleted. if ($user_row['user_type'] == USER_FOUNDER) { trigger_error($user->lang['CANNOT_REMOVE_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if ($user_id == $user->data['user_id']) { trigger_error($user->lang['CANNOT_REMOVE_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if ($delete_type) { if (confirm_box(true)) { user_delete($delete_type, $user_id, $user_row['username']); $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_DELETED', false, array($user_row['username'])); trigger_error($user->lang['USER_DELETED'] . adm_back_link(empty($redirect) ? $this->u_action : $redirect_url)); } else { $delete_confirm_hidden_fields = array('u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'update' => true, 'delete' => 1, 'delete_type' => $delete_type); // Checks if the redirection page is specified if (!empty($redirect)) { $delete_confirm_hidden_fields['redirect'] = $redirect; } confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($delete_confirm_hidden_fields)); } } else { trigger_error($user->lang['NO_MODE'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } } // Handle quicktool actions switch ($action) { case 'banuser': case 'banemail': case 'banip': if ($user_id == $user->data['user_id']) { trigger_error($user->lang['CANNOT_BAN_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if ($user_id == ANONYMOUS) { trigger_error($user->lang['CANNOT_BAN_ANONYMOUS'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if ($user_row['user_type'] == USER_FOUNDER) { trigger_error($user->lang['CANNOT_BAN_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if (!check_form_key($form_name)) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } $ban = array(); switch ($action) { case 'banuser': $ban[] = $user_row['username']; $reason = 'USER_ADMIN_BAN_NAME_REASON'; break; case 'banemail': $ban[] = $user_row['user_email']; $reason = 'USER_ADMIN_BAN_EMAIL_REASON'; break; case 'banip': $ban[] = $user_row['user_ip']; $sql = 'SELECT DISTINCT poster_ip FROM ' . POSTS_TABLE . "\n\t\t\t\t\t\t\t\t\t\tWHERE 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'; break; } $ban_reason = $request->variable('ban_reason', $user->lang[$reason], true); $ban_give_reason = $request->variable('ban_give_reason', '', true); // Log not used at the moment, we simply utilize the ban function. $result = user_ban(substr($action, 3), $ban, 0, 0, 0, $ban_reason, $ban_give_reason); trigger_error(($result === false ? $user->lang['BAN_ALREADY_ENTERED'] : $user->lang['BAN_SUCCESSFUL']) . adm_back_link($this->u_action . '&u=' . $user_id)); break; case 'reactivate': if ($user_id == $user->data['user_id']) { trigger_error($user->lang['CANNOT_FORCE_REACT_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if (!check_form_key($form_name)) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if ($user_row['user_type'] == USER_FOUNDER) { trigger_error($user->lang['CANNOT_FORCE_REACT_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if ($user_row['user_type'] == USER_IGNORE) { trigger_error($user->lang['CANNOT_FORCE_REACT_BOT'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if ($config['email_enable']) { if (!class_exists('messenger')) { include $phpbb_root_path . 'includes/functions_messenger.' . $phpEx; } $server_url = generate_board_url(); $user_actkey = gen_rand_string(mt_rand(6, 10)); $email_template = $user_row['user_type'] == USER_NORMAL ? 'user_reactivate_account' : 'user_resend_inactive'; if ($user_row['user_type'] == USER_NORMAL) { user_active_flip('deactivate', $user_id, INACTIVE_REMIND); $sql = 'UPDATE ' . USERS_TABLE . "\n\t\t\t\t\t\t\t\t\t\tSET user_actkey = '" . $db->sql_escape($user_actkey) . "'\n\t\t\t\t\t\t\t\t\t\tWHERE user_id = {$user_id}"; $db->sql_query($sql); } else { // Grabbing the last confirm key - we only send a reminder $sql = 'SELECT user_actkey FROM ' . USERS_TABLE . ' WHERE user_id = ' . $user_id; $result = $db->sql_query($sql); $user_actkey = (string) $db->sql_fetchfield('user_actkey'); $db->sql_freeresult($result); } $messenger = new messenger(false); $messenger->template($email_template, $user_row['user_lang']); $messenger->set_addresses($user_row); $messenger->anti_abuse_headers($config, $user); $messenger->assign_vars(array('WELCOME_MSG' => htmlspecialchars_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename'])), 'USERNAME' => htmlspecialchars_decode($user_row['username']), 'U_ACTIVATE' => "{$server_url}/ucp.{$phpEx}?mode=activate&u={$user_row['user_id']}&k={$user_actkey}")); $messenger->send(NOTIFY_EMAIL); $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_REACTIVATE', false, array($user_row['username'])); $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_REACTIVATE_USER', false, array('reportee_id' => $user_id)); trigger_error($user->lang['FORCE_REACTIVATION_SUCCESS'] . adm_back_link($this->u_action . '&u=' . $user_id)); } break; case 'active': if ($user_id == $user->data['user_id']) { // It is only deactivation since the user is already activated (else he would not have reached this page) trigger_error($user->lang['CANNOT_DEACTIVATE_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if (!check_form_key($form_name)) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if ($user_row['user_type'] == USER_FOUNDER) { trigger_error($user->lang['CANNOT_DEACTIVATE_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if ($user_row['user_type'] == USER_IGNORE) { trigger_error($user->lang['CANNOT_DEACTIVATE_BOT'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } user_active_flip('flip', $user_id); if ($user_row['user_type'] == USER_INACTIVE) { if ($config['require_activation'] == USER_ACTIVATION_ADMIN) { /* @var $phpbb_notifications \phpbb\notification\manager */ $phpbb_notifications = $phpbb_container->get('notification_manager'); $phpbb_notifications->delete_notifications('notification.type.admin_activate_user', $user_row['user_id']); if (!class_exists('messenger')) { include $phpbb_root_path . 'includes/functions_messenger.' . $phpEx; } $messenger = new messenger(false); $messenger->template('admin_welcome_activated', $user_row['user_lang']); $messenger->set_addresses($user_row); $messenger->anti_abuse_headers($config, $user); $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($user_row['username']))); $messenger->send(NOTIFY_EMAIL); } } $message = $user_row['user_type'] == USER_INACTIVE ? 'USER_ADMIN_ACTIVATED' : 'USER_ADMIN_DEACTIVED'; $log = $user_row['user_type'] == USER_INACTIVE ? 'LOG_USER_ACTIVE' : 'LOG_USER_INACTIVE'; $phpbb_log->add('admin', $user->data['user_id'], $user->ip, $log, false, array($user_row['username'])); $phpbb_log->add('user', $user->data['user_id'], $user->ip, $log . '_USER', false, array('reportee_id' => $user_id)); trigger_error($user->lang[$message] . adm_back_link($this->u_action . '&u=' . $user_id)); break; case 'delsig': if (!check_form_key($form_name)) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } $sql_ary = array('user_sig' => '', 'user_sig_bbcode_uid' => '', 'user_sig_bbcode_bitfield' => ''); $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\t\t\t\t\tWHERE user_id = {$user_id}"; $db->sql_query($sql); $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_DEL_SIG', false, array($user_row['username'])); $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_DEL_SIG_USER', false, array('reportee_id' => $user_id)); trigger_error($user->lang['USER_ADMIN_SIG_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id)); break; case 'delavatar': if (!check_form_key($form_name)) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } // Delete old avatar if present /* @var $phpbb_avatar_manager \phpbb\avatar\manager */ $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); $phpbb_avatar_manager->handle_avatar_delete($db, $user, $phpbb_avatar_manager->clean_row($user_row, 'user'), USERS_TABLE, 'user_'); $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_DEL_AVATAR', false, array($user_row['username'])); $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_DEL_AVATAR_USER', false, array('reportee_id' => $user_id)); trigger_error($user->lang['USER_ADMIN_AVATAR_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id)); break; case 'delposts': if (confirm_box(true)) { // Delete posts, attachments, etc. delete_posts('poster_id', $user_id); $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_DEL_POSTS', false, array($user_row['username'])); trigger_error($user->lang['USER_POSTS_DELETED'] . adm_back_link($this->u_action . '&u=' . $user_id)); } else { confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'update' => true))); } break; case 'delattach': if (confirm_box(true)) { /** @var \phpbb\attachment\manager $attachment_manager */ $attachment_manager = $phpbb_container->get('attachment.manager'); $attachment_manager->delete('user', $user_id); unset($attachment_manager); $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_DEL_ATTACH', false, array($user_row['username'])); trigger_error($user->lang['USER_ATTACHMENTS_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id)); } else { confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'update' => true))); } break; case 'deloutbox': if (confirm_box(true)) { $msg_ids = array(); $lang = 'EMPTY'; $sql = 'SELECT msg_id FROM ' . PRIVMSGS_TO_TABLE . "\n\t\t\t\t\t\t\t\t\tWHERE author_id = {$user_id}\n\t\t\t\t\t\t\t\t\t\tAND folder_id = " . PRIVMSGS_OUTBOX; $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) { if (!function_exists('delete_pm')) { include $phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx; } do { $msg_ids[] = (int) $row['msg_id']; } while ($row = $db->sql_fetchrow($result)); $db->sql_freeresult($result); delete_pm($user_id, $msg_ids, PRIVMSGS_OUTBOX); $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_DEL_OUTBOX', false, array($user_row['username'])); $lang = 'EMPTIED'; } $db->sql_freeresult($result); trigger_error($user->lang['USER_OUTBOX_' . $lang] . adm_back_link($this->u_action . '&u=' . $user_id)); } else { confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'update' => true))); } break; case 'moveposts': if (!check_form_key($form_name)) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } $user->add_lang('acp/forums'); $new_forum_id = $request->variable('new_f', 0); if (!$new_forum_id) { $this->page_title = 'USER_ADMIN_MOVE_POSTS'; $template->assign_vars(array('S_SELECT_FORUM' => true, 'U_ACTION' => $this->u_action . "&action={$action}&u={$user_id}", 'U_BACK' => $this->u_action . "&u={$user_id}", 'S_FORUM_OPTIONS' => make_forum_select(false, false, false, true))); return; } // Is the new forum postable to? $sql = 'SELECT forum_name, forum_type FROM ' . FORUMS_TABLE . "\n\t\t\t\t\t\t\t\tWHERE forum_id = {$new_forum_id}"; $result = $db->sql_query($sql); $forum_info = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$forum_info) { trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if ($forum_info['forum_type'] != FORUM_POST) { trigger_error($user->lang['MOVE_POSTS_NO_POSTABLE_FORUM'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } // Two stage? // Move topics comprising only posts from this user $topic_id_ary = $move_topic_ary = $move_post_ary = $new_topic_id_ary = array(); $forum_id_ary = array($new_forum_id); $sql = 'SELECT topic_id, post_visibility, COUNT(post_id) AS total_posts FROM ' . POSTS_TABLE . "\n\t\t\t\t\t\t\t\tWHERE poster_id = {$user_id}\n\t\t\t\t\t\t\t\t\tAND forum_id <> {$new_forum_id}\n\t\t\t\t\t\t\t\tGROUP BY topic_id, post_visibility"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $topic_id_ary[$row['topic_id']][$row['post_visibility']] = $row['total_posts']; } $db->sql_freeresult($result); if (sizeof($topic_id_ary)) { $sql = 'SELECT topic_id, forum_id, topic_title, topic_posts_approved, topic_posts_unapproved, topic_posts_softdeleted, topic_attachment FROM ' . TOPICS_TABLE . ' WHERE ' . $db->sql_in_set('topic_id', array_keys($topic_id_ary)); $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { if ($topic_id_ary[$row['topic_id']][ITEM_APPROVED] == $row['topic_posts_approved'] && $topic_id_ary[$row['topic_id']][ITEM_UNAPPROVED] == $row['topic_posts_unapproved'] && $topic_id_ary[$row['topic_id']][ITEM_REAPPROVE] == $row['topic_posts_unapproved'] && $topic_id_ary[$row['topic_id']][ITEM_DELETED] == $row['topic_posts_softdeleted']) { $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['topic_attachment'] ? 1 : 0; } $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); } 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_visibility' => ITEM_APPROVED, 'topic_title' => $post_ary['title'], 'topic_first_poster_name' => $user_row['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 . "\n\t\t\t\t\t\t\t\t\t\tSET forum_id = {$new_forum_id}, topic_id = {$new_topic_id}\n\t\t\t\t\t\t\t\t\t\tWHERE topic_id = {$topic_id}\n\t\t\t\t\t\t\t\t\t\t\tAND poster_id = {$user_id}"; $db->sql_query($sql); if ($post_ary['attach']) { $sql = 'UPDATE ' . ATTACHMENTS_TABLE . "\n\t\t\t\t\t\t\t\t\t\t\tSET topic_id = {$new_topic_id}\n\t\t\t\t\t\t\t\t\t\t\tWHERE topic_id = {$topic_id}\n\t\t\t\t\t\t\t\t\t\t\t\tAND poster_id = {$user_id}"; $db->sql_query($sql); } $new_topic_id_ary[] = $new_topic_id; } } $forum_id_ary = array_unique($forum_id_ary); $topic_id_ary = array_unique(array_merge(array_keys($topic_id_ary), $new_topic_id_ary)); if (sizeof($topic_id_ary)) { sync('topic_reported', 'topic_id', $topic_id_ary); sync('topic', 'topic_id', $topic_id_ary); } if (sizeof($forum_id_ary)) { sync('forum', 'forum_id', $forum_id_ary, false, true); } $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_MOVE_POSTS', false, array($user_row['username'], $forum_info['forum_name'])); $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_MOVE_POSTS_USER', false, array('reportee_id' => $user_id, $forum_info['forum_name'])); trigger_error($user->lang['USER_POSTS_MOVED'] . adm_back_link($this->u_action . '&u=' . $user_id)); break; case 'leave_nr': if (confirm_box(true)) { remove_newly_registered($user_id, $user_row); $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_REMOVED_NR', false, array($user_row['username'])); trigger_error($user->lang['USER_LIFTED_NR'] . adm_back_link($this->u_action . '&u=' . $user_id)); } else { confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'update' => true))); } break; default: /** * Run custom quicktool code * * @event core.acp_users_overview_run_quicktool * @var array user_row Current user data * @var string action Quick tool that should be run * @since 3.1.0-a1 */ $vars = array('action', 'user_row'); extract($phpbb_dispatcher->trigger_event('core.acp_users_overview_run_quicktool', compact($vars))); break; } // Handle registration info updates $data = array('username' => $request->variable('user', $user_row['username'], true), 'user_founder' => $request->variable('user_founder', $user_row['user_type'] == USER_FOUNDER ? 1 : 0), 'email' => strtolower($request->variable('user_email', $user_row['user_email'])), 'new_password' => $request->variable('new_password', '', true), 'password_confirm' => $request->variable('password_confirm', '', true)); // Validation data - we do not check the password complexity setting here $check_ary = array('new_password' => array(array('string', true, $config['min_pass_chars'], $config['max_pass_chars']), array('password')), 'password_confirm' => array('string', true, $config['min_pass_chars'], $config['max_pass_chars'])); // Check username if altered if ($data['username'] != $user_row['username']) { $check_ary += array('username' => array(array('string', false, $config['min_name_chars'], $config['max_name_chars']), array('username', $user_row['username']))); } // Check email if altered if ($data['email'] != $user_row['user_email']) { $check_ary += array('email' => array(array('string', false, 6, 60), array('user_email', $user_row['user_email']))); } $error = validate_data($data, $check_ary); if ($data['new_password'] && $data['password_confirm'] != $data['new_password']) { $error[] = 'NEW_PASSWORD_ERROR'; } if (!check_form_key($form_name)) { $error[] = 'FORM_INVALID'; } // Instantiate passwords manager /* @var $passwords_manager \phpbb\passwords\manager */ $passwords_manager = $phpbb_container->get('passwords.manager'); // Which updates do we need to do? $update_username = $user_row['username'] != $data['username'] ? $data['username'] : false; $update_password = $data['new_password'] && !$passwords_manager->check($data['new_password'], $user_row['user_password']); $update_email = $data['email'] != $user_row['user_email'] ? $data['email'] : false; if (!sizeof($error)) { $sql_ary = array(); if ($user_row['user_type'] != USER_FOUNDER || $user->data['user_type'] == USER_FOUNDER) { // Only allow founders updating the founder status... if ($user->data['user_type'] == USER_FOUNDER) { // Setting a normal member to be a founder if ($data['user_founder'] && $user_row['user_type'] != USER_FOUNDER) { // Make sure the user is not setting an Inactive or ignored user to be a founder if ($user_row['user_type'] == USER_IGNORE) { trigger_error($user->lang['CANNOT_SET_FOUNDER_IGNORED'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if ($user_row['user_type'] == USER_INACTIVE) { trigger_error($user->lang['CANNOT_SET_FOUNDER_INACTIVE'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } $sql_ary['user_type'] = USER_FOUNDER; } else { if (!$data['user_founder'] && $user_row['user_type'] == USER_FOUNDER) { // Check if at least one founder is present $sql = 'SELECT user_id FROM ' . USERS_TABLE . ' WHERE user_type = ' . USER_FOUNDER . ' AND user_id <> ' . $user_id; $result = $db->sql_query_limit($sql, 1); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if ($row) { $sql_ary['user_type'] = USER_NORMAL; } else { trigger_error($user->lang['AT_LEAST_ONE_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } } } } } /** * Modify user data before we update it * * @event core.acp_users_overview_modify_data * @var array user_row Current user data * @var array data Submitted user data * @var array sql_ary User data we udpate * @since 3.1.0-a1 */ $vars = array('user_row', 'data', 'sql_ary'); extract($phpbb_dispatcher->trigger_event('core.acp_users_overview_modify_data', compact($vars))); if ($update_username !== false) { $sql_ary['username'] = $update_username; $sql_ary['username_clean'] = utf8_clean_string($update_username); $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_UPDATE_NAME', false, array('reportee_id' => $user_id, $user_row['username'], $update_username)); } if ($update_email !== false) { $sql_ary += array('user_email' => $update_email, 'user_email_hash' => phpbb_email_hash($update_email)); $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_UPDATE_EMAIL', false, array('reportee_id' => $user_id, $user_row['username'], $user_row['user_email'], $update_email)); } if ($update_password) { $sql_ary += array('user_password' => $passwords_manager->hash($data['new_password']), 'user_passchg' => time()); $user->reset_login_keys($user_id); $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_NEW_PASSWORD', false, array('reportee_id' => $user_id, $user_row['username'])); } if (sizeof($sql_ary)) { $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $user_id; $db->sql_query($sql); } if ($update_username) { user_update_name($user_row['username'], $update_username); } // Let the users permissions being updated $auth->acl_clear_prefetch($user_id); $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_USER_UPDATE', false, array($data['username'])); trigger_error($user->lang['USER_OVERVIEW_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); } // Replace "error" strings with their real, localised form $error = array_map(array($user, 'lang'), $error); } if ($user_id == $user->data['user_id']) { $quick_tool_ary = array('delsig' => 'DEL_SIG', 'delavatar' => 'DEL_AVATAR', 'moveposts' => 'MOVE_POSTS', 'delposts' => 'DEL_POSTS', 'delattach' => 'DEL_ATTACH', 'deloutbox' => 'DEL_OUTBOX'); if ($user_row['user_new']) { $quick_tool_ary['leave_nr'] = 'LEAVE_NR'; } } else { $quick_tool_ary = array(); if ($user_row['user_type'] != USER_FOUNDER) { $quick_tool_ary += array('banuser' => 'BAN_USER', 'banemail' => 'BAN_EMAIL', 'banip' => 'BAN_IP'); } if ($user_row['user_type'] != USER_FOUNDER && $user_row['user_type'] != USER_IGNORE) { $quick_tool_ary += array('active' => $user_row['user_type'] == USER_INACTIVE ? 'ACTIVATE' : 'DEACTIVATE'); } $quick_tool_ary += array('delsig' => 'DEL_SIG', 'delavatar' => 'DEL_AVATAR', 'moveposts' => 'MOVE_POSTS', 'delposts' => 'DEL_POSTS', 'delattach' => 'DEL_ATTACH', 'deloutbox' => 'DEL_OUTBOX'); if ($config['email_enable'] && ($user_row['user_type'] == USER_NORMAL || $user_row['user_type'] == USER_INACTIVE)) { $quick_tool_ary['reactivate'] = 'FORCE'; } if ($user_row['user_new']) { $quick_tool_ary['leave_nr'] = 'LEAVE_NR'; } } if ($config['load_onlinetrack']) { $sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline FROM ' . SESSIONS_TABLE . "\n\t\t\t\t\t\tWHERE session_user_id = {$user_id}"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); $user_row['session_time'] = isset($row['session_time']) ? $row['session_time'] : 0; $user_row['session_viewonline'] = isset($row['session_viewonline']) ? $row['session_viewonline'] : 0; unset($row); } /** * Add additional quick tool options and overwrite user data * * @event core.acp_users_display_overview * @var array user_row Array with user data * @var array quick_tool_ary Ouick tool options * @since 3.1.0-a1 */ $vars = array('user_row', 'quick_tool_ary'); extract($phpbb_dispatcher->trigger_event('core.acp_users_display_overview', compact($vars))); $s_action_options = '<option class="sep" value="">' . $user->lang['SELECT_OPTION'] . '</option>'; foreach ($quick_tool_ary as $value => $lang) { $s_action_options .= '<option value="' . $value . '">' . $user->lang['USER_ADMIN_' . $lang] . '</option>'; } $last_active = !empty($user_row['session_time']) ? $user_row['session_time'] : $user_row['user_lastvisit']; $inactive_reason = ''; if ($user_row['user_type'] == USER_INACTIVE) { $inactive_reason = $user->lang['INACTIVE_REASON_UNKNOWN']; switch ($user_row['user_inactive_reason']) { case INACTIVE_REGISTER: $inactive_reason = $user->lang['INACTIVE_REASON_REGISTER']; break; case INACTIVE_PROFILE: $inactive_reason = $user->lang['INACTIVE_REASON_PROFILE']; break; case INACTIVE_MANUAL: $inactive_reason = $user->lang['INACTIVE_REASON_MANUAL']; break; case INACTIVE_REMIND: $inactive_reason = $user->lang['INACTIVE_REASON_REMIND']; break; } } // Posts in Queue $sql = 'SELECT COUNT(post_id) as posts_in_queue FROM ' . POSTS_TABLE . ' WHERE poster_id = ' . $user_id . ' AND ' . $db->sql_in_set('post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)); $result = $db->sql_query($sql); $user_row['posts_in_queue'] = (int) $db->sql_fetchfield('posts_in_queue'); $db->sql_freeresult($result); $sql = 'SELECT post_id FROM ' . POSTS_TABLE . ' WHERE poster_id = ' . $user_id; $result = $db->sql_query_limit($sql, 1); $user_row['user_has_posts'] = (bool) $db->sql_fetchfield('post_id'); $db->sql_freeresult($result); $template->assign_vars(array('L_NAME_CHARS_EXPLAIN' => $user->lang($config['allow_name_chars'] . '_EXPLAIN', $user->lang('CHARACTERS', (int) $config['min_name_chars']), $user->lang('CHARACTERS', (int) $config['max_name_chars'])), 'L_CHANGE_PASSWORD_EXPLAIN' => $user->lang($config['pass_complex'] . '_EXPLAIN', $user->lang('CHARACTERS', (int) $config['min_pass_chars']), $user->lang('CHARACTERS', (int) $config['max_pass_chars'])), 'L_POSTS_IN_QUEUE' => $user->lang('NUM_POSTS_IN_QUEUE', $user_row['posts_in_queue']), 'S_FOUNDER' => $user->data['user_type'] == USER_FOUNDER ? true : false, 'S_OVERVIEW' => true, 'S_USER_IP' => $user_row['user_ip'] ? true : false, 'S_USER_FOUNDER' => $user_row['user_type'] == USER_FOUNDER ? true : false, 'S_ACTION_OPTIONS' => $s_action_options, 'S_OWN_ACCOUNT' => $user_id == $user->data['user_id'] ? true : false, 'S_USER_INACTIVE' => $user_row['user_type'] == USER_INACTIVE ? true : false, 'U_SHOW_IP' => $this->u_action . "&u={$user_id}&ip=" . ($ip == 'ip' ? 'hostname' : 'ip'), 'U_WHOIS' => $this->u_action . "&action=whois&user_ip={$user_row['user_ip']}", 'U_MCP_QUEUE' => $auth->acl_getf_global('m_approve') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue', true, $user->session_id) : '', 'U_SEARCH_USER' => $config['load_search'] && $auth->acl_get('u_search') ? append_sid("{$phpbb_root_path}search.{$phpEx}", "author_id={$user_row['user_id']}&sr=posts") : '', 'U_SWITCH_PERMISSIONS' => $auth->acl_get('a_switchperm') && $user->data['user_id'] != $user_row['user_id'] ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", "mode=switch_perm&u={$user_row['user_id']}&hash=" . generate_link_hash('switchperm')) : '', 'POSTS_IN_QUEUE' => $user_row['posts_in_queue'], 'USER' => $user_row['username'], 'USER_REGISTERED' => $user->format_date($user_row['user_regdate']), 'REGISTERED_IP' => $ip == 'hostname' ? gethostbyaddr($user_row['user_ip']) : $user_row['user_ip'], 'USER_LASTACTIVE' => $last_active ? $user->format_date($last_active) : ' - ', 'USER_EMAIL' => $user_row['user_email'], 'USER_WARNINGS' => $user_row['user_warnings'], 'USER_POSTS' => $user_row['user_posts'], 'USER_HAS_POSTS' => $user_row['user_has_posts'], 'USER_INACTIVE_REASON' => $inactive_reason)); break; case 'feedback': $user->add_lang('mcp'); // Set up general vars $start = $request->variable('start', 0); $deletemark = isset($_POST['delmarked']) ? true : false; $deleteall = isset($_POST['delall']) ? true : false; $marked = $request->variable('mark', array(0)); $message = $request->variable('message', '', true); /* @var $pagination \phpbb\pagination */ $pagination = $phpbb_container->get('pagination'); // Sort keys $sort_days = $request->variable('st', 0); $sort_key = $request->variable('sk', 't'); $sort_dir = $request->variable('sd', 'd'); // Delete entries if requested and able if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs')) { if (!check_form_key($form_name)) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } $where_sql = ''; if ($deletemark && $marked) { $sql_in = array(); foreach ($marked as $mark) { $sql_in[] = $mark; } $where_sql = ' AND ' . $db->sql_in_set('log_id', $sql_in); unset($sql_in); } if ($where_sql || $deleteall) { $sql = 'DELETE FROM ' . LOG_TABLE . ' WHERE log_type = ' . LOG_USERS . "\n\t\t\t\t\t\t\tAND reportee_id = {$user_id}\n\t\t\t\t\t\t\t{$where_sql}"; $db->sql_query($sql); $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_CLEAR_USER', false, array($user_row['username'])); } } if ($submit && $message) { if (!check_form_key($form_name)) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_FEEDBACK', false, array($user_row['username'])); $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_USER_FEEDBACK', false, array('forum_id' => 0, 'topic_id' => 0, $user_row['username'])); $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_GENERAL', false, array('reportee_id' => $user_id, $message)); trigger_error($user->lang['USER_FEEDBACK_ADDED'] . adm_back_link($this->u_action . '&u=' . $user_id)); } // Sorting $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'], 365 => $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' => 'u.username_clean', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation'); $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); // Define where and sort sql for use in displaying logs $sql_where = $sort_days ? time() - $sort_days * 86400 : 0; $sql_sort = $sort_by_sql[$sort_key] . ' ' . ($sort_dir == 'd' ? 'DESC' : 'ASC'); // Grab log data $log_data = array(); $log_count = 0; $start = view_log('user', $log_data, $log_count, $config['topics_per_page'], $start, 0, 0, $user_id, $sql_where, $sql_sort); $base_url = $this->u_action . "&u={$user_id}&{$u_sort_param}"; $pagination->generate_template_pagination($base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start); $template->assign_vars(array('S_FEEDBACK' => true, 'S_LIMIT_DAYS' => $s_limit_days, 'S_SORT_KEY' => $s_sort_key, 'S_SORT_DIR' => $s_sort_dir, 'S_CLEARLOGS' => $auth->acl_get('a_clearlogs'))); foreach ($log_data as $row) { $template->assign_block_vars('log', array('USERNAME' => $row['username_full'], 'IP' => $row['ip'], 'DATE' => $user->format_date($row['time']), 'ACTION' => nl2br($row['action']), 'ID' => $row['id'])); } break; case 'warnings': $user->add_lang('mcp'); // Set up general vars $deletemark = isset($_POST['delmarked']) ? true : false; $deleteall = isset($_POST['delall']) ? true : false; $confirm = isset($_POST['confirm']) ? true : false; $marked = $request->variable('mark', array(0)); // Delete entries if requested and able if ($deletemark || $deleteall || $confirm) { if (confirm_box(true)) { $where_sql = ''; $deletemark = $request->variable('delmarked', 0); $deleteall = $request->variable('delall', 0); if ($deletemark && $marked) { $where_sql = ' AND ' . $db->sql_in_set('warning_id', array_values($marked)); } if ($where_sql || $deleteall) { $sql = 'DELETE FROM ' . WARNINGS_TABLE . "\n\t\t\t\t\t\t\t\tWHERE user_id = {$user_id}\n\t\t\t\t\t\t\t\t\t{$where_sql}"; $db->sql_query($sql); if ($deleteall) { $log_warnings = $deleted_warnings = 0; } else { $num_warnings = (int) $db->sql_affectedrows(); $deleted_warnings = ' user_warnings - ' . $num_warnings; $log_warnings = $num_warnings > 2 ? 2 : $num_warnings; } $sql = 'UPDATE ' . USERS_TABLE . "\n\t\t\t\t\t\t\t\tSET user_warnings = {$deleted_warnings}\n\t\t\t\t\t\t\t\tWHERE user_id = {$user_id}"; $db->sql_query($sql); if ($log_warnings) { $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_WARNINGS_DELETED', false, array($user_row['username'], $num_warnings)); } else { $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_WARNINGS_DELETED_ALL', false, array($user_row['username'])); } } } else { $s_hidden_fields = array('i' => $id, 'mode' => $mode, 'u' => $user_id, 'mark' => $marked); if (isset($_POST['delmarked'])) { $s_hidden_fields['delmarked'] = 1; } if (isset($_POST['delall'])) { $s_hidden_fields['delall'] = 1; } if (isset($_POST['delall']) || isset($_POST['delmarked']) && sizeof($marked)) { confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields)); } } } $sql = 'SELECT w.warning_id, w.warning_time, w.post_id, l.log_operation, l.log_data, l.user_id AS mod_user_id, m.username AS mod_username, m.user_colour AS mod_user_colour FROM ' . WARNINGS_TABLE . ' w LEFT JOIN ' . LOG_TABLE . ' l ON (w.log_id = l.log_id) LEFT JOIN ' . USERS_TABLE . ' m ON (l.user_id = m.user_id) WHERE w.user_id = ' . $user_id . ' ORDER BY w.warning_time DESC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { if (!$row['log_operation']) { // We do not have a log-entry anymore, so there is no data available $row['action'] = $user->lang['USER_WARNING_LOG_DELETED']; } else { $row['action'] = isset($user->lang[$row['log_operation']]) ? $user->lang[$row['log_operation']] : '{' . ucfirst(str_replace('_', ' ', $row['log_operation'])) . '}'; if (!empty($row['log_data'])) { $log_data_ary = @unserialize($row['log_data']); $log_data_ary = $log_data_ary === false ? array() : $log_data_ary; if (isset($user->lang[$row['log_operation']])) { // Check if there are more occurrences of % than arguments, if there are we fill out the arguments array // It doesn't matter if we add more arguments than placeholders if (substr_count($row['action'], '%') - sizeof($log_data_ary) > 0) { $log_data_ary = array_merge($log_data_ary, array_fill(0, substr_count($row['action'], '%') - sizeof($log_data_ary), '')); } $row['action'] = vsprintf($row['action'], $log_data_ary); $row['action'] = bbcode_nl2br(censor_text($row['action'])); } else { if (!empty($log_data_ary)) { $row['action'] .= '<br />' . implode('', $log_data_ary); } } } } $template->assign_block_vars('warn', array('ID' => $row['warning_id'], 'USERNAME' => $row['log_operation'] ? get_username_string('full', $row['mod_user_id'], $row['mod_username'], $row['mod_user_colour']) : '-', 'ACTION' => make_clickable($row['action']), 'DATE' => $user->format_date($row['warning_time']))); } $db->sql_freeresult($result); $template->assign_vars(array('S_WARNINGS' => true)); break; case 'profile': if (!function_exists('user_get_id_name')) { include $phpbb_root_path . 'includes/functions_user.' . $phpEx; } /* @var $cp \phpbb\profilefields\manager */ $cp = $phpbb_container->get('profilefields.manager'); $cp_data = $cp_error = array(); $sql = 'SELECT lang_id FROM ' . LANG_TABLE . "\n\t\t\t\t\tWHERE lang_iso = '" . $db->sql_escape($user->data['user_lang']) . "'"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); $user_row['iso_lang_id'] = $row['lang_id']; $data = array('jabber' => $request->variable('jabber', $user_row['user_jabber'], true), 'bday_day' => 0, 'bday_month' => 0, 'bday_year' => 0); if ($user_row['user_birthday']) { list($data['bday_day'], $data['bday_month'], $data['bday_year']) = explode('-', $user_row['user_birthday']); } $data['bday_day'] = $request->variable('bday_day', $data['bday_day']); $data['bday_month'] = $request->variable('bday_month', $data['bday_month']); $data['bday_year'] = $request->variable('bday_year', $data['bday_year']); $data['user_birthday'] = sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['bday_year']); /** * Modify user data on editing profile in ACP * * @event core.acp_users_modify_profile * @var array data Array with user profile data * @var bool submit Flag indicating if submit button has been pressed * @var int user_id The user id * @var array user_row Array with the full user data * @since 3.1.4-RC1 */ $vars = array('data', 'submit', 'user_id', 'user_row'); extract($phpbb_dispatcher->trigger_event('core.acp_users_modify_profile', compact($vars))); if ($submit) { $error = validate_data($data, array('jabber' => array(array('string', true, 5, 255), array('jabber')), 'bday_day' => array('num', true, 1, 31), 'bday_month' => array('num', true, 1, 12), 'bday_year' => array('num', true, 1901, gmdate('Y', time())), 'user_birthday' => array('date', true))); // validate custom profile fields $cp->submit_cp_field('profile', $user_row['iso_lang_id'], $cp_data, $cp_error); if (sizeof($cp_error)) { $error = array_merge($error, $cp_error); } if (!check_form_key($form_name)) { $error[] = 'FORM_INVALID'; } /** * Validate profile data in ACP before submitting to the database * * @event core.acp_users_profile_validate * @var bool submit Flag indicating if submit button has been pressed * @var array data Array with user profile data * @var array error Array with the form errors * @since 3.1.4-RC1 */ $vars = array('submit', 'data', 'error'); extract($phpbb_dispatcher->trigger_event('core.acp_users_profile_validate', compact($vars))); if (!sizeof($error)) { $sql_ary = array('user_jabber' => $data['jabber'], 'user_birthday' => $data['user_birthday']); /** * Modify profile data in ACP before submitting to the database * * @event core.acp_users_profile_modify_sql_ary * @var array cp_data Array with the user custom profile fields data * @var array data Array with user profile data * @var int user_id The user id * @var array user_row Array with the full user data * @var array sql_ary Array with sql data * @since 3.1.4-RC1 */ $vars = array('cp_data', 'data', 'user_id', 'user_row', 'sql_ary'); extract($phpbb_dispatcher->trigger_event('core.acp_users_profile_modify_sql_ary', compact($vars))); $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\t\t\t\tWHERE user_id = {$user_id}"; $db->sql_query($sql); // Update Custom Fields $cp->update_profile_field_data($user_id, $cp_data); trigger_error($user->lang['USER_PROFILE_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); } // Replace "error" strings with their real, localised form $error = array_map(array($user, 'lang'), $error); } $s_birthday_day_options = '<option value="0"' . (!$data['bday_day'] ? ' selected="selected"' : '') . '>--</option>'; for ($i = 1; $i < 32; $i++) { $selected = $i == $data['bday_day'] ? ' selected="selected"' : ''; $s_birthday_day_options .= "<option value=\"{$i}\"{$selected}>{$i}</option>"; } $s_birthday_month_options = '<option value="0"' . (!$data['bday_month'] ? ' selected="selected"' : '') . '>--</option>'; for ($i = 1; $i < 13; $i++) { $selected = $i == $data['bday_month'] ? ' selected="selected"' : ''; $s_birthday_month_options .= "<option value=\"{$i}\"{$selected}>{$i}</option>"; } $now = getdate(); $s_birthday_year_options = '<option value="0"' . (!$data['bday_year'] ? ' selected="selected"' : '') . '>--</option>'; for ($i = $now['year'] - 100; $i <= $now['year']; $i++) { $selected = $i == $data['bday_year'] ? ' selected="selected"' : ''; $s_birthday_year_options .= "<option value=\"{$i}\"{$selected}>{$i}</option>"; } unset($now); $template->assign_vars(array('JABBER' => $data['jabber'], 'S_BIRTHDAY_DAY_OPTIONS' => $s_birthday_day_options, 'S_BIRTHDAY_MONTH_OPTIONS' => $s_birthday_month_options, 'S_BIRTHDAY_YEAR_OPTIONS' => $s_birthday_year_options, 'S_PROFILE' => true)); // Get additional profile fields and assign them to the template block var 'profile_fields' $user->get_profile_fields($user_id); $cp->generate_profile_fields('profile', $user_row['iso_lang_id']); break; case 'prefs': if (!function_exists('user_get_id_name')) { include $phpbb_root_path . 'includes/functions_user.' . $phpEx; } $data = array('dateformat' => $request->variable('dateformat', $user_row['user_dateformat'], true), 'lang' => basename($request->variable('lang', $user_row['user_lang'])), 'tz' => $request->variable('tz', $user_row['user_timezone']), 'style' => $request->variable('style', $user_row['user_style']), 'viewemail' => $request->variable('viewemail', $user_row['user_allow_viewemail']), 'massemail' => $request->variable('massemail', $user_row['user_allow_massemail']), 'hideonline' => $request->variable('hideonline', !$user_row['user_allow_viewonline']), 'notifymethod' => $request->variable('notifymethod', $user_row['user_notify_type']), 'notifypm' => $request->variable('notifypm', $user_row['user_notify_pm']), 'allowpm' => $request->variable('allowpm', $user_row['user_allow_pm']), 'topic_sk' => $request->variable('topic_sk', $user_row['user_topic_sortby_type'] ? $user_row['user_topic_sortby_type'] : 't'), 'topic_sd' => $request->variable('topic_sd', $user_row['user_topic_sortby_dir'] ? $user_row['user_topic_sortby_dir'] : 'd'), 'topic_st' => $request->variable('topic_st', $user_row['user_topic_show_days'] ? $user_row['user_topic_show_days'] : 0), 'post_sk' => $request->variable('post_sk', $user_row['user_post_sortby_type'] ? $user_row['user_post_sortby_type'] : 't'), 'post_sd' => $request->variable('post_sd', $user_row['user_post_sortby_dir'] ? $user_row['user_post_sortby_dir'] : 'a'), 'post_st' => $request->variable('post_st', $user_row['user_post_show_days'] ? $user_row['user_post_show_days'] : 0), 'view_images' => $request->variable('view_images', $this->optionget($user_row, 'viewimg')), 'view_flash' => $request->variable('view_flash', $this->optionget($user_row, 'viewflash')), 'view_smilies' => $request->variable('view_smilies', $this->optionget($user_row, 'viewsmilies')), 'view_sigs' => $request->variable('view_sigs', $this->optionget($user_row, 'viewsigs')), 'view_avatars' => $request->variable('view_avatars', $this->optionget($user_row, 'viewavatars')), 'view_wordcensor' => $request->variable('view_wordcensor', $this->optionget($user_row, 'viewcensors')), 'bbcode' => $request->variable('bbcode', $this->optionget($user_row, 'bbcode')), 'smilies' => $request->variable('smilies', $this->optionget($user_row, 'smilies')), 'sig' => $request->variable('sig', $this->optionget($user_row, 'attachsig')), 'notify' => $request->variable('notify', $user_row['user_notify'])); /** * Modify users preferences data * * @event core.acp_users_prefs_modify_data * @var array data Array with users preferences data * @var array user_row Array with user data * @since 3.1.0-b3 */ $vars = array('data', 'user_row'); extract($phpbb_dispatcher->trigger_event('core.acp_users_prefs_modify_data', compact($vars))); if ($submit) { $error = validate_data($data, array('dateformat' => array('string', false, 1, 64), 'lang' => array('match', false, '#^[a-z_\\-]{2,}$#i'), 'tz' => array('timezone'), 'topic_sk' => array('string', false, 1, 1), 'topic_sd' => array('string', false, 1, 1), 'post_sk' => array('string', false, 1, 1), 'post_sd' => array('string', false, 1, 1))); if (!check_form_key($form_name)) { $error[] = 'FORM_INVALID'; } if (!sizeof($error)) { $this->optionset($user_row, 'viewimg', $data['view_images']); $this->optionset($user_row, 'viewflash', $data['view_flash']); $this->optionset($user_row, 'viewsmilies', $data['view_smilies']); $this->optionset($user_row, 'viewsigs', $data['view_sigs']); $this->optionset($user_row, 'viewavatars', $data['view_avatars']); $this->optionset($user_row, 'viewcensors', $data['view_wordcensor']); $this->optionset($user_row, 'bbcode', $data['bbcode']); $this->optionset($user_row, 'smilies', $data['smilies']); $this->optionset($user_row, 'attachsig', $data['sig']); $sql_ary = array('user_options' => $user_row['user_options'], 'user_allow_pm' => $data['allowpm'], 'user_allow_viewemail' => $data['viewemail'], 'user_allow_massemail' => $data['massemail'], 'user_allow_viewonline' => !$data['hideonline'], 'user_notify_type' => $data['notifymethod'], 'user_notify_pm' => $data['notifypm'], 'user_dateformat' => $data['dateformat'], 'user_lang' => $data['lang'], 'user_timezone' => $data['tz'], 'user_style' => $data['style'], 'user_topic_sortby_type' => $data['topic_sk'], 'user_post_sortby_type' => $data['post_sk'], 'user_topic_sortby_dir' => $data['topic_sd'], 'user_post_sortby_dir' => $data['post_sd'], 'user_topic_show_days' => $data['topic_st'], 'user_post_show_days' => $data['post_st'], 'user_notify' => $data['notify']); /** * Modify SQL query before users preferences are updated * * @event core.acp_users_prefs_modify_sql * @var array data Array with users preferences data * @var array user_row Array with user data * @var array sql_ary SQL array with users preferences data to update * @var array error Array with errors data * @since 3.1.0-b3 */ $vars = array('data', 'user_row', 'sql_ary', 'error'); extract($phpbb_dispatcher->trigger_event('core.acp_users_prefs_modify_sql', compact($vars))); if (!sizeof($error)) { $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\t\t\t\t\tWHERE user_id = {$user_id}"; $db->sql_query($sql); // Check if user has an active session if ($user_row['session_id']) { // We'll update the session if user_allow_viewonline has changed and the user is a bot // Or if it's a regular user and the admin set it to hide the session if ($user_row['user_allow_viewonline'] != $sql_ary['user_allow_viewonline'] && $user_row['user_type'] == USER_IGNORE || $user_row['user_allow_viewonline'] && !$sql_ary['user_allow_viewonline']) { // We also need to check if the user has the permission to cloak. $user_auth = new \phpbb\auth\auth(); $user_auth->acl($user_row); $session_sql_ary = array('session_viewonline' => $user_auth->acl_get('u_hideonline') ? $sql_ary['user_allow_viewonline'] : true); $sql = 'UPDATE ' . SESSIONS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $session_sql_ary) . "\n\t\t\t\t\t\t\t\t\t\tWHERE session_user_id = {$user_id}"; $db->sql_query($sql); unset($user_auth); } } trigger_error($user->lang['USER_PREFS_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); } } // Replace "error" strings with their real, localised form $error = array_map(array($user, 'lang'), $error); } $dateformat_options = ''; foreach ($user->lang['dateformats'] as $format => $null) { $dateformat_options .= '<option value="' . $format . '"' . ($format == $data['dateformat'] ? ' selected="selected"' : '') . '>'; $dateformat_options .= $user->format_date(time(), $format, false) . (strpos($format, '|') !== false ? $user->lang['VARIANT_DATE_SEPARATOR'] . $user->format_date(time(), $format, true) : ''); $dateformat_options .= '</option>'; } $s_custom = false; $dateformat_options .= '<option value="custom"'; if (!isset($user->lang['dateformats'][$data['dateformat']])) { $dateformat_options .= ' selected="selected"'; $s_custom = true; } $dateformat_options .= '>' . $user->lang['CUSTOM_DATEFORMAT'] . '</option>'; $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); // Topic ordering options $limit_topic_days = array(0 => $user->lang['ALL_TOPICS'], 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'], 365 => $user->lang['1_YEAR']); $sort_by_topic_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 'r' => $user->lang['REPLIES'], 's' => $user->lang['SUBJECT'], 'v' => $user->lang['VIEWS']); // Post ordering options $limit_post_days = array(0 => $user->lang['ALL_POSTS'], 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'], 365 => $user->lang['1_YEAR']); $sort_by_post_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']); $_options = array('topic', 'post'); foreach ($_options as $sort_option) { ${'s_limit_' . $sort_option . '_days'} = '<select name="' . $sort_option . '_st">'; foreach (${'limit_' . $sort_option . '_days'} as $day => $text) { $selected = $data[$sort_option . '_st'] == $day ? ' selected="selected"' : ''; ${'s_limit_' . $sort_option . '_days'} .= '<option value="' . $day . '"' . $selected . '>' . $text . '</option>'; } ${'s_limit_' . $sort_option . '_days'} .= '</select>'; ${'s_sort_' . $sort_option . '_key'} = '<select name="' . $sort_option . '_sk">'; foreach (${'sort_by_' . $sort_option . '_text'} as $key => $text) { $selected = $data[$sort_option . '_sk'] == $key ? ' selected="selected"' : ''; ${'s_sort_' . $sort_option . '_key'} .= '<option value="' . $key . '"' . $selected . '>' . $text . '</option>'; } ${'s_sort_' . $sort_option . '_key'} .= '</select>'; ${'s_sort_' . $sort_option . '_dir'} = '<select name="' . $sort_option . '_sd">'; foreach ($sort_dir_text as $key => $value) { $selected = $data[$sort_option . '_sd'] == $key ? ' selected="selected"' : ''; ${'s_sort_' . $sort_option . '_dir'} .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; } ${'s_sort_' . $sort_option . '_dir'} .= '</select>'; } phpbb_timezone_select($template, $user, $data['tz'], true); $user_prefs_data = array('S_PREFS' => true, 'S_JABBER_DISABLED' => $config['jab_enable'] && $user_row['user_jabber'] && @extension_loaded('xml') ? false : true, 'VIEW_EMAIL' => $data['viewemail'], 'MASS_EMAIL' => $data['massemail'], 'ALLOW_PM' => $data['allowpm'], 'HIDE_ONLINE' => $data['hideonline'], 'NOTIFY_EMAIL' => $data['notifymethod'] == NOTIFY_EMAIL ? true : false, 'NOTIFY_IM' => $data['notifymethod'] == NOTIFY_IM ? true : false, 'NOTIFY_BOTH' => $data['notifymethod'] == NOTIFY_BOTH ? true : false, 'NOTIFY_PM' => $data['notifypm'], 'BBCODE' => $data['bbcode'], 'SMILIES' => $data['smilies'], 'ATTACH_SIG' => $data['sig'], 'NOTIFY' => $data['notify'], 'VIEW_IMAGES' => $data['view_images'], 'VIEW_FLASH' => $data['view_flash'], 'VIEW_SMILIES' => $data['view_smilies'], 'VIEW_SIGS' => $data['view_sigs'], 'VIEW_AVATARS' => $data['view_avatars'], 'VIEW_WORDCENSOR' => $data['view_wordcensor'], 'S_TOPIC_SORT_DAYS' => $s_limit_topic_days, 'S_TOPIC_SORT_KEY' => $s_sort_topic_key, 'S_TOPIC_SORT_DIR' => $s_sort_topic_dir, 'S_POST_SORT_DAYS' => $s_limit_post_days, 'S_POST_SORT_KEY' => $s_sort_post_key, 'S_POST_SORT_DIR' => $s_sort_post_dir, 'DATE_FORMAT' => $data['dateformat'], 'S_DATEFORMAT_OPTIONS' => $dateformat_options, 'S_CUSTOM_DATEFORMAT' => $s_custom, 'DEFAULT_DATEFORMAT' => $config['default_dateformat'], 'A_DEFAULT_DATEFORMAT' => addslashes($config['default_dateformat']), 'S_LANG_OPTIONS' => language_select($data['lang']), 'S_STYLE_OPTIONS' => style_select($data['style'])); /** * Modify users preferences data before assigning it to the template * * @event core.acp_users_prefs_modify_template_data * @var array data Array with users preferences data * @var array user_row Array with user data * @var array user_prefs_data Array with users preferences data to be assigned to the template * @since 3.1.0-b3 */ $vars = array('data', 'user_row', 'user_prefs_data'); extract($phpbb_dispatcher->trigger_event('core.acp_users_prefs_modify_template_data', compact($vars))); $template->assign_vars($user_prefs_data); break; case 'avatar': $avatars_enabled = false; /** @var \phpbb\avatar\manager $phpbb_avatar_manager */ $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); if ($config['allow_avatar']) { $avatar_drivers = $phpbb_avatar_manager->get_enabled_drivers(); // This is normalised data, without the user_ prefix $avatar_data = \phpbb\avatar\manager::clean_row($user_row, 'user'); if ($submit) { if (check_form_key($form_name)) { $driver_name = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', '')); if (in_array($driver_name, $avatar_drivers) && !$request->is_set_post('avatar_delete')) { $driver = $phpbb_avatar_manager->get_driver($driver_name); $result = $driver->process_form($request, $template, $user, $avatar_data, $error); if ($result && empty($error)) { // Success! Lets save the result in the database $result = array('user_avatar_type' => $driver_name, 'user_avatar' => $result['avatar'], 'user_avatar_width' => $result['avatar_width'], 'user_avatar_height' => $result['avatar_height']); $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $result) . ' WHERE user_id = ' . (int) $user_id; $db->sql_query($sql); trigger_error($user->lang['USER_AVATAR_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); } } } else { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } } // Handle deletion of avatars if ($request->is_set_post('avatar_delete')) { if (!confirm_box(true)) { confirm_box(false, $user->lang('CONFIRM_AVATAR_DELETE'), build_hidden_fields(array('avatar_delete' => true))); } else { $phpbb_avatar_manager->handle_avatar_delete($db, $user, $avatar_data, USERS_TABLE, 'user_'); trigger_error($user->lang['USER_AVATAR_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); } } $selected_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $user_row['user_avatar_type'])); // Assign min and max values before generating avatar driver html $template->assign_vars(array('AVATAR_MIN_WIDTH' => $config['avatar_min_width'], 'AVATAR_MAX_WIDTH' => $config['avatar_max_width'], 'AVATAR_MIN_HEIGHT' => $config['avatar_min_height'], 'AVATAR_MAX_HEIGHT' => $config['avatar_max_height'])); foreach ($avatar_drivers as $current_driver) { $driver = $phpbb_avatar_manager->get_driver($current_driver); $avatars_enabled = true; $template->set_filenames(array('avatar' => $driver->get_acp_template_name())); if ($driver->prepare_form($request, $template, $user, $avatar_data, $error)) { $driver_name = $phpbb_avatar_manager->prepare_driver_name($current_driver); $driver_upper = strtoupper($driver_name); $template->assign_block_vars('avatar_drivers', array('L_TITLE' => $user->lang($driver_upper . '_TITLE'), 'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'), 'DRIVER' => $driver_name, 'SELECTED' => $current_driver == $selected_driver, 'OUTPUT' => $template->assign_display('avatar'))); } } } // Avatar manager is not initialized if avatars are disabled if (isset($phpbb_avatar_manager)) { // Replace "error" strings with their real, localised form $error = $phpbb_avatar_manager->localize_errors($user, $error); } $avatar = phpbb_get_user_avatar($user_row, 'USER_AVATAR', true); $template->assign_vars(array('S_AVATAR' => true, 'ERROR' => !empty($error) ? implode('<br />', $error) : '', 'AVATAR' => empty($avatar) ? '<img src="' . $phpbb_admin_path . 'images/no_avatar.gif" alt="" />' : $avatar, 'S_FORM_ENCTYPE' => ' enctype="multipart/form-data"', 'L_AVATAR_EXPLAIN' => sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], $config['avatar_filesize'] / 1024), 'S_AVATARS_ENABLED' => $config['allow_avatar'] && $avatars_enabled)); break; case 'rank': if ($submit) { if (!check_form_key($form_name)) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } $rank_id = $request->variable('user_rank', 0); $sql = 'UPDATE ' . USERS_TABLE . "\n\t\t\t\t\t\tSET user_rank = {$rank_id}\n\t\t\t\t\t\tWHERE user_id = {$user_id}"; $db->sql_query($sql); trigger_error($user->lang['USER_RANK_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); } $sql = 'SELECT * FROM ' . RANKS_TABLE . ' WHERE rank_special = 1 ORDER BY rank_title'; $result = $db->sql_query($sql); $s_rank_options = '<option value="0"' . (!$user_row['user_rank'] ? ' selected="selected"' : '') . '>' . $user->lang['NO_SPECIAL_RANK'] . '</option>'; while ($row = $db->sql_fetchrow($result)) { $selected = $user_row['user_rank'] && $row['rank_id'] == $user_row['user_rank'] ? ' selected="selected"' : ''; $s_rank_options .= '<option value="' . $row['rank_id'] . '"' . $selected . '>' . $row['rank_title'] . '</option>'; } $db->sql_freeresult($result); $template->assign_vars(array('S_RANK' => true, 'S_RANK_OPTIONS' => $s_rank_options)); break; case 'sig': if (!function_exists('display_custom_bbcodes')) { include $phpbb_root_path . 'includes/functions_display.' . $phpEx; } $enable_bbcode = $config['allow_sig_bbcode'] ? $this->optionget($user_row, 'sig_bbcode') : false; $enable_smilies = $config['allow_sig_smilies'] ? $this->optionget($user_row, 'sig_smilies') : false; $enable_urls = $config['allow_sig_links'] ? $this->optionget($user_row, 'sig_links') : false; $decoded_message = generate_text_for_edit($user_row['user_sig'], $user_row['user_sig_bbcode_uid'], $user_row['user_sig_bbcode_bitfield']); $signature = $request->variable('signature', $decoded_message['text'], true); $signature_preview = ''; if ($submit || $request->is_set_post('preview')) { $enable_bbcode = $config['allow_sig_bbcode'] ? !$request->variable('disable_bbcode', false) : false; $enable_smilies = $config['allow_sig_smilies'] ? !$request->variable('disable_smilies', false) : false; $enable_urls = $config['allow_sig_links'] ? !$request->variable('disable_magic_url', false) : false; if (!check_form_key($form_name)) { $error[] = 'FORM_INVALID'; } } $bbcode_uid = $bbcode_bitfield = $bbcode_flags = ''; $warn_msg = generate_text_for_storage($signature, $bbcode_uid, $bbcode_bitfield, $bbcode_flags, $enable_bbcode, $enable_urls, $enable_smilies, $config['allow_sig_img'], $config['allow_sig_flash'], true, $config['allow_sig_links'], 'sig'); if (sizeof($warn_msg)) { $error += $warn_msg; } if (!$submit) { // Parse it for displaying $signature_preview = generate_text_for_display($signature, $bbcode_uid, $bbcode_bitfield, $bbcode_flags); } else { if (!sizeof($error)) { $this->optionset($user_row, 'sig_bbcode', $enable_bbcode); $this->optionset($user_row, 'sig_smilies', $enable_smilies); $this->optionset($user_row, 'sig_links', $enable_urls); $sql_ary = array('user_sig' => $signature, 'user_options' => $user_row['user_options'], 'user_sig_bbcode_uid' => $bbcode_uid, 'user_sig_bbcode_bitfield' => $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['USER_SIG_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); } } // Replace "error" strings with their real, localised form $error = array_map(array($user, 'lang'), $error); if ($request->is_set_post('preview')) { $decoded_message = generate_text_for_edit($signature, $bbcode_uid, $bbcode_bitfield); } /** @var \phpbb\controller\helper $controller_helper */ $controller_helper = $phpbb_container->get('controller.helper'); $template->assign_vars(array('S_SIGNATURE' => true, 'SIGNATURE' => $decoded_message['text'], 'SIGNATURE_PREVIEW' => $signature_preview, 'S_BBCODE_CHECKED' => !$enable_bbcode ? ' checked="checked"' : '', 'S_SMILIES_CHECKED' => !$enable_smilies ? ' checked="checked"' : '', 'S_MAGIC_URL_CHECKED' => !$enable_urls ? ' checked="checked"' : '', 'BBCODE_STATUS' => $user->lang($config['allow_sig_bbcode'] ? 'BBCODE_IS_ON' : 'BBCODE_IS_OFF', '<a href="' . $controller_helper->route('phpbb_help_bbcode_controller') . '">', '</a>'), 'SMILIES_STATUS' => $config['allow_sig_smilies'] ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], 'IMG_STATUS' => $config['allow_sig_img'] ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'], 'FLASH_STATUS' => $config['allow_sig_flash'] ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'], 'URL_STATUS' => $config['allow_sig_links'] ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'], 'L_SIGNATURE_EXPLAIN' => $user->lang('SIGNATURE_EXPLAIN', (int) $config['max_sig_chars']), 'S_BBCODE_ALLOWED' => $config['allow_sig_bbcode'], 'S_SMILIES_ALLOWED' => $config['allow_sig_smilies'], 'S_BBCODE_IMG' => $config['allow_sig_img'] ? true : false, 'S_BBCODE_FLASH' => $config['allow_sig_flash'] ? true : false, 'S_LINKS_ALLOWED' => $config['allow_sig_links'] ? true : false)); // Assigning custom bbcodes display_custom_bbcodes(); break; case 'attach': /* @var $pagination \phpbb\pagination */ $pagination = $phpbb_container->get('pagination'); $start = $request->variable('start', 0); $deletemark = isset($_POST['delmarked']) ? true : false; $marked = $request->variable('mark', array(0)); // Sort keys $sort_key = $request->variable('sk', 'a'); $sort_dir = $request->variable('sd', 'd'); if ($deletemark && sizeof($marked)) { $sql = 'SELECT attach_id FROM ' . ATTACHMENTS_TABLE . ' WHERE poster_id = ' . $user_id . ' AND is_orphan = 0 AND ' . $db->sql_in_set('attach_id', $marked); $result = $db->sql_query($sql); $marked = array(); while ($row = $db->sql_fetchrow($result)) { $marked[] = $row['attach_id']; } $db->sql_freeresult($result); } if ($deletemark && sizeof($marked)) { if (confirm_box(true)) { $sql = 'SELECT real_filename FROM ' . ATTACHMENTS_TABLE . ' WHERE ' . $db->sql_in_set('attach_id', $marked); $result = $db->sql_query($sql); $log_attachments = array(); while ($row = $db->sql_fetchrow($result)) { $log_attachments[] = $row['real_filename']; } $db->sql_freeresult($result); /** @var \phpbb\attachment\manager $attachment_manager */ $attachment_manager = $phpbb_container->get('attachment.manager'); $attachment_manager->delete('attach', $marked); unset($attachment_manager); $message = sizeof($log_attachments) == 1 ? $user->lang['ATTACHMENT_DELETED'] : $user->lang['ATTACHMENTS_DELETED']; $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ATTACHMENTS_DELETED', false, array(implode($user->lang['COMMA_SEPARATOR'], $log_attachments))); trigger_error($message . adm_back_link($this->u_action . '&u=' . $user_id)); } else { confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'delmarked' => true, 'mark' => $marked))); } } $sk_text = array('a' => $user->lang['SORT_FILENAME'], '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', 'c' => 'a.extension', 'd' => 'a.filesize', 'e' => 'a.download_count', 'f' => 'a.filetime', 'g' => 't.topic_title'); $sd_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); $s_sort_key = ''; foreach ($sk_text as $key => $value) { $selected = $sort_key == $key ? ' selected="selected"' : ''; $s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; } $s_sort_dir = ''; foreach ($sd_text as $key => $value) { $selected = $sort_dir == $key ? ' selected="selected"' : ''; $s_sort_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; } if (!isset($sk_sql[$sort_key])) { $sort_key = 'a'; } $order_by = $sk_sql[$sort_key] . ' ' . ($sort_dir == 'a' ? 'ASC' : 'DESC'); $sql = 'SELECT COUNT(attach_id) as num_attachments FROM ' . ATTACHMENTS_TABLE . "\n\t\t\t\t\tWHERE poster_id = {$user_id}\n\t\t\t\t\t\tAND is_orphan = 0"; $result = $db->sql_query_limit($sql, 1); $num_attachments = (int) $db->sql_fetchfield('num_attachments'); $db->sql_freeresult($result); $sql = 'SELECT a.*, t.topic_title, p.message_subject as message_title FROM ' . ATTACHMENTS_TABLE . ' a LEFT JOIN ' . TOPICS_TABLE . ' t ON (a.topic_id = t.topic_id AND a.in_message = 0) LEFT JOIN ' . PRIVMSGS_TABLE . ' p ON (a.post_msg_id = p.msg_id AND a.in_message = 1) WHERE a.poster_id = ' . $user_id . "\n\t\t\t\t\t\tAND a.is_orphan = 0\n\t\t\t\t\tORDER BY {$order_by}"; $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); while ($row = $db->sql_fetchrow($result)) { if ($row['in_message']) { $view_topic = append_sid("{$phpbb_root_path}ucp.{$phpEx}", "i=pm&p={$row['post_msg_id']}"); } else { $view_topic = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "t={$row['topic_id']}&p={$row['post_msg_id']}") . '#p' . $row['post_msg_id']; } $template->assign_block_vars('attach', array('REAL_FILENAME' => $row['real_filename'], 'COMMENT' => nl2br($row['attach_comment']), 'EXTENSION' => $row['extension'], 'SIZE' => get_formatted_filesize($row['filesize']), 'DOWNLOAD_COUNT' => $row['download_count'], 'POST_TIME' => $user->format_date($row['filetime']), 'TOPIC_TITLE' => $row['in_message'] ? $row['message_title'] : $row['topic_title'], 'ATTACH_ID' => $row['attach_id'], 'POST_ID' => $row['post_msg_id'], 'TOPIC_ID' => $row['topic_id'], 'S_IN_MESSAGE' => $row['in_message'], 'U_DOWNLOAD' => append_sid("{$phpbb_root_path}download/file.{$phpEx}", 'mode=view&id=' . $row['attach_id']), 'U_VIEW_TOPIC' => $view_topic)); } $db->sql_freeresult($result); $base_url = $this->u_action . "&u={$user_id}&sk={$sort_key}&sd={$sort_dir}"; $pagination->generate_template_pagination($base_url, 'pagination', 'start', $num_attachments, $config['topics_per_page'], $start); $template->assign_vars(array('S_ATTACHMENTS' => true, 'S_SORT_KEY' => $s_sort_key, 'S_SORT_DIR' => $s_sort_dir)); break; case 'groups': if (!function_exists('group_user_attributes')) { include $phpbb_root_path . 'includes/functions_user.' . $phpEx; } $user->add_lang(array('groups', 'acp/groups')); $group_id = $request->variable('g', 0); if ($group_id) { // Check the founder only entry for this group to make sure everything is well $sql = 'SELECT group_founder_manage FROM ' . GROUPS_TABLE . ' WHERE group_id = ' . $group_id; $result = $db->sql_query($sql); $founder_manage = (int) $db->sql_fetchfield('group_founder_manage'); $db->sql_freeresult($result); if ($user->data['user_type'] != USER_FOUNDER && $founder_manage) { trigger_error($user->lang['NOT_ALLOWED_MANAGE_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } } switch ($action) { case 'demote': case 'promote': case 'default': if (!$group_id) { trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } group_user_attributes($action, $group_id, $user_id); if ($action == 'default') { $user_row['group_id'] = $group_id; } break; case 'delete': if (confirm_box(true)) { if (!$group_id) { trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if ($error = group_user_del($group_id, $user_id)) { trigger_error($user->lang[$error] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } $error = array(); // The delete action was successful - therefore update the user row... $sql = 'SELECT u.*, s.* FROM ' . USERS_TABLE . ' u LEFT JOIN ' . SESSIONS_TABLE . ' s ON (s.session_user_id = u.user_id) WHERE u.user_id = ' . $user_id . ' ORDER BY s.session_time DESC'; $result = $db->sql_query_limit($sql, 1); $user_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); } else { confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'g' => $group_id))); } break; case 'approve': if (confirm_box(true)) { if (!$group_id) { trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } group_user_attributes($action, $group_id, $user_id); } else { confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'g' => $group_id))); } break; } // Add user to group? if ($submit) { if (!check_form_key($form_name)) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } if (!$group_id) { trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } // Add user/s to group if ($error = group_user_add($group_id, $user_id)) { trigger_error($user->lang[$error] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } $error = array(); } /** @var \phpbb\group\helper $group_helper */ $group_helper = $phpbb_container->get('group_helper'); $sql = 'SELECT ug.*, g.* FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . " ug\n\t\t\t\t\tWHERE ug.user_id = {$user_id}\n\t\t\t\t\t\tAND g.group_id = ug.group_id\n\t\t\t\t\tORDER 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, group_founder_manage FROM ' . GROUPS_TABLE . ' ' . (sizeof($id_ary) ? 'WHERE ' . $db->sql_in_set('group_id', $id_ary, true) : '') . ' ORDER BY group_type DESC, group_name ASC'; $result = $db->sql_query($sql); $s_group_options = ''; while ($row = $db->sql_fetchrow($result)) { if (!$config['coppa_enable'] && $row['group_name'] == 'REGISTERED_COPPA') { continue; } // Do not display those groups not allowed to be managed if ($user->data['user_type'] != USER_FOUNDER && $row['group_founder_manage']) { continue; } $s_group_options .= '<option' . ($row['group_type'] == GROUP_SPECIAL ? ' class="sep"' : '') . ' value="' . $row['group_id'] . '">' . $group_helper->get_name($row['group_name']) . '</option>'; } $db->sql_freeresult($result); $current_type = ''; foreach ($group_data as $group_type => $data_ary) { if ($current_type != $group_type) { $template->assign_block_vars('group', array('S_NEW_GROUP_TYPE' => true, 'GROUP_TYPE' => $user->lang['USER_GROUP_' . strtoupper($group_type)])); } foreach ($data_ary as $data) { $template->assign_block_vars('group', array('U_EDIT_GROUP' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=groups&mode=manage&action=edit&u={$user_id}&g={$data['group_id']}&back_link=acp_users_groups"), 'U_DEFAULT' => $this->u_action . "&action=default&u={$user_id}&g=" . $data['group_id'], 'U_DEMOTE_PROMOTE' => $this->u_action . '&action=' . ($data['group_leader'] ? 'demote' : 'promote') . "&u={$user_id}&g=" . $data['group_id'], 'U_DELETE' => $this->u_action . "&action=delete&u={$user_id}&g=" . $data['group_id'], 'U_APPROVE' => $group_type == 'pending' ? $this->u_action . "&action=approve&u={$user_id}&g=" . $data['group_id'] : '', 'GROUP_NAME' => $group_type == 'special' ? $user->lang['G_' . $data['group_name']] : $data['group_name'], 'L_DEMOTE_PROMOTE' => $data['group_leader'] ? $user->lang['GROUP_DEMOTE'] : $user->lang['GROUP_PROMOTE'], 'S_IS_MEMBER' => $group_type != 'pending' ? true : false, 'S_NO_DEFAULT' => $user_row['group_id'] != $data['group_id'] ? true : false, 'S_SPECIAL_GROUP' => $group_type == 'special' ? true : false)); } } $template->assign_vars(array('S_GROUPS' => true, 'S_GROUP_OPTIONS' => $s_group_options)); break; case 'perm': if (!class_exists('auth_admin')) { include $phpbb_root_path . 'includes/acp/auth.' . $phpEx; } $auth_admin = new auth_admin(); $user->add_lang('acp/permissions'); add_permission_language(); $forum_id = $request->variable('f', 0); // Global Permissions if (!$forum_id) { // Select auth options $sql = 'SELECT auth_option, is_local, is_global FROM ' . ACL_OPTIONS_TABLE . ' WHERE auth_option ' . $db->sql_like_expression($db->get_any_char() . '_') . ' AND is_global = 1 ORDER BY auth_option'; $result = $db->sql_query($sql); $hold_ary = array(); while ($row = $db->sql_fetchrow($result)) { $hold_ary = $auth_admin->get_mask('view', $user_id, false, false, $row['auth_option'], 'global', ACL_NEVER); $auth_admin->display_mask('view', $row['auth_option'], $hold_ary, 'user', false, false); } $db->sql_freeresult($result); unset($hold_ary); } else { $sql = 'SELECT auth_option, is_local, is_global FROM ' . ACL_OPTIONS_TABLE . "\n\t\t\t\t\t\tWHERE auth_option " . $db->sql_like_expression($db->get_any_char() . '_') . "\n\t\t\t\t\t\t\tAND is_local = 1\n\t\t\t\t\t\tORDER BY is_global DESC, auth_option"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $hold_ary = $auth_admin->get_mask('view', $user_id, false, $forum_id, $row['auth_option'], 'local', ACL_NEVER); $auth_admin->display_mask('view', $row['auth_option'], $hold_ary, 'user', true, false); } $db->sql_freeresult($result); } $s_forum_options = '<option value="0"' . (!$forum_id ? ' selected="selected"' : '') . '>' . $user->lang['VIEW_GLOBAL_PERMS'] . '</option>'; $s_forum_options .= make_forum_select($forum_id, false, true, false, false, false); $template->assign_vars(array('S_PERMISSIONS' => true, 'S_GLOBAL' => !$forum_id ? true : false, 'S_FORUM_OPTIONS' => $s_forum_options, 'U_ACTION' => $this->u_action . '&u=' . $user_id, 'U_USER_PERMISSIONS' => append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=permissions&mode=setting_user_global&user_id[]=' . $user_id), 'U_USER_FORUM_PERMISSIONS' => append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=permissions&mode=setting_user_local&user_id[]=' . $user_id))); break; } // Assign general variables $template->assign_vars(array('S_ERROR' => sizeof($error) ? true : false, 'ERROR_MSG' => sizeof($error) ? implode('<br />', $error) : '')); }
/** * Prune forums */ function prune_forums($id, $mode) { global $db, $user, $auth, $template, $cache, $phpbb_log, $request; global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; $all_forums = $request->variable('all_forums', 0); $forum_id = $request->variable('f', array(0)); $submit = isset($_POST['submit']) ? true : false; if ($all_forums) { $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . ' ORDER BY left_id'; $result = $db->sql_query($sql); $forum_id = array(); while ($row = $db->sql_fetchrow($result)) { $forum_id[] = $row['forum_id']; } $db->sql_freeresult($result); } if ($submit) { if (confirm_box(true)) { $prune_posted = $request->variable('prune_days', 0); $prune_viewed = $request->variable('prune_vieweddays', 0); $prune_all = !$prune_posted && !$prune_viewed ? true : false; $prune_flags = 0; $prune_flags += $request->variable('prune_old_polls', 0) ? 2 : 0; $prune_flags += $request->variable('prune_announce', 0) ? 4 : 0; $prune_flags += $request->variable('prune_sticky', 0) ? 8 : 0; // Convert days to seconds for timestamp functions... $prunedate_posted = time() - $prune_posted * 86400; $prunedate_viewed = time() - $prune_viewed * 86400; $template->assign_vars(array('S_PRUNED' => true)); $sql_forum = sizeof($forum_id) ? ' AND ' . $db->sql_in_set('forum_id', $forum_id) : ''; // Get a list of forum's or the data for the forum that we are pruning. $sql = 'SELECT forum_id, forum_name FROM ' . FORUMS_TABLE . ' WHERE forum_type = ' . FORUM_POST . "\n\t\t\t\t\t\t{$sql_forum}\n\t\t\t\t\tORDER BY left_id ASC"; $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) { $prune_ids = array(); $p_result['topics'] = 0; $p_result['posts'] = 0; $log_data = ''; do { if (!$auth->acl_get('f_list', $row['forum_id'])) { continue; } if ($prune_all) { $p_result = prune($row['forum_id'], 'posted', time(), $prune_flags, false); } else { if ($prune_posted) { $return = prune($row['forum_id'], 'posted', $prunedate_posted, $prune_flags, false); $p_result['topics'] += $return['topics']; $p_result['posts'] += $return['posts']; } if ($prune_viewed) { $return = prune($row['forum_id'], 'viewed', $prunedate_viewed, $prune_flags, false); $p_result['topics'] += $return['topics']; $p_result['posts'] += $return['posts']; } } $prune_ids[] = $row['forum_id']; $template->assign_block_vars('pruned', array('FORUM_NAME' => $row['forum_name'], 'NUM_TOPICS' => $p_result['topics'], 'NUM_POSTS' => $p_result['posts'])); $log_data .= ($log_data != '' ? ', ' : '') . $row['forum_name']; } while ($row = $db->sql_fetchrow($result)); // Sync all pruned forums at once sync('forum', 'forum_id', $prune_ids, true, true); $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_PRUNE', false, array($log_data)); } $db->sql_freeresult($result); return; } else { confirm_box(false, $user->lang['PRUNE_FORUM_CONFIRM'], build_hidden_fields(array('i' => $id, 'mode' => $mode, 'submit' => 1, 'all_forums' => $all_forums, 'f' => $forum_id, 'prune_days' => $request->variable('prune_days', 0), 'prune_vieweddays' => $request->variable('prune_vieweddays', 0), 'prune_old_polls' => $request->variable('prune_old_polls', 0), 'prune_announce' => $request->variable('prune_announce', 0), 'prune_sticky' => $request->variable('prune_sticky', 0)))); } } // If they haven't selected a forum for pruning yet then // display a select box to use for pruning. if (!sizeof($forum_id)) { $template->assign_vars(array('U_ACTION' => $this->u_action, 'S_SELECT_FORUM' => true, 'S_FORUM_OPTIONS' => make_forum_select(false, false, false))); } else { $sql = 'SELECT forum_id, forum_name FROM ' . FORUMS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_id); $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); if (!$row) { $db->sql_freeresult($result); trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action), E_USER_WARNING); } $forum_list = $s_hidden_fields = ''; do { $forum_list .= ($forum_list != '' ? ', ' : '') . '<b>' . $row['forum_name'] . '</b>'; $s_hidden_fields .= '<input type="hidden" name="f[]" value="' . $row['forum_id'] . '" />'; } while ($row = $db->sql_fetchrow($result)); $db->sql_freeresult($result); $l_selected_forums = sizeof($forum_id) == 1 ? 'SELECTED_FORUM' : 'SELECTED_FORUMS'; $template->assign_vars(array('L_SELECTED_FORUMS' => $user->lang[$l_selected_forums], 'U_ACTION' => $this->u_action, 'U_BACK' => $this->u_action, 'FORUM_LIST' => $forum_list, 'S_HIDDEN_FIELDS' => $s_hidden_fields)); } }