diff --git a/admin/edit_user.php b/admin/edit_user.php index b9720fa..e36414e 100644 --- a/admin/edit_user.php +++ b/admin/edit_user.php @@ -25,7 +25,7 @@ if ($player) { unset($row); } if ($undress_char) { - undressall($_SESSION['player_id']); + \Battles\DressedItems::undressAllItems($_SESSION['player_id']); } if ($end) { unset($_SESSION['player_id']); diff --git a/classes/Battles/DressedItems.php b/classes/Battles/DressedItems.php index b8a8644..692d0b1 100644 --- a/classes/Battles/DressedItems.php +++ b/classes/Battles/DressedItems.php @@ -98,4 +98,8 @@ SQL; self::$db->execute('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot = ? AND owner_id = ?', [$slot_id, $this->USERID]); } } + public static function undressAllItems($user_id) + { + return self::$db->execute('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot BETWEEN 1 AND 12 AND owner_id = ?', $user_id); + } } \ No newline at end of file diff --git a/cronjobs/cron_tower.php b/cronjobs/cron_tower.php index bbf4a34..02d3c37 100644 --- a/cronjobs/cron_tower.php +++ b/cronjobs/cron_tower.php @@ -17,7 +17,7 @@ if (!$tr && $turnirstart[0] <= time() && $dd[0] >= 2) { while ($row = mysql_fetch_array($data)) { $pers = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "' . $row[0] . '" LIMIT 1')); - undressall($pers['id']); + \Battles\DressedItems::undressAllItems($pers['id']); ### mysql_query('UPDATE `inventory` SET `owner` = "' . ($pers['id'] + _BOTSEPARATOR_) . '" WHERE `owner` = "' . $pers['id'] . '"'); ### @@ -88,9 +88,9 @@ if (!$tr && $turnirstart[0] <= time() && $dd[0] >= 2) { } // Боты: Архивариус и два помощника. - undressall(233); - undressall(234); - undressall(235); + \Battles\DressedItems::undressAllItems(233); + \Battles\DressedItems::undressAllItems(234); + \Battles\DressedItems::undressAllItems(235); mysql_query("DELETE FROM `inventory` WHERE `owner` = 233"); mysql_query("DELETE FROM `inventory` WHERE `owner` = 234"); @@ -158,7 +158,7 @@ if ($tur_data['endtime'] < time() && $tur_data['id']) { $list = mysql_query("SELECT * FROM `users` WHERE `in_tower` = 1"); while ($u = mysql_fetch_array($list)) { - undressall($u['id']); + \Battles\DressedItems::undressAllItems($u['id']); $rep = mysql_query("SELECT * FROM `inventory` WHERE `owner` = '" . $u['id'] . "' AND `bs` = 1"); while ($r = mysql_fetch_array($rep)) { mysql_query("INSERT `deztow_items` (`iteam_id`, `name`, `img`, `room`) VALUES ('" . $r['prototype'] . "', '" . $r['name'] . "', '" . $r['img'] . "', '" . $u['room'] . "')"); diff --git a/functions.php b/functions.php index 8dbccff..6ae36aa 100644 --- a/functions.php +++ b/functions.php @@ -109,7 +109,7 @@ $var_map = [ function get_out($u) { $pers = db::c()->query('SELECT * FROM users WHERE id = ?i', $u)->fetch_assoc_array(); - undressall($pers['id']); + \Battles\DressedItems::undressAllItems($pers['id']); db::c()->query('UPDATE inventory SET owner = ?i WHERE owner = ?i', $pers['id'], $pers['id'] + _BOTSEPARATOR_); ### $row = db::c()->query('SELECT * FROM `effects` WHERE `owner` = ?i', $pers['id'] + _BOTSEPARATOR_); @@ -449,11 +449,6 @@ function addActions($time, $vars, $vls, $uid) return $ins; } -function undressall($user_id) -{ - db::c()->query('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot BETWEEN 1 AND 12 AND owner_id = ?i', $user_id); -} - #15 function ref_drop() { diff --git a/magic/attackk.php b/magic/attackk.php index d75171d..0624b9e 100644 --- a/magic/attackk.php +++ b/magic/attackk.php @@ -117,8 +117,8 @@ if ($user['battle'] > 0) { mysql_query("INSERT INTO `bots` (`name`,`prototype`,`battle`,`hp`) values ('Архивариус','83','','" . $jert['hp'] . "');"); $jert['id'] = mysql_insert_id(); } - undressall($jert['id']); - undressall($user['id']); + \Battles\DressedItems::undressAllItems($jert['id']); + \Battles\DressedItems::undressAllItems($user['id']); $teams = []; $teams[$user['id']][$jert['id']] = [0, 0, time()]; $teams[$jert['id']][$user['id']] = [0, 0, time()]; diff --git a/magic/attackk_close.php b/magic/attackk_close.php index 32c66cd..983e5d2 100644 --- a/magic/attackk_close.php +++ b/magic/attackk_close.php @@ -104,8 +104,8 @@ elseif (!$us['online']) { } if(rand(0,100)<80) - undressall($jert['id']); - undressall($user['id']); + \Battles\DressedItems::undressAllItems($jert['id']); + \Battles\DressedItems::undressAllItems($user['id']); $teams = array(); $teams[$user['id']][$jert['id']] = array(0,0,time()); $teams[$jert['id']][$user['id']] = array(0,0,time()); diff --git a/magic/attackk_open.php b/magic/attackk_open.php index 829370a..d5638fa 100644 --- a/magic/attackk_open.php +++ b/magic/attackk_open.php @@ -104,8 +104,8 @@ if ($user['battle'] > 0) { } if(rand(0,100)<80) - undressall($jert['id']); - undressall($user['id']); + \Battles\DressedItems::undressAllItems($jert['id']); + \Battles\DressedItems::undressAllItems($user['id']); $teams = array(); $teams[$user['id']][$jert['id']] = array(0,0,time()); $teams[$jert['id']][$user['id']] = array(0,0,time()); diff --git a/magic/down.php b/magic/down.php index edcc5e3..3b5b218 100644 --- a/magic/down.php +++ b/magic/down.php @@ -3,7 +3,7 @@ if ($user['battle'] > 0) { echo "Не в бою..."; } elseif (rand(1, 100) != 1) { - undressall($user['id']); + \Battles\DressedItems::undressAllItems($user['id']); $user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '{$_SESSION['uid']}' LIMIT 1;")); if (empty($_SESSION['uid'])) { header("Location: index.php"); diff --git a/main.php b/main.php index 04e240b..3da9ecf 100644 --- a/main.php +++ b/main.php @@ -74,7 +74,7 @@ if ($edit) { usemagic($use, $useTarget); } if ($undress) { - undressall($_SESSION['uid']); + \Battles\DressedItems::undressAllItems($_SESSION['uid']); } } diff --git a/towerin.php b/towerin.php index a358828..998619e 100644 --- a/towerin.php +++ b/towerin.php @@ -192,7 +192,7 @@ if ($rhar[$user->getRoom()][$_GET['path']] > 0 && $_GET['path'] < 5 && $_GET['pa $list = mysql_query("SELECT * FROM `users` WHERE `in_tower` = 1 AND `battle` = 0"); while ($u = mysql_fetch_array($list)) { if ($u['hp'] <= 0) { - undressall($u['id']); + \Battles\DressedItems::undressAllItems($u['id']); $rep = mysql_query("SELECT * FROM `inventory` WHERE `owner` = '" . $u['id'] . "' AND `bs` = 1"); while ($r = mysql_fetch_array($rep)) { mysql_query("INSERT `deztow_items` (`iteam_id`, `name`, `img`, `room`) VALUES ('" . $r['prototype'] . "', '" . $r['name'] . "', '" . $r['img'] . "', '" . $u['room'] . "')"); @@ -226,7 +226,7 @@ while ($u = mysql_fetch_array($list)) { if (($kol_pl + $ls) < 2 && ($tur_data['start_time'] + 60) <= time()) { $tur = mysql_fetch_array(mysql_query("SELECT * FROM `deztow_turnir` WHERE `active` = TRUE LIMIT 1")); - undressall($user['id']); + \Battles\DressedItems::undressAllItems($user['id']); $rep = mysql_query("SELECT * FROM `inventory` WHERE `owner` = '" . $user['id'] . "' AND `bs` = 1"); while ($r = mysql_fetch_array($rep)) { mysql_query("INSERT `deztow_items` (`iteam_id`, `name`, `img`, `room`) VALUES ('" . $r['prototype'] . "', '" . $r['name'] . "', '" . $r['img'] . "', '" . $user->getRoom() . "');"); diff --git a/towerstamp.php b/towerstamp.php index 1eac2cb..3eaf2f9 100644 --- a/towerstamp.php +++ b/towerstamp.php @@ -8,7 +8,7 @@ if ($user->getRoom() != 31) { if (isset($effect['id'])) { exit('Для распределения статов на Вас не дожно быть никаких эффектов'); } -undressall($user['id']); +\Battles\DressedItems::undressAllItems($user['id']); if ((int)$_GET['delsn'] > 0) { mysql_query("DELETE FROM `deztow_charstams` WHERE `id` = '" . (int)$_GET['delsn'] . "' AND `name` = '" . $_GET['ddname'] . "' AND `owner` = '" . (int)$user['id'] . "' LIMIT 1"); diff --git a/zayavka.php b/zayavka.php index 88bad11..73a8d50 100644 --- a/zayavka.php +++ b/zayavka.php @@ -421,11 +421,11 @@ class Zayavka if ($z['type'] == 4 || $z['type'] == 5) { foreach ($z['team1'] as $k => $v) { - undressall($v); + \Battles\DressedItems::undressAllItems($v); } foreach ($z['team2'] as $k => $v) { - undressall($v); + \Battles\DressedItems::undressAllItems($v); } }