<?php

require '../system/start.php';
require '../system/functions.php';
reg();
$str['mesto'] = 'Изменить анкету';
$str['block'] = $set['site'].' / Изменить анкету';
include '../style/'.$style.'/head.php';

echo '<div class="where"><a href="editanketa.php">Анкета</a> | <a href="editanketa.php?act=info">Контактное инфо</a> | <a href="editanketa.php?act=tipaz">Типаж</a> | <a href="editanketa.php?act=auto">Автобиография</a></div>';

switch($act) {
case 'info':
if ($_POST['submit']) {

if(isset($_POST['icq']) and !empty($_POST['icq'])) {

$rate = $user['rate'];
if(!empty($_POST['icq'])) {
if (($rate + 4) <= 50) {
$rate = $rate + 4;
mysql_query("UPDATE `users` SET `rate` = '" . $rate . "' WHERE `id` = '".$user['id']."'");

}
}
if(!empty($_POST['mail'])) {
if (($rate + 4) <= 50) {
$rate = $rate + 4;
mysql_query("UPDATE `users` SET `rate` = '" . $rate . "' WHERE `id` = '".$user['id']."'");

}
}
if(!empty($_POST['skype'])) {
if (($rate + 4) <= 50) {
$rate = $rate + 4;
mysql_query("UPDATE `users` SET `rate` = '" . $rate . "' WHERE `id` = '".$user['id']."'");

}
}
if(!empty($_POST['phone'])) {
if (($rate + 4) <= 50) {
$rate = $rate + 4;
mysql_query("UPDATE `users` SET `rate` = '" . $rate . "' WHERE `id` = '".$user['id']."'");

}
}
echo 'Рейтинг добавлен<br />';
}
mysql_query("UPDATE `users` SET
icq='".int($_POST['icq'])."',
mail='".protect($_POST['mail'])."',
skype='".protect($_POST['skype'])."',
phone='".protect($_POST['phone'])."'
WHERE id=".$user['id']."");
echo '<div class="mess">Контактное инфо изменено!</div>';
}
$user = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '" . $user['id'] . "'"));
echo '<form action="?act=info" method="post">
<div class="mess">
ICQ:<br/>
<input name="icq" type="text" value="'.$user['icq'].'"/><br/>
Еmаil:<br />
<input name="mail" type="text" value="' . $user['mail'] . '" /> <br />
Skype: <br />
<input name="skype" type="text" value="' . $user['skype'] . '" /> <br />
Номер телефона: <br />
<input name="phone" type="text" value="' . $user['phone'] . '" /> <br /></div>
<input name="submit" type="submit" value="Изменить" />';
break;

case 'tipaz' :
if ($_POST['submit']) {

if(isset($_POST['growth']) and !empty($_POST['growth'])) {

				$rate = $user['rate'];
				if(!empty($_POST['growth'])) {  
					if (($rate + 4) <= 50) {
						$rate = $rate + 4;
					mysql_query("UPDATE `users` SET `rate` = '" . $rate . "' WHERE `id` = '".$user['id']."'");		
					}
				} 
				if(!empty($_POST['weight'])) {  
					if (($rate + 4) <= 50) {
						$rate = $rate + 4;
					mysql_query("UPDATE `users` SET `rate` = '" . $rate . "' WHERE `id` = '".$user['id']."'");	
					}
				} 
				if(!empty($_POST['eyes'])) { 
					if (($rate + 4) <= 50) {
						$rate = $rate + 4;
					mysql_query("UPDATE `users` SET `rate` = '" . $rate . "' WHERE `id` = '".$user['id']."'");	
					}
				}  
				if(!empty($_POST['hair'])) {  
					if (($rate + 4) <= 50) {
						$rate = $rate + 4;
					mysql_query("UPDATE `users` SET `rate` = '" . $rate . "' WHERE `id` = '".$user['id']."'");	
					}
				} 
				if(!empty($_POST['constitution'])) {  
					if (($rate + 4) <= 50) {
						$rate = $rate + 4;
					mysql_query("UPDATE `users` SET `rate` = '" . $rate . "' WHERE `id` = '".$user['id']."'");	
					}
				}
			}
			 mysql_query("UPDATE `users` SET 
			 growth='".int($_POST['growth'])."', 
			 weight='".int($_POST['weight'])."', 
			 eyes='".protect($_POST['eyes'])."', 
			 hair='".protect($_POST['hair'])."',
			 constitution='".protect($_POST['constitution'])."'
			 WHERE id=".$user['id'].""); 
			echo '<div class="mess">Типаж изменен!</div>';
		} 
		$user = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '" . $user['id'] . "'"));
			echo '<form action="?act=tipaz" method="post">
			<div class="mess">
			Рост:<br/> 
			<input name="growth" type="text" value="'.$user['growth'].'"/><br/> 
			Вес:<br/> 
			<input name="weight" type="text" value="'.$user['weight'].'"/><br/> 
			Цвет глаз:<br/> 
			<input name="eyes" type="text" value="'.$user['eyes'].'"/><br/> 
			Волосы:<br/> 
			<input name="hair" type="text" value="'.$user['hair'].'"/><br/> 
			Телосложение:<br/> 
			<input name="constitution" type="text" value="'.$user['constitution'].'"/><br/>
			</div>
			<input name="submit" type="submit" value="Изменить" />';
	break;
	
	case "auto" :
		if ($_POST['submit']) {
		
			if(isset($_POST['purpose']) and !empty($_POST['purpose'])) { 
				
				$rate = $user['rate'];
				if(!empty($_POST['purpose'])) {  
					if (($rate + 4) <= 50) {
						$rate = $rate + 4;
					mysql_query("UPDATE `users` SET `rate` = '" . $rate . "' WHERE `id` = '".$user['id']."'");		
					}
				} 
				if(!empty($_POST['marriage'])) {  
					if (($rate + 4) <= 50) {
						$rate = $rate + 4;
					mysql_query("UPDATE `users` SET `rate` = '" . $rate . "' WHERE `id` = '".$user['id']."'");	
					}
				} 
				if(!empty($_POST['smoke'])) { 
					if (($rate + 4) <= 50) {
						$rate = $rate + 4;
					mysql_query("UPDATE `users` SET `rate` = '" . $rate . "' WHERE `id` = '".$user['id']."'");	
					}
				}  
				if(!empty($_POST['whatido'])) {  
					if (($rate + 4) <= 50) {
						$rate = $rate + 4;
					mysql_query("UPDATE `users` SET `rate` = '" . $rate . "' WHERE `id` = '".$user['id']."'");	
					}
				} 
				if(!empty($_POST['music'])) {  
					if (($rate + 4) <= 50) {
						$rate = $rate + 4;
					mysql_query("UPDATE `users` SET `rate` = '" . $rate . "' WHERE `id` = '".$user['id']."'");	
					}
				}
				if(!empty($_POST['films'])) {  
					if (($rate + 4) <= 50) {
						$rate = $rate + 4;
					mysql_query("UPDATE `users` SET `rate` = '" . $rate . "' WHERE `id` = '".$user['id']."'");	
					}
				}
				if(!empty($_POST['books'])) {  
					if (($rate + 4) <= 50) {
						$rate = $rate + 4;
					mysql_query("UPDATE `users` SET `rate` = '" . $rate . "' WHERE `id` = '".$user['id']."'");	
					}
				}
				if(!empty($_POST['mobile'])) {  
					if (($rate + 4) <= 50) {
						$rate = $rate + 4;
					mysql_query("UPDATE `users` SET `rate` = '" . $rate . "' WHERE `id` = '".$user['id']."'");	
					}
				}
				if(!empty($_POST['job'])) {  
					if (($rate + 4) <= 50) {
						$rate = $rate + 4;
					mysql_query("UPDATE `users` SET `rate` = '" . $rate . "' WHERE `id` = '".$user['id']."'");	
					}
				}
				if(!empty($_POST['interests'])) {  
					if (($rate + 4) <= 50) {
						$rate = $rate + 4;
					mysql_query("UPDATE `users` SET `rate` = '" . $rate . "' WHERE `id` = '".$user['id']."'");	
					}
				}
				if(!empty($_POST['about_me'])) {  
					if (($rate + 4) <= 50) {
						$rate = $rate + 4;
					mysql_query("UPDATE `users` SET `rate` = '" . $rate . "' WHERE `id` = '".$user['id']."'");	
					}
				}
			}
			 mysql_query("UPDATE `users` SET 
			 purpose='".int($_POST['purpose'])."', 
			 marriage='".int($_POST['marriage'])."', 
			 smoke='".int($_POST['smoke'])."', 
			 whatido='".protect($_POST['whatido'])."',
			 music='".protect($_POST['music'])."',
			 films='".protect($_POST['films'])."',
			 books='".protect($_POST['books'])."',
			 mobile='".protect($_POST['mobile'])."',
			 work='".protect($_POST['job'])."',
			 interests='".protect($_POST['interests'])."',
			 about_me='".protect($_POST['about_me'])."'
			 WHERE id=".$user['id'].""); 
			echo '<div class="mess">Автобиография изменена!</div>';
		} 
		$user = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '" . $user['id'] . "'"));
			echo '<form action="?act=auto" method="post">
			<div class="mess">		
			Цель знакомств:<br/> 
			<select size="1" name="purpose"> 
			  <option value="1">Дружба и общение</option> 
			  <option value="2">Флирт, СМС-переписка</option> 
			  <option value="3">Любовь, отношения</option> 
			  <option value="4">Брак, создание семьи</option> 
			  <option value="5">Ищу спонсора</option> 
			  <option value="6">Стану спонсором</option> 
			</select><br/> 
			Состою в браке:<br/> 
			<select size="1" name="marriage"> 
			  <option value="1">Секрет</option> 
			  <option value="2">Нет</option> 
			  <option value="3">Да</option> 
			  <option value="4">В активном поиске</option> 
			</select><br/> 
			Курите ли вы:<br/> 
			<select size="1" name="smoke"> 
			  <option value="1">Не скажу</option> 
			  <option value="2">Не курю</option> 
			  <option value="3">Курю</option> 
			  <option value="4">Иногда</option> 
			  <option value="5">Бросаю</option> 
			</select><br/> 
			
			Чем я занимаюсь:<br/> 
			<input name="whatido" type="text" value="'.$user['whatido'].'"/><br/> 
			Любимая музыка:<br/> 
			<input name="music" type="text" value="'.$user['music'].'"/><br/> 
			Любимые фильмы:<br/> 
			<input name="films" type="text" value="'.$user['films'].'"/><br/> 
			Любимые книги:<br/> 
			<input name="books" type="text" value="'.$user['books'].'"/><br/> 
			Модель телефона:<br/> 
			<input name="mobile" type="text" value="'.$user['mobile'].'"/><br/> 
			Род занятий:<br/> 
			<input name="job" type="text" value="'.$user['work'].'"/><br/> 
			Интересы:<br/> 
			<input name="interests" type="text" value="'.$user['interests'].'"/><br/> 
			О себе:<br/> 
			<input name="about_me" type="text" value="'.$user['about_me'].'"/><br/> 
			</div>
			<input name="submit" type="submit" value="Изменить" />';
	break;
default :
	if ($_POST['submit']) {
		
		if(isset($_POST['name']) and !empty($_POST['name'])) { 
			$rate = $user['rate'];
			
			if(isset($_POST['name'])) {  
				if (($rate + 4) <= 50) {
					$rate = $rate + 4;
					mysql_query("UPDATE `users` SET `rate` = '" . $rate . "' WHERE `id` = '".$user['id']."'");	
					
				}
			} 
			if(isset($_POST['family'])) {  
				if (($rate + 4) <= 50) {
					$rate = $rate + 4;
					mysql_query("UPDATE `users` SET `rate` = '" . $rate . "' WHERE `id` = '".$user['id']."'");	
					
				}
			} 
			if(isset($_POST['gender'])) { 
				if (($rate + 4) <= 50) {
					$rate = $rate + 4;
					mysql_query("UPDATE `users` SET `rate` = '" . $rate . "' WHERE `id` = '".$user['id']."'");	
					
				}
			} 
			if(isset($_POST['birthday_day']) and !empty($_POST['birthday_month']) and !empty($_POST['birthday_year'])) { 
				if (($rate + 4) <= 50) {
					$rate = $rate + 4;
					mysql_query("UPDATE `users` SET `rate` = '" . $rate . "' WHERE `id` = '".$user['id']."'");	
					
				}
			} 
			if(isset($_POST['country'])) {  
				if (($rate + 4) <= 50) {
					$rate = $rate + 4;
					mysql_query("UPDATE `users` SET `rate` = '" . $rate . "' WHERE `id` = '".$user['id']."'");	
					
				}
			} 
			if(isset($_POST['city'])) {  
				if (($rate + 4) <= 50) {
					$rate = $rate + 4;
					mysql_query("UPDATE `users` SET `rate` = '" . $rate . "' WHERE `id` = '".$user['id']."'");
					
				}
			} 
			
		}
		 mysql_query("UPDATE `users` SET 
		 name='".protect($_POST['name'])."', 
		 gender='".int($_POST['gender'])."', 
		 birthday_day='".int($_POST['birthday_day'])."', 
		 birthday_month='".int($_POST['birthday_month'])."', 
		 birthday_year='".int($_POST['birthday_year'])."', 
		 city='".protect($_POST['city'])."', 
		 country='".protect($_POST['country'])."', 
		 family='".protect($_POST['family'])."'
		 WHERE id=".$user['id']."") or die ("error"); 
		echo '<div class="mess">Анкета изменена!</div>';
	} 
	$user = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '" . $user['id'] . "'"));
		echo '<form action="" method="post">
		<div class="mess">
		Имя:<br/> 
		<input name="name" type="text" value="'.$user['name'].'"/><br/> 
		Фамилия:<br/> 
		<input name="family" type="text" value="'.$user['family'].'"/><br/> 
		Пол:<br/> 
		<select size="1" name="gender"> 
		<option value="1">Парень</option> 
		<option value="2">Девушка</option> 
		</select><br/> 
		Страна:<br/> 
		<input name="country" type="text" value="'.$user['country'].'"/><br/> 
		Город:<br/> 
		<input name="city" type="text" value="'.$user['city'].'"/><br/> ';
		echo 'Дата рождения:<br/><select name="birthday_day">'; 
		if ($user['birthday_day']==0)
			$sel=' selected="selected"';
		else 
			$sel=NULL; 
		echo "<option value=\"0\"$sel>  </option>"; 
		
		for ($i=1;$i<=31;$i++){ 
			if ($user['birthday_day']==$i)
				$sel=' selected="selected"';
			else 
				$sel=NULL; 
			echo "<option value=\"$i\"$sel>$i</option>";
		} 
		echo "</select>"; 
		echo "<select name=\"birthday_month\">"; 
		if ($user['birthday_month']==0)
			$sel=' selected="selected"';
		else 
			$sel=NULL; 
		
		echo "<option value=\"0\"$sel>  </option>"; 
		for ($i=1;$i<=12;$i++){ 
			if ($user['birthday_month']==$i)
				$sel=' selected="selected"';
			else 
				$sel=NULL; 
			echo "<option value=\"$i\"$sel>$i</option>";
		} 
		echo "</select>"; 
		echo "<select name=\"birthday_year\">"; 
		if ($user['birthday_year']==0)
			$sel=' selected="selected"';
		else 
			$sel=NULL; 
		echo "<option value=\"0\"$sel>  </option>"; 
		for ($i=date('Y')-10;$i>=date('Y')-50;$i--){ 
			if ($user['birthday_year']==$i)
				$sel=' selected="selected"';
			else 
				$sel=NULL; 
			echo "<option value=\"$i\"$sel>$i</option>";
		} 
		echo '</select><br /></div>
		<input name="submit" type="submit" value="Изменить" />';
	
}

include '../style/'.$style.'/foot.php'; 
?>