File size: 813B
<?php
include_once getenv('DOCUMENT_ROOT') . '/sys/inc/ajaxRequest.php';
$array = array();
if (isset($_POST['id']) && is_numeric($_POST['id'])) {
$q = mysql_query("SELECT * FROM `smile` WHERE `dir` = '" . (int)$_POST['id'] . "' ORDER BY `id` ASC");
while ($post = mysql_fetch_array($q)) {
$array [] = array(
'file' => $post['id'],
'smile' => stripcslashes(htmlspecialchars($post['smile']))
);
}
} else {
$q = mysql_query("SELECT sd.* FROM `smile_dir` as sd
INNER JOIN `smile` AS s ON sd.id = s.dir
GROUP BY s.dir
ORDER BY sd.id ASC");
while ($post = mysql_fetch_assoc($q)) {
$array [] = array(
'id' => $post['id'],
'smile' => stripcslashes(htmlspecialchars($post['name']))
);
}
}
exit(json_encode($array));