Ejemplo n.º 1
0
function post_get($db, $xtopic, $xbegin)
{
    if (is_numeric($xtopic) && is_numeric($xbegin)) {
        $limit = 20;
        $query = $db->prepare("SELECT topic_title, topic_text, topic_replies, topic_by, user_name, permissions, sticky, locked FROM topics LEFT JOIN users ON topic_by = user_id WHERE topic_id = ?");
        $query->execute(array($xtopic));
        if ($query->rowCount() < 1) {
            echo '<div id="topic_title" name=0 topic_replies=0 begin=0 end=0 limit=0>Unknown Topic</div>';
            die;
        }
        $topic = $query->fetch(PDO::FETCH_ASSOC);
        if ($xbegin == 0) {
            $begin = $topic['topic_replies'] - $limit;
        } else {
            $begin = $xbegin - 1;
        }
        if ($begin > $topic['topic_replies'] - 1) {
            $begin = $topic['topic_replies'] - 1;
        }
        if ($begin < 0) {
            $begin = 0;
        }
        $query = $db->prepare(" SELECT p.post_text, p.post_id, p.post_by, u.user_name, u.user_id, u.permissions FROM posts AS p INNER JOIN users AS u ON p.post_by = u.user_id WHERE post_topic = ? ORDER BY post_date ASC LIMIT {$begin}, {$limit}");
        $query->execute(array($xtopic));
        $end = $query->rowCount() + $begin - 1;
        echo '<div id="topic_title" name=' . $xtopic . ' topic_replies=' . $topic['topic_replies'] . ' begin=' . ($begin + 1) . ' end=' . ($end + 1) . ' limit=' . $limit . '>';
        displaytopiclocked($topic['topic_title'], $topic['locked']);
        echo '</div>';
        echo '<div id="topic_text">' . "<span class='username' style='font-weight: bold;'>";
        theusername($topic['user_name'], $topic['permissions']);
        echo ":</span> " . $topic['topic_text'] . '<div class="postbuttons">';
        if (isset($_SESSION['permissions']) && $_SESSION['permissions'] == 1) {
            echo '<div class="delete topicdelete hover" title="delete">⨯</div>';
        }
        echo '</div></div>';
        echo "<!-- this is just so the radio buttons can change, it isn't actually inputed -->";
        echo "<input type='hidden' name='issticky' id='isstickyhiddenfield' value='" . $topic['sticky'] . "'>";
        echo "<input type='hidden' name='islocked' id='islockedyhiddenfield' value='" . $topic['locked'] . "'>";
        if ($topic['locked'] == '1') {
            $isitlockeddisplaymessage = true;
        } else {
            $isitlockeddisplaymessage = false;
        }
        $i = $begin;
        while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
            echo '<div class="post" name="' . $row['post_id'] . '">' . '<span class="tcore">' . ($i + 1) . "</span>";
            if ($i == $begin && $i != 0) {
                echo '<span class="tcore tup hover">▲</span>';
            }
            if ($i == $end && $i != $topic['topic_replies'] - 1) {
                echo '<span class="tcore tdown hover">▼</span>';
            }
            echo "<span class='username' style='font-weight: bold;'>";
            theusername($row['user_name'], $row['permissions']);
            echo ":</span> ";
            echo $row['post_text'] . '<div class="postbuttons">';
            if (isset($_SESSION['permissions']) && $_SESSION['permissions'] == 1) {
                echo '<div id="' . $row['post_id'] . '-' . ($i + 1) . '" class="delete postdelete hover" title="delete">⨯</div>';
            }
            echo '</div></div>';
            $i++;
        }
        if ($isitlockeddisplaymessage == true) {
            echo "<div id='lockedmessage'>This topic is locked: You can not post in it unless you are a moderator.</div>";
            echo '<script type="text/javascript">$(document).ready(function() { $("#post_text").hide(); $("#post_button").hide();});</script>';
        } else {
            echo '<script type="text/javascript">$(document).ready(function() { $("#post_text").show(); $("#post_button").show();});</script>';
        }
    } else {
        $limit = 16;
        $begin = is_numeric($xbegin) ? $xbegin - 1 : 0;
        $begin = max($begin, 0);
        $query = $db->query("SELECT topic_title, topic_replies, user_name, topic_id, sticky, locked FROM topics LEFT JOIN users ON topic_by = user_id ORDER BY sticky DESC, topic_score DESC LIMIT {$begin}, {$limit}");
        $cnt = $query->rowCount();
        if ($cnt < 1) {
            echo '<div id="left_title" begin=0 end=0 limit=0>Topics</div>';
            echo '<div class="topic"><p>None at the moment.</p></div>';
            die;
        }
        $end = $begin + $cnt - 1;
        echo '<div id="left_title" begin=' . ($begin + 1) . ' end=' . ($end + 1) . ' limit=' . $limit . '>Topics</div>';
        $i = $begin;
        $first_topic = 0;
        while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
            if ($i == $begin) {
                $first_topic = $row['topic_id'];
            }
            echo '<div class="topic' . ($i == $end ? ' last' : '') . '" name="' . $row['topic_id'] . '">' . '<span class="tcore trep"' . ($row['topic_replies'] <= 0 ? ' style="display:none"' : '') . '>' . $row['topic_replies'] . '</span>' . '<span class="stuck">' . "</span>";
            if ($i == $begin && $i != 0) {
                echo '<span class="tcore tup hover">▲</span>';
            }
            if ($i == $end && $cnt == $limit) {
                echo '<span class="tcore tdown hover">▼</span>';
            }
            echo '<p>';
            displaytopiclocked($row['topic_title'], $row['locked']);
            echo ($row['sticky'] == 1 ? ' <i class="icon-pushpin"></i>' : '') . '</p></div>';
            $i++;
        }
        return $first_topic;
    }
}
Ejemplo n.º 2
0
} else {
    require_once 'header.php';
}
//die();
?>
<div id="left_container">
  <div id="left" class="box wall">
    <div class="button" id="refresh_button" style="float:right; margin-top:14px; margin-right:-1px"><i class="icon-refresh"></i>&nbsp;Refresh</div>
    <div class="button" id="prepare_post_button" style="float:right; margin-top:14px; margin-right:16px"><i class="icon-pencil"></i>&nbsp;Create</div>
    <div id="nav">
    </div>
    <div id="user_panel" style="margin-top:12px;margin-bottom:8px">
    <?php 
if (isset($_SESSION['user_name']) && isset($_SESSION['permissions'])) {
    echo '<i class="icon-user"></i>&nbsp;';
    theusername($_SESSION['user_name'], $_SESSION['permissions']);
    echo '<a href = "account.php?a=logout" class="hover" style="margin-left:26px"><i class="icon-signout"></i>&nbsp;Sign out</a>';
} else {
    echo '<a href = "account.php?a=login" class="hover"><i class="icon-signin"></i>&nbsp;Sign in</a>';
    echo '<a href = "account.php?a=register" class="hover" style="margin-left: 18px"><i class="icon-trophy"></i>&nbsp;Sign up</a>';
}
?>
    </div>
  </div>
</div>
<div id="mid_container">
  <div id="mid" class="box wall">
    <div class="button" id="page_bottom_button" style="float:right;margin-top:10px;margin-right:-36px;padding:4px 10px;"><i class="icon-chevron-down"></i></div>
    <div id="text_container">
    </div>
    <div id="post_container">