예제 #1
0
 protected function run_gmgetdate_assertion()
 {
     $expected = time();
     $date_array = phpbb_gmgetdate($expected);
     $actual = gmmktime($date_array['hours'], $date_array['minutes'], $date_array['seconds'], $date_array['mon'], $date_array['mday'], $date_array['year']);
     $this->assertEquals($expected, $actual);
 }
 public function main()
 {
     $asset_path = $this->sitemaker->asset_path;
     $this->sitemaker->add_assets(array('js' => array('//ajax.googleapis.com/ajax/libs/jqueryui/' . JQUI_VERSION . '/jquery-ui.min.js', $asset_path . 'ext/blitze/sitemaker/components/jquery-knob/js/jquery.knob.min.js', $asset_path . 'ext/blitze/sitemaker/components/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.min.js', $asset_path . 'ext/blitze/sitemaker/components/moment/moment.min.js', $asset_path . 'ext/blitze/sitemaker/components/jquery-rss/dist/jquery.rss.min.js', $asset_path . 'ext/blitze/sitemaker/components/jquery.sparkline/index.min.js', '@blitze_sitemaker/assets/adm/dashboard.min.js'), 'css' => array('//ajax.googleapis.com/ajax/libs/jqueryui/' . JQUI_VERSION . '/themes/smoothness/jquery-ui.css', $asset_path . 'ext/blitze/sitemaker/components/fontawesome/css/font-awesome.min.css', $asset_path . 'ext/blitze/sitemaker/components/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.min.css', '@blitze_sitemaker/assets/adm/dashboard.min.css')));
     $time = $this->user->create_datetime();
     $now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset());
     $wday = $now['wday'];
     $weekdays = array();
     while ($wday >= 0) {
         $weekdays[$wday] = 0;
         $wday--;
     }
     for ($i = 6, $size = sizeof($weekdays); $i >= $size; $i--) {
         $weekdays[$i] = 0;
     }
     $weekdays = array_reverse($weekdays, true);
     $count = 0;
     $js_weekdays = array();
     for ($i = 6; $i >= 0; $i--) {
         $js_weekdays[] = "{$count}: '" . $this->user->format_date(strtotime("- {$i} days"), 'l M j', true) . "'";
         $count++;
     }
     $this->template->assign_var('UA_WEEKDAYS', join(', ', $js_weekdays));
     $lookback = $now[0] - 6 * 24 * 3600;
     $boarddays = ($now[0] - $this->config['board_startdate']) / 86400;
     $this->get_stats('users', $weekdays, $lookback, $boarddays);
     $this->get_stats('topics', $weekdays, $lookback, $boarddays);
     $this->get_stats('posts', $weekdays, $lookback, $boarddays);
     $this->get_stats('files', $weekdays, $lookback, $boarddays);
     $this->user_contributions();
     // Set up the page
     $this->tpl_name = 'acp_dashboard';
     $this->page_title = 'SITEMAKER_DASHBOARD';
 }
예제 #3
0
 /**
  * @param $range date range to get (today, week, month, year)
  * @return array
  */
 public function get($range)
 {
     $time = $this->user->create_datetime($this->time);
     $now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset());
     $method = 'get_' . $range;
     $data = array('start' => 0, 'stop' => 0, 'date' => '');
     if (is_callable(array($this, $method))) {
         $data = call_user_func_array(array($this, $method), array($now));
     }
     return $data;
 }
예제 #4
0
    /**
     * Runs this cron task.
     *
     * @return null
     */
    public function run()
    {
        $time = $this->user->create_datetime();
        $now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset());
        // Display birthdays of 29th february on 28th february in non-leap-years
        $leap_year_birthdays = '';
        if ($now['mday'] == 28 && $now['mon'] == 2 && !$time->format('L')) {
            $leap_year_birthdays = ' OR user_birthday LIKE "' . $this->db->sql_escape(sprintf("%2d-%2d-", 29, 2)) . '%"';
        }
        $sql = 'SELECT user_id, username, user_email, user_lang, 
				YEAR(CURRENT_TIMESTAMP) - YEAR(str_to_date(user_birthday, "%d-%m-%Y")) AS age
				FROM ' . USERS_TABLE . ' 
				WHERE user_birthday <> " 0- 0-   0" AND user_birthday <> "" AND 
				(user_birthday LIKE "' . $this->db->sql_escape(sprintf("%2d-%2d-", $now["mday"], $now["mon"])) . '%"' . $leap_year_birthdays . ') AND 
				email_on_birthday + 15778463 < UNIX_TIMESTAMP(now())';
        $result = $this->db->sql_query($sql);
        $msg_list = array();
        while ($row = $this->db->sql_fetchrow($result)) {
            $msg_list[] = array('user_id' => $row['user_id'], 'name' => $row['username'], 'email' => $row['user_email'], 'lang' => $row['user_lang'], 'age' => $this->convertNumber($row['age']) . $this->text_number($row['age']), 'time' => time());
        }
        if (sizeof($msg_list)) {
            if ($this->config['email_enable']) {
                if (!class_exists('messenger')) {
                    include $this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext;
                }
                $server_url = generate_board_url();
                $messenger = new \messenger(false);
                foreach ($msg_list as $key => $value) {
                    $messenger->template('@forumhulp_emailonbirthday/emailonbirthday', $value['lang']);
                    $messenger->to($value['email'], $value['name']);
                    $messenger->headers('X-AntiAbuse: Board servername - ' . $this->config['server_name']);
                    $messenger->headers('X-AntiAbuse: User_id - ' . $value['user_id']);
                    $messenger->headers('X-AntiAbuse: Username - ' . $value['name']);
                    $messenger->headers('X-AntiAbuse: User IP - ' . '127.0.0.1');
                    $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($value['name']), 'BIRTHDAY' => $value['age'], 'SITENAME' => $this->config['sitename']));
                    $messenger->send(NOTIFY_EMAIL);
                    $sql = 'UPDATE ' . USERS_TABLE . ' SET email_on_birthday = ' . time() . ' WHERE user_id = ' . $value['user_id'];
                    $this->db->sql_query($sql);
                }
                $userlist = array_map(function ($entry) {
                    return $entry['name'];
                }, $msg_list);
                $this->log->add('admin', $this->user->data['user_id'], $this->user->data['session_ip'], 'BIRTHDAYSEND', false, array(implode(', ', $userlist)));
            }
        }
        $this->config->set('email_on_birthday_last_gc', time());
    }
