Перевод functions.php и основных направлений на класс User.
This commit is contained in:
parent
427149b90e
commit
8d8342d197
253
functions.php
253
functions.php
@ -11,24 +11,21 @@ require_once 'config.php';
|
|||||||
* Возвращает массив данных таблицы users.
|
* Возвращает массив данных таблицы users.
|
||||||
*/
|
*/
|
||||||
if (isset($_SESSION['uid'])) {
|
if (isset($_SESSION['uid'])) {
|
||||||
$user = (new users_row($_SESSION['uid']))->result();
|
//$user = (new users_row($_SESSION['uid']))->result();
|
||||||
$userr = new User($_SESSION['uid']);
|
$user = new User($_SESSION['uid']);
|
||||||
} else {
|
} else {
|
||||||
echo "Не могу проинициализировать игрока!";
|
echo "Не могу проинициализировать игрока!";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($user['id']) && $user['block'] == 1) {
|
if ($user->id && $user->block) {
|
||||||
die('user blocked!');
|
exit('user blocked!');
|
||||||
}
|
}
|
||||||
|
|
||||||
// ???
|
|
||||||
//define("HPADDICTIONEFFECT", 33);
|
|
||||||
|
|
||||||
$ip = filter_input(INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP);
|
$ip = filter_input(INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP);
|
||||||
|
|
||||||
if (isset($_GET['goto']) && isset($_GET['tStamp']) && isset($_GET['vcode']) && $_GET['vcode'] == md5(sha1($_GET['goto'] . $_GET['tStamp']))) {
|
if (isset($_GET['goto']) && isset($_GET['tStamp']) && isset($_GET['vcode']) && $_GET['vcode'] == md5(sha1($_GET['goto'] . $_GET['tStamp']))) {
|
||||||
db::c()->query('UPDATE `users`,`online` SET `users`.`room` = ?i, `online`.`room` = ?i WHERE `online`.`id` = `users`.`id` AND `online`.`id` = ?i', $_GET['goto'], $_GET['goto'], $_SESSION['uid']);
|
db::c()->query('UPDATE `users`,`online` SET `users`.`room` = ?i, `online`.`room` = ?i WHERE `online`.`id` = `users`.`id` AND `online`.`id` = ?i', $_GET['goto'], $_GET['goto'], $_SESSION['uid']);
|
||||||
$user['room'] = intval($_GET['goto']);
|
$user->room = intval($_GET['goto']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function createbot($bot, $login = "")
|
function createbot($bot, $login = "")
|
||||||
@ -91,7 +88,7 @@ function takeshopitem($item, $table = "shop", $present = '', $onlyonetrip = '',
|
|||||||
$flds = [];
|
$flds = [];
|
||||||
$goden = '';
|
$goden = '';
|
||||||
if (!$uid) {
|
if (!$uid) {
|
||||||
$uid = $user['id'];
|
$uid = $user->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = db::c()->query('SHOW FIELDS FROM ?f', $table);
|
$r = db::c()->query('SHOW FIELDS FROM ?f', $table);
|
||||||
@ -212,10 +209,10 @@ function GiveRep($id, $rep)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Генератор прогрессбара.
|
* Генератор прогрессбара.
|
||||||
* @param $current - Текущее значение.
|
* @param $current - Текущее значение.
|
||||||
* @param $maximum - Максимальное значение.
|
* @param $maximum - Максимальное значение.
|
||||||
* @param string $line_color - Цвет полоски прогрессбара.
|
* @param string $line_color - Цвет полоски прогрессбара.
|
||||||
* @param string $bg_color - Фон прогрессбара.
|
* @param string $bg_color - Фон прогрессбара.
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function showProgressBar($current, $maximum, $line_color = 'limegreen', $bg_color = 'silver')
|
function showProgressBar($current, $maximum, $line_color = 'limegreen', $bg_color = 'silver')
|
||||||
@ -243,19 +240,19 @@ function echoscroll($slot)
|
|||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
$all_magic = 0;
|
$all_magic = 0;
|
||||||
if ($user['battle']) {
|
if ($user->battle) {
|
||||||
$script = 'fbattle';
|
$script = 'fbattle';
|
||||||
$bat = db::c()->query('SELECT `magic` FROM `battle` WHERE `id` = ?i', $user['battle'])->fetch_assoc();
|
$bat = db::c()->query('SELECT `magic` FROM `battle` WHERE `id` = ?i', $user->battle)->fetch_assoc();
|
||||||
$all_magic = unserialize($bat['magic']);
|
$all_magic = unserialize($bat['magic']);
|
||||||
} else {
|
} else {
|
||||||
$script = 'main';
|
$script = 'main';
|
||||||
}
|
}
|
||||||
|
|
||||||
$dress = db::c()->query('SELECT `id`, `magic`, `name`, `img`, `duration`, `maxdur` FROM `inventory` WHERE `id` = ?i', $user[$slot])->fetch_assoc();
|
$dress = db::c()->query('SELECT `id`, `magic`, `name`, `img`, `duration`, `maxdur` FROM `inventory` WHERE `id` = ?i', $user->$slot)->fetch_assoc();
|
||||||
$need_charge = db::c()->query('SELECT `needcharge` FROM `magic` WHERE `id` = ?i', $dress['magic'])->fetch_assoc();
|
$need_charge = db::c()->query('SELECT `needcharge` FROM `magic` WHERE `id` = ?i', $dress['magic'])->fetch_assoc();
|
||||||
|
|
||||||
if (($user[$slot] > 0) && ($all_magic[$user['id']] < 1 || empty($need_charge['needcharge']))) {
|
if (($user->$slot > 0) && ($all_magic[$user->id] < 1 || empty($need_charge['needcharge']))) {
|
||||||
$row['id'] = $user[$slot];
|
$row['id'] = $user->$slot;
|
||||||
if ($dress['magic']) {
|
if ($dress['magic']) {
|
||||||
$magic = db::c()->query('SELECT targeted FROM `magic` WHERE `id` = ?i', $dress['magic'])->fetch_assoc();
|
$magic = db::c()->query('SELECT targeted FROM `magic` WHERE `id` = ?i', $dress['magic'])->fetch_assoc();
|
||||||
echo "<a onclick=\"";
|
echo "<a onclick=\"";
|
||||||
@ -272,7 +269,7 @@ function echoscroll($slot)
|
|||||||
echo <<<ACTIVE_SCROLL
|
echo <<<ACTIVE_SCROLL
|
||||||
<img class='tooltip' src="i/sh/{$dress['img']}" width='40' title="<b>{$dress['name']}</b><br> Прочность {$dress['duration']} / {$dress['maxdur']} " height='25' alt="Свиток"></a>
|
<img class='tooltip' src="i/sh/{$dress['img']}" width='40' title="<b>{$dress['name']}</b><br> Прочность {$dress['duration']} / {$dress['maxdur']} " height='25' alt="Свиток"></a>
|
||||||
ACTIVE_SCROLL;
|
ACTIVE_SCROLL;
|
||||||
} elseif (($user[$slot] > 0) && ($all_magic[$user['id']] >= 1) && $need_charge['needcharge'] > 0) {
|
} elseif (($user->$slot > 0) && ($all_magic[$user->id] >= 1) && $need_charge['needcharge'] > 0) {
|
||||||
echo <<<INACTIVE_SCROLL
|
echo <<<INACTIVE_SCROLL
|
||||||
<img src="i/sh/magicclock.gif" width="40" height="25" title='Произведите размен ударами и магия снова станет доступна' alt="Свиток">
|
<img src="i/sh/magicclock.gif" width="40" height="25" title='Произведите размен ударами и магия снова станет доступна' alt="Свиток">
|
||||||
INACTIVE_SCROLL;
|
INACTIVE_SCROLL;
|
||||||
@ -444,6 +441,7 @@ function undressall($user_id)
|
|||||||
|
|
||||||
function dropitemid($slot, $id)
|
function dropitemid($slot, $id)
|
||||||
{
|
{
|
||||||
|
global $user;
|
||||||
switch ($slot) {
|
switch ($slot) {
|
||||||
case 1:
|
case 1:
|
||||||
$slot1 = 'sergi';
|
$slot1 = 'sergi';
|
||||||
@ -522,7 +520,7 @@ function dropitemid($slot, $id)
|
|||||||
if ($checkid->getNumRows()) {
|
if ($checkid->getNumRows()) {
|
||||||
if (mysql_query('UPDATE `users`, `inventory` SET `users`.`' . $slot1 . '` = 0, `inventory`.`dressed` = 0, `users`.`sila` = `users`.`sila` - `inventory`.`gsila`, `users`.`lovk` = `users`.`lovk` - `inventory`.`glovk`, `users`.`inta` = `users`.`inta` - `inventory`.`ginta`, `users`.`intel` = `users`.`intel` - `inventory`.`gintel`, `users`.`maxhp` = `users`.`maxhp` - `inventory`.`ghp`, `users`.`noj` = `users`.`noj` - `inventory`.`gnoj`, `users`.`topor` = `users`.`topor` - `inventory`.`gtopor`, `users`.`dubina` = `users`.`dubina` - `inventory`.`gdubina`, `users`.`mec` = `users`.`mec` - `inventory`.`gmech`, `users`.`mfire` = `users`.`mfire` - `inventory`.`gfire`, `users`.`mwater` = `users`.`mwater` - `inventory`.`gwater`, `users`.`mair` = `users`.`mair` - `inventory`.`gair`, `users`.`mearth` = `users`.`mearth` - `inventory`.`gearth`, `users`.`mlight` = `users`.`mlight` - `inventory`.`glight`, `users`.`mgray` = `users`.`mgray` - `inventory`.`ggray`, `users`.`mdark` = `users`.`mdark` - `inventory`.`gdark`, `users`.`fkrit` = `users`.`fkrit` - `inventory`.`mfkrit`, `users`.`fakrit` = `users`.`fakrit` - `inventory`.`mfakrit`, `users`.`fuvorot` = `users`.`fuvorot` - `inventory`.`mfuvorot`, `users`.`fauvorot` = `users`.`fauvorot` - `inventory`.`mfauvorot`, `users`.`ubron1` = `users`.`ubron1` - `inventory`.`bron1`, `users`.`ubron2` = `users`.`ubron2` - `inventory`.`bron2`, `users`.`ubron3` = `users`.`ubron3` - `inventory`.`bron3`, `users`.`ubron4` = `users`.`ubron4` - `inventory`.`bron4`, `users`.`uminu` = `users`.`uminu` - `inventory`.`minu`, `users`.`umaxu` = `users`.`umaxu` - `inventory`.`maxu` WHERE `inventory`.`id` = `users`.`' . $slot1 . '` AND `inventory`.`dressed` = 1 AND `inventory`.`owner` = "' . $id . '" AND `users`.`id` = "' . $id . '"')) {
|
if (mysql_query('UPDATE `users`, `inventory` SET `users`.`' . $slot1 . '` = 0, `inventory`.`dressed` = 0, `users`.`sila` = `users`.`sila` - `inventory`.`gsila`, `users`.`lovk` = `users`.`lovk` - `inventory`.`glovk`, `users`.`inta` = `users`.`inta` - `inventory`.`ginta`, `users`.`intel` = `users`.`intel` - `inventory`.`gintel`, `users`.`maxhp` = `users`.`maxhp` - `inventory`.`ghp`, `users`.`noj` = `users`.`noj` - `inventory`.`gnoj`, `users`.`topor` = `users`.`topor` - `inventory`.`gtopor`, `users`.`dubina` = `users`.`dubina` - `inventory`.`gdubina`, `users`.`mec` = `users`.`mec` - `inventory`.`gmech`, `users`.`mfire` = `users`.`mfire` - `inventory`.`gfire`, `users`.`mwater` = `users`.`mwater` - `inventory`.`gwater`, `users`.`mair` = `users`.`mair` - `inventory`.`gair`, `users`.`mearth` = `users`.`mearth` - `inventory`.`gearth`, `users`.`mlight` = `users`.`mlight` - `inventory`.`glight`, `users`.`mgray` = `users`.`mgray` - `inventory`.`ggray`, `users`.`mdark` = `users`.`mdark` - `inventory`.`gdark`, `users`.`fkrit` = `users`.`fkrit` - `inventory`.`mfkrit`, `users`.`fakrit` = `users`.`fakrit` - `inventory`.`mfakrit`, `users`.`fuvorot` = `users`.`fuvorot` - `inventory`.`mfuvorot`, `users`.`fauvorot` = `users`.`fauvorot` - `inventory`.`mfauvorot`, `users`.`ubron1` = `users`.`ubron1` - `inventory`.`bron1`, `users`.`ubron2` = `users`.`ubron2` - `inventory`.`bron2`, `users`.`ubron3` = `users`.`ubron3` - `inventory`.`bron3`, `users`.`ubron4` = `users`.`ubron4` - `inventory`.`bron4`, `users`.`uminu` = `users`.`uminu` - `inventory`.`minu`, `users`.`umaxu` = `users`.`umaxu` - `inventory`.`maxu` WHERE `inventory`.`id` = `users`.`' . $slot1 . '` AND `inventory`.`dressed` = 1 AND `inventory`.`owner` = "' . $id . '" AND `users`.`id` = "' . $id . '"')) {
|
||||||
db::c()->query('UPDATE `users` SET `hp` = `maxhp`, `fullhptime` = ?i WHERE `hp` > `maxhp` AND `id` = ?i', time(), $id);
|
db::c()->query('UPDATE `users` SET `hp` = `maxhp`, `fullhptime` = ?i WHERE `hp` > `maxhp` AND `id` = ?i', time(), $id);
|
||||||
$user[$slot1] = 0;
|
$user->$slot1 = 0;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -609,8 +607,8 @@ function dropitem($slot)
|
|||||||
$slot1 = '';
|
$slot1 = '';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
{
|
|
||||||
if (db::c()->query('UPDATE `users` as `u`, `inventory` as `i` SET `u`.?f = 0, `i`.`dressed` = 0,
|
if (db::c()->query('UPDATE `users` as `u`, `inventory` as `i` SET `u`.?f = 0, `i`.`dressed` = 0,
|
||||||
`u`.`sila` = `u`.`sila` - `i`.`gsila`,
|
`u`.`sila` = `u`.`sila` - `i`.`gsila`,
|
||||||
`u`.`lovk` = `u`.`lovk` - `i`.`glovk`,
|
`u`.`lovk` = `u`.`lovk` - `i`.`glovk`,
|
||||||
`u`.`inta` = `u`.`inta` - `i`.`ginta`,
|
`u`.`inta` = `u`.`inta` - `i`.`ginta`,
|
||||||
@ -637,43 +635,43 @@ function dropitem($slot)
|
|||||||
`u`.`fauvorot` = `u`.`fauvorot` - `i`.`mfauvorot`,
|
`u`.`fauvorot` = `u`.`fauvorot` - `i`.`mfauvorot`,
|
||||||
`u`.`uminu` = `u`.`uminu` - `i`.`minu`,
|
`u`.`uminu` = `u`.`uminu` - `i`.`minu`,
|
||||||
`u`.`umaxu` = `u`.`umaxu` - `i`.`maxu`
|
`u`.`umaxu` = `u`.`umaxu` - `i`.`maxu`
|
||||||
WHERE `i`.`id` = `u`.?f AND `i`.`dressed` = 1 AND `i`.`owner` = ?i AND u.id = ?i', $slot1, $slot1, $user['id'], $user['id'])) {
|
WHERE `i`.`id` = `u`.?f AND `i`.`dressed` = 1 AND `i`.`owner` = ?i AND u.id = ?i', $slot1, $slot1, $user->id, $user->id)) {
|
||||||
db::c()->query('UPDATE `users` SET `hp` = `maxhp`, `fullhptime` = ?i WHERE `hp` > `maxhp` AND `id` = ?i', time(), $user['id']);
|
db::c()->query('UPDATE `users` SET `hp` = `maxhp`, `fullhptime` = ?i WHERE `hp` > `maxhp` AND `id` = ?i', time(), $user->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$wear_raw = db::c()->query('SELECT * FROM `inventory` where `owner` = ?i AND `dressed` = 1', $user['id']);
|
$wear_raw = db::c()->query('SELECT * FROM `inventory` where `owner` = ?i AND `dressed` = 1', $user->id);
|
||||||
while ($wear_list = $wear_raw->fetch_assoc()) {
|
while ($wear_list = $wear_raw->fetch_assoc()) {
|
||||||
$wear_arr[] = $wear_list['prototype'];
|
$wear_arr[] = $wear_list['prototype'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$item['id'] = $user[$slot1];
|
$item['id'] = $user->$slot1;
|
||||||
|
|
||||||
$get_pro = db::c()->query('SELECT * FROM `inventory` where `id` = ?i', $item['id'])->fetch_assoc();
|
$get_pro = db::c()->query('SELECT * FROM `inventory` where `id` = ?i', $item['id'])->fetch_assoc();
|
||||||
/////////////////////
|
/////////////////////
|
||||||
$sets_items = db::c()->query('SELECT * FROM `item_sets`');
|
$sets_items = db::c()->query('SELECT * FROM `item_sets`');
|
||||||
|
|
||||||
//для каждого комплекта
|
//для каждого комплекта
|
||||||
while ($items_in_set = $sets_items->fetch_assoc()) {
|
while ($items_in_set = $sets_items->fetch_assoc()) {
|
||||||
$checker = 0;
|
$checker = 0;
|
||||||
$temp_is = explode(",", $items_in_set['prot_id']);
|
$temp_is = explode(",", $items_in_set['prot_id']);
|
||||||
$set_id = $items_in_set['set_id'];
|
$set_id = $items_in_set['set_id'];
|
||||||
|
|
||||||
//если прото в комплекте и не одет
|
//если прото в комплекте и не одет
|
||||||
if (in_array($get_pro['prototype'], $temp_is) && (!in_array($get_pro['prototype'], $wear_arr))) {
|
if (in_array($get_pro['prototype'], $temp_is) && (!in_array($get_pro['prototype'], $wear_arr))) {
|
||||||
$checker = 1;
|
$checker = 1;
|
||||||
|
|
||||||
//для каждого одетого предмета
|
//для каждого одетого предмета
|
||||||
foreach ($temp_is as $check_proto) {
|
foreach ($temp_is as $check_proto) {
|
||||||
if ($check_proto != $get_pro['prototype'] && !in_array($check_proto, $wear_arr)) {
|
if ($check_proto != $get_pro['prototype'] && !in_array($check_proto, $wear_arr)) {
|
||||||
$checker = 0;
|
$checker = 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
if (($checker == 1) && (!in_array($get_pro['prototype'], $wear_arr))) {
|
if (($checker == 1) && (!in_array($get_pro['prototype'], $wear_arr))) {
|
||||||
db::c()->query('UPDATE `users` as `u`, `item_sets` as `s` SET
|
db::c()->query('UPDATE `users` as `u`, `item_sets` as `s` SET
|
||||||
`u`.`uminu` = `u`.`uminu` - `s`.`minu`,
|
`u`.`uminu` = `u`.`uminu` - `s`.`minu`,
|
||||||
`u`.`umaxu` = `u`.`umaxu` - `s`.`maxu`,
|
`u`.`umaxu` = `u`.`umaxu` - `s`.`maxu`,
|
||||||
`u`.`sila = `u`.`sila - `s`.`gsila`,
|
`u`.`sila = `u`.`sila - `s`.`gsila`,
|
||||||
@ -701,22 +699,18 @@ function dropitem($slot)
|
|||||||
`u`.`mlight = `u`.`mlight - `s`.`glight`,
|
`u`.`mlight = `u`.`mlight - `s`.`glight`,
|
||||||
`u`.`mgray = `u`.`mgray - `s`.`ggray`
|
`u`.`mgray = `u`.`mgray - `s`.`ggray`
|
||||||
WHERE
|
WHERE
|
||||||
`u`.`id` = ?i AND `s`.`set_id`= ?i', $user['id'], $set_id);
|
`u`.`id` = ?i AND `s`.`set_id`= ?i', $user->id, $set_id);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME роняем вещи, которые больше не можем держать
|
//FIXME роняем вещи, которые больше не можем держать
|
||||||
function ref_drop()
|
function ref_drop()
|
||||||
{
|
{
|
||||||
# global $user;
|
|
||||||
|
|
||||||
//сможет держать
|
//сможет держать
|
||||||
function derj($id)
|
function derj($id)
|
||||||
{
|
{
|
||||||
//global $user;
|
|
||||||
$user = db::c()->query('SELECT `id`, `align` FROM `users` WHERE `id` = ?i', $_SESSION['uid'])->fetch_assoc();
|
$user = db::c()->query('SELECT `id`, `align` FROM `users` WHERE `id` = ?i', $_SESSION['uid'])->fetch_assoc();
|
||||||
$ts = db::c()->query('SELECT `id`, `nalign` FROM `inventory` WHERE `id` = ?i', $id)->fetch_assoc();
|
$ts = db::c()->query('SELECT `id`, `nalign` FROM `inventory` WHERE `id` = ?i', $id)->fetch_assoc();
|
||||||
$al = '(1 = 1)';
|
$al = '(1 = 1)';
|
||||||
@ -763,94 +757,17 @@ function ref_drop()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// убить предмет
|
|
||||||
|
/**
|
||||||
|
* Уничтожить предмет, принадлежащий игроку, вызывающего функцию.
|
||||||
|
* @param $id - ID предмета игрока.
|
||||||
|
* @throws \Krugozor\Database\Mysql\Exception
|
||||||
|
*/
|
||||||
function destructitem($id)
|
function destructitem($id)
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
$slot1 = '';
|
$item = db::c()->query('SELECT 1 FROM inventory WHERE owner_id = ?i AND item_id = ?i', $user->id, $id);
|
||||||
$dress = db::c()->query('SELECT * FROM `inventory` WHERE `owner` = ?i AND `id` = ?i', $user['id'], $id)->fetch_assoc();
|
if ($item->getNumRows()) {
|
||||||
switch ($dress['type']) {
|
|
||||||
case 1:
|
|
||||||
$slot1 = 'sergi';
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
$slot1 = 'kulon';
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
$slot1 = 'weap';
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
$slot1 = 'bron';
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
$slot1 = 'r1';
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
$slot1 = 'r2';
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
$slot1 = 'r3';
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
$slot1 = 'helm';
|
|
||||||
break;
|
|
||||||
case 9:
|
|
||||||
$slot1 = 'perchi';
|
|
||||||
break;
|
|
||||||
case 10:
|
|
||||||
$slot1 = 'shit';
|
|
||||||
break;
|
|
||||||
case 11:
|
|
||||||
$slot1 = 'boots';
|
|
||||||
break;
|
|
||||||
case 12:
|
|
||||||
$slot1 = 'm1';
|
|
||||||
break;
|
|
||||||
case 22:
|
|
||||||
$slot1 = 'rybax';
|
|
||||||
break;
|
|
||||||
case 23:
|
|
||||||
$slot1 = 'plaw';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$slot1 = 'weap';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if ($dress['type'] == 5) {
|
|
||||||
if ($user['r1'] == $dress['id']) {
|
|
||||||
$slot1 = 'r1';
|
|
||||||
} elseif ($user['r2'] == $dress['id']) {
|
|
||||||
$slot1 = 'r2';
|
|
||||||
} elseif ($user['r3'] == $dress['id']) {
|
|
||||||
$slot1 = 'r3';
|
|
||||||
}
|
|
||||||
} elseif ($dress['type'] == 12) {
|
|
||||||
if ($user['m1'] == $dress['id']) {
|
|
||||||
$slot1 = 'm1';
|
|
||||||
} elseif ($user['m2'] == $dress['id']) {
|
|
||||||
$slot1 = 'm2';
|
|
||||||
} elseif ($user['m3'] == $dress['id']) {
|
|
||||||
$slot1 = 'm3';
|
|
||||||
} elseif ($user['m4'] == $dress['id']) {
|
|
||||||
$slot1 = 'm4';
|
|
||||||
} elseif ($user['m5'] == $dress['id']) {
|
|
||||||
$slot1 = 'm5';
|
|
||||||
} elseif ($user['m6'] == $dress['id']) {
|
|
||||||
$slot1 = 'm6';
|
|
||||||
} elseif ($user['m7'] == $dress['id']) {
|
|
||||||
$slot1 = 'm7';
|
|
||||||
} elseif ($user['m8'] == $dress['id']) {
|
|
||||||
$slot1 = 'm8';
|
|
||||||
} elseif ($user['m9'] == $dress['id']) {
|
|
||||||
$slot1 = 'm9';
|
|
||||||
} elseif ($user['m10'] == $dress['id']) {
|
|
||||||
$slot1 = 'm10';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($dress['owner'] == $user['id']) {
|
|
||||||
if ($dress['dressed'] == 1) {
|
|
||||||
db::c()->query('UPDATE `users` SET ?f = 0 WHERE `id` = ?i', $slot1, $user['id']);
|
|
||||||
}
|
|
||||||
db::c()->query('DELETE FROM `inventory` WHERE `id` = ?i', $id);
|
db::c()->query('DELETE FROM `inventory` WHERE `id` = ?i', $id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -859,8 +776,8 @@ function destructitem($id)
|
|||||||
function usemagic($id, $target)
|
function usemagic($id, $target)
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
$row = db::c()->query('SELECT * FROM `inventory` WHERE `owner` = ?i AND id = ?i', $user['id'], $id)->fetch_assoc_array();
|
$row = db::c()->query('SELECT * FROM `inventory` WHERE `owner` = ?i AND id = ?i', $user->id, $id)->fetch_assoc_array();
|
||||||
$bat = db::c()->query('SELECT * FROM `battle` WHERE `id` = ?i', $user['battle'])->fetch_assoc_array();
|
$bat = db::c()->query('SELECT * FROM `battle` WHERE `id` = ?i', $user->battle)->fetch_assoc_array();
|
||||||
$all_magic = unserialize($bat['magic']);
|
$all_magic = unserialize($bat['magic']);
|
||||||
$charge = 0;
|
$charge = 0;
|
||||||
$magic = db::c()->query('SELECT * FROM `magic` WHERE `id` = ?i', $row['magic'])->fetch_assoc_array();
|
$magic = db::c()->query('SELECT * FROM `magic` WHERE `id` = ?i', $row['magic'])->fetch_assoc_array();
|
||||||
@ -873,27 +790,27 @@ function usemagic($id, $target)
|
|||||||
if ($incmagic['needcharge'] > 0) {
|
if ($incmagic['needcharge'] > 0) {
|
||||||
$charge = $incmagic['needcharge'];
|
$charge = $incmagic['needcharge'];
|
||||||
}
|
}
|
||||||
|
//FIXME Переделать под новую базу
|
||||||
if ((($all_magic[$user['id']] < 1) || ($charge == '0')) &&
|
if (($all_magic[$user->id] < 1 || $charge == 0) &&
|
||||||
(($user['sila'] >= $row['nsila']) &&
|
($user['sila'] >= $row['nsila'] &&
|
||||||
($user['lovk'] >= $row['nlovk']) &&
|
$user['lovk'] >= $row['nlovk'] &&
|
||||||
($user['inta'] >= $row['ninta']) &&
|
$user['inta'] >= $row['ninta'] &&
|
||||||
($user['vinos'] >= $row['nvinos']) &&
|
$user['vinos'] >= $row['nvinos'] &&
|
||||||
($user['intel'] >= $row['nintel']) &&
|
$user['intel'] >= $row['nintel'] &&
|
||||||
($user['level'] >= $row['nlevel']) &&
|
$user['level'] >= $row['nlevel'] &&
|
||||||
(($user['align'] > 7 && $user['align'] < 8) || ((int)$user['align'] == (int)$row['nalign']) || ($row['nalign'] == 0)) &&
|
(($user['align'] > 7 && $user['align'] < 8) || ((int)$user['align'] == (int)$row['nalign']) || ($row['nalign'] == 0)) &&
|
||||||
($user['noj'] >= $row['nnoj']) &&
|
$user['noj'] >= $row['nnoj'] &&
|
||||||
($user['topor'] >= $row['ntopor']) &&
|
$user['topor'] >= $row['ntopor'] &&
|
||||||
($user['dubina'] >= $row['ndubina']) &&
|
$user['dubina'] >= $row['ndubina'] &&
|
||||||
($user['mec'] >= $row['nmech']) &&
|
$user['mec'] >= $row['nmech'] &&
|
||||||
($row['type'] < 13 || $row['type'] == 50) && ($user['mfire'] >= $row['nfire']) &&
|
($row['type'] < 13 || $row['type'] == 50) && ($user['mfire'] >= $row['nfire']) &&
|
||||||
($user['mwater'] >= $row['nwater']) &&
|
$user['mwater'] >= $row['nwater'] &&
|
||||||
($user['mair'] >= $row['nair']) &&
|
$user['mair'] >= $row['nair'] &&
|
||||||
($user['mearth'] >= $row['nearth']) &&
|
$user['mearth'] >= $row['nearth'] &&
|
||||||
($user['mlight'] >= $row['nlight']) &&
|
$user['mlight'] >= $row['nlight'] &&
|
||||||
($user['mgray'] >= $row['ngray']) &&
|
$user['mgray'] >= $row['ngray'] &&
|
||||||
($user['mdark'] >= $row['ndark']) &&
|
$user['mdark'] >= $row['ndark'] &&
|
||||||
($row['needident'] == 0)
|
$row['needident'] == 0
|
||||||
) || $row['magic'] == 48 || $row['magic'] == 50) {
|
) || $row['magic'] == 48 || $row['magic'] == 50) {
|
||||||
|
|
||||||
|
|
||||||
@ -927,16 +844,16 @@ function usemagic($id, $target)
|
|||||||
$charge = 0;
|
$charge = 0;
|
||||||
}
|
}
|
||||||
//ограничение по кол-ву за ход
|
//ограничение по кол-ву за ход
|
||||||
if ($user['battle'] > 0) {
|
if ($user->battle > 0) {
|
||||||
$bat = db::c()->query('SELECT * FROM `battle` WHERE `id` = ?i', $user['battle'])->fetch_assoc_array();
|
$bat = db::c()->query('SELECT * FROM `battle` WHERE `id` = ?i', $user->battle)->fetch_assoc_array();
|
||||||
}
|
}
|
||||||
if ($bat['magic'] == '') {
|
if ($bat['magic'] == '') {
|
||||||
$all_magic = [];
|
$all_magic = [];
|
||||||
} else {
|
} else {
|
||||||
$all_magic = unserialize($bat['magic']);
|
$all_magic = unserialize($bat['magic']);
|
||||||
}
|
}
|
||||||
$all_magic[$user['id']] += $charge;
|
$all_magic[$user->id] += $charge;
|
||||||
db::c()->query('UPDATE `battle` SET `magic`= "?s" WHERE id = ?i', serialize($all_magic), $user['battle']);
|
db::c()->query('UPDATE `battle` SET `magic`= "?s" WHERE id = ?i', serialize($all_magic), $user->battle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -946,7 +863,7 @@ function addch($text, $room = 0)
|
|||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
if ($room == 0) {
|
if ($room == 0) {
|
||||||
$room = $user['room'];
|
$room = $user->room;
|
||||||
}
|
}
|
||||||
if ($fp = @fopen("tmp/chat.txt", "a")) { //открытие
|
if ($fp = @fopen("tmp/chat.txt", "a")) { //открытие
|
||||||
flock($fp, LOCK_EX); //БЛОКИРОВКА ФАЙЛА
|
flock($fp, LOCK_EX); //БЛОКИРОВКА ФАЙЛА
|
||||||
@ -962,7 +879,7 @@ function addchp($text, $who, $room = 0)
|
|||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
if ($room == 0) {
|
if ($room == 0) {
|
||||||
$room = $user['room'];
|
$room = $user->room;
|
||||||
}
|
}
|
||||||
$fp = fopen("tmp/chat.txt", "a"); //открытие
|
$fp = fopen("tmp/chat.txt", "a"); //открытие
|
||||||
flock($fp, LOCK_EX); //БЛОКИРОВКА ФАЙЛА
|
flock($fp, LOCK_EX); //БЛОКИРОВКА ФАЙЛА
|
||||||
@ -1178,7 +1095,7 @@ function get_meshok()
|
|||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
$d = db::c()->query('SELECT SUM(`gmeshok`) AS `ves` FROM `inventory` WHERE `owner` = ?i AND `setsale` = 0 AND `gmeshok` > 0', $_SESSION['uid'])->fetch_assoc();
|
$d = db::c()->query('SELECT SUM(`gmeshok`) AS `ves` FROM `inventory` WHERE `owner` = ?i AND `setsale` = 0 AND `gmeshok` > 0', $_SESSION['uid'])->fetch_assoc();
|
||||||
return ($user['sila'] * 4 + $d['ves']);
|
return ($user->strength * 4 + $d['ves']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1238,7 +1155,7 @@ function star_sign($date)
|
|||||||
$zodiac[0] = "10";
|
$zodiac[0] = "10";
|
||||||
$dayOfYear = date("z", strtotime($date));
|
$dayOfYear = date("z", strtotime($date));
|
||||||
$isLeapYear = date("L", strtotime($date)); //Высокосный?
|
$isLeapYear = date("L", strtotime($date)); //Высокосный?
|
||||||
if ($isLeapYear && $dayOfYear >59) {
|
if ($isLeapYear && $dayOfYear > 59) {
|
||||||
--$dayOfYear;
|
--$dayOfYear;
|
||||||
}
|
}
|
||||||
foreach ($zodiac as $day => $sign) {
|
foreach ($zodiac as $day => $sign) {
|
||||||
|
13
main.php
13
main.php
@ -11,6 +11,7 @@ if (!isset($_SESSION['uid'])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
require_once 'functions.php';
|
require_once 'functions.php';
|
||||||
|
$user = $userr;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
db::c()->query('UPDATE `online` SET `real_time` = ?i WHERE `user_id` = ?i', time(), $user->id);
|
db::c()->query('UPDATE `online` SET `real_time` = ?i WHERE `user_id` = ?i', time(), $user->id);
|
||||||
@ -342,7 +343,7 @@ function setShadow($image)
|
|||||||
];
|
];
|
||||||
if (in_array($image, $shadows)) {
|
if (in_array($image, $shadows)) {
|
||||||
$i = $image . '.png';
|
$i = $image . '.png';
|
||||||
db::c()->query('UPDATE `users` SET `shadow` = "?s" WHERE `id` = ?i', $i, $user['id']);
|
db::c()->query('UPDATE `users` SET `shadow` = "?s" WHERE `id` = ?i', $i, $user->id);
|
||||||
} else {
|
} else {
|
||||||
err('Ошибка!');
|
err('Ошибка!');
|
||||||
}
|
}
|
||||||
@ -353,7 +354,7 @@ if ($obraz && ($user->shadow == 'g0.gif' || $user->shadow == 'man0.gif')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($del == 1 && $effectId > 0) {
|
if ($del == 1 && $effectId > 0) {
|
||||||
$pl = db::c()->query('SELECT type FROM users_effects WHERE owner_id = ?i AND effect_id = ?i', $user['id'], $effectId)->fetch_assoc();
|
$pl = db::c()->query('SELECT type FROM users_effects WHERE owner_id = ?i AND effect_id = ?i', $user->id, $effectId)->fetch_assoc();
|
||||||
if (isset($pl['type'])) {
|
if (isset($pl['type'])) {
|
||||||
echo del_efs($effectId, $pl['type']);
|
echo del_efs($effectId, $pl['type']);
|
||||||
} else {
|
} else {
|
||||||
@ -363,7 +364,7 @@ if ($del == 1 && $effectId > 0) {
|
|||||||
|
|
||||||
if ($brons && $ids) {
|
if ($brons && $ids) {
|
||||||
try {
|
try {
|
||||||
$cur = db::c()->query('SELECT free_bron, bron1, bron2, bron3, bron4 FROM inventory WHERE owner = ?i AND id = ?i', $user['id'], $ids)->fetch_assoc();
|
$cur = db::c()->query('SELECT free_bron, bron1, bron2, bron3, bron4 FROM inventory WHERE owner = ?i AND id = ?i', $user->id, $ids)->fetch_assoc();
|
||||||
} catch (\Krugozor\Database\Mysql\Exception $e) {
|
} catch (\Krugozor\Database\Mysql\Exception $e) {
|
||||||
echo "<div style='background-color: #ffaaaa;'>Ошибка: " . $e->getMessage() . "<br> В файле: " . $e->getFile() . " (" . $e->getLine() . ")</div>";
|
echo "<div style='background-color: #ffaaaa;'>Ошибка: " . $e->getMessage() . "<br> В файле: " . $e->getFile() . " (" . $e->getLine() . ")</div>";
|
||||||
}
|
}
|
||||||
@ -461,7 +462,7 @@ if ($edit) {
|
|||||||
$q = $q->fetch_assoc();
|
$q = $q->fetch_assoc();
|
||||||
if (empty($q['dressed'])) {
|
if (empty($q['dressed'])) {
|
||||||
destructitem($q['id']);
|
destructitem($q['id']);
|
||||||
addToDelo($user['login'] . " выбросил предмет " . $q['name'] . " id:(cap" . $q['id'] . ")");
|
addToDelo($user->login . " выбросил предмет " . $q['name'] . " id:(cap" . $q['id'] . ")");
|
||||||
err('Предмет ' . $q['name'] . ' выброшен.');
|
err('Предмет ' . $q['name'] . ' выброшен.');
|
||||||
} else {
|
} else {
|
||||||
err('Ошибка: нельзя выбросить одетый предмет!');
|
err('Ошибка: нельзя выбросить одетый предмет!');
|
||||||
@ -528,7 +529,7 @@ if ($edit) {
|
|||||||
<div align="center">
|
<div align="center">
|
||||||
<a href='main.php?edit=1&undress=all'>Снять все</a><BR>
|
<a href='main.php?edit=1&undress=all'>Снять все</a><BR>
|
||||||
<div class="effectList" style="padding-top: 15px; max-height: 150px; width: 220px;">
|
<div class="effectList" style="padding-top: 15px; max-height: 150px; width: 220px;">
|
||||||
<?= show_eff_inf($user['id'], 2) ?>
|
<?= show_eff_inf($user->id, 2) ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
@ -585,7 +586,7 @@ if ($edit) {
|
|||||||
<td valign=top>
|
<td valign=top>
|
||||||
<div class="button-container"> <!--Меню-кнопки-->
|
<div class="button-container"> <!--Меню-кнопки-->
|
||||||
<FORM METHOD=POST ACTION="?edit=1" name=f1>
|
<FORM METHOD=POST ACTION="?edit=1" name=f1>
|
||||||
<?php if ($user['shadow'] == '0.gif' || $user['admin'] == 1): ?>
|
<?php if ($user->shadow == '0.gif' || $user->admin == 1): ?>
|
||||||
<INPUT class="button primary icon user" TYPE="submit" name="setshadow" value="Образы"
|
<INPUT class="button primary icon user" TYPE="submit" name="setshadow" value="Образы"
|
||||||
title="Образы">
|
title="Образы">
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
$frt=mysql_query("select user_id from `labirint` where glava='".$glava."'");
|
$frt=mysql_query("select user_id from `labirint` where glava='".$glava."'");
|
||||||
while($rbb=mysql_fetch_array($frt)){
|
while($rbb=mysql_fetch_array($frt)){
|
||||||
addchp ('<b>'.$user["login"].'</b> поднял предмет "'.$mis.'". ','{[]}'.Nick::id($rbb["user_id"])->short().'{[]}');
|
addchp ('<b>'.$user->login.'</b> поднял предмет "'.$mis.'". ','{[]}'.Nick::id($rbb["user_id"])->short().'{[]}');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user