Файл: element_function/element_function_town.php
Строк: 69
<?php
function peplace_text_journal($text, $online) {
if (preg_match_all('/[user](.*?)[/user]/is', $text, $out, PREG_PATTERN_ORDER)) {
$count = count($out[1]);
if ($count > 0) {
foreach ($out[1] as $key => $v) {
$cache_user = cache_user($v);
$text = str_replace($out[0][$key], ' '.ikonka_user($cache_user['lost_race'], ((!empty($online[$v])) ? 'online' : 'offline')).' <a class="white" href="/user?id='.$v.'">'.$cache_user['lost_login'].'</a> ', $text);
}
} return $text;
} else return $text;
}
function cache_town_level($level) {
$cache_town_level = readcache('element_cache_town_level'.$level);
if (empty($cache_town_level)) {
$query = mysql_fetch_array(mysql_query("SELECT `lost_expoint` FROM `element_town_level` WHERE `lost_level` = '$level' LIMIT 1"));
$cache_town_level = $query['lost_expoint'];
}
return $cache_town_level;
}
function town_up_level($town_id, $town_level, $town_exp) {
$nex_exp = cache_town_level($town_level + 1);
$return = 0;
if ($town_exp >= $nex_exp) {
$return = 1;
$town_level = $town_level + 1;
$journal = '<span class="admin">Город получил '.$town_level.' уровень</span>';
mysql_query("INSERT INTO `element_town_journal` SET `lost_town` = '$town_id',
`lost_value` = '$journal',
`lost_time` = '".time()."'");
$nex_exp = cache_town_level($town_level + 1);
return array($return, $town_level, $nex_exp);
} else return array($return, $town_level, $nex_exp);
}
?>