Файл: ewar/cronjobs/league_update.php
Строк: 32
<?php
# 0 0 1 * * /usr/bin/wget -q -O /dev/null http://ewar.mobi/cronjobs/league_update.php
include("../includes/config.php");
$league_info = (isset($_GET['level']) && (int) $_GET['level'] > 1 && (int) $_GET['level'] <= 65) ? league((int) $_GET['level']) : false;
if($league_info != false) {
$my_league_cache = readcache($league_info['id'].'_league_cache');
if($my_league_cache == false) {
$query = mysql_query("SELECT `id` FROM `vartotojai` WHERE `level` >= '".$league_info['level_min']."' AND `level` <= '".$league_info['level_max']."' ORDER BY `str` + `vit` + `agi` + `def` DESC LIMIT 100");
$league_users = array();
$location = 50;
while($row = mysql_fetch_assoc($query)) {
#Users['user_id'] = array(vieta lygoje, likusių kovų skaičius, ar šiandien gavo atlygį, ar nenugalimas):
$league_users[$row['id']] = array($location, 5, 0, 0);
if($location < 100) $location ++;
}
writecache($league_info['id'].'_league_cache', $league_users);
}
}
else
{
#Visų lygų vietų numetimas:
for($i = 1; $i <= 6; $i ++) {
$league_cache = readcache($i.'_league_cache');
if($league_cache != false) {
foreach($league_cache as $key => $value) {
$location = $league_cache[$key][0] + rand(50, 70);
if($location > 100) {
$location = 100;
}
$league_cache[$key][0] = $location;
}
writecache($i.'_league_cache', $league_cache);
}
}
}
if (isset($_GET['k'])) {
header("Location: ../league.php");
}
?>