Example #1
0
        $template->assign_var('RUN_CRON_TASK', '<img src="' . $url . '" width="1" height="1" alt="cron" />');
    } else {
        // See if we should prune the shadow topics instead
        $task = $cron->find_task('cron.task.core.prune_shadow_topics');
        $task->set_forum_data($forum_data);
        if ($task->is_ready()) {
            $url = $task->get_url();
            $template->assign_var('RUN_CRON_TASK', '<img src="' . $url . '" width="1" height="1" alt="cron" />');
        }
    }
}
// Forum rules and subscription info
$s_watching_forum = array('link' => '', 'link_toggle' => '', 'title' => '', 'title_toggle' => '', 'is_watching' => false);
if ($config['allow_forum_notify'] && $forum_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_subscribe', $forum_id) || $user->data['user_id'] == ANONYMOUS)) {
    $notify_status = isset($forum_data['notify_status']) ? $forum_data['notify_status'] : NULL;
    watch_topic_forum('forum', $s_watching_forum, $user->data['user_id'], $forum_id, 0, $notify_status, $start, $forum_data['forum_name']);
}
$s_forum_rules = '';
gen_forum_auth_level('forum', $forum_id, $forum_data['forum_status']);
// Topic ordering options
$limit_days = array(0 => $user->lang['ALL_TOPICS'], 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'], 'r' => $user->lang['REPLIES'], 's' => $user->lang['SUBJECT'], 'v' => $user->lang['VIEWS']);
$sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => array('t.topic_last_post_time', 't.topic_last_post_id'), 'r' => $auth->acl_get('m_approve', $forum_id) ? 't.topic_posts_approved + t.topic_posts_unapproved + t.topic_posts_softdeleted' : 't.topic_posts_approved', 's' => 'LOWER(t.topic_title)', 'v' => 't.topic_views');
$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);
// Limit topics to certain time frame, obtain correct topic count
if ($sort_days) {
    $min_post_time = time() - $sort_days * 86400;
    $sql = 'SELECT COUNT(topic_id) AS num_topics
		FROM ' . TOPICS_TABLE . "\n\t\tWHERE forum_id = {$forum_id}\n\t\t\tAND (topic_last_post_time >= {$min_post_time}\n\t\t\t\tOR topic_type = " . POST_ANNOUNCE . '
				OR topic_type = ' . POST_GLOBAL . ')
