showHeader(); # Info box echo GWF_Box::box($chall->lang('info', array('index.php?show=source', 'index.php?highlight=christmas')), $chall->lang('title')); # Show highlighted src if (isset($_GET['highlight'])) { $source = '[PHP title=regex2/index.php]'.file_get_contents('challenge/training/regex2/index.php').'[/PHP]'; echo GWF_Box::box(GWF_Message::display($source, true, false)); } # Submitted? if (isset($_POST['submit'])) { # Check it! $error = ludde_is_satisfied($chall); # Oooops! if ($error === true) { $chall->onChallengeSolved(GWF_Session::getUserID()); } # All normal and ok elseif ($error === false) { echo GWF_HTML::message(GWF_PAGE_TITLE, $chall->lang('msg_ok', array($_POST['username'])), false); } # Error! else { echo GWF_HTML::error(GWF_PAGE_TITLE, $error, false); } } # Check it! function ludde_is_satisfied(WC_Challenge $chall) { # Missing POST var? if (!isset($_POST['username'])) { return $chall->lang('err_missing_var'); } # Submitted a string? if (!is_string($_POST['username'])) { return $chall->lang('err_var_type'); } # Valid username? if (!preg_match('/^[a-zA-Z]{1,16}$/', $_POST['username'])) { return $chall->lang('err_illegal_username', array(1, 16)); } # WTF! WTF! WTF! if (strlen($_POST['username']) > 16) { return true; } # Normal, OK and no error :) return false; } ?>
copyrightFooter(); require_once('challenge/html_foot.php'); ?>