Перенос функций, вызываемых один раз в файлы, из которых они вызываются. Раскрытие функций-однострочников.

This commit is contained in:
Igor Barkov [iwork] 2018-07-02 18:35:25 +03:00
parent 54e64ff1ec
commit 44d106696f
15 changed files with 2108 additions and 2099 deletions

View File

@ -12,6 +12,44 @@ $eff = db::c()->query('SELECT `id` FROM `effects` WHERE `owner` = ?i AND (`type`
$w = db::c()->query('SELECT `value` FROM `variables` WHERE `var` = "arena_win"')->fetch_assoc();
$al = aligntype($user['align']);
function join_arena($u, $btl, $team, $at)
{
$bd = mysql_fetch_array(mysql_query('SELECT * FROM `battle` WHERE `id` = "' . $btl . '" LIMIT 1'));
$battle = unserialize($bd['teams']);
$ak = array_keys($battle[$at]);
$battle[$u] = $battle[$ak[0]];
foreach ($battle[$u] as $k => $v) {
$battle[$u][$k] = array(0, 0, time());
$battle[$k][$u] = array(0, 0, time());
}
if ($team == 1) {
$adtxt = 'За сторону <b>Тьмы</b>.';
} else {
$adtxt = 'За сторону <b>Света</b>.';
}
addlog($btl, '<span class=date>' . date("H:i") . '</span> ' . nick5($u, "B" . $team) . ' вмешался в поединок! ' . $adtxt . '<br />');
mysql_query('UPDATE `battle` SET `teams` = \'' . serialize($battle) . '\', `t' . $team . '` = CONCAT(`t' . $team . '`,\';' . $u . '\') WHERE `id` = "' . $btl . '" LIMIT 1');
mysql_query("UPDATE users SET `battle` = '" . $btl . "', `zayavka` = 0 WHERE `id` = '" . $u . "' LIMIT 1");
header("Location: fbattle.php");
}
function aligntype($a)
{
$lightaligns = array("1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9");
$darkaligns = array("2.2", "3", "8.21");
$neutralaligns = array("2", "8.31");
if (in_array($a, $lightaligns)) {
return 1;
}
if (in_array($a, $darkaligns)) {
return 2;
}
if (in_array($a, $neutralaligns)) {
return 3;
}
return 0;
}
if ($w['value'] == 1) {
$winers = 'Прошлая победа за Силами Тьмы';
} elseif ($w['value'] == 2) {

18
buy.php
View File

@ -3,9 +3,25 @@
session_start();
if (!isset($_SESSION['uid'])) die();
include('config.php');
include('functions.php');
#include('functions.php');
$is_now = db::c()->query('SELECT `id`, `uid` FROM `abils_user` WHERE `uid` = ?i', $user['id'])->fetch_assoc();
function add_user_abil($ab, $cost)
{
global $user, $banks;
if (isset($ab)) {
if ($banks['ekr'] >= $cost) {
$isset = mysql_fetch_array(mysql_query('SELECT `id`, `' . $ab . '` FROM `abils_user` WHERE `uid` = "' . $user['id'] . '" LIMIT 1'));
$isset[$ab] += 1;
mysql_query('UPDATE `abils_user` SET `' . $ab . '` = "' . $isset[$ab] . '" WHERE `uid` = "' . $user['id'] . '" LIMIT 1');
$banks['ekr'] -= $cost;
mysql_query('UPDATE `bank` SET `ekr` = "' . $banks['ekr'] . '" WHERE `id` = "' . $user['id'] . '" LIMIT 1');
return true;
}
}
return false;
}
$cost = array(1, 2, 10, 0.50, 0.80, 1, 1, 0.10, 0.20, 4, 0.02, 20, 10, 1, 1);
$mag = array('sleep15', 'sleep30', 'closebattle', 'heal20', 'heal35', 'heal50', 'travmoff', 'attack', 'bloodattack', 'death', 'comment', 'openbattle', 'reamdeath', 'clone', 'unclone');

View File

@ -14,6 +14,23 @@ $clan = db::c()->query('SELECT `glava` FROM `clans` WHERE `id` = ?i', $user['kla
$cost = array(1, 2, 10, 0.50, 0.80, 1, 1, 0.10, 0.20, 4, 0.02, 20, 10, 1, 1);
$mag = array('sleep15', 'sleep30', 'closebattle', 'heal20', 'heal35', 'heal50', 'travmoff', 'attack', 'bloodattack', 'death', 'comment', 'openbattle', 'reamdeath', 'clone', 'unclone');
function add_klan_abil($ab, $cost)
{
global $user, $banks;
$clan = mysql_fetch_array(mysql_query('SELECT `id`, `glava` FROM `clans` WHERE `id` = "' . $user['klan'] . '" LIMIT 1'));
if (isset($ab)) {
if ($banks['ekr'] >= $cost && $clan['glava'] == $user['id']) {
$isset = mysql_fetch_array(mysql_query('SELECT `id`, `' . $ab . '` FROM `abils_klan` WHERE `klan` = "' . $user['klan'] . '" LIMIT 1'));
$isset[$ab] += 1;
mysql_query('UPDATE `abils_klan` SET `' . $ab . '` = "' . $isset[$ab] . '" WHERE `klan` = "' . $user['klan'] . '" LIMIT 1');
$banks['ekr'] -= $cost;
mysql_query('UPDATE `bank` SET `ekr` = "' . $banks['ekr'] . '" WHERE `id` = "' . $user['id'] . '" LIMIT 1');
return true;
}
}
return false;
}
if (isset($_POST['type'], $_POST['user'])) {
if (isset($user['id'])) {
$price = $cost[$_POST['type'] - 21];

230
cave.php
View File

@ -9,6 +9,218 @@ $user = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "'.$_S
include("functions.php");
include('cave/cave_bots.php');
function cancarry($m, $u)
{
global $user;
if (!$u) {
$u = $user['id'];
}
$bp = mysql_fetch_array(mysql_query("SELECT SUM(`massa`) AS `massa`, SUM(`gmeshok`) AS `gmeshok` FROM `inventory` WHERE `owner` = '$u[id]' AND `dressed` = 1 AND `setsale` = 0"));
$mw = 40 * $user['level'] + $user['vinos'] + $bp['gmeshok'];
if ($bp['massa'] + $m > $mw) {
return false;
}
return true;
}
function placeinbackpack($qty, $userid = 0)
{
global $user;
if (!$userid) {
$userid = $user['id'];
}
if ($userid == $user['id']) {
$user1 = $user;
} else {
$user1 = mysql_fetch_array(mysql_query("SELECT `id`, `level` FROM `users` WHERE `id` = '$user1[id]' LIMIT 1"));
}
$cnt = mysql_fetch_assoc(mysql_query("SELECT COUNT(`id`) AS `cnt` FROM `inventory` WHERE `owner` = '$user1[id]' AND `dressed` = 0 AND `setsale` = 0"));
return $cnt['cnt'] + $qty <= backpacksize($user1['id']);
}
function backpacksize($u = 0)
{ // $l * 10 +5
$l = 0;
if ($u) {
$l = $u['level'];
}
if ($l == 0) {
return 75;
}
if ($l == 1) {
return 100;
}
if ($l == 2) {
return 125;
}
if ($l == 3) {
return 175;
}
if ($l == 4) {
return 225;
}
if ($l == 5) {
return 325;
}
if ($l == 6) {
return 425;
}
if ($l == 7) {
return 525;
}
if ($l == 8) {
return 625;
}
if ($l == 9) {
return 725;
}
if ($l == 10) {
return 825;
}
if ($l == 11) {
return 925;
}
if ($l >= 12) {
return 1025;
}
}
function battlewithbot($b, $name = '', $time = 3, $blood = 1, $group = 1, $battleid = 0, $otherbots = array(), $noredir = 0, $userid = 0, $type = 1)
{
global $user;
if (!$userid) {
$user1 = $user;
} elseif (is_array($userid)) {
$user1 = $userid;
} else {
$user1 = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '$userid' LIMIT 1"));
}
$bot = mysql_fetch_array(mysql_query("SELECT `login`, `maxhp` FROM `users` WHERE `id` = '$b' LIMIT 1"));
if (!$name) {
$name = $bot['login'];
}
if ($battleid) {
$botid = mysql_fetch_assoc(mysql_query("SELECT `id` FROM `bots` WHERE `prototype` = '$b' AND `battle` = '$battleid' LIMIT 1"));
} elseif ($group) {
$arha = mysql_fetch_array(mysql_query("SELECT * FROM `bots` WHERE `prototype` = '$b' ORDER BY `id` DESC LIMIT 1"));
$battleid = $arha['battle'];
$botid = $arha['id'];
}
if (@$battleid > 0) {
$bd = mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `id` = '$battleid' LIMIT 1"));
$battle = unserialize($bd['teams']);
$t1 = explode(";", $bd['t1']);
$t2 = explode(";", $bd['t2']);
$ak = array_keys($battle[$t2[0]]);
$battle[$user1['id']] = $battle[$ak[0]];
foreach ($battle[$user1['id']] as $k => $v) {
$battle[$user1['id']][$k] = array(0, 0, time());
$battle[$k][$user1['id']] = array(0, 0, time());
}
if (in_array($botid, $t1)) {
$ttt = 2;
} else {
$ttt = 1;
}
if ($user1['invis'] == 1) {
addlog($battleid, '<span class=date>' . date("H:i") . '</span> <b>невидимка</b> вмешался в поединок!<BR>');
} else {
addlog($battleid, '<span class=date>' . date("H:i") . '</span> ' . nick5($user1['id'], "B" . $ttt) . ' вмешался в поединок!<BR>');
}
mysql_query('UPDATE `battle` SET `teams` = \'' . serialize($battle) . '\', `t' . $ttt . '` = CONCAT(`t' . $ttt . '`,\';' . $user1['id'] . '\') WHERE `id` = ' . $battleid . ' LIMIT 1');
mysql_query("UPDATE `users` SET `battle` = " . $battleid . ", `zayavka` = 0 WHERE `id`= " . $user1['id'] . " LIMIT 1");
if (!$noredir) {
header("Location: fbattle.php");
}
} else {
mysql_query("INSERT INTO `bots` (`name`, `prototype`, `battle`, `hp`) VALUES ('$name', '$b', '', '" . $bot['maxhp'] . "')");
$botnames = array();
$botnames[$name] = 1;
$hps[$b] = $bot['maxhp'];
$botid1 = mysql_insert_id();
$cond = " `id` = '$botid1' ";
$teams = array();
$teams[$user1['id']][$botid1] = array(0, 0, time());
$teams[$botid1][$user1['id']] = array(0, 0, time());
$t2 = "$botid1";
$others = "";
$hps = array();
foreach ($otherbots as $k => $v) {
if (@$botnames[$v['name']]) {
$i = 1;
while (@$botnames["$v[name] ($i)"]) $i++;
$botname = "$v[name] ($i)";
} else {
$botname = $v['name'];
}
$botnames[$botname] = 1;
if (!@$hps[$v['id']]) {
$hps[$v['id']] = mysql_fetch_array(mysql_query("SELECT `maxhp` FROM `users` WHERE `id` = '$v[id]' LIMIT 1"));
}
mysql_query("INSERT INTO `bots` (`name`, `prototype`, `battle`, `hp`) VALUES ('$botname', '$v[id]', '', '" . $hps[$v['id']]['maxhp'] . "')");
$botid = mysql_insert_id();
$cond .= " OR `id` = '$botid' ";
$teams[$user1['id']][$botid] = array(0, 0, time());
$teams[$botid][$user1['id']] = array(0, 0, time());
$others .= "<span class=date>" . date("H:i") . "</span> <span class=B2>$botname</span> вмешался в поединок.<BR>";
$t2 .= ";$botid";
}
mysql_query("INSERT INTO `battle` (`id`, `coment`, `teams`, `timeout`, `type`, `status`, `t1`, `t2`, `to1`, `to2`, `blood`, `date`) VALUES (NULL, '', '" . serialize($teams) . "', '" . $time . "', '$type', '0', '" . $user1['id'] . "', '" . $t2 . "', '" . time() . "', '" . time() . "', '$blood', '" . date("Y-m-d H:i") . "')");
$battleid = mysql_insert_id();
mysql_query("UPDATE `bots` SET `battle` = {$battleid} WHERE $cond");
mysql_query("UPDATE `users` SET `battle` = {$battleid} WHERE `id` = {$user1['id']} LIMIT 1");
if ($user1['invis'] == 1) {
$rr = "<b>невидимка</b> и <b>" . nick::id($botid1)->full(1) . "</b>";
} else {
$rr = "<b>" . nick::id($user1['id'])->full(1) . "</b> и <b>" . nick::id($botid1)->full(1) . "</b>";
}
addlog($battleid, "Часы показывали <span class=date>" . date("Y.m.d H.i") . "</span>, когда " . $rr . " бросили вызов друг другу. <BR>" . ($others ? "$others<BR>" : ""));
if (!$noredir) {
header("Location: fbattle.php");
}
}
return $battleid;
}
function gotoroom($r, $redir = 1)
{
mysql_query("UPDATE `users`, `online` SET `users`.`room` = '$r', `online`.`room` = '$r' WHERE `online`.`id` = `users`.`id` AND `online`.`id` = '{$_SESSION['uid']}'");
if ($redir) {
redirectbyroom($r);
}
}
function redirectbyroom($r)
{
global $canalenters;
if (in_array($r, $canalenters)) {
header("location: enter_cave.php");
die();
}
if ($r == 1) {
header("location: main.php");
die();
}
}
$roomnames = array(621 => "Рудник");
if($user["login"] == "Rallo Tabs") {
@ -194,6 +406,24 @@ function loadmap() {
$map = unserialize($map['map']);
}
function getslot($i, $user1 = 0)
{
global $userslots, $user;
if (!$user1) {
$user1 = $user;
}
foreach ($userslots as $k => $v) {
if ($user1[$v] == $i) {
return $v;
}
}
}
function getcavedata($caveleader, $floor)
{
return unserialize(implode("", file("cavedata/$caveleader-$floor.dat")));
}
if(!in_array($user['room'], $caverooms)) {
header("Location: main.php");
die('Not in this life ...');

View File

@ -1,4 +1,25 @@
<?
function getchance($p)
{
if (mt_rand(1, 100) <= $p) {
return 1;
} else {
return 0;
}
}
function cavesys($text)
{
global $user;
if ($fp = @fopen("tmp/chat.txt", "a")) {
flock($fp, LOCK_EX);
fputs($fp, ":[" . time() . "]:[!cavesys!!]:[$text]:[$user[caveleader]]\r\n");
fflush($fp);
flock($fp, LOCK_UN);
fclose($fp);
}
}
if(in_array($user['room'], $caverooms)) {
include("caveitems.php");

7
ch.php
View File

@ -250,6 +250,13 @@ if (isset($_GET['online']) && $_GET['online'] != null) {
}
if ($row['invis'] == 0 || $row['id'] == $_SESSION['uid']) {
if (!empty($row['action'])) {
function stripslashes_deep($text)
{
while (strstr($text, "\\")) {
$text = stripslashes($text);
}
return $text;
}
$rrr = $row['action'];
$act = explode("<>:<>", $rrr);
$aa = htmlspecialchars(stripslashes_deep($act[1]));

View File

@ -7,6 +7,11 @@ ini_set('error_reporting', E_ALL);
include "config.php";
include "functions.php";
function vCode($LocID, $Stamp)
{
return md5(sha1($LocID . $Stamp));
}
$timeStamp = time();
$user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '{$_SESSION['uid']}' LIMIT 1;"));

View File

@ -1,4 +1,26 @@
<?
function getchance($p)
{
if (mt_rand(1, 100) <= $p) {
return 1;
} else {
return 0;
}
}
function cavesys($text)
{
global $user;
if ($fp = @fopen("tmp/chat.txt", "a")) {
flock($fp, LOCK_EX);
fputs($fp, ":[" . time() . "]:[!cavesys!!]:[$text]:[$user[caveleader]]\r\n");
fflush($fp);
flock($fp, LOCK_UN);
fclose($fp);
}
}
if(in_array($user['room'], $caverooms)) {
include("caveitems.php");
mysql_query('LOCK TABLES `cavebots` WRITE, `caveitems` WRITE, `shop` WRITE, `caveparties` WRITE');

View File

@ -11,56 +11,59 @@ $tm = time();
##########
$zayavka = db::c()->query('SELECT `id`,`start`,`level`,`t1c`,`team1`,`t2c`,`team2` FROM `zayavka`')->fetch_assoc();
while($zayavka) {
if($zayavka['start'] <= time()) {
if($zayavka['level'] == 4 || (($zayavka['t1c'] == count($zayavka['team1'])) && ($zayavka['t2c'] == count($zayavka['team2'])))) {
while ($zayavka) {
if ($zayavka['start'] <= time()) {
if ($zayavka['level'] == 4 || (($zayavka['t1c'] == count($zayavka['team1'])) && ($zayavka['t2c'] == count($zayavka['team2'])))) {
startbattle("CHAOS", $zayavka['id'], 4);
} elseif($zayavka['level'] == 5) {
} elseif ($zayavka['level'] == 5) {
startbattle("CHAOS", $zayavka['id'], 5);
}
}
}
function delzayavka($id, $zay, $r, $f = 1) {
function delzayavka($id, $zay, $r, $f = 1)
{
$z = getlist($r, null, $zay);
if($f != 1) {
if($z[$zay]['level'] > 3) {
if ($f != 1) {
if ($z[$zay]['level'] > 3) {
return 'Ай-ай-ай!';
}
}
if(mysql_query("DELETE FROM `zayavka` WHERE `id` = {$zay} AND (`team1` LIKE '{$id};%' OR `team2` LIKE '{$id};%') LIMIT 1")) {
if(count($z[$zay]['team1']) > 0) {
foreach($z[$zay]['team1'] as $k => $v) {
if (mysql_query("DELETE FROM `zayavka` WHERE `id` = {$zay} AND (`team1` LIKE '{$id};%' OR `team2` LIKE '{$id};%') LIMIT 1")) {
if (count($z[$zay]['team1']) > 0) {
foreach ($z[$zay]['team1'] as $k => $v) {
mysql_query("UPDATE `users` SET `zayavka` = 0 WHERE `id` = {$v}");
}
}
if(count($z[$zay]['team2']) > 0) {
foreach($z[$zay]['team2'] as $k => $v) {
if (count($z[$zay]['team2']) > 0) {
foreach ($z[$zay]['team2'] as $k => $v) {
mysql_query("UPDATE `users` SET `zayavka` = 0 WHERE `id` = {$v}");
}
}
}
}
function fteam($team) {
function fteam($team)
{
$team = explode(";", $team);
unset($team[count($team)-1]);
unset($team[count($team) - 1]);
return $team;
}
function getlist($razdel = 1, $level = null, $id = null ) {
$fict = mysql_query("SELECT * FROM `zayavka` WHERE ".(($level != null)? " ((`t1min` <= '{$level}' OR `t1min` = '99') AND (`t1max` >= '{$level}' OR `t1max` = '99') ".(($razdel == 4)?"AND (`t2min` <= '{$level}' OR `t2min` = '99') AND (`t2max` >= '{$level}' OR `t2max` = '99')":"").") AND " : "")." `level` = {$razdel} ".(($id != null)? " AND `id` = {$id} " : "")." ORDER BY `podan` DESC");
while($row = mysql_fetch_array($fict)) {
if(($row['start']+300) < time()) {
if(mysql_query("DELETE FROM `zayavka` WHERE `id` = '{$row['id']}' LIMIT 1")) {
function getlist($razdel = 1, $level = null, $id = null)
{
$fict = mysql_query("SELECT * FROM `zayavka` WHERE " . (($level != null) ? " ((`t1min` <= '{$level}' OR `t1min` = '99') AND (`t1max` >= '{$level}' OR `t1max` = '99') " . (($razdel == 4) ? "AND (`t2min` <= '{$level}' OR `t2min` = '99') AND (`t2max` >= '{$level}' OR `t2max` = '99')" : "") . ") AND " : "") . " `level` = {$razdel} " . (($id != null) ? " AND `id` = {$id} " : "") . " ORDER BY `podan` DESC");
while ($row = mysql_fetch_array($fict)) {
if (($row['start'] + 300) < time()) {
if (mysql_query("DELETE FROM `zayavka` WHERE `id` = '{$row['id']}' LIMIT 1")) {
$team1 = fteam($row['team1']);
foreach($team1 as $k => $v) {
foreach ($team1 as $k => $v) {
mysql_query("UPDATE `users` SET `zayavka` = '0' WHERE `id` = {$v}");
}
$team2 = fteam($row['team2']);
foreach($z[$zay]['team2'] as $k => $v) {
foreach ($z[$zay]['team2'] as $k => $v) {
mysql_query("UPDATE `users` SET `zayavka` = '0' WHERE `id` = {$v}");
}
}
@ -70,18 +73,21 @@ function getlist($razdel = 1, $level = null, $id = null ) {
return $zayavka;
}
function startbattle($id, $zay, $r) {
function startbattle($id, $zay, $r)
{
$z = getlist($r, null, $zay);
if($id == 'CHAOS') { $id = $z[$zay]['team1'][0]; }
if ($id == 'CHAOS') {
$id = $z[$zay]['team1'][0];
}
delzayavka($id, $zay, $r);
$z = $z[$zay];
$count_users = count($z['team1']);
$bot = 0;
if($z['bots'] > 0 && $count_users > 0) {
if ($z['bots'] > 0 && $count_users > 0) {
$bots_raw = array(7 => array(10962, 10964, 10965), 8 => array(10962, 10964, 10965), 13 => array(10962, 10964, 10965));
$i = 0;
while($i <= count($bots_raw[$z['bots']])) {
while ($i <= count($bots_raw[$z['bots']])) {
$bot_id = $bots_raw[$z['bots']][$i];
$bot = createbot($bot_id, '');
$z['team1'][] = $bot['id'];
@ -90,37 +96,150 @@ function startbattle($id, $zay, $r) {
}
}
if($z['type'] == 4 || $z['type'] == 5) {
foreach($z['team1'] as $k => $v) {
function upd_vip($u, $type)
{
$abli = mysql_fetch_array(mysql_query('SELECT `id`, `uid`, `sokr`, `zash`, `invisible`, `attack`, `bloodattack`, `sleep30`, `travmoff`, `dontattack`, `unsleep`, `pers_attack` FROM `abils_vip` WHERE `uid` = "' . $u . '" LIMIT 1'));
if ($type == 1) {
$abli['attack'] += 1;
$abli['bloodattack'] += 1;
if ($abli['attack'] > 10) {
$abli['attack'] = 10;
}
if ($abli['bloodattack'] > 10) {
$abli['bloodattack'] = 10;
}
mysql_query('UPDATE `abils_vip` SET `sokr` = 1, `zash` = 1, `attack` = "' . $abli['attack'] . '", `bloodattack` = "' . $abli['bloodattack'] . '" WHERE `id` = "' . $abli['id'] . '" LIMIT 1');
echo mysql_error();
} elseif ($type == 2) {
$abli['attack'] += 1;
$abli['bloodattack'] += 1;
$abli['travmoff'] += 1;
if ($abli['attack'] > 10) {
$abli['attack'] = 10;
}
if ($abli['bloodattack'] > 10) {
$abli['bloodattack'] = 10;
}
if ($abli['travmoff'] > 10) {
$abli['travmoff'] = 10;
}
mysql_query('UPDATE `abils_vip` SET `sokr` = 1, `zash` = 1, `attack` = "' . $abli['attack'] . ', `bloodattack` = "' . $abli['bloodattack'] . '", `travmoff` = "' . $abli['travmoff'] . '" WHERE `id` = "' . $abli['id'] . '" LIMIT 1');
} elseif ($type == 3) {
$abli['attack'] += 1;
$abli['bloodattack'] += 1;
$abli['travmoff'] += 1;
if ($abli['attack'] > 10) {
$abli['attack'] = 10;
}
if ($abli['bloodattack'] > 10) {
$abli['bloodattack'] = 10;
}
if ($abli['travmoff'] > 10) {
$abli['travmoff'] = 10;
}
mysql_query('UPDATE `abils_vip` SET `sokr` = 1, `zash` = 1, `attack` = "' . $abli['attack'] . ', `bloodattack` = "' . $abli['bloodattack'] . '", `travmoff` = "' . $abli['travmoff'] . '" WHERE `id` = "' . $abli['id'] . '" LIMIT 1');
}
}
function remove_vip($uid)
{
mysql_query('UPDATE `users` SET `vip` = "0", `vip_time` = "0" WHERE `id` = "' . $uid . '" LIMIT 1');
$abil = mysql_fetch_array(mysql_query('SELECT `id`, `uid`, `sokr`, `zash`, `invisible`, `attack`, `bloodattack`, `sleep30`, `travmoff`, `daontattack`, `unsleep`, `pers_attack` FROM `abils_vip` WHERE `uid` = "' . $uid . '" LIMIT 1'));
if (isset($abil['id'])) {
mysql_query('UPDATE `abils_vip` SET `sokr` = 0, `zash` = 0, `invisible` = 0, `attack` = 0, `bloodattack` = 0, `sleep30` = 0, `travmoff` = 0, `daontattack` = 0, `unsleep` = 0, `pers_attack` = 0 WHERE `id` = "' . $abil['id'] . '" LIMIT 1');
}
return true;
}
if ($z['type'] == 4 || $z['type'] == 5) {
foreach ($z['team1'] as $k => $v) {
undressall($v);
}
foreach($z['team2'] as $k => $v) {
foreach ($z['team2'] as $k => $v) {
undressall($v);
}
}
if($z['type'] == 3 || $z['type'] == 5) {
if($count_users < 4) {
mysql_query("UPDATE `users` SET `zayavka` = '0' WHERE `zayavka` = '".$zay."'");
foreach($z['team1'] as $k => $v) {
if($v < _BOTSEPARATOR_) {
file_get_contents('http://capitalcity.old-dark.ru/chats.php?id=6&user='.$v);
function enter_bs($u)
{
$pers = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "' . $u . '" LIMIT 1'));
undressall($pers['id']);
###
mysql_query('UPDATE `inventory` SET `owner` = "' . ($pers['id'] + _BOTSEPARATOR_) . '" WHERE `owner` = "' . $pers['id'] . '"');
###
###
$efs = mysql_query('SELECT * FROM `effects` WHERE `owner` = "' . $pers['id'] . '"');
$travm = array(11, 12, 13, 14);
while ($row = mysql_fetch_array($efs)) {
if (in_array($row['type'], $travm)) {
$pers['sila'] += $row['sila'];
$pers['lovk'] += $row['lovk'];
$pers['inta'] += $row['inta'];
$pers['vinos'] += $row['vinos'];
} else {
$pers['sila'] -= $row['sila'];
$pers['lovk'] -= $row['lovk'];
$pers['inta'] -= $row['inta'];
$pers['vinos'] -= $row['vinos'];
$pers['maxhp'] -= $row['hp'];
}
$row['owner'] = ($user['id'] + _BOTSEPARATOR_);
mysql_query('UPDATE `effects` SET `owner` = "' . $row['owner'] . '" WHERE `id` = "' . $row['id'] . '" LIMIT 1');
mysql_query('UPDATE `users` SET `sila` = "' . $pers['sila'] . '", `lovk` = "' . $pers['lovk'] . '", `inta` = "' . $pers['inta'] . '", `vinos` = "' . $pers['vinos'] . '", `maxhp` = "' . $pers['maxhp'] . '" WHERE `id` = "' . $pers['id'] . '" LIMIT 1');
}
$udata = mysql_fetch_array(mysql_query('SELECT * FROM `deztow_realchars` WHERE `owner` = "' . $pers['id'] . '" LIMIT 1'));
if (isset($udata['id'])) {
$udata['sila'] = $pers['sila'];
$udata['lovk'] = $pers['lovk'];
$udata['inta'] = $pers['inta'];
$udata['vinos'] = $pers['vinos'];
$udata['maxhp'] = $pers['maxhp'];
$udata['money'] = $pers['money'];
$udata['level'] = $pers['level'];
$udata['exp'] = $pers['exp'];
$udata['nextup'] = $pers['nextup'];
$udata['align'] = $pers['align'];
$udata['stats'] = $pers['stats'];
$udata['master'] = $pers['master'];
$udata['intel'] = $pers['intel'];
$udata['noj'] = $pers['noj'];
$udata['mec'] = $pers['mec'];
$udata['topor'] = $pers['topor'];
$udata['dubina'] = $pers['dubina'];
$udata['mlight'] = $pers['mlight'];
$udata['mgray'] = $pers['mgray'];
$udata['mdark'] = $pers['mdark'];
mysql_query('UPDATE `deztow_realchars` SET `sila` = "' . $udata['sila'] . '", `lovk` = "' . $udata['lovk'] . '", `inta` = "' . $udata['inta'] . '", `vinos` = "' . $udata['vinos'] . '", `maxhp` = "' . $udata['maxhp'] . '", `money` = "' . $udata['money'] . '", `intel` = "' . $udata['intel'] . '", `level` = "' . $udata['level'] . '", `exp` = "' . $udata['exp'] . '", `nextup` = "' . $udata['nextup'] . '", `align` = "' . $udata['align'] . '", `stats` = "' . $udata['stats'] . '", `master` = "' . $udata['master'] . '", `noj` = "' . $udata['noj'] . '", `mec` = "' . $udata['mec'] . '", `topor` = "' . $udata['topor'] . '", `dubina` = "' . $udata['dubina'] . '", `mlight` = "' . $udata['mlight'] . '", `mgray` = "' . $udata['mgray'] . '", `mdark` = "' . $udata['mdark'] . '" WHERE `owner` = "' . $udata['id'] . '" LIMIT 1');
} else {
mysql_query('INSERT INTO `deztow_realchars` (`owner`, `sila`, `lovk`, `inta`, `vinos`, `maxhp`, `intel`, `level`, `money`, `exp`, `nextup`, `align`, `stats`, `master`, `noj`, `mec`, `topor`, `dubina`, `mlight`, `mgray`, `mdark`) VALUES ("' . $pers['id'] . '", "' . $pers['sila'] . '", "' . $pers['lovk'] . '", "' . $pers['inta'] . '", "' . $pers['vinos'] . '", "' . $pers['maxhp'] . '", "' . $pers['intel'] . '", "' . $pers['level'] . '", "' . $pers['money'] . '", "' . $pers['exp'] . '", "' . $pers['nextup'] . '", "' . $pers['align'] . '", "' . $pers['stats'] . '", "' . $pers['master'] . '", "' . $pers['noj'] . '", "' . $pers['mec'] . '", "' . $pers['topor'] . '", "' . $pers['dubina'] . '", "' . $pers['mlight'] . '", "' . $pers['mgray'] . '", "' . $pers['mdark'] . '")');
}
}
if ($z['type'] == 3 || $z['type'] == 5) {
if ($count_users < 4) {
mysql_query("UPDATE `users` SET `zayavka` = '0' WHERE `zayavka` = '" . $zay . "'");
foreach ($z['team1'] as $k => $v) {
if ($v < _BOTSEPARATOR_) {
file_get_contents('http://capitalcity.old-dark.ru/chats.php?id=6&user=' . $v);
}
}
mysql_query("UPDATE `variables` SET `value` = '{$count_users}}' WHERE `var` = 'haos_match' LIMIT 1");
mysql_query("DELETE FROM `zayavka` WHERE `id` = '".$zay."' LIMIT 1");
mysql_query("DELETE FROM `zayavka` WHERE `id` = '" . $zay . "' LIMIT 1");
}
$all = count($z['team1'])-1;
$power1 = 0; $power2 = 0;
$all = count($z['team1']) - 1;
$power1 = 0;
$power2 = 0;
for($i = 0; $i <= $all; $i++) {
if($z['team1'][$i] < _BOTSEPARATOR_) {
$gamer = mysql_fetch_array(mysql_query("SELECT (`level`*50)+`sila`+`lovk`+`inta`+`vinos`+`intel`+`stats`+IFNULL((SELECT SUM(`cost`) FROM `inventory` WHERE `owner` = `users`.`id` AND `dressed` = 1), 0) FROM `users` WHERE `id` = '".$z['team1'][$i]."' LIMIT 1"));
for ($i = 0; $i <= $all; $i++) {
if ($z['team1'][$i] < _BOTSEPARATOR_) {
$gamer = mysql_fetch_array(mysql_query("SELECT (`level`*50)+`sila`+`lovk`+`inta`+`vinos`+`intel`+`stats`+IFNULL((SELECT SUM(`cost`) FROM `inventory` WHERE `owner` = `users`.`id` AND `dressed` = 1), 0) FROM `users` WHERE `id` = '" . $z['team1'][$i] . "' LIMIT 1"));
} else {
$bt = mysql_fetch_array(mysql_query('SELECT `id`, `prototype` FROM `bots` WHERE `id` = "'.$z['team1'][$i].'"'));
$gamer = mysql_fetch_array(mysql_query("SELECT (`level`*50)+`sila`+`lovk`+`inta`+`vinos`+`intel`+`stats`+IFNULL((SELECT SUM(`cost`) FROM `inventory` WHERE `owner` = `users`.`id` AND `dressed` = 1), 0) FROM `users` WHERE `id` = '".$bt['prototype']."' LIMIT 1"));
$bt = mysql_fetch_array(mysql_query('SELECT `id`, `prototype` FROM `bots` WHERE `id` = "' . $z['team1'][$i] . '"'));
$gamer = mysql_fetch_array(mysql_query("SELECT (`level`*50)+`sila`+`lovk`+`inta`+`vinos`+`intel`+`stats`+IFNULL((SELECT SUM(`cost`) FROM `inventory` WHERE `owner` = `users`.`id` AND `dressed` = 1), 0) FROM `users` WHERE `id` = '" . $bt['prototype'] . "' LIMIT 1"));
}
$cost[] = array($z['team1'][$i], $gamer[0]);
@ -130,20 +249,20 @@ function startbattle($id, $zay, $r) {
$z['team2'] = null;
$flag = true;
while($flag) {
while ($flag) {
$flag = false;
for($ii = 0; $ii <= $all-1; $ii++) {
if($cost[$ii][1] < $cost[$ii+1][1]) {
$ctr = $cost[$ii+1];
$cost[$ii+1] = $cost[$ii];
for ($ii = 0; $ii <= $all - 1; $ii++) {
if ($cost[$ii][1] < $cost[$ii + 1][1]) {
$ctr = $cost[$ii + 1];
$cost[$ii + 1] = $cost[$ii];
$cost[$ii] = $ctr;
$flag = true;
}
}
}
while(count($cost) > 0) {
if($power1 <= $power2) {
while (count($cost) > 0) {
if ($power1 <= $power2) {
$tmp = array_shift($cost);
$power1 += $tmp[1];
$z['team1'][] = $tmp[0];
@ -157,90 +276,97 @@ function startbattle($id, $zay, $r) {
$teams = array();
foreach($z['team1'] as $k => $v) {
foreach($z['team2'] as $kk => $vv) {
foreach ($z['team1'] as $k => $v) {
foreach ($z['team2'] as $kk => $vv) {
$teams[$v][$vv] = array(0, 0, time());
}
}
foreach($z['team2'] as $k => $v) {
foreach($z['team1'] as $kk => $vv) {
foreach ($z['team2'] as $k => $v) {
foreach ($z['team1'] as $kk => $vv) {
$teams[$v][$vv] = array(0, 0, time());
}
}
if(count($z['team2']) == 0) {
mysql_query("UPDATE `users` SET `zayavka` = 0 WHERE `zayavka` = '".$zay."'");
foreach($z['team1'] as $k => $v) {
file_get_contents('http://capitalcity.old-dark.ru/chats.php?id=6&user='.$v);
if (count($z['team2']) == 0) {
mysql_query("UPDATE `users` SET `zayavka` = 0 WHERE `zayavka` = '" . $zay . "'");
foreach ($z['team1'] as $k => $v) {
file_get_contents('http://capitalcity.old-dark.ru/chats.php?id=6&user=' . $v);
}
mysql_query("DELETE FROM `zayavka` WHERE `id` = '".$zay."' LIMIT 1");
mysql_query("DELETE FROM `zayavka` WHERE `id` = '" . $zay . "' LIMIT 1");
die();
}
$arr = array(3, 4, 5, 7, 10);
if(in_array($z['timeout'], $arr)) {
if (in_array($z['timeout'], $arr)) {
} else {
$z['timeout'] = 3;
}
if($z['type'] == 1 || $z['type'] == 4) {
$rs = ', `fiz`'; $rss = ', 1';
if ($z['type'] == 1 || $z['type'] == 4) {
$rs = ', `fiz`';
$rss = ', 1';
} else {
$rs = ''; $rss = '';
$rs = '';
$rss = '';
}
mysql_query("INSERT INTO `battle` (`coment`, `teams`, `timeout`, `type`, `status`, `t1`, `t2`, `to1`, `to2`, `blood`$rs, `bots`) VALUES ('{$z['coment']}', '".serialize($teams)."', '{$z['timeout']}', '{$z['type']}', '0', '".implode(";", $z['team1'])."', '".implode(";", $z['team2'])."', '".time()."', '".time()."', '".$z['blood']."'$rss, '".$z['bots']."')");
mysql_query("INSERT INTO `battle` (`coment`, `teams`, `timeout`, `type`, `status`, `t1`, `t2`, `to1`, `to2`, `blood`$rs, `bots`) VALUES ('{$z['coment']}', '" . serialize($teams) . "', '{$z['timeout']}', '{$z['type']}', '0', '" . implode(";", $z['team1']) . "', '" . implode(";", $z['team2']) . "', '" . time() . "', '" . time() . "', '" . $z['blood'] . "'$rss, '" . $z['bots'] . "')");
$id = mysql_insert_id();
$rr = "<b>";
foreach($z['team1'] as $k => $v) {
if($k != 0) { $rr .= ", "; }
foreach ($z['team1'] as $k => $v) {
if ($k != 0) {
$rr .= ", ";
}
$rr .= nick::id($v)->full(1);
file_get_contents(GAMEDOMAIN.'/chats.php?id=7&user='.$v);
file_get_contents(GAMEDOMAIN . '/chats.php?id=7&user=' . $v);
}
$rr .= "</b> и <b>";
foreach($z['team2'] as $k => $v) {
if($k != 0) { $rr .= ", "; }
foreach ($z['team2'] as $k => $v) {
if ($k != 0) {
$rr .= ", ";
}
$rr .= nick::id($v)->full(1);
file_get_contents(GAMEDOMAIN.'/chats.php?id=7&user='.$v);
file_get_contents(GAMEDOMAIN . '/chats.php?id=7&user=' . $v);
}
$rr .= "</b>";
addlog($id, "Часы показывали <span class=date>".date("Y.m.d H.i")."</span>, когда ".$rr." бросили вызов друг другу.<BR>");
addlog($id, "Часы показывали <span class=date>" . date("Y.m.d H.i") . "</span>, когда " . $rr . " бросили вызов друг другу.<BR>");
foreach($z['team1'] as $k => $v) {
if($v < _BOTSEPARATOR_) {
foreach ($z['team1'] as $k => $v) {
if ($v < _BOTSEPARATOR_) {
mysql_query("UPDATE `users` SET `battle` = {$id}, `zayavka` = 0 WHERE `id` = {$v}");
} else {
mysql_query("UPDATE `bots` SET `battle` = {$id} WHERE `id` = {$v}");
}
}
foreach($z['team2'] as $k => $v) {
if($v < _BOTSEPARATOR_) {
foreach ($z['team2'] as $k => $v) {
if ($v < _BOTSEPARATOR_) {
mysql_query("UPDATE `users` SET `battle` = {$id}, `zayavka` = 0 WHERE `id` = {$v}");
} else {
mysql_query("UPDATE `bots` SET `battle` = {$id} WHERE `id` = {$v}");
}
}
}
##########
########Start Заявки для ботов в хаоты########
$battle_bots = mysql_fetch_array(mysql_query('SELECT `id` FROM `battle` WHERE `win` = 3 AND `bots` > 0 ORDER BY `id` DESC LIMIT 1'));
$zay_bots = mysql_fetch_array(mysql_query('SELECT `id` FROM `zayavka` WHERE `bots` > 0 ORDER BY `id` DESC LIMIT 1'));
if(!isset($battle_bots['id']) && !isset($zay_bots['id'])) {
if (!isset($battle_bots['id']) && !isset($zay_bots['id'])) {
$haos_match = array();
$hm_ok = array(7 => 1);
foreach($hm_ok as $lvl => $flag) {
if($flag == 1) {
mysql_query("INSERT INTO `zayavka` (`start`, `timeout`, `t1c`, `t2c`, `type`, `level`, `coment`, `team1`, `stavka`, `t1min`, `t2min`, `t1max`, `t2max`, `podan`, `blood`, `bots`) VALUES ('".(time()+3*60)."', '3', '99', '99', '3', '5', '<u>Бой с силами Хаоса <b>{$lvl}</b> уровня.</u>', '', '', '{$lvl}', '{$lvl}', '{$lvl}', '{$lvl}', '".date("H:i")."', '0', '{$lvl}')");
foreach ($hm_ok as $lvl => $flag) {
if ($flag == 1) {
mysql_query("INSERT INTO `zayavka` (`start`, `timeout`, `t1c`, `t2c`, `type`, `level`, `coment`, `team1`, `stavka`, `t1min`, `t2min`, `t1max`, `t2max`, `podan`, `blood`, `bots`) VALUES ('" . (time() + 3 * 60) . "', '3', '99', '99', '3', '5', '<u>Бой с силами Хаоса <b>{$lvl}</b> уровня.</u>', '', '', '{$lvl}', '{$lvl}', '{$lvl}', '{$lvl}', '" . date("H:i") . "', '0', '{$lvl}')");
$haos_match[$lvl] = mysql_insert_id();
}
}
@ -251,86 +377,86 @@ if(!isset($battle_bots['id']) && !isset($zay_bots['id'])) {
######
$te_zay = mysql_query('SELECT `id`, `start` FROM `zayavka`');
while($zs = mysql_fetch_array($te_zay)) {
if(($zs['start']+180) < time()) {
mysql_query('UPDATE `users` SET `zayavka` = "0" WHERE `zayavka` = "'.$zs['id'].'"');
mysql_query('DELETE FROM `zayavka` WHERE `id` = "'.$zs['id'].'"');
while ($zs = mysql_fetch_array($te_zay)) {
if (($zs['start'] + 180) < time()) {
mysql_query('UPDATE `users` SET `zayavka` = "0" WHERE `zayavka` = "' . $zs['id'] . '"');
mysql_query('DELETE FROM `zayavka` WHERE `id` = "' . $zs['id'] . '"');
}
}
######
if(date("H-i") == "03-00") {
$del_tm = (time()-60*60*24*7);
if (date("H-i") == "03-00") {
$del_tm = (time() - 60 * 60 * 24 * 7);
$us_lim = mysql_fetch_array(mysql_query("SELECT `id` FROM `battle` WHERE `to1` < '{$del_tm}' ORDER BY `to1` DESC LIMIT 1"));
$us_lim = $us_lim['id'];
mysql_query("DELETE FROM `battle` WHERE `id` < '{$us_lim}'");
$del_tm = (time()-60*60*24*60);
mysql_query("DELETE FROM `delo` WHERE `date` < '".$del_tm."'");
$del_tm = (time() - 60 * 60 * 24 * 60);
mysql_query("DELETE FROM `delo` WHERE `date` < '" . $del_tm . "'");
mysql_query("OPTIMIZE `battle`, `delo`");
}
if(date("H-i") == "00-00") {
if (date("H-i") == "00-00") {
$perses = mysql_query('SELECT `id`, `vip`, `vip_time` FROM `users` WHERE `vip` > 0 AND `vip_time` > 0');
while($unvip = mysql_fetch_array($perses)) {
if($unvip['vip'] > 0) {
if($unvip['vip_time'] <= time()) {
while ($unvip = mysql_fetch_array($perses)) {
if ($unvip['vip'] > 0) {
if ($unvip['vip_time'] <= time()) {
remove_vip($unvip['id']);
}
}
}
}
$sp = mysql_query('SELECT `id`, `vip`, `vip_time` FROM `users` WHERE `vip` > 0 AND `vip_time` > "'.time().'"');
while($pl = mysql_fetch_array($sp)) {
$sp = mysql_query('SELECT `id`, `vip`, `vip_time` FROM `users` WHERE `vip` > 0 AND `vip_time` > "' . time() . '"');
while ($pl = mysql_fetch_array($sp)) {
upd_vip($pl['id'], $pl['vip']);
}
mysql_query('UPDATE `actions` SET `vals` = "end" WHERE `vars` LIKE "start_quest%" AND `vals` = "go" AND `val` <= "'.time().'"');
mysql_query('UPDATE `actions` SET `vals` = "end" WHERE `vars` LIKE "start_quest%" AND `vals` = "go" AND `val` <= "' . time() . '"');
if(date("H-i") == "06-00") {
if(date("d") == "01") {
if (date("H-i") == "06-00") {
if (date("d") == "01") {
mysql_query("UPDATE `variables` SET `value` = '{$tm}' WHERE `var` = 'ref_month' LIMIT 1");
mysql_query("UPDATE `variables` SET `value` = '0' WHERE `var` = 'ref_m_id' LIMIT 1");
}
if(date("N") == "7") {
if (date("N") == "7") {
mysql_query("UPDATE `variables` SET `value` = '{$tm}' WHERE `var` = 'ref_week' LIMIT 1");
mysql_query("UPDATE `variables` SET `value` = '0' WHERE `var` = 'ref_w_id' LIMIT 1");
}
}
$st_ar = mysql_fetch_array(mysql_query('SELECT `value` FROM `variables` WHERE `var` = "arena_of_gods" LIMIT 1'));
if($st_ar['value'] <= time()) {
if ($st_ar['value'] <= time()) {
$dark = mysql_fetch_array(mysql_query('SELECT `id`, `login`, `level`, `hp` FROM `users` WHERE `id` = 10023 LIMIT 1'));
$light = mysql_fetch_array(mysql_query('SELECT `id`, `login`, `level`, `hp` FROM `users` WHERE `id` = 10024 LIMIT 1'));
##############
mysql_query("INSERT INTO `bots` (`name`, `prototype`, `battle`, `hp`, `owner`) VALUES ('".$light['login']."', '".$light['id']."', '', '".$light['hp']."', '1')");
mysql_query("INSERT INTO `bots` (`name`, `prototype`, `battle`, `hp`, `owner`) VALUES ('" . $light['login'] . "', '" . $light['id'] . "', '', '" . $light['hp'] . "', '1')");
$light['id_at'] = mysql_insert_id();
mysql_query("INSERT INTO `bots` (`name`, `prototype`, `battle`, `hp`) VALUES ('".$dark['login']."', '".$dark['id']."', '', '".$dark['hp']."')");
mysql_query("INSERT INTO `bots` (`name`, `prototype`, `battle`, `hp`) VALUES ('" . $dark['login'] . "', '" . $dark['id'] . "', '', '" . $dark['hp'] . "')");
$dark['id_at'] = mysql_insert_id();
##############
$teams = array();
$teams[$dark['id_at']][$light['id_at']] = array(0, 0, time());
$teams[$light['id_at']][$dark['id_at']] = array(0, 0, time());
mysql_query("INSERT INTO `battle` (`id`, `coment`, `teams`, `time_m`, `timeout`, `type`, `status`, `t1`, `t2`, `to1`, `to2`, `blood`, `aren_of`) VALUES (NULL, '', '".serialize($teams)."', '".time()."', '3', '1', '0', '".$dark['id_at']."', '".$light['id_at']."', '".time()."', '".time()."', '1', '1')");
mysql_query("INSERT INTO `battle` (`id`, `coment`, `teams`, `time_m`, `timeout`, `type`, `status`, `t1`, `t2`, `to1`, `to2`, `blood`, `aren_of`) VALUES (NULL, '', '" . serialize($teams) . "', '" . time() . "', '3', '1', '0', '" . $dark['id_at'] . "', '" . $light['id_at'] . "', '" . time() . "', '" . time() . "', '1', '1')");
$id = mysql_insert_id();
mysql_query("UPDATE `bots` SET `battle` = {$id} WHERE (`id` = {$dark['id_at']} OR `id` = {$light['id_at']}) LIMIT 2");
$rr = "<b>".nick::id($dark['id_at'])->full(1)."</b> и <b>".nick::id($light['id_at'])->full(1)."</b>";
addlog($id, "Часы показывали <span class=date>".date("Y.m.d H.i")."</span>, когда ".$rr." бросили вызов друг другу. <br />");
$rr = "<b>" . nick::id($dark['id_at'])->full(1) . "</b> и <b>" . nick::id($light['id_at'])->full(1) . "</b>";
addlog($id, "Часы показывали <span class=date>" . date("Y.m.d H.i") . "</span>, когда " . $rr . " бросили вызов друг другу. <br />");
mysql_query("UPDATE `users` SET `battle` = {$id}, `zayavka` = 0 WHERE (`id` = {$dark['id']} OR `id` = {$light['id']}) LIMIT 2");
file_get_contents('http://capitalcity.old-dark.ru/chats.php?id=2');
mysql_query('UPDATE `variables` SET `value` = "'.(time()+60*60*24*7).'" WHERE `var` = "arena_of_gods" LIMIT 1');
mysql_query('UPDATE `variables` SET `value` = "' . (time() + 60 * 60 * 24 * 7) . '" WHERE `var` = "arena_of_gods" LIMIT 1');
}
$st_ar['value'] -= 3600;
if(date("z-H-i") == date("z-H-i", $st_ar['value'])) {
if (date("z-H-i") == date("z-H-i", $st_ar['value'])) {
file_get_contents('http://capitalcity.old-dark.ru/chats.php?id=3');
}
$komp_users = mysql_query("SELECT * FROM `users`, `online` WHERE `users`.`id` = `online`.`id` AND `online`.`date` >= ".(time()-60)."");
while($ku = mysql_fetch_array($komp_users)) {
$komp_users = mysql_query("SELECT * FROM `users`, `online` WHERE `users`.`id` = `online`.`id` AND `online`.`date` >= " . (time() - 60) . "");
while ($ku = mysql_fetch_array($komp_users)) {
$bns = 0;
$efs_bns = mysql_fetch_array(mysql_query('SELECT SUM(`hp`) AS `hps` FROM `effects` WHERE `owner` = "'.$ku['id'].'"'));
if($efs_bns['hps'] > 0) {
$efs_bns = mysql_fetch_array(mysql_query('SELECT SUM(`hp`) AS `hps` FROM `effects` WHERE `owner` = "' . $ku['id'] . '"'));
if ($efs_bns['hps'] > 0) {
$bns = $efs_bns['hps'];
}
mysql_query("UPDATE `users` SET `maxhp` = (IFNULL((SELECT SUM(`ghp`) FROM `inventory` WHERE `dressed` = 1 AND `owner` = `users`.`id`),0) + (`users`.`vinos`*6)+$bns) WHERE `id` = '{$ku['id']}'");
@ -339,52 +465,52 @@ while($ku = mysql_fetch_array($komp_users)) {
mysql_query("UPDATE `users` SET `hp` = 0 WHERE `hp` < 0");
mysql_query("UPDATE `users` SET `mana` = 0 WHERE `mana` < 0");
$its = mysql_query("SELECT `id`, `owner`, `name` FROM `inventory` WHERE `dressed` = 0 AND ((`maxdur` <= `duration`) OR (`dategoden` > 0 AND `dategoden` <= '".time()."'))");
while($it = mysql_fetch_array($its)) {
mysql_query("DELETE FROM `inventory` WHERE `id` = '".$it['id']."' LIMIT 1;");
mysql_query("INSERT INTO `delo` (`author`, `pers`, `text`, `type`, `date`) VALUES ('0', '".$it['owner']."' '\"".$it['name']."\" разрушился id:(cap".$it['id'].").', 1, '".time()."')");
$its = mysql_query("SELECT `id`, `owner`, `name` FROM `inventory` WHERE `dressed` = 0 AND ((`maxdur` <= `duration`) OR (`dategoden` > 0 AND `dategoden` <= '" . time() . "'))");
while ($it = mysql_fetch_array($its)) {
mysql_query("DELETE FROM `inventory` WHERE `id` = '" . $it['id'] . "' LIMIT 1;");
mysql_query("INSERT INTO `delo` (`author`, `pers`, `text`, `type`, `date`) VALUES ('0', '" . $it['owner'] . "' '\"" . $it['name'] . "\" разрушился id:(cap" . $it['id'] . ").', 1, '" . time() . "')");
}
$effs = mysql_query("SELECT * FROM `effects` WHERE `time` <= ".time()." AND `sleep` = 0");
mysql_query("DELETE FROM `effects` WHERE `time` <= ".time()." AND `sleep` = 0");
while($eff = mysql_fetch_array($effs)) {
switch($eff['type']) {
$effs = mysql_query("SELECT * FROM `effects` WHERE `time` <= " . time() . " AND `sleep` = 0");
mysql_query("DELETE FROM `effects` WHERE `time` <= " . time() . " AND `sleep` = 0");
while ($eff = mysql_fetch_array($effs)) {
switch ($eff['type']) {
case 11:
mysql_query("UPDATE `users` SET `sila` = `sila`+'".$eff['sila']."', `lovk` = `lovk`+'".$eff['lovk']."', `inta` = `inta`+'".$eff['inta']."' WHERE `id` = '".$eff['owner']."' LIMIT 1");
mysql_query("UPDATE `users` SET `sila` = `sila`+'" . $eff['sila'] . "', `lovk` = `lovk`+'" . $eff['lovk'] . "', `inta` = `inta`+'" . $eff['inta'] . "' WHERE `id` = '" . $eff['owner'] . "' LIMIT 1");
break;
case 12:
mysql_query("UPDATE `users` SET `sila` = `sila`+'".$eff['sila']."', `lovk` = `lovk`+'".$eff['lovk']."', `inta` = `inta`+'".$eff['inta']."' WHERE `id` = '".$eff['owner']."' LIMIT 1");
mysql_query("UPDATE `users` SET `sila` = `sila`+'" . $eff['sila'] . "', `lovk` = `lovk`+'" . $eff['lovk'] . "', `inta` = `inta`+'" . $eff['inta'] . "' WHERE `id` = '" . $eff['owner'] . "' LIMIT 1");
break;
case 13:
mysql_query("UPDATE `users` SET `sila` = `sila`+'".$eff['sila']."', `lovk` = `lovk`+'".$eff['lovk']."', `inta` = `inta`+'".$eff['inta']."' WHERE `id` = '".$eff['owner']."' LIMIT 1");
mysql_query("UPDATE `users` SET `sila` = `sila`+'" . $eff['sila'] . "', `lovk` = `lovk`+'" . $eff['lovk'] . "', `inta` = `inta`+'" . $eff['inta'] . "' WHERE `id` = '" . $eff['owner'] . "' LIMIT 1");
break;
case 14:
mysql_query("UPDATE `users` SET `sila` = `sila`+'".$eff['sila']."', `lovk` = `lovk`+'".$eff['lovk']."', `inta` = `inta`+'".$eff['inta']."' WHERE `id` = '".$eff['owner']."' LIMIT 1");
mysql_query("UPDATE `users` SET `sila` = `sila`+'" . $eff['sila'] . "', `lovk` = `lovk`+'" . $eff['lovk'] . "', `inta` = `inta`+'" . $eff['inta'] . "' WHERE `id` = '" . $eff['owner'] . "' LIMIT 1");
break;
case 21:
mysql_query("UPDATE `users` SET `sila` = `sila`-'".$eff['sila']."', `lovk` = `lovk`-'".$eff['lovk']."', `inta` = `inta`-'".$eff['inta']."', `vinos` = `vinos`-'".$eff['vinos']."' WHERE `id` = '".$eff['owner']."' LIMIT 1");
mysql_query("UPDATE `users` SET `sila` = `sila`-'" . $eff['sila'] . "', `lovk` = `lovk`-'" . $eff['lovk'] . "', `inta` = `inta`-'" . $eff['inta'] . "', `vinos` = `vinos`-'" . $eff['vinos'] . "' WHERE `id` = '" . $eff['owner'] . "' LIMIT 1");
break;
case 4:
mysql_query("UPDATE `users` SET `align` = '0' WHERE `id` = '".$eff['owner']."' LIMIT 1");
mysql_query("UPDATE `users` SET `align` = '0' WHERE `id` = '" . $eff['owner'] . "' LIMIT 1");
break;
case 7:
mysql_query("UPDATE `users` SET `maxhp` = (`maxhp`-200), `hp` = `maxhp` WHERE `id` = '".$eff['owner']."' LIMIT 1");
mysql_query("UPDATE `users` SET `maxhp` = (`maxhp`-200), `hp` = `maxhp` WHERE `id` = '" . $eff['owner'] . "' LIMIT 1");
break;
case 1022:
mysql_query("UPDATE `users` SET `invis` = 0 WHERE `id` = '".$eff['owner']."' LIMIT 1");
mysql_query("UPDATE `users` SET `invis` = 0 WHERE `id` = '" . $eff['owner'] . "' LIMIT 1");
break;
}
}
$hostel = mysql_query('SELECT `id`, `sleep` FROM `users` WHERE `sleep` != 0');
while($pl = mysql_fetch_array($hostel)) {
if($pl['sleep'] <= time()) {
mysql_query('UPDATE `users` SET `sleep` = 0 WHERE `id` = "'.$pl['id'].'"');
mysql_query('UPDATE `hostel` SET `sleeptime` = "'.(time()+60*60*6).'" WHERE `uid` = "'.$pl['id'].'"');
$ef = mysql_query('SELECT `id`, `time`, `sleep` FROM `effects` WHERE `owner` = "'.$pl['id'].'" AND `sleep` != 0');
while($ps = mysql_fetch_array($ef)) {
$tm = (time()+$ps['sleep']);
mysql_query('UPDATE `effects` SET `time` = "'.$tm.'", `sleep` = "0" WHERE `id` = "'.$ps['id'].'" AND `owner` = "'.$pl['id'].'"');
while ($pl = mysql_fetch_array($hostel)) {
if ($pl['sleep'] <= time()) {
mysql_query('UPDATE `users` SET `sleep` = 0 WHERE `id` = "' . $pl['id'] . '"');
mysql_query('UPDATE `hostel` SET `sleeptime` = "' . (time() + 60 * 60 * 6) . '" WHERE `uid` = "' . $pl['id'] . '"');
$ef = mysql_query('SELECT `id`, `time`, `sleep` FROM `effects` WHERE `owner` = "' . $pl['id'] . '" AND `sleep` != 0');
while ($ps = mysql_fetch_array($ef)) {
$tm = (time() + $ps['sleep']);
mysql_query('UPDATE `effects` SET `time` = "' . $tm . '", `sleep` = "0" WHERE `id` = "' . $ps['id'] . '" AND `owner` = "' . $pl['id'] . '"');
}
}
}
@ -393,51 +519,53 @@ mysql_query('LOCK TABLES `inventory` WRITE, `variables` WRITE, `deztow_turnir` W
$turnirstart = mysql_fetch_array(mysql_query("SELECT `value`, `bs_art` FROM `variables` WHERE `var` = 'startbs' LIMIT 1"));
$turnirstart['value'] -= 900;
if(date("z-H-i") == date("z-H-i", $turnirstart['value']))
if($turnirstart['bs_art'] == 0) {
if (date("z-H-i") == date("z-H-i", $turnirstart['value']))
if ($turnirstart['bs_art'] == 0) {
file_get_contents('http://capitalcity.old-dark.ru/chats.php?id=4');
} elseif($turnirstart['bs_art'] == 1) {
} elseif ($turnirstart['bs_art'] == 1) {
file_get_contents('http://capitalcity.old-dark.ru/chats.php?id=4');
}
$tr = mysql_fetch_array(mysql_query("SELECT `id`, `type`, `winner`, `coin`, `start_time`, `log`, `endtime`, `active`, `winnerlog`, `art` FROM `deztow_turnir` WHERE `active` = TRUE LIMIT 1"));
$turnirstart = mysql_fetch_array(mysql_query("SELECT `value`, `bs_art` FROM `variables` WHERE `var` = 'startbs' LIMIT 1"));
$dd = mysql_fetch_array(mysql_query("SELECT COUNT(`kredit`) FROM `deztow_stavka` WHERE `owner` != 1254"));
$tr = mysql_fetch_array(mysql_query("SELECT `id`, `type`, `winner`, `coin`, `start_time`, `log`, `endtime`, `active`, `winnerlog`, `art` FROM `deztow_turnir` WHERE `active` = TRUE LIMIT 1"));
$turnirstart = mysql_fetch_array(mysql_query("SELECT `value`, `bs_art` FROM `variables` WHERE `var` = 'startbs' LIMIT 1"));
$dd = mysql_fetch_array(mysql_query("SELECT COUNT(`kredit`) FROM `deztow_stavka` WHERE `owner` != 1254"));
if($dd[0] < 2 && $turnirstart[0] <= time()) {
if($turnirstart['bs_art'] == 1) {
if ($dd[0] < 2 && $turnirstart[0] <= time()) {
if ($turnirstart['bs_art'] == 1) {
$bs_art = 0;
} elseif($turnirstart['bs_art'] == 0) {
} elseif ($turnirstart['bs_art'] == 0) {
$bs_art = 0;
}
mysql_query('UPDATE `variables` SET `value` = "'.(time()+60*60).'", `bs_art` = "'.$bs_art.'" WHERE `var` = "startbs" LIMIT 1');
mysql_query("INSERT INTO `deztow_stavka` (`owner`, `kredit`, `time`) VALUES ('1254', '30', '".time()."')");
mysql_query('UPDATE `variables` SET `value` = "' . (time() + 60 * 60) . '", `bs_art` = "' . $bs_art . '" WHERE `var` = "startbs" LIMIT 1');
mysql_query("INSERT INTO `deztow_stavka` (`owner`, `kredit`, `time`) VALUES ('1254', '30', '" . time() . "')");
file_get_contents('http://capitalcity.old-dark.ru/chats.php?id=5');
}
}
if(!$tr && $turnirstart[0] <= time() && $dd[0] >= 2) {
if (!$tr && $turnirstart[0] <= time() && $dd[0] >= 2) {
$minroom = 501;
$maxroom = 560;
$data = mysql_query("SELECT `dt`.`owner` FROM `deztow_stavka` AS `dt`, `online` AS `o` WHERE (SELECT COUNT(`id`) FROM `effects` WHERE `effects`.`owner` = `dt`.`owner` AND (`type` = 11 OR `type` = 12 OR `type` = 13 OR `type` = 14 OR `type` = 2 OR `type` = 3 OR `type` = 4 OR `type` = 202 OR `type` = 201 OR `type` = 21)) = 0 AND `o`.`id` = `dt`.`owner` AND `room` = 31 AND `o`.`date` >= '".(time()-300)."' ORDER BY `kredit` DESC, `dt`.`time` ASC LIMIT 50");
$data = mysql_query("SELECT `dt`.`owner` FROM `deztow_stavka` AS `dt`, `online` AS `o` WHERE (SELECT COUNT(`id`) FROM `effects` WHERE `effects`.`owner` = `dt`.`owner` AND (`type` = 11 OR `type` = 12 OR `type` = 13 OR `type` = 14 OR `type` = 2 OR `type` = 3 OR `type` = 4 OR `type` = 202 OR `type` = 201 OR `type` = 21)) = 0 AND `o`.`id` = `dt`.`owner` AND `room` = 31 AND `o`.`date` >= '" . (time() - 300) . "' ORDER BY `kredit` DESC, `dt`.`time` ASC LIMIT 50");
$stavka = mysql_fetch_array(mysql_query("SELECT SUM(`kredit`)*0.7 FROM `deztow_stavka`"));
while($row = mysql_fetch_array($data)) {
while ($row = mysql_fetch_array($data)) {
enter_bs($row[0]);
$tec = mysql_fetch_array(mysql_query("SELECT `id`, `owner`, `name`, `sila`, `lovk`, `inta`, `vinos`, `intel`, `mudra`, `def` FROM `deztow_charstams` WHERE `owner` = '{$row['owner']}' AND `def` = '1' LIMIT 1"));
$usk = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '".$row[0]."' LIMIT 1"));
$usk = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '" . $row[0] . "' LIMIT 1"));
if(isset($tec['id'])) {
mysql_query("UPDATE `users` SET `sila` = '".$tec['sila']."', `lovk` = '".$tec['lovk']."', `inta` = '".$tec['inta']."', `vinos` = '".$tec['vinos']."', `intel` = '".$tec['intel']."', `stats` = 0, `noj` = 0, `mec` = 0, `topor` = 0, `dubina` = 0, `mfire` = 0, `mwater` = 0, `mair` = 0, `mearth` = 0, `mlight` = 0, `mgray` = 0, `mdark` = 0, `master` = '8', `maxhp` = '".($tec['vinos']*6)."', `hp` = '".($tec['vinos']*6)."', `level` = 7, `nextup` = 999999999 WHERE `id` = '".$usk['id']."' LIMIT 1");
if (isset($tec['id'])) {
mysql_query("UPDATE `users` SET `sila` = '" . $tec['sila'] . "', `lovk` = '" . $tec['lovk'] . "', `inta` = '" . $tec['inta'] . "', `vinos` = '" . $tec['vinos'] . "', `intel` = '" . $tec['intel'] . "', `stats` = 0, `noj` = 0, `mec` = 0, `topor` = 0, `dubina` = 0, `mfire` = 0, `mwater` = 0, `mair` = 0, `mearth` = 0, `mlight` = 0, `mgray` = 0, `mdark` = 0, `master` = '8', `maxhp` = '" . ($tec['vinos'] * 6) . "', `hp` = '" . ($tec['vinos'] * 6) . "', `level` = 7, `nextup` = 999999999 WHERE `id` = '" . $usk['id'] . "' LIMIT 1");
} else {
mysql_query("UPDATE `users` SET `sila` = '3', `lovk` = '3', `inta` = '3', `vinos` = '10', `intel` = '0', `stats` = 64, `noj` = 0, `mec` = 0, `topor` = 0, `dubina` = 0, `mfire` = 0, `mwater` = 0, `mair` = 0, `mearth` = 0, `mlight` = 0, `mgray` = 0, `mdark` = 0, `master` = '8', `maxhp` = '60', `hp` = '60', `level` = 7, `nextup` = 999999999 WHERE `id` = '".$usk['id']."' LIMIT 1");
mysql_query("UPDATE `users` SET `sila` = '3', `lovk` = '3', `inta` = '3', `vinos` = '10', `intel` = '0', `stats` = 64, `noj` = 0, `mec` = 0, `topor` = 0, `dubina` = 0, `mfire` = 0, `mwater` = 0, `mair` = 0, `mearth` = 0, `mlight` = 0, `mgray` = 0, `mdark` = 0, `master` = '8', `maxhp` = '60', `hp` = '60', `level` = 7, `nextup` = 999999999 WHERE `id` = '" . $usk['id'] . "' LIMIT 1");
}
$rum = rand($minroom, $maxroom);
$urs[$row['owner']] = $rum;
$i++;
if($i > 1) { $lors .= ", "; }
if ($i > 1) {
$lors .= ", ";
}
$lors .= nick::id($row['owner'])->full(1);
}
@ -449,88 +577,88 @@ if(date("z-H-i") == date("z-H-i", $turnirstart['value']))
mysql_query("DELETE FROM `inventory` WHERE `owner` = 234");
mysql_query("DELETE FROM `inventory` WHERE `owner` = 235");
$rums = rand($minroom, $maxroom);
mysql_query("UPDATE `users` SET `in_tower` = 1, `chattime` = '999999999999', `room` = '".$rums."' WHERE `id` = '233' LIMIT 1");
mysql_query("UPDATE `users` SET `in_tower` = 1, `chattime` = '999999999999', `room` = '".$rums."' WHERE `id` = '234' LIMIT 1");
mysql_query("UPDATE `users` SET `in_tower` = 1, `chattime` = '999999999999', `room` = '".$rums."' WHERE `id` = '235' LIMIT 1");
mysql_query("UPDATE `online` SET `room` = '".$rums."', `date` = '999999999999' WHERE `id` = '233' LIMIT 1");
mysql_query("UPDATE `online` SET `room` = '".$rums."', `date` = '999999999999' WHERE `id` = '234' LIMIT 1");
mysql_query("UPDATE `online` SET `room` = '".$rums."', `date` = '999999999999' WHERE `id` = '235' LIMIT 1");
mysql_query("UPDATE `users` SET `in_tower` = 1, `chattime` = '999999999999', `room` = '" . $rums . "' WHERE `id` = '233' LIMIT 1");
mysql_query("UPDATE `users` SET `in_tower` = 1, `chattime` = '999999999999', `room` = '" . $rums . "' WHERE `id` = '234' LIMIT 1");
mysql_query("UPDATE `users` SET `in_tower` = 1, `chattime` = '999999999999', `room` = '" . $rums . "' WHERE `id` = '235' LIMIT 1");
mysql_query("UPDATE `online` SET `room` = '" . $rums . "', `date` = '999999999999' WHERE `id` = '233' LIMIT 1");
mysql_query("UPDATE `online` SET `room` = '" . $rums . "', `date` = '999999999999' WHERE `id` = '234' LIMIT 1");
mysql_query("UPDATE `online` SET `room` = '" . $rums . "', `date` = '999999999999' WHERE `id` = '235' LIMIT 1");
echo mysql_error();
$i++;
$lors .= ", ".nick::id(233)->full(1);
$lors .= ", ".nick::id(234)->full(1);
$lors .= ", ".nick::id(235)->full(1);
$lors .= ", " . nick::id(233)->full(1);
$lors .= ", " . nick::id(234)->full(1);
$lors .= ", " . nick::id(235)->full(1);
$lors .= ltrim(",", $lors);
mysql_query("TRUNCATE TABLE `deztow_items`");
$shmots = array("1", "1", "92", "92", "93", "93", "19", "19", "20", "20", "20", "23", "23", "24", "14", "87", "87", "6", "6", "17", "17", "17", "17", "11", "11", "12", "12", "12", "28", "28", "43", "43", "36", "36", "36", "37", "37", "37", "38", "38", "38", "50", "50", "57", "52", "52", "51", "51", "48", "48", "47", "47", "49", "49", "59", "59", "60", "60", "61", "61", "63", "64", "64", "65", "65", "66", "66", "68", "68", "69", "69", "72", "72", "4", "5", "79", "79", "80", "76", "75", "75", "94", "94", "95", "95", "82", "91", "91", "34", "34", "86", "86", "86", "9", "9", "101", "101", "101", "101", "101", "97", "97", "97", "97", "100", "100", "100", "100", "171", "171", "171", "171", "103", "103", "103", "104", "105", "105", "106", "106", "107", "107", "108", "108", "109", "110", "111", "112", "112", "113", "113", "119", "364", "284", "284", "284", "284", "284", "285", "285", "285", "285", "286", "286", "286", "286");
while($sh = array_shift($shmots)) {
$shopid = mysql_fetch_array(mysql_query("SELECT `id`, `name`, `img` FROM `shop` WHERE `id` = '".$sh."' LIMIT 1"));
if(isset($shopid['id'])) {
mysql_query("INSERT `deztow_items` (`iteam_id`, `name`, `img`, `room`) VALUES ('".$shopid['id']."', '".$shopid['name']."', '".$shopid['img']."', '".rand($minroom, $maxroom)."')");
while ($sh = array_shift($shmots)) {
$shopid = mysql_fetch_array(mysql_query("SELECT `id`, `name`, `img` FROM `shop` WHERE `id` = '" . $sh . "' LIMIT 1"));
if (isset($shopid['id'])) {
mysql_query("INSERT `deztow_items` (`iteam_id`, `name`, `img`, `room`) VALUES ('" . $shopid['id'] . "', '" . $shopid['name'] . "', '" . $shopid['img'] . "', '" . rand($minroom, $maxroom) . "')");
}
}
$log = '<span class=date>'.date("d.m.y H:i").'</span> Начало турнира. Участники : '.$lors.'<br />';
$log = '<span class=date>' . date("d.m.y H:i") . '</span> Начало турнира. Участники : ' . $lors . '<br />';
$end = (time() + 21600);
mysql_query("INSERT `deztow_turnir` (`type`, `winner`, `coin`, `start_time`, `log`, `endtime`, `active`) VALUES ('".rand(1, 7)."', '', '".$stavka[0]."', '".time()."', '".$log."', '".$end."', '1')");
mysql_query("INSERT `deztow_turnir` (`type`, `winner`, `coin`, `start_time`, `log`, `endtime`, `active`) VALUES ('" . rand(1, 7) . "', '', '" . $stavka[0] . "', '" . time() . "', '" . $log . "', '" . $end . "', '1')");
foreach($urs as $row => $rum) {
mysql_query("UPDATE `users` SET `in_tower` = 1, `room` = '".$rum."' WHERE `id` = '".$row."'");
mysql_query("UPDATE `online` SET `room` = '".$rum."' WHERE `id` = '".$row."' LIMIT 1");
}
foreach ($urs as $row => $rum) {
mysql_query("UPDATE `users` SET `in_tower` = 1, `room` = '" . $rum . "' WHERE `id` = '" . $row . "'");
mysql_query("UPDATE `online` SET `room` = '" . $rum . "' WHERE `id` = '" . $row . "' LIMIT 1");
}
}
$tur_data = mysql_fetch_array(mysql_query("SELECT `id`, `type`, `winner`, `coin`, `start_time`, `log`, `endtime`, `active`, `winnerlog`, `art` FROM `deztow_turnir` WHERE `active` = '1' LIMIT 1"));
if($tur_data['endtime'] < time() && $tur_data['id']) {
$tur_data = mysql_fetch_array(mysql_query("SELECT `id`, `type`, `winner`, `coin`, `start_time`, `log`, `endtime`, `active`, `winnerlog`, `art` FROM `deztow_turnir` WHERE `active` = '1' LIMIT 1"));
if ($tur_data['endtime'] < time() && $tur_data['id']) {
$list = mysql_query("SELECT * FROM `users` WHERE `in_tower` = 1");
while($u = mysql_fetch_array($list)) {
while ($u = mysql_fetch_array($list)) {
undressall($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']."')");
$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'] . "')");
}
mysql_query("DELETE FROM `inventory` WHERE `owner` = '".$u['id']."' AND `bs` = 1");
mysql_query("DELETE FROM `inventory` WHERE `owner` = '" . $u['id'] . "' AND `bs` = 1");
$rep = mysql_query("SELECT `id_item`, `owner` FROM `deztow_gamers_inv` WHERE `owner` = '".$u['id']."'");
while($r = mysql_fetch_array($rep)) {
mysql_query("UPDATE `inventory` SET `owner` = '".$u['id']."' WHERE `owner` = '0' AND `id` = '".$r['id_item']."'");
$rep = mysql_query("SELECT `id_item`, `owner` FROM `deztow_gamers_inv` WHERE `owner` = '" . $u['id'] . "'");
while ($r = mysql_fetch_array($rep)) {
mysql_query("UPDATE `inventory` SET `owner` = '" . $u['id'] . "' WHERE `owner` = '0' AND `id` = '" . $r['id_item'] . "'");
}
$tec = mysql_fetch_array(mysql_query("SELECT `id`, `owner`, `name`, `sila`, `lovk`, `inta`, `vinos`, `intel`, `maxhp`, `money`, `exp`, `mudra`, `stats`, `nextup`, `level`, `align`, `master`, `noj`, `mec`, `topor`, `dubina`, `mlight`, `mgray`, `mdark` FROM `deztow_realchars` WHERE `owner` = '{$u['id']}' LIMIT 1"));
if(isset($tec['id'])) {
if (isset($tec['id'])) {
$u = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '{$u['id']}' LIMIT 1"));
$stats = $tec['stats'];
$master = $tec['master'];
mysql_query("UPDATE `users` SET `sila` = '".$tec['sila']."', `lovk` = '".$tec['lovk']."', `inta` = '".$tec['inta']."', `vinos` = '".$tec['vinos']."', `hp` = '".($tec['vinos']*6)."', `maxhp` = '".($tec['vinos']*6)."', `intel` = '".$tec['intel']."', `stats` = '".$tec['stats']."', `nextup` = '".$tec['nextup']."', `level` = '".$tec['level']."', `align` = '".$tec['align']."', `noj` = '".$tec['noj']."', `mec` = '".$tec['mec']."', `topor` = '".$tec['topor']."', `dubina` = '".$tec['dubina']."', `mlight` = '".$tec['mlight']."', `mgray` = '".$tec['mgray']."', `mdark` = '".$tec['mdark']."', `master` = '".$tec['master']."' WHERE `id` = '".$u['id']."' LIMIT 1");
mysql_query("UPDATE `users` SET `sila` = '" . $tec['sila'] . "', `lovk` = '" . $tec['lovk'] . "', `inta` = '" . $tec['inta'] . "', `vinos` = '" . $tec['vinos'] . "', `hp` = '" . ($tec['vinos'] * 6) . "', `maxhp` = '" . ($tec['vinos'] * 6) . "', `intel` = '" . $tec['intel'] . "', `stats` = '" . $tec['stats'] . "', `nextup` = '" . $tec['nextup'] . "', `level` = '" . $tec['level'] . "', `align` = '" . $tec['align'] . "', `noj` = '" . $tec['noj'] . "', `mec` = '" . $tec['mec'] . "', `topor` = '" . $tec['topor'] . "', `dubina` = '" . $tec['dubina'] . "', `mlight` = '" . $tec['mlight'] . "', `mgray` = '" . $tec['mgray'] . "', `mdark` = '" . $tec['mdark'] . "', `master` = '" . $tec['master'] . "' WHERE `id` = '" . $u['id'] . "' LIMIT 1");
mysql_query("DELETE FROM `deztow_realchars` WHERE `owner` = '{$u['id']}'");
$eff = mysql_fetch_array(mysql_query("SELECT * FROM `effects` WHERE `owner` = '".$u['id']."' AND (`type` = 1 `type` = 2 `type` = 3 `type` = 4 `type` = 11 OR `type` = 12 OR `type` = 13 OR `type` = 14 `type` = 21 `type` = 201 `type` = 202)"));
mysql_query("DELETE FROM `effects` WHERE `owner` = '".$u['id']."' AND `type` != 1 AND `type` != 2 AND `type` != 3 AND `type` != 4 AND `type` != 5 AND `type` != 6 AND `type` != 11 AND `type` != 12 AND `type` != 13 AND `type` != 14");
$eff = mysql_fetch_array(mysql_query("SELECT * FROM `effects` WHERE `owner` = '" . $u['id'] . "' AND (`type` = 1 `type` = 2 `type` = 3 `type` = 4 `type` = 11 OR `type` = 12 OR `type` = 13 OR `type` = 14 `type` = 21 `type` = 201 `type` = 202)"));
mysql_query("DELETE FROM `effects` WHERE `owner` = '" . $u['id'] . "' AND `type` != 1 AND `type` != 2 AND `type` != 3 AND `type` != 4 AND `type` != 5 AND `type` != 6 AND `type` != 11 AND `type` != 12 AND `type` != 13 AND `type` != 14");
if(isset($tec['id'])) {
mysql_query("UPDATE `users` SET `sila` = (`sila`-'".$eff['sila']."'), `lovk` = (`lovk`-'".$eff['lovk']."'), `inta` = (`inta`-'".$eff['inta']."'), `maxhp` = (`maxhp`-'".$eff['hp']."') WHERE `id` = '".$eff['owner']."' LIMIT 1");
if (isset($tec['id'])) {
mysql_query("UPDATE `users` SET `sila` = (`sila`-'" . $eff['sila'] . "'), `lovk` = (`lovk`-'" . $eff['lovk'] . "'), `inta` = (`inta`-'" . $eff['inta'] . "'), `maxhp` = (`maxhp`-'" . $eff['hp'] . "') WHERE `id` = '" . $eff['owner'] . "' LIMIT 1");
}
if($u['id'] != 233 && $u['id'] != 234 && $u['id'] != 235) {
if ($u['id'] != 233 && $u['id'] != 234 && $u['id'] != 235) {
settravma($u['id'], 100, 86400, 1);
}
get_out($u['id']);
mysql_query("UPDATE `users` SET `in_tower` = 0, `room` = '31' WHERE `id` = '".$u['id']."' LIMIT 1");
mysql_query("UPDATE `online` SET `room` = '31' WHERE `id` = '".$u['id']."' LIMIT 1");
mysql_query("UPDATE `users` SET `in_tower` = 0, `room` = '31' WHERE `id` = '" . $u['id'] . "' LIMIT 1");
mysql_query("UPDATE `online` SET `room` = '31' WHERE `id` = '" . $u['id'] . "' LIMIT 1");
}
}
mysql_query('UPDATE `deztow_turnir` SET `winner` = \'NO!\', `winnerlog` = \'<b>Ничья</b>\', `endtime` = '.time().', `active` = 0, `log` = CONCAT(`log`,\''."Турнир закончен по тайм-ауту. Победителя нет!<br />".'\') WHERE `active` = TRUE LIMIT 1');
mysql_query('UPDATE `deztow_turnir` SET `winner` = \'NO!\', `winnerlog` = \'<b>Ничья</b>\', `endtime` = ' . time() . ', `active` = 0, `log` = CONCAT(`log`,\'' . "Турнир закончен по тайм-ауту. Победителя нет!<br />" . '\') WHERE `active` = TRUE LIMIT 1');
$turnirstart = mysql_fetch_array(mysql_query("SELECT `value`, `bs_art` FROM `variables` WHERE `var` = 'startbs' LIMIT 1"));
if($turnirstart['bs_art'] == 1) {
if ($turnirstart['bs_art'] == 1) {
$bs_art = 0;
} elseif($turnirstart['bs_art'] == 0) {
} elseif ($turnirstart['bs_art'] == 0) {
$bs_art = 0; #1
}
$times = (time() + 7200);
mysql_query("UPDATE `variables` SET `value` = '".$times."', `bs_art` = '".$bs_art."' WHERE `var` = 'startbs' LIMIT 1");
mysql_query("UPDATE `variables` SET `value` = '" . $times . "', `bs_art` = '" . $bs_art . "' WHERE `var` = 'startbs' LIMIT 1");
mysql_query("TRUNCATE TABLE `deztow_stavka`");
mysql_query("TRUNCATE TABLE `deztow_gamers_inv`");
mysql_query("TRUNCATE TABLE `deztow_items`");

View File

@ -6,6 +6,38 @@ include("config.php");
include("functions.php");
if($user['battle'] != 0) { header('location: fbattle.php'); die(); }
function secs2hrs($s, $short = 0)
{
if ($s < 60) return "$s сек.";
$retstr = '';
if ($s < 3600) {
$min = floor($s / 60);
if ($min || !$short) $retstr .= "$min мин. ";
$sec = $s % 60;
if ($sec || !$short) $retstr .= "$sec сек.";
return $retstr;
}
$ret = floor($s / 3600);
$s = $s % 3600;
$d = floor($ret / 24);
$h = $ret % 24;
if ($d && ($d > 1 || $h || $s)) {
$retstr .= "$d д. ";
if ($h || !$short) $retstr .= "$h ч. ";
$min = floor($s / 60);
if ($min || !$short) $retstr .= "$min мин.";
return $retstr;
} elseif ($d) $h += $d * 24;
if ($h) {
$retstr = "$h ч. ";
$min = floor($s / 60);
if ($min || !$short) $retstr .= "$min мин.";
return $retstr;
}
return floor($s / 60) . " мин. " . ($s % 60) . " сек.";
}
if($_GET['ext'] == 1) {
$yas = mysql_fetch_array(mysql_query("SELECT `id` FROM `vxodd` WHERE `login` = '$user[login]' LIMIT 1"));
$yad = mysql_fetch_array(mysql_query("SELECT `id` FROM `vxod` WHERE `login` = '$user[login]' LIMIT 1"));

File diff suppressed because it is too large Load Diff

View File

@ -4,12 +4,51 @@ if(!isset($_SESSION['uid'])) { header('Location: index.php'); die(); }
include('config.php');
$user = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "'.$_SESSION['uid'].'" LIMIT 1'));
$hostel = mysql_fetch_array(mysql_query('SELECT `id`, `uid`, `type`, `time` FROM `hostel` WHERE `uid` = "'.$user['id'].'" LIMIT 1'));
include('functions.php');
#include('functions.php');
$error = ''; $rs = '';
$base = array(1 => array('type' => 'Сумка'), 2 => array('type' => 'Сундук'), 3 => array('type' => 'Комната'), 4 => array('type' => 'Амбар'));
$times = array(1 => 7, 2 => 14, 3 => 21, 4 => 28);
$cost = array(1 => array(8, 16, 24, 32), 2 => array(15, 30, 45, 60), 3 => array(25, 50, 75, 100), 4 => array(40, 80, 120, 160));
function remove_hostel_items($u)
{
$itms = mysql_query('SELECT `id`, `owner` FROM `inventory` WHERE `owner` = "-101' . $u . '"');
while ($pl = mysql_fetch_array($itms)) {
mysql_query('UPDATE `inventory` SET `owner` = "' . $u . '" WHERE `id` = "' . $pl['id'] . '" AND `owner` = "-101' . $u . '"');
}
}
function select_arenda($u, $type, $redirect = false)
{
$hostel = mysql_fetch_array(mysql_query('SELECT `id` FROM `hostel` WHERE `uid` = "' . $u['id'] . '" LIMIT 1'));
$price = array(1 => 8, 2 => 15, 3 => 25, 4 => 40);
if (!isset($u['id'])) {
$r = 'Персонаж не найден ...';
} else {
if ($type > 0 && $type <= 4) {
if (isset($hostel['id'])) {
$r = 'Не более 1 арендованного места ...';
} else {
if ($u['money'] >= $price[$type]) {
$u['money'] -= $price[$type];
mysql_query('UPDATE `users` SET `money` = "' . $u['money'] . '" WHERE `id` = "' . $u['id'] . '" LIMIT 1');
mysql_query('INSERT INTO `hostel` (`uid`, `type`, `time`) VALUES ("' . $u['id'] . '", "' . $type . '", "' . (time() + 60 * 60 * 24 * 7) . '")');
$r = 'Поздравляем с успешной арендой ...';
} else {
$r = 'Недостаточно денег ...';
}
}
} else {
$r = 'Неверный тип аренды ...';
}
}
if ($redirect == true) {
header('Location: main.php');
}
return $r;
}
if($_GET['exit'] == 1) {
if($user['sleep'] == 0) {
mysql_query('UPDATE `users`,`online` SET `users`.`room` = 26, `online`.`room` = 26 WHERE `users`.`id` = "'.$user['id'].'" AND `online`.`id` = "'.$user['id'].'"');

View File

@ -11,6 +11,273 @@ $hostel = mysql_fetch_array(mysql_query('SELECT * FROM `hostel` WHERE `uid` = "'
$base = array(1 => 15, 2 => 30, 3 => 50, 4 => 100);
$vips = array(1 => 0.15, 2 => 0.30, 3 => 0.45);
function show_item($row, $txt, $place)
{
if (($row['maxdur'] <= $row['duration']) || ($row['dategoden'] && $row['dategoden'] <= time())) destructitem($row['id']);
$r = '';
$ntxt = "В инвентаре";
if ($txt == "В сундук") $ntxt = "В сундуке";
$magic = db::c()->query('SELECT * FROM `magic` WHERE `id` = ?i', $$row['magic'])->fetch_assoc();
$incmagic = mysql_fetch_array(mysql_query('SELECT * FROM `magic` WHERE `id` = \'' . $row['includemagic'] . '\' LIMIT 1'));
$incmagic['name'] = $row['includemagicname'];
$incmagic['cur'] = $row['includemagicdex'];
$incmagic['max'] = $row['includemagicmax'];
if (!$magic) {
$magic['chanse'] = $incmagic['chanse'];
$magic['time'] = $incmagic['time'];
$magic['targeted'] = $incmagic['targeted'];
}
#href="?search=1&otdel='.$row['otdel'].'&place='.$place.'&itm='.$row['id'].'&set=1"
if (isset($row['id'])) {
$r .= '<div id="inv_' . $row['id'] . '"><table><tbody>';
$r .= '<tr valign="top" style="border: 2px groove threedface;">';
$r .= '<td class="even links original"><img src="/i/sh/' . $row['img'] . '">
<span class="pk-new">
<a href="javascript: void(0);" style="display: none;">' . $ntxt . '</a><a href="?search=1&otdel=' . $row['otdel'] . '&place=' . $place . '&itm=' . $row['id'] . '&set=1" name="imt" id="itm_' . $row['id'] . '">' . $txt . '</a>
</span></td>';
$r .= '<input type="hidden" name="itid" value="' . $row['id'] . '" />';
$r .= '<td class="even item">';
$r .= '<div class="thinginfo"><a href="javascript: void(0);">' . $row['name'] . '</a> <img src="/i/align_' . $row['nalign'] . '.gif" /> (масса: ' . $row['massa'] . ') ' . (($row['present']) ? ' <img src="i/podarok.gif" width="16" height="18" title="Этот предмет вам подарил ' . $row['present'] . '. Вы не сможете передать этот предмет кому-либо еще." />' : "") . '<br />';
if ($row['ecost'] > 0) {
$r .= '<b>Цена: ' . $row['ecost'] . ' екр.</b> &nbsp; &nbsp;<br />';
} elseif ($row['point'] > 0) {
$r .= '<b>Цена: <font color=blue>' . $row['point'] . ' реп.</font></b> &nbsp; &nbsp;<br />';
} else {
$r .= '<b>Цена: ' . $row['cost'] . ' кр.</b> &nbsp; &nbsp;<br />';
}
if ($row['zeton'] > 0) {
$r .= '<b>Жетон: ' . $row['zeton'] . '</b>&nbsp<br />';
}
$r .= 'Долговечность: ' . $row['duration'] . '/' . $row['maxdur'] . '<br />';
if (!$row['needident']) {
if ($magic['chanse']) {
if ($magic['chanse'] >= 95) $magic['chanse'] = 95;
$r .= 'Вероятность срабатывания: ' . $magic['chanse'] . '%<br />';
}
if ($magic['time']) {
$r .= 'Продолжительность действия магии: ' . $magic['time'] . ' мин.<br />';
}
if ($row['goden']) {
$r .= 'Срок годности: ' . $row['goden'] . ' дн. (до ' . date("Y.m.d H:i", $row['dategoden']) . ')<br />';
}
$r .= '<div class="need">';
$user = array();
if ($row['nsila']) {
$r .= '&bull; ';
if ($row['nsila'] > $user['sila']) {
$r .= '<span class="red">';
}
$r .= 'Требуется Сила: ' . $row['nsila'] . '</span><br />';
}
if ($row['nlovk']) {
$r .= '&bull; ';
if ($row['nlovk'] > $user['lovk']) {
$r .= '<span class="red">';
}
$r .= 'Требуется Ловкость: ' . $row['nlovk'] . '</span><br />';
}
if ($row['ninta']) {
$r .= '&bull; ';
if ($row['ninta'] > $user['inta']) {
$r .= '<span class="red">';
}
$r .= 'Требуется Интуиция: ' . $row['ninta'] . '</span><br />';
}
if ($row['nvinos']) {
$r .= '&bull; ';
if ($row['nvinos'] > $user['vinos']) {
$r .= '<span class="red">';
}
$r .= 'Требуется Выносливость: ' . $row['nvinos'] . '</span><br />';
}
if ($row['nlevel']) {
$r .= '&bull; ';
if ($row['nlevel'] > $user['level']) {
$r .= '<span class="red">';
}
$r .= 'Требуется Уровень: ' . $row['nlevel'] . '</span><br />';
}
if ($row['nintel']) {
$r .= '&bull; ';
if ($row['nintel'] > $user['intel']) {
$r .= '<span class="red">';
}
$r .= 'Требуется Интеллект: ' . $row['nintel'] . '</span><br />';
}
if ($row['nnoj']) {
$r .= '&bull; ';
if ($row['nnoj'] > $user['noj']) {
$r .= '<span class="red">';
}
$r .= 'Требуется Мастерство владения ножами и кастетами: ' . $row['nnoj'] . '</span><br />';
}
if ($row['ntopor']) {
$r .= '&bull; ';
if ($row['ntopor'] > $user['topor']) {
$r .= '<span class="red">';
}
$r .= 'Требуется Мастерство владения топорами и секирами: ' . $row['ntopor'] . '</span><br />';
}
if ($row['ndubina']) {
$r .= '&bull; ';
if ($row['ndubina'] > $user['dubina']) {
$r .= '<span class="red">';
}
$r .= 'Требуется Мастерство владения дубинами и булавами: ' . $row['ndubina'] . '</span><br />';
}
if ($row['nmech']) {
$r .= '&bull; ';
if ($row['nmech'] > $user['mech']) {
$r .= '<span class="red">';
}
$r .= 'Требуется Мастерство владения мечами: ' . $row['nmech'] . '</span><br />';
}
if ($row['nfire']) {
$r .= '&bull; ';
if ($row['nfire'] > $user['mfire']) {
$r .= '<span class="red">';
}
$r .= 'Требуется Магия Огня: ' . $row['nfire'] . '</span><br />';
}
if ($row['nwater']) {
$r .= '&bull; ';
if ($row['nwater'] > $user['mwater']) {
$r .= '<span class="red">';
}
$r .= 'Требуется Магия Воды: ' . $row['nwater'] . '</span><br />';
}
if ($row['nair']) {
$r .= '&bull; ';
if ($row['nair'] > $user['mair']) {
$r .= '<span class="red">';
}
$r .= 'Требуется Магия Воздуха:: ' . $row['nair'] . '</span><br />';
}
if ($row['nearth']) {
$r .= '&bull; ';
if ($row['nearth'] > $user['mearth']) {
$r .= '<span class="red">';
}
$r .= 'Требуется Магия Земли: ' . $row['nearth'] . '</span><br />';
}
if ($row['nlight']) {
$r .= '&bull; ';
if ($row['nlight'] > $user['mlight']) {
$r .= '<span class="red">';
}
$r .= 'Требуется Магия Света: ' . $row['nlight'] . '</span><br />';
}
if ($row['ngray']) {
$r .= '&bull; ';
if ($row['ngray'] > $user['mgray']) {
$r .= '<span class="red">';
}
$r .= 'Требуется Магия Равновесия: ' . $row['ngray'] . '</span><br />';
}
if ($row['ndark']) {
$r .= '&bull; ';
if ($row['ndark'] > $user['mdark']) {
$r .= '<span class="red">';
}
$r .= 'Требуется Магия Тьмы: ' . $row['ndark'] . '</span><br />';
}
$r .= '</div><br />';
$r .= '<div class="bonus">';
if ($row['minu']) $r .= '+' . $row['minu'] . ' Минимальное наносимое повреждение <br />';
if ($row['maxu']) $r .= '+' . $row['maxu'] . ' Максимальное наносимое повреждение <br />';
if ($row['gsila']) $r .= '+' . $row['gsila'] . ' Сила <br />';
if ($row['glovk']) $r .= '+' . $row['glovk'] . ' Ловкость <br />';
if ($row['ginta']) $r .= '+' . $row['ginta'] . ' Интуиция <br />';
if ($row['gintel']) $r .= '+' . $row['gintel'] . ' Интеллект <br />';
if ($row['ghp']) $r .= '+' . $row['ghp'] . ' Уровень жизни <br />';
if ($row['mfkrit']) $r .= '+' . $row['mfkrit'] . '% Мф. критических ударов <br />';
if ($row['mfakrit']) $r .= '+' . $row['mfakrit'] . '% Мф. против крит. ударов <br />';
if ($row['mfuvorot']) $r .= '+' . $row['mfuvorot'] . '% Мф. увертливости <br />';
if ($row['mfauvorot']) $r .= '+' . $row['mfauvorot'] . '% Мф. против увертливости <br />';
if ($row['gnoj']) $r .= '+' . $row['gnoj'] . ' Мастерство владения ножами и кастетами <br />';
if ($row['gtopor']) $r .= '+' . $row['gtopor'] . ' Мастерство владения топорами и секирами <br />';
if ($row['gdubina']) $r .= '+' . $row['gdubina'] . ' Мастерство владения дубинами и булавами <br />';
if ($row['gmech']) $r .= '+' . $row['gmech'] . ' Мастерство владения мечами <br />';
if ($row['gfire']) $r .= '+' . $row['gfire'] . ' Мастерство владения стихией Огня <br />';
if ($row['gwater']) $r .= '+' . $row['gwater'] . ' Мастерство владения стихией Воды <br />';
if ($row['gair']) $r .= '+' . $row['gair'] . ' Мастерство владения стихией Воздуха <br />';
if ($row['gearth']) $r .= '+' . $row['gearth'] . ' Мастерство владения стихией Земли <br />';
if ($row['glight']) $r .= '+' . $row['glight'] . ' Мастерство владения магией Светa <br />';
if ($row['ggray']) $r .= '+' . $row['ggray'] . ' Мастерство владения Cерой магией <br />';
if ($row['gdark']) $r .= '+' . $row['gdark'] . ' Мастерство владения магией Тьмы <br />';
if ($row['bron1']) $r .= '+' . $row['bron1'] . ' Броня головы <br />';
if ($row['bron2']) $r .= '+' . $row['bron2'] . ' Броня корпуса <br />';
if ($row['bron3']) $r .= '+' . $row['bron3'] . ' Броня пояса <br />';
if ($row['bron4']) $r .= '+' . $row['bron4'] . ' Броня ног <br />';
if ($row['gmeshok']) $r .= '+' . $row['gmeshok'] . ' Увеличивает рюкзак: <br />';
$r .= '</div">';
if ($row['letter']) $r .= 'На бумаге записан текст: <div style="background-color:#FAF0E6;"> ' . nl2br($row['letter']) . '</div><br />';
if ($magic['name'] && $row['type'] != 50) $r .= '<span style="color: maroon;">Наложены заклятия:</span> ' . $magic['name'] . '<br />';
if ($row['text']) $r .= 'На ручке выгравирована надпись: <center>' . $row['text'] . '</center><br />';
if ($incmagic['max']) $r .= 'Встроено заклятие <img src="i/magic/' . $incmagic['img'] . '" /> ' . $incmagic['cur'] . ' шт.<br />';
if ($row['podzem']) $r .= '<span style="font-size: 11px; color: #990000">Предмет из подземелья</span><br />';
if ($row['laba'] == 1) $r .= '<span style="font-size: 11px; color: #990000">Пропадёт если не найти выход</span><br />';
if ($row['laba'] == 2) $r .= '<span style="font-size: 11px; color: #990000">Предмет пропадёт после выхода</span><br />';
if ($row['isrep']) $r .= '<small><span style="color: maroon;">Предмет не подлежит ремонту</span></small><br />';
if ($row['free_bron']) $r .= '+' . $row['free_bron'] . ' Улучшений брони <br />';
if ($row['free_stat']) $r .= '+' . $row['free_stat'] . ' Улучшений параметров <br />';
if ($row['free_mf']) $r .= '+' . $row['free_mf'] . ' Улучшений модификаторов <br />';
$r .= '</div>';
} else {
$r .= '<span style="color: maroon;"><b>Свойства предмета не идентифицированы</b></span><br />';
}
$osob = array(22, 23);
if (in_array($row['type'], $osob)) {
$r .= 'Особенности:<br />';
if ($row['type'] == 22) {
$r .= '&bull; может одеваться под броню';
} elseif ($row['type'] == 23) {
$r .= '&bull; может одеваться на броню';
}
}
$r .= '</td>';
$r .= '</tr>';
$r .= '</tbody></table></div>';
}
return $r;
}
function show_itm_hostel($uid, $otdel, $type = 1)
{
$r = '';
if ($type != 1) {
$sql = $uid;
$txt = 'В сундук';
} else {
$sql = '-101' . $uid . '';
$txt = 'В инвентарь';
}
$data = mysql_query("SELECT * FROM `inventory` WHERE `otdel` = '{$otdel}' AND `owner` = " . $sql . " AND `dressed`='0' ORDER BY `id` ASC");
while ($pl = mysql_fetch_array($data)) {
$r .= show_item($pl, 10, $txt, $type);
}
if ($r == '') {
$r = '<tr><td width="100%" align="center" class="even"><center><b>Пусто. <br />Попробуйте другой вариант фильтрации.</center></b></td></tr>';
}
return $r;
}
if($user['vip'] > 0 && $user['vip_time'] > time()) {
$count = $base[$hostel['type']];
$count += floor($base[$hostel['type']]*$vips[$user['vip']]);

617
main.php
View File

@ -14,6 +14,621 @@ if ($user['battle'] != 0) {
die();
}
/// fixme заводить переменную равную нулю и целую функцию, чтобы прибавить к нулю значение? исправить!
function sum_mf($u)
{
$t = 0;
$r = mysql_fetch_array(mysql_query('SELECT SUM(`add_proc_mf`) AS `mf` FROM `inventory` WHERE `owner` = "' . $u . '" AND `dressed` = "1" AND `add_proc_mf` > 0'));
$r = $t + $r['mf'];
return $r;
}
function sum_dmg($u)
{
$t = 0;
$r = mysql_fetch_array(mysql_query('SELECT SUM(`add_proc_uron`) AS `mf` FROM `inventory` WHERE `owner` = "' . $u . '" AND `dressed` = "1" AND `add_proc_uron` > 0'));
$r = $t + $r['mf'];
return $r;
}
function sum_bron($u)
{
$t = 0;
$r = mysql_fetch_array(mysql_query('SELECT SUM(`add_proc_bron`) AS `mf` FROM `inventory` WHERE `owner` = "' . $u . '" AND `dressed` = "1" AND `add_proc_bron` > 0'));
$r = $t + $r['mf'];
return $r;
}
function bron_ads($a1, $a2, $a3, $a4, $col)
{
return array('a1' => round(($a1 / 100) * $col), 'a2' => round(($a2 / 100) * $col), 'a3' => round(($a3 / 100) * $col), 'a4' => round(($a4 / 100) * $col));
}
function max_mf()
{
$r = '';
$mfs = countmf();
if (($mfs['fkrit'] > $mfs['fakrit']) && ($mfs['fkrit'] > $mfs['fuvorot']) && ($mfs['fkrit'] > $mfs['fauvorot'])) {
$r = 'fkrit';
} elseif (($mfs['fakrit'] > $mfs['fkrit']) && ($mfs['fakrit'] > $mfs['fuvorot']) && ($mfs['fakrit'] > $mfs['fauvorot'])) {
$r = 'fakrit';
} elseif (($mfs['fuvorot'] > $mfs['fkrit']) && ($mfs['fuvorot'] > $mfs['fakrit']) && ($mfs['fuvorot'] > $mfs['fauvorot'])) {
$r = 'fuvorot';
} elseif (($mfs['fauvorot'] > $mfs['fkrit']) && ($mfs['fauvorot'] > $mfs['fakrit']) && ($mfs['fauvorot'] > $mfs['fuvorot'])) {
$r = 'fauvorot';
}
return $r;
}
function stack($it_id)
{
global $user;
$it_id = (int)$it_id;
$stack = mysql_query("SELECT * FROM `inventory` WHERE `id` = '" . $it_id . "' AND `owner` = " . $user['id'] . " LIMIT 1");
if (mysql_num_rows($stack) == 1) {
$stack = mysql_fetch_array($stack);
$similar = mysql_fetch_array(mysql_query("SELECT SUM(`koll`) FROM `inventory` WHERE `owner` = '" . $user['id'] . "' AND `id` != '" . $stack['id'] . "' AND `name` = '" . $stack['name'] . "' AND `present` = '" . $stack['present'] . "' AND `duration` = '" . $stack['duration'] . "' AND `maxdur` = '" . $stack['maxdur'] . "' AND `laba` = '" . $stack['laba'] . "' AND `gmeshok` = '" . $stack['gmeshok'] . "' AND `dressed` = 0 AND `goden` = 0 AND `setsale` = 0 AND `koll` >= 1 AND `isrep` = '" . $stack['isrep'] . "' AND FORMAT(`cost`/`koll`, 2) = FORMAT(" . ($stack['cost'] / $stack['koll']) . ", 2) AND FORMAT(`point`/`koll`, 2) = FORMAT(" . ($stack['point'] / $stack['koll']) . ", 2) AND FORMAT(`bcost`/`koll`, 2) = FORMAT(" . ($stack['bcost'] / $stack['koll']) . ", 2)"));
if ($similar[0] >= 1) {
mysql_query("UPDATE `inventory` SET `cost` = (`cost`+`cost`/`koll`*" . $similar[0] . "), `point` = (`point`+`point`/`koll`*" . $similar[0] . "), `bcost` = (`bcost`+`bcost`/`koll`*" . $similar[0] . "), `massa` = (`massa`+`massa`/`koll`*" . $similar[0] . "), `koll` = (`koll`+" . $similar[0] . "), `gmeshok` = (`gmeshok`+`gmeshok`*" . $similar[0] . ") WHERE `id` = '" . $stack['id'] . "' LIMIT 1");
mysql_query("DELETE FROM `inventory` WHERE `owner` = '" . $user['id'] . "' AND `id` != '" . $stack['id'] . "' AND `name` = '" . $stack['name'] . "' AND `present` = '" . $stack['present'] . "' AND `duration` = '" . $stack['duration'] . "' AND `maxdur` = '" . $stack['maxdur'] . "' AND `dressed` = 0 AND `goden` = 0 AND `koll` >= 1 AND `setsale` = 0 AND `gmeshok` = '" . $stack['gmeshok'] . "' AND `laba` = '" . $stack['laba'] . "' AND `isrep` = '" . $stack['isrep'] . "' AND FORMAT(`cost`/`koll`, 2)=FORMAT(" . $stack['cost'] / $stack['koll'] . ", 2) AND FORMAT(`point`/`koll`, 2) = FORMAT(" . ($stack['point'] / $stack['koll']) . ", 2) AND FORMAT(`bcost`/`koll`, 2) = FORMAT(" . ($stack['bcost'] / $stack['koll']) . ", 2) ");
}
}
}
function unstack($it_id, $it_count)
{
global $user;
$it_id = (int)$it_id;
$it_count = (int)$it_count;
$it_count = abs($it_count);
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `owner` = " . $user['id'] . " AND `id` = '" . mysql_real_escape_string($it_id) . "' LIMIT 1"));
$prototype = mysql_fetch_array(mysql_query('SELECT `id`, `gmeshok` FROM `shop` WHERE `id` = "' . $dress['prototype'] . '" LIMIT 1'));
if (isset($dress['id'])) {
if ($it_count <= $dress['koll'] && $it_count > 0) {
if ($dress['koll'] == $it_count) {
mysql_query('DELETE FROM `inventory` WHERE `id` = "' . $dress['id'] . '" AND `owner` = "' . $user['id'] . '" LIMIT 1');
} else {
if ($dress['gmeshok'] > 0) {
$sqla = ", `gmeshok` = `gmeshok`-" . $prototype['gmeshok'];
} else {
$sqla = "";
}
mysql_query("UPDATE `inventory` SET `cost` = (`cost`-`cost`/`koll`*" . $it_count . "), `point` = (`point`-`point`/`koll`*" . $it_count . "), `bcost` = (`bcost`-`bcost`/`koll`*" . $it_count . "), `massa` = (`massa`-`massa`/`koll`*" . $it_count . "), `koll` = (`koll`-" . $it_count . ")$sqla WHERE `id` = '$dress[id]' AND `owner` = '$user[id]' LIMIT 1");
}
mysql_query("INSERT INTO `inventory` (`name`, `upgrade`, `modif`, `podgon`, `duration`, `maxdur`, `cost`, `bcost`, `point`, `nlevel`, `nsila`, `nlovk`, `ninta`, `nvinos`, `nintel`, `nmudra`, `nnoj`, `ntopor`, `ndubina`, `nmech`, `nalign`, `minu`, `maxu`, `gsila`, `glovk`, `ginta`, `gintel`, `ghp`, `mfkrit`, `mfakrit`, `mfuvorot`, `mfauvorot`, `gnoj`, `gtopor`, `gdubina`, `gmech`, `img`, `text`, `owner`, `dressed`, `bron1`, `bron2`, `bron3`, `bron4`, `dategoden`, `magic`, `type`, `present`, `sharped`, `massa`, `goden`, `needident`, `nfire`, `nwater`, `nair`, `nearth`, `nlight`, `ngray`, `ndark`, `gfire`, `gwater`, `gair`, `gearth`, `glight`, `ggray`, `gdark`, `free_bron`, `free_stat`, `free_mf`, `letter`, `isrep`, `update`, `setsale`, `prototype`, `otdel`, `bs`, `gmp`, `includemagic`, `includemagicdex`, `includemagicmax`, `includemagicname`, `includemagicuses`, `includemagiccost`, `gmeshok`, `tradesale`, `podzem`, `x_mis`, `artefact`, `destinyinv`, `encicl`, `foronetrip`, `koll`) VALUES ('" . $dress['name'] . "', '" . $dress['upgrade'] . "', '" . $dress['modif'] . "', '" . $dress['podgon'] . "', '" . $dress['duration'] . "', '" . $dress['maxdur'] . "', '" . ($dress['cost'] / $dress['koll'] * $it_count) . "', '" . ($dress['bcost'] / $dress['koll'] * $it_count) . "', '" . ($dress['point'] / $dress['koll'] * $it_count) . "', '" . $dress['nlevel'] . "', '" . $dress['nsila'] . "', '" . $dress['nlovk'] . "', '" . $dress['ninta'] . "', '" . $dress['nvinos'] . "', '" . $dress['nintel'] . "', '" . $dress['nmudra'] . "', '" . $dress['nnoj'] . "', '" . $dress['ntopor'] . "', '" . $dress['ndubina'] . "', '" . $dress['nmech'] . "', '" . $dress['nalign'] . "', '" . $dress['minu'] . "', '" . $dress['maxu'] . "', '" . $dress['gsila'] . "', '" . $dress['glovk'] . "', '" . $dress['ginta'] . "', '" . $dress['gintel'] . "', '" . $dress['ghp'] . "', '" . $dress['mfkrit'] . "', '" . $dress['mfakrit'] . "', '" . $dress['mfuvorot'] . "', '" . $dress['mfauvorot'] . "', '" . $dress['gnoj'] . "', '" . $dress['gtopor'] . "', '" . $dress['gdubina'] . "', '" . $dress['gmech'] . "', '" . $dress['img'] . "', '" . $dress['text'] . "', '" . $dress['owner'] . "', '" . $dress['dressed'] . "', '" . $dress['bron1'] . "', '" . $dress['bron2'] . "', '" . $dress['bron3'] . "', '" . $dress['bron4'] . "', '" . $dress['dategoden'] . "', '" . $dress['magic'] . "', '" . $dress['type'] . "', '" . $dress['present'] . "', '" . $dress['sharped'] . "', '" . ($dress['massa'] / $dress['koll'] * $it_count) . "', '" . $dress['goden'] . "', '" . $dress['needident'] . "', '" . $dress['nfire'] . "', '" . $dress['nwater'] . "', '" . $dress['nair'] . "', '" . $dress['nearth'] . "', '" . $dress['nlight'] . "', '" . $dress['ngray'] . "', '" . $dress['ndark'] . "', '" . $dress['gfire'] . "', '" . $dress['gwater'] . "', '" . $dress['gair'] . "', '" . $dress['gearth'] . "', '" . $dress['glight'] . "', '" . $dress['ggray'] . "', '" . $dress['gdark'] . "', '" . $dress['free_bron'] . "', '" . $dress['free_bron'] . "', '" . $dress['free_mf'] . "', '" . $dress['letter'] . "', '" . $dress['isrep'] . "', '" . $dress['update'] . "', '" . $dress['setsale'] . "', '" . $dress['prototype'] . "', '" . $dress['otdel'] . "', '" . $dress['bs'] . "', '" . $dress['gmp'] . "', '" . $dress['includemagic'] . "', '" . $dress['includemagicdex'] . "', '" . $dress['includemagicmax'] . "', '" . $dress['includemagicname'] . "', '" . $dress['ggrincludemagicusesay'] . "', '" . $dress['includemagiccost'] . "', '" . ($dress['gmeshok'] / $dress['koll'] * $it_count) . "', '" . $dress['tradesale'] . "', '" . $dress['podzem'] . "', '" . $dress['x_mis'] . "', '" . $dress['artefact'] . "', '" . $dress['destinyinv'] . "', '" . $dress['encicl'] . "', '" . $dress['foronetrip'] . "', '" . $it_count . "')");
return mysql_insert_id();
}
}
}
function del_efs($uid, $id, $type)
{
global $user;
$arr = [2, 3, 4, 5, 8, 10, 11, 12, 13, 14, 20];
if ($uid == $user['id']) {
if ($id != null) {
if (!in_array($type, $arr)) {
db::c()->query('DELETE FROM `effects` WHERE `owner` = ?i AND `id` = ?i', $uid, $id);
if ($type == 1022) {
db::c()->query('UPDATE `users` SET `invis` = ?i WHERE `id` = ?i', 0, $uid);
$user['invis'] = 0;
}
err('Эффект удалён.');
} else {
err('Данный эффект нельзя удалить.');
}
}
}
}
function countmf()
{ //TODO пересчитать модификаторы
global $user;
function GetWeaponType($idwep)
{
if ($idwep == 0 || $idwep == null || $idwep == '') {
return "kulak";
}
$wep = mysql_fetch_array(mysql_query('SELECT `otdel`, `minu` FROM `inventory` WHERE `id` = "' . $idwep . '" LIMIT 1'));
if ($wep[0] == '1') {
return "noj";
} elseif ($wep[0] == '12') {
return "dubina";
} elseif ($wep[0] == '11') {
return "topor";
} elseif ($wep[0] == '13') {
return "mech";
} elseif ($wep[1] > 0) {
return "buket";
} else {
return "kulak";
}
}
$zo = mysql_fetch_row(mysql_query("SELECT `id` FROM `effects` WHERE `type` = 201 AND `owner` = {$user['id']} LIMIT 1"));
$sokr = mysql_fetch_row(mysql_query("SELECT `id` FROM `effects` WHERE `type` = 202 AND `owner` = {$user['id']} LIMIT 1"));
if (isset($sokr[0])) {
$bmfud += 5;
} else {
$bmfud = 0;
}
if (isset($zo[0]) > 0) {
$bmfbron += 25;
} else {
$bmfbron = 0;
}
$mf = array();
$ud_raw = mysql_query('SELECT SUM(`minu`), SUM(`maxu`), SUM(`mfkrit`), SUM(`mfakrit`), SUM(`mfuvorot`), SUM(`mfauvorot`), SUM(`bron1`), SUM(`bron2`), SUM(`bron3`), SUM(`bron4`) FROM `inventory` WHERE `dressed` = 1 AND `owner` = \'' . $user['id'] . '\' LIMIT 1');
$user_dress = mysql_fetch_array($ud_raw);
$user_dress[6] = $bmfbron;
$user_dress[7] = $bmfbron;
$user_dress[8] = $bmfbron;
$user_dress[9] = $bmfbron;
$user_dress[6] += $user['ubron1'];
$user_dress[7] += $user['ubron2'];
$user_dress[8] += $user['ubron3'];
$user_dress[9] += $user['ubron4'];
$mykrit = $user_dress[2] + ($user['inta'] * 2.95);
$myakrit = $user_dress[3] + ($user['inta'] * 2.75);
$myuvorot = $user_dress[4] + ($user['lovk'] * 5);
$myauvorot = $user_dress[5] + ($user['lovk'] * 4);
$mf['me'] = array('udar' => (floor($user['sila'] / 3) + 1 + $user_dress[0]), 'maxudar' => (floor($user['sila'] / 3) + 4 + $user_dress[1]));
if ($mf['me']['udar'] < 0) {
$mf['me']['udar'] = 0;
}
$weap_b = 0;
switch (GetWeaponType($user['weap'])) {
case "noj":
$weap_b += $user['noj'];
break;
case "dubina":
$weap_b += $user['dubina'];
break;
case "topor":
$weap_b += $user['topor'];
break;
case "mech":
$weap_b += $user['mec'];
break;
}
return array('minu' => $mf['me']['udar'] + $bmfud + $weap_b, 'maxu' => $mf['me']['maxudar'] + $bmfud + $weap_b, 'fkrit' => round($mykrit, 0), 'fakrit' => round($myakrit, 0), 'fuvorot' => round($myuvorot, 0), 'fauvorot' => round($myauvorot, 0), 'bron1' => $user_dress[6], 'bron2' => $user_dress[7], 'bron3' => $user_dress[8], 'bron4' => $user_dress[9]);
}
// одеть предмет
function dressitem($id)
{
global $user;
$item = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` AS `i` WHERE `duration` < `maxdur` AND `id` = '{$id}' AND `owner` = '{$user['id']}' AND `dressed` = 0 LIMIT 1"));
switch ($item['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;
case 24:
$slot1 = 'rune_1';
break;
case 25:
$slot1 = 'rune_2';
break;
case 26:
$slot1 = 'rune_3';
break;
}
if ($item['type'] == 5) {
if (!$user['r1']) {
$slot1 = 'r1';
} elseif (!$user['r2']) {
$slot1 = 'r2';
} elseif (!$user['r3']) {
$slot1 = 'r3';
} else {
$slot1 = 'r1';
dropitem(5);
}
} elseif ($item['type'] == 24) {
if (!$user['rune_1']) {
$slot1 = 'rune_1';
} elseif (!$user['rune_2']) {
$slot1 = 'rune_2';
} elseif (!$user['rune_3']) {
$slot1 = 'rune_3';
} else {
$slot1 = 'rune_1';
dropitem(24);
}
} elseif ($item['type'] == 12) {
if (!$user['m1']) {
$slot1 = 'm1';
} elseif (!$user['m2']) {
$slot1 = 'm2';
} elseif (!$user['m3']) {
$slot1 = 'm3';
} elseif (!$user['m4']) {
$slot1 = 'm4';
} elseif (!$user['m5']) {
$slot1 = 'm5';
} elseif (!$user['m6']) {
$slot1 = 'm6';
} elseif (!$user['m7']) {
$slot1 = 'm7';
} elseif (!$user['m8']) {
$slot1 = 'm8';
} elseif (!$user['m9']) {
$slot1 = 'm9';
} elseif (!$user['m10']) {
$slot1 = 'm10';
} else {
$slot1 = 'm1';
dropitem(12);
}
} else {
dropitem($item['type']);
}
$al = '(1 = 1)';
if ($item['nalign'] > 0) {
if ($item['nalign'] == 1.1) {
if (($user['align'] == 6 || ($user['align'] > 1 && $user['align'] < 2))) {
$al = '(1 = 1)';
} else {
$al = '(1 = 2)';
}
}
}
if (!($item['type'] == 12 && $user['level'] < 4)) {
if (mysql_query("UPDATE `users` AS `u`, `inventory` AS `i` SET `u`.`{$slot1}` = {$id}, `i`.`dressed` = 1, `u`.`sila` = `u`.`sila` + `i`.`gsila`, `u`.`lovk` = `u`.`lovk` + `i`.`glovk`, `u`.`inta` = `u`.`inta` + `i`.`ginta`, `u`.`intel` = `u`.`intel` + `i`.`gintel`, `u`.`maxhp` = `u`.`maxhp` + `i`.`ghp`, `u`.`noj` = `u`.`noj` + `i`.`gnoj`, `u`.`topor` = `u`.`topor` + `i`.`gtopor`, `u`.`dubina` = `u`.`dubina` + `i`.`gdubina`, `u`.`mec` = `u`.`mec` + `i`.`gmech`, `u`.`mfire` = `u`.`mfire` + `i`.`gfire`, `u`.`mwater` = `u`.`mwater` + `i`.`gwater`, `u`.`mair` = `u`.`mair` + `i`.`gair`, `u`.`mearth` = `u`.`mearth` + `i`.`gearth`, `u`.`mlight` = `u`.`mlight` + `i`.`glight`, `u`.`mgray` = `u`.`mgray` + `i`.`ggray`, `u`.`mdark` = `u`.`mdark` + `i`.`gdark`, `u`.`ubron1` = `u`.`ubron1` + `i`.`bron1`, `u`.`ubron2` = `u`.`ubron2` + `i`.`bron2`, `u`.`ubron3` = `u`.`ubron3` + `i`.`bron3`, `u`.`ubron4` = `u`.`ubron4` + `i`.`bron4`, `u`.`fkrit` = `u`.`fkrit` + `i`.`mfkrit`, `u`.`fakrit` = `u`.`fakrit` + `i`.`mfakrit`, `u`.`fuvorot` = `u`.`fuvorot` + `i`.`mfuvorot`, `u`.`fauvorot` = `u`.`fauvorot` + `i`.`mfauvorot`, `u`.`uminu` = `u`.`uminu` + `i`.`minu`, `u`.`umaxu` = `u`.`umaxu` + `i`.`maxu` WHERE `i`.`needident` = 0 AND `i`.`id` = {$id} AND `i`.`dressed` = 0 AND `i`.owner = {$user['id']} AND (20 + `u`.`sila`) >= `i`.`nsila` AND (20 + `u`.`lovk`) >= `i`.`nlovk` AND (20 + `u`.`inta`) >= `i`.`ninta` AND `u`.`vinos` >= `i`.`nvinos` AND (20 + `u`.`intel`) >= `i`.`nintel` AND `u`.`mudra` >= `i`.`nmudra` AND `u`.`level` >= `i`.`nlevel` AND (($al OR (" . (int)$user['align'] . " = `i`.`nalign`)) OR (`i`.`nalign` = 0)) AND `u`.`noj` >= `i`.`nnoj` AND `u`.`topor` >= `i`.`ntopor` AND `u`.`dubina` >= `i`.`ndubina` AND `u`.`mec` >= `i`.`nmech` AND `u`.`mfire` >= `i`.`nfire` AND `u`.`mwater` >= `i`.`nwater` AND `u`.`mair` >= `i`.`nair` AND `u`.`mearth` >= `i`.`nearth` AND `u`.`mlight` >= `i`.`nlight` AND `u`.`mgray` >= `i`.`ngray` AND `u`.`mdark` >= `i`.`ndark` AND `i`.`setsale` = 0 AND `u`.`id` = {$user['id']}"))
$user[$slot1] = $item['id'];
return true;
}
}
/**
* Отображение персонажа в main.php
* @param $id
*/
function showpersinv($id)
{
$user = db::c()->query('SELECT * FROM `users` WHERE `id` = ?i', $id)->fetch_assoc();
$dressed = [];
$r = mysql_query("SELECT * FROM `inventory` WHERE
`id` = '$user[helm]' OR `id` = '$user[weap]' OR `id` = '$user[plaw]' OR `id` = '$user[bron]' OR
`id` = '$user[rybax]' OR `id` = '$user[belt]' OR `id` = '$user[sergi]' OR `id` = '$user[kulon]' OR
`id` = '$user[r1]' OR `id` = '$user[r2]' OR `id` = '$user[r3]' OR `id` = '$user[perchi]' OR
`id` = '$user[shit]' OR `id` = '$user[leg]' OR `id` = '$user[boots]' OR `id` = '$user[m1]' OR
`id` = '$user[m2]' OR `id` = '$user[m3]' OR `id` = '$user[m4]' OR `id` = '$user[m5]' OR
`id` = '$user[m6]' OR `id` = '$user[m7]' OR `id` = '$user[m8]' OR `id` = '$user[m9]' OR
`id` = '$user[m10]' OR `id` = '$user[m11]' OR `id` = '$user[m12]'");
while ($rec = mysql_fetch_assoc($r)) {
$dressed[$rec['id']] = $rec;
}
?>
<CENTER>
<img src="i/align_<?
echo($user['align'] > 0 ? $user['align'] : "0"); ?>.gif">
<img src="i/klan/<? ClanImage($user['klan']); ?>.gif">;
<B><?= $user['login'] ?></B> [<?= $user['level'] ?>]
<a href=inf.php?<?= $user['login'] ?> target=_blank><IMG SRC=i/inf.gif WIDTH=12 HEIGHT=11
ALT="Инф. о <?= $user['login'] ?>"></a>
<TABLE cellspacing=0 cellpadding=0>
<tr>
<TD colspan=3 width=100%>
<?= setHP($user['hp'], $user['maxhp'], 1); ?>
</td>
</tr>
<?
if ($user['level'] > 3) { ?>
<TR>
<TD colspan=3>
<? // TODO Сделать один запрос из десяти!
if ($user['m1'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['m1']}' LIMIT 1;"));
$mess = 'Снять <b>' . $dress['name'] . '</b><br />Прочность ' . $dress['duration'] . '/' . $dress['maxdur'];
echo '<a href="?edit=1&drop=12"><img class=\'tooltip\' title=\'' . $mess . '\' src="i/sh/' . $dress['img'] . '" width=40 height=25></a>';
} else {
$mess = '<b>Пустой слот магия</b>';
echo '<img class=\'tooltip\' title=\'' . $mess . '\' src=i/w13.gif width=40 height=25>';
}
if ($user['m2'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['m2']}' LIMIT 1;"));
$mess = 'Снять <b>' . $dress['name'] . '</b><br />Прочность ' . $dress['duration'] . '/' . $dress['maxdur'];
echo '<a href="?edit=1&drop=13"><img class=\'tooltip\' title=\'' . $mess . '\' src="i/sh/' . $dress['img'] . '" width=40 height=25></a>';
} else {
$mess = '<b>Пустой слот магия</b>';
echo '<img class=\'tooltip\' title=\'' . $mess . '\' src=i/w13.gif width=40 height=25>';
}
if ($user['m3'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['m3']}' LIMIT 1;"));
$mess = 'Снять <b>' . $dress['name'] . '</b><br />Прочность ' . $dress['duration'] . '/' . $dress['maxdur'];
echo '<a href="?edit=1&drop=14"><img class=\'tooltip\' title=\'' . $mess . '\' src="i/sh/' . $dress['img'] . '" width=40 height=25></a>';
} else {
$mess = '<b>Пустой слот магия</b>';
echo '<img class=\'tooltip\' title=\'' . $mess . '\' src=i/w13.gif width=40 height=25>';
}
if ($user['m4'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['m4']}' LIMIT 1;"));
$mess = 'Снять <b>' . $dress['name'] . '</b><br />Прочность ' . $dress['duration'] . '/' . $dress['maxdur'];
echo '<a href="?edit=1&drop=15"><img class=\'tooltip\' title=\'' . $mess . '\' src="i/sh/' . $dress['img'] . '" width=40 height=25></a>';
} else {
$mess = '<b>Пустой слот магия</b>';
echo '<img class=\'tooltip\' title=\'' . $mess . '\' src=i/w13.gif width=40 height=25>';
}
if ($user['m5'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['m5']}' LIMIT 1;"));
$mess = 'Снять <b>' . $dress['name'] . '</b><br />Прочность ' . $dress['duration'] . '/' . $dress['maxdur'];
echo '<a href="?edit=1&drop=16"><img class=\'tooltip\' title=\'' . $mess . '\' src="i/sh/' . $dress['img'] . '" width=40 height=25></a>';
} else {
$mess = '<b>Пустой слот магия</b>';
echo '<img class=\'tooltip\' title=\'' . $mess . '\' src=i/w13.gif width=40 height=25>';
}
?>
</TD>
</TR>
<TR>
<TD colspan=3>
<?
if ($user['m6'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['m6']}' LIMIT 1;"));
$mess = 'Снять <b>' . $dress['name'] . '</b><br />Прочность ' . $dress['duration'] . '/' . $dress['maxdur'];
echo '<a href="?edit=1&drop=17"><img class=\'tooltip\' title=\'' . $mess . '\' src="i/sh/' . $dress['img'] . '" width=40 height=25></a>';
} else {
$mess = '<b>Пустой слот магия</b>';
echo '<img class=\'tooltip\' title=\'' . $mess . '\' src=i/w13.gif width=40 height=25>';
}
if ($user['m7'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['m7']}' LIMIT 1;"));
$mess = 'Снять <b>' . $dress['name'] . '</b><br />Прочность ' . $dress['duration'] . '/' . $dress['maxdur'];
echo '<a href="?edit=1&drop=18"><img class=\'tooltip\' title=\'' . $mess . '\' src="i/sh/' . $dress['img'] . '" width=40 height=25></a>';
} else {
$mess = '<b>Пустой слот магия</b>';
echo '<img class=\'tooltip\' title=\'' . $mess . '\' src=i/w13.gif width=40 height=25>';
}
if ($user['m8'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['m8']}' LIMIT 1;"));
$mess = 'Снять <b>' . $dress['name'] . '</b><br />Прочность ' . $dress['duration'] . '/' . $dress['maxdur'];
echo '<a href="?edit=1&drop=19"><img class=\'tooltip\' title=\'' . $mess . '\' src="i/sh/' . $dress['img'] . '" width=40 height=25></a>';
} else {
$mess = '<b>Пустой слот магия</b>';
echo '<img class=\'tooltip\' title=\'' . $mess . '\' src=i/w13.gif width=40 height=25>';
}
if ($user['m9'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['m9']}' LIMIT 1;"));
$mess = 'Снять <b>' . $dress['name'] . '</b><br />Прочность ' . $dress['duration'] . '/' . $dress['maxdur'];
echo '<a href="?edit=1&drop=20"><img class=\'tooltip\' title=\'' . $mess . '\' src="i/sh/' . $dress['img'] . '" width=40 height=25></a>';
} else {
$mess = '<b>Пустой слот магия</b>';
echo '<img class=\'tooltip\' title=\'' . $mess . '\' src=i/w13.gif width=40 height=25>';
}
if ($user['m10'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['m10']}' LIMIT 1;"));
$mess = 'Снять <b>' . $dress['name'] . '</b><br />Прочность ' . $dress['duration'] . '/' . $dress['maxdur'];
echo '<a href="?edit=1&drop=21"><img class=\'tooltip\' title=\'' . $mess . '\' src="i/sh/' . $dress['img'] . '" width=40 height=25></a>';
} else {
$mess = '<b>Пустой слот магия</b>';
echo '<img class=\'tooltip\' title=\'' . $mess . '\' src=i/w13.gif width=40 height=25>';
}
?>
</TD>
</TR>
<?
} ?>
<TR>
<TD width=62 valign=top>
<TABLE width=100% cellspacing=0 cellpadding=0>
<TR>
<TD><?php
if ($user['sergi'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['sergi']}' LIMIT 1;"));
$mess = 'Снять <b>' . $dress['name'] . '</b><br>Прочность ' . $dress['duration'] . '/' . $dress['maxdur'] . '';
echo '<a href="?edit=1&drop=1"><img class=\'tooltip\' title=\'' . $mess . '\' src="i/sh/' . $dress['img'] . '" width=60 height=20></a>';
} else {
echo '<img src="i/w1.gif" width=60 height=20 class=\'tooltip\' title=\'<b>Пустой слот Серьги</b>\' />';
}
?></TD>
</TR>
<TR>
<TD><?php
if ($user['kulon'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['kulon']}' LIMIT 1;"));
$mess = 'Снять <b>' . $dress['name'] . '</b><br>Прочность ' . $dress['duration'] . '/' . $dress['maxdur'] . '';
echo '<a href="?edit=1&drop=2"><img src="i/sh/' . $dress['img'] . '" width=60 height=20 class=\'tooltip\' title=\'' . $mess . '\'></a>';
} else {
echo '<img src="i/w2.gif" width=60 height=20 class=\'tooltip\' title=\'<b>Пустой слот Ожерелье</b>\' />';
}
?></TD>
</TR>
<TR>
<TD><?php
if ($user['weap'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['weap']}' LIMIT 1;"));
$mess = 'Снять <b>' . $dress['name'] . '</b><br>Прочность ' . $dress['duration'] . '/' . $dress['maxdur'] . '';
echo '<a href="?edit=1&drop=3"><img src="i/sh/' . $dress['img'] . '" width=60 height=60 class=\'tooltip\' title=\'' . $mess . '\'></a>';
} else {
echo '<img class=\'tooltip\' src="i/w3.gif" width=60 height=60 title=\'<b>Пустой слот Оружие</b>\' />';
}
?></TD>
</TR>
<TR>
<TD><?php
if ($user['bron'] > 0 || $user['rybax'] > 0 || $user['plaw'] > 0) {
if ($user['plaw']) {
$d = $user['plaw'];
$n = 23;
} elseif ($user['bron']) {
$d = $user['bron'];
$n = 4;
} elseif ($user['rybax']) {
$d = $user['rybax'];
$n = 22;
}
$dress = $dressed[$d];
$mess = 'Снять <b>' . $dress['name'] . '</b><br>Прочность ' . $dress['duration'] . '/' . $dress['maxdur'] . '';
echo '<a href="?edit=1&drop=' . $n . '"><img class=\'tooltip\' title=\'' . $mess . '\' src="i/sh/' . $dress['img'] . '" width=60 height=80></a>';
} else {
echo '<img class=\'tooltip\' src="i/w4.gif" width=60 height=80 title=\'<b>Пустой слот Броня</b>\' />';
}
?></TD>
</TR>
<TR>
<TD>
<TABLE cellspacing=0 cellpadding=0>
<tr>
<td><?php
if ($user['r1'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['r1']}' LIMIT 1;"));
$mess = 'Снять <b>' . $dress['name'] . '</b><br>Прочность ' . $dress['duration'] . '/' . $dress['maxdur'] . '';
echo '<a href="?edit=1&drop=5"><img class=\'tooltip\' title=\'' . $mess . '\' src="i/sh/' . $dress['img'] . '" width=20 height=20></a>';
} else {
echo '<img class=\'tooltip\' src="i/w6.gif" width=20 height=20 title=\'<b>Пустой слот Кольцо</b>\' />';
}
?></td>
<td><?php
if ($user['r2'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['r2']}' LIMIT 1;"));
$mess = 'Снять <b>' . $dress['name'] . '</b><br>Прочность ' . $dress['duration'] . '/' . $dress['maxdur'] . '';
echo '<a class=\'tooltip\' title=\'' . $mess . '\' href="?edit=1&drop=6"><img src="i/sh/' . $dress['img'] . '" width=20 height=20></a>';
} else {
echo '<img src="i/w6.gif" width=20 height=20 class=\'tooltip\' title=\'<b>Пустой слот Кольцо</b>\' />';
}
?></td>
<td><?php
if ($user['r3'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['r3']}' LIMIT 1;"));
$mess = 'Снять <b>' . $dress['name'] . '</b><br>Прочность ' . $dress['duration'] . '/' . $dress['maxdur'] . '';
echo '<a href="?edit=1&drop=7"><img class=\'tooltip\' title=\'' . $mess . '\' src="i/sh/' . $dress['img'] . '" width=20 height=20></a>';
} else {
echo '<img class=\'tooltip\' src="i/w6.gif" width=20 height=20 title=\'<b>Пустой слот Кольцо</b>\' />';
}
?></td>
</tr>
</TABLE>
</TD>
</TR>
</TABLE>
</TD>
<TD valign=top><img src="i/shadow/<?= $user['shadow'] ?>" width=76 height=209
alt="<?= $user['login'] ?>"></TD>
<TD width=62 valign=top>
<TABLE width=100% cellspacing=0 cellpadding=0>
<TR>
<TD><?php
if ($user['helm'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['helm']}' LIMIT 1;"));
$mess = 'Снять <b>' . $dress['name'] . '</b><br>Прочность ' . $dress['duration'] . '/' . $dress['maxdur'] . '';
echo '<a href="?edit=1&drop=8"><img class=\'tooltip\' title=\'' . $mess . '\' src="i/sh/' . $dress['img'] . '" width=60 height=60></a>';
} else {
echo '<img class=\'tooltip\' src="i/w9.gif" width=60 height=60 title=\'<b>Пустой слот Шлем</b>\' />';
}
?></TD>
</TR>
<TR>
<TD><?php
if ($user['perchi'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['perchi']}' LIMIT 1;"));
$mess = 'Снять <b>' . $dress['name'] . '</b><br>Прочность ' . $dress['duration'] . '/' . $dress['maxdur'] . '';
echo '<a href="?edit=1&drop=9"><img class=\'tooltip\' title=\'' . $mess . '\' src="i/sh/' . $dress['img'] . '" width=60 height=40></a>';
} else {
echo '<img class=\'tooltip\' src="i/w11.gif" width=60 height=40 title=\'<b>Пустой слот Перчатки</b>\' />';
}
?></TD>
</TR>
<TR>
<TD><?php
if ($user['shit'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['shit']}' LIMIT 1;"));
$mess = 'Снять <b>' . $dress['name'] . '</b><br>Прочность ' . $dress['duration'] . '/' . $dress['maxdur'] . '';
echo '<a href="?edit=1&drop=10"><img class=\'tooltip\' title=\'' . $mess . '\' src="i/sh/' . $dress['img'] . '" width=60 height=60></a>';
} else {
echo '<img class=\'tooltip\' src="i/w10.gif" width=60 height=60 title=\'<b>Пустой слот Щит</b>\' />';
}
?></TD>
</TR>
<TR>
<TD><?php
if
($user['boots'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['boots']}' LIMIT 1;"));
$mess = '<span style="min-width: 350px;">Снять <b>' . $dress['name'] . '</b><br>Прочность ' . $dress['duration'] . '/' . $dress['maxdur'] . '</span>';
echo '<a href="?edit=1&drop=11"><img class=\'tooltip\' title=\'' . $mess . '\' src="i/sh/' . $dress['img'] . '" width=60 height=40></a>';
} else {
echo '<img class=\'tooltip\' src="i/w12.gif" width=60 height=40 title=\'<b>Пустой слот Обувь</b>\' />';
}
?></TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
<table cellspacing="0" cellpadding="0" border="0"
style="background: url('http://i.oldbk.com/i/runes_slots.jpg') no-repeat center bottom;">
<tbody>
<tr>
<td width="59" height="48" align="right"><? echo show_rune(1, $user['id'], 1); ?></td>
<td width="74" height="48" align="center"><? echo show_rune(2, $user['id'], 1); ?></td>
<td width="57" height="48" align="left"><? echo show_rune(3, $user['id'], 1); ?></td>
</tr>
</tbody>
</table>
</CENTER> <?php
}
function updstats()
{
global $user;
@ -2032,7 +2647,7 @@ if (isset($_GET['edit'])) {
if ($d[0] < 0) {
$d[0] = 0;
}
$d = getweight($user['id']);
$d = mysql_fetch_array(mysql_query("SELECT SUM(`massa`) AS `weight`, COUNT(`id`) AS `cnt` FROM `inventory` WHERE `owner` = {$user['id']} AND `dressed` = 0 AND `setsale` = 0"));
echo $d['weight'] + 0;
?>/<?= get_meshok() ?>)</B>
</td>

207
shop.php
View File

@ -19,6 +19,213 @@ if ($user['battle'] != 0) {
$sellItemId = filter_input(INPUT_GET,'sellitem');
$saleItems = false;
/**
* Показать предмет в магазине
*
* @param $it
* @param string $from
* @return string
*/
function show_shop_items($it, $from = 'shop')
{
global $user;
$r = '';
$item = mysql_fetch_array(mysql_query("SELECT * FROM `{$from}` WHERE `id` = '{$it}' LIMIT 1"));
if (isset($item['id'])) {
$magic = db::c()->query('SELECT * FROM `magic` WHERE `id` = ?i', $item['magic'])->fetch_assoc();
$incmagic = mysql_fetch_array(mysql_query('SELECT * FROM `magic` WHERE `id` = "' . $item['includemagic'] . '" LIMIT 1'));
$incmagic['name'] = $item['includemagicname'];
$incmagic['cur'] = $item['includemagicdex'];
$incmagic['max'] = $item['includemagicmax'];
if (!$magic) {
$magic['chanse'] = $incmagic['chanse'];
$magic['time'] = $incmagic['time'];
$magic['targeted'] = $incmagic['targeted'];
}
if ($item['destiny'] > 0) {
$r .= "<a href=\"javascript: void(0);\">{$item['name']}</a><img src=\"i/align_{$item['nalign']}.gif\" />&nbsp;(Масса:&nbsp;{$item['massa']})<img src=\"i/destiny{$item['destiny']}.gif\" /><img src=\"i/artefact{$item['artefact']}.gif\" /><br />";
} else {
$r .= "<a href=\"javascript: void(0);\">{$item['name']}</a><img src=\"i/align_{$item['nalign']}.gif\" />&nbsp;(Масса:&nbsp;{$item['massa']})<img src=\"i/destiny{$item['destiny']}.gif\" /><img src=\"i/artefact{$item['artefact']}.gif\" /><br />";
}
if ($item['ecost'] > 0) {
$r .= "<b>Цена: {$item['ecost']} екр.</b> &nbsp; &nbsp;";
} elseif ($item['point'] > 0) {
$r .= "<b>Цена: {$item['point']} реп.</b> &nbsp; &nbsp;";
} else {
$r .= "<b>Цена: {$item['cost']} кр.</b> &nbsp; &nbsp;";
}
if ($item['zeton'] > 0) {
$r .= "<br /><b>Жетон: {$item['zeton']}</b>&nbsp<br />";
}
if (@$item['count']) {
$r .= "<small>(количество: {$item['count']})</small>";
}
if ($item['for_me'] > 0) {
$r .= '<br /><small style=\'color: Red;\'>После покупки вещь будет привязана к персонажу.</small>';
}
$r .= "<br />Долговечность: {$item['duration']}/{$item['maxdur']}";
$r .= "<br />";
if (!$item['needident']) {
if ($magic['chanse'] >= 98) {
$magic['chanse'] = 99;
}
$r .= (($magic['chanse']) ? "Вероятность срабатывания: " . $magic['chanse'] . "%<br />" : "") . "
" . (($magic['time']) ? "Продолжительность действия магии: " . $magic['time'] . " мин.<br />" : "") . "
" . (($item['goden']) ? "Срок годности: {$item['goden']} дн. " . ((!$item['count']) ? "(до " . date("Y.m.d H:i", $item['dategoden']) . ")" : "") . "<br />" : "") . "
" . (($item['nsila'] || $item['nlovk'] || $item['ninta'] || $item['nvinos'] || $item['nlevel'] || $item['nintel'] || $item['nmudra'] || $item['nnoj'] || $item['ntopor'] || $item['ndubina'] || $item['nmech'] || $item['nfire'] || $item['nwater'] || $item['nair'] || $item['nearth'] || $item['nearth'] || $item['nlight'] || $item['ngray'] || $item['ndark']) ? "<b>Требуется минимальное:</b><br />" : "") . "
" . (($item['nsila'] > 0) ? " " . (($item['nsila'] > $user['sila']) ? "<font color=red>" : "") . "Сила: {$item['nsila']}</font><br />" : "") . "
" . (($item['nlovk'] > 0) ? " " . (($item['nlovk'] > $user['lovk']) ? "<font color=red>" : "") . "Ловкость: {$item['nlovk']}</font><br />" : "") . "
" . (($item['ninta'] > 0) ? " " . (($item['ninta'] > $user['inta']) ? "<font color=red>" : "") . "Интуиция: {$item['ninta']}</font><br />" : "") . "
" . (($item['nvinos'] > 0) ? " " . (($item['nvinos'] > $user['vinos']) ? "<font color=red>" : "") . "Выносливость: {$item['nvinos']}</font><br />" : "") . "
" . (($item['nlevel'] > 0) ? " " . (($item['nlevel'] > $user['level']) ? "<font color=red>" : "") . "Уровень: {$item['nlevel']}</font><br />" : "") . "
" . (($item['nintel'] > 0) ? " " . (($item['nintel'] > $user['intel']) ? "<font color=red>" : "") . "Интеллект: {$item['nintel']}</font><br />" : "") . "
" . (($item['nnoj'] > 0) ? " " . (($item['nnoj'] > $user['noj']) ? "<font color=red>" : "") . "Мастерство владения ножами и кастетами: {$item['nnoj']}</font><br />" : "") . "
" . (($item['ntopor'] > 0) ? " " . (($item['ntopor'] > $user['topor']) ? "<font color=red>" : "") . "Мастерство владения топорами и секирами: {$item['ntopor']}</font><br />" : "") . "
" . (($item['ndubina'] > 0) ? " " . (($item['ndubina'] > $user['dubina']) ? "<font color=red>" : "") . "Мастерство владения дубинами и булавами: {$item['ndubina']}</font><br />" : "") . "
" . (($item['nmech'] > 0) ? " " . (($item['nmech'] > $user['mec']) ? "<font color=red>" : "") . "Мастерство владения мечами: {$item['nmech']}</font><br />" : "") . "
" . (($item['nfire'] > 0) ? " " . (($item['nfire'] > $user['mfire']) ? "<font color=red>" : "") . "Мастерство владения стихией Огня: {$item['nfire']}</font><br />" : "") . "
" . (($item['nwater'] > 0) ? " " . (($item['nwater'] > $user['mwater']) ? "<font color=red>" : "") . "Мастерство владения стихией Воды: {$item['nwater']}</font><br />" : "") . "
" . (($item['nair'] > 0) ? " " . (($item['nair'] > $user['mair']) ? "<font color=red>" : "") . "Мастерство владения стихией Воздуха: {$item['nair']}</font><br />" : "") . "
" . (($item['nearth'] > 0) ? " " . (($item['nearth'] > $user['mearth']) ? "<font color=red>" : "") . "Мастерство владения стихией Земли: {$item['nearth']}</font><br />" : "") . "
" . (($item['nlight'] > 0) ? " " . (($item['nlight'] > $user['mlight']) ? "<font color=red>" : "") . "Мастерство владения магией Света: {$item['nlight']}</font><br />" : "") . "
" . (($item['ngray'] > 0) ? " " . (($item['ngray'] > $user['mgray']) ? "<font color=red>" : "") . "Мастерство владения серой магией: {$item['ngray']}</font><br />" : "") . "
" . (($item['ndark'] > 0) ? " " . (($item['ndark'] > $user['mdark']) ? "<font color=red>" : "") . "Мастерство владения магией Тьмы: {$item['ndark']}</font><br />" : "") . "
" . (($item['gmeshok'] || $item['gsila'] || $item['mfkrit'] || $item['mfakrit'] || $item['mfuvorot'] || $item['mfauvorot'] || $item['glovk'] || $item['ghp'] || $item['ginta'] || $item['gintel'] || $item['gnoj'] || $item['gtopor'] || $item['gdubina'] || $item['gmech'] || $item['gfire'] || $item['gwater'] || $item['gair'] || $item['gearth'] || $item['gearth'] || $item['glight'] || $item['ggray'] || $item['gdark'] || $item['minu'] || $item['maxu'] || $item['bron1'] || $item['bron2'] || $item['bron3'] || $item['bron4']) ? "<b>Действует на:</b><br />" : "") . "
" . (($item['minu']) ? " Минимальное наносимое повреждение: +{$item['minu']}<br />" : "") . "
" . (($item['maxu']) ? " Максимальное наносимое повреждение: +{$item['maxu']}<br />" : "");
if ($item['gsila']) {
$r .= "• Сила: +" . $item['gsila'];
$r .= "<br />";
}
if ($item['glovk']) {
$r .= "• Ловкость: " . plusorminus($item['glovk']);
$r .= "<br />";
}
if ($item['ginta']) {
$r .= "• Интуиция: " . plusorminus($item['ginta']);
$r .= "<br />";
}
if ($item['gintel']) {
$r .= "• Интеллект: " . plusorminus($item['gintel']);
$r .= "<br />";
}
$r .= (($item['ghp']) ? "• Уровень жизни: " . plusorminus($item['ghp']) . "<br />" : "");
if ($item['mfkrit'] > 0) {
$r .= "• Мф. критических ударов: " . plusorminus($item['mfkrit']) . "%";
$r .= "<br />";
}
if ($item['mfakrit'] > 0) {
$r .= "• Мф. против крит. ударов: " . plusorminus($item['mfakrit']) . "%";
$r .= "<br />";
}
if ($item['mfuvorot'] > 0) {
$r .= "• Мф. увертливости: " . plusorminus($item['mfuvorot']) . "%";
$r .= "<br />";
}
if ($item['mfauvorot'] > 0) {
$r .= "• Мф. против увертлив.: " . plusorminus($item['mfauvorot']) . "%";
$r .= "<br />";
}
$r .= (($item['gnoj']) ? "• Мастерство владения ножами и кастетами: +{$item['gnoj']}<br />" : "") . "
" . (($item['gtopor']) ? " Мастерство владения топорами и секирами: +{$item['gtopor']}<br />" : "") . "
" . (($item['gdubina']) ? " Мастерство владения дубинами и булавами: +{$item['gdubina']}<br />" : "") . "
" . (($item['gmech']) ? " Мастерство владения мечами: +{$item['gmech']}<br />" : "") . "
" . (($item['gfire']) ? " Мастерство владения стихией Огня: +{$item['gfire']}<br />" : "") . "
" . (($item['gwater']) ? " Мастерство владения стихией Воды: +{$item['gwater']}<br />" : "") . "
" . (($item['gair']) ? " Мастерство владения стихией Воздуха: +{$item['gair']}<br />" : "") . "
" . (($item['gearth']) ? " Мастерство владения стихией Земли: +{$item['gearth']}<br />" : "") . "
" . (($item['glight']) ? " Мастерство владения магией Света: +{$item['glight']}<br />" : "") . "
" . (($item['ggray']) ? " Мастерство владения серой магией: +{$item['ggray']}<br />" : "") . "
" . (($item['gdark']) ? " Мастерство владения магией Тьмы: +{$item['gdark']}<br />" : "");
if ($item['bron1'] > 0) {
$r .= "• Броня головы: " . $item['bron1'];
$r .= "<br />";
}
if ($item['bron2'] > 0) {
$r .= "• Броня корпуса: " . $item['bron2'];
$r .= "<br />";
}
if ($item['bron3'] > 0) {
$r .= "• Броня пояса: " . $item['bron3'];
$r .= "<br />";
}
if ($item['bron4'] > 0) {
$r .= "• Броня ног: " . $item['bron4'];
$r .= "<br />";
}
$r .= (($item['gmeshok']) ? "• Увеличивает рюкзак: +{$item['gmeshok']}<br />" : "") . "
" . (($item['letter']) ? "Количество символов: " . strlen($item['letter']) . "</div>" : "") . "
" . (($item['letter']) ? "На бумаге записан текст:<div style='background-color:#FAF0E6;'> " . nl2br($item['letter']) . "</div>" : "") . "
" . (($item['opisan']) ? "&bull; " . nl2br($item['opisan']) . "<br />" : "") . "
" . (($magic['name'] && $item['type'] != 50) ? "<font color=maroon>Наложены заклятия:</font> " . $magic['name'] . "<br />" : "") . "
" . (($item['text']) ? "На ручке выгравирована надпись:<center>" . $item['text'] . "</center><br />" : "") . "
" . (($incmagic['max']) ? " Встроено заклятие <img src=\"i/magic/" . $incmagic['img'] . "\" /> " . $incmagic['cur'] . " шт. <br />" : "") . "
" . (($item['podzem']) ? "<font style='font-size:11px; color:#990000'>Предмет из подземелья</font><br />" : "") . "
" . (($item['laba'] == 1) ? "<font style='font-size: 11px; color:#990000'>Пропадёт если не найти выход</font><br />" : "") . "
" . (($item['laba'] == 2) ? "<font style='font-size: 11px; color:#990000'>Предмет пропадёт после выхода</font><br />" : "") . "
" . ((!$item['isrep']) ? "<small><font color=maroon>Предмет не подлежит ремонту</font></small><br />" : "");
if ($item['free_bron'] > 0) {
$r .= "<font color=blue>Свободных улучшений брони: " . $item['free_bron'] . "</font><br />";
}
if ($item['free_stat'] > 0) {
$r .= "<font color=blue>Свободных улучшений параметров: " . $item['free_stat'] . "</font><br />";
}
if ($item['free_mf'] > 0) {
$r .= "<font color=blue>Свободных улучшений модификаторов: " . $item['free_mf'] . "%</font><br />";
}
if ($item['add_proc_mf'] > 0 || $item['add_proc_uron'] > 0 || $item['add_proc_bron'] > 0) {
$r .= 'Усиление:<br />';
if ($item['add_proc_mf'] > 0) {
$r .= '&bull; Максимального мф.:' . plusorminus($item['add_proc_mf']) . '%<br />';
}
if ($item['add_proc_uron'] > 0) {
$r .= '&bull; Урона:' . plusorminus($item['add_proc_uron']) . '%<br />';
}
if ($item['add_proc_bron'] > 0) {
$r .= '&bull; Брони:' . plusorminus($item['add_proc_bron']) . '%<br />';
}
}
} else {
$r .= "<font color=maroon><b>Свойства предмета не идентифицированы</b></font><br />";
}
$osob = array(22, 23);
if (in_array($item['type'], $osob)) {
$r .= 'Особенности:<br />';
if ($item['type'] == 22) {
$r .= '&bull; может одеваться под броню<br />';
} elseif ($item['type'] == 23) {
$r .= '&bull; может одеваться на броню<br />';
}
}
$r .= "<small>Сделано в CapitalCity</small><br /></td></TR>";
} else {
$r = 'Предмет не найден : {' . $it . '}';
}
return $r;
}
if ($sellItemId && is_numeric($sellItemId)) {
$dress = db::c()->query('SELECT `id`, `name`, `cost`, `type`, `duration`, `maxdur`, `goden`, `dategoden`, `koll` FROM `inventory` WHERE `dressed` = 0 AND `id` = ?i AND `owner` = ?i', $sellItemId, $user['id'])->fetch_assoc();
$price = $dress['cost'] * 1;