User Registration
25 ) ) {
print "Name does meet our standards (all alphabetic and less then 25 chars).";
return(FALSE);
}
if ( ( strlen($email) == 0 ) || ( ! eregi (
"^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email ) ) ||
( strlen ($email > 50 ) ) ){
print "Please enter a valid email address (must be less then 50 chars).";
return(FALSE);
}
if ( ( strlen($password) <= 3 ) || ( strlen($password) > 15) ){
# thought about scrubbing colons... but if i store password as last element on line it doesn't matter
print "Passwords must be between 4 and 15 characters ... mmkay.";
return(FALSE);
}
if ( ( $emailc != "yes" ) && ( $emailc != "no" ) ){
print "Strange... I gave you 2 choices for email but you responded with a 3rd choice. Fix it.\n";
return(FALSE);
}
return(TRUE);
}
# store user
function store( &$name, &$password, &$email, &$emailc ) {
global $dbfile;
# check to see if user exists
if ( ( is_file ( $dbfile) ) && ( $fp = fopen($dbfile, "r") ) ){
flock($fp, LOCK_SH);
while ( !feof ( $fp ) ){
if ( eregi ( "^$name:", fgets ( $fp ) ) ){
return(FALSE);
}
}
flock($fp, LOCK_UN);
fclose($fp);
}
# add user
if ( $fp = fopen($dbfile, "a") ){
flock($fp, LOCK_EX);
fputs($fp, "$name:$email:$emailc:" . str_rot13($password) . "\n");
flock($fp, LOCK_UN);
fclose($fp);
return(TRUE);
} else {
print "
Error occured while appending to user db. Please contact an administrator.
";
}
}
$dbfile = "../../../cgi_data/users.data";
$name = $_REQUEST['name'];
$password = $_REQUEST['password'];
$email = $_REQUEST['email'];
$emailc = $_REQUEST['emailu'];
# primitive sanity checks
if (isset($name)) {
if (valid($name, $password, $email, $emailc)) {
if ( store( $name, $password, $email, $emailc ) ){
print "Enroll Complete
Please record this information for your records:\n";
} else {
print "$name already exists in our database. Please choose another name.
\n";
}
}
else {
}
}
?>