本文整理汇总了PHP中base::rank_by方法的典型用法代码示例。如果您正苦于以下问题:PHP base::rank_by方法的具体用法?PHP base::rank_by怎么用?PHP base::rank_by使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类base
的用法示例。
在下文中一共展示了base::rank_by方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: strip_tags
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: list
// 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 = '{$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 = '{$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 = '{$username}'", __FILE__, __LINE__);
}
}
// Stat Buttons