コード例 #1
0
        unset($newpost);
        $res = do_sqlquery("SELECT COUNT(*) FROM {$TABLE_PREFIX}posts WHERE topicid={$topicid}" . ($new_id == "last" ? "" : " AND id<={$new_id}"), true);
    } else {
        $res = do_sqlquery("SELECT COUNT(*) FROM {$TABLE_PREFIX}posts WHERE topicid={$topicid} AND id<={$msg_number}", true);
    }
    $arr = mysql_fetch_row($res);
    $cur_post_pos = $arr[0];
    $_GET["pages"] = ceil($cur_post_pos / $postsperpage);
}
unset($arr);
mysql_free_result($res);
//------ Make page menu
if ($page == "last") {
    $_GET["pages"] = ceil($postcount / $postsperpage);
}
list($pagertop, $pagerbottom, $limit) = forum_pager($postsperpage, $postcount, "index.php?page=forum&amp;action=viewtopic&amp;topicid={$topicid}&amp;");
if ($XBTT_USE) {
    $query = "SELECT p.*, u.warn, u.username, IFNULL(ul.level,'" . $language['UNKNOWN'] . "') as user_group, u.avatar, u.uploaded+IFNULL(x.uploaded,0) as uploaded" . ", u.downloaded+IFNULL(x.downloaded,0) as downloaded, c.name as name, ue.username as editor, flagpic FROM {$TABLE_PREFIX}posts p" . " LEFT JOIN {$TABLE_PREFIX}users u ON p.userid=u.id LEFT JOIN xbt_users x ON x.uid=u.id LEFT JOIN {$TABLE_PREFIX}users_level ul" . " ON u.id_level=ul.id LEFT JOIN {$TABLE_PREFIX}countries c ON u.flag = c.id LEFT JOIN {$TABLE_PREFIX}users ue ON p.editedby=ue.id" . " WHERE topicid={$topicid} ORDER BY id {$limit}";
} else {
    $query = "SELECT p.*, u.warn, u.username,IFNULL(ul.level,'" . $language['UNKNOWN'] . "') as user_group, u.avatar, u.uploaded" . ", u.downloaded, c.name as name, ue.username as editor, flagpic FROM {$TABLE_PREFIX}posts p" . " LEFT JOIN {$TABLE_PREFIX}users u ON p.userid=u.id LEFT JOIN {$TABLE_PREFIX}users_level ul" . " ON u.id_level=ul.id LEFT JOIN {$TABLE_PREFIX}countries c ON u.flag = c.id LEFT JOIN {$TABLE_PREFIX}users ue ON p.editedby=ue.id" . " WHERE topicid={$topicid} ORDER BY id {$limit}";
}
$res = get_result($query, true);
$pc = count($res);
$pn = 0;
$posts = array();
$page = isset($page) ? $page > 0 ? max(1, $page) : 1 : 1;
$post_number = $postsperpage * ($page - 1) + 1;
foreach ($res as $id => $arr) {
    $posterid = $arr["userid"];
    if ($arr["username"]) {
        $posts[$pn]["username"] = ($arr["userid"] > 1 ? "<a href=\"index.php?page=userdetails&amp;id=" . $arr["userid"] . "\">" . unesc($arr["username"]) . "</a>" : unesc($arr["username"])) . warn($arr);
コード例 #2
0
}
unset($res);
unset($arr);
$block_title = "<a href=\"index.php?page=forum\">" . $language["FORUM"] . "</a>&nbsp;&gt;&nbsp;{$forumname}";
//------ Page links
//------ Get topic count
$perpage = $CURUSER["topicsperpage"];
if (!$perpage) {
    $perpage = 20;
}
$res = do_sqlquery("SELECT COUNT(*) FROM {$TABLE_PREFIX}topics WHERE forumid={$forumid}", true);
$arr = mysql_fetch_row($res);
$numtopics = $arr[0];
mysql_free_result($res);
unset($arr);
list($pagertop, $pagerbottom, $limit) = forum_pager($perpage, $numtopics, "index.php?page=forum&amp;action=viewforum&amp;forumid={$forumid}&amp;");
//------ Get topics data
$topicsres = do_sqlquery("SELECT t.*,(SELECT COUNT(*) FROM {$TABLE_PREFIX}posts WHERE topicid=t.id) as num_posts," . " ulp.username as lastposter, ulp.id as lastposter_uid, p.added as start_date, us.username as starter," . " IF(t.lastpost<=(SELECT lastpostread FROM {$TABLE_PREFIX}readposts rp WHERE rp.userid=" . intval($CURUSER["uid"]) . " AND rp.topicid=t.id) OR t.lastpost IS NULL,'unlocked','unlockednew') as img" . " FROM {$TABLE_PREFIX}topics t LEFT JOIN {$TABLE_PREFIX}users us ON t.userid=us.id" . " LEFT JOIN {$TABLE_PREFIX}posts p ON t.lastpost=p.id LEFT JOIN {$TABLE_PREFIX}users ulp ON p.userid=ulp.id" . " WHERE forumid={$forumid} ORDER BY sticky, lastpost DESC {$limit}", true);
$postsperpage = $CURUSER["postsperpage"];
if (!$postsperpage) {
    $postsperpage = 15;
}
if ($numtopics > 0) {
    $forumtpl->set("NO_TOPICS", false, true);
    $topics = array();
    $i = 0;
    while ($topicarr = mysql_fetch_assoc($topicsres)) {
        $topicid = $topicarr["id"];
        $topic_userid = $topicarr["userid"];
        $topic_views = $topicarr["views"];
        $locked = $topicarr["locked"] == "yes";
コード例 #3
0
ファイル: forum.search.php プロジェクト: Karpec/gizd
if ($keywords != "") {
    $perpage = $CURUSER["topicsperpage"];
    if (!$perpage) {
        $perpage = 20;
    }
    $pagemenu1 = "";
    $page = isset($_GET["page"]) ? max(1, intval(0 + $_GET["page"])) : 1;
    $ekeywords = sqlesc($keywords);
    $res = do_sqlquery("SELECT COUNT(*) FROM {$TABLE_PREFIX}posts WHERE MATCH (body) AGAINST ({$ekeywords} IN BOOLEAN MODE)", true);
    $arr = mysqli_fetch_row($res);
    $hits = intval(0 + $arr[0]);
    if ($hits == 0) {
        $forumtpl->set("NO_TOPICS", true, true);
    } else {
        $forumtpl->set("NO_TOPICS", false, true);
        list($pagertop, $pagerbottom, $limit) = forum_pager($perpage, $hits, "index.php?page=forum&amp;action=search&amp;keywords=" . htmlspecialchars($keywords) . "&amp;");
        $res = get_result("SELECT p.*, t.subject, f.id as forumid, f.name as forumname, u.username, p.added, MATCH (p.body) AGAINST ({$ekeywords} IN BOOLEAN MODE) as score FROM {$TABLE_PREFIX}posts p" . " LEFT JOIN {$TABLE_PREFIX}users u ON p.userid=u.id INNER JOIN {$TABLE_PREFIX}topics t ON p.topicid=t.id" . " INNER JOIN {$TABLE_PREFIX}forums f ON t.forumid=f.id" . " WHERE IFNULL(f.minclassread,999)<=" . $CURUSER["id_level"] . " AND MATCH (p.body) AGAINST ({$ekeywords} IN BOOLEAN MODE)" . " ORDER BY score, added DESC  {$limit}", true, $btit_settings['cache_duration']);
        $search = array();
        $i = 0;
        foreach ($res as $id => $sr) {
            if ($sr["forumname"] == "") {
                continue;
            }
            $search[$i]["match"] = $sr["score"];
            $search[$i]["postid"] = $sr["id"];
            $search[$i]["topic"] = "<a href=\"index.php?page=forum&amp;action=viewtopic&amp;topicid=" . $sr["topicid"] . "&amp;hl=" . urlencode($keywords) . "&amp;msg=" . $sr["id"] . "#" . $sr["id"] . "\">" . unesc(htmlspecialchars($sr["subject"])) . "</a>";
            $search[$i]["forum"] = "<a href=\"index.php?page=forum&amp;action=viewforum&amp;forumid=" . $sr["forumid"] . "\">" . unesc(htmlspecialchars($sr["forumname"])) . "</a>";
            $search[$i]["author"] = get_date_time($sr["added"]) . "&nbsp;" . $language["AT"] . "&nbsp;" . ($sr["username"] == "" ? "unknown[" . $sr["userid"] . "]" : "<a href=\"index.php?page=userdetails&amp;id=" . $sr["userid"] . "\">" . unesc(htmlspecialchars($sr["username"])) . "</a>");
            $search[$i]["body"] = highlight_search(cut_string($sr["body"], 200), explode(" ", $keywords));
            $i++;
        }