<?php
define('NTLCMS', 1);
$module = 'changes';
include ('../system/start.php');
include ('../system/function.php');
include ('../system/antidos.php');
$page_title = 'Страница ваших настроек - клик клуба ' . strtoupper($_SERVER['HTTP_HOST']);
include ('../system/head.php');
if (!$active){
header('Location: '.URL);
$_SESSION['fail'] = 'Вы не авторизированы!';
exit;
}
echo '<div class="title"><b>'.razd.' Мои настройки</b></div>';
$error = null;
if (isset($_POST['name'])){
$name = isset($_POST['name']) ? filter_var($_POST['name'], FILTER_SANITIZE_STRING) : false;
$sex = isset($_POST['sex']) ? filter_var($_POST['sex'], FILTER_SANITIZE_NUMBER_INT) : '0';
$pages = isset($_POST['pages']) ? filter_var($_POST['pages'], FILTER_SANITIZE_NUMBER_INT) : '0';
$times = isset($_POST['times']) ? filter_var($_POST['times'], FILTER_SANITIZE_STRING) : false;
$news = isset($_POST['news']) ? filter_var($_POST['news'], FILTER_SANITIZE_NUMBER_INT) : '0';
$payeer = isset($_POST['payeer']) ? filter_var($_POST['payeer'], FILTER_SANITIZE_STRING) : false;
$yoomoney = isset($_POST['yoomoney']) ? filter_var($_POST['yoomoney'], FILTER_SANITIZE_STRING) : false;
$linked = isset($_POST['linked']) ? filter_var($_POST['linked'], FILTER_SANITIZE_NUMBER_INT) : '0';			
if (empty($name)){
$error.= 'Поле Ваше имя обязательно для заполнения!<br/>';
} elseif (mb_strlen($name, 'UTF-8') < 3 or mb_strlen($name, 'UTF-8') > 50){
$error.= 'Ваше имя должно содержать от 3 до 50 символов!<br/>';
}
if ($error){
echo '<div class="post"><center><i class="fa fa-close fa-fw"></i> '.$error.'</center></div>';
} else {
if (DB :: run() -> query("update `users` set 
`name` = ?, 
`sex` = ?, 
`pages` = ?, 
`linked` = ?, 
`news` = ?, 
`payeer` = ?,
`yoomoney` = ?,
`times` = ? where `login` = ? limit 1", 
array($name, $sex, $pages, $linked, $news, $payeer, $yoomoney, $times, $ilogin))){
$_SESSION['success'] = 'Настройки успешно сохранены!';
header('Location: '.URL.'/changes');
} else {
$_SESSION['fail'] = 'Настройки не сохранены!';
header('Location: '.URL.'/changes');
}
}
}
echo '<div class="menu"><form action="'.URL.'/changes" method="post">
* Ваше имя:<br/><input type="text" name="name" value="'.checkout($_USER['name']).'" maxlength="25"/><br/>
* Ваш пол:<br/><select name="sex">
<option value="0"'.select(0, $_USER['sex']).'>Женский</option>
<option value="1"'.select(1, $_USER['sex']).'>Мужской</option>
</select><br/><hr>';
echo '* Payeer Кошелек:<br/><input type="text" name="payeer" value="'.checkout($_USER['payeer']).'" maxlength="15"/><br/><br/>';
echo '* YooMoney Кошелек:<br/><input type="text" name="yoomoney" value="'.checkout($_USER['yoomoney']).'" maxlength="15"/><br/>';
$arrtimezone = range(-12, 12);			
echo '<hr>Сдвиг времени:<br/>';
echo '<select name="times">';
foreach ($arrtimezone as $zone){
$selected = ($_USER['times'] == $zone) ? ' selected="selected"' : '';
echo '<option value="'.$zone.'"'.$selected.'>'.$zone.'</option>';
} 
echo '</select><br />';
echo '* Пунктов на стр:<br/>
<input type="text" name="pages" maxlength="3" value="'.ints($_USER['pages']).'"/><br/><br>
<input type="checkbox" name="news" value="1"'.check(1, $_USER['news']).'"/><b>Скрыть новость?</b><br/>
<input type="checkbox" name="linked" value="1"'.check(1, $_USER['linked']).'"/><b>Ссылки в новую вкладку?</b><br/>
<input type="submit" value="Сохранить настройки"/></form></div>';
echo '<div class="block"><i class="fa fa-home fa-fw"></i> <a href="'.URL.'/cabinet">В кабинет</a></div>';
include ('../system/foot.php');
?>