示例#1
0
if (isset($FORM['cat']) && $FORM['cat']) {
    $TMPL['category'] = strip_tags($FORM['cat']);
    $category_escaped = $DB->escape($FORM['cat']);
    $category_sql = "AND category = '{$category_escaped}'";
    $category_url = "/index.php?cat={$TMPL['category']}";
} else {
    $TMPL['category'] = $LNG['main_all'];
    $category_sql = '';
    $category_url = '';
}
$TMPL['category'] = htmlspecialchars($TMPL['category']);
$CONF['list_url'] = htmlspecialchars($CONF['list_url']);
$CONF['list_name'] = htmlspecialchars($CONF['list_name']);
// Make ORDER BY clause
require_once "{$CONF['path']}/sources/misc/classes.php";
$order_by = base::rank_by() . " DESC";
header('Content-Type: application/xml');
echo "<?xml version=\"1.0\" encoding=\"{$LNG['charset']}\"?>";
// Get the category, default to no category
if (isset($FORM['cat']) && $FORM['cat']) {
    $TMPL['category'] = strip_tags($FORM['cat']);
    $category_escaped = $DB->escape($FORM['cat']);
    $category_sql = "AND category = '{$category_escaped}'";
}
$result = $DB->select_limit("SELECT *\n                             FROM {$CONF['sql_prefix']}_sites sites, {$CONF['sql_prefix']}_stats stats\n                             WHERE sites.username = stats.username AND active = 1 {$category_sql}\n                             ORDER BY {$order_by}\n                            ", 10, 0, __FILE__, __LINE__);
?>

<rss version="2.0">
	<channel>
		<title><?php 
echo "{$CONF['list_name']} - {$TMPL['category']}";
示例#2
0
// What button to display?
$rank_on_button = 0;
if ($CONF['ranks_on_buttons']) {
    // See if rank is freshly cached.  If so, use cached value.  If not, calculate rank.
    list($rank_cache, $rank_cache_time) = $DB->fetch("SELECT rank_cache, rank_cache_time FROM {$CONF['sql_prefix']}_stats WHERE username = '******'", __FILE__, __LINE__);
    $current_time = time();
    if ($current_time - 1800 < $rank_cache_time) {
        // Cache every 30 minutes.  1800 is the number of seconds to cache.  Change it if you want.
        if ($rank_cache > 0 && $rank_cache <= $CONF['button_num']) {
            $rank = $rank_cache;
            $location = "{$CONF['button_dir']}/{$rank}.{$CONF['button_ext']}";
            $rank_on_button = 1;
        }
    } else {
        require_once "{$CONF['path']}/sources/misc/classes.php";
        $rank_by = base::rank_by();
        list($hits) = $DB->fetch("SELECT {$rank_by} FROM {$CONF['sql_prefix']}_sites sites, {$CONF['sql_prefix']}_stats stats WHERE sites.username = stats.username AND active = 1 AND sites.username = '******'", __FILE__, __LINE__);
        if ($hits) {
            list($rank) = $DB->fetch("SELECT count(*) FROM {$CONF['sql_prefix']}_sites sites, {$CONF['sql_prefix']}_stats stats WHERE sites.username = stats.username AND active = 1 AND ({$rank_by}) >= {$hits}", __FILE__, __LINE__);
            $new_rank_cache = 0;
            if ($rank <= $CONF['button_num']) {
                $location = "{$CONF['button_dir']}/{$rank}.{$CONF['button_ext']}";
                $rank_on_button = 1;
                $new_rank_cache = $rank;
            }
        }
        if ($new_rank_cache) {
            $DB->query("UPDATE {$CONF['sql_prefix']}_stats SET rank_cache = {$new_rank_cache}, rank_cache_time = {$current_time} WHERE username = '******'", __FILE__, __LINE__);
        }
    }
    // Stat Buttons