Exemple #1
0
 /**
  * Shortcut method to get the link to a specified idea.
  * Optionally add mode and hash URL arguments.
  *
  * @param int    $idea_id int The ID of the idea.
  * @param string $mode    The mode argument (vote, delete, etc.)
  * @param bool   $hash    Add a link hash
  * @return string The route
  */
 public function get_idea_link($idea_id, $mode = '', $hash = false)
 {
     $params = array('idea_id' => $idea_id);
     $params = $mode ? array_merge($params, array('mode' => $mode)) : $params;
     $params = $hash ? array_merge($params, array('hash' => generate_link_hash("{$mode}_{$idea_id}"))) : $params;
     return $this->helper->route('phpbb_ideas_idea_controller', $params);
 }
 /**
  * Run tool.
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function run_tool()
 {
     $type = $this->request->variable('type', 'queue');
     $start = $this->request->variable('start', 0);
     $continue_start = null;
     switch ($type) {
         case 'queue':
             $continue_start = $this->sync_queue_topics($start);
             if ($continue_start === null) {
                 $type = 'contrib';
                 $continue_start = 0;
             }
             break;
         case 'contrib':
             $continue_start = $this->sync_contrib_topics($start);
             break;
     }
     if ($continue_start !== null) {
         $params = array('tool' => 'rebuild_topic_urls', 'type' => $type, 'submit' => 1, 'hash' => generate_link_hash('manage'), 'start' => $continue_start);
         meta_refresh(2, $this->controller_helper->route('phpbb.titania.administration.tool', $params));
     }
     $msg = $continue_start !== null ? 'PLEASE_WAIT_FOR_TOOL' : 'DONE';
     $this->template->assign_vars(array('MESSAGE_TEXT' => $this->user->lang($msg), 'MESSAGE_TITLE' => $this->user->lang('INFORMATION')));
     return $this->controller_helper->render('message_body.html', $msg);
 }
Exemple #3
0
 /**
  * Configure Plupload for use under Titania.
  *
  * @param \phpbb\titania\config\config $ext_config
  * @param \phpbb\template\template $template
  * @param $s_action
  * @param $object_type
  * @param $max_files
  * @param $max_filesize
  */
 public function configure_ext(\phpbb\titania\config\config $ext_config, \phpbb\template\template $template, $s_action, $object_type, $max_files, $max_filesize)
 {
     $filters = $this->generate_filter_string_ext($ext_config, $object_type);
     $chunk_size = $this->get_chunk_size();
     $resize = $this->generate_resize_string();
     $template->assign_vars(array('S_RESIZE' => $resize, 'S_PLUPLOAD_EXT' => true, 'FILTERS' => $filters, 'CHUNK_SIZE' => $chunk_size, 'S_PLUPLOAD_URL' => htmlspecialchars_decode($s_action), 'MAX_ATTACHMENTS' => $max_files, 'ATTACH_ORDER' => $this->config['display_order'] ? 'asc' : 'desc', 'L_TOO_MANY_ATTACHMENTS' => $this->user->lang('TOO_MANY_ATTACHMENTS', $max_files), 'FILESIZE' => $max_filesize, 'S_PLUPLOAD_KEY' => generate_link_hash('plupload_key')));
     $this->user->add_lang('plupload');
 }
 /**
  * Add some additional elements to the BBCodes template
  *
  * @param object $event The event object
  * @return null
  * @access public
  */
 public function acp_bbcodes_custom_sorting_buttons($event)
 {
     $row = $event['row'];
     $bbcodes_array = $event['bbcodes_array'];
     $bbcodes_array['U_MOVE_UP'] = $event['u_action'] . '&action=move_up&id=' . $row['bbcode_id'] . '&hash=' . generate_link_hash('move_up' . $row['bbcode_id']);
     $bbcodes_array['U_MOVE_DOWN'] = $event['u_action'] . '&action=move_down&id=' . $row['bbcode_id'] . '&hash=' . generate_link_hash('move_down' . $row['bbcode_id']);
     $event['bbcodes_array'] = $bbcodes_array;
 }
Exemple #5
0
 /**
  * {@inheritdoc}
  */
 public function get_template_center($module_id)
 {
     if (!function_exists('display_forums')) {
         include $this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext;
     }
     \display_forums('', $this->config['load_moderators'], false);
     $this->template->assign_vars(array('FORUM_IMG' => $this->user->img('forum_read', 'NO_NEW_POSTS'), 'FORUM_NEW_IMG' => $this->user->img('forum_unread', 'NEW_POSTS'), 'FORUM_LOCKED_IMG' => $this->user->img('forum_read_locked', 'NO_NEW_POSTS_LOCKED'), 'FORUM_NEW_LOCKED_IMG' => $this->user->img('forum_unread_locked', 'NO_NEW_POSTS_LOCKED'), 'U_MARK_FORUMS' => $this->user->data['is_registered'] || $this->config['load_anon_lastread'] ? append_sid("{$this->phpbb_root_path}index.{$this->php_ext}", 'hash=' . generate_link_hash('global') . '&mark=forums') : '', 'U_MCP' => $this->auth->acl_get('m_') || $this->auth->acl_getf_global('m_') ? append_sid("{$this->phpbb_root_path}mcp.{$this->php_ext}", 'i=main&mode=front', true, $this->user->session_id) : ''));
     return 'forumlist.html';
 }
 /**
  * Set category display states
  *
  * @param object $event The event object
  *
  * @return null
  * @access public
  */
 public function show_collapsible_categories($event)
 {
     if (!isset($this->categories)) {
         $this->categories = $this->operator->get_user_categories();
     }
     $fid = 'fid_' . $event['row']['forum_id'];
     $row = isset($event['cat_row']) ? 'cat_row' : 'forum_row';
     $event_row = $event[$row];
     $event_row += array('S_FORUM_HIDDEN' => in_array($fid, $this->categories), 'U_COLLAPSE_URL' => $this->helper->route('phpbb_collapsiblecategories_main_controller', array('forum_id' => $fid, 'hash' => generate_link_hash("collapsible_{$fid}"))));
     $event[$row] = $event_row;
 }
 /**
  * {@inheritdoc}
  */
 public function display_autogroups()
 {
     // Get all auto groups data from the database
     $autogroup_rows = $this->get_all_autogroups();
     // Process all auto groups data for display in the template
     foreach ($autogroup_rows as $row) {
         $this->template->assign_block_vars('autogroups', array('GROUP_NAME' => $row['group_name'], 'CONDITION_NAME' => $this->manager->get_condition_lang($row['autogroups_type_name']), 'MIN_VALUE' => $row['autogroups_min_value'], 'MAX_VALUE' => $row['autogroups_max_value'], 'S_DEFAULT' => $row['autogroups_default'], 'S_NOTIFY' => $row['autogroups_notify'], 'U_EDIT' => "{$this->u_action}&action=edit&autogroups_id=" . $row['autogroups_id'], 'U_DELETE' => "{$this->u_action}&action=delete&autogroups_id=" . $row['autogroups_id'], 'U_SYNC' => "{$this->u_action}&action=sync&autogroups_id=" . $row['autogroups_id'] . '&hash=' . generate_link_hash('sync' . $row['autogroups_id'])));
     }
     $this->template->assign_vars(array('U_ACTION' => $this->u_action, 'U_ADD_AUTOGROUP_RULE' => "{$this->u_action}&action=add"));
     // Display the group exemption select box
     $this->display_group_exempt_options();
 }
 function run_tool()
 {
     $section = phpbb::$request->variable('section', 0);
     $start = phpbb::$request->variable('start', 0);
     $limit = titania::$config->search_backend == 'solr' ? 250 : 100;
     $total = 0;
     $search_manager = phpbb::$container->get('phpbb.titania.search.manager');
     $sync = phpbb::$container->get('phpbb.titania.sync');
     switch ($section) {
         case 0:
             $search_manager->truncate();
             $display_message = 'TRUNCATING_SEARCH';
             break;
         case 1:
             $sql = 'SELECT COUNT(contrib_id) AS cnt FROM ' . TITANIA_CONTRIBS_TABLE;
             phpbb::$db->sql_query($sql);
             $total = phpbb::$db->sql_fetchfield('cnt');
             phpbb::$db->sql_freeresult();
             $sync->contribs('index', false, $start, $limit);
             $display_message = 'INDEXING_CONTRIBS';
             break;
         case 2:
             $sql = 'SELECT COUNT(post_id) AS cnt FROM ' . TITANIA_POSTS_TABLE;
             phpbb::$db->sql_query($sql);
             $total = phpbb::$db->sql_fetchfield('cnt');
             phpbb::$db->sql_freeresult();
             $sync->posts('index', $start, $limit);
             $display_message = 'INDEXING_POSTS';
             break;
         case 3:
             $sql = 'SELECT COUNT(faq_id) AS cnt FROM ' . TITANIA_CONTRIB_FAQ_TABLE;
             phpbb::$db->sql_query($sql);
             $total = phpbb::$db->sql_fetchfield('cnt');
             phpbb::$db->sql_freeresult();
             $sync->faqs('index', $start, $limit);
             $display_message = 'INDEXING_FAQ';
             break;
         case 4:
             trigger_error('DONE');
             break;
     }
     $params = array('tool' => 'reindex', 'section' => $section, 'submit' => 1, 'hash' => generate_link_hash('manage'));
     if ($start + $limit >= $total) {
         $params['section']++;
     } else {
         $params['start'] = $start + $limit;
     }
     // Move to the next step
     meta_refresh(0, phpbb::$container->get('controller.helper')->route('phpbb.titania.administration.tool', $params));
     $display_message = phpbb::$user->lang[$display_message];
     $section_status = $start + $limit < $total ? sprintf(phpbb::$user->lang['SECTION_STATUS'], $start + $limit, $total) : phpbb::$user->lang['DONE'];
     trigger_error(sprintf(phpbb::$user->lang['REINDEX_STATUS'], $display_message, $section, $section_status));
 }
Exemple #9
0
 function run_tool()
 {
     $section = request_var('section', 0);
     $start = request_var('start', 0);
     $limit = titania::$config->search_backend == 'solr' ? 1000 : 100;
     $total = 0;
     $sync = new titania_sync();
     switch ($section) {
         case 0:
             titania_search::truncate();
             $display_message = 'Truncating Search';
             break;
         case 1:
             $sql = 'SELECT COUNT(contrib_id) AS cnt FROM ' . TITANIA_CONTRIBS_TABLE;
             phpbb::$db->sql_query($sql);
             $total = phpbb::$db->sql_fetchfield('cnt');
             phpbb::$db->sql_freeresult();
             $sync->contribs('index', false, $start, $limit);
             $display_message = 'Indexing Contributions';
             break;
         case 2:
             $sql = 'SELECT COUNT(post_id) AS cnt FROM ' . TITANIA_POSTS_TABLE;
             phpbb::$db->sql_query($sql);
             $total = phpbb::$db->sql_fetchfield('cnt');
             phpbb::$db->sql_freeresult();
             $sync->posts('index', $start, $limit);
             $display_message = 'Indexing Posts';
             break;
         case 3:
             $sql = 'SELECT COUNT(faq_id) AS cnt FROM ' . TITANIA_CONTRIB_FAQ_TABLE;
             phpbb::$db->sql_query($sql);
             $total = phpbb::$db->sql_fetchfield('cnt');
             phpbb::$db->sql_freeresult();
             $sync->faqs('index', $start, $limit);
             $display_message = 'Indexing FAQ';
             break;
         case 4:
             trigger_back('Done!');
             break;
     }
     if ($start + $limit >= $total) {
         // Move to the next step
         meta_refresh(0, titania_url::build_url('manage/administration', array('t' => 'reindex', 'section' => $section + 1, 'submit' => 1, 'hash' => generate_link_hash('manage'))));
     } else {
         // Move to the next step
         meta_refresh(0, titania_url::build_url('manage/administration', array('t' => 'reindex', 'section' => $section, 'start' => $start + $limit, 'submit' => 1, 'hash' => generate_link_hash('manage'))));
     }
     trigger_error($display_message . ' - section ' . $section . ' of 3 - ' . ($start + $limit < $total ? 'part ' . ($start + $limit) . ' of ' . $total : 'Done'));
 }
	public function get_template_center($module_id)
	{
		global $config, $template, $user, $auth, $phpbb_root_path, $phpEx;

		display_forums('', $config['load_moderators'], false);

		$template->assign_vars(array(
			'FORUM_IMG'			=> $user->img('forum_read', 'NO_NEW_POSTS'),
			'FORUM_NEW_IMG'			=> $user->img('forum_unread', 'NEW_POSTS'),
			'FORUM_LOCKED_IMG'		=> $user->img('forum_read_locked', 'NO_NEW_POSTS_LOCKED'),
			'FORUM_NEW_LOCKED_IMG'		=> $user->img('forum_unread_locked', 'NO_NEW_POSTS_LOCKED'),
			'U_MARK_FORUMS'			=> ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&amp;mark=forums') : '',
			'U_MCP'				=> ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&amp;mode=front', true, $user->session_id) : '',
		));

		return 'forumlist.html';
	}
 /**
  * Shorten the amount of code required for some places
  *
  * @param mixed $object_type
  * @param mixed $object_id
  * @param mixed $url
  */
 public static function handle_subscriptions($object_type, $object_id, $url)
 {
     if (!phpbb::$user->data['is_registered']) {
         // Cannot currently handle non-registered users
         return;
     }
     $subscribe = request_var('subscribe', '');
     if ($subscribe == 'subscribe' && check_link_hash(request_var('hash', ''), 'subscribe')) {
         titania_subscriptions::subscribe($object_type, $object_id);
     } else {
         if ($subscribe == 'unsubscribe' && check_link_hash(request_var('hash', ''), 'unsubscribe')) {
             titania_subscriptions::unsubscribe($object_type, $object_id);
         }
     }
     if (titania_subscriptions::is_subscribed($object_type, $object_id)) {
         phpbb::$template->assign_vars(array('IS_SUBSCRIBED' => true, 'U_SUBSCRIBE' => titania_url::append_url($url, array('subscribe' => 'unsubscribe', 'hash' => generate_link_hash('unsubscribe')))));
     } else {
         phpbb::$template->assign_vars(array('U_SUBSCRIBE' => titania_url::append_url($url, array('subscribe' => 'subscribe', 'hash' => generate_link_hash('subscribe')))));
     }
 }
