Файл: html/system/dbc.php
Строк: 41
<?php
require_once $_SERVER['DOCUMENT_ROOT'].'/system/connect.php';
$mc = $mc;
health_rechange();
function health_rechange() {
global $mc;
global $user;
if (!empty($user)) {
$user['max_health'] = $user['health'];
//read dress
$result = $mc->query("SELECT * FROM `userbag` WHERE `id_user` = '" . $user['id'] . "' && `dress`='1' && `BattleFlag`='1' || `id_user` = '" . $user['id'] . "' AND `id_punct`>'9' && `BattleFlag`='1'");
if ($result->num_rows) {
//dress to arr all
$dressarr = $result->fetch_all(MYSQLI_ASSOC);
for ($i = 0; $i < count($dressarr); $i++) {
//read thing
$result1 = $mc->query("SELECT * FROM `shop` WHERE `id`='" . $dressarr[$i]['id_shop'] . "'");
if ($result1->num_rows) {
//thing to arr par
$infoshop = $result1->fetch_array(MYSQLI_ASSOC);
$user['max_health'] += $infoshop['health'];
}
}
}
//обрежем хп если его больше максимума
if ($user['temp_health'] > $user['max_health']) {
$user['temp_health'] = $user['max_health'];
}
//запись параметров в бд
$mc->query("UPDATE `users` SET "
. "`max_health`='" . $user['max_health'] . "',"
. "`temp_health`='" . $user['temp_health'] . "'"
. " WHERE `id`='" . $user['id'] . "'");
}
}
function get_user_stats() {
global $mc;
global $user;
if (!empty($user)) {
$arr = [];
//setzero
$arr['temp_health'] = $user['temp_health'];
$arr['max_health'] = $user['health'];
$arr['strength'] = $user['strength'];
$arr['toch'] = $user['toch'];
$arr['lov'] = $user['lov'];
$arr['kd'] = $user['kd'];
$arr['block'] = $user['block'];
$arr['bron'] = $user['bron'];
//read dress
$result = $mc->query("SELECT * FROM `userbag` WHERE `id_user` = '" . $user['id'] . "' && `dress`='1' && `BattleFlag`='1' || `id_user` = '" . $user['id'] . "' AND `id_punct`>'9' && `BattleFlag`='1'");
if ($result->num_rows) {
//dress to arr all
$dressarr = $result->fetch_all(MYSQLI_ASSOC);
for ($i = 0; $i < count($dressarr); $i++) {
//read thing
$result1 = $mc->query("SELECT * FROM `shop` WHERE `id`='" . $dressarr[$i]['id_shop'] . "'");
if ($result1->num_rows) {
//thing to arr par
$infoshop = $result1->fetch_array(MYSQLI_ASSOC);
$arr['max_health'] += $infoshop['health'];
$arr['strength'] += $infoshop['strength'];
$arr['toch'] += $infoshop['toch'];
$arr['lov'] += $infoshop['lov'];
$arr['kd'] += $infoshop['kd'];
$arr['block'] += $infoshop['block'];
$arr['bron'] += $infoshop['bron'];
}
}
}
return $arr;
}
}