public static function load_cp_fields($user_ids) { // Only get the rows for those we have not gotten already $user_ids = array_diff($user_ids, array_keys(self::$cp_fields)); if (!sizeof($user_ids)) { return; } // Load custom profile fields if (phpbb::$config['load_cpf_viewtopic']) { phpbb::_include('functions_profile_fields', false, 'custom_profile'); $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', $user_ids); // filter out fields not to be displayed on viewtopic. Yes, it's a hack, but this shouldn't break any MODs. foreach ($profile_fields_tmp as $profile_user_id => $profile_fields) { self::$cp_fields[$profile_user_id] = array(); foreach ($profile_fields as $used_ident => $profile_field) { if ($profile_field['data']['field_show_on_vt']) { self::$cp_fields[$profile_user_id][$used_ident] = $profile_field; } } } unset($profile_fields_tmp); } }
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(); }
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 = getdate(time() + $user->timezone + $user->dst - date('Z')); // 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, $phpbb_seo->seo_static['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; include_once $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&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&action=aim&u={$poster_id}") : '', 'msn' => $row['user_msnm'] && $auth->acl_get('u_sendim') ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=contact&action=msnm&u={$poster_id}") : '', 'yim' => $row['user_yim'] ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($row['user_yim']) . '&.src=pg' : '', 'jabber' => $row['user_jabber'] && $auth->acl_get('u_sendim') ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=contact&action=jabber&u={$poster_id}") : '', 'search' => $auth->acl_get('u_search') ? append_sid("{$phpbb_root_path}search.{$phpEx}", "author_id={$poster_id}&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&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'] . '&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}&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&mode=report_details&f=' . $forum_id . '&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&mode=approve_details&f=' . $forum_id . '&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 . '&t=' . $topic_id . '&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}&t={$topic_id}&p={$row['post_id']}&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&mode=compose&action=quotepost&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&f={$forum_id}&p={$row['post_id']}") : ''), 'U_QUOTE' => $auth->acl_get('f_reply', $forum_id) ? append_sid("{$phpbb_root_path}posting.{$phpEx}", "mode=quote&f={$forum_id}&p={$row['post_id']}") : '', 'U_INFO' => $auth->acl_get('m_info', $forum_id) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=main&mode=post_details&f={$forum_id}&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&f={$forum_id}&p={$row['post_id']}") : ''), 'U_REPORT' => $auth->acl_get('f_report', $forum_id) ? append_sid("{$phpbb_root_path}report.{$phpEx}", 'f=' . $forum_id . '&p=' . $row['post_id']) : '', 'U_NOTES' => $auth->acl_getf_global('m_') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&mode=user_notes&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&mode=warn_post&f=' . $forum_id . '&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); }
} } } $db->sql_freeresult($result); // Load custom profile fields if ($config['load_cpf_viewtopic']) { if (!class_exists('custom_profile')) { 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);
} $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']); $template->assign_vars($karmamod->show_profile($member)); // 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(); } $template->assign_vars(array( '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'], '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']),
/** * Get user data * * grabs the data on the user and places it in the self::$user array * * @param int|bool $id The user_id (or multiple user_ids if given an array) of the user we want to grab the data for * @param bool $user_queue If user_queue is true then we just grab the user_ids from the user_queue, otherwise we select data from $id. */ public function get_user_data($id, $user_queue = false, $username = false) { global $user, $db, $phpbb_root_path, $phpEx, $config, $auth, $cp; // if we are using the user_queue, set $user_id as that for consistency if ($user_queue) { $id = self::$user_queue; } blog_plugins::plugin_do('user_data_start'); // this holds the user_id's we will query $users_to_query = array(); // if the $user_id isn't an array, make it one for consistency if (!is_array($id)) { $id = array(intval($id)); } if ($username) { $sql = 'SELECT user_id FROM ' . USERS_TABLE . ' WHERE username_clean = \'' . $db->sql_escape(utf8_clean_string($username)) . '\''; $result = $db->sql_query($sql); $id[] = $db->sql_fetchfield('user_id', $result); $db->sql_freeresult($result); } if (!sizeof($id)) { return; } $id[] = 1; foreach ($id as $i) { if ($i && !isset(self::$user[$i]) && !in_array($i, $users_to_query)) { $users_to_query[] = (int) $i; } } if (!sizeof($users_to_query)) { return; } // Grab all profile fields from users in id cache for later use - similar to the poster cache if ($config['user_blog_custom_profile_enable']) { if (!class_exists('custom_profile')) { include $phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx; $cp = new custom_profile(); } $profile_fields_cache = $cp->generate_profile_fields_template('grab', $users_to_query); } // Grab user status information $status_data = array(); $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', $users_to_query) . ' GROUP BY session_user_id'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $status_data[$row['session_user_id']] = $row; } $db->sql_freeresult($result); $update_time = $config['load_online_time'] * 60; // Get the rest of the data on the users and parse everything we need $sql = 'SELECT * FROM ' . USERS_TABLE . ' WHERE ' . $db->sql_in_set('user_id', $users_to_query); blog_plugins::plugin_do_ref('user_data_sql', $sql); $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $user_id = $row['user_id']; blog_plugins::plugin_do_ref('user_data_while', $row); // view profile link $row['view_profile'] = append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=viewprofile&u=" . $user_id); // Full username, with colour $row['username_full'] = get_username_string('full', $user_id, $row['username'], $row['user_colour']); // format the color correctly $row['user_colour'] = get_username_string('colour', $user_id, $row['username'], $row['user_colour']); // Avatar $row['avatar'] = get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']); // Rank get_user_rank($row['user_rank'], $row['user_posts'], $row['rank_title'], $row['rank_img'], $row['rank_img_src']); if ($row['user_type'] != USER_IGNORE && $row['user_id'] != ANONYMOUS) { // Online/Offline Status $row['status'] = isset($status_data[$user_id]) && time() - $update_time < $status_data[$user_id]['online_time'] && ($status_data[$user_id]['viewonline'] && $row['user_allow_viewonline'] || $auth->acl_get('u_viewonline')) ? true : false; // IM Links $row['aim_url'] = $row['user_aim'] ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=contact&action=aim&u={$user_id}") : ''; $row['icq_url'] = $row['user_icq'] ? 'http://www.icq.com/people/webmsg.php?to=' . $row['user_icq'] : ''; $row['jabber_url'] = $row['user_jabber'] ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=contact&action=jabber&u={$user_id}") : ''; $row['msn_url'] = $row['user_msnm'] ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=contact&action=msnm&u={$user_id}") : ''; $row['yim_url'] = $row['user_yim'] ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . $row['user_yim'] . '&.src=pg' : ''; // PM and email links $row['email_url'] = $config['board_email_form'] && $config['email_enable'] ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=email&u={$user_id}") : ($config['board_hide_emails'] && !$auth->acl_get('a_email') ? '' : 'mailto:' . $row['user_email']); $row['pm_url'] = $row['user_id'] != ANONYMOUS && $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&mode=compose&u={$user_id}") : ''; // get the custom profile fields if the admin wants them if ($config['user_blog_custom_profile_enable']) { $row['cp_row'] = isset($profile_fields_cache[$user_id]) ? $cp->generate_profile_fields_template('show', false, $profile_fields_cache[$user_id]) : array(); } } else { $row = array_merge($row, array('status' => false, 'aim_url' => '', 'icq_url' => '', 'jabber_url' => '', 'msn_url' => '', 'yim_url' => '', 'email_url' => '', 'pm_url' => '')); } // now lets put everything in the user array self::$user[$user_id] = $row; } $db->sql_freeresult($result); unset($status_data, $row); // if we did use the user_queue, reset it if ($user_queue) { self::$user_queue = array(); } if ($username) { if (isset($user_id) && $user_id != ANONYMOUS) { // Grab all profile fields from users in id cache for later use - similar to the poster cache if ($config['user_blog_custom_profile_enable']) { if (!class_exists('custom_profile')) { include $phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx; $cp = new custom_profile(); } $profile_fields_cache = $cp->generate_profile_fields_template('grab', $user_id); } // Grab user status information $status_data = array(); $sql = 'SELECT session_user_id, MAX(session_time) AS online_time, MIN(session_viewonline) AS viewonline FROM ' . SESSIONS_TABLE . ' WHERE session_user_id = ' . intval($user_id) . ' GROUP BY session_user_id'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $status_data[$row['session_user_id']] = $row; } $db->sql_freeresult($result); $update_time = $config['load_online_time'] * 60; self::$user[$user_id]['status'] = isset($status_data[$user_id]) && time() - $update_time < $status_data[$user_id]['online_time'] && ($status_data[$user_id]['viewonline'] && $row['user_allow_viewonline'] || $auth->acl_get('u_viewonline')) ? true : false; unset($status_data); return $user_id; } else { return false; } } else { // replace any non-existing users with the anonymous user. foreach ($id as $i) { if ($i && !array_key_exists($i, self::$user)) { self::$user[$i] = self::$user[1]; } } } }
function get_user_info_func($xmlrpc_params) { global $db, $user, $auth, $template, $config, $phpbb_root_path, $phpEx, $table_prefix; $user->setup(array('memberlist', 'groups')); if (!$auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel')) { if ($user->data['user_id'] != ANONYMOUS) { trigger_error('NO_VIEW_USERS'); } trigger_error('LOGIN_EXPLAIN_VIEWPROFILE'); } $params = php_xmlrpc_decode($xmlrpc_params); $username = $params[0]; if (isset($params[1]) && !empty($params[1])) { $user_id = $params[1]; } elseif (isset($params[0]) && !empty($params[0])) { $username = $params[0]; $user_id = get_user_id_by_name($username); } else { $user_id = $user->data['user_id']; } $user_id = intval($user_id); // Display a profile if (!$user_id) { trigger_error('NO_USER'); } // Get user... $sql = 'SELECT * FROM ' . USERS_TABLE . "\r\r\n WHERE 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']; // Do the SQL thang $sql = 'SELECT g.group_id, g.group_name, g.group_type FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . " ug\r\r\n WHERE ug.user_id = {$user_id}\r\r\n AND g.group_id = ug.group_id" . (!$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') ? ' AND g.group_type <> ' . GROUP_HIDDEN : '') . ' AND ug.user_pending = 0 ORDER BY g.group_type, g.group_name'; $result = $db->sql_query($sql); $group_options = ''; while ($row = $db->sql_fetchrow($result)) { 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_options .= $row['group_id'] == $member['group_id'] ? $row['group_name'] . " *\n" : $row['group_name'] . "\n"; } $group_options = trim($group_options); $db->sql_freeresult($result); // What colour is the zebra $sql = 'SELECT friend, foe FROM ' . ZEBRA_TABLE . "\r\r\n WHERE zebra_id = {$user_id}\r\r\n 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']) { if ($config['version'] < '3.0.3') { $sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline, session_page FROM ' . SESSIONS_TABLE . "\r\r\n WHERE session_user_id = {$user_id}\r\r\n GROUP BY session_page\r\r\n ORDER BY session_time DESC"; } else { $sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline, session_page, session_forum_id FROM ' . SESSIONS_TABLE . "\r\r\n WHERE session_user_id = {$user_id}\r\r\n GROUP BY session_page, session_forum_id\r\r\n ORDER BY session_time DESC"; } $result = $db->sql_query_limit($sql, 1); $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; $member['session_page'] = isset($row['session_page']) ? $row['session_page'] : 0; $member['session_forum_id'] = isset($row['session_forum_id']) ? $row['session_forum_id'] : 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('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&mode=overview&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&mode=user&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) : '', '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&add=' . urlencode(htmlspecialchars_decode($member['username']))) : '', 'U_ADD_FOE' => !$friend && !$foe && $foes_enabled ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=zebra&mode=foes&add=' . urlencode(htmlspecialchars_decode($member['username']))) : '', 'U_REMOVE_FRIEND' => $friend && $friends_enabled ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=zebra&remove=1&usernames[]=' . $user_id) : '', 'U_REMOVE_FOE' => $foe && $foes_enabled ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=zebra&remove=1&mode=foes&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)); } $custom_fields_list = get_custom_fields(); if (!empty($member['user_sig'])) { $custom_fields_list[] = new xmlrpcval(array('name' => new xmlrpcval($user->lang['SIGNATURE'], 'base64'), 'value' => new xmlrpcval(basic_clean($member['user_sig']), 'base64')), 'struct'); } if ($member['user_id'] == $user->data['user_id'] && push_table_exists()) { $sql = "SELECT * FROM " . $table_prefix . "tapatalk_users WHERE userid = '" . $member['user_id'] . "'"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); if (!empty($row)) { array_push($custom_fields_list, new xmlrpcval(array('name' => new xmlrpcval('Notification - Message', 'base64'), 'value' => new xmlrpcval($row['pm'] ? 'On' : 'Off', 'base64')), 'struct')); array_push($custom_fields_list, new xmlrpcval(array('name' => new xmlrpcval('Notification - Quoted', 'base64'), 'value' => new xmlrpcval($row['quote'] ? 'On' : 'Off', 'base64')), 'struct')); array_push($custom_fields_list, new xmlrpcval(array('name' => new xmlrpcval('Notification - Mentioned', 'base64'), 'value' => new xmlrpcval($row['tag'] ? 'On' : 'Off', 'base64')), 'struct')); array_push($custom_fields_list, new xmlrpcval(array('name' => new xmlrpcval('Notification - New Topic', 'base64'), 'value' => new xmlrpcval($row['newtopic'] ? 'On' : 'Off', 'base64')), 'struct')); array_push($custom_fields_list, new xmlrpcval(array('name' => new xmlrpcval('Notification - Replies', 'base64'), 'value' => new xmlrpcval($row['subscribe'] ? 'On' : 'Off', 'base64')), 'struct')); } } $user_avatar_url = get_user_avatar_url($member['user_avatar'], $member['user_avatar_type']); // Forum info $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, left_id, right_id FROM ' . FORUMS_TABLE . ' ORDER BY left_id ASC'; $result = $db->sql_query($sql, 600); $forum_data = array(); while ($row = $db->sql_fetchrow($result)) { $forum_data[$row['forum_id']] = $row; } $db->sql_freeresult($result); // get user current activity preg_match('#^([a-z0-9/_-]+)#i', $member['session_page'], $on_page); if (!sizeof($on_page)) { $on_page[1] = ''; } switch ($on_page[1]) { case 'index': $location = $user->lang['INDEX']; break; case 'adm/index': $location = $user->lang['ACP']; break; case 'posting': case 'viewforum': case 'viewtopic': $forum_id = $member['session_forum_id']; if ($forum_id && $auth->acl_get('f_list', $forum_id)) { $location = ''; if ($forum_data[$forum_id]['forum_type'] == FORUM_LINK) { $location = sprintf($user->lang['READING_LINK'], $forum_data[$forum_id]['forum_name']); break; } switch ($on_page[1]) { case 'posting': preg_match('#mode=([a-z]+)#', $member['session_page'], $on_page); $posting_mode = !empty($on_page[1]) ? $on_page[1] : ''; switch ($posting_mode) { case 'reply': case 'quote': $location = sprintf($user->lang['REPLYING_MESSAGE'], $forum_data[$forum_id]['forum_name']); break; default: $location = sprintf($user->lang['POSTING_MESSAGE'], $forum_data[$forum_id]['forum_name']); break; } break; case 'viewtopic': $location = sprintf($user->lang['READING_TOPIC'], $forum_data[$forum_id]['forum_name']); break; case 'viewforum': $location = sprintf($user->lang['READING_FORUM'], $forum_data[$forum_id]['forum_name']); break; } } else { $location = $user->lang['INDEX']; } break; case 'search': $location = $user->lang['SEARCHING_FORUMS']; break; case 'faq': $location = $user->lang['VIEWING_FAQ']; break; case 'viewonline': $location = $user->lang['VIEWING_ONLINE']; break; case 'memberlist': $location = strpos($member['session_page'], 'mode=viewprofile') !== false ? $user->lang['VIEWING_MEMBER_PROFILE'] : $user->lang['VIEWING_MEMBERS']; break; case 'mcp': $location = $user->lang['VIEWING_MCP']; break; case 'ucp': $location = $user->lang['VIEWING_UCP']; // Grab some common modules $url_params = array('mode=register' => 'VIEWING_REGISTER', 'i=pm&mode=compose' => 'POSTING_PRIVATE_MESSAGE', 'i=pm&' => 'VIEWING_PRIVATE_MESSAGES', 'i=profile&' => 'CHANGING_PROFILE', 'i=prefs&' => 'CHANGING_PREFERENCES'); foreach ($url_params as $param => $lang) { if (strpos($member['session_page'], $param) !== false) { $location = $user->lang[$lang]; break; } } break; case 'download/file': $location = $user->lang['DOWNLOADING_FILE']; break; case 'report': $location = $user->lang['REPORTING_POST']; break; case 'mobiquo/mobiquo': $location = 'On Tapatalk'; break; default: $location = $user->lang['INDEX']; break; } $user_info = array('user_id' => new xmlrpcval($member['user_id']), 'username' => new xmlrpcval(basic_clean($member['username']), 'base64'), 'user_type' => check_return_user_type($member['username']), 'post_count' => new xmlrpcval($member['user_posts'], 'int'), 'reg_time' => new xmlrpcval(mobiquo_iso8601_encode($member['user_regdate']), 'dateTime.iso8601'), 'timestamp_reg' => new xmlrpcval($member['user_regdate'], 'string'), 'last_activity_time' => new xmlrpcval(mobiquo_iso8601_encode($template->_rootref['VISITED']), 'dateTime.iso8601'), 'timestamp' => new xmlrpcval($template->_rootref['VISITED'], 'string'), 'is_online' => new xmlrpcval($template->_rootref['S_ONLINE'], 'boolean'), 'accept_pm' => new xmlrpcval($template->_rootref['U_PM'] ? true : false, 'boolean'), 'display_text' => new xmlrpcval('', 'base64'), 'icon_url' => new xmlrpcval($user_avatar_url), 'current_activity' => new xmlrpcval($location, 'base64'), 'custom_fields_list' => new xmlrpcval($custom_fields_list, 'array')); $xmlrpc_user_info = new xmlrpcval($user_info, 'struct'); return new xmlrpcresp($xmlrpc_user_info); }
AND c.ad_id = ' . $ad_id; $result = $db->sql_query_limit($sql, 1); $report = $db->sql_fetchrow($result); $db->sql_freeresult($result); $template->assign_vars(array('REPORTER' => get_username_string('full', $report['user_id'], $report['username'], $report['user_colour']), 'REPORT_TEXT' => $report['report_text'])); } $allow_bbcode = $allow_urls = $allow_smilies = true; $row['bbcode_options'] = ($allow_bbcode ? OPTION_FLAG_BBCODE : 0) + ($allow_smilies ? OPTION_FLAG_SMILIES : 0) + ($allow_urls ? OPTION_FLAG_LINKS : 0); $description = generate_text_for_display($row['ad_description'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']); // Load custom profile fields if (!class_exists('custom_profile')) { 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 $profile_fields_tmp = $cp->generate_profile_fields_template('grab', $row['ad_poster_id']); // filter out fields not to be displayed on classifieds $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_cl']) { $profile_fields_cache[$profile_user_id][$used_ident] = $profile_field; } } } unset($profile_fields_tmp); $cp_row = array(); $cp_row = isset($profile_fields_cache[$row['ad_poster_id']]) ? $cp->generate_profile_fields_template('show', false, $profile_fields_cache[$row['ad_poster_id']]) : array(); if ($row['ad_status'] == 0) { $ad_status = $row['ad_expire'] > time() ? false : $user->lang['CL_EXPIRED'];
/** * Display topic section for support/tracker/etc * * @param object $topic The topic object * @param titania_sort $sort The sort object (includes/tools/sort.php) */ public static function display_topic($topic, $sort = false) { if ($sort === false) { // Setup the sort tool $sort = self::build_sort(); } $sort->request(); $sql_ary = array('SELECT' => 'p.*', 'FROM' => array(TITANIA_POSTS_TABLE => 'p'), 'WHERE' => 'p.topic_id = ' . (int) $topic->topic_id . self::sql_permissions('p.'), 'ORDER_BY' => $sort->get_order_by()); // Main SQL Query $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary); // Handle pagination if (!$sort->sql_count($sql_ary, 'p.post_id')) { // No results...no need to query more... return; } $sort->build_pagination($topic->get_url()); // Get the data $post_ids = $user_ids = array(); $last_post_time = 0; // tracking $result = phpbb::$db->sql_query_limit($sql, $sort->limit, $sort->start); while ($row = phpbb::$db->sql_fetchrow($result)) { self::$posts[$row['post_id']] = $row; self::$posts[$row['post_id']]['attachments'] = array(); $post_ids[] = $row['post_id']; $user_ids[] = $row['post_user_id']; $user_ids[] = $row['post_edit_user']; $user_ids[] = $row['post_delete_user']; $last_post_time = $row['post_time']; // to set tracking } phpbb::$db->sql_freeresult($result); // Grab the tracking data $last_mark_time = titania_tracking::get_track(TITANIA_TOPIC, $topic->topic_id); // Store tracking data titania_tracking::track(TITANIA_TOPIC, $topic->topic_id, $last_post_time); // load the user data users_overlord::load($user_ids); phpbb::_include('functions_profile_fields', false, 'custom_profile'); $cp = new custom_profile(); $post = new titania_post($topic->topic_type, $topic); $attachments = new titania_attachment($topic->topic_type, false); // Grab all attachments $attachments_set = $attachments->load_attachments_set($post_ids); // Loop de loop $prev_post_time = 0; foreach ($post_ids as $post_id) { $post->__set_array(self::$posts[$post_id]); $attachments->clear_attachments(); if (isset($attachments_set[$post_id])) { $attachments->store_attachments($attachments_set[$post_id]); } // Parse attachments before outputting the message $message = $post->generate_text_for_display(); $parsed_attachments = $attachments->parse_attachments($message); // Prepare message text for use in javascript $message_decoded = censor_text($post->post_text); titania_decode_message($message_decoded, $post->post_text_uid); $message_decoded = bbcode_nl2br($message_decoded); // Build CP Fields $cp_row = array(); if (isset(users_overlord::$cp_fields[$post->post_user_id])) { $cp_row = $cp->generate_profile_fields_template('show', false, users_overlord::$cp_fields[$post->post_user_id]); } $cp_row['row'] = isset($cp_row['row']) && sizeof($cp_row['row']) ? $cp_row['row'] : array(); // Display edit info $display_username = get_username_string('full', $post->post_user_id, users_overlord::get_user($post->post_user_id, 'username'), users_overlord::get_user($post->post_user_id, 'user_colour'), false, phpbb::append_sid('memberlist', 'mode=viewprofile')); $l_edited_by = $post->post_edit_time ? sprintf(phpbb::$user->lang['EDITED_MESSAGE'], $display_username, phpbb::$user->format_date($post->post_edit_time)) : ''; phpbb::$template->assign_block_vars('posts', array_merge($post->assign_details(false), users_overlord::assign_details($post->post_user_id), $cp_row['row'], array('POST_TEXT' => $message, 'POST_TEXT_DECODED' => $message_decoded, 'EDITED_MESSAGE' => $l_edited_by, 'U_MINI_POST' => titania_url::append_url($topic->get_url(), array('p' => $post_id, '#p' => $post_id)), 'MINI_POST_IMG' => $post->post_time > $last_mark_time ? phpbb::$user->img('icon_post_target_unread', 'NEW_POST') : phpbb::$user->img('icon_post_target', 'POST'), 'S_FIRST_UNREAD' => $post->post_time > $last_mark_time && $prev_post_time <= $last_mark_time ? true : false))); // Output CP Fields if (!empty($cp_row['blockrow'])) { foreach ($cp_row['blockrow'] as $field_data) { phpbb::$template->assign_block_vars('posts.custom_fields', $field_data); } } //S_IGNORE_POST //POST_ICON_IMG //MINI_POST_IMG foreach ($parsed_attachments as $attachment) { phpbb::$template->assign_block_vars('posts.attachment', array('DISPLAY_ATTACHMENT' => $attachment)); } $prev_post_time = $post->post_time; } unset($post, $attachments); // Increment the topic view count $sql = 'UPDATE ' . TITANIA_TOPICS_TABLE . ' SET topic_views = topic_views + 1 WHERE topic_id = ' . (int) $topic->topic_id; phpbb::$db->sql_query($sql); }
function main($id, $mode) { global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx, $filename; $template->assign_vars(array( 'S_GALLERY' => true, )); $template_root = 'gallery/'; $cat_id = request_var('c', 0); $gallery_id = request_var('g', 0); $user_id = request_var('u', 0); $username = request_var('un', '', true); $start = request_var('start', 0); $photo_id = request_var('p', 0); $submit = isset($_REQUEST['submit']) ? true : false; define('USER_GALLERIES', 1); define('GALLERY_UPLOAD', 1); //define the extensions we need to grab $sql = 'SELECT e.extension FROM ' . EXTENSIONS_TABLE . ' e LEFT JOIN ' . EXTENSION_GROUPS_TABLE . " eg ON (eg.group_id = e.group_id) WHERE eg.group_name = 'Images'"; $result = $db->sql_query($sql); $extensions = ''; while ($row = $db->sql_fetchrow($result)) { $extensions .= (!$extensions) ? "'{$row['extension']}'" : ", '{$row['extension']}'"; } $db->sql_freeresult($result); //set our multibyte to utf8 mb_internal_encoding("UTF-8"); // Set desired template $this->tpl_name = $template_root . $mode; $this->page_title = $user->lang['GALLERY_' . strtoupper($mode)] . ' ' . $user->lang['PHOTOS']; $template->assign_vars(array( 'WHOS_PHOTOS' => $user->lang['GALLERY_' . strtoupper($mode)] . ' ' . $user->lang['PHOTOS'], )); $this->u_action = str_replace("&mode=$mode", '', $this->u_action); switch ($mode) { case 'browse': //select information about the gallery we're in if (!$cat_id && !$gallery_id) { if ($gallery_id) { $sql = 'SELECT * FROM ' . GALLERY_TABLE . " WHERE gallery_id = $gallery_id"; } else if ($user_id) { $sql = 'SELECT * FROM ' . GALLERY_TABLE . " WHERE user_id = $user_id"; } else if ($username) { $sql = 'SELECT g.* FROM ' . GALLERY_TABLE . ' g, ' . USERS_TABLE . " u WHERE u.username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "' AND g.user_id = u.user_id"; } } else { $sql = 'SELECT * FROM ' . GALLERY_TABLE . " WHERE gallery_id = $cat_id"; } $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $gallery = array( 'gallery_id' => isset($row['gallery_id']) ? $row['gallery_id'] : 0, 'user_id' => isset($row['user_id']) ? $row['user_id'] : 0, 'parent_id' => isset($row['parent_id']) ? $row['parent_id'] : 0, 'left_id' => isset($row['left_id']) ? $row['left_id'] : 0, 'right_id' => isset($row['right_id']) ? $row['right_id'] : 0, 'gallery_name' => isset($row['gallery_name']) ? $row['gallery_name'] : 'gallery', 'gallery_desc' => isset($row['gallery_desc']) ? $row['gallery_desc'] : 'gallery', 'gallery_type' => isset($row['gallery_type']) ? $row['gallery_type'] : 0, 'gallery_last_update_time' => isset($row['gallery_last_update_time']) ? $row['gallery_last_update_time'] : 0, ); $db->sql_freeresult($result); //get list of categories under current category $sql = 'SELECT * FROM ' . GALLERY_TABLE . " WHERE parent_id = {$gallery['gallery_id']} ORDER BY left_id ASC"; //if this is a user galleries cat, grab a little differently if ($gallery['gallery_type'] == USER_GALLERIES) { $sql = 'SELECT g.*, u.username, u.user_colour FROM ' . GALLERY_TABLE . ' g, ' . USERS_TABLE .' u WHERE g.user_id <> 0 AND g.user_id = u.user_id ORDER BY u.username ASC'; } $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); while ($row = $db->sql_fetchrow($result)) { if ($row['gallery_id'] != $gallery['gallery_id']) { $template->assign_block_vars('catrow', array( 'GALLERY_COMMENTS' => $row['gallery_comments'], 'GALLERY_DESC' => $row['gallery_desc'], 'GALLERY_IMAGE' => ($row['gallery_image']) ? $row['gallery_image'] : false, 'GALLERY_LAST_IMAGE_ID' => $row['gallery_last_image_id'], 'GALLERY_LAST_COMMENT_ID' => $row['gallery_last_comment_id'], 'GALLERY_LAST_UPLOADER_ID' => $row['gallery_last_uploader_id'], 'GALLERY_LAST_COMMENTOR_ID' => $row['gallery_last_comenter_id'], 'GALLERY_NAME' => $row['gallery_name'], 'GALLERY_PHOTOS' => $row['gallery_photos'], 'GALLERY_VIEWS' => $row['gallery_views'], 'U_GALLERY_LINK' => $this->u_action . "&mode=$mode&c={$row['gallery_id']}", )); } } $db->sql_freeresult($result); //if we're looking at a users gallery, grab their images $where = "a.gallery_id = {$gallery['gallery_id']}"; if ($gallery['user_id']) { $where = "a.poster_id = {$gallery['user_id']} AND a.gallery_id <> 0"; } //grab gallery information if ($gallery['gallery_id']) { //grab images for this gallery $sql = 'SELECT a.*, u.username, u.user_id, u.user_colour FROM ' . GALLERY_PHOTOS_TABLE . ' a LEFT JOIN ' . USERS_TABLE . " u ON (u.user_id = a.poster_id) WHERE $where AND a.extension IN ($extensions) ORDER BY a.filetime DESC"; $result = $db->sql_query_limit($sql, $config['images_per_page'], $start); while ($row = $db->sql_fetchrow($result)) { $template->assign_block_vars('imagerow', array( 'PHOTO_COMMENT' => ((mb_strlen($row['photo_comment']) > 20) ? mb_substr($row['photo_comment'], 0, 20) . '...' : $row['photo_comment']), 'PHOTO_MOUSEOVER' => (mb_strlen($row['photo_comment']) > 20) ? $row['photo_comment'] : '', 'PHOTO_NAME' => $row['photo_name'], 'COMMENT_FULL' => $row['photo_comment'], 'IMAGE_TIME' => $user->format_date($row['filetime']), 'IMAGE_VIEWS' => $row['download_count'], 'IMAGE_ID' => $row['photo_id'], 'TOPIC_ID' => ($row['thumbnail']) ? 1 : false, 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $user->lang['GUEST']), 'U_IMAGE_DOWNLOAD' => $this->u_action . "&mode=photo&p={$row['photo_id']}", 'U_IMAGE_THUMBNAIL' => append_sid("{$phpbb_root_path}photo.$phpEx", "id={$row['photo_id']}" . (($row['thumbnail']) ? '&t=1' : '')), )); $template->assign_vars(array( 'S_PHOTOS' => true, )); } //if we're looking at a users gallery, grab their images $where = "gallery_id = {$gallery['gallery_id']}"; if ($gallery['user_id']) { $where = "poster_id = {$gallery['user_id']} AND gallery_id <> 0"; } $update_photos = ''; if ($gallery['gallery_last_update_time'] < strtotime('-1 day', time()) && $gallery['gallery_id']) { //update number of images in gallery… this will be removed when this feature works properly $sql = 'SELECT COUNT(gallery_id) as total_photos FROM ' . GALLERY_PHOTOS_TABLE . " WHERE $where AND extension IN ($extensions)"; $result = $db->sql_query($sql); $gallery_photos = $db->sql_fetchfield('total_photos'); $db->sql_freeresult($result); $update_photos = ", gallery_photos = $gallery_photos, gallery_last_update_time = " . time(); } //increment the view number for this gallery $sql = 'UPDATE ' . GALLERY_TABLE . " SET gallery_views = gallery_views + 1 $update_photos WHERE gallery_id = {$gallery['gallery_id']}"; $db->sql_query($sql); } $template->assign_vars(array( 'GALLERY_NAME' => $gallery['gallery_name'], 'GALLERY_DESC' => $gallery['gallery_desc'], 'UPLOAD_ICON' => $user->img('icon_upload', 'REPLY_WITH_QUOTE'), )); break; case 'gallery': if (!$user->data['is_registered']) { // Can this user view profiles/memberlist? login_box('', $user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)]); } $sql = "SELECT * FROM " . GALLERY_PHOTOS_TABLE . " WHERE poster_id = {$user->data['user_id']} AND extension IN ($extensions) and gallery_id <> 0 ORDER BY filetime DESC"; $result = $db->sql_query_limit($sql, $config['images_per_page'], $start); $count = 0; while ($row = $db->sql_fetchrow($result)) { $template->assign_block_vars('imagerow', array( 'PHOTO_COMMENT' => ((mb_strlen($row['photo_comment']) > 20) ? mb_substr($row['photo_comment'], 0, 20) . '...' : $row['photo_comment']), 'PHOTO_MOUSEOVER' => (mb_strlen($row['photo_comment']) > 20) ? $row['photo_comment'] : '', 'PHOTO_NAME' => $row['photo_name'], 'COMMENT_FULL' => $row['photo_comment'], 'IMAGE_TIME' => $user->format_date($row['filetime']), 'IMAGE_VIEWS' => $row['download_count'], 'IMAGE_ID' => $row['photo_id'], 'TOPIC_ID' => ($row['thumbnail']) ? 1 : false, 'USERNAME_FULL' => get_username_string('full', $user->data['user_id'], $user->data['username'], $user->data['user_colour'], $user->lang['GUEST']), 'U_IMAGE_DOWNLOAD' => $this->u_action . "&mode=photo&p={$row['photo_id']}", 'U_IMAGE_THUMBNAIL' => append_sid("{$phpbb_root_path}photo.$phpEx", "id={$row['photo_id']}" . (($row['thumbnail']) ? '&t=1' : '')), )); $count++; } $total_pages = 1; if ($count == $config['images_per_page']) { $sql = "SELECT COUNT(photo_id) as total_images FROM " . GALLERY_PHOTOS_TABLE . " WHERE poster_id = {$user->data['user_id']} AND extension IN ($extensions)"; $result = $db->sql_query($sql); $total_pages = $db->sql_fetchfield('total_images') / ($config['images_per_page'] > 0) ? $config['images_per_page'] : 1; $db->sql_freeresult($result); } $template->assign_vars(array( 'WHOS_PHOTOS' => get_username_string('full', $user->data['user_id'], $user->data['username'], $user->data['user_colour'], $user->lang['GUEST']) . ' ' . $user->lang['PHOTOS'], 'USERNAME_FULL' => get_username_string('full', $user->data['user_id'], $user->data['username'], $user->data['user_colour'], $user->lang['GUEST']), 'MAX_WIDTH' => $config['img_max_thumb_width'], 'MAX_HEIGHT' => $config['img_link_height'], 'PAGINATION' => generate_pagination($this->u_action . "&mode=$mode&un={$user->data['username']}", $total_pages, $config['images_per_page'], $start, true), 'U_UPLOAD' => $this->u_action . '&mode=upload', )); $this->page_title = $user->data['username'] . ' ' . $user->lang['PHOTOS']; break; case 'photo': if ($submit) { $rating = request_var('rating', 0); $comment = utf8_normalize_nfc(request_var('message', '', true)); //update the rating for this photo if ($rating) { $sql = 'SELECT * FROM ' . GALLERY_RATINGS_TABLE . " WHERE user_id = {$user->data['user_id']} AND photo_id = $photo_id"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_fetchrow($result); if ($row['photo_id']) { trigger_error('ALREADY_RATED'); } else { $sql_ary = array( 'photo_id' => $photo_id, 'user_id' => $user->data['user_id'], 'rating' => $rating, ); $sql = 'INSERT INTO ' . GALLERY_RATINGS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); $db->sql_query($sql); $count = $rating = 0; $sql = 'SELECT rating FROM ' . GALLERY_RATINGS_TABLE . " WHERE photo_id = $photo_id"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $count++; $rating += $row['rating']; } $db->sql_freeresult($result); if ($count) { $rating = $rating / $count; $sql = 'UPDATE ' . GALLERY_PHOTOS_TABLE . " SET photo_rating = $rating WHERE photo_id = $photo_id"; $db->sql_query($sql); redirect(append_sid("./$filename", "i=$id&mode=$mode&p=$photo_id")); } } } //add a comment for this photo else if ($comment) { $uid = $bitfield = $options = ''; // will be modified by generate_text_for_storage $allow_bbcode = $allow_urls = $allow_smilies = true; generate_text_for_storage($comment, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies); $sql_ary = array( 'photo_id' => $photo_id, 'user_id' => $user->data['user_id'], 'comment_time' => time(), 'comment_text' => $comment, 'comment_bitfield' => $bitfield, 'comment_uid' => $uid, 'comment_options' => $options, ); $sql = 'INSERT INTO ' . GALLERY_COMMENTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); $db->sql_query($sql); redirect(append_sid("./$filename", "i=$id&mode=$mode&p=$photo_id")); } } $where = "ORDER BY a.filetime DESC"; if ($photo_id) { $where = "AND a.photo_id = $photo_id"; } //generate smliies include($phpbb_root_path . 'includes/functions_posting.' . $phpEx); generate_smilies('inline', 1); $sql = 'SELECT a.*, u.username, u.user_colour, g.rating FROM ' . GALLERY_PHOTOS_TABLE . ' a, ' . USERS_TABLE . ' u LEFT JOIN ' . GALLERY_RATINGS_TABLE . " g ON (g.photo_id = $photo_id) WHERE a.extension IN ($extensions) AND a.poster_id = u.user_id $where"; $result = $db->sql_query_limit($sql, 1); $photo = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$photo['rating']) { //setup rate photo $start = $config['photo_min_rating']; $stop = $config['photo_max_rating']; $photo_rate = '<select name="rating">'; $photo_rate .= '<option disabled="disabled" selected="selected">' . $user->lang['RATE_THIS'] . '</option>'; for ($i = $start; $i <= $stop; $i++) { $photo_rate .= '<option id="' . $i . '">' . $i . '</option>'; } $photo_rate .= '</select>'; } else { $photo_rate = "({$photo['rating']})"; } $template->assign_vars(array( 'PHOTO_BBCODE' => "[{$config['photo_bbcode']}]{$photo['photo_id']}[/{$config['photo_bbcode']}]", 'PHOTO_DESCRIPTION' => $photo['photo_comment'], 'PHOTO_DETAILS' => '', 'PHOTO_ID' => $photo['photo_id'], 'PHOTO_NAME' => $photo['photo_name'], 'PHOTO_POST_TIME' => $user->format_date($photo['filetime']), 'PHOTO_POSTER' => get_username_string('full', $photo['poster_id'], $photo['username'], $photo['user_colour']), 'PHOTO_RATE' => $photo_rate, 'PHOTO_RATED' => $photo['rating'], 'PHOTO_RATING' => round($photo['photo_rating'], 2), 'PHOTO_SIZE' => $photo['filesize'], 'PHOTO_TYPE' => $photo['extension'], 'PHOTO_VIEWS' => $photo['download_count'], 'I_PHOTO' => append_sid("{$phpbb_root_path}photo.$phpEx", "id={$photo['photo_id']}"), 'U_SUBMIT' => $this->u_action . "&mode=$mode&p=$photo_id", )); $now = getdate(time() + $user->timezone + $user->dst - date('Z')); include($phpbb_root_path . 'includes/functions_display.' . $phpEx); $id_cache = $user_cache = $message_cache = array(); $sql = 'SELECT g.*, u.* FROM ' . GALLERY_COMMENTS_TABLE . ' g LEFT JOIN ' . USERS_TABLE . " u ON (u.user_id = g.user_id) WHERE photo_id = $photo_id ORDER BY g.comment_time DESC"; $result = $db->sql_query_limit($sql, $config['comments_per_page']); while ($row = $db->sql_fetchrow($result)) { $poster_id = $row['user_id']; $id_cache[] = $poster_id; $message_cache[$row['comment_id']] = array( 'message' => generate_text_for_display($row['comment_text'], $row['comment_uid'], $row['comment_bitfield'], $row['comment_options']), 'user_id' => $row['user_id'], 'post_time' => $user->format_date($row['comment_time']), 'username' => $row['username'], 'user_colour' => $row['user_colour'], ); $user_cache[$poster_id] = array( 'joined' => $user->format_date($row['user_regdate']), 'posts' => $row['user_posts'], 'warnings' => $row['user_warnings'], 'from' => $row['user_from'], '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&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&action=aim&u=$poster_id") : '', 'msn' => ($row['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=msnm&u=$poster_id") : '', 'yim' => ($row['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . $row['user_yim'] . '&.src=pg' : '', 'jabber' => ($row['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=jabber&u=$poster_id") : '', 'search' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", 'search_author=' . urlencode($row['username']) .'&showresults=posts') : '', 'email' => '', 'icq' => ($row['user_icq']) ? 'http://www.icq.com/people/webmsg.php?to=' . $row['user_icq'] : '', 'icq_status_img' => ($row['user_icq']) ? '<img src="http://web.icq.com/whitepages/online?icq=' . $row['user_icq'] . '&img=5" width="18" height="18" alt="" />' : '', ); 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&u=$poster_id") : (($config['board_hide_emails'] && !$auth->acl_get('a_email')) ? '' : 'mailto:' . $row['user_email']); } if ($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_cache = $cp->generate_profile_fields_template('grab', $id_cache); } // 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); } unset($id_cache); $cp_row = array(); foreach ($message_cache as $post_id => $row) { $poster_id = $row['user_id']; // 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(); } $postrow = array( 'POST_AUTHOR_FULL' => get_username_string('full', $poster_id, $row['username'], $row['user_colour']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $poster_id, $row['username'], $row['user_colour']), 'POST_AUTHOR' => get_username_string('username', $poster_id, $row['username'], $row['user_colour']), 'U_POST_AUTHOR' => get_username_string('profile', $poster_id, $row['username'], $row['user_colour']), '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'], 'POST_DATE' => $user->format_date($row['post_time']), 'MESSAGE' => $row['message'], 'MINI_POST_IMG' => $user->img('icon_post_target', 'POST'), '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' => (!$user->data['is_registered']) ? '' : ((($user->data['user_id'] == $poster_id && ($row['post_time'] > time() - ($config['edit_time'] * 60) || !$config['edit_time'])) || $auth->acl_get('m_')) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=edit&p={$post_id}") : ''), //'U_DELETE' => ($auth->acl_get('m_')) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=delete&p={$post_id}") : '', 'U_PROFILE' => $user_cache[$poster_id]['profile'], 'U_SEARCH' => $user_cache[$poster_id]['search'], 'U_PM' => ($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&mode=compose") : '', '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_WARN' => ($auth->acl_get('m_warn') && $poster_id != $user->data['user_id']) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_post', true, $user->session_id) : '', 'POST_ID' => $post_id, 'POSTER_ID' => $poster_id, 'S_CUSTOM_FIELDS' => (isset($cp_row['row']) && sizeof($cp_row['row'])) ? true : false, 'S_TOPIC_POSTER' => ($user->data['user_id'] == $poster_id) ? true : false, ); 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); } } } break; case 'rating': case 'recent': $sql = "SELECT a.*, u.username, u.user_colour, u.user_id FROM " . GALLERY_PHOTOS_TABLE . ' a LEFT JOIN ' . USERS_TABLE . " u ON (u.user_id = a.poster_id) WHERE a.gallery_id <> 0 AND a.extension IN ($extensions) ORDER BY a.filetime DESC"; $result = $db->sql_query_limit($sql, $config['images_per_page'], $start); while ($row = $db->sql_fetchrow($result)) { $template->assign_block_vars('imagerow', array( 'PHOTO_COMMENT' => ((mb_strlen($row['photo_comment']) > 20) ? mb_substr($row['photo_comment'], 0, 20) . '...' : $row['photo_comment']), 'PHOTO_MOUSEOVER' => (mb_strlen($row['photo_comment']) > 20) ? $row['photo_comment'] : '', 'PHOTO_NAME' => $row['photo_name'], 'COMMENT_FULL' => $row['photo_comment'], 'IMAGE_TIME' => $user->format_date($row['filetime']), 'IMAGE_VIEWS' => $row['download_count'], 'IMAGE_ID' => $row['photo_id'], 'TOPIC_ID' => ($row['thumbnail']) ? 1 : false, 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $user->lang['GUEST']), 'U_IMAGE_DOWNLOAD' => $this->u_action . "&mode=photo&p={$row['photo_id']}", 'U_IMAGE_THUMBNAIL' => append_sid("{$phpbb_root_path}photo.$phpEx", "id={$row['photo_id']}" . (($row['thumbnail']) ? '&t=1' : '')), )); } $db->sql_freeresult($result); $template->assign_vars(array( 'MAX_WIDTH' => $config['img_max_thumb_width'], 'MAX_HEIGHT' => $config['img_link_height'], )); break; case 'upload': if (!$user->data['is_registered']) { // Can this user view profiles/memberlist? login_box('', $user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)]); } if ($submit) { include($phpbb_root_path . 'includes/functions_gallery.' . $phpEx); $filedata = upload_attachment(); if (!sizeof($filedata['error'])) { redirect(append_sid("./$filename", "i=$id&mode=$mode&p={$filedata['photo_id']}")); } $error_message = ''; foreach ($filedata['error'] as $error) { $error_message .= $error . '<br />'; } trigger_error($error); } $template->assign_vars(array( 'I_IMAGE_THUMBNAIL' => ($photo_id) ? append_sid("{$phpbb_root_path}photo.$phpEx", "id=$photo_id&t=1") : '', 'U_ACTION' => $this->u_action . "&mode=$mode", )); break; case 'views': $sql = "SELECT a.*, u.username, u.user_colour, u.user_id FROM " . GALLERY_PHOTOS_TABLE . ' a LEFT JOIN ' . USERS_TABLE . " u ON (u.user_id = a.poster_id) WHERE a.gallery_id <> 0 AND a.extension IN ($extensions) ORDER BY a.download_count DESC"; $result = $db->sql_query_limit($sql, $config['images_per_page'], $start); while ($row = $db->sql_fetchrow($result)) { $template->assign_block_vars('imagerow', array( 'PHOTO_COMMENT' => ((mb_strlen($row['photo_comment']) > 20) ? mb_substr($row['photo_comment'], 0, 20) . '...' : $row['photo_comment']), 'PHOTO_MOUSEOVER' => (mb_strlen($row['photo_comment']) > 20) ? $row['photo_comment'] : '', 'PHOTO_NAME' => $row['photo_name'], 'COMMENT_FULL' => $row['photo_comment'], 'IMAGE_TIME' => $user->format_date($row['filetime']), 'IMAGE_VIEWS' => $row['download_count'], 'IMAGE_ID' => $row['photo_id'], 'TOPIC_ID' => ($row['thumbnail']) ? 1 : false, 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $user->lang['GUEST']), 'U_IMAGE_DOWNLOAD' => $this->u_action . "&mode=photo&p={$row['photo_id']}", 'U_IMAGE_THUMBNAIL' => append_sid("{$phpbb_root_path}photo.$phpEx", "id={$row['photo_id']}" . (($row['thumbnail']) ? '&t=1' : '')), )); } $db->sql_freeresult($result); $template->assign_vars(array( 'MAX_WIDTH' => $config['img_max_thumb_width'], 'MAX_HEIGHT' => $config['img_link_height'], )); break; } $template->assign_vars(array( 'S_' . strtoupper($mode) => true, )); }
private function display() { global $template, $user, $config; global $phpbb_root_path, $phpEx, $db; global $cache, $auth; $user->add_lang(array('viewtopic')); $template->assign_var('S_GUESTBOOK_ENABLED', true); $start = request_var('start', 0); $view = request_var('view', ''); $post_id = request_var('p', 0); $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); $hilit_words = request_var('hilit', '', true); $template->assign_vars(array('QUOTE_IMG' => $user->img('icon_post_quote', 'REPLY_WITH_QUOTE'), 'REPLY_IMG' => $user->img('button_topic_reply', 'REPLY_TO_GUESTBOOK'), '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' => false, 'S_GUESTBOOK_ACTION' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "u={$this->user_id}&gbmode=display&mode=viewprofile"), 'S_DISPLAY_POST_INFO' => true, 'S_DISPLAY_REPLY_INFO' => $auth->acl_get('u_gb_post') ? true : false, 'U_POST_REPLY_TOPIC' => $auth->acl_get('u_gb_post') ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "u={$this->user_id}&gbmode=post&mode=viewprofile") : '')); // let's set up quick_reply // We cant have this at the same place as within viewtopic, as we return if there are no posts. $s_quick_reply = false; if ($user->data['is_registered'] && $config['allow_quick_reply'] && $auth->acl_get('u_gb_post')) { // Quick reply enabled forum $s_quick_reply = true; } if ($s_quick_reply) { add_form_key('posting'); $s_attach_sig = $config['allow_sig'] && $user->optionget('attachsig') && $auth->acl_get('f_sigs') && $auth->acl_get('u_gb_sig'); $s_smilies = $config['allow_smilies'] && $user->optionget('smilies') && $auth->acl_get('u_gb_smilies'); $s_bbcode = $config['allow_bbcode'] && $user->optionget('bbcode') && $auth->acl_get('u_gb_bbcode'); $s_notify = $config['allow_topic_notify'] && $user->data['user_notify']; $qr_hidden_fields = array('lastclick' => (int) time()); // 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; $template->assign_vars(array('S_QUICK_REPLY' => true, 'U_QR_ACTION' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=viewprofile&u={$this->user_id}&gbmode=post"), 'QR_HIDDEN_FIELDS' => build_hidden_fields($qr_hidden_fields), 'SUBJECT' => '')); } // now I have the urge to wash my hands :( // 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' => 'g.*', 'FROM' => array(GUESTBOOK_TABLE => 'g')); $sql_array['WHERE'] = 'g.user_id = ' . (int) $this->user_id; if ($post_id) { $sql_array['WHERE'] .= ' AND g.post_id = ' . (int) $post_id; } $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); $gb_data = $db->sql_fetchrow($result); $db->sql_freeresult($result); // link to unapproved post or incorrect link if (!$gb_data) { // If post_id was submitted, we try at least to display the normal profile as a last resort... if ($post_id) { redirect(append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "u={$this->user_id}&mode=viewprofile")); } $total_posts = 0; // Send vars to template $template->assign_vars(array('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))); return; } // This is for determining where we are (page) if ($post_id) { if ($post_id == $this->member['user_guestbook_first_post_id'] || $post_id == $this->member['user_guestbook_last_post_id']) { $check_sort = $post_id == $this->member['user_guestbook_first_post_id'] ? 'd' : 'a'; if ($sort_dir == $check_sort) { $gb_data['prev_posts'] = $this->member['user_guestbook_posts']; } else { $gb_data['prev_posts'] = 0; } } else { $sql = 'SELECT COUNT(p1.post_id) AS prev_posts FROM ' . GUESTBOOK_TABLE . ' p1, ' . GUESTBOOK_TABLE . ' p2 WHERE p1.user_id = ' . (int) $this->user_id . ' AND p2.post_id = ' . (int) $post_id . ' 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); $gb_data['prev_posts'] = $row['prev_posts'] - 1; } } // $gb_replies = $this->member['user_guestbook_posts']; // What is start equal to? if ($post_id) { $start = floor($gb_data['prev_posts'] / $config['posts_per_page']) * $config['posts_per_page']; } // 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', 'g.post_id'), 't' => 'g.post_time', 's' => array('g.post_subject', 'g.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 ' . GUESTBOOK_TABLE . ' WHERE user_id = ' . (int) $this->user_id . ' AND post_time >= ' . (int) $min_post_time; $result = $db->sql_query($sql); $total_posts = (int) $db->sql_fetchfield('num_posts'); $db->sql_freeresult($result); $limit_posts_time = 'AND g.post_time >= ' . (int) $min_post_time . ' '; if (isset($_POST['sort'])) { $start = 0; } } else { $total_posts = $gb_replies; $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}memberlist.{$phpEx}", "u={$this->user_id}&mode=viewprofile&gbmode=display&start={$start}" . (strlen($u_sort_param) ? "&{$u_sort_param}" : '') . ($highlight_match ? "&hilit={$highlight}" : '')); // Grab ranks $ranks = $cache->obtain_ranks(); // Grab icons $icons = $cache->obtain_icons(); // This is only used for print view so ... $server_path = !$view ? $phpbb_root_path : generate_board_url() . '/'; // If we've got a hightlight set pass it on to pagination. $pagination = generate_pagination(append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "u={$this->user_id}&gbmode=display&mode=viewprofile"), $total_posts, $config['posts_per_page'], $start); // Send vars to template $template->assign_vars(array('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), 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days)); // If the user is trying to reach the second half of the guestbook, 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 = $rowset = $update_count = $post_edit_list = array(); $bbcode_bitfield = ''; $i = $i_total = 0; // Go ahead and pull all data for this topic $sql = 'SELECT g.post_id FROM ' . GUESTBOOK_TABLE . ' g' . ($join_user_sql[$sort_key] ? ', ' . USERS_TABLE . ' u' : '') . ' WHERE g.user_id = ' . (int) $this->user_id . ' ' . ($join_user_sql[$sort_key] ? 'AND u.user_id = g.poster_id' : '') . "\n\t\t\t\t{$limit_posts_time}\n\t\t\tORDER 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 { return; } } // 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, g.*', 'FROM' => array(USERS_TABLE => 'u', GUESTBOOK_TABLE => 'g'), 'LEFT_JOIN' => array(array('FROM' => array(ZEBRA_TABLE => 'z'), 'ON' => 'z.user_id = ' . (int) $user->data['user_id'] . ' AND z.zebra_id = g.poster_id')), 'WHERE' => $db->sql_in_set('g.post_id', $post_list) . ' AND u.user_id = g.poster_id')); $result = $db->sql_query($sql); $now = getdate(time() + $user->timezone + $user->dst - date('Z')); // Posts are stored in the $rowset array while $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']; $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['poster_id'], 'username' => $row['username'], 'user_colour' => $row['user_colour'], 'post_subject' => $row['post_subject'], 'icon_id' => isset($icons[$row['icon_id']]['img'], $icons[$row['icon_id']]['height'], $icons[$row['icon_id']]['width']) ? $row['icon_id'] : 0, 'post_approved' => true, '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); 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&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&action=aim&u={$poster_id}") : '', 'msn' => $row['user_msnm'] && $auth->acl_get('u_sendim') ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=contact&action=msnm&u={$poster_id}") : '', 'yim' => $row['user_yim'] ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($row['user_yim']) . '&.src=pg' : '', 'jabber' => $row['user_jabber'] && $auth->acl_get('u_sendim') ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=contact&action=jabber&u={$poster_id}") : '', 'search' => $auth->acl_get('u_search') ? append_sid("{$phpbb_root_path}search.{$phpEx}", "author_id={$poster_id}&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')) { $user_cache[$poster_id]['email'] = $config['board_email_form'] && $config['email_enable'] ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=email&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/' . $row['user_icq'] . '/'; $user_cache[$poster_id]['icq_status_img'] = '<img src="http://web.icq.com/whitepages/online?icq=' . $row['user_icq'] . '&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']) { if (!class_exists('custom_profile')) { 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); } unset($id_cache); // Instantiate BBCode if need be if ($bbcode_bitfield !== '') { if (!class_exists('bbcode')) { include "{$phpbb_root_path}includes/bbcode.{$phpEx}"; } $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))); // 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']); // 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); // 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']); } $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(); } $edit_allowed = $user->data['is_registered'] && ($auth->acl_get('m_gb_edit') || $user->data['user_id'] == $poster_id && $auth->acl_get('u_gb_edit') && ($row['post_time'] > time() - $config['edit_time'] * 60 || !$config['edit_time'])); $delete_allowed = $user->data['is_registered'] && ($auth->acl_get('m_gb_delete') || $user->data['user_id'] == $poster_id && $auth->acl_get('u_gb_delete') && ($row['post_time'] > time() - $config['delete_time'] * 60 || !$config['delete_time'])); // $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'], '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'], false, $view == 'print' ? true : false), 'POST_SUBJECT' => $row['post_subject'], 'MESSAGE' => $message, 'SIGNATURE' => $row['enable_sig'] ? $user_cache[$poster_id]['sig'] : '', 'MINI_POST_IMG' => $post_unread ? $user->img('icon_post_target_unread', 'NEW_POST') : $user->img('icon_post_target', 'POST'), 'POST_ICON_IMG' => !empty($row['icon_id']) ? $icons[$row['icon_id']]['img'] : '', 'POST_ICON_IMG_WIDTH' => !empty($row['icon_id']) ? $icons[$row['icon_id']]['width'] : '', 'POST_ICON_IMG_HEIGHT' => !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}memberlist.{$phpEx}", "mode=viewprofile&u={$this->user_id}&gbmode=edit&p={$row['post_id']}") : '', 'U_QUOTE' => $auth->acl_get('u_gb_post') ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=viewprofile&u={$this->user_id}&gbmode=quote&p={$row['post_id']}") : '', 'U_DELETE' => $delete_allowed ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=viewprofile&u={$this->user_id}&gbmode=delete&p={$row['post_id']}") : '', '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&mode=compose&u=' . $poster_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_MINI_POST' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=viewprofile&u={$this->user_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&mode=user_notes&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&mode=warn_user&u=' . $poster_id, true, $user->session_id) : '', 'POST_ID' => $row['post_id'], 'POSTER_ID' => $poster_id, 'S_POST_UNAPPROVED' => false, 'S_FRIEND' => $row['friend'] ? true : false, 'S_UNREAD_POST' => $post_unread, 'S_CUSTOM_FIELDS' => isset($cp_row['row']) && sizeof($cp_row['row']) ? true : false); 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); } } $prev_post_id = $row['post_id']; unset($rowset[$post_list[$i]]); } unset($rowset, $user_cache); }