function bbcodeForum($contents, $arg, $parenttag)
{
    global $forumLinkCache, $loguser;
    $id = (int) $arg;
    if (!isset($forumLinkCache[$id])) {
        $rForum = Query("select id, title from {forums} where id={0} AND id IN ({1c})", $id, ForumsWithPermission('forum.viewforum'));
        if (NumRows($rForum)) {
            $forum = Fetch($rForum);
            $forumLinkCache[$id] = actionLinkTag($forum['title'], "forum", $forum['id'], '', HasPermission('forum.viewforum', $forum['id'], true) ? $forum['title'] : '');
        } else {
            $forumLinkCache[$id] = "<invalid forum ID>";
        }
    }
    return $forumLinkCache[$id];
}
<?php

$viewableforums = ForumsWithPermission('forum.viewforum');
$tag = $_GET['tag'];
$tagcode = '"[' . $tag . ']"';
$forum = $_GET['fid'];
$cond = "WHERE MATCH (t.title) AGAINST ({0} IN BOOLEAN MODE)";
if ($forum) {
    $cond .= " AND t.forum = {1}";
}
$total = Fetch(Query("SELECT count(*) from threads t {$cond} AND t.forum IN ({2c})", $tag, $forum, $viewableforums));
$total = $total[0];
$tpp = $loguser['threadsperpage'];
if (isset($_GET['from'])) {
    $from = (int) $_GET['from'];
} else {
    $from = 0;
}
if (!$tpp) {
    $tpp = 50;
}
$rThreads = Query("\tSELECT\n\t\t\t\t\t\tt.*,\n\t\t\t\t\t\tf.(title, id),\n\t\t\t\t\t\t" . ($loguserid ? "tr.date readdate," : '') . "\n\t\t\t\t\t\tsu.(_userfields),\n\t\t\t\t\t\tlu.(_userfields)\n\t\t\t\t\tFROM\n\t\t\t\t\t\tthreads t\n\t\t\t\t\t\t" . ($loguserid ? "LEFT JOIN threadsread tr ON tr.thread=t.id AND tr.id={2}" : '') . "\n\t\t\t\t\t\tLEFT JOIN users su ON su.id=t.user\n\t\t\t\t\t\tLEFT JOIN users lu ON lu.id=t.lastposter\n\t\t\t\t\t\tLEFT JOIN forums f ON f.id=t.forum\n\t\t\t\t\t{$cond} AND f.id IN ({5c})\n\t\t\t\t\tORDER BY sticky DESC, lastpostdate DESC LIMIT {3u}, {4u}", $tagcode, $forum, $loguserid, $from, $tpp, $viewableforums);
$pagelinks = PageLinks(actionLink("tagsearch", "", "tag={$tag}&fid={$forum}&from="), $tpp, $from, $total);
if (NumRows($rThreads)) {
    makeThreadListing($rThreads, $pagelinks, false, !$forum);
} else {
    Alert(format(__("Tag {0} was not found in any thread."), htmlspecialchars($tag)), __("No threads found."));
}
Beispiel #3
0
    $user = Fetch($rUser);
} else {
    Kill(__("Unknown user ID."));
}
$title = __("Post list");
$total = FetchResult("\n\t\t\tSELECT\n\t\t\t\tcount(p.id)\n\t\t\tFROM\n\t\t\t\t{posts} p\n\t\t\t\tLEFT JOIN {threads} t ON t.id=p.thread{$extrashit}\n\t\t\tWHERE p.user={0} AND t.forum IN ({1c})", $id, ForumsWithPermission('forum.viewforum'));
$ppp = $loguser['postsperpage'];
if (isset($_GET['from'])) {
    $from = (int) $_GET['from'];
} else {
    $from = 0;
}
if (!$ppp) {
    $ppp = 25;
}
$rPosts = Query("\tSELECT\n\t\t\t\tp.*,\n\t\t\t\tpt.text, pt.revision, pt.user AS revuser, pt.date AS revdate,\n\t\t\t\tu.(_userfields), u.(rankset,title,picture,posts,postheader,signature,signsep,lastposttime,lastactivity,regdate,globalblock,fulllayout),\n\t\t\t\tru.(_userfields),\n\t\t\t\tdu.(_userfields),\n\t\t\t\tt.id thread, t.title threadname,\n\t\t\t\tf.id fid\n\t\t\tFROM\n\t\t\t\t{posts} p\n\t\t\t\tLEFT JOIN {posts_text} pt ON pt.pid = p.id AND pt.revision = p.currentrevision\n\t\t\t\tLEFT JOIN {users} u ON u.id = p.user\n\t\t\t\tLEFT JOIN {users} ru ON ru.id=pt.user\n\t\t\t\tLEFT JOIN {users} du ON du.id=p.deletedby\n\t\t\t\tLEFT JOIN {threads} t ON t.id=p.thread\n\t\t\t\tLEFT JOIN {forums} f ON f.id=t.forum\n\t\t\t\tLEFT JOIN {categories} c ON c.id=f.catid\n\t\t\tWHERE u.id={1} AND f.id IN ({4c}){$extrashit}\n\t\t\tORDER BY date ASC LIMIT {2u}, {3u}", $loguserid, $id, $from, $ppp, ForumsWithPermission('forum.viewforum'));
$numonpage = NumRows($rPosts);
$uname = $user["name"];
if ($user["displayname"]) {
    $uname = $user["displayname"];
}
MakeCrumbs(array(actionLink("profile", $id, "", $user["name"]) => htmlspecialchars($uname), '' => __("List of posts")));
$pagelinks = PageLinks(actionLink("listposts", $id, "from=", $user['name']), $ppp, $from, $total);
RenderTemplate('pagelinks', array('pagelinks' => $pagelinks, 'position' => 'top'));
if (NumRows($rPosts)) {
    while ($post = Fetch($rPosts)) {
        MakePost($post, POST_NORMAL, array('threadlink' => 1, 'tid' => $post['thread'], 'fid' => $post['fid'], 'noreplylinks' => 1));
    }
} else {
    Alert('This user has no posts.', 'Notice');
}
Beispiel #4
0
     while ($revision = Fetch($revs)) {
         $reply .= " <a href=\"javascript:void(0)\" onclick=\"showRevision(" . $id . "," . $revision["revision"] . ")\">" . format(__("rev. {0}"), $revision["revision"]) . "</a>";
         if ($revision['ru_id']) {
             $ru_link = UserLink(getDataPrefix($revision, "ru_"));
             $revdetail = " " . format(__("by {0} on {1}"), $ru_link, formatdate($revision['revdate']));
         } else {
             $revdetail = '';
         }
         $reply .= $revdetail;
         $reply .= "<br />";
     }
     $hideTricks = " <a href=\"javascript:void(0)\" onclick=\"showRevision(" . $id . "," . $post["currentrevision"] . "); hideTricks(" . $id . ")\">" . __("Back") . "</a>";
     $reply .= $hideTricks;
     die($reply);
 } elseif ($action == "sr") {
     $rPost = Query("\n\t\t\tSELECT\n\t\t\t\tp.*,\n\t\t\t\tpt.text, pt.revision, pt.user AS revuser, pt.date AS revdate,\n\t\t\t\tu.(_userfields), u.(rankset,title,picture,posts,postheader,signature,signsep,lastposttime,lastactivity,regdate,globalblock),\n\t\t\t\tru.(_userfields),\n\t\t\t\tdu.(_userfields),\n\t\t\t\tt.forum fid\n\t\t\tFROM\n\t\t\t\t{posts} p\n\t\t\t\tLEFT JOIN {posts_text} pt ON pt.pid = p.id AND pt.revision = {1}\n\t\t\t\tLEFT JOIN {threads} t ON t.id=p.thread\n\t\t\t\tLEFT JOIN {users} u ON u.id = p.user\n\t\t\t\tLEFT JOIN {users} ru ON ru.id=pt.user\n\t\t\t\tLEFT JOIN {users} du ON du.id=p.deletedby\n\t\t\tWHERE p.id={0} AND t.forum IN ({2c})", $id, (int) $_GET['rev'], ForumsWithPermission('forum.viewforum'));
     if (NumRows($rPost)) {
         $post = Fetch($rPost);
     } else {
         die(format(__("Unknown post ID #{0} or revision missing."), $id));
     }
     if (!HasPermission('mod.editposts', $post['fid'])) {
         die('No.');
     }
     die(makePostText($post, getDataPrefix($post, 'u_')));
 } elseif ($action == "em") {
     $privacy = HasPermission('admin.editusers') ? '' : ' and showemail=1';
     $blah = FetchResult("select email from {users} where id={0}{$privacy}", $id);
     die(htmlspecialchars($blah));
 } elseif ($action == "vc") {
     $blah = FetchResult("select views from {misc}");
<?php

$title = __("Last posts");
MakeCrumbs(array(actionLink("lastposts") => __("Last posts")));
$allowedforums = ForumsWithPermission('forum.viewforum');
$time = $_GET['time'];
if ($time != 'new') {
    $time = (int) $time;
}
if (!$time) {
    $time = 86400;
}
$show = $_GET['show'];
if ($show != 'threads' && $show != 'posts') {
    $show = 'threads';
}
$from = (int) $_GET['from'];
$fparam = $from ? '&from=' . $from : '';
$spans = array(3600 => __('1 hour'), 86400 => __('1 day'), 259200 => __('3 days'), 'new' => __('New posts'));
$options = array();
foreach ($spans as $span => $desc) {
    if ($span == $time) {
        $options[] = $desc;
    } else {
        $options[] = actionLinkTag($desc, 'lastposts', '', 'time=' . $span . '&show=' . $show . $fparam);
    }
}
$options2 = array();
$options2[] = $show == 'threads' ? __('List threads') : actionLinkTag(__('Show threads'), 'lastposts', '', 'time=' . $time . '&show=threads' . $fparam);
$options2[] = $show == 'posts' ? __('Show posts') : actionLinkTag(__('Show posts'), 'lastposts', '', 'time=' . $time . '&show=posts' . $fparam);
RenderTemplate('lastposts_options', array('timelinks' => $options, 'misclinks' => $options2));
Beispiel #6
0
function makeForumListing($parent, $board = '')
{
    global $loguserid, $loguser, $usergroups;
    $viewableforums = ForumsWithPermission('forum.viewforum');
    $viewhidden = HasPermission('user.viewhiddenforums');
    $rFora = Query("\tSELECT f.*,\n\t\t\t\t\t\t\tc.name cname,\n\t\t\t\t\t\t\t" . ($loguserid ? "(NOT ISNULL(i.fid))" : "0") . " ignored,\n\t\t\t\t\t\t\t(SELECT COUNT(*) FROM {threads} t" . ($loguserid ? " LEFT JOIN {threadsread} tr ON tr.thread=t.id AND tr.id={0}" : "") . "\n\t\t\t\t\t\t\t\tWHERE t.forum=f.id AND t.lastpostdate>" . ($loguserid ? "IFNULL(tr.date,0)" : time() - 900) . ") numnew,\n\t\t\t\t\t\t\tlu.(_userfields)\n\t\t\t\t\t\tFROM {forums} f\n\t\t\t\t\t\t\tLEFT JOIN {categories} c ON c.id=f.catid\n\t\t\t\t\t\t\t" . ($loguserid ? "LEFT JOIN {ignoredforums} i ON i.fid=f.id AND i.uid={0}" : "") . "\n\t\t\t\t\t\t\tLEFT JOIN {users} lu ON lu.id=f.lastpostuser\n\t\t\t\t\t\tWHERE f.id IN ({1c}) AND " . ($parent == 0 ? 'c.board={2} AND f.catid>0' : 'f.catid={3}') . (!$viewhidden ? " AND f.hidden=0" : '') . "\n\t\t\t\t\t\tORDER BY c.corder, c.id, f.forder, f.id", $loguserid, $viewableforums, $board, -$parent);
    if (!NumRows($rFora)) {
        return;
    }
    $f = Fetch(Query("SELECT MIN(l) minl, MAX(r) maxr FROM {forums} WHERE " . ($parent == 0 ? 'board={0}' : 'catid={1}'), $board, -$parent));
    $rSubfora = Query("\tSELECT f.*,\n\t\t\t\t\t\t\t" . ($loguserid ? "(NOT ISNULL(i.fid))" : "0") . " ignored,\n\t\t\t\t\t\t\t(SELECT COUNT(*) FROM {threads} t" . ($loguserid ? " LEFT JOIN {threadsread} tr ON tr.thread=t.id AND tr.id={0}" : "") . "\n\t\t\t\t\t\t\t\tWHERE t.forum=f.id AND t.lastpostdate>" . ($loguserid ? "IFNULL(tr.date,0)" : time() - 900) . ") numnew\n\t\t\t\t\t\tFROM {forums} f\n\t\t\t\t\t\t\t" . ($loguserid ? "LEFT JOIN {ignoredforums} i ON i.fid=f.id AND i.uid={0}" : "") . "\n\t\t\t\t\t\tWHERE f.id IN ({1c}) AND f.l>{2} AND f.r<{3} AND f.catid!={4}" . (!$viewhidden ? " AND f.hidden=0" : '') . "\n\t\t\t\t\t\tORDER BY f.forder, f.id", $loguserid, $viewableforums, $f['minl'], $f['maxr'], -$parent);
    $subfora = array();
    while ($sf = Fetch($rSubfora)) {
        $subfora[-$sf['catid']][] = $sf;
    }
    $rMods = Query("\tSELECT \n\t\t\t\t\t\t\tp.(arg, applyto, id),\n\t\t\t\t\t\t\tu.(_userfields)\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t{permissions} p\n\t\t\t\t\t\t\tLEFT JOIN {users} u ON p.applyto=1 AND p.id=u.id\n\t\t\t\t\t\tWHERE SUBSTR(p.perm,1,4)={0} AND p.arg!=0 AND p.value=1\n\t\t\t\t\t\tGROUP BY p.applyto, p.id, p.arg\n\t\t\t\t\t\tORDER BY p.applyto, p.id", 'mod.');
    $mods = array();
    while ($mod = Fetch($rMods)) {
        $mods[$mod['p_arg']][] = $mod['p_applyto'] ? getDataPrefix($mod, "u_") : array('groupid' => $mod['p_id']);
    }
    $categories = array();
    while ($forum = Fetch($rFora)) {
        $skipThisOne = false;
        $bucket = "forumListMangler";
        include __DIR__ . "/pluginloader.php";
        if ($skipThisOne) {
            continue;
        }
        if (!$categories[$forum['catid']]) {
            $categories[$forum['catid']] = array('id' => $forum['catid'], 'name' => $parent == 0 ? $forum['cname'] : 'Subforums', 'forums' => array());
        }
        $fdata = array('id' => $forum['id']);
        if ($forum['redirect']) {
            $redir = $forum['redirect'];
            if ($redir[0] == ':') {
                $redir = explode(':', $redir);
                $fdata['link'] = actionLinkTag($forum['title'], $redir[1], $redir[2], $redir[3], $redir[4]);
                $forum['numthreads'] = '-';
                $forum['numposts'] = '-';
                if ($redir[1] == 'board') {
                    $tboard = $redir[2];
                    $f = Fetch(Query("SELECT MIN(l) minl, MAX(r) maxr FROM {forums} WHERE board={0}", $tboard));
                    $forum['numthreads'] = 0;
                    $forum['numposts'] = 0;
                    $sforums = Query("\tSELECT f.id, f.numthreads, f.numposts, f.lastpostid, f.lastpostuser, f.lastpostdate,\n\t\t\t\t\t\t\t\t\t\t\t" . ($loguserid ? "(NOT ISNULL(i.fid))" : "0") . " ignored,\n\t\t\t\t\t\t\t\t\t\t\t(SELECT COUNT(*) FROM {threads} t" . ($loguserid ? " LEFT JOIN {threadsread} tr ON tr.thread=t.id AND tr.id={0}" : "") . "\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE t.forum=f.id AND t.lastpostdate>" . ($loguserid ? "IFNULL(tr.date,0)" : time() - 900) . ") numnew,\n\t\t\t\t\t\t\t\t\t\t\tlu.(_userfields)\n\t\t\t\t\t\t\t\t\t\tFROM {forums} f\n\t\t\t\t\t\t\t\t\t\t\t" . ($loguserid ? "LEFT JOIN {ignoredforums} i ON i.fid=f.id AND i.uid={0}" : "") . "\n\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN {users} lu ON lu.id=f.lastpostuser\n\t\t\t\t\t\t\t\t\t\tWHERE f.l>={1} AND f.r<={2}", $loguserid, $f['minl'], $f['maxr']);
                    while ($sforum = Fetch($sforums)) {
                        $forum['numthreads'] += $sforum['numthreads'];
                        $forum['numposts'] += $sforum['numposts'];
                        if (!HasPermission('forum.viewforum', $sforum['id'])) {
                            continue;
                        }
                        if (!$sforum['ignored']) {
                            $forum['numnew'] += $sforum['numnew'];
                        }
                        if ($sforum['lastpostdate'] > $forum['lastpostdate']) {
                            $forum['lastpostdate'] = $sforum['lastpostdate'];
                            $forum['lastpostid'] = $sforum['lastpostid'];
                            $forum['lastpostuser'] = $sforum['lastpostuser'];
                            foreach ($sforum as $key => $val) {
                                if (substr($key, 0, 3) != 'lu_') {
                                    continue;
                                }
                                $forum[$key] = $val;
                            }
                        }
                    }
                }
            } else {
                $fdata['link'] = '<a href="' . htmlspecialchars($redir) . '">' . $forum['title'] . '</a>';
            }
        } else {
            $fdata['link'] = actionLinkTag($forum['title'], "forum", $forum['id'], '', HasPermission('forum.viewforum', $forum['id'], true) ? $forum['title'] : '');
        }
        $fdata['ignored'] = $forum['ignored'];
        $newstuff = 0;
        $localMods = '';
        $subforaList = '';
        $newstuff = $forum['ignored'] ? 0 : $forum['numnew'];
        if ($newstuff > 0) {
            $fdata['new'] = "<div class=\"statusIcon new\">{$newstuff}</div>";
        }
        $fdata['description'] = $forum['description'];
        if (isset($mods[$forum['id']])) {
            foreach ($mods[$forum['id']] as $user) {
                if ($user['groupid']) {
                    $localMods .= htmlspecialchars($usergroups[$user['groupid']]['name']) . ', ';
                } else {
                    $localMods .= UserLink($user) . ', ';
                }
            }
        }
        if ($localMods) {
            $fdata['localmods'] = substr($localMods, 0, -2);
        }
        if (isset($subfora[$forum['id']])) {
            foreach ($subfora[$forum['id']] as $subforum) {
                $link = actionLinkTag($subforum['title'], 'forum', $subforum['id'], '', HasPermission('forum.viewforum', $subforum['id'], true) ? $subforum['title'] : '');
                if ($subforum['ignored']) {
                    $link = '<span class="ignored">' . $link . '</span>';
                } else {
                    if ($subforum['numnew'] > 0) {
                        $link = '<div class="statusIcon new"></div> ' . $link;
                    }
                }
                $subforaList .= $link . ', ';
            }
        }
        if ($subforaList) {
            $fdata['subforums'] = substr($subforaList, 0, -2);
        }
        $fdata['threads'] = $forum['numthreads'];
        $fdata['posts'] = $forum['numposts'];
        if ($forum['lastpostdate']) {
            $user = getDataPrefix($forum, "lu_");
            $fdata['lastpostdate'] = formatdate($forum['lastpostdate']);
            $fdata['lastpostuser'] = UserLink($user);
            $fdata['lastpostlink'] = actionLink('post', $forum['lastpostid']);
        } else {
            $fdata['lastpostdate'] = 0;
        }
        $categories[$forum['catid']]['forums'][$forum['id']] = $fdata;
    }
    RenderTemplate('forumlist', array('categories' => $categories));
}
Beispiel #7
0
function ForumJump()
{
    global $fid, $loguserid, $loguser, $forum;
    $viewableforums = ForumsWithPermission('forum.viewforum');
    $viewhidden = HasPermission('user.viewhiddenforums');
    $rCats = Query("SELECT id, name FROM {categories} WHERE board={0} ORDER BY corder, id", $forum['board']);
    $cats = array();
    while ($cat = Fetch($rCats)) {
        $cats[$cat['id']] = $cat['name'];
    }
    $rFora = Query("\tSELECT\n\t\t\t\t\t\t\tf.id, f.title, f.catid, f.redirect\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t{forums} f\n\t\t\t\t\t\tWHERE f.id IN ({0c})" . (!$viewhidden ? " AND f.hidden=0" : '') . "\n\t\t\t\t\t\tORDER BY f.forder, f.id", $viewableforums);
    $fora = array();
    while ($forum = Fetch($rFora)) {
        $fora[$forum['catid']][] = $forum;
    }
    $theList = '';
    foreach ($cats as $cid => $cname) {
        if (empty($fora[$cid])) {
            continue;
        }
        $theList .= '			<optgroup label="' . htmlspecialchars($cname) . '">
' . fj_forumBlock($fora, $cid, $fid, 0) . '			</optgroup>
';
    }
    $theList = '<select onchange="document.location=this.options[this.selectedIndex].value;">' . ($forum['board'] ? '<option value="' . actionLink('board') . '">Back to main forums</option>' : '') . $theList . '</select>';
    RenderTemplate('forumjump', array('forumlist' => $theList));
}