<?php
include_once("incs/conf.php");
include_once("incs/fmysql.php");

if($on==1){
include_once("incs/head.php");
head("Авторизация",$meuser,$auth);
echo "<div class='rowup'>";
echo "Авторизация</div>";
echo "Вы уже авторизованы!<br/>";
include_once("incs/down.php");
}else{

$a = fil($_GET['a']);
$p = fil($_GET['p']);

switch($a){

case '':
include_once("incs/head.php");
head("Авторизация",$meuser,$auth);
echo "<div class='rowup'>";
echo "Авторизация</div>";

switch($p){
case 'error1':
echo "Неверный логин или пароль!<br>";
break;

case 'error2':
echo "Вы не зополнили одно или несколько полей!<br>";
break;
}
echo "<form method='post' action='aut.php?a=autor'>\n";
echo "Логин:<br /><input type='text' name='nick' size='12' maxlength='32' /><br />\n";
echo "Пароль:<br /><input type='password' name='pass' size='12' maxlength='32' /><br/>\n";
echo "<input type='submit' value='Войти' />";
echo "</form>";
break;

case 'autor':
if($_POST['nick']!="" && $_POST['pass']!=""){
$nick = $_POST['nick'];
$nick=filtr($nick);
$pass = $_POST['pass'];
$pass=filtr($pass);
$pass_us=md5($pass);

$pf = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `nick` = '$nick' AND `pass` = '$pass_us'"));

if($pf[id]!=""){
SetCookie("nick","$nick",time()+15552000);
SetCookie("pass","$pass",time()+15552000);
header("Location: index.php?");
}else{
header("Location: aut.php?p=error1");
}
}else{
header("Location: aut.php?p=error2");
}
break;
}
include_once("incs/down.php");
}
?>