本文整理汇总了PHP中tracking_unserialize函数的典型用法代码示例。如果您正苦于以下问题:PHP tracking_unserialize函数的具体用法?PHP tracking_unserialize怎么用?PHP tracking_unserialize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tracking_unserialize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_subscribed_forum_func
function get_subscribed_forum_func()
{
global $config, $db, $user, $auth, $mobiquo_config, $phpbb_home;
$user->setup('ucp');
if (!$user->data['is_registered']) {
trigger_error('LOGIN_EXPLAIN_UCP');
}
$forum_list = array();
if ($config['allow_forum_notify']) {
$forbidden_forums = $auth->acl_getf('!f_read', true);
$forbidden_forums = array_unique(array_keys($forbidden_forums));
if (isset($mobiquo_config['hide_forum_id'])) {
$forbidden_forums = array_unique(array_merge($forbidden_forums, $mobiquo_config['hide_forum_id']));
}
$sql_array = array('SELECT' => 'f.*', 'FROM' => array(FORUMS_WATCH_TABLE => 'fw', FORUMS_TABLE => 'f'), 'WHERE' => 'fw.user_id = ' . $user->data['user_id'] . '
AND f.forum_id = fw.forum_id
AND ' . $db->sql_in_set('f.forum_id', $forbidden_forums, true, true), 'ORDER_BY' => 'left_id');
if ($config['load_db_lastread']) {
$sql_array['LEFT_JOIN'] = array(array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id'));
$sql_array['SELECT'] .= ', ft.mark_time ';
} else {
$tracking_topics = isset($_COOKIE[$config['cookie_name'] . '_track']) ? STRIP ? stripslashes($_COOKIE[$config['cookie_name'] . '_track']) : $_COOKIE[$config['cookie_name'] . '_track'] : '';
$tracking_topics = $tracking_topics ? tracking_unserialize($tracking_topics) : array();
}
$sql = $db->sql_build_query('SELECT', $sql_array);
$result = $db->sql_query($sql);
$forum_list = array();
while ($row = $db->sql_fetchrow($result)) {
$forum_id = $row['forum_id'];
if ($config['load_db_lastread']) {
$forum_check = !empty($row['mark_time']) ? $row['mark_time'] : $user->data['user_lastmark'];
} else {
$forum_check = isset($tracking_topics['f'][$forum_id]) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']) : $user->data['user_lastmark'];
}
$unread_forum = $row['forum_last_post_time'] > $forum_check ? true : false;
$logo_url = '';
if (file_exists("./forum_icons/{$forum_id}.png")) {
$logo_url = $phpbb_home . $config['tapatalkdir'] . "/forum_icons/{$forum_id}.png";
} else {
if (file_exists("./forum_icons/{$forum_id}.jpg")) {
$logo_url = $phpbb_home . $config['tapatalkdir'] . "/forum_icons/{$forum_id}.jpg";
} else {
if (file_exists("./forum_icons/default.png")) {
$logo_url = $phpbb_home . $config['tapatalkdir'] . "/forum_icons/default.png";
} else {
if ($row['forum_image']) {
$logo_url = $phpbb_home . $row['forum_image'];
}
}
}
}
$xmlrpc_forum = new xmlrpcval(array('forum_id' => new xmlrpcval($forum_id), 'forum_name' => new xmlrpcval(html_entity_decode($row['forum_name']), 'base64'), 'icon_url' => new xmlrpcval($logo_url), 'is_protected' => new xmlrpcval($row['forum_password'] ? true : false, 'boolean'), 'sub_only' => new xmlrpcval($row['forum_type'] == FORUM_POST ? false : true, 'boolean'), 'new_post' => new xmlrpcval($unread_forum, 'boolean')), 'struct');
$forum_list[] = $xmlrpc_forum;
}
$db->sql_freeresult($result);
}
$forum_num = count($forum_list);
$response = new xmlrpcval(array('total_forums_num' => new xmlrpcval($forum_num, 'int'), 'forums' => new xmlrpcval($forum_list, 'array')), 'struct');
return new xmlrpcresp($response);
}
示例2: ON
}
if ($config['load_db_lastread'])
{
$sql_from .= ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.user_id = ' . $user->data['user_id'] . '
AND t.topic_id = tt.topic_id)
LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $user->data['user_id'] . '
AND ft.forum_id = f.forum_id)';
$sql_select .= ', tt.mark_time, ft.mark_time as f_mark_time';
}
}
if ($config['load_anon_lastread'] || ($user->data['is_registered'] && !$config['load_db_lastread']))
{
$tracking_topics = (isset($_COOKIE[$config['cookie_name'] . '_track'])) ? ((STRIP) ? stripslashes($_COOKIE[$config['cookie_name'] . '_track']) : $_COOKIE[$config['cookie_name'] . '_track']) : '';
$tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array();
}
$sql = "SELECT $sql_select
FROM $sql_from
WHERE $sql_where";
}
$sql .= ' ORDER BY ' . $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
$result = $db->sql_query($sql);
$result_topic_id = 0;
$rowset = array();
if ($show_results == 'topics')
{
$forums = $rowset = $shadow_topic_list = array();
示例3: display_forums
/**
* Display Forums
*/
function display_forums($root_data = '', $display_moderators = true, $return_moderators = false)
{
global $db, $auth, $user, $template;
global $phpbb_root_path, $phpEx, $config;
$forum_rows = $subforums = $forum_ids = $forum_ids_moderator = $forum_moderators = $active_forum_ary = array();
$parent_id = $visible_forums = 0;
$sql_from = '';
// Mark forums read?
$mark_read = request_var('mark', '');
if ($mark_read == 'all') {
$mark_read = '';
}
if (!$root_data) {
if ($mark_read == 'forums') {
$mark_read = 'all';
}
$root_data = array('forum_id' => 0);
$sql_where = '';
} else {
$sql_where = 'left_id > ' . $root_data['left_id'] . ' AND left_id < ' . $root_data['right_id'];
}
// Display list of active topics for this category?
$show_active = isset($root_data['forum_flags']) && $root_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS ? true : false;
$sql_array = array('SELECT' => 'f.*', 'FROM' => array(FORUMS_TABLE => 'f'), 'LEFT_JOIN' => array());
if ($config['load_db_lastread'] && $user->data['is_registered']) {
$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['SELECT'] .= ', ft.mark_time';
} else {
if ($config['load_anon_lastread'] || $user->data['is_registered']) {
$tracking_topics = isset($_COOKIE[$config['cookie_name'] . '_track']) ? STRIP ? stripslashes($_COOKIE[$config['cookie_name'] . '_track']) : $_COOKIE[$config['cookie_name'] . '_track'] : '';
$tracking_topics = $tracking_topics ? tracking_unserialize($tracking_topics) : array();
if (!$user->data['is_registered']) {
$user->data['user_lastmark'] = isset($tracking_topics['l']) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0;
}
}
}
if ($show_active) {
$sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_ACCESS_TABLE => 'fa'), 'ON' => "fa.forum_id = f.forum_id AND fa.session_id = '" . $db->sql_escape($user->session_id) . "'");
$sql_array['SELECT'] .= ', fa.user_id';
}
$sql = $db->sql_build_query('SELECT', array('SELECT' => $sql_array['SELECT'], 'FROM' => $sql_array['FROM'], 'LEFT_JOIN' => $sql_array['LEFT_JOIN'], 'WHERE' => $sql_where, 'ORDER_BY' => 'f.left_id'));
$result = $db->sql_query($sql);
$forum_tracking_info = array();
$branch_root_id = $root_data['forum_id'];
// Check for unread global announcements (index page only)
$ga_unread = false;
if ($root_data['forum_id'] == 0) {
$unread_ga_list = get_unread_topics($user->data['user_id'], 'AND t.forum_id = 0', '', 1);
if (!empty($unread_ga_list)) {
$ga_unread = true;
}
}
while ($row = $db->sql_fetchrow($result)) {
$forum_id = $row['forum_id'];
// Mark forums read?
if ($mark_read == 'forums' || $mark_read == 'all') {
if ($auth->acl_get('f_list', $forum_id)) {
$forum_ids[] = $forum_id;
continue;
}
}
// Category with no members
if ($row['forum_type'] == FORUM_CAT && $row['left_id'] + 1 == $row['right_id']) {
continue;
}
// Skip branch
if (isset($right_id)) {
if ($row['left_id'] < $right_id) {
continue;
}
unset($right_id);
}
if (!$auth->acl_get('f_list', $forum_id)) {
// if the user does not have permissions to list this forum, skip everything until next branch
$right_id = $row['right_id'];
continue;
}
$forum_ids[] = $forum_id;
if ($config['load_db_lastread'] && $user->data['is_registered']) {
$forum_tracking_info[$forum_id] = !empty($row['mark_time']) ? $row['mark_time'] : $user->data['user_lastmark'];
} else {
if ($config['load_anon_lastread'] || $user->data['is_registered']) {
if (!$user->data['is_registered']) {
$user->data['user_lastmark'] = isset($tracking_topics['l']) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0;
}
$forum_tracking_info[$forum_id] = isset($tracking_topics['f'][$forum_id]) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']) : $user->data['user_lastmark'];
}
}
// Count the difference of real to public topics, so we can display an information to moderators
$row['forum_id_unapproved_topics'] = $auth->acl_get('m_approve', $forum_id) && $row['forum_topics_real'] != $row['forum_topics'] ? $forum_id : 0;
$row['forum_topics'] = $auth->acl_get('m_approve', $forum_id) ? $row['forum_topics_real'] : $row['forum_topics'];
// Display active topics from this forum?
if ($show_active && $row['forum_type'] == FORUM_POST && $auth->acl_get('f_read', $forum_id) && $row['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) {
if (!isset($active_forum_ary['forum_topics'])) {
$active_forum_ary['forum_topics'] = 0;
}
if (!isset($active_forum_ary['forum_posts'])) {
//.........这里部分代码省略.........
示例4: get_portal_tracking_info
/**
* get topic tracking info for news
* based on get_complete_tracking_info of phpBB3
* this should reduce the queries for the news and announcements block
*/
function get_portal_tracking_info($fetch_news)
{
global $config, $request, $user;
$last_read = $topic_ids = $forum_ids = $tracking_info = $rev_forum_ids = $user_lastmark = array();
/**
* group everything by the forum IDs
*/
$count = $fetch_news['topic_count'];
for ($i = 0; $i < $count; ++$i) {
$tracking_info[$fetch_news[$i]['forum_id']][] = $fetch_news[$i]['topic_id'];
$topic_ids[] = $fetch_news[$i]['topic_id'];
$forum_ids[] = $fetch_news[$i]['forum_id'];
$rev_forum_ids[$fetch_news[$i]['topic_id']] = $fetch_news[$i]['forum_id'];
// the other way round also helps
}
foreach ($tracking_info as $forum_id => $current_forum) {
if ($config['load_db_lastread'] && $user->data['is_registered']) {
global $db;
$mark_time = array();
$sql = 'SELECT topic_id, mark_time
FROM ' . TOPICS_TRACK_TABLE . '
WHERE user_id = ' . (int) $user->data['user_id'] . '
AND ' . $db->sql_in_set('topic_id', $current_forum);
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$last_read[$row['topic_id']] = $row['mark_time'];
}
$db->sql_freeresult($result);
$current_forum = array_diff($current_forum, array_keys($last_read));
if (sizeof($topic_ids)) {
$sql = 'SELECT forum_id, mark_time
FROM ' . FORUMS_TRACK_TABLE . '
WHERE user_id = ' . (int) $user->data['user_id'] . '
AND ' . $db->sql_in_set('forum_id', $forum_ids);
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$mark_time[$row['forum_id']] = $row['mark_time'];
}
$db->sql_freeresult($result);
// Set user last mark time
foreach ($forum_ids as $current_forum_id) {
$user_lastmark[$current_forum_id] = isset($mark_time[$current_forum_id]) ? $mark_time[$current_forum_id] : $user->data['user_lastmark'];
}
// @todo: also check if $user_lastmark has been defined for this specific forum_id
foreach ($topic_ids as $topic_id) {
if (!isset($last_read[$topic_id]) || isset($user_lastmark[$rev_forum_ids[$topic_id]]) && $user_lastmark[$rev_forum_ids[$topic_id]] > $last_read[$topic_id]) {
$last_read[$topic_id] = $user_lastmark[$rev_forum_ids[$topic_id]];
}
}
}
} else {
if ($config['load_anon_lastread'] || $user->data['is_registered']) {
global $tracking_topics;
if (!isset($tracking_topics) || !sizeof($tracking_topics)) {
if ($request->is_set($config['cookie_name'] . '_track', \phpbb\request\request_interface::COOKIE)) {
$tracking_topics = $request->variable($config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE);
} else {
$tracking_topics = '';
}
$tracking_topics = $tracking_topics ? tracking_unserialize($tracking_topics) : array();
}
if (!$user->data['is_registered']) {
$user_lastmark = isset($tracking_topics['l']) ? base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate'] : 0;
} else {
$user_lastmark = $user->data['user_lastmark'];
}
foreach ($topic_ids as $topic_id) {
$topic_id36 = base_convert($topic_id, 10, 36);
if (isset($tracking_topics['t'][$topic_id36])) {
$last_read[$topic_id] = base_convert($tracking_topics['t'][$topic_id36], 36, 10) + $config['board_startdate'];
}
}
$topic_ids = array_diff($topic_ids, array_keys($last_read));
if (sizeof($topic_ids)) {
$mark_time = array();
if (isset($tracking_topics['f'][$forum_id])) {
$mark_time[$forum_id] = base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate'];
}
$user_lastmark = isset($mark_time[$forum_id]) ? $mark_time[$forum_id] : $user_lastmark;
foreach ($topic_ids as $topic_id) {
$last_read[$topic_id] = $user_lastmark;
}
}
}
}
}
return $last_read;
}
示例5: display_posts
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;
//.........这里部分代码省略.........
示例6: update_forum_tracking_info
/**
* Check for read forums and update topic tracking info accordingly
*
* @param int $forum_id the forum id to check
* @param int $forum_last_post_time the forums last post time
* @param int $f_mark_time the forums last mark time if user is registered and load_db_lastread enabled
* @param int $mark_time_forum false if the mark time needs to be obtained, else the last users forum mark time
*
* @return true if complete forum got marked read, else false.
*/
function update_forum_tracking_info($forum_id, $forum_last_post_time, $f_mark_time = false, $mark_time_forum = false)
{
global $db, $tracking_topics, $user, $config, $auth, $request, $phpbb_container;
// Determine the users last forum mark time if not given.
if ($mark_time_forum === false) {
if ($config['load_db_lastread'] && $user->data['is_registered']) {
$mark_time_forum = !empty($f_mark_time) ? $f_mark_time : $user->data['user_lastmark'];
} else {
if ($config['load_anon_lastread'] || $user->data['is_registered']) {
$tracking_topics = $request->variable($config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE);
$tracking_topics = $tracking_topics ? tracking_unserialize($tracking_topics) : array();
if (!$user->data['is_registered']) {
$user->data['user_lastmark'] = isset($tracking_topics['l']) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0;
}
$mark_time_forum = isset($tracking_topics['f'][$forum_id]) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']) : $user->data['user_lastmark'];
}
}
}
// Handle update of unapproved topics info.
// Only update for moderators having m_approve permission for the forum.
$phpbb_content_visibility = $phpbb_container->get('content.visibility');
// Check the forum for any left unread topics.
// If there are none, we mark the forum as read.
if ($config['load_db_lastread'] && $user->data['is_registered']) {
if ($mark_time_forum >= $forum_last_post_time) {
// We do not need to mark read, this happened before. Therefore setting this to true
$row = true;
} else {
$sql = 'SELECT t.forum_id
FROM ' . TOPICS_TABLE . ' t
LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt
ON (tt.topic_id = t.topic_id
AND tt.user_id = ' . $user->data['user_id'] . ')
WHERE t.forum_id = ' . $forum_id . '
AND t.topic_last_post_time > ' . $mark_time_forum . '
AND t.topic_moved_id = 0
AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.') . '
AND (tt.topic_id IS NULL
OR tt.mark_time < t.topic_last_post_time)';
$result = $db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
}
} else {
if ($config['load_anon_lastread'] || $user->data['is_registered']) {
// Get information from cookie
$row = false;
if (!isset($tracking_topics['tf'][$forum_id])) {
// We do not need to mark read, this happened before. Therefore setting this to true
$row = true;
} else {
$sql = 'SELECT t.topic_id
FROM ' . TOPICS_TABLE . ' t
WHERE t.forum_id = ' . $forum_id . '
AND t.topic_last_post_time > ' . $mark_time_forum . '
AND t.topic_moved_id = 0
AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.');
$result = $db->sql_query($sql);
$check_forum = $tracking_topics['tf'][$forum_id];
$unread = false;
while ($row = $db->sql_fetchrow($result)) {
if (!isset($check_forum[base_convert($row['topic_id'], 10, 36)])) {
$unread = true;
break;
}
}
$db->sql_freeresult($result);
$row = $unread;
}
} else {
$row = true;
}
}
if (!$row) {
markread('topics', $forum_id);
return true;
}
return false;
}
示例7: get_track_cookie
/**
* Get tracking data from cookie.
*/
protected function get_track_cookie()
{
if ($this->grabbed_cookies == true || $this->user->data['is_registered']) {
return;
}
$cookie = $this->request->variable($this->config['cookie_name'] . '_titania_track', '', false, true);
if ($cookie) {
$this->store = tracking_unserialize($cookie);
}
$this->grabbed_cookies = true;
}
示例8: display_topics
function display_topics(&$master)
{
global $user, $template, $config, $phpEx, $db, $auth, $cache, $phpbb_root_path;
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';
// Specific options
$display_file =& $master->call['display_file'];
$display_user_info =& $master->call['display_user_info'];
$display_link =& $master->call['display_link'];
$display_pagination =& $master->call['display_pagination'];
$display_tracking =& $master->call['display_tracking'];
$display_topic_status =& $master->call['display_topic_status'];
$display_user_link = !empty($master->call['display_user_link']) ? true : false;
$display_user_link_key = $display_user_link ? 'full' : 'no_profile';
$display_last_post =& $master->call['display_last_post'];
$display_order = isset($display_orders[$master->call['display_order']]) ? $display_orders[$master->call['display_order']] : $display_orders['first'];
$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'];
// Do some reset
$topic_datas = $topic_ids = $forum_ids = $user_cache = $id_cache = $post_datas = $forum_datas = array();
$forum_id = $master->call['forum_id'];
// 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);
while ($row = $db->sql_fetchrow($result)) {
//.........这里部分代码省略.........
示例9: display_recent_topics
//.........这里部分代码省略.........
$topics_count++;
if ($topics_count > $start && $topics_count <= $start + $topics_per_page) {
$topic_list[] = $row['topic_id'];
$rowset[$row['topic_id']] = $row;
if (!isset($forums[$row['forum_id']]) && $this->user->data['is_registered'] && $this->config['load_db_lastread']) {
$forums[$row['forum_id']]['mark_time'] = $row['f_mark_time'];
}
$forums[$row['forum_id']]['topic_list'][] = $row['topic_id'];
$forums[$row['forum_id']]['rowset'][$row['topic_id']] =& $rowset[$row['topic_id']];
if ($row['icon_id'] && $this->auth->acl_get('f_icons', $row['forum_id'])) {
$obtain_icons = true;
}
}
}
$this->db->sql_freeresult($result);
}
// No topics to display
if (!sizeof($topic_list)) {
return;
}
// Grab icons
if ($obtain_icons) {
$icons = $this->cache->obtain_icons();
} else {
$icons = array();
}
// Borrowed from search.php
foreach ($forums as $forum_id => $forum) {
if ($this->user->data['is_registered'] && $this->config['load_db_lastread']) {
$topic_tracking_info[$forum_id] = get_topic_tracking($forum_id, $forum['topic_list'], $forum['rowset'], array($forum_id => $forum['mark_time']), $forum_id ? false : $forum['topic_list']);
} else {
if ($this->config['load_anon_lastread'] || $this->user->data['is_registered']) {
$tracking_topics = $this->request->variable($this->config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE);
$tracking_topics = $tracking_topics ? tracking_unserialize($tracking_topics) : array();
$topic_tracking_info[$forum_id] = get_complete_topic_tracking($forum_id, $forum['topic_list'], $forum_id ? false : $forum['topic_list']);
if (!$this->user->data['is_registered']) {
$this->user->data['user_lastmark'] = isset($tracking_topics['l']) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $this->config['board_startdate']) : 0;
}
}
}
}
// Now only pull the data of the requested topics
$sql_array = array('SELECT' => 't.*, tp.topic_posted, f.forum_name', 'FROM' => array(TOPICS_TABLE => 't'), 'LEFT_JOIN' => array(array('FROM' => array(TOPICS_POSTED_TABLE => 'tp'), 'ON' => 't.topic_id = tp.topic_id AND tp.user_id = ' . $this->user->data['user_id']), array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 'f.forum_id = t.forum_id')), 'WHERE' => $this->db->sql_in_set('t.topic_id', $topic_list), 'ORDER_BY' => 't.' . $sort_topics . ' DESC');
if ($display_parent_forums) {
$sql_array['SELECT'] .= ', f.parent_id, f.forum_parents, f.left_id, f.right_id';
}
/**
* Event to modify the SQL query before the topics data is retrieved
*
* @event paybas.recenttopics.sql_pull_topics_data
* @var array sql_array The SQL array
* @since 2.0.0
*/
$vars = array('sql_array');
extract($this->dispatcher->trigger_event('paybas.recenttopics.sql_pull_topics_data', compact($vars)));
$sql = $this->db->sql_build_query('SELECT', $sql_array);
$result = $this->db->sql_query_limit($sql, $topics_per_page);
$rowset = $topic_icons = array();
while ($row = $this->db->sql_fetchrow($result)) {
$rowset[] = $row;
}
$this->db->sql_freeresult($result);
// No topics returned by the DB
if (!sizeof($rowset)) {
return;
}
示例10: display_similar_topics
/**
* Get similar topics by matching topic titles
*
* NOTE: Currently requires MySQL due to the use of FULLTEXT indexes
* and MATCH and AGAINST and UNIX_TIMESTAMP. MySQL FULLTEXT has built-in
* English ignore words. We use phpBB's ignore words for non-English
* languages. We also remove any admin-defined special ignore words.
*
* @param array $topic_data Array with topic data
* @return null
* @access public
*/
public function display_similar_topics($topic_data)
{
$topic_title = $this->clean_topic_title($topic_data['topic_title']);
// If the cleaned up topic_title is empty, no need to continue
if (empty($topic_title)) {
return;
}
// Similar Topics query
$sql_array = array('SELECT' => "f.forum_id, f.forum_name, t.*,\n\t\t\t\tMATCH (t.topic_title) AGAINST ('" . $this->db->sql_escape($topic_title) . "') AS score", 'FROM' => array(TOPICS_TABLE => 't'), 'LEFT_JOIN' => array(array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 'f.forum_id = t.forum_id')), 'WHERE' => "MATCH (t.topic_title) AGAINST ('" . $this->db->sql_escape($topic_title) . "') >= 0.5\n\t\t\t\tAND t.topic_status <> " . ITEM_MOVED . '
AND t.topic_visibility = ' . ITEM_APPROVED . '
AND t.topic_time > (UNIX_TIMESTAMP() - ' . $this->config['similar_topics_time'] . ')
AND t.topic_id <> ' . (int) $topic_data['topic_id']);
// Add topic tracking data to the query (only if query caching is off)
if ($this->user->data['is_registered'] && $this->config['load_db_lastread'] && !$this->config['similar_topics_cache']) {
$sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_TRACK_TABLE => 'tt'), 'ON' => 'tt.topic_id = t.topic_id AND tt.user_id = ' . $this->user->data['user_id']);
$sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.forum_id = f.forum_id AND ft.user_id = ' . $this->user->data['user_id']);
$sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time as f_mark_time';
} else {
if ($this->config['load_anon_lastread'] || $this->user->data['is_registered']) {
// Cookie based tracking copied from search.php
$tracking_topics = $this->request->variable($this->config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE);
$tracking_topics = $tracking_topics ? tracking_unserialize($tracking_topics) : array();
}
}
// We need to exclude passworded forums so we do not leak the topic title
$passworded_forums = $this->user->get_passworded_forums();
// See if the admin set this forum to only search a specific group of other forums, and include them
if (!empty($topic_data['similar_topic_forums'])) {
// Remove any passworded forums from this group of forums we will be searching
$included_forums = array_diff(explode(',', $topic_data['similar_topic_forums']), $passworded_forums);
// if there's nothing left to display (user has no access to the forums we want to search)
if (empty($included_forums)) {
return;
}
$sql_array['WHERE'] .= ' AND ' . $this->db->sql_in_set('f.forum_id', $included_forums);
} else {
if (!empty($this->config['similar_topics_ignore'])) {
// Add passworded forums to the exlude array
$excluded_forums = array_unique(array_merge(explode(',', $this->config['similar_topics_ignore']), $passworded_forums));
$sql_array['WHERE'] .= ' AND ' . $this->db->sql_in_set('f.forum_id', $excluded_forums, true);
} else {
if (!empty($passworded_forums)) {
$sql_array['WHERE'] .= ' AND ' . $this->db->sql_in_set('f.forum_id', $passworded_forums, true);
}
}
}
/**
* Event to modify the sql_array for similar topics
*
* @event vse.similartopics.get_topic_data
* @var array sql_array SQL array to get similar topics data
* @since 1.3.0
*/
$vars = array('sql_array');
extract($this->dispatcher->trigger_event('vse.similartopics.get_topic_data', compact($vars)));
$sql = $this->db->sql_build_query('SELECT', $sql_array);
$result = $this->db->sql_query_limit($sql, $this->config['similar_topics_limit'], 0, $this->config['similar_topics_cache']);
// Grab icons
$icons = $this->cache->obtain_icons();
$rowset = array();
while ($row = $this->db->sql_fetchrow($result)) {
$similar_forum_id = (int) $row['forum_id'];
$similar_topic_id = (int) $row['topic_id'];
$rowset[$similar_topic_id] = $row;
if ($this->auth->acl_get('f_read', $similar_forum_id)) {
// Get topic tracking info
if ($this->user->data['is_registered'] && $this->config['load_db_lastread'] && !$this->config['similar_topics_cache']) {
$topic_tracking_info = get_topic_tracking($similar_forum_id, $similar_topic_id, $rowset, array($similar_forum_id => $row['f_mark_time']));
} else {
if ($this->config['load_anon_lastread'] || $this->user->data['is_registered']) {
$topic_tracking_info = get_complete_topic_tracking($similar_forum_id, $similar_topic_id);
if (!$this->user->data['is_registered']) {
$this->user->data['user_lastmark'] = isset($tracking_topics['l']) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $this->config['board_startdate']) : 0;
}
}
}
// Replies
$replies = $this->content_visibility->get_count('topic_posts', $row, $similar_forum_id) - 1;
// Get folder img, topic status/type related information
$folder_img = $folder_alt = $topic_type = '';
$unread_topic = isset($topic_tracking_info[$similar_topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$similar_topic_id] ? true : false;
topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type);
$topic_unapproved = $row['topic_visibility'] == ITEM_UNAPPROVED && $this->auth->acl_get('m_approve', $similar_forum_id) ? true : false;
$posts_unapproved = $row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $this->auth->acl_get('m_approve', $similar_forum_id) ? true : false;
//$topic_deleted = $row['topic_visibility'] == ITEM_DELETED;
$u_mcp_queue = $topic_unapproved || $posts_unapproved ? append_sid("{$this->root_path}mcp.{$this->php_ext}", 'i=queue&mode=' . ($topic_unapproved ? 'approve_details' : 'unapproved_posts') . "&t={$similar_topic_id}", true, $this->user->session_id) : '';
//$u_mcp_queue = (!$u_mcp_queue && $topic_deleted) ? append_sid("{$this->root_path}mcp.{$this->php_ext}", "i=queue&mode=deleted_topics&t=$similar_topic_id", true, $this->user->session_id) : $u_mcp_queue;
$base_url = append_sid("{$this->root_path}viewtopic.{$this->php_ext}", 'f=' . $similar_forum_id . '&t=' . $similar_topic_id);
//.........这里部分代码省略.........
示例11: display_forums
/**
* Display Forums
*/
function display_forums($root_data = '', $display_moderators = true, $return_moderators = false)
{
global $db, $auth, $user, $template;
global $phpbb_root_path, $phpEx, $config;
global $request, $phpbb_dispatcher, $phpbb_container;
$forum_rows = $subforums = $forum_ids = $forum_ids_moderator = $forum_moderators = $active_forum_ary = array();
$parent_id = $visible_forums = 0;
$sql_from = '';
// Mark forums read?
$mark_read = $request->variable('mark', '');
if ($mark_read == 'all') {
$mark_read = '';
}
if (!$root_data) {
if ($mark_read == 'forums') {
$mark_read = 'all';
}
$root_data = array('forum_id' => 0);
$sql_where = '';
} else {
$sql_where = 'left_id > ' . $root_data['left_id'] . ' AND left_id < ' . $root_data['right_id'];
}
// Handle marking everything read
if ($mark_read == 'all') {
$redirect = build_url(array('mark', 'hash', 'mark_time'));
meta_refresh(3, $redirect);
if (check_link_hash($request->variable('hash', ''), 'global')) {
markread('all', false, false, $request->variable('mark_time', 0));
if ($request->is_ajax()) {
// Tell the ajax script what language vars and URL need to be replaced
$data = array('NO_UNREAD_POSTS' => $user->lang['NO_UNREAD_POSTS'], 'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'], 'U_MARK_FORUMS' => $user->data['is_registered'] || $config['load_anon_lastread'] ? append_sid("{$phpbb_root_path}index.{$phpEx}", 'hash=' . generate_link_hash('global') . '&mark=forums&mark_time=' . time()) : '', 'MESSAGE_TITLE' => $user->lang['INFORMATION'], 'MESSAGE_TEXT' => $user->lang['FORUMS_MARKED']);
$json_response = new \phpbb\json_response();
$json_response->send($data);
}
trigger_error($user->lang['FORUMS_MARKED'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect . '">', '</a>'));
} else {
trigger_error(sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
}
}
// Display list of active topics for this category?
$show_active = isset($root_data['forum_flags']) && $root_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS ? true : false;
$sql_array = array('SELECT' => 'f.*', 'FROM' => array(FORUMS_TABLE => 'f'), 'LEFT_JOIN' => array());
if ($config['load_db_lastread'] && $user->data['is_registered']) {
$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['SELECT'] .= ', ft.mark_time';
} else {
if ($config['load_anon_lastread'] || $user->data['is_registered']) {
$tracking_topics = $request->variable($config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE);
$tracking_topics = $tracking_topics ? tracking_unserialize($tracking_topics) : array();
if (!$user->data['is_registered']) {
$user->data['user_lastmark'] = isset($tracking_topics['l']) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0;
}
}
}
if ($show_active) {
$sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_ACCESS_TABLE => 'fa'), 'ON' => "fa.forum_id = f.forum_id AND fa.session_id = '" . $db->sql_escape($user->session_id) . "'");
$sql_array['SELECT'] .= ', fa.user_id';
}
$sql_ary = array('SELECT' => $sql_array['SELECT'], 'FROM' => $sql_array['FROM'], 'LEFT_JOIN' => $sql_array['LEFT_JOIN'], 'WHERE' => $sql_where, 'ORDER_BY' => 'f.left_id');
/**
* Event to modify the SQL query before the forum data is queried
*
* @event core.display_forums_modify_sql
* @var array sql_ary The SQL array to get the data of the forums
* @since 3.1.0-a1
*/
$vars = array('sql_ary');
extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_sql', compact($vars)));
$sql = $db->sql_build_query('SELECT', $sql_ary);
$result = $db->sql_query($sql);
$forum_tracking_info = $valid_categories = array();
$branch_root_id = $root_data['forum_id'];
/* @var $phpbb_content_visibility \phpbb\content_visibility */
$phpbb_content_visibility = $phpbb_container->get('content.visibility');
while ($row = $db->sql_fetchrow($result)) {
/**
* Event to modify the data set of a forum
*
* This event is triggered once per forum
*
* @event core.display_forums_modify_row
* @var int branch_root_id Last top-level forum
* @var array row The data of the forum
* @since 3.1.0-a1
*/
$vars = array('branch_root_id', 'row');
extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_row', compact($vars)));
$forum_id = $row['forum_id'];
// Mark forums read?
if ($mark_read == 'forums') {
if ($auth->acl_get('f_list', $forum_id)) {
$forum_ids[] = $forum_id;
}
continue;
}
// Category with no members
if ($row['forum_type'] == FORUM_CAT && $row['left_id'] + 1 == $row['right_id']) {
//.........这里部分代码省略.........
示例12: display_forums
function display_forums(&$master)
{
global $user, $template, $config, $phpEx, $db, $auth, $cache, $phpbb_root_path;
global $phpbb_seo;
static $tpl = array('link' => '<a href="%1$s" title="%3$s">%2$s</a>', 'img' => '<img src="%1$s" alt="%2$s"/>');
// Usefull for multi bb topic & forum tracking
// Leave default for single forum eg : '_track'
$tracking_cookie_name = (defined('XLANG_AKEY') ? XLANG_AKEY : '') . '_track';
// Specific options
$display_file =& $master->call['display_file'];
$display_user_info =& $master->call['display_user_info'];
$display_link =& $master->call['display_link'];
$display_pagination =& $master->call['display_pagination'];
$display_tracking =& $master->call['display_tracking'];
$display_topic_status =& $master->call['display_topic_status'];
$display_user_link = !empty($master->call['display_user_link']) ? true : false;
$display_user_link_key = $display_user_link ? 'full' : 'no_profile';
$display_last_post =& $master->call['display_last_post'];
$forum_sql =& $master->call['forum_sql'];
$forum_read_auth =& $master->actions['auth_view_read'];
$forum_list_auth =& $master->actions['auth_view_list'];
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']);
}
// Do some reset
$forum_datas = $forum_ids = $sub_forums = array();
$sql_array = array('SELECT' => 'f.*', 'FROM' => array(FORUMS_TABLE => 'f'), 'LEFT_JOIN' => array(), 'WHERE' => $forum_sql, 'ORDER_BY' => 'f.left_id ASC');
// www.phpBB-SEO.com SEO TOOLKIT BEGIN -> no dupe
if (!empty($phpbb_seo->seo_opt['no_dupe']['on'])) {
$sql_array['SELECT'] .= ', t.topic_id, t.topic_title, t.topic_replies, t.topic_replies_real, t.topic_status, t.topic_type, t.topic_moved_id' . (!empty($phpbb_seo->seo_opt['sql_rewrite']) ? ', t.topic_url ' : ' ');
$sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_TABLE => 't'), 'ON' => "t.topic_last_post_id = f.forum_last_post_id");
}
// www.phpBB-SEO.com SEO TOOLKIT END -> no dupe
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');
} 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;
}
}
$right = 0;
$level_store = array(0 => 0);
$processed = array();
$level = $last_level = 0;
$html = $html_before = $html_after = '';
$separator = ' ';
$news_img = sprintf($tpl['img'], $master->gym_master->path_config['gym_img_url'] . 'html_news.gif', $user->lang['HTML_NEWS']);
$map_img = sprintf($tpl['img'], $master->gym_master->path_config['gym_img_url'] . 'maps-icon.gif', $user->lang['HTML_MAP']);
$subf_img = $user->img('subforum_read', 'NO_NEW_POSTS');
$sql = $db->sql_build_query('SELECT', $sql_array);
unset($sql_array);
$result = $db->sql_query_limit($sql, 600);
while ($row = $db->sql_fetchrow($result)) {
$forum_id = (int) $row['forum_id'];
//@TODO Find why in hell the above query could return more than one row per forum
if (isset($processed[$forum_id])) {
continue;
}
$processed[$forum_id] = $forum_id;
$is_cat = $row['parent_id'] == 0 ? true : false;
if (empty($master->forum_datas[$forum_id])) {
// www.phpBB-SEO.com SEO TOOLKIT BEGIN
$phpbb_seo->seo_url['forum'][$forum_id] = $phpbb_seo->set_url($row['forum_name'], $forum_id, $phpbb_seo->seo_static['forum']);
// www.phpBB-SEO.com SEO TOOLKIT END
$master->forum_datas[$forum_id] = array_merge($row, array('m_approve' => $auth->acl_get('m_approve', $forum_id), 'forum_name' => !empty($row['forum_name']) ? $row['forum_name'] : '', 'forum_status' => !empty($row['forum_status']) ? $row['forum_status'] : '', 'forum_last_post_time' => !empty($row['forum_last_post_time']) ? $row['forum_last_post_time'] : 0, 'enable_icons' => !empty($row['enable_icons']) ? $row['enable_icons'] : 0, 'forum_url' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", "f={$forum_id}")));
if ($load_db_lastread) {
$master->forum_tracking_info[$forum_id] = !empty($row['forum_mark_time']) ? $row['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'];
}
}
$master->forum_datas[$forum_id]['forum_news_url'] = $master->forum_datas[$forum_id]['forum_map_url'] = '';
if (!isset($root_forum_id)) {
$root_forum_id = $forum_id;
$sub_forums[$root_forum_id] = '';
}
$parent_id = (int) $row['parent_id'];
if ($row['left_id'] < $right) {
$level++;
$level_store[$parent_id] = $level;
} else {
if ($row['left_id'] > $right + 1) {
if (isset($level_store[$parent_id])) {
$level = $level_store[$parent_id];
} else {
$level = 0;
}
}
}
$right = (int) $row['right_id'];
if ($level > 1) {
// sub forums
if ($level > $last_level) {
// going one or several level down
//.........这里部分代码省略.........
示例13: display_recent_topics
//.........这里部分代码省略.........
while ($row = $db->sql_fetchrow($result)) {
$num_topics++;
if ($num_topics > $start && $num_topics <= $start + $topics_per_page) {
$topic_ids[] = $row['topic_id'];
$rowset[$row['topic_id']] = $row;
if (!isset($forums[$row['forum_id']]) && $user->data['is_registered'] && $config['load_db_lastread']) {
$forums[$row['forum_id']]['mark_time'] = $row['f_mark_time'];
}
$forums[$row['forum_id']]['topic_list'][] = $row['topic_id'];
$forums[$row['forum_id']]['rowset'][$row['topic_id']] =& $rowset[$row['topic_id']];
if ($row['icon_id'] && $auth->acl_get('f_icons', $row['forum_id'])) {
$obtain_icons = true;
}
}
}
$db->sql_freeresult($result);
// No topics to display
if (!sizeof($topic_ids)) {
return;
}
// Grab icons
if ($obtain_icons) {
$icons = $cache->obtain_icons();
} else {
$icons = array();
}
// Borrowed from search.php
foreach ($forums as $forum_id => $forum) {
if ($user->data['is_registered'] && $config['load_db_lastread']) {
$topic_tracking_info[$forum_id] = get_topic_tracking($forum_id, $forum['topic_list'], $forum['rowset'], array($forum_id => $forum['mark_time']), $forum_id ? false : $forum['topic_list']);
} else {
if ($config['load_anon_lastread'] || $user->data['is_registered']) {
$tracking_topics = isset($_COOKIE[$config['cookie_name'] . '_track']) ? STRIP ? stripslashes($_COOKIE[$config['cookie_name'] . '_track']) : $_COOKIE[$config['cookie_name'] . '_track'] : '';
$tracking_topics = $tracking_topics ? tracking_unserialize($tracking_topics) : array();
$topic_tracking_info[$forum_id] = get_complete_topic_tracking($forum_id, $forum['topic_list'], $forum_id ? false : $forum['topic_list']);
if (!$user->data['is_registered']) {
$user->data['user_lastmark'] = isset($tracking_topics['l']) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0;
}
}
}
}
// Now only pull the data of the requested topics
$sql_query_array = array('SELECT' => 't.*, tp.topic_posted, f.forum_name', 'FROM' => array(TOPICS_TABLE => 't'), 'LEFT_JOIN' => array(array('FROM' => array(TOPICS_POSTED_TABLE => 'tp'), 'ON' => 't.topic_id = tp.topic_id AND tp.user_id = ' . $user->data['user_id']), array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 'f.forum_id = t.forum_id')), 'WHERE' => $db->sql_in_set('t.topic_id', $topic_ids), 'ORDER_BY' => 't.topic_last_post_time DESC');
if ($display_parent_forums) {
$sql_query_array['SELECT'] .= ', f.parent_id, f.forum_parents, f.left_id, f.right_id';
}
$sql = $db->sql_build_query('SELECT', $sql_query_array);
$result = $db->sql_query_limit($sql, $topics_per_page);
$topic_icons = array();
while ($row = $db->sql_fetchrow($result)) {
$topic_id = $row['topic_id'];
$forum_id = $row['forum_id'];
// Cheat for Global Announcements on the unread-link: copied from search.php
if (!$forum_id && !$ga_forum_id) {
$sql2 = 'SELECT forum_id
FROM ' . FORUMS_TABLE . '
WHERE forum_type = ' . FORUM_POST . '
AND ' . $db->sql_in_set('forum_id', $forum_ary, false, true);
$result2 = $db->sql_query_limit($sql2, 1);
$ga_forum_id = (int) $db->sql_fetchfield('forum_id');
$db->sql_freeresult($result2);
$forum_id = $ga_forum_id;
} else {
if (!$forum_id && $ga_forum_id) {
$forum_id = $ga_forum_id;
}
示例14: tt_get_unread_topics
function tt_get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $sql_limit = 1001, $sql_limit_offset = 0)
{
global $config, $db, $user;
$user_id = $user_id === false ? (int) $user->data['user_id'] : (int) $user_id;
// Data array we're going to return
$unread_topics = array();
if (empty($sql_sort)) {
$sql_sort = 'ORDER BY t.topic_last_post_time DESC';
}
if ($config['load_db_lastread'] && $user->data['is_registered']) {
// Get list of the unread topics
$last_mark = (int) $user->data['user_lastmark'];
$sql_array = array('SELECT' => 't.topic_id, t.topic_last_post_time, tt.mark_time as topic_mark_time, ft.mark_time as forum_mark_time', 'FROM' => array(TOPICS_TABLE => 't'), 'LEFT_JOIN' => array(array('FROM' => array(TOPICS_TRACK_TABLE => 'tt'), 'ON' => "tt.user_id = {$user_id} AND t.topic_id = tt.topic_id"), array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => "ft.user_id = {$user_id} AND t.forum_id = ft.forum_id")), 'WHERE' => "\r\r\n t.topic_last_post_time > {$last_mark} AND\r\r\n (\r\r\n (tt.mark_time IS NOT NULL AND t.topic_last_post_time > tt.mark_time) OR\r\r\n (tt.mark_time IS NULL AND ft.mark_time IS NOT NULL AND t.topic_last_post_time > ft.mark_time) OR\r\r\n (tt.mark_time IS NULL AND ft.mark_time IS NULL)\r\r\n )\r\r\n {$sql_extra}\r\r\n {$sql_sort}");
$sql = $db->sql_build_query('SELECT', $sql_array);
$result = $db->sql_query_limit($sql, $sql_limit, $sql_limit_offset);
while ($row = $db->sql_fetchrow($result)) {
$topic_id = (int) $row['topic_id'];
$unread_topics[$topic_id] = $row['topic_mark_time'] ? (int) $row['topic_mark_time'] : ($row['forum_mark_time'] ? (int) $row['forum_mark_time'] : $last_mark);
}
$db->sql_freeresult($result);
} else {
if ($config['load_anon_lastread'] || $user->data['is_registered']) {
global $tracking_topics;
if (empty($tracking_topics)) {
$tracking_topics = request_var($config['cookie_name'] . '_track', '', false, true);
$tracking_topics = $tracking_topics ? tracking_unserialize($tracking_topics) : array();
}
if (!$user->data['is_registered']) {
$user_lastmark = isset($tracking_topics['l']) ? base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate'] : 0;
} else {
$user_lastmark = (int) $user->data['user_lastmark'];
}
$sql = 'SELECT t.topic_id, t.forum_id, t.topic_last_post_time
FROM ' . TOPICS_TABLE . ' t
WHERE t.topic_last_post_time > ' . $user_lastmark . "\r\r\n {$sql_extra}\r\r\n {$sql_sort}";
$result = $db->sql_query_limit($sql, $sql_limit, $sql_limit_offset);
while ($row = $db->sql_fetchrow($result)) {
$forum_id = (int) $row['forum_id'];
$topic_id = (int) $row['topic_id'];
$topic_id36 = base_convert($topic_id, 10, 36);
if (isset($tracking_topics['t'][$topic_id36])) {
$last_read = base_convert($tracking_topics['t'][$topic_id36], 36, 10) + $config['board_startdate'];
if ($row['topic_last_post_time'] > $last_read) {
$unread_topics[$topic_id] = $last_read;
}
} else {
if (isset($tracking_topics['f'][$forum_id])) {
$mark_time = base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate'];
if ($row['topic_last_post_time'] > $mark_time) {
$unread_topics[$topic_id] = $mark_time;
}
} else {
$unread_topics[$topic_id] = $user_lastmark;
}
}
}
$db->sql_freeresult($result);
}
}
return $unread_topics;
}
示例15: main
//.........这里部分代码省略.........
$db->sql_query($sql);
$l_unwatch .= '_FORUMS';
}
if (sizeof($topics)) {
$sql = 'DELETE FROM ' . TOPICS_WATCH_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', $topics) . '
AND user_id = ' . $user->data['user_id'];
$db->sql_query($sql);
$l_unwatch .= '_TOPICS';
}
$msg = $user->lang['UNWATCHED' . $l_unwatch];
} else {
$msg = $user->lang['NO_WATCHED_SELECTED'];
}
} else {
$msg = $user->lang['FORM_INVALID'];
}
$message = $msg . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . append_sid("{$phpbb_root_path}ucp.{$phpEx}", "i={$id}&mode=subscribed") . '">', '</a>');
meta_refresh(3, append_sid("{$phpbb_root_path}ucp.{$phpEx}", "i={$id}&mode=subscribed"));
trigger_error($message);
}
$forbidden_forums = array();
if ($config['allow_forum_notify']) {
$forbidden_forums = $auth->acl_getf('!f_read', true);
$forbidden_forums = array_unique(array_keys($forbidden_forums));
$sql_array = array('SELECT' => 'f.*', 'FROM' => array(FORUMS_WATCH_TABLE => 'fw', FORUMS_TABLE => 'f'), 'WHERE' => 'fw.user_id = ' . $user->data['user_id'] . '
AND f.forum_id = fw.forum_id
AND ' . $db->sql_in_set('f.forum_id', $forbidden_forums, true, true), 'ORDER_BY' => 'left_id');
if ($config['load_db_lastread']) {
$sql_array['LEFT_JOIN'] = array(array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id'));
$sql_array['SELECT'] .= ', ft.mark_time ';
} else {
$tracking_topics = isset($_COOKIE[$config['cookie_name'] . '_track']) ? STRIP ? stripslashes($_COOKIE[$config['cookie_name'] . '_track']) : $_COOKIE[$config['cookie_name'] . '_track'] : '';
$tracking_topics = $tracking_topics ? tracking_unserialize($tracking_topics) : array();
}
$sql = $db->sql_build_query('SELECT', $sql_array);
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$forum_id = $row['forum_id'];
if ($config['load_db_lastread']) {
$forum_check = !empty($row['mark_time']) ? $row['mark_time'] : $user->data['user_lastmark'];
} else {
$forum_check = isset($tracking_topics['f'][$forum_id]) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']) : $user->data['user_lastmark'];
}
$unread_forum = $row['forum_last_post_time'] > $forum_check ? true : false;
// Which folder should we display?
if ($row['forum_status'] == ITEM_LOCKED) {
$folder_image = $unread_forum ? 'forum_unread_locked' : 'forum_read_locked';
$folder_alt = 'FORUM_LOCKED';
} else {
$folder_image = $unread_forum ? 'forum_unread' : 'forum_read';
$folder_alt = $unread_forum ? 'NEW_POSTS' : 'NO_NEW_POSTS';
}
// Create last post link information, if appropriate
if ($row['forum_last_post_id']) {
$last_post_time = $user->format_date($row['forum_last_post_time']);
$last_post_url = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$forum_id}&p=" . $row['forum_last_post_id']) . '#p' . $row['forum_last_post_id'];
} else {
$last_post_time = $last_post_url = '';
}
$template->assign_block_vars('forumrow', array('FORUM_ID' => $forum_id, 'FORUM_FOLDER_IMG' => $user->img($folder_image, $folder_alt), 'FORUM_FOLDER_IMG_SRC' => $user->img($folder_image, $folder_alt, false, '', 'src'), 'FORUM_IMAGE' => $row['forum_image'] ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="' . $user->lang[$folder_alt] . '" />' : '', 'FORUM_IMAGE_SRC' => $row['forum_image'] ? $phpbb_root_path . $row['forum_image'] : '', 'FORUM_NAME' => $row['forum_name'], 'FORUM_DESC' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']), 'LAST_POST_SUBJECT' => $row['forum_last_post_subject'], 'LAST_POST_TIME' => $last_post_time, 'LAST_POST_AUTHOR' => get_username_string('username', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), 'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), 'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), 'U_LAST_POST' => $last_post_url, 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $row['forum_id'])));
}
$db->sql_freeresult($result);
}
// Subscribed Topics
if ($config['allow_topic_notify']) {