예제 #1
0
}
$sql = select($post_type, array("id", "name", "date", "views", "body", "writer"), array("id", $post_id));
while ($rows = mysqli_fetch_array($sql)) {
    $post_id = $rows['id'];
    $post_name = $rows['name'];
    if (isset($_SESSION['userlogin'])) {
        $post_writer = $_SESSION['username'];
    } else {
        $post_writer = $rows['writer'];
    }
    $created = $rows['date'];
    $post_body = nl2br($rows['body']);
    $post_views = $rows['views'] + 1;
}
//add view
add_views($post_type, $post_id);
//O_O
//Add Comments
if (isset($_POST['addreply'])) {
    if (!empty($_POST['addreply_name_edit']) && !empty($_POST['addreply_body_edit'])) {
        $addreply_name = $_POST['addreply_name_edit'];
        $addreply_body = $_POST['addreply_body_edit'];
        if (isset($_SESSION['userlogin'])) {
            $addreply_writer = $_SESSION['username'];
        } else {
            $addreply_writer = $_POST['addreply_writer_edit'];
        }
        $date = date('Y-m-d H:i:s');
        $comments_type = "comments_{$post_type}";
        $sql = insert($comments_type, array(array("name", "body", "post_id", "writer", "date"), array($addreply_name, $addreply_body, $post_id, $addreply_writer, $date)));
    }
예제 #2
0
파일: topics.php 프로젝트: exts/nab145
function RUN_Topic()
{
    global $logged, $permissions;
    if (is_numeric($_GET['id']) and !empty($_GET['id'])) {
        $id = intval(htmlspecialchars($_GET['id']));
    } else {
        pageerror("Topic Error", "", "Sorry, but there wasn't a topic id present.");
    }
    if (!getFP(topic_parent_($id), 1)) {
        pageerror("Permission Error", "", "Sorry, but you don't have permissions viewing this topic.");
    }
    //do some post stuff
    //total replies pagination limit
    $ppt = mysql_query("SELECT `postpertopic` FROM `boardstatus` LIMIT 1");
    $p_p_t = mysql_fetch_array($ppt);
    $total_limit = $p_p_t['postpertopic'];
    topic_pagination($id, $total_limit);
    $main = mysql_query("SELECT * FROM `topics` WHERE `id` = '" . $id . "' ");
    $tmain = mysql_fetch_array($main);
    $umain = mysql_query("SELECT * FROM `users` WHERE `username` = '" . $tmain['username'] . "'");
    $fuser = mysql_fetch_array($umain);
    $isSticked = $tmain['sticky'] == 1 ? "<a href='mode.php?type=sticktopic&tid=" . $id . "'>Sticky</a>" : "<a href='mode.php?type=unsticktopic&tid=" . $id . "'>Un-Sticky</a>";
    $isLocked = $tmain['closed'] == 1 ? "<a href='mode.php?type=closetopic&tid=" . $id . "'>Lock</a>" : "<a href='mode.php?type=opentopic&tid=" . $id . "'>Un-Lock</a>";
    //check if user has permissions
    if ($permissions['admin'] == 't' || $permissions['e_topic'] == 't') {
        $modet = "<a href='mode.php?type=edit&post=topic&id=" . $id . "'>Edit</a> | <a href='mode.php?type=move&post=topic&id=" . $id . "'>Move Topic</a> | " . $isSticked . " | " . $isLocked;
    } elseif ($logged['username'] == $tmain['username'] && $permissions['e_topic'] == 't') {
        $modet = "<a href='mode.php?type=edit&post=topic&id=" . $id . "'>Edit</a>";
    } else {
        $modet = "";
    }
    echo "<br />" . run_buttons($id);
    $Temp = new Template();
    $Temp->dir = $logged['dskin'];
    $Temp->file = "topic_title.tpl";
    $Temp->tp();
    $Temp->tr(array('TITLE' => $tmain['title']));
    echo $Temp->html;
    //if($_GET['p'] == 1 || !isset($_GET['p']) )
    //	{
    echo '
						<tr>
							<td colspan="2" class="small_title"><span style="float:left;"><b>Posted On:</b> ' . timezone_stamp($tmain['timestamp'], $logged['timezone']) . '</span><span style="float:right" class="small_title_link">' . $modet . '</span></td>
						</tr>
				';
    //}
    if (!isset($_GET['p']) || empty($_GET['p']) || $_GET['p'] == 0) {
        $page = 1;
    } else {
        if (!is_numeric($_GET['p'])) {
            pageerror("Page Error", "", "Didn't specify a correct page id.");
        } else {
            $page = intval(mysql_real_escape_string($_GET['p']));
        }
    }
    $limit_start = $page * $total_limit - $total_limit;
    //get replies
    $replies = mysql_query("SELECT * FROM `replies` WHERE `tid` = '" . $id . "' ORDER BY `id` LIMIT {$limit_start},{$total_limit}") or die(mysql_error(__FILE__, __LINE__));
    $has_replys = mysql_num_rows($replies);
    if ($has_replys != 0) {
        //check to see if there are any replies :D
        while ($replys = mysql_fetch_array($replies)) {
            //check if user has permissions
            if ($permissions['admin'] == 't' || $permissions['d_post'] == 't') {
                $modep = "<a href='mode.php?type=edit&post=reply&id=" . $replys['id'] . "&tid=" . $id . "'>Edit</a> | <a href='mode.php?type=delete&post=reply&id=" . $replys['id'] . "&tid=" . $id . "'>Delete</a>";
            } elseif ($logged['username'] == $replys['username']) {
                $modep = "<a href='mode.php?type=edit&post=reply&id=" . $replys['id'] . "&tid=" . $id . "'>Edit</a>";
            } else {
                $modep = "";
            }
            $usez = mysql_query("SELECT * FROM `users` WHERE `username` = '" . $replys['username'] . "'");
            $useri = mysql_fetch_array($usez);
            //show replies
            $Temp = new Template();
            $Temp->dir = $logged['dskin'];
            $Temp->file = "topic_post.tpl";
            $Temp->tp();
            $Temp->tr(array('OPTIONS' => $modep, 'POSTER' => $replys['username'], 'AVY' => !empty($useri['avatar']) ? '<img width="100" height="100" src="' . $useri['avatar'] . '" alt="" /><br />' : '', 'DATE' => timezone_stamp($replys['date'], $logged['timezone']), 'GROUP' => group($useri['level']), 'UID' => $useri['id'], 'UPOST' => $useri['post'], 'POST' => nl2br(bbcode_format($replys['post'])) . "<br />__________________<br />" . ($useri['signature'] == '' ? '&nbsp;' : nl2br(bbcode_format($useri['signature'])))));
            echo $Temp->html;
        }
    } else {
        echo "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width='100%' class='rows' align='center'><em>There isn't any posts in this topic</em></td>\n\t\t\t\t\t</tr>\n\t\t\t\t";
    }
    echo ' </table> ' . run_buttons($id) . '<br />';
    topic_pagination($id, $total_limit);
    add_views($id);
}