Exemple #1
0
function outputStory($article, $only_snippet = FALSE)
{
    global $conn;
    if ($article) {
        $sql = "SELECT ar.*, usr.name " . "FROM cms_articles ar " . "LEFT OUTER JOIN cms_users usr " . "ON ar.author_id = usr.user_id " . "WHERE ar.article_id = " . $article;
        $result = mysql_query($sql, $conn);
        if ($row = mysql_fetch_array($result)) {
            echo "<h3>" . htmlspecialchars($row["title"]) . "</h3>\n";
            echo "<h5><div class=\"byline\">By: " . htmlspecialchars($row["name"]) . "</div>";
            echo "<div class=\"pubdate\">";
            if ($row["is_published"] == 1) {
                echo date("F j, Y", strtotime($row["date_published"]));
            } else {
                echo "not yet published";
            }
            echo "</div></h5>\n";
            if ($only_snippet) {
                echo "<p>\n";
                echo nl2br(htmlspecialchars(trimBody($row["body"])));
                echo "</p>\n";
                echo "<h4><a href=\"viewarticle.php?article=" . $row["article_id"] . "\">Full Story...</a></a4><br>\n";
            } else {
                echo "<p>\n";
                echo nl2br(htmlspecialchars($row["body"]));
                echo "<br/><a href=\"authorinfo.php?author=" . $row["name"] . "\">Author Info</a>";
                echo "</p>\n";
            }
        }
    }
}
function showTopic($topicid, $showfull = TRUE)
{
    global $conn;
    global $userid;
    global $limit;
    echo breadcrumb($topicid, "P");
    if (isset($_GET['page'])) {
        $page = $_GET['page'];
    } else {
        $page = 1;
    }
    if ($limit == "") {
        $limit = 25;
    }
    $start = ($page - 1) * $limit;
    if (isset($_SESSION['user_id'])) {
        echo topicReplyBar($topicid, getForumID($topicid), "right");
    }
    $sql = "SELECT SQL_CALC_FOUND_ROWS " . "p.id, p.subject, p.body, p.date_posted, " . "p.date_updated, u.username as author, u.id as author_id, " . "c.post_count as postcount, " . "p.forum_id as forum_id, f.forum_moderator as mod, " . "p.update_id, u2.username as updated_by " . "FROM forum f " . "JOIN posts p " . "ON f.id = p.forum_id " . "JOIN login u " . "ON u.id = p.author_id " . "LEFT JOIN login u2 " . "ON u2.id = p.update_id " . "LEFT JOIN info c " . "ON u.id = c.user_id " . "WHERE (p.topic_id = {$topicid} OR p.id = {$topicid}) " . "ORDER BY p.topic_id, p.date_posted " . "LIMIT {$start}, {$limit}";
    $result = mysql_query($sql, $db) or die(mysql_error() . "<br />" . $sql);
    $pagelinks = paginate($limit);
    if (mysql_num_rows($result) == 0) {
        $msg = "There are currently no posts.Would you like to be the first person to create a thread?";
        $title = "No Posts...";
        $dest = "./frm_compose.php?forumid=" . $forumid;
        $sev = "Info";
        $message = msgBox($msg, $title, $dest, $sev);
        echo $message;
    } else {
        echo "<table class='forumtable' cellspacing='0' ";
        echo "cellpadding='2'><tr>";
        echo "<th class='author'>Author</th>";
        echo "<th class='post'>Post</th>";
        echo "</tr>";
        while ($row = mysql_fetch_array($result)) {
            $lastupdate = "";
            $editlink = "";
            $dellink = "";
            $replylink = "&nbsp;";
            $pcount = "";
            $pdate = "";
            $sig = "";
            if ($showfull) {
                $body = $row['body'];
                if (isset($_SESSION['user_id'])) {
                    $replylink = "<a href='frm_compose.php?forumid=" . $row['forum_id'] . "&topicid={$topicid}&reid=" . $row['id'] . "' class='buttonlink'>REPLY</a>&nbsp;";
                } else {
                    $replylink = "";
                }
                if ($row['update_id'] > 0) {
                    $lastupdate = "<p class='smallNote'>Last updated: " . $row['date_updated'] . " by " . $row['updated_by'] . "</p>";
                }
                if ($userid == $row['author_id'] or $userid == $row['mod'] or $_SESSION['access_lvl'] > 1) {
                    $editlink = "<a href='frm_compose.php?a=edit&post=" . $row['id'] . "' class='buttonlink'>EDIT</a>&nbsp;";
                    $dellink = "<a href='frm_transact_affirm.php?action=deletepost&id=" . $row['id'] . "' class='buttonlink'>DELETE</a>&nbsp;";
                }
                $pcount = "<br /><span class='textsmall'>Posts: " . ($row['postcount'] == "" ? "0" : $row['postcount']) . "</span>";
                $pdate = $row['date_posted'];
                $sig = ($row['sig'] != "" ? "<p class='sig'>" . nl2br($row['sig']) : "") . "</p>";
            } else {
                $body = trimBody($body);
            }
            $rowclass = $rowclass == "row1" ? "row2" : "row1";
            echo "<tr class='{$rowclass}'>";
            echo "<td class='author'>" . $row['author'];
            echo $pcount;
            echo "</td><td class='post'><p>";
            if (isset($_SESSION['user_id']) and $_SESSION['last_login'] < $row['date_posted']) {
                echo NEWPOST . " ";
            }
            if (isset($_GET['page'])) {
                $pagelink = "&page=" . $_GET['page'];
            }
            echo "<a name='post" . $row['id'] . "' href='frm_view_topic.php?t=" . $topicid . $pagelink . "#post" . $row['id'] . "'>" . POSTLINK . "</a>";
            if (isset($row['subject'])) {
                echo " <strong>" . $row['subject'] . "</strong>";
            }
            echo "</p><p>" . nl2br(htmlspecialchars($body)) . "</p>";
            echo $sig;
            echo $lastupdate;
            echo "</td></tr>";
            echo "<tr class='{$rowclass}'><td class='authorfooter'>";
            echo $pdate . "</td><td class='threadfooter'>";
            echo $replylink;
            echo $editlink;
            echo $dellink;
            echo "</td></tr>\n";
        }
        echo "</table>";
        echo $pagelinks;
        echo "<p>" . NEWPOST . " = New Post&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
        echo POSTLINK . " = Post link (use to bookmark)</p>";
    }
}
Exemple #3
0
if (isset($_GET['keywords'])) {
    $sql = "SELECT *, MATCH (subject,body) " . "AGAINST ('" . $_GET['keywords'] . "') AS score " . "FROM posts " . "WHERE MATCH (subject,body) " . "AGAINST ('" . $_GET['keywords'] . "') " . "ORDER BY score DESC";
    $result = mysql_query($sql, $db) or die('Could not perform search; ' . mysql_error());
}
echo "<table class='forumtable' width='100%' cellspacing='0'>\n";
echo "<tr><th class='searchHeader'>Search Results</th></tr>\n";
if ($result and !mysql_num_rows($result)) {
    echo "<tr class='row1'><td>No articles found that match the ";
    echo "search term(s) '<strong>" . $_GET['keywords'] . "</strong>'";
    if ($access_level > 1) {
        echo "<p>SQL: {$sql}</p>";
    }
    echo "</td></tr>\n";
} else {
    while ($row = mysql_fetch_array($result)) {
        $rowclass = $rowclass == "row1" ? "row2" : "row1";
        echo "<tr class='{$rowclass}'>\n<td>\n";
        $topicid = $row['topic_id'] == 0 ? $row['id'] : $row['topic_id'];
        echo "<p class='searchSubject'>\n<a href='frm_view_topic.php?t=" . $topicid . "#post" . $row['id'] . "'>" . $row['subject'] . "</a>\n";
        echo "</p>\n";
        echo "<p class='searchBody'>\n";
        echo htmlspecialchars(trimBody($row['body']));
        if ($access_lvl > 1) {
            echo "<br /><br />relevance: " . $row['score'];
        }
        echo "\n</p>\n";
        echo "</td>\n</tr>\n\n";
    }
}
echo "</table>";
require_once 'ft.inc.php';