File size: 2.65Kb
<?php
function update_rating_user($rating, $town) {
if (!empty($rating)) {
$cache_rating = readcache('element_rating'.$rating);
if (!is_array($cache_rating)) $cache_rating = array();
if (empty($cache_rating)) {
if ($town == 0) {
$query = mysql_query("SELECT `lost_id` FROM `element_user` ORDER BY `lost_params_$rating` DESC LIMIT 1000");
$i = 1;
while ($myrrow = mysql_fetch_array($query)) {
$cache_rating[$i] = $myrrow['lost_id'];
$i++;
}
writecache('element_rating'.$rating, $cache_rating);
return $cache_rating;
} else {
$query = mysql_query("SELECT `lost_id` FROM `element_town` ORDER BY `lost_exp` DESC");
$i = 1;
while ($myrrow = mysql_fetch_array($query)) {
$cache_rating[$i] = $myrrow['lost_id'];
$i++;
}
if ($i > 1) writecache('element_rating'.$rating, $cache_rating);
return $cache_rating;
}
} else return $cache_rating;
} else {
// Сила
$cache_rating = array();
$query = mysql_query("SELECT `lost_id` FROM `element_user` ORDER BY `lost_params_strlen` DESC LIMIT 1000");
$i = 1;
while ($myrrow = mysql_fetch_array($query)) {
$cache_rating[$i] = $myrrow['lost_id'];
$i++;
}
writecache('element_ratingstrlen', $cache_rating);
// Сила стоп
// Здоровье
$cache_rating = array();
$query = mysql_query("SELECT `lost_id` FROM `element_user` ORDER BY `lost_params_heatpoints` DESC LIMIT 1000");
$i = 1;
while ($myrrow = mysql_fetch_array($query)) {
$cache_rating[$i] = $myrrow['lost_id'];
$i++;
}
writecache('element_ratingheatpoints', $cache_rating);
// Здоровье стоп
// Защита
$cache_rating = array();
$query = mysql_query("SELECT `lost_id` FROM `element_user` ORDER BY `lost_params_protection` DESC LIMIT 1000");
$i = 1;
while ($myrrow = mysql_fetch_array($query)) {
$cache_rating[$i] = $myrrow['lost_id'];
$i++;
}
writecache('element_ratingprotection', $cache_rating);
// Защита стоп
// Сумма
$cache_rating = array();
$query = mysql_query("SELECT `lost_id` FROM `element_user` ORDER BY `lost_params_summa` DESC LIMIT 1000");
$i = 1;
while ($myrrow = mysql_fetch_array($query)) {
$cache_rating[$i] = $myrrow['lost_id'];
$i++;
}
writecache('element_ratingsumma', $cache_rating);
// Сумма стоп
// Города
$cache_rating = array();
$query = mysql_query("SELECT `lost_id` FROM `element_town` ORDER BY `lost_exp` DESC");
$i = 1;
while ($myrrow = mysql_fetch_array($query)) {
$cache_rating[$i] = $myrrow['lost_id'];
$i++;
}
if ($i > 1) writecache('element_ratingtown', $cache_rating);
}
}
?>