Handle exceptions.

This commit is contained in:
Igor Barkov (iwork) 2020-06-23 16:13:25 +03:00
parent 9ce4a48f42
commit 39c56ea1c1

View File

@ -12,7 +12,11 @@ if (!isset($_SESSION['uid'])) {
}
require_once 'functions.php';
$tmaz = time();
db::c()->query('UPDATE `online` SET `real_time` = ?i WHERE `id` = ?i', time(), $user['id']);
try {
db::c()->query('UPDATE `online` SET `real_time` = ?i WHERE `id` = ?i', time(), $user['id']);
} catch (\Krugozor\Database\Mysql\Exception $e) {
echo "<div style='background-color: #ffaaaa;'>Ошибка: " . $e->getMessage() . "<br> В файле: " . $e->getFile() . " (" . $e->getLine() . ")</div>";
}
if ($user['battle'] != 0) {
header('location: fbattle.php');
die();
@ -186,7 +190,11 @@ if ($user['room'] == 666) {
function sum_mf($u)
{
$sum = db::c()->query('SELECT SUM(`add_proc_mf`) AS `mf` FROM `inventory` WHERE `dressed` = 1 AND `add_proc_mf` > 0 AND `owner` = ?i', $u);
try {
$sum = db::c()->query('SELECT SUM(`add_proc_mf`) AS `mf` FROM `inventory` WHERE `dressed` = 1 AND `add_proc_mf` > 0 AND `owner` = ?i', $u);
} catch (\Krugozor\Database\Mysql\Exception $e) {
echo "<div style='background-color: #ffaaaa;'>Ошибка: " . $e->getMessage() . "<br> В файле: " . $e->getFile() . " (" . $e->getLine() . ")</div>";
}
if ($sum->fetch_assoc() > 0) {
return $sum;
} else {
@ -196,7 +204,11 @@ function sum_mf($u)
function sum_dmg($u)
{
$sum = db::c()->query('SELECT SUM(`add_proc_uron`) AS `mf` FROM `inventory` WHERE `dressed` = 1 AND `add_proc_uron` > 0 AND `owner` = ?i', $u);
try {
$sum = db::c()->query('SELECT SUM(`add_proc_uron`) AS `mf` FROM `inventory` WHERE `dressed` = 1 AND `add_proc_uron` > 0 AND `owner` = ?i', $u);
} catch (\Krugozor\Database\Mysql\Exception $e) {
echo "<div style='background-color: #ffaaaa;'>Ошибка: " . $e->getMessage() . "<br> В файле: " . $e->getFile() . " (" . $e->getLine() . ")</div>";
}
if ($sum->fetch_assoc() > 0) {
return $sum;
} else {
@ -206,7 +218,11 @@ function sum_dmg($u)
function sum_bron($u)
{
$sum = db::c()->query('SELECT SUM(`add_proc_bron`) AS `mf` FROM `inventory` WHERE `dressed` = 1 AND `add_proc_bron` > 0 AND `owner` = ?i', $u);
try {
$sum = db::c()->query('SELECT SUM(`add_proc_bron`) AS `mf` FROM `inventory` WHERE `dressed` = 1 AND `add_proc_bron` > 0 AND `owner` = ?i', $u);
} catch (\Krugozor\Database\Mysql\Exception $e) {
echo "<div style='background-color: #ffaaaa;'>Ошибка: " . $e->getMessage() . "<br> В файле: " . $e->getFile() . " (" . $e->getLine() . ")</div>";
}
if ($sum->fetch_assoc() > 0) {
return $sum;
} else {
@ -1098,13 +1114,13 @@ if (input::get('edit')) {
function setHPlocal() {
tkHP > maxHP && (tkHP = maxHP);
var a = Math.round(tkHP) + "/" + maxHP;
let a = Math.round(tkHP) + "/" + maxHP;
a = stLen - (a.length + 2) * 7;
var b = Math.round((a - 1) / maxHP * tkHP);
const b = Math.round((a - 1) / maxHP * tkHP);
a -= b;
var HP = document.getElementById("hp_value");
var HP1 = document.getElementById("HP1");
var HP2 = document.getElementById("HP2");
const HP = document.getElementById("hp_value");
const HP1 = document.getElementById("HP1");
const HP2 = document.getElementById("HP2");
if (HP) {
HP1.width = b, HP2.width = a, HP1.src = tkHP / maxHP < redHP ? "i/1red.gif" : tkHP / maxHP < yellowHP ? "i/1yellow.gif" : "i/1green.gif", HP.innerHTML = Math.round(tkHP) + "/" + maxHP;
}
@ -1166,6 +1182,7 @@ if (input::get('edit')) {
-webkit-border-radius: 5px;
}
</style>
<title></title>
</HEAD>
<body>
<div id=hint3 class=ahint></div>
@ -1641,13 +1658,13 @@ if (input::get('edit')) {
function setHPlocal() {
tkHP > maxHP && (tkHP = maxHP);
var a = Math.round(tkHP) + "/" + maxHP;
let a = Math.round(tkHP) + "/" + maxHP;
a = stLen - (a.length + 2) * 7;
var b = Math.round((a - 1) / maxHP * tkHP);
const b = Math.round((a - 1) / maxHP * tkHP);
a -= b;
var HP = document.getElementById("hp_value");
var HP1 = document.getElementById("HP1");
var HP2 = document.getElementById("HP2");
const HP = document.getElementById("hp_value");
const HP1 = document.getElementById("HP1");
const HP2 = document.getElementById("HP2");
if (HP) {
HP1.width = b, HP2.width = a, HP1.src = tkHP / maxHP < redHP ? "i/1red.gif" : tkHP / maxHP < yellowHP ? "i/1yellow.gif" : "i/1green.gif", HP.innerHTML = Math.round(tkHP) + "/" + maxHP;
}