本文整理匯總了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