Файл: app/user/settings.php
Строк: 60
<?php
Core::only('user');
$smarty->header('Настройки');
$listing[] = [
'title' => Lang::word('Аватар'),
'url' => '/user/avatar',
'icon' => 'camera',
'div' => 'block'
];
$listing[] = [
'title' => Lang::word('Сменить пароль'),
'url' => '/user/password',
'icon' => 'key',
'div' => 'block'
];
if (filter_has_var(INPUT_POST, 'submit'))
{
$filter = [
'pages' => filter_has_var(INPUT_POST, 'pages')
? filter_input(INPUT_POST, 'pages', FILTER_SANITIZE_NUMBER_INT)
: null,
'language' => filter_has_var(INPUT_POST, 'language')
? filter_input(INPUT_POST, 'language', FILTER_UNSAFE_RAW)
: null
];
if (Filter::strlen($filter['language']) > 3 || Filter::strlen($filter['language']) < 0)
{
$error[] = 'Неверный формат языка.';
}
if ($filter['pages'] < 1 || $filter['pages'] > 50)
{
$error[] = 'Неверный формат пунктов на страницу.';
}
if (empty($error))
{
$stmt = $db->prepare("UPDATE `users` SET `pages` = :pages, `language` = :language WHERE `id` = :id");
$stmt->execute([
':pages' => $filter['pages'],
':language' => $filter['language'],
':id' => $user['id']
]);
Core::go('?');
}
}
Core::show('error');
$elements[] = [
'type' => 'input',
'title' => Lang::word('Пунктов на страницу'),
'br' => 1,
'info' => [
'name' => 'pages',
'value' => $user['pages'],
]
];
foreach (glob('system/language/*') AS $lang)
{
$name = str_replace('system/language/', '', $lang);
$options[] = [
$name,
file_get_contents(ROOT . 'system/language/' . $name . '/lang.name'),
$user['language'] == $name
];
}
$elements[]= [
'type' => 'select',
'title' => Lang::word('Язык'),
'br' => 1,
'info' => [
'name' => 'language',
'options' => $options
]
];
$elements[] = [
'type' => 'submit',
'info' => [
'name' => 'submit',
'value' => Lang::word('Сохранить')
]
];
$smarty->assign([
'method' => 'POST',
'action' => '?',
'el' => $elements,
'listing' => $listing
]);
$smarty->display('listing.tpl');
$smarty->display('form.tpl');
$smarty->footer();