예제 #5
0
 /**
  * {@inheritdoc}
  */
 public function get_template_side($module_id)
 {
     // Generate birthday list if required ... / borrowed from index.php 3.0.6
     $birthday_list = $birthday_ahead_list = '';
     if ($this->config['load_birthdays'] && $this->config['allow_birthdays']) {
         $time = $this->user->create_datetime();
         $now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset());
         $cache_days = $this->config['board3_birthdays_ahead_' . $module_id];
         $sql_days = '';
         while ($cache_days > 0) {
             $day = phpbb_gmgetdate($time->getTimestamp() + 86400 * $cache_days + $time->getOffset());
             $like_expression = $this->db->sql_like_expression($this->db->get_any_char() . sprintf('%2d-%2d-', $day['mday'], $day['mon']) . $this->db->get_any_char());
             $sql_days .= " OR u.user_birthday " . $like_expression . "";
             $cache_days--;
         }
         switch ($this->db->get_sql_layer()) {
             case 'mssql':
             case 'mssql_odbc':
                 $order_by = 'u.user_birthday ASC';
                 break;
             default:
                 $order_by = 'SUBSTRING(u.user_birthday FROM 4 FOR 2) ASC, SUBSTRING(u.user_birthday FROM 1 FOR 2) ASC, u.username_clean ASC';
                 break;
         }
         $sql_array = array('SELECT' => 'u.user_id, u.username, u.user_colour, u.user_birthday', 'FROM' => array(USERS_TABLE => 'u'), 'LEFT_JOIN' => array(array('FROM' => array(BANLIST_TABLE => 'b'), 'ON' => 'u.user_id = b.ban_userid')), 'WHERE' => "(b.ban_id IS NULL\n\t\t\t\t\t\tOR b.ban_exclude = 1)\n\t\t\t\t\tAND (u.user_birthday " . $this->db->sql_like_expression($this->db->get_any_char() . sprintf('%2d-%2d-', $now['mday'], $now['mon']) . $this->db->get_any_char()) . " {$sql_days})\n\t\t\t\t\tAND " . $this->db->sql_in_set('u.user_type', array(USER_NORMAL, USER_FOUNDER)), 'ORDER BY' => $order_by);
         $sql = $this->db->sql_build_query('SELECT', $sql_array);
         $result = $this->db->sql_query($sql, 3600);
         $today = sprintf('%2d-%2d-', $now['mday'], $now['mon']);
         while ($row = $this->db->sql_fetchrow($result)) {
             if (substr($row['user_birthday'], 0, 6) == $today) {
                 $birthday_list = true;
                 $this->template->assign_block_vars('board3_birthday_list', array('USER' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'AGE' => ($age = (int) substr($row['user_birthday'], -4)) ? ' (' . ($now['year'] - $age) . ')' : ''));
             } else {
                 if ($this->config['board3_birthdays_ahead_' . $module_id] > 0) {
                     $birthday_ahead_list = true;
                     $this->template->assign_block_vars('board3_birthday_ahead_list', array('USER' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'AGE' => ($age = (int) substr($row['user_birthday'], -4)) ? ' (' . ($now['year'] - $age) . ')' : '', 'DATE' => $this->format_birthday($this->user, $row['user_birthday'], 'd M')));
                 }
             }
         }
         $this->db->sql_freeresult($result);
     }
     // Assign index specific vars
     $this->template->assign_vars(array('BIRTHDAY_LIST' => $birthday_list, 'BIRTHDAYS_AHEAD_LIST' => $this->config['board3_birthdays_ahead_' . $module_id] ? $birthday_ahead_list : '', 'L_BIRTHDAYS_AHEAD' => sprintf($this->user->lang['BIRTHDAYS_AHEAD'], $this->config['board3_birthdays_ahead_' . $module_id]), 'S_DISPLAY_BIRTHDAY_LIST' => $this->config['load_birthdays'] ? true : false, 'S_DISPLAY_BIRTHDAY_AHEAD_LIST' => $this->config['board3_birthdays_ahead_' . $module_id] > 0 ? true : false));
     return 'birthdays_side.html';
 }
예제 #6
0
 /**
  * @dataProvider phpbb_gmgetdate_data
  */
 public function test_phpbb_gmgetdate($timezone_identifier)
 {
     if ($timezone_identifier) {
         $current_timezone = date_default_timezone_get();
         date_default_timezone_set($timezone_identifier);
     }
     $expected = time();
     $date_array = phpbb_gmgetdate($expected);
     $actual = gmmktime($date_array['hours'], $date_array['minutes'], $date_array['seconds'], $date_array['mon'], $date_array['mday'], $date_array['year']);
     // Calling second-granularity time functions twice isn't guaranteed to
     // give the same results. As long as they're in the right order, allow
     // a 1 second difference.
     $this->assertGreaterThanOrEqual($expected, $actual, 'Expected second time to be after (or equal to) the previous one');
     $this->assertLessThanOrEqual(1, abs($actual - $expected), "Expected {$actual} to be within 1 second of {$expected}.");
     if (isset($current_timezone)) {
         date_default_timezone_set($current_timezone);
     }
 }
예제 #7
0
    /**
     * @return bool
     */
    private function _find_birthday_users()
    {
        $time = $this->user->create_datetime($this->time);
        $now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset());
        $leap_year_birthdays = $this->_adjust_leap_year($now, $time);
        $sql = 'SELECT u.user_id, u.username, u.user_colour, u.user_birthday 
				FROM ' . USERS_TABLE . ' u
				LEFT JOIN ' . BANLIST_TABLE . " b ON (u.user_id = b.ban_userid)\n\t\t\t\tWHERE (b.ban_id IS NULL\n\t\t\t\t\tOR b.ban_exclude = 1)\n\t\t\t\t\tAND (u.user_birthday LIKE '" . $this->db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%' {$leap_year_birthdays})\n\t\t\t\t\tAND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')
				ORDER BY u.username ASC';
        $result = $this->db->sql_query($sql);
        $show_birthday = false;
        while ($row = $this->db->sql_fetchrow($result)) {
            $show_birthday = true;
            $this->ptemplate->assign_block_vars('birthday', array('USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'USER_AGE' => $this->_get_user_age($row['user_birthday'], $now['year'])));
        }
        $this->db->sql_freeresult($result);
        return $show_birthday;
    }
    public function upcoming_birthdays()
    {
        $time = $this->user->create_datetime();
        $now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset());
        $today = mktime(0, 0, 0, $now['mon'], $now['mday'], $now['year']);
        // Number of seconds per day
        $secs_per_day = 24 * 60 * 60;
        // We will use the timezone offset for our cache name
        $cache_name = $time->getOffset();
        $cache_name = str_replace('-', 'minus_', $cache_name);
        $cache_name = $cache_name . '_ubl';
        if (($upcomingbirthdays = $this->cache->get('_' . $cache_name)) === false) {
            // Only care about dates ahead of today.  Start date is always tomorrow
            $date_start = $now[0] + $secs_per_day;
            $date_end = $date_start + (int) $this->config['allow_birthdays_ahead'] * $secs_per_day;
            $dates = array();
            while ($date_start <= $date_end) {
                $day = date('j', $date_start);
                $month = date('n', $date_start);
                $dates[] = $this->db->sql_escape(sprintf('%2d-%2d-', $day, $month));
                $date_start = $date_start + $secs_per_day;
            }
            $sql_array = array();
            foreach ($dates as $date) {
                $sql_array[] = "u.user_birthday LIKE '" . $date . "%'";
            }
            $sql = 'SELECT u.user_id, u.username, u.user_colour, u.user_birthday, b.ban_id
				FROM ' . USERS_TABLE . ' u
				LEFT JOIN ' . BANLIST_TABLE . " b ON (u.user_id = b.ban_userid)\n\t\t\t\tWHERE (b.ban_id IS NULL\n\t\t\t\t\tOR b.ban_exclude = 1)\n\t\t\t\t\tAND (" . implode(' OR ', $sql_array) . ")\n\t\t\t\t\tAND " . $this->db->sql_in_set('u.user_type', array(USER_NORMAL, USER_FOUNDER));
            $result = $this->db->sql_query($sql);
            $upcomingbirthdays = array();
            while ($row = $this->db->sql_fetchrow($result)) {
                $bdday = $bdmonth = 0;
                list($bdday, $bdmonth) = array_map('intval', explode('-', $row['user_birthday']));
                $bdcheck = strtotime(gmdate('Y') . '-' . (int) trim($bdmonth) . '-' . (int) trim($bdday) . ' UTC');
                $bdyear = $bdcheck < $today ? (int) gmdate('Y') + 1 : (int) gmdate('Y');
                $bddate = $bdyear . '-' . (int) $bdmonth . '-' . (int) $bdday;
                // re-write those who have feb 29th as a birthday but only on non leap years
                if ((int) trim($bdday) == 29 && (int) trim($bdmonth) == 2) {
                    if (!$this->is_leap_year($bdyear) && !$time->format('L')) {
                        $bdday = 28;
                        $bddate = $bdyear . '-' . (int) trim($bdmonth) . '-' . (int) trim($bdday);
                    }
                }
                $upcomingbirthdays[] = array('user_birthday_tstamp' => strtotime($bddate . ' UTC'), 'username' => $row['username'], 'user_birthdayyear' => $bdyear, 'user_birthday' => $row['user_birthday'], 'user_id' => $row['user_id'], 'user_colour' => $row['user_colour']);
            }
            $this->db->sql_freeresult($result);
            // cache this data for one hour, this improves performance
            $this->cache->put('_' . $cache_name, $upcomingbirthdays, 3600);
        }
        sort($upcomingbirthdays);
        $birthday_ahead_list = '';
        $tomorrow = mktime(0, 0, 0, $now['mon'], $now['mday'] + 1, $now['year']);
        for ($i = 0, $end = sizeof($upcomingbirthdays); $i < $end; $i++) {
            if ($upcomingbirthdays[$i]['user_birthday_tstamp'] >= $tomorrow && $upcomingbirthdays[$i]['user_birthday_tstamp'] <= $today + $this->config['allow_birthdays_ahead'] * $secs_per_day) {
                $user_link = get_username_string('full', $upcomingbirthdays[$i]['user_id'], $upcomingbirthdays[$i]['username'], $upcomingbirthdays[$i]['user_colour']);
                $birthdate = getdate($upcomingbirthdays[$i]['user_birthday_tstamp']);
                //lets add to the birthday_ahead list.
                $birthday_ahead_list .= ($birthday_ahead_list != '' ? $this->user->lang['COMMA_SEPARATOR'] : '') . '<span title="' . $birthdate['mday'] . '-' . $birthdate['mon'] . '-' . $birthdate['year'] . '">' . $user_link . '</span>';
                if ($age = (int) substr($upcomingbirthdays[$i]['user_birthday'], -4)) {
                    $birthday_ahead_list .= ' (' . ($upcomingbirthdays[$i]['user_birthdayyear'] - $age) . ')';
                }
            }
        }
        // Assign index specific vars
        $this->template->assign_vars(array('BIRTHDAYS_AHEAD_LIST' => $birthday_ahead_list, 'L_BIRTHDAYS_AHEAD' => $this->user->lang('BIRTHDAYS_AHEAD', $this->config['allow_birthdays_ahead'])));
    }
