Fix mysql

This commit is contained in:
Igor Barkov [iwork] 2018-11-01 18:44:20 +02:00
parent 4ae5b4ff17
commit c384e85730

View File

@ -341,25 +341,24 @@ 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)) {
$r = db::c()->query('SELECT * FROM `inventory` WHERE
`id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR
`id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR
`id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR `id` = ?i OR
`id` = ?i',
$user['helm'],$user['weap'],$user['plaw'],$user['bron'],$user['rybax'],$user['belt'],
$user['sergi'],$user['kulon'],$user['r1'],$user['r2'],$user['r3'],$user['perchi'],
$user['shit'],$user['leg'],$user['boots'],$user['m1'],$user['m2'],$user['m3'],$user['m4'],
$user['m5'],$user['m6'],$user['m7'],$user['m8'],$user['m9'],$user['m10']);
while ($rec = $r->fetch_assoc()) {
$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">;
<img src="i/align_<?= ($user['align'] > 0 ? $user['align'] : "0") ?>.gif">
<img src="i/klan/<?php 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>
<a href=inf.php?<?= $user['login'] ?> target=_blank><IMG SRC=i/inf.gif ALT="Инф. о <?= $user['login'] ?>"></a>
<TABLE cellspacing=0 cellpadding=0>
<tr>
@ -374,7 +373,7 @@ function showpersinv($id)
<TD colspan=3>
<? // TODO Сделать один запрос из десяти!
if ($user['m1'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['m1']}' LIMIT 1;"));
$dress = db::c()->query('SELECT `name`,`duration`,`maxdur`,`img` FROM `inventory` WHERE `id` = ?i',$user['m1'])->fetch_assoc();
$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 {
@ -382,7 +381,7 @@ function showpersinv($id)
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;"));
$dress = db::c()->query('SELECT `name`,`duration`,`maxdur`,`img` FROM `inventory` WHERE `id` = ?i',$user['m2'])->fetch_assoc();
$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 {
@ -390,7 +389,7 @@ function showpersinv($id)
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;"));
$dress = db::c()->query('SELECT `name`,`duration`,`maxdur`,`img` FROM `inventory` WHERE `id` = ?i',$user['m3'])->fetch_assoc();
$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 {
@ -398,7 +397,7 @@ function showpersinv($id)
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;"));
$dress = db::c()->query('SELECT `name`,`duration`,`maxdur`,`img` FROM `inventory` WHERE `id` = ?i',$user['m4'])->fetch_assoc();
$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 {
@ -406,7 +405,7 @@ function showpersinv($id)
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;"));
$dress = db::c()->query('SELECT `name`,`duration`,`maxdur`,`img` FROM `inventory` WHERE `id` = ?i',$user['m5'])->fetch_assoc();
$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 {
@ -420,7 +419,7 @@ function showpersinv($id)
<TD colspan=3>
<?
if ($user['m6'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['m6']}' LIMIT 1;"));
$dress = db::c()->query('SELECT `name`,`duration`,`maxdur`,`img` FROM `inventory` WHERE `id` = ?i',$user['m6'])->fetch_assoc();
$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 {
@ -428,7 +427,7 @@ function showpersinv($id)
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;"));
$dress = db::c()->query('SELECT `name`,`duration`,`maxdur`,`img` FROM `inventory` WHERE `id` = ?i',$user['m7'])->fetch_assoc();
$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 {
@ -436,7 +435,7 @@ function showpersinv($id)
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;"));
$dress = db::c()->query('SELECT `name`,`duration`,`maxdur`,`img` FROM `inventory` WHERE `id` = ?i',$user['m8'])->fetch_assoc();
$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 {
@ -444,7 +443,7 @@ function showpersinv($id)
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;"));
$dress = db::c()->query('SELECT `name`,`duration`,`maxdur`,`img` FROM `inventory` WHERE `id` = ?i',$user['m9'])->fetch_assoc();
$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 {
@ -452,7 +451,7 @@ function showpersinv($id)
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;"));
$dress = db::c()->query('SELECT `name`,`duration`,`maxdur`,`img` FROM `inventory` WHERE `id` = ?i',$user['m10'])->fetch_assoc();
$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 {
@ -470,7 +469,7 @@ function showpersinv($id)
<TR>
<TD><?php
if ($user['sergi'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['sergi']}' LIMIT 1;"));
$dress = db::c()->query('SELECT `name`,`duration`,`maxdur`,`img` FROM `inventory` WHERE `id` = ?i',$user['sergi'])->fetch_assoc();
$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 {
@ -481,7 +480,7 @@ function showpersinv($id)
<TR>
<TD><?php
if ($user['kulon'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['kulon']}' LIMIT 1;"));
$dress = db::c()->query('SELECT `name`,`duration`,`maxdur`,`img` FROM `inventory` WHERE `id` = ?i',$user['kulon'])->fetch_assoc();
$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 {
@ -492,7 +491,7 @@ function showpersinv($id)
<TR>
<TD><?php
if ($user['weap'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['weap']}' LIMIT 1;"));
$dress = db::c()->query('SELECT `name`,`duration`,`maxdur`,`img` FROM `inventory` WHERE `id` = ?i',$user['weap'])->fetch_assoc();
$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 {
@ -527,7 +526,7 @@ function showpersinv($id)
<tr>
<td><?php
if ($user['r1'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['r1']}' LIMIT 1;"));
$dress = db::c()->query('SELECT `name`,`duration`,`maxdur`,`img` FROM `inventory` WHERE `id` = ?i',$user['r1'])->fetch_assoc();
$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 {
@ -536,7 +535,7 @@ function showpersinv($id)
?></td>
<td><?php
if ($user['r2'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['r2']}' LIMIT 1;"));
$dress = db::c()->query('SELECT `name`,`duration`,`maxdur`,`img` FROM `inventory` WHERE `id` = ?i',$user['r2'])->fetch_assoc();
$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 {
@ -545,7 +544,7 @@ function showpersinv($id)
?></td>
<td><?php
if ($user['r3'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['r3']}' LIMIT 1;"));
$dress = db::c()->query('SELECT `name`,`duration`,`maxdur`,`img` FROM `inventory` WHERE `id` = ?i',$user['r3'])->fetch_assoc();
$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 {
@ -566,7 +565,7 @@ function showpersinv($id)
<TR>
<TD><?php
if ($user['helm'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['helm']}' LIMIT 1;"));
$dress = db::c()->query('SELECT `name`,`duration`,`maxdur`,`img` FROM `inventory` WHERE `id` = ?i',$user['helm'])->fetch_assoc();
$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 {
@ -577,7 +576,7 @@ function showpersinv($id)
<TR>
<TD><?php
if ($user['perchi'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['perchi']}' LIMIT 1;"));
$dress = db::c()->query('SELECT `name`,`duration`,`maxdur`,`img` FROM `inventory` WHERE `id` = ?i',$user['perchi'])->fetch_assoc();
$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 {
@ -588,7 +587,7 @@ function showpersinv($id)
<TR>
<TD><?php
if ($user['shit'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['shit']}' LIMIT 1;"));
$dress = db::c()->query('SELECT `name`,`duration`,`maxdur`,`img` FROM `inventory` WHERE `id` = ?i',$user['shit'])->fetch_assoc();
$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 {
@ -600,7 +599,7 @@ function showpersinv($id)
<TD><?php
if
($user['boots'] > 0) {
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$user['boots']}' LIMIT 1;"));
$dress = db::c()->query('SELECT `name`,`duration`,`maxdur`,`img` FROM `inventory` WHERE `id` = ?i',$user['boots'])->fetch_assoc();
$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 {
@ -631,13 +630,10 @@ function showpersinv($id)
function updstats()
{
global $user;
$u1 = mysql_fetch_array(mysql_query("
SELECT
`sila`, `lovk`, `inta`, `intel`,
`noj`, `mec`, `topor`, `dubina`,
`mfire`, `mwater`, `mair`, `mearth`,
`mlight`, `mgray`, `mdark`, `hp`, `maxhp`
FROM `users` WHERE `id` = '$user[id]' LIMIT 1"));
$u1 = db::c()->query('SELECT
`sila`, `lovk`, `inta`, `intel`, `noj`, `mec`, `topor`, `dubina`,
`mfire`, `mwater`, `mair`, `mearth`, `mlight`, `mgray`, `mdark`, `hp`, `maxhp`
FROM `users` WHERE `id` = ?i',$user['id'])->fetch_assoc();
foreach ($u1 as $k => $v) {
$user[$k] = $v;
}
@ -663,7 +659,7 @@ if (isset($_GET['stackall'])) {
if (isset($_GET["stack"])) {
$_GET["stack"] = (int)$_GET["stack"];
$rec = mysql_fetch_array(mysql_query("SELECT `id` FROM `inventory` WHERE `id` = '" . mysql_real_escape_string($_GET['stack']) . "' AND `owner` = '$user[id]' AND `setsale` = 0 LIMIT 1"));
$rec = db::c()->query('SELECT `id` FROM `inventory` WHERE `id` = ?i AND `owner` = ?i AND `setsale` = 0',$_GET['stack'],$user['id'])->fetch_assoc();
if (isset($rec['id'])) {
stack($rec['id']);
unset($rec);