<?
/*
=============================================
Движок: SHCMS Engine
=============================================
Название файла: Профиль
=============================================
Official website: http://shcms.ru
=============================================
*/
define('SHCMS', true);
include_once'../system/inc/basic_settings.php';
$shcmsengine['title'] = 'Личное меню '.$login.'';
include_once'../template/head.php';
registrat();
$integ = $errors;


$user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id`='$user_id'"));

if(isset($_POST['submit']))
{$submit = $_POST['submit'];}

if(isset($submit))
{
if ($user['id'] == $user_id);
if(isset($_POST['name']))
{$name = $_POST['name'];}
if(isset($_POST['last_name']))
{$last_name = $_POST['last_name'];}
if($_POST['pol'])
{$pol =$_POST['pol'];}
if(isset($_POST['email']))
{$email = $_POST['email'];}
if(isset($_POST['icq']))
{$icq = $_POST['icq'];}
if(isset($_POST['skype']))
{$skype = $_POST['skype'];}
if(isset($_POST['us_d']))
{$us_d = $_POST['us_d'];}
if(isset($_POST['us_m']))
{$us_m = $_POST['us_m'];}
if(isset($_POST['us_g']))
{$us_g = $_POST['us_g'];}
if(isset($_POST['description']))
{$description = $_POST['description'];}
if(isset($_POST['wmid']))
{$wmid = $_POST['wmid'];}
$user['name'] = isset($name) ? shcms_sh_shcms(substr($name, 0, 30)) : '';  
$user['last_name'] = isset($last_name) ? shcms_sh_shcms(substr($last_name, 0, 30)) : '';           
$user['email'] = isset($email) ? shcms_sh_shcms(substr($email, 0, 30)) : ''; 
$user['icq'] = isset($icq) ? shcms_sh_shcms(substr($icq, 0, 10)) : ''; 
$user['skype'] = isset($skype) ? shcms_sh_shcms(substr($skype, 0, 25)) : ''; 
$user['us_d'] = isset($us_d) ? shcms_sh_shcms(substr($us_d, 0, 2)) : ''; 
$user['us_m'] = isset($us_m) ? shcms_sh_shcms(substr($us_m, 0, 2)) : ''; 
$user['us_g'] = isset($us_g) ? shcms_sh_shcms(substr($us_g, 0, 25)) : ''; 
$user['description'] = isset($description) ? shcms_sh_shcms(substr($description, 0, 255)) : '';  
$user['wmid'] = isset($wmid) ? shcms_sh_shcms(substr($wmid, 0, 13)) : '';  
$user['pol'] = (isset ($pol) && $pol);
$icq = rus_lat(strtolower($user['icq']));
			
			if(!is_numeric($icq)){
			echo '<div class="errors">В ICQ должны быть только цифры!</div>';}
	
	
	    if (!preg_match('#^[A-z0-9-\._]+@[A-z0-9]{2,}\.[A-z]{2,4}$#ui',$email))
		{
		echo '<div class="errors">Email введен неправильно</div>';
		header("Refresh: 1; url=?");
		include_once'../template/foot.php';
		exit();
		}
	
			if($submit ==true)
{
$ok_true = mysql_query("UPDATE `users` SET `name`='$name',`last_name`='$last_name',`email`='$email',`icq`='$icq',`skype`='$skype',`us_d`='$us_d',`us_m`='$us_m',`us_g`='$us_g',`description`='$description',`wmid`='$wmid',`pol`='$pol' WHERE `id`='$user_id'");

if ($ok_true == true)
{
echo '<div class="actshcms">Изминение успешно вступили в силу</div>';
header("Refresh: 1; url=?");
include_once'../template/foot.php';
exit();
}
else
{
echo 'Ошибка';
}

}

}

echo '<form action="?'.$conservation.'" method="post">';
echo '<strong>Ваше Имя:</strong><br/><input type="text" maxlength="32" name="name" value="'.$user['name'].'"><br/>';
echo '<strong>Ваша Фамилия:</strong><br/><input type="text" maxlength="32" name="last_name" value="'.$user['last_name'].'"><br/>';
echo '<strong>Дата рождение:</strong><br/><input size="2" type="text"  maxlength="2"name="us_d" value="'.$user['us_d'].'"> ';
echo '<input size="2" type="text"  maxlength="2"name="us_m" value="'.$user['us_m'].'"> ';
echo '<input size="4" type="text"  maxlength="4"name="us_g" value="'.$user['us_g'].'"><br/>';
echo '<strong>Ваш E-Mail:</strong><br/><input type="text"  maxlength="32"name="email" value="'.$user['email'].'"><br/>';
echo '<strong>Номер ICQ:</strong><br/><input type="text" maxlength="10" name="icq" value="'.$user['icq'].'"><br/>';
echo '<strong>Skype:</strong><br/><input type="text" maxlength="32" name="skype" value="'.$user['skype'].'"><br/>';
echo '<strong>WMID:</strong><br/><input type="text" maxlength="12" name="wmid" value="'.$user['wmid'].'"><br/>';
echo'<strong>Ваш Пол</strong><br/> <select name="pol">';
echo '<option value="1"'.((isset($user['pol']) and $user['pol'] == 1)?" selected='selected'":null).'>Мужской</option>';
echo '<option value="2"'.((isset($user['pol']) and $user['pol'] == 2)?" selected='selected'":null).'>Женский</option>';
echo '</select><br/>';
echo '<strong>О себе:</strong>(мах: 255 символов)<br/><textarea name="description">'.$user['description'].'</textarea><br/>';
echo '<input type="submit" name="submit" value="Применить"></form>';
include_once'../template/foot.php';
?>