예제 #9
0
    protected function display_brithdays()
    {
        // Generate birthday list if required ...
        if ($this->config['load_birthdays'] && $this->config['allow_birthdays'] && $this->config['phpbb_gallery_disp_birthdays'] && $this->auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel')) {
            $this->template->assign_vars(array('S_DISPLAY_BIRTHDAY_LIST' => true));
            $time = $this->user->create_datetime();
            $now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset());
            // Display birthdays of 29th february on 28th february in non-leap-years
            $leap_year_birthdays = '';
            if ($now['mday'] == 28 && $now['mon'] == 2 && !$time->format('L')) {
                $leap_year_birthdays = " OR u.user_birthday LIKE '" . $this->db->sql_escape(sprintf('%2d-%2d-', 29, 2)) . "%'";
            }
            $sql = 'SELECT u.user_id, u.username, u.user_colour, u.user_birthday
				FROM ' . USERS_TABLE . ' u
				LEFT JOIN ' . BANLIST_TABLE . " b ON (u.user_id = b.ban_userid)\n\t\t\t\tWHERE (b.ban_id IS NULL\n\t\t\t\t\tOR b.ban_exclude = 1)\n\t\t\t\t\tAND (u.user_birthday LIKE '" . $this->db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%' {$leap_year_birthdays})\n\t\t\t\t\tAND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
            $result = $this->db->sql_query($sql);
            while ($row = $this->db->sql_fetchrow($result)) {
                $birthday_username = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
                $birthday_year = (int) substr($row['user_birthday'], -4);
                $birthday_age = $birthday_year ? max(0, $now['year'] - $birthday_year) : '';
                $this->template->assign_block_vars('birthdays', array('USERNAME' => $birthday_username, 'AGE' => $birthday_age));
            }
            $this->db->sql_freeresult($result);
        }
    }
예제 #10
0
 public function memberlist_view_profile($event)
 {
     $reg_date = phpbb_gmgetdate($event['member']['user_regdate']);
     $member_for = $reg_date['mday'] . ' ' . $reg_date['month'] . ' ' . $reg_date['year'] . ', ' . $reg_date['hours'] . ':' . $reg_date['minutes'] . ':' . $reg_date['seconds'];
     $this->template->assign_vars(array('MEMBER_FOR' => $member_for));
 }
예제 #11
0
/**
* Prepare profile data
*/
function phpbb_show_profile($data, $user_notes_enabled = false, $warn_user_enabled = false, $check_can_receive_pm = true)
{
    global $config, $auth, $user, $phpEx, $phpbb_root_path, $phpbb_dispatcher;
    $username = $data['username'];
    $user_id = $data['user_id'];
    $user_rank_data = phpbb_get_user_rank($data, $user_id == ANONYMOUS ? false : $data['user_posts']);
    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_active = !empty($data['session_time']) ? $data['session_time'] : $data['user_lastvisit'];
    } else {
        $last_active = '';
    }
    $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 = $user->create_datetime();
            $now = phpbb_gmgetdate($now->getTimestamp() + $now->getOffset());
            $diff = $now['mon'] - $bday_month;
            if ($diff == 0) {
                $diff = $now['mday'] - $bday_day < 0 ? 1 : 0;
            } else {
                $diff = $diff < 0 ? 1 : 0;
            }
            $age = max(0, (int) ($now['year'] - $bday_year - $diff));
        }
    }
    if (!function_exists('phpbb_get_banned_user_ids')) {
        include $phpbb_root_path . 'includes/functions_user.' . $phpEx;
    }
    // Can this user receive a Private Message?
    $can_receive_pm = $check_can_receive_pm && ($data['user_type'] != USER_IGNORE && ($data['user_type'] != USER_INACTIVE || $data['user_inactive_reason'] != INACTIVE_MANUAL) && sizeof($auth->acl_get_list($user_id, 'u_readpm')) && !sizeof(phpbb_get_banned_user_ids($user_id, false)) && ($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_') || $data['user_allow_pm']));
    // Dump it out to the template
    $template_data = array('AGE' => $age, 'RANK_TITLE' => $user_rank_data['title'], 'JOINED' => $user->format_date($data['user_regdate']), 'LAST_ACTIVE' => empty($last_active) ? ' - ' : $user->format_date($last_active), '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' => phpbb_get_user_avatar($data), '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' => $user_rank_data['img'], 'RANK_IMG_SRC' => $user_rank_data['img_src'], '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') && $can_receive_pm ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $user_id) : '', 'U_EMAIL' => $email, '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) : '', 'USER_JABBER' => $config['jab_enable'] ? $data['user_jabber'] : '', 'USER_JABBER_IMG' => $config['jab_enable'] && $data['user_jabber'] ? $user->img('icon_contact_jabber', $data['user_jabber']) : '', 'L_SEND_EMAIL_USER' => $user->lang('SEND_EMAIL_USER', $username), 'L_CONTACT_USER' => $user->lang('CONTACT_USER', $username), 'L_VIEWING_PROFILE' => $user->lang('VIEWING_PROFILE', $username));
    /**
     * Preparing a user's data before displaying it in profile and memberlist
     *
     * @event core.memberlist_prepare_profile_data
     * @var	array	data				Array with user's data
     * @var	array	template_data		Template array with user's data
     * @since 3.1.0-a1
     */
    $vars = array('data', 'template_data');
    extract($phpbb_dispatcher->trigger_event('core.memberlist_prepare_profile_data', compact($vars)));
    return $template_data;
}
예제 #12
0
 public function age($user_birthday)
 {
     list($bday_day, $bday_month, $bday_year) = array_map('intval', explode('-', $user_birthday));
     if ($bday_year) {
         $now = $this->user->create_datetime();
         $now = phpbb_gmgetdate($now->getTimestamp() + $now->getOffset());
         $diff = $now['mon'] - $bday_month;
         if ($diff == 0) {
             $diff = $now['mday'] - $bday_day < 0 ? 1 : 0;
         } else {
             $diff = $diff < 0 ? 1 : 0;
         }
         $age = max(0, (int) ($now['year'] - $bday_year - $diff));
     }
     return $age;
 }
