list($pagertop, $pagerbottom, $limit) = pager($perpage, $hits, "forums.php?action=search&keywords=" . rawurlencode($keywords) . "&"); $res = sql_query("SELECT posts.id, posts.topicid, posts.userid, posts.added, topics.subject, topics.hlcolor, forums.id AS forumid, forums.name AS forumname FROM posts LEFT JOIN topics ON posts.topicid = topics.id LEFT JOIN forums ON topics.forumid = forums.id WHERE forums.minclassread <= " . sqlesc(get_user_class()) . " AND ((topics.subject {$extraSql} AND posts.id=topics.firstpost) OR posts.body {$extraSql}) AND topics.casinomode = \"no\" ORDER BY posts.id DESC {$limit}") or sqlerr(__FILE__, __LINE__); print $pagertop; print "<table border=\"1\" cellspacing=\"0\" cellpadding=\"5\" width=\"940\">\n"; print "<tr><td class=\"colhead\" align=\"center\">" . $lang_forums['col_post'] . "</td><td class=\"colhead\" align=\"center\" width=\"70%\">" . $lang_forums['col_topic'] . "</td><td class=\"colhead\" align=\"left\">" . $lang_forums['col_forum'] . "</td><td class=\"colhead\" align=\"left\">" . $lang_forums['col_posted_by'] . "</td></tr>\n"; while ($post = mysql_fetch_array($res)) { print "<tr><td class=\"rowfollow\" align=\"center\" width=\"1%\">" . $post[id] . "</td><td class=\"rowfollow\" align=\"left\"><a href=\"" . htmlspecialchars("?action=viewtopic&topicid=" . $post[topicid] . "&highlight=" . rawurlencode($keywords) . "&page=p" . $post[id] . "#pid" . $post[id]) . "\">" . highlight_topic(highlight($keywords, htmlspecialchars($post['subject'])), $post['hlcolor']) . "</a></td><td class=\"rowfollow nowrap\" align=\"left\"><a href=\"" . htmlspecialchars("?action=viewforum&forumid=" . $post['forumid']) . "\"><b>" . htmlspecialchars($post["forumname"]) . "</b></a></td><td class=\"rowfollow nowrap\" align=\"left\">" . gettime($post['added'], true, false) . " | " . get_username($post['userid']) . "</td></tr>\n"; } print "</table>\n"; print $pagerbottom; } stdfoot(); die; } if ($_GET["catchup"] == 1) { catch_up(); } //-------- Handle unknown action if ($action != "") { stderr($lang_forums['std_forum_error'], $lang_forums['std_unknown_action']); } //-------- Default action: View forums //-------- Get forums if ($CURUSER) { $USERUPDATESET[] = "forum_access = " . sqlesc(date("Y-m-d H:i:s")); } stdhead($lang_forums['head_forums']); begin_main_frame(); print "<h1 align=\"center\">" . $SITENAME . " " . $lang_forums['text_forums'] . "</h1>"; print "<p align=\"center\"><a href=\"?action=search\"><b>" . $lang_forums['text_search'] . "</b></a> | <a href=\"?action=viewunread\"><b>" . $lang_forums['text_view_unread'] . "</b></a> | <a href=\"?catchup=1\"><b>" . $lang_forums['text_catch_up'] . "</b></a> " . (get_user_class() >= $forummanage_class ? "| <a href=\"forummanage.php\"><b>" . $lang_forums['text_forum_manager'] . "</b></a>" : "") . "</p>"; print "<table border=\"1\" cellspacing=\"0\" cellpadding=\"5\" width=\"100%\">\n";
echo $HTMLOUT; exit; } // -------- Action: View unread posts if ((isset($_POST[$action]) ? htmlsafechars($_POST[$action]) : '') == 'clear') { $topic_ids = isset($_POST['topic_id']) ? $_POST['topic_id'] : array(); if (empty($topic_ids)) { header('Location: ' . $INSTALLER09['baseurl'] . '/forums.php?action=' . $action); exit; } foreach ($topic_ids as $topic_id) { if (!is_valid_id($topic_id)) { stderr('Error...', 'Invalid ID!'); } } $HTMLOUT .= catch_up($topic_ids); header('Location: ' . $INSTALLER09['baseurl'] . '/forums.php?action=' . $action); exit; } else { $added = TIME_NOW - $INSTALLER09['readpost_expiry']; $res = sql_query('SELECT t.last_post, r.last_post_read, f.min_class_read ' . 'FROM topics AS t ' . 'LEFT JOIN posts AS p ON t.last_post=p.id ' . 'LEFT JOIN read_posts AS r ON r.user_id=' . sqlesc((int) $CURUSER['id']) . ' AND r.topic_id=t.id ' . 'LEFT JOIN forums AS f ON f.id=t.forum_id ' . 'WHERE p.added > ' . $added) or sqlerr(__FILE__, __LINE__); $count = 0; while ($arr = mysqli_fetch_assoc($res)) { if ($arr['last_post_read'] >= $arr['last_post'] || $CURUSER['class'] < $arr['min_class_read']) { continue; } $count++; } mysqli_free_result($res) || is_object($res) && get_class($res) == "mysqli_result" ? true : false; if ($count > 0) { $perpage = 25;