Example #2
0
    meta_refresh(3, $redirect_url);
    trigger_error($user->lang['TOPICS_MARKED'] . '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect_url . '">', '</a>'));
}
// Is a forum specific topic count required?
if ($forum_data['forum_topics_per_page']) {
    $config['topics_per_page'] = $forum_data['forum_topics_per_page'];
}
// Do the forum Prune thang - cron type job ...
if ($forum_data['prune_next'] < time() && $forum_data['enable_prune']) {
    $template->assign_var('RUN_CRON_TASK', '<img src="' . append_sid($phpbb_root_path . 'cron.' . $phpEx, 'cron_type=prune_forum&amp;f=' . $forum_id) . '" alt="cron" width="1" height="1" />');
}
// Forum rules and subscription info
$s_watching_forum = array('link' => '', 'title' => '', 'is_watching' => false);
if (($config['email_enable'] || $config['jab_enable']) && $config['allow_forum_notify'] && $forum_data['forum_type'] == FORUM_POST && $auth->acl_get('f_subscribe', $forum_id)) {
    $notify_status = isset($forum_data['notify_status']) ? $forum_data['notify_status'] : NULL;
    watch_topic_forum('forum', $s_watching_forum, $user->data['user_id'], $forum_id, 0, $notify_status);
}
$s_forum_rules = '';
gen_forum_auth_level('forum', $forum_id, $forum_data['forum_status']);
// Topic ordering options
$limit_days = array(0 => $user->lang['ALL_TOPICS'], 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'], 'r' => $user->lang['REPLIES'], 's' => $user->lang['SUBJECT'], 'v' => $user->lang['VIEWS']);
$sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => 't.topic_last_post_time', 'r' => 't.topic_replies', 's' => 't.topic_title', 'v' => 't.topic_views');
$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);
// Limit topics to certain time frame, obtain correct topic count
// global announcements must not be counted, normal announcements have to
// be counted, as forum_topics(_real) includes them
if ($sort_days) {
    $min_post_time = time() - $sort_days * 86400;
    $sql = 'SELECT COUNT(topic_id) AS num_topics
Example #3
0
    $highlight_match = preg_replace('#(?<=^|\\s)\\\\w\\*\\?(?=\\s|$)#', '\\w+?', $highlight_match);
    $highlight_match = str_replace(' ', '|', $highlight_match);
}
// Make sure $start is set to the last page if it exceeds the amount
$start = $pagination->validate_start($start, $config['posts_per_page'], $total_posts);
// General Viewtopic URL for return links
$viewtopic_url = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$forum_id}&amp;t={$topic_id}" . ($start == 0 ? '' : "&amp;start={$start}") . (strlen($u_sort_param) ? "&amp;{$u_sort_param}" : '') . ($highlight_match ? "&amp;hilit={$highlight}" : ''));
// Are we watching this topic?
$s_watching_topic = array('link' => '', 'link_toggle' => '', 'title' => '', 'title_toggle' => '', 'is_watching' => false);
if ($config['allow_topic_notify']) {
    $notify_status = isset($topic_data['notify_status']) ? $topic_data['notify_status'] : null;
    watch_topic_forum('topic', $s_watching_topic, $user->data['user_id'], $forum_id, $topic_id, $notify_status, $start, $topic_data['topic_title']);
    // Reset forum notification if forum notify is set
    if ($config['allow_forum_notify'] && $auth->acl_get('f_subscribe', $forum_id)) {
        $s_watching_forum = $s_watching_topic;
        watch_topic_forum('forum', $s_watching_forum, $user->data['user_id'], $forum_id, 0);
    }
}
// Bookmarks
if ($config['allow_bookmarks'] && $user->data['is_registered'] && $request->variable('bookmark', 0)) {
    if (check_link_hash($request->variable('hash', ''), "topic_{$topic_id}")) {
        if (!$topic_data['bookmarked']) {
            $sql = 'INSERT INTO ' . BOOKMARKS_TABLE . ' ' . $db->sql_build_array('INSERT', array('user_id' => $user->data['user_id'], 'topic_id' => $topic_id));
            $db->sql_query($sql);
        } else {
            $sql = 'DELETE FROM ' . BOOKMARKS_TABLE . "\n\t\t\t\tWHERE user_id = {$user->data['user_id']}\n\t\t\t\t\tAND topic_id = {$topic_id}";
            $db->sql_query($sql);
        }
        $message = $topic_data['bookmarked'] ? $user->lang['BOOKMARK_REMOVED'] : $user->lang['BOOKMARK_ADDED'];
        if (!$request->is_ajax()) {
            $message .= '<br /><br />' . $user->lang('RETURN_TOPIC', '<a href="' . $viewtopic_url . '">', '</a>');
if (!$topic_data || $topic_data['forum_status'] == ITEM_DELETING || !$topic_data['topic_approved'] && !$_CLASS['auth']->acl_get('m_approve', $forum_id)) {
    trigger_error('NO_TOPIC');
}
//Check for read permission
if (!$_CLASS['auth']->acl_get('f_read', $forum_id)) {
    if ($_CLASS['core_user']->data['user_id'] != ANONYMOUS) {
        trigger_error('SORRY_AUTH_READ');
    }
    login_box(array('explain' => $_CLASS['core_user']->lang['LOGIN_VIEWFORUM']));
}
// Are we watching this topic?
if (!isset($topic_data['notify_status'])) {
    $topic_data['notify_status'] = null;
    $topic_data['watch_topic'] = false;
}
$s_watching_topic = watch_topic_forum('topic', $_CLASS['core_user']->data['user_id'], $forum_id, $topic_id, $topic_data['notify_status'], $start);
// Bookmarks
if ($config['allow_bookmarks'] && $_CLASS['core_user']->is_user && request_var('bookmark', 0)) {
    if (!$topic_data['bookmarked']) {
        $sql = 'INSERT INTO ' . FORUMS_BOOKMARKS_TABLE . ' ' . $_CLASS['core_db']->sql_build_array('INSERT', array('user_id' => $_CLASS['core_user']->data['user_id'], 'topic_id' => $topic_id, 'order_id' => 0));
        $_CLASS['core_db']->query($sql);
        $where_sql = '';
        $sign = '+';
    } else {
        $sql = 'DELETE FROM ' . FORUMS_BOOKMARKS_TABLE . ' 
			WHERE user_id = ' . $_CLASS['core_user']->data['user_id'] . '
				AND order_id = ' . $topic_data['bookmarked'];
        $_CLASS['core_db']->query($sql);
        // Works because of current order_id selected as bookmark value (please do not change because of simplicity)
        $where_sql = " AND order_id > " . $topic_data['bookmarked'];
        $sign = '-';
if ($forum_data['enable_prune'] && $forum_data['prune_next'] < $_CLASS['core_user']->time)
{
	require_once(SITE_FILE_ROOT.'includes/forums/functions_admin.php');
	if ($forum_data['prune_days'])
	{
		auto_prune($forum_id, 'posted', $forum_data['forum_flags'], $forum_data['prune_days'], $forum_data['prune_freq']);
	}
	if ($forum_data['prune_viewed'])
	{
		auto_prune($forum_id, 'viewed', $forum_data['forum_flags'], $forum_data['prune_viewed'], $forum_data['prune_freq']);
	}
}
*/
if ($_CLASS['auth']->acl_get('f_subscribe', $forum_id)) {
    $notify_status = isset($forum_data['notify_status']) ? $forum_data['notify_status'] : null;
    $s_watching_forum = watch_topic_forum('forum', $_CLASS['core_user']->data['user_id'], $forum_id, 0, $notify_status);
} else {
    $s_watching_forum['link'] = $s_watching_forum['title'] = '';
}
gen_forum_auth_level('forum', $forum_id);
// Topic ordering options
$limit_days = array(0 => $_CLASS['core_user']->lang['ALL_TOPICS'], 1 => $_CLASS['core_user']->lang['1_DAY'], 7 => $_CLASS['core_user']->lang['7_DAYS'], 14 => $_CLASS['core_user']->lang['2_WEEKS'], 30 => $_CLASS['core_user']->lang['1_MONTH'], 90 => $_CLASS['core_user']->lang['3_MONTHS'], 180 => $_CLASS['core_user']->lang['6_MONTHS'], 364 => $_CLASS['core_user']->lang['1_YEAR']);
$sort_by_text = array('a' => $_CLASS['core_user']->lang['AUTHOR'], 't' => $_CLASS['core_user']->lang['POST_TIME'], 'r' => $_CLASS['core_user']->lang['REPLIES'], 's' => $_CLASS['core_user']->lang['SUBJECT'], 'v' => $_CLASS['core_user']->lang['VIEWS']);
$sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => 't.topic_last_post_time', 'r' => 't.topic_replies', 's' => 't.topic_title', 'v' => 't.topic_views');
$sort_key = !in_array($sort_key, array('a', 't', 'r', 's', 'v')) ? 't' : $sort_key;
$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);
// Limit topics to certain time frame, obtain correct topic count
if ($sort_days) {
    $min_post_time = $_CLASS['core_user']->time - $sort_days * 86400;
    $sql = 'SELECT COUNT(topic_id) AS num_topics
Example #6
0
if ($start < 0 || $start > $total_posts)
{
	$start = ($start < 0) ? 0 : floor(($total_posts - 1) / $config['posts_per_page']) * $config['posts_per_page'];
}

// General Viewtopic URL for return links
$viewtopic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;start=$start&amp;$u_sort_param" . (($highlight_match) ? "&amp;hilit=$highlight" : ''));

// Are we watching this topic?
$s_watching_topic = $s_watching_topic_img = array();
$s_watching_topic['link'] = $s_watching_topic['title'] = '';
$s_watching_topic['is_watching'] = false;

if ($config['email_enable'] && $config['allow_topic_notify'] && $user->data['is_registered'])
{
	watch_topic_forum('topic', $s_watching_topic, $s_watching_topic_img, $user->data['user_id'], $forum_id, $topic_id, $topic_data['notify_status'], $start);
}

// Bookmarks
if ($config['allow_bookmarks'] && $user->data['is_registered'] && request_var('bookmark', 0))
{
	if (!$topic_data['bookmarked'])
	{
		$sql = 'INSERT INTO ' . BOOKMARKS_TABLE . ' ' . $db->sql_build_array('INSERT', array(
			'user_id'	=> $user->data['user_id'],
			'topic_id'	=> $topic_id,
		));
		$db->sql_query($sql);
	}
	else
	{