Exemple #12
0
 public function main($id, $mode)
 {
     global $config, $template, $user, $request, $phpbb_container;
     global $phpbb_root_path, $phpEx;
     add_form_key('ucp_notification');
     $start = $request->variable('start', 0);
     $form_time = $request->variable('form_time', 0);
     $form_time = $form_time <= 0 || $form_time > time() ? time() : $form_time;
     /* @var $phpbb_notifications \phpbb\notification\manager */
     $phpbb_notifications = $phpbb_container->get('notification_manager');
     /* @var $pagination \phpbb\pagination */
     $pagination = $phpbb_container->get('pagination');
     switch ($mode) {
         case 'notification_options':
             $subscriptions = $phpbb_notifications->get_global_subscriptions(false);
             // Add/remove subscriptions
             if ($request->is_set_post('submit')) {
                 if (!check_form_key('ucp_notification')) {
                     trigger_error('FORM_INVALID');
                 }
                 $notification_methods = $phpbb_notifications->get_subscription_methods();
                 foreach ($phpbb_notifications->get_subscription_types() as $group => $subscription_types) {
                     foreach ($subscription_types as $type => $data) {
                         foreach ($notification_methods as $method => $method_data) {
                             if ($request->is_set_post(str_replace('.', '_', $type . '_' . $method_data['id'])) && (!isset($subscriptions[$type]) || !in_array($method_data['id'], $subscriptions[$type]))) {
                                 $phpbb_notifications->add_subscription($type, 0, $method_data['id']);
                             } else {
                                 if (!$request->is_set_post(str_replace('.', '_', $type . '_' . $method_data['id'])) && isset($subscriptions[$type]) && in_array($method_data['id'], $subscriptions[$type])) {
                                     $phpbb_notifications->delete_subscription($type, 0, $method_data['id']);
                                 }
                             }
                         }
                         if ($request->is_set_post(str_replace('.', '_', $type) . '_notification') && !isset($subscriptions[$type])) {
                             $phpbb_notifications->add_subscription($type);
                         } else {
                             if (!$request->is_set_post(str_replace('.', '_', $type) . '_notification') && isset($subscriptions[$type])) {
                                 $phpbb_notifications->delete_subscription($type);
                             }
                         }
                     }
                 }
                 meta_refresh(3, $this->u_action);
                 $message = $user->lang['PREFERENCES_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
                 trigger_error($message);
             }
             $this->output_notification_methods($phpbb_notifications, $template, $user, 'notification_methods');
             $this->output_notification_types($subscriptions, $phpbb_notifications, $template, $user, 'notification_types');
             $this->tpl_name = 'ucp_notifications';
             $this->page_title = 'UCP_NOTIFICATION_OPTIONS';
             break;
         case 'notification_list':
         default:
             // Mark all items read
             if ($request->variable('mark', '') == 'all' && check_link_hash($request->variable('token', ''), 'mark_all_notifications_read')) {
                 $phpbb_notifications->mark_notifications_read(false, false, $user->data['user_id'], $form_time);
                 meta_refresh(3, $this->u_action);
                 $message = $user->lang['NOTIFICATIONS_MARK_ALL_READ_SUCCESS'];
                 if ($request->is_ajax()) {
                     $json_response = new \phpbb\json_response();
                     $json_response->send(array('MESSAGE_TITLE' => $user->lang['INFORMATION'], 'MESSAGE_TEXT' => $message, 'success' => true));
                 }
                 $message .= '<br /><br />' . $user->lang('RETURN_UCP', '<a href="' . $this->u_action . '">', '</a>');
                 trigger_error($message);
             }
             // Mark specific notifications read
             if ($request->is_set_post('submit')) {
                 if (!check_form_key('ucp_notification')) {
                     trigger_error('FORM_INVALID');
                 }
                 $mark_read = $request->variable('mark', array(0));
                 if (!empty($mark_read)) {
                     $phpbb_notifications->mark_notifications_read_by_id($mark_read, $form_time);
                 }
             }
             $notifications = $phpbb_notifications->load_notifications(array('start' => $start, 'limit' => $config['topics_per_page'], 'count_total' => true));
             foreach ($notifications['notifications'] as $notification) {
                 $template->assign_block_vars('notification_list', $notification->prepare_for_display());
             }
             $base_url = append_sid("{$phpbb_root_path}ucp.{$phpEx}", "i=ucp_notifications&amp;mode=notification_list");
             $start = $pagination->validate_start($start, $config['topics_per_page'], $notifications['total_count']);
             $pagination->generate_template_pagination($base_url, 'pagination', 'start', $notifications['total_count'], $config['topics_per_page'], $start);
             $template->assign_vars(array('TOTAL_COUNT' => $notifications['total_count'], 'U_MARK_ALL' => $base_url . '&amp;mark=all&amp;token=' . generate_link_hash('mark_all_notifications_read')));
             $this->tpl_name = 'ucp_notifications';
             $this->page_title = 'UCP_NOTIFICATION_LIST';
             break;
     }
     $template->assign_vars(array('TITLE' => $user->lang($this->page_title), 'TITLE_EXPLAIN' => $user->lang($this->page_title . '_EXPLAIN'), 'MODE' => $mode, 'FORM_TIME' => time()));
 }
Exemple #13
0
$topic_mod .= $auth->acl_get('m_', $forum_id) ? '<option value="topic_logs">' . $user->lang['VIEW_TOPIC_LOGS'] . '</option>' : '';
// If we've got a hightlight set pass it on to pagination.
$pagination = generate_pagination(append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$forum_id}&amp;t={$topic_id}" . (strlen($u_sort_param) ? "&amp;{$u_sort_param}" : '') . ($highlight_match ? "&amp;hilit={$highlight}" : '')), $total_posts, $config['posts_per_page'], $start);
// Navigation links
generate_forum_nav($topic_data);
// Forum Rules
generate_forum_rules($topic_data);
// Moderators
$forum_moderators = array();
get_moderators($forum_moderators, $forum_id);
// This is only used for print view so ...
$server_path = !$view ? $phpbb_root_path : generate_board_url() . '/';
// Replace naughty words in title
$topic_data['topic_title'] = censor_text($topic_data['topic_title']);
// Send vars to template
$template->assign_vars(array('FORUM_ID' => $forum_id, 'FORUM_NAME' => $topic_data['forum_name'], 'FORUM_DESC' => generate_text_for_display($topic_data['forum_desc'], $topic_data['forum_desc_uid'], $topic_data['forum_desc_bitfield'], $topic_data['forum_desc_options']), 'TOPIC_ID' => $topic_id, 'TOPIC_TITLE' => $topic_data['topic_title'], 'TOPIC_POSTER' => $topic_data['topic_poster'], 'TOPIC_AUTHOR_FULL' => get_username_string('full', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']), 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']), 'TOPIC_AUTHOR' => get_username_string('username', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']), 'PAGINATION' => $pagination, 'PAGE_NUMBER' => on_page($total_posts, $config['posts_per_page'], $start), 'TOTAL_POSTS' => $total_posts == 1 ? $user->lang['VIEW_TOPIC_POST'] : sprintf($user->lang['VIEW_TOPIC_POSTS'], $total_posts), 'U_MCP' => $auth->acl_get('m_', $forum_id) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=main&amp;mode=topic_view&amp;f={$forum_id}&amp;t={$topic_id}&amp;start={$start}" . (strlen($u_sort_param) ? "&amp;{$u_sort_param}" : ''), true, $user->session_id) : '', 'MODERATORS' => isset($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id]) ? implode(', ', $forum_moderators[$forum_id]) : '', 'POST_IMG' => $topic_data['forum_status'] == ITEM_LOCKED ? $user->img('button_topic_locked', 'FORUM_LOCKED') : $user->img('button_topic_new', 'POST_NEW_TOPIC'), 'QUOTE_IMG' => $user->img('icon_post_quote', 'REPLY_WITH_QUOTE'), 'REPLY_IMG' => $topic_data['forum_status'] == ITEM_LOCKED || $topic_data['topic_status'] == ITEM_LOCKED ? $user->img('button_topic_locked', 'TOPIC_LOCKED') : $user->img('button_topic_reply', 'REPLY_TO_TOPIC'), 'EDIT_IMG' => $user->img('icon_post_edit', 'EDIT_POST'), 'DELETE_IMG' => $user->img('icon_post_delete', 'DELETE_POST'), 'INFO_IMG' => $user->img('icon_post_info', 'VIEW_INFO'), 'PROFILE_IMG' => $user->img('icon_user_profile', 'READ_PROFILE'), 'SEARCH_IMG' => $user->img('icon_user_search', 'SEARCH_USER_POSTS'), 'PM_IMG' => $user->img('icon_contact_pm', 'SEND_PRIVATE_MESSAGE'), 'EMAIL_IMG' => $user->img('icon_contact_email', 'SEND_EMAIL'), 'WWW_IMG' => $user->img('icon_contact_www', 'VISIT_WEBSITE'), 'ICQ_IMG' => $user->img('icon_contact_icq', 'ICQ'), 'AIM_IMG' => $user->img('icon_contact_aim', 'AIM'), 'MSN_IMG' => $user->img('icon_contact_msnm', 'MSNM'), 'YIM_IMG' => $user->img('icon_contact_yahoo', 'YIM'), 'JABBER_IMG' => $user->img('icon_contact_jabber', 'JABBER'), 'REPORT_IMG' => $user->img('icon_post_report', 'REPORT_POST'), 'REPORTED_IMG' => $user->img('icon_topic_reported', 'POST_REPORTED'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'), 'WARN_IMG' => $user->img('icon_user_warn', 'WARN_USER'), 'S_IS_LOCKED' => $topic_data['topic_status'] == ITEM_UNLOCKED ? false : true, 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days, 'S_SINGLE_MODERATOR' => !empty($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id]) > 1 ? false : true, 'S_TOPIC_ACTION' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$forum_id}&amp;t={$topic_id}&amp;start={$start}"), 'S_TOPIC_MOD' => $topic_mod != '' ? '<select name="action" id="quick-mod-select">' . $topic_mod . '</select>' : '', 'S_MOD_ACTION' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "f={$forum_id}&amp;t={$topic_id}&amp;quickmod=1&amp;redirect=" . urlencode(str_replace('&amp;', '&', $viewtopic_url)), true, $user->session_id), 'S_VIEWTOPIC' => true, 'S_DISPLAY_SEARCHBOX' => $auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search'] ? true : false, 'S_SEARCHBOX_ACTION' => append_sid("{$phpbb_root_path}search.{$phpEx}", 't=' . $topic_id), 'S_DISPLAY_POST_INFO' => $topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? true : false, 'S_DISPLAY_REPLY_INFO' => $topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_reply', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? true : false, 'U_TOPIC' => "{$server_path}viewtopic.{$phpEx}?f={$forum_id}&amp;t={$topic_id}", 'U_FORUM' => $server_path, 'U_VIEW_TOPIC' => $viewtopic_url, 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $forum_id), 'U_VIEW_OLDER_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$forum_id}&amp;t={$topic_id}&amp;view=previous"), 'U_VIEW_NEWER_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$forum_id}&amp;t={$topic_id}&amp;view=next"), 'U_PRINT_TOPIC' => $auth->acl_get('f_print', $forum_id) ? $viewtopic_url . '&amp;view=print' : '', 'U_EMAIL_TOPIC' => $auth->acl_get('f_email', $forum_id) && $config['email_enable'] ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=email&amp;t={$topic_id}") : '', 'U_WATCH_TOPIC' => $s_watching_topic['link'], 'L_WATCH_TOPIC' => $s_watching_topic['title'], 'S_WATCHING_TOPIC' => $s_watching_topic['is_watching'], 'U_BOOKMARK_TOPIC' => $user->data['is_registered'] && $config['allow_bookmarks'] ? $viewtopic_url . '&amp;bookmark=1&amp;hash=' . generate_link_hash("topic_{$topic_id}") : '', 'L_BOOKMARK_TOPIC' => $user->data['is_registered'] && $config['allow_bookmarks'] && $topic_data['bookmarked'] ? $user->lang['BOOKMARK_TOPIC_REMOVE'] : $user->lang['BOOKMARK_TOPIC'], 'U_POST_NEW_TOPIC' => $auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS ? append_sid("{$phpbb_root_path}posting.{$phpEx}", "mode=post&amp;f={$forum_id}") : '', 'U_POST_REPLY_TOPIC' => $auth->acl_get('f_reply', $forum_id) || $user->data['user_id'] == ANONYMOUS ? append_sid("{$phpbb_root_path}posting.{$phpEx}", "mode=reply&amp;f={$forum_id}&amp;t={$topic_id}") : '', 'U_BUMP_TOPIC' => bump_topic_allowed($forum_id, $topic_data['topic_bumped'], $topic_data['topic_last_post_time'], $topic_data['topic_poster'], $topic_data['topic_last_poster_id']) ? append_sid("{$phpbb_root_path}posting.{$phpEx}", "mode=bump&amp;f={$forum_id}&amp;t={$topic_id}&amp;hash=" . generate_link_hash("topic_{$topic_id}")) : ''));
// Does this topic contain a poll?
if (!empty($topic_data['poll_start'])) {
    $sql = 'SELECT o.*, p.bbcode_bitfield, p.bbcode_uid
		FROM ' . POLL_OPTIONS_TABLE . ' o, ' . POSTS_TABLE . " p\n\t\tWHERE o.topic_id = {$topic_id}\n\t\t\tAND p.post_id = {$topic_data['topic_first_post_id']}\n\t\t\tAND p.topic_id = o.topic_id\n\t\tORDER BY o.poll_option_id";
    $result = $db->sql_query($sql);
    $poll_info = array();
    while ($row = $db->sql_fetchrow($result)) {
        $poll_info[] = $row;
    }
    $db->sql_freeresult($result);
    $cur_voted_id = array();
    if ($user->data['is_registered']) {
        $sql = 'SELECT poll_option_id
			FROM ' . POLL_VOTES_TABLE . '
			WHERE topic_id = ' . $topic_id . '
/**
* Generate page header
*/
function page_header($page_title = '', $display_online_list = false, $item_id = 0, $item = 'forum', $send_headers = true)
{
    global $db, $config, $template, $SID, $_SID, $_EXTRA_URL, $user, $auth, $phpEx, $phpbb_root_path;
    global $phpbb_dispatcher, $request, $phpbb_container, $phpbb_admin_path;
    if (defined('HEADER_INC')) {
        return;
    }
    define('HEADER_INC', true);
    // A listener can set this variable to `true` when it overrides this function
    $page_header_override = false;
    /**
     * Execute code and/or overwrite page_header()
     *
     * @event core.page_header
     * @var	string	page_title			Page title
     * @var	bool	display_online_list		Do we display online users list
     * @var	string	item				Restrict online users to a certain
     *									session item, e.g. forum for
     *									session_forum_id
     * @var	int		item_id				Restrict online users to item id
     * @var	bool	page_header_override	Shall we return instead of running
     *										the rest of page_header()
     * @since 3.1.0-a1
     */
    $vars = array('page_title', 'display_online_list', 'item_id', 'item', 'page_header_override');
    extract($phpbb_dispatcher->trigger_event('core.page_header', compact($vars)));
    if ($page_header_override) {
        return;
    }
    // gzip_compression
    if ($config['gzip_compress']) {
        // to avoid partially compressed output resulting in blank pages in
        // the browser or error messages, compression is disabled in a few cases:
        //
        // 1) if headers have already been sent, this indicates plaintext output
        //    has been started so further content must not be compressed
        // 2) the length of the current output buffer is non-zero. This means
        //    there is already some uncompressed content in this output buffer
        //    so further output must not be compressed
        // 3) if more than one level of output buffering is used because we
        //    cannot test all output buffer level content lengths. One level
        //    could be caused by php.ini output_buffering. Anything
        //    beyond that is manual, so the code wrapping phpBB in output buffering
        //    can easily compress the output itself.
        //
        if (@extension_loaded('zlib') && !headers_sent() && ob_get_level() <= 1 && ob_get_length() == 0) {
            ob_start('ob_gzhandler');
        }
    }
    $user->update_session_infos();
    // Generate logged in/logged out status
    if ($user->data['user_id'] != ANONYMOUS) {
        $u_login_logout = append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=logout', true, $user->session_id);
        $l_login_logout = $user->lang['LOGOUT'];
    } else {
        $u_login_logout = append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=login');
        $l_login_logout = $user->lang['LOGIN'];
    }
    // Last visit date/time
    $s_last_visit = $user->data['user_id'] != ANONYMOUS ? $user->format_date($user->data['session_last_visit']) : '';
    // Get users online list ... if required
    $l_online_users = $online_userlist = $l_online_record = $l_online_time = '';
    if ($config['load_online'] && $config['load_online_time'] && $display_online_list) {
        /**
         * Load online data:
         * For obtaining another session column use $item and $item_id in the function-parameter, whereby the column is session_{$item}_id.
         */
        $item_id = max($item_id, 0);
        $online_users = obtain_users_online($item_id, $item);
        $user_online_strings = obtain_users_online_string($online_users, $item_id, $item);
        $l_online_users = $user_online_strings['l_online_users'];
        $online_userlist = $user_online_strings['online_userlist'];
        $total_online_users = $online_users['total_online'];
        if ($total_online_users > $config['record_online_users']) {
            set_config('record_online_users', $total_online_users, true);
            set_config('record_online_date', time(), true);
        }
        $l_online_record = $user->lang('RECORD_ONLINE_USERS', (int) $config['record_online_users'], $user->format_date($config['record_online_date'], false, true));
        $l_online_time = $user->lang('VIEW_ONLINE_TIMES', (int) $config['load_online_time']);
    }
    $s_privmsg_new = false;
    // Check for new private messages if user is logged in
    if (!empty($user->data['is_registered'])) {
        if ($user->data['user_new_privmsg']) {
            if (!$user->data['user_last_privmsg'] || $user->data['user_last_privmsg'] > $user->data['session_last_visit']) {
                $sql = 'UPDATE ' . USERS_TABLE . '
					SET user_last_privmsg = ' . $user->data['session_last_visit'] . '
					WHERE user_id = ' . $user->data['user_id'];
                $db->sql_query($sql);
                $s_privmsg_new = true;
            } else {
                $s_privmsg_new = false;
            }
        } else {
            $s_privmsg_new = false;
        }
    }
    $forum_id = request_var('f', 0);
    $topic_id = request_var('t', 0);
    $s_feed_news = false;
    // Get option for news
    if ($config['feed_enable']) {
        $sql = 'SELECT forum_id
			FROM ' . FORUMS_TABLE . '
			WHERE ' . $db->sql_bit_and('forum_options', FORUM_OPTION_FEED_NEWS, '<> 0');
        $result = $db->sql_query_limit($sql, 1, 0, 600);
        $s_feed_news = (int) $db->sql_fetchfield('forum_id');
        $db->sql_freeresult($result);
    }
    // Determine board url - we may need it later
    $board_url = generate_board_url() . '/';
    // This path is sent with the base template paths in the assign_vars()
    // call below. We need to correct it in case we are accessing from a
    // controller because the web paths will be incorrect otherwise.
    $phpbb_path_helper = $phpbb_container->get('path_helper');
    $corrected_path = $phpbb_path_helper->get_web_root_path();
    $web_path = defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH ? $board_url : $corrected_path;
    // Send a proper content-language to the output
    $user_lang = $user->lang['USER_LANG'];
    if (strpos($user_lang, '-x-') !== false) {
        $user_lang = substr($user_lang, 0, strpos($user_lang, '-x-'));
    }
    $s_search_hidden_fields = array();
    if ($_SID) {
        $s_search_hidden_fields['sid'] = $_SID;
    }
    if (!empty($_EXTRA_URL)) {
        foreach ($_EXTRA_URL as $url_param) {
            $url_param = explode('=', $url_param, 2);
            $s_search_hidden_fields[$url_param[0]] = $url_param[1];
        }
    }
    $dt = $user->create_datetime();
    $timezone_offset = $user->lang(array('timezones', 'UTC_OFFSET'), phpbb_format_timezone_offset($dt->getOffset()));
    $timezone_name = $user->timezone->getName();
    if (isset($user->lang['timezones'][$timezone_name])) {
        $timezone_name = $user->lang['timezones'][$timezone_name];
    }
    // Output the notifications
    $notifications = false;
    if ($config['load_notifications'] && $user->data['user_id'] != ANONYMOUS && $user->data['user_type'] != USER_IGNORE) {
        $phpbb_notifications = $phpbb_container->get('notification_manager');
        $notifications = $phpbb_notifications->load_notifications(array('all_unread' => true, 'limit' => 5));
        foreach ($notifications['notifications'] as $notification) {
            $template->assign_block_vars('notifications', $notification->prepare_for_display());
        }
    }
    $notification_mark_hash = generate_link_hash('mark_all_notifications_read');
    // The following assigns all _common_ variables that may be used at any point in a template.
    $template->assign_vars(array('SITENAME' => $config['sitename'], 'SITE_DESCRIPTION' => $config['site_desc'], 'PAGE_TITLE' => $page_title, 'SCRIPT_NAME' => str_replace('.' . $phpEx, '', $user->page['page_name']), 'LAST_VISIT_DATE' => sprintf($user->lang['YOU_LAST_VISIT'], $s_last_visit), 'LAST_VISIT_YOU' => $s_last_visit, 'CURRENT_TIME' => sprintf($user->lang['CURRENT_TIME'], $user->format_date(time(), false, true)), 'TOTAL_USERS_ONLINE' => $l_online_users, 'LOGGED_IN_USER_LIST' => $online_userlist, 'RECORD_USERS' => $l_online_record, 'PRIVATE_MESSAGE_COUNT' => !empty($user->data['user_unread_privmsg']) ? $user->data['user_unread_privmsg'] : 0, 'CURRENT_USER_AVATAR' => phpbb_get_user_avatar($user->data), 'CURRENT_USERNAME_SIMPLE' => get_username_string('no_profile', $user->data['user_id'], $user->data['username'], $user->data['user_colour']), 'CURRENT_USERNAME_FULL' => get_username_string('full', $user->data['user_id'], $user->data['username'], $user->data['user_colour']), 'UNREAD_NOTIFICATIONS_COUNT' => $notifications !== false ? $notifications['unread_count'] : '', 'NOTIFICATIONS_COUNT' => $notifications !== false ? $notifications['unread_count'] : '', 'U_VIEW_ALL_NOTIFICATIONS' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=ucp_notifications'), 'U_MARK_ALL_NOTIFICATIONS' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=ucp_notifications&amp;mode=notification_list&amp;mark=all&amp;token=' . $notification_mark_hash), 'U_NOTIFICATION_SETTINGS' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=ucp_notifications&amp;mode=notification_options'), 'S_NOTIFICATIONS_DISPLAY' => $config['load_notifications'], 'S_USER_NEW_PRIVMSG' => $user->data['user_new_privmsg'], 'S_USER_UNREAD_PRIVMSG' => $user->data['user_unread_privmsg'], 'S_USER_NEW' => $user->data['user_new'], 'SID' => $SID, '_SID' => $_SID, 'SESSION_ID' => $user->session_id, 'ROOT_PATH' => $web_path, 'BOARD_URL' => $board_url, 'L_LOGIN_LOGOUT' => $l_login_logout, 'L_INDEX' => $config['board_index_text'] !== '' ? $config['board_index_text'] : $user->lang['FORUM_INDEX'], 'L_SITE_HOME' => $config['site_home_text'] !== '' ? $config['site_home_text'] : $user->lang['HOME'], 'L_ONLINE_EXPLAIN' => $l_online_time, 'U_PRIVATEMSGS' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&amp;folder=inbox'), 'U_RETURN_INBOX' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&amp;folder=inbox'), 'U_MEMBERLIST' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}"), 'U_VIEWONLINE' => $auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel') ? append_sid("{$phpbb_root_path}viewonline.{$phpEx}") : '', 'U_LOGIN_LOGOUT' => $u_login_logout, 'U_INDEX' => append_sid("{$phpbb_root_path}index.{$phpEx}"), 'U_SEARCH' => append_sid("{$phpbb_root_path}search.{$phpEx}"), 'U_SITE_HOME' => $config['site_home_url'], 'U_REGISTER' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=register'), 'U_PROFILE' => append_sid("{$phpbb_root_path}ucp.{$phpEx}"), 'U_USER_PROFILE' => get_username_string('profile', $user->data['user_id'], $user->data['username'], $user->data['user_colour']), 'U_MODCP' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", false, true, $user->session_id), 'U_FAQ' => append_sid("{$phpbb_root_path}faq.{$phpEx}"), 'U_SEARCH_SELF' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=egosearch'), 'U_SEARCH_NEW' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=newposts'), 'U_SEARCH_UNANSWERED' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=unanswered'), 'U_SEARCH_UNREAD' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=unreadposts'), 'U_SEARCH_ACTIVE_TOPICS' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'search_id=active_topics'), 'U_DELETE_COOKIES' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=delete_cookies'), 'U_CONTACT_US' => $config['contact_admin_form_enable'] && $config['email_enable'] ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=contactadmin') : '', 'U_TEAM' => $user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile') ? '' : append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=team'), 'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=terms'), 'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=privacy'), 'U_RESTORE_PERMISSIONS' => $user->data['user_perm_from'] && $auth->acl_get('a_switchperm') ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=restore_perm') : '', 'U_FEED' => generate_board_url() . "/feed.{$phpEx}", 'S_USER_LOGGED_IN' => $user->data['user_id'] != ANONYMOUS ? true : false, 'S_AUTOLOGIN_ENABLED' => $config['allow_autologin'] ? true : false, 'S_BOARD_DISABLED' => $config['board_disable'] ? true : false, 'S_REGISTERED_USER' => !empty($user->data['is_registered']) ? true : false, 'S_IS_BOT' => !empty($user->data['is_bot']) ? true : false, 'S_USER_LANG' => $user_lang, 'S_USER_BROWSER' => isset($user->data['session_browser']) ? $user->data['session_browser'] : $user->lang['UNKNOWN_BROWSER'], 'S_USERNAME' => $user->data['username'], 'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'], 'S_CONTENT_FLOW_BEGIN' => $user->lang['DIRECTION'] == 'ltr' ? 'left' : 'right', 'S_CONTENT_FLOW_END' => $user->lang['DIRECTION'] == 'ltr' ? 'right' : 'left', 'S_CONTENT_ENCODING' => 'UTF-8', 'S_TIMEZONE' => sprintf($user->lang['ALL_TIMES'], $timezone_offset, $timezone_name), 'S_DISPLAY_ONLINE_LIST' => $l_online_time ? 1 : 0, 'S_DISPLAY_SEARCH' => !$config['load_search'] ? 0 : (isset($auth) ? $auth->acl_get('u_search') && $auth->acl_getf_global('f_search') : 1), 'S_DISPLAY_PM' => $config['allow_privmsg'] && !empty($user->data['is_registered']) && ($auth->acl_get('u_readpm') || $auth->acl_get('u_sendpm')) ? true : false, 'S_DISPLAY_MEMBERLIST' => isset($auth) ? $auth->acl_get('u_viewprofile') : 0, 'S_NEW_PM' => $s_privmsg_new ? 1 : 0, 'S_REGISTER_ENABLED' => $config['require_activation'] != USER_ACTIVATION_DISABLE ? true : false, 'S_FORUM_ID' => $forum_id, 'S_TOPIC_ID' => $topic_id, 'S_LOGIN_ACTION' => !defined('ADMIN_START') ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=login') : append_sid("{$phpbb_admin_path}index.{$phpEx}", false, true, $user->session_id), 'S_LOGIN_REDIRECT' => build_hidden_fields(array('redirect' => $phpbb_path_helper->remove_web_root_path(build_url()))), 'S_ENABLE_FEEDS' => $config['feed_enable'] ? true : false, 'S_ENABLE_FEEDS_OVERALL' => $config['feed_overall'] ? true : false, 'S_ENABLE_FEEDS_FORUMS' => $config['feed_overall_forums'] ? true : false, 'S_ENABLE_FEEDS_TOPICS' => $config['feed_topics_new'] ? true : false, 'S_ENABLE_FEEDS_TOPICS_ACTIVE' => $config['feed_topics_active'] ? true : false, 'S_ENABLE_FEEDS_NEWS' => $s_feed_news ? true : false, 'S_LOAD_UNREADS' => $config['load_unreads_search'] && ($config['load_anon_lastread'] || $user->data['is_registered']) ? true : false, 'S_SEARCH_HIDDEN_FIELDS' => build_hidden_fields($s_search_hidden_fields), 'T_ASSETS_VERSION' => $config['assets_version'], 'T_ASSETS_PATH' => "{$web_path}assets", 'T_THEME_PATH' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme', 'T_TEMPLATE_PATH' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/template', 'T_SUPER_TEMPLATE_PATH' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/template', 'T_IMAGES_PATH' => "{$web_path}images/", 'T_SMILIES_PATH' => "{$web_path}{$config['smilies_path']}/", 'T_AVATAR_PATH' => "{$web_path}{$config['avatar_path']}/", 'T_AVATAR_GALLERY_PATH' => "{$web_path}{$config['avatar_gallery_path']}/", 'T_ICONS_PATH' => "{$web_path}{$config['icons_path']}/", 'T_RANKS_PATH' => "{$web_path}{$config['ranks_path']}/", 'T_UPLOAD_PATH' => "{$web_path}{$config['upload_path']}/", 'T_STYLESHEET_LINK' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme/stylesheet.css?assets_version=' . $config['assets_version'], 'T_STYLESHEET_LANG_LINK' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme/' . $user->lang_name . '/stylesheet.css?assets_version=' . $config['assets_version'], 'T_JQUERY_LINK' => !empty($config['allow_cdn']) && !empty($config['load_jquery_url']) ? $config['load_jquery_url'] : "{$web_path}assets/javascript/jquery.min.js?assets_version=" . $config['assets_version'], 'S_ALLOW_CDN' => !empty($config['allow_cdn']), 'T_THEME_NAME' => rawurlencode($user->style['style_path']), 'T_THEME_LANG_NAME' => $user->data['user_lang'], 'T_TEMPLATE_NAME' => $user->style['style_path'], 'T_SUPER_TEMPLATE_NAME' => rawurlencode(isset($user->style['style_parent_tree']) && $user->style['style_parent_tree'] ? $user->style['style_parent_tree'] : $user->style['style_path']), 'T_IMAGES' => 'images', 'T_SMILIES' => $config['smilies_path'], 'T_AVATAR' => $config['avatar_path'], 'T_AVATAR_GALLERY' => $config['avatar_gallery_path'], 'T_ICONS' => $config['icons_path'], 'T_RANKS' => $config['ranks_path'], 'T_UPLOAD' => $config['upload_path'], 'SITE_LOGO_IMG' => $user->img('site_logo')));
    $http_headers = array();
    if ($send_headers) {
        // An array of http headers that phpbb will set. The following event may override these.
        $http_headers += array('Content-type' => 'text/html; charset=UTF-8', 'Cache-Control' => 'private, no-cache="set-cookie"', 'Expires' => gmdate('D, d M Y H:i:s', time()) . ' GMT');
        if (!empty($user->data['is_bot'])) {
            // Let reverse proxies know we detected a bot.
            $http_headers['X-PHPBB-IS-BOT'] = 'yes';
        }
    }
    /**
     * Execute code and/or overwrite _common_ template variables after they have been assigned.
     *
     * @event core.page_header_after
     * @var	string	page_title			Page title
     * @var	bool	display_online_list		Do we display online users list
     * @var	string	item				Restrict online users to a certain
     *									session item, e.g. forum for
     *									session_forum_id
     * @var	int		item_id				Restrict online users to item id
     * @var	array		http_headers			HTTP headers that should be set by phpbb
     *
     * @since 3.1.0-b3
     */
    $vars = array('page_title', 'display_online_list', 'item_id', 'item', 'http_headers');
    extract($phpbb_dispatcher->trigger_event('core.page_header_after', compact($vars)));
    foreach ($http_headers as $hname => $hval) {
        header((string) $hname . ': ' . (string) $hval);
    }
    return;
}
Exemple #15
0
	'U_VIEW_FORUM' 			=> append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id),
	'U_VIEW_OLDER_TOPIC'	=> append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;view=previous"),
	'U_VIEW_NEWER_TOPIC'	=> append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;view=next"),
	'U_PRINT_TOPIC'			=> ($auth->acl_get('f_print', $forum_id)) ? $viewtopic_url . '&amp;view=print' : '',
	'U_EMAIL_TOPIC'			=> ($auth->acl_get('f_email', $forum_id) && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=email&amp;t=$topic_id") : '',

	'U_WATCH_TOPIC' 		=> $s_watching_topic['link'],
	'L_WATCH_TOPIC' 		=> $s_watching_topic['title'],
	'S_WATCHING_TOPIC'		=> $s_watching_topic['is_watching'],

	'U_BOOKMARK_TOPIC'		=> ($user->data['is_registered'] && $config['allow_bookmarks']) ? $viewtopic_url . '&amp;bookmark=1&amp;hash=' . generate_link_hash("topic_$topic_id") : '',
	'L_BOOKMARK_TOPIC'		=> ($user->data['is_registered'] && $config['allow_bookmarks'] && $topic_data['bookmarked']) ? $user->lang['BOOKMARK_TOPIC_REMOVE'] : $user->lang['BOOKMARK_TOPIC'],

	'U_POST_NEW_TOPIC' 		=> ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=post&amp;f=$forum_id") : '',
	'U_POST_REPLY_TOPIC' 	=> ($auth->acl_get('f_reply', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=reply&amp;f=$forum_id&amp;t=$topic_id") : '',
	'U_BUMP_TOPIC'			=> (bump_topic_allowed($forum_id, $topic_data['topic_bumped'], $topic_data['topic_last_post_time'], $topic_data['topic_poster'], $topic_data['topic_last_poster_id'])) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=bump&amp;f=$forum_id&amp;t=$topic_id&amp;hash=" . generate_link_hash("topic_$topic_id")) : '')
);

// Does this topic contain a poll?
if (!empty($topic_data['poll_start']))
{
	$sql = 'SELECT o.*, p.bbcode_bitfield, p.bbcode_uid
		FROM ' . POLL_OPTIONS_TABLE . ' o, ' . POSTS_TABLE . " p
		WHERE o.topic_id = $topic_id
			AND p.post_id = {$topic_data['topic_first_post_id']}
			AND p.topic_id = o.topic_id
		ORDER BY o.poll_option_id";
	$result = $db->sql_query($sql);

	$poll_info = array();
	while ($row = $db->sql_fetchrow($result))
Exemple #16
0
    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&amp;form=select_user&amp;field=username&amp;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}&amp;u={$user_id}"), 'U_ACTION' => $this->u_action . '&amp;u=' . $user_id . (empty($redirect) ? '' : '&amp;' . $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 . '&amp;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 . '&amp;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 . '&amp;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 . '&amp;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 . '&amp;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 . '&amp;u=' . $user_id), E_USER_WARNING);
                            }
                            if ($user_id == ANONYMOUS) {
                                trigger_error($user->lang['CANNOT_BAN_ANONYMOUS'] . adm_back_link($this->u_action . '&amp;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 . '&amp;u=' . $user_id), E_USER_WARNING);
                            }
                            if (!check_form_key($form_name)) {
                                trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&amp;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 . '&amp;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 . '&amp;u=' . $user_id), E_USER_WARNING);
                            }
                            if (!check_form_key($form_name)) {
                                trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&amp;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 . '&amp;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 . '&amp;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 . '&amp;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 . '&amp;u=' . $user_id), E_USER_WARNING);
                            }
                            if (!check_form_key($form_name)) {
                                trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&amp;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 . '&amp;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 . '&amp;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 . '&amp;u=' . $user_id));
                            break;
                        case 'delsig':
                            if (!check_form_key($form_name)) {
                                trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&amp;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 . '&amp;u=' . $user_id));
                            break;
                        case 'delavatar':
                            if (!check_form_key($form_name)) {
                                trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&amp;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 . '&amp;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 . '&amp;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 . '&amp;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 . '&amp;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 . '&amp;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 . "&amp;action={$action}&amp;u={$user_id}", 'U_BACK' => $this->u_action . "&amp;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 . '&amp;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 . '&amp;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 . '&amp;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 . '&amp;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 . '&amp;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 . '&amp;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 . '&amp;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 . '&amp;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 . "&amp;u={$user_id}&amp;ip=" . ($ip == 'ip' ? 'hostname' : 'ip'), 'U_WHOIS' => $this->u_action . "&amp;action=whois&amp;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']}&amp;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&amp;u={$user_row['user_id']}&amp;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 . '&amp;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 . '&amp;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 . '&amp;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 . "&amp;u={$user_id}&amp;{$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 . '&amp;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 . '&amp;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 . '&amp;u=' . $user_id));
                                }
                            }
                        } else {
                            trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&amp;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 . '&amp;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 . '&amp;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 . '&amp;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 . '&amp;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 . '&amp;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&amp;p={$row['post_msg_id']}");
                    } else {
                        $view_topic = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "t={$row['topic_id']}&amp;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&amp;id=' . $row['attach_id']), 'U_VIEW_TOPIC' => $view_topic));
                }
                $db->sql_freeresult($result);
                $base_url = $this->u_action . "&amp;u={$user_id}&amp;sk={$sort_key}&amp;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 . '&amp;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 . '&amp;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 . '&amp;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 . '&amp;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 . '&amp;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 . '&amp;u=' . $user_id), E_USER_WARNING);
                    }
                    if (!$group_id) {
                        trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&amp;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 . '&amp;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&amp;mode=manage&amp;action=edit&amp;u={$user_id}&amp;g={$data['group_id']}&amp;back_link=acp_users_groups"), 'U_DEFAULT' => $this->u_action . "&amp;action=default&amp;u={$user_id}&amp;g=" . $data['group_id'], 'U_DEMOTE_PROMOTE' => $this->u_action . '&amp;action=' . ($data['group_leader'] ? 'demote' : 'promote') . "&amp;u={$user_id}&amp;g=" . $data['group_id'], 'U_DELETE' => $this->u_action . "&amp;action=delete&amp;u={$user_id}&amp;g=" . $data['group_id'], 'U_APPROVE' => $group_type == 'pending' ? $this->u_action . "&amp;action=approve&amp;u={$user_id}&amp;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 . '&amp;u=' . $user_id, 'U_USER_PERMISSIONS' => append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=permissions&amp;mode=setting_user_global&amp;user_id[]=' . $user_id), 'U_USER_FORUM_PERMISSIONS' => append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=permissions&amp;mode=setting_user_local&amp;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) : ''));
    }
