Файл: bk/trainers.php
Строк: 47
<?php
$setMsg = '';
$sesTime = isset($_SESSION['bot_trainers_health']) ? $_SESSION['bot_trainers_health'] : 0;
if (100 > $user['bk_health'] && time() > $sesTime) {
$user['bk_health'] = $user['bk_health'] + 5;
if (100 < $user['bk_health']) $user['bk_health'] = 100;
mysql_query("UPDATE users SET bk_health = '$user[bk_health]' WHERE id = '$user[id]' LIMIT 1");
$_SESSION['bot_trainers_health'] = time() + 10;
}
if (isset($_SESSION['bot_trainers_time']) && $_SESSION['bot_trainers_time'] < time()) {
$value = unserialize($_SESSION['bot_trainers_value']);
$user[$value[0]] += $value[1];
if ($user[$value[0]] > 100) $user[$value[0]] = 100;
mysql_query("UPDATE users SET ".$value[0]." = '".$user[$value[0]]."' WHERE id = '$user[id]' LIMIT 1");
$setMsg = $user['user'] . ', ' . $value[2] . "n" . $value[3];
unset($_SESSION['bot_trainers_time']);
unset($_SESSION['bot_trainers_value']);
}
$stop = false;
if (preg_match("#!(.+?)(s|$)#i", $msg, $arr)) {
$data = file_get_contents('../upload/bk/trainers_force.dat');
if (preg_match('/'.$arr[1].'|::|.*?n/is', $data, $force_preg)) {
$field = 'bk_force';
$field_name = 'Сила';
$stop = true;
}
$data = file_get_contents('../upload/bk/trainers_endurance.dat');
if (!$stop && preg_match('/'.$arr[1].'|::|.*?n/is', $data, $force_preg)) {
$field = 'bk_endurance';
$field_name = 'Выносливость ';
$stop = true;
}
$data = file_get_contents('../upload/bk/trainers_adroitness.dat');
if (!$stop && preg_match('/'.$arr[1].'|::|.*?n/is', $data, $force_preg)) {
$field = 'bk_adroitness';
$field_name = 'Ловкость ';
$stop = true;
}
$data = file_get_contents('../upload/bk/trainers_accuracy.dat');
if (!$stop && preg_match('/'.$arr[1].'|::|.*?n/is', $data, $force_preg)) {
$field = 'bk_accuracy';
$field_name = 'Меткость ';
$stop = true;
}
if (isset($force_preg[0])) {
$ex = explode('|::|', $force_preg[0]);
if (count($ex) == 6) {
if ($user['balls'] > $ex[2]) {
$ex2 = explode('#', $ex[5]);
$_SESSION['bot_trainers_value'] = serialize(array(
$field,
$ex[1],
$ex2[array_rand($ex2)],
$field_name . ' увеличена на ' . $ex[1] . '%',
));
$_SESSION['bot_trainers_time'] = time() + $ex[3];
$ex2 = explode('#', $ex[4]);
$setMsg = $user['user'] . ', ' . $ex2[array_rand($ex2)];
mysql_query("UPDATE users SET balls = (balls-".$ex[2].") WHERE id = '$user[id]' LIMIT 1");
} else $setMsg = 'Недостаточно бубликов!';
}
}
}
if ($setMsg != '') {
$ids = mt_rand(100000, 999999);
mysql_query("INSERT INTO message SET
id = '$ids',
user = 'Рефери',
who = '0',
time = '" . (time() + 1) . "',
msg = '" . mysql_real_escape_string($setMsg) . "',
room = '$rm'");
}
?>