public function get_bookmarks($ext_mode = '', $forums = array())
  {
      define('POSTS_BOOKMARKS_TABLE', $this->table_prefix . 'posts_bookmarks');
      $start = $this->request->variable('start', 0);
      $sql = 'SELECT COUNT(post_id) as posts_count
	FROM ' . POSTS_BOOKMARKS_TABLE . '
	WHERE user_id = ' . $this->user->data['user_id'];
      $result = $this->db->sql_query($sql);
      $posts_count = (int) $this->db->sql_fetchfield('posts_count');
      $this->db->sql_freeresult($result);
      $sql_where = $sql_fields = '';
      if ($ext_mode != 'find') {
          $sql_where = 'LEFT JOIN ' . USERS_TABLE . ' u ON (p.poster_id = u.user_id)';
          $sql_fields = ', p.post_time, u.user_id, u.username, u.user_colour';
      }
      $pagination_url = append_sid("{$this->phpbb_root_path}postbookmark", "mode=find");
      $this->pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $posts_count, $this->config['topics_per_page'], $start);
      $sql = 'SELECT b.post_id AS b_post_id, b.user_id, b.bookmark_time, b.bookmark_desc, p.post_id, p.forum_id, p.topic_id, p.poster_id, p.post_subject, t.topic_title ' . $sql_fields . '
	FROM ' . POSTS_BOOKMARKS_TABLE . ' b
	LEFT JOIN ' . POSTS_TABLE . ' p ON( b.post_id = p.post_id)
	LEFT JOIN ' . TOPICS_TABLE . ' t ON( t.topic_id = p.topic_id)
	' . $sql_where . '
	WHERE b.user_id = ' . $this->user->data['user_id'] . '
	ORDER BY b.bookmark_time ASC';
      $result = $this->db->sql_query_limit($sql, $this->config['topics_per_page'], $start);
      while ($row = $this->db->sql_fetchrow($result)) {
          $topic_author = $sql_where ? get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']) : '';
          $post_time = $sql_where ? $this->user->format_date($row['post_time']) : '';
          // Send vars to template
          $this->template->assign_block_vars('postrow', array('POST_ID' => $row['b_post_id'], 'POST_TIME' => $post_time, 'BOOKMARK_TIME' => $this->user->format_date($row['bookmark_time']), 'BOOKMARK_DESC' => $row['bookmark_desc'], 'TOPIC_AUTHOR' => $topic_author, 'POST_TITLE' => $row['post_subject'] ? $row['post_subject'] : $row['topic_title'], 'U_VIEW_POST' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", "p=" . $row['post_id'] . "#p" . $row['post_id'] . ""), 'S_DELETED_TOPIC' => !$row['topic_id'] ? true : false, 'S_DELETED_POST' => !$row['post_id'] ? true : false, 'U_POST_BOOKMARK' => '[url=' . generate_board_url() . '/viewtopic.' . $this->php_ext . '?p=' . $row['post_id'] . '#p' . $row['post_id'] . ']' . ($row['post_subject'] ? $row['post_subject'] : $row['topic_title']) . '[/url]'));
      }
      $this->db->sql_freeresult($result);
      $this->template->assign_vars(array('TOTAL_BOOKMARKS' => $this->user->lang('TOTAL_BOOKMARKS', (int) $posts_count), 'PAGE_NUMBER' => $this->pagination->on_page($posts_count, $this->config['topics_per_page'], $start)));
  }
Example #2
0
 /**
  * Assigns an image with all data to the defined template-block
  *
  * @param string	$template_block	Name of the template-block
  * @param array	$image_data		Array with the image-data, all columns of GALLERY_IMAGES_TABLE are needed. album_name may be additionally assigned
  */
 public static function assign_block($template_block, &$image_data, $album_status, $display = 126, $album_user_id = -1)
 {
     global $auth, $template, $user;
     static $lang_loaded;
     if (!$lang_loaded) {
         $user->add_lang('mods/gallery_mcp');
         $lang_loaded = true;
     }
     $st = request_var('st', 0);
     $sk = request_var('sk', phpbb_gallery_config::get('default_sort_key'));
     $sd = request_var('sd', phpbb_gallery_config::get('default_sort_dir'));
     $image_data['rating'] = $user->lang['NOT_RATED'];
     if ($image_data['image_rates']) {
         $image_data['rating'] = sprintf($image_data['image_rates'] == 1 ? $user->lang['RATE_STRING'] : $user->lang['RATES_STRING'], $image_data['image_rate_avg'] / 100, $image_data['image_rates']);
     }
     // Hide the result, while still rating on contests
     if ($image_data['image_contest']) {
         $image_data['rating'] = $user->lang['CONTEST_RATING_HIDDEN'];
     }
     $s_user_allowed = $image_data['image_user_id'] == $user->data['user_id'] && $album_status != phpbb_gallery_album::STATUS_LOCKED;
     $s_allowed_delete = phpbb_gallery::$auth->acl_check('i_delete', $image_data['image_album_id'], $album_user_id) && $s_user_allowed || phpbb_gallery::$auth->acl_check('m_delete', $image_data['image_album_id'], $album_user_id);
     $s_allowed_edit = phpbb_gallery::$auth->acl_check('i_edit', $image_data['image_album_id'], $album_user_id) && $s_user_allowed || phpbb_gallery::$auth->acl_check('m_edit', $image_data['image_album_id'], $album_user_id);
     $s_quick_mod = $s_allowed_delete || $s_allowed_edit || phpbb_gallery::$auth->acl_check('m_status', $image_data['image_album_id'], $album_user_id) || phpbb_gallery::$auth->acl_check('m_move', $image_data['image_album_id'], $album_user_id);
     $template->assign_block_vars($template_block, array('IMAGE_ID' => $image_data['image_id'], 'UC_IMAGE_NAME' => $display & phpbb_gallery_block::DISPLAY_IMAGENAME ? self::generate_link('image_name', phpbb_gallery_config::get('link_image_name'), $image_data['image_id'], $image_data['image_name'], $image_data['image_album_id'], false, true, "&sk={$sk}&sd={$sd}&st={$st}") : '', 'UC_THUMBNAIL' => self::generate_link('thumbnail', phpbb_gallery_config::get('link_thumbnail'), $image_data['image_id'], $image_data['image_name'], $image_data['image_album_id']), 'U_ALBUM' => $display & phpbb_gallery_block::DISPLAY_ALBUMNAME ? phpbb_gallery_url::append_sid('album', 'album_id=' . $image_data['image_album_id']) : '', 'S_UNAPPROVED' => phpbb_gallery::$auth->acl_check('m_status', $image_data['image_album_id'], $album_user_id) && $image_data['image_status'] == self::STATUS_UNAPPROVED ? true : false, 'S_LOCKED' => $image_data['image_status'] == self::STATUS_LOCKED ? true : false, 'S_REPORTED' => phpbb_gallery::$auth->acl_check('m_report', $image_data['image_album_id'], $album_user_id) && $image_data['image_reported'] ? true : false, 'ALBUM_NAME' => $display & phpbb_gallery_block::DISPLAY_ALBUMNAME ? isset($image_data['album_name']) ? utf8_strlen(htmlspecialchars_decode($image_data['album_name'])) > phpbb_gallery_config::get('shortnames') + 3 ? htmlspecialchars(utf8_substr(htmlspecialchars_decode($image_data['album_name']), 0, phpbb_gallery_config::get('shortnames')) . '...') : $image_data['album_name'] : '' : '', 'ALBUM_NAME_FULL' => $display & phpbb_gallery_block::DISPLAY_ALBUMNAME ? isset($image_data['album_name']) ? $image_data['album_name'] : '' : '', 'POSTER' => $display & phpbb_gallery_block::DISPLAY_USERNAME ? $image_data['image_contest'] && !phpbb_gallery::$auth->acl_check('m_status', $image_data['image_album_id'], $album_user_id) ? $user->lang['CONTEST_USERNAME'] : get_username_string('full', $image_data['image_user_id'], $image_data['image_username'], $image_data['image_user_colour']) : '', 'TIME' => $display & phpbb_gallery_block::DISPLAY_IMAGETIME ? $user->format_date($image_data['image_time']) : '', 'VIEW' => $display & phpbb_gallery_block::DISPLAY_IMAGEVIEWS ? $image_data['image_view_count'] : -1, 'CONTEST_RANK' => $image_data['image_contest_rank'] ? $user->lang['CONTEST_RESULT_' . $image_data['image_contest_rank']] : '', 'CONTEST_RANK_ID' => $image_data['image_contest_rank'], 'S_RATINGS' => $display & phpbb_gallery_block::DISPLAY_RATINGS ? phpbb_gallery_config::get('allow_rates') && phpbb_gallery::$auth->acl_check('i_rate', $image_data['image_album_id'], $album_user_id) ? $image_data['rating'] : '' : '', 'U_RATINGS' => phpbb_gallery_url::append_sid('image_page', 'album_id=' . $image_data['image_album_id'] . "&image_id=" . $image_data['image_id']) . '#rating', 'L_COMMENTS' => $image_data['image_comments'] == 1 ? $user->lang['COMMENT'] : $user->lang['COMMENTS'], 'S_COMMENTS' => $display & phpbb_gallery_block::DISPLAY_COMMENTS ? phpbb_gallery_config::get('allow_comments') && phpbb_gallery::$auth->acl_check('c_read', $image_data['image_album_id'], $album_user_id) ? $image_data['image_comments'] ? $image_data['image_comments'] : $user->lang['NO_COMMENTS'] : '' : '', 'U_COMMENTS' => phpbb_gallery_url::append_sid('image_page', 'album_id=' . $image_data['image_album_id'] . "&image_id=" . $image_data['image_id']) . '#comments', 'S_MOD_ACTION' => phpbb_gallery_url::append_sid('mcp', "album_id={$image_data['image_album_id']}&image_id={$image_data['image_id']}&quickmod=1", true, $user->session_id), 'S_QUICK_MOD' => $s_quick_mod, 'S_QM_MOVE' => phpbb_gallery::$auth->acl_check('m_move', $image_data['image_album_id'], $album_user_id), 'S_QM_EDIT' => $s_allowed_edit, 'S_QM_DELETE' => $s_allowed_delete, 'S_QM_REPORT' => phpbb_gallery::$auth->acl_check('m_report', $image_data['image_album_id'], $album_user_id), 'S_QM_STATUS' => phpbb_gallery::$auth->acl_check('m_status', $image_data['image_album_id'], $album_user_id), 'S_IMAGE_REPORTED' => $image_data['image_reported'], 'U_IMAGE_REPORTED' => $image_data['image_reported'] ? phpbb_gallery_url::append_sid('mcp', "mode=report_details&album_id={$image_data['image_album_id']}&option_id=" . $image_data['image_reported']) : '', 'S_STATUS_APPROVED' => $image_data['image_status'] == phpbb_gallery_image::STATUS_APPROVED, 'S_STATUS_UNAPPROVED' => $image_data['image_status'] == phpbb_gallery_image::STATUS_UNAPPROVED, 'S_STATUS_LOCKED' => $image_data['image_status'] == phpbb_gallery_image::STATUS_LOCKED, 'S_IP' => $display & phpbb_gallery_block::DISPLAY_IP && $auth->acl_get('a_') ? $image_data['image_user_ip'] : '', 'U_WHOIS' => phpbb_gallery_url::append_sid('mcp', 'mode=whois&ip=' . $image_data['image_user_ip']), 'U_REPORT' => phpbb_gallery::$auth->acl_check('m_report', $image_data['image_album_id'], $album_user_id) && $image_data['image_reported'] ? phpbb_gallery_url::append_sid('mcp', "mode=report_details&album_id={$image_data['image_album_id']}&option_id=" . $image_data['image_reported']) : '', 'U_STATUS' => phpbb_gallery::$auth->acl_check('m_status', $image_data['image_album_id'], $album_user_id) ? phpbb_gallery_url::append_sid('mcp', "mode=queue_details&album_id={$image_data['image_album_id']}&option_id=" . $image_data['image_id']) : '', 'L_STATUS' => $image_data['image_status'] == self::STATUS_UNAPPROVED ? $user->lang['APPROVE_IMAGE'] : ($image_data['image_status'] == self::STATUS_APPROVED ? $user->lang['CHANGE_IMAGE_STATUS'] : $user->lang['UNLOCK_IMAGE']), 'U_MOVE' => phpbb_gallery::$auth->acl_check('m_move', $image_data['image_album_id'], $album_user_id) ? phpbb_gallery_url::append_sid('mcp', "action=images_move&album_id={$image_data['image_album_id']}&image_id=" . $image_data['image_id'] . "&redirect=redirect") : '', 'U_EDIT' => $s_allowed_edit ? phpbb_gallery_url::append_sid('posting', "mode=image&submode=edit&album_id={$image_data['image_album_id']}&image_id=" . $image_data['image_id']) : '', 'U_DELETE' => $s_allowed_delete ? phpbb_gallery_url::append_sid('posting', "mode=image&submode=delete&album_id={$image_data['image_album_id']}&image_id=" . $image_data['image_id']) : ''));
 }
  /**
   * Display the user ranks page
   *
   * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
   * @access public
   */
  public function display($name)
  {
      // Get the rank details
      $sql = 'SELECT *
	FROM ' . RANKS_TABLE . '
	ORDER BY rank_special DESC, rank_min ASC, rank_title ASC';
      $result = $this->db->sql_query($sql);
      while ($row = $this->db->sql_fetchrow($result)) {
          if ($this->config['userranks_special'] || $this->config['userranks_special_admin'] && $this->auth->acl_get('a_') || !$this->config['userranks_special'] && !$row['rank_special']) {
              $rank_row = array('S_RANK_IMAGE' => $row['rank_image'] ? true : false, 'S_SPECIAL_RANK' => $row['rank_special'] ? true : false, 'RANK_IMAGE' => $this->path_helper->get_web_root_path() . $this->config['ranks_path'] . '/' . $row['rank_image'], 'RANK_TITLE' => $row['rank_title'], 'MIN_POSTS' => $row['rank_min']);
              $this->template->assign_block_vars('ranks', $rank_row);
              // Are we displaying members?
              if ($this->config['userranks_members'] || $this->config['userranks_members_admin'] && $this->auth->acl_get('a_')) {
                  $rank_users = $this->get_user_rank_data($row['rank_id']);
                  if (sizeof($rank_users) > 0) {
                      foreach ($rank_users as $row_rank) {
                          $this->template->assign_block_vars('ranks.rank_member', array('MEMBERS' => get_username_string('full', $row_rank['user_id'], $row_rank['username'], $row_rank['user_colour'])));
                      }
                  } else {
                      $this->template->assign_block_vars('ranks.rank_member', array('MEMBERS' => $this->user->lang('NO_MEMBERS')));
                  }
              }
          }
      }
      $this->db->sql_freeresult($result);
      // Assign breadcrumb template vars for the user ranks page
      $this->template->assign_block_vars('navlinks', array('U_VIEW_FORUM' => $this->helper->route('david63_userranks_main_controller', array('name' => 'ranks')), 'FORUM_NAME' => $this->user->lang('USER_RANKS')));
      // Send all data to the template file
      return $this->helper->render('user_ranks.html', $name);
  }
Example #4
0
  public function create_welcome_topic($user_id)
  {
      if (!$this->config['welcomerobot_enable']) {
          return false;
      }
      if (!function_exists('get_username_string')) {
          include $this->root_path . 'includes/functions_content.' . $this->phpEx;
      }
      if (!function_exists('submit_post')) {
          include $this->root_path . 'includes/functions_posting.' . $this->phpEx;
      }
      $sql = 'SELECT *
	FROM ' . USERS_TABLE . "\n\t\t\tWHERE user_id = " . intval($user_id) . "";
      $dbresult = $this->db->sql_query($sql);
      $row = $this->db->sql_fetchrow($dbresult);
      $this->db->sql_freeresult($dbresult);
      if (empty($row)) {
          return false;
      }
      $username = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
      $clean_username = utf8_clean_string($row['username']);
      $topic_title = str_replace(array('%user', '%robot', '%board'), array($clean_username, $this->config['welcomerobot_username'], $this->config['sitename']), $this->config['welcomerobot_title']);
      $topic_content = str_replace(array('%user', '%robot', '%board'), array($clean_username, $this->config['welcomerobot_username'], $this->config['sitename']), $this->config['welcomerobot_detail']);
      $poll = $uid = $bitfield = $options = '';
      // will be modified by generate_text_for_storage
      $allow_bbcode = $allow_urls = $allow_smilies = true;
      generate_text_for_storage($topic_content, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies);
      $data = array('forum_id' => $this->config['welcomerobot_forum'], 'topic_id' => 0, 'icon_id' => false, 'robot_name' => $this->config['welcomerobot_username'], 'enable_bbcode' => true, 'enable_smilies' => true, 'enable_urls' => true, 'enable_sig' => true, 'message' => $topic_content, 'message_md5' => md5($topic_content), 'bbcode_bitfield' => $bitfield, 'bbcode_uid' => $uid, 'post_edit_locked' => 0, 'topic_title' => $topic_title, 'notify_set' => false, 'notify' => false, 'post_time' => 0, 'forum_name' => '', 'enable_indexing' => true, 'force_approved_state' => true);
      submit_post('post', $topic_title, 'robot_name', POST_NORMAL, $poll, $data);
      return true;
  }
	public function get_template_side($module_id)
	{
		global $config, $db, $template;
		global $phpbb_root_path, $phpEx;

		$sql = 'SELECT user_id, username, user_posts, user_colour
			FROM ' . USERS_TABLE . '
			WHERE user_type <> ' . USER_IGNORE . "
				AND user_posts <> 0
				AND username <> ''
			ORDER BY user_posts DESC";
		$result = $db->sql_query_limit($sql, $config['board3_topposters_' . $module_id]);

		while (($row = $db->sql_fetchrow($result)))
		{
			$template->assign_block_vars('topposters', array(
				'S_SEARCH_ACTION'	=> append_sid("{$phpbb_root_path}search.$phpEx", 'author_id=' . $row['user_id'] . '&amp;sr=posts'),
				'USERNAME_FULL'		=> get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
				'POSTER_POSTS'		=> $row['user_posts'],
			));
		}
		$db->sql_freeresult($result);

		return 'topposters_side.html';
	}
	public function get_template_side($module_id)
	{
		global $config, $template, $db, $user;

		// Last x visited bots
		$sql = 'SELECT username, user_colour, user_lastvisit
			FROM ' . USERS_TABLE . '
			WHERE user_type = ' . USER_IGNORE . '
			AND user_lastvisit > 0
			ORDER BY user_lastvisit DESC';
		$result = $db->sql_query_limit($sql, $config['board3_last_visited_bots_number_' . $module_id]);

		$show_module = false;

		while ($row = $db->sql_fetchrow($result))
		{
			$template->assign_block_vars('last_visited_bots', array(
				'BOT_NAME'			=> get_username_string('full', '', $row['username'], $row['user_colour']),
				'LAST_VISIT_DATE'	=> $user->format_date($row['user_lastvisit']),
			));
			$show_module = true;
		}
		$db->sql_freeresult($result);

		if($show_module)
		{
			return 'latest_bots_side.html';
		}
	}
Example #7
0
function friends_function_generate_menu(&$arg)
{
    global $auth, $cache, $config, $db, $user, $template, $phpbb_root_path;
    global $user_id, $blog_template, $blog_images_path;
    $limit = 4;
    $template->assign_vars(array('ZEBRA_LIST_LIMIT' => $limit, 'IMG_PORTAL_MEMBER' => $blog_images_path . 'icon_friend.gif', 'S_CONTENT_FLOW_BEGIN' => $user->lang['DIRECTION'] == 'ltr' ? 'left' : 'right', 'S_CONTENT_FLOW_END' => $user->lang['DIRECTION'] == 'ltr' ? 'right' : 'left'));
    if ($user_id == ANONYMOUS || $user->data['is_bot']) {
        return;
    }
    // Output listing of friends online
    $menu_friends_online = $menu_friends_offline = $user_friends = 0;
    $update_time = time() - intval($config['load_online_time']) * 60;
    // lets use the cache...as this query is quite intensive
    $cache_data = false;
    //$cache->get("_zebra{$user_id}");
    if ($cache_data === false) {
        $sql = $db->sql_build_query('SELECT_DISTINCT', array('SELECT' => 'u.user_id, u.username, u.username_clean, u.user_colour, MAX(s.session_time) as online_time, MIN(s.session_viewonline) AS viewonline', 'FROM' => array(USERS_TABLE => 'u', ZEBRA_TABLE => 'z'), 'LEFT_JOIN' => array(array('FROM' => array(SESSIONS_TABLE => 's'), 'ON' => 's.session_user_id = z.zebra_id')), 'WHERE' => 'z.user_id = ' . intval($user_id) . '
				AND z.friend = 1
				AND u.user_id = z.zebra_id', 'GROUP_BY' => 'z.zebra_id, u.user_id, u.username_clean, u.user_colour, u.username', 'ORDER_BY' => 'u.username_clean ASC'));
        $result = $db->sql_query($sql);
        $rowset = $db->sql_fetchrowset($result);
        $db->sql_freeresult($result);
        //$cache->put("_zebra{$user_id}", $rowset, 60); // cache for 1 minute
        $cache_data = $rowset;
    }
    foreach ($cache_data as $row) {
        $which = $update_time < $row['online_time'] && ($row['viewonline'] || $auth->acl_get('u_viewonline')) ? 'menu_friends_online' : 'menu_friends_offline';
        ${$which}++;
        $template->assign_block_vars("{$which}", array('USER_ID' => $row['user_id'], 'U_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), 'U_VIEW_BLOG' => blog_url($row['user_id']), 'USER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'HIDE' => true));
    }
    $template->assign_vars(array('S_SHOW_NEXT_ONLINE' => $menu_friends_online > $limit ? true : false, 'S_SHOW_NEXT_OFFLINE' => $menu_friends_offline > $limit ? true : false, 'S_MENU_ZEBRA_ENABLED' => $menu_friends_online || $menu_friends_offline ? true : false));
    $arg['user_menu_extra'] .= blog_plugins::parse_template('blog/plugins/friends/friends_body.html');
}
Example #8
0
   /**
    * Changes the regex replacement for second pass
    *
    * @param object $event
    * @return null
    * @access public
    */
   public function modify_replies($event)
   {
       if (!function_exists('get_username_string')) {
           include $this->root_path . 'includes/functions_content.' . $this->php_ext;
       }
       // 1. output each line with user + post-count
       // 2. output in "inline-popup" like in "mark posts read"
       $topic_row = $event['topic_row'];
       $topic_id = $topic_row['TOPIC_ID'];
       $sql = 'SELECT COUNT(p.post_id) AS posts, p.poster_id, u.username, u.user_colour
	FROM phpbb_posts p, phpbb_users u
	WHERE p.topic_id = ' . (int) $topic_id . '
	AND p.poster_id = u.user_id
	GROUP BY p.poster_id
	ORDER BY posts DESC';
       $result = $this->db->sql_query_limit($sql, 5);
       while ($row = $this->db->sql_fetchrow($result)) {
           var_dump($row);
           $post_count = $row['posts'];
           $display_username = get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour']);
           echo $display_username . ' with ' . $post_count . 'posts<br />';
       }
       $this->db->sql_freeresult($result);
       $topic_row['REPLIES'] = '<a href="#t=' . $topic_id . '" class="whoposted">' . $topic_row['REPLIES'] . '</a>';
       $event['topic_row'] = $topic_row;
   }
    function main($id, $mode)
    {
        global $db, $user, $auth, $template;
        global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
        $error = $notify = array();
        $user->add_lang(array('mods/info_acp_emails_users_list'));
        $mode = request_var('mode', '');
        $start = request_var('start', 0);
        if ($mode == 'list') {
            // How many Users do we have?
            $sql = 'SELECT COUNT(user_id) AS total_users
	FROM ' . USERS_TABLE . '
	WHERE user_type <> ' . USER_IGNORE;
            $result = $db->sql_query($sql);
            $total_users = (int) $db->sql_fetchfield('total_users');
            $db->sql_freeresult($result);
            // want more to display...change the 20 to a higher number
            $tf = 20;
            //Pull Users from the database
            $sql = 'SELECT *
	FROM ' . USERS_TABLE . '
	WHERE user_type <> ' . USER_IGNORE . '
	ORDER BY user_id';
            $result = $db->sql_query_limit($sql, $tf, $start);
            // Assign specific vars
            while ($row = $db->sql_fetchrow($result)) {
                $template->assign_block_vars('list', array('ID' => $row['user_id'], 'EMAIL' => $row['user_email'], 'REGDATE' => $user->format_date($row['user_regdate']), 'LASTVISIT' => $user->format_date($row['user_lastvisit']), 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), 'USER_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), 'U_VIEW_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour'])));
            }
            $this->tpl_name = 'acp_emails_users_list';
            $this->page_title = 'EMAILS_USERS_LIST';
            $template->assign_vars(array('PAGINATION' => generate_pagination($this->u_action, $total_users, $tf, $start), 'PAGE_NUMBER' => on_page($total_users, $tf, $start), 'U_CSV_LIST' => append_sid("{$phpbb_root_path}list.{$phpEx}", 'mode=list'), 'U_ACTION' => $this->u_action, 'TOTAL_USERS' => $total_users == 1 ? $user->lang['USER_COUNT'] : sprintf($user->lang['USER_COUNTS'], $total_users)));
            $db->sql_freeresult($result);
        }
    }
Example #10
0
 /**
  * {@inheritdoc}
  */
 public function display(array $bdata, $edit_mode = false)
 {
     $content = '';
     if ($this->user->data['is_registered']) {
         $this->ptemplate->assign_vars(array('USER_AVATAR' => phpbb_get_user_avatar($this->user->data), 'USERNAME' => get_username_string('no_profile', $this->user->data['user_id'], $this->user->data['username'], $this->user->data['user_colour']), 'USERNAME_FULL' => get_username_string('full', $this->user->data['user_id'], $this->user->data['username'], $this->user->data['user_colour']), 'U_PROFILE' => append_sid($this->phpbb_root_path . 'memberlist.' . $this->php_ext, 'mode=viewprofile&amp;u=' . $this->user->data['user_id']), 'U_SEARCH_NEW' => append_sid($this->phpbb_root_path . 'search.' . $this->php_ext, 'search_id=newposts'), 'U_SEARCH_SELF' => append_sid($this->phpbb_root_path . 'search.' . $this->php_ext, 'search_id=egosearch'), 'U_PRIVATE_MSG' => append_sid($this->phpbb_root_path . 'ucp.' . $this->php_ext, 'i=pm&amp;folder=inbox'), 'U_LOGOUT' => append_sid($this->phpbb_root_path . 'ucp.' . $this->php_ext, 'mode=logout', true, $this->user->session_id), 'U_MCP' => $this->auth->acl_get('m_') ? append_sid($this->phpbb_root_path . 'mcp.' . $this->php_ext, false, true, $this->user->session_id) : '', 'U_ACP' => $this->auth->acl_get('a_') ? append_sid($this->phpbb_root_path . 'adm/index.' . $this->php_ext, 'i=-blitze-sitemaker-acp-menu_module', true, $this->user->session_id) : ''));
         $content = $this->ptemplate->render_view('blitze/sitemaker', 'blocks/member_menu.html', 'member_menu_block');
     }
     return array('title' => 'WELCOME', 'content' => $content);
 }
Example #11
0
 /**
  * {@inheritdoc}
  */
 public function display(array $settings, $edit_mode = false)
 {
     $content = '';
     $content .= $this->user->lang('TOTAL_POSTS_COUNT', (int) $this->config['num_posts']) . '<br />';
     $content .= $this->user->lang('TOTAL_TOPICS', (int) $this->config['num_topics']) . '<br />';
     $content .= $this->user->lang('TOTAL_USERS', (int) $this->config['num_users']) . '<br />';
     $content .= $this->user->lang('NEWEST_USER', get_username_string('full', $this->config['newest_user_id'], $this->config['newest_username'], $this->config['newest_user_colour']));
     return array('title' => 'STATISTICS', 'content' => $content);
 }
Example #12
0
  /**
   * {@inheritdoc}
   */
  public function get_template_side($module_id)
  {
      $sql = 'SELECT user_id, username, user_regdate, user_colour
	FROM ' . USERS_TABLE . '
	WHERE user_type <> ' . USER_IGNORE . '
		AND user_inactive_time = 0
	ORDER BY user_regdate DESC';
      $result = $this->db->sql_query_limit($sql, $this->config['board3_max_last_member_' . $module_id], 0, 600);
      while (($row = $this->db->sql_fetchrow($result)) && $row['username']) {
          $this->template->assign_block_vars('latest_members', array('USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'JOINED' => $this->user->format_date($row['user_regdate'], $format = 'd M')));
      }
      $this->db->sql_freeresult($result);
      return 'latest_members_side.html';
  }
 function main($id, $mode)
 {
     global $template, $user, $db, $config, $phpEx, $phpbb_root_path, $ultimate_points, $points_config, $points_values, $auth, $check_auth;
     $adm_points = request_var('adm_points', false);
     $u_id = request_var('user_id', 0);
     $post_id = request_var('post_id', 0);
     if (empty($u_id)) {
         $message = $user->lang['EDIT_NO_ID_SPECIFIED'] . '<br /><br /><a href="' . append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=bank_edit") . '">&laquo; ' . $user->lang['BACK_TO_PREV'] . '</a>';
         trigger_error($message);
     }
     $user_id = $u_id;
     add_form_key('bank_edit');
     if ($adm_points != false && ($auth->acl_get('a_points') || $auth->acl_get('m_chg_bank'))) {
         $template->assign_block_vars('administer_bank', array());
         if (isset($_POST['submit'])) {
             if (!check_form_key('bank_edit')) {
                 trigger_error('FORM_INVALID');
             }
             $new_points = round(request_var('points', 0.0), 2);
             set_bank($u_id, $new_points);
             $sql_array = array('SELECT' => 'user_id, username, user_points, user_colour', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => 'user_id = ' . (int) $u_id);
             $sql = $db->sql_build_query('SELECT', $sql_array);
             $result = $db->sql_query($sql);
             $points_user = $db->sql_fetchrow($result);
             add_log('admin', 'LOG_MOD_BANK', $points_user['username']);
             $message = $post_id ? sprintf($user->lang['EDIT_P_RETURN_POST'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "p=" . $post_id) . '">', '</a>') : sprintf($user->lang['EDIT_P_RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.{$phpEx}") . '">', '</a>');
             trigger_error(sprintf($user->lang['EDIT_POINTS_SET'], $config['points_name']) . $message);
         } else {
             $sql_array = array('SELECT' => 'u.user_id, u.username, u.user_points, u.user_colour, b.holding', 'FROM' => array(USERS_TABLE => 'u'), 'LEFT_JOIN' => array(array('FROM' => array(POINTS_BANK_TABLE => 'b'), 'ON' => 'u.user_id = b.user_id')), 'WHERE' => 'u.user_id = ' . (int) $u_id);
             $sql = $db->sql_build_query('SELECT', $sql_array);
             $result = $db->sql_query($sql);
             $row = $db->sql_fetchrow($result);
             if (empty($u_id)) {
                 $message = $user->lang['EDIT_USER_NOT_EXIST'] . '<br /><br /><a href="' . append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=bank_edit") . '">&laquo; ' . $user->lang['BACK_TO_PREV'] . '</a>';
                 trigger_error($message);
             }
             $hidden_fields = build_hidden_fields(array('user_id' => $u_id, 'post_id' => $post_id));
             $template->assign_vars(array('USER_NAME' => get_username_string('full', $u_id, $row['username'], $row['user_colour']), 'BANK_POINTS' => sprintf(number_format_points($row['holding'])), 'POINTS_NAME' => $config['points_name'], 'CURRENT_VALUE' => $row['holding'], 'L_POINTS_MODIFY' => sprintf($user->lang['EDIT_BANK_MODIFY'], $config['points_name']), 'L_P_BANK_TITLE' => sprintf($user->lang['EDIT_P_BANK_TITLE'], $config['points_name']), 'L_USERNAME' => $user->lang['USERNAME'], 'L_SET_AMOUNT' => $user->lang['EDIT_SET_AMOUNT'], 'U_USER_LINK' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=viewprofile&amp;u=" . $u_id), 'S_ACTION' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=bank_edit&amp;adm_points=1"), 'S_HIDDEN_FIELDS' => $hidden_fields));
         }
     } else {
         $message = $user->lang['NOT_AUTHORISED'];
         trigger_error($message);
     }
     // Generate the page
     page_header($user->lang['EDIT_POINTS_ADMIN']);
     // Generate the page template
     $template->set_filenames(array('body' => 'points/points_bank_edit.html'));
     page_footer();
 }
Example #14
0
  public function index_modify_page_title($event)
  {
      $this->user->add_lang_ext('dmzx/newestmembers', 'common');
      $sql = 'SELECT user_id, username, user_colour
	FROM ' . USERS_TABLE . '
	WHERE user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')
	ORDER BY user_id DESC';
      $result = $this->db->sql_query_limit($sql, 5);
      if ($result) {
          while ($row = $this->db->sql_fetchrow($result)) {
              $this->template->assign_block_vars('newestmembers', array('NEWESTMEMBERS' => sprintf($this->user->lang['NEWEST_MEMBERS'], get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']))));
          }
      }
      $this->db->sql_freeresult($result);
  }
Example #15
0
 function user_get_name($u_id)
 {
     global $db;
     $sql = 'SELECT username, user_colour
       FROM ' . USERS_TABLE . '
       WHERE user_id = ' . $db->sql_escape($u_id);
     $result = $result = $db->sql_query_limit($sql, 1);
     $row = $db->sql_fetchrow($result);
     $db->sql_freeresult($result);
     if ($row) {
         return ': ' . get_username_string('no_profile', $u_id, $row['username'], $row['user_colour']);
     } else {
         return '';
     }
 }
 /**
  * Display reputation toplist
  *
  * @return null
  * @access public
  */
 public function reputation_toplist()
 {
     if ($this->config['rs_enable'] && $this->config['rs_enable_toplist'] && $this->config['rs_toplist_num']) {
         $this->user->add_lang_ext('pico/reputation', 'reputation_toplist');
         $sql = 'SELECT user_id, username, user_colour, user_reputation
	FROM ' . USERS_TABLE . '
	WHERE user_reputation > 0
	ORDER BY user_reputation DESC';
         $result = $this->db->sql_query_limit($sql, $this->config['rs_toplist_num']);
         while ($row = $this->db->sql_fetchrow($result)) {
             $this->template->assign_block_vars('toplist', array('USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'USER_REPUTATION' => $row['user_reputation'], 'U_VIEW_USER_REPUTATION' => $this->helper->route('reputation_details_controller', array('uid' => $row['user_id'])), 'S_DIRECTION' => $this->config['rs_toplist_direction'] ? true : false));
         }
         $this->db->sql_freeresult($result);
         $this->template->assign_vars(array('S_RS_TOPLIST' => true, 'S_VIEW_REPUTATION' => $this->auth->acl_get('u_rs_view') ? true : false));
     }
 }
Example #17
0
 public function index_modify_page_title()
 {
     global $phpbb_dispatcher;
     $this->user->add_lang_ext('alg/wwhlight', 'wwhlight');
     $user_online_link = $rowset = array();
     $sql_ary = array('SELECT' => 'u.user_id, u.username, u.username_clean, u.user_type, u.user_colour, u.user_ip, u.user_lastvisit, u.user_allow_viewonline', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => 'user_type <> ' . USER_IGNORE . ' AND DATE(FROM_UNIXTIME (user_lastvisit)) = CURDATE()', 'ORDER_BY' => 'u.user_lastvisit DESC');
     /**
      * Modify SQL query to obtain wwhlight users data
      *
      * @event wwhlight.obtain_users_online_string_sql
      */
     $vars = array('sql_ary');
     extract($phpbb_dispatcher->trigger_event('wwhlight.obtain_users_online_string_sql', compact($vars)));
     $result = $this->db->sql_query($this->db->sql_build_query('SELECT', $sql_ary));
     $rowset = $this->db->sql_fetchrowset($result);
     $this->db->sql_freeresult($result);
     foreach ($rowset as $row) {
         if ($row['user_allow_viewonline']) {
             $last_visit_time = sprintf($this->user->lang['WWHLIGHT_LATEST'], $this->user->format_date($row['user_lastvisit'], 'H:i'));
             $username = get_username_string($row['user_type'] != USER_IGNORE ? 'full' : 'no_profile', $row['user_id'], $row['username'], $row['user_colour']);
             $user_online_link[$row['user_id']] = '<span title="' . ($last_visit_time ? $last_visit_time : '') . '">' . $username . '</span>';
             $this->counter_users_reg++;
         } else {
             if ($this->auth->acl_get('u_viewonline')) {
                 $user_online_link[$row['user_id']] = '<em>' . $row['username'] . '</em>';
             }
             $this->counter_users_hidden++;
         }
         $this->counter_users_total++;
     }
     $online_userlist = $this->user->lang['REGISTERED_USERS'] . ' ' . implode(', ', $user_online_link);
     /**
      * Modify wwhlight userlist data
      *
      * @event wwhlight.obtain_users_online_string_modify
      * @var	array	rowset				Array with wwhlight users data
      * @var	array	user_online_link	Array with wwhlight usernames
      * @var	string	online_userlist		String containing users wwhlight list
      */
     $vars = array('rowset', 'user_online_link', 'online_userlist');
     extract($phpbb_dispatcher->trigger_event('wwhlight.obtain_users_online_string_modify', compact($vars)));
     if (!sizeof($user_online_link)) {
         $online_userlist = $this->user->lang['NO_ONLINE_USERS'];
     }
     $this->template->assign_vars(array('WWHLIGHT_LIST' => $online_userlist, 'WWHLIGHT_DETAILS' => $this->obtain_users_string(), 'WWHLIGHT_RECORD' => sprintf($this->user->lang['WWHLIGHT_RECORD'], $this->config['wwhlight_record'], $this->config['wwhlight_record_time']) . '<br />'));
 }
Example #18
0
  /**
   * Display Options
   *
   * Output the options available
   */
  function display_options()
  {
      global $db, $template, $user;
      // Generate a list of founders
      $sql = 'SELECT user_id, username, user_colour
	FROM ' . USERS_TABLE . '
	WHERE user_type = ' . USER_FOUNDER;
      $result = $db->sql_query($sql);
      while ($row = $db->sql_fetchrow($result)) {
          $template->assign_block_vars('founders', array('L_FOUNDER_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'L_FOUNDER_ID' => $row['user_id'], 'S_DISABLED' => $row['user_id'] == $user->data['user_id'] ? true : false));
      }
      $db->sql_freeresult($result);
      // Additional template stuff
      $template->assign_vars(array('U_DEMOTE_FOUNDERS' => append_sid(STK_INDEX, array('c' => 'user_group', 't' => 'manage_founders', 'mode' => 'demote', 'submit' => 1)), 'U_FIND_USER' => append_sid(PHPBB_ROOT_PATH . 'memberlist.' . PHP_EXT, array('mode' => 'searchuser', 'form' => 'select_user', 'field' => 'username', 'select_single' => 'true', 'form' => 'stk_promote_founder', 'field' => 'username')), 'U_PROMOTE_FOUNDER' => append_sid(STK_INDEX, array('c' => 'user_group', 't' => 'manage_founders', 'mode' => 'promote', 'submit' => 1))));
      $template->set_filenames(array('body' => 'tools/manage_founders.html'));
      page_header($user->lang['MANAGE_FOUNDERS'], false);
      page_footer();
  }
 /**
  * Handle the requests
  *
  * @return null
  * @access public
  */
 public function handle()
 {
     switch ($this->request->variable('mode', '')) {
         case 'who_is_online':
             // Output page
             page_header('', true);
             $this->template->set_filenames(array('body' => 'ajax_base/who_is_online.html'));
             page_footer();
             break;
         case 'statistics':
             $this->template->assign_vars(array('TOTAL_POSTS' => $this->user->lang('TOTAL_POSTS_COUNT', (int) $this->config['num_posts']), 'TOTAL_TOPICS' => $this->user->lang('TOTAL_TOPICS', (int) $this->config['num_topics']), 'TOTAL_USERS' => $this->user->lang('TOTAL_USERS', (int) $this->config['num_users']), 'NEWEST_USER' => $this->user->lang('NEWEST_USER', get_username_string('full', $this->config['newest_user_id'], $this->config['newest_username'], $this->config['newest_user_colour']))));
             // Output page
             page_header('');
             $this->template->set_filenames(array('body' => 'ajax_base/statistics.html'));
             page_footer();
             break;
     }
 }
 /**
  * @return bool
  */
 private function _find_birthday_users()
 {
     $time = $this->user->create_datetime($this->time);
     $now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset());
     $leap_year_birthdays = $this->_adjust_leap_year($now, $time);
     $sql = 'SELECT u.user_id, u.username, u.user_colour, u.user_birthday 
	FROM ' . USERS_TABLE . ' u
	LEFT JOIN ' . BANLIST_TABLE . " b ON (u.user_id = b.ban_userid)\n\t\t\t\tWHERE (b.ban_id IS NULL\n\t\t\t\t\tOR b.ban_exclude = 1)\n\t\t\t\t\tAND (u.user_birthday LIKE '" . $this->db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%' {$leap_year_birthdays})\n\t\t\t\t\tAND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')
	ORDER BY u.username ASC';
     $result = $this->db->sql_query($sql);
     $show_birthday = false;
     while ($row = $this->db->sql_fetchrow($result)) {
         $show_birthday = true;
         $this->ptemplate->assign_block_vars('birthday', array('USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'USER_AGE' => $this->_get_user_age($row['user_birthday'], $now['year'])));
     }
     $this->db->sql_freeresult($result);
     return $show_birthday;
 }
 function main($id, $mode)
 {
     global $template, $user, $db, $config, $phpEx, $phpbb_root_path, $ultimate_points, $points_config, $points_values, $auth, $checked_user, $check_auth;
     print_r('test');
     // Select user's bank holding
     $sql_array = array('SELECT' => '*', 'FROM' => array(POINTS_BANK_TABLE => 'b'), 'WHERE' => 'user_id = ' . (int) $user->data['user_id']);
     $sql = $db->sql_build_query('SELECT', $sql_array);
     $result = $db->sql_query($sql);
     $row = $db->sql_fetchrow($result);
     // Select user's lottery tickets
     $viewer_total_tickets = '';
     if ($user->data['user_id'] != ANONYMOUS) {
         $sql_array = array('SELECT' => 'COUNT(ticket_id) AS num_tickets', 'FROM' => array(POINTS_LOTTERY_TICKETS_TABLE => 't'), 'WHERE' => 'user_id = ' . (int) $user->data['user_id']);
         $sql = $db->sql_build_query('SELECT', $sql_array);
         $result = $db->sql_query($sql);
         $viewer_total_tickets = (int) $db->sql_fetchfield('num_tickets');
         $db->sql_freeresult($result);
     }
     // Generate the page header
     page_header(sprintf($user->lang['POINTS_TITLE_MAIN'], $config['points_name']));
     $user_name = get_username_string('full', $checked_user['user_id'], $checked_user['username'], $checked_user['user_colour']);
     // Generate some language stuff, dependig on the fact, if user has a bank account or not
     if ($row['user_id'] != $user->data['user_id'] || $row['holding'] < 1) {
         $template->assign_vars(array('L_MAIN_ON_HAND' => sprintf($user->lang['MAIN_ON_HAND'], number_format_points($checked_user['user_points']), $config['points_name']), 'L_MAIN_HELLO_USERNAME' => sprintf($user->lang['MAIN_HELLO_USERNAME'], $user_name), 'L_MAIN_LOTTERY_TICKETS' => sprintf($user->lang['MAIN_LOTTERY_TICKETS'], $viewer_total_tickets)));
     } else {
         $template->assign_vars(array('L_MAIN_ON_HAND' => $auth->acl_get('u_use_points') ? sprintf($user->lang['MAIN_ON_HAND'], number_format_points($checked_user['user_points']), $config['points_name']) : '', 'L_MAIN_HELLO_USERNAME' => sprintf($user->lang['MAIN_HELLO_USERNAME'], $user_name), 'L_MAIN_LOTTERY_TICKETS' => $auth->acl_get('u_use_lottery') ? sprintf($user->lang['MAIN_LOTTERY_TICKETS'], $viewer_total_tickets) : ''));
         if ($auth->acl_get('u_use_bank')) {
             $template->assign_block_vars('has_bank_account', array('L_MAIN_BANK_HAVE' => sprintf($user->lang['MAIN_BANK_HAVE'], number_format_points($row['holding']), $config['points_name'])));
         }
     }
     // Generate most rich users
     $limit = $points_values['number_show_top_points'];
     $sql_array = array('SELECT' => 'user_id, username, user_colour, user_points', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => 'user_points > 0', 'ORDER_BY' => 'user_points DESC, username_clean ASC');
     $sql = $db->sql_build_query('SELECT', $sql_array);
     $result = $db->sql_query_limit($sql, $limit);
     while ($row = $db->sql_fetchrow($result)) {
         $template->assign_block_vars('points', array('USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'POINT' => sprintf(number_format_points($row['user_points']))));
     }
     $db->sql_freeresult($result);
     $template->assign_vars(array('LOTTERY_NAME' => $points_values['lottery_name'], 'BANK_NAME' => $points_values['bank_name'], 'S_DISPLAY_INDEX' => $points_values['number_show_top_points'] > 0 ? true : false, 'U_TRANSFER_USER' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=transfer_user"), 'U_LOGS' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=logs"), 'U_LOTTERY' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=lottery"), 'U_BANK' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=bank"), 'U_ROBBERY' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=robbery"), 'U_INFO' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=info"), 'U_USE_TRANSFER' => $auth->acl_get('u_use_transfer'), 'U_USE_LOGS' => $auth->acl_get('u_use_logs'), 'U_USE_LOTTERY' => $auth->acl_get('u_use_lottery'), 'U_USE_BANK' => $auth->acl_get('u_use_bank'), 'U_USE_ROBBERY' => $auth->acl_get('u_use_robbery')));
     // Generate the page template
     $template->set_filenames(array('body' => 'points/points_main.html'));
     page_footer();
 }
Example #22
0
 public function info($user_id)
 {
     if (!$this->auth->acl_gets('u_viewprofile')) {
         trigger_error('NOT_AUTHORISED');
     }
     $sql_ary = array('SELECT' => 'u.username, u.user_colour, u.user_regdate, u.user_posts, u.user_lastvisit, u.user_rank, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => 'u.user_id = ' . (int) $user_id);
     /**
      * Modify SQL query in tas2580 AJAX userinfo extension
      *
      * @event tas2580.userinfo_modify_sql
      * @var    string		sql_ary	The SQL query
      * @var    int		user_id	The ID of the user
      * @since 0.2.3
      */
     $vars = array('sql_ary', 'user_id');
     extract($this->phpbb_dispatcher->trigger_event('tas2580.userinfo_modify_sql', compact($vars)));
     $result = $this->db->sql_query_limit($this->db->sql_build_query('SELECT', $sql_ary), 1);
     $this->data = $this->db->sql_fetchrow($result);
     $this->db->sql_freeresult($result);
     if (!function_exists('phpbb_get_user_rank')) {
         include $this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext;
     }
     $user_rank_data = phpbb_get_user_rank($this->data, $this->data['user_posts']);
     // Get the avatar
     // Wen need to use the full URL here because we don't know the path where userinfo is called
     define('PHPBB_USE_BOARD_URL_PATH', true);
     $avatar = phpbb_get_user_avatar($this->data);
     $avatar = empty($avatar) ? '<img src="' . generate_board_url() . '/styles/' . $this->user->style['style_name'] . '/theme/images/no_avatar.gif" width="100" height="100" alt="' . $this->user->lang('USER_AVATAR') . '">' : $avatar;
     $memberdays = max(1, round((time() - $this->data['user_regdate']) / 86400));
     $posts_per_day = $this->data['user_posts'] / $memberdays;
     $percentage = $this->config['num_posts'] ? min(100, $this->data['user_posts'] / $this->config['num_posts'] * 100) : 0;
     $result = array('userinfo_header' => sprintf($this->user->lang['VIEWING_PROFILE'], $this->data['username']), 'username' => get_username_string('no_profile', $user_id, $this->data['username'], $this->data['user_colour']), 'regdate' => $this->user->format_date($this->data['user_regdate']), 'posts' => $this->data['user_posts'], 'lastvisit' => $this->user->format_date($this->data['user_lastvisit']), 'avatar' => $avatar, 'rank' => empty($user_rank_data['title']) ? $this->user->lang('NA') : $user_rank_data['title'], 'postsperday' => $this->user->lang('POST_DAY', $posts_per_day), 'percentage' => $this->user->lang('POST_PCT', $percentage));
     /**
      * Modify return data in tas2580 AJAX userinfo extension
      *
      * @event tas2580.userinfo_modify_result
      * @var    array	result	The result array
      * @var    int	user_id	The ID of the user
      * @since 0.2.3
      */
     $vars = array('result', 'user_id');
     extract($this->phpbb_dispatcher->trigger_event('tas2580.userinfo_modify_result', compact($vars)));
     return new JsonResponse($result);
 }
Example #23
0
 public function afficher_photos($event)
 {
     $user_id = $this->user->data["user_id"];
     $this->user->add_lang_ext('Aurelienazerty/Photos', 'photos');
     $lesPhotos = fonctionGetLastCommentaireForUser($user_id, 10, false);
     $lesPhotos = commentaireForUser($lesPhotos, $user_id);
     $tpl_loopname = 'recent_photos';
     foreach ($lesPhotos['lignesMessage'] as $photo) {
         if ($photo['compteNonLu']) {
             $folder_alt = 'UNREAD_POST';
             $folder_type = 'topic_unread';
             $contexte = $photo['contexte'];
             $tpl_ary = array('LAST_POST_AUTHOR_FULL' => get_username_string('full', $photo['user_id'], $photo['username'], $photo['user_colour']), 'U_VIEW_PHOTO' => $photo['link'], 'PHOTO_TITLE' => $photo['nom'], 'LAST_POST_TIME' => $this->user->format_date($photo['date']), 'TOPIC_FOLDER_IMG_ALT' => $this->user->lang[$folder_alt], 'TOPIC_IMG_STYLE' => $folder_type, 'NEWEST_POST_IMG' => $this->user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), 'PHOTO_CONTEXTE_URL' => replace_mod_rewrite($contexte[1]['href']), 'PHOTO_CONTEXTE' => $contexte[1]['txt']);
             //$vars = array('photo', 'tpl_ary');
             //extract($this->dispatcher->trigger_event('Aurelienazerty.Photos.modify_tpl_ary', compact($vars)));
             $this->template->assign_block_vars($tpl_loopname, $tpl_ary);
         }
     }
 }
Example #24
0
 /**
  * {@inheritdoc}
  */
 public function get_template_side($module_id)
 {
     $s_display_friends = false;
     // Output listing of friends online
     $update_time = $this->config['load_online_time'] * 60;
     $sql = $this->db->sql_build_query('SELECT_DISTINCT', array('SELECT' => 'u.user_id, u.username, u.username_clean, u.user_colour, u.user_allow_viewonline, MAX(s.session_time) as online_time, MIN(s.session_viewonline) AS viewonline', 'FROM' => array(USERS_TABLE => 'u', ZEBRA_TABLE => 'z'), 'LEFT_JOIN' => array(array('FROM' => array(SESSIONS_TABLE => 's'), 'ON' => 's.session_user_id = z.zebra_id')), 'WHERE' => 'z.user_id = ' . $this->user->data['user_id'] . '
	AND z.friend = 1
	AND u.user_id = z.zebra_id', 'GROUP_BY' => 'z.zebra_id, u.user_id, u.username, u.username_clean, u.user_allow_viewonline, u.user_colour', 'ORDER_BY' => 'u.username_clean ASC'));
     $result = $this->db->sql_query_limit($sql, $this->config['board3_max_online_friends_' . $module_id]);
     while ($row = $this->db->sql_fetchrow($result)) {
         $which = time() - $update_time < $row['online_time'] && ($row['viewonline'] || $this->auth->acl_get('u_viewonline')) ? 'online' : 'offline';
         $s_display_friends = $row['user_id'] ? true : false;
         $this->template->assign_block_vars("b3p_friends_{$which}", array('USER_ID' => $row['user_id'], 'U_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), 'USER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'])));
     }
     $this->db->sql_freeresult($result);
     // Assign specific vars
     $this->template->assign_vars(array('S_DISPLAY_FRIENDS' => $s_display_friends));
     return 'friends_side.html';
 }
  public function handle_ultimatepoints_list()
  {
      // UPlist disabled
      if (!$this->config['points_enable']) {
          trigger_error($this->user->lang['POINTS_LIST_DISABLE'], E_USER_NOTICE);
      }
      // Get some values
      $sql_array = array('SELECT' => '*', 'FROM' => array($this->points_values_table => 'v'));
      $sql = $this->db->sql_build_query('SELECT', $sql_array);
      $result = $this->db->sql_query($sql);
      $points_values = $this->db->sql_fetchrow($result);
      $this->db->sql_freeresult($result);
      // Generate donors list
      $start = $this->request->variable('start', 0);
      $limit = $points_values['number_show_per_page'];
      $sql = 'SELECT *
	FROM ' . USERS_TABLE . '
	WHERE user_points > 0
	ORDER BY user_points DESC';
      $result = $this->db->sql_query_limit($sql, $limit, $start);
      while ($row = $this->db->sql_fetchrow($result)) {
          $this->template->assign_block_vars('ultimatelist', array('USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'POINT' => sprintf($this->functions_points->number_format_points($row['user_points']))));
      }
      $this->db->sql_freeresult($result);
      // Generate pagination
      $sql = 'SELECT COUNT(user_points) AS ultimatepoints_total
	FROM ' . USERS_TABLE . '
	WHERE user_points > 0';
      $result = $this->db->sql_query($sql);
      $ultimatepoints_total = (int) $this->db->sql_fetchfield('ultimatepoints_total');
      //Start pagination
      $pagination_url = $this->helper->route('dmzx_ultimatepoints_list_controller');
      $this->pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $ultimatepoints_total, $limit, $start);
      $this->template->assign_vars(array('TOTAL_ULTIMATEPOINTS_LIST' => $ultimatepoints_total == 1 ? $this->user->lang['POINTS_LIST_USER'] : sprintf($this->user->lang['POINTS_LIST_USERS'], $ultimatepoints_total), 'POINTSLIST' => $this->config['points_name']));
      // Output the page
      page_header($this->user->lang['POINTS_LIST_TOTAL']);
      $this->template->set_filenames(array('body' => 'points/points_list.html'));
      page_footer();
  }
 /**
  * Display stats on index page
  *
  * @param object $event The event object
  * @return null
  * @access public
  */
 public function display_24_hour_stats($event)
 {
     // if the user is a bot, we won’t even process this function...
     if ($this->user->data['is_bot']) {
         return;
     }
     $this->user->add_lang_ext('rmcgirr83/activity24hours', 'common');
     // obtain user activity data
     $active_users = $this->obtain_active_user_data();
     // obtain posts/topics/new users activity
     $activity = $this->obtain_activity_data();
     // Obtain guests data
     $total_guests_online_24 = $this->obtain_guest_count_24();
     // 24 hour users online list, assign to the template block: lastvisit
     foreach ((array) $active_users as $row) {
         $max_last_visit = max($row['user_lastvisit'], $row['session_time']);
         $hover_info = ' title="' . $this->user->format_date($max_last_visit) . '"';
         $this->template->assign_block_vars('lastvisit', array('USERNAME_FULL' => '<span' . $hover_info . '>' . get_username_string($row['user_type'] == USER_IGNORE ? 'no_profile' : 'full', $row['user_id'], $row['username'], $row['user_colour']) . '</span>'));
     }
     // assign the stats to the template.
     $this->template->assign_vars(array('USERS_24HOUR_TOTAL' => $this->user->lang('USERS_24HOUR_TOTAL', sizeof($active_users)), 'USERS_ACTIVE' => sizeof($active_users), 'HOUR_TOPICS' => $this->user->lang('24HOUR_TOPICS', $activity['topics']), 'HOUR_POSTS' => $this->user->lang('24HOUR_POSTS', $activity['posts']), 'HOUR_USERS' => $this->user->lang('24HOUR_USERS', $activity['users']), 'GUEST_ONLINE_24' => $this->user->lang('GUEST_ONLINE_24', $total_guests_online_24)));
 }
Example #27
0
/**
* Uses the result of obtain_users_online to generate a localized, readable representation.
* @param mixed $online_users result of obtain_users_online - array with user_id lists for total, hidden and visible users, and statistics
* @param int $forum_id Indicate that the data is limited to one forum and not global.
* @return array An array containing the string for output to the template
*/
function obtain_users_online_string($online_users, $forum_id = 0)
{
    global $config, $db, $user, $auth;
    $user_online_link = $online_userlist = '';
    if (sizeof($online_users['online_users'])) {
        $sql = 'SELECT username, username_clean, user_id, user_type, user_allow_viewonline, user_colour
				FROM ' . USERS_TABLE . '
				WHERE ' . $db->sql_in_set('user_id', $online_users['online_users']) . '
				ORDER BY username_clean ASC';
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            // User is logged in and therefore not a guest
            if ($row['user_id'] != ANONYMOUS) {
                if (isset($online_users['hidden_users'][$row['user_id']])) {
                    $row['username'] = '<em>' . $row['username'] . '</em>';
                }
                if (!isset($online_users['hidden_users'][$row['user_id']]) || $auth->acl_get('u_viewonline')) {
                    $user_online_link = get_username_string($row['user_type'] != USER_IGNORE ? 'full' : 'no_profile', $row['user_id'], $row['username'], $row['user_colour']);
                    $online_userlist .= $online_userlist != '' ? ', ' . $user_online_link : $user_online_link;
                }
            }
        }
        $db->sql_freeresult($result);
    }
    if (!$online_userlist) {
        $online_userlist = $user->lang['NO_ONLINE_USERS'];
    }
    if ($forum_id === 0) {
        $online_userlist = $user->lang['REGISTERED_USERS'] . ' ' . $online_userlist;
    } else {
        if ($config['load_online_guests']) {
            $l_online = $online_users['guests_online'] === 1 ? $user->lang['BROWSING_FORUM_GUEST'] : $user->lang['BROWSING_FORUM_GUESTS'];
            $online_userlist = sprintf($l_online, $online_userlist, $online_users['guests_online']);
        } else {
            $online_userlist = sprintf($user->lang['BROWSING_FORUM'], $online_userlist);
        }
    }
    // Build online listing
    $vars_online = array('ONLINE' => array('total_online', 'l_t_user_s', 0), 'REG' => array('visible_online', 'l_r_user_s', !$config['load_online_guests']), 'HIDDEN' => array('hidden_online', 'l_h_user_s', $config['load_online_guests']), 'GUEST' => array('guests_online', 'l_g_user_s', 0));
    foreach ($vars_online as $l_prefix => $var_ary) {
        if ($var_ary[2]) {
            $l_suffix = '_AND';
        } else {
            $l_suffix = '';
        }
        switch ($online_users[$var_ary[0]]) {
            case 0:
                ${$var_ary[1]} = $user->lang[$l_prefix . '_USERS_ZERO_TOTAL' . $l_suffix];
                break;
            case 1:
                ${$var_ary[1]} = $user->lang[$l_prefix . '_USER_TOTAL' . $l_suffix];
                break;
            default:
                ${$var_ary[1]} = $user->lang[$l_prefix . '_USERS_TOTAL' . $l_suffix];
                break;
        }
    }
    unset($vars_online);
    $l_online_users = sprintf($l_t_user_s, $online_users['total_online']);
    $l_online_users .= sprintf($l_r_user_s, $online_users['visible_online']);
    $l_online_users .= sprintf($l_h_user_s, $online_users['hidden_online']);
    if ($config['load_online_guests']) {
        $l_online_users .= sprintf($l_g_user_s, $online_users['guests_online']);
    }
    return array('online_userlist' => $online_userlist, 'l_online_users' => $l_online_users);
}
Example #28
0
 function main($id, $mode)
 {
     global $auth, $db, $user, $template, $cache;
     global $config, $phpbb_root_path, $phpEx, $action, $phpbb_container, $phpbb_dispatcher;
     include_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx;
     $forum_id = request_var('f', 0);
     $start = request_var('start', 0);
     $this->page_title = 'MCP_REPORTS';
     switch ($action) {
         case 'close':
         case 'delete':
             include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
             $report_id_list = request_var('report_id_list', array(0));
             if (!sizeof($report_id_list)) {
                 trigger_error('NO_REPORT_SELECTED');
             }
             close_report($report_id_list, $mode, $action);
             break;
     }
     switch ($mode) {
         case 'report_details':
             $user->add_lang(array('posting', 'viewforum', 'viewtopic'));
             $post_id = request_var('p', 0);
             // closed reports are accessed by report id
             $report_id = request_var('r', 0);
             $sql = 'SELECT r.post_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, r.reported_post_text, r.reported_post_uid, r.reported_post_bitfield, r.reported_post_enable_magic_url, r.reported_post_enable_smilies, r.reported_post_enable_bbcode, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour
		FROM ' . REPORTS_TABLE . ' r, ' . REPORTS_REASONS_TABLE . ' rr, ' . USERS_TABLE . ' u
		WHERE ' . ($report_id ? 'r.report_id = ' . $report_id : "r.post_id = {$post_id}") . '
			AND rr.reason_id = r.reason_id
			AND r.user_id = u.user_id
			AND r.pm_id = 0
		ORDER BY report_closed ASC';
             $result = $db->sql_query_limit($sql, 1);
             $report = $db->sql_fetchrow($result);
             $db->sql_freeresult($result);
             if (!$report) {
                 trigger_error('NO_REPORT');
             }
             $phpbb_notifications = $phpbb_container->get('notification_manager');
             $phpbb_notifications->mark_notifications_read('notification.type.report_post', $post_id, $user->data['user_id']);
             if (!$report_id && $report['report_closed']) {
                 trigger_error('REPORT_CLOSED');
             }
             $post_id = $report['post_id'];
             $report_id = $report['report_id'];
             $parse_post_flags = $report['reported_post_enable_bbcode'] ? OPTION_FLAG_BBCODE : 0;
             $parse_post_flags += $report['reported_post_enable_smilies'] ? OPTION_FLAG_SMILIES : 0;
             $parse_post_flags += $report['reported_post_enable_magic_url'] ? OPTION_FLAG_LINKS : 0;
             $post_info = phpbb_get_post_data(array($post_id), 'm_report', true);
             if (!sizeof($post_info)) {
                 trigger_error('NO_REPORT_SELECTED');
             }
             $post_info = $post_info[$post_id];
             $reason = array('title' => $report['reason_title'], 'description' => $report['reason_description']);
             if (isset($user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])]) && isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])])) {
                 $reason['description'] = $user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])];
                 $reason['title'] = $user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])];
             }
             if (topic_review($post_info['topic_id'], $post_info['forum_id'], 'topic_review', 0, false)) {
                 $template->assign_vars(array('S_TOPIC_REVIEW' => true, 'S_BBCODE_ALLOWED' => $post_info['enable_bbcode'], 'TOPIC_TITLE' => $post_info['topic_title'], 'REPORTED_POST_ID' => $post_id));
             }
             $topic_tracking_info = $extensions = $attachments = array();
             // Get topic tracking info
             if ($config['load_db_lastread']) {
                 $tmp_topic_data = array($post_info['topic_id'] => $post_info);
                 $topic_tracking_info = get_topic_tracking($post_info['forum_id'], $post_info['topic_id'], $tmp_topic_data, array($post_info['forum_id'] => $post_info['forum_mark_time']));
                 unset($tmp_topic_data);
             } else {
                 $topic_tracking_info = get_complete_topic_tracking($post_info['forum_id'], $post_info['topic_id']);
             }
             $post_unread = isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']] ? true : false;
             $message = generate_text_for_display($report['reported_post_text'], $report['reported_post_uid'], $report['reported_post_bitfield'], $parse_post_flags, false);
             $report['report_text'] = make_clickable(bbcode_nl2br($report['report_text']));
             if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) {
                 $sql = 'SELECT *
			FROM ' . ATTACHMENTS_TABLE . '
			WHERE post_msg_id = ' . $post_id . '
				AND in_message = 0
				AND filetime <= ' . (int) $report['report_time'] . '
			ORDER BY filetime DESC';
                 $result = $db->sql_query($sql);
                 while ($row = $db->sql_fetchrow($result)) {
                     $attachments[] = $row;
                 }
                 $db->sql_freeresult($result);
                 if (sizeof($attachments)) {
                     $update_count = array();
                     parse_attachments($post_info['forum_id'], $message, $attachments, $update_count);
                 }
                 // Display not already displayed Attachments for this post, we already parsed them. ;)
                 if (!empty($attachments)) {
                     $template->assign_var('S_HAS_ATTACHMENTS', true);
                     foreach ($attachments as $attachment) {
                         $template->assign_block_vars('attachment', array('DISPLAY_ATTACHMENT' => $attachment));
                     }
                 }
             }
             $template->assign_vars(array('S_MCP_REPORT' => true, 'S_CLOSE_ACTION' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports&amp;mode=report_details&amp;f=' . $post_info['forum_id'] . '&amp;p=' . $post_id), 'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']), 'S_POST_REPORTED' => $post_info['post_reported'], 'S_POST_UNAPPROVED' => $post_info['post_visibility'] == ITEM_UNAPPROVED || $post_info['post_visibility'] == ITEM_REAPPROVE, 'S_POST_LOCKED' => $post_info['post_edit_locked'], 'S_REPORT_CLOSED' => $report['report_closed'], 'S_USER_NOTES' => true, 'U_EDIT' => $auth->acl_get('m_edit', $post_info['forum_id']) ? append_sid("{$phpbb_root_path}posting.{$phpEx}", "mode=edit&amp;f={$post_info['forum_id']}&amp;p={$post_info['post_id']}") : '', 'U_MCP_APPROVE' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&amp;mode=approve_details&amp;f=' . $post_info['forum_id'] . '&amp;p=' . $post_id), 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports&amp;mode=report_details&amp;f=' . $post_info['forum_id'] . '&amp;p=' . $post_id), 'U_MCP_REPORTER_NOTES' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&amp;mode=user_notes&amp;u=' . $report['user_id']), 'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&amp;mode=user_notes&amp;u=' . $post_info['user_id']), 'U_MCP_WARN_REPORTER' => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=warn&amp;mode=warn_user&amp;u=' . $report['user_id']) : '', 'U_MCP_WARN_USER' => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=warn&amp;mode=warn_user&amp;u=' . $post_info['user_id']) : '', 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $post_info['forum_id']), 'U_VIEW_POST' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $post_info['forum_id'] . '&amp;p=' . $post_info['post_id'] . '#p' . $post_info['post_id']), 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $post_info['forum_id'] . '&amp;t=' . $post_info['topic_id']), 'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']), 'MINI_POST_IMG' => $post_unread ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', $user->lang['POST_UNAPPROVED']), 'RETURN_REPORTS' => sprintf($user->lang['RETURN_REPORTS'], '<a href="' . append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports' . ($post_info['post_reported'] ? '&amp;mode=reports' : '&amp;mode=reports_closed') . '&amp;start=' . $start . '&amp;f=' . $post_info['forum_id']) . '">', '</a>'), 'REPORTED_IMG' => $user->img('icon_topic_reported', $user->lang['POST_REPORTED']), 'REPORT_DATE' => $user->format_date($report['report_time']), 'REPORT_ID' => $report_id, 'REPORT_REASON_TITLE' => $reason['title'], 'REPORT_REASON_DESCRIPTION' => $reason['description'], 'REPORT_TEXT' => $report['report_text'], 'POST_AUTHOR_FULL' => get_username_string('full', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'POST_AUTHOR' => get_username_string('username', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'U_POST_AUTHOR' => get_username_string('profile', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'REPORTER_FULL' => get_username_string('full', $report['user_id'], $report['username'], $report['user_colour']), 'REPORTER_COLOUR' => get_username_string('colour', $report['user_id'], $report['username'], $report['user_colour']), 'REPORTER_NAME' => get_username_string('username', $report['user_id'], $report['username'], $report['user_colour']), 'U_VIEW_REPORTER_PROFILE' => get_username_string('profile', $report['user_id'], $report['username'], $report['user_colour']), 'POST_PREVIEW' => $message, 'POST_SUBJECT' => $post_info['post_subject'] ? $post_info['post_subject'] : $user->lang['NO_SUBJECT'], 'POST_DATE' => $user->format_date($post_info['post_time']), 'POST_IP' => $post_info['poster_ip'], 'POST_IPADDR' => $auth->acl_get('m_info', $post_info['forum_id']) && request_var('lookup', '') ? @gethostbyaddr($post_info['poster_ip']) : '', 'POST_ID' => $post_info['post_id'], 'U_LOOKUP_IP' => $auth->acl_get('m_info', $post_info['forum_id']) ? $this->u_action . '&amp;r=' . $report_id . '&amp;p=' . $post_id . '&amp;f=' . $forum_id . '&amp;lookup=' . $post_info['poster_ip'] . '#ip' : ''));
             $this->tpl_name = 'mcp_post';
             break;
         case 'reports':
         case 'reports_closed':
             $topic_id = request_var('t', 0);
             $forum_info = array();
             $forum_list_reports = get_forum_list('m_report', false, true);
             $forum_list_read = array_flip(get_forum_list('f_read', true, true));
             // Flipped so we can isset() the forum IDs
             // Remove forums we cannot read
             foreach ($forum_list_reports as $k => $forum_data) {
                 if (!isset($forum_list_read[$forum_data['forum_id']])) {
                     unset($forum_list_reports[$k]);
                 }
             }
             unset($forum_list_read);
             if ($topic_id) {
                 $topic_info = phpbb_get_topic_data(array($topic_id));
                 if (!sizeof($topic_info)) {
                     trigger_error('TOPIC_NOT_EXIST');
                 }
                 if ($forum_id != $topic_info[$topic_id]['forum_id']) {
                     $topic_id = 0;
                 } else {
                     $topic_info = $topic_info[$topic_id];
                     $forum_id = (int) $topic_info['forum_id'];
                 }
             }
             $forum_list = array();
             if (!$forum_id) {
                 foreach ($forum_list_reports as $row) {
                     $forum_list[] = $row['forum_id'];
                 }
                 if (!sizeof($forum_list)) {
                     trigger_error('NOT_MODERATOR');
                 }
                 $global_id = $forum_list[0];
                 $sql = 'SELECT SUM(forum_topics_approved) as sum_forum_topics
			FROM ' . FORUMS_TABLE . '
			WHERE ' . $db->sql_in_set('forum_id', $forum_list);
                 $result = $db->sql_query($sql);
                 $forum_info['forum_topics_approved'] = (int) $db->sql_fetchfield('sum_forum_topics');
                 $db->sql_freeresult($result);
             } else {
                 $forum_info = phpbb_get_forum_data(array($forum_id), 'm_report');
                 if (!sizeof($forum_info)) {
                     trigger_error('NOT_MODERATOR');
                 }
                 $forum_info = $forum_info[$forum_id];
                 $forum_list = array($forum_id);
             }
             $forum_list[] = 0;
             $forum_data = array();
             $pagination = $phpbb_container->get('pagination');
             $forum_options = '<option value="0"' . ($forum_id == 0 ? ' selected="selected"' : '') . '>' . $user->lang['ALL_FORUMS'] . '</option>';
             foreach ($forum_list_reports as $row) {
                 $forum_options .= '<option value="' . $row['forum_id'] . '"' . ($forum_id == $row['forum_id'] ? ' selected="selected"' : '') . '>' . str_repeat('&nbsp; &nbsp;', $row['padding']) . $row['forum_name'] . '</option>';
                 $forum_data[$row['forum_id']] = $row;
             }
             unset($forum_list_reports);
             $sort_days = $total = 0;
             $sort_key = $sort_dir = '';
             $sort_by_sql = $sort_order_sql = array();
             phpbb_mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id);
             $forum_topics = $total == -1 ? $forum_info['forum_topics_approved'] : $total;
             $limit_time_sql = $sort_days ? 'AND r.report_time >= ' . (time() - $sort_days * 86400) : '';
             if ($mode == 'reports') {
                 $report_state = 'AND p.post_reported = 1 AND r.report_closed = 0';
             } else {
                 $report_state = 'AND r.report_closed = 1';
             }
             $sql = 'SELECT r.report_id
		FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . REPORTS_TABLE . ' r ' . ($sort_order_sql[0] == 'u' ? ', ' . USERS_TABLE . ' u' : '') . ($sort_order_sql[0] == 'r' ? ', ' . USERS_TABLE . ' ru' : '') . '
		WHERE ' . $db->sql_in_set('p.forum_id', $forum_list) . "\n\t\t\t\t\t\t{$report_state}\n\t\t\t\t\t\tAND r.post_id = p.post_id\n\t\t\t\t\t\t" . ($sort_order_sql[0] == 'u' ? 'AND u.user_id = p.poster_id' : '') . '
			' . ($sort_order_sql[0] == 'r' ? 'AND ru.user_id = r.user_id' : '') . '
			' . ($topic_id ? 'AND p.topic_id = ' . $topic_id : '') . "\n\t\t\t\t\t\tAND t.topic_id = p.topic_id\n\t\t\t\t\t\tAND r.pm_id = 0\n\t\t\t\t\t\t{$limit_time_sql}\n\t\t\t\t\tORDER BY {$sort_order_sql}";
             /**
              * Alter sql query to get report id of all reports for requested forum and topic or just forum
              *
              * @event core.mcp_reports_get_reports_query_before
              * @var	string	sql						String with the query to be executed
              * @var	array	forum_list				List of forums that contain the posts
              * @var	int		topic_id				topic_id in the page request
              * @var	string	limit_time_sql			String with the SQL code to limit the time interval of the post (Note: May be empty string)
              * @var	string	sort_order_sql			String with the ORDER BY SQL code used in this query
              * @since 3.1.0-RC4
              */
             $vars = array('sql', 'forum_list', 'topic_id', 'limit_time_sql', 'sort_order_sql');
             extract($phpbb_dispatcher->trigger_event('core.mcp_reports_get_reports_query_before', compact($vars)));
             $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
             $i = 0;
             $report_ids = array();
             while ($row = $db->sql_fetchrow($result)) {
                 $report_ids[] = $row['report_id'];
                 $row_num[$row['report_id']] = $i++;
             }
             $db->sql_freeresult($result);
             if (sizeof($report_ids)) {
                 $sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, p.post_id, p.post_subject, p.post_username, p.poster_id, p.post_time, p.post_attachment, u.username, u.username_clean, u.user_colour, r.user_id as reporter_id, ru.username as reporter_name, ru.user_colour as reporter_colour, r.report_time, r.report_id
			FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u, ' . USERS_TABLE . ' ru
			WHERE ' . $db->sql_in_set('r.report_id', $report_ids) . '
				AND t.topic_id = p.topic_id
				AND r.post_id = p.post_id
				AND u.user_id = p.poster_id
				AND ru.user_id = r.user_id
				AND r.pm_id = 0
			ORDER BY ' . $sort_order_sql;
                 $result = $db->sql_query($sql);
                 $report_data = $rowset = array();
                 while ($row = $db->sql_fetchrow($result)) {
                     $template->assign_block_vars('postrow', array('U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $row['forum_id']), 'U_VIEWPOST' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $row['forum_id'] . '&amp;p=' . $row['post_id']) . '#p' . $row['post_id'], 'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=reports&amp;start={$start}&amp;mode=report_details&amp;f={$row['forum_id']}&amp;r={$row['report_id']}"), 'POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'REPORTER_FULL' => get_username_string('full', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'REPORTER_COLOUR' => get_username_string('colour', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'REPORTER' => get_username_string('username', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'U_REPORTER' => get_username_string('profile', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'FORUM_NAME' => $forum_data[$row['forum_id']]['forum_name'], 'POST_ID' => $row['post_id'], 'POST_SUBJECT' => $row['post_subject'] ? $row['post_subject'] : $user->lang['NO_SUBJECT'], 'POST_TIME' => $user->format_date($row['post_time']), 'REPORT_ID' => $row['report_id'], 'REPORT_TIME' => $user->format_date($row['report_time']), 'TOPIC_TITLE' => $row['topic_title'], 'ATTACH_ICON_IMG' => $auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['post_attachment'] ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : ''));
                 }
                 $db->sql_freeresult($result);
                 unset($report_ids, $row);
             }
             $base_url = $this->u_action . "&amp;f={$forum_id}&amp;t={$topic_id}&amp;st={$sort_days}&amp;sk={$sort_key}&amp;sd={$sort_dir}";
             $pagination->generate_template_pagination($base_url, 'pagination', 'start', $total, $config['topics_per_page'], $start);
             // Now display the page
             $template->assign_vars(array('L_EXPLAIN' => $mode == 'reports' ? $user->lang['MCP_REPORTS_OPEN_EXPLAIN'] : $user->lang['MCP_REPORTS_CLOSED_EXPLAIN'], 'L_TITLE' => $mode == 'reports' ? $user->lang['MCP_REPORTS_OPEN'] : $user->lang['MCP_REPORTS_CLOSED'], 'L_ONLY_TOPIC' => $topic_id ? sprintf($user->lang['ONLY_TOPIC'], $topic_info['topic_title']) : '', 'S_MCP_ACTION' => $this->u_action, 'S_FORUM_OPTIONS' => $forum_options, 'S_CLOSED' => $mode == 'reports_closed' ? true : false, 'TOPIC_ID' => $topic_id, 'TOTAL' => $total, 'TOTAL_REPORTS' => $user->lang('LIST_REPORTS', (int) $total)));
             $this->tpl_name = 'mcp_reports';
             break;
     }
 }