Exemple #17
0
		FROM ' . USERS_TABLE . ' u
		LEFT JOIN ' . BANLIST_TABLE . " b ON (u.user_id = b.ban_userid)\n\t\tWHERE (b.ban_id IS NULL\n\t\t\tOR b.ban_exclude = 1)\n\t\t\tAND (u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%' {$leap_year_birthdays})\n\t\t\tAND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
    $result = $db->sql_query($sql);
    while ($row = $db->sql_fetchrow($result)) {
        $birthday_username = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
        $birthday_year = (int) substr($row['user_birthday'], -4);
        $birthday_age = $birthday_year ? max(0, $now['year'] - $birthday_year) : '';
        $template->assign_block_vars('birthdays', array('USERNAME' => $birthday_username, 'AGE' => $birthday_age));
        // For 3.0 compatibility
        if ($age = (int) substr($row['user_birthday'], -4)) {
            $birthday_list[] = $birthday_username . ($birthday_year ? ' (' . $birthday_age . ')' : '');
        }
    }
    $db->sql_freeresult($result);
}
// Assign index specific vars
$template->assign_vars(array('TOTAL_POSTS' => $user->lang('TOTAL_POSTS_COUNT', (int) $config['num_posts']), 'TOTAL_TOPICS' => $user->lang('TOTAL_TOPICS', (int) $config['num_topics']), 'TOTAL_USERS' => $user->lang('TOTAL_USERS', (int) $config['num_users']), 'NEWEST_USER' => $user->lang('NEWEST_USER', get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])), 'LEGEND' => $legend, 'BIRTHDAY_LIST' => empty($birthday_list) ? '' : implode($user->lang['COMMA_SEPARATOR'], $birthday_list), 'FORUM_IMG' => $user->img('forum_read', 'NO_UNREAD_POSTS'), 'FORUM_UNREAD_IMG' => $user->img('forum_unread', 'UNREAD_POSTS'), 'FORUM_LOCKED_IMG' => $user->img('forum_read_locked', 'NO_UNREAD_POSTS_LOCKED'), 'FORUM_UNREAD_LOCKED_IMG' => $user->img('forum_unread_locked', 'UNREAD_POSTS_LOCKED'), 'S_LOGIN_ACTION' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=login'), 'U_SEND_PASSWORD' => $config['email_enable'] ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=sendpassword') : '', 'S_DISPLAY_BIRTHDAY_LIST' => $config['load_birthdays'] ? true : false, 'S_INDEX' => true, 'U_MARK_FORUMS' => $user->data['is_registered'] || $config['load_anon_lastread'] ? append_sid("{$phpbb_root_path}index.{$phpEx}", 'hash=' . generate_link_hash('global') . '&amp;mark=forums&amp;mark_time=' . time()) : '', 'U_MCP' => $auth->acl_get('m_') || $auth->acl_getf_global('m_') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=main&amp;mode=front', true, $user->session_id) : ''));
$page_title = $config['board_index_text'] !== '' ? $config['board_index_text'] : $user->lang['INDEX'];
/**
* You can use this event to modify the page title and load data for the index
*
* @event core.index_modify_page_title
* @var	string	page_title		Title of the index page
* @since 3.1.0-a1
*/
$vars = array('page_title');
extract($phpbb_dispatcher->trigger_event('core.index_modify_page_title', compact($vars)));
// Output page
page_header($page_title, true);
$template->set_filenames(array('body' => 'index_body.html'));
page_footer();
Exemple #18
0
* @var	int		post_id				Post ID
* @var	array	quickmod_array		Array with quick moderation options data
* @var	int		start				Pagination information
* @var	array	topic_data			Array with topic data
* @var	int		topic_id			Topic ID
* @var	array	topic_tracking_info	Array with topic tracking data
* @var	int		total_posts			Topic total posts count
* @var	string	viewtopic_url		URL to the topic page
* @since 3.1.0-RC4
* @change 3.1.2-RC1 Added viewtopic_url
*/
$vars = array('base_url', 'forum_id', 'post_id', 'quickmod_array', 'start', 'topic_data', 'topic_id', 'topic_tracking_info', 'total_posts', 'viewtopic_url');
extract($phpbb_dispatcher->trigger_event('core.viewtopic_assign_template_vars_before', compact($vars)));
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_posts, $config['posts_per_page'], $start);
// Send vars to template
$template->assign_vars(array('FORUM_ID' => $forum_id, 'FORUM_NAME' => $topic_data['forum_name'], 'FORUM_DESC' => generate_text_for_display($topic_data['forum_desc'], $topic_data['forum_desc_uid'], $topic_data['forum_desc_bitfield'], $topic_data['forum_desc_options']), 'TOPIC_ID' => $topic_id, 'TOPIC_TITLE' => $topic_data['topic_title'], 'TOPIC_POSTER' => $topic_data['topic_poster'], 'TOPIC_AUTHOR_FULL' => get_username_string('full', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']), 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']), 'TOPIC_AUTHOR' => get_username_string('username', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']), 'TOTAL_POSTS' => $user->lang('VIEW_TOPIC_POSTS', (int) $total_posts), 'U_MCP' => $auth->acl_get('m_', $forum_id) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=main&amp;mode=topic_view&amp;f={$forum_id}&amp;t={$topic_id}" . ($start == 0 ? '' : "&amp;start={$start}") . (strlen($u_sort_param) ? "&amp;{$u_sort_param}" : ''), true, $user->session_id) : '', 'MODERATORS' => isset($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id]) ? implode($user->lang['COMMA_SEPARATOR'], $forum_moderators[$forum_id]) : '', 'POST_IMG' => $topic_data['forum_status'] == ITEM_LOCKED ? $user->img('button_topic_locked', 'FORUM_LOCKED') : $user->img('button_topic_new', 'POST_NEW_TOPIC'), 'QUOTE_IMG' => $user->img('icon_post_quote', 'REPLY_WITH_QUOTE'), 'REPLY_IMG' => $topic_data['forum_status'] == ITEM_LOCKED || $topic_data['topic_status'] == ITEM_LOCKED ? $user->img('button_topic_locked', 'TOPIC_LOCKED') : $user->img('button_topic_reply', 'REPLY_TO_TOPIC'), 'EDIT_IMG' => $user->img('icon_post_edit', 'EDIT_POST'), 'DELETE_IMG' => $user->img('icon_post_delete', 'DELETE_POST'), 'DELETED_IMG' => $user->img('icon_topic_deleted', 'POST_DELETED_RESTORE'), 'INFO_IMG' => $user->img('icon_post_info', 'VIEW_INFO'), 'PROFILE_IMG' => $user->img('icon_user_profile', 'READ_PROFILE'), 'SEARCH_IMG' => $user->img('icon_user_search', 'SEARCH_USER_POSTS'), 'PM_IMG' => $user->img('icon_contact_pm', 'SEND_PRIVATE_MESSAGE'), 'EMAIL_IMG' => $user->img('icon_contact_email', 'SEND_EMAIL'), 'JABBER_IMG' => $user->img('icon_contact_jabber', 'JABBER'), 'REPORT_IMG' => $user->img('icon_post_report', 'REPORT_POST'), 'REPORTED_IMG' => $user->img('icon_topic_reported', 'POST_REPORTED'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'), 'WARN_IMG' => $user->img('icon_user_warn', 'WARN_USER'), 'S_IS_LOCKED' => $topic_data['topic_status'] == ITEM_UNLOCKED && $topic_data['forum_status'] == ITEM_UNLOCKED ? false : true, 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days, 'S_SINGLE_MODERATOR' => !empty($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id]) > 1 ? false : true, 'S_TOPIC_ACTION' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$forum_id}&amp;t={$topic_id}" . ($start == 0 ? '' : "&amp;start={$start}")), 'S_MOD_ACTION' => $s_quickmod_action, 'L_RETURN_TO_FORUM' => $user->lang('RETURN_TO', $topic_data['forum_name']), 'S_VIEWTOPIC' => true, 'S_UNREAD_VIEW' => $view == 'unread', 'S_DISPLAY_SEARCHBOX' => $auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search'] ? true : false, 'S_SEARCHBOX_ACTION' => append_sid("{$phpbb_root_path}search.{$phpEx}"), 'S_SEARCH_LOCAL_HIDDEN_FIELDS' => build_hidden_fields($s_search_hidden_fields), 'S_DISPLAY_POST_INFO' => $topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? true : false, 'S_DISPLAY_REPLY_INFO' => $topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_reply', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? true : false, 'S_ENABLE_FEEDS_TOPIC' => $config['feed_topic'] && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $topic_data['forum_options']) ? true : false, 'U_TOPIC' => "{$server_path}viewtopic.{$phpEx}?f={$forum_id}&amp;t={$topic_id}", 'U_FORUM' => $server_path, 'U_VIEW_TOPIC' => $viewtopic_url, 'U_CANONICAL' => generate_board_url() . '/' . append_sid("viewtopic.{$phpEx}", "t={$topic_id}" . ($start ? "&amp;start={$start}" : ''), true, ''), 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $forum_id), 'U_VIEW_OLDER_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$forum_id}&amp;t={$topic_id}&amp;view=previous"), 'U_VIEW_NEWER_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$forum_id}&amp;t={$topic_id}&amp;view=next"), 'U_PRINT_TOPIC' => $auth->acl_get('f_print', $forum_id) ? $viewtopic_url . '&amp;view=print' : '', 'U_EMAIL_TOPIC' => $auth->acl_get('f_email', $forum_id) && $config['email_enable'] ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=email&amp;t={$topic_id}") : '', 'U_WATCH_TOPIC' => $s_watching_topic['link'], 'U_WATCH_TOPIC_TOGGLE' => $s_watching_topic['link_toggle'], 'S_WATCH_TOPIC_TITLE' => $s_watching_topic['title'], 'S_WATCH_TOPIC_TOGGLE' => $s_watching_topic['title_toggle'], 'S_WATCHING_TOPIC' => $s_watching_topic['is_watching'], 'U_BOOKMARK_TOPIC' => $user->data['is_registered'] && $config['allow_bookmarks'] ? $viewtopic_url . '&amp;bookmark=1&amp;hash=' . generate_link_hash("topic_{$topic_id}") : '', 'S_BOOKMARK_TOPIC' => $user->data['is_registered'] && $config['allow_bookmarks'] && $topic_data['bookmarked'] ? $user->lang['BOOKMARK_TOPIC_REMOVE'] : $user->lang['BOOKMARK_TOPIC'], 'S_BOOKMARK_TOGGLE' => !$user->data['is_registered'] || !$config['allow_bookmarks'] || !$topic_data['bookmarked'] ? $user->lang['BOOKMARK_TOPIC_REMOVE'] : $user->lang['BOOKMARK_TOPIC'], 'S_BOOKMARKED_TOPIC' => $user->data['is_registered'] && $config['allow_bookmarks'] && $topic_data['bookmarked'] ? true : false, 'U_POST_NEW_TOPIC' => $auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS ? append_sid("{$phpbb_root_path}posting.{$phpEx}", "mode=post&amp;f={$forum_id}") : '', 'U_POST_REPLY_TOPIC' => $auth->acl_get('f_reply', $forum_id) || $user->data['user_id'] == ANONYMOUS ? append_sid("{$phpbb_root_path}posting.{$phpEx}", "mode=reply&amp;f={$forum_id}&amp;t={$topic_id}") : '', 'U_BUMP_TOPIC' => bump_topic_allowed($forum_id, $topic_data['topic_bumped'], $topic_data['topic_last_post_time'], $topic_data['topic_poster'], $topic_data['topic_last_poster_id']) ? append_sid("{$phpbb_root_path}posting.{$phpEx}", "mode=bump&amp;f={$forum_id}&amp;t={$topic_id}&amp;hash=" . generate_link_hash("topic_{$topic_id}")) : ''));
// Does this topic contain a poll?
if (!empty($topic_data['poll_start'])) {
    $sql = 'SELECT o.*, p.bbcode_bitfield, p.bbcode_uid
		FROM ' . POLL_OPTIONS_TABLE . ' o, ' . POSTS_TABLE . " p\n\t\tWHERE o.topic_id = {$topic_id}\n\t\t\tAND p.post_id = {$topic_data['topic_first_post_id']}\n\t\t\tAND p.topic_id = o.topic_id\n\t\tORDER BY o.poll_option_id";
    $result = $db->sql_query($sql);
    $poll_info = $vote_counts = array();
    while ($row = $db->sql_fetchrow($result)) {
        $poll_info[] = $row;
        $option_id = (int) $row['poll_option_id'];
        $vote_counts[$option_id] = (int) $row['poll_option_total'];
    }
    $db->sql_freeresult($result);
    $cur_voted_id = array();
    if ($user->data['is_registered']) {
        $sql = 'SELECT poll_option_id
Exemple #19
0
 /**
  * The function that purges data of the specified extension.
  * @param string $ext_name The name of the extension.
  * @return bool
  */
 public static function purge($ext_name)
 {
     // What is a safe limit of execution time? Half the max execution time should be safe.
     $safe_time_limit = ini_get('max_execution_time') / 2;
     $start_time = time();
     // We do not check the metadata to be able to purge broken extensions.
     if (!$ext_name || $ext_name === objects::$upload_ext_name) {
         self::response(array('ext_name' => $ext_name, 'status' => 'error', 'error' => objects::$user->lang['EXT_ACTION_ERROR']));
         return false;
     }
     if (objects::$phpbb_extension_manager->is_enabled($ext_name)) {
         self::response(array('ext_name' => $ext_name, 'status' => 'error', 'error' => objects::$user->lang['EXT_CANNOT_BE_PURGED']));
         return false;
     }
     try {
         while (objects::$phpbb_extension_manager->purge_step($ext_name)) {
             // Are we approaching the time limit? If so we want to pause the update and continue after refreshing
             if (time() - $start_time >= $safe_time_limit) {
                 if (objects::$is_ajax) {
                     self::response(array('ext_name' => $ext_name, 'status' => 'force_update', 'hash' => generate_link_hash('purge.' . $ext_name)));
                 } else {
                     objects::$template->assign_var('S_NEXT_STEP', objects::$user->lang['EXTENSION_DELETE_DATA_IN_PROGRESS']);
                     meta_refresh(0, objects::$u_action . '&amp;action=purge&amp;hash=' . generate_link_hash('purge.' . $ext_name) . '&amp;ext_name=' . urlencode($ext_name));
                 }
                 return false;
             }
         }
         objects::$log->add('admin', objects::$user->data['user_id'], objects::$user->ip, 'LOG_EXT_PURGE', time(), array($ext_name));
     } catch (\phpbb\db\migration\exception $e) {
         self::response(array('ext_name' => $ext_name, 'status' => 'error', 'error' => $e->getLocalisedMessage(objects::$user)));
         return false;
     }
     self::response(array('ext_name' => $ext_name, 'status' => 'purged', 'refresh' => self::generate_refresh_link($ext_name)));
     return true;
 }
    /**
     * Run the tool
     */
    function run_tool()
    {
        // Define some vars that we'll need
        $start = request_var('start', 0);
        $limit = 100;
        // Create topic if it does not exist?
        $create_topic = true;
        titania::_include('functions_posting', 'phpbb_posting');
        titania::add_lang('contributions');
        $types = array();
        foreach (titania_types::$types as $id => $class) {
            if ($class->forum_robot && $class->forum_database) {
                $types[] = $id;
            }
        }
        if (!sizeof($types)) {
            trigger_back('UPDATE_RELEASE_TOPICS_COMPLETE');
        }
        $sql = 'SELECT COUNT(contrib_id) AS cnt FROM ' . TITANIA_CONTRIBS_TABLE . '
			WHERE ' . phpbb::$db->sql_in_set('contrib_status', array(TITANIA_CONTRIB_APPROVED, TITANIA_CONTRIB_DOWNLOAD_DISABLED)) . '
				AND ' . phpbb::$db->sql_in_set('contrib_type', $types);
        phpbb::$db->sql_query($sql);
        $total = phpbb::$db->sql_fetchfield('cnt');
        phpbb::$db->sql_freeresult();
        // Grab our batch
        $sql_ary = array('SELECT' => 'c.contrib_id, c.contrib_user_id, c.contrib_type, c.contrib_name, c.contrib_name_clean, c.contrib_desc, c.contrib_desc_uid, c.contrib_release_topic_id,
				t.topic_first_post_id,
				u.user_id, u.username, u.username_clean, u.user_colour', 'FROM' => array(TITANIA_CONTRIBS_TABLE => 'c', USERS_TABLE => 'u'), 'LEFT_JOIN' => array(array('FROM' => array(TOPICS_TABLE => 't'), 'ON' => 't.topic_id = c.contrib_release_topic_id')), 'GROUP_BY' => 'c.contrib_id', 'WHERE' => phpbb::$db->sql_in_set('c.contrib_status', array(TITANIA_CONTRIB_APPROVED, TITANIA_CONTRIB_DOWNLOAD_DISABLED)) . '
				AND u.user_id = c.contrib_user_id
				AND ' . phpbb::$db->sql_in_set('contrib_type', $types), 'ORDER_BY' => 'c.contrib_id DESC');
        $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
        $result = phpbb::$db->sql_query_limit($sql, $limit, $start);
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            // Grab the revisions
            $revisions = array();
            $sql = 'SELECT r.revision_id, r.attachment_id, r.revision_version, a.real_filename, a.filesize
				FROM ' . TITANIA_REVISIONS_TABLE . ' r, ' . TITANIA_ATTACHMENTS_TABLE . ' a
				WHERE r.contrib_id = ' . $row['contrib_id'] . '
					AND r.revision_status = ' . TITANIA_REVISION_APPROVED . '
					AND a.attachment_id = r.attachment_id';
            $rev_result = phpbb::$db->sql_query($sql);
            while ($rev_row = phpbb::$db->sql_fetchrow($rev_result)) {
                $revisions[$rev_row['revision_version']] = $rev_row;
            }
            phpbb::$db->sql_freeresult($rev_result);
            // Sort the revisions by their version, put the newest one in $revision
            uksort($revisions, 'reverse_version_compare');
            if (!sizeof($revisions)) {
                continue;
            }
            $revision = array_shift($revisions);
            users_overlord::$users[$row['user_id']] = $row;
            $contrib = new titania_contribution();
            $contrib->__set_array($row);
            $contrib->download = $row;
            // Update the release topic
            $contrib->update_release_topic();
        }
        phpbb::$db->sql_freeresult($result);
        if ($start + $limit >= $total) {
            trigger_back('UPDATE_RELEASE_TOPICS_COMPLETE');
        } else {
            meta_refresh(0, titania_url::build_url('manage/administration', array('t' => 'update_release_topics', 'start' => $start + $limit, 'submit' => 1, 'hash' => generate_link_hash('manage'))));
            trigger_error(phpbb::$user->lang('UPDATE_RELEASE_TOPICS_PROGRESS', $start + $limit, $total));
        }
    }
/**
* Topic and forum watching common code
*/
function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id, $notify_status = 'unset', $start = 0)
{
    global $template, $db, $user, $phpEx, $start, $phpbb_root_path;
    $table_sql = $mode == 'forum' ? FORUMS_WATCH_TABLE : TOPICS_WATCH_TABLE;
    $where_sql = $mode == 'forum' ? 'forum_id' : 'topic_id';
    $match_id = $mode == 'forum' ? $forum_id : $topic_id;
    $u_url = "uid={$user->data['user_id']}";
    $u_url .= $mode == 'forum' ? '&amp;f' : '&amp;f=' . $forum_id . '&amp;t';
    // Is user watching this thread?
    if ($user_id != ANONYMOUS) {
        $can_watch = true;
        if ($notify_status == 'unset') {
            $sql = "SELECT notify_status\n\t\t\t\tFROM {$table_sql}\n\t\t\t\tWHERE {$where_sql} = {$match_id}\n\t\t\t\t\tAND user_id = {$user_id}";
            $result = $db->sql_query($sql);
            $notify_status = ($row = $db->sql_fetchrow($result)) ? $row['notify_status'] : NULL;
            $db->sql_freeresult($result);
        }
        if (!is_null($notify_status) && $notify_status !== '') {
            if (isset($_GET['unwatch'])) {
                $uid = request_var('uid', 0);
                if ($uid != $user_id) {
                    $redirect_url = append_sid("{$phpbb_root_path}view{$mode}.{$phpEx}", "{$u_url}={$match_id}&amp;start={$start}");
                    $message = $user->lang['ERR_UNWATCHING'] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
                    trigger_error($message);
                }
                if ($_GET['unwatch'] == $mode) {
                    $is_watching = 0;
                    $sql = 'DELETE FROM ' . $table_sql . "\n\t\t\t\t\t\tWHERE {$where_sql} = {$match_id}\n\t\t\t\t\t\t\tAND user_id = {$user_id}";
                    $db->sql_query($sql);
                }
                $redirect_url = append_sid("{$phpbb_root_path}view{$mode}.{$phpEx}", "{$u_url}={$match_id}&amp;start={$start}");
                meta_refresh(3, $redirect_url);
                $message = $user->lang['NOT_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
                trigger_error($message);
            } else {
                $is_watching = true;
                if ($notify_status) {
                    $sql = 'UPDATE ' . $table_sql . "\n\t\t\t\t\t\tSET notify_status = 0\n\t\t\t\t\t\tWHERE {$where_sql} = {$match_id}\n\t\t\t\t\t\t\tAND user_id = {$user_id}";
                    $db->sql_query($sql);
                }
            }
        } else {
            if (isset($_GET['watch'])) {
                $token = request_var('hash', '');
                $redirect_url = append_sid("{$phpbb_root_path}view{$mode}.{$phpEx}", "{$u_url}={$match_id}&amp;start={$start}");
                if ($_GET['watch'] == $mode && check_link_hash($token, "{$mode}_{$match_id}")) {
                    $is_watching = true;
                    $sql = 'INSERT INTO ' . $table_sql . " (user_id, {$where_sql}, notify_status)\n\t\t\t\t\t\tVALUES ({$user_id}, {$match_id}, 0)";
                    $db->sql_query($sql);
                    $message = $user->lang['ARE_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
                } else {
                    $message = $user->lang['ERR_WATCHING'] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
                }
                meta_refresh(3, $redirect_url);
                trigger_error($message);
            } else {
                $is_watching = 0;
            }
        }
    } else {
        if (isset($_GET['unwatch']) && $_GET['unwatch'] == $mode) {
            login_box();
        } else {
            $can_watch = 0;
            $is_watching = 0;
        }
    }
    if ($can_watch) {
        $s_watching['link'] = append_sid("{$phpbb_root_path}view{$mode}.{$phpEx}", "{$u_url}={$match_id}&amp;" . ($is_watching ? 'unwatch' : 'watch') . "={$mode}&amp;start={$start}&amp;hash=" . generate_link_hash("{$mode}_{$match_id}"));
        $s_watching['title'] = $user->lang[($is_watching ? 'STOP' : 'START') . '_WATCHING_' . strtoupper($mode)];
        $s_watching['is_watching'] = $is_watching;
    }
    return;
}
Exemple #22
0
 /**
  * Display albums
  *
  * borrowed from phpBB3
  * @author: phpBB Group
  * @function: display_forums
  */
 public static function display_albums($root_data = '', $display_moderators = true, $return_moderators = false)
 {
     global $auth, $db, $template, $user;
     $album_rows = $subalbums = $album_ids = $album_ids_moderator = $album_moderators = $active_album_ary = array();
     $parent_id = $visible_albums = 0;
     $sql_from = '';
     $mode = request_var('mode', '');
     // Mark albums read?
     $mark_read = request_var('mark', '');
     if ($mark_read == 'all') {
         $mark_read = '';
     }
     if (!$root_data) {
         if ($mark_read == 'albums') {
             $mark_read = 'all';
         }
         $root_data = array('album_id' => self::PUBLIC_ALBUM);
         $sql_where = 'a.album_user_id = ' . self::PUBLIC_ALBUM;
     } else {
         if ($root_data == 'personal') {
             if ($mark_read == 'albums') {
                 $mark_read = 'all';
             }
             $root_data = array('album_id' => 0);
             //@todo: I think this is incorrect!?
             $sql_where = 'a.album_user_id > ' . self::PUBLIC_ALBUM;
             $num_pegas = phpbb_gallery_config::get('num_pegas');
             $first_char = request_var('first_char', '');
             if ($first_char == 'other') {
                 // Loop the ASCII: a-z
                 for ($i = 97; $i < 123; $i++) {
                     $sql_where .= ' AND u.username_clean NOT ' . $db->sql_like_expression(chr($i) . $db->any_char);
                 }
             } else {
                 if ($first_char) {
                     $sql_where .= ' AND u.username_clean ' . $db->sql_like_expression(substr($first_char, 0, 1) . $db->any_char);
                 }
             }
             if ($first_char) {
                 // We do not view all personal albums, so we need to recount, for the pagination.
                 $sql_array = array('SELECT' => 'count(a.album_id) as pgalleries', 'FROM' => array(GALLERY_ALBUMS_TABLE => 'a'), 'LEFT_JOIN' => array(array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 'u.user_id = a.album_user_id')), 'WHERE' => 'a.parent_id = 0 AND ' . $sql_where);
                 $sql = $db->sql_build_query('SELECT', $sql_array);
                 $result = $db->sql_query($sql);
                 $num_pegas = $db->sql_fetchfield('pgalleries');
                 $db->sql_freeresult($result);
             }
             $mode_personal = true;
             $start = request_var('start', 0);
             $limit = phpbb_gallery_config::get('pegas_per_page');
             $template->assign_vars(array('PAGINATION' => generate_pagination(phpbb_gallery_url::append_sid('index', 'mode=' . $mode . ($first_char ? '&amp;first_char=' . $first_char : '')), $num_pegas, $limit, $start), 'TOTAL_PGALLERIES_SHORT' => sprintf($user->lang['TOTAL_PGALLERIES_SHORT'], $num_pegas), 'PAGE_NUMBER' => on_page($num_pegas, $limit, $start)));
         } else {
             $sql_where = 'a.left_id > ' . $root_data['left_id'] . ' AND a.left_id < ' . $root_data['right_id'] . ' AND a.album_user_id = ' . $root_data['album_user_id'];
         }
     }
     $sql_array = array('SELECT' => 'a.*, at.mark_time', 'FROM' => array(GALLERY_ALBUMS_TABLE => 'a'), 'LEFT_JOIN' => array(array('FROM' => array(GALLERY_ATRACK_TABLE => 'at'), 'ON' => 'at.user_id = ' . $user->data['user_id'] . ' AND a.album_id = at.album_id')), 'ORDER_BY' => 'a.album_user_id, a.left_id');
     if (isset($mode_personal)) {
         $sql_array['LEFT_JOIN'][] = array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 'u.user_id = a.album_user_id');
         $sql_array['ORDER_BY'] = 'u.username_clean, a.left_id';
     }
     $sql_array['LEFT_JOIN'][] = array('FROM' => array(GALLERY_CONTESTS_TABLE => 'c'), 'ON' => 'c.contest_album_id = a.album_id');
     $sql_array['SELECT'] = $sql_array['SELECT'] . ', c.contest_marked';
     $sql = $db->sql_build_query('SELECT', array('SELECT' => $sql_array['SELECT'], 'FROM' => $sql_array['FROM'], 'LEFT_JOIN' => $sql_array['LEFT_JOIN'], 'WHERE' => $sql_where, 'ORDER_BY' => $sql_array['ORDER_BY']));
     $result = $db->sql_query($sql);
     $album_tracking_info = array();
     $branch_root_id = $root_data['album_id'];
     while ($row = $db->sql_fetchrow($result)) {
         $album_id = $row['album_id'];
         // Mark albums read?
         if ($mark_read == 'albums' || $mark_read == 'all') {
             if (phpbb_gallery::$auth->acl_check('a_list', $album_id, $row['album_user_id'])) {
                 $album_ids[] = $album_id;
                 continue;
             }
         }
         // Category with no members
         if (!$row['album_type'] && $row['left_id'] + 1 == $row['right_id']) {
             continue;
         }
         // Skip branch
         if (isset($right_id)) {
             if ($row['left_id'] < $right_id) {
                 continue;
             }
             unset($right_id);
         }
         if (!phpbb_gallery::$auth->acl_check('a_list', $album_id, $row['album_user_id'])) {
             // if the user does not have permissions to list this album, skip everything until next branch
             $right_id = $row['right_id'];
             continue;
         }
         $album_tracking_info[$album_id] = !empty($row['mark_time']) ? $row['mark_time'] : phpbb_gallery::$user->data('user_lastmark');
         $row['album_images'] = $row['album_images'];
         $row['album_images_real'] = $row['album_images_real'];
         if ($row['parent_id'] == $root_data['album_id'] || $row['parent_id'] == $branch_root_id) {
             if ($row['album_type']) {
                 $album_ids_moderator[] = (int) $album_id;
             }
             // Direct child of current branch
             $parent_id = $album_id;
             $album_rows[$album_id] = $row;
             if (!$row['album_type'] && $row['parent_id'] == $root_data['album_id']) {
                 $branch_root_id = $album_id;
             }
             $album_rows[$parent_id]['album_id_last_image'] = $row['album_id'];
             $album_rows[$parent_id]['album_type_last_image'] = $row['album_type'];
             $album_rows[$parent_id]['album_contest_marked'] = $row['contest_marked'];
             $album_rows[$parent_id]['orig_album_last_image_time'] = $row['album_last_image_time'];
         } else {
             if ($row['album_type']) {
                 $subalbums[$parent_id][$album_id]['display'] = $row['display_on_index'] ? true : false;
                 $subalbums[$parent_id][$album_id]['name'] = $row['album_name'];
                 $subalbums[$parent_id][$album_id]['orig_album_last_image_time'] = $row['album_last_image_time'];
                 $subalbums[$parent_id][$album_id]['children'] = array();
                 if (isset($subalbums[$parent_id][$row['parent_id']]) && !$row['display_on_index']) {
                     $subalbums[$parent_id][$row['parent_id']]['children'][] = $album_id;
                 }
                 $album_rows[$parent_id]['album_images'] += $row['album_images'];
                 $album_rows[$parent_id]['album_images_real'] += $row['album_images_real'];
                 if ($row['album_last_image_time'] > $album_rows[$parent_id]['album_last_image_time']) {
                     $album_rows[$parent_id]['album_last_image_id'] = $row['album_last_image_id'];
                     $album_rows[$parent_id]['album_last_image_name'] = $row['album_last_image_name'];
                     $album_rows[$parent_id]['album_last_image_time'] = $row['album_last_image_time'];
                     $album_rows[$parent_id]['album_last_user_id'] = $row['album_last_user_id'];
                     $album_rows[$parent_id]['album_last_username'] = $row['album_last_username'];
                     $album_rows[$parent_id]['album_last_user_colour'] = $row['album_last_user_colour'];
                     $album_rows[$parent_id]['album_type_last_image'] = $row['album_type'];
                     $album_rows[$parent_id]['album_contest_marked'] = $row['contest_marked'];
                     $album_rows[$parent_id]['album_id_last_image'] = $album_id;
                 }
             }
         }
     }
     $db->sql_freeresult($result);
     // Handle marking albums
     if ($mark_read == 'albums' || $mark_read == 'all') {
         $redirect = build_url('mark', 'hash');
         $token = request_var('hash', '');
         if (check_link_hash($token, 'global')) {
             if ($mark_read == 'all') {
                 phpbb_gallery_misc::markread('all');
                 $message = sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect . '">', '</a>');
             } else {
                 phpbb_gallery_misc::markread('albums', $album_ids);
                 $message = sprintf($user->lang['RETURN_ALBUM'], '<a href="' . $redirect . '">', '</a>');
             }
             meta_refresh(3, $redirect);
             trigger_error($user->lang['ALBUMS_MARKED'] . '<br /><br />' . $message);
         } else {
             $message = sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>');
             meta_refresh(3, $redirect);
             trigger_error($message);
         }
     }
     // Grab moderators ... if necessary
     if ($display_moderators) {
         if ($return_moderators) {
             $album_ids_moderator[] = $root_data['album_id'];
         }
         self::get_moderators($album_moderators, $album_ids_moderator);
     }
     // Used to tell whatever we have to create a dummy category or not.
     $last_catless = true;
     foreach ($album_rows as $row) {
         // Empty category
         if ($row['parent_id'] == $root_data['album_id'] && $row['album_type'] == self::TYPE_CAT) {
             $template->assign_block_vars('albumrow', array('S_IS_CAT' => true, 'ALBUM_ID' => $row['album_id'], 'ALBUM_NAME' => $row['album_name'], 'ALBUM_DESC' => generate_text_for_display($row['album_desc'], $row['album_desc_uid'], $row['album_desc_bitfield'], $row['album_desc_options']), 'ALBUM_FOLDER_IMG' => '', 'ALBUM_FOLDER_IMG_SRC' => '', 'ALBUM_IMAGE' => $row['album_image'] ? phpbb_gallery_url::path('phpbb') . $row['album_image'] : '', 'U_VIEWALBUM' => phpbb_gallery_url::append_sid('album', 'album_id=' . $row['album_id'])));
             continue;
         }
         $visible_albums++;
         if ($mode == 'personal' && ($visible_albums <= $start || $visible_albums > $start + $limit)) {
             continue;
         }
         $album_id = $row['album_id'];
         $album_unread = isset($album_tracking_info[$album_id]) && $row['orig_album_last_image_time'] > $album_tracking_info[$album_id] && $user->data['user_id'] != ANONYMOUS ? true : false;
         $folder_image = $folder_alt = $l_subalbums = '';
         $subalbums_list = array();
         // Generate list of subalbums if we need to
         if (isset($subalbums[$album_id])) {
             foreach ($subalbums[$album_id] as $subalbum_id => $subalbum_row) {
                 $subalbum_unread = isset($album_tracking_info[$subalbum_id]) && $subalbum_row['orig_album_last_image_time'] > $album_tracking_info[$subalbum_id] && $user->data['user_id'] != ANONYMOUS ? true : false;
                 if (!$subalbum_unread && !empty($subalbum_row['children']) && $user->data['user_id'] != ANONYMOUS) {
                     foreach ($subalbum_row['children'] as $child_id) {
                         if (isset($album_tracking_info[$child_id]) && $subalbums[$album_id][$child_id]['orig_album_last_image_time'] > $album_tracking_info[$child_id]) {
                             // Once we found an unread child album, we can drop out of this loop
                             $subalbum_unread = true;
                             break;
                         }
                     }
                 }
                 if ($subalbum_row['display'] && $subalbum_row['name']) {
                     $subalbums_list[] = array('link' => phpbb_gallery_url::append_sid('album', 'album_id=' . $subalbum_id), 'name' => $subalbum_row['name'], 'unread' => $subalbum_unread);
                 } else {
                     unset($subalbums[$album_id][$subalbum_id]);
                 }
                 if ($subalbum_unread) {
                     $album_unread = true;
                 }
             }
             $l_subalbums = sizeof($subalbums[$album_id]) == 1 ? $user->lang['SUBALBUM'] . ': ' : $user->lang['SUBALBUMS'] . ': ';
             $folder_image = $album_unread ? 'forum_unread_subforum' : 'forum_read_subforum';
         } else {
             $folder_alt = $album_unread ? 'NEW_IMAGES' : 'NO_NEW_IMAGES';
             $folder_image = $album_unread ? 'forum_unread' : 'forum_read';
         }
         if ($row['album_status'] == self::STATUS_LOCKED) {
             $folder_image = $album_unread ? 'forum_unread_locked' : 'forum_read_locked';
             $folder_alt = 'ALBUM_LOCKED';
         }
         // Create last post link information, if appropriate
         if ($row['album_last_image_id']) {
             $lastimage_name = $row['album_last_image_name'];
             $lastimage_time = $user->format_date($row['album_last_image_time']);
             $lastimage_image_id = $row['album_last_image_id'];
             $lastimage_album_id = $row['album_id_last_image'];
             $lastimage_album_type = $row['album_type_last_image'];
             $lastimage_contest_marked = $row['album_contest_marked'];
             $lastimage_uc_fake_thumbnail = phpbb_gallery_image::generate_link('fake_thumbnail', phpbb_gallery_config::get('link_thumbnail'), $lastimage_image_id, $lastimage_name, $lastimage_album_id);
             $lastimage_uc_thumbnail = phpbb_gallery_image::generate_link('thumbnail', phpbb_gallery_config::get('link_thumbnail'), $lastimage_image_id, $lastimage_name, $lastimage_album_id);
             $lastimage_uc_name = phpbb_gallery_image::generate_link('image_name', phpbb_gallery_config::get('link_image_name'), $lastimage_image_id, $lastimage_name, $lastimage_album_id);
             $lastimage_uc_icon = phpbb_gallery_image::generate_link('lastimage_icon', phpbb_gallery_config::get('link_image_icon'), $lastimage_image_id, $lastimage_name, $lastimage_album_id);
         } else {
             $lastimage_time = $lastimage_image_id = $lastimage_album_id = $lastimage_album_type = 0;
             $lastimage_name = $lastimage_uc_fake_thumbnail = $lastimage_uc_thumbnail = $lastimage_uc_name = $lastimage_uc_icon = '';
         }
         // Output moderator listing ... if applicable
         $l_moderator = $moderators_list = '';
         if ($display_moderators && !empty($album_moderators[$album_id])) {
             $l_moderator = sizeof($album_moderators[$album_id]) == 1 ? $user->lang['MODERATOR'] : $user->lang['MODERATORS'];
             $moderators_list = implode(', ', $album_moderators[$album_id]);
         }
         $s_subalbums_list = array();
         foreach ($subalbums_list as $subalbum) {
             $s_subalbums_list[] = '<a href="' . $subalbum['link'] . '" class="subforum ' . ($subalbum['unread'] ? 'unread' : 'read') . '" title="' . ($subalbum['unread'] ? $user->lang['NEW_IMAGES'] : $user->lang['NO_NEW_IMAGES']) . '">' . $subalbum['name'] . '</a>';
         }
         $s_subalbums_list = (string) implode(', ', $s_subalbums_list);
         $catless = $row['parent_id'] == $root_data['album_id'] ? true : false;
         $template->assign_block_vars('albumrow', array('S_IS_CAT' => false, 'S_NO_CAT' => $catless && !$last_catless, 'S_LOCKED_ALBUM' => $row['album_status'] == self::STATUS_LOCKED ? true : false, 'S_LIST_SUBALBUMS' => $row['display_subalbum_list'] ? true : false, 'S_SUBALBUMS' => sizeof($subalbums_list) ? true : false, 'ALBUM_ID' => $row['album_id'], 'ALBUM_NAME' => $row['album_name'], 'ALBUM_DESC' => generate_text_for_display($row['album_desc'], $row['album_desc_uid'], $row['album_desc_bitfield'], $row['album_desc_options']), 'IMAGES' => $row['album_images'], 'UNAPPROVED_IMAGES' => phpbb_gallery::$auth->acl_check('m_status', $album_id, $row['album_user_id']) ? $row['album_images_real'] - $row['album_images'] : 0, 'ALBUM_FOLDER_IMG' => $user->img($folder_image, $folder_alt), 'ALBUM_FOLDER_IMG_SRC' => $user->img($folder_image, $folder_alt, false, '', 'src'), 'ALBUM_FOLDER_IMG_ALT' => isset($user->lang[$folder_alt]) ? $user->lang[$folder_alt] : '', 'ALBUM_IMAGE' => $row['album_image'] ? phpbb_gallery_url::path('phpbb') . $row['album_image'] : '', 'LAST_IMAGE_TIME' => $lastimage_time, 'LAST_USER_FULL' => $lastimage_album_type == self::TYPE_CONTEST && ($lastimage_contest_marked && !phpbb_gallery::$auth->acl_check('m_status', $album_id, $row['album_user_id'])) ? $user->lang['CONTEST_USERNAME'] : get_username_string('full', $row['album_last_user_id'], $row['album_last_username'], $row['album_last_user_colour']), 'UC_THUMBNAIL' => phpbb_gallery_config::get('mini_thumbnail_disp') ? $lastimage_uc_thumbnail : '', 'UC_FAKE_THUMBNAIL' => phpbb_gallery_config::get('mini_thumbnail_disp') ? $lastimage_uc_fake_thumbnail : '', 'UC_IMAGE_NAME' => $lastimage_uc_name, 'UC_LASTIMAGE_ICON' => $lastimage_uc_icon, 'ALBUM_COLOUR' => get_username_string('colour', $row['album_last_user_id'], $row['album_last_username'], $row['album_last_user_colour']), 'MODERATORS' => $moderators_list, 'SUBALBUMS' => $s_subalbums_list, 'L_SUBALBUM_STR' => $l_subalbums, 'L_ALBUM_FOLDER_ALT' => $folder_alt, 'L_MODERATOR_STR' => $l_moderator, 'U_VIEWALBUM' => phpbb_gallery_url::append_sid('album', 'album_id=' . $row['album_id'])));
         // Assign subforums loop for style authors
         foreach ($subalbums_list as $subalbum) {
             $template->assign_block_vars('albumrow.subalbum', array('U_SUBALBUM' => $subalbum['link'], 'SUBALBUM_NAME' => $subalbum['name'], 'S_UNREAD' => $subalbum['unread']));
         }
         $last_catless = $catless;
     }
     $template->assign_vars(array('U_MARK_ALBUMS' => $user->data['is_registered'] ? phpbb_gallery_url::append_sid('album', 'hash=' . generate_link_hash('global') . '&amp;album_id=' . $root_data['album_id'] . '&amp;mark=albums') : '', 'S_HAS_SUBALBUM' => $visible_albums ? true : false, 'L_SUBFORUM' => $visible_albums == 1 ? $user->lang['SUBALBUM'] : $user->lang['SUBALBUMS'], 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 'FAKE_THUMB_SIZE' => phpbb_gallery_config::get('mini_thumbnail_size')));
     if ($return_moderators) {
         return array($active_album_ary, $album_moderators);
     }
     return array($active_album_ary, array());
 }
