Удаление mysql_query.

This commit is contained in:
Igor Barkov [iwork] 2018-06-22 19:46:48 +03:00
parent 20aa7316b6
commit 332d814360

107
ashop.php
View File

@ -15,7 +15,7 @@ if ($user['battle'] != 0) {
die(); die();
} }
$bank = mysql_fetch_array(mysql_query("SELECT * FROM `bank` WHERE `id`='" . $_SESSION['uid'] . "';")); $bank = db::c()->query('SELECT `ekr` FROM `bank` WHERE `id`=?i', $_SESSION['uid'])->fetch_assoc();
if (($_GET['set'] OR $_POST['set'])) { if (($_GET['set'] OR $_POST['set'])) {
if ($_GET['set']) { if ($_GET['set']) {
@ -35,7 +35,7 @@ if (($_GET['set'] OR $_POST['set'])) {
$count_ok = 0; $count_ok = 0;
} else $count_ok = 1; } else $count_ok = 1;
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `ashop` WHERE `id`='" . $set . "' LIMIT 1;")); $dress = db::c()->query('SELECT * FROM `ashop` WHERE `id`=?i', $set)->fetch_assoc();
if ($count_ok == 0) { if ($count_ok == 0) {
echo "<font color=red><b>Неправильно введено количество</b></font>"; echo "<font color=red><b>Неправильно введено количество</b></font>";
//$good = 0; //$good = 0;
@ -44,37 +44,44 @@ if (($_GET['set'] OR $_POST['set'])) {
//$good = 0; //$good = 0;
} elseif ($count_ok == 1 && ($bank['ekr'] >= ($dress['ecost'] * $_POST['count'])) && ($dress['count'] >= $_POST['count'])) { } elseif ($count_ok == 1 && ($bank['ekr'] >= ($dress['ecost'] * $_POST['count'])) && ($dress['count'] >= $_POST['count'])) {
for ($k = 1; $k <= $_POST['count']; $k++) { for ($k = 1; $k <= $_POST['count']; $k++) {
if (mysql_query("INSERT INTO `inventory` if (isset($dress['goden'])) $goden = $dress['goden'] * 24 * 60 * 60 + time(); // Ну вот нахуя?
(`prototype`,`owner`,`name`,`type`,`massa`,`cost`,`img`,`maxdur`,`isrep`, db::c()->query('
`gsila`,`glovk`,`ginta`,`gintel`,`ghp`,`gnoj`,`gtopor`,`gdubina`,`gmech`,`gfire`,`gwater`,`gair`,`gearth`,`glight`,`ggray`,`gdark`,`needident`,`nsila`,`nlovk`,`ninta`,`nintel`,`nmudra`,`nvinos`,`nnoj`,`ntopor`,`ndubina`,`nmech`,`nfire`,`nwater`,`nair`,`nearth`,`nlight`,`ngray`,`ndark`, INSERT INTO `inventory`
`mfkrit`,`mfakrit`,`mfuvorot`,`mfauvorot`,`bron1`,`bron2`,`bron3`,`bron4`,`maxu`,`minu`,`magic`,`nlevel`,`nalign`,`dategoden`,`goden`,`otdel`,`artefact`, `koll`) (
VALUES `prototype`,`owner`,`name`,`type`,`massa`,`cost`,`img`,`maxdur`,`isrep`,`gsila`,`glovk`,`ginta`,`gintel`,
('{$dress['id']}','{$_SESSION['uid']}','{$dress['name']}','{$dress['type']}',{$dress['massa']},{$dress['cost']},'{$dress['img']}',{$dress['maxdur']},{$dress['isrep']},'{$dress['gsila']}','{$dress['glovk']}','{$dress['ginta']}','{$dress['gintel']}','{$dress['ghp']}','{$dress['gnoj']}','{$dress['gtopor']}','{$dress['gdubina']}','{$dress['gmech']}','{$dress['gfire']}','{$dress['gwater']}','{$dress['gair']}','{$dress['gearth']}','{$dress['glight']}','{$dress['ggray']}','{$dress['gdark']}','{$dress['needident']}','{$dress['nsila']}','{$dress['nlovk']}','{$dress['ninta']}','{$dress['nintel']}','{$dress['nmudra']}','{$dress['nvinos']}','{$dress['nnoj']}','{$dress['ntopor']}','{$dress['ndubina']}','{$dress['nmech']}','{$dress['nfire']}','{$dress['nwater']}','{$dress['nair']}','{$dress['nearth']}','{$dress['nlight']}','{$dress['ngray']}','{$dress['ndark']}', `ghp`,`gnoj`,`gtopor`,`gdubina`,`gmech`,`gfire`,`gwater`,`gair`,`gearth`,`glight`,`ggray`,`gdark`,
'{$dress['mfkrit']}','{$dress['mfakrit']}','{$dress['mfuvorot']}','{$dress['mfauvorot']}','{$dress['bron1']}','{$dress['bron3']}','{$dress['bron2']}','{$dress['bron4']}','{$dress['maxu']}','{$dress['minu']}','{$dress['magic']}','{$dress['nlevel']}','{$dress['nalign']}','" . (($dress['goden']) ? ($dress['goden'] * 24 * 60 * 60 + time()) : "") . "','{$dress['goden']}','{$dress['razdel']}','{$dress['artefact']}', '{$dress['koll']}');")) { `needident`,`nsila`,`nlovk`,`ninta`,`nintel`,`nmudra`,`nvinos`,`nnoj`,`ntopor`,`ndubina`,`nmech`,
$good = 1; `nfire`,`nwater`,`nair`,`nearth`,`nlight`,`ngray`,`ndark`,`mfkrit`,`mfakrit`,`mfuvorot`,`mfauvorot`,
} else { `bron1`,`bron2`,`bron3`,`bron4`,`maxu`,`minu`,`magic`,`nlevel`,`nalign`,`dategoden`,`goden`,`otdel`,
$good = 0; `artefact`, `koll`
} )
} VALUES (?i,?i,"?s",?i,?i,"?s","?s",?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i)
if ($good) { ', $dress['id'], $_SESSION['uid'], $dress['name'], $dress['type'], $dress['massa'], $dress['cost'], $dress['img'], $dress['maxdur'], $dress['isrep'],
mysql_query("UPDATE `ashop` SET `count`=`count`-" . $_POST['count'] . " WHERE `id`='" . $set . "' LIMIT 1;"); $dress['gsila'], $dress['glovk'], $dress['ginta'], $dress['gintel'], $dress['ghp'], $dress['gnoj'], $dress['gtopor'], $dress['gdubina'], $dress['gmech'],
$limit = $_POST['count']; $dress['gfire'], $dress['gwater'], $dress['gair'], $dress['gearth'], $dress['glight'], $dress['ggray'], $dress['gdark'], $dress['needident'],
$invdb = mysql_query("SELECT `id` FROM `inventory` WHERE `name` = '" . $dress['name'] . "' ORDER by `id` DESC LIMIT " . $limit . ";"); $dress['nsila'], $dress['nlovk'], $dress['ninta'], $dress['nintel'], $dress['nmudra'], $dress['nvinos'], $dress['nnoj'], $dress['ntopor'], $dress['ndubina'], $dress['nmech'],
if ($limit == 1) { $dress['nfire'], $dress['nwater'], $dress['nair'], $dress['nearth'], $dress['nlight'], $dress['ngray'], $dress['ndark'], $dress['mfkrit'], $dress['mfakrit'],
$dressinv = mysql_fetch_array($invdb); $dress['mfuvorot'], $dress['mfauvorot'], $dress['bron1'], $dress['bron3'], $dress['bron2'], $dress['bron4'], $dress['maxu'], $dress['minu'], $dress['magic'],
$dress['nlevel'], $dress['nalign'], $goden, $dress['goden'], $dress['razdel'], $dress['artefact'], $dress['koll']);
db::c()->query('UPDATE `ashop` SET `count` = `count`- ?i WHERE `id` = ?i', $_POST['count'], $set);
$invdb = db::c()->query('SELECT `id` FROM `inventory` WHERE `name` = "?s" ORDER by `id` DESC LIMIT ?i', $dress['name'], $_POST['count']);
if ($_POST['count'] == 1) {
$dressinv = $invdb->fetch_assoc();
$dressid = "cap" . $dressinv['id']; $dressid = "cap" . $dressinv['id'];
$dresscount = " "; $dresscount = " ";
} else { } else {
$dressid = ""; $dressid = "";
while ($dressinv = mysql_fetch_array($invdb)) { while ($dressinv = $invdb->fetch_assoc()) {
$dressid .= "cap" . $dressinv['id'] . ","; $dressid .= "cap" . $dressinv['id'] . ",";
} }
$dresscount = "(x" . $_POST['count'] . ") "; $dresscount = "(x" . $_POST['count'] . ") ";
} }
$allcost = $_POST['count'] * $dress['ecost']; $allcost = $_POST['count'] * $dress['ecost'];
mysql_query("INSERT INTO `delo` (`id` , `author` ,`pers`, `text`, `type`, `date`) VALUES ('','0','{$_SESSION['uid']}','\"" . $user['login'] . "\" купил товар: \"" . $dress['name'] . "\" " . $dresscount . "id:(" . $dressid . ") [0/" . $dress['maxdur'] . "] за " . $allcost . " екр. ',1,'" . time() . "');"); $deloText = $user['login'] . " купил товар: " . $dress['name'] . $dresscount . "id:(" . $dressid . ") [0/" . $dress['maxdur'] . "] за " . $allcost . " екр.";
db::c()->query('INSERT INTO `delo` (`author` ,`pers`, `text`, `type`, `date`) VALUES (?i, ?i, "?s", ?i, "?s")', 0, $user['id'], $deloText, 1, time());
echo "<font color=red><b>Вы купили {$_POST['count']} шт. \"{$dress['name']}\".</b></font>"; echo "<font color=red><b>Вы купили {$_POST['count']} шт. \"{$dress['name']}\".</b></font>";
mysql_query("UPDATE `bank` set `ekr`=`ekr`-'" . ($allcost) . "' WHERE `id`='" . $_SESSION['uid'] . "';"); db::c()->query('UPDATE `bank` set `ekr` = `ekr` - ?i WHERE `id` = ?i', $allcost, $_SESSION['uid']);
$bank['ekr'] -= $allcost; $bank['ekr'] -= $allcost;
} }
} else { } else {
@ -209,7 +216,7 @@ if (($_GET['set'] OR $_POST['set'])) {
<? <?
if ($_REQUEST['present']) { if ($_REQUEST['present']) {
if ($_POST['to_login'] && $_POST['flower']) { if ($_POST['to_login'] && $_POST['flower']) {
$to = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `login`='" . $_POST['to_login'] . "' LIMIT 1;")); $to = db::c()->query('SELECT `id`,`login`,`room` FROM `users` WHERE `login` = ?i', $_POST['to_login'])->fetch_assoc();
if ($_POST['to_login'] == $user['login']) { if ($_POST['to_login'] == $user['login']) {
echo "<b><font color=red>Очень щедро дарить что-то самому себе ;)</font></b>"; echo "<b><font color=red>Очень щедро дарить что-то самому себе ;)</font></b>";
} elseif ($to['room'] > 500 && $to['room'] < 561) { } elseif ($to['room'] > 500 && $to['room'] < 561) {
@ -222,31 +229,18 @@ if (($_GET['set'] OR $_POST['set'])) {
} else { } else {
$from = $user['login']; $from = $user['login'];
} }
if ($to) if (mysql_query("UPDATE `inventory` SET `owner`='" . $to['id'] . "', `present`='" . $from . "', `letter`='" . $_POST['podarok2'] . "' WHERE `present`='' AND `id`='" . $_POST['flower'] . "' AND `owner`='" . $_SESSION['uid'] . "' AND `dressed`=0 AND `setsale`=0;")) {
$res = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '" . $_POST['flower'] . "' LIMIT 1;")); db::c()->query('UPDATE `inventory` SET `owner` = ?i, `present` = "?s", `letter` = "?s" WHERE `present` = "?s" AND `id` = ?i AND `owner` = ?i AND `dressed` = 0 AND `setsale` = 0', $to['id'], $from, $_POST['podarok2'], null, $_POST['flower'], $_SESSION['uid']);
$buket_name = $res['name']; $res = db::c()->query('SELECT `id`,`name`,`duration`,`maxdur` FROM `inventory` WHERE `id` = ?i', $_POST['flower'])->fetch_assoc();
mysql_query("INSERT INTO `delo`(`id`,`author`,`pers`,`text`,`type`,`date`) VALUES ('','0','" . $_SESSION['uid'] . "','Подарен предмет \"" . $res['name'] . "\" id:(cap" . $res['id'] . ") [" . $res['duration'] . "/" . $res['maxdur'] . "] от \"" . $from . "\" к \"" . $to['login'] . "\"','1','" . time() . "');"); $deloTextSender = "Подарен предмет \"" . $res['name'] . "\" id:(cap" . $res['id'] . ") [" . $res['duration'] . "/" . $res['maxdur'] . "] от \"" . $user['login'] . "\" к \"" . $to['login'] . "\"";
mysql_query("INSERT INTO `delo`(`id`,`author`,`pers`,`text`,`type`,`date`) VALUES ('','0','{$to['id']}','Подарен предмет \"" . $res['name'] . "\" id:(cap" . $res['id'] . ") [" . $res['duration'] . "/" . $res['maxdur'] . "] от \"" . $from . "\" к \"" . $to['login'] . "\"','1','" . time() . "');"); $deloTextReceiver = "Подарен предмет \"" . $res['name'] . "\" id:(cap" . $res['id'] . ") [" . $res['duration'] . "/" . $res['maxdur'] . "] от \"" . $user['login'] . "\" к \"" . $to['login'] . "\"";
if (($_POST['from'] == 1) || ($_POST['from'] == 2)) { db::c()->query('INSERT INTO `delo`(`author`,`pers`,`text`,`type`,`date`) VALUES (0,?i,"?s",1,?i)', $_SESSION['uid'], $deloTextSender, time());
$action = "подарил"; db::c()->query('INSERT INTO `delo`(`author`,`pers`,`text`,`type`,`date`) VALUES (0,?i,"?s",1,?i)', $to['id'], $deloTextReceiver, time());
mysql_query("INSERT INTO `delo`(`id`,`author`,`pers`,`text`,`type`,`date`) VALUES ('','0','" . $to['id'] . "','Подарен предмет \"" . $res['name'] . "\" id:(cap" . $res['id'] . ") [" . $res['duration'] . "/" . $res['maxdur'] . "] от \"" . $user['login'] . "\" к \"" . $to['login'] . "\"','5','" . time() . "');");
} else { $telegraphText = "Вам пришёл подарок \"" . $res['name'] . "\" от " . $from . "!";
if ($user['sex'] == 0) { db::c()->query('INSERT INTO `telegraph` (owner, text) VALUES (?i,"?s")', $to['id'], $telegraphText)->fetch_assoc();
$action = "подарила";
} else { err('Подарок удачно доставлен к ' . $_POST['to_login']);
$action = "подарил";
}
}
$us = mysql_fetch_array(mysql_query("select `id` from `online` WHERE `date`>=" . (time() - 60) . " AND `id` = '" . $to['id'] . "' LIMIT 1;"));
if ($us[0]) {
addchp('<font color=red>Внимание!</font> <span oncontextmenu=OpenMenu()>' . $from . '</span> ' . $action . ' вам <b>' . $buket_name . '</b>. ', '{[]}' . $_POST['to_login'] . '{[]}');
} else {
// если в офе
mysql_query("INSERT INTO `telegraph` (`owner`,`date`,`text`) values ('" . $to['id'] . "','','" . '<font color=red>Внимание!</font> <span oncontextmenu=OpenMenu()>' . $from . '</span> ' . $action . ' вам <b>' . $buket_name . '</b>. ' . "');");
}
echo "<b><font color=red>Подарок удачно доставлен к \"", $_POST['to_login'], "\"</font></b>";
}
echo mysql_error();
} }
} }
?> ?>
@ -279,8 +273,15 @@ if (($_GET['set'] OR $_POST['set'])) {
bgcolor="#A5A5A5"> bgcolor="#A5A5A5">
<? <?
//print_r($_POST); //print_r($_POST);
$data = mysql_query("SELECT * FROM `inventory` WHERE `owner`='" . $_SESSION['uid'] . "' AND `dressed`=0 AND (`name` LIKE '%Букет%' OR `name` LIKE '%Сувенир%' OR `name` LIKE '%Подарок%' OR `name` LIKE '%Валентинка%' OR `name` LIKE '%Открытка%' OR `name` LIKE 'Ель%' OR `name` LIKE '%Медаль%' OR `name` LIKE '%Статуэтка%') AND `setsale`=0 AND `present` = '' ORDER by `id` DESC;"); $data = db::c()->query('SELECT `id`,`img` FROM `inventory` WHERE `owner`= ?i
while ($row = mysql_fetch_array($data)) { AND `dressed` = 0
AND (
`name` LIKE "?S" OR `name` LIKE "?S" OR `name` LIKE "?S" OR `name` LIKE "?S" OR `name` LIKE "?S" OR
`name` LIKE "?S" OR `name` LIKE "?S" OR `name` LIKE "?S"
)
AND `setsale` = 0 AND `present` = "?s"
ORDER by `id` DESC', $_SESSION['uid'], '%Букет%','%Сувенир%','%Подарок%','%Валентинка%','%Открытка%','Ель%','%Медаль%','%Статуэтка%',null);
while ($row = $data->fetch_assoc()) {
if (!in_array($row['id'], array_keys($_SESSION['flowers']))) { if (!in_array($row['id'], array_keys($_SESSION['flowers']))) {
$row['count'] = 1; $row['count'] = 1;
if ($i == 0) { if ($i == 0) {
@ -306,8 +307,8 @@ if (($_GET['set'] OR $_POST['set'])) {
</form> </form>
<? <?
} else { } else {
$data = mysql_query("SELECT * FROM `ashop` WHERE `count`>0 AND `razdel`='" . $_GET['otdel'] . "' AND `ecost`>0 ORDER by `ecost` ASC;"); $data = db::c()->query('SELECT `id`,`img`,`name` FROM `ashop` WHERE `count` > 0 AND `razdel` = ?i AND `ecost` > 0 ORDER by `ecost` ASC', $_GET['otdel']);
while ($row = mysql_fetch_array($data)) { while ($row = $data->fetch_assoc()) {
if ($i == 0) { if ($i == 0) {
$i = 1; $i = 1;
$color = '#C7C7C7'; $color = '#C7C7C7';