require("login.php");
if($s_online) {
header("Location: index.php");
exit;
} else {
@$cmd = $_POST["cmd"];
@$pass = $_POST["pass"];
@$pcon = $_POST["pcon"];
@$unam = $_POST["unam"];
if($cmd == "reg") {
if(!ereg('^[a-zA-Z0-9]*$', $pass)) {
PrintForm($unam,2,'Password contains illegal characters!
Use only a-z and numbers.');
} else if($pass == '') {
PrintForm($unam,2,'You have to choose a password!');
} else if($pass != $pcon) {
PrintForm($unam,3,'The passwords did not match!');
} else {
require("l-user-db");
if(!ereg('^[a-zA-Z0-9\-]*$', $unam)) {
PrintForm($unam,1,'Username may only contain letters a-z and numbers.');
} else if($s_users[$unam]) {
PrintForm($unam,1,'This username is already taken!
Please choose another name.');
} else {
$s_users[$unam] = crypt($pass, $pass);
$fd = @fopen ("l-user-db", "r+");
if($fd) {
flock($fd, LOCK_EX);
ftruncate($fd, 0);
fputs($fd, "\n \$s_users = array(");
reset($s_users);
$i = 0;
while(list($ukey, $uval) = each($s_users)) {
if($i > 0)
fputs($fd, ",");
fputs($fd, "\n\t\t\"" . $ukey . "\" => \"" . $uval . "\"");
$i++;
}
fputs($fd, "\n );\n?>\n");
flock($fd, LOCK_UN);
fclose ($fd);
$_SESSION['online'] = 1;
$_SESSION['user'] = $unam;
header("Location: index.php");
exit;
} else {
HtmlHeader();
print "Can't open";
HtmlFooter();
}
}
}
} else {
PrintForm('',0,'');
}
}
function HtmlHeader() {
?>