Обновление sql, чистка неипользуемого кода.

This commit is contained in:
lopar 2018-01-30 00:05:41 +02:00
parent ecf5a4fe96
commit f40e15c470
2 changed files with 20 additions and 88 deletions

View File

@ -1,4 +1,10 @@
<?php
/**
* Copyright (c) 2018.
* Author: Igor Barkov <lopar.4ever@gmail.com>
* Project name: Battles-Game
*/
ini_set('display_errors', 'On');
error_reporting(E_ALL);
define("GAMEDOMAIN","combats.loc");
@ -8,6 +14,4 @@ $var_security = array('g_login' => array('align' => array(2.99), 'id' => array(1
require_once('Database/Mysql.php');
require_once('Database/Exception.php');
require_once('Database/Statement.php');
require_once('Database/db.php');
?>
require_once('Database/db.php');

View File

@ -1,4 +1,10 @@
<?php
/**
* Copyright (c) 2018.
* Author: Igor Barkov <lopar.4ever@gmail.com>
* Project name: Battles-Game
*/
require_once 'config.php';
define("HPADDICTIONEFFECT", 33);
@ -36,12 +42,10 @@ $unkilable = array(
$runes_exp = array('1' => 10500, '2' => 23500, '3' => 38500, '4' => 57000, '5' => 77000, '6' => 103000, '7' => 136500, '8' => 171500, '9' => 212500, '10' => 257500);
#####
$canalenters = array(620);
$caverooms = array(621);
$userslots = array('sergi', 'kulon', 'perchi', 'weap', 'bron', 'r1', 'r2', 'r3', 'helm', 'shit', 'boots', 'rybax', 'plaw', 'm1', 'm2', 'm3', 'm4', 'm5', 'm6', 'm7', 'm8', 'm9', 'm10');
//$dressslots = array('sergi', 'kulon', 'perchi', 'weap', 'bron', 'r1', 'r2', 'r3', 'helm', 'shit', 'boots', 'rybax', 'plaw', 'rune_1', 'rune_2', 'rune_3');
function getuserdata($id = 0)
{
@ -61,7 +65,7 @@ if (!isset($user)) {
$user = getuserdata();
}
if (empty($user['battle']) && $user['hp'] < $user['maxhp']) {
if (empty($user['battle']) && ($user['hp'] < @$user['maxhp'])) {
regenhp($user);
}
@ -77,8 +81,6 @@ function auth_bank($id, $pass, $us)
if ($bn['pass'] == md5($pass)) {
setcookie('inder', $bn['id'], time() + 60 * 60 * 24 * 7, '/', GAMEDOMAIN, 0, true);
$banks['id'] = $bn['id'];
// $banks['cr'] = $banks['cr'];
// $banks['ekr'] = $banks['ekr'];
$msg = 'Успешная авторизация ...';
} else {
$msg = 'Неверный пароль ...';
@ -196,15 +198,6 @@ function redirectbyroom($r)
}
}
//function test_quest($u, $t) {
// $sp = mysql_fetch_array(mysql_query('SELECT `id` FROM `quest_user` WHERE `uid` = "'.$u.'" AND `type` = "'.$t.'" AND `end` = 0 LIMIT 1'));
// if(isset($sp['id'])) {
// return $sp;
// } else {
// return false;
// }
//}
function battlewithbot($b, $name = '', $time = 3, $blood = 1, $group = 1, $battleid = 0, $otherbots = array(), $noredir = 0, $userid = 0, $type = 1)
{
global $user;
@ -429,37 +422,6 @@ function secs2hrs($s, $short = 0)
return floor($s / 60) . " мин. " . ($s % 60) . " сек.";
}
///* Либо я тугой, либо эти две функции нигде не используются. */
//function list_q($u, $par)
//{
// $sp = mysql_query('SELECT `id`, `vars` FROM `actions` WHERE `vars` LIKE "start_quest%" AND `vals` = "go" ORDER BY `id` DESC');
// while ($pl = mysql_fetch_array($sp)) {
// $quest = mysql_fetch_array(mysql_query('SELECT `id`, `act_date` FROM `quests` WHERE `id` = "' . str_replace('start_quest', '', $pl['vars']) . '" LIMIT 1'));
// if (isset($quest['id'])) {
// $d = explod($quest['act_date']);
// if (isset($d['kill_bot']) && $par == $d['kill_bot']) {
// return 1;
// }
// }
// }
// return 0;
//}
//
//function explod($d)
//{
// $i = 0;
// $e = explode(':|:', $d);
// while ($i < count($e)) {
// $t = explode(':=:', $e[$i]);
// if (isset($t[0])) {
// $dr[$t[0]] = $t[1];
// }
// $i++;
// }
// unset($i, $e, $t);
// return $dr;
//} /* Либо я тугой, либо эти две функции нигде не используются. END*/
function show_itm_hostel($uid, $otdel, $type = 1)
{
$r = '';
@ -686,12 +648,6 @@ function bank_check($item, $table = "shop", $present = '', $onlyonetrip = '', $f
$rec1['cost'] = $cost;
}
// if ($fields) {
// foreach ($fields as $k => $v) {
// $rec1[$k] = $v;
// }
// }
$sql = "";
while ($rec = mysql_fetch_assoc($r)) {
if (!$flds[$rec['Field']]) continue;
@ -1519,41 +1475,13 @@ header("Cache-Control: no-cache");
function level_up($uid)
{
global $exptable, $RefBonus;
$us = mysql_fetch_array(mysql_query('SELECT `id`, `login`, `level`, `money`, `sex`, `exp`, `vinos`, `nextup`, `stats`, `master`, `maxhp`, `refer`, `ip`, `in_tower` FROM `users` WHERE `id` = "' . $uid . '" LIMIT 1'));
global $exptable;
$us = db::c()->query('SELECT `id`, `login`, `level`, `money`, `sex`, `exp`, `vinos`, `nextup`, `stats`, `master`, `maxhp`, `refer`, `ip`, `in_tower` FROM `users` WHERE `id` =?i', $uid)->fetch_assoc();
if (isset($us['id'])) {
if ($us['exp'] >= $us['nextup'] && !$us['in_tower']) {
if ($exptable[$us['nextup']][4] == 1) {
if ($us['sex'] == 1) {
addch("<font color=\"Black\">Персонаж <b>{$us['login']}</b> перешел на " . ($us['level'] + 1) . " уровень.</font>");
} else {
addch("<font color=\"Black\">Персонаж <b>{$us['login']}</b> перешел на " . ($us['level'] + 1) . " уровень.</font>");
}
addch("Персонаж <b>{$us['login']}</b> перешел на " . ($us['level'] + 1) . " уровень.");
addchp('<font color=red>Внимание!</font> Вы перешли на новый уровень. За это Вы получаете: ' . $exptable[$us['nextup']][3] . ' кр.', '{[]}' . $us['login'] . '{[]}');
#####
$ReferalIP = mysql_fetch_array(mysql_query("SELECT `ip` FROM `users` WHERE `id` = {$us['refer']} LIMIT 1"));
$ReferalIP = $ReferalIP['ip'];
if (!empty($ReferalIP) && ($us['ip'] != $ReferalIP) && in_array($us['level'] + 1, array_keys($RefBonus))) {
if ($RefBonus[$us['level'] + 1][0] > 0) {
$text = "<font color=red>Внимание!</font> <font color=\"Black\">Персонаж <b>" . $us['login'] . "</b> перешел на " . ($us['level'] + 1) . " уровень.";
GiveKr($us['refer'], $RefBonus[$us['level'] + 1][0], null);
mysql_query("INSERT INTO `referal` (`money`, `master_id`, `ref_id`, `date`) VALUES('" . $RefBonus[$us['level'] + 1][0] . "', '{$us['refer']}', '{$us['id']}', '" . time() . "')");
$text .= ' Вам перечислено ' . $RefBonus[$us['level'] + 1][0] . ' кр. ';
if ($RefBonus[$us['level'] + 1][1] > 0) {
GiveDoblest($us['refer'], $RefBonus[$us['level'] + 1][1], null);
$text .= ' Вы получили ' . $RefBonus[$us['level'] + 1][1] . ' доблести.';
}
$text .= "</font>";
}
$RefOnline = mysql_fetch_array(mysql_query("SELECT `id` FROM `online` WHERE `date` >= " . (time() - 60) . " AND `id` = '{$us['refer']}' LIMIT 1"));
if ($RefOnline[0]) {
addchp($text, '{[]}' . nick7($us['refer']) . '{[]}');
} else {
mysql_query("INSERT INTO `telegraph` (`owner`, `date`, `text`) values ('{$us['refer']}', '', '{$text}')");
}
}
$us['level'] += $exptable[$us['nextup']][4];
####
} elseif ($exptable[$us['nextup']][4] == 0) {
addchp('<font color=red>Внимание!</font> Вы перешли на новый АП. За это Вы получаете: ' . $exptable[$us['nextup']][3] . ' кр.', '{[]}' . $us['login'] . '{[]}');
}
@ -1563,13 +1491,13 @@ function level_up($uid)
$us['vinos'] += $exptable[$us['nextup']][2];
$us['maxhp'] += ($exptable[$us['nextup']][2] * 6);
$us['money'] += $exptable[$us['nextup']][3];
mysql_query('UPDATE `users` SET `nextup` = "' . $us['nextup'] . '", `stats` = "' . $us['stats'] . '", `master` = "' . $us['master'] . '", `vinos` = "' . $us['vinos'] . '", `maxhp` = "' . $us['maxhp'] . '", `money` = "' . $us['money'] . '", `level` = "' . $us['level'] . '" WHERE `id` = "' . $us['id'] . '" LIMIT 1');
db::c()->query('UPDATE `users` SET `nextup` = ?i, `stats` = ?i, `master` = ?i, `vinos` = ?i, `maxhp` = ?i, `money` = ?i, `level` = ?i WHERE `id` = ?i', $us['nextup'], $us['stats'], $us['master'], $us['vinos'], $us['maxhp'], $us['money'], $us['level'], $us['id']);
}
}
}
########
$in_user = mysql_fetch_array(mysql_query("SELECT `id`, `exp`, `nextup`, `level` FROM `users` WHERE `id` = {$_SESSION['uid']} LIMIT 1"));
######## FIXME ВЕЧНЫЕ 12-ТКИ!!!!!!!!!!!!
$in_user = db::c()->query('SELECT `id`, `exp`, `nextup`, `level` FROM `users` WHERE `id` = ?i', $_SESSION['uid'])->fetch_assoc();
if (isset($in_user['id']) && ($in_user['exp'] >= $in_user['nextup']) && $in_user['level'] < 13) {
level_up($in_user['id']);
}