$_GET['days'] = 10;
}
if (!$smarty->is_cached($template, $cacheid)) {
    $db = NewADOConnection($GLOBALS['DSN']);
    if (empty($db)) {
        die('Database connection failed');
    }
    if ($u) {
        $where = "where submitted > date_sub(now(),interval {$_GET['days']} day) and user_id = {$u}";
        $having = isset($_GET['full']) ? '' : 'having cnt>5';
        $table = 'gridimage';
        $smarty->assign('varname', 'catListUser');
        $arr = $db->getCol("select imageclass,count(*) as cnt from {$table} {$where} group by imageclass {$having}");
    } else {
        $where = isset($_GET['full']) ? '' : 'where c>5';
        $table = 'category_stat';
        $smarty->assign('varname', 'catList');
        $arr = $db->getCol("select imageclass,c as cnt from {$table} {$where}");
    }
    $smarty->assign_by_ref('classes', $arr);
}
if ($u) {
    customExpiresHeader(300, false);
} else {
    customExpiresHeader(3600 * 3, true);
}
header("Content-type: text/javascript");
customGZipHandlerStart();
//always turn off debugging, it will break the js
$smarty->debugging = false;
$smarty->display($template, $cacheid);
 function beginResponse($skip = null)
 {
     customGZipHandlerStart();
     if ($this->output == 'json') {
         if (!empty($this->callback)) {
             customExpiresHeader(3600 * 24, true, true);
             echo "{$this->callback}(";
         } else {
             customExpiresHeader(360, true, true);
         }
     } else {
         customExpiresHeader(360, true, true);
         header("Content-Type:text/xml");
         echo '<?xml version="1.0" encoding="UTF-8"?>';
         if (empty($skip)) {
             echo '<geograph>';
         }
     }
 }