Файл: app/user/setting.php
Строк: 52
<?php
if (!$user->isAuth()) {
redirect('/');
exit;
}
$form = [
'value' => [
'qiwi' => isset($_POST['qiwi']) ? Clean::int($_POST['qiwi']) : null,
'yandex' => isset($_POST['yandex']) ? Clean::int($_POST['yandex']) : null,
'bitcoin' => isset($_POST['bitcoin']) ? Clean::str($_POST['bitcoin']) : null,
'automoney' => isset($_POST['automoney']) ? Clean::bool($_POST['automoney']) : null,
],
'error' => [],
];
function payments_disambled($payment){
if(!empty($payment)) $payment = 'readonly';
return $payment;
}
if (isset($_POST['submit'])) {
if (!empty($form['value']['qiwi']) and !is_numeric($form['value']['qiwi'])) {
$form['error']['qiwi'] = 'Неверный формат QIWI кошелька';
}
if (!empty($form['value']['yandex']) and !is_numeric($form['value']['yandex'])) {
$form['error']['yandex'] = 'Неверный формат Яндекс кошелька';
}
if (count($form['error']) == 0) {
$change = $db->prepare('UPDATE `users` SET `qiwi` = ?, `yandex` = ?, `bitcoin` = ?, `automoney` = ? WHERE `user_id` = ?');
$change -> execute([$form['value']['qiwi'],
$form['value']['yandex'],
$form['value']['bitcoin'],
$form['value']['automoney'],
$user->get()->user_id]);
Notif :: message('Настройки успешно сохранены','/setting');
exit;
}
}
if(empty($user->get()->telegramCode) and empty($user->get()->telegram)){
$sql = $db->prepare('UPDATE `users` SET `telegramCode` = ? WHERE `user_id` = ?');
$sql -> execute([random_string(5),$user->get()->user_id]);
redirect('/setting');
exit;
}
echo $template->render('user.setting', [
'form' => $form,
]);