Search found 78 matches: bbcode+custom+profile+field

Go to advanced search

Positioning in profile.

Hello, much as a user has posted below me, you can see here: http://forum.xboxnatter.com/memberlist. ... rofile&u=2, the "Latest Post:" is not in line with "Joined", "Last Visit", "Total posts:", etc.

I've been scouting around the "memberlist.php" file near where I added the 'latest post' code:

Code: Select all

// BEGIN latest_post_in_profile
      if(!function_exists('latest_post_in_profile'))
      {
         include($phpbb_root_path . 'includes/latest_post_in_profile.' . $phpEx);
      }
      latest_post_in_profile($user_id);
// END latest_post_in_profile


Unfortunately I cannot find where to edit to change this.
I would also like it to have a line between it like it has for *Date of my last post* and "Search user's posts". (So it is effectivley moving "Latest Post:" to the left, and down a space.

http://awesomescreenshot.com/0617kda6b (An image of my profile and the positioning of "Latest Post:")

My apologies for the now lengthy code box, this is my entire memberlist.php file. (You can easily find the latest post in profile by using the code to search for it).

Code: Select all

<?php
/**
*
* @package phpBB3
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup(array('memberlist', 'groups'));

// Grab data
$mode      = request_var('mode', '');
$action      = request_var('action', '');
$user_id   = request_var('u', ANONYMOUS);
$username   = request_var('un', '', true);
$group_id   = request_var('g', 0);
$topic_id   = request_var('t', 0);

// Check our mode...
if (!in_array($mode, array('', 'group', 'viewprofile', 'email', 'contact', 'searchuser', 'leaders')))
{
   trigger_error('NO_MODE');
}

switch ($mode)
{
   case 'email':
   break;

   default:
      // Can this user view profiles/memberlist?
      if (!$auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel'))
      {
         if ($user->data['user_id'] != ANONYMOUS)
         {
            trigger_error('NO_VIEW_USERS');
         }

         login_box('', ((isset($user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)])) ? $user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)] : $user->lang['LOGIN_EXPLAIN_MEMBERLIST']));
      }
   break;
}

$start   = request_var('start', 0);
$submit = (isset($_POST['submit'])) ? true : false;

$default_key = 'c';
$sort_key = request_var('sk', $default_key);
$sort_dir = request_var('sd', 'a');


// Grab rank information for later
$ranks = $cache->obtain_ranks();


// What do you want to do today? ... oops, I think that line is taken ...
switch ($mode)
{
   case 'leaders':
      // Display a listing of board admins, moderators
      include($phpbb_root_path . 'includes/functions_user.' . $phpEx);

      $page_title = $user->lang['THE_TEAM'];
      $template_html = 'memberlist_leaders.html';

      $user_ary = $auth->acl_get_list(false, array('a_', 'm_'), false);

      $admin_id_ary = $global_mod_id_ary = $mod_id_ary = $forum_id_ary = array();
      foreach ($user_ary as $forum_id => $forum_ary)
      {
         foreach ($forum_ary as $auth_option => $id_ary)
         {
            if (!$forum_id)
            {
               if ($auth_option == 'a_')
               {
                  $admin_id_ary = array_merge($admin_id_ary, $id_ary);
               }
               else
               {
                  $global_mod_id_ary = array_merge($global_mod_id_ary, $id_ary);
               }
               continue;
            }
            else
            {
               $mod_id_ary = array_merge($mod_id_ary, $id_ary);
            }

            if ($forum_id)
            {
               foreach ($id_ary as $id)
               {
                  $forum_id_ary[$id][] = $forum_id;
               }
            }
         }
      }

      $admin_id_ary = array_unique($admin_id_ary);
      $global_mod_id_ary = array_unique($global_mod_id_ary);

      $mod_id_ary = array_merge($mod_id_ary, $global_mod_id_ary);
      $mod_id_ary = array_unique($mod_id_ary);

      // Admin group id...
      $sql = 'SELECT group_id
         FROM ' . GROUPS_TABLE . "
         WHERE group_name = 'ADMINISTRATORS'";
      $result = $db->sql_query($sql);
      $admin_group_id = (int) $db->sql_fetchfield('group_id');
      $db->sql_freeresult($result);

      // Get group memberships for the admin id ary...
      $admin_memberships = group_memberships($admin_group_id, $admin_id_ary);

      $admin_user_ids = array();

      if (!empty($admin_memberships))
      {
         // ok, we only need the user ids...
         foreach ($admin_memberships as $row)
         {
            $admin_user_ids[$row['user_id']] = true;
         }
      }
      unset($admin_memberships);

      $sql = 'SELECT forum_id, forum_name
         FROM ' . FORUMS_TABLE;
      $result = $db->sql_query($sql);

      $forums = array();
      while ($row = $db->sql_fetchrow($result))
      {
         $forums[$row['forum_id']] = $row['forum_name'];
      }
      $db->sql_freeresult($result);

      $sql = $db->sql_build_query('SELECT', array(
         'SELECT'   => 'u.user_id, u.group_id as default_group, u.username, u.username_clean, u.user_colour, u.user_rank, u.user_posts, u.user_allow_pm, g.group_id, g.group_name, g.group_colour, g.group_type, ug.user_id as ug_user_id',

         'FROM'      => array(
            USERS_TABLE      => 'u',
            GROUPS_TABLE   => 'g'
         ),

         'LEFT_JOIN'   => array(
            array(
               'FROM'   => array(USER_GROUP_TABLE => 'ug'),
               'ON'   => 'ug.group_id = g.group_id AND ug.user_pending = 0 AND ug.user_id = ' . $user->data['user_id']
            )
         ),

         'WHERE'      => $db->sql_in_set('u.user_id', array_unique(array_merge($admin_id_ary, $mod_id_ary)), false, true) . '
            AND u.group_id = g.group_id',

         'ORDER_BY'   => 'g.group_name ASC, u.username_clean ASC'
      ));
      $result = $db->sql_query($sql);

      while ($row = $db->sql_fetchrow($result))
      {
         $which_row = (in_array($row['user_id'], $admin_id_ary)) ? 'admin' : 'mod';

         // We sort out admins not within the 'Administrators' group.
         // Else, we will list those as admin only having the permission to view logs for example.
         if ($which_row == 'admin' && empty($admin_user_ids[$row['user_id']]))
         {
            // Remove from admin_id_ary, because the user may be a mod instead
            unset($admin_id_ary[array_search($row['user_id'], $admin_id_ary)]);

            if (!in_array($row['user_id'], $mod_id_ary) && !in_array($row['user_id'], $global_mod_id_ary))
            {
               continue;
            }
            else
            {
               $which_row = 'mod';
            }
         }

         $s_forum_select = '';
         $undisclosed_forum = false;

         if (isset($forum_id_ary[$row['user_id']]) && !in_array($row['user_id'], $global_mod_id_ary))
         {
            if ($which_row == 'mod' && sizeof(array_diff(array_keys($forums), $forum_id_ary[$row['user_id']])))
            {
               foreach ($forum_id_ary[$row['user_id']] as $forum_id)
               {
                  if (isset($forums[$forum_id]))
                  {
                     if ($auth->acl_get('f_list', $forum_id))
                     {
                        $s_forum_select .= '<option value="">' . $forums[$forum_id] . '</option>';
                     }
                     else
                     {
                        $undisclosed_forum = true;
                     }
                  }
               }
            }
         }

         // If the mod is only moderating non-viewable forums we skip the user. There is no gain in displaying the person then...
         if (!$s_forum_select && $undisclosed_forum)
         {
//            $s_forum_select = '<option value="">' . $user->lang['FORUM_UNDISCLOSED'] . '</option>';
            continue;
         }

         // The person is moderating several "public" forums, therefore the person should be listed, but not giving the real group name if hidden.
         if ($row['group_type'] == GROUP_HIDDEN && !$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $row['ug_user_id'] != $user->data['user_id'])
         {
            $group_name = $user->lang['GROUP_UNDISCLOSED'];
            $u_group = '';
         }
         else
         {
            $group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];
            $u_group = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp;g=' . $row['group_id']);
         }

         $rank_title = $rank_img = '';
         get_user_rank($row['user_rank'], (($row['user_id'] == ANONYMOUS) ? false : $row['user_posts']), $rank_title, $rank_img, $rank_img_src);

         $template->assign_block_vars($which_row, array(
            'USER_ID'      => $row['user_id'],
            'FORUMS'      => $s_forum_select,
            'RANK_TITLE'   => $rank_title,
            'GROUP_NAME'   => $group_name,
            'GROUP_COLOR'   => $row['group_colour'],

            'RANK_IMG'      => $rank_img,
            'RANK_IMG_SRC'   => $rank_img_src,

            'U_GROUP'         => $u_group,
            'U_PM'            => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($row['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '',

            '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']),
         ));
      }
      $db->sql_freeresult($result);

      $template->assign_vars(array(
         'PM_IMG'      => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']))
      );
   break;

   case 'contact':

      $page_title = $user->lang['IM_USER'];
      $template_html = 'memberlist_im.html';

      if (!$auth->acl_get('u_sendim'))
      {
         trigger_error('NOT_AUTHORISED');
      }

      $presence_img = '';
      switch ($action)
      {
         case 'aim':
            $lang = 'AIM';
            $sql_field = 'user_aim';
            $s_select = 'S_SEND_AIM';
            $s_action = '';
         break;

         case 'msnm':
            $lang = 'MSNM';
            $sql_field = 'user_msnm';
            $s_select = 'S_SEND_MSNM';
            $s_action = '';
         break;

         case 'jabber':
            $lang = 'JABBER';
            $sql_field = 'user_jabber';
            $s_select = (@extension_loaded('xml') && $config['jab_enable']) ? 'S_SEND_JABBER' : 'S_NO_SEND_JABBER';
            $s_action = append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&amp;action=$action&amp;u=$user_id");
         break;

         default:
            trigger_error('NO_MODE', E_USER_ERROR);
         break;
      }

      // Grab relevant data
      $sql = "SELECT user_id, username, user_email, user_lang, $sql_field
         FROM " . USERS_TABLE . "
         WHERE user_id = $user_id
            AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
      $result = $db->sql_query($sql);
      $row = $db->sql_fetchrow($result);
      $db->sql_freeresult($result);

      if (!$row)
      {
         trigger_error('NO_USER');
      }
      else if (empty($row[$sql_field]))
      {
         trigger_error('IM_NO_DATA');
      }

      // Post data grab actions
      switch ($action)
      {
         case 'jabber':
            add_form_key('memberlist_messaging');

            if ($submit && @extension_loaded('xml') && $config['jab_enable'])
            {
               if (check_form_key('memberlist_messaging'))
               {

                  include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);

                  $subject = sprintf($user->lang['IM_JABBER_SUBJECT'], $user->data['username'], $config['server_name']);
                  $message = utf8_normalize_nfc(request_var('message', '', true));

                  if (empty($message))
                  {
                     trigger_error('EMPTY_MESSAGE_IM');
                  }

                  $messenger = new messenger(false);

                  $messenger->template('profile_send_im', $row['user_lang']);
                  $messenger->subject(htmlspecialchars_decode($subject));

                  $messenger->replyto($user->data['user_email']);
                  $messenger->im($row['user_jabber'], $row['username']);

                  $messenger->assign_vars(array(
                     'BOARD_CONTACT'   => $config['board_contact'],
                     'FROM_USERNAME'   => htmlspecialchars_decode($user->data['username']),
                     'TO_USERNAME'   => htmlspecialchars_decode($row['username']),
                     'MESSAGE'      => htmlspecialchars_decode($message))
                  );

                  $messenger->send(NOTIFY_IM);

                  $s_select = 'S_SENT_JABBER';
               }
               else
               {
                  trigger_error('FORM_INVALID');
               }
            }
         break;
      }

      // Send vars to the template
      $template->assign_vars(array(
         'IM_CONTACT'   => $row[$sql_field],
         'A_IM_CONTACT'   => addslashes($row[$sql_field]),

         'U_AIM_CONTACT'   => ($action == 'aim') ? 'aim:addbuddy?screenname=' . urlencode($row[$sql_field]) : '',
         'U_AIM_MESSAGE'   => ($action == 'aim') ? 'aim:goim?screenname=' . urlencode($row[$sql_field]) . '&amp;message=' . urlencode($config['sitename']) : '',

         'USERNAME'      => $row['username'],
         'CONTACT_NAME'   => $row[$sql_field],
         'SITENAME'      => $config['sitename'],

         'PRESENCE_IMG'      => $presence_img,

         'L_SEND_IM_EXPLAIN'   => $user->lang['IM_' . $lang],
         'L_IM_SENT_JABBER'   => sprintf($user->lang['IM_SENT_JABBER'], $row['username']),

         $s_select         => true,
         'S_IM_ACTION'      => $s_action)
      );

   break;

   case 'viewprofile':
      // Display a profile
      if ($user_id == ANONYMOUS && !$username)
      {
         trigger_error('NO_USER');
      }
      
      include($phpbb_root_path . 'includes/arcade/arcade_constants.' . $phpEx);
      include($phpbb_root_path . 'includes/arcade/arcade_cache.' . $phpEx);
      include($phpbb_root_path . 'includes/arcade/functions_arcade.' . $phpEx);
      $user->add_lang('mods/arcade');

      // Get user...
      $sql = 'SELECT *
         FROM ' . USERS_TABLE . '
         WHERE ' . (($username) ? "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'" : "user_id = $user_id");
      $result = $db->sql_query($sql);
      $member = $db->sql_fetchrow($result);
      $db->sql_freeresult($result);

      if (!$member)
      {
         trigger_error('NO_USER');
      }

      // a_user admins and founder are able to view inactive users and bots to be able to manage them more easily
      // Normal users are able to see at least users having only changed their profile settings but not yet reactivated.
      if (!$auth->acl_get('a_user') && $user->data['user_type'] != USER_FOUNDER)
      {
         if ($member['user_type'] == USER_IGNORE)
         {
            trigger_error('NO_USER');
         }
         else if ($member['user_type'] == USER_INACTIVE && $member['user_inactive_reason'] != INACTIVE_PROFILE)
         {
            trigger_error('NO_USER');
         }
      }

      $user_id = (int) $member['user_id'];
      // BEGIN latest_post_in_profile
                        if(!function_exists('latest_post_in_profile'))
                        {
                                include($phpbb_root_path . 'includes/latest_post_in_profile.' . $phpEx);
                        }
                        latest_post_in_profile($user_id);
        // END latest_post_in_profile

      // Get group memberships
      // Also get visiting user's groups to determine hidden group memberships if necessary.
      $auth_hidden_groups = ($user_id === (int) $user->data['user_id'] || $auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) ? true : false;
      $sql_uid_ary = ($auth_hidden_groups) ? array($user_id) : array($user_id, (int) $user->data['user_id']);

      // Do the SQL thang
      $sql = 'SELECT g.group_id, g.group_name, g.group_type, ug.user_id
         FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . ' ug
         WHERE ' . $db->sql_in_set('ug.user_id', $sql_uid_ary) . '
            AND g.group_id = ug.group_id
            AND ug.user_pending = 0';
      $result = $db->sql_query($sql);

      // Divide data into profile data and current user data
      $profile_groups = $user_groups = array();
      while ($row = $db->sql_fetchrow($result))
      {
         $row['user_id'] = (int) $row['user_id'];
         $row['group_id'] = (int) $row['group_id'];

         if ($row['user_id'] == $user_id)
         {
            $profile_groups[] = $row;
         }
         else
         {
            $user_groups[$row['group_id']] = $row['group_id'];
         }
      }
      $db->sql_freeresult($result);

      // Filter out hidden groups and sort groups by name
      $group_data = $group_sort = array();
      foreach ($profile_groups as $row)
      {
         if ($row['group_type'] == GROUP_SPECIAL)
         {
            // Lookup group name in language dictionary
            if (isset($user->lang['G_' . $row['group_name']]))
            {
               $row['group_name'] = $user->lang['G_' . $row['group_name']];
            }
         }
         else if (!$auth_hidden_groups && $row['group_type'] == GROUP_HIDDEN && !isset($user_groups[$row['group_id']]))
         {
            // Skip over hidden groups the user cannot see
            continue;
         }

         $group_sort[$row['group_id']] = utf8_clean_string($row['group_name']);
         $group_data[$row['group_id']] = $row;
      }
      unset($profile_groups);
      unset($user_groups);
      asort($group_sort);

      $group_options = '';
      foreach ($group_sort as $group_id => $null)
      {
         $row = $group_data[$group_id];

         $group_options .= '<option value="' . $row['group_id'] . '"' . (($row['group_id'] == $member['group_id']) ? ' selected="selected"' : '') . '>' . $row['group_name'] . '</option>';
      }
      unset($group_data);
      unset($group_sort);

      // What colour is the zebra
      $sql = 'SELECT friend, foe
         FROM ' . ZEBRA_TABLE . "
         WHERE zebra_id = $user_id
            AND user_id = {$user->data['user_id']}";

      $result = $db->sql_query($sql);
      $row = $db->sql_fetchrow($result);
      $foe = ($row['foe']) ? true : false;
      $friend = ($row['friend']) ? true : false;
      $db->sql_freeresult($result);

      if ($config['load_onlinetrack'])
      {
         $sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline
            FROM ' . SESSIONS_TABLE . "
            WHERE session_user_id = $user_id";
         $result = $db->sql_query($sql);
         $row = $db->sql_fetchrow($result);
         $db->sql_freeresult($result);

         $member['session_time'] = (isset($row['session_time'])) ? $row['session_time'] : 0;
         $member['session_viewonline'] = (isset($row['session_viewonline'])) ? $row['session_viewonline'] :   0;
         unset($row);
      }

      if ($config['load_user_activity'])
      {
         display_user_activity($member);
      }

      // Do the relevant calculations
      $memberdays = max(1, round((time() - $member['user_regdate']) / 86400));
      $posts_per_day = $member['user_posts'] / $memberdays;
      $percentage = ($config['num_posts']) ? min(100, ($member['user_posts'] / $config['num_posts']) * 100) : 0;


      if ($member['user_sig'])
      {
         $member['user_sig'] = censor_text($member['user_sig']);

         if ($member['user_sig_bbcode_bitfield'])
         {
            include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
            $bbcode = new bbcode();
            $bbcode->bbcode_second_pass($member['user_sig'], $member['user_sig_bbcode_uid'], $member['user_sig_bbcode_bitfield']);
         }

         $member['user_sig'] = bbcode_nl2br($member['user_sig']);
         $member['user_sig'] = smiley_text($member['user_sig']);
      }

      $poster_avatar = get_user_avatar($member['user_avatar'], $member['user_avatar_type'], $member['user_avatar_width'], $member['user_avatar_height']);

      // We need to check if the modules 'zebra' ('friends' & 'foes' mode),  'notes' ('user_notes' mode) and  'warn' ('warn_user' mode) are accessible to decide if we can display appropriate links
      $zebra_enabled = $friends_enabled = $foes_enabled = $user_notes_enabled = $warn_user_enabled = false;

      // Only check if the user is logged in
      if ($user->data['is_registered'])
      {
         if (!class_exists('p_master'))
         {
            include($phpbb_root_path . 'includes/functions_module.' . $phpEx);
         }
         $module = new p_master();

         $module->list_modules('ucp');
         $module->list_modules('mcp');

         $user_notes_enabled = ($module->loaded('notes', 'user_notes')) ? true : false;
         $warn_user_enabled = ($module->loaded('warn', 'warn_user')) ? true : false;
         $zebra_enabled = ($module->loaded('zebra')) ? true : false;
         $friends_enabled = ($module->loaded('zebra', 'friends')) ? true : false;
         $foes_enabled = ($module->loaded('zebra', 'foes')) ? true : false;

         unset($module);
      }
      
      // phpBB Gallery integration
      if (!function_exists('integrate_memberlist_viewprofile'))
      {
         $gallery_root_path = GALLERY_ROOT_PATH;
         include($phpbb_root_path . $gallery_root_path . 'includes/phpbb_integration.' . $phpEx);
      }
      integrate_memberlist_viewprofile($member);
      
      // [+] Karma MOD
      $karmamod->memberlist_viewprofile($member, $foe, $friend);
      // [-] Karma MOD

      $template->assign_vars(show_profile($member, $user_notes_enabled, $warn_user_enabled));

      // Custom Profile Fields
      $profile_fields = array();
      if ($config['load_cpf_viewprofile'])
      {
         include_once($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
         $cp = new custom_profile();
         $profile_fields = $cp->generate_profile_fields_template('grab', $user_id);
         $profile_fields = (isset($profile_fields[$user_id])) ? $cp->generate_profile_fields_template('show', false, $profile_fields[$user_id]) : array();
      }

      // If the user has m_approve permission or a_user permission, then list then display unapproved posts
      if ($auth->acl_getf_global('m_approve') || $auth->acl_get('a_user'))
      {
         $sql = 'SELECT COUNT(post_id) as posts_in_queue
            FROM ' . POSTS_TABLE . '
            WHERE poster_id = ' . $user_id . '
               AND post_approved = 0';
         $result = $db->sql_query($sql);
         $member['posts_in_queue'] = (int) $db->sql_fetchfield('posts_in_queue');
         $db->sql_freeresult($result);
      }
      else
      {
         $member['posts_in_queue'] = 0;
      }

      $template->assign_vars(array(
         'L_POSTS_IN_QUEUE'   => $user->lang('NUM_POSTS_IN_QUEUE', $member['posts_in_queue']),

         'POSTS_DAY'         => sprintf($user->lang['POST_DAY'], $posts_per_day),
         'POSTS_PCT'         => sprintf($user->lang['POST_PCT'], $percentage),

         'OCCUPATION'   => (!empty($member['user_occ'])) ? censor_text($member['user_occ']) : '',
         'INTERESTS'      => (!empty($member['user_interests'])) ? censor_text($member['user_interests']) : '',
         'SIGNATURE'      => $member['user_sig'],
         'POSTS_IN_QUEUE'=> $member['posts_in_queue'],

         'AVATAR_IMG'   => $poster_avatar,
         'PM_IMG'      => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']),
         'EMAIL_IMG'      => $user->img('icon_contact_email', $user->lang['EMAIL']),
         'WWW_IMG'      => $user->img('icon_contact_www', $user->lang['WWW']),
         'ICQ_IMG'      => $user->img('icon_contact_icq', $user->lang['ICQ']),
         'AIM_IMG'      => $user->img('icon_contact_aim', $user->lang['AIM']),
         'MSN_IMG'      => $user->img('icon_contact_msnm', $user->lang['MSNM']),
         'YIM_IMG'      => $user->img('icon_contact_yahoo', $user->lang['YIM']),
         'JABBER_IMG'   => $user->img('icon_contact_jabber', $user->lang['JABBER']),
         'SEARCH_IMG'   => $user->img('icon_user_search', $user->lang['SEARCH']),

         'S_PROFILE_ACTION'   => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group'),
         'S_GROUP_OPTIONS'   => $group_options,
         'S_CUSTOM_FIELDS'   => (isset($profile_fields['row']) && sizeof($profile_fields['row'])) ? true : false,

         'U_USER_ADMIN'         => ($auth->acl_get('a_user')) ? append_sid("{$phpbb_root_path}adm/index.$phpEx", 'i=users&amp;mode=overview&amp;u=' . $user_id, true, $user->session_id) : '',
         'U_USER_BAN'         => ($auth->acl_get('m_ban') && $user_id != $user->data['user_id']) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=ban&amp;mode=user&amp;u=' . $user_id, true, $user->session_id) : '',
         'U_MCP_QUEUE'         => ($auth->acl_getf_global('m_approve')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue', true, $user->session_id) : '',

         'U_SWITCH_PERMISSIONS'   => ($auth->acl_get('a_switchperm') && $user->data['user_id'] != $user_id) ? append_sid("{$phpbb_root_path}ucp.$phpEx", "mode=switch_perm&amp;u={$user_id}&amp;hash=" . generate_link_hash('switchperm')) : '',

         'S_USER_NOTES'      => ($user_notes_enabled) ? true : false,
         'S_WARN_USER'      => ($warn_user_enabled) ? true : false,
         'S_ZEBRA'         => ($user->data['user_id'] != $user_id && $user->data['is_registered'] && $zebra_enabled) ? true : false,
         'U_ADD_FRIEND'      => (!$friend && !$foe && $friends_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&amp;add=' . urlencode(htmlspecialchars_decode($member['username']))) : '',
         'U_ADD_FOE'         => (!$friend && !$foe && $foes_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&amp;mode=foes&amp;add=' . urlencode(htmlspecialchars_decode($member['username']))) : '',
         'U_REMOVE_FRIEND'   => ($friend && $friends_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&amp;remove=1&amp;usernames[]=' . $user_id) : '',
         'U_REMOVE_FOE'      => ($foe && $foes_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&amp;remove=1&amp;mode=foes&amp;usernames[]=' . $user_id) : '',
      ));
      
      $arcade_data = display_arcade_highscores($user_id, basename(__FILE__, '.' . $phpEx));
      if (sizeof($arcade_data))
      {
         $template->assign_vars($arcade_data);
      }

      if (!empty($profile_fields['row']))
      {
         $template->assign_vars($profile_fields['row']);
      }

      if (!empty($profile_fields['blockrow']))
      {
         foreach ($profile_fields['blockrow'] as $field_data)
         {
            $template->assign_block_vars('custom_fields', $field_data);
         }
      }

      // Inactive reason/account?
      if ($member['user_type'] == USER_INACTIVE)
      {
         $user->add_lang('acp/common');

         $inactive_reason = $user->lang['INACTIVE_REASON_UNKNOWN'];

         switch ($member['user_inactive_reason'])
         {
            case INACTIVE_REGISTER:
               $inactive_reason = $user->lang['INACTIVE_REASON_REGISTER'];
            break;

            case INACTIVE_PROFILE:
               $inactive_reason = $user->lang['INACTIVE_REASON_PROFILE'];
            break;

            case INACTIVE_MANUAL:
               $inactive_reason = $user->lang['INACTIVE_REASON_MANUAL'];
            break;

            case INACTIVE_REMIND:
               $inactive_reason = $user->lang['INACTIVE_REASON_REMIND'];
            break;
         }

         $template->assign_vars(array(
            'S_USER_INACTIVE'      => true,
            'USER_INACTIVE_REASON'   => $inactive_reason)
         );
      }

      // Now generate page title
      $page_title = sprintf($user->lang['VIEWING_PROFILE'], $member['username']);
      $template_html = 'memberlist_view.html';

   break;

   case 'email':

      // Send an email
      $page_title = $user->lang['SEND_EMAIL'];
      $template_html = 'memberlist_email.html';

      add_form_key('memberlist_email');

      if (!$config['email_enable'])
      {
         trigger_error('EMAIL_DISABLED');
      }

      if (!$auth->acl_get('u_sendemail'))
      {
         trigger_error('NO_EMAIL');
      }

      // Are we trying to abuse the facility?
      if (time() - $user->data['user_emailtime'] < $config['flood_interval'])
      {
         trigger_error('FLOOD_EMAIL_LIMIT');
      }

      // Determine action...
      $user_id = request_var('u', 0);
      $topic_id = request_var('t', 0);

      // Send email to user...
      if ($user_id)
      {
         if ($user_id == ANONYMOUS || !$config['board_email_form'])
         {
            trigger_error('NO_EMAIL');
         }

         // Get the appropriate username, etc.
         $sql = 'SELECT username, user_email, user_allow_viewemail, user_lang, user_jabber, user_notify_type
            FROM ' . USERS_TABLE . "
            WHERE user_id = $user_id
               AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
         $result = $db->sql_query($sql);
         $row = $db->sql_fetchrow($result);
         $db->sql_freeresult($result);

         if (!$row)
         {
            trigger_error('NO_USER');
         }

         // Can we send email to this user?
         if (!$row['user_allow_viewemail'] && !$auth->acl_get('a_user'))
         {
            trigger_error('NO_EMAIL');
         }
      }
      else if ($topic_id)
      {
         // Send topic heads-up to email address
         $sql = 'SELECT forum_id, topic_title
            FROM ' . TOPICS_TABLE . "
            WHERE topic_id = $topic_id";
         $result = $db->sql_query($sql);
         $row = $db->sql_fetchrow($result);
         $db->sql_freeresult($result);

         if (!$row)
         {
            trigger_error('NO_TOPIC');
         }

         if ($row['forum_id'])
         {
            if (!$auth->acl_get('f_read', $row['forum_id']))
            {
               trigger_error('SORRY_AUTH_READ');
            }

            if (!$auth->acl_get('f_email', $row['forum_id']))
            {
               trigger_error('NO_EMAIL');
            }
         }
         else
         {
            // If global announcement, we need to check if the user is able to at least read and email in one forum...
            if (!$auth->acl_getf_global('f_read'))
            {
               trigger_error('SORRY_AUTH_READ');
            }

            if (!$auth->acl_getf_global('f_email'))
            {
               trigger_error('NO_EMAIL');
            }
         }
      }
      else
      {
         trigger_error('NO_EMAIL');
      }

      $error = array();

      $name      = utf8_normalize_nfc(request_var('name', '', true));
      $email      = request_var('email', '');
      $email_lang = request_var('lang', $config['default_lang']);
      $subject   = utf8_normalize_nfc(request_var('subject', '', true));
      $message   = utf8_normalize_nfc(request_var('message', '', true));
      $cc         = (isset($_POST['cc_email'])) ? true : false;
      $submit      = (isset($_POST['submit'])) ? true : false;

      if ($submit)
      {
         if (!check_form_key('memberlist_email'))
         {
            $error[] = 'FORM_INVALID';
         }
         if ($user_id)
         {
            if (!$subject)
            {
               $error[] = $user->lang['EMPTY_SUBJECT_EMAIL'];
            }

            if (!$message)
            {
               $error[] = $user->lang['EMPTY_MESSAGE_EMAIL'];
            }

            $name = $row['username'];
            $email_lang = $row['user_lang'];
            $email = $row['user_email'];
         }
         else
         {
            if (!$email || !preg_match('/^' . get_preg_expression('email') . '$/i', $email))
            {
               $error[] = $user->lang['EMPTY_ADDRESS_EMAIL'];
            }

            if (!$name)
            {
               $error[] = $user->lang['EMPTY_NAME_EMAIL'];
            }
         }

         if (!sizeof($error))
         {
            $sql = 'UPDATE ' . USERS_TABLE . '
               SET user_emailtime = ' . time() . '
               WHERE user_id = ' . $user->data['user_id'];
            $result = $db->sql_query($sql);

            include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
            $messenger = new messenger(false);
            $email_tpl = ($user_id) ? 'profile_send_email' : 'email_notify';

            $mail_to_users = array();

            $mail_to_users[] = array(
               'email_lang'      => $email_lang,
               'email'            => $email,
               'name'            => $name,
               'username'         => ($user_id) ? $row['username'] : '',
               'to_name'         => $name,
               'user_jabber'      => ($user_id) ? $row['user_jabber'] : '',
               'user_notify_type'   => ($user_id) ? $row['user_notify_type'] : NOTIFY_EMAIL,
               'topic_title'      => (!$user_id) ? $row['topic_title'] : '',
               'forum_id'         => (!$user_id) ? $row['forum_id'] : 0,
            );

            // Ok, now the same email if CC specified, but without exposing the users email address
            if ($cc)
            {
               $mail_to_users[] = array(
                  'email_lang'      => $user->data['user_lang'],
                  'email'            => $user->data['user_email'],
                  'name'            => $user->data['username'],
                  'username'         => $user->data['username'],
                  'to_name'         => $name,
                  'user_jabber'      => $user->data['user_jabber'],
                  'user_notify_type'   => ($user_id) ? $user->data['user_notify_type'] : NOTIFY_EMAIL,
                  'topic_title'      => (!$user_id) ? $row['topic_title'] : '',
                  'forum_id'         => (!$user_id) ? $row['forum_id'] : 0,
               );
            }

            foreach ($mail_to_users as $row)
            {
               $messenger->template($email_tpl, $row['email_lang']);
               $messenger->replyto($user->data['user_email']);
               $messenger->to($row['email'], $row['name']);

               if ($user_id)
               {
                  $messenger->subject(htmlspecialchars_decode($subject));
                  $messenger->im($row['user_jabber'], $row['username']);
                  $notify_type = $row['user_notify_type'];
               }
               else
               {
                  $notify_type = NOTIFY_EMAIL;
               }

               $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
               $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
               $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
               $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);

               $messenger->assign_vars(array(
                  'BOARD_CONTACT'   => $config['board_contact'],
                  'TO_USERNAME'   => htmlspecialchars_decode($row['to_name']),
                  'FROM_USERNAME'   => htmlspecialchars_decode($user->data['username']),
                  'MESSAGE'      => htmlspecialchars_decode($message))
               );

               if ($topic_id)
               {
                  $messenger->assign_vars(array(
                     'TOPIC_NAME'   => htmlspecialchars_decode($row['topic_title']),
                     'U_TOPIC'      => generate_board_url() . "/viewtopic.$phpEx?f=" . $row['forum_id'] . "&t=$topic_id")
                  );
               }

               $messenger->send($notify_type);
            }

            meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
            $message = ($user_id) ? sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>') : sprintf($user->lang['RETURN_TOPIC'],  '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$row['forum_id']}&amp;t=$topic_id") . '">', '</a>');
            trigger_error($user->lang['EMAIL_SENT'] . '<br /><br />' . $message);
         }
      }

      if ($user_id)
      {
         $template->assign_vars(array(
            'S_SEND_USER'   => true,
            'USERNAME'      => $row['username'],

            'L_EMAIL_BODY_EXPLAIN'   => $user->lang['EMAIL_BODY_EXPLAIN'],
            'S_POST_ACTION'         => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=email&amp;u=' . $user_id))
         );
      }
      else
      {
         $template->assign_vars(array(
            'EMAIL'            => $email,
            'NAME'            => $name,
            'S_LANG_OPTIONS'   => language_select($email_lang),

            'L_EMAIL_BODY_EXPLAIN'   => $user->lang['EMAIL_TOPIC_EXPLAIN'],
            'S_POST_ACTION'         => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=email&amp;t=' . $topic_id))
         );
      }

      $template->assign_vars(array(
         'ERROR_MESSAGE'      => (sizeof($error)) ? implode('<br />', $error) : '',
         'SUBJECT'         => $subject,
         'MESSAGE'         => $message,
         )
      );

   break;

   case 'group':
   default:
      // The basic memberlist
      $page_title = $user->lang['MEMBERLIST'];
      $template_html = 'memberlist_body.html';

      // Sorting
      $sort_key_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_LOCATION'], 'c' => $user->lang['SORT_JOINED'], 'd' => $user->lang['SORT_POST_COUNT'], 'f' => $user->lang['WEBSITE'], 'g' => $user->lang['ICQ'], 'h' => $user->lang['AIM'], 'i' => $user->lang['MSNM'], 'j' => $user->lang['YIM'], 'k' => $user->lang['JABBER']);
      $sort_key_sql = array('a' => 'u.username_clean', 'b' => 'u.user_from', 'c' => 'u.user_regdate', 'd' => 'u.user_posts', 'f' => 'u.user_website', 'g' => 'u.user_icq', 'h' => 'u.user_aim', 'i' => 'u.user_msnm', 'j' => 'u.user_yim', 'k' => 'u.user_jabber');

      if ($auth->acl_get('a_user'))
      {
         $sort_key_text['e'] = $user->lang['SORT_EMAIL'];
         $sort_key_sql['e'] = 'u.user_email';
      }

      if ($auth->acl_get('u_viewonline'))
      {
         $sort_key_text['l'] = $user->lang['SORT_LAST_ACTIVE'];
         $sort_key_sql['l'] = 'u.user_lastvisit';
      }

      $sort_key_text['m'] = $user->lang['SORT_RANK'];
      $sort_key_sql['m'] = 'u.user_rank';

      $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']);

      $s_sort_key = '';
      foreach ($sort_key_text as $key => $value)
      {
         $selected = ($sort_key == $key) ? ' selected="selected"' : '';
         $s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
      }

      $s_sort_dir = '';
      foreach ($sort_dir_text as $key => $value)
      {
         $selected = ($sort_dir == $key) ? ' selected="selected"' : '';
         $s_sort_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
      }

      // Additional sorting options for user search ... if search is enabled, if not
      // then only admins can make use of this (for ACP functionality)
      $sql_select = $sql_where_data = $sql_from = $sql_where = $order_by = '';


      $form         = request_var('form', '');
      $field         = request_var('field', '');
      $select_single    = request_var('select_single', false);

      // Search URL parameters, if any of these are in the URL we do a search
      $search_params = array('username', 'email', 'icq', 'aim', 'yahoo', 'msn', 'jabber', 'search_group_id', 'joined_select', 'active_select', 'count_select', 'joined', 'active', 'count', 'ip');

      // We validate form and field here, only id/class allowed
      $form = (!preg_match('/^[a-z0-9_-]+$/i', $form)) ? '' : $form;
      $field = (!preg_match('/^[a-z0-9_-]+$/i', $field)) ? '' : $field;
      if (($mode == 'searchuser' || sizeof(array_intersect(array_keys($_GET), $search_params)) > 0) && ($config['load_search'] || $auth->acl_get('a_')))
      {
         $username   = request_var('username', '', true);
         $email      = strtolower(request_var('email', ''));
         $icq      = request_var('icq', '');
         $aim      = request_var('aim', '');
         $yahoo      = request_var('yahoo', '');
         $msn      = request_var('msn', '');
         $jabber      = request_var('jabber', '');
         $search_group_id   = request_var('search_group_id', 0);

         // when using these, make sure that we actually have values defined in $find_key_match
         $joined_select   = request_var('joined_select', 'lt');
         $active_select   = request_var('active_select', 'lt');
         $count_select   = request_var('count_select', 'eq');

         $joined         = explode('-', request_var('joined', ''));
         $active         = explode('-', request_var('active', ''));
         $count         = (request_var('count', '') !== '') ? request_var('count', 0) : '';
         $ipdomain      = request_var('ip', '');

         $find_key_match = array('lt' => '<', 'gt' => '>', 'eq' => '=');

         $find_count = array('lt' => $user->lang['LESS_THAN'], 'eq' => $user->lang['EQUAL_TO'], 'gt' => $user->lang['MORE_THAN']);
         $s_find_count = '';
         foreach ($find_count as $key => $value)
         {
            $selected = ($count_select == $key) ? ' selected="selected"' : '';
            $s_find_count .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
         }

         $find_time = array('lt' => $user->lang['BEFORE'], 'gt' => $user->lang['AFTER']);
         $s_find_join_time = '';
         foreach ($find_time as $key => $value)
         {
            $selected = ($joined_select == $key) ? ' selected="selected"' : '';
            $s_find_join_time .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
         }

         $s_find_active_time = '';
         foreach ($find_time as $key => $value)
         {
            $selected = ($active_select == $key) ? ' selected="selected"' : '';
            $s_find_active_time .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
         }

         $sql_where .= ($username) ? ' AND u.username_clean ' . $db->sql_like_expression(str_replace('*', $db->any_char, utf8_clean_string($username))) : '';
         $sql_where .= ($auth->acl_get('a_user') && $email) ? ' AND u.user_email ' . $db->sql_like_expression(str_replace('*', $db->any_char, $email)) . ' ' : '';
         $sql_where .= ($icq) ? ' AND u.user_icq ' . $db->sql_like_expression(str_replace('*', $db->any_char, $icq)) . ' ' : '';
         $sql_where .= ($aim) ? ' AND u.user_aim ' . $db->sql_like_expression(str_replace('*', $db->any_char, $aim)) . ' ' : '';
         $sql_where .= ($yahoo) ? ' AND u.user_yim ' . $db->sql_like_expression(str_replace('*', $db->any_char, $yahoo)) . ' ' : '';
         $sql_where .= ($msn) ? ' AND u.user_msnm ' . $db->sql_like_expression(str_replace('*', $db->any_char, $msn)) . ' ' : '';
         $sql_where .= ($jabber) ? ' AND u.user_jabber ' . $db->sql_like_expression(str_replace('*', $db->any_char, $jabber)) . ' ' : '';
         $sql_where .= (is_numeric($count) && isset($find_key_match[$count_select])) ? ' AND u.user_posts ' . $find_key_match[$count_select] . ' ' . (int) $count . ' ' : '';
         $sql_where .= (sizeof($joined) > 1 && isset($find_key_match[$joined_select])) ? " AND u.user_regdate " . $find_key_match[$joined_select] . ' ' . gmmktime(0, 0, 0, intval($joined[1]), intval($joined[2]), intval($joined[0])) : '';
         $sql_where .= ($auth->acl_get('u_viewonline') && sizeof($active) > 1 && isset($find_key_match[$active_select])) ? " AND u.user_lastvisit " . $find_key_match[$active_select] . ' ' . gmmktime(0, 0, 0, $active[1], intval($active[2]), intval($active[0])) : '';
         $sql_where .= ($search_group_id) ? " AND u.user_id = ug.user_id AND ug.group_id = $search_group_id AND ug.user_pending = 0 " : '';

         if ($search_group_id)
         {
            $sql_from = ', ' . USER_GROUP_TABLE . ' ug ';
         }

         if ($ipdomain && $auth->acl_getf_global('m_info'))
         {
            if (strspn($ipdomain, 'abcdefghijklmnopqrstuvwxyz'))
            {
               $hostnames = gethostbynamel($ipdomain);

               if ($hostnames !== false)
               {
                  $ips = "'" . implode('\', \'', array_map(array($db, 'sql_escape'), preg_replace('#([0-9]{1,3}\.[0-9]{1,3}[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})#', "\\1", gethostbynamel($ipdomain)))) . "'";
               }
               else
               {
                  $ips = false;
               }
            }
            else
            {
               $ips = "'" . str_replace('*', '%', $db->sql_escape($ipdomain)) . "'";
            }

            if ($ips === false)
            {
               // A minor fudge but it does the job :D
               $sql_where .= " AND u.user_id = 0";
            }
            else
            {
               $ip_forums = array_keys($auth->acl_getf('m_info', true));

               $sql = 'SELECT DISTINCT poster_id
                  FROM ' . POSTS_TABLE . '
                  WHERE poster_ip ' . ((strpos($ips, '%') !== false) ? 'LIKE' : 'IN') . " ($ips)
                     AND forum_id IN (0, " . implode(', ', $ip_forums) . ')';
               $result = $db->sql_query($sql);

               if ($row = $db->sql_fetchrow($result))
               {
                  $ip_sql = array();
                  do
                  {
                     $ip_sql[] = $row['poster_id'];
                  }
                  while ($row = $db->sql_fetchrow($result));

                  $sql_where .= ' AND ' . $db->sql_in_set('u.user_id', $ip_sql);
               }
               else
               {
                  // A minor fudge but it does the job :D
                  $sql_where .= " AND u.user_id = 0";
               }
               unset($ip_forums);

               $db->sql_freeresult($result);
            }
         }
      }

      $first_char = request_var('first_char', '');

      if ($first_char == 'other')
      {
         for ($i = 97; $i < 123; $i++)
         {
            $sql_where .= ' AND u.username_clean NOT ' . $db->sql_like_expression(chr($i) . $db->any_char);
         }
      }
      else if ($first_char)
      {
         $sql_where .= ' AND u.username_clean ' . $db->sql_like_expression(substr($first_char, 0, 1) . $db->any_char);
      }

      // Are we looking at a usergroup? If so, fetch additional info
      // and further restrict the user info query
      if ($mode == 'group')
      {
         // We JOIN here to save a query for determining membership for hidden groups. ;)
         $sql = 'SELECT g.*, ug.user_id
            FROM ' . GROUPS_TABLE . ' g
            LEFT JOIN ' . USER_GROUP_TABLE . ' ug ON (ug.user_pending = 0 AND ug.user_id = ' . $user->data['user_id'] . " AND ug.group_id = $group_id)
            WHERE g.group_id = $group_id";
         $result = $db->sql_query($sql);
         $group_row = $db->sql_fetchrow($result);
         $db->sql_freeresult($result);

         if (!$group_row)
         {
            trigger_error('NO_GROUP');
         }

         switch ($group_row['group_type'])
         {
            case GROUP_OPEN:
               $group_row['l_group_type'] = 'OPEN';
            break;

            case GROUP_CLOSED:
               $group_row['l_group_type'] = 'CLOSED';
            break;

            case GROUP_HIDDEN:
               $group_row['l_group_type'] = 'HIDDEN';

               // Check for membership or special permissions
               if (!$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $group_row['user_id'] != $user->data['user_id'])
               {
                  trigger_error('NO_GROUP');
               }
            break;

            case GROUP_SPECIAL:
               $group_row['l_group_type'] = 'SPECIAL';
            break;

            case GROUP_FREE:
               $group_row['l_group_type'] = 'FREE';
            break;
         }

         // Misusing the avatar function for displaying group avatars...
         $avatar_img = get_user_avatar($group_row['group_avatar'], $group_row['group_avatar_type'], $group_row['group_avatar_width'], $group_row['group_avatar_height'], 'GROUP_AVATAR');

         $rank_title = $rank_img = $rank_img_src = '';
         if ($group_row['group_rank'])
         {
            if (isset($ranks['special'][$group_row['group_rank']]))
            {
               $rank_title = $ranks['special'][$group_row['group_rank']]['rank_title'];
            }
            $rank_img = (!empty($ranks['special'][$group_row['group_rank']]['rank_image'])) ? '<img src="' . $config['ranks_path'] . '/' . $ranks['special'][$group_row['group_rank']]['rank_image'] . '" alt="' . $ranks['special'][$group_row['group_rank']]['rank_title'] . '" title="' . $ranks['special'][$group_row['group_rank']]['rank_title'] . '" /><br />' : '';
            $rank_img_src = (!empty($ranks['special'][$group_row['group_rank']]['rank_image'])) ? $config['ranks_path'] . '/' . $ranks['special'][$group_row['group_rank']]['rank_image'] : '';
         }
         else
         {
            $rank_title = '';
            $rank_img = '';
            $rank_img_src = '';
         }

         $template->assign_vars(array(
            'GROUP_DESC'   => generate_text_for_display($group_row['group_desc'], $group_row['group_desc_uid'], $group_row['group_desc_bitfield'], $group_row['group_desc_options']),
            'GROUP_NAME'   => ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'],
            'GROUP_COLOR'   => $group_row['group_colour'],
            'GROUP_TYPE'   => $user->lang['GROUP_IS_' . $group_row['l_group_type']],
            'GROUP_RANK'   => $rank_title,

            'AVATAR_IMG'   => $avatar_img,
            'RANK_IMG'      => $rank_img,
            'RANK_IMG_SRC'   => $rank_img_src,

            'U_PM'         => ($auth->acl_get('u_sendpm') && $auth->acl_get('u_masspm_group') && $group_row['group_receive_pm'] && $config['allow_privmsg'] && $config['allow_mass_pm']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;mode=compose&amp;g=' . $group_id) : '',)
         );

         $sql_select = ', ug.group_leader';
         $sql_from = ', ' . USER_GROUP_TABLE . ' ug ';
         $order_by = 'ug.group_leader DESC, ';

         $sql_where .= " AND ug.user_pending = 0 AND u.user_id = ug.user_id AND ug.group_id = $group_id";
         $sql_where_data = " AND u.user_id = ug.user_id AND ug.group_id = $group_id";
      }

      // Sorting and order
      if (!isset($sort_key_sql[$sort_key]))
      {
         $sort_key = $default_key;
      }

      $order_by .= $sort_key_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC');

      // Unfortunately we must do this here for sorting by rank, else the sort order is applied wrongly
      if ($sort_key == 'm')
      {
         $order_by .= ', u.user_posts DESC';
      }

      // Count the users ...
      if ($sql_where)
      {
         $sql = 'SELECT COUNT(u.user_id) AS total_users
            FROM ' . USERS_TABLE . " u$sql_from
            WHERE u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ")
            $sql_where";
         $result = $db->sql_query($sql);
         $total_users = (int) $db->sql_fetchfield('total_users');
         $db->sql_freeresult($result);
      }
      else
      {
         $total_users = $config['num_users'];
      }

      $s_char_options = '<option value=""' . ((!$first_char) ? ' selected="selected"' : '') . '>&nbsp; &nbsp;</option>';
      for ($i = 97; $i < 123; $i++)
      {
         $s_char_options .= '<option value="' . chr($i) . '"' . (($first_char == chr($i)) ? ' selected="selected"' : '') . '>' . chr($i-32) . '</option>';
      }
      $s_char_options .= '<option value="other"' . (($first_char == 'other') ? ' selected="selected"' : '') . '>' . $user->lang['OTHER'] . '</option>';

      // Build a relevant pagination_url
      $params = $sort_params = array();

      // We do not use request_var() here directly to save some calls (not all variables are set)
      $check_params = array(
         'g'            => array('g', 0),
         'sk'         => array('sk', $default_key),
         'sd'         => array('sd', 'a'),
         'form'         => array('form', ''),
         'field'         => array('field', ''),
         'select_single'   => array('select_single', $select_single),
         'username'      => array('username', '', true),
         'email'         => array('email', ''),
         'icq'         => array('icq', ''),
         'aim'         => array('aim', ''),
         'yahoo'         => array('yahoo', ''),
         'msn'         => array('msn', ''),
         'jabber'      => array('jabber', ''),
         'search_group_id'   => array('search_group_id', 0),
         'joined_select'   => array('joined_select', 'lt'),
         'active_select'   => array('active_select', 'lt'),
         'count_select'   => array('count_select', 'eq'),
         'joined'      => array('joined', ''),
         'active'      => array('active', ''),
         'count'         => (request_var('count', '') !== '') ? array('count', 0) : array('count', ''),
         'ip'         => array('ip', ''),
         'first_char'   => array('first_char', ''),
      );

      foreach ($check_params as $key => $call)
      {
         if (!isset($_REQUEST[$key]))
         {
            continue;
         }

         $param = call_user_func_array('request_var', $call);
         $param = urlencode($key) . '=' . ((is_string($param)) ? urlencode($param) : $param);
         $params[] = $param;

         if ($key != 'sk' && $key != 'sd')
         {
            $sort_params[] = $param;
         }
      }

      $u_hide_find_member = append_sid("{$phpbb_root_path}memberlist.$phpEx", "start=$start" . (!empty($params) ? '&amp;' . implode('&amp;', $params) : ''));

      if ($mode)
      {
         $params[] = "mode=$mode";
      }
      $sort_params[] = "mode=$mode";

      $pagination_url = append_sid("{$phpbb_root_path}memberlist.$phpEx", implode('&amp;', $params));
      $sort_url = append_sid("{$phpbb_root_path}memberlist.$phpEx", implode('&amp;', $sort_params));

      unset($search_params, $sort_params);

      // Some search user specific data
      if ($mode == 'searchuser' && ($config['load_search'] || $auth->acl_get('a_')))
      {
         $group_selected = request_var('search_group_id', 0);
         $s_group_select = '<option value="0"' . ((!$group_selected) ? ' selected="selected"' : '') . '>&nbsp;</option>';
         $group_ids = array();

         /**
         * @todo add this to a separate function (function is responsible for returning the groups the user is able to see based on the users group membership)
         */

         if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel'))
         {
            $sql = 'SELECT group_id, group_name, group_type
               FROM ' . GROUPS_TABLE;

            if (!$config['coppa_enable'])
            {
               $sql .= " WHERE group_name <> 'REGISTERED_COPPA'";
            }

            $sql .= ' ORDER BY group_name ASC';
         }
         else
         {
            $sql = 'SELECT g.group_id, g.group_name, g.group_type
               FROM ' . GROUPS_TABLE . ' g
               LEFT JOIN ' . USER_GROUP_TABLE . ' ug
                  ON (
                     g.group_id = ug.group_id
                     AND ug.user_id = ' . $user->data['user_id'] . '
                     AND ug.user_pending = 0
                  )
               WHERE (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ')';

            if (!$config['coppa_enable'])
            {
               $sql .= " AND g.group_name <> 'REGISTERED_COPPA'";
            }

            $sql .= ' ORDER BY g.group_name ASC';
         }
         $result = $db->sql_query($sql);

         while ($row = $db->sql_fetchrow($result))
         {
            $group_ids[] = $row['group_id'];
            $s_group_select .= '<option value="' . $row['group_id'] . '"' . (($group_selected == $row['group_id']) ? ' selected="selected"' : '') . '>' . (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>';
         }
         $db->sql_freeresult($result);

         if ($group_selected !== 0 && !in_array($group_selected, $group_ids))
         {
            trigger_error('NO_GROUP');
         }

         $template->assign_vars(array(
            'USERNAME'   => $username,
            'EMAIL'      => $email,
            'ICQ'      => $icq,
            'AIM'      => $aim,
            'YAHOO'      => $yahoo,
            'MSNM'      => $msn,
            'JABBER'   => $jabber,
            'JOINED'   => implode('-', $joined),
            'ACTIVE'   => implode('-', $active),
            'COUNT'      => $count,
            'IP'      => $ipdomain,

            'S_IP_SEARCH_ALLOWED'   => ($auth->acl_getf_global('m_info')) ? true : false,
            'S_EMAIL_SEARCH_ALLOWED'=> ($auth->acl_get('a_user')) ? true : false,
            'S_IN_SEARCH_POPUP'      => ($form && $field) ? true : false,
            'S_SEARCH_USER'         => true,
            'S_FORM_NAME'         => $form,
            'S_FIELD_NAME'         => $field,
            'S_SELECT_SINGLE'      => $select_single,
            'S_COUNT_OPTIONS'      => $s_find_count,
            'S_SORT_OPTIONS'      => $s_sort_key,
            'S_JOINED_TIME_OPTIONS'   => $s_find_join_time,
            'S_ACTIVE_TIME_OPTIONS'   => $s_find_active_time,
            'S_GROUP_SELECT'      => $s_group_select,
            'S_USER_SEARCH_ACTION'   => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=searchuser&amp;form=$form&amp;field=$field"))
         );
      }

      // Get us some users :D
      $sql = "SELECT u.user_id
         FROM " . USERS_TABLE . " u
            $sql_from
         WHERE u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ")
            $sql_where
         ORDER BY $order_by";
      $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);

      $user_list = array();
      while ($row = $db->sql_fetchrow($result))
      {
         $user_list[] = (int) $row['user_id'];
      }
      $db->sql_freeresult($result);
      $leaders_set = false;
      // So, did we get any users?
      if (sizeof($user_list))
      {
         // Session time?! Session time...
         $sql = 'SELECT session_user_id, MAX(session_time) AS session_time
            FROM ' . SESSIONS_TABLE . '
            WHERE session_time >= ' . (time() - $config['session_length']) . '
               AND ' . $db->sql_in_set('session_user_id', $user_list) . '
            GROUP BY session_user_id';
         $result = $db->sql_query($sql);

         $session_times = array();
         while ($row = $db->sql_fetchrow($result))
         {
            $session_times[$row['session_user_id']] = $row['session_time'];
         }
         $db->sql_freeresult($result);

         // Do the SQL thang
         if ($mode == 'group')
         {
            $sql = "SELECT u.*
                  $sql_select
               FROM " . USERS_TABLE . " u
                  $sql_from
               WHERE " . $db->sql_in_set('u.user_id', $user_list) . "
                  $sql_where_data";
         }
         else
         {
            $sql = 'SELECT *
               FROM ' . USERS_TABLE . '
               WHERE ' . $db->sql_in_set('user_id', $user_list);
         }
         $result = $db->sql_query($sql);

         $id_cache = array();
         while ($row = $db->sql_fetchrow($result))
         {
            $row['session_time'] = (!empty($session_times[$row['user_id']])) ? $session_times[$row['user_id']] : 0;
            $row['last_visit'] = (!empty($row['session_time'])) ? $row['session_time'] : $row['user_lastvisit'];

            $id_cache[$row['user_id']] = $row;
         }
         $db->sql_freeresult($result);

         // Load custom profile fields
         if ($config['load_cpf_memberlist'])
         {
            include_once($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
            $cp = new custom_profile();

            // Grab all profile fields from users in id cache for later use - similar to the poster cache
            $profile_fields_cache = $cp->generate_profile_fields_template('grab', $user_list);
         }

         // If we sort by last active date we need to adjust the id cache due to user_lastvisit not being the last active date...
         if ($sort_key == 'l')
         {
//            uasort($id_cache, create_function('$first, $second', "return (\$first['last_visit'] == \$second['last_visit']) ? 0 : ((\$first['last_visit'] < \$second['last_visit']) ? $lesser_than : ($lesser_than * -1));"));
            usort($user_list,  '_sort_last_active');
         }

         for ($i = 0, $end = sizeof($user_list); $i < $end; ++$i)
         {
            $user_id = $user_list[$i];
            $row =& $id_cache[$user_id];
            $is_leader = (isset($row['group_leader']) && $row['group_leader']) ? true : false;
            $leaders_set = ($leaders_set || $is_leader);

            $cp_row = array();
            if ($config['load_cpf_memberlist'])
            {
               $cp_row = (isset($profile_fields_cache[$user_id])) ? $cp->generate_profile_fields_template('show', false, $profile_fields_cache[$user_id]) : array();
            }

            $memberrow = array_merge(show_profile($row), array(
               'ROW_NUMBER'      => $i + ($start + 1),

               'S_CUSTOM_PROFILE'   => (isset($cp_row['row']) && sizeof($cp_row['row'])) ? true : false,
               'S_GROUP_LEADER'   => $is_leader,

               'U_VIEW_PROFILE'   => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&amp;u=' . $user_id))
            );

            if (isset($cp_row['row']) && sizeof($cp_row['row']))
            {
               $memberrow = array_merge($memberrow, $cp_row['row']);
            }

            $template->assign_block_vars('memberrow', $memberrow);

            if (isset($cp_row['blockrow']) && sizeof($cp_row['blockrow']))
            {
               foreach ($cp_row['blockrow'] as $field_data)
               {
                  $template->assign_block_vars('memberrow.custom_fields', $field_data);
               }
            }

            unset($id_cache[$user_id]);
         }
      }

      // Generate page
      $template->assign_vars(array(
         'PAGINATION'   => generate_pagination($pagination_url, $total_users, $config['topics_per_page'], $start),
         'PAGE_NUMBER'   => on_page($total_users, $config['topics_per_page'], $start),
         'TOTAL_USERS'   => ($total_users == 1) ? $user->lang['LIST_USER'] : sprintf($user->lang['LIST_USERS'], $total_users),

         'PROFILE_IMG'   => $user->img('icon_user_profile', $user->lang['PROFILE']),
         'PM_IMG'      => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']),
         'EMAIL_IMG'      => $user->img('icon_contact_email', $user->lang['EMAIL']),
         'WWW_IMG'      => $user->img('icon_contact_www', $user->lang['WWW']),
         'ICQ_IMG'      => $user->img('icon_contact_icq', $user->lang['ICQ']),
         'AIM_IMG'      => $user->img('icon_contact_aim', $user->lang['AIM']),
         'MSN_IMG'      => $user->img('icon_contact_msnm', $user->lang['MSNM']),
         'YIM_IMG'      => $user->img('icon_contact_yahoo', $user->lang['YIM']),
         'JABBER_IMG'   => $user->img('icon_contact_jabber', $user->lang['JABBER']),
         'SEARCH_IMG'   => $user->img('icon_user_search', $user->lang['SEARCH']),

         'U_FIND_MEMBER'         => ($config['load_search'] || $auth->acl_get('a_')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser' . (($start) ? "&amp;start=$start" : '') . (!empty($params) ? '&amp;' . implode('&amp;', $params) : '')) : '',
         'U_HIDE_FIND_MEMBER'   => ($mode == 'searchuser') ? $u_hide_find_member : '',
         'U_SORT_USERNAME'      => $sort_url . '&amp;sk=a&amp;sd=' . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a'),
         'U_SORT_FROM'         => $sort_url . '&amp;sk=b&amp;sd=' . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a'),
         'U_SORT_JOINED'         => $sort_url . '&amp;sk=c&amp;sd=' . (($sort_key == 'c' && $sort_dir == 'a') ? 'd' : 'a'),
         'U_SORT_POSTS'         => $sort_url . '&amp;sk=d&amp;sd=' . (($sort_key == 'd' && $sort_dir == 'a') ? 'd' : 'a'),
         'U_SORT_EMAIL'         => $sort_url . '&amp;sk=e&amp;sd=' . (($sort_key == 'e' && $sort_dir == 'a') ? 'd' : 'a'),
         'U_SORT_WEBSITE'      => $sort_url . '&amp;sk=f&amp;sd=' . (($sort_key == 'f' && $sort_dir == 'a') ? 'd' : 'a'),
         'U_SORT_LOCATION'      => $sort_url . '&amp;sk=b&amp;sd=' . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a'),
         'U_SORT_ICQ'         => $sort_url . '&amp;sk=g&amp;sd=' . (($sort_key == 'g' && $sort_dir == 'a') ? 'd' : 'a'),
         'U_SORT_AIM'         => $sort_url . '&amp;sk=h&amp;sd=' . (($sort_key == 'h' && $sort_dir == 'a') ? 'd' : 'a'),
         'U_SORT_MSN'         => $sort_url . '&amp;sk=i&amp;sd=' . (($sort_key == 'i' && $sort_dir == 'a') ? 'd' : 'a'),
         'U_SORT_YIM'         => $sort_url . '&amp;sk=j&amp;sd=' . (($sort_key == 'j' && $sort_dir == 'a') ? 'd' : 'a'),
         'U_SORT_ACTIVE'         => ($auth->acl_get('u_viewonline')) ? $sort_url . '&amp;sk=l&amp;sd=' . (($sort_key == 'l' && $sort_dir == 'a') ? 'd' : 'a') : '',
         'U_SORT_RANK'         => $sort_url . '&amp;sk=m&amp;sd=' . (($sort_key == 'm' && $sort_dir == 'a') ? 'd' : 'a'),
         'U_LIST_CHAR'         => $sort_url . '&amp;sk=a&amp;sd=' . (($sort_key == 'l' && $sort_dir == 'a') ? 'd' : 'a'),

         'S_SHOW_GROUP'      => ($mode == 'group') ? true : false,
         'S_VIEWONLINE'      => $auth->acl_get('u_viewonline'),
         'S_LEADERS_SET'      => $leaders_set,
         'S_MODE_SELECT'      => $s_sort_key,
         'S_ORDER_SELECT'   => $s_sort_dir,
         'S_CHAR_OPTIONS'   => $s_char_options,
         'S_MODE_ACTION'      => $pagination_url)
      );
}

// Output the page
page_header($page_title, false);

$template->set_filenames(array(
   'body' => $template_html)
);
make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));

page_footer();

/**
* Prepare profile data
*/
function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = false)
{
   global $config, $auth, $template, $user, $phpEx, $phpbb_root_path;

   $username = $data['username'];
   $user_id = $data['user_id'];

   $rank_title = $rank_img = $rank_img_src = '';
   get_user_rank($data['user_rank'], (($user_id == ANONYMOUS) ? false : $data['user_posts']), $rank_title, $rank_img, $rank_img_src);

   if ((!empty($data['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_user'))
   {
      $email = ($config['board_email_form'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=email&amp;u=' . $user_id) : (($config['board_hide_emails'] && !$auth->acl_get('a_user')) ? '' : 'mailto:' . $data['user_email']);
   }
   else
   {
      $email = '';
   }

   if ($config['load_onlinetrack'])
   {
      $update_time = $config['load_online_time'] * 60;
      $online = (time() - $update_time < $data['session_time'] && ((isset($data['session_viewonline']) && $data['session_viewonline']) || $auth->acl_get('u_viewonline'))) ? true : false;
   }
   else
   {
      $online = false;
   }

   if ($data['user_allow_viewonline'] || $auth->acl_get('u_viewonline'))
   {
      $last_visit = (!empty($data['session_time'])) ? $data['session_time'] : $data['user_lastvisit'];
   }
   else
   {
      $last_visit = '';
   }

   $age = '';

   if ($config['allow_birthdays'] && $data['user_birthday'])
   {
      list($bday_day, $bday_month, $bday_year) = array_map('intval', explode('-', $data['user_birthday']));

      if ($bday_year)
      {
         $now = getdate(time() + $user->timezone + $user->dst - date('Z'));

         $diff = $now['mon'] - $bday_month;
         if ($diff == 0)
         {
            $diff = ($now['mday'] - $bday_day < 0) ? 1 : 0;
         }
         else
         {
            $diff = ($diff < 0) ? 1 : 0;
         }

         $age = (int) ($now['year'] - $bday_year - $diff);
      }
   }

   // Dump it out to the template
   return array(
      'AGE'         => $age,
      'RANK_TITLE'   => $rank_title,
      'JOINED'      => $user->format_date($data['user_regdate']),
      'VISITED'      => (empty($last_visit)) ? ' - ' : $user->format_date($last_visit),
      'POSTS'         => ($data['user_posts']) ? $data['user_posts'] : 0,
      'WARNINGS'      => isset($data['user_warnings']) ? $data['user_warnings'] : 0,

      'USERNAME_FULL'      => get_username_string('full', $user_id, $username, $data['user_colour']),
      'USERNAME'         => get_username_string('username', $user_id, $username, $data['user_colour']),
      'USER_COLOR'      => get_username_string('colour', $user_id, $username, $data['user_colour']),
      'U_VIEW_PROFILE'   => get_username_string('profile', $user_id, $username, $data['user_colour']),

      'A_USERNAME'      => addslashes(get_username_string('username', $user_id, $username, $data['user_colour'])),

      'AVATAR_IMG'      => get_user_avatar($data['user_avatar'], $data['user_avatar_type'], $data['user_avatar_width'], $data['user_avatar_height']),
      'ONLINE_IMG'      => (!$config['load_onlinetrack']) ? '' : (($online) ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')),
      'S_ONLINE'         => ($config['load_onlinetrack'] && $online) ? true : false,
      'RANK_IMG'         => $rank_img,
      'RANK_IMG_SRC'      => $rank_img_src,
      'ICQ_STATUS_IMG'   => (!empty($data['user_icq'])) ? '<img src="http://web.icq.com/whitepages/online?icq=' . $data['user_icq'] . '&amp;img=5" width="18" height="18" />' : '',
      'S_JABBER_ENABLED'   => ($config['jab_enable']) ? true : false,

      'S_WARNINGS'   => ($auth->acl_getf_global('m_') || $auth->acl_get('m_warn')) ? true : false,

      'U_SEARCH_USER'   => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$user_id&amp;sr=posts") : '',
      'U_NOTES'      => ($user_notes_enabled && $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&amp;mode=user_notes&amp;u=' . $user_id, true, $user->session_id) : '',
      'U_WARN'      => ($warn_user_enabled && $auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&amp;mode=warn_user&amp;u=' . $user_id, true, $user->session_id) : '',
      'U_PM'         => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($data['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;mode=compose&amp;u=' . $user_id) : '',
      'U_EMAIL'      => $email,
      'U_WWW'         => (!empty($data['user_website'])) ? $data['user_website'] : '',
      'U_SHORT_WWW'         => (!empty($data['user_website'])) ? ((strlen($data['user_website']) > 55) ? substr($data['user_website'], 0, 39) . ' ... ' . substr($data['user_website'], -10) : $data['user_website']) : '',
      'U_ICQ'         => ($data['user_icq']) ? 'http://www.icq.com/people/webmsg.php?to=' . urlencode($data['user_icq']) : '',
      'U_AIM'         => ($data['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&amp;action=aim&amp;u=' . $user_id) : '',
      'U_YIM'         => ($data['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($data['user_yim']) . '&amp;.src=pg' : '',
      'U_MSN'         => ($data['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&amp;action=msnm&amp;u=' . $user_id) : '',
      'U_JABBER'      => ($data['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&amp;action=jabber&amp;u=' . $user_id) : '',
      'LOCATION'      => ($data['user_from']) ? $data['user_from'] : '',

      'USER_ICQ'         => $data['user_icq'],
      'USER_AIM'         => $data['user_aim'],
      'USER_YIM'         => $data['user_yim'],
      'USER_MSN'         => $data['user_msnm'],
      'USER_JABBER'      => $data['user_jabber'],
      'USER_JABBER_IMG'   => ($data['user_jabber']) ? $user->img('icon_contact_jabber', $data['user_jabber']) : '',

      'L_VIEWING_PROFILE'   => sprintf($user->lang['VIEWING_PROFILE'], $username),
   );
}

function _sort_last_active($first, $second)
{
   global $id_cache, $sort_dir;

   $lesser_than = ($sort_dir === 'd') ? -1 : 1;

   if (isset($id_cache[$first]['group_leader']) && $id_cache[$first]['group_leader'] && (!isset($id_cache[$second]['group_leader']) || !$id_cache[$second]['group_leader']))
   {
      return -1;
   }
   else if (isset($id_cache[$second]['group_leader']) && (!isset($id_cache[$first]['group_leader']) || !$id_cache[$first]['group_leader']) && $id_cache[$second]['group_leader'])
   {
      return 1;
   }
   else
   {
      return $lesser_than * (int) ($id_cache[$first]['last_visit'] - $id_cache[$second]['last_visit']);
   }
}

?>


Many thanks for your help!
by Cable Player
Tue Feb 15, 2011 1:00 am

Re: bbcode in memberlist

In memberlist_body.html

After

Code: Select all

    <th class="posts"><a href="{U_SORT_POSTS}#memberlist">{L_POSTS}</a></th>


add

Code: Select all

    <th>Medailles</th>


After

Code: Select all

          <td class="posts"><!-- IF memberrow.POSTS --><a href="{memberrow.U_SEARCH_USER}" title="{L_SEARCH_USER_POSTS}">{memberrow.POSTS}</a><!-- ELSE -->{memberrow.POSTS}<!-- ENDIF --></td>


add

Code: Select all

          <td><!-- IF memberrow.PROFILE_MEDAILLES_VALUE -->
          {memberrow.PROFILE_MEDAILLES_VALUE}
          <!-- ELSE -->&nbsp;<!-- ENDIF --></td>


The name of the custom field is Medailles
by vinnie19
Tue Jun 29, 2010 9:53 am

Bad install of advanced_bbcode_box_3_3_0_12

Tried to install with PHPBB3 V3.0.11 this is what I get!

Info:

Host PHP 5.4
Host MySQL 5
New fresh install with old DB and etc copied in.

Installed with new AutoMod V1.02


Code: Select all

   Return to the index page   
General Error
SQL ERROR [ mysql4 ]

Unknown column 'mod_contribs' in 'field list' [1054]

SQL

INSERT INTO phpbb_V3_mods (mod_time, mod_dependencies, mod_name, mod_description, mod_version, mod_path, mod_author_notes, mod_author_name, mod_author_email, mod_author_url, mod_actions, mod_languages, mod_template, mod_contribs) VALUES (1371064361, '', 'a:1:{s:2:\"en\";s:33:\"Advanced BBCode Box 3 (aka ABBC3)\";}', 'ABBC3 replaces phpBB3\'s BBCode buttons with icons in a beautiful and highly customizable toolbar. ABBC3 also adds many new and useful BBCodes giving users more ways to customize their posts. It also improves some of phpBB3\'s built-in BBCodes and supports your own custom BBCodes. Additional features include an Image Resizer with various Lightbox styled expanders, and Auto-Embed Video for dozens of media sites and file formats. ABBC3 is a sleek addition to your phpBB bulletin board.', '3.0.12', './../store/mods/advanced_bbcode_box_3_3_0_12/install_ABBC3.xml', 'To learn more about ABBC3, please read the contrib/docs/README.HTML<br />\n-------------------------------------------------------------------<br />\nWARNING: Please be advised that this MOD might overwrite some custom BBCodes you already have and as a result, those BBCodes might not display correctly due to the changes introduced by ABBC3\'s BBCodes. If you are using custom BBCodes, please read the contrib/docs/README.HTML file for more information before you proceed.', 'VSE', '', 'http://www.phpbb.com/customise/db/mod/advanced_bbcode_box_3/', 'a:5:{s:3:\"SQL\";a:0:{}s:9:\"NEW_FILES\";a:11:{s:21:\"root/abbcode_ajax.php\";s:16:\"abbcode_ajax.php\";s:21:\"root/abbcode_page.php\";s:16:\"abbcode_page.php\";s:12:\"root/adm/*.*\";s:7:\"adm/*.*\";s:20:\"root/flashplayer/*.*\";s:15:\"flashplayer/*.*\";s:17:\"root/includes/*.*\";s:12:\"includes/*.*\";s:22:\"root/install_abbc3.php\";s:17:\"install_abbc3.php\";s:25:\"root/language/en/mods/*.*\";s:20:\"language/en/mods/*.*\";s:23:\"root/styles/abbcode/*.*\";s:18:\"styles/abbcode/*.*\";s:34:\"root/styles/prosilver/template/*.*\";s:29:\"styles/prosilver/template/*.*\";s:13:\"root/umil/*.*\";s:8:\"umil/*.*\";s:35:\"root/styles/subsilver2/template/*.*\";s:30:\"styles/subsilver2/template/*.*\";}s:5:\"EDITS\";a:31:{s:34:\"adm/style/acp_users_signature.html\";a:5:{i:0;a:1:{s:29:\" <p>{SIGNATURE_PREVIEW}</p>\";a:1:{s:12:\"replace-with\";s:67:\" <div id=\"sig\" class=\"signature\"><p>{SIGNATURE_PREVIEW}</p></div>\";}}i:1;a:1:{s:27:\" <div id=\"format-buttons\">\";a:1:{s:9:\"after add\";s:157:\"<!-- MOD : MSSTI ABBC3 (v{S_ABBC3_VERSION}) - Start //-->\n <!-- IF S_ABBC3_MOD -->\n <!-- INCLUDE posting_abbcode_buttons.html -->\n </div>\n <!-- ELSE -->\";}}i:2;a:1:{s:6:\" <dl>\";a:1:{s:12:\"replace-with\";s:182:\" <!-- ENDIF -->\n<!-- MOD : MSSTI ABBC3 (v{S_ABBC3_VERSION}) - End //-->\n <dl>\n<!-- MOD : MSSTI ABBC3 (v{S_ABBC3_VERSION}) - Start //-->\n <!-- IF S_ABBC3_COLOR_MODE eq \'phpbb\' -->\";}}i:3;a:1:{s:274:\" <dd style=\"margin-{S_CONTENT_FLOW_BEGIN}: 90px;\"><textarea name=\"signature\" id=\"signature\" rows=\"10\" cols=\"60\" style=\"width: 95%;\" onselect=\"storeCaret(this);\" onclick=\"storeCaret(this);\" onkeyup=\"storeCaret(this);\" onfocus=\"initInsertions();\">{SIGNATURE}</textarea></dd>\";a:1:{s:12:\"in-line-edit\";a:1:{i:0;a:1:{s:16:\"name=\"signature\"\";a:1:{s:17:\"in-line-after-add\";a:1:{i:0;s:15:\" id=\"signature\"\";}}}}}}i:4;a:1:{s:69:\" <dd style=\"margin-{S_CONTENT_FLOW_BEGIN}: 90px; margin-top: 5px;\">\";a:1:{s:10:\"before add\";s:361:\" <!-- ELSE -->\n <dt style=\"width: 100%; margin-bottom: 5px;\"><textarea name=\"signature\" id=\"signature\" rows=\"10\" cols=\"60\" style=\"width: 99%;\" onselect=\"storeCaret(this);\" onclick=\"storeCaret(this);\" onkeyup=\"storeCaret(this);\" onfocus=\"initInsertions();\">{SIGNATURE}</textarea></dt>\n <!-- ENDIF -->\n<!-- MOD : MSSTI ABBC3 (v{S_ABBC3_VERSION}) - End //-->\";}}}s:29:\"adm/style/overall_header.html\";a:1:{i:0;a:1:{s:7:\"</head>\";a:1:{s:10:\"before add\";s:173:\"<!-- MOD : MSSTI ABBC3 (v{S_ABBC3_VERSION}) - Start //-->\n<!-- INCLUDE ./../../styles/abbcode/abbcode_header.html -->\n<!-- MOD : MSSTI ABBC3 (v{S_ABBC3_VERSION}) - End //-->\";}}}s:28:\"adm/style/simple_header.html\";a:1:{i:0;a:1:{s:7:\"</head>\";a:1:{s:10:\"before add\";s:201:\"<!-- MOD : MSSTI ABBC3 (v{S_ABBC3_VERSION}) - Start //-->\n<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"{S_ABBC3_PATH}/abbcode.css\" />\n<!-- MOD : MSSTI ABBC3 (v{S_ABBC3_VERSION}) - End //-->\";}}}s:19:\"includes/bbcode.php\";a:9:{i:0;a:1:{s:52:\"/**\n* BBCode class\n* @package phpBB3\n*/\nclass bbcode\";a:1:{s:12:\"replace-with\";s:233:\"// MOD : MSSTI ABBC3 - Start\nif (!class_exists(\'abbcode\'))\n{\n include($phpbb_root_path . \'includes/abbcode.\' . $phpEx);\n}\n/**\n* BBCode class\n* @package phpBB3\n*/\n// class bbcode\nclass bbcode extends abbcode\n// MOD : MSSTI ABBC3 - end\";}}i:1;a:1:{s:37:\" $undid_bbcode_specialchars = false;\";a:1:{s:10:\"before add\";s:601:\"// MOD : MSSTI ABBC3 - Start\n // Try to avoid duplicates anchor ID\'s inside quotes\n if (preg_match(\'#\\[quote(?:=&quot;(.*?)&quot;)?:\' . $this->bbcode_uid . \'\\](.*?)\\[anchor=(.*?)?\\sgoto=(.*?)?:\' . $this->bbcode_uid . \'\\](.*?)\\[/anchor:\' . $this->bbcode_uid . \'\\](.*?)\\[/quote:\' . $this->bbcode_uid . \'\\]#is\', $message))\n {\n $message = preg_replace(\'#(\\[anchor=(.*?)(\\s)goto=(.*?):\' . $this->bbcode_uid . \'\\](.*?)\\[/anchor:\' . $this->bbcode_uid . \'\\]?)#is\', \"[anchor=quoted$2 goto=quoted$4:\" . $this->bbcode_uid . \"]$5[/anchor:\" . $this->bbcode_uid . \"]\", $message);\n }\n// MOD : MSSTI ABBC3 - End\";}}i:2;a:1:{s:46:\" }\n\n $bbcode_ids = $rowset = $sql = array();\";a:1:{s:10:\"before add\";s:741:\"// MOD : MSSTI ABBC3 - Start\n $this->template_filename2 = $phpbb_root_path . \'styles/\' . $user->theme[\'template_path\'] . \'/template/abbcode.html\';\n\n if (!@file_exists($this->template_filename2))\n {\n if (isset($user->theme[\'template_inherits_id\']) && $user->theme[\'template_inherits_id\'])\n {\n $this->template_filename2 = $phpbb_root_path . \'styles/\' . $user->theme[\'template_inherit_path\'] . \'/template/abbcode.html\';\n if (!@file_exists($this->template_filename2))\n {\n trigger_error(\'The file \' . $this->template_filename2 . \' is missing.\', E_USER_ERROR);\n }\n }\n else\n {\n trigger_error(\'The file \' . $this->template_filename2 . \' is missing.\', E_USER_ERROR);\n }\n }\n// MOD : MSSTI ABBC3 - End\";}}i:3;a:1:{s:134:\" $bitfield = new bitfield($this->bbcode_bitfield);\n $bbcodes_set = $bitfield->get_all_set();\n\n foreach ($bbcodes_set as $bbcode_id)\";a:1:{s:10:\"before add\";s:83:\"// MOD : MSSTI ABBC3 - Start\n $abbcode = new abbcode();\n// MOD : MSSTI ABBC3 - end\";}}i:4;a:1:{s:100:\" $sql = \'SELECT *\n FROM \' . BBCODES_TABLE . \'\n WHERE \' . $db->sql_in_set(\'bbcode_id\', $sql);\";a:1:{s:9:\"after add\";s:94:\"// MOD : MSSTI ABBC3 - Start\n $sql .= \" AND bbcode_match <> \'.\'\";\n// MOD : MSSTI ABBC3 - End\";}}i:5;a:1:{s:87:\" \'#\\[url:$uid\\]((.*?))\\[/url:$uid\\]#s\' => $this->bbcode_tpl(\'url\', $bbcode_id),\";a:1:{s:10:\"before add\";s:399:\"// MOD : MSSTI ABBC3 - Start\n \'#\\[url:$uid\\](ed2k://\\|(file|server|serverlist|friend)(|\\|[^\\\\/\\|:<>\\*\\?\\\"]+?)\\|(.*?)\\|/?)\\[/url:$uid\\]#sie\' => \"\\$this->ed2k_pass( \\$bbcode_id, \'\\$1\', \'\' )\",\n \'#\\[url=(ed2k://\\|(file|server|serverlist|friend)(|\\|[^\\\\/\\|:<>\\*\\?\\\"]+?)\\|(.*?)\\|/?):$uid\\](.*?)\\[/url:$uid\\]#sie\' => \"\\$this->ed2k_pass( \\$bbcode_id, \'\\$1\', \'\\$5\' )\",\n// MOD : MSSTI ABBC3 - End\";}}i:6;a:1:{s:35:\" // Replace {L_*} lang strings\";a:1:{s:9:\"after add\";s:94:\"// MOD : MSSTI ABBC3 - Start\n $user->add_lang(\'mods/abbcode\');\n// MOD : MSSTI ABBC3 - End\";}}i:7;a:1:{s:86:\" \'img\' => \'<img src=\"$1\" alt=\"\' . $user->lang[\'IMAGE\'] . \'\" class=\"resize_me\" />\',\";a:1:{s:12:\"in-line-edit\";a:1:{i:0;a:1:{s:5:\" />\',\";a:1:{s:18:\"in-line-before-add\";a:1:{i:0;s:18:\" class=\"resize_me\"\";}}}}}}i:8;a:1:{s:147:\" if (($tpl = file_get_contents($this->template_filename)) === false)\n {\n trigger_error(\'Could not load bbcode template\', E_USER_ERROR);\n }\";a:1:{s:9:\"after add\";s:243:\"// MOD : MSSTI ABBC3 - Start\n if (($tpl2 = file_get_contents($this->template_filename2)) === false)\n {\n trigger_error(\'Could not load abbcode template\', E_USER_ERROR);\n }\n else\n {\n $tpl .= $tpl2;\n }\n// MOD : MSSTI ABBC3 - End\";}}}s:22:\"includes/constants.php\";a:1:{i:0;a:1:{s:20:\"// Additional tables\";a:1:{s:9:\"after add\";s:138:\"// MOD : MSSTI ABBC3 Clicks Counter - Start\ndefine(\'CLICKS_TABLE\', $table_prefix . \'clicks\');\n// MOD : MSSTI ABBC3 Clicks Counter - End\";}}}s:22:\"includes/functions.php\";a:1:{i:0;a:1:{s:93:\" // The following assigns all _common_ variables that may be used at any point in a template.\";a:1:{s:10:\"before add\";s:122:\"// MOD : MSSTI ABBC3 - Start\n if (defined(\'IN_ABBC3\'))\n {\n $user->add_lang(\'mods/abbcode\');\n }\n// MOD : MSSTI ABBC3 - End\";}}}s:30:\"includes/functions_content.php\";a:1:{i:0;a:1:{s:50:\" \'L_DOWNLOAD_COUNT\' => $l_download_count\n );\";a:1:{s:9:\"after add\";s:740:\"// MOD : MSSTI ABBC3 - Start\n global $abbcode;\n // We need to check if ABBC3 is properly initialized for attached images and the ABBC3 img resizer\n if (@$config[\'ABBC3_MOD\'])\n {\n // For attached images being resized in private messages only when bbcodes are not present\n if (!class_exists(\'abbcode\'))\n {\n include($phpbb_root_path . \'includes/abbcode.\' . $phpEx);\n }\n // For attached image resizer regular messages when bbcodes are not present\n if ($abbcode->abbcode_config[\'S_ABBC3_RESIZE\'] && !isset($template->_rootref[\'S_ABBC3_RESIZE\']) && ($display_cat == ATTACHMENT_CATEGORY_IMAGE || $display_cat == ATTACHMENT_CATEGORY_THUMB))\n {\n $abbcode->abbcode_init();\n }\n }\n// MOD : MSSTI ABBC3 - End\";}}}s:30:\"includes/functions_display.php\";a:5:{i:0;a:1:{s:46:\"function display_custom_bbcodes($abbc3 = true)\";a:1:{s:12:\"in-line-edit\";a:1:{i:0;a:1:{s:23:\"display_custom_bbcodes(\";a:1:{s:17:\"in-line-after-add\";a:1:{i:0;s:13:\"$abbc3 = true\";}}}}}}i:1;a:1:{s:30:\" $num_predefined_bbcodes = 22;\";a:1:{s:9:\"after add\";s:861:\"// MOD : MSSTI ABBC3 - Start\n global $config, $mode, $abbcode;\n\n $abbc3 = ($abbc3 && @$config[\'ABBC3_UCP_MODE\'] && isset($user->data[\'user_abbcode_mod\'])) ? $user->data[\'user_abbcode_mod\'] : $abbc3;\n\n $display = ($mode == \'signature\' || $mode == \'sig\') ? \'display_on_sig\' : ($mode == \'compose\' ? \'display_on_pm\' : \'display_on_posting\');\n\n if ($abbc3 && @$config[\'ABBC3_MOD\'])\n {\n // We need to check if ABBC3 is properly initialized\n if (!class_exists(\'abbcode\'))\n {\n global $phpbb_root_path, $phpEx;\n\n include($phpbb_root_path . \'includes/abbcode.\' . $phpEx);\n }\n\n $abbcode->abbcode_init();\n $abbcode->abbcode_display($mode);\n\n $sql_where = \" $display = 1 AND (abbcode = 0 AND bbcode_image = \'\')\";\n }\n else\n {\n $sql_where = \" $display = 1 AND abbcode = 0\";\n\n $template->assign_vars(array(\'S_ABBC3_DISABLED\' => true));\n }\n// MOD : MSSTI ABBC3 - End\";}}i:2;a:1:{s:68:\" $sql = \'SELECT bbcode_id, bbcode_tag, bbcode_helpline, bbcode_group\";a:1:{s:12:\"in-line-edit\";a:1:{i:0;a:1:{s:15:\"bbcode_helpline\";a:1:{s:17:\"in-line-after-add\";a:1:{i:0;s:14:\", bbcode_group\";}}}}}}i:3;a:1:{s:26:\" WHERE \' . $sql_where . \'\";a:1:{s:12:\"in-line-edit\";a:1:{i:0;a:1:{s:22:\"display_on_posting = 1\";a:1:{s:15:\"in-line-replace\";a:1:{i:0;s:18:\"\' . $sql_where . \'\";}}}}}}i:4;a:1:{s:45:\" while ($row = $db->sql_fetchrow($result))\n {\";a:1:{s:9:\"after add\";s:474:\"// MOD : MSSTI ABBC3 - Start\n if ($abbc3 && @$config[\'ABBC3_MOD\'])\n {\n // Check phpbb permissions status\n // Check ABBC3 groups permission\n // try to make it as quicky as it can be \n $auth_tag = preg_replace(\'#\\=(.*)?#\', \'\', strtoupper(trim($row[\'bbcode_tag\'])));\n if (isset($row[\'bbcode_group\']) && $row[\'bbcode_group\'])\n {\n if (!$abbcode->abbcode_permissions($auth_tag, $row[\'bbcode_group\']))\n {\n continue;\n }\n }\n }\n// MOD : MSSTI ABBC3 - End\";}}}s:27:\"includes/message_parser.php\";a:3:{i:0;a:1:{s:46:\" $this->bbcodes[$row[\'bbcode_tag\']] = array(\";a:1:{s:10:\"before add\";s:296:\"// MOD : MSSTI ABBC3 - Start\n if ($row[\'bbcode_match\'] == \'.\')\n {\n if (isset($this->bbcodes[$row[\'bbcode_tag\']]) && $this->bbcodes[$row[\'bbcode_tag\']])\n {\n $this->bbcodes[$row[\'bbcode_tag\']][\'bbcode_group\'] = $row[\'bbcode_group\'];\n }\n continue;\n }\n// MOD : MSSTI ABBC3 - End\";}}i:1;a:1:{s:43:\" \'bbcode_id\' => (int) $row[\'bbcode_id\'],\";a:1:{s:10:\"before add\";s:99:\"// MOD : MSSTI ABBC3 - Start\n \'bbcode_group\' => $row[\'bbcode_group\'],\n// MOD : MSSTI ABBC3 - End\";}}i:2;a:1:{s:18:\" // Parse smilies\";a:1:{s:10:\"before add\";s:639:\"// MOD : MSSTI ABBC3 - Start\n // Check phpbb permissions status\n // Check ABBC3 groups permission\n // try to make it as quicky as it can be \n foreach ($this->bbcodes as $bbcode_name => $bbcode_data)\n {\n $auth_tag = preg_replace(\'#\\=(.*)?#\', \'\', strtoupper(trim($bbcode_name)));\n if ((isset($bbcode_data[\'bbcode_group\']) && $bbcode_data[\'bbcode_group\']) || in_array($auth_tag, $this->need_permissions))\n {\n if (!$this->abbcode_permissions($auth_tag, (isset($bbcode_data[\'bbcode_group\']) ? $bbcode_data[\'bbcode_group\'] : 0)))\n {\n $this->bbcodes[$bbcode_name][\'disabled\'] = true;\n }\n }\n }\n// MOD : MSSTI ABBC3 - End\";}}}s:28:\"includes/acp/acp_bbcodes.php\";a:5:{i:0;a:1:{s:59:\" WHERE bbcode_id = \' . $bbcode_id . \' AND abbcode = 0\';\";a:1:{s:12:\"in-line-edit\";a:2:{i:0;a:1:{s:17:\", bbcode_helpline\";a:1:{s:17:\"in-line-after-add\";a:1:{i:0;s:10:\", abbcode \";}}}i:1;a:1:{s:10:\"$bbcode_id\";a:1:{s:17:\"in-line-after-add\";a:1:{i:0;s:21:\" . \' AND abbcode = 0\'\";}}}}}}i:1;a:1:{s:59:\" WHERE bbcode_id = \' . $bbcode_id . \' AND abbcode = 0\';\";a:1:{s:12:\"in-line-edit\";a:2:{i:0;a:1:{s:12:\", bbcode_tag\";a:1:{s:17:\"in-line-after-add\";a:1:{i:0;s:10:\", abbcode \";}}}i:1;a:1:{s:10:\"$bbcode_id\";a:1:{s:17:\"in-line-after-add\";a:1:{i:0;s:21:\" . \' AND abbcode = 0\'\";}}}}}}i:2;a:1:{s:47:\" $sql_ary[\'bbcode_id\'] = (int) $bbcode_id;\";a:1:{s:9:\"after add\";s:366:\"// MOD : MSSTI ABBC3 - Start\n $sql = \'SELECT MAX(bbcode_order) as max_bbcode_order\n FROM \' . BBCODES_TABLE;\n $result = $db->sql_query($sql);\n $row = $db->sql_fetchrow($result);\n $db->sql_freeresult($result);\n $bbcode_order = $row[\'max_bbcode_order\'] + 1;\n $sql_ary[\'bbcode_order\'] = (int) $bbcode_order;\n// MOD : MSSTI ABBC3 - End\";}}i:3;a:1:{s:56:\" WHERE bbcode_id = $bbcode_id\" . \' AND abbcode = 0\';\";a:1:{s:12:\"in-line-edit\";a:2:{i:0;a:1:{s:10:\"bbcode_tag\";a:1:{s:17:\"in-line-after-add\";a:1:{i:0;s:10:\", abbcode \";}}}i:1;a:1:{s:11:\"$bbcode_id\"\";a:1:{s:17:\"in-line-after-add\";a:1:{i:0;s:21:\" . \' AND abbcode = 0\'\";}}}}}}i:4;a:1:{s:42:\" WHERE abbcode = 0 ORDER BY bbcode_tag\';\";a:1:{s:12:\"in-line-edit\";a:1:{i:0;a:1:{s:21:\"ORDER BY bbcode_tag\';\";a:1:{s:18:\"in-line-before-add\";a:1:{i:0;s:18:\"WHERE abbcode = 0 \";}}}}}}}s:27:\"includes/acp/acp_styles.php\";a:1:{i:0;a:1:{s:140:\" if ($file[0] != \'.\' && strtoupper($file) != \'CVS\' && !is_file($dir . \'/\' . $file) && !is_link($dir . \'/\' . $file) && $file != \'abbcode\')\";a:1:{s:12:\"in-line-edit\";a:1:{i:0;a:1:{s:32:\" && !is_link($dir . \'/\' . $file)\";a:1:{s:17:\"in-line-after-add\";a:1:{i:0;s:22:\" && $file != \'abbcode\'\";}}}}}}}s:26:\"includes/ucp/ucp_prefs.php\";a:4:{i:0;a:1:{s:74:\" \'notify\' => request_var(\'notify\', (bool) $user->data[\'user_notify\']),\";a:1:{s:9:\"after add\";s:219:\"// MOD : MSSTI ABBC3 - Start\n \'abbcode_mod\' => request_var(\'abbcode_mod\', (($user->data[\'user_abbcode_mod\']) ? ($user->data[\'user_abbcode_compact\'] ? \'compact\' : \'standard\') : \'limited\')),\n// MOD : MSSTI ABBC3 - End\";}}i:1;a:1:{s:40:\" \'user_notify\' => $data[\'notify\'],\";a:1:{s:9:\"after add\";s:212:\"// MOD : MSSTI ABBC3 - Start\n \'user_abbcode_mod\' => (($data[\'abbcode_mod\'] == \'limited\') ? 0 : 1),\n \'user_abbcode_compact\' => (($data[\'abbcode_mod\'] == \'compact\') ? 1 : 0),\n// MOD : MSSTI ABBC3 - End\";}}i:2;a:1:{s:69:\" $template->assign_vars(array(\n \'S_BBCODE\' => $data[\'bbcode\'],\";a:1:{s:10:\"before add\";s:579:\"// MOD : MSSTI ABBC3 - Start\n $user->add_lang(\'mods/info_acp_abbcodes\');\n\n $abbc3_options = \'\';\n $abbc3_modes = array(\'standard\' => $user->lang[\'UCP_ABBC3_STANDARD\'], \'compact\' => $user->lang[\'UCP_ABBC3_COMPACT\'], \'limited\' => $user->lang[\'UCP_ABBC3_LIMITED\']);\n\n foreach ($abbc3_modes as $abbc3_mode => $abbc3_lang)\n {\n $abbc3_options .= \'<option value=\"\' . $abbc3_mode . \'\"\' . (($data[\'abbcode_mod\'] == $abbc3_mode) ? \' selected=\"selected\"\' : \'\') . \'>\';\n $abbc3_options .= $abbc3_lang;\n $abbc3_options .= \'</option>\';\n }\n// MOD : MSSTI ABBC3 - End\";}}i:3;a:1:{s:37:\" \'S_SMILIES\' => $data[\'smilies\'],\";a:1:{s:10:\"before add\";s:253:\"// MOD : MSSTI ABBC3 - Start\n \'S_ABBC3_VERSION\' => @$config[\'ABBC3_VERSION\'],\n \'S_ABBC3_MOD\' => @$config[\'ABBC3_MOD\'],\n \'S_ABBC3_UCP_MODE\' => @$config[\'ABBC3_UCP_MODE\'],\n \'S_ABBCODE_OPTIONS\' => $abbc3_options,\n// MOD : MSSTI ABBC3 - End\";}}}s:41:\"styles/prosilver/template/attachment.html\";a:2:{i:0;a:1:{s:225:\" <dt><a href=\"{_file.U_DOWNLOAD_LINK}\"><img src=\"{_file.THUMB_IMAGE}\" alt=\"{_file.DOWNLOAD_NAME}\" title=\"{_file.DOWNLOAD_NAME} ({_file.FILESIZE} {_file.SIZE_LANG}) {_file.L_DOWNLOAD_COUNT}\" class=\"attach_parent\" /></a></dt>\";a:1:{s:12:\"in-line-edit\";a:1:{i:0;a:1:{s:25:\"{_file.L_DOWNLOAD_COUNT}\"\";a:1:{s:17:\"in-line-after-add\";a:1:{i:0;s:22:\" class=\"attach_parent\"\";}}}}}}i:1;a:1:{s:144:\" <dt class=\"attach-image\"><img src=\"{_file.U_INLINE_LINK}\" alt=\"{_file.DOWNLOAD_NAME}\" onclick=\"viewableArea(this);\" class=\"attach_me\" /></dt>\";a:1:{s:12:\"in-line-edit\";a:1:{i:0;a:1:{s:21:\"\"viewableArea(this);\"\";a:1:{s:17:\"in-line-after-add\";a:1:{i:0;s:18:\" class=\"attach_me\"\";}}}}}}}s:37:\"styles/prosilver/template/bbcode.html\";a:1:{i:0;a:1:{s:87:\"<!-- BEGIN img --><img src=\"{URL}\" alt=\"{L_IMAGE}\" class=\"resize_me\" /><!-- END img -->\";a:1:{s:12:\"in-line-edit\";a:1:{i:0;a:1:{s:15:\"alt=\"{L_IMAGE}\"\";a:1:{s:17:\"in-line-after-add\";a:1:{i:0;s:18:\" class=\"resize_me\"\";}}}}}}}s:45:\"styles/prosilver/template/overall_header.html\";a:1:{i:0;a:1:{s:7:\"</head>\";a:1:{s:10:\"before add\";s:166:\"<!-- MOD : MSSTI ABBC3 (v{S_ABBC3_VERSION}) - Start //-->\n<!-- INCLUDE ./../../abbcode/abbcode_header.html -->\n<!-- MOD : MSSTI ABBC3 (v{S_ABBC3_VERSION}) - End //-->\";}}}s:46:\"styles/prosilver/template/posting_buttons.html\";a:2:{i:0;a:1:{s:25:\"<div id=\"format-buttons\">\";a:1:{s:9:\"after add\";s:223:\"<!-- MOD : MSSTI ABBC3 (v{S_ABBC3_VERSION}) - Start //-->\n<!-- IF S_ABBC3_MOD and not S_ABBC3_DISABLED -->\n <!-- INCLUDE posting_abbcode_buttons.html -->\n<!-- ELSE -->\n<!-- MOD : MSSTI ABBC3 (v{S_ABBC3_VERSION}) - End //-->\";}}i:1;a:1:{s:21:\"</div>\n<!-- ENDIF -->\";a:1:{s:10:\"before add\";s:128:\"<!-- MOD : MSSTI ABBC3 (v{S_ABBC3_VERSION}) - Start //-->\n<!-- ENDIF -->\n<!-- MOD : MSSTI ABBC3 (v{S_ABBC3_VERSION}) - End //-->\";}}}s:46:\"styles/prosilver/template/posting_preview.html\";a:1:{i:0;a:1:{s:102:\" <!-- IF PREVIEW_SIGNATURE --><div id=\"sig\" class=\"signature\">{PREVIEW_SIGNATURE}</div><!-- ENDIF -->\";a:1:{s:12:\"in-line-edit\";a:1:{i:0;a:1:{s:18:\" class=\"signature\"\";a:1:{s:18:\"in-line-before-add\";a:1:{i:0;s:9:\" id=\"sig\"\";}}}}}}}s:44:\"styles/prosilver/template/simple_header.html\";a:1:{i:0;a:1:{s:7:\"</head>\";a:1:{s:10:\"before add\";s:201:\"<!-- MOD : MSSTI ABBC3 (v{S_ABBC3_VERSION}) - Start //-->\n<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"{S_ABBC3_PATH}/abbcode.css\" />\n<!-- MOD : MSSTI ABBC3 (v{S_ABBC3_VERSION}) - End //-->\";}}}s:45:\"styles/prosilver/template/ucp_prefs_post.html\";a:1:{i:0;a:1:{s:33:\"<fieldset class=\"submit-buttons\">\";a:1:{s:10:\"before add\";s:592:\"<!-- MOD : MSSTI ABBC3 (v{S_ABBC3_VERSION}) - Start //-->\n<!-- IF S_ABBC3_MOD and S_ABBC3_UCP_MODE -->\n<h2>{L_UCP_ABBCODES}</h2>\n<div class=\"panel\">\n <div class=\"inner\"><span class=\"corners-top\"><span></span></span>\n\n <fieldset>\n <dl>\n <dt><label for=\"abbcode_mod\">{L_UCP_ABBC3_SETTINGS}:</label><br /><span>{L_UCP_ABBC3_SETTINGS_EXPLAIN}</span></dt>\n <dd><select name=\"abbcode_mod\" id=\"abbcode_mod\">{S_ABBCODE_OPTIONS}</select></dd>\n </dl>\n </fieldset>\n \n <span class=\"corners-bottom\"><span></span></span></div>\n</div>\n<!-- ENDIF -->\n<!-- MOD : MSSTI ABBC3 (v{S_ABBC3_VERSION}) - End //-->\";}}}s:52:\"styles/prosilver/template/ucp_profile_signature.html\";a:1:{i:0;a:1:{s:101:\" <div id=\"sig\" class=\"signature\" style=\"border-top:none; margin-top: 0; \">{SIGNATURE_PREVIEW}</div>\";a:1:{s:12:\"in-line-edit\";a:1:{i:0;a:1:{s:18:\" class=\"signature\"\";a:1:{s:18:\"in-line-before-add\";a:1:{i:0;s:9:\" id=\"sig\"\";}}}}}}}s:42:\"styles/subsilver2/template/attachment.html\";a:2:{i:0;a:1:{s:130:\" <a href=\"{_file.U_DOWNLOAD_LINK}\"><img src=\"{_file.THUMB_IMAGE}\" alt=\"{_file.DOWNLOAD_NAME}\" class=\"attach_parent\" /></a><br />\";a:1:{s:12:\"in-line-edit\";a:1:{i:0;a:1:{s:27:\"alt=\"{_file.DOWNLOAD_NAME}\"\";a:1:{s:17:\"in-line-after-add\";a:1:{i:0;s:22:\" class=\"attach_parent\"\";}}}}}}i:1;a:1:{s:90:\" <img src=\"{_file.U_INLINE_LINK}\" alt=\"{_file.DOWNLOAD_NAME}\" class=\"attach_me\" /><br />\";a:1:{s:12:\"in-line-edit\";a:1:{i:0;a:1:{s:27:\"alt=\"{_file.DOWNLOAD_NAME}\"\";a:1:{s:17:\"in-line-after-add\";a:1:{i:0;s:18:\" class=\"attach_me\"\";}}}}}}}s:38:\"styles/subsilver2/template/bbcode.html\";a:1:{i:0;a:1:{s:87:\"<!-- BEGIN img --><img src=\"{URL}\" alt=\"{L_IMAGE}\" class=\"resize_me\" /><!-- END img -->\";a:1:{s:12:\"in-line-edit\";a:1:{i:0;a:1:{s:15:\"alt=\"{L_IMAGE}\"\";a:1:{s:17:\"in-line-after-add\";a:1:{i:0;s:18:\" class=\"resize_me\"\";}}}}}}}s:46:\"styles/subsilver2/template/overall_header.html\";a:1:{i:0;a:1:{s:7:\"</head>\";a:1:{s:10:\"before add\";s:166:\"<!-- MOD : MSSTI ABBC3 (v{S_ABBC3_VERSION}) - Start //-->\n<!-- INCLUDE ./../../abbcode/abbcode_header.html -->\n<!-- MOD : MSSTI ABBC3 (v{S_ABBC3_VERSION}) - End //-->\";}}}s:44:\"styles/subsilver2/template/posting_body.html\";a:2:{i:0;a:1:{s:319:\" <td valign=\"top\" style=\"width: 100%;\"><textarea id=\"message\" name=\"message\" rows=\"15\" cols=\"76\" tabindex=\"3\" onselect=\"storeCaret(this);\" onclick=\"storeCaret(this);\" onkeyup=\"storeCaret(this);\" onfocus=\"initInsertions();\" style=\"width: 700px; height: 270px; min-width: 98%; max-width: 98%;\">{MESSAGE}</textarea></td>\";a:1:{s:12:\"in-line-edit\";a:1:{i:0;a:1:{s:14:\"name=\"message\"\";a:1:{s:18:\"in-line-before-add\";a:1:{i:0;s:13:\"id=\"message\" \";}}}}}}i:1;a:1:{s:88:\" <!-- IF S_BBCODE_ALLOWED and (not S_ABBC3_COLOR or S_ABBC3_COLOR_MODE eq \'phpbb\') -->\";a:1:{s:12:\"in-line-edit\";a:1:{i:0;a:1:{s:16:\"S_BBCODE_ALLOWED\";a:1:{s:17:\"in-line-after-add\";a:1:{i:0;s:57:\" and (not S_ABBC3_COLOR or S_ABBC3_COLOR_MODE eq \'phpbb\')\";}}}}}}}s:47:\"styles/subsilver2/template/posting_buttons.html\";a:3:{i:0;a:1:{s:28:\"<!-- IF S_BBCODE_ALLOWED -->\";a:1:{s:9:\"after add\";s:226:\"<!-- MOD : MSSTI ABBC3 (v{S_ABBC3_VERSION}) - Start //-->\n <!-- IF S_ABBC3_MOD and not S_ABBC3_DISABLED -->\n <!-- INCLUDE posting_abbcode_buttons.html -->\n <!-- ELSE -->\n<!-- MOD : MSSTI ABBC3 (v{S_ABBC3_VERSION}) - End //-->\";}}i:1;a:1:{s:27:\"<!-- ENDIF -->\n </td>\n</tr>\";a:1:{s:12:\"replace-with\";s:265:\"<!-- MOD : MSSTI ABBC3 (v{S_ABBC3_VERSION}) - Start //-->\n <!-- ENDIF -->\n<!-- MOD : MSSTI ABBC3 (v{S_ABBC3_VERSION}) - End //-->\n\n<!-- ENDIF -->\n </td>\n</tr>\n\n<!-- MOD : MSSTI ABBC3 (v{S_ABBC3_VERSION}) - Start //-->\n<!-- IF not S_ABBC3_MOD or S_ABBC3_DISABLED -->\";}}i:2;a:1:{s:92:\" <td class=\"genmed\" align=\"center\">{L_FONT_COLOR}</td>\n <!-- ENDIF -->\n</tr>\n<!-- ENDIF -->\";a:1:{s:9:\"after add\";s:70:\"<!-- ENDIF -->\n<!-- MOD : MSSTI ABBC3 (v{S_ABBC3_VERSION}) - End //-->\";}}}s:47:\"styles/subsilver2/template/posting_preview.html\";a:1:{i:0;a:1:{s:138:\" <!-- IF PREVIEW_SIGNATURE --><span id=\"sig\" class=\"postbody\"><br />_________________<br />{PREVIEW_SIGNATURE}</span><!-- ENDIF --></td>\";a:1:{s:12:\"in-line-edit\";a:1:{i:0;a:1:{s:17:\" class=\"postbody\"\";a:1:{s:18:\"in-line-before-add\";a:1:{i:0;s:9:\" id=\"sig\"\";}}}}}}}s:45:\"styles/subsilver2/template/simple_header.html\";a:1:{i:0;a:1:{s:7:\"</head>\";a:1:{s:10:\"before add\";s:212:\"<!-- MOD : MSSTI ABBC3 (v{S_ABBC3_VERSION}) - Start //-->\n<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"{T_IMAGESET_PATH}/abbcode/abbcode.css\" />\n<!-- MOD : MSSTI ABBC3 (v{S_ABBC3_VERSION}) - End //-->\";}}}s:50:\"styles/subsilver2/template/ucp_pm_viewmessage.html\";a:1:{i:0;a:1:{s:84:\" <span id=\"sig\" class=\"postbody\"><br />_________________<br />{SIGNATURE}</span>\";a:1:{s:12:\"in-line-edit\";a:1:{i:0;a:1:{s:17:\" class=\"postbody\"\";a:1:{s:18:\"in-line-before-add\";a:1:{i:0;s:9:\" id=\"sig\"\";}}}}}}}s:46:\"styles/subsilver2/template/ucp_prefs_post.html\";a:1:{i:0;a:1:{s:224:\"<tr>\n <td class=\"cat\" colspan=\"2\" align=\"center\">{S_HIDDEN_FIELDS}<input class=\"btnmain\" type=\"submit\" name=\"submit\" value=\"{L_SUBMIT}\" />&nbsp;&nbsp;<input class=\"btnlite\" type=\"reset\" value=\"{L_RESET}\" name=\"reset\" /></td>\";a:1:{s:10:\"before add\";s:477:\"<!-- MOD : MSSTI ABBC3 (v{S_ABBC3_VERSION}) - Start //-->\n<!-- IF S_ABBC3_MOD and S_ABBC3_UCP_MODE -->\n<tr>\n <th colspan=\"2\">{L_UCP_ABBCODES}</th>\n</tr>\n<tr>\n <td class=\"row1\" width=\"50%\"><b class=\"genmed\">{L_UCP_ABBC3_SETTINGS}:</b><br /><span class=\"gensmall\">{L_UCP_ABBC3_SETTINGS_EXPLAIN}</span></td>\n <td class=\"row2\"><select name=\"abbcode_mod\" id=\"abbcode_mod\">{S_ABBCODE_OPTIONS}</select></td>\n</tr>\n<!-- ENDIF -->\n<!-- MOD : MSSTI ABBC3 (v{S_ABBC3_VERSION}) - End //-->\";}}}s:53:\"styles/subsilver2/template/ucp_profile_signature.html\";a:3:{i:0;a:1:{s:254:\" <td colspan=\"2\"><textarea class=\"post\" id=\"signature\" name=\"signature\" rows=\"10\" cols=\"76\" style=\"width: 90%;\" onselect=\"storeCaret(this);\" onclick=\"storeCaret(this);\" onkeyup=\"storeCaret(this);\" onfocus=\"initInsertions();\">{SIGNATURE}</textarea></td>\";a:1:{s:12:\"in-line-edit\";a:1:{i:0;a:1:{s:17:\" name=\"signature\"\";a:1:{s:18:\"in-line-before-add\";a:1:{i:0;s:15:\" id=\"signature\"\";}}}}}}i:1;a:1:{s:87:\" <!-- IF S_BBCODE_ALLOWED and (not S_ABBC3_COLOR or S_ABBC3_COLOR_MODE eq \'phpbb\') -->\";a:1:{s:12:\"in-line-edit\";a:1:{i:0;a:1:{s:16:\"S_BBCODE_ALLOWED\";a:1:{s:17:\"in-line-after-add\";a:1:{i:0;s:57:\" and (not S_ABBC3_COLOR or S_ABBC3_COLOR_MODE eq \'phpbb\')\";}}}}}}i:2;a:1:{s:114:\" <td class=\"row1\" colspan=\"2\"><div id=\"sig\" class=\"postbody\" style=\"padding: 6px;\">{SIGNATURE_PREVIEW}</div></td>\";a:1:{s:12:\"in-line-edit\";a:1:{i:0;a:1:{s:17:\" class=\"postbody\"\";a:1:{s:18:\"in-line-before-add\";a:1:{i:0;s:9:\" id=\"sig\"\";}}}}}}}s:46:\"styles/subsilver2/template/viewtopic_body.html\";a:1:{i:0;a:1:{s:108:\" <div id=\"sig{postrow.POST_ID}\" class=\"postbody\"><br />_________________<br />{postrow.SIGNATURE}</div>\";a:1:{s:12:\"in-line-edit\";a:1:{i:0;a:1:{s:17:\" class=\"postbody\"\";a:1:{s:18:\"in-line-before-add\";a:1:{i:0;s:26:\" id=\"sig{postrow.POST_ID}\"\";}}}}}}}}s:13:\"PHP_INSTALLER\";s:17:\"install_abbc3.php\";s:16:\"DIY_INSTRUCTIONS\";a:1:{i:0;s:482:\"Once all the files have been modified and uploaded to your site, point your browser to the &quot;install_abbc3.php&quot; script\n(or click the highlighted link above if you are using AutoMOD) and follow the instructions. Once that is complete,\nyou can delete the &quot;install_abbc3.php&quot; script.\n\nYou can configure ABBC3\'s settings in the ACP under the &quot;POSTING&quot; tab. In the left menu you will find the category\n&quot;ADVANCED BBCODE BOX 3&quot; with all its settings.\";}}', '', 'subsilver2', '')

BACKTRACE

FILE: (not given by php)
LINE: (not given by php)
CALL: msg_handler()

FILE: [ROOT]/includes/db/dbal.php
LINE: 754
CALL: trigger_error()

FILE: [ROOT]/includes/db/mysql.php
LINE: 175
CALL: dbal->sql_error()

FILE: [ROOT]/includes/acp/acp_mods.php
LINE: 1262
CALL: dbal_mysql->sql_query()

FILE: [ROOT]/includes/acp/acp_mods.php
LINE: 253
CALL: acp_mods->install()

FILE: [ROOT]/includes/functions_module.php
LINE: 507
CALL: acp_mods->main()

FILE: [ROOT]/adm/index.php
LINE: 74
CALL: p_master->load_active()
by RLHoldenSr
Wed Jun 12, 2013 7:23 pm

Re: Feature Requests, Bugs and others

trefex wrote:One big request I gathered from the previous thread was:

- Parse the BB Code when you edit your profile.
- Parse the BB Code when you work on the memberlist and in Private Messages.

Does anyone still want / require this feature?

--
Trefex


so nice,, ;)

trefex wrote:Some other Suggestion that I will have a look at:

* Add a way to turn this on/off per profile field.
* Add a way to disallow certain bbcodes globally (i.e. if the admin doesn't want users to use links or quote boxes, or certain custom bbcodes)
* Add a permission so that the admin can disable bbcode in profile fields per user


soooo greaat..

i'll wait these.. :roll:


trefex wrote:
Gino wrote:thanks a loot for this gread mod..

but i wonder if there is a way to disallow some bbcodes.. like (images & Links & Flashs list & code & quete)

specially images .. cause when some one put a big image the forum will be deformed ..!
or if there is a possibility to specific image size in custom profile fields.. so users can't put huge images ?


and something else..
by this mod there will be an ability to add a custom profile field called (MOOD) or (SMS) as VB ?


What do you mean VB?

Would it be useful for you to have a "configuration" page where you can select Allow / Disallow for every BBCode that exist?

Let me know,
Cheers,


i mean VBulletin forum..

the features above will be so great..

and there is one thing i need..
you know. avater size assigned by the admin.. and i need something like that to assign image size in custom profile field by Admin..

i need to assign image size to add a custom profile field called (SMS), and this field allow images, but images max size is (150 hight, 150 width) << for example
by Gino
Sun Jun 27, 2010 10:25 am

phpBB Statistics v1.0.2 (NL) Dutch Translation

Modificatie: phpBB Statistics v1.0.2 (NL) Dutch Translation
Laatste Update: 13-2-2011
Vertaald Door: obiewan , Neo

Vertaling:
Open: language/nl/acp/common.php

Zoek:

Code: Select all

?>


Plaats ervoor:

Code: Select all

// phpBB Statistics MOD
$lang = array_merge($lang, array(
   'STATS'                     => 'phpBB Statistieken',   
   'STATS_BASIC'                  => 'Basic statistieken',
   'STATS_BASIC_BASIC'            => 'Basis',
   'STATS_BASIC_ADVANCED'            => 'Geavanceerd',
   'STATS_BASIC_MISCELLANEOUS'      => 'Diverse',
   'STATS_ACTIVITY'               => 'Forum activiteit',
   'STATS_ACTIVITY_FORUMS'         => 'Forums',
   'STATS_ACTIVITY_TOPICS'         => 'Onderwerpen',
   'STATS_ACTIVITY_USERS'            => 'Gebruikers',
   'STATS_CONTRIBUTIONS'            => 'Forum bijdragen',
   'STATS_CONTRIBUTIONS_ATTACHMENTS'   => 'Bijlagen',
   'STATS_CONTRIBUTIONS_POLLS'      => 'Peilingen',
   'STATS_PERIODIC'               => 'Periodieke statistieken',
   'STATS_PERIODIC_DAILY'            => 'Dagelijkse statistieken',
   'STATS_PERIODIC_MONTHLY'         => 'Maandelijkse statistieken',
   'STATS_PERIODIC_HOURLY'         => 'Statistieken per uur',
   'STATS_SETTINGS'               => 'Statistieken instellingen',
   'STATS_SETTINGS_BOARD'            => 'Forum instellingen',
   'STATS_SETTINGS_PROFILE'         => 'Profiel instellingen',
   'STATS_ADDONS'               => 'Add-Ons',
   'STATS_ADDONS_MISCELLANEOUS'      => 'scapegoat', // do not change
   
   'LOG_STATS_CONFIG_SETTINGS'            => '<strong>phpBB Statistieken: Aangepaste Algemene instellingen</strong>',
   'LOG_STATS_CONFIG_ADDONS'            => '<strong>phpBB Statistieken: Aangepaste add-ons Instellingen</strong>',
   'LOG_STATS_ADDON_REMOVED'            => '<strong>phpBB Statistieken: Verwijderd %1$s add-on</strong>',
   'LOG_STATS_ADDON_ENABLED'            => '<strong>phpBB Statistieken: Ingeschakeldd %1$s add-on</strong>',
   'LOG_STATS_ADDON_DISABLED'            => '<strong>phpBB Statistieken: Uitgeschakeld %1$s add-on</strong>',
   
   'FIELD_STATS_SHOW'               => 'Toon dit aangepast profiel veld op het forum Statistieken pagina',
   'FIELD_STATS_SHOW_EXPLAIN'               => 'Wanneer ingeschakeld zal dit aangepaste profielveld te zien zijn als statistiek in de profielinstellingen statistieken op de forum statistieken pagina. Wanneer aangepaste profielvelden zijn uitgeschakeld of verborgen, zullen deze statistieken niet te zien zijn in de statistieken, ook al is de optie hier ingeschakeld.<br />De weergave van de statistieken is afhankelijk van het type data dat dit veld opslaat.',
   
   'acl_u_view_stats'      => array('lang' => 'Kan statistieken bekijken', 'cat' => 'misc'),
));
//END MOD



Daarna kan je dit downloaden, en uitpakken en uploaden naar je webhost in de phpBB-hoofdmap/language/nl/mods/ map:


root/language/nl/mods/stats.php

Code: Select all

<?php
/**
*
* @package phpBB Statistics
* @version $Id: stats.php 146 2010-05-18 22:33:54Z marc1706 $
* @copyright (c) 2009 Marc Alexander(marc1706) www.m-a-styles.de, (c) TheUniqueTiger - Nayan Ghosh
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @based on: Forum Statistics by TheUniqueTiger - Nayan Ghosh
* @translator (c) ( Marc Alexander - http://www.m-a-styles.de ), TheUniqueTiger - Nayan Ghosh
*/

if (!defined('IN_PHPBB'))
{
   exit;
}

if (empty($lang) || !is_array($lang))
{
   $lang = array();
}

$lang = array_merge($lang, array(   
   'STATS'                        => 'phpBB Statistieken',   
   'STATS_EXPLAIN'                  => 'Open phpBB Statistics',
   'STATS_BASIC'                  => 'Basis statistieken',
   'STATS_BASIC_BASIC'               => 'Basis forumstatistieken',
   'STATS_BASIC_ADVANCED'            => 'Uitgebreide forumstatistieken',
   'STATS_BASIC_MISCELLANEOUS'         => 'Diverse statistieken',
   'STATS_ACTIVITY'               => 'Forum activiteit',
   'STATS_ACTIVITY_FORUMS'            => 'Forum statistieken',
   'STATS_ACTIVITY_TOPICS'            => 'Onderwerp statistieken',
   'STATS_ACTIVITY_USERS'            => 'Gebruikers statistieken',
   'STATS_CONTRIBUTIONS'            => 'Forum bijdragen',
   'STATS_CONTRIBUTIONS_ATTACHMENTS'   => 'Bijlagen statistieken',
   'STATS_CONTRIBUTIONS_POLLS'         => 'Poll statistieken',
   'STATS_PERIODIC'               => 'Periodieke statistieken',
   'STATS_PERIODIC_DAILY'            => 'Dagelijkse statistieken',
   'STATS_PERIODIC_MONTHLY'         => 'Maandelijkse statistieken',
   'STATS_PERIODIC_HOURLY'            => 'Statistieken per uur',
   'STATS_SETTINGS'               => 'Instellingen statistieken',
   'STATS_SETTINGS_BOARD'            => 'Forum instellingen statistieken',
   'STATS_SETTINGS_PROFILE'         => 'Profiel instellingen statistieken',
   'STATS_ADDONS'                  => 'Add-Ons',
   'STATS_ADDONS_MISCELLANEOUS'      => 'verberg',
   'STATS_DISABLED'               => 'zijn momenteel uitgeschakeld',
   
   'TOTALS'                     => 'Totalen',
   'OVERALL'                     => 'Algemeen',
   'NONE'                        => 'Geen',
   'LIMIT_PROMPT'                  => 'Aantal van top %s om opgehaald te worden',
   'GB'                        => 'GB',
   'AS_ON'                        => 'Als op %s',   
   'DAMAGED_ADDON'                  => 'De Add-On %1$s is beschadigd. De volgende variabelen bestaan niet: %2$s. Neem contact op met de auteur van de Add-On.',
   'ADDON_DISABLED'               => 'De add-on die u hebt geselecteerd is momenteel uitgeschakeld.<br /><br />',
   'ADDON_DISABLED_TITLE'            => 'Add-On uitgeschakeld',
   'NO_ADDONS'                     => 'Er zijn momenteel geen add-ons geïnstalleerd.<br /><br />',
   'NO_ADDONS_TITLE'               => 'Geen geïnstalleerde add-ons',
   
   //basic stats
   'TOTAL_TOPICS'                  => 'Totaal onderwerpen',
   'TOTAL_USERS'                  => 'Totaal gebruikers',
   'TOTAL_FORUM_CAT'               => 'Totaal forum categoriën',
   'TOTAL_FORUM_POST'               => 'Totaal postforums',
   'TOTAL_FORUM_LINK'               => 'Totaal forumlinks',
   'TOTAL_FORUMS'                  => 'Totaal forums',
   'FORUMS'                     => 'Forums',
   'TOTAL_ATTACHMENTS'               => 'Totaal bijlagen',
   'TOTAL_POLLS'                  => 'Totaal polls',
   'TOTAL_VIEWS'                  => 'Totaal onderwerpen bekeken',
   'TOPICS'                     => 'Onderwerpen',
   'TOPICS_GLOBAL'                  => 'Forummededelingen',
   'TOPICS_ANNOUNCE'               => 'Mededelingen',
   'TOPICS_STICKY'                  => 'Sticky onderwerpen',
   'TOPICS_NORMAL'                  => 'Normale onderwerpen',
   'TOPICS_UNAPPROVED'               => 'Afgekeurde onderwerpen',
   'UNAPPROVED_POSTS'               => 'Afgekeurde berichten',
   'USERS'                        => 'Gebruikers',
   'USERS_INACTIVE'               => 'Inactieve gebruikers',
   'USERS_INACTIVE_EXPLAIN'         => 'Gebruikers die niet actief waren de afgelopen %d dagen',
   'USERS_ACTIVE'                  => 'Actieve gebruikers',
   'USERS_ACTIVE_EXPLAIN'            => 'Gebruikers die minstens 1x online waren de afgelopen %d dagen',
   'USERS_TOTAL_BOTS'               => 'Geregistreerde bots',
   'USERS_VISITED_BOTS'            => 'Bezoekende bots',
   'AVG_FILES_DAY'                  => 'Gemiddeld aantal bijlagen per dag',
   'AVERAGES'                     => 'Gemiddelden',
   //advanced stats
   'BOARD_BACKGROUND'               => 'Forum achtergrond',
   'START_DATE'                  => 'Forum start datum',
   'BOARD_AGE'                     => 'Forum leeftijd',
   'SECOND'                     => 'seconde',
   'MINUTE'                     => 'minuut',
   'HOUR'                        => 'uur',
   'MONTHS'                     => 'maanden',
   'YEARS'                        => 'jaren',
   'BOARD_VERSION'                  => 'Forum versie',
   'GZIP_COMPRESSION'               => 'GZip Compressie',
   'ON'                        => 'Aan',
   'OFF'                        => 'Uit',
   'DATABASE'                     => 'Database',
   'DATABASE_SIZE'                  => 'Database grootte',
   'DATABASE_INFO'                  => 'Database info',
   'FILESYSTEM'                  => 'Bestandssysteem',
   'ATTACHMENTS_TOTAL'               => 'Totaal bijlagen',
   'ATTACHMENTS_SIZE'               => 'Totaal bijlagen grootte',
   'AVATARS_TOTAL'                  => 'Totaal avatars',
   'AVATARS_SIZE'                  => 'Totaal avatars gootte',
   'CACHED_FILES_TOTAL'            => 'Totaal gecachede bestanden',
   'CACHED_FILES_SIZE'               => 'Totaal cache grootte',
   'INSTALLED_COMPONENTS'            => 'Geïnstalleerde componenten',
   'STYLES'                     => 'Stijlen',
   'IMAGESETS'                     => 'Afbeelding sets',
   'TEMPLATES'                     => 'Templates',
   'THEMES'                     => 'Themas',
   'LANG_PACKS'                  => 'Taal pakketten',
   'BY'                        => 'door',
   'BOARD_VERSION_SECURE'            => '3.x.x',
   'SORT_BY_PROMPT'               => 'Sorteer geïnstalleerde componenten informatie door',
   
   // miscellaneous stats
   'SMILEY'                     => 'Smilies',
   'SMILEY_COUNT'                  => 'Smilies geïnstalleerd',
   'SMILEY_POST_COUNT'               => 'Smilies weergegeven op posting',
   'TOP_SMILIES_BY_URL'            => 'Top %d smilies',
   'TOP_BBCODES'                  => 'Top %d bbcodes',
   'TOP_ICONS'                     => 'Top %d onderwerpafbeeldingen',
   'WARNING_COUNT'                  => 'Waarschuwingen',
   'OWN_WARNINGS_COUNT'            => 'Ontvangen waarschuwingen',
   'WARNINGS_PER_USER'               => 'Waarschuwingen per gebruiker',
   'WARNINGS_PER_DAY'               => 'Waarschuwingen per dag',
   'BBCODE'                     => 'BBCodes',
   'BBCODE_COUNT'                  => 'Aantal BBCodes',
   'BBCODE_COUNT_CUSTOM'            => 'Aantal aangepaste BBCodes',
   'ICONS'                        => 'Onderwerpafbeeldingen',
   'COMPONENTS_NAME'               => 'Naam',
   'COMPONENTS_ID'                  => 'ID',
   'COMPONENTS_AUTHOR'               => 'Copyright/Author',
   'RECOUNT_PROGRESS'               => '<br />%1$d van %2$d berichten zijn verwerkt. Gelieve te wachten tot het script klaar is.<br /><br />',
   
   //activity - forums
   'COUNT'                        => 'Aantal',
   'PERCENT'                     => 'Percentage',
   'TOP_FORUMS_BY_TOPICS'            => 'Top %d forums (aantal onderwerpen)',
   'TOP_FORUMS_BY_POSTS'            => 'Top %d forums (aantal berichten)',
   'TOP_FORUMS_BY_POLLS'            => 'Top %d forums (aantal polls)',
   'TOP_FORUMS_BY_STICKY'            => 'Top %d forums (aantal sticky onderwerpen)',
   'TOP_FORUMS_BY_VIEWS'            => 'Top %d forums (aantal x bekeken onderwerpen)',
   'TOP_FORUMS_BY_PARTICIPATION'      => 'Top %d forums (bijdragen onderwerpstarter)',
   'TOP_FORUMS_BY_SUBSCRIPTIONS'      => 'Top %d forums (aantal abbonnementen)',
   //activity - topics
   'TOP_TOPICS_BY_POSTS'            => 'Top %d onderwerpen (aantal berichten)',
   'TOP_TOPICS_BY_POSTS_PCT_EXPLAIN'   => 'Het percentage weergegeven, is het percentage van berichten in dat onderwerp ten opzichte van het totaal aantal berichten.',
   'TOP_TOPICS_BY_POSTS_BAR_EXPLAIN'   => 'De zichtbare balk is ter vergelijking met het onderwerp met het hoogste aantal berichten.',
   'TOP_TOPICS_BY_VIEWS'            => 'Top %d onderwerpen (aantal x bekeken)',
   'TOP_TOPICS_BY_VIEWS_PCT_EXPLAIN'   => 'Het percentage weergegeven, is het percentage van het aantal keren dat een onderwerp is bekeken ten opzichte van het totaal aantal keren dat een onderwerp is bekeken.',
   'TOP_TOPICS_BY_PARTICIPATION'      => 'Top %d onderwerpen (bijdrage onderwerpstarter)',
   'TOP_TOPICS_BY_ATTACHMENTS'         => 'Top %d onderwerpen (aantal bijlagen)',
   'TOP_TOPICS_BY_BOOKMARKS'         => 'Top %d onderwerpen (aantal favorieten)',
   'TOP_TOPICS_BY_SUBSCRIPTIONS'      => 'Top %d onderwerpen (aantal abbonnementen)',
   //activity - users
   'MEMBERS'                     => 'Geregistreerde gebruikers',
   'TOTAL_MEMBERS'                  => 'Totaal geregistreerde gebruikers',
   'TOTAL_REG_USERS'               => 'Totaal geregistreerde gebruikers',
   'MOST_ONLINE'                  => 'Meeste geregistreerde gebruikers online',
   'INCLUDING_BOTS'               => 'inclusief Bots',
   'TOTAL_ONLINE'                  => 'Totaal bezoekers online',
   'ONLINE_ON'                     => 'op',
   'TOTAL_HIDDEN'                  => 'Verborgen gebruikers online',
   'TOTAL_MEMBERS_ONLINE'            => 'Totaal gebruikers online',
   'TOP_USERS_BY_POSTS'            => 'Top %d gebruikers (aantal berichten)',
   'TOP_USERS_BY_TOPICS'            => 'Top %d gebruikers (aantal onderwerpen)',
   'TOP_FRIENDS'                  => 'Top %d vrienden',
   'TOP_FOES'                     => 'Top %d genegeerde gebruikers',
   'TOP_USERS_BY_RECENT_POSTS'         => 'Top %1$d gebruikers (aantal berichten in de laatste %2$d dagen)',
   'RECENT_POSTS_DAYS_LIMIT_PROMPT'   => 'Aantal dagen om in aanmerking te komen voor recente berichten',
   'WHO_IS_ONLINE_EXPLAIN'            => 'gebaseerd op gebruikers actief gedurende de laatste %d minuten',
   'RANKS_POSTS'                  => 'Rangen (gewone rangen, gebaseerd op berichten aantal)',
   'RANKS'                        => 'Rangen',
   'RANK_MIN_POSTS'               => 'Minimum bericht aantal',
   'MEMBER_COUNT'                  => 'Gebruikers aantal',
   'DELETED_USERS'                  => 'Verwijderde gebruikers',
   //contributions - attachments
   'ATTACHMENTS_ORPHAN'            => 'Bijlagen zonder bericht',
   'ATTACHMENTS_ORPHAN_SIZE'         => 'Bijlagen zonder bericht grootte',
   'ATTACHMENTS_OR_USERS'            => 'Bijlagen/forumleden',
   'RECENT_ATTACHMENTS'            => 'Recente %d bijlagen',
   'ATTACH_ON'                     => 'op',
   'ATTACH_DETAILS'               => 'Details',   
   'TOP_ATTACHMENTS_BY_FILETYPE'      => 'Top %d bijlagen bestandstype (extensie)',
   'ATTACHMENT_FILETYPES'            => 'Bijlagen bestandstype',
   'TOP_ATTACHMENTS_BY_FILESIZE'      => 'Top %d bijlagen (bestandsgrootte)',
   'TOP_ATTACHMENTS_BY_DOWNLOAD'      => 'Top %d bijlagen (download aantal)',
   'FILESIZE'                     => 'Bestandsgrootte',
   'TOP_USERS_BY_ATTACHMENTS'         => 'Top %d gebruikers (aantal bijlagen)',
   'TOTAL_DOWNLOADS'               => 'Totaal bestandsdownloads',
   'TOTAL_DOWNLOADS_SIZE'            => 'Totaal downloads grootte',
   //contributions - polls
   'TOTAL_OPEN_POLLS'               => 'Totaal open peilingen',
   'TOTAL_POLL_VOTES'               => 'Total peiling stemmen',
   'RECENT_POLLS'                  => 'Recente %d peilingen',
   'POLLS'                        => 'Peilingen',   
   'TOP_POLLS_BY_VOTES'            => 'Top %d peilingen (aantal stemmen)',
   'TOTAL_POLLS_VOTED'               => 'Totaal aantal peilingen waarin je hebt gestemd',
   'TOTAL_ACCESSIBLE_POLLS'         => 'Aantal toegankelijke peilingen',
   //periodic - daily, monthly
   'PERIODIC_DAY'                  => 'Dag',
   'PERIODIC_MONTH'               => 'Maand',
   'AVG_POSTS_DAY'                  => 'Gemiddeld aantal berichten per dag',   
   'AVG_TOPICS_DAY'               => 'Gemiddeld aantal onderwerpen per dag',
   'AVG_USER_REGS_DAY'               => 'Gemiddeld aantal registraties per dag',
   'AVG_POSTS_MONTH'               => 'Gemiddeld aantal berichten per maand',   
   'AVG_TOPICS_MONTH'               => 'Gemiddeld aantal onderwerpen per maand',
   'AVG_USER_REGS_MONTH'            => 'Gemiddeld aantal registraties per maand',
   'TOTAL_USER_REGS'               => 'Totaal aantal registraties',
   'STATS_MONTH_EXPLAIN'            => 'De volgende statistieken zijn van de maand <strong>%s</strong>',
   'STATS_YEAR_EXPLAIN'            => 'De volgende statistieken zijn van het jaar <strong>%s</strong>',
   'USER_REGS'                     => 'Registraties',
   'SHOW_STATS_FOR_MONTH'            => 'Laat statistieken zien van de geselcteerde maand',
   'SHOW_STATS_FOR_YEAR'            => 'Laat statistieken zien van het geselcteerde jaar',
   'ALL'                        => 'Alle',
   //periodic- hourly
   'SELECT_TIME_PERIOD'            => 'Selecteer de tijdsperiode',
   'PERCENT_OF_TOTAL'               => '%% van totale forum %s',
   'PERIODIC_HOUR'                  => 'Uur',
   'HOURLY_STATS_EXPLAIN'            => 'Statistieken van  <strong>%s</strong>',
   //settings - board
   'OVERRIDE_STYLE_EXPLAIN'         => 'De administrator heeft de stijlkeuze van de gebruikers overschreven.',
   'DEFAULT_STYLE_EXPLAIN'            => 'De standaardstijl is <strong>%1$s (%2$s)</strong> dit is de stijl die de anderen overschrijft(inclusief voor bots).',
   'STYLE'                        => 'Stijl',
   'USERS_INCL_BOTS'               => 'Gebruikers die deze stijl gebruiken (inclusief bots)',
   'LANGUAGES_BY_USERS'            => 'Talen (forumleden die de taal gebruiken)',
   'LANGUAGE'                     => 'Taal',
   'TIMEZONES_BY_USERS'             => 'Tijdzones (gebruikers die deze tijdzone gebruiken)',
   'TIMEZONE'                     => 'Tijdzone',
   'LEGEND_BOLD_ITALIC'            => 'Het element wat te zien is in dikke letters het maximum van die groep. Het element wat je cursief ziet is de groep waar jij toe behoort.',
   'SINGLE_LANG_EXPLAIN'            => 'Er is 1 taalpakket geïnstalleerd, die door alle forumleden gebruikt wordt.',
   'DEFAULT_LANG_EXPLAIN'            => 'Het standaard taalpakket is <strong>%1$s (%2$s)</strong>.',
   //settings - profile
   'AGE_RANGES'                  => 'Aantal gebruikers naar leeftijd',
   'AGE_RANGE'                     => 'Leeftijdsbereik',
   'SEL_AGE_INTERVAL_PROMPT'         => 'Selecteer het leeftijdsbereik',
   'USERS_WITH_BIRTHDAY'            => 'Gebruikers die hun verjaardag hebben ingegeven',
   'USERS_WITH_LOCATION'            => 'Gebruikers die hun woonplaats hebben ingegeven',
   'USER_LOCATIONS'               => 'Woonplaats',
   'TOP_USER_LOCATIONS'            => 'Top %d woonplaatsen',
   'CUSTOM_PROFILE_FIELD'            => 'Aangepast profielveld',
   'CPF_TOP_X'                     => 'Top %1$d %2$s',
   'TOTAL_VALUES_SET_PROMPT'         => 'Aantal gebruikers die hebben ingegeven %s',
   'DEFAULT'                     => 'Standaard',
   
   // viewonline
   'VIEWING_STATS'                  => 'Bekijkt phpBB Statistieken',
   
   // Error message
   'STATS_NOT_ENABLED'               => 'phpBB Statistieken zijn momenteel uitgeschakeld.',
));
?>



root/language/nl/mods/lang_stats_acp.php

Code: Select all

<?php
/**
*
* @package phpBB Statistics
* @version $Id: lang_stats_acp.php 141 2010-05-07 18:01:31Z marc1706 $
* @copyright (c) 2009 Marc Alexander(marc1706) www.m-a-styles.de
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @based on: lang_portal_acp.php included in the Board3 Portal package (www.board3.de)
* @translator (c) ( Marc Alexander - http://www.m-a-styles.de )
*/

if (!defined('IN_PHPBB'))
{
   exit;
}
if (empty($lang) || !is_array($lang))
{
   $lang = array();
}

// DEVELOPERS PLEASE NOTE
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine


$lang = array_merge($lang, array(
   'ACP_STATS_VERSION'                     => '<strong>phpBB Statistieken v%s</strong>',
   // General
   'ACP_STATS_GENERAL_INFO'                => 'phpBB Statistieken administratie',
   'ACP_STATS_GENERAL_INFO_EXPLAIN'         => 'Bedankt voor het kiezen van phpBB Statistieken.',
   'ACP_STATS_GENERAL_SETTINGS'             => 'Algemene instellingen',
   'ACP_STATS_GENERAL_SETTINGS_EXPLAIN'      => 'Op deze pagina kan je de instellingen beheren van de gehele statistieken MOD',
   'ACP_STATS_ENABLE'                     => 'Statistieken inschakelen',
   'ACP_STATS_ENABLE_EXPLAIN'               => 'Het in of uitschakelen van de statistieken',
   'ACP_BASIC_BASIC_ENABLE'               => 'Basis statistieken inschakelen',
   'ACP_BASIC_BASIC_ENABLE_EXPLAIN'         => 'In of uitschakelen van de basis statistieken',
   'ACP_BASIC_ADVANCED_ENABLE'               => 'Geavanceerde statistieken inschakelen',
   'ACP_BASIC_ADVANCED_ENABLE_EXPLAIN'         => 'In of uitschakelen van de geavanceerde statistieken',
   'ACP_BASIC_MISCELLANEOUS_ENABLE'         => 'Diverse statistieken inschakelen',
   'ACP_BASIC_MISCELLANEOUS_ENABLE_EXPLAIN'   => 'In of uitschakelen van diverse statistieken',
   'ACP_ACTIVITY_FORUMS_ENABLE'            => 'Inschakelen forum activiteit statistieken',
   'ACP_ACTIVITY_FORUMS_ENABLE_EXPLAIN'      => 'In of uitschakelen van forum activiteit statistieken',
   'ACP_ACTIVITY_TOPICS_ENABLE'            => 'Inschakelen onderwerp activiteit statistieken',
   'ACP_ACTIVITY_TOPICS_ENABLE_EXPLAIN'      => 'In of uitschakelen van onderwerp activiteit statistieken',
   'ACP_ACTIVITY_USERS_ENABLE'               => 'Inschakelen gebruikers actviteit statistieken',
   'ACP_ACTIVITY_USERS_ENABLE_EXPLAIN'         => 'In of uitschakelen van gebruikers activiteit statistieken',
   'ACP_CONTRIBUTIONS_ATTACHMENTS_ENABLE'       => 'Inschakelen bijlagen statistieken',
   'ACP_CONTRIBUTIONS_ATTACHMENTS_ENABLE_EXPLAIN' => 'In of uitschakelen van bijlagen statistieken',
   'ACP_CONTRIBUTIONS_POLLS_ENABLE'         => 'Inschakelen poll statistieken',
   'ACP_CONTRIBUTIONS_POLLS_ENABLE_EXPLAIN'   => 'In of uitschakelen van poll statistieken',
   'ACP_PERIODIC_DAILY_ENABLE'               => 'Inschakelen dagelijkse statistieken',
   'ACP_PERIODIC_DAILY_ENABLE_EXPLAIN'         => 'In of uitschakelen van dagelijkse statistieken',
   'ACP_PERIODIC_MONTHLY_ENABLE'            => 'Inschakelen maandelijkse statistieken',
   'ACP_PERIODIC_MONTHLY_ENABLE_EXPLAIN'      => 'In of uitschakelen van maandelijkse statistieken',
   'ACP_PERIODIC_HOURLY_ENABLE'            => 'Inschakelen statistieken per uur',
   'ACP_PERIODIC_HOURLY_ENABLE_EXPLAIN'      => 'In of uitschakelen van statistieken per uur',
   'ACP_SETTINGS_BOARD_ENABLE'               => 'Inschakelen forum instellingen statistieken',
   'ACP_SETTINGS_BOARD_ENABLE_EXPLAIN'         => 'In of uitschakelen van forum instellingen statistieken',
   'ACP_SETTINGS_PROFILE_ENABLE'            => 'Inschakelen profiel instellingen statistieken',
   'ACP_SETTINGS_PROFILE_ENABLE_EXPLAIN'      => 'In of uitschakelen van profiel instellingen statistieken',
   
   // Advanced Stats
   'ACP_BASIC_ADVANCED_INFO'               => 'Geavanceerde statistieken',
   'ACP_BASIC_ADVANCED_INFO_EXPLAIN'         => 'Hier kan je de instellingen van de geavanceerde statistieken beheren',
   'ACP_BASIC_ADVANCED_SETTINGS'            => 'Geavanceerde statistieken instellingen',
   'ACP_BASIC_ADVANCED_SECURITY'            => 'Veilige geavanceerde statistieken instellingen',
   'ACP_BASIC_ADVANCED_SECURITY_EXPLAIN'      => 'phpBB versie en database informatie worden NIET weergegeven wanneer ingeschakeld',
   'ACP_BASIC_ADVANCED_PRETEND'            => 'Doe net alsof de laatste phpBB versie is geïnstalleerd',
   'ACP_BASIC_ADVANCED_PRETEND_EXPLAIN'      => 'De geavanceerde statistieken doen net alsof de laatste phpBB versie is geïnstalleerd. <br /><strong>NOOT:</strong> Dit werkt alleen als de veilige geavanceerde statistieken zijn UIT geschakeld. Ook als de versie controle van phpBB niet werkt, zal deze functie het ook niet doen.',
   
   // Miscellaneous Stats
   'ACP_BASIC_MISCELLANEOUS_INFO'            => 'Diverse statistieken',
   'ACP_BASIC_MISCELLANEOUS_INFO_EXPLAIN'      => 'Hier kan je de instellingen van de diverse statistieken beheren',
   'ACP_BASIC_MISCELLANEOUS_SETTINGS'         => 'Diverse statistieken instellingen',
   'ACP_BASIC_MISCELLANEOUS_WARNINGS'         => 'Verberg waarschuwingen statistieken',
   'ACP_BASIC_MISCELLANEOUS_WARNINGS_EXPLAIN'   => 'Wanneer ingeschakeld zullen de waarschuwingsstatistieken niet worden weergegeven',
   'ACP_BASIC_MISCELLANEOUS_BBCODES'         => 'Tel opnieuw de BBCodes en smilies',
   'ACP_BASIC_MISCELLANEOUS_BBCODES_EXPLAIN'   => 'Zet op JA als je nieuwe hebt toegevoegd of wijzigingen hebt aangebracht of als het aantal op een of andere manier niet meer klopt. Deze functie schakelt zich automatisch uit, zodra de hertelling gereed is.',
   
   // Users Activity Stats
   'ACP_ACTIVITY_USERS_INFO'            => 'Gebruikers activiteit statistieken',
   'ACP_ACTIVITY_USERS_INFO_EXPLAIN'      => 'Hier kan je de instellingen van de gebruikers activiteit statistieken beheren',
   'ACP_ACTIVITY_USERS_SETTINGS'         => 'Gebruikers activiteiten statistieken instellingen',
   'ACP_ACTIVITY_USERS_HIDE_ANONYMOUS'         => 'Verberg gasten van de top XX gebruikers statistieken',
   'ACP_ACTIVITY_USERS_HIDE_ANONYMOUS_EXPLAIN' => 'Wanneer ingeschakeld zullen gasten niet worden meegenomen in de statistieken',
   
   // Add-Ons
   'INSTALLED_ADDONS'                  => 'Geïnstalleerde add-ons',
   'UNINSTALLED_ADDONS'               => 'Verwijderde Add-Ons',

   ));

?>


root/language/nl/mods/install_stats.php

Code: Select all

<?php
/**
*
* @package phpBB Statistics
* @version $Id: install_stats.php 146 2010-05-18 22:33:54Z marc1706 $
* @copyright (c) 2009 Marc Alexander(marc1706) http://www.m-a-styles.de
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @based on: Board3 Portal Installer (http://www.board3.de)
*/

/**
* DO NOT CHANGE
*/
if (!defined('IN_PHPBB'))
{
   exit;
}

if (empty($lang) || !is_array($lang))
{
   $lang = array();
}

$lang = array_merge($lang, array(
   'INSTALL_CONGRATS_EXPLAIN'      =>    '<p>Je hebt phpBB statistieken succesvol geïnstalleerd v%s<br/><br/><strong>Verwijder, verplaats of hernoem de "install"-map. Zo lang deze map nog in de root directory staat, heb je alleen toegang tot het beheerderspaneel.</strong></p>',
   'INSTALL_INTRO_BODY'         =>    'Dit installatiesysteem zal je door de installatie van phpBB Statistieken op jouw forum leiden.',

   'MISSING_CONSTANTS'         =>    'Voordat je het installatiescript uitvoert, moet je eerst je bestandswijzigingen uitvoeren en uploaden, voornamelijk /includes/constants.php.',
   'MODULES_CREATE_PARENT'      =>    'Creëer standaard hoofdmodule',
   'MODULES_PARENT_SELECT'      =>    'Selecteer hoofdmodule',
   'MODULES_SELECT_4ACP'      =>    'Hoofdmodule voor het beheerderspaneel',
   'MODULES_SELECT_NONE'      =>    'Geen hoofdmodule',

   'STAGE_ADVANCED_EXPLAIN'        =>  'De phpBB Statistieken modules worden nu gecreëerd.',
   'STAGE_CREATE_TABLE_EXPLAIN'   =>    'De phpBB Statistieken database tabellen zijn aangemaakt en worden met de basiswaarden gevuld. Ga verder met de volgende stap om de installatie van phpBB Statistieken te vervolgen.',
   'STAGE_ADVANCED_IN_PROGRESS'   =>    'De BBCode en smilies in je berichten worden geteld. Dit kan een tijdje duren en de pagina wordt vernieuwd zichzelf iedere 5 seconden. <br /> Wees geduldig en laat het script zijn taak voltooien.',
   'STAGE_ADVANCED_SUCCESSFUL'      =>    'De phpBB Statistieken modules zijn gecreëerd. Ga verder om de installatie van phpBB Statistieken te voltooien.',
   'STAGE_UNINSTALL'            =>    'De-installeren',

   'FILES_EXISTS'            =>    'Bestand bestaat reeds',
   'FILES_OUTDATED'         =>    'Verouderde bestanden',
   'FILES_OUTDATED_EXPLAIN'   =>    '<strong>Verouderde bestanden</strong> - Verwijder deze bestanden om een veiligheidsrisico te voorkomen.',
   'FILES_CHANGE'            =>    'bestand is gewijzigd in de huidige versie',
   'FILES_CHANGED'            =>    'Gewijzigde bestanden',
   'FILES_CHANGED_EXPLAIN'   =>    '<strong>Gewijzigde bestanden</strong> - Zorg ervoor dat je de gewijzigde bestanden kopieert naar je forum.',
   'REQUIREMENTS_EXPLAIN'      =>    'Verwijder alle verouderde bestanden vóór je verder gaat met updaten.',
   'NOT_REQUIREMENTS_EXPLAIN'   =>    'Geen verouderde bestanden gevonden, je kunt verder gaan met updaten.',

   'UPDATE_INSTALLATION'         =>    'phpBB Statistieken updaten',
   'UPDATE_INSTALLATION_EXPLAIN'   =>    'Met deze optie kan je je phpBB Statistieken updaten naar de huidige versie.',
   'UPDATE_CONGRATS_EXPLAIN'      =>    '<p>Je hebt phpBB Statistieken succesvol geüpdate naar v%s<br/><br/><strong>Verwijder, verplaats of hernoem de "install"-map. Zo lang deze map nog in de root directory staat, heb je alleen toegang tot het beheerderspaneel.</strong></p>',

   'UNINSTALL_INTRO'            =>    'Welkom bij de-installatie',
   'UNINSTALL_INTRO_BODY'         =>    'Dit de-installatiesysteem zal je door de de-installatie van phpBB Statistieken leiden.',
   'CAT_UNINSTALL'               =>    'De-installeer',
   'UNINSTALL_CONGRATS'         =>    '<h1>phpBB Statistieken verwijderd.</h1>
                           Je hebt met succes phpBB Statistieken Gede-installeerd.',
   'UNINSTALL_CONGRATS_EXPLAIN'   =>    '<strong>Verwijder, verplaats of hernoem de "install"-map. Zo lang deze map nog in de root directory staat, heb je alleen toegang tot het beheerderspanee.<br /><br />Verwijder alle phpBB statistieken gerelateerde bestanden en verwijder alle wijzigingen in de standaard phpBB bestanden.</strong></p>',

   'SUPPORT_BODY'      =>    'Ondersteuning voor de laatste versie van phpBB Statistieken voor:</p><ul><li>Installatie</li><li>Technische vragen</li><li>Mod-gerelateerde problemen</li><li>Updaten van phpBB Statistieken, Betas of de laatste versie van phpBB Statistieken</li></ul><p>Je kunt ondersteuning vinden in de volgende forums:</p><ul><li><a href="http://www.m-a-styles.de/">M-A-Styles - Homepage of Marc Alexander (marc1706) - MOD author</a></li><li><a href="http://www.phpbb.de/">phpbb.de</a></li><li><a href="http://www.phpbb.com/">phpbb.com</a></li></ul><p>',
   'GOTO_INDEX'      =>    'Ga verder naar het forum',
   'GOTO_STATS'      =>    'Ga verder naar phpBB Statistieken',
   'UNSUPPORTED_DB'   =>   'Sorry, niet-ondersteunde Databases gevonden',
   'UNSUPPORTED_VERSION' => 'Sorry, niet-ondersteunde versie gevonden',
));

?>


root/language/nl/mods/info_acp_stats.php

Code: Select all

<?php
/**
*
* @package phpBB Statistics
* @version $Id: info_acp_stats.php 107 2010-04-03 21:00:46Z marc1706 $
* @copyright (c) 2009 Marc Alexander(marc1706) www.m-a-styles.de
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @based on: info_acp_portal.php included in the Board3 Portal package (www.board3.de)
* @translator (c) ( Marc Alexander - http://www.m-a-styles.de )
*/


if (!defined('IN_PHPBB'))
{
   exit;
}
if (empty($lang) || !is_array($lang))
{
   $lang = array();
}

$lang = array_merge($lang, array(
   'ACP_STATS_INFO'                     => 'phpBB statistieken',
   'ACP_STATS_GENERAL_INFO'               => 'Algemene instellingen',
   'ACP_STATS_ADDONS'                     => 'Add-Ons',
));

?>


root/language/nl/mods/stats_addons/stats_test.php

Code: Select all

<?php
/**
*
* @package phpBB Statistics
* @version $Id: stats_test.php 96 2010-02-21 14:47:13Z marc1706 $
* @copyright (c) 2009 Marc Alexander(marc1706) www.m-a-styles.de, (c) TheUniqueTiger - Nayan Ghosh
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @based on: Forum Statistics by TheUniqueTiger - Nayan Ghosh
* @translator (c) ( Marc Alexander - http://www.m-a-styles.de ), TheUniqueTiger - Nayan Ghosh
*/

if (!defined('IN_PHPBB') || !defined('IN_STATS_MOD'))
{
   exit;
}

if (empty($lang) || !is_array($lang))
{
   $lang = array();
}


/*   Example:
$lang = array_merge($lang, array(   
   'STATS'                        => 'phpBB Statistics',   

));
*/

$lang = array_merge($lang, array(   
   'STATS_TEST'            => 'Test',
   'STATS_TEST_EXPLAIN'      => 'Dit is slechts een test add-on',
   'STATS_TEST_SHOW'         => 'Toon test add-on (doet niets)',
   'STATS_TEST_SHOW_EXPLAIN'    => 'Dit is echt niet iets doen',
   'INFO'                  => 'Deze add-on is alleen voor testdoeleinden. Je kunt deze verwijderen als je al een add-on hebt toegevoegd.',
));
?>
by Neo
Sun Feb 13, 2011 6:59 pm

unexpected $end in acp_board.php?

Hello, running 1thank style and MOD appeared to have installed correctly, except I can't access some areas of my ACP now. This is the message I'm receiving:

Parse error: syntax error, unexpected $end in /home/habunit1/public_html/forum/includes/acp/acp_board.php on line 991

Ideas? Attaching code for acp_board.php here:

Code: Select all

<?php
/**
*
* @package acp
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
* @todo add cron intervals to server settings? (database_gc, queue_interval, session_gc, search_gc, cache_gc, warnings_gc)
*/

/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
   exit;
}

/**
* @package acp
*/
class acp_board
{
   var $u_action;
   var $new_config = array();

   function main($id, $mode)
   {
      global $db, $user, $auth, $template;
      global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
      global $cache;

      $user->add_lang('acp/board');
$user->add_lang('mods/reimg');

      $action   = request_var('action', '');
      $submit = (isset($_POST['submit']) || isset($_POST['allow_quick_reply_enable'])) ? true : false;

      $form_key = 'acp_board';
      add_form_key($form_key);

      /**
      *   Validation types are:
      *      string, int, bool,
      *      script_path (absolute path in url - beginning with / and no trailing slash),
      *      rpath (relative), rwpath (realtive, writable), path (relative path, but able to escape the root), wpath (writable)
      */
      switch ($mode)
      {
         case 'settings':
            $display_vars = array(
               'title'   => 'ACP_BOARD_SETTINGS',
               'vars'   => array(
                  'legend1'            => 'ACP_BOARD_SETTINGS',
                  'sitename'            => array('lang' => 'SITE_NAME',            'validate' => 'string',   'type' => 'text:40:255', 'explain' => false),
                  'site_desc'            => array('lang' => 'SITE_DESC',            'validate' => 'string',   'type' => 'text:40:255', 'explain' => false),
                  'board_disable'         => array('lang' => 'DISABLE_BOARD',         'validate' => 'bool',   'type' => 'custom', 'method' => 'board_disable', 'explain' => true),
                  'board_disable_msg'      => false,
                  'default_lang'         => array('lang' => 'DEFAULT_LANGUAGE',      'validate' => 'lang',   'type' => 'select', 'function' => 'language_select', 'params' => array('{CONFIG_VALUE}'), 'explain' => false),
                  'default_dateformat'   => array('lang' => 'DEFAULT_DATE_FORMAT',   'validate' => 'string',   'type' => 'custom', 'method' => 'dateformat_select', 'explain' => true),
                  'board_timezone'      => array('lang' => 'SYSTEM_TIMEZONE',      'validate' => 'string',   'type' => 'select', 'function' => 'tz_select', 'params' => array('{CONFIG_VALUE}', 1), 'explain' => false),
                  'board_dst'            => array('lang' => 'SYSTEM_DST',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'default_style'         => array('lang' => 'DEFAULT_STYLE',         'validate' => 'int',   'type' => 'select', 'function' => 'style_select', 'params' => array('{CONFIG_VALUE}', false), 'explain' => false),
                  'override_user_style'   => array('lang' => 'OVERRIDE_STYLE',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),

                  'legend2'            => 'WARNINGS',
                  'warnings_expire_days'   => array('lang' => 'WARNINGS_EXPIRE',      'validate' => 'int',   'type' => 'text:3:4', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),

                  'legend3'               => 'ACP_SUBMIT_CHANGES',
               )
            );
         break;

         case 'features':
            $display_vars = array(
               'title'   => 'ACP_BOARD_FEATURES',
               'vars'   => array(
                  'legend1'            => 'ACP_BOARD_FEATURES',
                  'allow_privmsg'         => array('lang' => 'BOARD_PM',            'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_topic_notify'   => array('lang' => 'ALLOW_TOPIC_NOTIFY',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_forum_notify'   => array('lang' => 'ALLOW_FORUM_NOTIFY',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_namechange'      => array('lang' => 'ALLOW_NAME_CHANGE',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_attachments'      => array('lang' => 'ALLOW_ATTACHMENTS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_pm_attach'      => array('lang' => 'ALLOW_PM_ATTACHMENTS',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_pm_report'      => array('lang' => 'ALLOW_PM_REPORT',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_bbcode'         => array('lang' => 'ALLOW_BBCODE',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_smilies'         => array('lang' => 'ALLOW_SMILIES',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_sig'            => array('lang' => 'ALLOW_SIG',            'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_nocensors'      => array('lang' => 'ALLOW_NO_CENSORS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_bookmarks'      => array('lang' => 'ALLOW_BOOKMARKS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_birthdays'      => array('lang' => 'ALLOW_BIRTHDAYS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_quick_reply'      => array('lang' => 'ALLOW_QUICK_REPLY',      'validate' => 'bool',   'type' => 'custom', 'method' => 'quick_reply', 'explain' => true),

                  'legend2'            => 'ACP_LOAD_SETTINGS',
                  'load_birthdays'      => array('lang' => 'YES_BIRTHDAYS',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'load_moderators'      => array('lang' => 'YES_MODERATORS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'load_jumpbox'         => array('lang' => 'YES_JUMPBOX',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'load_cpf_memberlist'   => array('lang' => 'LOAD_CPF_MEMBERLIST',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'load_cpf_viewprofile'   => array('lang' => 'LOAD_CPF_VIEWPROFILE',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'load_cpf_viewtopic'   => array('lang' => 'LOAD_CPF_VIEWTOPIC',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),

                  'legend3'               => 'ACP_SUBMIT_CHANGES',
               )
            );
         break;

         case 'avatar':
            $display_vars = array(
               'title'   => 'ACP_AVATAR_SETTINGS',
               'vars'   => array(
                  'legend1'            => 'ACP_AVATAR_SETTINGS',

                  'avatar_min_width'      => array('lang' => 'MIN_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,),
                  'avatar_min_height'      => array('lang' => 'MIN_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,),
                  'avatar_max_width'      => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,),
                  'avatar_max_height'      => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,),

                  'allow_avatar'         => array('lang' => 'ALLOW_AVATARS',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_avatar_local'   => array('lang' => 'ALLOW_LOCAL',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_avatar_remote'   => array('lang' => 'ALLOW_REMOTE',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_avatar_upload'   => array('lang' => 'ALLOW_UPLOAD',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_avatar_remote_upload'=> array('lang' => 'ALLOW_REMOTE_UPLOAD', 'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'avatar_filesize'      => array('lang' => 'MAX_FILESIZE',         'validate' => 'int:0',   'type' => 'text:4:10', 'explain' => true, 'append' => ' ' . $user->lang['BYTES']),
                  'avatar_min'         => array('lang' => 'MIN_AVATAR_SIZE',      'validate' => 'int:0',   'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
                  'avatar_max'         => array('lang' => 'MAX_AVATAR_SIZE',      'validate' => 'int:0',   'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
                  'avatar_path'         => array('lang' => 'AVATAR_STORAGE_PATH',   'validate' => 'rwpath',   'type' => 'text:20:255', 'explain' => true),
                  'avatar_gallery_path'   => array('lang' => 'AVATAR_GALLERY_PATH',   'validate' => 'rpath',   'type' => 'text:20:255', 'explain' => true)
               )
            );
         break;

         case 'message':
            $display_vars = array(
               'title'   => 'ACP_MESSAGE_SETTINGS',
               'lang'   => 'ucp',
               'vars'   => array(
                  'legend1'            => 'GENERAL_SETTINGS',
                  'allow_privmsg'         => array('lang' => 'BOARD_PM',            'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'pm_max_boxes'         => array('lang' => 'BOXES_MAX',            'validate' => 'int:0',   'type' => 'text:4:4', 'explain' => true),
                  'pm_max_msgs'         => array('lang' => 'BOXES_LIMIT',         'validate' => 'int:0',   'type' => 'text:4:4', 'explain' => true),
                  'full_folder_action'   => array('lang' => 'FULL_FOLDER_ACTION',   'validate' => 'int',   'type' => 'select', 'method' => 'full_folder_select', 'explain' => true),
                  'pm_edit_time'         => array('lang' => 'PM_EDIT_TIME',         'validate' => 'int:0',   'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),
                  'pm_max_recipients'      => array('lang' => 'PM_MAX_RECIPIENTS',      'validate' => 'int:0',   'type' => 'text:5:5', 'explain' => true),

                  'legend2'            => 'GENERAL_OPTIONS',
                  'allow_mass_pm'         => array('lang' => 'ALLOW_MASS_PM',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'auth_bbcode_pm'      => array('lang' => 'ALLOW_BBCODE_PM',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'auth_smilies_pm'      => array('lang' => 'ALLOW_SMILIES_PM',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_pm_attach'      => array('lang' => 'ALLOW_PM_ATTACHMENTS',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_sig_pm'         => array('lang' => 'ALLOW_SIG_PM',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'print_pm'            => array('lang' => 'ALLOW_PRINT_PM',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'forward_pm'         => array('lang' => 'ALLOW_FORWARD_PM',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'auth_img_pm'         => array('lang' => 'ALLOW_IMG_PM',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'auth_flash_pm'         => array('lang' => 'ALLOW_FLASH_PM',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'enable_pm_icons'      => array('lang' => 'ENABLE_PM_ICONS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),

                  'legend3'               => 'ACP_SUBMIT_CHANGES',
               )
            );
         break;

         case 'post':
            $display_vars = array(
               'title'   => 'ACP_POST_SETTINGS',
               'vars'   => array(
                  'legend1'            => 'GENERAL_OPTIONS',
                  'allow_topic_notify'   => array('lang' => 'ALLOW_TOPIC_NOTIFY',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_forum_notify'   => array('lang' => 'ALLOW_FORUM_NOTIFY',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_bbcode'         => array('lang' => 'ALLOW_BBCODE',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_post_flash'      => array('lang' => 'ALLOW_POST_FLASH',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_smilies'         => array('lang' => 'ALLOW_SMILIES',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_post_links'      => array('lang' => 'ALLOW_POST_LINKS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_nocensors'      => array('lang' => 'ALLOW_NO_CENSORS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_bookmarks'      => array('lang' => 'ALLOW_BOOKMARKS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'enable_post_confirm'   => array('lang' => 'VISUAL_CONFIRM_POST',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_quick_reply'      => array('lang' => 'ALLOW_QUICK_REPLY',      'validate' => 'bool',   'type' => 'custom', 'method' => 'quick_reply', 'explain' => true),

                  'legend2'            => 'POSTING',
                  'bump_type'            => false,
                  'edit_time'            => array('lang' => 'EDIT_TIME',            'validate' => 'int:0',      'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),
                  'delete_time'         => array('lang' => 'DELETE_TIME',         'validate' => 'int:0',      'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),
                  'display_last_edited'   => array('lang' => 'DISPLAY_LAST_EDITED',   'validate' => 'bool',      'type' => 'radio:yes_no', 'explain' => true),
                  'flood_interval'      => array('lang' => 'FLOOD_INTERVAL',      'validate' => 'int:0',      'type' => 'text:3:10', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
                  'bump_interval'         => array('lang' => 'BUMP_INTERVAL',         'validate' => 'int:0',      'type' => 'custom', 'method' => 'bump_interval', 'explain' => true),
                  'topics_per_page'      => array('lang' => 'TOPICS_PER_PAGE',      'validate' => 'int:1',      'type' => 'text:3:4', 'explain' => false),
                  'posts_per_page'      => array('lang' => 'POSTS_PER_PAGE',      'validate' => 'int:1',      'type' => 'text:3:4', 'explain' => false),
                  'smilies_per_page'      => array('lang' => 'SMILIES_PER_PAGE',      'validate' => 'int:1',      'type' => 'text:3:4', 'explain' => false),
                  'hot_threshold'         => array('lang' => 'HOT_THRESHOLD',         'validate' => 'int:0',      'type' => 'text:3:4', 'explain' => true),
                  'max_poll_options'      => array('lang' => 'MAX_POLL_OPTIONS',      'validate' => 'int:2:127',   'type' => 'text:4:4', 'explain' => false),
                  'max_post_chars'      => array('lang' => 'CHAR_LIMIT',         'validate' => 'int:0',      'type' => 'text:4:6', 'explain' => true),
                  'min_post_chars'      => array('lang' => 'MIN_CHAR_LIMIT',      'validate' => 'int:0',      'type' => 'text:4:6', 'explain' => true),
                  'max_post_smilies'      => array('lang' => 'SMILIES_LIMIT',         'validate' => 'int:0',      'type' => 'text:4:4', 'explain' => true),
                  'max_post_urls'         => array('lang' => 'MAX_POST_URLS',         'validate' => 'int:0',      'type' => 'text:5:4', 'explain' => true),
                  'max_post_font_size'   => array('lang' => 'MAX_POST_FONT_SIZE',   'validate' => 'int:0',      'type' => 'text:5:4', 'explain' => true, 'append' => ' %'),
                  'max_quote_depth'      => array('lang' => 'QUOTE_DEPTH_LIMIT',      'validate' => 'int:0',      'type' => 'text:4:4', 'explain' => true),
                  'max_post_img_width'   => array('lang' => 'MAX_POST_IMG_WIDTH',   'validate' => 'int:0',      'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
                  'max_post_img_height'   => array('lang' => 'MAX_POST_IMG_HEIGHT',   'validate' => 'int:0',      'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
'legend_reimg' => 'REIMG_SETTINGS', 'reimg_max_width' => array('lang' => 'REIMG_MAX_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false), 'reimg_max_height' => array('lang' => 'REIMG_MAX_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false), 'reimg_max' => array('lang' => 'REIMG_MAX_SIZE', 'validate' => 'int:0', 'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), 'reimg_rel_width' => array('lang' => 'REIMG_REL_WIDTH', 'validate' => 'int:0', 'type' => 'text:3:4', 'explain' => true, 'append' => ' %'), 'reimg_swap_portrait' => array('lang' => 'REIMG_SWAP_PORTRAIT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'reimg_ignore_sig_img' => array('lang' => 'REIMG_IGNORE_SIG_IMG', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'reimg_link' => array('lang' => 'REIMG_LINK_METHOD', 'validate' => 'string', 'type' => 'select', 'method' => 'select_reimg_link_method', 'explain' => true), 'reimg_zoom' => array('lang' => 'REIMG_ZOOM_METHOD', 'validate' => 'string', 'type' => 'select', 'method' => 'select_reimg_zoom_method', 'explain' => true),

                  'legend3'               => 'ACP_SUBMIT_CHANGES',
               )
            );
         break;

         case 'signature':
            $display_vars = array(
               'title'   => 'ACP_SIGNATURE_SETTINGS',
               'vars'   => array(
                  'legend1'            => 'GENERAL_OPTIONS',
                  'allow_sig'            => array('lang' => 'ALLOW_SIG',            'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_sig_bbcode'      => array('lang' => 'ALLOW_SIG_BBCODE',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_sig_img'         => array('lang' => 'ALLOW_SIG_IMG',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_sig_flash'      => array('lang' => 'ALLOW_SIG_FLASH',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_sig_smilies'      => array('lang' => 'ALLOW_SIG_SMILIES',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_sig_links'      => array('lang' => 'ALLOW_SIG_LINKS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),

                  'legend2'            => 'GENERAL_SETTINGS',
                  'max_sig_chars'         => array('lang' => 'MAX_SIG_LENGTH',      'validate' => 'int:0',   'type' => 'text:5:4', 'explain' => true),
                  'max_sig_urls'         => array('lang' => 'MAX_SIG_URLS',         'validate' => 'int:0',   'type' => 'text:5:4', 'explain' => true),
                  'max_sig_font_size'      => array('lang' => 'MAX_SIG_FONT_SIZE',      'validate' => 'int:0',   'type' => 'text:5:4', 'explain' => true, 'append' => ' %'),
                  'max_sig_smilies'      => array('lang' => 'MAX_SIG_SMILIES',      'validate' => 'int:0',   'type' => 'text:5:4', 'explain' => true),
                  'max_sig_img_width'      => array('lang' => 'MAX_SIG_IMG_WIDTH',      'validate' => 'int:0',   'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
                  'max_sig_img_height'   => array('lang' => 'MAX_SIG_IMG_HEIGHT',   'validate' => 'int:0',   'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),

                  'legend3'               => 'ACP_SUBMIT_CHANGES',
               )
            );
         break;

         case 'registration':
            $display_vars = array(
               'title'   => 'ACP_REGISTER_SETTINGS',
               'vars'   => array(
                  'legend1'            => 'GENERAL_SETTINGS',
                  'max_name_chars'      => array('lang' => 'USERNAME_LENGTH', 'validate' => 'int:8:180', 'type' => false, 'method' => false, 'explain' => false,),
                  'max_pass_chars'      => array('lang' => 'PASSWORD_LENGTH', 'validate' => 'int:8:255', 'type' => false, 'method' => false, 'explain' => false,),

                  'require_activation'   => array('lang' => 'ACC_ACTIVATION',   'validate' => 'int',   'type' => 'custom', 'method' => 'select_acc_activation', 'explain' => true),
                  'new_member_post_limit'   => array('lang' => 'NEW_MEMBER_POST_LIMIT', 'validate' => 'int:0:255', 'type' => 'text:4:4', 'explain' => true, 'append' => ' ' . $user->lang['POSTS']),
                  'new_member_group_default'=> array('lang' => 'NEW_MEMBER_GROUP_DEFAULT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
                  'min_name_chars'      => array('lang' => 'USERNAME_LENGTH',   'validate' => 'int:1',   'type' => 'custom:5:180', 'method' => 'username_length', 'explain' => true),
                  'min_pass_chars'      => array('lang' => 'PASSWORD_LENGTH',   'validate' => 'int:1',   'type' => 'custom', 'method' => 'password_length', 'explain' => true),
                  'allow_name_chars'      => array('lang' => 'USERNAME_CHARS',   'validate' => 'string',   'type' => 'select', 'method' => 'select_username_chars', 'explain' => true),
                  'pass_complex'         => array('lang' => 'PASSWORD_TYPE',      'validate' => 'string',   'type' => 'select', 'method' => 'select_password_chars', 'explain' => true),
                  'chg_passforce'         => array('lang' => 'FORCE_PASS_CHANGE',   'validate' => 'int:0',   'type' => 'text:3:3', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),

                  'legend2'            => 'GENERAL_OPTIONS',
                  'allow_namechange'      => array('lang' => 'ALLOW_NAME_CHANGE',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_emailreuse'      => array('lang' => 'ALLOW_EMAIL_REUSE',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'enable_confirm'      => array('lang' => 'VISUAL_CONFIRM_REG',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'max_login_attempts'   => array('lang' => 'MAX_LOGIN_ATTEMPTS',   'validate' => 'int:0',   'type' => 'text:3:3', 'explain' => true),
                  'max_reg_attempts'      => array('lang' => 'REG_LIMIT',            'validate' => 'int:0',   'type' => 'text:4:4', 'explain' => true),

                  'legend3'         => 'COPPA',
                  'coppa_enable'      => array('lang' => 'ENABLE_COPPA',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'coppa_mail'      => array('lang' => 'COPPA_MAIL',      'validate' => 'string',   'type' => 'textarea:5:40', 'explain' => true),
                  'coppa_fax'         => array('lang' => 'COPPA_FAX',         'validate' => 'string',   'type' => 'text:25:100', 'explain' => false),

                  'legend4'         => 'ACP_SUBMIT_CHANGES',
               )
            );
         break;

         case 'feed':
            $display_vars = array(
               'title'   => 'ACP_FEED_MANAGEMENT',
               'vars'   => array(
                  'legend1'               => 'ACP_FEED_GENERAL',
                  'feed_enable'            => array('lang' => 'ACP_FEED_ENABLE',            'validate' => 'bool',   'type' => 'radio:enabled_disabled',   'explain' => true ),
                  'feed_item_statistics'      => array('lang' => 'ACP_FEED_ITEM_STATISTICS',      'validate' => 'bool',   'type' => 'radio:enabled_disabled',   'explain' => true),
                  'feed_http_auth'         => array('lang' => 'ACP_FEED_HTTP_AUTH',         'validate' => 'bool',   'type' => 'radio:enabled_disabled',   'explain' => true),

                  'legend2'               => 'ACP_FEED_POST_BASED',
                  'feed_limit_post'         => array('lang' => 'ACP_FEED_LIMIT',            'validate' => 'int:5',   'type' => 'text:3:4',            'explain' => true),
                  'feed_overall'            => array('lang' => 'ACP_FEED_OVERALL',            'validate' => 'bool',   'type' => 'radio:enabled_disabled',   'explain' => true ),
                  'feed_forum'            => array('lang' => 'ACP_FEED_FORUM',            'validate' => 'bool',   'type' => 'radio:enabled_disabled',   'explain' => true ),
                  'feed_topic'            => array('lang' => 'ACP_FEED_TOPIC',            'validate' => 'bool',   'type' => 'radio:enabled_disabled',   'explain' => true ),

                  'legend3'               => 'ACP_FEED_TOPIC_BASED',
                  'feed_limit_topic'         => array('lang' => 'ACP_FEED_LIMIT',            'validate' => 'int:5',   'type' => 'text:3:4',            'explain' => true),
                  'feed_topics_new'         => array('lang' => 'ACP_FEED_TOPICS_NEW',         'validate' => 'bool',   'type' => 'radio:enabled_disabled',   'explain' => true ),
                  'feed_topics_active'      => array('lang' => 'ACP_FEED_TOPICS_ACTIVE',      'validate' => 'bool',   'type' => 'radio:enabled_disabled',   'explain' => true ),
                  'feed_news_id'            => array('lang' => 'ACP_FEED_NEWS',               'validate' => 'string',   'type' => 'custom', 'method' => 'select_news_forums', 'explain' => true),

                  'legend4'               => 'ACP_FEED_SETTINGS_OTHER',
                  'feed_overall_forums'      => array('lang'   => 'ACP_FEED_OVERALL_FORUMS',      'validate' => 'bool',   'type' => 'radio:enabled_disabled',   'explain' => true ),
                  'feed_exclude_id'         => array('lang' => 'ACP_FEED_EXCLUDE_ID',         'validate' => 'string',   'type' => 'custom', 'method' => 'select_exclude_forums', 'explain' => true),
               )
            );
         break;

         case 'cookie':
            $display_vars = array(
               'title'   => 'ACP_COOKIE_SETTINGS',
               'vars'   => array(
                  'legend1'      => 'ACP_COOKIE_SETTINGS',
                  'cookie_domain'   => array('lang' => 'COOKIE_DOMAIN',   'validate' => 'string',   'type' => 'text::255', 'explain' => false),
                  'cookie_name'   => array('lang' => 'COOKIE_NAME',   'validate' => 'string',   'type' => 'text::16', 'explain' => false),
                  'cookie_path'   => array('lang'   => 'COOKIE_PATH',   'validate' => 'string',   'type' => 'text::255', 'explain' => false),
                  'cookie_secure'   => array('lang' => 'COOKIE_SECURE',   'validate' => 'bool',   'type' => 'radio:disabled_enabled', 'explain' => true)
               )
            );
         break;

         case 'load':
            $display_vars = array(
               'title'   => 'ACP_LOAD_SETTINGS',
               'vars'   => array(
                  'legend1'         => 'GENERAL_SETTINGS',
                  'limit_load'      => array('lang' => 'LIMIT_LOAD',      'validate' => 'string',   'type' => 'text:4:4', 'explain' => true),
                  'session_length'   => array('lang' => 'SESSION_LENGTH',   'validate' => 'int:60',   'type' => 'text:5:10', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
                  'active_sessions'   => array('lang' => 'LIMIT_SESSIONS',   'validate' => 'int:0',   'type' => 'text:4:4', 'explain' => true),
                  'load_online_time'   => array('lang' => 'ONLINE_LENGTH',      'validate' => 'int:0',   'type' => 'text:4:3', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),

                  'legend2'            => 'GENERAL_OPTIONS',
                  'load_db_track'         => array('lang' => 'YES_POST_MARKING',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'load_db_lastread'      => array('lang' => 'YES_READ_MARKING',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'load_anon_lastread'   => array('lang' => 'YES_ANON_READ_MARKING',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'load_online'         => array('lang' => 'YES_ONLINE',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'load_online_guests'   => array('lang' => 'YES_ONLINE_GUESTS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'load_onlinetrack'      => array('lang' => 'YES_ONLINE_TRACK',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'load_birthdays'      => array('lang' => 'YES_BIRTHDAYS',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'load_moderators'      => array('lang' => 'YES_MODERATORS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'load_jumpbox'         => array('lang' => 'YES_JUMPBOX',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'load_user_activity'   => array('lang' => 'LOAD_USER_ACTIVITY',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'load_tplcompile'      => array('lang' => 'RECOMPILE_STYLES',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),

                  'legend3'            => 'CUSTOM_PROFILE_FIELDS',
                  'load_cpf_memberlist'   => array('lang' => 'LOAD_CPF_MEMBERLIST',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'load_cpf_viewprofile'   => array('lang' => 'LOAD_CPF_VIEWPROFILE',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'load_cpf_viewtopic'   => array('lang' => 'LOAD_CPF_VIEWTOPIC',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),

                  'legend4'               => 'ACP_SUBMIT_CHANGES',
               )
            );
         break;

         case 'auth':
            $display_vars = array(
               'title'   => 'ACP_AUTH_SETTINGS',
               'vars'   => array(
                  'legend1'      => 'ACP_AUTH_SETTINGS',
                  'auth_method'   => array('lang' => 'AUTH_METHOD',   'validate' => 'string',   'type' => 'select', 'method' => 'select_auth_method', 'explain' => false)
               )
            );
         break;

         case 'server':
            $display_vars = array(
               'title'   => 'ACP_SERVER_SETTINGS',
               'vars'   => array(
                  'legend1'            => 'ACP_SERVER_SETTINGS',
                  'gzip_compress'         => array('lang' => 'ENABLE_GZIP',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),

                  'legend2'            => 'PATH_SETTINGS',
                  'smilies_path'         => array('lang' => 'SMILIES_PATH',      'validate' => 'rpath',   'type' => 'text:20:255', 'explain' => true),
                  'icons_path'         => array('lang' => 'ICONS_PATH',      'validate' => 'rpath',   'type' => 'text:20:255', 'explain' => true),
                  'upload_icons_path'      => array('lang' => 'UPLOAD_ICONS_PATH',   'validate' => 'rpath',   'type' => 'text:20:255', 'explain' => true),
                  'ranks_path'         => array('lang' => 'RANKS_PATH',      'validate' => 'rpath',   'type' => 'text:20:255', 'explain' => true),

                  'legend3'            => 'SERVER_URL_SETTINGS',
                  'force_server_vars'      => array('lang' => 'FORCE_SERVER_VARS',   'validate' => 'bool',         'type' => 'radio:yes_no', 'explain' => true),
                  'server_protocol'      => array('lang' => 'SERVER_PROTOCOL',   'validate' => 'string',         'type' => 'text:10:10', 'explain' => true),
                  'server_name'         => array('lang' => 'SERVER_NAME',      'validate' => 'string',         'type' => 'text:40:255', 'explain' => true),
                  'server_port'         => array('lang' => 'SERVER_PORT',      'validate' => 'int:0',         'type' => 'text:5:5', 'explain' => true),
                  'script_path'         => array('lang' => 'SCRIPT_PATH',      'validate' => 'script_path',   'type' => 'text::255', 'explain' => true),

                  'legend4'               => 'ACP_SUBMIT_CHANGES',
               )
            );
         break;

         case 'security':
            $display_vars = array(
               'title'   => 'ACP_SECURITY_SETTINGS',
               'vars'   => array(
                  'legend1'            => 'ACP_SECURITY_SETTINGS',
                  'allow_autologin'      => array('lang' => 'ALLOW_AUTOLOGIN',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'max_autologin_time'   => array('lang' => 'AUTOLOGIN_LENGTH',      'validate' => 'int:0',   'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),
                  'ip_check'            => array('lang' => 'IP_VALID',            'validate' => 'int',   'type' => 'custom', 'method' => 'select_ip_check', 'explain' => true),
                  'browser_check'         => array('lang' => 'BROWSER_VALID',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'forwarded_for_check'   => array('lang' => 'FORWARDED_FOR_VALID',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'referer_validation'   => array('lang' => 'REFERER_VALID',      'validate' => 'int:0:3','type' => 'custom', 'method' => 'select_ref_check', 'explain' => true),
                  'check_dnsbl'         => array('lang' => 'CHECK_DNSBL',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'email_check_mx'      => array('lang' => 'EMAIL_CHECK_MX',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'pass_complex'         => array('lang' => 'PASSWORD_TYPE',         'validate' => 'string',   'type' => 'select', 'method' => 'select_password_chars', 'explain' => true),
                  'chg_passforce'         => array('lang' => 'FORCE_PASS_CHANGE',      'validate' => 'int:0',   'type' => 'text:3:3', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),
                  'max_login_attempts'   => array('lang' => 'MAX_LOGIN_ATTEMPTS',   'validate' => 'int:0',   'type' => 'text:3:3', 'explain' => true),
                  'tpl_allow_php'         => array('lang' => 'TPL_ALLOW_PHP',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'form_token_lifetime'   => array('lang' => 'FORM_TIME_MAX',         'validate' => 'int:-1',   'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
                  'form_token_sid_guests'   => array('lang' => 'FORM_SID_GUESTS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),

               )
            );
         break;

         case 'email':
            $display_vars = array(
               'title'   => 'ACP_EMAIL_SETTINGS',
               'vars'   => array(
                  'legend1'            => 'GENERAL_SETTINGS',
                  'email_enable'         => array('lang' => 'ENABLE_EMAIL',         'validate' => 'bool',   'type' => 'radio:enabled_disabled', 'explain' => true),
                  'board_email_form'      => array('lang' => 'BOARD_EMAIL_FORM',      'validate' => 'bool',   'type' => 'radio:enabled_disabled', 'explain' => true),
                  'email_function_name'   => array('lang' => 'EMAIL_FUNCTION_NAME',   'validate' => 'string',   'type' => 'text:20:50', 'explain' => true),
                  'email_package_size'   => array('lang' => 'EMAIL_PACKAGE_SIZE',   'validate' => 'int:0',   'type' => 'text:5:5', 'explain' => true),
                  'board_contact'         => array('lang' => 'CONTACT_EMAIL',         'validate' => 'string',   'type' => 'text:25:100', 'explain' => true),
                  'board_email'         => array('lang' => 'ADMIN_EMAIL',         'validate' => 'string',   'type' => 'text:25:100', 'explain' => true),
                  'board_email_sig'      => array('lang' => 'EMAIL_SIG',            'validate' => 'string',   'type' => 'textarea:5:30', 'explain' => true),
                  'board_hide_emails'      => array('lang' => 'BOARD_HIDE_EMAILS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),

                  'legend2'            => 'SMTP_SETTINGS',
                  'smtp_delivery'         => array('lang' => 'USE_SMTP',            'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'smtp_host'            => array('lang' => 'SMTP_SERVER',         'validate' => 'string',   'type' => 'text:25:50', 'explain' => false),
                  'smtp_port'            => array('lang' => 'SMTP_PORT',            'validate' => 'int:0',   'type' => 'text:4:5', 'explain' => true),
                  'smtp_auth_method'      => array('lang' => 'SMTP_AUTH_METHOD',      'validate' => 'string',   'type' => 'select', 'method' => 'mail_auth_select', 'explain' => true),
                  'smtp_username'         => array('lang' => 'SMTP_USERNAME',         'validate' => 'string',   'type' => 'text:25:255', 'explain' => true),
                  'smtp_password'         => array('lang' => 'SMTP_PASSWORD',         'validate' => 'string',   'type' => 'password:25:255', 'explain' => true),

                  'legend3'               => 'ACP_SUBMIT_CHANGES',
               )
            );
         break;

         default:
            trigger_error('NO_MODE', E_USER_ERROR);
         break;
      }

      if (isset($display_vars['lang']))
      {
         $user->add_lang($display_vars['lang']);
      }

      $this->new_config = $config;
      $cfg_array = (isset($_REQUEST['config'])) ? utf8_normalize_nfc(request_var('config', array('' => ''), true)) : $this->new_config;
      $error = array();

      // We validate the complete config if whished
      validate_config_vars($display_vars['vars'], $cfg_array, $error);

      if ($submit && !check_form_key($form_key))
      {
         $error[] = $user->lang['FORM_INVALID'];
      }
      // Do not write values if there is an error
      if (sizeof($error))
      {
         $submit = false;
      }

      // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to...
      foreach ($display_vars['vars'] as $config_name => $null)
      {
         if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false)
         {
            continue;
         }

         if ($config_name == 'auth_method' || $config_name == 'feed_news_id' || $config_name == 'feed_exclude_id')
         {
            continue;
         }

         $this->new_config[$config_name] = $config_value = $cfg_array[$config_name];

         if ($config_name == 'email_function_name')
         {
            $this->new_config['email_function_name'] = trim(str_replace(array('(', ')'), array('', ''), $this->new_config['email_function_name']));
            $this->new_config['email_function_name'] = (empty($this->new_config['email_function_name']) || !function_exists($this->new_config['email_function_name'])) ? 'mail' : $this->new_config['email_function_name'];
            $config_value = $this->new_config['email_function_name'];
         }

         if ($submit)
         {
            set_config($config_name, $config_value);

            if ($config_name == 'allow_quick_reply' && isset($_POST['allow_quick_reply_enable']))
            {
               enable_bitfield_column_flag(FORUMS_TABLE, 'forum_flags', log(FORUM_FLAG_QUICK_REPLY, 2));
            }
         }
      }

      // Store news and exclude ids
      if ($mode == 'feed' && $submit)
      {
         $cache->destroy('_feed_news_forum_ids');
         $cache->destroy('_feed_excluded_forum_ids');

         $this->store_feed_forums(FORUM_OPTION_FEED_NEWS, 'feed_news_id');
         $this->store_feed_forums(FORUM_OPTION_FEED_EXCLUDE, 'feed_exclude_id');
      }

      if ($mode == 'auth')
      {
         // Retrieve a list of auth plugins and check their config values
         $auth_plugins = array();

         $dp = @opendir($phpbb_root_path . 'includes/auth');

         if ($dp)
         {
            while (($file = readdir($dp)) !== false)
            {
               if (preg_match('#^auth_(.*?)\.' . $phpEx . '$#', $file))
               {
                  $auth_plugins[] = basename(preg_replace('#^auth_(.*?)\.' . $phpEx . '$#', '\1', $file));
               }
            }
            closedir($dp);

            sort($auth_plugins);
         }

         $updated_auth_settings = false;
         $old_auth_config = array();
         foreach ($auth_plugins as $method)
         {
            if ($method && file_exists($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx))
            {
               include_once($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx);

               $method = 'acp_' . $method;
               if (function_exists($method))
               {
                  if ($fields = $method($this->new_config))
                  {
                     // Check if we need to create config fields for this plugin and save config when submit was pressed
                     foreach ($fields['config'] as $field)
                     {
                        if (!isset($config[$field]))
                        {
                           set_config($field, '');
                        }

                        if (!isset($cfg_array[$field]) || strpos($field, 'legend') !== false)
                        {
                           continue;
                        }

                        $old_auth_config[$field] = $this->new_config[$field];
                        $config_value = $cfg_array[$field];
                        $this->new_config[$field] = $config_value;

                        if ($submit)
                        {
                           $updated_auth_settings = true;
                           set_config($field, $config_value);
                        }
                     }
                  }
                  unset($fields);
               }
            }
         }

         if ($submit && (($cfg_array['auth_method'] != $this->new_config['auth_method']) || $updated_auth_settings))
         {
            $method = basename($cfg_array['auth_method']);
            if ($method && in_array($method, $auth_plugins))
            {
               include_once($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx);

               $method = 'init_' . $method;
               if (function_exists($method))
               {
                  if ($error = $method())
                  {
                     foreach ($old_auth_config as $config_name => $config_value)
                     {
                        set_config($config_name, $config_value);
                     }
                     trigger_error($error . adm_back_link($this->u_action), E_USER_WARNING);
                  }
               }
               set_config('auth_method', basename($cfg_array['auth_method']));
            }
            else
            {
               trigger_error('NO_AUTH_PLUGIN', E_USER_ERROR);
            }
         }
      }

      if ($submit)
      {
         add_log('admin', 'LOG_CONFIG_' . strtoupper($mode));

         trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
      }

      $this->tpl_name = 'acp_board';
      $this->page_title = $display_vars['title'];

      $template->assign_vars(array(
         'L_TITLE'         => $user->lang[$display_vars['title']],
         'L_TITLE_EXPLAIN'   => $user->lang[$display_vars['title'] . '_EXPLAIN'],

         'S_ERROR'         => (sizeof($error)) ? true : false,
         'ERROR_MSG'         => implode('<br />', $error),

         'U_ACTION'         => $this->u_action)
      );

      // Output relevant page
      foreach ($display_vars['vars'] as $config_key => $vars)
      {
         if (!is_array($vars) && strpos($config_key, 'legend') === false)
         {
            continue;
         }

         if (strpos($config_key, 'legend') !== false)
         {
            $template->assign_block_vars('options', array(
               'S_LEGEND'      => true,
               'LEGEND'      => (isset($user->lang[$vars])) ? $user->lang[$vars] : $vars)
            );

            continue;
         }

         $type = explode(':', $vars['type']);

         $l_explain = '';
         if ($vars['explain'] && isset($vars['lang_explain']))
         {
            $l_explain = (isset($user->lang[$vars['lang_explain']])) ? $user->lang[$vars['lang_explain']] : $vars['lang_explain'];
         }
         else if ($vars['explain'])
         {
            $l_explain = (isset($user->lang[$vars['lang'] . '_EXPLAIN'])) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : '';
         }

         $content = build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars);

         if (empty($content))
         {
            continue;
         }

         $template->assign_block_vars('options', array(
            'KEY'         => $config_key,
            'TITLE'         => (isset($user->lang[$vars['lang']])) ? $user->lang[$vars['lang']] : $vars['lang'],
            'S_EXPLAIN'      => $vars['explain'],
            'TITLE_EXPLAIN'   => $l_explain,
            'CONTENT'      => $content,
            )
         );

         unset($display_vars['vars'][$config_key]);
      }

      if ($mode == 'auth')
      {
         $template->assign_var('S_AUTH', true);

         foreach ($auth_plugins as $method)
         {
            if ($method && file_exists($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx))
            {
               $method = 'acp_' . $method;
               if (function_exists($method))
               {
                  $fields = $method($this->new_config);

                  if ($fields['tpl'])
                  {
                     $template->assign_block_vars('auth_tpl', array(
                        'TPL'   => $fields['tpl'])
                     );
                  }
                  unset($fields);
               }
            }
         }
      }
   }

   /**
   * Select auth method
   */
   function select_auth_method($selected_method, $key = '')
   {
      global $phpbb_root_path, $phpEx;

      $auth_plugins = array();

      $dp = @opendir($phpbb_root_path . 'includes/auth');

      if (!$dp)
      {
         return '';
      }

      while (($file = readdir($dp)) !== false)
      {
         if (preg_match('#^auth_(.*?)\.' . $phpEx . '$#', $file))
         {
            $auth_plugins[] = preg_replace('#^auth_(.*?)\.' . $phpEx . '$#', '\1', $file);
         }
      }
      closedir($dp);

      sort($auth_plugins);

      $auth_select = '';
      foreach ($auth_plugins as $method)
      {
         $selected = ($selected_method == $method) ? ' selected="selected"' : '';
         $auth_select .= '<option value="' . $method . '"' . $selected . '>' . ucfirst($method) . '</option>';
      }

      return $auth_select;
   }

   /**
   * Select mail authentication method
   */
   function mail_auth_select($selected_method, $key = '')
   {
      global $user;

      $auth_methods = array('PLAIN', 'LOGIN', 'CRAM-MD5', 'DIGEST-MD5', 'POP-BEFORE-SMTP');
      $s_smtp_auth_options = '';

      foreach ($auth_methods as $method)
      {
         $s_smtp_auth_options .= '<option value="' . $method . '"' . (($selected_method == $method) ? ' selected="selected"' : '') . '>' . $user->lang['SMTP_' . str_replace('-', '_', $method)] . '</option>';
      }

      return $s_smtp_auth_options;
   }

   /**
   * Select full folder action
   */
   function full_folder_select($value, $key = '')
   {
      global $user;

      return '<option value="1"' . (($value == 1) ? ' selected="selected"' : '') . '>' . $user->lang['DELETE_OLDEST_MESSAGES'] . '</option><option value="2"' . (($value == 2) ? ' selected="selected"' : '') . '>' . $user->lang['HOLD_NEW_MESSAGES_SHORT'] . '</option>';
   }

   /**
   * Select ip validation
   */
   function select_ip_check($value, $key = '')
   {
      $radio_ary = array(4 => 'ALL', 3 => 'CLASS_C', 2 => 'CLASS_B', 0 => 'NO_IP_VALIDATION');

      return h_radio('config[ip_check]', $radio_ary, $value, $key);
   }

   /**
   * Select referer validation
   */
   function select_ref_check($value, $key = '')
   {
      $radio_ary = array(REFERER_VALIDATE_PATH => 'REF_PATH', REFERER_VALIDATE_HOST => 'REF_HOST', REFERER_VALIDATE_NONE => 'NO_REF_VALIDATION');

      return h_radio('config[referer_validation]', $radio_ary, $value, $key);
   }

   /**
   * Select account activation method
   */
   function select_acc_activation($value, $key = '')
   {
      global $user, $config;

      $radio_ary = array(USER_ACTIVATION_DISABLE => 'ACC_DISABLE', USER_ACTIVATION_NONE => 'ACC_NONE');
      if ($config['email_enable'])
      {
         $radio_ary += array(USER_ACTIVATION_SELF => 'ACC_USER', USER_ACTIVATION_ADMIN => 'ACC_ADMIN');
      }

      return h_radio('config[require_activation]', $radio_ary, $value, $key);
   }

   /**
   * Maximum/Minimum username length
   */
   function username_length($value, $key = '')
   {
      global $user;

      return '<input id="' . $key . '" type="text" size="3" maxlength="3" name="config[min_name_chars]" value="' . $value . '" /> ' . $user->lang['MIN_CHARS'] . '&nbsp;&nbsp;<input type="text" size="3" maxlength="3" name="config[max_name_chars]" value="' . $this->new_config['max_name_chars'] . '" /> ' . $user->lang['MAX_CHARS'];
   }

   /**
   * Allowed chars in usernames
   */
   function select_username_chars($selected_value, $key)
   {
      global $user;

      $user_char_ary = array('USERNAME_CHARS_ANY', 'USERNAME_ALPHA_ONLY', 'USERNAME_ALPHA_SPACERS', 'USERNAME_LETTER_NUM', 'USERNAME_LETTER_NUM_SPACERS', 'USERNAME_ASCII');
      $user_char_options = '';
      foreach ($user_char_ary as $user_type)
      {
         $selected = ($selected_value == $user_type) ? ' selected="selected"' : '';
         $user_char_options .= '<option value="' . $user_type . '"' . $selected . '>' . $user->lang[$user_type] . '</option>';
      }

      return $user_char_options;
   }

   /**
   * Maximum/Minimum password length
   */
   function password_length($value, $key)
   {
      global $user;

      return '<input id="' . $key . '" type="text" size="3" maxlength="3" name="config[min_pass_chars]" value="' . $value . '" /> ' . $user->lang['MIN_CHARS'] . '&nbsp;&nbsp;<input type="text" size="3" maxlength="3" name="config[max_pass_chars]" value="' . $this->new_config['max_pass_chars'] . '" /> ' . $user->lang['MAX_CHARS'];
   }

   /**
   * Required chars in passwords
   */
   function select_password_chars($selected_value, $key)
   {
      global $user;

      $pass_type_ary = array('PASS_TYPE_ANY', 'PASS_TYPE_CASE', 'PASS_TYPE_ALPHA', 'PASS_TYPE_SYMBOL');
      $pass_char_options = '';
      foreach ($pass_type_ary as $pass_type)
      {
         $selected = ($selected_value == $pass_type) ? ' selected="selected"' : '';
         $pass_char_options .= '<option value="' . $pass_type . '"' . $selected . '>' . $user->lang[$pass_type] . '</option>';
      }

      return $pass_char_options;
   }
/** * Select resized image link method */ function select_reimg_link_method($selected_value, $key) { global $user; $link_method_ary = array('button' => 'REIMG_LINK_BUTTON', 'link' => 'REIMG_LINK_IMAGE', 'button_link' => 'REIMG_LINK_BOTH'); $link_options = ''; foreach ($link_method_ary as $link_mehod => $lang) { $selected = ($selected_value == $link_mehod) ? ' selected="selected"' : ''; $link_options .= '<option value="' . $link_mehod . '"' . $selected . '>' . $user->lang[$lang] . '</option>'; } return $link_options; } /** * Select resized image zoom method */ function select_reimg_zoom_method($selected_value, $key) { global $user, $phpbb_root_path; $zoom_method_ary = array('' => 'DISABLED', '_default' => 'REIMG_ZOOM_DEFAULT', '_exturl' => 'REIMG_ZOOM_EXTURL', '_blank' => 'REIMG_ZOOM_BLANK', '_litebox' => 'REIMG_ZOOM_LITEBOX', '_litebox1' => 'REIMG_ZOOM_LITEBOX_1_1', '_litebox0' => 'REIMG_ZOOM_LITEBOX_RESIZED', '_highslide' => 'REIMG_ZOOM_HIGHSLIDE'); $zoom_options = ''; foreach ($zoom_method_ary as $zoom_method => $lang) { $disabled = ''; //We need to check and see if the Highslide library actually exists before allowing the option to be selectable if ($zoom_method == '_highslide') { //We need one of the highslide js libraries if (!file_exists($phpbb_root_path . 'reimg/highslide/highslide-full.packed.js')) { $disabled = ' disabled'; } } $selected = ($selected_value == $zoom_method) ? ' selected="selected"' : ''; $zoom_options .= '<option value="' . $zoom_method . '"' . $selected . $disabled . '>' . $user->lang[$lang] . '</option>'; } return $zoom_options; }

   /**
   * Select bump interval
   */
   function bump_interval($value, $key)
   {
      global $user;

      $s_bump_type = '';
      $types = array('m' => 'MINUTES', 'h' => 'HOURS', 'd' => 'DAYS');
      foreach ($types as $type => $lang)
      {
         $selected = ($this->new_config['bump_type'] == $type) ? ' selected="selected"' : '';
         $s_bump_type .= '<option value="' . $type . '"' . $selected . '>' . $user->lang[$lang] . '</option>';
      }

      return '<input id="' . $key . '" type="text" size="3" maxlength="4" name="config[bump_interval]" value="' . $value . '" />&nbsp;<select name="config[bump_type]">' . $s_bump_type . '</select>';
   }

   /**
   * Board disable option and message
   */
   function board_disable($value, $key)
   {
      global $user;

      $radio_ary = array(1 => 'YES', 0 => 'NO');

      return h_radio('config[board_disable]', $radio_ary, $value) . '<br /><input id="' . $key . '" type="text" name="config[board_disable_msg]" maxlength="255" size="40" value="' . $this->new_config['board_disable_msg'] . '" />';
   }

   /**
   * Global quick reply enable/disable setting and button to enable in all forums
   */
   function quick_reply($value, $key)
   {
      global $user;

      $radio_ary = array(1 => 'YES', 0 => 'NO');

      return h_radio('config[allow_quick_reply]', $radio_ary, $value) .
         '<br /><br /><input class="button2" type="submit" id="' . $key . '_enable" name="' . $key . '_enable" value="' . $user->lang['ALLOW_QUICK_REPLY_BUTTON'] . '" />';
   }


   /**
   * Select default dateformat
   */
   function dateformat_select($value, $key)
   {
      global $user, $config;

      // Let the format_date function operate with the acp values
      $old_tz = $user->timezone;
      $old_dst = $user->dst;

      $user->timezone = $config['board_timezone'];
      $user->dst = $config['board_dst'];

      $dateformat_options = '';

      foreach ($user->lang['dateformats'] as $format => $null)
      {
         $dateformat_options .= '<option value="' . $format . '"' . (($format == $value) ? ' 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>';
      }

      $dateformat_options .= '<option value="custom"';
      if (!isset($user->lang['dateformats'][$value]))
      {
         $dateformat_options .= ' selected="selected"';
      }
      $dateformat_options .= '>' . $user->lang['CUSTOM_DATEFORMAT'] . '</option>';

      // Reset users date options
      $user->timezone = $old_tz;
      $user->dst = $old_dst;

      return "<select name=\"dateoptions\" id=\"dateoptions\" onchange=\"if (this.value == 'custom') { document.getElementById('" . addslashes($key) . "').value = '" . addslashes($value) . "'; } else { document.getElementById('" . addslashes($key) . "').value = this.value; }\">$dateformat_options</select>
      <input type=\"text\" name=\"config[$key]\" id=\"$key\" value=\"$value\" maxlength=\"30\" />";
   }

   /**
   * Select multiple forums
   */
   function select_news_forums($value, $key)
   {
      global $user, $config;

      $forum_list = make_forum_select(false, false, true, true, true, false, true);

      // Build forum options
      $s_forum_options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">';
      foreach ($forum_list as $f_id => $f_row)
      {
         $f_row['selected'] = phpbb_optionget(FORUM_OPTION_FEED_NEWS, $f_row['forum_options']);

         $s_forum_options .= '<option value="' . $f_id . '"' . (($f_row['selected']) ? ' selected="selected"' : '') . (($f_row['disabled']) ? ' disabled="disabled" class="disabled-option"' : '') . '>' . $f_row['padding'] . $f_row['forum_name'] . '</option>';
      }
      $s_forum_options .= '</select>';

      return $s_forum_options;
   }

   function select_exclude_forums($value, $key)
   {
      global $user, $config;

      $forum_list = make_forum_select(false, false, true, true, true, false, true);

      // Build forum options
      $s_forum_options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">';
      foreach ($forum_list as $f_id => $f_row)
      {
         $f_row['selected'] = phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $f_row['forum_options']);

         $s_forum_options .= '<option value="' . $f_id . '"' . (($f_row['selected']) ? ' selected="selected"' : '') . (($f_row['disabled']) ? ' disabled="disabled" class="disabled-option"' : '') . '>' . $f_row['padding'] . $f_row['forum_name'] . '</option>';
      }
      $s_forum_options .= '</select>';

      return $s_forum_options;
   }

   function store_feed_forums($option, $key)
   {
      global $db, $cache;

      // Get key
      $values = request_var($key, array(0 => 0));

      // Empty option bit for all forums
      $sql = 'UPDATE ' . FORUMS_TABLE . '
         SET forum_options = forum_options - ' . (1 << $option) . '
         WHERE ' . $db->sql_bit_and('forum_options', $option, '<> 0');
      $db->sql_query($sql);

      // Already emptied for all...
      if (sizeof($values))
      {
         // Set for selected forums
         $sql = 'UPDATE ' . FORUMS_TABLE . '
            SET forum_options = forum_options + ' . (1 << $option) . '
            WHERE ' . $db->sql_in_set('forum_id', $values);
         $db->sql_query($sql);
      }

      // Empty sql cache for forums table because options changed
      $cache->destroy('sql', FORUMS_TABLE);
   }

}

?>
by darah
Mon May 10, 2010 4:30 am

(3.0.7-PL1) Empty Drop Down Menu in Profiles

What would cause the groups drop down menu in a user's profile to show blank names? The links to the groups work fine when you click on "Go"

I'm using phpBB 3.0.7PL-1 w/ Simple Profile Comments (installed using the modified install.xml file for 3.0.7PL-1 via Automod).

Image

The link is memberlist.php?mode=viewprofile&u=2

I'm wondering if it's in memberlist.php or somewhere else.

Here is my memberlist.php file:

Code: Select all

<?php
/**
*
* @package phpBB3
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup(array('memberlist', 'groups'));

// Grab data
$mode      = request_var('mode', '');
$action      = request_var('action', '');
$user_id   = request_var('u', ANONYMOUS);
$username   = request_var('un', '', true);
$group_id   = request_var('g', 0);
$topic_id   = request_var('t', 0);

// Check our mode...
if (!in_array($mode, array('', 'group', 'viewprofile', 'email', 'contact', 'searchuser', 'leaders')))
{
   trigger_error('NO_MODE');
}

switch ($mode)
{
   case 'email':
   break;

   default:
      // Can this user view profiles/memberlist?
      if (!$auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel'))
      {
         if ($user->data['user_id'] != ANONYMOUS)
         {
            trigger_error('NO_VIEW_USERS');
         }

         login_box('', ((isset($user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)])) ? $user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)] : $user->lang['LOGIN_EXPLAIN_MEMBERLIST']));
      }
   break;
}

$start   = request_var('start', 0);
$submit = (isset($_POST['submit'])) ? true : false;

$default_key = 'c';
$sort_key = request_var('sk', $default_key);
$sort_dir = request_var('sd', 'a');


// Grab rank information for later
$ranks = $cache->obtain_ranks();


// What do you want to do today? ... oops, I think that line is taken ...
switch ($mode)
{
   case 'leaders':
      // Display a listing of board admins, moderators
      include($phpbb_root_path . 'includes/functions_user.' . $phpEx);

      $page_title = $user->lang['THE_TEAM'];
      $template_html = 'memberlist_leaders.html';

      $user_ary = $auth->acl_get_list(false, array('a_', 'm_'), false);

      $admin_id_ary = $global_mod_id_ary = $mod_id_ary = $forum_id_ary = array();
      foreach ($user_ary as $forum_id => $forum_ary)
      {
         foreach ($forum_ary as $auth_option => $id_ary)
         {
            if (!$forum_id)
            {
               if ($auth_option == 'a_')
               {
                  $admin_id_ary = array_merge($admin_id_ary, $id_ary);
               }
               else
               {
                  $global_mod_id_ary = array_merge($global_mod_id_ary, $id_ary);
               }
               continue;
            }
            else
            {
               $mod_id_ary = array_merge($mod_id_ary, $id_ary);
            }

            if ($forum_id)
            {
               foreach ($id_ary as $id)
               {
                  $forum_id_ary[$id][] = $forum_id;
               }
            }
         }
      }

      $admin_id_ary = array_unique($admin_id_ary);
      $global_mod_id_ary = array_unique($global_mod_id_ary);

      $mod_id_ary = array_merge($mod_id_ary, $global_mod_id_ary);
      $mod_id_ary = array_unique($mod_id_ary);

      // Admin group id...
      $sql = 'SELECT group_id
         FROM ' . GROUPS_TABLE . "
         WHERE group_name = 'ADMINISTRATORS'";
      $result = $db->sql_query($sql);
      $admin_group_id = (int) $db->sql_fetchfield('group_id');
      $db->sql_freeresult($result);

      // Get group memberships for the admin id ary...
      $admin_memberships = group_memberships($admin_group_id, $admin_id_ary);

      $admin_user_ids = array();

      if (!empty($admin_memberships))
      {
         // ok, we only need the user ids...
         foreach ($admin_memberships as $row)
         {
            $admin_user_ids[$row['user_id']] = true;
         }
      }
      unset($admin_memberships);

      $sql = 'SELECT forum_id, forum_name
         FROM ' . FORUMS_TABLE;
      $result = $db->sql_query($sql);

      $forums = array();
      while ($row = $db->sql_fetchrow($result))
      {
         $forums[$row['forum_id']] = $row['forum_name'];
      }
      $db->sql_freeresult($result);

      $sql = $db->sql_build_query('SELECT', array(
         'SELECT'   => 'u.user_id, u.group_id as default_group, u.username, u.username_clean, u.user_colour, u.user_rank, u.user_posts, u.user_allow_pm, g.group_id, g.group_name, g.group_colour, g.group_type, ug.user_id as ug_user_id',

         'FROM'      => array(
            USERS_TABLE      => 'u',
            GROUPS_TABLE   => 'g'
         ),

         'LEFT_JOIN'   => array(
            array(
               'FROM'   => array(USER_GROUP_TABLE => 'ug'),
               'ON'   => 'ug.group_id = g.group_id AND ug.user_pending = 0 AND ug.user_id = ' . $user->data['user_id']
            )
         ),

         'WHERE'      => $db->sql_in_set('u.user_id', array_unique(array_merge($admin_id_ary, $mod_id_ary)), false, true) . '
            AND u.group_id = g.group_id',

         'ORDER_BY'   => 'g.group_name ASC, u.username_clean ASC'
      ));
      $result = $db->sql_query($sql);

      while ($row = $db->sql_fetchrow($result))
      {
         $which_row = (in_array($row['user_id'], $admin_id_ary)) ? 'admin' : 'mod';

         // We sort out admins not within the 'Administrators' group.
         // Else, we will list those as admin only having the permission to view logs for example.
         if ($which_row == 'admin' && empty($admin_user_ids[$row['user_id']]))
         {
            // Remove from admin_id_ary, because the user may be a mod instead
            unset($admin_id_ary[array_search($row['user_id'], $admin_id_ary)]);

            if (!in_array($row['user_id'], $mod_id_ary) && !in_array($row['user_id'], $global_mod_id_ary))
            {
               continue;
            }
            else
            {
               $which_row = 'mod';
            }
         }

         $s_forum_select = '';
         $undisclosed_forum = false;

         if (isset($forum_id_ary[$row['user_id']]) && !in_array($row['user_id'], $global_mod_id_ary))
         {
            if ($which_row == 'mod' && sizeof(array_diff(array_keys($forums), $forum_id_ary[$row['user_id']])))
            {
               foreach ($forum_id_ary[$row['user_id']] as $forum_id)
               {
                  if (isset($forums[$forum_id]))
                  {
                     if ($auth->acl_get('f_list', $forum_id))
                     {
                        $s_forum_select .= '<option value="">' . $forums[$forum_id] . '</option>';
                     }
                     else
                     {
                        $undisclosed_forum = true;
                     }
                  }
               }
            }
         }

         // If the mod is only moderating non-viewable forums we skip the user. There is no gain in displaying the person then...
         if (!$s_forum_select && $undisclosed_forum)
         {
//            $s_forum_select = '<option value="">' . $user->lang['FORUM_UNDISCLOSED'] . '</option>';
            continue;
         }

         // The person is moderating several "public" forums, therefore the person should be listed, but not giving the real group name if hidden.
         if ($row['group_type'] == GROUP_HIDDEN && !$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $row['ug_user_id'] != $user->data['user_id'])
         {
            $group_name = $user->lang['GROUP_UNDISCLOSED'];
            $u_group = '';
         }
         else
         {
            $group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];
            $u_group = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp;g=' . $row['group_id']);
         }

         $rank_title = $rank_img = '';
         get_user_rank($row['user_rank'], (($row['user_id'] == ANONYMOUS) ? false : $row['user_posts']), $rank_title, $rank_img, $rank_img_src);

         $template->assign_block_vars($which_row, array(
            'USER_ID'      => $row['user_id'],
            'FORUMS'      => $s_forum_select,
            'RANK_TITLE'   => $rank_title,
            'GROUP_NAME'   => $group_name,
            'GROUP_COLOR'   => $row['group_colour'],

            'RANK_IMG'      => $rank_img,
            'RANK_IMG_SRC'   => $rank_img_src,

            'U_GROUP'         => $u_group,
            'U_PM'            => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($row['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '',

            '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']),
         ));
      }
      $db->sql_freeresult($result);

      $template->assign_vars(array(
         'PM_IMG'      => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']))
      );
   break;

   case 'contact':

      $page_title = $user->lang['IM_USER'];
      $template_html = 'memberlist_im.html';

      if (!$auth->acl_get('u_sendim'))
      {
         trigger_error('NOT_AUTHORISED');
      }

      $presence_img = '';
      switch ($action)
      {
         case 'aim':
            $lang = 'AIM';
            $sql_field = 'user_aim';
            $s_select = 'S_SEND_AIM';
            $s_action = '';
         break;

         case 'msnm':
            $lang = 'MSNM';
            $sql_field = 'user_msnm';
            $s_select = 'S_SEND_MSNM';
            $s_action = '';
         break;

         case 'jabber':
            $lang = 'JABBER';
            $sql_field = 'user_jabber';
            $s_select = (@extension_loaded('xml') && $config['jab_enable']) ? 'S_SEND_JABBER' : 'S_NO_SEND_JABBER';
            $s_action = append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&amp;action=$action&amp;u=$user_id");
         break;

         default:
            trigger_error('NO_MODE', E_USER_ERROR);
         break;
      }

      // Grab relevant data
      $sql = "SELECT user_id, username, user_email, user_lang, $sql_field
         FROM " . USERS_TABLE . "
         WHERE user_id = $user_id
            AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
      $result = $db->sql_query($sql);
      $row = $db->sql_fetchrow($result);
      $db->sql_freeresult($result);

      if (!$row)
      {
         trigger_error('NO_USER');
      }
      else if (empty($row[$sql_field]))
      {
         trigger_error('IM_NO_DATA');
      }

      // Post data grab actions
      switch ($action)
      {
         case 'jabber':
            add_form_key('memberlist_messaging');

            if ($submit && @extension_loaded('xml') && $config['jab_enable'])
            {
               if (check_form_key('memberlist_messaging'))
               {

                  include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);

                  $subject = sprintf($user->lang['IM_JABBER_SUBJECT'], $user->data['username'], $config['server_name']);
                  $message = utf8_normalize_nfc(request_var('message', '', true));

                  if (empty($message))
                  {
                     trigger_error('EMPTY_MESSAGE_IM');
                  }

                  $messenger = new messenger(false);

                  $messenger->template('profile_send_im', $row['user_lang']);
                  $messenger->subject(htmlspecialchars_decode($subject));

                  $messenger->replyto($user->data['user_email']);
                  $messenger->im($row['user_jabber'], $row['username']);

                  $messenger->assign_vars(array(
                     'BOARD_CONTACT'   => $config['board_contact'],
                     'FROM_USERNAME'   => htmlspecialchars_decode($user->data['username']),
                     'TO_USERNAME'   => htmlspecialchars_decode($row['username']),
                     'MESSAGE'      => htmlspecialchars_decode($message))
                  );

                  $messenger->send(NOTIFY_IM);

                  $s_select = 'S_SENT_JABBER';
               }
               else
               {
                  trigger_error('FORM_INVALID');
               }
            }
         break;
      }

      // Send vars to the template
      $template->assign_vars(array(
         'IM_CONTACT'   => $row[$sql_field],
         'A_IM_CONTACT'   => addslashes($row[$sql_field]),

         'U_AIM_CONTACT'   => ($action == 'aim') ? 'aim:addbuddy?screenname=' . urlencode($row[$sql_field]) : '',
         'U_AIM_MESSAGE'   => ($action == 'aim') ? 'aim:goim?screenname=' . urlencode($row[$sql_field]) . '&amp;message=' . urlencode($config['sitename']) : '',

         'USERNAME'      => $row['username'],
         'CONTACT_NAME'   => $row[$sql_field],
         'SITENAME'      => $config['sitename'],

         'PRESENCE_IMG'      => $presence_img,

         'L_SEND_IM_EXPLAIN'   => $user->lang['IM_' . $lang],
         'L_IM_SENT_JABBER'   => sprintf($user->lang['IM_SENT_JABBER'], $row['username']),

         $s_select         => true,
         'S_IM_ACTION'      => $s_action)
      );

   break;

   case 'viewprofile':
      // Display a profile
      if ($user_id == ANONYMOUS && !$username)
      {
         trigger_error('NO_USER');
      }

      // Get user...
      $sql = 'SELECT *
         FROM ' . USERS_TABLE . '
         WHERE ' . (($username) ? "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'" : "user_id = $user_id");
      $result = $db->sql_query($sql);
      $member = $db->sql_fetchrow($result);
      $db->sql_freeresult($result);

      if (!$member)
      {
         trigger_error('NO_USER');
      }

      // a_user admins and founder are able to view inactive users and bots to be able to manage them more easily
      // Normal users are able to see at least users having only changed their profile settings but not yet reactivated.
      if (!$auth->acl_get('a_user') && $user->data['user_type'] != USER_FOUNDER)
      {
         if ($member['user_type'] == USER_IGNORE)
         {
            trigger_error('NO_USER');
         }
         else if ($member['user_type'] == USER_INACTIVE && $member['user_inactive_reason'] != INACTIVE_PROFILE)
         {
            trigger_error('NO_USER');
         }
      }

      $user_id = (int) $member['user_id'];

      // Get group memberships
      // Also get visiting user's groups to determine hidden group memberships if necessary.
      $auth_hidden_groups = ($user_id === (int) $user->data['user_id'] || $auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) ? true : false;
      $sql_uid_ary = ($auth_hidden_groups) ? array($user_id) : array($user_id, (int) $user->data['user_id']);

      // Do the SQL thang
      $sql = 'SELECT g.group_id, g.group_name, g.group_type, ug.user_id
         FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . ' ug
         WHERE ' . $db->sql_in_set('ug.user_id', $sql_uid_ary) . '
            AND g.group_id = ug.group_id
            AND ug.user_pending = 0';
      $result = $db->sql_query($sql);

      // Divide data into profile data and current user data
      $profile_groups = $user_groups = array();
      while ($row = $db->sql_fetchrow($result))
      {
         $row['user_id'] = (int) $row['user_id'];
         $row['group_id'] = (int) $row['group_id'];

         if ($row['user_id'] == $user_id)
         {
            $profile_groups[] = $row;
         }
         else
         {
            $user_groups[$row['group_id']] = $row['group_id'];
         }
      }
      $db->sql_freeresult($result);

      // Filter out hidden groups and sort groups by name
      $group_data = $group_sort = array();
      foreach ($profile_groups as $row)
      {
         if ($row['group_type'] == GROUP_SPECIAL)
         {
            // Lookup group name in language dictionary
            if (isset($user->lang['G_' . $row['group_name']]))
            {
               $row['group_name'] = $user->lang['G_' . $row['group_name']];
            }
         }
         else if (!$auth_hidden_groups && $row['group_type'] == GROUP_HIDDEN && !isset($user_groups[$row['group_id']]))
         {
            // Skip over hidden groups the user cannot see
            continue;
         }

         $group_sort[$row['group_id']] = utf8_clean_string($row['group_name']);
         $group_data[$row['group_id']] = $row;
      }
      unset($profile_groups);
      unset($user_groups);
      asort($group_sort);

      $group_options = '';
      foreach ($group_sort as $group_id => $null)
      {
         $row = $group_data[$group_id];

 $group_options .= '<option value="' . $row['group_id'] . '"' . (($row['group_id'] == $member['group_id']) ? ' selected="selected"' : '') . '>' . (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>';
      }
      $db->sql_freeresult($result);

   // Is the comment mod enabled ?
   if (isset($config['enable_qc']))
   {
      include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
      generate_smilies('inline', 2);
      $user->add_lang('posting');
      $userid = $user->data['user_id'];
      // Change the comment counter back to 0 when the user visits his/her profile
      if ($user_id == $userid)
      {
            $timestamp = time();
            $sqlupd = "UPDATE 
            " . USERS_TABLE . "
            SET   user_last_comment = $timestamp
            WHERE user_id = ".$db->sql_escape($userid);
            $db->sql_query($sqlupd);
      }
      
      $start   = request_var('start', 0);
      $limit   = request_var('limit', intval($config['comm_per_page']));
      $pagination_url = append_sid($phpbb_root_path . 'memberlist.' . $phpEx ,'mode=viewprofile&amp;u='.$user_id);

      $sql = $db->sql_build_query('SELECT', array(
         'SELECT'   => 'u.username, u.user_avatar,u.user_avatar_type, u.user_avatar_width, u.user_avatar_height,u.user_colour, u.allow_all_comment, c.*',
         'FROM'      => array(
            USERS_TABLE      => 'u',
         ),
         'LEFT_JOIN'   => array(
            array(
               'FROM'   => array(COMMENT_TABLE => 'c'),
               'ON'   => 'u.user_id = c.comment_poster_id'      
            )
         ),
         'WHERE'      => 'c.comment_to_id = '.$user_id,
         'ORDER_BY'   => 'c.comment_id DESC'
      ));
               
      $result = $db->sql_query_limit($sql, $limit, $start);
      
            
   while($row = $db->sql_fetchrow($result))
   {


      $row['bbcode_options'] = (($row['enable_bbcode']) ? OPTION_FLAG_BBCODE : 0) +
                   (($row['enable_smilies']) ? OPTION_FLAG_SMILIES : 0) +
                   (($row['enable_magic_url']) ? OPTION_FLAG_LINKS : 0);
      $comment_text_format = generate_text_for_display($row['comment_text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']);
      $avatar          = get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']);
      $av_size          = $config['sc_av_size'];
      $comment_id       = $row['comment_id'];
      $comment_author_id    = $row['comment_poster_id'];
         
      // Assign the needed template vars.
      $template->assign_block_vars('comment',array(   
         'COMMENT_DATE'      => $user->format_date($row['comment_date']),
         'COMMENT_AUTHOR'   => get_username_string('full', $row['comment_poster_id'], $row['username'], $row['user_colour']),
         'COMMENT_TEXT'      => $comment_text_format,
         'COMMENT_AVATAR_THUMB'   =>  ($row['user_avatar']) ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], ($row['user_avatar_width'] > $row['user_avatar_height']) ? $av_size : ($av_size / $row['user_avatar_height']) * $row['user_avatar_width'], ($row['user_avatar_height'] > $row['user_avatar_width']) ? $av_size : ($av_size / $row['user_avatar_width']) * $row['user_avatar_height']) : '',
         'U_USER_URL'         => append_sid($phpbb_root_path . 'memberlist.' . $phpEx ,'mode=viewprofile&amp;u='.$comment_author_id),
         'U_DELETE_URL'      => append_sid($phpbb_root_path . 'new_comment.' . $phpEx ,'mode=delete&amp;comment='.$comment_id.'&amp;u='.$comment_author_id.'&amp;p='.$user_id),   
         'CAN_DELETE'      => ($user_id == $user->data['user_id'] || $user->data['user_id'] == $row['comment_poster_id']) ? true:false,

         ));
}
         $db->sql_freeresult($result);         

   // count some stuff up for the pagination
   $sql = 'SELECT COUNT(comment_id) AS comment_number
            FROM '. COMMENT_TABLE ."
            WHERE comment_to_id = $user_id";
            
   $result = $db->sql_query($sql);
   $total_comments = $db->sql_fetchfield('comment_number');
   
   $db->sql_freeresult($result);
   
      // Are you my foe?
      $sql = 'SELECT friend, foe
         FROM ' . ZEBRA_TABLE . "
         WHERE zebra_id = {$user->data['user_id']}
            AND user_id = $user_id";

      $result = $db->sql_query($sql);
      $row = $db->sql_fetchrow($result);


      // are you my friend?
   $sql = 'SELECT friend, foe
         FROM ' . ZEBRA_TABLE . "
         WHERE zebra_id = $user_id
            AND user_id = {$user->data['user_id']}";

      $result = $db->sql_query($sql);
      $row = $db->sql_fetchrow($result);
      
      $user_ids       = ($user_id == $user->data['user_id']) ? true : false;
      
      $template->assign_vars(array(
         'ALLOW_ALL_COMMENT'   =>  ($member['allow_all_comment']) ? true:false,
         'ALLOW_FRIEND_ONLY' => ($member['allow_friend_only'] && !$row['friend']  && !$user_ids) ? true:false,
         'ALLOW_FRIEND_VIEW' => ($member['allow_friend_view'] && !$row['friend']  && !$user_ids) ? true:false,      
         'FOE'              => ($row['foe']) ? true:false,
         'S_BBCODE_ALLOWED'    => true,

         'COMMENT_TO_ID'      => $user_id,      
             'PAGINATION'        => generate_pagination($pagination_url, $total_comments, $limit, $start),
           'PAGE_NUMBER'       => on_page($total_comments, $limit, $start),
             'TOTAL_COMMENT'     => ($total_comments == 1) ? $user->lang['LIST_COMMENT'] : sprintf($user->lang['LIST_COMMENTS'], $total_comments),
           'NO_COMMENT'          => $total_comments,
           'DELETE_IMG'       => $user->img('icon_post_delete', 'DELETE_POST'),
           'SIMPLE_COMMENT_ENABLED' => $config['enable_comment'],


      ));
      $db->sql_freeresult($result);

   }
      unset($group_data);
      unset($group_sort);

      // What colour is the zebra
      $sql = 'SELECT friend, foe
         FROM ' . ZEBRA_TABLE . "
         WHERE zebra_id = $user_id
            AND user_id = {$user->data['user_id']}";

      $result = $db->sql_query($sql);
      $row = $db->sql_fetchrow($result);
      $foe = ($row['foe']) ? true : false;
      $friend = ($row['friend']) ? true : false;
      $db->sql_freeresult($result);

      if ($config['load_onlinetrack'])
      {
         $sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline
            FROM ' . SESSIONS_TABLE . "
            WHERE session_user_id = $user_id";
         $result = $db->sql_query($sql);
         $row = $db->sql_fetchrow($result);
         $db->sql_freeresult($result);

         $member['session_time'] = (isset($row['session_time'])) ? $row['session_time'] : 0;
         $member['session_viewonline'] = (isset($row['session_viewonline'])) ? $row['session_viewonline'] :   0;
         unset($row);
      }

      if ($config['load_user_activity'])
      {
         display_user_activity($member);
      }

      // Do the relevant calculations
      $memberdays = max(1, round((time() - $member['user_regdate']) / 86400));
      $posts_per_day = $member['user_posts'] / $memberdays;
      $percentage = ($config['num_posts']) ? min(100, ($member['user_posts'] / $config['num_posts']) * 100) : 0;


      if ($member['user_sig'])
      {
         $member['user_sig'] = censor_text($member['user_sig']);

         if ($member['user_sig_bbcode_bitfield'])
         {
            include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
            $bbcode = new bbcode();
            $bbcode->bbcode_second_pass($member['user_sig'], $member['user_sig_bbcode_uid'], $member['user_sig_bbcode_bitfield']);
         }

         $member['user_sig'] = bbcode_nl2br($member['user_sig']);
         $member['user_sig'] = smiley_text($member['user_sig']);
      }

      $poster_avatar = get_user_avatar($member['user_avatar'], $member['user_avatar_type'], $member['user_avatar_width'], $member['user_avatar_height']);

      // We need to check if the modules 'zebra' ('friends' & 'foes' mode),  'notes' ('user_notes' mode) and  'warn' ('warn_user' mode) are accessible to decide if we can display appropriate links
      $zebra_enabled = $friends_enabled = $foes_enabled = $user_notes_enabled = $warn_user_enabled = false;

      // Only check if the user is logged in
      if ($user->data['is_registered'])
      {
         if (!class_exists('p_master'))
         {
            include($phpbb_root_path . 'includes/functions_module.' . $phpEx);
         }
         $module = new p_master();

         $module->list_modules('ucp');
         $module->list_modules('mcp');

         $user_notes_enabled = ($module->loaded('notes', 'user_notes')) ? true : false;
         $warn_user_enabled = ($module->loaded('warn', 'warn_user')) ? true : false;
         $zebra_enabled = ($module->loaded('zebra')) ? true : false;
         $friends_enabled = ($module->loaded('zebra', 'friends')) ? true : false;
         $foes_enabled = ($module->loaded('zebra', 'foes')) ? true : false;

         unset($module);
      }

      $template->assign_vars(show_profile($member, $user_notes_enabled, $warn_user_enabled));

      // Custom Profile Fields
      $profile_fields = array();
      if ($config['load_cpf_viewprofile'])
      {
         include_once($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
         $cp = new custom_profile();
         $profile_fields = $cp->generate_profile_fields_template('grab', $user_id);
         $profile_fields = (isset($profile_fields[$user_id])) ? $cp->generate_profile_fields_template('show', false, $profile_fields[$user_id]) : array();
      }

      // If the user has m_approve permission or a_user permission, then list then display unapproved posts
      if ($auth->acl_getf_global('m_approve') || $auth->acl_get('a_user'))
      {
         $sql = 'SELECT COUNT(post_id) as posts_in_queue
            FROM ' . POSTS_TABLE . '
            WHERE poster_id = ' . $user_id . '
               AND post_approved = 0';
         $result = $db->sql_query($sql);
         $member['posts_in_queue'] = (int) $db->sql_fetchfield('posts_in_queue');
         $db->sql_freeresult($result);
      }
      else
      {
         $member['posts_in_queue'] = 0;
      }

      $template->assign_vars(array(
         'L_POSTS_IN_QUEUE'   => $user->lang('NUM_POSTS_IN_QUEUE', $member['posts_in_queue']),

         'POSTS_DAY'         => sprintf($user->lang['POST_DAY'], $posts_per_day),
         'POSTS_PCT'         => sprintf($user->lang['POST_PCT'], $percentage),

         'OCCUPATION'   => (!empty($member['user_occ'])) ? censor_text($member['user_occ']) : '',
         'INTERESTS'      => (!empty($member['user_interests'])) ? censor_text($member['user_interests']) : '',
         'SIGNATURE'      => ($config['reimg_ignore_sig_img']) ? str_replace(reimg_properties(), '', $member['user_sig']) : $member['user_sig'],
         'POSTS_IN_QUEUE'=> $member['posts_in_queue'],

         'AVATAR_IMG'   => $poster_avatar,
         'PM_IMG'      => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']),
         'EMAIL_IMG'      => $user->img('icon_contact_email', $user->lang['EMAIL']),
         'WWW_IMG'      => $user->img('icon_contact_www', $user->lang['WWW']),
         'ICQ_IMG'      => $user->img('icon_contact_icq', $user->lang['ICQ']),
         'AIM_IMG'      => $user->img('icon_contact_aim', $user->lang['AIM']),
         'MSN_IMG'      => $user->img('icon_contact_msnm', $user->lang['MSNM']),
         'YIM_IMG'      => $user->img('icon_contact_yahoo', $user->lang['YIM']),
         'JABBER_IMG'   => $user->img('icon_contact_jabber', $user->lang['JABBER']),
         'SEARCH_IMG'   => $user->img('icon_user_search', $user->lang['SEARCH']),

         'S_PROFILE_ACTION'   => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group'),
         'S_GROUP_OPTIONS'   => $group_options,
         'S_CUSTOM_FIELDS'   => (isset($profile_fields['row']) && sizeof($profile_fields['row'])) ? true : false,

         'U_USER_ADMIN'         => ($auth->acl_get('a_user')) ? append_sid("{$phpbb_root_path}adm/index.$phpEx", 'i=users&amp;mode=overview&amp;u=' . $user_id, true, $user->session_id) : '',
         'U_USER_BAN'         => ($auth->acl_get('m_ban') && $user_id != $user->data['user_id']) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=ban&amp;mode=user&amp;u=' . $user_id, true, $user->session_id) : '',
         'U_MCP_QUEUE'         => ($auth->acl_getf_global('m_approve')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue', true, $user->session_id) : '',

         'U_SWITCH_PERMISSIONS'   => ($auth->acl_get('a_switchperm') && $user->data['user_id'] != $user_id) ? append_sid("{$phpbb_root_path}ucp.$phpEx", "mode=switch_perm&amp;u={$user_id}&amp;hash=" . generate_link_hash('switchperm')) : '',

         'S_USER_NOTES'      => ($user_notes_enabled) ? true : false,
         'S_WARN_USER'      => ($warn_user_enabled) ? true : false,
         'S_ZEBRA'         => ($user->data['user_id'] != $user_id && $user->data['is_registered'] && $zebra_enabled) ? true : false,
         'U_ADD_FRIEND'      => (!$friend && !$foe && $friends_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&amp;add=' . urlencode(htmlspecialchars_decode($member['username']))) : '',
         'U_ADD_FOE'         => (!$friend && !$foe && $foes_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&amp;mode=foes&amp;add=' . urlencode(htmlspecialchars_decode($member['username']))) : '',
         'U_REMOVE_FRIEND'   => ($friend && $friends_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&amp;remove=1&amp;usernames[]=' . $user_id) : '',
         'U_REMOVE_FOE'      => ($foe && $foes_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&amp;remove=1&amp;mode=foes&amp;usernames[]=' . $user_id) : '',
      ));

      if (!empty($profile_fields['row']))
      {
         $template->assign_vars($profile_fields['row']);
      }

      if (!empty($profile_fields['blockrow']))
      {
         foreach ($profile_fields['blockrow'] as $field_data)
         {
            $template->assign_block_vars('custom_fields', $field_data);
         }
      }

      // Inactive reason/account?
      if ($member['user_type'] == USER_INACTIVE)
      {
         $user->add_lang('acp/common');

         $inactive_reason = $user->lang['INACTIVE_REASON_UNKNOWN'];

         switch ($member['user_inactive_reason'])
         {
            case INACTIVE_REGISTER:
               $inactive_reason = $user->lang['INACTIVE_REASON_REGISTER'];
            break;

            case INACTIVE_PROFILE:
               $inactive_reason = $user->lang['INACTIVE_REASON_PROFILE'];
            break;

            case INACTIVE_MANUAL:
               $inactive_reason = $user->lang['INACTIVE_REASON_MANUAL'];
            break;

            case INACTIVE_REMIND:
               $inactive_reason = $user->lang['INACTIVE_REASON_REMIND'];
            break;
         }

         $template->assign_vars(array(
            'S_USER_INACTIVE'      => true,
            'USER_INACTIVE_REASON'   => $inactive_reason)
         );
      }

      // Now generate page title
      $page_title = sprintf($user->lang['VIEWING_PROFILE'], $member['username']);
      $template_html = 'memberlist_view.html';

   break;

   case 'email':

      // Send an email
      $page_title = $user->lang['SEND_EMAIL'];
      $template_html = 'memberlist_email.html';

      add_form_key('memberlist_email');

      if (!$config['email_enable'])
      {
         trigger_error('EMAIL_DISABLED');
      }

      if (!$auth->acl_get('u_sendemail'))
      {
         trigger_error('NO_EMAIL');
      }

      // Are we trying to abuse the facility?
      if (time() - $user->data['user_emailtime'] < $config['flood_interval'])
      {
         trigger_error('FLOOD_EMAIL_LIMIT');
      }

      // Determine action...
      $user_id = request_var('u', 0);
      $topic_id = request_var('t', 0);

      // Send email to user...
      if ($user_id)
      {
         if ($user_id == ANONYMOUS || !$config['board_email_form'])
         {
            trigger_error('NO_EMAIL');
         }

         // Get the appropriate username, etc.
         $sql = 'SELECT username, user_email, user_allow_viewemail, user_lang, user_jabber, user_notify_type
            FROM ' . USERS_TABLE . "
            WHERE user_id = $user_id
               AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
         $result = $db->sql_query($sql);
         $row = $db->sql_fetchrow($result);
         $db->sql_freeresult($result);

         if (!$row)
         {
            trigger_error('NO_USER');
         }

         // Can we send email to this user?
         if (!$row['user_allow_viewemail'] && !$auth->acl_get('a_user'))
         {
            trigger_error('NO_EMAIL');
         }
      }
      else if ($topic_id)
      {
         // Send topic heads-up to email address
         $sql = 'SELECT forum_id, topic_title
            FROM ' . TOPICS_TABLE . "
            WHERE topic_id = $topic_id";
         $result = $db->sql_query($sql);
         $row = $db->sql_fetchrow($result);
         $db->sql_freeresult($result);

         if (!$row)
         {
            trigger_error('NO_TOPIC');
         }

         if ($row['forum_id'])
         {
            if (!$auth->acl_get('f_read', $row['forum_id']))
            {
               trigger_error('SORRY_AUTH_READ');
            }

            if (!$auth->acl_get('f_email', $row['forum_id']))
            {
               trigger_error('NO_EMAIL');
            }
         }
         else
         {
            // If global announcement, we need to check if the user is able to at least read and email in one forum...
            if (!$auth->acl_getf_global('f_read'))
            {
               trigger_error('SORRY_AUTH_READ');
            }

            if (!$auth->acl_getf_global('f_email'))
            {
               trigger_error('NO_EMAIL');
            }
         }
      }
      else
      {
         trigger_error('NO_EMAIL');
      }

      $error = array();

      $name      = utf8_normalize_nfc(request_var('name', '', true));
      $email      = request_var('email', '');
      $email_lang = request_var('lang', $config['default_lang']);
      $subject   = utf8_normalize_nfc(request_var('subject', '', true));
      $message   = utf8_normalize_nfc(request_var('message', '', true));
      $cc         = (isset($_POST['cc_email'])) ? true : false;
      $submit      = (isset($_POST['submit'])) ? true : false;

      if ($submit)
      {
         if (!check_form_key('memberlist_email'))
         {
            $error[] = 'FORM_INVALID';
         }
         if ($user_id)
         {
            if (!$subject)
            {
               $error[] = $user->lang['EMPTY_SUBJECT_EMAIL'];
            }

            if (!$message)
            {
               $error[] = $user->lang['EMPTY_MESSAGE_EMAIL'];
            }

            $name = $row['username'];
            $email_lang = $row['user_lang'];
            $email = $row['user_email'];
         }
         else
         {
            if (!$email || !preg_match('/^' . get_preg_expression('email') . '$/i', $email))
            {
               $error[] = $user->lang['EMPTY_ADDRESS_EMAIL'];
            }

            if (!$name)
            {
               $error[] = $user->lang['EMPTY_NAME_EMAIL'];
            }
         }

         if (!sizeof($error))
         {
            $sql = 'UPDATE ' . USERS_TABLE . '
               SET user_emailtime = ' . time() . '
               WHERE user_id = ' . $user->data['user_id'];
            $result = $db->sql_query($sql);

            include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
            $messenger = new messenger(false);
            $email_tpl = ($user_id) ? 'profile_send_email' : 'email_notify';

            $mail_to_users = array();

            $mail_to_users[] = array(
               'email_lang'      => $email_lang,
               'email'            => $email,
               'name'            => $name,
               'username'         => ($user_id) ? $row['username'] : '',
               'to_name'         => $name,
               'user_jabber'      => ($user_id) ? $row['user_jabber'] : '',
               'user_notify_type'   => ($user_id) ? $row['user_notify_type'] : NOTIFY_EMAIL,
               'topic_title'      => (!$user_id) ? $row['topic_title'] : '',
               'forum_id'         => (!$user_id) ? $row['forum_id'] : 0,
            );

            // Ok, now the same email if CC specified, but without exposing the users email address
            if ($cc)
            {
               $mail_to_users[] = array(
                  'email_lang'      => $user->data['user_lang'],
                  'email'            => $user->data['user_email'],
                  'name'            => $user->data['username'],
                  'username'         => $user->data['username'],
                  'to_name'         => $name,
                  'user_jabber'      => $user->data['user_jabber'],
                  'user_notify_type'   => ($user_id) ? $user->data['user_notify_type'] : NOTIFY_EMAIL,
                  'topic_title'      => (!$user_id) ? $row['topic_title'] : '',
                  'forum_id'         => (!$user_id) ? $row['forum_id'] : 0,
               );
            }

            foreach ($mail_to_users as $row)
            {
               $messenger->template($email_tpl, $row['email_lang']);
               $messenger->replyto($user->data['user_email']);
               $messenger->to($row['email'], $row['name']);

               if ($user_id)
               {
                  $messenger->subject(htmlspecialchars_decode($subject));
                  $messenger->im($row['user_jabber'], $row['username']);
                  $notify_type = $row['user_notify_type'];
               }
               else
               {
                  $notify_type = NOTIFY_EMAIL;
               }

               $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
               $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
               $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
               $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);

               $messenger->assign_vars(array(
                  'BOARD_CONTACT'   => $config['board_contact'],
                  'TO_USERNAME'   => htmlspecialchars_decode($row['to_name']),
                  'FROM_USERNAME'   => htmlspecialchars_decode($user->data['username']),
                  'MESSAGE'      => htmlspecialchars_decode($message))
               );

               if ($topic_id)
               {
                  $messenger->assign_vars(array(
                     'TOPIC_NAME'   => htmlspecialchars_decode($row['topic_title']),
                     'U_TOPIC'      => generate_board_url() . "/viewtopic.$phpEx?f=" . $row['forum_id'] . "&t=$topic_id")
                  );
               }

               $messenger->send($notify_type);
            }

            meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
            $message = ($user_id) ? sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>') : sprintf($user->lang['RETURN_TOPIC'],  '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$row['forum_id']}&amp;t=$topic_id") . '">', '</a>');
            trigger_error($user->lang['EMAIL_SENT'] . '<br /><br />' . $message);
         }
      }

      if ($user_id)
      {
         $template->assign_vars(array(
            'S_SEND_USER'   => true,
            'USERNAME'      => $row['username'],

            'L_EMAIL_BODY_EXPLAIN'   => $user->lang['EMAIL_BODY_EXPLAIN'],
            'S_POST_ACTION'         => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=email&amp;u=' . $user_id))
         );
      }
      else
      {
         $template->assign_vars(array(
            'EMAIL'            => $email,
            'NAME'            => $name,
            'S_LANG_OPTIONS'   => language_select($email_lang),

            'L_EMAIL_BODY_EXPLAIN'   => $user->lang['EMAIL_TOPIC_EXPLAIN'],
            'S_POST_ACTION'         => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=email&amp;t=' . $topic_id))
         );
      }

      $template->assign_vars(array(
         'ERROR_MESSAGE'      => (sizeof($error)) ? implode('<br />', $error) : '',
         'SUBJECT'         => $subject,
         'MESSAGE'         => $message,
         )
      );

   break;

   case 'group':
   default:
      // The basic memberlist
      $page_title = $user->lang['MEMBERLIST'];
      $template_html = 'memberlist_body.html';

      // Sorting
      $sort_key_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_LOCATION'], 'c' => $user->lang['SORT_JOINED'], 'd' => $user->lang['SORT_POST_COUNT'], 'f' => $user->lang['WEBSITE'], 'g' => $user->lang['ICQ'], 'h' => $user->lang['AIM'], 'i' => $user->lang['MSNM'], 'j' => $user->lang['YIM'], 'k' => $user->lang['JABBER']);
      $sort_key_sql = array('a' => 'u.username_clean', 'b' => 'u.user_from', 'c' => 'u.user_regdate', 'd' => 'u.user_posts', 'f' => 'u.user_website', 'g' => 'u.user_icq', 'h' => 'u.user_aim', 'i' => 'u.user_msnm', 'j' => 'u.user_yim', 'k' => 'u.user_jabber');

      if ($auth->acl_get('a_user'))
      {
         $sort_key_text['e'] = $user->lang['SORT_EMAIL'];
         $sort_key_sql['e'] = 'u.user_email';
      }

      if ($auth->acl_get('u_viewonline'))
      {
         $sort_key_text['l'] = $user->lang['SORT_LAST_ACTIVE'];
         $sort_key_sql['l'] = 'u.user_lastvisit';
      }

      $sort_key_text['m'] = $user->lang['SORT_RANK'];
      $sort_key_sql['m'] = 'u.user_rank';

      $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']);

      $s_sort_key = '';
      foreach ($sort_key_text as $key => $value)
      {
         $selected = ($sort_key == $key) ? ' selected="selected"' : '';
         $s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
      }

      $s_sort_dir = '';
      foreach ($sort_dir_text as $key => $value)
      {
         $selected = ($sort_dir == $key) ? ' selected="selected"' : '';
         $s_sort_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
      }

      // Additional sorting options for user search ... if search is enabled, if not
      // then only admins can make use of this (for ACP functionality)
      $sql_select = $sql_where_data = $sql_from = $sql_where = $order_by = '';


      $form         = request_var('form', '');
      $field         = request_var('field', '');
      $select_single    = request_var('select_single', false);

      // Search URL parameters, if any of these are in the URL we do a search
      $search_params = array('username', 'email', 'icq', 'aim', 'yahoo', 'msn', 'jabber', 'search_group_id', 'joined_select', 'active_select', 'count_select', 'joined', 'active', 'count', 'ip');

      // We validate form and field here, only id/class allowed
      $form = (!preg_match('/^[a-z0-9_-]+$/i', $form)) ? '' : $form;
      $field = (!preg_match('/^[a-z0-9_-]+$/i', $field)) ? '' : $field;
      if (($mode == 'searchuser' || sizeof(array_intersect(array_keys($_GET), $search_params)) > 0) && ($config['load_search'] || $auth->acl_get('a_')))
      {
         $username   = request_var('username', '', true);
         $email      = strtolower(request_var('email', ''));
         $icq      = request_var('icq', '');
         $aim      = request_var('aim', '');
         $yahoo      = request_var('yahoo', '');
         $msn      = request_var('msn', '');
         $jabber      = request_var('jabber', '');
         $search_group_id   = request_var('search_group_id', 0);

         // when using these, make sure that we actually have values defined in $find_key_match
         $joined_select   = request_var('joined_select', 'lt');
         $active_select   = request_var('active_select', 'lt');
         $count_select   = request_var('count_select', 'eq');

         $joined         = explode('-', request_var('joined', ''));
         $active         = explode('-', request_var('active', ''));
         $count         = (request_var('count', '') !== '') ? request_var('count', 0) : '';
         $ipdomain      = request_var('ip', '');

         $find_key_match = array('lt' => '<', 'gt' => '>', 'eq' => '=');

         $find_count = array('lt' => $user->lang['LESS_THAN'], 'eq' => $user->lang['EQUAL_TO'], 'gt' => $user->lang['MORE_THAN']);
         $s_find_count = '';
         foreach ($find_count as $key => $value)
         {
            $selected = ($count_select == $key) ? ' selected="selected"' : '';
            $s_find_count .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
         }

         $find_time = array('lt' => $user->lang['BEFORE'], 'gt' => $user->lang['AFTER']);
         $s_find_join_time = '';
         foreach ($find_time as $key => $value)
         {
            $selected = ($joined_select == $key) ? ' selected="selected"' : '';
            $s_find_join_time .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
         }

         $s_find_active_time = '';
         foreach ($find_time as $key => $value)
         {
            $selected = ($active_select == $key) ? ' selected="selected"' : '';
            $s_find_active_time .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
         }

         $sql_where .= ($username) ? ' AND u.username_clean ' . $db->sql_like_expression(str_replace('*', $db->any_char, utf8_clean_string($username))) : '';
         $sql_where .= ($auth->acl_get('a_user') && $email) ? ' AND u.user_email ' . $db->sql_like_expression(str_replace('*', $db->any_char, $email)) . ' ' : '';
         $sql_where .= ($icq) ? ' AND u.user_icq ' . $db->sql_like_expression(str_replace('*', $db->any_char, $icq)) . ' ' : '';
         $sql_where .= ($aim) ? ' AND u.user_aim ' . $db->sql_like_expression(str_replace('*', $db->any_char, $aim)) . ' ' : '';
         $sql_where .= ($yahoo) ? ' AND u.user_yim ' . $db->sql_like_expression(str_replace('*', $db->any_char, $yahoo)) . ' ' : '';
         $sql_where .= ($msn) ? ' AND u.user_msnm ' . $db->sql_like_expression(str_replace('*', $db->any_char, $msn)) . ' ' : '';
         $sql_where .= ($jabber) ? ' AND u.user_jabber ' . $db->sql_like_expression(str_replace('*', $db->any_char, $jabber)) . ' ' : '';
         $sql_where .= (is_numeric($count) && isset($find_key_match[$count_select])) ? ' AND u.user_posts ' . $find_key_match[$count_select] . ' ' . (int) $count . ' ' : '';
         $sql_where .= (sizeof($joined) > 1 && isset($find_key_match[$joined_select])) ? " AND u.user_regdate " . $find_key_match[$joined_select] . ' ' . gmmktime(0, 0, 0, intval($joined[1]), intval($joined[2]), intval($joined[0])) : '';
         $sql_where .= ($auth->acl_get('u_viewonline') && sizeof($active) > 1 && isset($find_key_match[$active_select])) ? " AND u.user_lastvisit " . $find_key_match[$active_select] . ' ' . gmmktime(0, 0, 0, $active[1], intval($active[2]), intval($active[0])) : '';
         $sql_where .= ($search_group_id) ? " AND u.user_id = ug.user_id AND ug.group_id = $search_group_id AND ug.user_pending = 0 " : '';

         if ($search_group_id)
         {
            $sql_from = ', ' . USER_GROUP_TABLE . ' ug ';
         }

         if ($ipdomain && $auth->acl_getf_global('m_info'))
         {
            if (strspn($ipdomain, 'abcdefghijklmnopqrstuvwxyz'))
            {
               $hostnames = gethostbynamel($ipdomain);

               if ($hostnames !== false)
               {
                  $ips = "'" . implode('', '', array_map(array($db, 'sql_escape'), preg_replace('#([0-9]{1,3}.[0-9]{1,3}[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3})#', "\1", gethostbynamel($ipdomain)))) . "'";
               }
               else
               {
                  $ips = false;
               }
            }
            else
            {
               $ips = "'" . str_replace('*', '%', $db->sql_escape($ipdomain)) . "'";
            }

            if ($ips === false)
            {
               // A minor fudge but it does the job :D
               $sql_where .= " AND u.user_id = 0";
            }
            else
            {
               $ip_forums = array_keys($auth->acl_getf('m_info', true));

               $sql = 'SELECT DISTINCT poster_id
                  FROM ' . POSTS_TABLE . '
                  WHERE poster_ip ' . ((strpos($ips, '%') !== false) ? 'LIKE' : 'IN') . " ($ips)
                     AND forum_id IN (0, " . implode(', ', $ip_forums) . ')';
               $result = $db->sql_query($sql);

               if ($row = $db->sql_fetchrow($result))
               {
                  $ip_sql = array();
                  do
                  {
                     $ip_sql[] = $row['poster_id'];
                  }
                  while ($row = $db->sql_fetchrow($result));

                  $sql_where .= ' AND ' . $db->sql_in_set('u.user_id', $ip_sql);
               }
               else
               {
                  // A minor fudge but it does the job :D
                  $sql_where .= " AND u.user_id = 0";
               }
               unset($ip_forums);

               $db->sql_freeresult($result);
            }
         }
      }

      $first_char = request_var('first_char', '');

      if ($first_char == 'other')
      {
         for ($i = 97; $i < 123; $i++)
         {
            $sql_where .= ' AND u.username_clean NOT ' . $db->sql_like_expression(chr($i) . $db->any_char);
         }
      }
      else if ($first_char)
      {
         $sql_where .= ' AND u.username_clean ' . $db->sql_like_expression(substr($first_char, 0, 1) . $db->any_char);
      }

      // Are we looking at a usergroup? If so, fetch additional info
      // and further restrict the user info query
      if ($mode == 'group')
      {
         // We JOIN here to save a query for determining membership for hidden groups. ;)
         $sql = 'SELECT g.*, ug.user_id
            FROM ' . GROUPS_TABLE . ' g
            LEFT JOIN ' . USER_GROUP_TABLE . ' ug ON (ug.user_pending = 0 AND ug.user_id = ' . $user->data['user_id'] . " AND ug.group_id = $group_id)
            WHERE g.group_id = $group_id";
         $result = $db->sql_query($sql);
         $group_row = $db->sql_fetchrow($result);
         $db->sql_freeresult($result);

         if (!$group_row)
         {
            trigger_error('NO_GROUP');
         }

         switch ($group_row['group_type'])
         {
            case GROUP_OPEN:
               $group_row['l_group_type'] = 'OPEN';
            break;

            case GROUP_CLOSED:
               $group_row['l_group_type'] = 'CLOSED';
            break;

            case GROUP_HIDDEN:
               $group_row['l_group_type'] = 'HIDDEN';

               // Check for membership or special permissions
               if (!$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $group_row['user_id'] != $user->data['user_id'])
               {
                  trigger_error('NO_GROUP');
               }
            break;

            case GROUP_SPECIAL:
               $group_row['l_group_type'] = 'SPECIAL';
            break;

            case GROUP_FREE:
               $group_row['l_group_type'] = 'FREE';
            break;
         }

         // Misusing the avatar function for displaying group avatars...
         $avatar_img = get_user_avatar($group_row['group_avatar'], $group_row['group_avatar_type'], $group_row['group_avatar_width'], $group_row['group_avatar_height'], 'GROUP_AVATAR');

         $rank_title = $rank_img = $rank_img_src = '';
         if ($group_row['group_rank'])
         {
            if (isset($ranks['special'][$group_row['group_rank']]))
            {
               $rank_title = $ranks['special'][$group_row['group_rank']]['rank_title'];
            }
            $rank_img = (!empty($ranks['special'][$group_row['group_rank']]['rank_image'])) ? '<img src="' . $config['ranks_path'] . '/' . $ranks['special'][$group_row['group_rank']]['rank_image'] . '" alt="' . $ranks['special'][$group_row['group_rank']]['rank_title'] . '" title="' . $ranks['special'][$group_row['group_rank']]['rank_title'] . '" /><br />' : '';
            $rank_img_src = (!empty($ranks['special'][$group_row['group_rank']]['rank_image'])) ? $config['ranks_path'] . '/' . $ranks['special'][$group_row['group_rank']]['rank_image'] : '';
         }
         else
         {
            $rank_title = '';
            $rank_img = '';
            $rank_img_src = '';
         }

         $template->assign_vars(array(
            'GROUP_DESC'   => generate_text_for_display($group_row['group_desc'], $group_row['group_desc_uid'], $group_row['group_desc_bitfield'], $group_row['group_desc_options']),
            'GROUP_NAME'   => ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'],
            'GROUP_COLOR'   => $group_row['group_colour'],
            'GROUP_TYPE'   => $user->lang['GROUP_IS_' . $group_row['l_group_type']],
            'GROUP_RANK'   => $rank_title,

            'AVATAR_IMG'   => $avatar_img,
            'RANK_IMG'      => $rank_img,
            'RANK_IMG_SRC'   => $rank_img_src,

            'U_PM'         => ($auth->acl_get('u_sendpm') && $auth->acl_get('u_masspm_group') && $group_row['group_receive_pm'] && $config['allow_privmsg'] && $config['allow_mass_pm']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;mode=compose&amp;g=' . $group_id) : '',)
         );

         $sql_select = ', ug.group_leader';
         $sql_from = ', ' . USER_GROUP_TABLE . ' ug ';
         $order_by = 'ug.group_leader DESC, ';

         $sql_where .= " AND ug.user_pending = 0 AND u.user_id = ug.user_id AND ug.group_id = $group_id";
         $sql_where_data = " AND u.user_id = ug.user_id AND ug.group_id = $group_id";
      }

      // Sorting and order
      if (!isset($sort_key_sql[$sort_key]))
      {
         $sort_key = $default_key;
      }

      $order_by .= $sort_key_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC');

      // Unfortunately we must do this here for sorting by rank, else the sort order is applied wrongly
      if ($sort_key == 'm')
      {
         $order_by .= ', u.user_posts DESC';
      }

      // Count the users ...
      if ($sql_where)
      {
         $sql = 'SELECT COUNT(u.user_id) AS total_users
            FROM ' . USERS_TABLE . " u$sql_from
            WHERE u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ")
            $sql_where";
         $result = $db->sql_query($sql);
         $total_users = (int) $db->sql_fetchfield('total_users');
         $db->sql_freeresult($result);
      }
      else
      {
         $total_users = $config['num_users'];
      }

      $s_char_options = '<option value=""' . ((!$first_char) ? ' selected="selected"' : '') . '>&nbsp; &nbsp;</option>';
      for ($i = 97; $i < 123; $i++)
      {
         $s_char_options .= '<option value="' . chr($i) . '"' . (($first_char == chr($i)) ? ' selected="selected"' : '') . '>' . chr($i-32) . '</option>';
      }
      $s_char_options .= '<option value="other"' . (($first_char == 'other') ? ' selected="selected"' : '') . '>' . $user->lang['OTHER'] . '</option>';

      // Build a relevant pagination_url
      $params = $sort_params = array();

      // We do not use request_var() here directly to save some calls (not all variables are set)
      $check_params = array(
         'g'            => array('g', 0),
         'sk'         => array('sk', $default_key),
         'sd'         => array('sd', 'a'),
         'form'         => array('form', ''),
         'field'         => array('field', ''),
         'select_single'   => array('select_single', $select_single),
         'username'      => array('username', '', true),
         'email'         => array('email', ''),
         'icq'         => array('icq', ''),
         'aim'         => array('aim', ''),
         'yahoo'         => array('yahoo', ''),
         'msn'         => array('msn', ''),
         'jabber'      => array('jabber', ''),
         'search_group_id'   => array('search_group_id', 0),
         'joined_select'   => array('joined_select', 'lt'),
         'active_select'   => array('active_select', 'lt'),
         'count_select'   => array('count_select', 'eq'),
         'joined'      => array('joined', ''),
         'active'      => array('active', ''),
         'count'         => (request_var('count', '') !== '') ? array('count', 0) : array('count', ''),
         'ip'         => array('ip', ''),
         'first_char'   => array('first_char', ''),
      );

      foreach ($check_params as $key => $call)
      {
         if (!isset($_REQUEST[$key]))
         {
            continue;
         }

         $param = call_user_func_array('request_var', $call);
         $param = urlencode($key) . '=' . ((is_string($param)) ? urlencode($param) : $param);
         $params[] = $param;

         if ($key != 'sk' && $key != 'sd')
         {
            $sort_params[] = $param;
         }
      }

      $u_hide_find_member = append_sid("{$phpbb_root_path}memberlist.$phpEx", "start=$start" . (!empty($params) ? '&amp;' . implode('&amp;', $params) : ''));

      if ($mode)
      {
         $params[] = "mode=$mode";
      }
      $sort_params[] = "mode=$mode";

      $pagination_url = append_sid("{$phpbb_root_path}memberlist.$phpEx", implode('&amp;', $params));
      $sort_url = append_sid("{$phpbb_root_path}memberlist.$phpEx", implode('&amp;', $sort_params));

      unset($search_params, $sort_params);

      // Some search user specific data
      if ($mode == 'searchuser' && ($config['load_search'] || $auth->acl_get('a_')))
      {
         $group_selected = request_var('search_group_id', 0);
         $s_group_select = '<option value="0"' . ((!$group_selected) ? ' selected="selected"' : '') . '>&nbsp;</option>';
         $group_ids = array();

         /**
         * @todo add this to a separate function (function is responsible for returning the groups the user is able to see based on the users group membership)
         */

         if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel'))
         {
            $sql = 'SELECT group_id, group_name, group_type
               FROM ' . GROUPS_TABLE;

            if (!$config['coppa_enable'])
            {
               $sql .= " WHERE group_name <> 'REGISTERED_COPPA'";
            }

            $sql .= ' ORDER BY group_name ASC';
         }
         else
         {
            $sql = 'SELECT g.group_id, g.group_name, g.group_type
               FROM ' . GROUPS_TABLE . ' g
               LEFT JOIN ' . USER_GROUP_TABLE . ' ug
                  ON (
                     g.group_id = ug.group_id
                     AND ug.user_id = ' . $user->data['user_id'] . '
                     AND ug.user_pending = 0
                  )
               WHERE (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ')';

            if (!$config['coppa_enable'])
            {
               $sql .= " AND g.group_name <> 'REGISTERED_COPPA'";
            }

            $sql .= ' ORDER BY g.group_name ASC';
         }
         $result = $db->sql_query($sql);

         while ($row = $db->sql_fetchrow($result))
         {
            $group_ids[] = $row['group_id'];
            $s_group_select .= '<option value="' . $row['group_id'] . '"' . (($group_selected == $row['group_id']) ? ' selected="selected"' : '') . '>' . (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>';
         }
         $db->sql_freeresult($result);

         if ($group_selected !== 0 && !in_array($group_selected, $group_ids))
         {
            trigger_error('NO_GROUP');
         }

         $template->assign_vars(array(
            'USERNAME'   => $username,
            'EMAIL'      => $email,
            'ICQ'      => $icq,
            'AIM'      => $aim,
            'YAHOO'      => $yahoo,
            'MSNM'      => $msn,
            'JABBER'   => $jabber,
            'JOINED'   => implode('-', $joined),
            'ACTIVE'   => implode('-', $active),
            'COUNT'      => $count,
            'IP'      => $ipdomain,

            'S_IP_SEARCH_ALLOWED'   => ($auth->acl_getf_global('m_info')) ? true : false,
            'S_EMAIL_SEARCH_ALLOWED'=> ($auth->acl_get('a_user')) ? true : false,
            'S_IN_SEARCH_POPUP'      => ($form && $field) ? true : false,
            'S_SEARCH_USER'         => true,
            'S_FORM_NAME'         => $form,
            'S_FIELD_NAME'         => $field,
            'S_SELECT_SINGLE'      => $select_single,
            'S_COUNT_OPTIONS'      => $s_find_count,
            'S_SORT_OPTIONS'      => $s_sort_key,
            'S_JOINED_TIME_OPTIONS'   => $s_find_join_time,
            'S_ACTIVE_TIME_OPTIONS'   => $s_find_active_time,
            'S_GROUP_SELECT'      => $s_group_select,
            'S_USER_SEARCH_ACTION'   => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=searchuser&amp;form=$form&amp;field=$field"))
         );
      }

      // Get us some users :D
      $sql = "SELECT u.user_id
         FROM " . USERS_TABLE . " u
            $sql_from
         WHERE u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ")
            $sql_where
         ORDER BY $order_by";
      $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);

      $user_list = array();
      while ($row = $db->sql_fetchrow($result))
      {
         $user_list[] = (int) $row['user_id'];
      }
      $db->sql_freeresult($result);
      $leaders_set = false;
      // So, did we get any users?
      if (sizeof($user_list))
      {
         // Session time?! Session time...
         $sql = 'SELECT session_user_id, MAX(session_time) AS session_time
            FROM ' . SESSIONS_TABLE . '
            WHERE session_time >= ' . (time() - $config['session_length']) . '
               AND ' . $db->sql_in_set('session_user_id', $user_list) . '
            GROUP BY session_user_id';
         $result = $db->sql_query($sql);

         $session_times = array();
         while ($row = $db->sql_fetchrow($result))
         {
            $session_times[$row['session_user_id']] = $row['session_time'];
         }
         $db->sql_freeresult($result);

         // Do the SQL thang
         if ($mode == 'group')
         {
            $sql = "SELECT u.*
                  $sql_select
               FROM " . USERS_TABLE . " u
                  $sql_from
               WHERE " . $db->sql_in_set('u.user_id', $user_list) . "
                  $sql_where_data";
         }
         else
         {
            $sql = 'SELECT *
               FROM ' . USERS_TABLE . '
               WHERE ' . $db->sql_in_set('user_id', $user_list);
         }
         $result = $db->sql_query($sql);

         $id_cache = array();
         while ($row = $db->sql_fetchrow($result))
         {
            $row['session_time'] = (!empty($session_times[$row['user_id']])) ? $session_times[$row['user_id']] : 0;
            $row['last_visit'] = (!empty($row['session_time'])) ? $row['session_time'] : $row['user_lastvisit'];

            $id_cache[$row['user_id']] = $row;
         }
         $db->sql_freeresult($result);

         // Load custom profile fields
         if ($config['load_cpf_memberlist'])
         {
            include_once($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
            $cp = new custom_profile();

            // Grab all profile fields from users in id cache for later use - similar to the poster cache
            $profile_fields_cache = $cp->generate_profile_fields_template('grab', $user_list);
         }

         // If we sort by last active date we need to adjust the id cache due to user_lastvisit not being the last active date...
         if ($sort_key == 'l')
         {
//            uasort($id_cache, create_function('$first, $second', "return ($first['last_visit'] == $second['last_visit']) ? 0 : (($first['last_visit'] < $second['last_visit']) ? $lesser_than : ($lesser_than * -1));"));
            usort($user_list,  '_sort_last_active');
         }

         for ($i = 0, $end = sizeof($user_list); $i < $end; ++$i)
         {
            $user_id = $user_list[$i];
            $row =& $id_cache[$user_id];
            $is_leader = (isset($row['group_leader']) && $row['group_leader']) ? true : false;
            $leaders_set = ($leaders_set || $is_leader);

            $cp_row = array();
            if ($config['load_cpf_memberlist'])
            {
               $cp_row = (isset($profile_fields_cache[$user_id])) ? $cp->generate_profile_fields_template('show', false, $profile_fields_cache[$user_id]) : array();
            }

            $memberrow = array_merge(show_profile($row), array(
               'ROW_NUMBER'      => $i + ($start + 1),

               'S_CUSTOM_PROFILE'   => (isset($cp_row['row']) && sizeof($cp_row['row'])) ? true : false,
               'S_GROUP_LEADER'   => $is_leader,

               'U_VIEW_PROFILE'   => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&amp;u=' . $user_id))
            );

            if (isset($cp_row['row']) && sizeof($cp_row['row']))
            {
               $memberrow = array_merge($memberrow, $cp_row['row']);
            }

            $template->assign_block_vars('memberrow', $memberrow);

            if (isset($cp_row['blockrow']) && sizeof($cp_row['blockrow']))
            {
               foreach ($cp_row['blockrow'] as $field_data)
               {
                  $template->assign_block_vars('memberrow.custom_fields', $field_data);
               }
            }

            unset($id_cache[$user_id]);
         }
      }

      // Generate page
      $template->assign_vars(array(
         'PAGINATION'   => generate_pagination($pagination_url, $total_users, $config['topics_per_page'], $start),
         'PAGE_NUMBER'   => on_page($total_users, $config['topics_per_page'], $start),
         'TOTAL_USERS'   => ($total_users == 1) ? $user->lang['LIST_USER'] : sprintf($user->lang['LIST_USERS'], $total_users),

         'PROFILE_IMG'   => $user->img('icon_user_profile', $user->lang['PROFILE']),
         'PM_IMG'      => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']),
         'EMAIL_IMG'      => $user->img('icon_contact_email', $user->lang['EMAIL']),
         'WWW_IMG'      => $user->img('icon_contact_www', $user->lang['WWW']),
         'ICQ_IMG'      => $user->img('icon_contact_icq', $user->lang['ICQ']),
         'AIM_IMG'      => $user->img('icon_contact_aim', $user->lang['AIM']),
         'MSN_IMG'      => $user->img('icon_contact_msnm', $user->lang['MSNM']),
         'YIM_IMG'      => $user->img('icon_contact_yahoo', $user->lang['YIM']),
         'JABBER_IMG'   => $user->img('icon_contact_jabber', $user->lang['JABBER']),
         'SEARCH_IMG'   => $user->img('icon_user_search', $user->lang['SEARCH']),

         'U_FIND_MEMBER'         => ($config['load_search'] || $auth->acl_get('a_')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser' . (($start) ? "&amp;start=$start" : '') . (!empty($params) ? '&amp;' . implode('&amp;', $params) : '')) : '',
         'U_HIDE_FIND_MEMBER'   => ($mode == 'searchuser') ? $u_hide_find_member : '',
         'U_SORT_USERNAME'      => $sort_url . '&amp;sk=a&amp;sd=' . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a'),
         'U_SORT_FROM'         => $sort_url . '&amp;sk=b&amp;sd=' . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a'),
         'U_SORT_JOINED'         => $sort_url . '&amp;sk=c&amp;sd=' . (($sort_key == 'c' && $sort_dir == 'a') ? 'd' : 'a'),
         'U_SORT_POSTS'         => $sort_url . '&amp;sk=d&amp;sd=' . (($sort_key == 'd' && $sort_dir == 'a') ? 'd' : 'a'),
         'U_SORT_EMAIL'         => $sort_url . '&amp;sk=e&amp;sd=' . (($sort_key == 'e' && $sort_dir == 'a') ? 'd' : 'a'),
         'U_SORT_WEBSITE'      => $sort_url . '&amp;sk=f&amp;sd=' . (($sort_key == 'f' && $sort_dir == 'a') ? 'd' : 'a'),
         'U_SORT_LOCATION'      => $sort_url . '&amp;sk=b&amp;sd=' . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a'),
         'U_SORT_ICQ'         => $sort_url . '&amp;sk=g&amp;sd=' . (($sort_key == 'g' && $sort_dir == 'a') ? 'd' : 'a'),
         'U_SORT_AIM'         => $sort_url . '&amp;sk=h&amp;sd=' . (($sort_key == 'h' && $sort_dir == 'a') ? 'd' : 'a'),
         'U_SORT_MSN'         => $sort_url . '&amp;sk=i&amp;sd=' . (($sort_key == 'i' && $sort_dir == 'a') ? 'd' : 'a'),
         'U_SORT_YIM'         => $sort_url . '&amp;sk=j&amp;sd=' . (($sort_key == 'j' && $sort_dir == 'a') ? 'd' : 'a'),
         'U_SORT_ACTIVE'         => ($auth->acl_get('u_viewonline')) ? $sort_url . '&amp;sk=l&amp;sd=' . (($sort_key == 'l' && $sort_dir == 'a') ? 'd' : 'a') : '',
         'U_SORT_RANK'         => $sort_url . '&amp;sk=m&amp;sd=' . (($sort_key == 'm' && $sort_dir == 'a') ? 'd' : 'a'),
         'U_LIST_CHAR'         => $sort_url . '&amp;sk=a&amp;sd=' . (($sort_key == 'l' && $sort_dir == 'a') ? 'd' : 'a'),

         'S_SHOW_GROUP'      => ($mode == 'group') ? true : false,
         'S_VIEWONLINE'      => $auth->acl_get('u_viewonline'),
         'S_LEADERS_SET'      => $leaders_set,
         'S_MODE_SELECT'      => $s_sort_key,
         'S_ORDER_SELECT'   => $s_sort_dir,
         'S_CHAR_OPTIONS'   => $s_char_options,
         'S_MODE_ACTION'      => $pagination_url)
      );
}

// Output the page
page_header($page_title, false);

$template->set_filenames(array(
   'body' => $template_html)
);
make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));

page_footer();

/**
* Prepare profile data
*/
function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = false)
{
   global $config, $auth, $template, $user, $phpEx, $phpbb_root_path;

   $username = $data['username'];
   $user_id = $data['user_id'];

   $rank_title = $rank_img = $rank_img_src = '';
   get_user_rank($data['user_rank'], (($user_id == ANONYMOUS) ? false : $data['user_posts']), $rank_title, $rank_img, $rank_img_src);

   if (!empty($data['user_allow_viewemail']) || $auth->acl_get('a_user'))
   {
      $email = ($config['board_email_form'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=email&amp;u=' . $user_id) : (($config['board_hide_emails'] && !$auth->acl_get('a_user')) ? '' : 'mailto:' . $data['user_email']);
   }
   else
   {
      $email = '';
   }

   if ($config['load_onlinetrack'])
   {
      $update_time = $config['load_online_time'] * 60;
      $online = (time() - $update_time < $data['session_time'] && ((isset($data['session_viewonline']) && $data['session_viewonline']) || $auth->acl_get('u_viewonline'))) ? true : false;
   }
   else
   {
      $online = false;
   }

   if ($data['user_allow_viewonline'] || $auth->acl_get('u_viewonline'))
   {
      $last_visit = (!empty($data['session_time'])) ? $data['session_time'] : $data['user_lastvisit'];
   }
   else
   {
      $last_visit = '';
   }

   $age = '';

   if ($config['allow_birthdays'] && $data['user_birthday'])
   {
      list($bday_day, $bday_month, $bday_year) = array_map('intval', explode('-', $data['user_birthday']));

      if ($bday_year)
      {
         $now = getdate(time() + $user->timezone + $user->dst - date('Z'));

         $diff = $now['mon'] - $bday_month;
         if ($diff == 0)
         {
            $diff = ($now['mday'] - $bday_day < 0) ? 1 : 0;
         }
         else
         {
            $diff = ($diff < 0) ? 1 : 0;
         }

         $age = (int) ($now['year'] - $bday_year - $diff);
      }
   }

   // Dump it out to the template
   return array(
      'AGE'         => $age,
      'RANK_TITLE'   => $rank_title,
      'JOINED'      => $user->format_date($data['user_regdate']),
      'VISITED'      => (empty($last_visit)) ? ' - ' : $user->format_date($last_visit),
      'POSTS'         => ($data['user_posts']) ? $data['user_posts'] : 0,
      'WARNINGS'      => isset($data['user_warnings']) ? $data['user_warnings'] : 0,

      'USERNAME_FULL'      => get_username_string('full', $user_id, $username, $data['user_colour']),
      'USERNAME'         => get_username_string('username', $user_id, $username, $data['user_colour']),
      'USER_COLOR'      => get_username_string('colour', $user_id, $username, $data['user_colour']),
      'U_VIEW_PROFILE'   => get_username_string('profile', $user_id, $username, $data['user_colour']),

      'A_USERNAME'      => addslashes(get_username_string('username', $user_id, $username, $data['user_colour'])),

      'AVATAR_IMG'      => get_user_avatar($data['user_avatar'], $data['user_avatar_type'], $data['user_avatar_width'], $data['user_avatar_height']),
      'ONLINE_IMG'      => (!$config['load_onlinetrack']) ? '' : (($online) ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')),
      'S_ONLINE'         => ($config['load_onlinetrack'] && $online) ? true : false,
      'RANK_IMG'         => $rank_img,
      'RANK_IMG_SRC'      => $rank_img_src,
      'ICQ_STATUS_IMG'   => (!empty($data['user_icq'])) ? '<img src="http://web.icq.com/whitepages/online?icq=' . $data['user_icq'] . '&amp;img=5" width="18" height="18" />' : '',
      'S_JABBER_ENABLED'   => ($config['jab_enable']) ? true : false,

      'S_WARNINGS'   => ($auth->acl_getf_global('m_') || $auth->acl_get('m_warn')) ? true : false,

      'U_SEARCH_USER'   => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$user_id&amp;sr=posts") : '',
      'U_NOTES'      => ($user_notes_enabled && $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&amp;mode=user_notes&amp;u=' . $user_id, true, $user->session_id) : '',
      'U_WARN'      => ($warn_user_enabled && $auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&amp;mode=warn_user&amp;u=' . $user_id, true, $user->session_id) : '',
      'U_PM'         => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($data['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;mode=compose&amp;u=' . $user_id) : '',
      'U_EMAIL'      => $email,
      'U_WWW'         => (!empty($data['user_website'])) ? $data['user_website'] : '',
      'U_SHORT_WWW'         => (!empty($data['user_website'])) ? ((strlen($data['user_website']) > 55) ? substr($data['user_website'], 0, 39) . ' ... ' . substr($data['user_website'], -10) : $data['user_website']) : '',
      'U_ICQ'         => ($data['user_icq']) ? 'http://www.icq.com/people/webmsg.php?to=' . urlencode($data['user_icq']) : '',
      'U_AIM'         => ($data['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&amp;action=aim&amp;u=' . $user_id) : '',
      'U_YIM'         => ($data['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($data['user_yim']) . '&amp;.src=pg' : '',
      'U_MSN'         => ($data['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&amp;action=msnm&amp;u=' . $user_id) : '',
      'U_JABBER'      => ($data['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&amp;action=jabber&amp;u=' . $user_id) : '',
      'LOCATION'      => ($data['user_from']) ? $data['user_from'] : '',

      'USER_ICQ'         => $data['user_icq'],
      'USER_AIM'         => $data['user_aim'],
      'USER_YIM'         => $data['user_yim'],
      'USER_MSN'         => $data['user_msnm'],
      'USER_JABBER'      => $data['user_jabber'],
      'USER_JABBER_IMG'   => ($data['user_jabber']) ? $user->img('icon_contact_jabber', $data['user_jabber']) : '',

      'L_VIEWING_PROFILE'   => sprintf($user->lang['VIEWING_PROFILE'], $username),
   );
}

function _sort_last_active($first, $second)
{
   global $id_cache, $sort_dir;

   $lesser_than = ($sort_dir === 'd') ? -1 : 1;

   if (isset($id_cache[$first]['group_leader']) && $id_cache[$first]['group_leader'] && (!isset($id_cache[$second]['group_leader']) || !$id_cache[$second]['group_leader']))
   {
      return -1;
   }
   else if (isset($id_cache[$second]['group_leader']) && (!isset($id_cache[$first]['group_leader']) || !$id_cache[$first]['group_leader']) && $id_cache[$second]['group_leader'])
   {
      return 1;
   }
   else
   {
      return $lesser_than * (int) ($id_cache[$first]['last_visit'] - $id_cache[$second]['last_visit']);
   }
}

?>
by am.hitek
Fri May 14, 2010 8:12 pm

Re: Configuration in ACP

Code: Select all

<?php
/**
*
* @package acp
* @version $Id: acp_board.php 10529 2010-02-23 23:46:43Z naderman $
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
* @todo add cron intervals to server settings? (database_gc, queue_interval, session_gc, search_gc, cache_gc, warnings_gc)
*/

/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
   exit;
}

/**
* @package acp
*/
class acp_board
{
   var $u_action;
   var $new_config = array();

   function main($id, $mode)
   {
      global $db, $user, $auth, $template;
      global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
      global $cache;

      $user->add_lang('acp/board');
      $user->add_lang('mods/reimg');

      $action   = request_var('action', '');
      $submit = (isset($_POST['submit']) || isset($_POST['allow_quick_reply_enable'])) ? true : false;

      $form_key = 'acp_board';
      add_form_key($form_key);

      /**
      *   Validation types are:
      *      string, int, bool,
      *      script_path (absolute path in url - beginning with / and no trailing slash),
      *      rpath (relative), rwpath (realtive, writable), path (relative path, but able to escape the root), wpath (writable)
      */
      switch ($mode)
      {
         case 'settings':
            $display_vars = array(
               'title'   => 'ACP_BOARD_SETTINGS',
               'vars'   => array(
                  'legend1'            => 'ACP_BOARD_SETTINGS',
                  'sitename'            => array('lang' => 'SITE_NAME',            'validate' => 'string',   'type' => 'text:40:255', 'explain' => false),
                  'site_desc'            => array('lang' => 'SITE_DESC',            'validate' => 'string',   'type' => 'text:40:255', 'explain' => false),
                  'board_disable'         => array('lang' => 'DISABLE_BOARD',         'validate' => 'bool',   'type' => 'custom', 'method' => 'board_disable', 'explain' => true),
                  'board_disable_msg'      => false,
                  'default_lang'         => array('lang' => 'DEFAULT_LANGUAGE',      'validate' => 'lang',   'type' => 'select', 'function' => 'language_select', 'params' => array('{CONFIG_VALUE}'), 'explain' => false),
                  'default_dateformat'   => array('lang' => 'DEFAULT_DATE_FORMAT',   'validate' => 'string',   'type' => 'custom', 'method' => 'dateformat_select', 'explain' => true),
                  'board_timezone'      => array('lang' => 'SYSTEM_TIMEZONE',      'validate' => 'string',   'type' => 'select', 'function' => 'tz_select', 'params' => array('{CONFIG_VALUE}', 1), 'explain' => false),
                  'board_dst'            => array('lang' => 'SYSTEM_DST',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'default_style'         => array('lang' => 'DEFAULT_STYLE',         'validate' => 'int',   'type' => 'select', 'function' => 'style_select', 'params' => array('{CONFIG_VALUE}', false), 'explain' => false),
                  'override_user_style'   => array('lang' => 'OVERRIDE_STYLE',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  //MOD Advanced Forum Statistics
                  'allow_guests_view_fs'   => array('lang' => 'ALLOW_GUESTS_VIEW_FS',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  //END MOD
                  'legend2'            => 'WARNINGS',
                  'warnings_expire_days'   => array('lang' => 'WARNINGS_EXPIRE',      'validate' => 'int',   'type' => 'text:3:4', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),

                  'legend3'               => 'ACP_SUBMIT_CHANGES',
               )
            );
         break;

         case 'features':
            $display_vars = array(
               'title'   => 'ACP_BOARD_FEATURES',
               'vars'   => array(
                  'legend1'            => 'ACP_BOARD_FEATURES',
                  'allow_privmsg'         => array('lang' => 'BOARD_PM',            'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_topic_notify'   => array('lang' => 'ALLOW_TOPIC_NOTIFY',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_forum_notify'   => array('lang' => 'ALLOW_FORUM_NOTIFY',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_namechange'      => array('lang' => 'ALLOW_NAME_CHANGE',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_attachments'      => array('lang' => 'ALLOW_ATTACHMENTS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_pm_attach'      => array('lang' => 'ALLOW_PM_ATTACHMENTS',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_pm_report'      => array('lang' => 'ALLOW_PM_REPORT',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_bbcode'         => array('lang' => 'ALLOW_BBCODE',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_smilies'         => array('lang' => 'ALLOW_SMILIES',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_sig'            => array('lang' => 'ALLOW_SIG',            'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_nocensors'      => array('lang' => 'ALLOW_NO_CENSORS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_bookmarks'      => array('lang' => 'ALLOW_BOOKMARKS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_birthdays'      => array('lang' => 'ALLOW_BIRTHDAYS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_quick_reply'      => array('lang' => 'ALLOW_QUICK_REPLY',      'validate' => 'bool',   'type' => 'custom', 'method' => 'quick_reply', 'explain' => true),

                  'legend2'            => 'ACP_LOAD_SETTINGS',
                  'load_birthdays'      => array('lang' => 'YES_BIRTHDAYS',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'load_moderators'      => array('lang' => 'YES_MODERATORS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'load_jumpbox'         => array('lang' => 'YES_JUMPBOX',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'load_cpf_memberlist'   => array('lang' => 'LOAD_CPF_MEMBERLIST',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'load_cpf_viewprofile'   => array('lang' => 'LOAD_CPF_VIEWPROFILE',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'load_cpf_viewtopic'   => array('lang' => 'LOAD_CPF_VIEWTOPIC',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),

                  'legend3'               => 'ACP_SUBMIT_CHANGES',
               )
            );
         break;

         case 'avatar':
            $display_vars = array(
               'title'   => 'ACP_AVATAR_SETTINGS',
               'vars'   => array(
                  'legend1'            => 'ACP_AVATAR_SETTINGS',

                  'avatar_min_width'      => array('lang' => 'MIN_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,),
                  'avatar_min_height'      => array('lang' => 'MIN_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,),
                  'avatar_max_width'      => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,),
                  'avatar_max_height'      => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,),

                  'allow_avatar'         => array('lang' => 'ALLOW_AVATARS',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_avatar_local'   => array('lang' => 'ALLOW_LOCAL',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_avatar_remote'   => array('lang' => 'ALLOW_REMOTE',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_avatar_upload'   => array('lang' => 'ALLOW_UPLOAD',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_avatar_remote_upload'=> array('lang' => 'ALLOW_REMOTE_UPLOAD', 'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'avatar_filesize'      => array('lang' => 'MAX_FILESIZE',         'validate' => 'int:0',   'type' => 'text:4:10', 'explain' => true, 'append' => ' ' . $user->lang['BYTES']),
                  'avatar_min'         => array('lang' => 'MIN_AVATAR_SIZE',      'validate' => 'int:0',   'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
                  'avatar_max'         => array('lang' => 'MAX_AVATAR_SIZE',      'validate' => 'int:0',   'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
                  'avatar_path'         => array('lang' => 'AVATAR_STORAGE_PATH',   'validate' => 'rwpath',   'type' => 'text:20:255', 'explain' => true),
                  'avatar_gallery_path'   => array('lang' => 'AVATAR_GALLERY_PATH',   'validate' => 'rpath',   'type' => 'text:20:255', 'explain' => true)
               )
            );
         break;

         case 'message':
            $display_vars = array(
               'title'   => 'ACP_MESSAGE_SETTINGS',
               'lang'   => 'ucp',
               'vars'   => array(
                  'legend1'            => 'GENERAL_SETTINGS',
                  'allow_privmsg'         => array('lang' => 'BOARD_PM',            'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'pm_max_boxes'         => array('lang' => 'BOXES_MAX',            'validate' => 'int:0',   'type' => 'text:4:4', 'explain' => true),
                  'pm_max_msgs'         => array('lang' => 'BOXES_LIMIT',         'validate' => 'int:0',   'type' => 'text:4:4', 'explain' => true),
                  'full_folder_action'   => array('lang' => 'FULL_FOLDER_ACTION',   'validate' => 'int',   'type' => 'select', 'method' => 'full_folder_select', 'explain' => true),
                  'pm_edit_time'         => array('lang' => 'PM_EDIT_TIME',         'validate' => 'int:0',   'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),
                  'pm_max_recipients'      => array('lang' => 'PM_MAX_RECIPIENTS',      'validate' => 'int:0',   'type' => 'text:5:5', 'explain' => true),

                  'legend2'            => 'GENERAL_OPTIONS',
                  'allow_mass_pm'         => array('lang' => 'ALLOW_MASS_PM',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'auth_bbcode_pm'      => array('lang' => 'ALLOW_BBCODE_PM',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'auth_smilies_pm'      => array('lang' => 'ALLOW_SMILIES_PM',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_pm_attach'      => array('lang' => 'ALLOW_PM_ATTACHMENTS',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_sig_pm'         => array('lang' => 'ALLOW_SIG_PM',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'print_pm'            => array('lang' => 'ALLOW_PRINT_PM',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'forward_pm'         => array('lang' => 'ALLOW_FORWARD_PM',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'auth_img_pm'         => array('lang' => 'ALLOW_IMG_PM',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'auth_flash_pm'         => array('lang' => 'ALLOW_FLASH_PM',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'enable_pm_icons'      => array('lang' => 'ENABLE_PM_ICONS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),

                  'legend3'               => 'ACP_SUBMIT_CHANGES',
               )
            );
         break;

         case 'post':
            $display_vars = array(
               'title'   => 'ACP_POST_SETTINGS',
               'vars'   => array(
                  'legend1'            => 'GENERAL_OPTIONS',
                  'allow_topic_notify'   => array('lang' => 'ALLOW_TOPIC_NOTIFY',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_forum_notify'   => array('lang' => 'ALLOW_FORUM_NOTIFY',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_bbcode'         => array('lang' => 'ALLOW_BBCODE',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_post_flash'      => array('lang' => 'ALLOW_POST_FLASH',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_smilies'         => array('lang' => 'ALLOW_SMILIES',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_post_links'      => array('lang' => 'ALLOW_POST_LINKS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_nocensors'      => array('lang' => 'ALLOW_NO_CENSORS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_bookmarks'      => array('lang' => 'ALLOW_BOOKMARKS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'enable_post_confirm'   => array('lang' => 'VISUAL_CONFIRM_POST',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_quick_reply'      => array('lang' => 'ALLOW_QUICK_REPLY',      'validate' => 'bool',   'type' => 'custom', 'method' => 'quick_reply', 'explain' => true),

                  'legend2'            => 'POSTING',
                  'bump_type'            => false,
                  'edit_time'            => array('lang' => 'EDIT_TIME',            'validate' => 'int:0',      'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),
                  'delete_time'         => array('lang' => 'DELETE_TIME',         'validate' => 'int:0',      'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),
                  'display_last_edited'   => array('lang' => 'DISPLAY_LAST_EDITED',   'validate' => 'bool',      'type' => 'radio:yes_no', 'explain' => true),
                  'flood_interval'      => array('lang' => 'FLOOD_INTERVAL',      'validate' => 'int:0',      'type' => 'text:3:10', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
                  'bump_interval'         => array('lang' => 'BUMP_INTERVAL',         'validate' => 'int:0',      'type' => 'custom', 'method' => 'bump_interval', 'explain' => true),
                  'topics_per_page'      => array('lang' => 'TOPICS_PER_PAGE',      'validate' => 'int:1',      'type' => 'text:3:4', 'explain' => false),
                  'posts_per_page'      => array('lang' => 'POSTS_PER_PAGE',      'validate' => 'int:1',      'type' => 'text:3:4', 'explain' => false),
                  'smilies_per_page'      => array('lang' => 'SMILIES_PER_PAGE',      'validate' => 'int:1',      'type' => 'text:3:4', 'explain' => false),
                  'hot_threshold'         => array('lang' => 'HOT_THRESHOLD',         'validate' => 'int:0',      'type' => 'text:3:4', 'explain' => true),
                  'max_poll_options'      => array('lang' => 'MAX_POLL_OPTIONS',      'validate' => 'int:2:127',   'type' => 'text:4:4', 'explain' => false),
                  'max_post_chars'      => array('lang' => 'CHAR_LIMIT',         'validate' => 'int:0',      'type' => 'text:4:6', 'explain' => true),
                  'min_post_chars'      => array('lang' => 'MIN_CHAR_LIMIT',      'validate' => 'int:0',      'type' => 'text:4:6', 'explain' => true),
                  'max_post_smilies'      => array('lang' => 'SMILIES_LIMIT',         'validate' => 'int:0',      'type' => 'text:4:4', 'explain' => true),
                  'max_post_urls'         => array('lang' => 'MAX_POST_URLS',         'validate' => 'int:0',      'type' => 'text:5:4', 'explain' => true),
                  'max_post_font_size'   => array('lang' => 'MAX_POST_FONT_SIZE',   'validate' => 'int:0',      'type' => 'text:5:4', 'explain' => true, 'append' => ' %'),
                  'max_quote_depth'      => array('lang' => 'QUOTE_DEPTH_LIMIT',      'validate' => 'int:0',      'type' => 'text:4:4', 'explain' => true),
                  'max_post_img_width'   => array('lang' => 'MAX_POST_IMG_WIDTH',   'validate' => 'int:0',      'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
                  'max_post_img_height'   => array('lang' => 'MAX_POST_IMG_HEIGHT',   'validate' => 'int:0',      'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),


                  'legend3'               => 'ACP_SUBMIT_CHANGES',
               )
            );
         break;

         case 'signature':
            $display_vars = array(
               'title'   => 'ACP_SIGNATURE_SETTINGS',
               'vars'   => array(
                  'legend1'            => 'GENERAL_OPTIONS',
                  'allow_sig'            => array('lang' => 'ALLOW_SIG',            'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_sig_bbcode'      => array('lang' => 'ALLOW_SIG_BBCODE',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_sig_img'         => array('lang' => 'ALLOW_SIG_IMG',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_sig_flash'      => array('lang' => 'ALLOW_SIG_FLASH',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_sig_smilies'      => array('lang' => 'ALLOW_SIG_SMILIES',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_sig_links'      => array('lang' => 'ALLOW_SIG_LINKS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),

                  'legend2'            => 'GENERAL_SETTINGS',
                  'max_sig_chars'         => array('lang' => 'MAX_SIG_LENGTH',      'validate' => 'int:0',   'type' => 'text:5:4', 'explain' => true),
                  'max_sig_urls'         => array('lang' => 'MAX_SIG_URLS',         'validate' => 'int:0',   'type' => 'text:5:4', 'explain' => true),
                  'max_sig_font_size'      => array('lang' => 'MAX_SIG_FONT_SIZE',      'validate' => 'int:0',   'type' => 'text:5:4', 'explain' => true, 'append' => ' %'),
                  'max_sig_smilies'      => array('lang' => 'MAX_SIG_SMILIES',      'validate' => 'int:0',   'type' => 'text:5:4', 'explain' => true),
                  'max_sig_img_width'      => array('lang' => 'MAX_SIG_IMG_WIDTH',      'validate' => 'int:0',   'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
                  'max_sig_img_height'   => array('lang' => 'MAX_SIG_IMG_HEIGHT',   'validate' => 'int:0',   'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),

                  'legend3'               => 'ACP_SUBMIT_CHANGES',
               )
            );
         break;

         case 'registration':
            $display_vars = array(
               'title'   => 'ACP_REGISTER_SETTINGS',
               'vars'   => array(
                  'legend1'            => 'GENERAL_SETTINGS',
                  'max_name_chars'      => array('lang' => 'USERNAME_LENGTH', 'validate' => 'int:8:180', 'type' => false, 'method' => false, 'explain' => false,),
                  'max_pass_chars'      => array('lang' => 'PASSWORD_LENGTH', 'validate' => 'int:8:255', 'type' => false, 'method' => false, 'explain' => false,),

                  'require_activation'   => array('lang' => 'ACC_ACTIVATION',   'validate' => 'int',   'type' => 'custom', 'method' => 'select_acc_activation', 'explain' => true),
                  'new_member_post_limit'   => array('lang' => 'NEW_MEMBER_POST_LIMIT', 'validate' => 'int:0:255', 'type' => 'text:4:4', 'explain' => true, 'append' => ' ' . $user->lang['POSTS']),
                  'new_member_group_default'=> array('lang' => 'NEW_MEMBER_GROUP_DEFAULT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
                  'min_name_chars'      => array('lang' => 'USERNAME_LENGTH',   'validate' => 'int:1',   'type' => 'custom:5:180', 'method' => 'username_length', 'explain' => true),
                  'min_pass_chars'      => array('lang' => 'PASSWORD_LENGTH',   'validate' => 'int:1',   'type' => 'custom', 'method' => 'password_length', 'explain' => true),
                  'allow_name_chars'      => array('lang' => 'USERNAME_CHARS',   'validate' => 'string',   'type' => 'select', 'method' => 'select_username_chars', 'explain' => true),
                  'pass_complex'         => array('lang' => 'PASSWORD_TYPE',      'validate' => 'string',   'type' => 'select', 'method' => 'select_password_chars', 'explain' => true),
                  'chg_passforce'         => array('lang' => 'FORCE_PASS_CHANGE',   'validate' => 'int:0',   'type' => 'text:3:3', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),

                  'legend2'            => 'GENERAL_OPTIONS',
                  'allow_namechange'      => array('lang' => 'ALLOW_NAME_CHANGE',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_emailreuse'      => array('lang' => 'ALLOW_EMAIL_REUSE',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'enable_confirm'      => array('lang' => 'VISUAL_CONFIRM_REG',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'max_login_attempts'   => array('lang' => 'MAX_LOGIN_ATTEMPTS',   'validate' => 'int:0',   'type' => 'text:3:3', 'explain' => true),
                  'max_reg_attempts'      => array('lang' => 'REG_LIMIT',            'validate' => 'int:0',   'type' => 'text:4:4', 'explain' => true),

                  'legend3'         => 'COPPA',
                  'coppa_enable'      => array('lang' => 'ENABLE_COPPA',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'coppa_mail'      => array('lang' => 'COPPA_MAIL',      'validate' => 'string',   'type' => 'textarea:5:40', 'explain' => true),
                  'coppa_fax'         => array('lang' => 'COPPA_FAX',         'validate' => 'string',   'type' => 'text:25:100', 'explain' => false),

                  'legend4'         => 'ACP_SUBMIT_CHANGES',
               )
            );
         break;

         case 'feed':
            $display_vars = array(
               'title'   => 'ACP_FEED_MANAGEMENT',
               'vars'   => array(
                  'legend1'               => 'ACP_FEED_GENERAL',
                  'feed_enable'            => array('lang' => 'ACP_FEED_ENABLE',            'validate' => 'bool',   'type' => 'radio:enabled_disabled',   'explain' => true ),
                  'feed_item_statistics'      => array('lang' => 'ACP_FEED_ITEM_STATISTICS',      'validate' => 'bool',   'type' => 'radio:enabled_disabled',   'explain' => true),
                  'feed_http_auth'         => array('lang' => 'ACP_FEED_HTTP_AUTH',         'validate' => 'bool',   'type' => 'radio:enabled_disabled',   'explain' => true),

                  'legend2'               => 'ACP_FEED_POST_BASED',
                  'feed_limit_post'         => array('lang' => 'ACP_FEED_LIMIT',            'validate' => 'int:5',   'type' => 'text:3:4',            'explain' => true),
                  'feed_overall'            => array('lang' => 'ACP_FEED_OVERALL',            'validate' => 'bool',   'type' => 'radio:enabled_disabled',   'explain' => true ),
                  'feed_forum'            => array('lang' => 'ACP_FEED_FORUM',            'validate' => 'bool',   'type' => 'radio:enabled_disabled',   'explain' => true ),
                  'feed_topic'            => array('lang' => 'ACP_FEED_TOPIC',            'validate' => 'bool',   'type' => 'radio:enabled_disabled',   'explain' => true ),

                  'legend3'               => 'ACP_FEED_TOPIC_BASED',
                  'feed_limit_topic'         => array('lang' => 'ACP_FEED_LIMIT',            'validate' => 'int:5',   'type' => 'text:3:4',            'explain' => true),
                  'feed_topics_new'         => array('lang' => 'ACP_FEED_TOPICS_NEW',         'validate' => 'bool',   'type' => 'radio:enabled_disabled',   'explain' => true ),
                  'feed_topics_active'      => array('lang' => 'ACP_FEED_TOPICS_ACTIVE',      'validate' => 'bool',   'type' => 'radio:enabled_disabled',   'explain' => true ),
                  'feed_news_id'            => array('lang' => 'ACP_FEED_NEWS',               'validate' => 'string',   'type' => 'custom', 'method' => 'select_news_forums', 'explain' => true),

                  'legend4'               => 'ACP_FEED_SETTINGS_OTHER',
                  'feed_overall_forums'      => array('lang'   => 'ACP_FEED_OVERALL_FORUMS',      'validate' => 'bool',   'type' => 'radio:enabled_disabled',   'explain' => true ),
                  'feed_exclude_id'         => array('lang' => 'ACP_FEED_EXCLUDE_ID',         'validate' => 'string',   'type' => 'custom', 'method' => 'select_exclude_forums', 'explain' => true),
               )
            );
         break;

         case 'cookie':
            $display_vars = array(
               'title'   => 'ACP_COOKIE_SETTINGS',
               'vars'   => array(
                  'legend1'      => 'ACP_COOKIE_SETTINGS',
                  'cookie_domain'   => array('lang' => 'COOKIE_DOMAIN',   'validate' => 'string',   'type' => 'text::255', 'explain' => false),
                  'cookie_name'   => array('lang' => 'COOKIE_NAME',   'validate' => 'string',   'type' => 'text::16', 'explain' => false),
                  'cookie_path'   => array('lang'   => 'COOKIE_PATH',   'validate' => 'string',   'type' => 'text::255', 'explain' => false),
                  'cookie_secure'   => array('lang' => 'COOKIE_SECURE',   'validate' => 'bool',   'type' => 'radio:disabled_enabled', 'explain' => true)
               )
            );
         break;

         case 'load':
            $display_vars = array(
               'title'   => 'ACP_LOAD_SETTINGS',
               'vars'   => array(
                  'legend1'         => 'GENERAL_SETTINGS',
                  'limit_load'      => array('lang' => 'LIMIT_LOAD',      'validate' => 'string',   'type' => 'text:4:4', 'explain' => true),
                  'session_length'   => array('lang' => 'SESSION_LENGTH',   'validate' => 'int:60',   'type' => 'text:5:10', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
                  'active_sessions'   => array('lang' => 'LIMIT_SESSIONS',   'validate' => 'int:0',   'type' => 'text:4:4', 'explain' => true),
                  'load_online_time'   => array('lang' => 'ONLINE_LENGTH',      'validate' => 'int:0',   'type' => 'text:4:3', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),

                  'legend2'            => 'GENERAL_OPTIONS',
                  'load_db_track'         => array('lang' => 'YES_POST_MARKING',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'load_db_lastread'      => array('lang' => 'YES_READ_MARKING',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'load_anon_lastread'   => array('lang' => 'YES_ANON_READ_MARKING',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'load_online'         => array('lang' => 'YES_ONLINE',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'load_online_guests'   => array('lang' => 'YES_ONLINE_GUESTS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'load_onlinetrack'      => array('lang' => 'YES_ONLINE_TRACK',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'load_birthdays'      => array('lang' => 'YES_BIRTHDAYS',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'load_moderators'      => array('lang' => 'YES_MODERATORS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'load_jumpbox'         => array('lang' => 'YES_JUMPBOX',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'load_user_activity'   => array('lang' => 'LOAD_USER_ACTIVITY',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'load_tplcompile'      => array('lang' => 'RECOMPILE_STYLES',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),

                  'legend3'            => 'CUSTOM_PROFILE_FIELDS',
                  'load_cpf_memberlist'   => array('lang' => 'LOAD_CPF_MEMBERLIST',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'load_cpf_viewprofile'   => array('lang' => 'LOAD_CPF_VIEWPROFILE',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'load_cpf_viewtopic'   => array('lang' => 'LOAD_CPF_VIEWTOPIC',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),

                  'legend4'               => 'ACP_SUBMIT_CHANGES',
               )
            );
         break;

         case 'auth':
            $display_vars = array(
               'title'   => 'ACP_AUTH_SETTINGS',
               'vars'   => array(
                  'legend1'      => 'ACP_AUTH_SETTINGS',
                  'auth_method'   => array('lang' => 'AUTH_METHOD',   'validate' => 'string',   'type' => 'select', 'method' => 'select_auth_method', 'explain' => false)
               )
            );
         break;

         case 'server':
            $display_vars = array(
               'title'   => 'ACP_SERVER_SETTINGS',
               'vars'   => array(
                  'legend1'            => 'ACP_SERVER_SETTINGS',
                  'gzip_compress'         => array('lang' => 'ENABLE_GZIP',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),

                  'legend2'            => 'PATH_SETTINGS',
                  'smilies_path'         => array('lang' => 'SMILIES_PATH',      'validate' => 'rpath',   'type' => 'text:20:255', 'explain' => true),
                  'icons_path'         => array('lang' => 'ICONS_PATH',      'validate' => 'rpath',   'type' => 'text:20:255', 'explain' => true),
                  'upload_icons_path'      => array('lang' => 'UPLOAD_ICONS_PATH',   'validate' => 'rpath',   'type' => 'text:20:255', 'explain' => true),
                  'ranks_path'         => array('lang' => 'RANKS_PATH',      'validate' => 'rpath',   'type' => 'text:20:255', 'explain' => true),

                  'legend3'            => 'SERVER_URL_SETTINGS',
                  'force_server_vars'      => array('lang' => 'FORCE_SERVER_VARS',   'validate' => 'bool',         'type' => 'radio:yes_no', 'explain' => true),
                  'server_protocol'      => array('lang' => 'SERVER_PROTOCOL',   'validate' => 'string',         'type' => 'text:10:10', 'explain' => true),
                  'server_name'         => array('lang' => 'SERVER_NAME',      'validate' => 'string',         'type' => 'text:40:255', 'explain' => true),
                  'server_port'         => array('lang' => 'SERVER_PORT',      'validate' => 'int:0',         'type' => 'text:5:5', 'explain' => true),
                  'script_path'         => array('lang' => 'SCRIPT_PATH',      'validate' => 'script_path',   'type' => 'text::255', 'explain' => true),

                  'legend4'               => 'ACP_SUBMIT_CHANGES',
               )
            );
         break;

         case 'security':
            $display_vars = array(
               'title'   => 'ACP_SECURITY_SETTINGS',
               'vars'   => array(
                  'legend1'            => 'ACP_SECURITY_SETTINGS',
                  'allow_autologin'      => array('lang' => 'ALLOW_AUTOLOGIN',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'max_autologin_time'   => array('lang' => 'AUTOLOGIN_LENGTH',      'validate' => 'int:0',   'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),
                  'ip_check'            => array('lang' => 'IP_VALID',            'validate' => 'int',   'type' => 'custom', 'method' => 'select_ip_check', 'explain' => true),
                  'browser_check'         => array('lang' => 'BROWSER_VALID',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'forwarded_for_check'   => array('lang' => 'FORWARDED_FOR_VALID',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'referer_validation'   => array('lang' => 'REFERER_VALID',      'validate' => 'int:0:3','type' => 'custom', 'method' => 'select_ref_check', 'explain' => true),
                  'check_dnsbl'         => array('lang' => 'CHECK_DNSBL',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'email_check_mx'      => array('lang' => 'EMAIL_CHECK_MX',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'pass_complex'         => array('lang' => 'PASSWORD_TYPE',         'validate' => 'string',   'type' => 'select', 'method' => 'select_password_chars', 'explain' => true),
                  'chg_passforce'         => array('lang' => 'FORCE_PASS_CHANGE',      'validate' => 'int:0',   'type' => 'text:3:3', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),
                  'max_login_attempts'   => array('lang' => 'MAX_LOGIN_ATTEMPTS',   'validate' => 'int:0',   'type' => 'text:3:3', 'explain' => true),
                  'tpl_allow_php'         => array('lang' => 'TPL_ALLOW_PHP',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'form_token_lifetime'   => array('lang' => 'FORM_TIME_MAX',         'validate' => 'int:-1',   'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
                  'form_token_sid_guests'   => array('lang' => 'FORM_SID_GUESTS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),

               )
            );
         break;

         case 'email':
            $display_vars = array(
               'title'   => 'ACP_EMAIL_SETTINGS',
               'vars'   => array(
                  'legend1'            => 'GENERAL_SETTINGS',
                  'email_enable'         => array('lang' => 'ENABLE_EMAIL',         'validate' => 'bool',   'type' => 'radio:enabled_disabled', 'explain' => true),
                  'board_email_form'      => array('lang' => 'BOARD_EMAIL_FORM',      'validate' => 'bool',   'type' => 'radio:enabled_disabled', 'explain' => true),
                  'email_function_name'   => array('lang' => 'EMAIL_FUNCTION_NAME',   'validate' => 'string',   'type' => 'text:20:50', 'explain' => true),
                  'email_package_size'   => array('lang' => 'EMAIL_PACKAGE_SIZE',   'validate' => 'int:0',   'type' => 'text:5:5', 'explain' => true),
                  'board_contact'         => array('lang' => 'CONTACT_EMAIL',         'validate' => 'string',   'type' => 'text:25:100', 'explain' => true),
                  'board_email'         => array('lang' => 'ADMIN_EMAIL',         'validate' => 'string',   'type' => 'text:25:100', 'explain' => true),
                  'board_email_sig'      => array('lang' => 'EMAIL_SIG',            'validate' => 'string',   'type' => 'textarea:5:30', 'explain' => true),
                  'board_hide_emails'      => array('lang' => 'BOARD_HIDE_EMAILS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),

                  'legend2'            => 'SMTP_SETTINGS',
                  'smtp_delivery'         => array('lang' => 'USE_SMTP',            'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'smtp_host'            => array('lang' => 'SMTP_SERVER',         'validate' => 'string',   'type' => 'text:25:50', 'explain' => false),
                  'smtp_port'            => array('lang' => 'SMTP_PORT',            'validate' => 'int:0',   'type' => 'text:4:5', 'explain' => true),
                  'smtp_auth_method'      => array('lang' => 'SMTP_AUTH_METHOD',      'validate' => 'string',   'type' => 'select', 'method' => 'mail_auth_select', 'explain' => true),
                  'smtp_username'         => array('lang' => 'SMTP_USERNAME',         'validate' => 'string',   'type' => 'text:25:255', 'explain' => true),
                  'smtp_password'         => array('lang' => 'SMTP_PASSWORD',         'validate' => 'string',   'type' => 'password:25:255', 'explain' => true),

                  'legend3'               => 'ACP_SUBMIT_CHANGES',
               )
            );
         break;

         default:
            trigger_error('NO_MODE', E_USER_ERROR);
         break;
      }
      //-- mod: Prime Birthdate ---------------------------------------------------//
      include($phpbb_root_path . 'includes/prime_birthdate.' . $phpEx);
      $prime_birthdate->display_acp_options($display_vars, $mode);
//-- end: Prime Birthdate ---------------------------------------------------//


      if (isset($display_vars['lang']))
      {
         $user->add_lang($display_vars['lang']);
      }

      $this->new_config = $config;
      $cfg_array = (isset($_REQUEST['config'])) ? utf8_normalize_nfc(request_var('config', array('' => ''), true)) : $this->new_config;
      $error = array();

      // We validate the complete config if whished
      validate_config_vars($display_vars['vars'], $cfg_array, $error);

      if ($submit && !check_form_key($form_key))
      {
         $error[] = $user->lang['FORM_INVALID'];
      }
      // Do not write values if there is an error
      if (sizeof($error))
      {
         $submit = false;
      }

      // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to...
      foreach ($display_vars['vars'] as $config_name => $null)
      {
         if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false)
         {
            continue;
         }

         if ($config_name == 'auth_method' || $config_name == 'feed_news_id' || $config_name == 'feed_exclude_id')
         {
            continue;
         }

         $this->new_config[$config_name] = $config_value = $cfg_array[$config_name];

         if ($config_name == 'email_function_name')
         {
            $this->new_config['email_function_name'] = trim(str_replace(array('(', ')'), array('', ''), $this->new_config['email_function_name']));
            $this->new_config['email_function_name'] = (empty($this->new_config['email_function_name']) || !function_exists($this->new_config['email_function_name'])) ? 'mail' : $this->new_config['email_function_name'];
            $config_value = $this->new_config['email_function_name'];
         }

         if ($submit)
         {
            set_config($config_name, $config_value);

            if ($config_name == 'allow_quick_reply' && isset($_POST['allow_quick_reply_enable']))
            {
               enable_bitfield_column_flag(FORUMS_TABLE, 'forum_flags', log(FORUM_FLAG_QUICK_REPLY, 2));
            }
         }
      }

      // Store news and exclude ids
      if ($mode == 'feed' && $submit)
      {
         $cache->destroy('_feed_news_forum_ids');
         $cache->destroy('_feed_excluded_forum_ids');

         $this->store_feed_forums(FORUM_OPTION_FEED_NEWS, 'feed_news_id');
         $this->store_feed_forums(FORUM_OPTION_FEED_EXCLUDE, 'feed_exclude_id');
      }

      if ($mode == 'auth')
      {
         // Retrieve a list of auth plugins and check their config values
         $auth_plugins = array();

         $dp = @opendir($phpbb_root_path . 'includes/auth');

         if ($dp)
         {
            while (($file = readdir($dp)) !== false)
            {
               if (preg_match('#^auth_(.*?)\.' . $phpEx . '$#', $file))
               {
                  $auth_plugins[] = basename(preg_replace('#^auth_(.*?)\.' . $phpEx . '$#', '\1', $file));
               }
            }
            closedir($dp);

            sort($auth_plugins);
         }

         $updated_auth_settings = false;
         $old_auth_config = array();
         foreach ($auth_plugins as $method)
         {
            if ($method && file_exists($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx))
            {
               include_once($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx);

               $method = 'acp_' . $method;
               if (function_exists($method))
               {
                  if ($fields = $method($this->new_config))
                  {
                     // Check if we need to create config fields for this plugin and save config when submit was pressed
                     foreach ($fields['config'] as $field)
                     {
                        if (!isset($config[$field]))
                        {
                           set_config($field, '');
                        }

                        if (!isset($cfg_array[$field]) || strpos($field, 'legend') !== false)
                        {
                           continue;
                        }

                        $old_auth_config[$field] = $this->new_config[$field];
                        $config_value = $cfg_array[$field];
                        $this->new_config[$field] = $config_value;

                        if ($submit)
                        {
                           $updated_auth_settings = true;
                           set_config($field, $config_value);
                        }
                     }
                  }
                  unset($fields);
               }
            }
         }

         if ($submit && (($cfg_array['auth_method'] != $this->new_config['auth_method']) || $updated_auth_settings))
         {
            $method = basename($cfg_array['auth_method']);
            if ($method && in_array($method, $auth_plugins))
            {
               include_once($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx);

               $method = 'init_' . $method;
               if (function_exists($method))
               {
                  if ($error = $method())
                  {
                     foreach ($old_auth_config as $config_name => $config_value)
                     {
                        set_config($config_name, $config_value);
                     }
                     trigger_error($error . adm_back_link($this->u_action), E_USER_WARNING);
                  }
               }
               set_config('auth_method', basename($cfg_array['auth_method']));
            }
            else
            {
               trigger_error('NO_AUTH_PLUGIN', E_USER_ERROR);
            }
         }
      }

      if ($submit)
      {
         add_log('admin', 'LOG_CONFIG_' . strtoupper($mode));

         trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
      }

      $this->tpl_name = 'acp_board';
      $this->page_title = $display_vars['title'];

      $template->assign_vars(array(
         'L_TITLE'         => $user->lang[$display_vars['title']],
         'L_TITLE_EXPLAIN'   => $user->lang[$display_vars['title'] . '_EXPLAIN'],

         'S_ERROR'         => (sizeof($error)) ? true : false,
         'ERROR_MSG'         => implode('<br />', $error),

         'U_ACTION'         => $this->u_action)
      );

      // Output relevant page
      foreach ($display_vars['vars'] as $config_key => $vars)
      {
         if (!is_array($vars) && strpos($config_key, 'legend') === false)
         {
            continue;
         }

         if (strpos($config_key, 'legend') !== false)
         {
            $template->assign_block_vars('options', array(
               'S_LEGEND'      => true,
               'LEGEND'      => (isset($user->lang[$vars])) ? $user->lang[$vars] : $vars)
            );

            continue;
         }

         $type = explode(':', $vars['type']);

         $l_explain = '';
         if ($vars['explain'] && isset($vars['lang_explain']))
         {
            $l_explain = (isset($user->lang[$vars['lang_explain']])) ? $user->lang[$vars['lang_explain']] : $vars['lang_explain'];
         }
         else if ($vars['explain'])
         {
            $l_explain = (isset($user->lang[$vars['lang'] . '_EXPLAIN'])) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : '';
         }

         $content = build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars);

         if (empty($content))
         {
            continue;
         }

         $template->assign_block_vars('options', array(
            'KEY'         => $config_key,
            'TITLE'         => (isset($user->lang[$vars['lang']])) ? $user->lang[$vars['lang']] : $vars['lang'],
            'S_EXPLAIN'      => $vars['explain'],
            'TITLE_EXPLAIN'   => $l_explain,
            'CONTENT'      => $content,
            )
         );

         unset($display_vars['vars'][$config_key]);
      }

      if ($mode == 'auth')
      {
         $template->assign_var('S_AUTH', true);

         foreach ($auth_plugins as $method)
         {
            if ($method && file_exists($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx))
            {
               $method = 'acp_' . $method;
               if (function_exists($method))
               {
                  $fields = $method($this->new_config);

                  if ($fields['tpl'])
                  {
                     $template->assign_block_vars('auth_tpl', array(
                        'TPL'   => $fields['tpl'])
                     );
                  }
                  unset($fields);
               }
            }
         }
      }
   }

   /**
   * Select auth method
   */
   function select_auth_method($selected_method, $key = '')
   {
      global $phpbb_root_path, $phpEx;

      $auth_plugins = array();

      $dp = @opendir($phpbb_root_path . 'includes/auth');

      if (!$dp)
      {
         return '';
      }

      while (($file = readdir($dp)) !== false)
      {
         if (preg_match('#^auth_(.*?)\.' . $phpEx . '$#', $file))
         {
            $auth_plugins[] = preg_replace('#^auth_(.*?)\.' . $phpEx . '$#', '\1', $file);
         }
      }
      closedir($dp);

      sort($auth_plugins);

      $auth_select = '';
      foreach ($auth_plugins as $method)
      {
         $selected = ($selected_method == $method) ? ' selected="selected"' : '';
         $auth_select .= '<option value="' . $method . '"' . $selected . '>' . ucfirst($method) . '</option>';
      }

      return $auth_select;
   }

   /**
   * Select mail authentication method
   */
   function mail_auth_select($selected_method, $key = '')
   {
      global $user;

      $auth_methods = array('PLAIN', 'LOGIN', 'CRAM-MD5', 'DIGEST-MD5', 'POP-BEFORE-SMTP');
      $s_smtp_auth_options = '';

      foreach ($auth_methods as $method)
      {
         $s_smtp_auth_options .= '<option value="' . $method . '"' . (($selected_method == $method) ? ' selected="selected"' : '') . '>' . $user->lang['SMTP_' . str_replace('-', '_', $method)] . '</option>';
      }

      return $s_smtp_auth_options;
   }

   /**
   * Select full folder action
   */
   function full_folder_select($value, $key = '')
   {
      global $user;

      return '<option value="1"' . (($value == 1) ? ' selected="selected"' : '') . '>' . $user->lang['DELETE_OLDEST_MESSAGES'] . '</option><option value="2"' . (($value == 2) ? ' selected="selected"' : '') . '>' . $user->lang['HOLD_NEW_MESSAGES_SHORT'] . '</option>';
   }

   /**
   * Select ip validation
   */
   function select_ip_check($value, $key = '')
   {
      $radio_ary = array(4 => 'ALL', 3 => 'CLASS_C', 2 => 'CLASS_B', 0 => 'NO_IP_VALIDATION');

      return h_radio('config[ip_check]', $radio_ary, $value, $key);
   }

   /**
   * Select referer validation
   */
   function select_ref_check($value, $key = '')
   {
      $radio_ary = array(REFERER_VALIDATE_PATH => 'REF_PATH', REFERER_VALIDATE_HOST => 'REF_HOST', REFERER_VALIDATE_NONE => 'NO_REF_VALIDATION');

      return h_radio('config[referer_validation]', $radio_ary, $value, $key);
   }

   /**
   * Select account activation method
   */
   function select_acc_activation($value, $key = '')
   {
      global $user, $config;

      $radio_ary = array(USER_ACTIVATION_DISABLE => 'ACC_DISABLE', USER_ACTIVATION_NONE => 'ACC_NONE');
      if ($config['email_enable'])
      {
         $radio_ary += array(USER_ACTIVATION_SELF => 'ACC_USER', USER_ACTIVATION_ADMIN => 'ACC_ADMIN');
      }

      return h_radio('config[require_activation]', $radio_ary, $value, $key);
   }

   /**
   * Maximum/Minimum username length
   */
   function username_length($value, $key = '')
   {
      global $user;

      return '<input id="' . $key . '" type="text" size="3" maxlength="3" name="config[min_name_chars]" value="' . $value . '" /> ' . $user->lang['MIN_CHARS'] . '&nbsp;&nbsp;<input type="text" size="3" maxlength="3" name="config[max_name_chars]" value="' . $this->new_config['max_name_chars'] . '" /> ' . $user->lang['MAX_CHARS'];
   }

   /**
   * Allowed chars in usernames
   */
   function select_username_chars($selected_value, $key)
   {
      global $user;

      $user_char_ary = array('USERNAME_CHARS_ANY', 'USERNAME_ALPHA_ONLY', 'USERNAME_ALPHA_SPACERS', 'USERNAME_LETTER_NUM', 'USERNAME_LETTER_NUM_SPACERS', 'USERNAME_ASCII');
      $user_char_options = '';
      foreach ($user_char_ary as $user_type)
      {
         $selected = ($selected_value == $user_type) ? ' selected="selected"' : '';
         $user_char_options .= '<option value="' . $user_type . '"' . $selected . '>' . $user->lang[$user_type] . '</option>';
      }

      return $user_char_options;
   }

   /**
   * Maximum/Minimum password length
   */
   function password_length($value, $key)
   {
      global $user;

      return '<input id="' . $key . '" type="text" size="3" maxlength="3" name="config[min_pass_chars]" value="' . $value . '" /> ' . $user->lang['MIN_CHARS'] . '&nbsp;&nbsp;<input type="text" size="3" maxlength="3" name="config[max_pass_chars]" value="' . $this->new_config['max_pass_chars'] . '" /> ' . $user->lang['MAX_CHARS'];
   }

   /**
   * Required chars in passwords
   */
   function select_password_chars($selected_value, $key)
   {
      global $user;

      $pass_type_ary = array('PASS_TYPE_ANY', 'PASS_TYPE_CASE', 'PASS_TYPE_ALPHA', 'PASS_TYPE_SYMBOL');
      $pass_char_options = '';
      foreach ($pass_type_ary as $pass_type)
      {
         $selected = ($selected_value == $pass_type) ? ' selected="selected"' : '';
         $pass_char_options .= '<option value="' . $pass_type . '"' . $selected . '>' . $user->lang[$pass_type] . '</option>';
      }

      return $pass_char_options;
   }
      /**
   * Select resized image link method
   */
   function select_reimg_link_method($selected_value, $key)
   {
      global $user;

      $link_method_ary = array('button' => 'REIMG_LINK_BUTTON', 'link' => 'REIMG_LINK_IMAGE', 'button_link' => 'REIMG_LINK_BOTH');
      $link_options = '';
      foreach ($link_method_ary as $link_mehod => $lang)
      {
         $selected = ($selected_value == $link_mehod) ? ' selected="selected"' : '';
         $link_options .= '<option value="' . $link_mehod . '"' . $selected . '>' . $user->lang[$lang] . '</option>';
      }

      return $link_options;
   }

   /**
   * Select resized image zoom method
   */
   function select_reimg_zoom_method($selected_value, $key)
   {
      global $user, $phpbb_root_path;

      $zoom_method_ary = array('' => 'DISABLED', '_default' => 'REIMG_ZOOM_DEFAULT', '_exturl' => 'REIMG_ZOOM_EXTURL', '_blank' => 'REIMG_ZOOM_BLANK', '_litebox' => 'REIMG_ZOOM_LITEBOX', '_litebox1' => 'REIMG_ZOOM_LITEBOX_1_1', '_litebox0' => 'REIMG_ZOOM_LITEBOX_RESIZED', '_highslide' => 'REIMG_ZOOM_HIGHSLIDE');
      $zoom_options = '';
      foreach ($zoom_method_ary as $zoom_method => $lang)
      {
         $disabled = '';
         //We need to check and see if the Highslide library actually exists before allowing the option to be selectable
         if ($zoom_method == '_highslide')
         {
            //We need one of the highslide js libraries
            if (!file_exists($phpbb_root_path . 'reimg/highslide/highslide-full.packed.js'))
            {
               $disabled = ' disabled';
            }
         }
         $selected = ($selected_value == $zoom_method) ? ' selected="selected"' : '';
         $zoom_options .= '<option value="' . $zoom_method . '"' . $selected . $disabled . '>' . $user->lang[$lang] . '</option>';
      }

      return $zoom_options;
   }
   

   /**
   * Select bump interval
   */
   function bump_interval($value, $key)
   {
      global $user;

      $s_bump_type = '';
      $types = array('m' => 'MINUTES', 'h' => 'HOURS', 'd' => 'DAYS');
      foreach ($types as $type => $lang)
      {
         $selected = ($this->new_config['bump_type'] == $type) ? ' selected="selected"' : '';
         $s_bump_type .= '<option value="' . $type . '"' . $selected . '>' . $user->lang[$lang] . '</option>';
      }

      return '<input id="' . $key . '" type="text" size="3" maxlength="4" name="config[bump_interval]" value="' . $value . '" />&nbsp;<select name="config[bump_type]">' . $s_bump_type . '</select>';
   }

   /**
   * Board disable option and message
   */
   function board_disable($value, $key)
   {
      global $user;

      $radio_ary = array(1 => 'YES', 0 => 'NO');

      return h_radio('config[board_disable]', $radio_ary, $value) . '<br /><input id="' . $key . '" type="text" name="config[board_disable_msg]" maxlength="255" size="40" value="' . $this->new_config['board_disable_msg'] . '" />';
   }

   /**
   * Global quick reply enable/disable setting and button to enable in all forums
   */
   function quick_reply($value, $key)
   {
      global $user;

      $radio_ary = array(1 => 'YES', 0 => 'NO');

      return h_radio('config[allow_quick_reply]', $radio_ary, $value) .
         '<br /><br /><input class="button2" type="submit" id="' . $key . '_enable" name="' . $key . '_enable" value="' . $user->lang['ALLOW_QUICK_REPLY_BUTTON'] . '" />';
   }


   /**
   * Select default dateformat
   */
   function dateformat_select($value, $key)
   {
      global $user, $config;

      // Let the format_date function operate with the acp values
      $old_tz = $user->timezone;
      $old_dst = $user->dst;

      $user->timezone = $config['board_timezone'];
      $user->dst = $config['board_dst'];

      $dateformat_options = '';

      foreach ($user->lang['dateformats'] as $format => $null)
      {
         $dateformat_options .= '<option value="' . $format . '"' . (($format == $value) ? ' 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>';
      }

      $dateformat_options .= '<option value="custom"';
      if (!isset($user->lang['dateformats'][$value]))
      {
         $dateformat_options .= ' selected="selected"';
      }
      $dateformat_options .= '>' . $user->lang['CUSTOM_DATEFORMAT'] . '</option>';

      // Reset users date options
      $user->timezone = $old_tz;
      $user->dst = $old_dst;

      return "<select name=\"dateoptions\" id=\"dateoptions\" onchange=\"if (this.value == 'custom') { document.getElementById('" . addslashes($key) . "').value = '" . addslashes($value) . "'; } else { document.getElementById('" . addslashes($key) . "').value = this.value; }\">$dateformat_options</select>
      <input type=\"text\" name=\"config[$key]\" id=\"$key\" value=\"$value\" maxlength=\"30\" />";
   }

   /**
   * Select multiple forums
   */
   function select_news_forums($value, $key)
   {
      global $user, $config;

      $forum_list = make_forum_select(false, false, true, true, true, false, true);

      // Build forum options
      $s_forum_options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">';
      foreach ($forum_list as $f_id => $f_row)
      {
         $f_row['selected'] = phpbb_optionget(FORUM_OPTION_FEED_NEWS, $f_row['forum_options']);

         $s_forum_options .= '<option value="' . $f_id . '"' . (($f_row['selected']) ? ' selected="selected"' : '') . (($f_row['disabled']) ? ' disabled="disabled" class="disabled-option"' : '') . '>' . $f_row['padding'] . $f_row['forum_name'] . '</option>';
      }
      $s_forum_options .= '</select>';

      return $s_forum_options;
   }

   function select_exclude_forums($value, $key)
   {
      global $user, $config;

      $forum_list = make_forum_select(false, false, true, true, true, false, true);

      // Build forum options
      $s_forum_options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">';
      foreach ($forum_list as $f_id => $f_row)
      {
         $f_row['selected'] = phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $f_row['forum_options']);

         $s_forum_options .= '<option value="' . $f_id . '"' . (($f_row['selected']) ? ' selected="selected"' : '') . (($f_row['disabled']) ? ' disabled="disabled" class="disabled-option"' : '') . '>' . $f_row['padding'] . $f_row['forum_name'] . '</option>';
      }
      $s_forum_options .= '</select>';

      return $s_forum_options;
   }

   function store_feed_forums($option, $key)
   {
      global $db, $cache;

      // Get key
      $values = request_var($key, array(0 => 0));

      // Empty option bit for all forums
      $sql = 'UPDATE ' . FORUMS_TABLE . '
         SET forum_options = forum_options - ' . (1 << $option) . '
         WHERE ' . $db->sql_bit_and('forum_options', $option, '<> 0');
      $db->sql_query($sql);

      // Already emptied for all...
      if (sizeof($values))
      {
         // Set for selected forums
         $sql = 'UPDATE ' . FORUMS_TABLE . '
            SET forum_options = forum_options + ' . (1 << $option) . '
            WHERE ' . $db->sql_in_set('forum_id', $values);
         $db->sql_query($sql);
      }

      // Empty sql cache for forums table because options changed
      $cache->destroy('sql', FORUMS_TABLE);
   }

}

?>
by mnc8
Tue May 25, 2010 8:17 pm

Not found in ACP

Hello

I have followed all instructions in the file install the mod, however, does not appear in my ACP. The mod still works in my posts because my images are automatically resized, I have refreshed the templates ...

Here is my file acp_board.php:

Code: Select all

<?php
/**
*
* @package acp
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
* @todo add cron intervals to server settings? (database_gc, queue_interval, session_gc, search_gc, cache_gc, warnings_gc)
*/

/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
   exit;
}

/**
* @package acp
*/
class acp_board
{
   var $u_action;
   var $new_config = array();

   function main($id, $mode)
   {
      global $db, $user, $auth, $template;
      global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
      global $cache;

      $user->add_lang('acp/board');
      $user->add_lang('mods/reimg');
      $action   = request_var('action', '');
      $submit = (isset($_POST['submit']) || isset($_POST['allow_quick_reply_enable'])) ? true : false;

      $form_key = 'acp_board';
      add_form_key($form_key);

      /**
      *   Validation types are:
      *      string, int, bool,
      *      script_path (absolute path in url - beginning with / and no trailing slash),
      *      rpath (relative), rwpath (realtive, writable), path (relative path, but able to escape the root), wpath (writable)
      */
      switch ($mode)
      {
         case 'settings':
            $display_vars = array(
               'title'   => 'ACP_BOARD_SETTINGS',
               'vars'   => array(
                  'legend1'            => 'ACP_BOARD_SETTINGS',
                  'sitename'            => array('lang' => 'SITE_NAME',            'validate' => 'string',   'type' => 'text:40:255', 'explain' => false),
                  'site_desc'            => array('lang' => 'SITE_DESC',            'validate' => 'string',   'type' => 'text:40:255', 'explain' => false),
                  'board_disable'         => array('lang' => 'DISABLE_BOARD',         'validate' => 'bool',   'type' => 'custom', 'method' => 'board_disable', 'explain' => true),
                  'board_disable_msg'      => false,
                  'default_lang'         => array('lang' => 'DEFAULT_LANGUAGE',      'validate' => 'lang',   'type' => 'select', 'function' => 'language_select', 'params' => array('{CONFIG_VALUE}'), 'explain' => false),
                  'default_dateformat'   => array('lang' => 'DEFAULT_DATE_FORMAT',   'validate' => 'string',   'type' => 'custom', 'method' => 'dateformat_select', 'explain' => true),
                  'board_timezone'      => array('lang' => 'SYSTEM_TIMEZONE',      'validate' => 'string',   'type' => 'select', 'function' => 'tz_select', 'params' => array('{CONFIG_VALUE}', 1), 'explain' => false),
                  'board_dst'            => array('lang' => 'SYSTEM_DST',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                                    'use_client_browser'         => array('lang' => 'USE_CLIENT_BROWSER',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'default_style'         => array('lang' => 'DEFAULT_STYLE',         'validate' => 'int',   'type' => 'select', 'function' => 'style_select', 'params' => array('{CONFIG_VALUE}', false), 'explain' => false),
                  'override_user_style'   => array('lang' => 'OVERRIDE_STYLE',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),

                  'legend2'            => 'WARNINGS',
                  'warnings_expire_days'   => array('lang' => 'WARNINGS_EXPIRE',      'validate' => 'int',   'type' => 'text:3:4', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),

                  'legend3'               => 'ACP_SUBMIT_CHANGES',
               )
            );
         break;

         case 'features':
            $display_vars = array(
               'title'   => 'ACP_BOARD_FEATURES',
               'vars'   => array(
                  'legend1'            => 'ACP_BOARD_FEATURES',
                  'allow_privmsg'         => array('lang' => 'BOARD_PM',            'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_topic_notify'   => array('lang' => 'ALLOW_TOPIC_NOTIFY',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_forum_notify'   => array('lang' => 'ALLOW_FORUM_NOTIFY',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_namechange'      => array('lang' => 'ALLOW_NAME_CHANGE',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_attachments'      => array('lang' => 'ALLOW_ATTACHMENTS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_pm_attach'      => array('lang' => 'ALLOW_PM_ATTACHMENTS',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_pm_report'      => array('lang' => 'ALLOW_PM_REPORT',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_bbcode'         => array('lang' => 'ALLOW_BBCODE',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_smilies'         => array('lang' => 'ALLOW_SMILIES',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_sig'            => array('lang' => 'ALLOW_SIG',            'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_nocensors'      => array('lang' => 'ALLOW_NO_CENSORS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_bookmarks'      => array('lang' => 'ALLOW_BOOKMARKS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_birthdays'      => array('lang' => 'ALLOW_BIRTHDAYS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_quick_reply'      => array('lang' => 'ALLOW_QUICK_REPLY',      'validate' => 'bool',   'type' => 'custom', 'method' => 'quick_reply', 'explain' => true),

                  'legend2'            => 'ACP_LOAD_SETTINGS',
                  'load_birthdays'      => array('lang' => 'YES_BIRTHDAYS',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'load_moderators'      => array('lang' => 'YES_MODERATORS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'load_jumpbox'         => array('lang' => 'YES_JUMPBOX',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'load_cpf_memberlist'   => array('lang' => 'LOAD_CPF_MEMBERLIST',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'load_cpf_viewprofile'   => array('lang' => 'LOAD_CPF_VIEWPROFILE',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'load_cpf_viewtopic'   => array('lang' => 'LOAD_CPF_VIEWTOPIC',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),

                  'legend3'               => 'ACP_SUBMIT_CHANGES',
               )
            );
         break;

         case 'avatar':
            $display_vars = array(
               'title'   => 'ACP_AVATAR_SETTINGS',
               'vars'   => array(
                  'legend1'            => 'ACP_AVATAR_SETTINGS',

                  'avatar_min_width'      => array('lang' => 'MIN_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,),
                  'avatar_min_height'      => array('lang' => 'MIN_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,),
                  'avatar_max_width'      => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,),
                  'avatar_max_height'      => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false,),

                  'allow_avatar'         => array('lang' => 'ALLOW_AVATARS',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_avatar_local'   => array('lang' => 'ALLOW_LOCAL',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_avatar_remote'   => array('lang' => 'ALLOW_REMOTE',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_avatar_upload'   => array('lang' => 'ALLOW_UPLOAD',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_avatar_remote_upload'=> array('lang' => 'ALLOW_REMOTE_UPLOAD', 'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'avatar_filesize'      => array('lang' => 'MAX_FILESIZE',         'validate' => 'int:0',   'type' => 'text:4:10', 'explain' => true, 'append' => ' ' . $user->lang['BYTES']),
                  'avatar_min'         => array('lang' => 'MIN_AVATAR_SIZE',      'validate' => 'int:0',   'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
                  'avatar_max'         => array('lang' => 'MAX_AVATAR_SIZE',      'validate' => 'int:0',   'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
                  'avatar_path'         => array('lang' => 'AVATAR_STORAGE_PATH',   'validate' => 'rwpath',   'type' => 'text:20:255', 'explain' => true),
                  'avatar_gallery_path'   => array('lang' => 'AVATAR_GALLERY_PATH',   'validate' => 'rpath',   'type' => 'text:20:255', 'explain' => true)
               )
            );
         break;

         case 'message':
            $display_vars = array(
               'title'   => 'ACP_MESSAGE_SETTINGS',
               'lang'   => 'ucp',
               'vars'   => array(
                  'legend1'            => 'GENERAL_SETTINGS',
                  'allow_privmsg'         => array('lang' => 'BOARD_PM',            'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'pm_max_boxes'         => array('lang' => 'BOXES_MAX',            'validate' => 'int:0',   'type' => 'text:4:4', 'explain' => true),
                  'pm_max_msgs'         => array('lang' => 'BOXES_LIMIT',         'validate' => 'int:0',   'type' => 'text:4:4', 'explain' => true),
                  'full_folder_action'   => array('lang' => 'FULL_FOLDER_ACTION',   'validate' => 'int',   'type' => 'select', 'method' => 'full_folder_select', 'explain' => true),
                  'pm_edit_time'         => array('lang' => 'PM_EDIT_TIME',         'validate' => 'int:0',   'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),
                  'pm_max_recipients'      => array('lang' => 'PM_MAX_RECIPIENTS',      'validate' => 'int:0',   'type' => 'text:5:5', 'explain' => true),

                  'legend2'            => 'GENERAL_OPTIONS',
                  'allow_mass_pm'         => array('lang' => 'ALLOW_MASS_PM',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'auth_bbcode_pm'      => array('lang' => 'ALLOW_BBCODE_PM',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'auth_smilies_pm'      => array('lang' => 'ALLOW_SMILIES_PM',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_pm_attach'      => array('lang' => 'ALLOW_PM_ATTACHMENTS',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_sig_pm'         => array('lang' => 'ALLOW_SIG_PM',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'print_pm'            => array('lang' => 'ALLOW_PRINT_PM',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'forward_pm'         => array('lang' => 'ALLOW_FORWARD_PM',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'auth_img_pm'         => array('lang' => 'ALLOW_IMG_PM',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'auth_flash_pm'         => array('lang' => 'ALLOW_FLASH_PM',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'enable_pm_icons'      => array('lang' => 'ENABLE_PM_ICONS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),

                  'legend3'               => 'ACP_SUBMIT_CHANGES',
               )
            );
         break;

         case 'post':
            $display_vars = array(
               'title'   => 'ACP_POST_SETTINGS',
               'vars'   => array(
                  'legend1'            => 'GENERAL_OPTIONS',
                  'allow_topic_notify'   => array('lang' => 'ALLOW_TOPIC_NOTIFY',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_forum_notify'   => array('lang' => 'ALLOW_FORUM_NOTIFY',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_bbcode'         => array('lang' => 'ALLOW_BBCODE',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_post_flash'      => array('lang' => 'ALLOW_POST_FLASH',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_smilies'         => array('lang' => 'ALLOW_SMILIES',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_post_links'      => array('lang' => 'ALLOW_POST_LINKS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_nocensors'      => array('lang' => 'ALLOW_NO_CENSORS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_bookmarks'      => array('lang' => 'ALLOW_BOOKMARKS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'enable_post_confirm'   => array('lang' => 'VISUAL_CONFIRM_POST',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'allow_quick_reply'      => array('lang' => 'ALLOW_QUICK_REPLY',      'validate' => 'bool',   'type' => 'custom', 'method' => 'quick_reply', 'explain' => true),

                  'legend2'            => 'POSTING',
                  'bump_type'            => false,
                  'edit_time'            => array('lang' => 'EDIT_TIME',            'validate' => 'int:0',      'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),
                  'delete_time'         => array('lang' => 'DELETE_TIME',         'validate' => 'int:0',      'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),
                  'display_last_edited'   => array('lang' => 'DISPLAY_LAST_EDITED',   'validate' => 'bool',      'type' => 'radio:yes_no', 'explain' => true),
                  'flood_interval'      => array('lang' => 'FLOOD_INTERVAL',      'validate' => 'int:0',      'type' => 'text:3:10', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
                  'bump_interval'         => array('lang' => 'BUMP_INTERVAL',         'validate' => 'int:0',      'type' => 'custom', 'method' => 'bump_interval', 'explain' => true),
                  'topics_per_page'      => array('lang' => 'TOPICS_PER_PAGE',      'validate' => 'int:1',      'type' => 'text:3:4', 'explain' => false),
                  'posts_per_page'      => array('lang' => 'POSTS_PER_PAGE',      'validate' => 'int:1',      'type' => 'text:3:4', 'explain' => false),
                  'smilies_per_page'      => array('lang' => 'SMILIES_PER_PAGE',      'validate' => 'int:1',      'type' => 'text:3:4', 'explain' => false),
                  'hot_threshold'         => array('lang' => 'HOT_THRESHOLD',         'validate' => 'int:0',      'type' => 'text:3:4', 'explain' => true),
                  'max_poll_options'      => array('lang' => 'MAX_POLL_OPTIONS',      'validate' => 'int:2:127',   'type' => 'text:4:4', 'explain' => false),
                  'max_post_chars'      => array('lang' => 'CHAR_LIMIT',         'validate' => 'int:0',      'type' => 'text:4:6', 'explain' => true),
                  'min_post_chars'      => array('lang' => 'MIN_CHAR_LIMIT',      'validate' => 'int:0',      'type' => 'text:4:6', 'explain' => true),
                  'max_post_smilies'      => array('lang' => 'SMILIES_LIMIT',         'validate' => 'int:0',      'type' => 'text:4:4', 'explain' => true),
                  'max_post_urls'         => array('lang' => 'MAX_POST_URLS',         'validate' => 'int:0',      'type' => 'text:5:4', 'explain' => true),
                  'max_post_font_size'   => array('lang' => 'MAX_POST_FONT_SIZE',   'validate' => 'int:0',      'type' => 'text:5:4', 'explain' => true, 'append' => ' %'),
                  'max_quote_depth'      => array('lang' => 'QUOTE_DEPTH_LIMIT',      'validate' => 'int:0',      'type' => 'text:4:4', 'explain' => true),
                  'max_post_img_width'   => array('lang' => 'MAX_POST_IMG_WIDTH',   'validate' => 'int:0',      'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
                  'max_post_img_height'   => array('lang' => 'MAX_POST_IMG_HEIGHT',   'validate' => 'int:0',      'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),

                  'legend_reimg'         => 'REIMG_SETTINGS',
                  'reimg_max_width'      => array('lang' => 'REIMG_MAX_SIZE',      'validate' => 'int:0',   'type' => false, 'method' => false, 'explain' => false),
                  'reimg_max_height'      => array('lang' => 'REIMG_MAX_SIZE',      'validate' => 'int:0',   'type' => false, 'method' => false, 'explain' => false),
                  'reimg_max'            => array('lang' => 'REIMG_MAX_SIZE',      'validate' => 'int:0',   'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
                  'reimg_rel_width'      => array('lang' => 'REIMG_REL_WIDTH',      'validate' => 'int:0',   'type' => 'text:3:4', 'explain' => true, 'append' => ' %'),
                  'reimg_swap_portrait'   => array('lang' => 'REIMG_SWAP_PORTRAIT',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'reimg_ignore_sig_img'   => array('lang' => 'REIMG_IGNORE_SIG_IMG',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'reimg_link'         => array('lang' => 'REIMG_LINK_METHOD',      'validate' => 'string',   'type' => 'select', 'method' => 'select_reimg_link_method', 'explain' => true),
                  'reimg_zoom'         => array('lang' => 'REIMG_ZOOM_METHOD',      'validate' => 'string',   'type' => 'select', 'method' => 'select_reimg_zoom_method', 'explain' => true),
                  'legend3'               => 'ACP_SUBMIT_CHANGES',
               )
            );
         break;

         case 'signature':
            $display_vars = array(
               'title'   => 'ACP_SIGNATURE_SETTINGS',
               'vars'   => array(
                  'legend1'            => 'GENERAL_OPTIONS',
                  'allow_sig'            => array('lang' => 'ALLOW_SIG',            'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_sig_bbcode'      => array('lang' => 'ALLOW_SIG_BBCODE',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_sig_img'         => array('lang' => 'ALLOW_SIG_IMG',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_sig_flash'      => array('lang' => 'ALLOW_SIG_FLASH',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_sig_smilies'      => array('lang' => 'ALLOW_SIG_SMILIES',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_sig_links'      => array('lang' => 'ALLOW_SIG_LINKS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),

                  'legend2'            => 'GENERAL_SETTINGS',
                  'max_sig_chars'         => array('lang' => 'MAX_SIG_LENGTH',      'validate' => 'int:0',   'type' => 'text:5:4', 'explain' => true),
                  'max_sig_urls'         => array('lang' => 'MAX_SIG_URLS',         'validate' => 'int:0',   'type' => 'text:5:4', 'explain' => true),
                  'max_sig_font_size'      => array('lang' => 'MAX_SIG_FONT_SIZE',      'validate' => 'int:0',   'type' => 'text:5:4', 'explain' => true, 'append' => ' %'),
                  'max_sig_smilies'      => array('lang' => 'MAX_SIG_SMILIES',      'validate' => 'int:0',   'type' => 'text:5:4', 'explain' => true),
                  'max_sig_img_width'      => array('lang' => 'MAX_SIG_IMG_WIDTH',      'validate' => 'int:0',   'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
                  'max_sig_img_height'   => array('lang' => 'MAX_SIG_IMG_HEIGHT',   'validate' => 'int:0',   'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),

                  'legend3'               => 'ACP_SUBMIT_CHANGES',
               )
            );
         break;

         case 'registration':
            $display_vars = array(
               'title'   => 'ACP_REGISTER_SETTINGS',
               'vars'   => array(
                  'legend1'            => 'GENERAL_SETTINGS',
                  'max_name_chars'      => array('lang' => 'USERNAME_LENGTH', 'validate' => 'int:8:180', 'type' => false, 'method' => false, 'explain' => false,),
                  'max_pass_chars'      => array('lang' => 'PASSWORD_LENGTH', 'validate' => 'int:8:255', 'type' => false, 'method' => false, 'explain' => false,),

                  'require_activation'   => array('lang' => 'ACC_ACTIVATION',   'validate' => 'int',   'type' => 'custom', 'method' => 'select_acc_activation', 'explain' => true),
                  'new_member_post_limit'   => array('lang' => 'NEW_MEMBER_POST_LIMIT', 'validate' => 'int:0:255', 'type' => 'text:4:4', 'explain' => true, 'append' => ' ' . $user->lang['POSTS']),
                  'new_member_group_default'=> array('lang' => 'NEW_MEMBER_GROUP_DEFAULT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
                  'min_name_chars'      => array('lang' => 'USERNAME_LENGTH',   'validate' => 'int:1',   'type' => 'custom:5:180', 'method' => 'username_length', 'explain' => true),
                  'min_pass_chars'      => array('lang' => 'PASSWORD_LENGTH',   'validate' => 'int:1',   'type' => 'custom', 'method' => 'password_length', 'explain' => true),
                  'allow_name_chars'      => array('lang' => 'USERNAME_CHARS',   'validate' => 'string',   'type' => 'select', 'method' => 'select_username_chars', 'explain' => true),
                  'pass_complex'         => array('lang' => 'PASSWORD_TYPE',      'validate' => 'string',   'type' => 'select', 'method' => 'select_password_chars', 'explain' => true),
                  'chg_passforce'         => array('lang' => 'FORCE_PASS_CHANGE',   'validate' => 'int:0',   'type' => 'text:3:3', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),

                  'legend2'            => 'GENERAL_OPTIONS',
                  'allow_namechange'      => array('lang' => 'ALLOW_NAME_CHANGE',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'allow_emailreuse'      => array('lang' => 'ALLOW_EMAIL_REUSE',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'enable_confirm'      => array('lang' => 'VISUAL_CONFIRM_REG',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'max_login_attempts'   => array('lang' => 'MAX_LOGIN_ATTEMPTS',   'validate' => 'int:0',   'type' => 'text:3:3', 'explain' => true),
                  'max_reg_attempts'      => array('lang' => 'REG_LIMIT',            'validate' => 'int:0',   'type' => 'text:4:4', 'explain' => true),

                  'legend3'         => 'COPPA',
                  'coppa_enable'      => array('lang' => 'ENABLE_COPPA',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'coppa_mail'      => array('lang' => 'COPPA_MAIL',      'validate' => 'string',   'type' => 'textarea:5:40', 'explain' => true),
                  'coppa_fax'         => array('lang' => 'COPPA_FAX',         'validate' => 'string',   'type' => 'text:25:100', 'explain' => false),

                  'legend4'         => 'ACP_SUBMIT_CHANGES',
               )
            );
         break;

         case 'feed':
            $display_vars = array(
               'title'   => 'ACP_FEED_MANAGEMENT',
               'vars'   => array(
                  'legend1'               => 'ACP_FEED_GENERAL',
                  'feed_enable'            => array('lang' => 'ACP_FEED_ENABLE',            'validate' => 'bool',   'type' => 'radio:enabled_disabled',   'explain' => true ),
                  'feed_item_statistics'      => array('lang' => 'ACP_FEED_ITEM_STATISTICS',      'validate' => 'bool',   'type' => 'radio:enabled_disabled',   'explain' => true),
                  'feed_http_auth'         => array('lang' => 'ACP_FEED_HTTP_AUTH',         'validate' => 'bool',   'type' => 'radio:enabled_disabled',   'explain' => true),

                  'legend2'               => 'ACP_FEED_POST_BASED',
                  'feed_limit_post'         => array('lang' => 'ACP_FEED_LIMIT',            'validate' => 'int:5',   'type' => 'text:3:4',            'explain' => true),
                  'feed_overall'            => array('lang' => 'ACP_FEED_OVERALL',            'validate' => 'bool',   'type' => 'radio:enabled_disabled',   'explain' => true ),
                  'feed_forum'            => array('lang' => 'ACP_FEED_FORUM',            'validate' => 'bool',   'type' => 'radio:enabled_disabled',   'explain' => true ),
                  'feed_topic'            => array('lang' => 'ACP_FEED_TOPIC',            'validate' => 'bool',   'type' => 'radio:enabled_disabled',   'explain' => true ),

                  'legend3'               => 'ACP_FEED_TOPIC_BASED',
                  'feed_limit_topic'         => array('lang' => 'ACP_FEED_LIMIT',            'validate' => 'int:5',   'type' => 'text:3:4',            'explain' => true),
                  'feed_topics_new'         => array('lang' => 'ACP_FEED_TOPICS_NEW',         'validate' => 'bool',   'type' => 'radio:enabled_disabled',   'explain' => true ),
                  'feed_topics_active'      => array('lang' => 'ACP_FEED_TOPICS_ACTIVE',      'validate' => 'bool',   'type' => 'radio:enabled_disabled',   'explain' => true ),
                  'feed_news_id'            => array('lang' => 'ACP_FEED_NEWS',               'validate' => 'string',   'type' => 'custom', 'method' => 'select_news_forums', 'explain' => true),

                  'legend4'               => 'ACP_FEED_SETTINGS_OTHER',
                  'feed_overall_forums'      => array('lang'   => 'ACP_FEED_OVERALL_FORUMS',      'validate' => 'bool',   'type' => 'radio:enabled_disabled',   'explain' => true ),
                  'feed_exclude_id'         => array('lang' => 'ACP_FEED_EXCLUDE_ID',         'validate' => 'string',   'type' => 'custom', 'method' => 'select_exclude_forums', 'explain' => true),
               )
            );
         break;

         case 'cookie':
            $display_vars = array(
               'title'   => 'ACP_COOKIE_SETTINGS',
               'vars'   => array(
                  'legend1'      => 'ACP_COOKIE_SETTINGS',
                  'cookie_domain'   => array('lang' => 'COOKIE_DOMAIN',   'validate' => 'string',   'type' => 'text::255', 'explain' => false),
                  'cookie_name'   => array('lang' => 'COOKIE_NAME',   'validate' => 'string',   'type' => 'text::16', 'explain' => false),
                  'cookie_path'   => array('lang'   => 'COOKIE_PATH',   'validate' => 'string',   'type' => 'text::255', 'explain' => false),
                  'cookie_secure'   => array('lang' => 'COOKIE_SECURE',   'validate' => 'bool',   'type' => 'radio:disabled_enabled', 'explain' => true)
               )
            );
         break;

         case 'load':
            $display_vars = array(
               'title'   => 'ACP_LOAD_SETTINGS',
               'vars'   => array(
                  'legend1'         => 'GENERAL_SETTINGS',
                  'limit_load'      => array('lang' => 'LIMIT_LOAD',      'validate' => 'string',   'type' => 'text:4:4', 'explain' => true),
                  'session_length'   => array('lang' => 'SESSION_LENGTH',   'validate' => 'int:60',   'type' => 'text:5:10', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
                  'active_sessions'   => array('lang' => 'LIMIT_SESSIONS',   'validate' => 'int:0',   'type' => 'text:4:4', 'explain' => true),
                  'load_online_time'   => array('lang' => 'ONLINE_LENGTH',      'validate' => 'int:0',   'type' => 'text:4:3', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),

                  'legend2'            => 'GENERAL_OPTIONS',
                  'load_db_track'         => array('lang' => 'YES_POST_MARKING',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'load_db_lastread'      => array('lang' => 'YES_READ_MARKING',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'load_anon_lastread'   => array('lang' => 'YES_ANON_READ_MARKING',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'load_online'         => array('lang' => 'YES_ONLINE',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'load_online_guests'   => array('lang' => 'YES_ONLINE_GUESTS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'load_onlinetrack'      => array('lang' => 'YES_ONLINE_TRACK',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'load_birthdays'      => array('lang' => 'YES_BIRTHDAYS',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'load_moderators'      => array('lang' => 'YES_MODERATORS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'load_jumpbox'         => array('lang' => 'YES_JUMPBOX',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'load_user_activity'   => array('lang' => 'LOAD_USER_ACTIVITY',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'load_tplcompile'      => array('lang' => 'RECOMPILE_STYLES',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),

                  'legend3'            => 'CUSTOM_PROFILE_FIELDS',
                  'load_cpf_memberlist'   => array('lang' => 'LOAD_CPF_MEMBERLIST',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'load_cpf_viewprofile'   => array('lang' => 'LOAD_CPF_VIEWPROFILE',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),
                  'load_cpf_viewtopic'   => array('lang' => 'LOAD_CPF_VIEWTOPIC',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => false),

                  'legend4'               => 'ACP_SUBMIT_CHANGES',
               )
            );
         break;

         case 'auth':
            $display_vars = array(
               'title'   => 'ACP_AUTH_SETTINGS',
               'vars'   => array(
                  'legend1'      => 'ACP_AUTH_SETTINGS',
                  'auth_method'   => array('lang' => 'AUTH_METHOD',   'validate' => 'string',   'type' => 'select', 'method' => 'select_auth_method', 'explain' => false)
               )
            );
         break;

         case 'server':
            $display_vars = array(
               'title'   => 'ACP_SERVER_SETTINGS',
               'vars'   => array(
                  'legend1'            => 'ACP_SERVER_SETTINGS',
                  'gzip_compress'         => array('lang' => 'ENABLE_GZIP',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),

                  'legend2'            => 'PATH_SETTINGS',
                  'smilies_path'         => array('lang' => 'SMILIES_PATH',      'validate' => 'rpath',   'type' => 'text:20:255', 'explain' => true),
                  'icons_path'         => array('lang' => 'ICONS_PATH',      'validate' => 'rpath',   'type' => 'text:20:255', 'explain' => true),
                  'upload_icons_path'      => array('lang' => 'UPLOAD_ICONS_PATH',   'validate' => 'rpath',   'type' => 'text:20:255', 'explain' => true),
                  'ranks_path'         => array('lang' => 'RANKS_PATH',      'validate' => 'rpath',   'type' => 'text:20:255', 'explain' => true),

                  'legend3'            => 'SERVER_URL_SETTINGS',
                  'force_server_vars'      => array('lang' => 'FORCE_SERVER_VARS',   'validate' => 'bool',         'type' => 'radio:yes_no', 'explain' => true),
                  'server_protocol'      => array('lang' => 'SERVER_PROTOCOL',   'validate' => 'string',         'type' => 'text:10:10', 'explain' => true),
                  'server_name'         => array('lang' => 'SERVER_NAME',      'validate' => 'string',         'type' => 'text:40:255', 'explain' => true),
                  'server_port'         => array('lang' => 'SERVER_PORT',      'validate' => 'int:0',         'type' => 'text:5:5', 'explain' => true),
                  'script_path'         => array('lang' => 'SCRIPT_PATH',      'validate' => 'script_path',   'type' => 'text::255', 'explain' => true),

                  'legend4'               => 'ACP_SUBMIT_CHANGES',
               )
            );
         break;

         case 'security':
            $display_vars = array(
               'title'   => 'ACP_SECURITY_SETTINGS',
               'vars'   => array(
                  'legend1'            => 'ACP_SECURITY_SETTINGS',
                  'allow_autologin'      => array('lang' => 'ALLOW_AUTOLOGIN',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'max_autologin_time'   => array('lang' => 'AUTOLOGIN_LENGTH',      'validate' => 'int:0',   'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),
                  'ip_check'            => array('lang' => 'IP_VALID',            'validate' => 'int',   'type' => 'custom', 'method' => 'select_ip_check', 'explain' => true),
                  'browser_check'         => array('lang' => 'BROWSER_VALID',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'forwarded_for_check'   => array('lang' => 'FORWARDED_FOR_VALID',   'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'referer_validation'   => array('lang' => 'REFERER_VALID',      'validate' => 'int:0:3','type' => 'custom', 'method' => 'select_ref_check', 'explain' => true),
                  'check_dnsbl'         => array('lang' => 'CHECK_DNSBL',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'email_check_mx'      => array('lang' => 'EMAIL_CHECK_MX',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'pass_complex'         => array('lang' => 'PASSWORD_TYPE',         'validate' => 'string',   'type' => 'select', 'method' => 'select_password_chars', 'explain' => true),
                  'chg_passforce'         => array('lang' => 'FORCE_PASS_CHANGE',      'validate' => 'int:0',   'type' => 'text:3:3', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),
                  'max_login_attempts'   => array('lang' => 'MAX_LOGIN_ATTEMPTS',   'validate' => 'int:0',   'type' => 'text:3:3', 'explain' => true),
                  'tpl_allow_php'         => array('lang' => 'TPL_ALLOW_PHP',         'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'form_token_lifetime'   => array('lang' => 'FORM_TIME_MAX',         'validate' => 'int:-1',   'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
                  'form_token_sid_guests'   => array('lang' => 'FORM_SID_GUESTS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),

               )
            );
         break;

         case 'email':
            $display_vars = array(
               'title'   => 'ACP_EMAIL_SETTINGS',
               'vars'   => array(
                  'legend1'            => 'GENERAL_SETTINGS',
                  'email_enable'         => array('lang' => 'ENABLE_EMAIL',         'validate' => 'bool',   'type' => 'radio:enabled_disabled', 'explain' => true),
                  'board_email_form'      => array('lang' => 'BOARD_EMAIL_FORM',      'validate' => 'bool',   'type' => 'radio:enabled_disabled', 'explain' => true),
                  'email_function_name'   => array('lang' => 'EMAIL_FUNCTION_NAME',   'validate' => 'string',   'type' => 'text:20:50', 'explain' => true),
                  'email_package_size'   => array('lang' => 'EMAIL_PACKAGE_SIZE',   'validate' => 'int:0',   'type' => 'text:5:5', 'explain' => true),
                  'board_contact'         => array('lang' => 'CONTACT_EMAIL',         'validate' => 'string',   'type' => 'text:25:100', 'explain' => true),
                  'board_email'         => array('lang' => 'ADMIN_EMAIL',         'validate' => 'string',   'type' => 'text:25:100', 'explain' => true),
                  'board_email_sig'      => array('lang' => 'EMAIL_SIG',            'validate' => 'string',   'type' => 'textarea:5:30', 'explain' => true),
                  'board_hide_emails'      => array('lang' => 'BOARD_HIDE_EMAILS',      'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),

                  'legend2'            => 'SMTP_SETTINGS',
                  'smtp_delivery'         => array('lang' => 'USE_SMTP',            'validate' => 'bool',   'type' => 'radio:yes_no', 'explain' => true),
                  'smtp_host'            => array('lang' => 'SMTP_SERVER',         'validate' => 'string',   'type' => 'text:25:50', 'explain' => false),
                  'smtp_port'            => array('lang' => 'SMTP_PORT',            'validate' => 'int:0',   'type' => 'text:4:5', 'explain' => true),
                  'smtp_auth_method'      => array('lang' => 'SMTP_AUTH_METHOD',      'validate' => 'string',   'type' => 'select', 'method' => 'mail_auth_select', 'explain' => true),
                  'smtp_username'         => array('lang' => 'SMTP_USERNAME',         'validate' => 'string',   'type' => 'text:25:255', 'explain' => true),
                  'smtp_password'         => array('lang' => 'SMTP_PASSWORD',         'validate' => 'string',   'type' => 'password:25:255', 'explain' => true),

                  'legend3'               => 'ACP_SUBMIT_CHANGES',
               )
            );
         break;

         default:
            trigger_error('NO_MODE', E_USER_ERROR);
         break;
      }
//-- mod: Prime Login via E-Mail --------------------------------------------//
      include($phpbb_root_path . 'includes/prime_login_via_email.' . $phpEx);
      $prime_login_via_email->display_acp_options($display_vars);
//-- end: Prime Login via E-Mail --------------------------------------------//
      if (isset($display_vars['lang']))
      {
         $user->add_lang($display_vars['lang']);
      }

      $this->new_config = $config;
      $cfg_array = (isset($_REQUEST['config'])) ? utf8_normalize_nfc(request_var('config', array('' => ''), true)) : $this->new_config;
      $error = array();

      // We validate the complete config if whished
      validate_config_vars($display_vars['vars'], $cfg_array, $error);

      if ($submit && !check_form_key($form_key))
      {
         $error[] = $user->lang['FORM_INVALID'];
      }
      // Do not write values if there is an error
      if (sizeof($error))
      {
         $submit = false;
      }

      // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to...
      foreach ($display_vars['vars'] as $config_name => $null)
      {
         if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false)
         {
            continue;
         }

         if ($config_name == 'auth_method' || $config_name == 'feed_news_id' || $config_name == 'feed_exclude_id')
         {
            continue;
         }

         $this->new_config[$config_name] = $config_value = $cfg_array[$config_name];

         if ($config_name == 'email_function_name')
         {
            $this->new_config['email_function_name'] = trim(str_replace(array('(', ')'), array('', ''), $this->new_config['email_function_name']));
            $this->new_config['email_function_name'] = (empty($this->new_config['email_function_name']) || !function_exists($this->new_config['email_function_name'])) ? 'mail' : $this->new_config['email_function_name'];
            $config_value = $this->new_config['email_function_name'];
         }

         if ($submit)
         {
            set_config($config_name, $config_value);

            if ($config_name == 'allow_quick_reply' && isset($_POST['allow_quick_reply_enable']))
            {
               enable_bitfield_column_flag(FORUMS_TABLE, 'forum_flags', log(FORUM_FLAG_QUICK_REPLY, 2));
            }
         }
      }

      // Store news and exclude ids
      if ($mode == 'feed' && $submit)
      {
         $cache->destroy('_feed_news_forum_ids');
         $cache->destroy('_feed_excluded_forum_ids');

         $this->store_feed_forums(FORUM_OPTION_FEED_NEWS, 'feed_news_id');
         $this->store_feed_forums(FORUM_OPTION_FEED_EXCLUDE, 'feed_exclude_id');
      }

      if ($mode == 'auth')
      {
         // Retrieve a list of auth plugins and check their config values
         $auth_plugins = array();

         $dp = @opendir($phpbb_root_path . 'includes/auth');

         if ($dp)
         {
            while (($file = readdir($dp)) !== false)
            {
               if (preg_match('#^auth_(.*?)\.' . $phpEx . '$#', $file))
               {
                  $auth_plugins[] = basename(preg_replace('#^auth_(.*?)\.' . $phpEx . '$#', '\1', $file));
               }
            }
            closedir($dp);

            sort($auth_plugins);
         }

         $updated_auth_settings = false;
         $old_auth_config = array();
         foreach ($auth_plugins as $method)
         {
            if ($method && file_exists($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx))
            {
               include_once($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx);

               $method = 'acp_' . $method;
               if (function_exists($method))
               {
                  if ($fields = $method($this->new_config))
                  {
                     // Check if we need to create config fields for this plugin and save config when submit was pressed
                     foreach ($fields['config'] as $field)
                     {
                        if (!isset($config[$field]))
                        {
                           set_config($field, '');
                        }

                        if (!isset($cfg_array[$field]) || strpos($field, 'legend') !== false)
                        {
                           continue;
                        }

                        $old_auth_config[$field] = $this->new_config[$field];
                        $config_value = $cfg_array[$field];
                        $this->new_config[$field] = $config_value;

                        if ($submit)
                        {
                           $updated_auth_settings = true;
                           set_config($field, $config_value);
                        }
                     }
                  }
                  unset($fields);
               }
            }
         }

         if ($submit && (($cfg_array['auth_method'] != $this->new_config['auth_method']) || $updated_auth_settings))
         {
            $method = basename($cfg_array['auth_method']);
            if ($method && in_array($method, $auth_plugins))
            {
               include_once($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx);

               $method = 'init_' . $method;
               if (function_exists($method))
               {
                  if ($error = $method())
                  {
                     foreach ($old_auth_config as $config_name => $config_value)
                     {
                        set_config($config_name, $config_value);
                     }
                     trigger_error($error . adm_back_link($this->u_action), E_USER_WARNING);
                  }
               }
               set_config('auth_method', basename($cfg_array['auth_method']));
            }
            else
            {
               trigger_error('NO_AUTH_PLUGIN', E_USER_ERROR);
            }
         }
      }

      if ($submit)
      {
         add_log('admin', 'LOG_CONFIG_' . strtoupper($mode));

         trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
      }

      $this->tpl_name = 'acp_board';
      $this->page_title = $display_vars['title'];

      $template->assign_vars(array(
         'L_TITLE'         => $user->lang[$display_vars['title']],
         'L_TITLE_EXPLAIN'   => $user->lang[$display_vars['title'] . '_EXPLAIN'],

         'S_ERROR'         => (sizeof($error)) ? true : false,
         'ERROR_MSG'         => implode('<br />', $error),

         'U_ACTION'         => $this->u_action)
      );

      // Output relevant page
      foreach ($display_vars['vars'] as $config_key => $vars)
      {
         if (!is_array($vars) && strpos($config_key, 'legend') === false)
         {
            continue;
         }

         if (strpos($config_key, 'legend') !== false)
         {
            $template->assign_block_vars('options', array(
               'S_LEGEND'      => true,
               'LEGEND'      => (isset($user->lang[$vars])) ? $user->lang[$vars] : $vars)
            );

            continue;
         }

         $type = explode(':', $vars['type']);

         $l_explain = '';
         if ($vars['explain'] && isset($vars['lang_explain']))
         {
            $l_explain = (isset($user->lang[$vars['lang_explain']])) ? $user->lang[$vars['lang_explain']] : $vars['lang_explain'];
         }
         else if ($vars['explain'])
         {
            $l_explain = (isset($user->lang[$vars['lang'] . '_EXPLAIN'])) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : '';
         }

         $content = build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars);

         if (empty($content))
         {
            continue;
         }

         $template->assign_block_vars('options', array(
            'KEY'         => $config_key,
            'TITLE'         => (isset($user->lang[$vars['lang']])) ? $user->lang[$vars['lang']] : $vars['lang'],
            'S_EXPLAIN'      => $vars['explain'],
            'TITLE_EXPLAIN'   => $l_explain,
            'CONTENT'      => $content,
            )
         );

         unset($display_vars['vars'][$config_key]);
      }

      if ($mode == 'auth')
      {
         $template->assign_var('S_AUTH', true);

         foreach ($auth_plugins as $method)
         {
            if ($method && file_exists($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx))
            {
               $method = 'acp_' . $method;
               if (function_exists($method))
               {
                  $fields = $method($this->new_config);

                  if ($fields['tpl'])
                  {
                     $template->assign_block_vars('auth_tpl', array(
                        'TPL'   => $fields['tpl'])
                     );
                  }
                  unset($fields);
               }
            }
         }
      }
   }

   /**
   * Select auth method
   */
   function select_auth_method($selected_method, $key = '')
   {
      global $phpbb_root_path, $phpEx;

      $auth_plugins = array();

      $dp = @opendir($phpbb_root_path . 'includes/auth');

      if (!$dp)
      {
         return '';
      }

      while (($file = readdir($dp)) !== false)
      {
         if (preg_match('#^auth_(.*?)\.' . $phpEx . '$#', $file))
         {
            $auth_plugins[] = preg_replace('#^auth_(.*?)\.' . $phpEx . '$#', '\1', $file);
         }
      }
      closedir($dp);

      sort($auth_plugins);

      $auth_select = '';
      foreach ($auth_plugins as $method)
      {
         $selected = ($selected_method == $method) ? ' selected="selected"' : '';
         $auth_select .= '<option value="' . $method . '"' . $selected . '>' . ucfirst($method) . '</option>';
      }

      return $auth_select;
   }

   /**
   * Select mail authentication method
   */
   function mail_auth_select($selected_method, $key = '')
   {
      global $user;

      $auth_methods = array('PLAIN', 'LOGIN', 'CRAM-MD5', 'DIGEST-MD5', 'POP-BEFORE-SMTP');
      $s_smtp_auth_options = '';

      foreach ($auth_methods as $method)
      {
         $s_smtp_auth_options .= '<option value="' . $method . '"' . (($selected_method == $method) ? ' selected="selected"' : '') . '>' . $user->lang['SMTP_' . str_replace('-', '_', $method)] . '</option>';
      }

      return $s_smtp_auth_options;
   }

   /**
   * Select full folder action
   */
   function full_folder_select($value, $key = '')
   {
      global $user;

      return '<option value="1"' . (($value == 1) ? ' selected="selected"' : '') . '>' . $user->lang['DELETE_OLDEST_MESSAGES'] . '</option><option value="2"' . (($value == 2) ? ' selected="selected"' : '') . '>' . $user->lang['HOLD_NEW_MESSAGES_SHORT'] . '</option>';
   }

   /**
   * Select ip validation
   */
   function select_ip_check($value, $key = '')
   {
      $radio_ary = array(4 => 'ALL', 3 => 'CLASS_C', 2 => 'CLASS_B', 0 => 'NO_IP_VALIDATION');

      return h_radio('config[ip_check]', $radio_ary, $value, $key);
   }

   /**
   * Select referer validation
   */
   function select_ref_check($value, $key = '')
   {
      $radio_ary = array(REFERER_VALIDATE_PATH => 'REF_PATH', REFERER_VALIDATE_HOST => 'REF_HOST', REFERER_VALIDATE_NONE => 'NO_REF_VALIDATION');

      return h_radio('config[referer_validation]', $radio_ary, $value, $key);
   }

   /**
   * Select account activation method
   */
   function select_acc_activation($value, $key = '')
   {
      global $user, $config;

      $radio_ary = array(USER_ACTIVATION_DISABLE => 'ACC_DISABLE', USER_ACTIVATION_NONE => 'ACC_NONE');
      if ($config['email_enable'])
      {
         $radio_ary += array(USER_ACTIVATION_SELF => 'ACC_USER', USER_ACTIVATION_ADMIN => 'ACC_ADMIN');
      }

      return h_radio('config[require_activation]', $radio_ary, $value, $key);
   }

   /**
   * Maximum/Minimum username length
   */
   function username_length($value, $key = '')
   {
      global $user;

      return '<input id="' . $key . '" type="text" size="3" maxlength="3" name="config[min_name_chars]" value="' . $value . '" /> ' . $user->lang['MIN_CHARS'] . '&nbsp;&nbsp;<input type="text" size="3" maxlength="3" name="config[max_name_chars]" value="' . $this->new_config['max_name_chars'] . '" /> ' . $user->lang['MAX_CHARS'];
   }

   /**
   * Allowed chars in usernames
   */
   function select_username_chars($selected_value, $key)
   {
      global $user;

      $user_char_ary = array('USERNAME_CHARS_ANY', 'USERNAME_ALPHA_ONLY', 'USERNAME_ALPHA_SPACERS', 'USERNAME_LETTER_NUM', 'USERNAME_LETTER_NUM_SPACERS', 'USERNAME_ASCII');
      $user_char_options = '';
      foreach ($user_char_ary as $user_type)
      {
         $selected = ($selected_value == $user_type) ? ' selected="selected"' : '';
         $user_char_options .= '<option value="' . $user_type . '"' . $selected . '>' . $user->lang[$user_type] . '</option>';
      }

      return $user_char_options;
   }

   /**
   * Maximum/Minimum password length
   */
   function password_length($value, $key)
   {
      global $user;

      return '<input id="' . $key . '" type="text" size="3" maxlength="3" name="config[min_pass_chars]" value="' . $value . '" /> ' . $user->lang['MIN_CHARS'] . '&nbsp;&nbsp;<input type="text" size="3" maxlength="3" name="config[max_pass_chars]" value="' . $this->new_config['max_pass_chars'] . '" /> ' . $user->lang['MAX_CHARS'];
   }

   /**
   * Required chars in passwords
   */
   function select_password_chars($selected_value, $key)
   {
      global $user;

      $pass_type_ary = array('PASS_TYPE_ANY', 'PASS_TYPE_CASE', 'PASS_TYPE_ALPHA', 'PASS_TYPE_SYMBOL');
      $pass_char_options = '';
      foreach ($pass_type_ary as $pass_type)
      {
         $selected = ($selected_value == $pass_type) ? ' selected="selected"' : '';
         $pass_char_options .= '<option value="' . $pass_type . '"' . $selected . '>' . $user->lang[$pass_type] . '</option>';
      }

      return $pass_char_options;
   }
   /**
   * Select resized image link method
   */
   function select_reimg_link_method($selected_value, $key)
   {
      global $user;

      $link_method_ary = array('button' => 'REIMG_LINK_BUTTON', 'link' => 'REIMG_LINK_IMAGE', 'button_link' => 'REIMG_LINK_BOTH');
      $link_options = '';
      foreach ($link_method_ary as $link_mehod => $lang)
      {
         $selected = ($selected_value == $link_mehod) ? ' selected="selected"' : '';
         $link_options .= '<option value="' . $link_mehod . '"' . $selected . '>' . $user->lang[$lang] . '</option>';
      }

      return $link_options;
   }

   /**
   * Select resized image zoom method
   */
   function select_reimg_zoom_method($selected_value, $key)
   {
      global $user, $phpbb_root_path;

      $zoom_method_ary = array('' => 'DISABLED', '_default' => 'REIMG_ZOOM_DEFAULT', '_exturl' => 'REIMG_ZOOM_EXTURL', '_blank' => 'REIMG_ZOOM_BLANK', '_litebox' => 'REIMG_ZOOM_LITEBOX', '_litebox1' => 'REIMG_ZOOM_LITEBOX_1_1', '_litebox0' => 'REIMG_ZOOM_LITEBOX_RESIZED', '_highslide' => 'REIMG_ZOOM_HIGHSLIDE');
      $zoom_options = '';
      foreach ($zoom_method_ary as $zoom_method => $lang)
      {
         $disabled = '';
         //We need to check and see if the Highslide library actually exists before allowing the option to be selectable
         if ($zoom_method == '_highslide')
         {
            //We need one of the highslide js libraries
            if (!file_exists($phpbb_root_path . 'highslide/highslide-full.packed.js'))
            {
               $disabled = ' disabled';
            }
         }
         $selected = ($selected_value == $zoom_method) ? ' selected="selected"' : '';
         $zoom_options .= '<option value="' . $zoom_method . '"' . $selected . $disabled . '>' . $user->lang[$lang] . '</option>';
      }

      return $zoom_options;
   }
   
   /**
   * Select bump interval
   */
   function bump_interval($value, $key)
   {
      global $user;

      $s_bump_type = '';
      $types = array('m' => 'MINUTES', 'h' => 'HOURS', 'd' => 'DAYS');
      foreach ($types as $type => $lang)
      {
         $selected = ($this->new_config['bump_type'] == $type) ? ' selected="selected"' : '';
         $s_bump_type .= '<option value="' . $type . '"' . $selected . '>' . $user->lang[$lang] . '</option>';
      }

      return '<input id="' . $key . '" type="text" size="3" maxlength="4" name="config[bump_interval]" value="' . $value . '" />&nbsp;<select name="config[bump_type]">' . $s_bump_type . '</select>';
   }

   /**
   * Board disable option and message
   */
   function board_disable($value, $key)
   {
      global $user;

      $radio_ary = array(1 => 'YES', 0 => 'NO');

      return h_radio('config[board_disable]', $radio_ary, $value) . '<br /><input id="' . $key . '" type="text" name="config[board_disable_msg]" maxlength="255" size="40" value="' . $this->new_config['board_disable_msg'] . '" />';
   }

   /**
   * Global quick reply enable/disable setting and button to enable in all forums
   */
   function quick_reply($value, $key)
   {
      global $user;

      $radio_ary = array(1 => 'YES', 0 => 'NO');

      return h_radio('config[allow_quick_reply]', $radio_ary, $value) .
         '<br /><br /><input class="button2" type="submit" id="' . $key . '_enable" name="' . $key . '_enable" value="' . $user->lang['ALLOW_QUICK_REPLY_BUTTON'] . '" />';
   }


   /**
   * Select default dateformat
   */
   function dateformat_select($value, $key)
   {
      global $user, $config;

      // Let the format_date function operate with the acp values
      $old_tz = $user->timezone;
      $old_dst = $user->dst;

      $user->timezone = $config['board_timezone'];
      $user->dst = $config['board_dst'];

      $dateformat_options = '';

      foreach ($user->lang['dateformats'] as $format => $null)
      {
         $dateformat_options .= '<option value="' . $format . '"' . (($format == $value) ? ' 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>';
      }

      $dateformat_options .= '<option value="custom"';
      if (!isset($user->lang['dateformats'][$value]))
      {
         $dateformat_options .= ' selected="selected"';
      }
      $dateformat_options .= '>' . $user->lang['CUSTOM_DATEFORMAT'] . '</option>';

      // Reset users date options
      $user->timezone = $old_tz;
      $user->dst = $old_dst;

      return "<select name=\"dateoptions\" id=\"dateoptions\" onchange=\"if (this.value == 'custom') { document.getElementById('" . addslashes($key) . "').value = '" . addslashes($value) . "'; } else { document.getElementById('" . addslashes($key) . "').value = this.value; }\">$dateformat_options</select>
      <input type=\"text\" name=\"config[$key]\" id=\"$key\" value=\"$value\" maxlength=\"30\" />";
   }

   /**
   * Select multiple forums
   */
   function select_news_forums($value, $key)
   {
      global $user, $config;

      $forum_list = make_forum_select(false, false, true, true, true, false, true);

      // Build forum options
      $s_forum_options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">';
      foreach ($forum_list as $f_id => $f_row)
      {
         $f_row['selected'] = phpbb_optionget(FORUM_OPTION_FEED_NEWS, $f_row['forum_options']);

         $s_forum_options .= '<option value="' . $f_id . '"' . (($f_row['selected']) ? ' selected="selected"' : '') . (($f_row['disabled']) ? ' disabled="disabled" class="disabled-option"' : '') . '>' . $f_row['padding'] . $f_row['forum_name'] . '</option>';
      }
      $s_forum_options .= '</select>';

      return $s_forum_options;
   }

   function select_exclude_forums($value, $key)
   {
      global $user, $config;

      $forum_list = make_forum_select(false, false, true, true, true, false, true);

      // Build forum options
      $s_forum_options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">';
      foreach ($forum_list as $f_id => $f_row)
      {
         $f_row['selected'] = phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $f_row['forum_options']);

         $s_forum_options .= '<option value="' . $f_id . '"' . (($f_row['selected']) ? ' selected="selected"' : '') . (($f_row['disabled']) ? ' disabled="disabled" class="disabled-option"' : '') . '>' . $f_row['padding'] . $f_row['forum_name'] . '</option>';
      }
      $s_forum_options .= '</select>';

      return $s_forum_options;
   }

   function store_feed_forums($option, $key)
   {
      global $db, $cache;

      // Get key
      $values = request_var($key, array(0 => 0));

      // Empty option bit for all forums
      $sql = 'UPDATE ' . FORUMS_TABLE . '
         SET forum_options = forum_options - ' . (1 << $option) . '
         WHERE ' . $db->sql_bit_and('forum_options', $option, '<> 0');
      $db->sql_query($sql);

      // Already emptied for all...
      if (sizeof($values))
      {
         // Set for selected forums
         $sql = 'UPDATE ' . FORUMS_TABLE . '
            SET forum_options = forum_options + ' . (1 << $option) . '
            WHERE ' . $db->sql_in_set('forum_id', $values);
         $db->sql_query($sql);
      }

      // Empty sql cache for forums table because options changed
      $cache->destroy('sql', FORUMS_TABLE);
   }

}

?>
by Anonymous
Wed May 26, 2010 10:35 am

Re: Abandoned?

No,

It should parse custom BBcode but only in Custom profile fields :)

Can you try that out once?

For example, http://cohortguild.com/joomla/distribut ... p?f=2&t=32

Here you can see that the "Armory" custom field is parsed using a custom BBCode that I created.

Right?
by trefex
Fri Jun 18, 2010 4:28 pm

Installing this MOD with already MOD'd files

Firstly, this looks like a great MOD and I'm looking forward to rolling it out, but I am having a problem making the code changes because I already have a couple of MOD's installed.

Can you please tell me how to apply this MOD to my existing install.

My "quickreply_editor.html" file is OK and I have been able to make the code changes successfully.

My "viewtopic_body.html" file is already MOD'd and I cant work out how to make the two code changes to this. Here is my current code:-

Code: Select all

<!-- INCLUDE overall_header.html -->
<!-- INCLUDE quickedit.html -->

<!-- IF PRIME_MULTI_QUOTE -->

   <script type="text/javascript" src="{T_TEMPLATE_PATH}/prime_multi_quote.js"></script>

<!-- ENDIF -->

<!-- IF U_MCP --><p>[&nbsp;<a href="{U_MCP}">{L_MCP}</a> <!-- IF TOTAL_MODERATOR_REPORTS --> &bull; <a href="{U_MODERATOR_REPORTS}">{TOTAL_MODERATOR_REPORTS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_POSTS --> &bull; <a href="{U_MODERATOR_APPROVE_POSTS}">{TOTAL_MODERATOR_POSTS}</a><!-- ENDIF --><!-- IF TOTAL_MODERATOR_TOPICS --> &bull; <a href="{U_MODERATOR_APPROVE_TOPICS}">{TOTAL_MODERATOR_TOPICS}</a><!-- ENDIF -->&nbsp;]</p><!-- ENDIF -->

<h2><a href="{U_VIEW_TOPIC}">{TOPIC_TITLE}</a></h2>

<!-- NOTE: remove the style="display: none" when you want to have the forum description on the topic body -->

<!-- IF FORUM_DESC --><div style="display: none !important;">{FORUM_DESC}<br /></div><!-- ENDIF -->



<!-- IF MODERATORS or U_MCP -->

   <p>

      <!-- IF MODERATORS -->

         <strong><!-- IF S_SINGLE_MODERATOR -->{L_MODERATOR}<!-- ELSE -->{L_MODERATORS}<!-- ENDIF -->:</strong> {MODERATORS}

      <!-- ENDIF -->



   </p>

<!-- ENDIF -->



<!-- IF S_FORUM_RULES -->

   <div class="rules">

      <div class="inner"><span class="corners-top"><span></span></span>



      <!-- IF U_FORUM_RULES -->

         <a href="{U_FORUM_RULES}">{L_FORUM_RULES}</a>

      <!-- ELSE -->

         <strong>{L_FORUM_RULES}</strong><br />

         {FORUM_RULES}

      <!-- ENDIF -->



      <span class="corners-bottom"><span></span></span></div>

   </div>

<!-- ENDIF -->



<div class="topic-actions">



   <div class="buttons">

   <!-- IF not S_IS_BOT and S_DISPLAY_REPLY_INFO -->

      <div class="<!-- IF S_IS_LOCKED -->locked-icon<!-- ELSE -->reply-icon<!-- ENDIF -->"><a href="{U_POST_REPLY_TOPIC}" title="<!-- IF S_IS_LOCKED -->{L_TOPIC_LOCKED}<!-- ELSE -->{L_POST_REPLY}<!-- ENDIF -->"<!-- IF PRIME_MULTI_QUOTE --> onclick="prime_multi_quote(this);"<!-- ENDIF -->><span></span><!-- IF S_IS_LOCKED -->{L_TOPIC_LOCKED_SHORT}<!-- ELSE -->{L_POST_REPLY}<!-- ENDIF --></a></div>

   <!-- ENDIF -->

   </div>



   <!-- IF S_DISPLAY_SEARCHBOX -->

      <div class="search-box">

         <form method="post" id="topic-search" action="{S_SEARCHBOX_ACTION}">

         <fieldset>

            <input class="inputbox search tiny"  type="text" name="keywords" id="search_keywords" size="20" value="{L_SEARCH_TOPIC}" onclick="if(this.value=='{LA_SEARCH_TOPIC}')this.value='';" onblur="if(this.value=='')this.value='{LA_SEARCH_TOPIC}';" />

            <input class="button2" type="submit" value="{L_SEARCH}" />

            <input type="hidden" value="{TOPIC_ID}" name="t" />

            <input type="hidden" value="msgonly" name="sf" />

         </fieldset>

         </form>

      </div>

   <!-- ENDIF -->



   <!-- IF PAGINATION or TOTAL_POSTS -->

      <div class="pagination">

         <!-- IF U_VIEW_UNREAD_POST and not S_IS_BOT --><a href="{U_VIEW_UNREAD_POST}">{L_VIEW_UNREAD_POST}</a> &bull; <!-- ENDIF -->{TOTAL_POSTS}

         <!-- IF PAGE_NUMBER --><!-- IF PAGINATION --> &bull; <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull; <span>{PAGINATION}</span><!-- ELSE --> &bull; {PAGE_NUMBER}<!-- ENDIF --><!-- ENDIF -->

      </div>

   <!-- ENDIF -->



</div>

<div class="clear"></div>



<!-- IF S_TOPIC_DELETED -->

   <div id="p0" class="post bg2 deleted_topic">

      <div class="inner"><span class="corners-top"><span></span></span>

      <div class="postbody">

         <h3 class="first">{L_PRIME_TOPIC_DELETED_MSG}</h3>

         <div class="ignore">

            {DELETED_MSG}

         </div>

      </div>

      <div class="back2top"><a href="#wrap" class="top" title="{L_BACK_TO_TOP}">{L_BACK_TO_TOP}</a></div>

      <span class="corners-bottom"><span></span></span></div>

   </div>

<!-- ENDIF -->



<!-- IF S_HAS_POLL -->

   <form method="post" action="{S_POLL_ACTION}">



   <div class="panel">

      <div class="inner"><span class="corners-top"><span></span></span>



      <div class="content">

         <h2>{POLL_QUESTION}</h2>

         <p class="author">{L_POLL_LENGTH}<!-- IF S_CAN_VOTE and L_POLL_LENGTH --><br /><!-- ENDIF --><!-- IF S_CAN_VOTE -->{L_MAX_VOTES}<!-- ENDIF --></p>



         <fieldset class="polls">

         <!-- BEGIN poll_option -->

            <dl class="<!-- IF poll_option.POLL_OPTION_VOTED -->voted<!-- ENDIF -->"<!-- IF poll_option.POLL_OPTION_VOTED --> title="{L_POLL_VOTED_OPTION}"<!-- ENDIF -->>

               <dt><!-- IF S_CAN_VOTE --><label for="vote_{poll_option.POLL_OPTION_ID}">{poll_option.POLL_OPTION_CAPTION}</label><!-- ELSE -->{poll_option.POLL_OPTION_CAPTION}<!-- ENDIF --></dt>

               <!-- IF S_CAN_VOTE --><dd style="width: auto;"><!-- IF S_IS_MULTI_CHOICE --><input type="checkbox" name="vote_id[]" id="vote_{poll_option.POLL_OPTION_ID}" value="{poll_option.POLL_OPTION_ID}"<!-- IF poll_option.POLL_OPTION_VOTED --> checked="checked"<!-- ENDIF --> /><!-- ELSE --><input type="radio" name="vote_id[]" id="vote_{poll_option.POLL_OPTION_ID}" value="{poll_option.POLL_OPTION_ID}"<!-- IF poll_option.POLL_OPTION_VOTED --> checked="checked"<!-- ENDIF --> /><!-- ENDIF --></dd><!-- ENDIF -->

               <!-- IF S_DISPLAY_RESULTS --><dd class="resultbar"><div class="<!-- IF poll_option.POLL_OPTION_PCT < 20 -->pollbar1<!-- ELSEIF poll_option.POLL_OPTION_PCT < 40 -->pollbar2<!-- ELSEIF poll_option.POLL_OPTION_PCT < 60 -->pollbar3<!-- ELSEIF poll_option.POLL_OPTION_PCT < 80 -->pollbar4<!-- ELSE -->pollbar5<!-- ENDIF -->" style="width:{poll_option.POLL_OPTION_PERCENT};">{poll_option.POLL_OPTION_RESULT}</div></dd>

               <dd><!-- IF poll_option.POLL_OPTION_RESULT == 0 -->{L_NO_VOTES}<!-- ELSE -->{poll_option.POLL_OPTION_PERCENT}<!-- ENDIF --></dd><!-- ENDIF -->

            </dl>

         <!-- END poll_option -->



         <!-- IF S_DISPLAY_RESULTS -->

            <dl>

               <dt>&nbsp;</dt>

               <dd class="resultbar">{L_TOTAL_VOTES} : {TOTAL_VOTES}</dd>

            </dl>

         <!-- ENDIF -->



         <!-- IF S_CAN_VOTE -->

            <dl style="border-top: none;">

               <dt>&nbsp;</dt>

               <dd class="resultbar"><input type="submit" name="update" value="{L_SUBMIT_VOTE}" class="button1" /></dd>

            </dl>

         <!-- ENDIF -->



         <!-- IF not S_DISPLAY_RESULTS -->

            <dl style="border-top: none;">

               <dt>&nbsp;</dt>

               <dd class="resultbar"><a href="{U_VIEW_RESULTS}">{L_VIEW_RESULTS}</a></dd>

            </dl>

         <!-- ENDIF -->

         </fieldset>

      </div>



      <span class="corners-bottom"><span></span></span></div>

      {S_FORM_TOKEN}

      {S_HIDDEN_FIELDS}

   </div>





   </form>

   <hr />

<!-- ENDIF -->

<!-- IF PRIME_MULTI_QUOTE --><form action="{U_POST_REPLY_TOPIC}" method="get" name="prime_multi_quote_form" id="prime_multi_quote_form"><!-- ENDIF -->

<!-- BEGIN postrow -->

   <!-- IF postrow.S_FIRST_UNREAD --><a id="unread"></a><!-- ENDIF -->

   <div id="p{postrow.POST_ID}" class="post <!-- IF postrow.S_ROW_COUNT is odd -->bg1<!-- ELSE -->bg2<!-- ENDIF --><!-- IF postrow.S_UNREAD_POST --> unreadpost<!-- ENDIF --><!-- IF postrow.S_POST_REPORTED --> reported<!-- ENDIF --><!-- IF postrow.S_ONLINE and not postrow.S_IGNORE_POST --> online<!-- ENDIF --><!-- IF postrow.S_DELETED --> deleted_post<!-- ENDIF -->">

      <div class="inner"><span class="corners-top"><span></span></span>



      <div class="postbody">

         <!-- IF postrow.S_IGNORE_POST -->

            <div class="ignore">{postrow.L_IGNORE_POST}</div>

         <!-- ELSE -->



      <!-- IF not S_IS_BOT -->

         <!-- IF postrow.U_EDIT or postrow.U_DELETE or postrow.U_REPORT or postrow.U_WARN or postrow.U_INFO or postrow.U_QUOTE -->

            <ul class="profile-icons">
          <!-- IF postrow.U_EDIT --><li class="quick-edit-icon"><a href="#" id="quick_edit{postrow.POST_ID}" onclick="quick_edit({postrow.POST_ID}); return false;" title="{L_QUICKEDIT_POST}"><span>{L_QUICKEDIT_POST}</span></a></li><!-- ENDIF -->
               <!-- IF postrow.U_EDIT --><li class="edit-icon"><a href="{postrow.U_EDIT}" title="{L_EDIT_POST}"><span>{L_EDIT_POST}</span></a></li><!-- ENDIF -->

               <!-- IF postrow.U_DELETE --><li class="delete-icon"><a href="{postrow.U_DELETE}" title="{L_DELETE_POST}"><span>{L_DELETE_POST}</span></a></li><!-- ENDIF -->

               <!-- IF postrow.U_REPORT --><li class="report-icon"><a href="{postrow.U_REPORT}" title="{L_REPORT_POST}"><span>{L_REPORT_POST}</span></a></li><!-- ENDIF -->

               <!-- IF postrow.U_WARN --><li class="warn-icon"><a href="{postrow.U_WARN}" title="{L_WARN_USER}"><span>{L_WARN_USER}</span></a></li><!-- ENDIF -->

               <!-- IF postrow.U_INFO --><li class="info-icon"><a href="{postrow.U_INFO}" title="{L_INFORMATION}"><span>{L_INFORMATION}</span></a></li><!-- ENDIF -->

               <!-- IF postrow.U_QUOTE --><li class="quote-icon"><a href="{postrow.U_QUOTE}" title="{L_REPLY_WITH_QUOTE}"<!-- IF PRIME_MULTI_QUOTE --> onclick="prime_multi_quote(this);"<!-- ENDIF -->><span>{L_REPLY_WITH_QUOTE}</span></a></li><!-- ENDIF -->

                              <!-- IF PRIME_MULTI_QUOTE --><li><input type="checkbox" name="quotes" value="{postrow.POST_ID}" class="radio" style="width:14px;margin-bottom:-3px;" title="{L_REPLY_WITH_QUOTE}" /></li><!-- ENDIF -->

                              <!-- IF  not postrow.S_FIRST_POST_ONLY or (not START and postrow.S_ROW_COUNT == 0) -->

                  <!-- IF  postrow.S_FORUM_THANKS and S_USER_LOGGED_IN and not postrow.S_IS_OWN_POST and (not postrow.S_ALREADY_THANKED or postrow.S_REMOVE_THANKS) --><li class="{postrow.THANKS_IMG}"><a href="{postrow.THANKS_LINK}" title="{postrow.THANK_ALT}{postrow.POST_AUTHOR}"></a></li><!-- ENDIF -->               

               <!-- ENDIF -->

            </ul>

         <!-- ENDIF -->

      <!-- ENDIF -->



         <h3 <!-- IF postrow.S_FIRST_ROW -->class="first"<!-- ENDIF -->><!-- IF postrow.POST_ICON_IMG --><img src="{T_ICONS_PATH}{postrow.POST_ICON_IMG}" width="{postrow.POST_ICON_IMG_WIDTH}" height="{postrow.POST_ICON_IMG_HEIGHT}" alt="" /> <!-- ENDIF --><a href="#p{postrow.POST_ID}">{postrow.POST_SUBJECT}</a></h3>

         <p class="author"><!-- IF S_IS_BOT -->{postrow.MINI_POST_IMG}<!-- ELSE --><a href="{postrow.U_MINI_POST}">{postrow.MINI_POST_IMG}</a><!-- ENDIF -->{L_POST_BY_AUTHOR} <strong>{postrow.POST_AUTHOR_FULL}</strong> &raquo; {postrow.POST_DATE}     &nbsp;{L_POST_NUM}&nbsp;<a href="{postrow.U_MINI_POST}" onclick="prompt('{L_POST_DIRECT_LINK}',this.href); return false;"><strong>{L_POST_NUM_SYMBOL}{postrow.S_POST_NUM}</strong></a></p>



         <!-- IF postrow.S_POST_UNAPPROVED or postrow.S_POST_REPORTED -->

            <p class="rules">

               <!-- IF postrow.S_POST_UNAPPROVED -->{UNAPPROVED_IMG} <a href="{postrow.U_MCP_APPROVE}"><strong>{L_POST_UNAPPROVED}</strong></a><br /><!-- ENDIF -->

               <!-- IF postrow.S_POST_REPORTED -->{REPORTED_IMG} <a href="{postrow.U_MCP_REPORT}"><strong>{L_POST_REPORTED}</strong></a><!-- ENDIF -->

            </p>

         <!-- ENDIF -->



         <div class="content" id="postdiv{postrow.POST_ID}">{postrow.MESSAGE}</div>



         <!-- IF postrow.S_HAS_ATTACHMENTS -->

            <dl class="attachbox" style="width: 97%;">

               <dt>{L_ATTACHMENTS}</dt>

               <!-- BEGIN attachment -->

                  <dd>{postrow.attachment.DISPLAY_ATTACHMENT}</dd>

               <!-- END attachment -->

            </dl>

         <!-- ENDIF -->



         <!-- IF postrow.S_DISPLAY_NOTICE --><div class="rules">{L_DOWNLOAD_NOTICE}</div><!-- ENDIF -->

         <!-- IF postrow.EDITED_MESSAGE or postrow.EDIT_REASON -->

            <div class="notice">{postrow.EDITED_MESSAGE}

               <!-- IF postrow.EDIT_REASON --><br /><strong>{L_REASON}:</strong> <em>{postrow.EDIT_REASON}</em><!-- ENDIF -->

            </div>

         <!-- ENDIF -->



         <!-- IF postrow.BUMPED_MESSAGE --><div class="notice"><br /><br />{postrow.BUMPED_MESSAGE}</div><!-- ENDIF -->

         <!-- IF postrow.SIGNATURE --><div id="sig{postrow.POST_ID}" class="signature">{postrow.SIGNATURE}</div><!-- ENDIF -->

      <!-- ENDIF -->

            <!-- IF postrow.THANKS and postrow.THANKS_POSTLIST_VIEW -->

         <hr />

         <div class="content">

            <dl class="postbody">

               <dt>

                  <!-- IF not postrow.S_POST_ANONYMOUS and not S_IS_BOT-->

                  {postrow.THANK_TEXT}{postrow.POST_AUTHOR_FULL}{postrow.THANK_TEXT_2}: <dd>{postrow.THANKS}</dd>

                  <!-- ENDIF -->   

               </dt>

            </dl>

         </div>

      <!-- ENDIF -->



      </div>



      <!-- IF not postrow.S_IGNORE_POST -->

         <dl class="postprofile" id="profile{postrow.POST_ID}">

         <dt>

            <!-- IF postrow.POSTER_AVATAR -->

               <!-- IF postrow.U_POST_AUTHOR --><a href="{postrow.U_POST_AUTHOR}">{postrow.POSTER_AVATAR}</a><!-- ELSE -->{postrow.POSTER_AVATAR}<!-- ENDIF --><br />

            <!-- ENDIF -->

            <!-- IF not postrow.U_POST_AUTHOR --><strong>{postrow.POST_AUTHOR_FULL}</strong><!-- ELSE -->{postrow.POST_AUTHOR_FULL}<!-- ENDIF -->

                     <!-- IF STATUS_ENABLE_VIEWTOPIC and ENABLE_STATUS -->

         <!-- BEGIN stat -->

         <p>{postrow.stat.STATUS}</p>

         <!-- END stat -->

         <!-- ENDIF -->

         </dt>



         <!-- IF postrow.RANK_TITLE or postrow.RANK_IMG --><dd>{postrow.RANK_TITLE}<!-- IF postrow.RANK_TITLE and postrow.RANK_IMG --><br /><!-- ENDIF -->{postrow.RANK_IMG}</dd><!-- ENDIF -->



         <!-- IF postrow.EXTRA_RANK_TITLE or postrow.EXTRA_RANK_IMG --><dd>{postrow.EXTRA_RANK_TITLE}<!-- IF postrow.EXTRA_RANK_TITLE and postrow.EXTRA_RANK_IMG --><br /><!-- ENDIF -->{postrow.EXTRA_RANK_IMG}</dd><!-- ENDIF -->

            



<!-- IF postrow.RANK2_TITLE or postrow.RANK2_IMG --><dd>{postrow.RANK2_TITLE}<!-- IF postrow.RANK2_TITLE and postrow.RANK2_IMG --><br /><!-- ENDIF -->{postrow.RANK2_IMG}</dd><!-- ENDIF -->

<!-- IF postrow.RANK3_TITLE or postrow.RANK3_IMG --><dd>{postrow.RANK3_TITLE}<!-- IF postrow.RANK3_TITLE and postrow.RANK3_IMG --><br /><!-- ENDIF -->{postrow.RANK3_IMG}</dd><!-- ENDIF -->



      <dd>&nbsp;</dd>



      <!-- IF postrow.POSTER_POSTS != '' --><dd><strong>{L_POSTS}:</strong> {postrow.POSTER_POSTS}</dd><!-- ENDIF -->
    <!-- IF postrow.GALLERY_IMAGES != '' --><dd><strong>{L_IMAGES}:</strong> <!-- IF postrow.U_GALLERY_SEARCH --><a href="{postrow.U_GALLERY_SEARCH}">{postrow.GALLERY_IMAGES}</a><!-- ELSE -->{postrow.GALLERY_IMAGES}<!-- ENDIF --></dd><!-- ENDIF -->
      <!-- IF postrow.POSTER_JOINED --><dd><strong>{L_JOINED}:</strong> {postrow.POSTER_JOINED}</dd><!-- ENDIF -->

      <!-- IF postrow.POSTER_FROM --><dd><strong>{L_LOCATION}:</strong> {postrow.POSTER_FROM}</dd><!-- ENDIF -->

                      <!-- IF postrow.S_USERID_BANNED --><dd><strong><span style="color:#FF0000">{L_CURRENTLY_BANNED}</span></strong></dd><!-- ELSEIF postrow.POSTER_WARNINGS --><dd><strong>{L_WARNINGS}:</strong> <span style="color:#FF0000">{postrow.POSTER_WARNINGS}</span></dd><!-- ENDIF -->

            <!-- IF not postrow.S_POST_ANONYMOUS and postrow.THANKS_COUNTERS_VIEW -->

         <dd><strong>{L_GIVEN}:</strong> {postrow.POSTER_GIVE_COUNT} {L_THANKS}</dd>

         <dd><strong>{L_RECEIVED}:</strong> {postrow.POSTER_RECEIVE_COUNT} {L_THANKS}</dd>

      <!-- ENDIF -->



      <!-- IF postrow.S_PROFILE_FIELD1 -->

         <!-- Use a construct like this to include admin defined profile fields. Replace FIELD1 with the name of your field. -->

         <dd><strong>{postrow.PROFILE_FIELD1_NAME}:</strong> {postrow.PROFILE_FIELD1_VALUE}</dd>

      <!-- ENDIF -->



      <!-- BEGIN custom_fields -->

         <dd><strong>{postrow.custom_fields.PROFILE_FIELD_NAME}:</strong> {postrow.custom_fields.PROFILE_FIELD_VALUE}</dd>

      <!-- END custom_fields -->



      <!-- IF not S_IS_BOT -->

      <!-- IF postrow.U_PM or postrow.U_EMAIL or postrow.U_WWW or postrow.U_MSN or postrow.U_ICQ or postrow.U_YIM or postrow.U_AIM or postrow.U_JABBER or postrow.U_FACEBOOK -->

         <dd>

            <ul class="profile-icons">

               <!-- IF postrow.U_PM --><li class="pm-icon"><a href="{postrow.U_PM}" title="{L_PRIVATE_MESSAGE}"><span>{L_PRIVATE_MESSAGE}</span></a></li><!-- ENDIF -->

               <!-- IF postrow.U_EMAIL --><li class="email-icon"><a href="{postrow.U_EMAIL}" title="{L_SEND_EMAIL_USER} {postrow.POST_AUTHOR}"><span>{L_SEND_EMAIL_USER} {postrow.POST_AUTHOR}</span></a></li><!-- ENDIF -->

               <!-- IF postrow.U_WWW --><li class="web-icon"><a href="{postrow.U_WWW}" title="{L_VISIT_WEBSITE}: {postrow.U_WWW}"><span>{L_WEBSITE}</span></a></li><!-- ENDIF -->

               <!-- IF postrow.U_MSN --><li class="msnm-icon"><a href="{postrow.U_MSN}" onclick="popup(this.href, 550, 320); return false;" title="{L_MSNM}"><span>{L_MSNM}</span></a></li><!-- ENDIF -->

               <!-- IF postrow.U_ICQ --><li class="icq-icon"><a href="{postrow.U_ICQ}" onclick="popup(this.href, 550, 320); return false;" title="{L_ICQ}"><span>{L_ICQ}</span></a></li><!-- ENDIF -->

               <!-- IF postrow.U_YIM --><li class="yahoo-icon"><a href="{postrow.U_YIM}" onclick="popup(this.href, 780, 550); return false;" title="{L_YIM}"><span>{L_YIM}</span></a></li><!-- ENDIF -->

               <!-- IF postrow.U_AIM --><li class="aim-icon"><a href="{postrow.U_AIM}" onclick="popup(this.href, 550, 320); return false;" title="{L_AIM}"><span>{L_AIM}</span></a></li><!-- ENDIF -->

               <!-- IF postrow.U_JABBER --><li class="jabber-icon"><a href="{postrow.U_JABBER}" onclick="popup(this.href, 550, 320); return false;" title="{L_JABBER}"><span>{L_JABBER}</span></a></li><!-- ENDIF -->
               <!-- IF postrow.U_FACEBOOK --><li class="facebook-icon"><a href="{postrow.U_FACEBOOK}" title="{L_FACEBOOK}"><span>{L_FACEBOOK}</span></a></li><!-- ENDIF -->               

          <!-- IF postrow.U_GALLERY --><li class="gallery-icon"><a href="{postrow.U_GALLERY}" title="{L_PERSONAL_ALBUM}"><span>{L_PERSONAL_ALBUM}</span></a></li><!-- ENDIF -->

            </ul>

         </dd>

      <!-- ENDIF -->

      <!-- ENDIF -->



      </dl>

   <!-- ENDIF -->



      <div class="back2top"><a href="#wrap" class="top" title="{L_BACK_TO_TOP}">{L_BACK_TO_TOP}</a></div>



      <span class="corners-bottom"><span></span></span></div>

   </div>



   <hr class="divider" />

<!-- END postrow -->

<!-- IF PRIME_MULTI_QUOTE --></form><!-- ENDIF -->



<!-- IF S_QUICK_REPLY -->

   <!-- INCLUDE quickreply_editor.html -->

<!-- ENDIF -->

<!-- IF S_NUM_POSTS > 1 or PREVIOUS_PAGE -->

   <form id="viewtopic" method="post" action="{S_TOPIC_ACTION}">



   <fieldset class="display-options" style="margin-top: 0; ">

      <!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}" class="left-box {S_CONTENT_FLOW_BEGIN}">{L_PREVIOUS}</a><!-- ENDIF -->

      <!-- IF NEXT_PAGE --><a href="{NEXT_PAGE}" class="right-box {S_CONTENT_FLOW_END}">{L_NEXT}</a><!-- ENDIF -->

      <!-- IF not S_IS_BOT -->

      <label>{L_DISPLAY_POSTS}: {S_SELECT_SORT_DAYS}</label>

      <label>{L_SORT_BY} {S_SELECT_SORT_KEY}</label> <label>{S_SELECT_SORT_DIR} <input type="submit" name="sort" value="{L_GO}" class="button2" /></label>

      <!-- ENDIF -->

   </fieldset>



   </form>

   <hr />

<!-- ENDIF -->



<div class="topic-actions">

   <div class="buttons">

   <!-- IF not S_IS_BOT and S_DISPLAY_REPLY_INFO -->

      <div class="<!-- IF S_IS_LOCKED -->locked-icon<!-- ELSE -->reply-icon<!-- ENDIF -->"><a href="{U_POST_REPLY_TOPIC}" title="<!-- IF S_IS_LOCKED -->{L_TOPIC_LOCKED}<!-- ELSE -->{L_POST_REPLY}<!-- ENDIF -->"<!-- IF PRIME_MULTI_QUOTE --> onclick="prime_multi_quote(this);"<!-- ENDIF -->><span></span><!-- IF S_IS_LOCKED -->{L_TOPIC_LOCKED_SHORT}<!-- ELSE -->{L_POST_REPLY}<!-- ENDIF --></a></div>

   <!-- ENDIF -->

   </div>



   <!-- IF PAGINATION or TOTAL_POSTS -->

      <div class="pagination">

         {TOTAL_POSTS}

         <!-- IF PAGE_NUMBER --><!-- IF PAGINATION --> &bull; <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull; <span>{PAGINATION}</span><!-- ELSE --> &bull; {PAGE_NUMBER}<!-- ENDIF --><!-- ENDIF -->

      </div>

   <!-- ENDIF -->

</div>



<!-- IF not S_IS_LOCKED and S_QR_ENABLED -->

   <!-- INCLUDE posting_qr_body.html -->

<!-- ENDIF -->



<!-- INCLUDE jumpbox.html -->



<!-- IF S_TOPIC_MOD -->

   <form method="post" action="{S_MOD_ACTION}">

   <fieldset class="quickmod">

      <label for="quick-mod-select">{L_QUICK_MOD}:</label> {S_TOPIC_MOD} <input type="submit" value="{L_GO}" class="button2" />

      {S_FORM_TOKEN}

   </fieldset>

   </form>

<!-- ENDIF -->



<!-- IF S_DISPLAY_ONLINE_LIST -->

   <h3><!-- IF U_VIEWONLINE --><a href="{U_VIEWONLINE}">{L_WHO_IS_ONLINE}</a><!-- ELSE -->{L_WHO_IS_ONLINE}<!-- ENDIF --></h3>

   <p>{LOGGED_IN_USER_LIST}</p>

<!-- ENDIF -->



<!-- INCLUDE overall_footer.html -->


I was able to make all but one of the changes to the "viewtopic.php" file. The only change I couldn't do it this one.
FIND AND DELETE

Code: Select all

// let's set up quick_reply
$s_quick_reply = false;
if ($user->data['is_registered'] && $config['allow_quick_reply'] && ($topic_data['forum_flags'] & FORUM_FLAG_QUICK_REPLY) && $auth->acl_get('f_reply', $forum_id))
{
   // Quick reply enabled forum
   $s_quick_reply = (($topic_data['forum_status'] == ITEM_UNLOCKED && $topic_data['topic_status'] == ITEM_UNLOCKED) || $auth->acl_get('m_edit', $forum_id)) ? true : false;
}


Here is my "viewtopic.php" code with all the code changes performed with the exception of the one above.

Code: Select all

<?php

/**

*

* @package phpBB3

* @version $Id: viewtopic.php 10179 2009-09-23 08:19:22Z nickvergessen $

* @copyright (c) 2005 phpBB Group

* @license http://opensource.org/licenses/gpl-license.php GNU Public License

*

*/







/**

* @ignore

*/

define('IN_PHPBB', true);

$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';

$phpEx = substr(strrchr(__FILE__, '.'), 1);

include($phpbb_root_path . 'common.' . $phpEx);

include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);

include($phpbb_root_path . 'includes/bbcode.' . $phpEx);



//added by Nyquist Show Groups Info

include($phpbb_root_path . 'includes/functions_nyqshowgroupsinfo.' . $phpEx);

//end added by Nyquist Show Groups Info











// Start session management

$user->session_begin();

$auth->acl($user->data);







// Initial var setup

$forum_id   = request_var('f', 0);

$topic_id   = request_var('t', 0);

$post_id   = request_var('p', 0);

$voted_id   = request_var('vote_id', array('' => 0));



$voted_id = (sizeof($voted_id) > 1) ? array_unique($voted_id) : $voted_id;





$start      = request_var('start', 0);

$view      = request_var('view', '');







$default_sort_days   = (!empty($user->data['user_post_show_days'])) ? $user->data['user_post_show_days'] : 0;

$default_sort_key   = (!empty($user->data['user_post_sortby_type'])) ? $user->data['user_post_sortby_type'] : 't';

$default_sort_dir   = (!empty($user->data['user_post_sortby_dir'])) ? $user->data['user_post_sortby_dir'] : 'a';







$sort_days   = request_var('st', $default_sort_days);

$sort_key   = request_var('sk', $default_sort_key);

$sort_dir   = request_var('sd', $default_sort_dir);







$update      = request_var('update', false);

$config['posts_per_page'] = $user->data['user_posts_per_page'];







$s_can_vote = false;

/**

* @todo normalize?

*/

$hilit_words   = request_var('hilit', '', true);







// Do we have a topic or post id?

if (!$topic_id && !$post_id)

{

   trigger_error('NO_TOPIC');

}







// Find topic id if user requested a newer or older topic

if ($view && !$post_id)

{

   if (!$forum_id)

   {

      $sql = 'SELECT forum_id

         FROM ' . TOPICS_TABLE . "

         WHERE topic_id = $topic_id";

      $result = $db->sql_query($sql);

      $forum_id = (int) $db->sql_fetchfield('forum_id');

      $db->sql_freeresult($result);







      if (!$forum_id)

      {

         trigger_error('NO_TOPIC');

      }

   }







   if ($view == 'unread')

   {

      // Get topic tracking info

      $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id);







      $topic_last_read = (isset($topic_tracking_info[$topic_id])) ? $topic_tracking_info[$topic_id] : 0;







      $sql = 'SELECT post_id, topic_id, forum_id

         FROM ' . POSTS_TABLE . "

         WHERE topic_id = $topic_id

            " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND post_approved = 1') . "

            AND post_time > $topic_last_read

            AND forum_id = $forum_id

         ORDER BY post_time ASC";

      $result = $db->sql_query_limit($sql, 1);

      $row = $db->sql_fetchrow($result);

      $db->sql_freeresult($result);







      if (!$row)

      {

         $sql = 'SELECT topic_last_post_id as post_id, topic_id, forum_id

            FROM ' . TOPICS_TABLE . '

            WHERE topic_id = ' . $topic_id;

         $result = $db->sql_query($sql);

         $row = $db->sql_fetchrow($result);

         $db->sql_freeresult($result);

      }







      if (!$row)

      {

         // Setup user environment so we can process lang string

         $user->setup('viewtopic');







         trigger_error('NO_TOPIC');

      }







      $post_id = $row['post_id'];

      $topic_id = $row['topic_id'];

   }

   else if ($view == 'next' || $view == 'previous')

   {

      $sql_condition = ($view == 'next') ? '>' : '<';

      $sql_ordering = ($view == 'next') ? 'ASC' : 'DESC';







      $sql = 'SELECT forum_id, topic_last_post_time

         FROM ' . TOPICS_TABLE . '

         WHERE topic_id = ' . $topic_id;

      $result = $db->sql_query($sql);

      $row = $db->sql_fetchrow($result);

      $db->sql_freeresult($result);







      if (!$row)

      {

         $user->setup('viewtopic');

         // OK, the topic doesn't exist. This error message is not helpful, but technically correct.

         trigger_error(($view == 'next') ? 'NO_NEWER_TOPICS' : 'NO_OLDER_TOPICS');

      }

      else

      {

         $sql = 'SELECT topic_id, forum_id

            FROM ' . TOPICS_TABLE . '

            WHERE forum_id = ' . $row['forum_id'] . "

               AND topic_moved_id = 0

               AND topic_last_post_time $sql_condition {$row['topic_last_post_time']}

               " . (($auth->acl_get('m_approve', $row['forum_id'])) ? '' : 'AND topic_approved = 1') . "

            ORDER BY topic_last_post_time $sql_ordering";

         $result = $db->sql_query_limit($sql, 1);

         $row = $db->sql_fetchrow($result);

         $db->sql_freeresult($result);







         if (!$row)

         {

            $user->setup('viewtopic');

            trigger_error(($view == 'next') ? 'NO_NEWER_TOPICS' : 'NO_OLDER_TOPICS');

         }

         else

         {

            $topic_id = $row['topic_id'];







            // Check for global announcement correctness?

            if (!$row['forum_id'] && !$forum_id)

            {

               trigger_error('NO_TOPIC');

            }

            else if ($row['forum_id'])

            {

               $forum_id = $row['forum_id'];

            }

         }

      }

   }







   // Check for global announcement correctness?

   if ((!isset($row) || !$row['forum_id']) && !$forum_id)

   {

      trigger_error('NO_TOPIC');

   }

   else if (isset($row) && $row['forum_id'])

   {

      $forum_id = $row['forum_id'];

   }

}







// This rather complex gaggle of code handles querying for topics but

// also allows for direct linking to a post (and the calculation of which

// page the post is on and the correct display of viewtopic)

$sql_array = array(

   'SELECT'   => 't.*, f.*',







   'FROM'      => array(FORUMS_TABLE => 'f'),

);







// The FROM-Order is quite important here, else t.* columns can not be correctly bound.

if ($post_id)

{

   $sql_array['SELECT'] .= ', p.post_approved';

   $sql_array['FROM'][POSTS_TABLE] = 'p';

}







// Topics table need to be the last in the chain

$sql_array['FROM'][TOPICS_TABLE] = 't';







if ($user->data['is_registered'])

{

   $sql_array['SELECT'] .= ', tw.notify_status';

   $sql_array['LEFT_JOIN'] = array();







   $sql_array['LEFT_JOIN'][] = array(

      'FROM'   => array(TOPICS_WATCH_TABLE => 'tw'),

      'ON'   => 'tw.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tw.topic_id'

   );







   if ($config['allow_bookmarks'])

   {

      $sql_array['SELECT'] .= ', bm.topic_id as bookmarked';

      $sql_array['LEFT_JOIN'][] = array(

         'FROM'   => array(BOOKMARKS_TABLE => 'bm'),

         'ON'   => 'bm.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = bm.topic_id'

      );

   }







   if ($config['load_db_lastread'])

   {

      $sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time as forum_mark_time';







      $sql_array['LEFT_JOIN'][] = array(

         'FROM'   => array(TOPICS_TRACK_TABLE => 'tt'),

         'ON'   => 'tt.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tt.topic_id'

      );







      $sql_array['LEFT_JOIN'][] = array(

         'FROM'   => array(FORUMS_TRACK_TABLE => 'ft'),

         'ON'   => 'ft.user_id = ' . $user->data['user_id'] . ' AND t.forum_id = ft.forum_id'

      );

   }

}







if (!$post_id)

{

   $sql_array['WHERE'] = "t.topic_id = $topic_id";

}

else

{

   $sql_array['WHERE'] = "p.post_id = $post_id AND t.topic_id = p.topic_id";

}







$sql_array['WHERE'] .= ' AND (f.forum_id = t.forum_id';







if (!$forum_id)

{

   // If it is a global announcement make sure to set the forum id to a postable forum

   $sql_array['WHERE'] .= ' OR (t.topic_type = ' . POST_GLOBAL . '

      AND f.forum_type = ' . FORUM_POST . ')';

}

else

{

   $sql_array['WHERE'] .= ' OR (t.topic_type = ' . POST_GLOBAL . "

      AND f.forum_id = $forum_id)";

}







$sql_array['WHERE'] .= ')';







// Join to forum table on topic forum_id unless topic forum_id is zero

// whereupon we join on the forum_id passed as a parameter ... this

// is done so navigation, forum name, etc. remain consistent with where

// user clicked to view a global topic

$sql = $db->sql_build_query('SELECT', $sql_array);

$result = $db->sql_query($sql);

$topic_data = $db->sql_fetchrow($result);

$db->sql_freeresult($result);







// link to unapproved post or incorrect link

if (!$topic_data)

{

   // If post_id was submitted, we try at least to display the topic as a last resort...



   if ($post_id && $forum_id && $topic_id)



   {



      redirect(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id"));



   }







   trigger_error('NO_TOPIC');

}







$forum_id = (int) $topic_data['forum_id'];

// This is for determining where we are (page)

if ($post_id)

{

   // are we where we are supposed to be?

   if (!$topic_data['post_approved'] && !$auth->acl_get('m_approve', $topic_data['forum_id']))

   {

      // If post_id was submitted, we try at least to display the topic as a last resort...

      if ($topic_id)

      {

         redirect(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=$topic_id" . (($forum_id) ? "&amp;f=$forum_id" : '')));

      }



      trigger_error('NO_TOPIC');

   }

   if ($post_id == $topic_data['topic_first_post_id'] || $post_id == $topic_data['topic_last_post_id'])

   {

      $check_sort = ($post_id == $topic_data['topic_first_post_id']) ? 'd' : 'a';







      if ($sort_dir == $check_sort)

      {

         $topic_data['prev_posts'] = ($auth->acl_get('m_approve', $forum_id)) ? $topic_data['topic_replies_real'] : $topic_data['topic_replies'];

      }

      else

      {

         $topic_data['prev_posts'] = 0;

      }

   }

   else

   {

      $sql = 'SELECT COUNT(p1.post_id) AS prev_posts

         FROM ' . POSTS_TABLE . ' p1, ' . POSTS_TABLE . " p2

         WHERE p1.topic_id = {$topic_data['topic_id']}

            AND p2.post_id = {$post_id}

            " . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND p1.post_approved = 1' : '') . '

            AND ' . (($sort_dir == 'd') ? 'p1.post_time >= p2.post_time' : 'p1.post_time <= p2.post_time');







      $result = $db->sql_query($sql);

      $row = $db->sql_fetchrow($result);

      $db->sql_freeresult($result);







      $topic_data['prev_posts'] = $row['prev_posts'] - 1;

   }

}







$topic_id = (int) $topic_data['topic_id'];







//

$topic_replies = ($auth->acl_get('m_approve', $forum_id)) ? $topic_data['topic_replies_real'] : $topic_data['topic_replies'];







// Check sticky/announcement time limit

if (($topic_data['topic_type'] == POST_STICKY || $topic_data['topic_type'] == POST_ANNOUNCE) && $topic_data['topic_time_limit'] && ($topic_data['topic_time'] + $topic_data['topic_time_limit']) < time())

{

   $sql = 'UPDATE ' . TOPICS_TABLE . '

      SET topic_type = ' . POST_NORMAL . ', topic_time_limit = 0

      WHERE topic_id = ' . $topic_id;

   $db->sql_query($sql);







   $topic_data['topic_type'] = POST_NORMAL;

   $topic_data['topic_time_limit'] = 0;

}







// Setup look and feel

$user->setup('viewtopic', $topic_data['forum_style']);







if (!$topic_data['topic_approved'] && !$auth->acl_get('m_approve', $forum_id))

{

   trigger_error('NO_TOPIC');

}







// Start auth check

if (!$auth->acl_get('f_read', $forum_id))

{

   if ($user->data['user_id'] != ANONYMOUS)

   {

      trigger_error('SORRY_AUTH_READ');

   }







   login_box('', $user->lang['LOGIN_VIEWFORUM']);

}







// Forum is passworded ... check whether access has been granted to this

// user this session, if not show login box

if ($topic_data['forum_password'])

{

   login_forum_box($topic_data);

}







// Redirect to login or to the correct post upon emailed notification links

if (isset($_GET['e']))

{

   $jump_to = request_var('e', 0);







   $redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id");







   if ($user->data['user_id'] == ANONYMOUS)

   {

      login_box($redirect_url . "&amp;p=$post_id&amp;e=$jump_to", $user->lang['LOGIN_NOTIFY_TOPIC']);

   }







   if ($jump_to > 0)

   {

      // We direct the already logged in user to the correct post...

      redirect($redirect_url . ((!$post_id) ? "&amp;p=$jump_to" : "&amp;p=$post_id") . "#p$jump_to");

   }

}







// What is start equal to?

if ($post_id)

{

   $start = floor(($topic_data['prev_posts']) / $config['posts_per_page']) * $config['posts_per_page'];

}







// Get topic tracking info

if (!isset($topic_tracking_info))

{

   $topic_tracking_info = array();







   // Get topic tracking info

   if ($config['load_db_lastread'] && $user->data['is_registered'])

   {

      $tmp_topic_data = array($topic_id => $topic_data);

      $topic_tracking_info = get_topic_tracking($forum_id, $topic_id, $tmp_topic_data, array($forum_id => $topic_data['forum_mark_time']));

      unset($tmp_topic_data);

   }

   else if ($config['load_anon_lastread'] || $user->data['is_registered'])

   {

      $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id);

   }

}







// Post ordering options

$limit_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_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']);

$sort_by_sql = array('a' => array('u.username_clean', 'p.post_id'), 't' => 'p.post_time', 's' => array('p.post_subject', 'p.post_id'));

$join_user_sql = array('a' => true, 't' => false, 's' => false);



$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, $default_sort_days, $default_sort_key, $default_sort_dir);







// Obtain correct post count and ordering SQL if user has

// requested anything different

if ($sort_days)

{

   $min_post_time = time() - ($sort_days * 86400);







   $sql = 'SELECT COUNT(post_id) AS num_posts

      FROM ' . POSTS_TABLE . "

      WHERE topic_id = $topic_id

         AND post_time >= $min_post_time

      " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND post_approved = 1');

   $result = $db->sql_query($sql);

   $total_posts = (int) $db->sql_fetchfield('num_posts');

   $db->sql_freeresult($result);







   $limit_posts_time = "AND p.post_time >= $min_post_time ";







   if (isset($_POST['sort']))

   {

      $start = 0;

   }

}

else

{

   $total_posts = $topic_replies + 1;

   $limit_posts_time = '';

}







// Was a highlight request part of the URI?

$highlight_match = $highlight = '';

if ($hilit_words)

{

   foreach (explode(' ', trim($hilit_words)) as $word)

   {

      if (trim($word))

      {

         $word = str_replace('*', 'w+?', preg_quote($word, '#'));

         $word = preg_replace('#(^|s)w*?(s|$)#', '$1w+?$2', $word);

         $highlight_match .= (($highlight_match != '') ? '|' : '') . $word;

      }

   }







   $highlight = urlencode($hilit_words);

}







// Make sure $start is set to the last page if it exceeds the amount

if ($start < 0 || $start >= $total_posts)

{

   $start = ($start < 0) ? 0 : floor(($total_posts - 1) / $config['posts_per_page']) * $config['posts_per_page'];

}







// General Viewtopic URL for return links

$viewtopic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;start=$start" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : '') . (($highlight_match) ? "&amp;hilit=$highlight" : ''));







// Are we watching this topic?

$s_watching_topic = array(

   'link'         => '',

   'title'         => '',

   'is_watching'   => false,

);







if (($config['email_enable'] || $config['jab_enable']) && $config['allow_topic_notify'] && $user->data['is_registered'])

{

   watch_topic_forum('topic', $s_watching_topic, $user->data['user_id'], $forum_id, $topic_id, $topic_data['notify_status'], $start);







   // Reset forum notification if forum notify is set

   if ($config['allow_forum_notify'] && $auth->acl_get('f_subscribe', $forum_id))

   {

      $s_watching_forum = $s_watching_topic;

      watch_topic_forum('forum', $s_watching_forum, $user->data['user_id'], $forum_id, 0);

   }

}







// Bookmarks

if ($config['allow_bookmarks'] && $user->data['is_registered'] && request_var('bookmark', 0))

{

   if (check_link_hash(request_var('hash', ''), "topic_$topic_id"))

   {

      if (!$topic_data['bookmarked'])

      {

         $sql = 'INSERT INTO ' . BOOKMARKS_TABLE . ' ' . $db->sql_build_array('INSERT', array(

            'user_id'   => $user->data['user_id'],

            'topic_id'   => $topic_id,

         ));

         $db->sql_query($sql);

      }

      else

      {

         $sql = 'DELETE FROM ' . BOOKMARKS_TABLE . "

            WHERE user_id = {$user->data['user_id']}

               AND topic_id = $topic_id";

         $db->sql_query($sql);

      }

      $message = (($topic_data['bookmarked']) ? $user->lang['BOOKMARK_REMOVED'] : $user->lang['BOOKMARK_ADDED']) . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $viewtopic_url . '">', '</a>');

   }

   else

   {

      $message = $user->lang['BOOKMARK_ERR'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $viewtopic_url . '">', '</a>');

   }

   meta_refresh(3, $viewtopic_url);







   trigger_error($message);

}







// Grab ranks

$ranks = $cache->obtain_ranks();







// Grab icons

$icons = $cache->obtain_icons();







// Grab extensions

$extensions = array();

if ($topic_data['topic_attachment'])

{

   $extensions = $cache->obtain_attach_extensions($forum_id);

}







// Forum rules listing

$s_forum_rules = '';

gen_forum_auth_level('topic', $forum_id, $topic_data['forum_status']);







// Quick mod tools

$allow_change_type = ($auth->acl_get('m_', $forum_id) || ($user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'])) ? true : false;







$topic_mod = '';

$topic_mod .= ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'] && $topic_data['topic_status'] == ITEM_UNLOCKED)) ? (($topic_data['topic_status'] == ITEM_UNLOCKED) ? '<option value="lock">' . $user->lang['LOCK_TOPIC'] . '</option>' : '<option value="unlock">' . $user->lang['UNLOCK_TOPIC'] . '</option>') : '';

$topic_mod .= ($auth->acl_get('m_delete', $forum_id)) ? '<option value="delete_topic">' . $user->lang['DELETE_TOPIC'] . '</option>' : '';

$topic_mod .= ($auth->acl_get('m_move', $forum_id) && $topic_data['topic_status'] != ITEM_MOVED) ? '<option value="move">' . $user->lang['MOVE_TOPIC'] . '</option>' : '';

$topic_mod .= ($auth->acl_get('m_split', $forum_id)) ? '<option value="split">' . $user->lang['SPLIT_TOPIC'] . '</option>' : '';

$topic_mod .= ($auth->acl_get('m_merge', $forum_id)) ? '<option value="merge">' . $user->lang['MERGE_POSTS'] . '</option>' : '';

$topic_mod .= ($auth->acl_get('m_merge', $forum_id)) ? '<option value="merge_topic">' . $user->lang['MERGE_TOPIC'] . '</option>' : '';

$topic_mod .= ($auth->acl_get('m_move', $forum_id)) ? '<option value="fork">' . $user->lang['FORK_TOPIC'] . '</option>' : '';

$topic_mod .= ($allow_change_type && $auth->acl_gets('f_sticky', 'f_announce', $forum_id) && $topic_data['topic_type'] != POST_NORMAL) ? '<option value="make_normal">' . $user->lang['MAKE_NORMAL'] . '</option>' : '';

$topic_mod .= ($allow_change_type && $auth->acl_get('f_sticky', $forum_id) && $topic_data['topic_type'] != POST_STICKY) ? '<option value="make_sticky">' . $user->lang['MAKE_STICKY'] . '</option>' : '';

$topic_mod .= ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_ANNOUNCE) ? '<option value="make_announce">' . $user->lang['MAKE_ANNOUNCE'] . '</option>' : '';

$topic_mod .= ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_GLOBAL) ? '<option value="make_global">' . $user->lang['MAKE_GLOBAL'] . '</option>' : '';

$topic_mod .= ($auth->acl_get('m_', $forum_id)) ? '<option value="topic_logs">' . $user->lang['VIEW_TOPIC_LOGS'] . '</option>' : '';







// If we've got a hightlight set pass it on to pagination.

$pagination = generate_pagination(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : '') . (($highlight_match) ? "&amp;hilit=$highlight" : '')), $total_posts, $config['posts_per_page'], $start);







// Navigation links

generate_forum_nav($topic_data);







// Forum Rules

generate_forum_rules($topic_data);







// Moderators

$forum_moderators = array();

if ($config['load_moderators'])

{

get_moderators($forum_moderators, $forum_id);

}



// This is only used for print view so ...

$server_path = (!$view) ? $phpbb_root_path : generate_board_url() . '/';







// Replace naughty words in title

$topic_data['topic_title'] = censor_text($topic_data['topic_title']);



//-- mod: Prime Trash Bin (Topics) ------------------------------------------//

// Adjust the quickmod dropdown list if necessary.

include ($phpbb_root_path . 'includes/prime_trash_bin.' . $phpEx);

$topic_deleted = !empty($topic_data['topic_deleted_time']);

if ($topic_deleted)

{

   $topic_mod = fake_delete_alter_quickmod($topic_mod, $forum_id);

}

//-- end: Prime Trash Bin (Topics) ------------------------------------------//



// Send vars to template

$template->assign_vars(array(

   'FORUM_ID'       => $forum_id,

   'FORUM_NAME'    => $topic_data['forum_name'],

   'FORUM_DESC'   => generate_text_for_display($topic_data['forum_desc'], $topic_data['forum_desc_uid'], $topic_data['forum_desc_bitfield'], $topic_data['forum_desc_options']),

   'TOPIC_ID'       => $topic_id,

   'TOPIC_TITLE'    => $topic_data['topic_title'],

   'TOPIC_POSTER'   => $topic_data['topic_poster'],

   //-- mod : forum title colour --------------------------------------------------

//-- add

   'FORUM_NAME_COLOUR'   => $topic_data['forum_name_colour'],

   'S_FORUM_NAME_COLOUR'   => !empty($topic_data['forum_name_colour']) ? true : false,

//-- fin mod : forum title colour ----------------------------------------------







   'TOPIC_AUTHOR_FULL'      => get_username_string('full', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']),

   'TOPIC_AUTHOR_COLOUR'   => get_username_string('colour', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']),

   'TOPIC_AUTHOR'         => get_username_string('username', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']),







   'PAGINATION'    => $pagination,

   'PAGE_NUMBER'    => on_page($total_posts, $config['posts_per_page'], $start),

   'START'         => $start,

   'STATUS_ENABLE_VIEWTOPIC'   =>     $config['enable_status_viewtopic'],



   'TOTAL_POSTS'   => ($total_posts == 1) ? $user->lang['VIEW_TOPIC_POST'] : sprintf($user->lang['VIEW_TOPIC_POSTS'], $total_posts),

   'U_MCP'       => ($auth->acl_get('m_', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&amp;mode=topic_view&amp;f=$forum_id&amp;t=$topic_id&amp;start=$start" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : ''), true, $user->session_id) : '',

   'MODERATORS'   => (isset($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id])) ? implode(', ', $forum_moderators[$forum_id]) : '',







   'POST_IMG'          => ($topic_data['forum_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', 'FORUM_LOCKED') : $user->img('button_topic_new', 'POST_NEW_TOPIC'),

   'QUOTE_IMG'       => $user->img('icon_post_quote', 'REPLY_WITH_QUOTE'),

   'REPLY_IMG'         => ($topic_data['forum_status'] == ITEM_LOCKED || $topic_data['topic_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', 'TOPIC_LOCKED') : $user->img('button_topic_reply', 'REPLY_TO_TOPIC'),

   'EDIT_IMG'          => $user->img('icon_post_edit', 'EDIT_POST'),
   //added by Ajax Quick Edit
   'QUICKEDIT_IMG'      => $user->img('icon_post_quickedit', 'QUICKEDIT_POST'),
//end added by Ajax Quick Edit

   'DELETE_IMG'       => $user->img('icon_post_delete', 'DELETE_POST'),

   'INFO_IMG'          => $user->img('icon_post_info', 'VIEW_INFO'),

   'PROFILE_IMG'      => $user->img('icon_user_profile', 'READ_PROFILE'),

   'SEARCH_IMG'       => $user->img('icon_user_search', 'SEARCH_USER_POSTS'),

   'PM_IMG'          => $user->img('icon_contact_pm', 'SEND_PRIVATE_MESSAGE'),

   'EMAIL_IMG'       => $user->img('icon_contact_email', 'SEND_EMAIL'),

   'WWW_IMG'          => $user->img('icon_contact_www', 'VISIT_WEBSITE'),

   'ICQ_IMG'          => $user->img('icon_contact_icq', 'ICQ'),

   'AIM_IMG'          => $user->img('icon_contact_aim', 'AIM'),

   'MSN_IMG'          => $user->img('icon_contact_msnm', 'MSNM'),

   'YIM_IMG'          => $user->img('icon_contact_yahoo', 'YIM'),

   'JABBER_IMG'      => $user->img('icon_contact_jabber', 'JABBER') ,

  'GALLERY_IMG'      => $user->img('icon_contact_gallery', 'PERSONAL_ALBUM'),

   'REPORT_IMG'      => $user->img('icon_post_report', 'REPORT_POST'),

   'REPORTED_IMG'      => $user->img('icon_topic_reported', 'POST_REPORTED'),

   'UNAPPROVED_IMG'   => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'),

   'WARN_IMG'         => $user->img('icon_user_warn', 'WARN_USER'),







   'S_IS_LOCKED'         => ($topic_data['topic_status'] == ITEM_UNLOCKED && $topic_data['forum_status'] == ITEM_UNLOCKED) ? false : true,

   'S_SELECT_SORT_DIR'    => $s_sort_dir,

   'S_SELECT_SORT_KEY'    => $s_sort_key,

   'S_SELECT_SORT_DAYS'    => $s_limit_days,

   'S_SINGLE_MODERATOR'   => (!empty($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id]) > 1) ? false : true,

   'S_TOPIC_ACTION'       => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;start=$start"),

   'S_TOPIC_MOD'          => ($topic_mod != '') ? '<select name="action" id="quick-mod-select">' . $topic_mod . '</select>' : '',



   'S_MOD_ACTION'          => append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;quickmod=1&amp;redirect=" . urlencode(str_replace('&amp;', '&', $viewtopic_url)), true, $user->session_id),







   'S_VIEWTOPIC'         => true,

   'S_DISPLAY_SEARCHBOX'   => ($auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search']) ? true : false,

   'S_SEARCHBOX_ACTION'   => append_sid("{$phpbb_root_path}search.$phpEx", 't=' . $topic_id),







   'S_DISPLAY_POST_INFO'   => ($topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS)) ? true : false,

   'S_DISPLAY_REPLY_INFO'   => ($topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_reply', $forum_id) || $user->data['user_id'] == ANONYMOUS)) ? true : false,

   'S_ENABLE_FEEDS_TOPIC'   => ($config['feed_topic'] && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $topic_data['forum_options'])) ? true : false,



   'U_TOPIC'            => "{$server_path}viewtopic.$phpEx?f=$forum_id&amp;t=$topic_id",

   'U_FORUM'            => $server_path,

   'U_VIEW_TOPIC'          => $viewtopic_url,

   'U_VIEW_FORUM'          => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id),

   'U_VIEW_OLDER_TOPIC'   => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;view=previous"),

   'U_VIEW_NEWER_TOPIC'   => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;view=next"),

   'U_PRINT_TOPIC'         => ($auth->acl_get('f_print', $forum_id)) ? $viewtopic_url . '&amp;view=print' : '',

   'U_EMAIL_TOPIC'         => ($auth->acl_get('f_email', $forum_id) && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=email&amp;t=$topic_id") : '',






  //added by Ajax Quick Edit
   'U_QUICKEDIT'          => append_sid("{$phpbb_root_path}quickedit.$phpEx"),
//end added by Ajax Quick Edit
   'U_WATCH_TOPIC'       => $s_watching_topic['link'],

   'L_WATCH_TOPIC'       => $s_watching_topic['title'],

   'S_WATCHING_TOPIC'      => $s_watching_topic['is_watching'],







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

   'L_BOOKMARK_TOPIC'      => ($user->data['is_registered'] && $config['allow_bookmarks'] && $topic_data['bookmarked']) ? $user->lang['BOOKMARK_TOPIC_REMOVE'] : $user->lang['BOOKMARK_TOPIC'],







   'U_POST_NEW_TOPIC'       => ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=post&amp;f=$forum_id") : '',

   'U_POST_REPLY_TOPIC'    => ($auth->acl_get('f_reply', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=reply&amp;f=$forum_id&amp;t=$topic_id") : '',

   'U_BUMP_TOPIC'         => (bump_topic_allowed($forum_id, $topic_data['topic_bumped'], $topic_data['topic_last_post_time'], $topic_data['topic_poster'], $topic_data['topic_last_poster_id'])) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=bump&amp;f=$forum_id&amp;t=$topic_id&amp;hash=" . generate_link_hash("topic_$topic_id")) : '')

);
$user->add_lang('mods/facebook');
$template->assign_var('FACEBOOK_IMG', $user->img('icon_contact_facebook', 'FACEBOOK'));






// Does this topic contain a poll?

if (!empty($topic_data['poll_start']))

{

   $sql = 'SELECT o.*, p.bbcode_bitfield, p.bbcode_uid

      FROM ' . POLL_OPTIONS_TABLE . ' o, ' . POSTS_TABLE . " p

      WHERE o.topic_id = $topic_id

         AND p.post_id = {$topic_data['topic_first_post_id']}

         AND p.topic_id = o.topic_id

      ORDER BY o.poll_option_id";

   $result = $db->sql_query($sql);







   $poll_info = array();

   while ($row = $db->sql_fetchrow($result))

   {

      $poll_info[] = $row;

   }

   $db->sql_freeresult($result);







   $cur_voted_id = array();

   if ($user->data['is_registered'])

   {

      $sql = 'SELECT poll_option_id

         FROM ' . POLL_VOTES_TABLE . '

         WHERE topic_id = ' . $topic_id . '

            AND vote_user_id = ' . $user->data['user_id'];

      $result = $db->sql_query($sql);







      while ($row = $db->sql_fetchrow($result))

      {

         $cur_voted_id[] = $row['poll_option_id'];

      }

      $db->sql_freeresult($result);

   }

   else

   {

      // Cookie based guest tracking ... I don't like this but hum ho

      // it's oft requested. This relies on "nice" users who don't feel

      // the need to delete cookies to mess with results.

      if (isset($_COOKIE[$config['cookie_name'] . '_poll_' . $topic_id]))

      {

         $cur_voted_id = explode(',', $_COOKIE[$config['cookie_name'] . '_poll_' . $topic_id]);

         $cur_voted_id = array_map('intval', $cur_voted_id);

      }

   }







   $s_can_vote = (((!sizeof($cur_voted_id) && $auth->acl_get('f_vote', $forum_id)) ||



      ($auth->acl_get('f_votechg', $forum_id) && $topic_data['poll_vote_change'])) &&



      (($topic_data['poll_length'] != 0 && $topic_data['poll_start'] + $topic_data['poll_length'] > time()) || $topic_data['poll_length'] == 0) &&

      $topic_data['topic_status'] != ITEM_LOCKED &&

      $topic_data['forum_status'] != ITEM_LOCKED &&

      (!sizeof($cur_voted_id) ||

      ($auth->acl_get('f_votechg', $forum_id) && $topic_data['poll_vote_change']))) ? true : false;

   $s_display_results = (!$s_can_vote || ($s_can_vote && sizeof($cur_voted_id)) || $view == 'viewpoll') ? true : false;







   if ($update && $s_can_vote)

   {







      if (!sizeof($voted_id) || sizeof($voted_id) > $topic_data['poll_max_options'] || in_array(VOTE_CONVERTED, $cur_voted_id) || !check_form_key('posting'))

      {

         $redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;start=$start");







         meta_refresh(5, $redirect_url);

         if (!sizeof($voted_id))

         {

            $message = 'NO_VOTE_OPTION';

         }

         else if (sizeof($voted_id) > $topic_data['poll_max_options'])

         {

            $message = 'TOO_MANY_VOTE_OPTIONS';

         }

         else if (in_array(VOTE_CONVERTED, $cur_voted_id))

         {

            $message = 'VOTE_CONVERTED';

         }

         else

         {

            $message = 'FORM_INVALID';

         }







         $message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>');

         trigger_error($message);

      }







      foreach ($voted_id as $option)

      {

         if (in_array($option, $cur_voted_id))

         {

            continue;

         }







         $sql = 'UPDATE ' . POLL_OPTIONS_TABLE . '

            SET poll_option_total = poll_option_total + 1

            WHERE poll_option_id = ' . (int) $option . '

               AND topic_id = ' . (int) $topic_id;

         $db->sql_query($sql);







         if ($user->data['is_registered'])

         {

            $sql_ary = array(

               'topic_id'         => (int) $topic_id,

               'poll_option_id'   => (int) $option,

               'vote_user_id'      => (int) $user->data['user_id'],

               'vote_user_ip'      => (string) $user->ip,

            );







            $sql = 'INSERT INTO ' . POLL_VOTES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);

            $db->sql_query($sql);

         }

      }







      foreach ($cur_voted_id as $option)

      {

         if (!in_array($option, $voted_id))

         {

            $sql = 'UPDATE ' . POLL_OPTIONS_TABLE . '

               SET poll_option_total = poll_option_total - 1

               WHERE poll_option_id = ' . (int) $option . '

                  AND topic_id = ' . (int) $topic_id;

            $db->sql_query($sql);







            if ($user->data['is_registered'])

            {

               $sql = 'DELETE FROM ' . POLL_VOTES_TABLE . '

                  WHERE topic_id = ' . (int) $topic_id . '

                     AND poll_option_id = ' . (int) $option . '

                     AND vote_user_id = ' . (int) $user->data['user_id'];

               $db->sql_query($sql);

            }

         }

      }







      if ($user->data['user_id'] == ANONYMOUS && !$user->data['is_bot'])

      {

         $user->set_cookie('poll_' . $topic_id, implode(',', $voted_id), time() + 31536000);

      }







      $sql = 'UPDATE ' . TOPICS_TABLE . '

         SET poll_last_vote = ' . time() . "

         WHERE topic_id = $topic_id";

      //, topic_last_post_time = ' . time() . " -- for bumping topics with new votes, ignore for now

      $db->sql_query($sql);







      $redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;start=$start");







      meta_refresh(5, $redirect_url);

      trigger_error($user->lang['VOTE_SUBMITTED'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>'));

   }







   $poll_total = 0;

   foreach ($poll_info as $poll_option)

   {

      $poll_total += $poll_option['poll_option_total'];

   }







   if ($poll_info[0]['bbcode_bitfield'])

   {

      $poll_bbcode = new bbcode();

   }

   else

   {

      $poll_bbcode = false;

   }







   for ($i = 0, $size = sizeof($poll_info); $i < $size; $i++)

   {

      $poll_info[$i]['poll_option_text'] = censor_text($poll_info[$i]['poll_option_text']);







      if ($poll_bbcode !== false)

      {

         $poll_bbcode->bbcode_second_pass($poll_info[$i]['poll_option_text'], $poll_info[$i]['bbcode_uid'], $poll_option['bbcode_bitfield']);

      }







      $poll_info[$i]['poll_option_text'] = bbcode_nl2br($poll_info[$i]['poll_option_text']);

      $poll_info[$i]['poll_option_text'] = smiley_text($poll_info[$i]['poll_option_text']);

   }







   $topic_data['poll_title'] = censor_text($topic_data['poll_title']);







   if ($poll_bbcode !== false)

   {

      $poll_bbcode->bbcode_second_pass($topic_data['poll_title'], $poll_info[0]['bbcode_uid'], $poll_info[0]['bbcode_bitfield']);

   }







   $topic_data['poll_title'] = bbcode_nl2br($topic_data['poll_title']);

   $topic_data['poll_title'] = smiley_text($topic_data['poll_title']);







   unset($poll_bbcode);







   foreach ($poll_info as $poll_option)

   {

      $option_pct = ($poll_total > 0) ? $poll_option['poll_option_total'] / $poll_total : 0;

      $option_pct_txt = sprintf("%.1d%%", round($option_pct * 100));







      $template->assign_block_vars('poll_option', array(

         'POLL_OPTION_ID'       => $poll_option['poll_option_id'],

         'POLL_OPTION_CAPTION'    => $poll_option['poll_option_text'],

         'POLL_OPTION_RESULT'    => $poll_option['poll_option_total'],

         'POLL_OPTION_PERCENT'    => $option_pct_txt,

         'POLL_OPTION_PCT'      => round($option_pct * 100),

         'POLL_OPTION_IMG'       => $user->img('poll_center', $option_pct_txt, round($option_pct * 250)),

         'POLL_OPTION_VOTED'      => (in_array($poll_option['poll_option_id'], $cur_voted_id)) ? true : false)

      );

   }







   $poll_end = $topic_data['poll_length'] + $topic_data['poll_start'];







   $template->assign_vars(array(

      'POLL_QUESTION'      => $topic_data['poll_title'],

      'TOTAL_VOTES'       => $poll_total,

      'POLL_LEFT_CAP_IMG'   => $user->img('poll_left'),

      'POLL_RIGHT_CAP_IMG'=> $user->img('poll_right'),







      'L_MAX_VOTES'      => ($topic_data['poll_max_options'] == 1) ? $user->lang['MAX_OPTION_SELECT'] : sprintf($user->lang['MAX_OPTIONS_SELECT'], $topic_data['poll_max_options']),

      'L_POLL_LENGTH'      => ($topic_data['poll_length']) ? sprintf($user->lang[($poll_end > time()) ? 'POLL_RUN_TILL' : 'POLL_ENDED_AT'], $user->format_date($poll_end)) : '',







      'S_HAS_POLL'      => true,

      'S_CAN_VOTE'      => $s_can_vote,

      'S_DISPLAY_RESULTS'   => $s_display_results,

      'S_IS_MULTI_CHOICE'   => ($topic_data['poll_max_options'] > 1) ? true : false,

      'S_POLL_ACTION'      => $viewtopic_url,







      'U_VIEW_RESULTS'   => $viewtopic_url . '&amp;view=viewpoll')

   );







   unset($poll_end, $poll_info, $voted_id);

}







// If the user is trying to reach the second half of the topic, fetch it starting from the end

$store_reverse = false;

$sql_limit = $config['posts_per_page'];

$sql_sort_order = $direction = '';



if ($start > $total_posts / 2)

{

   $store_reverse = true;







   if ($start + $config['posts_per_page'] > $total_posts)

   {

      $sql_limit = min($config['posts_per_page'], max(1, $total_posts - $start));

   }







   // Select the sort order

   $direction = (($sort_dir == 'd') ? 'ASC' : 'DESC');

   $sql_start = max(0, $total_posts - $sql_limit - $start);

}

else

{

   // Select the sort order

   $direction = (($sort_dir == 'd') ? 'DESC' : 'ASC');

   $sql_start = $start;

}



if (is_array($sort_by_sql[$sort_key]))

{

   $sql_sort_order = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction;

}

else

{

   $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction;

}







// Container for user details, only process once

$post_list = $user_cache = $id_cache = $attachments = $attach_list = $rowset = $update_count = $post_edit_list = array();

$has_attachments = $display_notice = false;

$bbcode_bitfield = '';

$i = $i_total = 0;







// Go ahead and pull all data for this topic

$sql = 'SELECT p.post_id

   FROM ' . POSTS_TABLE . ' p' . (($join_user_sql[$sort_key]) ? ', ' . USERS_TABLE . ' u': '') . "

   WHERE p.topic_id = $topic_id

      " . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND p.post_approved = 1' : '') . "

      " . (($join_user_sql[$sort_key]) ? 'AND u.user_id = p.poster_id': '') . "

      $limit_posts_time

   ORDER BY $sql_sort_order";

$result = $db->sql_query_limit($sql, $sql_limit, $sql_start);







$i = ($store_reverse) ? $sql_limit - 1 : 0;

while ($row = $db->sql_fetchrow($result))

{



   $post_list[$i] = $row['post_id'];



   ($store_reverse) ? $i-- : $i++;

}

$db->sql_freeresult($result);



//-- mod: Prime Trash Bin (Topics) ------------------------------------------//

// Make it so no posts will show up if the topic has been deleted and

// the user doesn't have the permissions to view the deleted content.

if ($topic_deleted)

{

   if (!auth_fake_delete('list', $forum_id)) // User can't view placeholder, so display "No Topic"

   {

      $post_list = array();

   }

   else if (!auth_fake_delete('view', $forum_id)) // User can view placeholder, but not the deleted posts

   {

      $post_list = array(0); //Needs an element or a "No Topic" message will be displayed

   }

}

//-- end: Prime Trash Bin (Topics) ------------------------------------------//



if (!sizeof($post_list))

{

   if ($sort_days)

   {

      trigger_error('NO_POSTS_TIME_FRAME');

   }

   else

   {

      trigger_error('NO_TOPIC');

   }

}







// Holding maximum post time for marking topic read

// We need to grab it because we do reverse ordering sometimes

$max_post_time = 0;







$sql = $db->sql_build_query('SELECT', array(

  //below line removed by IC, 3 May 2010 - phpbb_gallery_1_0_5 MOD
   //'SELECT'   => 'u.*, z.friend, z.foe, p.*',
   'SELECT'   => 'u.*, z.friend, z.foe, p.*, gu.personal_album_id, gu.user_images',






   'FROM'      => array(

      USERS_TABLE      => 'u',

      POSTS_TABLE      => 'p',

   ),







   'LEFT_JOIN'   => array(

      array(

         'FROM'   => array(ZEBRA_TABLE => 'z'),

         'ON'   => 'z.user_id = ' . $user->data['user_id'] . ' AND z.zebra_id = p.poster_id'

      )

      , array(
         'FROM'   => array(GALLERY_USERS_TABLE => 'gu'),
         'ON'   => 'gu.user_id = p.poster_id'
      )

   ),







   'WHERE'      => $db->sql_in_set('p.post_id', $post_list) . '

      AND u.user_id = p.poster_id'

));







$result = $db->sql_query($sql);







$now = getdate(time() + $user->timezone + $user->dst - date('Z'));







// Posts are stored in the $rowset array while $attach_list, $user_cache

// and the global bbcode_bitfield are built

while ($row = $db->sql_fetchrow($result))

{



//-- mod: Prime Trash Bin (Posts) -------------------------------------------//

// If the post has been deleted, we need to check if the user is allowed to view the placeholder.

   if (!empty($row['post_deleted_time']) && !auth_fake_delete('list', $forum_id))

   {

      continue;

   }

//-- end: Prime Trash Bin (Posts) -------------------------------------------//



   // Set max_post_time

   if ($row['post_time'] > $max_post_time)

   {

      $max_post_time = $row['post_time'];

   }







   $poster_id = $row['poster_id'];







   // Does post have an attachment? If so, add it to the list

   if ($row['post_attachment'] && $config['allow_attachments'])

   {



      $attach_list[] = $row['post_id'];







      if ($row['post_approved'])

      {

         $has_attachments = true;

      }

   }







   $rowset[$row['post_id']] = array(

      'hide_post'         => ($row['foe'] && ($view != 'show' || $post_id != $row['post_id'])) ? true : false,







      'post_id'         => $row['post_id'],

      'post_time'         => $row['post_time'],

      'user_id'         => $row['user_id'],

      'username'         => $row['username'],

      'user_colour'      => $row['user_colour'],

      'topic_id'         => $row['topic_id'],

      'forum_id'         => $row['forum_id'],

      'post_subject'      => $row['post_subject'],

      'post_edit_count'   => $row['post_edit_count'],

      'post_edit_time'   => $row['post_edit_time'],

      'post_edit_reason'   => $row['post_edit_reason'],

      'post_edit_user'   => $row['post_edit_user'],

      'post_edit_locked'   => $row['post_edit_locked'],







      // Make sure the icon actually exists

      'icon_id'         => (isset($icons[$row['icon_id']]['img'], $icons[$row['icon_id']]['height'], $icons[$row['icon_id']]['width'])) ? $row['icon_id'] : 0,

      'post_attachment'   => $row['post_attachment'],

      'post_approved'      => $row['post_approved'],

      'post_reported'      => $row['post_reported'],

      'post_username'      => $row['post_username'],

      'post_text'         => $row['post_text'],

      'bbcode_uid'      => $row['bbcode_uid'],

      'bbcode_bitfield'   => $row['bbcode_bitfield'],

      'enable_smilies'   => $row['enable_smilies'],

      'enable_sig'      => $row['enable_sig'],

      'friend'         => $row['friend'],

      'foe'            => $row['foe'],

   );



//-- mod: Prime Trash Bin (Posts) -------------------------------------------//

// This is where we make the deletion info available for when the script starts

// looping through each post to set the template variables. If we're viewing

// the post's revision history (another MOD), then don't hide the post's content.

   if (!empty($row['post_deleted_time']) && empty($display_history))

   {

      $rowset[$row['post_id']]['post_deleted_from']   = $row['post_deleted_from'];

      $rowset[$row['post_id']]['post_deleted_user']   = $row['post_deleted_user'];

      $rowset[$row['post_id']]['post_deleted_time']   = $row['post_deleted_time'];

      $rowset[$row['post_id']]['post_deleted_reason'] = censor_text($row['post_deleted_reason']);



      // We don't want to display any info about previous edits.

      $rowset[$row['post_id']]['post_edit_reason'] = '';

      $rowset[$row['post_id']]['post_edit_count']  = 0;

   }

//-- end: Prime Trash Bin (Posts) -------------------------------------------//



   // Define the global bbcode bitfield, will be used to load bbcodes

   $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']);







   // Is a signature attached? Are we going to display it?

   if ($row['enable_sig'] && $config['allow_sig'] && $user->optionget('viewsigs'))

   {

      $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['user_sig_bbcode_bitfield']);

   }







   // Cache various user specific data ... so we don't have to recompute

   // this each time the same user appears on this page

   if (!isset($user_cache[$poster_id]))

   {

      if ($poster_id == ANONYMOUS)

      {

         $user_cache[$poster_id] = array(

            'joined'      => '',

            'posts'         => '',

            'from'         => '',







            'sig'               => '',

            'sig_bbcode_uid'      => '',

            'sig_bbcode_bitfield'   => '',







            'online'         => false,

            'avatar'         => ($user->optionget('viewavatars')) ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']) : '',

            'rank_title'      => '',

            'rank_image'      => '',

            'rank_image_src'   => '',



            //multiple rank mod by Goz



         'rank2_title'      => '',



         'rank2_image'      => '',



         'rank2_image_src'         => '',



         'rank3_title'      => '',



         'rank3_image'      => '',



         'rank3_image_src'         => '',



            'extra_rank_title'      => '',

            'extra_rank_image'      => '',

            'extra_rank_image_src'   => '',



            'sig'            => '',

            'profile'         => '',

            'pm'            => '',

            'email'            => '',

            'www'            => '',

            'icq_status_img'   => '',

            'icq'            => '',

            'aim'            => '',

            'msn'            => '',

            'yim'            => '',

            'jabber'         => '',

            'search'         => '',

            'age'            => '',

            'gallery_album'      => '',
            'gallery_images'   => '',
            'gallery_search'   => '',

            'extra_rank_title'      => '',

            'extra_rank_image'      => '',

            'extra_rank_image_src'   => '',



            'username'         => $row['username'],

            'user_colour'      => $row['user_colour'],







            'warnings'         => 0,

            'allow_pm'         => 0,

         );
               $user_cache[$poster_id]['facebook'] = '';






         get_user_rank($row['user_rank'], false, $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);



      //Multiple ranks mod by Goz



get_user_rank2($row['user_rank2'], $row['user_posts'],



$user_cache[$poster_id]['rank2_title'],



$user_cache[$poster_id]['rank2_image'],



$user_cache[$poster_id]['rank2_image_src']);



get_user_rank3($row['user_rank3'], $row['user_posts'],



$user_cache[$poster_id]['rank3_title'],



$user_cache[$poster_id]['rank3_image'],



$user_cache[$poster_id]['rank3_image_src']);



      }

      else

      {

         $user_sig = '';







         // We add the signature to every posters entry because enable_sig is post dependant

         if ($row['user_sig'] && $config['allow_sig'] && $user->optionget('viewsigs'))

         {

            $user_sig = $row['user_sig'];

         }







         $id_cache[] = $poster_id;







         $user_cache[$poster_id] = array(

            'joined'      => $user->format_date($row['user_regdate']),

            'posts'         => $row['user_posts'],

            'warnings'      => (isset($row['user_warnings'])) ? $row['user_warnings'] : 0,

            'from'         => (!empty($row['user_from'])) ? $row['user_from'] : '',







            'sig'               => $user_sig,

            'sig_bbcode_uid'      => (!empty($row['user_sig_bbcode_uid'])) ? $row['user_sig_bbcode_uid'] : '',

            'sig_bbcode_bitfield'   => (!empty($row['user_sig_bbcode_bitfield'])) ? $row['user_sig_bbcode_bitfield'] : '',







            'viewonline'   => $row['user_allow_viewonline'],

            'allow_pm'      => $row['user_allow_pm'],

            'allow_thanks_pm' => $row['user_allow_thanks_pm'],







            'avatar'      => ($user->optionget('viewavatars')) ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']) : '',

            'age'         => '',







            'rank_title'      => '',

            'rank_image'      => '',

            'rank_image_src'   => '',



            //multiple rank mod by Goz



         'rank2_title'      => '',



         'rank2_image'      => '',



         'rank2_image_src'    => '',



         'rank3_title'      => '',



         'rank3_image'      => '',



         'rank3_image_src'         => '',







            'username'         => $row['username'],

            'user_colour'      => $row['user_colour'],







            'online'      => false,

            'profile'      => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=viewprofile&amp;u=$poster_id"),

            'www'         => $row['user_website'],

            'aim'         => ($row['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&amp;action=aim&amp;u=$poster_id") : '',

            'msn'         => ($row['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&amp;action=msnm&amp;u=$poster_id") : '',

            'yim'         => ($row['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($row['user_yim']) . '&amp;.src=pg' : '',

            'jabber'      => ($row['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&amp;action=jabber&amp;u=$poster_id") : '',
        'facebook'      => ($row['user_facebook']) ? 'http://facebook.com/' . urlencode($row['user_facebook']) : '',
            'search'      => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$poster_id&amp;sr=posts") : '',

            'gallery_album'      => ($row['personal_album_id'] && $config['gallery_viewtopic_icon']) ? append_sid("{$phpbb_root_path}" . GALLERY_ROOT_PATH . "album.$phpEx", "album_id=" . $row['personal_album_id']) : '',
            'gallery_images'   => ($config['gallery_viewtopic_images']) ? $row['user_images'] : 0,
            'gallery_search'   => ($config['gallery_viewtopic_images'] && $config['gallery_viewtopic_link'] && $row['user_images']) ? append_sid("{$phpbb_root_path}" . GALLERY_ROOT_PATH . "search.$phpEx", "user_id=$poster_id") : '',

            'author_full'      => get_username_string('full', $poster_id, $row['username'], $row['user_colour']),

            'author_colour'      => get_username_string('colour', $poster_id, $row['username'], $row['user_colour']),

            'author_username'   => get_username_string('username', $poster_id, $row['username'], $row['user_colour']),

            'author_profile'   => get_username_string('profile', $poster_id, $row['username'], $row['user_colour']),

         );
               






         get_user_rank($row['user_rank'], $row['user_posts'], $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);



         //added by Nyquist Show Groups Info

         //check the system var:

         if (isset($config['nyq_showgroupsinfo']))

         {

            //extract the groups

            $nyq_groups_ranks_array = nyq_getgroupsarray_new($poster_id, $config['nyq_showgroupsinfo'], $user_cache[$poster_id]['rank_image_src']);

            $user_cache[$poster_id]['nyq_showgroupsinfo'] = $nyq_groups_ranks_array;

         }

         //end added by Nyquist Show Groups Info



         if (defined('SHOW_SPECIAL_AS_EXTRA') && SHOW_SPECIAL_AS_EXTRA)

         {

            $user_cache[$poster_id]['extra_rank_title'] = $user_cache[$poster_id]['rank_title'];

            $user_cache[$poster_id]['extra_rank_image'] = $user_cache[$poster_id]['rank_image'];

            $user_cache[$poster_id]['extra_rank_image_src'] = $user_cache[$poster_id]['rank_image_src'];

            $user_cache[$poster_id]['rank_title'] = $user_cache[$poster_id]['rank_image'] = $user_cache[$poster_id]['rank_image_src'] = '';

            

            get_user_additional_rank($row['user_rank'], $row['user_posts'], $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);

         }

         else

         {

            get_user_additional_rank($row['user_rank'], $row['user_posts'], $user_cache[$poster_id]['extra_rank_title'], $user_cache[$poster_id]['extra_rank_image'], $user_cache[$poster_id]['extra_rank_image_src']);

         }



         if (!empty($row['user_allow_viewemail']) || $auth->acl_get('a_email'))

         {

            $user_cache[$poster_id]['email'] = ($config['board_email_form'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=email&amp;u=$poster_id") : (($config['board_hide_emails'] && !$auth->acl_get('a_email')) ? '' : 'mailto:' . $row['user_email']);

         }

         else

         {

            $user_cache[$poster_id]['email'] = '';

         }







         if (!empty($row['user_icq']))

         {

            $user_cache[$poster_id]['icq'] = 'http://www.icq.com/people/webmsg.php?to=' . $row['user_icq'];

            $user_cache[$poster_id]['icq_status_img'] = '<img src="http://web.icq.com/whitepages/online?icq=' . $row['user_icq'] . '&amp;img=5" width="18" height="18" alt="" />';

         }

         else

         {

            $user_cache[$poster_id]['icq_status_img'] = '';

            $user_cache[$poster_id]['icq'] = '';

         }







         if ($config['allow_birthdays'] && !empty($row['user_birthday']))

         {

            list($bday_day, $bday_month, $bday_year) = array_map('intval', explode('-', $row['user_birthday']));







            if ($bday_year)

            {

               $diff = $now['mon'] - $bday_month;

               if ($diff == 0)

               {

                  $diff = ($now['mday'] - $bday_day < 0) ? 1 : 0;

               }

               else

               {

                  $diff = ($diff < 0) ? 1 : 0;

               }







               $user_cache[$poster_id]['age'] = (int) ($now['year'] - $bday_year - $diff);

            }

         }

      }

   }

}

$db->sql_freeresult($result);







// Load custom profile fields

if ($config['load_cpf_viewtopic'])

{

      include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);

   $cp = new custom_profile();







   // Grab all profile fields from users in id cache for later use - similar to the poster cache

   $profile_fields_tmp = $cp->generate_profile_fields_template('grab', $id_cache);



   // filter out fields not to be displayed on viewtopic. Yes, it's a hack, but this shouldn't break any MODs.

   $profile_fields_cache = array();

   foreach ($profile_fields_tmp as $profile_user_id => $profile_fields)

   {

      $profile_fields_cache[$profile_user_id] = array();

      foreach ($profile_fields as $used_ident => $profile_field)

      {

         if ($profile_field['data']['field_show_on_vt'])

         {

            $profile_fields_cache[$profile_user_id][$used_ident] = $profile_field;

         }

      }

   }

   unset($profile_fields_tmp);

}







// Generate online information for user

if ($config['load_onlinetrack'] && sizeof($id_cache))

{

   $sql = 'SELECT session_user_id, MAX(session_time) as online_time, MIN(session_viewonline) AS viewonline

      FROM ' . SESSIONS_TABLE . '

      WHERE ' . $db->sql_in_set('session_user_id', $id_cache) . '

      GROUP BY session_user_id';

   $result = $db->sql_query($sql);







   $update_time = $config['load_online_time'] * 60;

   while ($row = $db->sql_fetchrow($result))

   {

      $user_cache[$row['session_user_id']]['online'] = (time() - $update_time < $row['online_time'] && (($row['viewonline']) || $auth->acl_get('u_viewonline'))) ? true : false;

   }

   $db->sql_freeresult($result);

}



// BEGIN BAN TEST

$sql = 'SELECT b.*, u.user_id

   FROM ' . BANLIST_TABLE . ' b, ' . USERS_TABLE . ' u

   WHERE (b.ban_end >= ' . time() . '

      OR b.ban_end = 0)';



$result = $db->sql_query($sql);

$ban_list = array();

while ($row2 = $db->sql_fetchrow($result))

{

   $ban_list[] = $row2['ban_userid'];

}

$db->sql_freeresult($result);

// END BAN TEST



unset($id_cache);







// Pull attachment data

if (sizeof($attach_list))

{

   if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id))

   {

      $sql = 'SELECT *

         FROM ' . ATTACHMENTS_TABLE . '

         WHERE ' . $db->sql_in_set('post_msg_id', $attach_list) . '

            AND in_message = 0

         ORDER BY filetime DESC, post_msg_id ASC';

      $result = $db->sql_query($sql);







      while ($row = $db->sql_fetchrow($result))

      {

         $attachments[$row['post_msg_id']][] = $row;

      }

      $db->sql_freeresult($result);







      // No attachments exist, but post table thinks they do so go ahead and reset post_attach flags

      if (!sizeof($attachments))

      {

         $sql = 'UPDATE ' . POSTS_TABLE . '

            SET post_attachment = 0

            WHERE ' . $db->sql_in_set('post_id', $attach_list);

         $db->sql_query($sql);







         // We need to update the topic indicator too if the complete topic is now without an attachment

         if (sizeof($rowset) != $total_posts)

         {

            // Not all posts are displayed so we query the db to find if there's any attachment for this topic

            $sql = 'SELECT a.post_msg_id as post_id

               FROM ' . ATTACHMENTS_TABLE . ' a, ' . POSTS_TABLE . " p

               WHERE p.topic_id = $topic_id

                  AND p.post_approved = 1

                  AND p.topic_id = a.topic_id";

            $result = $db->sql_query_limit($sql, 1);

            $row = $db->sql_fetchrow($result);

            $db->sql_freeresult($result);







            if (!$row)

            {

               $sql = 'UPDATE ' . TOPICS_TABLE . "

                  SET topic_attachment = 0

                  WHERE topic_id = $topic_id";

               $db->sql_query($sql);

            }

         }

         else

         {

            $sql = 'UPDATE ' . TOPICS_TABLE . "

               SET topic_attachment = 0

               WHERE topic_id = $topic_id";

            $db->sql_query($sql);

         }

      }

      else if ($has_attachments && !$topic_data['topic_attachment'])

      {

         // Topic has approved attachments but its flag is wrong

         $sql = 'UPDATE ' . TOPICS_TABLE . "

            SET topic_attachment = 1

            WHERE topic_id = $topic_id";

         $db->sql_query($sql);







         $topic_data['topic_attachment'] = 1;

      }

   }

   else

   {

      $display_notice = true;

   }

}







// Instantiate BBCode if need be

if ($bbcode_bitfield !== '')

{

   $bbcode = new bbcode(base64_encode($bbcode_bitfield));

}







$i_total = sizeof($rowset) - 1;

$prev_post_id = '';







$template->assign_vars(array(

   'S_NUM_POSTS' => sizeof($post_list))

);





include($phpbb_root_path . 'includes/functions_thanks.' . $phpEx);

array_all_thanks($post_list);

if (isset($_REQUEST['thanks']) && !isset($_REQUEST['rthanks']))

{

   insert_thanks(request_var('thanks', 0), $user->data['user_id']);

}

if (isset($_REQUEST['rthanks']) && !isset($_REQUEST['thanks']))

{

   delete_thanks(request_var('rthanks', 0), $user->data['user_id']);

}
// Check whether quick reply is enabled
$s_quick_reply = false;
if ($user->data['is_registered'] && $config['allow_quick_reply'] && ($topic_data['forum_flags'] & FORUM_FLAG_QUICK_REPLY) && $auth->acl_get('f_reply', $forum_id))
{
   // Quick reply enabled forum
   $s_quick_reply = (($topic_data['forum_status'] == ITEM_UNLOCKED && $topic_data['topic_status'] == ITEM_UNLOCKED) || $auth->acl_get('m_edit', $forum_id)) ? true : false;
}
// Output the posts

$first_unread = $post_unread = false;

for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)

{

   // A non-existing rowset only happens if there was no user present for the entered poster_id

   // This could be a broken posts table.

   if (!isset($rowset[$post_list[$i]]))

   {

      continue;

   }







   $row =& $rowset[$post_list[$i]];

   $poster_id = $row['user_id'];







   // End signature parsing, only if needed

   if ($user_cache[$poster_id]['sig'] && $row['enable_sig'] && empty($user_cache[$poster_id]['sig_parsed']))

   {

      $user_cache[$poster_id]['sig'] = censor_text($user_cache[$poster_id]['sig']);







      if ($user_cache[$poster_id]['sig_bbcode_bitfield'])

      {

         $bbcode->bbcode_second_pass($user_cache[$poster_id]['sig'], $user_cache[$poster_id]['sig_bbcode_uid'], $user_cache[$poster_id]['sig_bbcode_bitfield']);

      }







      $user_cache[$poster_id]['sig'] = bbcode_nl2br($user_cache[$poster_id]['sig']);

      $user_cache[$poster_id]['sig'] = smiley_text($user_cache[$poster_id]['sig']);

      $user_cache[$poster_id]['sig_parsed'] = true;

   }







   // Parse the message and subject

   $message = censor_text($row['post_text']);
  $decoded_message = false;

   if ($s_quick_reply)
   {
      $decoded_message = $message;
      decode_message($decoded_message, $row['bbcode_uid']);

      $decoded_message = bbcode_nl2br($decoded_message);
   }






   // Second parse bbcode here

   if ($row['bbcode_bitfield'])

   {

      $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);

   }







   $message = bbcode_nl2br($message);

   $message = smiley_text($message);







   if (!empty($attachments[$row['post_id']]))

   {

      parse_attachments($forum_id, $message, $attachments[$row['post_id']], $update_count);

   }







   // Replace naughty words such as farty pants

   $row['post_subject'] = censor_text($row['post_subject']);







   // Highlight active words (primarily for search)

   if ($highlight_match)

   {

      $message = preg_replace('#(?!<.*)(?<!w)(' . $highlight_match . ')(?!w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">1</span>', $message);

      $row['post_subject'] = preg_replace('#(?!<.*)(?<!w)(' . $highlight_match . ')(?!w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">1</span>', $row['post_subject']);

   }







   // Editing information

   if (($row['post_edit_count'] && $config['display_last_edited']) || $row['post_edit_reason'])

   {

      // Get usernames for all following posts if not already stored

      if (!sizeof($post_edit_list) && ($row['post_edit_reason'] || ($row['post_edit_user'] && !isset($user_cache[$row['post_edit_user']]))))

      {

         // Remove all post_ids already parsed (we do not have to check them)

         $post_storage_list = (!$store_reverse) ? array_slice($post_list, $i) : array_slice(array_reverse($post_list), $i);







         $sql = 'SELECT DISTINCT u.user_id, u.username, u.user_colour

            FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u

            WHERE ' . $db->sql_in_set('p.post_id', $post_storage_list) . '

               AND p.post_edit_count <> 0

               AND p.post_edit_user <> 0

               AND p.post_edit_user = u.user_id';

         $result2 = $db->sql_query($sql);

         while ($user_edit_row = $db->sql_fetchrow($result2))

         {

            $post_edit_list[$user_edit_row['user_id']] = $user_edit_row;

         }

         $db->sql_freeresult($result2);







         unset($post_storage_list);

      }







      $l_edit_time_total = ($row['post_edit_count'] == 1) ? $user->lang['EDITED_TIME_TOTAL'] : $user->lang['EDITED_TIMES_TOTAL'];







      if ($row['post_edit_reason'])

      {

         // User having edited the post also being the post author?

         if (!$row['post_edit_user'] || $row['post_edit_user'] == $poster_id)

         {

            $display_username = get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']);

         }

         else

         {

            $display_username = get_username_string('full', $row['post_edit_user'], $post_edit_list[$row['post_edit_user']]['username'], $post_edit_list[$row['post_edit_user']]['user_colour']);

         }







         $l_edited_by = sprintf($l_edit_time_total, $display_username, $user->format_date($row['post_edit_time'], false, true), $row['post_edit_count']);

      }

      else

      {

         if ($row['post_edit_user'] && !isset($user_cache[$row['post_edit_user']]))

         {

            $user_cache[$row['post_edit_user']] = $post_edit_list[$row['post_edit_user']];

         }







         // User having edited the post also being the post author?

         if (!$row['post_edit_user'] || $row['post_edit_user'] == $poster_id)

         {

            $display_username = get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']);

         }

         else

         {

            $display_username = get_username_string('full', $row['post_edit_user'], $user_cache[$row['post_edit_user']]['username'], $user_cache[$row['post_edit_user']]['user_colour']);

         }







         $l_edited_by = sprintf($l_edit_time_total, $display_username, $user->format_date($row['post_edit_time'], false, true), $row['post_edit_count']);

      }

   }

   else

   {

      $l_edited_by = '';

   }







   // Bump information

   if ($topic_data['topic_bumped'] && $row['post_id'] == $topic_data['topic_last_post_id'] && isset($user_cache[$topic_data['topic_bumper']]) )

   {

      // It is safe to grab the username from the user cache array, we are at the last

      // post and only the topic poster and last poster are allowed to bump.

      // Admins and mods are bound to the above rules too...

      $l_bumped_by = sprintf($user->lang['BUMPED_BY'], $user_cache[$topic_data['topic_bumper']]['username'], $user->format_date($topic_data['topic_last_post_time'], false, true));

   }

   else

   {

      $l_bumped_by = '';

   }







   $cp_row = array();







   //

   if ($config['load_cpf_viewtopic'])

   {

      $cp_row = (isset($profile_fields_cache[$poster_id])) ? $cp->generate_profile_fields_template('show', false, $profile_fields_cache[$poster_id]) : array();

   }







   $post_unread = (isset($topic_tracking_info[$topic_id]) && $row['post_time'] > $topic_tracking_info[$topic_id]) ? true : false;







   $s_first_unread = false;

   if (!$first_unread && $post_unread)

   {

      $s_first_unread = $first_unread = true;

   }



   $edit_allowed = ($user->data['is_registered'] && ($auth->acl_get('m_edit', $forum_id) || (

      $user->data['user_id'] == $poster_id &&

      $auth->acl_get('f_edit', $forum_id) &&

      !$row['post_edit_locked'] &&

      ($row['post_time'] > time() - ($config['edit_time'] * 60) || !$config['edit_time'])

   )));



   $delete_allowed = ($user->data['is_registered'] && ($auth->acl_get('m_delete', $forum_id) || (

      $user->data['user_id'] == $poster_id &&

      $auth->acl_get('f_delete', $forum_id) &&

      $topic_data['topic_last_post_id'] == $row['post_id'] &&

      ($row['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time']) &&

      // we do not want to allow removal of the last post if a moderator locked it!

      !$row['post_edit_locked']

   )));



   //

   $postrow = array(

      'POST_AUTHOR_FULL'      => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_full'] : get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),

      'POST_AUTHOR_COLOUR'   => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_colour'] : get_username_string('colour', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),

      'POST_AUTHOR'         => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_username'] : get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),

      'U_POST_AUTHOR'         => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_profile'] : get_username_string('profile', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),



      'RANK_TITLE'      => $user_cache[$poster_id]['rank_title'],

      'RANK_IMG'         => $user_cache[$poster_id]['rank_image'],

      'RANK_IMG_SRC'      => $user_cache[$poster_id]['rank_image_src'],

      

      'EXTRA_RANK_TITLE'   => $user_cache[$poster_id]['extra_rank_title'],

      'EXTRA_RANK_IMG'   => $user_cache[$poster_id]['extra_rank_image'],

      'EXTRA_RANK_IMG_SRC'=> $user_cache[$poster_id]['extra_rank_image_src'],



      //multiple rank mod by Goz



     'RANK2_TITLE'      => $user_cache[$poster_id]['rank2_title'],



     'RANK2_IMG'      => $user_cache[$poster_id]['rank2_image'],



     'RANK2_IMG_SRC'      => $user_cache[$poster_id]['rank2_image_src'],



     'RANK3_TITLE'      => $user_cache[$poster_id]['rank3_title'],



     'RANK3_IMG'      => $user_cache[$poster_id]['rank3_image'],



     'RANK3_IMG_SRC'      => $user_cache[$poster_id]['rank3_image_src'],



      'POSTER_JOINED'      => $user_cache[$poster_id]['joined'],

      'POSTER_POSTS'      => $user_cache[$poster_id]['posts'],

      'POSTER_FROM'      => $user_cache[$poster_id]['from'],

      'POSTER_AVATAR'      => $user_cache[$poster_id]['avatar'],

      'POSTER_WARNINGS'   => $user_cache[$poster_id]['warnings'],

      'POSTER_AGE'      => $user_cache[$poster_id]['age'],







      'POST_DATE'         => $user->format_date($row['post_time']),



      'POST_SUBJECT'      => $row['post_subject'],

      'MESSAGE'         => $message,
    'DECODED_MESSAGE'   => $decoded_message,


      'SIGNATURE'         => ($row['enable_sig']) ? ($config['reimg_ignore_sig_img'] ? str_replace(reimg_properties(), '', $user_cache[$poster_id]['sig']) : $user_cache[$poster_id]['sig']) : '',



      'EDITED_MESSAGE'   => $l_edited_by,

      'EDIT_REASON'      => $row['post_edit_reason'],

      'BUMPED_MESSAGE'   => $l_bumped_by,







      'MINI_POST_IMG'         => ($post_unread) ? $user->img('icon_post_target_unread', 'NEW_POST') : $user->img('icon_post_target', 'POST'),

      'POST_ICON_IMG'         => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['img'] : '',

      'POST_ICON_IMG_WIDTH'   => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['width'] : '',

      'POST_ICON_IMG_HEIGHT'   => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['height'] : '',

      'ICQ_STATUS_IMG'      => $user_cache[$poster_id]['icq_status_img'],

      'ONLINE_IMG'         => ($poster_id == ANONYMOUS || !$config['load_onlinetrack']) ? '' : (($user_cache[$poster_id]['online']) ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')),

      'S_ONLINE'            => ($poster_id == ANONYMOUS || !$config['load_onlinetrack']) ? false : (($user_cache[$poster_id]['online']) ? true : false),







      'U_EDIT'         => ($edit_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=edit&amp;f=$forum_id&amp;p={$row['post_id']}") : '',

      'U_QUOTE'         => ($auth->acl_get('f_reply', $forum_id)) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=quote&amp;f=$forum_id&amp;p={$row['post_id']}") : '',

      'U_INFO'         => ($auth->acl_get('m_info', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&amp;mode=post_details&amp;f=$forum_id&amp;p=" . $row['post_id'], true, $user->session_id) : '',

      'U_DELETE'         => ($delete_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=delete&amp;f=$forum_id&amp;p={$row['post_id']}") : '',



      'U_PROFILE'      => $user_cache[$poster_id]['profile'],

      'U_SEARCH'      => $user_cache[$poster_id]['search'],

      

    'S_USERID_BANNED' => (in_array($poster_id, $ban_list)) ? true : false,      



      'U_PM'         => ($poster_id != ANONYMOUS && $config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($user_cache[$poster_id]['allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;mode=compose&amp;action=quotepost&amp;p=' . $row['post_id']) : '',

      'U_EMAIL'      => $user_cache[$poster_id]['email'],

      'U_WWW'         => $user_cache[$poster_id]['www'],

      'U_ICQ'         => $user_cache[$poster_id]['icq'],

      'U_AIM'         => $user_cache[$poster_id]['aim'],

      'U_MSN'         => $user_cache[$poster_id]['msn'],

      'U_YIM'         => $user_cache[$poster_id]['yim'],

      'U_JABBER'      => $user_cache[$poster_id]['jabber'],

      'U_GALLERY'         => $user_cache[$poster_id]['gallery_album'],
      'GALLERY_IMAGES'   => $user_cache[$poster_id]['gallery_images'],
      'U_GALLERY_SEARCH'   => $user_cache[$poster_id]['gallery_search'],





      'U_REPORT'         => ($auth->acl_get('f_report', $forum_id)) ? append_sid("{$phpbb_root_path}report.$phpEx", 'f=' . $forum_id . '&amp;p=' . $row['post_id']) : '',

      'U_MCP_REPORT'      => ($auth->acl_get('m_report', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&amp;mode=report_details&amp;f=' . $forum_id . '&amp;p=' . $row['post_id'], true, $user->session_id) : '',

      'U_MCP_APPROVE'      => ($auth->acl_get('m_approve', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=approve_details&amp;f=' . $forum_id . '&amp;p=' . $row['post_id'], true, $user->session_id) : '',

      'U_MINI_POST'      => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['post_id']) . (($topic_data['topic_type'] == POST_GLOBAL) ? '&amp;f=' . $forum_id : '') . '#p' . $row['post_id'],

      'U_NEXT_POST_ID'   => ($i < $i_total && isset($rowset[$post_list[$i + 1]])) ? $rowset[$post_list[$i + 1]]['post_id'] : '',

      'U_PREV_POST_ID'   => $prev_post_id,

      'U_NOTES'         => ($auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&amp;mode=user_notes&amp;u=' . $poster_id, true, $user->session_id) : '',

      'U_WARN'         => ($auth->acl_get('m_warn') && $poster_id != $user->data['user_id'] && $poster_id != ANONYMOUS) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&amp;mode=warn_post&amp;f=' . $forum_id . '&amp;p=' . $row['post_id'], true, $user->session_id) : '',







      'POST_ID'         => $row['post_id'],

      'POSTER_ID'         => $poster_id,







      'S_HAS_ATTACHMENTS'   => (!empty($attachments[$row['post_id']])) ? true : false,

      'S_POST_UNAPPROVED'   => ($row['post_approved']) ? false : true,

      'S_POST_REPORTED'   => ($row['post_reported'] && $auth->acl_get('m_report', $forum_id)) ? true : false,

      'S_DISPLAY_NOTICE'   => $display_notice && $row['post_attachment'],

      'S_FRIEND'         => ($row['friend']) ? true : false,

      'S_UNREAD_POST'      => $post_unread,

      'S_FIRST_UNREAD'   => $s_first_unread,

      'S_CUSTOM_FIELDS'   => (isset($cp_row['row']) && sizeof($cp_row['row'])) ? true : false,

      'S_TOPIC_POSTER'   => ($topic_data['topic_poster'] == $poster_id) ? true : false,







      'S_IGNORE_POST'      => ($row['hide_post']) ? true : false,

      'L_IGNORE_POST'      => ($row['hide_post']) ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), '<a href="' . $viewtopic_url . "&amp;p={$row['post_id']}&amp;view=show#p{$row['post_id']}" . '">', '</a>') : '',

      'S_FORUM_THANKS'   => ($auth->acl_get('f_thanks', $forum_id)) ? true : false,



   );
     $postrow['U_FACEBOOK'] = $user_cache[$poster_id]['facebook'];




   output_thanks($row['user_id']);

   if (isset($cp_row['row']) && sizeof($cp_row['row']))

   {

      $postrow = array_merge($postrow, $cp_row['row']);

   }



  $postrow['S_POST_NUM'] = $start + ($i+1);



//-- mod: Prime Trash Bin (Posts) -------------------------------------------//

// Set up what we're going to display for the deleted message.

   if (!empty($row['post_deleted_time']))

   {

      include ($phpbb_root_path . 'includes/prime_trash_bin.' . $phpEx);

      set_stifled_post_template_vars($row, $message, $row['post_subject'], $postrow);

   }

   // If there is only one post, and the topic has been deleted, then only display the delete icon if user can permanently delete the topic.

   if ($topic_data['topic_first_post_id'] == $topic_data['topic_last_post_id'] && $topic_data['topic_deleted_time'])

   {

      $postrow['U_DELETE'] = auth_fake_delete('delete', isset($topic_data['forum_id'])) ? $postrow['U_DELETE'] : '';

   }

//-- end: Prime Trash Bin (Posts) -------------------------------------------//



   // Dump vars into template

   $template->assign_block_vars('postrow', $postrow);







   if (!empty($cp_row['blockrow']))

   {

      foreach ($cp_row['blockrow'] as $field_data)

      {

         $template->assign_block_vars('postrow.custom_fields', $field_data);

      }

   }



   //added by Nyquist Show Groups Info

   //check the system var:

   if (isset($config['nyq_showgroupsinfo']))

   {

      if (isset($user_cache[$poster_id]['nyq_showgroupsinfo']))

      {

         foreach ($user_cache[$poster_id]['nyq_showgroupsinfo'] as $single_rank)

         {

            $nyq_listofranks = array(

               'TITLE' => $single_rank['TITLE'],

               'IMAGE' => $single_rank['IMAGE'],

            );

            $template->assign_block_vars('postrow.nyq_listofranks', $nyq_listofranks);

         }

      }

   }

   //end added by Nyquist Show Groups Info



       



   // Display not already displayed Attachments for this post, we already parsed them. ;)

   if (!empty($attachments[$row['post_id']]))

   {

      foreach ($attachments[$row['post_id']] as $attachment)

      {

         $template->assign_block_vars('postrow.attachment', array(

            'DISPLAY_ATTACHMENT'   => $attachment)

         );

      }

   }

   if (isset($config['enable_status']))

{

         // status

      $sql = 'SELECT status_text

            FROM '.STATUS_TABLE.'

               WHERE user_id ='.intval($poster_id).' ORDER BY status_time DESC';

            $result = $db->sql_query_limit($sql, 1);

      

            while($row = $db->sql_fetchrow( $result )) {

            $template->assign_block_vars('postrow.stat', array(   

                                       

               'STATUS'         => $row['status_text'],

      ));

   }

}







   $prev_post_id = $row['post_id'];

   //-- mod: Prime Multi-Quote -------------------------------------------------//

   $prime_multi_quote_count = !isset($prime_multi_quote_count) ? 1 : ($prime_multi_quote_count + (empty($row['post_deleted_time']) ? 1 : 0));

//-- end: Prime Multi-Quote -------------------------------------------------//







   unset($rowset[$post_list[$i]]);

   unset($attachments[$row['post_id']]);

}

unset($rowset, $user_cache);







// Update topic view and if necessary attachment view counters ... but only for humans and if this is the first 'page view'



if (isset($user->data['session_page']) && !$user->data['is_bot'] && strpos($user->data['session_page'], '&t=' . $topic_id) === false)



{

   $sql = 'UPDATE ' . TOPICS_TABLE . '

      SET topic_views = topic_views + 1, topic_last_view_time = ' . time() . "

      WHERE topic_id = $topic_id";

   $db->sql_query($sql);







   // Update the attachment download counts

   if (sizeof($update_count))

   {

      $sql = 'UPDATE ' . ATTACHMENTS_TABLE . '

         SET download_count = download_count + 1

         WHERE ' . $db->sql_in_set('attach_id', array_unique($update_count));

      $db->sql_query($sql);

   }

}



// Get last post time for all global announcements

// to keep proper forums tracking

if ($topic_data['topic_type'] == POST_GLOBAL)

{

   $sql = 'SELECT topic_last_post_time as forum_last_post_time

      FROM ' . TOPICS_TABLE . '

      WHERE forum_id = 0

      ORDER BY topic_last_post_time DESC';

   $result = $db->sql_query_limit($sql, 1);

   $topic_data['forum_last_post_time'] = (int) $db->sql_fetchfield('forum_last_post_time');

   $db->sql_freeresult($result);



   $sql = 'SELECT mark_time as forum_mark_time

      FROM ' . FORUMS_TRACK_TABLE . '

      WHERE forum_id = 0

         AND user_id = ' . $user->data['user_id'];

   $result = $db->sql_query($sql);

   $topic_data['forum_mark_time'] = (int) $db->sql_fetchfield('forum_mark_time');

   $db->sql_freeresult($result);

}







// Only mark topic if it's currently unread. Also make sure we do not set topic tracking back if earlier pages are viewed.

if (isset($topic_tracking_info[$topic_id]) && $topic_data['topic_last_post_time'] > $topic_tracking_info[$topic_id] && $max_post_time > $topic_tracking_info[$topic_id])

{

   markread('topic', (($topic_data['topic_type'] == POST_GLOBAL) ? 0 : $forum_id), $topic_id, $max_post_time);



   // Update forum info

   $all_marked_read = update_forum_tracking_info((($topic_data['topic_type'] == POST_GLOBAL) ? 0 : $forum_id), $topic_data['forum_last_post_time'], (isset($topic_data['forum_mark_time'])) ? $topic_data['forum_mark_time'] : false, false);

}

else

{

   $all_marked_read = true;

}







// If there are absolutely no more unread posts in this forum and unread posts shown, we can savely show the #unread link

if ($all_marked_read)

{

   if ($post_unread)

   {

      $template->assign_vars(array(

         'U_VIEW_UNREAD_POST'   => '#unread',

      ));

   }

   else if (isset($topic_tracking_info[$topic_id]) && $topic_data['topic_last_post_time'] > $topic_tracking_info[$topic_id])

   {

      $template->assign_vars(array(

         'U_VIEW_UNREAD_POST'   => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;view=unread") . '#unread',

      ));

   }

}

else if (!$all_marked_read)

{

   $last_page = ((floor($start / $config['posts_per_page']) + 1) == max(ceil($total_posts / $config['posts_per_page']), 1)) ? true : false;







   // What can happen is that we are at the last displayed page. If so, we also display the #unread link based in $post_unread

   if ($last_page && $post_unread)

   {

      $template->assign_vars(array(

         'U_VIEW_UNREAD_POST'   => '#unread',

      ));

   }

   else if (!$last_page)

   {

      $template->assign_vars(array(

         'U_VIEW_UNREAD_POST'   => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;view=unread") . '#unread',

      ));

   }

}



// let's set up quick_reply

$s_allowed_reply = ((!$auth->acl_get('f_reply', $forum_id) || ($topic_data['forum_status'] == ITEM_LOCKED) || ($topic_data['topic_status'] == ITEM_LOCKED)) && !$auth->acl_get('m_edit', $forum_id)) ? false : true;

$s_quick_reply = $s_allowed_reply && $user->data['is_registered'] && $config['allow_quick_reply'] && ($topic_data['forum_flags'] & FORUM_FLAG_QUICK_REPLY);



if ($s_can_vote || $s_quick_reply)

{

   add_form_key('posting');



   if ($s_quick_reply)

   {
      $user->add_lang(array('posting', 'mcp'));
      $s_attach_sig   = $config['allow_sig'] && $user->optionget('attachsig') && $auth->acl_get('f_sigs', $forum_id) && $auth->acl_get('u_sig');

      $s_smilies      = $config['allow_smilies'] && $user->optionget('smilies') && $auth->acl_get('f_smilies', $forum_id);

      $s_bbcode      = $config['allow_bbcode'] && $user->optionget('bbcode') && $auth->acl_get('f_bbcode', $forum_id);

      $s_notify      = $config['allow_topic_notify'] && $user->data['user_notify'];
      $s_url         = $config['allow_post_links'];
      $s_img         = $s_bbcode && $auth->acl_get('f_img', $forum_id);
      $s_flash      = $s_bbcode && $auth->acl_get('f_flash', $forum_id) && $config['allow_post_flash'];
      $s_topic_icons   = false;

      if ($topic_data['enable_icons'] && $auth->acl_get('f_icons', $forum_id))
      {
         $s_topic_icons = posting_gen_topic_icons('reply', $topic_data['icon_id']);
      }


      $qr_hidden_fields = array(

         'topic_cur_post_id'      => (int) $topic_data['topic_last_post_id'],

         'lastclick'            => (int) time(),

         'topic_id'            => (int) $topic_data['topic_id'],

         'forum_id'            => (int) $forum_id,

      );



      // Originally we use checkboxes and check with isset(), so we only provide them if they would be checked

      (!$s_bbcode)               ? $qr_hidden_fields['disable_bbcode'] = 1      : true;

      (!$s_smilies)               ? $qr_hidden_fields['disable_smilies'] = 1      : true;

      (!$config['allow_post_links'])   ? $qr_hidden_fields['disable_magic_url'] = 1   : true;

      ($s_attach_sig)               ? $qr_hidden_fields['attach_sig'] = 1         : true;

      ($s_notify)                  ? $qr_hidden_fields['notify'] = 1            : true;

      ($topic_data['topic_status'] == ITEM_LOCKED) ? $qr_hidden_fields['lock_topic'] = 1 : true;



      $template->assign_vars(array(
         'L_ICON'               => $user->lang['POST_ICON'],
         'L_MESSAGE_BODY_EXPLAIN'   => (intval($config['max_post_chars'])) ? sprintf($user->lang['MESSAGE_BODY_EXPLAIN'], intval($config['max_post_chars'])) : '',

         'SUBJECT'            => 'Re: ' . censor_text($topic_data['topic_title']),
         'BBCODE_STATUS'         => ($s_bbcode) ? sprintf($user->lang['BBCODE_IS_ON'], '<a href="' . append_sid("{$phpbb_root_path}faq.$phpEx", 'mode=bbcode') . '">', '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], '<a href="' . append_sid("{$phpbb_root_path}faq.$phpEx", 'mode=bbcode') . '">', '</a>'),
         'IMG_STATUS'         => ($s_img) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'],
         'FLASH_STATUS'         => ($s_flash) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'],
         'SMILIES_STATUS'      => ($s_smilies) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'],
         'URL_STATUS'         => ($s_bbcode && $s_url) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'],
         'U_QR_ACTION'         => append_sid("{$phpbb_root_path}posting.$phpEx", "mode=reply&amp;f=$forum_id&amp;t=$topic_id"),
         'QR_HIDDEN_FIELDS'      => build_hidden_fields($qr_hidden_fields),

         'S_QUICK_REPLY'         => true,
         'S_SHOW_TOPIC_ICONS'   => $s_topic_icons,
         'S_BBCODE_ALLOWED'      => $s_bbcode,
         'S_SMILIES_ALLOWED'      => $s_smilies,
         'S_LINKS_ALLOWED'      => $s_url,
         'S_SAVE_ALLOWED'      => ($auth->acl_get('u_savedrafts') && $user->data['is_registered']) ? true : false,
         
         'S_BBCODE_IMG'         => $s_img,
         'S_BBCODE_URL'         => $s_url,
         'S_BBCODE_FLASH'      => $s_flash,
         'S_BBCODE_QUOTE'      => true,
      ));

      // Build custom bbcodes array
      display_custom_bbcodes();

      // Generate smiley listing
      generate_smilies('inline', $forum_id);

   }

}

// now I have the urge to wash my hands :(





// We overwrite $_REQUEST['f'] if there is no forum specified

// to be able to display the correct online list.

// One downside is that the user currently viewing this topic/post is not taken into account.

if (empty($_REQUEST['f']))

{

   $_REQUEST['f'] = $forum_id;

}



//-- mod: Prime Trash Bin (Topics) ------------------------------------------//

if ($topic_deleted)

{

   $template_vars = set_stifled_topic_template_vars($topic_data, $topic_data['topic_title'], ($blockname = true));



   // This will become the page's title (in the browser's title bar).

   $topic_data['topic_title'] = $template_vars['TOPIC_TITLE'];

}

//-- end: Prime Trash Bin (Topics) ------------------------------------------//



// Output the page

page_header($user->lang['VIEW_TOPIC'] . ' - ' . $topic_data['topic_title'], true, $forum_id);



$template->set_filenames(array(

   'body' => ($view == 'print') ? 'viewtopic_print.html' : 'viewtopic_body.html')

);

make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"), $forum_id);

//-- mod: Prime Multi-Quote -------------------------------------------------//

// Multi-Quote is active if there is more than one quotable post and the user is able to reply (and user is not a bot).

if (isset($prime_multi_quote_count) && $prime_multi_quote_count > 1 && $template->_rootref['S_DISPLAY_REPLY_INFO'] && !$user->data['is_bot'])

{

   $template->assign_var('PRIME_MULTI_QUOTE', $prime_multi_quote_count);

}

//-- end: Prime Multi-Quote -------------------------------------------------//







include($phpbb_root_path . 'includes/functions_quick_reply.' . $phpEx);



quick_reply($topic_id, $forum_id, $topic_data);







page_footer();







?>


I'd really appreciate it if someone could help me through this please.

Thank you
by brett05
Thu Jun 24, 2010 11:37 pm

Re: Unable to install via AutoMod

Code: Select all

<?php
/**
*
* @package phpBB3
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);

// Initial var setup
$forum_id   = request_var('f', 0);
$topic_id   = request_var('t', 0);
$post_id   = request_var('p', 0);
$voted_id   = request_var('vote_id', array('' => 0));

$voted_id = (sizeof($voted_id) > 1) ? array_unique($voted_id) : $voted_id;


$start      = request_var('start', 0);
$view      = request_var('view', '');

$default_sort_days   = (!empty($user->data['user_post_show_days'])) ? $user->data['user_post_show_days'] : 0;
$default_sort_key   = (!empty($user->data['user_post_sortby_type'])) ? $user->data['user_post_sortby_type'] : 't';
$default_sort_dir   = (!empty($user->data['user_post_sortby_dir'])) ? $user->data['user_post_sortby_dir'] : 'a';

$sort_days   = request_var('st', $default_sort_days);
$sort_key   = request_var('sk', $default_sort_key);
$sort_dir   = request_var('sd', $default_sort_dir);

$update      = request_var('update', false);

$s_can_vote = false;
/**
* @todo normalize?
*/
$hilit_words   = request_var('hilit', '', true);

// Do we have a topic or post id?
if (!$topic_id && !$post_id)
{
   trigger_error('NO_TOPIC');
}

// Find topic id if user requested a newer or older topic
if ($view && !$post_id)
{
   if (!$forum_id)
   {
      $sql = 'SELECT forum_id
         FROM ' . TOPICS_TABLE . "
         WHERE topic_id = $topic_id";
      $result = $db->sql_query($sql);
      $forum_id = (int) $db->sql_fetchfield('forum_id');
      $db->sql_freeresult($result);

      if (!$forum_id)
      {
         trigger_error('NO_TOPIC');
      }
   }

   if ($view == 'unread')
   {
      // Get topic tracking info
      $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id);

      $topic_last_read = (isset($topic_tracking_info[$topic_id])) ? $topic_tracking_info[$topic_id] : 0;

      $sql = 'SELECT post_id, topic_id, forum_id
         FROM ' . POSTS_TABLE . "
         WHERE topic_id = $topic_id
            " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND post_approved = 1') . "
            AND post_time > $topic_last_read
            AND forum_id = $forum_id
         ORDER BY post_time ASC";
      $result = $db->sql_query_limit($sql, 1);
      $row = $db->sql_fetchrow($result);
      $db->sql_freeresult($result);

      if (!$row)
      {
         $sql = 'SELECT topic_last_post_id as post_id, topic_id, forum_id
            FROM ' . TOPICS_TABLE . '
            WHERE topic_id = ' . $topic_id;
         $result = $db->sql_query($sql);
         $row = $db->sql_fetchrow($result);
         $db->sql_freeresult($result);
      }

      if (!$row)
      {
         // Setup user environment so we can process lang string
         $user->setup('viewtopic');

         trigger_error('NO_TOPIC');
      }

      $post_id = $row['post_id'];
      $topic_id = $row['topic_id'];
   }
   else if ($view == 'next' || $view == 'previous')
   {
      $sql_condition = ($view == 'next') ? '>' : '<';
      $sql_ordering = ($view == 'next') ? 'ASC' : 'DESC';

      $sql = 'SELECT forum_id, topic_last_post_time
         FROM ' . TOPICS_TABLE . '
         WHERE topic_id = ' . $topic_id;
      $result = $db->sql_query($sql);
      $row = $db->sql_fetchrow($result);
      $db->sql_freeresult($result);

      if (!$row)
      {
         $user->setup('viewtopic');
         // OK, the topic doesn't exist. This error message is not helpful, but technically correct.
         trigger_error(($view == 'next') ? 'NO_NEWER_TOPICS' : 'NO_OLDER_TOPICS');
      }
      else
      {
         $sql = 'SELECT topic_id, forum_id
            FROM ' . TOPICS_TABLE . '
            WHERE forum_id = ' . $row['forum_id'] . "
               AND topic_moved_id = 0
               AND topic_last_post_time $sql_condition {$row['topic_last_post_time']}
               " . (($auth->acl_get('m_approve', $row['forum_id'])) ? '' : 'AND topic_approved = 1') . "
            ORDER BY topic_last_post_time $sql_ordering";
         $result = $db->sql_query_limit($sql, 1);
         $row = $db->sql_fetchrow($result);
         $db->sql_freeresult($result);

         if (!$row)
         {
            $user->setup('viewtopic');
            trigger_error(($view == 'next') ? 'NO_NEWER_TOPICS' : 'NO_OLDER_TOPICS');
         }
         else
         {
            $topic_id = $row['topic_id'];

            // Check for global announcement correctness?
            if (!$row['forum_id'] && !$forum_id)
            {
               trigger_error('NO_TOPIC');
            }
            else if ($row['forum_id'])
            {
               $forum_id = $row['forum_id'];
            }
         }
      }
   }

   // Check for global announcement correctness?
   if ((!isset($row) || !$row['forum_id']) && !$forum_id)
   {
      trigger_error('NO_TOPIC');
   }
   else if (isset($row) && $row['forum_id'])
   {
      $forum_id = $row['forum_id'];
   }
}

// This rather complex gaggle of code handles querying for topics but
// also allows for direct linking to a post (and the calculation of which
// page the post is on and the correct display of viewtopic)
$sql_array = array(
   'SELECT'   => 't.*, f.*',

   'FROM'      => array(FORUMS_TABLE => 'f'),
);

// Firebird handles two columns of the same name a little differently, this
// addresses that by forcing the forum_id to come from the forums table.
if ($db->sql_layer === 'firebird')
{
   $sql_array['SELECT'] = 'f.forum_id AS forum_id, ' . $sql_array['SELECT'];
}

// The FROM-Order is quite important here, else t.* columns can not be correctly bound.
if ($post_id)
{
   $sql_array['SELECT'] .= ', p.post_approved';
   $sql_array['FROM'][POSTS_TABLE] = 'p';
}

// Topics table need to be the last in the chain
$sql_array['FROM'][TOPICS_TABLE] = 't';

if ($user->data['is_registered'])
{
   $sql_array['SELECT'] .= ', tw.notify_status';
   $sql_array['LEFT_JOIN'] = array();

   $sql_array['LEFT_JOIN'][] = array(
      'FROM'   => array(TOPICS_WATCH_TABLE => 'tw'),
      'ON'   => 'tw.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tw.topic_id'
   );

   if ($config['allow_bookmarks'])
   {
      $sql_array['SELECT'] .= ', bm.topic_id as bookmarked';
      $sql_array['LEFT_JOIN'][] = array(
         'FROM'   => array(BOOKMARKS_TABLE => 'bm'),
         'ON'   => 'bm.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = bm.topic_id'
      );
   }

   if ($config['load_db_lastread'])
   {
      $sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time as forum_mark_time';

      $sql_array['LEFT_JOIN'][] = array(
         'FROM'   => array(TOPICS_TRACK_TABLE => 'tt'),
         'ON'   => 'tt.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tt.topic_id'
      );

      $sql_array['LEFT_JOIN'][] = array(
         'FROM'   => array(FORUMS_TRACK_TABLE => 'ft'),
         'ON'   => 'ft.user_id = ' . $user->data['user_id'] . ' AND t.forum_id = ft.forum_id'
      );
   }
}

if (!$post_id)
{
   $sql_array['WHERE'] = "t.topic_id = $topic_id";
}
else
{
   $sql_array['WHERE'] = "p.post_id = $post_id AND t.topic_id = p.topic_id";
}

$sql_array['WHERE'] .= ' AND (f.forum_id = t.forum_id';

if (!$forum_id)
{
   // If it is a global announcement make sure to set the forum id to a postable forum
   $sql_array['WHERE'] .= ' OR (t.topic_type = ' . POST_GLOBAL . '
      AND f.forum_type = ' . FORUM_POST . ')';
}
else
{
   $sql_array['WHERE'] .= ' OR (t.topic_type = ' . POST_GLOBAL . "
      AND f.forum_id = $forum_id)";
}

$sql_array['WHERE'] .= ')';

// Join to forum table on topic forum_id unless topic forum_id is zero
// whereupon we join on the forum_id passed as a parameter ... this
// is done so navigation, forum name, etc. remain consistent with where
// user clicked to view a global topic
$sql = $db->sql_build_query('SELECT', $sql_array);
$result = $db->sql_query($sql);
$topic_data = $db->sql_fetchrow($result);
$db->sql_freeresult($result);

// link to unapproved post or incorrect link
if (!$topic_data)
{
   // If post_id was submitted, we try at least to display the topic as a last resort...
   if ($post_id && $topic_id)
   {
      redirect(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=$topic_id" . (($forum_id) ? "&amp;f=$forum_id" : '')));
   }

   trigger_error('NO_TOPIC');
}

$forum_id = (int) $topic_data['forum_id'];
// This is for determining where we are (page)
if ($post_id)
{
   // are we where we are supposed to be?
   if (!$topic_data['post_approved'] && !$auth->acl_get('m_approve', $topic_data['forum_id']))
   {
      // If post_id was submitted, we try at least to display the topic as a last resort...
      if ($topic_id)
      {
         redirect(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=$topic_id" . (($forum_id) ? "&amp;f=$forum_id" : '')));
      }

      trigger_error('NO_TOPIC');
   }
   if ($post_id == $topic_data['topic_first_post_id'] || $post_id == $topic_data['topic_last_post_id'])
   {
      $check_sort = ($post_id == $topic_data['topic_first_post_id']) ? 'd' : 'a';

      if ($sort_dir == $check_sort)
      {
         $topic_data['prev_posts'] = ($auth->acl_get('m_approve', $forum_id)) ? $topic_data['topic_replies_real'] : $topic_data['topic_replies'];
      }
      else
      {
         $topic_data['prev_posts'] = 0;
      }
   }
   else
   {
      $sql = 'SELECT COUNT(p1.post_id) AS prev_posts
         FROM ' . POSTS_TABLE . ' p1, ' . POSTS_TABLE . " p2
         WHERE p1.topic_id = {$topic_data['topic_id']}
            AND p2.post_id = {$post_id}
            " . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND p1.post_approved = 1' : '') . '
            AND ' . (($sort_dir == 'd') ? 'p1.post_time >= p2.post_time' : 'p1.post_time <= p2.post_time');

      $result = $db->sql_query($sql);
      $row = $db->sql_fetchrow($result);
      $db->sql_freeresult($result);

      $topic_data['prev_posts'] = $row['prev_posts'] - 1;
   }
}

$topic_id = (int) $topic_data['topic_id'];
//
$topic_replies = ($auth->acl_get('m_approve', $forum_id)) ? $topic_data['topic_replies_real'] : $topic_data['topic_replies'];

// Check sticky/announcement time limit
if (($topic_data['topic_type'] == POST_STICKY || $topic_data['topic_type'] == POST_ANNOUNCE) && $topic_data['topic_time_limit'] && ($topic_data['topic_time'] + $topic_data['topic_time_limit']) < time())
{
   $sql = 'UPDATE ' . TOPICS_TABLE . '
      SET topic_type = ' . POST_NORMAL . ', topic_time_limit = 0
      WHERE topic_id = ' . $topic_id;
   $db->sql_query($sql);

   $topic_data['topic_type'] = POST_NORMAL;
   $topic_data['topic_time_limit'] = 0;
}

// Setup look and feel
$user->setup('viewtopic', $topic_data['forum_style']);

if (!$topic_data['topic_approved'] && !$auth->acl_get('m_approve', $forum_id))
{
   trigger_error('NO_TOPIC');
}

// Start auth check
if (!$auth->acl_get('f_read', $forum_id))
{
   if ($user->data['user_id'] != ANONYMOUS)
   {
      trigger_error('SORRY_AUTH_READ');
   }

   login_box('', $user->lang['LOGIN_VIEWFORUM']);
}

// Forum is passworded ... check whether access has been granted to this
// user this session, if not show login box
if ($topic_data['forum_password'])
{
   login_forum_box($topic_data);
}

// Redirect to login or to the correct post upon emailed notification links
if (isset($_GET['e']))
{
   $jump_to = request_var('e', 0);

   $redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id");

   if ($user->data['user_id'] == ANONYMOUS)
   {
      login_box($redirect_url . "&amp;p=$post_id&amp;e=$jump_to", $user->lang['LOGIN_NOTIFY_TOPIC']);
   }

   if ($jump_to > 0)
   {
      // We direct the already logged in user to the correct post...
      redirect($redirect_url . ((!$post_id) ? "&amp;p=$jump_to" : "&amp;p=$post_id") . "#p$jump_to");
   }
}

// What is start equal to?
if ($post_id)
{
   $start = floor(($topic_data['prev_posts']) / $config['posts_per_page']) * $config['posts_per_page'];
}

// Get topic tracking info
if (!isset($topic_tracking_info))
{
   $topic_tracking_info = array();

   // Get topic tracking info
   if ($config['load_db_lastread'] && $user->data['is_registered'])
   {
      $tmp_topic_data = array($topic_id => $topic_data);
      $topic_tracking_info = get_topic_tracking($forum_id, $topic_id, $tmp_topic_data, array($forum_id => $topic_data['forum_mark_time']));
      unset($tmp_topic_data);
   }
   else if ($config['load_anon_lastread'] || $user->data['is_registered'])
   {
      $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id);
   }
}

// Post ordering options
$limit_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_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']);
$sort_by_sql = array('a' => array('u.username_clean', 'p.post_id'), 't' => 'p.post_time', 's' => array('p.post_subject', 'p.post_id'));
$join_user_sql = array('a' => true, 't' => false, 's' => false);

$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, $default_sort_days, $default_sort_key, $default_sort_dir);

// Obtain correct post count and ordering SQL if user has
// requested anything different
if ($sort_days)
{
   $min_post_time = time() - ($sort_days * 86400);

   $sql = 'SELECT COUNT(post_id) AS num_posts
      FROM ' . POSTS_TABLE . "
      WHERE topic_id = $topic_id
         AND post_time >= $min_post_time
      " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND post_approved = 1');
   $result = $db->sql_query($sql);
   $total_posts = (int) $db->sql_fetchfield('num_posts');
   $db->sql_freeresult($result);

   $limit_posts_time = "AND p.post_time >= $min_post_time ";

   if (isset($_POST['sort']))
   {
      $start = 0;
   }
}
else
{
   $total_posts = $topic_replies + 1;
   $limit_posts_time = '';
}

// Was a highlight request part of the URI?
$highlight_match = $highlight = '';
if ($hilit_words)
{
   foreach (explode(' ', trim($hilit_words)) as $word)
   {
      if (trim($word))
      {
         $word = str_replace('\*', '\w+?', preg_quote($word, '#'));
         $word = preg_replace('#(^|\s)\\\\w\*\?(\s|$)#', '$1\w+?$2', $word);
         $highlight_match .= (($highlight_match != '') ? '|' : '') . $word;
      }
   }

   $highlight = urlencode($hilit_words);
}

// Make sure $start is set to the last page if it exceeds the amount
if ($start < 0 || $start >= $total_posts)
{
   $start = ($start < 0) ? 0 : floor(($total_posts - 1) / $config['posts_per_page']) * $config['posts_per_page'];
}

// General Viewtopic URL for return links
$viewtopic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;start=$start" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : '') . (($highlight_match) ? "&amp;hilit=$highlight" : ''));

// Are we watching this topic?
$s_watching_topic = array(
   'link'         => '',
   'title'         => '',
   'is_watching'   => false,
);

if (($config['email_enable'] || $config['jab_enable']) && $config['allow_topic_notify'] && $user->data['is_registered'])
{
   watch_topic_forum('topic', $s_watching_topic, $user->data['user_id'], $forum_id, $topic_id, $topic_data['notify_status'], $start);

   // Reset forum notification if forum notify is set
   if ($config['allow_forum_notify'] && $auth->acl_get('f_subscribe', $forum_id))
   {
      $s_watching_forum = $s_watching_topic;
      watch_topic_forum('forum', $s_watching_forum, $user->data['user_id'], $forum_id, 0);
   }
}

// Bookmarks
if ($config['allow_bookmarks'] && $user->data['is_registered'] && request_var('bookmark', 0))
{
   if (check_link_hash(request_var('hash', ''), "topic_$topic_id"))
   {
      if (!$topic_data['bookmarked'])
      {
         $sql = 'INSERT INTO ' . BOOKMARKS_TABLE . ' ' . $db->sql_build_array('INSERT', array(
            'user_id'   => $user->data['user_id'],
            'topic_id'   => $topic_id,
         ));
         $db->sql_query($sql);
      }
      else
      {
         $sql = 'DELETE FROM ' . BOOKMARKS_TABLE . "
            WHERE user_id = {$user->data['user_id']}
               AND topic_id = $topic_id";
         $db->sql_query($sql);
      }
      $message = (($topic_data['bookmarked']) ? $user->lang['BOOKMARK_REMOVED'] : $user->lang['BOOKMARK_ADDED']) . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $viewtopic_url . '">', '</a>');
   }
   else
   {
      $message = $user->lang['BOOKMARK_ERR'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $viewtopic_url . '">', '</a>');
   }
   meta_refresh(3, $viewtopic_url);

   trigger_error($message);
}

// Grab ranks
$ranks = $cache->obtain_ranks();

// Grab icons
$icons = $cache->obtain_icons();

// Grab extensions
$extensions = array();
if ($topic_data['topic_attachment'])
{
   $extensions = $cache->obtain_attach_extensions($forum_id);
}

// Forum rules listing
$s_forum_rules = '';
gen_forum_auth_level('topic', $forum_id, $topic_data['forum_status']);

// Quick mod tools
$allow_change_type = ($auth->acl_get('m_', $forum_id) || ($user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'])) ? true : false;

$topic_mod = '';
$topic_mod .= ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'] && $topic_data['topic_status'] == ITEM_UNLOCKED)) ? (($topic_data['topic_status'] == ITEM_UNLOCKED) ? '<option value="lock">' . $user->lang['LOCK_TOPIC'] . '</option>' : '<option value="unlock">' . $user->lang['UNLOCK_TOPIC'] . '</option>') : '';
$topic_mod .= ($auth->acl_get('m_delete', $forum_id)) ? '<option value="delete_topic">' . $user->lang['DELETE_TOPIC'] . '</option>' : '';
$topic_mod .= ($auth->acl_get('m_move', $forum_id) && $topic_data['topic_status'] != ITEM_MOVED) ? '<option value="move">' . $user->lang['MOVE_TOPIC'] . '</option>' : '';
$topic_mod .= ($auth->acl_get('m_split', $forum_id)) ? '<option value="split">' . $user->lang['SPLIT_TOPIC'] . '</option>' : '';
$topic_mod .= ($auth->acl_get('m_merge', $forum_id)) ? '<option value="merge">' . $user->lang['MERGE_POSTS'] . '</option>' : '';
$topic_mod .= ($auth->acl_get('m_merge', $forum_id)) ? '<option value="merge_topic">' . $user->lang['MERGE_TOPIC'] . '</option>' : '';
$topic_mod .= ($auth->acl_get('m_move', $forum_id)) ? '<option value="fork">' . $user->lang['FORK_TOPIC'] . '</option>' : '';
$topic_mod .= ($allow_change_type && $auth->acl_gets('f_sticky', 'f_announce', $forum_id) && $topic_data['topic_type'] != POST_NORMAL) ? '<option value="make_normal">' . $user->lang['MAKE_NORMAL'] . '</option>' : '';
$topic_mod .= ($allow_change_type && $auth->acl_get('f_sticky', $forum_id) && $topic_data['topic_type'] != POST_STICKY) ? '<option value="make_sticky">' . $user->lang['MAKE_STICKY'] . '</option>' : '';
$topic_mod .= ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_ANNOUNCE) ? '<option value="make_announce">' . $user->lang['MAKE_ANNOUNCE'] . '</option>' : '';
$topic_mod .= ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_GLOBAL) ? '<option value="make_global">' . $user->lang['MAKE_GLOBAL'] . '</option>' : '';
$topic_mod .= ($auth->acl_get('m_', $forum_id)) ? '<option value="topic_logs">' . $user->lang['VIEW_TOPIC_LOGS'] . '</option>' : '';

// If we've got a hightlight set pass it on to pagination.
$pagination = generate_pagination(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : '') . (($highlight_match) ? "&amp;hilit=$highlight" : '')), $total_posts, $config['posts_per_page'], $start);

// Navigation links
generate_forum_nav($topic_data);

// Forum Rules
generate_forum_rules($topic_data);

// Moderators
$forum_moderators = array();
if ($config['load_moderators'])
{
   get_moderators($forum_moderators, $forum_id);
}

// This is only used for print view so ...
$server_path = (!$view) ? $phpbb_root_path : generate_board_url() . '/';

// Replace naughty words in title
$topic_data['topic_title'] = censor_text($topic_data['topic_title']);

// Send vars to template
$template->assign_vars(array(
   'FORUM_ID'       => $forum_id,
   'FORUM_NAME'    => $topic_data['forum_name'],
   'FORUM_DESC'   => generate_text_for_display($topic_data['forum_desc'], $topic_data['forum_desc_uid'], $topic_data['forum_desc_bitfield'], $topic_data['forum_desc_options']),
   'TOPIC_ID'       => $topic_id,
   'TOPIC_TITLE'    => $topic_data['topic_title'],
   'TOPIC_POSTER'   => $topic_data['topic_poster'],

   'TOPIC_AUTHOR_FULL'      => get_username_string('full', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']),
   'TOPIC_AUTHOR_COLOUR'   => get_username_string('colour', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']),
   'TOPIC_AUTHOR'         => get_username_string('username', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']),

   'PAGINATION'    => $pagination,
   'PAGE_NUMBER'    => on_page($total_posts, $config['posts_per_page'], $start),
   'TOTAL_POSTS'   => ($total_posts == 1) ? $user->lang['VIEW_TOPIC_POST'] : sprintf($user->lang['VIEW_TOPIC_POSTS'], $total_posts),
   'U_MCP'       => ($auth->acl_get('m_', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&amp;mode=topic_view&amp;f=$forum_id&amp;t=$topic_id&amp;start=$start" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : ''), true, $user->session_id) : '',
   'MODERATORS'   => (isset($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id])) ? implode(', ', $forum_moderators[$forum_id]) : '',

   'POST_IMG'          => ($topic_data['forum_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', 'FORUM_LOCKED') : $user->img('button_topic_new', 'POST_NEW_TOPIC'),
   'QUOTE_IMG'       => $user->img('icon_post_quote', 'REPLY_WITH_QUOTE'),
   'REPLY_IMG'         => ($topic_data['forum_status'] == ITEM_LOCKED || $topic_data['topic_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', 'TOPIC_LOCKED') : $user->img('button_topic_reply', 'REPLY_TO_TOPIC'),
   'EDIT_IMG'          => $user->img('icon_post_edit', 'EDIT_POST'),
   'DELETE_IMG'       => $user->img('icon_post_delete', 'DELETE_POST'),
   'INFO_IMG'          => $user->img('icon_post_info', 'VIEW_INFO'),
   'PROFILE_IMG'      => $user->img('icon_user_profile', 'READ_PROFILE'),
   'SEARCH_IMG'       => $user->img('icon_user_search', 'SEARCH_USER_POSTS'),
   'PM_IMG'          => $user->img('icon_contact_pm', 'SEND_PRIVATE_MESSAGE'),
   'EMAIL_IMG'       => $user->img('icon_contact_email', 'SEND_EMAIL'),
   'WWW_IMG'          => $user->img('icon_contact_www', 'VISIT_WEBSITE'),
   'ICQ_IMG'          => $user->img('icon_contact_icq', 'ICQ'),
   'AIM_IMG'          => $user->img('icon_contact_aim', 'AIM'),
   'MSN_IMG'          => $user->img('icon_contact_msnm', 'MSNM'),
   'YIM_IMG'          => $user->img('icon_contact_yahoo', 'YIM'),
   'JABBER_IMG'      => $user->img('icon_contact_jabber', 'JABBER') ,
   'REPORT_IMG'      => $user->img('icon_post_report', 'REPORT_POST'),
   'REPORTED_IMG'      => $user->img('icon_topic_reported', 'POST_REPORTED'),
   'UNAPPROVED_IMG'   => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'),
   'WARN_IMG'         => $user->img('icon_user_warn', 'WARN_USER'),

   'S_IS_LOCKED'         => ($topic_data['topic_status'] == ITEM_UNLOCKED && $topic_data['forum_status'] == ITEM_UNLOCKED) ? false : true,
   'S_SELECT_SORT_DIR'    => $s_sort_dir,
   'S_SELECT_SORT_KEY'    => $s_sort_key,
   'S_SELECT_SORT_DAYS'    => $s_limit_days,
   'S_SINGLE_MODERATOR'   => (!empty($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id]) > 1) ? false : true,
   'S_TOPIC_ACTION'       => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;start=$start"),
   'S_TOPIC_MOD'          => ($topic_mod != '') ? '<select name="action" id="quick-mod-select">' . $topic_mod . '</select>' : '',
   'S_MOD_ACTION'          => append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;start=$start&amp;quickmod=1&amp;redirect=" . urlencode(str_replace('&amp;', '&', $viewtopic_url)), true, $user->session_id),

   'S_VIEWTOPIC'         => true,
   'S_DISPLAY_SEARCHBOX'   => ($auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search']) ? true : false,
   'S_SEARCHBOX_ACTION'   => append_sid("{$phpbb_root_path}search.$phpEx", 't=' . $topic_id),

   'S_DISPLAY_POST_INFO'   => ($topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS)) ? true : false,
   'S_DISPLAY_REPLY_INFO'   => ($topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_reply', $forum_id) || $user->data['user_id'] == ANONYMOUS)) ? true : false,
   'S_ENABLE_FEEDS_TOPIC'   => ($config['feed_topic'] && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $topic_data['forum_options'])) ? true : false,

   'U_TOPIC'            => "{$server_path}viewtopic.$phpEx?f=$forum_id&amp;t=$topic_id",
   'U_FORUM'            => $server_path,
   'U_VIEW_TOPIC'          => $viewtopic_url,
   'U_VIEW_FORUM'          => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id),
   'U_VIEW_OLDER_TOPIC'   => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;view=previous"),
   'U_VIEW_NEWER_TOPIC'   => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;view=next"),
   'U_PRINT_TOPIC'         => ($auth->acl_get('f_print', $forum_id)) ? $viewtopic_url . '&amp;view=print' : '',
   'U_EMAIL_TOPIC'         => ($auth->acl_get('f_email', $forum_id) && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=email&amp;t=$topic_id") : '',

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

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

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

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

   $poll_info = array();
   while ($row = $db->sql_fetchrow($result))
   {
      $poll_info[] = $row;
   }
   $db->sql_freeresult($result);

   $cur_voted_id = array();
   if ($user->data['is_registered'])
   {
      $sql = 'SELECT poll_option_id
         FROM ' . POLL_VOTES_TABLE . '
         WHERE topic_id = ' . $topic_id . '
            AND vote_user_id = ' . $user->data['user_id'];
      $result = $db->sql_query($sql);

      while ($row = $db->sql_fetchrow($result))
      {
         $cur_voted_id[] = $row['poll_option_id'];
      }
      $db->sql_freeresult($result);
   }
   else
   {
      // Cookie based guest tracking ... I don't like this but hum ho
      // it's oft requested. This relies on "nice" users who don't feel
      // the need to delete cookies to mess with results.
      if (isset($_COOKIE[$config['cookie_name'] . '_poll_' . $topic_id]))
      {
         $cur_voted_id = explode(',', $_COOKIE[$config['cookie_name'] . '_poll_' . $topic_id]);
         $cur_voted_id = array_map('intval', $cur_voted_id);
      }
   }

   // Can not vote at all if no vote permission
   $s_can_vote = ($auth->acl_get('f_vote', $forum_id) &&
      (($topic_data['poll_length'] != 0 && $topic_data['poll_start'] + $topic_data['poll_length'] > time()) || $topic_data['poll_length'] == 0) &&
      $topic_data['topic_status'] != ITEM_LOCKED &&
      $topic_data['forum_status'] != ITEM_LOCKED &&
      (!sizeof($cur_voted_id) ||
      ($auth->acl_get('f_votechg', $forum_id) && $topic_data['poll_vote_change']))) ? true : false;
   $s_display_results = (!$s_can_vote || ($s_can_vote && sizeof($cur_voted_id)) || $view == 'viewpoll') ? true : false;

   if ($update && $s_can_vote)
   {

      if (!sizeof($voted_id) || sizeof($voted_id) > $topic_data['poll_max_options'] || in_array(VOTE_CONVERTED, $cur_voted_id) || !check_form_key('posting'))
      {
         $redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;start=$start");

         meta_refresh(5, $redirect_url);
         if (!sizeof($voted_id))
         {
            $message = 'NO_VOTE_OPTION';
         }
         else if (sizeof($voted_id) > $topic_data['poll_max_options'])
         {
            $message = 'TOO_MANY_VOTE_OPTIONS';
         }
         else if (in_array(VOTE_CONVERTED, $cur_voted_id))
         {
            $message = 'VOTE_CONVERTED';
         }
         else
         {
            $message = 'FORM_INVALID';
         }

         $message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>');
         trigger_error($message);
      }

      foreach ($voted_id as $option)
      {
         if (in_array($option, $cur_voted_id))
         {
            continue;
         }

         $sql = 'UPDATE ' . POLL_OPTIONS_TABLE . '
            SET poll_option_total = poll_option_total + 1
            WHERE poll_option_id = ' . (int) $option . '
               AND topic_id = ' . (int) $topic_id;
         $db->sql_query($sql);

         if ($user->data['is_registered'])
         {
            $sql_ary = array(
               'topic_id'         => (int) $topic_id,
               'poll_option_id'   => (int) $option,
               'vote_user_id'      => (int) $user->data['user_id'],
               'vote_user_ip'      => (string) $user->ip,
            );

            $sql = 'INSERT INTO ' . POLL_VOTES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
            $db->sql_query($sql);
         }
      }

      foreach ($cur_voted_id as $option)
      {
         if (!in_array($option, $voted_id))
         {
            $sql = 'UPDATE ' . POLL_OPTIONS_TABLE . '
               SET poll_option_total = poll_option_total - 1
               WHERE poll_option_id = ' . (int) $option . '
                  AND topic_id = ' . (int) $topic_id;
            $db->sql_query($sql);

            if ($user->data['is_registered'])
            {
               $sql = 'DELETE FROM ' . POLL_VOTES_TABLE . '
                  WHERE topic_id = ' . (int) $topic_id . '
                     AND poll_option_id = ' . (int) $option . '
                     AND vote_user_id = ' . (int) $user->data['user_id'];
               $db->sql_query($sql);
            }
         }
      }

      if ($user->data['user_id'] == ANONYMOUS && !$user->data['is_bot'])
      {
         $user->set_cookie('poll_' . $topic_id, implode(',', $voted_id), time() + 31536000);
      }

      $sql = 'UPDATE ' . TOPICS_TABLE . '
         SET poll_last_vote = ' . time() . "
         WHERE topic_id = $topic_id";
      //, topic_last_post_time = ' . time() . " -- for bumping topics with new votes, ignore for now
      $db->sql_query($sql);

      $redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;start=$start");

      meta_refresh(5, $redirect_url);
      trigger_error($user->lang['VOTE_SUBMITTED'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>'));
   }

   $poll_total = 0;
   foreach ($poll_info as $poll_option)
   {
      $poll_total += $poll_option['poll_option_total'];
   }

   if ($poll_info[0]['bbcode_bitfield'])
   {
      $poll_bbcode = new bbcode();
   }
   else
   {
      $poll_bbcode = false;
   }

   for ($i = 0, $size = sizeof($poll_info); $i < $size; $i++)
   {
      $poll_info[$i]['poll_option_text'] = censor_text($poll_info[$i]['poll_option_text']);

      if ($poll_bbcode !== false)
      {
         $poll_bbcode->bbcode_second_pass($poll_info[$i]['poll_option_text'], $poll_info[$i]['bbcode_uid'], $poll_option['bbcode_bitfield']);
      }

      $poll_info[$i]['poll_option_text'] = bbcode_nl2br($poll_info[$i]['poll_option_text']);
      $poll_info[$i]['poll_option_text'] = smiley_text($poll_info[$i]['poll_option_text']);
   }

   $topic_data['poll_title'] = censor_text($topic_data['poll_title']);

   if ($poll_bbcode !== false)
   {
      $poll_bbcode->bbcode_second_pass($topic_data['poll_title'], $poll_info[0]['bbcode_uid'], $poll_info[0]['bbcode_bitfield']);
   }

   $topic_data['poll_title'] = bbcode_nl2br($topic_data['poll_title']);
   $topic_data['poll_title'] = smiley_text($topic_data['poll_title']);

   unset($poll_bbcode);

   foreach ($poll_info as $poll_option)
   {
      $option_pct = ($poll_total > 0) ? $poll_option['poll_option_total'] / $poll_total : 0;
      $option_pct_txt = sprintf("%.1d%%", round($option_pct * 100));

      $template->assign_block_vars('poll_option', array(
         'POLL_OPTION_ID'       => $poll_option['poll_option_id'],
         'POLL_OPTION_CAPTION'    => $poll_option['poll_option_text'],
         'POLL_OPTION_RESULT'    => $poll_option['poll_option_total'],
         'POLL_OPTION_PERCENT'    => $option_pct_txt,
         'POLL_OPTION_PCT'      => round($option_pct * 100),
         'POLL_OPTION_IMG'       => $user->img('poll_center', $option_pct_txt, round($option_pct * 250)),
         'POLL_OPTION_VOTED'      => (in_array($poll_option['poll_option_id'], $cur_voted_id)) ? true : false)
      );
   }

   $poll_end = $topic_data['poll_length'] + $topic_data['poll_start'];

   $template->assign_vars(array(
      'POLL_QUESTION'      => $topic_data['poll_title'],
      'TOTAL_VOTES'       => $poll_total,
      'POLL_LEFT_CAP_IMG'   => $user->img('poll_left'),
      'POLL_RIGHT_CAP_IMG'=> $user->img('poll_right'),

      'L_MAX_VOTES'      => ($topic_data['poll_max_options'] == 1) ? $user->lang['MAX_OPTION_SELECT'] : sprintf($user->lang['MAX_OPTIONS_SELECT'], $topic_data['poll_max_options']),
      'L_POLL_LENGTH'      => ($topic_data['poll_length']) ? sprintf($user->lang[($poll_end > time()) ? 'POLL_RUN_TILL' : 'POLL_ENDED_AT'], $user->format_date($poll_end)) : '',

      'S_HAS_POLL'      => true,
      'S_CAN_VOTE'      => $s_can_vote,
      'S_DISPLAY_RESULTS'   => $s_display_results,
      'S_IS_MULTI_CHOICE'   => ($topic_data['poll_max_options'] > 1) ? true : false,
      'S_POLL_ACTION'      => $viewtopic_url,

      'U_VIEW_RESULTS'   => $viewtopic_url . '&amp;view=viewpoll')
   );

   unset($poll_end, $poll_info, $voted_id);
}

// If the user is trying to reach the second half of the topic, fetch it starting from the end
$store_reverse = false;
$sql_limit = $config['posts_per_page'];
$sql_sort_order = $direction = '';

if ($start > $total_posts / 2)
{
   $store_reverse = true;

   if ($start + $config['posts_per_page'] > $total_posts)
   {
      $sql_limit = min($config['posts_per_page'], max(1, $total_posts - $start));
   }

   // Select the sort order
   $direction = (($sort_dir == 'd') ? 'ASC' : 'DESC');
   $sql_start = max(0, $total_posts - $sql_limit - $start);
}
else
{
   // Select the sort order
   $direction = (($sort_dir == 'd') ? 'DESC' : 'ASC');
   $sql_start = $start;
}

if (is_array($sort_by_sql[$sort_key]))
{
   $sql_sort_order = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction;
}
else
{
   $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction;
}

// Container for user details, only process once
$post_list = $user_cache = $id_cache = $attachments = $attach_list = $rowset = $update_count = $post_edit_list = array();
$has_attachments = $display_notice = false;
$bbcode_bitfield = '';
$i = $i_total = 0;

// Go ahead and pull all data for this topic
$sql = 'SELECT p.post_id
   FROM ' . POSTS_TABLE . ' p' . (($join_user_sql[$sort_key]) ? ', ' . USERS_TABLE . ' u': '') . "
   WHERE p.topic_id = $topic_id
      " . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND p.post_approved = 1' : '') . "
      " . (($join_user_sql[$sort_key]) ? 'AND u.user_id = p.poster_id': '') . "
      $limit_posts_time
   ORDER BY $sql_sort_order";
$result = $db->sql_query_limit($sql, $sql_limit, $sql_start);

$i = ($store_reverse) ? $sql_limit - 1 : 0;
while ($row = $db->sql_fetchrow($result))
{
   $post_list[$i] = (int) $row['post_id'];
   ($store_reverse) ? $i-- : $i++;
}
$db->sql_freeresult($result);

if (!sizeof($post_list))
{
   if ($sort_days)
   {
      trigger_error('NO_POSTS_TIME_FRAME');
   }
   else
   {
      trigger_error('NO_TOPIC');
   }
}

// Holding maximum post time for marking topic read
// We need to grab it because we do reverse ordering sometimes
$max_post_time = 0;

$sql = $db->sql_build_query('SELECT', array(
   'SELECT'   => 'u.*, z.friend, z.foe, p.*',

   'FROM'      => array(
      USERS_TABLE      => 'u',
      POSTS_TABLE      => 'p',
   ),

   'LEFT_JOIN'   => array(
      array(
         'FROM'   => array(ZEBRA_TABLE => 'z'),
         'ON'   => 'z.user_id = ' . $user->data['user_id'] . ' AND z.zebra_id = p.poster_id'
      )
   ),

   'WHERE'      => $db->sql_in_set('p.post_id', $post_list) . '
      AND u.user_id = p.poster_id'
));

$result = $db->sql_query($sql);

$now = getdate(time() + $user->timezone + $user->dst - date('Z'));

// Posts are stored in the $rowset array while $attach_list, $user_cache
// and the global bbcode_bitfield are built
while ($row = $db->sql_fetchrow($result))
{
   // Set max_post_time
   if ($row['post_time'] > $max_post_time)
   {
      $max_post_time = $row['post_time'];
   }

   $poster_id = (int) $row['poster_id'];

   // Does post have an attachment? If so, add it to the list
   if ($row['post_attachment'] && $config['allow_attachments'])
   {
      $attach_list[] = (int) $row['post_id'];

      if ($row['post_approved'])
      {
         $has_attachments = true;
      }
   }

   $rowset[$row['post_id']] = array(
      'hide_post'         => ($row['foe'] && ($view != 'show' || $post_id != $row['post_id'])) ? true : false,

      'post_id'         => $row['post_id'],
      'post_time'         => $row['post_time'],
      'user_id'         => $row['user_id'],
      'username'         => $row['username'],
      'user_colour'      => $row['user_colour'],
      'topic_id'         => $row['topic_id'],
      'forum_id'         => $row['forum_id'],
      'post_subject'      => $row['post_subject'],
      'post_edit_count'   => $row['post_edit_count'],
      'post_edit_time'   => $row['post_edit_time'],
      'post_edit_reason'   => $row['post_edit_reason'],
      'post_edit_user'   => $row['post_edit_user'],
      'post_edit_locked'   => $row['post_edit_locked'],

      // Make sure the icon actually exists
      'icon_id'         => (isset($icons[$row['icon_id']]['img'], $icons[$row['icon_id']]['height'], $icons[$row['icon_id']]['width'])) ? $row['icon_id'] : 0,
      'post_attachment'   => $row['post_attachment'],
      'post_approved'      => $row['post_approved'],
      'post_reported'      => $row['post_reported'],
      'post_username'      => $row['post_username'],
      'post_text'         => $row['post_text'],
      'bbcode_uid'      => $row['bbcode_uid'],
      'bbcode_bitfield'   => $row['bbcode_bitfield'],
      'enable_smilies'   => $row['enable_smilies'],
      'enable_sig'      => $row['enable_sig'],
      'friend'         => $row['friend'],
      'foe'            => $row['foe'],
   );

   // Define the global bbcode bitfield, will be used to load bbcodes
   $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']);

   // Is a signature attached? Are we going to display it?
   if ($row['enable_sig'] && $config['allow_sig'] && $user->optionget('viewsigs'))
   {
      $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['user_sig_bbcode_bitfield']);
   }

   // Cache various user specific data ... so we don't have to recompute
   // this each time the same user appears on this page
   if (!isset($user_cache[$poster_id]))
   {
      if ($poster_id == ANONYMOUS)
      {
         $user_cache[$poster_id] = array(
            'joined'      => '',
            'posts'         => '',
            'from'         => '',

            'sig'               => '',
            'sig_bbcode_uid'      => '',
            'sig_bbcode_bitfield'   => '',

            'online'         => false,
            'avatar'         => ($user->optionget('viewavatars')) ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']) : '',
            'rank_title'      => '',
            'rank_image'      => '',
            'rank_image_src'   => '',
            'sig'            => '',
            'profile'         => '',
            'pm'            => '',
            'email'            => '',
            'www'            => '',
            'icq_status_img'   => '',
            'icq'            => '',
            'aim'            => '',
            'msn'            => '',
            'yim'            => '',
            'jabber'         => '',
            'search'         => '',
            'age'            => '',

            'username'         => $row['username'],
            'user_colour'      => $row['user_colour'],

            'warnings'         => 0,
            'allow_pm'         => 0,
            // viewtopic birthday
            'viewtopic_birthday'=> false,
         );

         get_user_rank($row['user_rank'], false, $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);
      }
      else
      {
         $user_sig = '';

         // We add the signature to every posters entry because enable_sig is post dependant
         if ($row['user_sig'] && $config['allow_sig'] && $user->optionget('viewsigs'))
         {
            $user_sig = $row['user_sig'];
         }

         $id_cache[] = $poster_id;

         $user_cache[$poster_id] = array(
            'joined'      => $user->format_date($row['user_regdate']),
            'posts'         => $row['user_posts'],
            'warnings'      => (isset($row['user_warnings'])) ? $row['user_warnings'] : 0,
            'from'         => (!empty($row['user_from'])) ? $row['user_from'] : '',

            'sig'               => $user_sig,
            'sig_bbcode_uid'      => (!empty($row['user_sig_bbcode_uid'])) ? $row['user_sig_bbcode_uid'] : '',
            'sig_bbcode_bitfield'   => (!empty($row['user_sig_bbcode_bitfield'])) ? $row['user_sig_bbcode_bitfield'] : '',

            'viewonline'   => $row['user_allow_viewonline'],
            'allow_pm'      => $row['user_allow_pm'],

            'avatar'      => ($user->optionget('viewavatars')) ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']) : '',
            'age'         => '',

            'rank_title'      => '',
            'rank_image'      => '',
            'rank_image_src'   => '',

            'username'         => $row['username'],
            'user_colour'      => $row['user_colour'],

            'online'      => false,
            'profile'      => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=viewprofile&amp;u=$poster_id"),
            'www'         => $row['user_website'],
            'aim'         => ($row['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&amp;action=aim&amp;u=$poster_id") : '',
            'msn'         => ($row['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&amp;action=msnm&amp;u=$poster_id") : '',
            'yim'         => ($row['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($row['user_yim']) . '&amp;.src=pg' : '',
            'jabber'      => ($row['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&amp;action=jabber&amp;u=$poster_id") : '',
            'search'      => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$poster_id&amp;sr=posts") : '',

            'author_full'      => get_username_string('full', $poster_id, $row['username'], $row['user_colour']),
            'author_colour'      => get_username_string('colour', $poster_id, $row['username'], $row['user_colour']),
            'author_username'   => get_username_string('username', $poster_id, $row['username'], $row['user_colour']),
            'author_profile'   => get_username_string('profile', $poster_id, $row['username'], $row['user_colour']),
         );

         get_user_rank($row['user_rank'], $row['user_posts'], $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);

         if (!empty($row['user_allow_viewemail']) || $auth->acl_get('a_email'))
         {