Файл: vobljatrol/bk/trainers.php
Строк: 46
<?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'] . "'");
$_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'] . "'");
$setMsg = '<b>' . $user['user'] . '</b>, '.$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('data/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('data/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('data/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('data/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['rur'] > $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 = '<b>' . $user['user'] . '</b>, '.$ex2[array_rand($ex2)];
mysql_query("UPDATE users SET rur = (rur-".$ex[2].") WHERE id = '" . $user['id'] . "'");
} else $setMsg = 'У тебя недостаточно денег!';
}
}
}
if ($setMsg != '') {
mysql_query("INSERT INTO message SET
user = 'Рефери',
user_id = '0',
time = '".(time()+1)."',
msg = '".mysql_real_escape_string($setMsg)."',
rm = '6',
emo = '0',
bb = '0',
color = '0'
");
}
?>