Обработка ошибок. Меньше sql-запросов в логике.

This commit is contained in:
Igor Barkov (iwork)
2020-09-25 19:27:11 +03:00
parent 5b78d00f19
commit 3ca33f38aa
3 changed files with 94 additions and 79 deletions

View File

@@ -6,11 +6,10 @@
* Project name: Battles-Game
*/
require_once 'config.php';
if (isset($_SESSION['uid'])) {
$user = new User($_SESSION['uid']);
} else {
echo "Не могу проинициализировать игрока!";
if (empty($_SESSION['uid'])) {
throw new Exception('Не могу проинициализировать игрока!');
}
$user = new User($_SESSION['uid']);
if ($user->id && $user->block) {
exit('user blocked!');
}