<?php
set_magic_quotes_runtime(0);
include ("txt/vars.php");
if (isset ($_POST['username'])) {
$username=$_POST['username'];
}
else {
$username="";
}
if (isset ($_POST['password'])) {
$password=$_POST['password'];
}
else {
$password="";
}
$username=str_replace ('"',"'",$username);
$username=substr ($username,0,50);
$username=trim ($username);
$username=htmlspecialchars ($username);
$username=mysql_escape_string($username);
$username=eregi_replace ("[\']","",$username);

$password=str_replace ('"',"'",$password);
$password=substr ($password,0,50);
$password=trim ($password);
$password=htmlspecialchars ($password);
$password=mysql_escape_string($password);
$password=eregi_replace ("[\']","",$password);
$link=mysql_connect("$mysqlhost","$mysqllogin","$mysqlpass") or die("Could not connect");
mysql_select_db($mysqldb) or die("Could not select database");
$pass2=md5 ($password);
$crc_username=crc32($username);
$query="select pass,crcname from users where(pass='$pass2' and crcname='$crc_username')";
$result=mysql_query($query);
$rows=mysql_num_rows($result);
if ($rows>0) {
SetCookie ("cookname_auc",$username,time()+31536000);
SetCookie ("cookpass_auc",$password,time()+31536000);
}
if ($rows<=0) {
echo "<center><b>Вы не смогли пройти авторизацию!</b></center>";
echo "<meta http-equiv='refresh' content='2 url=index.php'>";
exit;
}
mysql_close ($link);
?>
<script language="JavaScript">
location.href="cp.php";
</script>