<?php
set_magic_quotes_runtime(0);
include ("txt/vars.php");

$password=$_POST['password'];
$password=str_replace ('"',"'",$password);
$password=substr ($password,0,100);
$password=trim ($password);
$password=htmlspecialchars ($password);
$password=mysql_escape_string($password);
$password=eregi_replace ("[\']","",$password);

$email=$_POST['email'];
$email=str_replace ('"',"'",$email);
$email=substr ($email,0,70);
$email=trim ($email);
$email=htmlspecialchars ($email);
$email=mysql_escape_string($email);

$firstname=$_POST['firstname'];
$firstname=str_replace ('"',"'",$firstname);
$firstname=substr ($firstname,0,30);
$firstname=trim ($firstname);
$firstname=htmlspecialchars ($firstname);
$firstname=mysql_escape_string($firstname);

$lastname=$_POST['lastname'];
$lastname=str_replace ('"',"'",$lastname);
$lastname=substr ($lastname,0,50);
$lastname=trim ($lastname);
$lastname=htmlspecialchars ($lastname);
$lastname=mysql_escape_string($lastname);

$country=$_POST['country'];
$country=str_replace ('"',"'",$country);
$country=substr ($country,0,50);
$country=trim ($country);
$country=htmlspecialchars ($country);
$country=mysql_escape_string($country);

$city=$_POST['city'];
$city=str_replace ('"',"'",$city);
$city=substr ($city,0,50);
$city=trim ($city);
$city=htmlspecialchars ($city);
$city=mysql_escape_string($city);

$cookpass_auc=$_COOKIE['cookpass_auc'];
if ($password!=$cookpass_auc) {
SetCookie ("cookpass_auc",$password,time()+31536000);
}

if (!eregi ("@",$email)) {
echo "<center><b>Вы ввели ошибочный e-mail!</b></center>";
echo "<meta http-equiv='refresh' content='2 url=cp.php'>";
exit;
}
if ($password=="" || $email=="" || $firstname=="" || $lastname=="" || $country=="" || $city=="") {
echo "<center><b>Заполните все поля!</b></center>";
echo "<meta http-equiv='refresh' content='2 url=cp.php'>";
exit;
}

$link=mysql_connect("$mysqlhost","$mysqllogin","$mysqlpass") or die("Could not connect");
mysql_select_db($mysqldb) or die("Could not select database");
include ("auth_user.php");
$pass2=md5($password);
$query="update users set pass='$pass2',email='$email',firstname='$firstname',lastname='$lastname',country='$country',city='$city' where (crcname='$crc_username')";
mysql_query($query);
mysql_close ($link);
?>
<script language="JavaScript">
location.href="cp.php";
</script>