Example #1
0
<?php

//Individual post template
$uid = isset($_SESSION['uid']) ? $_SESSION['uid'] : 0;
if (in_array($pid, $pids)) {
    print view_post($pid, $uid, 1);
} else {
    print view_post($pid, $uid, 1);
}
?>
<script>
setInterval(function(){
	$("#feeds").load("triggers/feeds_update.php",{feeds_type:"post"});
},1000*60*5);
</script>
Example #2
0
function search_question($query, $cid, $count, $page = 1)
{
    //Search questions by post title and post body
    $output = '';
    $uid = isset($_SESSION['uid']) ? $_SESSION['uid'] : 0;
    $posts = array();
    if (isset($_SESSION['rid']) && $_SESSION['rid'] != 2) {
        $result = mysql_query("SELECT * FROM " . PREFIX . "POST WHERE (Post_Title LIKE '%" . $query . "%' OR Post_Question LIKE '%" . $query . "%' OR Post_Answer LIKE '%" . $query . "%' OR Post_URL LIKE '%" . $query . "%')");
    } elseif (!isset($_SESSION['rid']) || $_SESSION['rid'] == 2) {
        $result = mysql_query("SELECT * FROM " . PREFIX . "POST WHERE Post_Current=1 AND (Post_Title LIKE '%" . $query . "%' OR Post_Question LIKE '%" . $query . "%' OR Post_Answer LIKE '%" . $query . "%' OR Post_URL LIKE '%" . $query . "%')");
    }
    if ($result) {
        while ($row = mysql_fetch_assoc($result)) {
            $posts[] = $row;
        }
    }
    if ($cid != 0) {
        $posts = array_filter($posts, array(new Filter($cid), 'filter_cid'));
    }
    usort($posts, 'sort_post_date_descend');
    $pagination = new pagination($posts, $page, $count, 5);
    $pagination->setShowFirstAndLast(true);
    $pagination->setMainSeperator('');
    $posts = $pagination->getResults();
    $output .= '<div class="paging">' . $pagination->getLinks() . '</div>';
    $output .= '<div class="posts">';
    for ($i = 0; $i < count($posts); $i++) {
        if (isset($posts[$i])) {
            $pid = $posts[$i]['Post_ID'];
            $output .= view_post($pid, $uid);
            $output .= $i != count($posts) - 1 ? '<hr>' : '';
        }
    }
    $output .= '</div>';
    $output .= '<div class="paging">' . $pagination->getLinks() . '</div>';
    $output .= '<script>
				function turnPage(page) {
					$("#feeds").load("triggers/paging_search.php",{count:' . $count . ',cid:' . $cid . ',page:page,keyword:"' . $query . '"});
				}
				</script>';
    if (count($posts) == 0) {
        $output .= '<h3>There is no results for this search criteria.</h3>';
    }
    return $output;
}