<?php
include '../env.php';
require_once(LIB.'common.inc.php');
require_once(LIB.'Post.class.php');
header('Access-Control-Allow-Origin: *');
$post = new Post();
$n = @$_GET['name'];
if (empty($n)) {
	echo json_encode($post->getRecentUrl(@$_GET['limit']=='none' ? NULL : 3));
} else {
	$n = '%'.str_replace('%', '\\%', $n).'%';
	echo json_encode($post->getRecentUrl(
		@$_GET['limit']=='none' ? NULL : 3,
		'title like ? or url like ?',
		array($n,$n,$n,$n)
	));
}
?>