Example #29
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) : ''));
  }
Example #30
0
    }
    login_box('', $user->lang['LOGIN_EXPLAIN_UCP']);
}
// Instantiate module system and generate list of available modules
$module->list_modules('ucp');
// Check if the zebra module is set
if ($module->is_active('zebra', 'friends')) {
    // Output listing of friends online
    $update_time = $config['load_online_time'] * 60;
    $sql = $db->sql_build_query('SELECT_DISTINCT', array('SELECT' => 'u.user_id, u.username, u.username_clean, u.user_colour, MAX(s.session_time) as online_time, MIN(s.session_viewonline) AS viewonline', 'FROM' => array(USERS_TABLE => 'u', ZEBRA_TABLE => 'z'), 'LEFT_JOIN' => array(array('FROM' => array(SESSIONS_TABLE => 's'), 'ON' => 's.session_user_id = z.zebra_id')), 'WHERE' => 'z.user_id = ' . $user->data['user_id'] . '
			AND z.friend = 1
			AND u.user_id = z.zebra_id', 'GROUP_BY' => 'z.zebra_id, u.user_id, u.username_clean, u.user_colour, u.username', 'ORDER_BY' => 'u.username_clean ASC'));
    $result = $db->sql_query($sql);
    while ($row = $db->sql_fetchrow($result)) {
        $which = time() - $update_time < $row['online_time'] && ($row['viewonline'] || $auth->acl_get('u_viewonline')) ? 'online' : 'offline';
        $template->assign_block_vars("friends_{$which}", array('USER_ID' => $row['user_id'], 'U_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), 'USER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'])));
    }
    $db->sql_freeresult($result);
}
// Do not display subscribed topics/forums if not allowed
if (!$config['allow_topic_notify'] && !$config['allow_forum_notify']) {
    $module->set_display('main', 'subscribed', false);
}
// Select the active module
$module->set_active($id, $mode);
// Load and execute the relevant module
$module->load_active();
// Assign data to the template engine for the list of modules
$module->assign_tpl_vars(append_sid("{$phpbb_root_path}ucp.{$phpEx}"));
// Generate the page, do not display/query online list
$module->display($module->get_page_title(), false);