battles/magic/unmarry.php
2018-11-01 13:19:07 +02:00

25 lines
1.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
if (empty($_SESSION['uid'])) header("Location: index.php");
$u1 = filter_input(INPUT_POST, 'target');
$u2 = filter_input(INPUT_POST, 'target1');
$u1Row = db::c()->query('SELECT `id`,`married`,`login` FROM `users` WHERE `login` = "?s"', $u1)->fetch_assoc();
$u2Row = db::c()->query('SELECT `id`,`married`,`login` FROM `users` WHERE `login` = "?s"', $u2)->fetch_assoc();
if ($u1Row['id'] and $u2Row['id']) {
if (($u1Row['married'] != $u2Row['login']) OR ($u2Row['married'] != $u1Row['login'])) {
$status = "Персонажи {$u1Row['login']} и {$u2Row['login']} не состоят в браке друг с другом!";
} else {
if ($user['align'] > '1.6' && $user['align'] < '2') {
db::c()->query('UPDATE `users` SET `married`= 0 WHERE `id` = ?i', $u1Row['id']);
db::c()->query('UPDATE `users` SET `married`= 0 WHERE `id` = ?i', $u2Row['id']);
$status = "Расторжение брака между «{$u1Row['login']}» и «{$u2Row['login']}», регистратор «{$user['login']}».";
} else {
$status = "Вы не можете расторгнуть брак!";
}
}
} else {
$status = "Ошибка! Персонаж {$u1} или {$u2} не существует!";
}
if (!empty($status)) err($status);