Exemple #23
0
	'TOTAL_POSTS'	=> sprintf($user->lang[$l_total_post_s], $total_posts),
	'TOTAL_TOPICS'	=> sprintf($user->lang[$l_total_topic_s], $total_topics),
	'TOTAL_USERS'	=> sprintf($user->lang[$l_total_user_s], $total_users),
	'NEWEST_USER'	=> sprintf($user->lang['NEWEST_USER'], get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])),

	'LEGEND'		=> $legend,
	'BIRTHDAY_LIST'	=> $birthday_list,

	'FORUM_IMG'				=> $user->img('forum_read', 'NO_UNREAD_POSTS'),
	'FORUM_UNREAD_IMG'			=> $user->img('forum_unread', 'UNREAD_POSTS'),
	'FORUM_LOCKED_IMG'		=> $user->img('forum_read_locked', 'NO_UNREAD_POSTS_LOCKED'),
	'FORUM_UNREAD_LOCKED_IMG'	=> $user->img('forum_unread_locked', 'UNREAD_POSTS_LOCKED'),

	'S_LOGIN_ACTION'			=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'),
	'S_DISPLAY_BIRTHDAY_LIST'	=> ($config['load_birthdays']) ? true : false,

	'U_MARK_FORUMS'		=> ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&amp;mark=forums') : '',
	'U_MCP'				=> ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&amp;mode=front', true, $user->session_id) : '')
);


