$breadcrumbs['bottom_right_links'] .= (($breadcrumbs['bottom_right_links'] != '') ? (' ' . MENU_SEP_CHAR . ' ') : '') . '<a href="' . append_sid(CMS_PAGE_TAGS) . '">' . $lang['TOPIC_TAGS'] . '</a>'; $template_to_parse = 'tags_view_body.tpl'; $tags = array($tag_text); $topics = $class_topics_tags->get_topics_with_tags($tags, $start, $per_page); $num_items = sizeof($topics); $topic_length = 60; // UPI2DB - BEGIN if($user->data['upi2db_access']) { if (!defined('UPI2DB_UNREAD')) { $user->data['upi2db_unread'] = upi2db_unread(); } $count_new_posts = sizeof($user->data['upi2db_unread']['new_posts']); $count_edit_posts = sizeof($user->data['upi2db_unread']['edit_posts']); $count_always_read = sizeof($user->data['upi2db_unread']['always_read']['topics']); $count_mark_unread = sizeof($user->data['upi2db_unread']['mark_posts']); } // UPI2DB - END // MG User Replied - BEGIN // check if user replied to the topic define('USER_REPLIED_ICON', true); $user_topics = $class_topics->user_replied_array($topics); // MG User Replied - END $i = 0;
function read_tree($force = false) { global $db, $config, $user, $tree; // UPI2DB - BEGIN if ($user->data['upi2db_access']) { if (!defined('UPI2DB_UNREAD')) { $user->data['upi2db_unread'] = upi2db_unread(); } } // UPI2DB - END // read the user cookie $tracking_forums = isset($_COOKIE[$config['cookie_name'] . '_f']) ? unserialize($_COOKIE[$config['cookie_name'] . '_f']) : array(); $tracking_topics = isset($_COOKIE[$config['cookie_name'] . '_t']) ? unserialize($_COOKIE[$config['cookie_name'] . '_t']) : array(); $tracking_all = isset($_COOKIE[$config['cookie_name'] . '_f_all']) ? intval($_COOKIE[$config['cookie_name'] . '_f_all']) : -1; // try the cache $use_cache_file = false; if (defined('CACHE_TREE')) { $cache_included = false; $cache_file = MAIN_CACHE_FOLDER . CACHE_TREE_FILE; if (!file_exists($cache_file)) { cache_tree(true); } @(include $cache_file); if (!$cache_included || empty($tree) || $force) { cache_tree(true); @(include $cache_file); } if (!empty($tree)) { $use_cache_file = true; } } else { cache_tree(); } // New SQL based only on Forums table // Get last posts details for each forum $sql = "SELECT f.forum_id, f.forum_last_post_id, f.forum_last_topic_id as topic_id, f.forum_last_post_time as post_time, f.forum_last_post_subject as topic_title, f.forum_last_poster_id as user_id, f.forum_last_poster_name as username, f.forum_last_poster_color as user_color\n\t\t\t\tFROM " . FORUMS_TABLE . " f\n\t\t\t\tORDER BY f.forum_id"; $result = CACHE_CH_SQL ? $db->sql_query($sql, 3600, 'posts_', POSTS_CACHE_FOLDER) : $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { if (!empty($row['forum_last_post_id'])) { $row['user_active'] = 1; $row['topic_title'] = censor_text($row['topic_title']); // store the added columns $idx = $tree['keys'][POST_FORUM_URL . $row['forum_id']]; @reset($row); while (list($key, $value) = @each($row)) { $nkey = intval($key); if ($key != "{$nkey}") { $tree['data'][$idx][$key] = $row[$key]; } } } } $db->sql_freeresult($result); // set the unread flag // UPI2DB - BEGIN if (!$user->data['upi2db_access']) { // UPI2DB - END // Get new posts since last visit... only for registered users if ($user->data['session_logged_in']) { $time_limit = time() - LAST_LOGIN_DAYS_NEW_POSTS_RESET * 24 * 60 * 60; $user_lastvisit = $user->data['user_lastvisit'] < $time_limit ? $time_limit : $user->data['user_lastvisit']; $sql_limit = " LIMIT " . LAST_LOGIN_NEW_POSTS_LIMIT; $sql = "SELECT p.forum_id, p.topic_id, p.post_time\n\t\t\t\t\t\tFROM " . POSTS_TABLE . " p\n\t\t\t\t\t\tWHERE (p.post_time > " . $user_lastvisit . ")\n\t\t\t\t\t\tORDER BY p.post_time DESC\n\t\t\t\t\t\t" . $sql_limit; //$result = (CACHE_CH_SQL ? $db->sql_query($sql, 3600, 'posts_', POSTS_CACHE_FOLDER) : $db->sql_query($sql)); $result = $db->sql_query($sql); $new_topic_data = array(); while ($row = $db->sql_fetchrow($result)) { $new_topic_data[$row['forum_id']][$row['topic_id']] = $row['post_time']; } $db->sql_freeresult($result); } $tree['unread_topics'] = array(); for ($i = 0; $i < sizeof($tree['data']); $i++) { if ($tree['type'][$i] == POST_FORUM_URL) { // get the last post time per forums $forum_id = $tree['id'][$i]; $unread_topics = false; if (!empty($new_topic_data[$forum_id])) { $forum_last_post_time = 0; @reset($new_topic_data[$forum_id]); while (list($check_topic_id, $check_post_time) = @each($new_topic_data[$forum_id])) { if (empty($tracking_topics[$check_topic_id])) { $unread_topics = true; $forum_last_post_time = max($check_post_time, $forum_last_post_time); } else { if ($tracking_topics[$check_topic_id] < $check_post_time) { $unread_topics = true; $forum_last_post_time = max($check_post_time, $forum_last_post_time); } } } // is there a cookie for this forum ? if (!empty($tracking_forums[$forum_id])) { if ($tracking_forums[$forum_id] > $forum_last_post_time) { $unread_topics = false; } } // is there a cookie for all forums ? if ($tracking_all > $forum_last_post_time) { $unread_topics = false; } } // store the result $tree['unread_topics'][$i] = $unread_topics; } } // UPI2DB - BEGIN } else { for ($i = 0; $i < sizeof($tree['data']); $i++) { if ($tree['type'][$i] == POST_FORUM_URL) { $unread_topics = false; $forum_id = $tree['id'][$i]; if (in_array($forum_id, $user->data['upi2db_unread']['forums']) || in_array('A', $user->data['upi2db_unread']['forums'])) { $unread_topics = true; } $tree['unread_topics'][$i] = $unread_topics; } } } // UPI2DB - END return; }
/** * upi2db_menu_links */ function upi2db_menu_links($link_type) { global $db, $cache, $config, $user, $lang, $template, $theme, $images; $link = array('lang' => 'NEW_POSTS_SHORT', 'link' => CMS_PAGE_SEARCH . '?search_id=newposts', 'auth' => AUTH_CMS_ADMIN); if (empty($user->data['upi2db_access'])) { return $link; } if (!defined('UPI2DB_UNREAD')) { $user->data['upi2db_unread'] = upi2db_unread(); } $u_display_new = index_display_new($user->data['upi2db_unread']); switch ($link_type) { case 'unread': $link = array('lang' => $u_display_new['unread_string'], 'link' => $u_display_new['u_url'], 'auth' => AUTH_CMS_REG, 'title' => $u_display_new['u_string_full']); break; case 'marked': $link = array('lang' => $u_display_new['marked_string'], 'link' => $u_display_new['m_url'], 'auth' => AUTH_CMS_REG, 'title' => $u_display_new['m_string_full']); break; case 'perm': $link = array('lang' => $u_display_new['permanent_string'], 'link' => $u_display_new['p_url'], 'auth' => AUTH_CMS_REG, 'title' => $u_display_new['p_string_full']); break; case 'full': default: $full_link = $lang['Posts'] . ': <a href="search.' . PHP_EXT . '?search_id=newposts">' . $lang['NEW_POSTS_SHORT'] . '</a>' . ' • ' . $u_display_new['u'] . ' • ' . $u_display_new['m'] . ' • ' . $u_display_new['p']; $link = array('full_link' => $full_link, 'lang' => 'UPI2DB_LINK_FULL', 'link' => CMS_PAGE_SEARCH . '?search_id=newposts', 'auth' => AUTH_CMS_REG); break; } return $link; }
/** * Setup basic user-specific items (style, language, ...) */ function setup($lang_set = false, $style = false) { global $db, $cache, $config, $auth, $template; // We need $lang declared as global to make sure we do not miss extra $lang vars added using this function global $theme, $images, $lang, $nav_separator; global $class_settings, $tree; // Get all settings $class_settings->setup_settings(); // Mighty Gorgon - Change Lang - BEGIN $test_language = request_var(LANG_URL, ''); if (!empty($test_language)) { $test_language = str_replace(array('.', '/'), '', urldecode($test_language)); $config['default_lang'] = file_exists(@phpbb_realpath($this->lang_path . 'lang_' . basename($test_language) . '/lang_main.' . PHP_EXT)) ? $test_language : $config['default_lang']; $this->set_cookie('lang', $config['default_lang'], $user->cookie_expire); } else { if (isset($_COOKIE[$config['cookie_name'] . '_lang']) && file_exists(@phpbb_realpath($this->lang_path . 'lang_' . basename($_COOKIE[$config['cookie_name'] . '_lang']) . '/lang_main.' . PHP_EXT))) { $config['default_lang'] = $_COOKIE[$config['cookie_name'] . '_lang']; } } // Mighty Gorgon - Change Lang - END if ($this->data['user_id'] != ANONYMOUS) { $this->lang_name = file_exists($this->lang_path . 'lang_' . basename($this->data['user_lang']) . '/lang_main.' . PHP_EXT) ? basename($this->data['user_lang']) : basename($config['default_lang']); $this->date_format = $this->data['user_dateformat']; $this->timezone = $this->data['user_timezone'] * 3600; $this->dst = $this->data['user_dst'] * 3600; $config['board_timezone'] = !empty($this->data['user_timezone']) ? $this->data['user_timezone'] : $config['board_timezone']; $config['default_dateformat'] = !empty($this->data['user_dateformat']) ? $this->data['user_dateformat'] : $config['default_dateformat']; $config['topics_per_page'] = !empty($this->data['user_topics_per_page']) ? $this->data['user_topics_per_page'] : $config['topics_per_page']; $config['posts_per_page'] = !empty($this->data['user_posts_per_page']) ? $this->data['user_posts_per_page'] : $config['posts_per_page']; $config['hot_threshold'] = !empty($this->data['user_hot_threshold']) ? $this->data['user_hot_threshold'] : $config['hot_threshold']; // Store CMS AUTH - BEGIN if (empty($this->data['user_cms_auth'])) { $auth_array = array(); $auth_to_get_array = array('cmsl_admin', 'cmss_admin', 'cmsb_admin'); foreach ($auth_to_get_array as $auth_to_get) { $auth_getf = $auth->acl_getf($auth_to_get, true); foreach ($auth_getf as $auth_id => $auth_value) { $auth_array[$auth_to_get][$auth_id] = $auth_value[$auth_to_get]; } } $this->data['user_cms_auth'] = $auth_array; $sql = "UPDATE " . USERS_TABLE . "\n\t\t\t\t\tSET user_cms_auth = '" . $db->sql_escape(serialize($this->data['user_cms_auth'])) . "'\n\t\t\t\t\tWHERE user_id = " . $this->data['user_id']; $db->sql_query($sql); } else { $this->data['user_cms_auth'] = unserialize($this->data['user_cms_auth']); } // Store CMS AUTH - END } else { $this->lang_name = basename($config['default_lang']); $this->date_format = $config['default_dateformat']; $this->timezone = $config['board_timezone'] * 3600; $this->dst = $config['board_dst'] * 3600; } // If we've had to change the value in any way then let's write it back to the database before we go any further since it means there is something wrong with it if ($this->data['user_id'] != ANONYMOUS && $this->data['user_lang'] !== $this->lang_name && file_exists($this->lang_path . 'lang_' . basename($this->lang_name) . '/lang_main.' . PHP_EXT)) { $sql = 'UPDATE ' . USERS_TABLE . "\n\t\t\t\tSET user_lang = '" . $db->sql_escape($this->lang_name) . "'\n\t\t\t\tWHERE user_lang = '" . $this->data['user_lang'] . "'"; $result = $db->sql_query($sql); $this->data['user_lang'] = $this->lang_name; } elseif ($this->data['user_id'] === ANONYMOUS && $config['default_lang'] !== $this->lang_name && file_exists($this->lang_path . 'lang_' . basename($this->lang_name) . '/lang_main.' . PHP_EXT)) { $sql = 'UPDATE ' . CONFIG_TABLE . "\n\t\t\t\tSET config_value = '" . $db->sql_escape($this->lang_name) . "'\n\t\t\t\tWHERE config_name = 'default_lang'"; $result = $db->sql_query($sql); } $config['default_lang'] = $this->lang_name; // We include common language file here to not load it every time a custom language file is included $lang =& $this->lang; setup_basic_lang(); $this->add_lang($lang_set); unset($lang_set); $nav_separator = empty($nav_separator) ? empty($lang['Nav_Separator']) ? ' » ' : $lang['Nav_Separator'] : $nav_separator; if (empty($tree['auth'])) { get_user_tree($this->data); } // MG Logs - BEGIN if ($config['mg_log_actions'] || $config['db_log_actions']) { include IP_ROOT_PATH . 'includes/log_http_cmd.' . PHP_EXT; } // MG Logs - END // UPI2DB - BEGIN if (!defined('IN_CMS') && $this->data['upi2db_access']) { if (!defined('UPI2DB_UNREAD')) { $this->data['upi2db_unread'] = upi2db_unread(); } } else { $this->data['upi2db_unread'] = array(); } // UPI2DB - END // Mighty Gorgon Edit // DISABLED BY MG /* //if (!empty($_GET['style']) && $auth->acl_get('a_styles') && !defined('IN_ADMIN') && !defined('IN_CMS')) if (!empty($_GET['style']) && !defined('IN_ADMIN') && !defined('IN_CMS')) { global $SID, $_EXTRA_URL; $style = request_var(STYLE_URL, 0); $SID .= '&' . STYLE_URL . '=' . $style; $_EXTRA_URL = array(STYLE_URL . '=' . $style); } else { // Set up style $style = ($style) ? $style : ((!$config['override_user_style']) ? $this->data['user_style'] : $config['default_style']); } */ // Call phpbb_user_session_handler() in case external application want to "bend" some variables or replace classes... // After calling it we continue script execution... phpbb_user_session_handler(); // If this function got called from the error handler we are finished here. if (defined('IN_ERROR_HANDLER')) { return; } // Disable board if the install/ directory is still present // For the brave development army we do not care about this, else we need to comment out this everytime we develop locally // DISABLED BY MG /* if (!defined('DEBUG_EXTRA') && !defined('IN_ADMIN') && !defined('IN_CMS') && !defined('IN_INSTALL') && !defined('IN_LOGIN') && file_exists(IP_ROOT_PATH . 'install') && !is_file(IP_ROOT_PATH . 'install')) { // Adjust the message slightly according to the permissions if ($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) { $message = 'REMOVE_INSTALL'; } else { $message = (!empty($config['board_disable_msg'])) ? $config['board_disable_msg'] : 'BOARD_DISABLE'; } trigger_error($message); } */ // Is board disabled and user not an admin or moderator? // DISABLED BY MG /* if ($config['board_disable'] && !defined('IN_LOGIN') && !$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) { if ($this->data['is_bot']) { send_status_line(503, 'Service Unavailable'); } $message = (!empty($config['board_disable_msg'])) ? $config['board_disable_msg'] : 'BOARD_DISABLE'; trigger_error($message); } */ // Is load exceeded? // DISABLED BY MG /* if ($config['limit_load'] && $this->load !== false) { if ($this->load > floatval($config['limit_load']) && !defined('IN_LOGIN') && !defined('IN_ADMIN')) { // Set board disabled to true to let the admins/mods get the proper notification $config['board_disable'] = '1'; if (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) { if ($this->data['is_bot']) { send_status_line(503, 'Service Unavailable'); } trigger_error('BOARD_UNAVAILABLE'); } } } */ // DISABLED BY MG /* if (isset($this->data['session_viewonline'])) { // Make sure the user is able to hide his session if (!$this->data['session_viewonline']) { // Reset online status if not allowed to hide the session... if (!$auth->acl_get('u_hideonline')) { $sql = 'UPDATE ' . SESSIONS_TABLE . ' SET session_viewonline = 1 WHERE session_user_id = ' . $this->data['user_id']; $db->sql_query($sql); $this->data['session_viewonline'] = 1; } } elseif (!$this->data['user_allow_viewonline']) { // the user wants to hide and is allowed to -> cloaking device on. if ($auth->acl_get('u_hideonline')) { $sql = 'UPDATE ' . SESSIONS_TABLE . ' SET session_viewonline = 0 WHERE session_user_id = ' . $this->data['user_id']; $db->sql_query($sql); $this->data['session_viewonline'] = 0; } } } */ // Set up style $current_default_style = $config['default_style']; $change_style = false; $is_mobile = is_mobile(); // For debugging purpose you can force this to true //$this->data['is_mobile'] = true; // We need to store somewhere if the user has the mobile style enabled... so we can output a link to switch between mobile style and norma style $this->data['mobile_style'] = false; $disable_mobile_style = false; // MOBILE STYLE DISABLING - BEGIN // Let's check if the user wants to disable the mobile style if (isset($_GET['mob'])) { $mob_get = isset($_GET['mob']) && intval($_GET['mob']) == 0 ? 0 : 1; $_GET['mob'] = $mob_get; $_COOKIE[$config['cookie_name'] . '_mob'] = $mob_get; $this->set_cookie('mob', $mob_get, $user->cookie_expire); if (empty($mob_get)) { $disable_mobile_style = true; } } $mob_cok = isset($_COOKIE[$config['cookie_name'] . '_mob']) && intval($_COOKIE[$config['cookie_name'] . '_mob']) == 0 ? false : true; if (empty($mob_cok)) { $disable_mobile_style = true; } // MOBILE STYLE DISABLING - END if (empty($disable_mobile_style) && !empty($this->data['is_mobile']) && !defined('IN_CMS') && !defined('IN_ADMIN')) { $this->data['mobile_style'] = true; $_COOKIE[$config['cookie_name'] . '_mob'] = 1; $this->set_cookie('mob', 1, $user->cookie_expire); $theme = setup_mobile_style(); } else { if (empty($config['override_user_style'])) { // Mighty Gorgon - Change Style - BEGIN // Check cookie as well!!! $test_style = request_var(STYLE_URL, 0); if ($test_style > 0) { $config['default_style'] = urldecode($test_style); $config['default_style'] = check_style_exists($config['default_style']) == false ? $current_default_style : $config['default_style']; $this->set_cookie('style', $config['default_style'], $user->cookie_expire); $change_style = true; } else { if (isset($_COOKIE[$config['cookie_name'] . '_style']) && check_style_exists($_COOKIE[$config['cookie_name'] . '_style']) != false) { $config['default_style'] = $_COOKIE[$config['cookie_name'] . '_style']; } } // Mighty Gorgon - Change Style - END $style = $this->data['user_id'] != ANONYMOUS && $this->data['user_style'] > 0 && empty($change_style) ? $this->data['user_style'] : $config['default_style']; if ($theme = setup_style($style, $current_default_style)) { if ($this->data['user_id'] != ANONYMOUS && !empty($change_style)) { // user logged in --> save new style ID in user profile $sql = "UPDATE " . USERS_TABLE . "\n\t\t\t\t\t\t\tSET user_style = " . $theme['themes_id'] . "\n\t\t\t\t\t\t\tWHERE user_id = " . $this->data['user_id']; $db->sql_query($sql); $this->data['user_style'] = $theme['themes_id']; } return; } } $theme = setup_style($config['default_style'], $current_default_style); } return; }