Post Reply  Post Thread 
Code Validator
Author Message
12-24-2009 09:08 PM
Post: #1
Code Validator
 
Truffle Troubadour
System Administrator
******


Posts: 554
Group: System Administrators
Joined: Mar 2006
Status: Offline
Reputation: 5

Here's the code for the code validator. It takes a file name and a code to validate. It returns TRUE on successful validation and FALSE otherwise(including if the file doesn't exist or fails to open or any such error).


function codechecker($filename, $codeattempt) {
$correct = FALSE;
if ( $fh = fopen($filename, 'r') ) {
do {
$kcode = fgets($fh);
if ( $kcode == $codeattempt."\n" ) {
$correct = TRUE;
}
} while ( !feof($fh) && $correct == false );
}
fclose($fh);
return $correct;
}


The code file should be newline delimited and should not have any empty lines.

I will work this into the registration at some point.


IE hampers my semantic expression.
My lady Liberty will not be entertaining any gentlemen callers.
Political philosophy is not spatial.

This post was last modified: 12-24-2009 09:09 PM by Truffle Troubadour.

Post Reply  Post Thread