Handle exceptions.
This commit is contained in:
parent
39c56ea1c1
commit
b0e92398c3
21
main.php
21
main.php
@ -10,7 +10,9 @@ if ($get === 'exit') {
|
||||
if (!isset($_SESSION['uid'])) {
|
||||
header("Location: index.php");
|
||||
}
|
||||
echo '1';
|
||||
require_once 'functions.php';
|
||||
echo '2';
|
||||
$tmaz = time();
|
||||
try {
|
||||
db::c()->query('UPDATE `online` SET `real_time` = ?i WHERE `id` = ?i', time(), $user['id']);
|
||||
@ -274,11 +276,17 @@ function unstack($it_id, $it_count)
|
||||
$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"));
|
||||
|
||||
try {
|
||||
$dress = db::c()->query('SELECT * FROM inventory WHERE owner = ?i AND id = ?i', $user['id'], $it_id)->fetch_assoc_array();
|
||||
}
|
||||
catch(\Krugozor\Database\Mysql\Exception $e) {
|
||||
echo "<div style='background-color: #ffaaaa;'>Ошибка: " . $e->getMessage() . "<br> В файле: " . $e->getFile() . " (" . $e->getLine() . ")</div>";
|
||||
}
|
||||
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');
|
||||
db::c()->query('DELETE FROM inventory WHERE owner = ?i AND id = ?i', $user['id'], $dress['id']);
|
||||
} else {
|
||||
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 . ") WHERE `id` = '$dress[id]' AND `owner` = '$user[id]' LIMIT 1");
|
||||
}
|
||||
@ -866,8 +874,13 @@ if (isset($_GET['del']) && $_GET['del'] == 1 && $_GET['efid'] > 0) {
|
||||
if (isset($_GET['modif_bron'])) {
|
||||
$brons = $_GET['modif_bron'];
|
||||
$ids = $_GET['ids'];
|
||||
$cur = mysql_fetch_assoc(mysql_query("SELECT `id`, `free_bron`, `bron1`, `bron2`, `bron3`, `bron4` FROM `inventory` WHERE `owner` = '" . $user['id'] . "' AND `id` = '" . mysql_real_escape_string($ids) . "' LIMIT 1"));
|
||||
if (isset($cur['id']) && $cur['free_bron'] > 0 && $cur[$brons] > 0) {
|
||||
try {
|
||||
$cur = db::c()->query('SELECT free_bron, bron1, bron2, bron3, bron4 FROM inventory WHERE owner = ?i AND id = ?i', $user['id'], $ids)->fetch_assoc();
|
||||
}
|
||||
catch (\Krugozor\Database\Mysql\Exception $e) {
|
||||
echo "<div style='background-color: #ffaaaa;'>Ошибка: " . $e->getMessage() . "<br> В файле: " . $e->getFile() . " (" . $e->getLine() . ")</div>";
|
||||
}
|
||||
if ($cur['free_bron'] > 0 && $cur[$brons] > 0) {
|
||||
mysql_query("UPDATE `inventory` SET `free_bron` = (`free_bron`-1), `" . $brons . "` = (`" . $brons . "`+1) WHERE `owner` = '" . $user['id'] . "' AND `id` = '" . mysql_real_escape_string($ids) . "' LIMIT 1");
|
||||
echo "<span class='success'>Параметр брони увеличен!</span>";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user