<?php
include '../env.php';
require_once(LIB.'common.inc.php');
if (can_action('view')) {
	try_update_session();
	require_once(LIB.'Post.class.php');
	$post = new Post();
	if (empty($_GET['format'])) {
		echo json_encode($post->get($_GET));
	} else {
		require_once(LIB.'Formatter.class.php');
		$formatter = new Formatter();
		$method = $_GET['format'];
		echo $formatter->$method($post->get($_GET));
	}
}
?>