// This is a php file that allows users to register themselves for a // tipping competition, such that the competition administrator can enter // data for all tipsters with a single command in Wests. // // This script is provided as-is with no warranty whatsoever. Use it at // your own risk! // Updates available at http://footytips.net/forum/viewtopic.php?t=95 // This version: 02/01/2007 // this script assumes that you have a HTML/PHP header in a file called // header.php in this directory, and a footer called footer.php include('header.php'); // this is the file that the new users are written to. Make sure that the // file exists and is world-writable (at a unix shell in the directory // containing this file, type "chmod o+w filename"). // Preferably do not put this in a world-readable // directory (eg, in the parent of your web directory). $usersfile = "newusers"; // this is the time that registrations for your competition close // in order, the arguments to mktime are: // hour, minute, second, month, day, year, // in the timezone that your server is configured to. // If you don't know what timezone your server is in, then you can specify // the cutoff time in UTC by replacing mktime with gmmktime. $cutofftime = mktime(12, 00, 00, 12, 31, 2007); if (time() > $cutofftime) { echo "Registrations have now closed. Sorry."; include('footer.php'); return; } $success = 0; $message = ""; $email = ""; import_request_variables("p",""); // check that the inputs exist if (isset($name) && isset($password) && isset($password2) && isset($email)) { // are the inputs valid? if (strlen($name) < 2 || strlen($name) > 20 || strpos($name,":")!=FALSE || strpos($name,"\n")!=FALSE || strlen($password) < 4 || strcmp($password,$password2)!=0 || strpos($email,"@")===FALSE || strpos($email,".")===FALSE) { ?> The data you submitted is not valid. Please don't use a colon ":" in your username, and ensure that you entered the same password twice. Press the back button to try again. include('footer.php'); return; } $lines = file($usersfile); $namealreadyexists = 0; foreach ($lines as $line) // user already exists { $linecontents = explode(":",$line); if (strcasecmp($linecontents[0], $name)==0) $namealreadyexists = 1; } if ($namealreadyexists) { $message .= "Someone already has the name $name - please choose another name."; } else { $password = md5($password); $addline = "$name:$password:$email"; $fid = fopen($usersfile,"a"); fwrite($fid, $addline."\n"); fclose($fid); $message .= "Thanks for joining!
"; $success = 1; } } else { // echo "Required data missing."; } echo ''; echo $message; echo "
"; if (!$success) { ?> Use the form below to register for the current tipping competition.