freepost codebase git repo

[[ 🗃 ^Avlxv freepost ]] :: [📥 Inbox] [📤 Outbox] [🐤 Followers] [🤝 Collaborators] [🛠 Commits]

Clone

HTTPS: git clone https://vervis.peers.community/repos/Avlxv

SSH: git clone USERNAME@vervis.peers.community:Avlxv

Branches

Tags

master ::

index.php

<?php

require_once 'session.php';
require_once 'database.php';
require_once 'date.php';
require_once 'twig.php';

// Open database connection
$db = new Database ();
$db->connect ();

// Pagination. What page are we in?
if (isset ($_GET['page']))
{
    $page = intval ($_GET['page']);
    
    if ($page < 0)
        $page = 0;
} else {
    $page = 0;
}

// Retrieve list of posts
if (isset ($_GET['new']))
    $posts = $db->get_new_posts ($page);
else
    $posts = $db->get_hot_posts ($page);

// Retrieve a list of user votes for the posts
$IDs = array ();

foreach ($posts as $post)
    $IDs[] = $post['id'];

$votes = $db->get_posts_votes (implode (',', $IDs), Session::get_userid ());

// Render template
echo $twig->render (
    'index.twig',
    array(
        'posts' => $posts,
        'votes' => $votes,
        'page'  => $page));
[See repo JSON]