예제 #13
0
/**
* 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 = phpbb_gmgetdate(time() + $user->timezone + $user->dst);

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

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




	// BEGIN PBWoW 2 MOD
	$posts_rank_title = $posts_rank_image = $posts_rank_image_src = $user_special_styling = $user_special_color = '';
	
	get_user_rank(0, (($user_id == ANONYMOUS) ? false : $data['user_posts']), $posts_rank_title, $posts_rank_image, $posts_rank_image_src);
	
	check_rank_special_styling($data['user_rank'], $user_special_styling, $user_special_color);
	$avatar_src = get_user_avatar_src($data['user_avatar'], $data['user_avatar_type']);

	$template->assign_vars(array(
		'AVATAR_SRC'			=> $avatar_src,
		'POSTS_RANK_TITLE'		=> $posts_rank_title,
		'POSTS_RANK_IMG'		=> $posts_rank_image,
		'POSTS_RANK_IMG_SRC'	=> $posts_rank_image_src,
		'USER_SPECIAL_STYLING'	=> $user_special_styling,
		'USER_SPECIAL_COLOR'	=> $user_special_color,
	));
	// END PBWoW 2 MOD
	// 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/' . 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),
	);
}
예제 #14
0
    function display_posts(&$master)
    {
        global $user, $template, $config, $phpEx, $db, $auth, $phpbb_root_path, $cache;
        static $bbcode;
        static $display_orders = array('first' => 't.topic_id', 'last' => 't.topic_last_post_time');
        global $phpbb_seo;
        // Usefull for multi bb topic & forum tracking
        // Leave default for single forum eg : '_track'
        $tracking_cookie_name = (defined('XLANG_AKEY') ? XLANG_AKEY : '') . '_track';
        $forum_read_auth =& $master->actions['auth_view_read'];
        // Specific options
        $display_file =& $master->call['display_file'];
        $display_user_info =& $master->call['display_user_info'];
        $display_user_link = !empty($master->call['display_user_link']) ? true : false;
        $display_user_link_key = $display_user_link ? 'full' : 'no_profile';
        $display_link =& $master->call['display_link'];
        $display_pagination =& $master->call['display_pagination'];
        $display_tracking =& $master->call['display_tracking'];
        $display_sig = !empty($master->call['display_sig']) ? (bool) ($config['allow_sig'] && $user->optionget('viewsigs')) : false;
        $display_order = isset($display_orders[$master->call['display_order']]) ? $display_orders[$master->call['display_order']] : $display_orders['first'];
        $display_post_buttons =& $master->call['display_post_buttons'];
        $display_sumarize =& $master->call['display_sumarize'];
        $limit_time_sql = !empty($master->call['limit_time']) ? ' AND t.topic_last_post_time > ' . ($user->time_now - $master->call['limit_time']) : '';
        $order_sql = @$master->call['sort'] == 'ASC' ? ' ASC' : ' DESC';
        if (!$display_tracking) {
            $load_db_lastread = $load_anon_lastread = false;
        } else {
            $load_db_lastread = (bool) ($config['load_db_lastread'] && $user->data['is_registered']);
            $load_anon_lastread = (bool) ($config['load_anon_lastread'] || $user->data['is_registered']);
        }
        // hanlde options
        $limit = $master->call['limit'] >= 1 ? (int) $master->call['limit'] : 5;
        $start =& $master->start;
        if (!$display_pagination || empty($display_file)) {
            $start = 0;
            $display_pagination = false;
        }
        $total_topics = 0;
        $topic_sql = $master->call['topic_sql'];
        $forum_sql = $master->call['forum_sql'];
        $s_global = $master->call['s_global'];
        $bbcode_bitfield = '';
        // Do some reset
        $topic_datas = $topic_ids = $forum_ids = $user_cache = $id_cache = $post_datas = $forum_datas = array();
        $forum_id = $master->call['forum_id'];
        $now = phpbb_gmgetdate(time() + $user->timezone + $user->dst);
        // Get The Data, first forums
        if (!$s_global && !$master->call['single_forum'] || $master->call['single_forum'] && empty($master->forum_datas[$master->call['forum_id']])) {
            $sql_array = array('SELECT' => 'f.*', 'FROM' => array(FORUMS_TABLE => 'f'), 'LEFT_JOIN' => array());
            if ($load_db_lastread) {
                $sql_array['SELECT'] .= ', ft.mark_time as forum_mark_time';
                $sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id');
            }
            $sql_array['WHERE'] = $forum_sql ? str_replace('t.forum_id', 'f.forum_id', $forum_sql) : '';
            $sql = $db->sql_build_query('SELECT', $sql_array);
            unset($sql_array);
            $result = $db->sql_query($sql);
            while ($row = $db->sql_fetchrow($result)) {
                $forum_id = (int) $row['forum_id'];
                $forum_datas[$forum_id] = $row;
            }
            $db->sql_freeresult($result);
        }
        // Now the topics
        $sql_array = array('SELECT' => 't.*', 'FROM' => array(TOPICS_TABLE => 't'), 'LEFT_JOIN' => array());
        if ($load_db_lastread) {
            $sql_array['SELECT'] .= ', tt.mark_time';
            $sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_TRACK_TABLE => 'tt'), 'ON' => 'tt.user_id = ' . $user->data['user_id'] . ' AND tt.topic_id = t.topic_id');
        } elseif ($load_anon_lastread && empty($master->tracking_topics)) {
            $master->tracking_topics = isset($_COOKIE[$config['cookie_name'] . $tracking_cookie_name]) ? STRIP ? stripslashes($_COOKIE[$config['cookie_name'] . $tracking_cookie_name]) : $_COOKIE[$config['cookie_name'] . $tracking_cookie_name] : '';
            $master->tracking_topics = $master->tracking_topics ? tracking_unserialize($master->tracking_topics) : array();
            if (!$user->data['is_registered']) {
                $user->data['user_lastmark'] = isset($master->tracking_topics['l']) ? (int) (base_convert($master->tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0;
            }
        }
        $sql_where = ($forum_sql ? $forum_sql : '') . $limit_time_sql;
        $sql_where .= $topic_sql ? ($sql_where ? ' AND ' : '') . $topic_sql : '';
        $sql_where .= ($sql_where ? ' AND ' : '') . 't.topic_status <> ' . ITEM_MOVED;
        if ($master->call['single_forum']) {
            $sql_where .= $auth->acl_get('m_approve', $master->call['forum_id']) ? '' : ' AND t.topic_approved = 1';
        } else {
            // only admins and global moderators will see un-approved topics
            // in the forum they have access to.
            $sql_where .= $auth->acl_gets('a_') || $auth->acl_getf_global('m_') ? '' : ' AND t.topic_approved = 1';
        }
        // obtain correct topic count if we display pagination
        if ($display_pagination) {
            $sql = "SELECT COUNT(t.topic_id) AS num_topics\n\t\t\t\tFROM " . TOPICS_TABLE . " t\n\t\t\t\tWHERE {$sql_where}";
            $result = $db->sql_query($sql);
            $total_topics = (int) $db->sql_fetchfield('num_topics');
            $db->sql_freeresult($result);
            // Make sure $start is set to the last page if it exceeds the amount
            if ($start < 0 || $start > $total_topics) {
                $start = $start < 0 ? 0 : floor(($total_topics - 1) / $limit) * $limit;
                // Since we've reached here, $start is not set proper, kill the dupe!
                $url = $display_file . $master->gym_master->html_add_start($start);
                $master->gym_master->seo_kill_dupes($url);
            }
        }
        $sql_array['WHERE'] = $sql_where;
        $sql_array['ORDER_BY'] = $display_order . $order_sql;
        $sql = $db->sql_build_query('SELECT', $sql_array);
        unset($sql_array);
        $result = $db->sql_query_limit($sql, $limit, $start);
        // First we parse the basic data
        while ($row = $db->sql_fetchrow($result)) {
            $forum_id = (int) $row['forum_id'];
            $topic_id = (int) $row['topic_id'];
            // Start with the forum
            if (!$s_global && empty($master->forum_datas[$forum_id])) {
                // www.phpBB-SEO.com SEO TOOLKIT BEGIN
                $phpbb_seo->set_url($forum_datas[$forum_id]['forum_name'], $forum_id, 'forum');
                // www.phpBB-SEO.com SEO TOOLKIT END
                $master->forum_datas[$forum_id] = array_merge($forum_datas[$forum_id], array('forum_url' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", "f={$forum_id}"), 'm_approve' => $auth->acl_get('m_approve', $forum_id)));
                if ($load_db_lastread) {
                    $master->forum_tracking_info[$forum_id] = !empty($forum_datas[$forum_id]['forum_mark_time']) ? $forum_datas[$forum_id]['forum_mark_time'] : $user->data['user_lastmark'];
                } elseif ($load_anon_lastread) {
                    $master->forum_tracking_info[$forum_id] = isset($master->tracking_topics['f'][$forum_id]) ? (int) (base_convert($master->tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']) : $user->data['user_lastmark'];
                }
            }
            if (empty($master->forum_tracking_info[$forum_id])) {
                if ($load_db_lastread) {
                    $master->topic_tracking_info[$topic_id] = !empty($row['mark_time']) ? $row['mark_time'] : $user->data['user_lastmark'];
                } else {
                    if ($load_anon_lastread) {
                        $topic_id36 = base_convert($topic_id, 10, 36);
                        if (isset($master->tracking_topics['t'][$topic_id36])) {
                            $master->tracking_topics['t'][$topic_id] = base_convert($master->tracking_topics['t'][$topic_id36], 36, 10) + $config['board_startdate'];
                        }
                        $master->topic_tracking_info[$topic_id] = isset($master->tracking_topics['t'][$topic_id]) ? $master->tracking_topics['t'][$topic_id] : $user->data['user_lastmark'];
                    }
                }
            } else {
                $master->topic_tracking_info[$topic_id] = $master->forum_tracking_info[$forum_id];
            }
            // Topic post count
            $row['replies'] = !empty($master->forum_datas[$forum_id]['m_approve']) ? $row['topic_replies_real'] : $row['topic_replies'];
            $row['enable_icons'] = !empty($master->forum_datas[$forum_id]['enable_icons']);
            // www.phpBB-SEO.com SEO TOOLKIT BEGIN
            $phpbb_seo->prepare_iurl($row, 'topic', $row['topic_type'] == POST_GLOBAL ? $phpbb_seo->seo_static['global_announce'] : $phpbb_seo->seo_url['forum'][$forum_id]);
            // www.phpBB-SEO.com SEO TOOLKIT END
            $topic_datas[$forum_id][$topic_id] = $row;
            // @TODO deal with last post case ?
            $topic_ids[$topic_id] = $row['topic_first_post_id'];
            $forum_ids[$topic_id] = $forum_id;
        }
        $db->sql_freeresult($result);
        unset($forum_datas);
        // Let's go
        $has_result = false;
        if (!empty($topic_datas)) {
            $has_result = true;
            $bbcode_filter = false;
            if (!class_exists('bbcode')) {
                global $phpbb_root_path, $phpEx;
                require $phpbb_root_path . 'includes/bbcode.' . $phpEx;
            }
            $patterns = $replaces = array();
            if (!empty($master->module_config['html_msg_filters']['pattern'])) {
                $patterns = $master->module_config['html_msg_filters']['pattern'];
                $replaces = $master->module_config['html_msg_filters']['replace'];
                $bbcode_filter = true;
            }
            // Grab ranks
            $ranks = $cache->obtain_ranks();
            // Grab icons
            if (empty($master->icons)) {
                $master->icons = $cache->obtain_icons();
            }
            // Go ahead and pull all data for these topics
            $sql_array = array();
            $sql_array['SELECT'] = $sql_array['WHERE'] = '';
            if ($display_user_info) {
                $sql_array['SELECT'] = 'u.*, z.friend, z.foe, ';
                $sql_array['FROM'] = array(USERS_TABLE => 'u');
                $sql_array['LEFT_JOIN'] = array(array('FROM' => array(ZEBRA_TABLE => 'z'), 'ON' => 'z.user_id = ' . $user->data['user_id'] . ' AND z.zebra_id = p.poster_id'));
                $sql_array['WHERE'] = 'AND u.user_id = p.poster_id';
            }
            $sql_array['SELECT'] .= 'p.*';
            $sql_array['FROM'][POSTS_TABLE] = 'p';
            $sql_array['WHERE'] = $db->sql_in_set('p.post_id', $topic_ids) . $sql_array['WHERE'];
            $sql = $db->sql_build_query('SELECT', $sql_array);
            $result = $db->sql_query($sql);
            while ($row = $db->sql_fetchrow($result)) {
                $forum_id = (int) $row['forum_id'];
                $topic_id = (int) $row['topic_id'];
                // Define the global bbcode bitfield, will be used to load bbcodes
                $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']);
                // Only compute profile data if required
                if ($display_user_info) {
                    // www.phpBB-SEO.com SEO TOOLKIT BEGIN
                    $phpbb_seo->set_user_url($row['username'], $row['poster_id']);
                    // www.phpBB-SEO.com SEO TOOLKIT END
                    // Is a signature attached? Are we going to display it?
                    if ($display_sig && $row['enable_sig']) {
                        $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['user_sig_bbcode_bitfield']);
                    }
                } else {
                    // @TODO deal with last post case ?
                    $row['user_id'] = $row['poster_id'];
                    $row['username'] = $topic_datas[$forum_id][$topic_id]['topic_first_poster_name'];
                    $row['user_colour'] = $topic_datas[$forum_id][$topic_id]['topic_first_poster_colour'];
                }
                $poster_id = (int) $row['poster_id'];
                $post_datas[$forum_id][$topic_id] = array('hide_post' => 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'], 'icon_id' => isset($master->icons[$row['icon_id']]['img'], $master->icons[$row['icon_id']]['height'], $master->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' => false, 'foe' => false);
                // 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 || !$display_user_info) {
                        $user_cache[$poster_id] = array('joined' => '', 'posts' => '', 'from' => '', 'sig' => '', 'sig_bbcode_uid' => '', 'sig_bbcode_bitfield' => '', 'online' => false, 'avatar' => '', 'rank_title' => '', 'rank_image' => '', 'rank_image_src' => '', '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);
                    } else {
                        $user_sig = '';
                        // We add the signature to every posters entry because enable_sig is post dependant
                        if ($display_sig && $row['user_sig']) {
                            $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') ? $master->gym_master->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") : '');
                        $master->gym_master->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')) {
                            $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);
                            }
                        }
                    }
                    $user_cache[$poster_id]['post_author_full'] = get_username_string($display_user_link_key, $poster_id, $row['username'], $row['user_colour'], $row['post_username']);
                    $user_cache[$poster_id]['post_author_colour'] = get_username_string('colour', $poster_id, $row['username'], $row['user_colour'], $row['post_username']);
                    $user_cache[$poster_id]['post_author'] = get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username']);
                    $user_cache[$poster_id]['u_post_author'] = $display_user_link ? get_username_string('profile', $poster_id, $row['username'], $row['user_colour'], $row['post_username']) : '';
                }
            }
            $db->sql_freeresult($result);
            // Load custom profile fields
            if ($display_user_info && $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_cache = $cp->generate_profile_fields_template('grab', $id_cache);
            }
            // Generate online information for user
            if (@$master->call['display_online'] && 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);
            }
            unset($id_cache);
            // Instantiate BBCode
            if (empty($bbcode)) {
                $bbcode = new bbcode(base64_encode($bbcode_bitfield));
            } else {
                $bbcode->bbcode(base64_encode($bbcode_bitfield));
            }
            $prev_post_id = '';
            // Parse messages
            foreach ($forum_ids as $topic_id => $forum_id) {
                if (!isset($post_datas[$forum_id][$topic_id])) {
                    continue;
                }
                $row =& $post_datas[$forum_id][$topic_id];
                $topic_data =& $topic_datas[$forum_id][$topic_id];
                $poster_id = (int) $row['user_id'];
                $l_edited_by = $l_bumped_by = '';
                $s_first_unread = false;
                // 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']) {
                        if ($bbcode_filter) {
                            $user_cache[$poster_id]['sig'] = preg_replace($patterns, $replaces, $user_cache[$poster_id]['sig']);
                        }
                        $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'] = $master->gym_master->smiley_text($user_cache[$poster_id]['sig'], !$master->module_config['html_allow_smilies']);
                    $user_cache[$poster_id]['sig_parsed'] = true;
                } else {
                    // Remove sig
                    $user_cache[$poster_id]['sig'] = '';
                }
                // Parse the message and subject
                $message =& $row['post_text'];
                if ($bbcode_filter) {
                    $message = preg_replace($patterns, $replaces, $message);
                }
                if ($display_sumarize > 0) {
                    $message = $master->gym_master->summarize($message, $display_sumarize, $master->call['display_sumarize_method']);
                    // Clean broken tag at the end of the message
                    $message = preg_replace('`\\<[^\\<\\>]*$`i', ' ...', $message);
                    // Close broken bbcode tags requiring it, only quotes for now
                    $master->gym_master->close_bbcode_tags($message, $row['bbcode_uid']);
                }
                // Parse the message and subject
                $message = censor_text($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 = $master->gym_master->smiley_text($message, !$master->module_config['html_allow_smilies']);
                if ($display_sumarize > 0) {
                    // Clean up
                    static $find = array('`\\<\\!--[^\\<\\>]+--\\>`Ui', '`\\[\\/?[^\\]\\[]*\\]`Ui');
                    $message = preg_replace($find, '', $message);
                }
                // Replace naughty words such as farty pants
                $row['post_subject'] = censor_text(!empty($row['post_subject']) ? $row['post_subject'] : $topic_data['topic_title']);
                // custom profile fields
                $cp_row = array();
                if ($display_user_info && $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;
                // Generate all the URIs ...
                if (!$s_global && !isset($master->module_config['global_exclude_list'][$forum_id])) {
                    $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$forum_id}&amp;t={$topic_id}") . '#p' . $row['post_id'];
                    $view_forum_url = $master->forum_datas[$forum_id]['forum_url'];
                } else {
                    $view_topic_url = $view_forum_url = '';
                }
                $postrow = array('FORUM_NAME' => !$s_global ? $master->forum_datas[$forum_id]['forum_name'] : '', 'U_VIEW_FORUM' => $view_forum_url, 'VIEWS' => $topic_data['topic_views'], 'POST_DATE' => $user->format_date($row['post_time']), 'POST_SUBJECT' => $row['post_subject'], 'MESSAGE' => $message, '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']) ? $master->icons[$row['icon_id']]['img'] : '', 'POST_ICON_IMG_WIDTH' => $topic_data['enable_icons'] && !empty($row['icon_id']) ? $master->icons[$row['icon_id']]['width'] : '', 'POST_ICON_IMG_HEIGHT' => $topic_data['enable_icons'] && !empty($row['icon_id']) ? $master->icons[$row['icon_id']]['height'] : '', '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' => $view_topic_url, 'U_NEWEST_POST' => $post_unread ? append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $forum_id . '&amp;t=' . $topic_id . '&amp;view=unread#unread') : '', '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' => 0, 'S_FRIEND' => $row['friend'] ? true : false, 'S_UNREAD_POST' => $post_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="' . append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$forum_id}&amp;t={$topic_id}&amp;p={$row['post_id']}&amp;view=show") . '#p' . $row['post_id'] . '">', '</a>') : '', 'REPLIES' => $topic_datas[$forum_id][$topic_id]['replies']);
                if ($display_user_info) {
                    $postrow += array('POST_AUTHOR_FULL' => $user_cache[$poster_id]['post_author_full'], 'POST_AUTHOR_COLOUR' => $user_cache[$poster_id]['post_author_colour'], 'POST_AUTHOR' => $user_cache[$poster_id]['post_author'], 'U_POST_AUTHOR' => $user_cache[$poster_id]['u_post_author'], 'SIGNATURE' => $user_cache[$poster_id]['sig'], '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'], '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'], '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_PROFILE' => $user_cache[$poster_id]['profile'], 'U_SEARCH' => $user_cache[$poster_id]['search'], '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']);
                }
                if ($display_post_buttons) {
                    $postrow += array('U_EDIT' => !$user->data['is_registered'] ? '' : ($user->data['user_id'] == $poster_id && $auth->acl_get('f_edit', $forum_id) && ($row['post_time'] > time() - $config['edit_time'] * 60 || !$config['edit_time']) || $auth->acl_get('m_edit', $forum_id) ? 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' => !$user->data['is_registered'] ? '' : ($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['edit_time'] * 60 || !$config['edit_time']) || $auth->acl_get('m_delete', $forum_id) ? append_sid("{$phpbb_root_path}posting.{$phpEx}", "mode=delete&amp;f={$forum_id}&amp;p={$row['post_id']}") : ''), '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_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) : '');
                }
                if (isset($cp_row['row']) && sizeof($cp_row['row'])) {
                    $postrow = array_merge($postrow, $cp_row['row']);
                }
                // 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);
                    }
                }
                // 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));
                    }
                }
                $prev_post_id = $row['post_id'];
                unset($topic_datas[$forum_id][$topic_id]);
            }
            unset($topic_datas, $user_cache);
        }
        $news_desc = false;
        $rules_info = array('forum_rules' => false, 'forum_rules_link' => false);
        // In case we are listing category's children
        if ($master->call['cat_forum']) {
            $forum_id = $master->call['cat_forum'];
        }
        if ($master->call['display_desc']) {
            $news_desc = !empty($master->module_config['html_site_desc']) ? $master->module_config['html_site_desc'] : '';
            if ($master->call['single_forum'] || $master->call['cat_forum']) {
                $news_desc = $master->generate_forum_info($master->forum_datas[$forum_id]);
            }
        }
        if ($master->call['display_rules'] && ($master->call['single_forum'] || $master->call['cat_forum'])) {
            $rules_info = $master->generate_forum_info($master->forum_datas[$forum_id], 'rules');
        }
        $tpl_vars = array('H1_POSTS' => $master->outputs['page_title'], 'DISPLAY_POSTS_H1' => $display_link, 'U_POSTS' => $display_link ? append_sid($display_file) : false, 'DISPLAY_USER_INFO' => $display_user_info, 'DISPLAY_POSTS' => $has_result, 'DISPLAY_POST_BUTTONS' => $display_post_buttons, 'NEWS_DESC' => $news_desc, 'NEWS_RULES' => $rules_info['forum_rules'], 'NEWS_RULES_LINK' => $rules_info['forum_rules_link'], 'REPORTED_IMG' => $user->img('icon_topic_reported', 'POST_REPORTED'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'), 'T_ICONS_PATH' => "{$phpbb_root_path}{$config['icons_path']}/", 'NEWS_IMG_SRC' => $master->gym_master->path_config['gym_img_url'] . 'html_news.gif');
        if ($master->call['single_forum'] || $master->call['cat_forum']) {
            $tpl_vars += array('FORUM_MAP_URL' => $master->module_config['html_allow_cat_map'] ? append_sid($master->gym_master->html_build_url('html_forum_cat_map', $phpbb_seo->seo_url['forum'][$forum_id], $forum_id)) : '', 'FORUM_MAP' => sprintf($user->lang['HTML_MAP_OF'], $master->forum_datas[$forum_id]['forum_name']), 'FORUM_URL' => $master->forum_datas[$forum_id]['forum_url'], 'FORUM_NAME' => $master->forum_datas[$forum_id]['forum_name'], 'S_SINGLE_FORUM' => $master->call['cat_forum'] ? false : true);
        } else {
            $tpl_vars += array('FORUM_MAP' => sprintf($user->lang['HTML_MAP_OF'], $master->module_config['html_sitename']), 'FORUM_MAP_URL' => $master->module_config['html_allow_map'] ? append_sid($master->module_config['html_url'] . $master->url_settings['html_forum_map']) : '', 'FORUM_URL' => append_sid("{$phpbb_root_path}index.{$phpEx}"), 'FORUM_NAME' => $master->module_config['html_sitename']);
        }
        if ($display_user_info) {
            $tpl_vars += array('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'));
        }
        if ($display_post_buttons) {
            $tpl_vars += array('QUOTE_IMG' => $user->img('icon_post_quote', 'REPLY_WITH_QUOTE'), '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'), 'REPORT_IMG' => $user->img('icon_post_report', 'REPORT_POST'), 'WARN_IMG' => $user->img('icon_user_warn', 'WARN_USER'));
        }
        if ($display_pagination) {
            $l_total_topic_s = $total_topics == 0 ? 'TOTAL_TOPICS_ZERO' : 'TOTAL_TOPICS_OTHER';
            $tpl_vars += array('DISPLAY_PAGINATION' => generate_pagination(append_sid($display_file), $total_topics, $limit, $start), 'DISPLAY_PAGE_NUMBER' => on_page($total_topics, $limit, $start), 'DISPLAY_TOTAL_TOPICS' => sprintf($user->lang[$l_total_topic_s], $total_topics));
        }
        $template->assign_vars($tpl_vars);
        unset($tpl_vars);
    }
예제 #15
0
    /**
     * html_output() will build all html output
     * @access private
     */
    function html_output()
    {
        global $phpEx, $db, $config, $phpbb_root_path, $user, $template, $cache, $phpbb_seo;
        $module_obj = null;
        $left_col = $right_col = false;
        // Set up the base href tag, could be done better but saves a file edit this way ( and works too ;-) )
        // Assuming that map.php is either in phpBB's dir or above (not under).
        $bhref_ulr = $phpbb_root_path === './' ? $phpbb_seo->seo_path['phpbb_url'] : str_replace(ltrim($phpbb_root_path, './'), '', $phpbb_seo->seo_path['phpbb_url']);
        $template->assign_vars(array('META' => '<base href="' . $bhref_ulr . '"/>' . "\n", 'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'], 'S_CONTENT_FLOW_BEGIN' => $user->lang['DIRECTION'] == 'ltr' ? 'left' : 'right', 'S_CONTENT_FLOW_END' => $user->lang['DIRECTION'] == 'ltr' ? 'right' : 'left', 'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST')));
        // module action
        if (in_array($this->actions['module_main'], $this->actions['action_modules'])) {
            // List item from the module
            // Add index page in navigation links
            $template->assign_block_vars('navlinks', array('FORUM_NAME' => $user->lang['HTML_MAP'], 'U_VIEW_FORUM' => append_sid($this->html_config['html_url'] . $this->url_config['html_default'])));
            $module_class = $this->actions['action_type'] . '_' . $this->actions['module_main'];
            $module_obj = $this->load_module($module_class, 'html_init', true);
        } else {
            // sitemap index
            // We are working on all available modules
            $left_col = $this->html_index();
        }
        $page_title = (!empty($this->output_data['page_title']) ? $this->output_data['page_title'] : $user->lang['HTML_' . strtoupper($this->actions['html_type'])]) . $this->html_config['extra_title'];
        // Add current page in navigation links
        $template->assign_block_vars('navlinks', array('FORUM_NAME' => $page_title, 'U_VIEW_FORUM' => append_sid($this->url_config['current'])));
        if (!$this->actions['is_active']) {
            header('HTTP/1.1 404 Not Found');
            global $msg_title;
            $msg_title = $user->lang['GYM_ERROR_404'];
            trigger_error('GYM_ERROR_404_EXPLAIN');
        }
        if (!$this->actions['is_auth']) {
            header('HTTP/1.1 401 Unauthorized');
            if ($user->data['user_id'] != ANONYMOUS) {
                trigger_error('GYM_ERROR_401');
            }
            login_box('', $user->lang['GYM_LOGIN']);
        }
        // Let's kill duplicate now !
        if (!empty($this->url_config['current'])) {
            $this->seo_kill_dupes(append_sid($this->url_config['current']));
        }
        $template->set_filenames(array('body' => 'gym_sitemaps/index_body.html'));
        $this->cache_config['do_cache_main'] = (bool) ($this->cache_config['do_cache_main'] && $this->actions['is_public']);
        $this->cache_config['do_cache_opt'] = (bool) ($this->cache_config['do_cache_opt'] && $this->actions['is_public']);
        $cache_find = array('`(\\?|&amp;|&)sid\\=[a-z0-9]+`i', '`[\\s]+`');
        $cache_replace = array('', ' ');
        $ssl_bit = $phpbb_seo->ssl['use'] ? 'ssl_' : '';
        // Main output
        if (!empty($this->output_data['left_col_tpl'])) {
            $template->set_filenames(array('left_col' => $this->output_data['left_col_tpl']));
            if ($this->cache_config['do_cache_main'] && !empty($this->output_data['left_col_cache_file'])) {
                $cache_file = '_gym_html_' . $this->output_data['left_col_cache_file'] . '_' . $ssl_bit . $user->data['user_lang'] . '_' . $this->start;
                if (($left_col = $cache->get($cache_file)) === false) {
                    $module_obj->html_main();
                    $left_col = $template->assign_display('left_col', '', true);
                    // Strip whitespaces and sids
                    $left_col = preg_replace($cache_find, $cache_replace, $left_col);
                    $cache->put($cache_file, $left_col, $this->cache_config['main_cache_ttl']);
                }
            }
            if (!$left_col) {
                $module_obj->html_main();
                $left_col = $template->assign_display('left_col', '', true);
            }
        }
        // Optional output
        if (!empty($this->output_data['right_col'])) {
            if ($this->cache_config['do_cache_opt'] && !empty($this->output_data['right_col_cache_file'])) {
                $cache_file = '_gym_html_' . $this->output_data['right_col_cache_file'] . '_' . $ssl_bit . $user->data['user_lang'];
                if (($right_col = $cache->get($cache_file)) === false) {
                    $module_obj->html_module();
                    $template->set_filenames(array('right_col' => $this->output_data['right_col_tpl']));
                    $right_col = $template->assign_display('right_col', '', true);
                    // Strip whitespaces and sids
                    $right_col = preg_replace($cache_find, $cache_replace, $right_col);
                    $cache->put($cache_file, $right_col, $this->cache_config['opt_cache_ttl']);
                }
            }
            if (!$right_col) {
                $module_obj->html_module();
                $template->set_filenames(array('right_col' => $this->output_data['right_col_tpl']));
                $right_col = $template->assign_display('right_col', '', true);
            }
        }
        unset($module_obj);
        $tpl_data = array();
        if ($this->actions['display_stats']) {
            // Set some stats, get posts count from forums data if we... hum... retrieve all forums data
            $total_posts = $config['num_posts'];
            $total_topics = $config['num_topics'];
            $total_users = $config['num_users'];
            $l_total_user_s = $total_users == 0 ? 'TOTAL_USERS_ZERO' : 'TOTAL_USERS_OTHER';
            $l_total_post_s = $total_posts == 0 ? 'TOTAL_POSTS_ZERO' : 'TOTAL_POSTS_OTHER';
            $l_total_topic_s = $total_topics == 0 ? 'TOTAL_TOPICS_ZERO' : 'TOTAL_TOPICS_OTHER';
            $tpl_data += array('TOTAL_POSTS' => sprintf($user->lang[$l_total_post_s], $total_posts), 'TOTAL_TOPICS' => sprintf($user->lang[$l_total_topic_s], $total_topics), 'TOTAL_USERS' => sprintf($user->lang[$l_total_user_s], $total_users));
            if ($this->html_config['html_allow_profile']) {
                $tpl_data += array('NEWEST_USER' => sprintf($user->lang['NEWEST_USER'], get_username_string($this->html_config['html_allow_profile_links'] ? 'full' : 'no_profile', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])));
            }
        }
        // Generate birthday list if required ...
        if ($this->actions['display_birthdays']) {
            $birthday_list = '';
            $now = phpbb_gmgetdate(time() + $user->timezone + $user->dst);
            // Display birthdays of 29th february on 28th february in non-leap-years
            $leap_year_birthdays = '';
            if ($now['mday'] == 28 && $now['mon'] == 2 && !$user->format_date(time(), 'L')) {
                $leap_year_birthdays = " OR user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', 29, 2)) . "%'";
            }
            $sql = 'SELECT u.user_id, u.username, u.user_colour, u.user_birthday
				FROM ' . USERS_TABLE . ' u
				LEFT JOIN ' . BANLIST_TABLE . " b ON (u.user_id = b.ban_userid)\n\t\t\t\tWHERE (b.ban_id IS NULL\n\t\t\t\t\tOR b.ban_exclude = 1)\n\t\t\t\t\tAND (u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%' {$leap_year_birthdays})\n\t\t\t\t\tAND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
            $result = $db->sql_query($sql);
            while ($row = $db->sql_fetchrow($result)) {
                $birthday_list .= ($birthday_list != '' ? ', ' : '') . get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
                if ($age = (int) substr($row['user_birthday'], -4)) {
                    $birthday_list .= ' (' . ($now['year'] - $age) . ')';
                }
            }
            $db->sql_freeresult($result);
            $tpl_data += array('BIRTHDAY_LIST' => $birthday_list, 'S_DISPLAY_BIRTHDAY_LIST' => !empty($birthday_list));
        }
        $template->assign_vars($tpl_data + array('S_SINGLE_TRAKING' => !empty($this->output_data['single_traking']) ? true : false, 'S_LOGIN_ACTION' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=login'), 'S_SEO_FORUM' => strpos($config['default_lang'], 'fr') !== false ? 'fr/' : 'en/', 'LEFT_COL' => $left_col, 'RIGHT_COL' => $right_col));
        if ($this->actions['pagination_limit'] > 0) {
            // Add page number to title
            $page_title .= $this->start > 0 ? ' - ' . $user->lang['HTML_PAGE'] . ' ' . (floor($this->start / $this->actions['pagination_limit']) + 1) : '';
        }
        page_header($page_title, $this->html_config['html_disp_online']);
        if (!empty($this->html_config['html_logo_url'])) {
            $template->assign_vars(array('SITE_LOGO_IMG' => '<img src="' . $this->path_config['gym_img_url'] . $this->html_config['html_logo_url'] . '" alt="' . $this->output_data['page_title'] . '" />'));
        }
        page_footer();
        return;
    }
예제 #16
0
 /**
  * Helper to get the users current age
  *
  * @param string $user_birthday The users birth date (e.g.: 20-10-1990)
  * @return int The users age in years
  */
 protected function get_user_age($user_birthday)
 {
     static $now;
     if (!isset($now)) {
         // Get the current UTC timestamp
         $now = phpbb_gmgetdate();
     }
     // Get birth year from the stored birth date
     $birthday_year = (int) substr($user_birthday, -4);
     // Return the users age
     return $birthday_year ? (int) max(0, $now['year'] - $birthday_year) : 0;
 }
예제 #17
0
		$legend[] = '<span' . $colour_text . '>' . $group_name . '</span>';
	}
	else
	{
		$legend[] = '<a' . $colour_text . ' href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp;g=' . $row['group_id']) . '">' . $group_name . '</a>';
	}
}
$db->sql_freeresult($result);