// Output page
page_header($user->lang['INDEX']);

$template->set_filenames(array(
	'body' => 'index_body.html')
);

page_footer();

?>
Exemple #24
0
            $profile_fields = $cp->generate_profile_fields_template('grab', $user_id);
            $profile_fields = isset($profile_fields[$user_id]) ? $cp->generate_profile_fields_template('show', false, $profile_fields[$user_id]) : array();
        }
        // If the user has m_approve permission or a_user permission, then list then display unapproved posts
        if ($auth->acl_getf_global('m_approve') || $auth->acl_get('a_user')) {
            $sql = 'SELECT COUNT(post_id) as posts_in_queue
				FROM ' . POSTS_TABLE . '
				WHERE poster_id = ' . $user_id . '
					AND post_approved = 0';
            $result = $db->sql_query($sql);
            $member['posts_in_queue'] = (int) $db->sql_fetchfield('posts_in_queue');
            $db->sql_freeresult($result);
        } else {
            $member['posts_in_queue'] = 0;
        }
        $template->assign_vars(array('L_POSTS_IN_QUEUE' => $user->lang('NUM_POSTS_IN_QUEUE', $member['posts_in_queue']), 'POSTS_DAY' => sprintf($user->lang['POST_DAY'], $posts_per_day), 'POSTS_PCT' => sprintf($user->lang['POST_PCT'], $percentage), 'OCCUPATION' => !empty($member['user_occ']) ? censor_text($member['user_occ']) : '', 'INTERESTS' => !empty($member['user_interests']) ? censor_text($member['user_interests']) : '', 'SIGNATURE' => $member['user_sig'], 'POSTS_IN_QUEUE' => $member['posts_in_queue'], 'AVATAR_IMG' => $poster_avatar, 'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']), 'EMAIL_IMG' => $user->img('icon_contact_email', $user->lang['EMAIL']), 'WWW_IMG' => $user->img('icon_contact_www', $user->lang['WWW']), 'ICQ_IMG' => $user->img('icon_contact_icq', $user->lang['ICQ']), 'AIM_IMG' => $user->img('icon_contact_aim', $user->lang['AIM']), 'MSN_IMG' => $user->img('icon_contact_msnm', $user->lang['MSNM']), 'YIM_IMG' => $user->img('icon_contact_yahoo', $user->lang['YIM']), 'JABBER_IMG' => $user->img('icon_contact_jabber', $user->lang['JABBER']), 'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']), 'S_PROFILE_ACTION' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=group'), 'S_GROUP_OPTIONS' => $group_options, 'S_CUSTOM_FIELDS' => isset($profile_fields['row']) && sizeof($profile_fields['row']) ? true : false, 'U_USER_ADMIN' => $auth->acl_get('a_user') ? append_sid("{$phpbb_root_path}adm/index.{$phpEx}", 'i=users&amp;mode=overview&amp;u=' . $user_id, true, $user->session_id) : '', 'U_USER_BAN' => $auth->acl_get('m_ban') && $user_id != $user->data['user_id'] ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=ban&amp;mode=user&amp;u=' . $user_id, true, $user->session_id) : '', 'U_MCP_QUEUE' => $auth->acl_getf_global('m_approve') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue', true, $user->session_id) : '', 'U_SWITCH_PERMISSIONS' => $auth->acl_get('a_switchperm') && $user->data['user_id'] != $user_id ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", "mode=switch_perm&amp;u={$user_id}&amp;hash=" . generate_link_hash('switchperm')) : '', 'S_USER_NOTES' => $user_notes_enabled ? true : false, 'S_WARN_USER' => $warn_user_enabled ? true : false, 'S_ZEBRA' => $user->data['user_id'] != $user_id && $user->data['is_registered'] && $zebra_enabled ? true : false, 'U_ADD_FRIEND' => !$friend && !$foe && $friends_enabled ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=zebra&amp;add=' . urlencode(htmlspecialchars_decode($member['username']))) : '', 'U_ADD_FOE' => !$friend && !$foe && $foes_enabled ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=zebra&amp;mode=foes&amp;add=' . urlencode(htmlspecialchars_decode($member['username']))) : '', 'U_REMOVE_FRIEND' => $friend && $friends_enabled ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=zebra&amp;remove=1&amp;usernames[]=' . $user_id) : '', 'U_REMOVE_FOE' => $foe && $foes_enabled ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=zebra&amp;remove=1&amp;mode=foes&amp;usernames[]=' . $user_id) : ''));
        if (!empty($profile_fields['row'])) {
            $template->assign_vars($profile_fields['row']);
        }
        if (!empty($profile_fields['blockrow'])) {
            foreach ($profile_fields['blockrow'] as $field_data) {
                $template->assign_block_vars('custom_fields', $field_data);
            }
        }
        // Inactive reason/account?
        if ($member['user_type'] == USER_INACTIVE) {
            $user->add_lang('acp/common');
            $inactive_reason = $user->lang['INACTIVE_REASON_UNKNOWN'];
            switch ($member['user_inactive_reason']) {
                case INACTIVE_REGISTER:
                    $inactive_reason = $user->lang['INACTIVE_REASON_REGISTER'];
Exemple #25
0
 function main()
 {
     // Start the page
     global $config, $user, $template, $request, $phpbb_extension_manager, $db, $phpbb_root_path, $phpEx, $phpbb_log, $cache;
     $this->db = $db;
     $this->config = $config;
     $this->template = $template;
     $this->user = $user;
     $this->cache = $cache;
     $this->request = $request;
     $this->log = $phpbb_log;
     $user->add_lang(array('install', 'acp/extensions', 'migrator'));
     $this->page_title = 'ACP_EXTENSIONS';
     $action = $request->variable('action', 'list');
     $ext_name = $request->variable('ext_name', '');
     // What is a safe limit of execution time? Half the max execution time should be safe.
     $safe_time_limit = ini_get('max_execution_time') / 2;
     $start_time = time();
     // Cancel action
     if ($request->is_set_post('cancel')) {
         $action = 'list';
         $ext_name = '';
     }
     if (in_array($action, array('enable', 'disable', 'delete_data')) && !check_link_hash($request->variable('hash', ''), $action . '.' . $ext_name)) {
         trigger_error('FORM_INVALID', E_USER_WARNING);
     }
     // If they've specified an extension, let's load the metadata manager and validate it.
     if ($ext_name) {
         $md_manager = new \phpbb\extension\metadata_manager($ext_name, $config, $phpbb_extension_manager, $template, $user, $phpbb_root_path);
         try {
             $md_manager->get_metadata('all');
         } catch (\phpbb\extension\exception $e) {
             trigger_error($e, E_USER_WARNING);
         }
     }
     // What are we doing?
     switch ($action) {
         case 'set_config_version_check_force_unstable':
             $force_unstable = $this->request->variable('force_unstable', false);
             if ($force_unstable) {
                 $s_hidden_fields = build_hidden_fields(array('force_unstable' => $force_unstable));
                 confirm_box(false, $user->lang('EXTENSION_FORCE_UNSTABLE_CONFIRM'), $s_hidden_fields);
             } else {
                 $config->set('extension_force_unstable', false);
                 trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
             }
             break;
         case 'list':
         default:
             if (confirm_box(true)) {
                 $config->set('extension_force_unstable', true);
                 trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
             }
             $this->list_enabled_exts($phpbb_extension_manager);
             $this->list_disabled_exts($phpbb_extension_manager);
             $this->list_available_exts($phpbb_extension_manager);
             $this->template->assign_vars(array('U_VERSIONCHECK_FORCE' => $this->u_action . '&amp;action=list&amp;versioncheck_force=1', 'FORCE_UNSTABLE' => $config['extension_force_unstable'], 'U_ACTION' => $this->u_action));
             add_form_key('version_check_settings');
             $this->tpl_name = 'acp_ext_list';
             break;
         case 'enable_pre':
             if (!$md_manager->validate_dir()) {
                 trigger_error($user->lang['EXTENSION_DIR_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
             }
             if (!$md_manager->validate_enable()) {
                 trigger_error($user->lang['EXTENSION_NOT_AVAILABLE'] . adm_back_link($this->u_action), E_USER_WARNING);
             }
             $extension = $phpbb_extension_manager->get_extension($ext_name);
             if (!$extension->is_enableable()) {
                 trigger_error($user->lang['EXTENSION_NOT_ENABLEABLE'] . adm_back_link($this->u_action), E_USER_WARNING);
             }
             if ($phpbb_extension_manager->is_enabled($ext_name)) {
                 redirect($this->u_action);
             }
             $this->tpl_name = 'acp_ext_enable';
             $template->assign_vars(array('PRE' => true, 'L_CONFIRM_MESSAGE' => $this->user->lang('EXTENSION_ENABLE_CONFIRM', $md_manager->get_metadata('display-name')), 'U_ENABLE' => $this->u_action . '&amp;action=enable&amp;ext_name=' . urlencode($ext_name) . '&amp;hash=' . generate_link_hash('enable.' . $ext_name)));
             break;
         case 'enable':
             if (!$md_manager->validate_dir()) {
                 trigger_error($user->lang['EXTENSION_DIR_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
             }
             if (!$md_manager->validate_enable()) {
                 trigger_error($user->lang['EXTENSION_NOT_AVAILABLE'] . adm_back_link($this->u_action), E_USER_WARNING);
             }
             $extension = $phpbb_extension_manager->get_extension($ext_name);
             if (!$extension->is_enableable()) {
                 trigger_error($user->lang['EXTENSION_NOT_ENABLEABLE'] . adm_back_link($this->u_action), E_USER_WARNING);
             }
             if ($phpbb_extension_manager->is_enabled($ext_name)) {
                 redirect($this->u_action);
             }
             try {
                 while ($phpbb_extension_manager->enable_step($ext_name)) {
                     // Are we approaching the time limit? If so we want to pause the update and continue after refreshing
                     if (time() - $start_time >= $safe_time_limit) {
                         $template->assign_var('S_NEXT_STEP', true);
                         meta_refresh(0, $this->u_action . '&amp;action=enable&amp;ext_name=' . urlencode($ext_name) . '&amp;hash=' . generate_link_hash('enable.' . $ext_name));
                     }
                 }
                 $this->log->add('admin', $user->data['user_id'], $user->ip, 'LOG_EXT_ENABLE', time(), array($ext_name));
             } catch (\phpbb\db\migration\exception $e) {
                 $template->assign_var('MIGRATOR_ERROR', $e->getLocalisedMessage($user));
             }
             $this->tpl_name = 'acp_ext_enable';
             $template->assign_vars(array('U_RETURN' => $this->u_action . '&amp;action=list'));
             break;
         case 'disable_pre':
             if (!$phpbb_extension_manager->is_enabled($ext_name)) {
                 redirect($this->u_action);
             }
             $this->tpl_name = 'acp_ext_disable';
             $template->assign_vars(array('PRE' => true, 'L_CONFIRM_MESSAGE' => $this->user->lang('EXTENSION_DISABLE_CONFIRM', $md_manager->get_metadata('display-name')), 'U_DISABLE' => $this->u_action . '&amp;action=disable&amp;ext_name=' . urlencode($ext_name) . '&amp;hash=' . generate_link_hash('disable.' . $ext_name)));
             break;
         case 'disable':
             if (!$phpbb_extension_manager->is_enabled($ext_name)) {
                 redirect($this->u_action);
             }
             while ($phpbb_extension_manager->disable_step($ext_name)) {
                 // Are we approaching the time limit? If so we want to pause the update and continue after refreshing
                 if (time() - $start_time >= $safe_time_limit) {
                     $template->assign_var('S_NEXT_STEP', true);
                     meta_refresh(0, $this->u_action . '&amp;action=disable&amp;ext_name=' . urlencode($ext_name) . '&amp;hash=' . generate_link_hash('disable.' . $ext_name));
                 }
             }
             $this->log->add('admin', $user->data['user_id'], $user->ip, 'LOG_EXT_DISABLE', time(), array($ext_name));
             $this->tpl_name = 'acp_ext_disable';
             $template->assign_vars(array('U_RETURN' => $this->u_action . '&amp;action=list'));
             break;
         case 'delete_data_pre':
             if ($phpbb_extension_manager->is_enabled($ext_name)) {
                 redirect($this->u_action);
             }
             $this->tpl_name = 'acp_ext_delete_data';
             $template->assign_vars(array('PRE' => true, 'L_CONFIRM_MESSAGE' => $this->user->lang('EXTENSION_DELETE_DATA_CONFIRM', $md_manager->get_metadata('display-name')), 'U_PURGE' => $this->u_action . '&amp;action=delete_data&amp;ext_name=' . urlencode($ext_name) . '&amp;hash=' . generate_link_hash('delete_data.' . $ext_name)));
             break;
         case 'delete_data':
             if ($phpbb_extension_manager->is_enabled($ext_name)) {
                 redirect($this->u_action);
             }
             try {
                 while ($phpbb_extension_manager->purge_step($ext_name)) {
                     // Are we approaching the time limit? If so we want to pause the update and continue after refreshing
                     if (time() - $start_time >= $safe_time_limit) {
                         $template->assign_var('S_NEXT_STEP', true);
                         meta_refresh(0, $this->u_action . '&amp;action=delete_data&amp;ext_name=' . urlencode($ext_name) . '&amp;hash=' . generate_link_hash('delete_data.' . $ext_name));
                     }
                 }
                 $this->log->add('admin', $user->data['user_id'], $user->ip, 'LOG_EXT_PURGE', time(), array($ext_name));
             } catch (\phpbb\db\migration\exception $e) {
                 $template->assign_var('MIGRATOR_ERROR', $e->getLocalisedMessage($user));
             }
             $this->tpl_name = 'acp_ext_delete_data';
             $template->assign_vars(array('U_RETURN' => $this->u_action . '&amp;action=list'));
             break;
         case 'details':
             // Output it to the template
             $md_manager->output_template_data();
             try {
                 $updates_available = $this->version_check($md_manager, $request->variable('versioncheck_force', false));
                 $template->assign_vars(array('S_UP_TO_DATE' => empty($updates_available), 'S_VERSIONCHECK' => true, 'UP_TO_DATE_MSG' => $this->user->lang(empty($updates_available) ? 'UP_TO_DATE' : 'NOT_UP_TO_DATE', $md_manager->get_metadata('display-name'))));
                 foreach ($updates_available as $branch => $version_data) {
                     $template->assign_block_vars('updates_available', $version_data);
                 }
             } catch (\RuntimeException $e) {
                 $template->assign_vars(array('S_VERSIONCHECK_STATUS' => $e->getCode(), 'VERSIONCHECK_FAIL_REASON' => $e->getMessage() !== $user->lang('VERSIONCHECK_FAIL') ? $e->getMessage() : ''));
             }
             $template->assign_vars(array('U_BACK' => $this->u_action . '&amp;action=list', 'U_VERSIONCHECK_FORCE' => $this->u_action . '&amp;action=details&amp;versioncheck_force=1&amp;ext_name=' . urlencode($md_manager->get_metadata('name'))));
             $this->tpl_name = 'acp_ext_details';
             break;
     }
 }
Exemple #26
0
    function main($id, $mode)
    {
        global $user, $template, $phpbb_root_path, $auth, $phpEx, $db, $config, $request;
        if (!$user->data['is_registered']) {
            trigger_error('NO_MESSAGE');
        }
        // Is PM disabled?
        if (!$config['allow_privmsg']) {
            trigger_error('PM_DISABLED');
        }
        $user->add_lang('posting');
        $template->assign_var('S_PRIVMSGS', true);
        // Folder directly specified?
        $folder_specified = $request->variable('folder', '');
        if (!in_array($folder_specified, array('inbox', 'outbox', 'sentbox'))) {
            $folder_specified = (int) $folder_specified;
        } else {
            $folder_specified = $folder_specified == 'inbox' ? PRIVMSGS_INBOX : ($folder_specified == 'outbox' ? PRIVMSGS_OUTBOX : PRIVMSGS_SENTBOX);
        }
        if (!$folder_specified) {
            $mode = !$mode ? $request->variable('mode', 'view') : $mode;
        } else {
            $mode = 'view';
        }
        include $phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx;
        switch ($mode) {
            // Compose message
            case 'compose':
                $action = $request->variable('action', 'post');
                $user_folders = get_folder($user->data['user_id']);
                if ($action != 'delete' && !$auth->acl_get('u_sendpm')) {
                    // trigger_error('NO_AUTH_SEND_MESSAGE');
                    $template->assign_vars(array('S_NO_AUTH_SEND_MESSAGE' => true, 'S_COMPOSE_PM_VIEW' => true));
                    $tpl_file = 'ucp_pm_viewfolder';
                    break;
                }
                include $phpbb_root_path . 'includes/ucp/ucp_pm_compose.' . $phpEx;
                compose_pm($id, $mode, $action, $user_folders);
                $tpl_file = 'posting_body';
                break;
            case 'options':
                set_user_message_limit();
                get_folder($user->data['user_id']);
                include $phpbb_root_path . 'includes/ucp/ucp_pm_options.' . $phpEx;
                message_options($id, $mode, $global_privmsgs_rules, $global_rule_conditions);
                $tpl_file = 'ucp_pm_options';
                break;
            case 'drafts':
                get_folder($user->data['user_id']);
                $this->p_name = 'pm';
                // Call another module... please do not try this at home... Hoochie Coochie Man
                include $phpbb_root_path . 'includes/ucp/ucp_main.' . $phpEx;
                $module = new ucp_main($this);
                $module->u_action = $this->u_action;
                $module->main($id, $mode);
                $this->tpl_name = $module->tpl_name;
                $this->page_title = 'UCP_PM_DRAFTS';
                unset($module);
                return;
                break;
            case 'view':
                set_user_message_limit();
                if ($folder_specified) {
                    $folder_id = $folder_specified;
                    $action = 'view_folder';
                } else {
                    $folder_id = $request->variable('f', PRIVMSGS_NO_BOX);
                    $action = $request->variable('action', 'view_folder');
                }
                $msg_id = $request->variable('p', 0);
                $view = $request->variable('view', '');
                // View message if specified
                if ($msg_id) {
                    $action = 'view_message';
                }
                if (!$auth->acl_get('u_readpm')) {
                    trigger_error('NO_AUTH_READ_MESSAGE');
                }
                // Do not allow hold messages to be seen
                if ($folder_id == PRIVMSGS_HOLD_BOX) {
                    trigger_error('NO_AUTH_READ_HOLD_MESSAGE');
                }
                // First Handle Mark actions and moving messages
                $submit_mark = isset($_POST['submit_mark']) ? true : false;
                $move_pm = isset($_POST['move_pm']) ? true : false;
                $mark_option = $request->variable('mark_option', '');
                $dest_folder = $request->variable('dest_folder', PRIVMSGS_NO_BOX);
                // Is moving PM triggered through mark options?
                if (!in_array($mark_option, array('mark_important', 'delete_marked')) && $submit_mark) {
                    $move_pm = true;
                    $dest_folder = (int) $mark_option;
                    $submit_mark = false;
                }
                // Move PM
                if ($move_pm) {
                    $move_msg_ids = isset($_POST['marked_msg_id']) ? $request->variable('marked_msg_id', array(0)) : array();
                    $cur_folder_id = $request->variable('cur_folder_id', PRIVMSGS_NO_BOX);
                    if (move_pm($user->data['user_id'], $user->data['message_limit'], $move_msg_ids, $dest_folder, $cur_folder_id)) {
                        // Return to folder view if single message moved
                        if ($action == 'view_message') {
                            $msg_id = 0;
                            $folder_id = $request->variable('cur_folder_id', PRIVMSGS_NO_BOX);
                            $action = 'view_folder';
                        }
                    }
                }
                // Message Mark Options
                if ($submit_mark) {
                    handle_mark_actions($user->data['user_id'], $mark_option);
                }
                // If new messages arrived, place them into the appropriate folder
                $num_not_moved = $num_removed = 0;
                $release = $request->variable('release', 0);
                if ($user->data['user_new_privmsg'] && ($action == 'view_folder' || $action == 'view_message')) {
                    $return = place_pm_into_folder($global_privmsgs_rules, $release);
                    $num_not_moved = $return['not_moved'];
                    $num_removed = $return['removed'];
                }
                if (!$msg_id && $folder_id == PRIVMSGS_NO_BOX) {
                    $folder_id = PRIVMSGS_INBOX;
                } else {
                    if ($msg_id && $folder_id == PRIVMSGS_NO_BOX) {
                        $sql = 'SELECT folder_id
						FROM ' . PRIVMSGS_TO_TABLE . "\n\t\t\t\t\t\tWHERE msg_id = {$msg_id}\n\t\t\t\t\t\t\tAND folder_id <> " . PRIVMSGS_NO_BOX . '
							AND user_id = ' . $user->data['user_id'];
                        $result = $db->sql_query($sql);
                        $row = $db->sql_fetchrow($result);
                        $db->sql_freeresult($result);
                        if (!$row) {
                            trigger_error('NO_MESSAGE');
                        }
                        $folder_id = (int) $row['folder_id'];
                    }
                }
                if ($request->variable('mark', '') == 'all' && check_link_hash($request->variable('token', ''), 'mark_all_pms_read')) {
                    mark_folder_read($user->data['user_id'], $folder_id);
                    meta_refresh(3, $this->u_action);
                    $message = $user->lang['PM_MARK_ALL_READ_SUCCESS'];
                    if ($request->is_ajax()) {
                        $json_response = new \phpbb\json_response();
                        $json_response->send(array('MESSAGE_TITLE' => $user->lang['INFORMATION'], 'MESSAGE_TEXT' => $message, 'success' => true));
                    }
                    $message .= '<br /><br />' . $user->lang('RETURN_UCP', '<a href="' . $this->u_action . '">', '</a>');
                    trigger_error($message);
                }
                $message_row = array();
                if ($action == 'view_message' && $msg_id) {
                    // Get Message user want to see
                    if ($view == 'next' || $view == 'previous') {
                        $sql_condition = $view == 'next' ? '>' : '<';
                        $sql_ordering = $view == 'next' ? 'ASC' : 'DESC';
                        $sql = 'SELECT t.msg_id
							FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . PRIVMSGS_TABLE . " p2\n\t\t\t\t\t\t\tWHERE p2.msg_id = {$msg_id}\n\t\t\t\t\t\t\t\tAND t.folder_id = {$folder_id}\n\t\t\t\t\t\t\t\tAND t.user_id = " . $user->data['user_id'] . "\n\t\t\t\t\t\t\t\tAND t.msg_id = p.msg_id\n\t\t\t\t\t\t\t\tAND p.message_time {$sql_condition} p2.message_time\n\t\t\t\t\t\t\tORDER BY p.message_time {$sql_ordering}";
                        $result = $db->sql_query_limit($sql, 1);
                        $row = $db->sql_fetchrow($result);
                        $db->sql_freeresult($result);
                        if (!$row) {
                            $message = $view == 'next' ? 'NO_NEWER_PM' : 'NO_OLDER_PM';
                            trigger_error($message);
                        } else {
                            $msg_id = $row['msg_id'];
                        }
                    }
                    $sql = 'SELECT t.*, p.*, u.*
						FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . ' u
						WHERE t.user_id = ' . $user->data['user_id'] . "\n\t\t\t\t\t\t\tAND p.author_id = u.user_id\n\t\t\t\t\t\t\tAND t.folder_id = {$folder_id}\n\t\t\t\t\t\t\tAND t.msg_id = p.msg_id\n\t\t\t\t\t\t\tAND p.msg_id = {$msg_id}";
                    $result = $db->sql_query($sql);
                    $message_row = $db->sql_fetchrow($result);
                    $db->sql_freeresult($result);
                    if (!$message_row) {
                        trigger_error('NO_MESSAGE');
                    }
                    // Update unread status
                    update_unread_status($message_row['pm_unread'], $message_row['msg_id'], $user->data['user_id'], $folder_id);
                }
                $folder = get_folder($user->data['user_id'], $folder_id);
                $s_folder_options = $s_to_folder_options = '';
                foreach ($folder as $f_id => $folder_ary) {
                    $option = '<option' . (!in_array($f_id, array(PRIVMSGS_INBOX, PRIVMSGS_OUTBOX, PRIVMSGS_SENTBOX)) ? ' class="sep"' : '') . ' value="' . $f_id . '"' . ($f_id == $folder_id ? ' selected="selected"' : '') . '>' . $folder_ary['folder_name'] . ($folder_ary['unread_messages'] ? ' [' . $folder_ary['unread_messages'] . '] ' : '') . '</option>';
                    $s_to_folder_options .= $f_id != PRIVMSGS_OUTBOX && $f_id != PRIVMSGS_SENTBOX ? $option : '';
                    $s_folder_options .= $option;
                }
                clean_sentbox($folder[PRIVMSGS_SENTBOX]['num_messages']);
                // Header for message view - folder and so on
                $folder_status = get_folder_status($folder_id, $folder);
                $template->assign_vars(array('CUR_FOLDER_ID' => $folder_id, 'CUR_FOLDER_NAME' => $folder_status['folder_name'], 'NUM_NOT_MOVED' => $num_not_moved, 'NUM_REMOVED' => $num_removed, 'RELEASE_MESSAGE_INFO' => sprintf($user->lang['RELEASE_MESSAGES'], '<a href="' . $this->u_action . '&amp;folder=' . $folder_id . '&amp;release=1">', '</a>'), 'NOT_MOVED_MESSAGES' => $user->lang('NOT_MOVED_MESSAGES', (int) $num_not_moved), 'RULE_REMOVED_MESSAGES' => $user->lang('RULE_REMOVED_MESSAGES', (int) $num_removed), 'S_FOLDER_OPTIONS' => $s_folder_options, 'S_TO_FOLDER_OPTIONS' => $s_to_folder_options, 'S_FOLDER_ACTION' => $this->u_action . '&amp;action=view_folder', 'S_PM_ACTION' => $this->u_action . '&amp;action=' . $action, 'U_INBOX' => $this->u_action . '&amp;folder=inbox', 'U_OUTBOX' => $this->u_action . '&amp;folder=outbox', 'U_SENTBOX' => $this->u_action . '&amp;folder=sentbox', 'U_CREATE_FOLDER' => $this->u_action . '&amp;mode=options', 'U_CURRENT_FOLDER' => $this->u_action . '&amp;folder=' . $folder_id, 'U_MARK_ALL' => $this->u_action . '&amp;folder=' . $folder_id . '&amp;mark=all&amp;token=' . generate_link_hash('mark_all_pms_read'), 'S_IN_INBOX' => $folder_id == PRIVMSGS_INBOX ? true : false, 'S_IN_OUTBOX' => $folder_id == PRIVMSGS_OUTBOX ? true : false, 'S_IN_SENTBOX' => $folder_id == PRIVMSGS_SENTBOX ? true : false, 'FOLDER_STATUS' => $folder_status['message'], 'FOLDER_MAX_MESSAGES' => $folder_status['max'], 'FOLDER_CUR_MESSAGES' => $folder_status['cur'], 'FOLDER_REMAINING_MESSAGES' => $folder_status['remaining'], 'FOLDER_PERCENT' => $folder_status['percent']));
                if ($action == 'view_folder') {
                    include $phpbb_root_path . 'includes/ucp/ucp_pm_viewfolder.' . $phpEx;
                    view_folder($id, $mode, $folder_id, $folder);
                    $tpl_file = 'ucp_pm_viewfolder';
                } else {
                    if ($action == 'view_message') {
                        $template->assign_vars(array('S_VIEW_MESSAGE' => true, 'L_RETURN_TO_FOLDER' => $user->lang('RETURN_TO', $folder_status['folder_name']), 'MSG_ID' => $msg_id));
                        if (!$msg_id) {
                            trigger_error('NO_MESSAGE');
                        }
                        include $phpbb_root_path . 'includes/ucp/ucp_pm_viewmessage.' . $phpEx;
                        view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row);
                        $tpl_file = $view == 'print' ? 'ucp_pm_viewmessage_print' : 'ucp_pm_viewmessage';
                    }
                }
                break;
            default:
                trigger_error('NO_ACTION_MODE', E_USER_ERROR);
                break;
        }
        $template->assign_vars(array('L_TITLE' => $user->lang['UCP_PM_' . strtoupper($mode)], 'S_UCP_ACTION' => $this->u_action . (isset($action) ? "&amp;action={$action}" : '')));
        // Set desired template
        $this->tpl_name = $tpl_file;
        $this->page_title = 'UCP_PM_' . strtoupper($mode);
    }
Exemple #27
0
}
// Basic pagewide vars
$post_alt = $forum_data['forum_status'] == ITEM_LOCKED ? $user->lang['FORUM_LOCKED'] : $user->lang['POST_NEW_TOPIC'];
// Display active topics?
$s_display_active = $forum_data['forum_type'] == FORUM_CAT && $forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS ? true : false;
$s_search_hidden_fields = array('fid' => array($forum_id));
if ($_SID) {
    $s_search_hidden_fields['sid'] = $_SID;
}
if (!empty($_EXTRA_URL)) {
    foreach ($_EXTRA_URL as $url_param) {
        $url_param = explode('=', $url_param, 2);
        $s_search_hidden_fields[$url_param[0]] = $url_param[1];
    }
}
$template->assign_vars(array('MODERATORS' => !empty($moderators[$forum_id]) ? implode($user->lang['COMMA_SEPARATOR'], $moderators[$forum_id]) : '', 'POST_IMG' => $forum_data['forum_status'] == ITEM_LOCKED ? $user->img('button_topic_locked', $post_alt) : $user->img('button_topic_new', $post_alt), 'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 'FOLDER_IMG' => $user->img('topic_read', 'NO_UNREAD_POSTS'), 'FOLDER_UNREAD_IMG' => $user->img('topic_unread', 'UNREAD_POSTS'), 'FOLDER_HOT_IMG' => $user->img('topic_read_hot', 'NO_UNREAD_POSTS_HOT'), 'FOLDER_HOT_UNREAD_IMG' => $user->img('topic_unread_hot', 'UNREAD_POSTS_HOT'), 'FOLDER_LOCKED_IMG' => $user->img('topic_read_locked', 'NO_UNREAD_POSTS_LOCKED'), 'FOLDER_LOCKED_UNREAD_IMG' => $user->img('topic_unread_locked', 'UNREAD_POSTS_LOCKED'), 'FOLDER_STICKY_IMG' => $user->img('sticky_read', 'POST_STICKY'), 'FOLDER_STICKY_UNREAD_IMG' => $user->img('sticky_unread', 'POST_STICKY'), 'FOLDER_ANNOUNCE_IMG' => $user->img('announce_read', 'POST_ANNOUNCEMENT'), 'FOLDER_ANNOUNCE_UNREAD_IMG' => $user->img('announce_unread', 'POST_ANNOUNCEMENT'), 'FOLDER_MOVED_IMG' => $user->img('topic_moved', 'TOPIC_MOVED'), 'REPORTED_IMG' => $user->img('icon_topic_reported', 'TOPIC_REPORTED'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPIC_UNAPPROVED'), 'DELETED_IMG' => $user->img('icon_topic_deleted', 'TOPIC_DELETED'), 'POLL_IMG' => $user->img('icon_topic_poll', 'TOPIC_POLL'), 'GOTO_PAGE_IMG' => $user->img('icon_post_target', 'GOTO_PAGE'), 'L_NO_TOPICS' => $forum_data['forum_status'] == ITEM_LOCKED ? $user->lang['POST_FORUM_LOCKED'] : $user->lang['NO_TOPICS'], 'S_DISPLAY_POST_INFO' => $forum_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? true : false, 'S_IS_POSTABLE' => $forum_data['forum_type'] == FORUM_POST ? true : false, 'S_USER_CAN_POST' => $auth->acl_get('f_post', $forum_id) ? true : false, 'S_DISPLAY_ACTIVE' => $s_display_active, 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days, 'S_TOPIC_ICONS' => $s_display_active && sizeof($active_forum_ary) ? max($active_forum_ary['enable_icons']) : ($forum_data['enable_icons'] ? true : false), 'U_WATCH_FORUM_LINK' => $s_watching_forum['link'], 'U_WATCH_FORUM_TOGGLE' => $s_watching_forum['link_toggle'], 'S_WATCH_FORUM_TITLE' => $s_watching_forum['title'], 'S_WATCH_FORUM_TOGGLE' => $s_watching_forum['title_toggle'], 'S_WATCHING_FORUM' => $s_watching_forum['is_watching'], 'S_FORUM_ACTION' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", "f={$forum_id}" . ($start == 0 ? '' : "&amp;start={$start}")), 'S_DISPLAY_SEARCHBOX' => $auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search'] ? true : false, 'S_SEARCHBOX_ACTION' => append_sid("{$phpbb_root_path}search.{$phpEx}"), 'S_SEARCH_LOCAL_HIDDEN_FIELDS' => build_hidden_fields($s_search_hidden_fields), 'S_SINGLE_MODERATOR' => !empty($moderators[$forum_id]) && sizeof($moderators[$forum_id]) > 1 ? false : true, 'S_IS_LOCKED' => $forum_data['forum_status'] == ITEM_LOCKED ? true : false, 'S_VIEWFORUM' => true, 'U_MCP' => $auth->acl_get('m_', $forum_id) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", "f={$forum_id}&amp;i=main&amp;mode=forum_view", true, $user->session_id) : '', 'U_POST_NEW_TOPIC' => $auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS ? append_sid("{$phpbb_root_path}posting.{$phpEx}", 'mode=post&amp;f=' . $forum_id) : '', 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", "f={$forum_id}" . (strlen($u_sort_param) ? "&amp;{$u_sort_param}" : '') . ($start == 0 ? '' : "&amp;start={$start}")), 'U_CANONICAL' => generate_board_url() . '/' . append_sid("viewforum.{$phpEx}", "f={$forum_id}" . ($start ? "&amp;start={$start}" : ''), true, ''), 'U_MARK_TOPICS' => $user->data['is_registered'] || $config['load_anon_lastread'] ? append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'hash=' . generate_link_hash('global') . "&amp;f={$forum_id}&amp;mark=topics&amp;mark_time=" . time()) : ''));
// Grab icons
$icons = $cache->obtain_icons();
// Grab all topic data
$rowset = $announcement_list = $topic_list = $global_announce_forums = array();
$sql_array = array('SELECT' => 't.*', 'FROM' => array(TOPICS_TABLE => 't'), 'LEFT_JOIN' => array());
/**
* Event to modify the SQL query before the topic data is retrieved
*
* It may also be used to override the above assigned template vars
*
* @event core.viewforum_get_topic_data
* @var	array	forum_data			Array with forum data
* @var	array	sql_array			The SQL array to get the data of all topics
* @var	array	forum_id			The forum_id whose topics are being listed
* @var	array	topics_count		The total number of topics for display
Exemple #28
0
    function main($id, $mode)
    {
        global $db, $user, $template, $cache;
        global $config, $phpbb_root_path;
        global $request, $phpbb_container;
        $user->add_lang('acp/posting');
        // Set up general vars
        $action = $request->variable('action', '');
        $action = isset($_POST['add']) ? 'add' : $action;
        $action = isset($_POST['edit']) ? 'edit' : $action;
        $action = isset($_POST['import']) ? 'import' : $action;
        $icon_id = $request->variable('id', 0);
        $submit = $request->is_set_post('submit', false);
        $form_key = 'acp_icons';
        add_form_key($form_key);
        $mode = $mode == 'smilies' ? 'smilies' : 'icons';
        $this->tpl_name = 'acp_icons';
        // What are we working on?
        switch ($mode) {
            case 'smilies':
                $table = SMILIES_TABLE;
                $lang = 'SMILIES';
                $fields = 'smiley';
                $img_path = $config['smilies_path'];
                break;
            case 'icons':
                $table = ICONS_TABLE;
                $lang = 'ICONS';
                $fields = 'icons';
                $img_path = $config['icons_path'];
                break;
        }
        $this->page_title = 'ACP_' . $lang;
        // Clear some arrays
        $_images = $_paks = array();
        $notice = '';
        // Grab file list of paks and images
        if ($action == 'edit' || $action == 'add' || $action == 'import') {
            $imglist = filelist($phpbb_root_path . $img_path, '');
            foreach ($imglist as $path => $img_ary) {
                if (empty($img_ary)) {
                    continue;
                }
                asort($img_ary, SORT_STRING);
                foreach ($img_ary as $img) {
                    $img_size = getimagesize($phpbb_root_path . $img_path . '/' . $path . $img);
                    if (!$img_size[0] || !$img_size[1] || strlen($img) > 255) {
                        continue;
                    }
                    // adjust the width and height to be lower than 128px while perserving the aspect ratio (for icons)
                    if ($mode == 'icons') {
                        if ($img_size[0] > 127 && $img_size[0] > $img_size[1]) {
                            $img_size[1] = (int) ($img_size[1] * (127 / $img_size[0]));
                            $img_size[0] = 127;
                        } else {
                            if ($img_size[1] > 127) {
                                $img_size[0] = (int) ($img_size[0] * (127 / $img_size[1]));
                                $img_size[1] = 127;
                            }
                        }
                    }
                    $_images[$path . $img]['file'] = $path . $img;
                    $_images[$path . $img]['width'] = $img_size[0];
                    $_images[$path . $img]['height'] = $img_size[1];
                }
            }
            unset($imglist);
            if ($dir = @opendir($phpbb_root_path . $img_path)) {
                while (($file = readdir($dir)) !== false) {
                    if (is_file($phpbb_root_path . $img_path . '/' . $file) && preg_match('#\\.pak$#i', $file)) {
                        $_paks[] = $file;
                    }
                }
                closedir($dir);
                if (!empty($_paks)) {
                    asort($_paks, SORT_STRING);
                }
            }
        }
        // What shall we do today? Oops, I believe that's trademarked ...
        switch ($action) {
            case 'edit':
                unset($_images);
                $_images = array();
                // no break;
            // no break;
            case 'add':
                $smilies = $default_row = array();
                $smiley_options = $order_list = $add_order_list = '';
                if ($action == 'add' && $mode == 'smilies') {
                    $sql = 'SELECT *
						FROM ' . SMILIES_TABLE . '
						ORDER BY smiley_order';
                    $result = $db->sql_query($sql);
                    while ($row = $db->sql_fetchrow($result)) {
                        if (empty($smilies[$row['smiley_url']])) {
                            $smilies[$row['smiley_url']] = $row;
                        }
                    }
                    $db->sql_freeresult($result);
                    if (sizeof($smilies)) {
                        foreach ($smilies as $row) {
                            $selected = false;
                            if (!$smiley_options) {
                                $selected = true;
                                $default_row = $row;
                            }
                            $smiley_options .= '<option value="' . $row['smiley_url'] . '"' . ($selected ? ' selected="selected"' : '') . '>' . $row['smiley_url'] . '</option>';
                            $template->assign_block_vars('smile', array('SMILEY_URL' => addslashes($row['smiley_url']), 'CODE' => addslashes($row['code']), 'EMOTION' => addslashes($row['emotion']), 'WIDTH' => $row['smiley_width'], 'HEIGHT' => $row['smiley_height'], 'ORDER' => $row['smiley_order'] + 1));
                        }
                    }
                }
                $sql = "SELECT *\n\t\t\t\t\tFROM {$table}\n\t\t\t\t\tORDER BY {$fields}_order " . ($icon_id || $action == 'add' ? 'DESC' : 'ASC');
                $result = $db->sql_query($sql);
                $data = array();
                $after = false;
                $order_lists = array('', '');
                $add_order_lists = array('', '');
                $display_count = 0;
                while ($row = $db->sql_fetchrow($result)) {
                    if ($action == 'add') {
                        unset($_images[$row[$fields . '_url']]);
                    }
                    if ($row[$fields . '_id'] == $icon_id) {
                        $after = true;
                        $data[$row[$fields . '_url']] = $row;
                    } else {
                        if ($action == 'edit' && !$icon_id) {
                            $data[$row[$fields . '_url']] = $row;
                        }
                        $selected = '';
                        if (!empty($after)) {
                            $selected = ' selected="selected"';
                            $after = false;
                        }
                        if ($row['display_on_posting']) {
                            $display_count++;
                        }
                        $after_txt = $mode == 'smilies' ? $row['code'] : $row['icons_url'];
                        $order_lists[$row['display_on_posting']] = '<option value="' . ($row[$fields . '_order'] + 1) . '"' . $selected . '>' . sprintf($user->lang['AFTER_' . $lang], ' -&gt; ' . $after_txt) . '</option>' . $order_lists[$row['display_on_posting']];
                        if (!empty($default_row)) {
                            $add_order_lists[$row['display_on_posting']] = '<option value="' . ($row[$fields . '_order'] + 1) . '"' . ($row[$fields . '_id'] == $default_row['smiley_id'] ? ' selected="selected"' : '') . '>' . sprintf($user->lang['AFTER_' . $lang], ' -&gt; ' . $after_txt) . '</option>' . $add_order_lists[$row['display_on_posting']];
                        }
                    }
                }
                $db->sql_freeresult($result);
                $order_list = '<option value="1"' . (!isset($after) ? ' selected="selected"' : '') . '>' . $user->lang['FIRST'] . '</option>';
                $add_order_list = '<option value="1">' . $user->lang['FIRST'] . '</option>';
                if ($action == 'add') {
                    $data = $_images;
                }
                $colspan = $mode == 'smilies' ? 7 : 6;
                $colspan += $icon_id ? 1 : 0;
                $colspan += $action == 'add' ? 2 : 0;
                $template->assign_vars(array('S_EDIT' => true, 'S_SMILIES' => $mode == 'smilies' ? true : false, 'S_ADD' => $action == 'add' ? true : false, 'S_ORDER_LIST_DISPLAY' => $order_list . $order_lists[1], 'S_ORDER_LIST_UNDISPLAY' => $order_list . $order_lists[0], 'S_ORDER_LIST_DISPLAY_COUNT' => $display_count + 1, 'L_TITLE' => $user->lang['ACP_' . $lang], 'L_EXPLAIN' => $user->lang['ACP_' . $lang . '_EXPLAIN'], 'L_CONFIG' => $user->lang[$lang . '_CONFIG'], 'L_URL' => $user->lang[$lang . '_URL'], 'L_LOCATION' => $user->lang[$lang . '_LOCATION'], 'L_WIDTH' => $user->lang[$lang . '_WIDTH'], 'L_HEIGHT' => $user->lang[$lang . '_HEIGHT'], 'L_ORDER' => $user->lang[$lang . '_ORDER'], 'L_NO_ICONS' => $user->lang['NO_' . $lang . '_' . strtoupper($action)], 'COLSPAN' => $colspan, 'ID' => $icon_id, 'U_BACK' => $this->u_action, 'U_ACTION' => $this->u_action . '&amp;action=' . ($action == 'add' ? 'create' : 'modify')));
                foreach ($data as $img => $img_row) {
                    $template->assign_block_vars('items', array('IMG' => $img, 'A_IMG' => addslashes($img), 'IMG_SRC' => $phpbb_root_path . $img_path . '/' . $img, 'CODE' => $mode == 'smilies' && isset($img_row['code']) ? $img_row['code'] : '', 'EMOTION' => $mode == 'smilies' && isset($img_row['emotion']) ? $img_row['emotion'] : '', 'S_ID' => isset($img_row[$fields . '_id']) ? true : false, 'ID' => isset($img_row[$fields . '_id']) ? $img_row[$fields . '_id'] : 0, 'WIDTH' => !empty($img_row[$fields . '_width']) ? $img_row[$fields . '_width'] : $img_row['width'], 'HEIGHT' => !empty($img_row[$fields . '_height']) ? $img_row[$fields . '_height'] : $img_row['height'], 'TEXT_ALT' => $mode == 'icons' && !empty($img_row['icons_alt']) ? $img_row['icons_alt'] : $img, 'ALT' => $mode == 'icons' && !empty($img_row['icons_alt']) ? $img_row['icons_alt'] : '', 'POSTING_CHECKED' => !empty($img_row['display_on_posting']) || $action == 'add' ? ' checked="checked"' : ''));
                }
                // Ok, another row for adding an addition code for a pre-existing image...
                if ($action == 'add' && $mode == 'smilies' && sizeof($smilies)) {
                    $template->assign_vars(array('S_ADD_CODE' => true, 'S_IMG_OPTIONS' => $smiley_options, 'S_ADD_ORDER_LIST_DISPLAY' => $add_order_list . $add_order_lists[1], 'S_ADD_ORDER_LIST_UNDISPLAY' => $add_order_list . $add_order_lists[0], 'IMG_SRC' => $phpbb_root_path . $img_path . '/' . $default_row['smiley_url'], 'IMG_PATH' => $img_path, 'CODE' => $default_row['code'], 'EMOTION' => $default_row['emotion'], 'WIDTH' => $default_row['smiley_width'], 'HEIGHT' => $default_row['smiley_height']));
                }
                return;
                break;
            case 'create':
            case 'modify':
                if (!check_form_key($form_key)) {
                    trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
                }
                // Get items to create/modify
                $images = isset($_POST['image']) ? array_keys($request->variable('image', array('' => 0))) : array();
                // Now really get the items
                $image_id = isset($_POST['id']) ? $request->variable('id', array('' => 0)) : array();
                $image_order = isset($_POST['order']) ? $request->variable('order', array('' => 0)) : array();
                $image_width = isset($_POST['width']) ? $request->variable('width', array('' => 0)) : array();
                $image_height = isset($_POST['height']) ? $request->variable('height', array('' => 0)) : array();
                $image_add = isset($_POST['add_img']) ? $request->variable('add_img', array('' => 0)) : array();
                $image_emotion = $request->variable('emotion', array('' => ''), true);
                $image_code = $request->variable('code', array('' => ''), true);
                $image_alt = $request->is_set_post('alt') ? $request->variable('alt', array('' => ''), true) : array();
                $image_display_on_posting = isset($_POST['display_on_posting']) ? $request->variable('display_on_posting', array('' => 0)) : array();
                // Ok, add the relevant bits if we are adding new codes to existing emoticons...
                if ($request->variable('add_additional_code', false, false, \phpbb\request\request_interface::POST)) {
                    $add_image = $request->variable('add_image', '');
                    $add_code = $request->variable('add_code', '', true);
                    $add_emotion = $request->variable('add_emotion', '', true);
                    if ($add_image && $add_emotion && $add_code) {
                        $images[] = $add_image;
                        $image_add[$add_image] = true;
                        $image_code[$add_image] = $add_code;
                        $image_emotion[$add_image] = $add_emotion;
                        $image_width[$add_image] = $request->variable('add_width', 0);
                        $image_height[$add_image] = $request->variable('add_height', 0);
                        if ($request->variable('add_display_on_posting', false, false, \phpbb\request\request_interface::POST)) {
                            $image_display_on_posting[$add_image] = 1;
                        }
                        $image_order[$add_image] = $request->variable('add_order', 0);
                    }
                }
                if ($mode == 'smilies' && $action == 'create') {
                    $smiley_count = $this->item_count($table);
                    $addable_smileys_count = sizeof($images);
                    foreach ($images as $image) {
                        if (!isset($image_add[$image])) {
                            --$addable_smileys_count;
                        }
                    }
                    if ($smiley_count + $addable_smileys_count > SMILEY_LIMIT) {
                        trigger_error($user->lang('TOO_MANY_SMILIES', SMILEY_LIMIT) . adm_back_link($this->u_action), E_USER_WARNING);
                    }
                }
                $icons_updated = 0;
                $errors = array();
                foreach ($images as $image) {
                    if ($mode == 'smilies' && ($image_emotion[$image] == '' || $image_code[$image] == '')) {
                        $errors[$image] = 'SMILIE_NO_' . ($image_emotion[$image] == '' ? 'EMOTION' : 'CODE');
                    } else {
                        if ($action == 'create' && !isset($image_add[$image])) {
                            // skip images where add wasn't checked
                        } else {
                            if (!file_exists($phpbb_root_path . $img_path . '/' . $image)) {
                                $errors[$image] = 'SMILIE_NO_FILE';
                            } else {
                                if ($image_width[$image] == 0 || $image_height[$image] == 0) {
                                    $img_size = getimagesize($phpbb_root_path . $img_path . '/' . $image);
                                    $image_width[$image] = $img_size[0];
                                    $image_height[$image] = $img_size[1];
                                }
                                // Adjust image width/height for icons
                                if ($mode == 'icons') {
                                    if ($image_width[$image] > 127 && $image_width[$image] > $image_height[$image]) {
                                        $image_height[$image] = (int) ($image_height[$image] * (127 / $image_width[$image]));
                                        $image_width[$image] = 127;
                                    } else {
                                        if ($image_height[$image] > 127) {
                                            $image_width[$image] = (int) ($image_width[$image] * (127 / $image_height[$image]));
                                            $image_height[$image] = 127;
                                        }
                                    }
                                }
                                $img_sql = array($fields . '_url' => $image, $fields . '_width' => $image_width[$image], $fields . '_height' => $image_height[$image], 'display_on_posting' => isset($image_display_on_posting[$image]) ? 1 : 0);
                                if ($mode == 'smilies') {
                                    $img_sql = array_merge($img_sql, array('emotion' => $image_emotion[$image], 'code' => $image_code[$image]));
                                }
                                if ($mode == 'icons') {
                                    $img_sql = array_merge($img_sql, array('icons_alt' => $image_alt[$image]));
                                }
                                // Image_order holds the 'new' order value
                                if (!empty($image_order[$image])) {
                                    $img_sql = array_merge($img_sql, array($fields . '_order' => $image_order[$image]));
                                    // Since we always add 'after' an item, we just need to increase all following + the current by one
                                    $sql = "UPDATE {$table}\n\t\t\t\t\t\t\t\tSET {$fields}_order = {$fields}_order + 1\n\t\t\t\t\t\t\t\tWHERE {$fields}_order >= {$image_order[$image]}";
                                    $db->sql_query($sql);
                                    // If we adjust the order, we need to adjust all other orders too - they became inaccurate...
                                    foreach ($image_order as $_image => $_order) {
                                        if ($_image == $image) {
                                            continue;
                                        }
                                        if ($_order >= $image_order[$image]) {
                                            $image_order[$_image]++;
                                        }
                                    }
                                }
                                if ($action == 'modify' && !empty($image_id[$image])) {
                                    $sql = "UPDATE {$table}\n\t\t\t\t\t\t\t\tSET " . $db->sql_build_array('UPDATE', $img_sql) . "\n\t\t\t\t\t\t\t\tWHERE {$fields}_id = " . $image_id[$image];
                                    $db->sql_query($sql);
                                    $icons_updated++;
                                } else {
                                    if ($action !== 'modify') {
                                        $sql = "INSERT INTO {$table} " . $db->sql_build_array('INSERT', $img_sql);
                                        $db->sql_query($sql);
                                        $icons_updated++;
                                    }
                                }
                            }
                        }
                    }
                }
                $cache->destroy('_icons');
                $cache->destroy('sql', $table);
                $phpbb_container->get('text_formatter.cache')->invalidate();
                $level = $icons_updated ? E_USER_NOTICE : E_USER_WARNING;
                $errormsgs = '';
                foreach ($errors as $img => $error) {
                    $errormsgs .= '<br />' . sprintf($user->lang[$error], $img);
                }
                if ($action == 'modify') {
                    trigger_error($user->lang($lang . '_EDITED', $icons_updated) . $errormsgs . adm_back_link($this->u_action), $level);
                } else {
                    trigger_error($user->lang($lang . '_ADDED', $icons_updated) . $errormsgs . adm_back_link($this->u_action), $level);
                }
                break;
            case 'import':
                $pak = $request->variable('pak', '');
                $current = $request->variable('current', '');
                if ($pak != '') {
                    $order = 0;
                    if (!check_form_key($form_key)) {
                        trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
                    }
                    if (!($pak_ary = @file($phpbb_root_path . $img_path . '/' . $pak))) {
                        trigger_error($user->lang['PAK_FILE_NOT_READABLE'] . adm_back_link($this->u_action), E_USER_WARNING);
                    }
                    // Make sure the pak_ary is valid
                    foreach ($pak_ary as $pak_entry) {
                        if (preg_match_all("#'(.*?)', ?#", $pak_entry, $data)) {
                            if (sizeof($data[1]) != 4 && $mode == 'icons' || (sizeof($data[1]) != 6 || (empty($data[1][4]) || empty($data[1][5]))) && $mode == 'smilies') {
                                trigger_error($user->lang['WRONG_PAK_TYPE'] . adm_back_link($this->u_action), E_USER_WARNING);
                            }
                        } else {
                            trigger_error($user->lang['WRONG_PAK_TYPE'] . adm_back_link($this->u_action), E_USER_WARNING);
                        }
                    }
                    // The user has already selected a smilies_pak file
                    if ($current == 'delete') {
                        switch ($db->get_sql_layer()) {
                            case 'sqlite3':
                                $db->sql_query('DELETE FROM ' . $table);
                                break;
                            default:
                                $db->sql_query('TRUNCATE TABLE ' . $table);
                                break;
                        }
                        switch ($mode) {
                            case 'smilies':
                                break;
                            case 'icons':
                                // Reset all icon_ids
                                $db->sql_query('UPDATE ' . TOPICS_TABLE . ' SET icon_id = 0');
                                $db->sql_query('UPDATE ' . POSTS_TABLE . ' SET icon_id = 0');
                                break;
                        }
                    } else {
                        $cur_img = array();
                        $field_sql = $mode == 'smilies' ? 'code' : 'icons_url';
                        $sql = "SELECT {$field_sql}\n\t\t\t\t\t\t\tFROM {$table}";
                        $result = $db->sql_query($sql);
                        while ($row = $db->sql_fetchrow($result)) {
                            ++$order;
                            $cur_img[$row[$field_sql]] = 1;
                        }
                        $db->sql_freeresult($result);
                    }
                    if ($mode == 'smilies') {
                        $smiley_count = $this->item_count($table);
                        if ($smiley_count + sizeof($pak_ary) > SMILEY_LIMIT) {
                            trigger_error($user->lang('TOO_MANY_SMILIES', SMILEY_LIMIT) . adm_back_link($this->u_action), E_USER_WARNING);
                        }
                    }
                    foreach ($pak_ary as $pak_entry) {
                        $data = array();
                        if (preg_match_all("#'(.*?)', ?#", $pak_entry, $data)) {
                            if (sizeof($data[1]) != 4 && $mode == 'icons' || sizeof($data[1]) != 6 && $mode == 'smilies') {
                                trigger_error($user->lang['WRONG_PAK_TYPE'] . adm_back_link($this->u_action), E_USER_WARNING);
                            }
                            // Stripslash here because it got addslashed before... (on export)
                            $img = stripslashes($data[1][0]);
                            $width = stripslashes($data[1][1]);
                            $height = stripslashes($data[1][2]);
                            $display_on_posting = stripslashes($data[1][3]);
                            if (isset($data[1][4]) && isset($data[1][5])) {
                                $emotion = stripslashes($data[1][4]);
                                $code = stripslashes($data[1][5]);
                            }
                            if ($current == 'replace' && ($mode == 'smilies' && !empty($cur_img[$code]) || $mode == 'icons' && !empty($cur_img[$img]))) {
                                $replace_sql = $mode == 'smilies' ? $code : $img;
                                $sql = array($fields . '_url' => $img, $fields . '_height' => (int) $height, $fields . '_width' => (int) $width, 'display_on_posting' => (int) $display_on_posting);
                                if ($mode == 'smilies') {
                                    $sql = array_merge($sql, array('emotion' => $emotion));
                                }
                                $sql = "UPDATE {$table} SET " . $db->sql_build_array('UPDATE', $sql) . "\n\t\t\t\t\t\t\t\t\tWHERE {$field_sql} = '" . $db->sql_escape($replace_sql) . "'";
                                $db->sql_query($sql);
                            } else {
                                ++$order;
                                $sql = array($fields . '_url' => $img, $fields . '_height' => (int) $height, $fields . '_width' => (int) $width, $fields . '_order' => (int) $order, 'display_on_posting' => (int) $display_on_posting);
                                if ($mode == 'smilies') {
                                    $sql = array_merge($sql, array('code' => $code, 'emotion' => $emotion));
                                }
                                $db->sql_query("INSERT INTO {$table} " . $db->sql_build_array('INSERT', $sql));
                            }
                        }
                    }
                    $cache->destroy('_icons');
                    $cache->destroy('sql', $table);
                    $phpbb_container->get('text_formatter.cache')->invalidate();
                    trigger_error($user->lang[$lang . '_IMPORT_SUCCESS'] . adm_back_link($this->u_action));
                } else {
                    $pak_options = '';
                    foreach ($_paks as $pak) {
                        $pak_options .= '<option value="' . $pak . '">' . htmlspecialchars($pak) . '</option>';
                    }
                    $template->assign_vars(array('S_CHOOSE_PAK' => true, 'S_PAK_OPTIONS' => $pak_options, 'L_TITLE' => $user->lang['ACP_' . $lang], 'L_EXPLAIN' => $user->lang['ACP_' . $lang . '_EXPLAIN'], 'L_NO_PAK_OPTIONS' => $user->lang['NO_' . $lang . '_PAK'], 'L_CURRENT' => $user->lang['CURRENT_' . $lang], 'L_CURRENT_EXPLAIN' => $user->lang['CURRENT_' . $lang . '_EXPLAIN'], 'L_IMPORT_SUBMIT' => $user->lang['IMPORT_' . $lang], 'U_BACK' => $this->u_action, 'U_ACTION' => $this->u_action . '&amp;action=import'));
                }
                break;
            case 'export':
                $this->page_title = 'EXPORT_' . $lang;
                $this->tpl_name = 'message_body';
                $template->assign_vars(array('MESSAGE_TITLE' => $user->lang['EXPORT_' . $lang], 'MESSAGE_TEXT' => sprintf($user->lang['EXPORT_' . $lang . '_EXPLAIN'], '<a href="' . $this->u_action . '&amp;action=send&amp;hash=' . generate_link_hash('acp_icons') . '">', '</a>'), 'S_USER_NOTICE' => true));
                return;
                break;
            case 'send':
                if (!check_link_hash($request->variable('hash', ''), 'acp_icons')) {
                    trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
                }
                $sql = "SELECT *\n\t\t\t\t\tFROM {$table}\n\t\t\t\t\tORDER BY {$fields}_order";
                $result = $db->sql_query($sql);
                $pak = '';
                while ($row = $db->sql_fetchrow($result)) {
                    $pak .= "'" . addslashes($row[$fields . '_url']) . "', ";
                    $pak .= "'" . addslashes($row[$fields . '_width']) . "', ";
                    $pak .= "'" . addslashes($row[$fields . '_height']) . "', ";
                    $pak .= "'" . addslashes($row['display_on_posting']) . "', ";
                    if ($mode == 'smilies') {
                        $pak .= "'" . addslashes($row['emotion']) . "', ";
                        $pak .= "'" . addslashes($row['code']) . "', ";
                    }
                    $pak .= "\n";
                }
                $db->sql_freeresult($result);
                if ($pak != '') {
                    garbage_collection();
                    header('Cache-Control: public');
                    // Send out the Headers
                    header('Content-Type: text/x-delimtext; name="' . $mode . '.pak"');
                    header('Content-Disposition: inline; filename="' . $mode . '.pak"');
                    echo $pak;
                    flush();
                    exit;
                } else {
                    trigger_error($user->lang['NO_' . strtoupper($fields) . '_EXPORT'] . adm_back_link($this->u_action), E_USER_WARNING);
                }
                break;
            case 'delete':
                if (confirm_box(true)) {
                    $sql = "DELETE FROM {$table}\n\t\t\t\t\t\tWHERE {$fields}_id = {$icon_id}";
                    $db->sql_query($sql);
                    switch ($mode) {
                        case 'smilies':
                            break;
                        case 'icons':
                            // Reset appropriate icon_ids
                            $db->sql_query('UPDATE ' . TOPICS_TABLE . "\n\t\t\t\t\t\t\t\tSET icon_id = 0\n\t\t\t\t\t\t\t\tWHERE icon_id = {$icon_id}");
                            $db->sql_query('UPDATE ' . POSTS_TABLE . "\n\t\t\t\t\t\t\t\tSET icon_id = 0\n\t\t\t\t\t\t\t\tWHERE icon_id = {$icon_id}");
                            break;
                    }
                    $notice = $user->lang[$lang . '_DELETED'];
                    $cache->destroy('_icons');
                    $cache->destroy('sql', $table);
                    $phpbb_container->get('text_formatter.cache')->invalidate();
                    if ($request->is_ajax()) {
                        $json_response = new \phpbb\json_response();
                        $json_response->send(array('MESSAGE_TITLE' => $user->lang['INFORMATION'], 'MESSAGE_TEXT' => $notice, 'REFRESH_DATA' => array('time' => 3)));
                    }
                } else {
                    confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('i' => $id, 'mode' => $mode, 'id' => $icon_id, 'action' => 'delete')));
                }
                break;
            case 'move_up':
            case 'move_down':
                if (!check_link_hash($request->variable('hash', ''), 'acp_icons')) {
                    trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
                }
                // Get current order id...
                $sql = "SELECT {$fields}_order as current_order\n\t\t\t\t\tFROM {$table}\n\t\t\t\t\tWHERE {$fields}_id = {$icon_id}";
                $result = $db->sql_query($sql);
                $current_order = (int) $db->sql_fetchfield('current_order');
                $db->sql_freeresult($result);
                if ($current_order == 0 && $action == 'move_up') {
                    break;
                }
                // on move_down, switch position with next order_id...
                // on move_up, switch position with previous order_id...
                $switch_order_id = $action == 'move_down' ? $current_order + 1 : $current_order - 1;
                //
                $sql = "UPDATE {$table}\n\t\t\t\t\tSET {$fields}_order = {$current_order}\n\t\t\t\t\tWHERE {$fields}_order = {$switch_order_id}\n\t\t\t\t\t\tAND {$fields}_id <> {$icon_id}";
                $db->sql_query($sql);
                $move_executed = (bool) $db->sql_affectedrows();
                // Only update the other entry too if the previous entry got updated
                if ($move_executed) {
                    $sql = "UPDATE {$table}\n\t\t\t\t\t\tSET {$fields}_order = {$switch_order_id}\n\t\t\t\t\t\tWHERE {$fields}_order = {$current_order}\n\t\t\t\t\t\t\tAND {$fields}_id = {$icon_id}";
                    $db->sql_query($sql);
                }
                $cache->destroy('_icons');
                $cache->destroy('sql', $table);
                $phpbb_container->get('text_formatter.cache')->invalidate();
                if ($request->is_ajax()) {
                    $json_response = new \phpbb\json_response();
                    $json_response->send(array('success' => $move_executed));
                }
                break;
        }
        // By default, check that image_order is valid and fix it if necessary
        $sql = "SELECT {$fields}_id AS order_id, {$fields}_order AS fields_order\n\t\t\tFROM {$table}\n\t\t\tORDER BY display_on_posting DESC, {$fields}_order";
        $result = $db->sql_query($sql);
        if ($row = $db->sql_fetchrow($result)) {
            $order = 0;
            do {
                ++$order;
                if ($row['fields_order'] != $order) {
                    $db->sql_query("UPDATE {$table}\n\t\t\t\t\t\tSET {$fields}_order = {$order}\n\t\t\t\t\t\tWHERE {$fields}_id = " . $row['order_id']);
                }
            } while ($row = $db->sql_fetchrow($result));
        }
        $db->sql_freeresult($result);
        $template->assign_vars(array('L_TITLE' => $user->lang['ACP_' . $lang], 'L_EXPLAIN' => $user->lang['ACP_' . $lang . '_EXPLAIN'], 'L_IMPORT' => $user->lang['IMPORT_' . $lang], 'L_EXPORT' => $user->lang['EXPORT_' . $lang], 'L_NOT_DISPLAYED' => $user->lang[$lang . '_NOT_DISPLAYED'], 'L_ICON_ADD' => $user->lang['ADD_' . $lang], 'L_ICON_EDIT' => $user->lang['EDIT_' . $lang], 'NOTICE' => $notice, 'COLSPAN' => $mode == 'smilies' ? 5 : 3, 'S_SMILIES' => $mode == 'smilies' ? true : false, 'U_ACTION' => $this->u_action, 'U_IMPORT' => $this->u_action . '&amp;action=import', 'U_EXPORT' => $this->u_action . '&amp;action=export'));
        /* @var $pagination \phpbb\pagination */
        $pagination = $phpbb_container->get('pagination');
        $pagination_start = $request->variable('start', 0);
        $spacer = false;
        $item_count = $this->item_count($table);
        $sql = "SELECT *\n\t\t\tFROM {$table}\n\t\t\tORDER BY {$fields}_order ASC";
        $result = $db->sql_query_limit($sql, $config['smilies_per_page'], $pagination_start);
        while ($row = $db->sql_fetchrow($result)) {
            $alt_text = $mode == 'smilies' ? $row['code'] : ($mode == 'icons' && !empty($row['icons_alt']) ? $row['icons_alt'] : $row['icons_url']);
            $template->assign_block_vars('items', array('S_SPACER' => !$spacer && !$row['display_on_posting'] ? true : false, 'ALT_TEXT' => $alt_text, 'IMG_SRC' => $phpbb_root_path . $img_path . '/' . $row[$fields . '_url'], 'WIDTH' => $row[$fields . '_width'], 'HEIGHT' => $row[$fields . '_height'], 'CODE' => isset($row['code']) ? $row['code'] : '', 'EMOTION' => isset($row['emotion']) ? $row['emotion'] : '', 'U_EDIT' => $this->u_action . '&amp;action=edit&amp;id=' . $row[$fields . '_id'], 'U_DELETE' => $this->u_action . '&amp;action=delete&amp;id=' . $row[$fields . '_id'], 'U_MOVE_UP' => $this->u_action . '&amp;action=move_up&amp;id=' . $row[$fields . '_id'] . '&amp;start=' . $pagination_start . '&amp;hash=' . generate_link_hash('acp_icons'), 'U_MOVE_DOWN' => $this->u_action . '&amp;action=move_down&amp;id=' . $row[$fields . '_id'] . '&amp;start=' . $pagination_start . '&amp;hash=' . generate_link_hash('acp_icons')));
            if (!$spacer && !$row['display_on_posting']) {
                $spacer = true;
            }
        }
        $db->sql_freeresult($result);
        $pagination->generate_template_pagination($this->u_action, 'pagination', 'start', $item_count, $config['smilies_per_page'], $pagination_start);
    }
Exemple #29
0
/**
* checks a link hash - for GET requests
* @param string $token the submitted token
* @param string $link_name The name of the link
* @return boolean true if all is fine
*/
function check_link_hash($token, $link_name)
{
    return $token === generate_link_hash($link_name);
}
Exemple #30
0
 public function generate_menus()
 {
     static $process = 0;
     $menu_image_path = $this->phpbb_root_path . 'ext/phpbbireland/portal/images/block_images/menu/';
     // process all menus at once //
     if ($process) {
         return;
     }
     $this->user->add_lang_ext('phpbbireland/portal', 'kiss_block_variables');
     $p_count = count($k_menus);
     $hash = $request->variable('hash', '');
     if (!function_exists('group_memberships')) {
         include $this->phpbb_root_path . 'includes/functions_user.' . $this->phpEx;
     }
     $memberships = array();
     $memberships = group_memberships(false, $this->user->data['user_id'], false);
     for ($i = 1; $i < $p_count + 1; $i++) {
         if (isset($this->k_menus[$i]['menu_type'])) {
             $u_id = '';
             $isamp = '';
             $menu_view_groups = $this->k_menus[$i]['view_groups'];
             $menu_item_view_all = $this->k_menus[$i]['view_all'];
             // skip process if everyone can view this menus //
             if ($menu_item_view_all == 1) {
                 $process_menu_item = true;
             } else {
                 $process_menu_item = false;
             }
             if (!$process_menu_item) {
                 $grps = explode(",", $menu_view_groups);
                 if ($memberships) {
                     foreach ($memberships as $member) {
                         for ($j = 0; $j < count($grps); $j++) {
                             if ($grps[$j] == $member['group_id']) {
                                 $process_menu_item = true;
                             }
                         }
                     }
                 }
             }
             if ($k_menus[$i]['append_uid'] == 1) {
                 $isamp = '&amp';
                 $u_id = $user->data['user_id'];
             } else {
                 $u_id = '';
                 $isamp = '';
             }
             if ($process_menu_item) {
                 $name = strtoupper($this->k_menus[$i]['name']);
                 $tmp_name = str_replace(' ', '_', $name);
                 $name = !empty($user->lang[$tmp_name]) ? $this->user->lang[$tmp_name] : $this->k_menus[$i]['name'];
                 if (strstr($this->k_menus[$i]['link_to'], 'http')) {
                     $link = $this->k_menus[$i]['link_to'] ? $this->k_menus[$i]['link_to'] : '';
                 } else {
                     if ($this->k_menus[$i]['append_sid']) {
                         if (strpos($this->k_menus[$i]['link_to'], 'hash')) {
                             $link = $this->user->data['is_registered'] || $this->config['load_anon_lastread'] ? append_sid("{$this->phpbb_root_path}index.{$this->phpEx}", 'hash=' . generate_link_hash('global') . '&amp;mark=forums') : '';
                         } else {
                             $link = $this->auth->acl_get('a_') && !empty($this->user->data['is_registered']) ? append_sid("{$this->phpbb_root_path}{$this->k_menus[$i]['link_to']}", false, true, $this->user->session_id) : '';
                         }
                     } else {
                         $link = $this->k_menus[$i]['link_to'] ? append_sid("{$this->phpbb_root_path}" . $this->k_menus[$i]['link_to'] . $u_id) : '';
                     }
                 }
                 $is_sub_heading = $this->k_menus[$i]['sub_heading'] ? true : false;
                 // we use js to manage open ibn tab //
                 switch ($k_menus[$i]['extern']) {
                     case 1:
                         $link_option = 'rel="external"';
                         break;
                     case 2:
                         $link_option = ' onclick="window.open(this.href); return false;"';
                         break;
                     default:
                         $link_option = '';
                         break;
                 }
                 // can be reduce later...
                 if ($this->k_menus[$i]['menu_type'] == NAV_MENUS) {
                     $template->assign_block_vars('portal_nav_menus_row', array('PORTAL_LINK_OPTION' => $link_option, 'PORTAL_MENU_HEAD_NAME' => $is_sub_heading ? $name : '', 'PORTAL_MENU_NAME' => $name, 'PORTAL_MENU_ICON' => $this->k_menus[$i]['menu_icon'] ? '<img src="' . $menu_image_path . $this->k_menus[$i]['menu_icon'] . '" height="16" width="16" alt="" />' : '<img src="' . $menu_image_path . 'spacer.gif" height="15px" width="15px" alt="" />', 'U_PORTAL_MENU_LINK' => $this->k_menus[$i]['sub_heading'] ? '' : $link, 'S_SOFT_HR' => $this->k_menus[$i]['soft_hr'], 'S_SUB_HEADING' => $this->k_menus[$i]['sub_heading'] ? true : false));
                 } else {
                     if ($this->k_menus[$i]['menu_type'] == SUB_MENUS) {
                         $template->assign_block_vars('portal_sub_menus_row', array('PORTAL_LINK_OPTION' => $link_option, 'PORTAL_MENU_HEAD_NAME' => $is_sub_heading ? $name : '', 'PORTAL_MENU_NAME' => $name, 'PORTAL_MENU_ICON' => $this->k_menus[$i]['menu_icon'] ? '<img src="' . $menu_image_path . $this->k_menus[$i]['menu_icon'] . '" height="16" width="16" alt="" />' : '<img src="' . $menu_image_path . 'spacer.gif" height="15px" width="15px" alt="" />', 'U_PORTAL_MENU_LINK' => $this->k_menus[$i]['sub_heading'] ? '' : $link, 'S_SOFT_HR' => $this->k_menus[$i]['soft_hr'], 'S_SUB_HEADING' => $this->k_menus[$i]['sub_heading'] ? true : false));
                     } else {
                         if ($this->k_menus[$i]['menu_type'] == LINKS_MENUS) {
                             $template->assign_block_vars('portal_link_menus_row', array('LINK_OPTION' => $link_option, 'PORTAL_LINK_MENU_HEAD_NAME' => $is_sub_heading ? $name : '', 'PORTAL_LINK_MENU_NAME' => $is_sub_heading ? '' : $name, 'U_PORTAL_LINK_MENU_LINK' => $is_sub_heading ? '' : $link, 'PORTAL_LINK_MENU_ICON' => $this->k_menus[$i]['menu_icon'] == 'NONE' ? '' : '<img src="' . $menu_image_path . $this->k_menus[$i]['menu_icon'] . '" alt="" />', 'S_SOFT_HR' => $this->k_menus[$i]['soft_hr'], 'S_SUB_HEADING' => $this->k_menus[$i]['sub_heading'] ? true : false));
                         }
                     }
                 }
             }
         }
     }
     $process = 1;
     $template->assign_vars(array('S_USER_LOGGED_IN' => $this->user->data['user_id'] != ANONYMOUS ? true : false, 'U_INDEX' => append_sid("{$phpbb_root_path}index.{$this->phpEx}"), 'U_PORTAL' => append_sid("{$phpbb_root_path}portal")));
 }