<?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->getRecentTheme(@$_GET['limit']=='none' ? NULL : 10));
} else {
	$n = '%'.str_replace('%', '\\%', $n).'%';
	echo json_encode($post->getRecentTheme(
		@$_GET['limit']=='none' ? NULL : 10,
		'`name` like ? or key1 like ? or key2 like ? or key3 like ?',
		array($n,$n,$n,$n)
	));
}
?>