$legend = implode(', ', $legend);

// Generate birthday list if required ...
$birthday_list = '';
if ($config['load_birthdays'] && $config['allow_birthdays'] && $auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel'))
{
	$now = phpbb_gmgetdate(time() + $user->timezone + $user->dst);

	// Display birthdays of 29th february on 28th february in non-leap-years
	$leap_year_birthdays = '';
	if ($now['mday'] == 28 && $now['mon'] == 2 && !$user->format_date(time(), 'L'))
	{
		$leap_year_birthdays = " OR u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', 29, 2)) . "%'";
	}

	$sql = 'SELECT u.user_id, u.username, u.user_colour, u.user_birthday
		FROM ' . USERS_TABLE . ' u
		LEFT JOIN ' . BANLIST_TABLE . " b ON (u.user_id = b.ban_userid)
		WHERE (b.ban_id IS NULL
			OR b.ban_exclude = 1)
			AND (u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%' $leap_year_birthdays)
			AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
예제 #18
0
 /**
  * Get date listed in array
  *
  * @param string $call_date Date
  *
  * @return null
  */
 protected function get_month($call_date)
 {
     $this->make_timestamp($call_date);
     // last or first day of some months need to be treated in a special way
     if (!empty($this->mini_cal_month)) {
         $time = $this->user->create_datetime();
         $now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset());
         $today_timestamp = $now[0];
         $cur_month = date("n", $today_timestamp);
         $correct_month = $cur_month + $this->mini_cal_month;
         // move back or forth the correct number of years
         while ($correct_month < 1 || $correct_month > self::MONTHS_PER_YEAR) {
             $correct_month = $correct_month < 1 ? $correct_month + self::MONTHS_PER_YEAR : $correct_month - self::MONTHS_PER_YEAR;
         }
         // fix incorrect months
         while (date("n", $this->stamp) != $correct_month) {
             // Go back one day or move forward in order to
             // get to the correct month
             $this->stamp = date("n", $this->stamp) > $correct_month ? $this->stamp - self::TIME_DAY : $this->stamp + self::TIME_DAY;
         }
     }
     $this->dateYYYY = (int) date("Y", $this->stamp);
     $this->dateMM = (int) date("n", $this->stamp);
     $this->ext_dateMM = date("F", $this->stamp);
     $this->dateDD = (int) date("d", $this->stamp);
     $this->daysMonth = (int) date("t", $this->stamp);
     for ($i = 1; $i < $this->daysMonth + 1; $i++) {
         $this->make_timestamp("{$i} {$this->ext_dateMM} {$this->dateYYYY}");
         $this->day[] = array('0' => "{$i}", '1' => $this->dateMM, '2' => $this->dateYYYY, '3' => date('w', $this->stamp));
     }
 }
예제 #19
0
파일: index.php 프로젝트: Alexey3112/phpbb
while ($row = $db->sql_fetchrow($result)) {
    $colour_text = $row['group_colour'] ? ' style="color:#' . $row['group_colour'] . '"' : '';
    $group_name = $row['group_type'] == GROUP_SPECIAL ? $user->lang['G_' . $row['group_name']] : $row['group_name'];
    if ($row['group_name'] == 'BOTS' || $user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')) {
        $legend[] = '<span' . $colour_text . '>' . $group_name . '</span>';
    } else {
        $legend[] = '<a' . $colour_text . ' href="' . append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=group&amp;g=' . $row['group_id']) . '">' . $group_name . '</a>';
    }
}
$db->sql_freeresult($result);
$legend = implode($user->lang['COMMA_SEPARATOR'], $legend);
// Generate birthday list if required ...
$birthday_list = array();
if ($config['load_birthdays'] && $config['allow_birthdays'] && $auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel')) {
    $time = $user->create_datetime();
    $now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset());
    // Display birthdays of 29th february on 28th february in non-leap-years
    $leap_year_birthdays = '';
    if ($now['mday'] == 28 && $now['mon'] == 2 && !$time->format('L')) {
        $leap_year_birthdays = " OR u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', 29, 2)) . "%'";
    }
    $sql = 'SELECT u.user_id, u.username, u.user_colour, u.user_birthday
		FROM ' . USERS_TABLE . ' u
		LEFT JOIN ' . BANLIST_TABLE . " b ON (u.user_id = b.ban_userid)\n\t\tWHERE (b.ban_id IS NULL\n\t\t\tOR b.ban_exclude = 1)\n\t\t\tAND (u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%' {$leap_year_birthdays})\n\t\t\tAND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
    $result = $db->sql_query($sql);
    while ($row = $db->sql_fetchrow($result)) {
        $birthday_username = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
        $birthday_year = (int) substr($row['user_birthday'], -4);
        $birthday_age = $birthday_year ? max(0, $now['year'] - $birthday_year) : '';
        $template->assign_block_vars('birthdays', array('USERNAME' => $birthday_username, 'AGE' => $birthday_age));
        // For 3.0 compatibility
예제 #20
0
    /**
     * Gets the birthday list
     */
    public function get_birthday_list()
    {
        global $config, $auth, $db, $user;
        $birthday_list = '';
        $fStateChanged = $this->foreground();
        if ($config['load_birthdays'] && $config['allow_birthdays'] && $auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel')) {
            $now = phpbb_gmgetdate(time() + $user->timezone + $user->dst);
            // Display birthdays of 29th february on 28th february in non-leap-years
            $leap_year_birthdays = '';
            if ($now['mday'] == 28 && $now['mon'] == 2 && !$user->format_date(time(), 'L')) {
                $leap_year_birthdays = " OR u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', 29, 2)) . "%'";
            }
            $sql = 'SELECT u.user_id, u.username, u.user_colour, u.user_birthday, u.user_type 
				FROM ' . USERS_TABLE . ' u
				LEFT JOIN ' . BANLIST_TABLE . " b ON (u.user_id = b.ban_userid)\n\t\t\t\tWHERE (b.ban_id IS NULL\n\t\t\t\t\tOR b.ban_exclude = 1)\n\t\t\t\t\tAND (u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%' {$leap_year_birthdays})\n\t\t\t\t\tAND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
            $result = $db->sql_query($sql);
            while ($row = $db->sql_fetchrow($result)) {
                $birthday_list .= ($birthday_list != '' ? ', ' : '') . $this->get_username_link($row['user_type'], $row['user_id'], $row['username'], $row['user_colour']);
                if ($age = (int) substr($row['user_birthday'], -4)) {
                    $birthday_list .= ' (' . max(0, $now['year'] - $age) . ')';
                }
            }
            $db->sql_freeresult($result);
        }
        $this->restore_state($fStateChanged);
        return $birthday_list;
    }