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.