View file reguser.php

File size: 1.5Kb
<?php

include 'include/head.php';

if ($_POST['key'] != $_SESSION['key'])
{
echo 'Error in check number!';
echo '<meta http-equiv="refresh" content="2; url=registration.php">';
exit;
}

if(empty($name) or empty($pass))
{
echo 'Write name and password!';
echo '<meta http-equiv="refresh" content="2; url=registration.php">';
exit;
}

if(file_exists("users/$name.class"))
{
echo 'This nick already exist!';
echo '<meta http-equiv="refresh" content="2; url=registration.php">';
exit;
}
$name=trim($name);
$pass=trim($pass);


$error=null;
if (!preg_match("!^[a-z1-9@\\*\\)\\(\\?\\!\\-_\\]\\[=~]+$!i",$name)) $error.='In nick is other symbols!<br>';
if (!preg_match("!^[a-z1-9@\\*\\)\\(\\?\\!\\-_\\]\\[=~]+$!i",$pass)) $error.='In password is symbols!';
if (!empty($error))
{
echo $error."<br /><br /><a href='registration.php'>Registration</a>";
}
else
{
$write = fopen("users/".basename($name).".class", "a");
fputs ($write,"$pass");
fclose ($write);
$write = fopen("letters/".basename($name).".class", "a");
fputs ($write,"<br><u>System</u>($time1|$IP)<br/>- Welcome! .ad.\r\n");
fclose ($write);
echo "<form action=\"index.php\"><u>Registration's finish:</u><br />
Name<br/><input name=\"name\" type=\"text\" value=\"$name\" /><br/>
Pass<br/><input name=\"pass\" type=\"text\" value=\"$pass\" /><br/>
<input type=\"submit\" value=\"Login\" /><br/>";
echo "Autologin<br/><input type=\"text\" value=\"http://$Main/index.php?name=$name&pass=$pass\">";
}
include 'include/foot.php';

?>