<?php
error_reporting(E_ALL);
ini_set('display_errors',1);
date_default_timezone_set('Europe/Paris');
include('SpamChecker.class.php');
$SpamChk = new SpamChecker();
?><html><head><title>SpamChecker test</title>
</head><body>
<h1>SpamChecker test</h1>
<p>This test will output error messages for the individual fields A, B and C.
This is for demonstration only, do not show these to the end user.</p>
<p>The sessionkey is ignored (see PHP source)</p>
<p>Test form, enter something:</p>
<?php
if(count($_REQUEST)) { # will also check GET requests (URL params)
$SpamChk->Ignore('sessionkey'); # example
$accepted = $SpamChk->Accepted();
if(!$accepted) {
if(count($_POST))
$msg = 'Please check your input, there seems to be a problem';
else # GET
$msg = 'Bad URL detected! Please go <a href="?">here</a> and try again!';
} else $msg = 'ok!';
echo '<p style="color:'.($accepted ? 'green':'red').'">'.$msg.'</p>';
}
function field($name,$value='') {
$SpamChk = & $GLOBALS['SpamChk'];
if(isset($_REQUEST[$name])) {
$value = $_REQUEST[$name];
$msg = $SpamChk->ParamIsValid($name) ? '' : $SpamChk->GetParamStatus($name);
} else $msg = '';
return '<fieldset>'.strtoupper($name).
': <input name="'.$name.'" '.
'type="text" '.
($msg?'style="color:red" ':'').
'value="'.htmlentities($value).'" />'.
($msg?'<p style="font-family:sans-serif;color:red">'.$msg.'</p>':'').
'</fieldset>';
}
?>
<form method="post" style="float:left;margin:1em;">
<div style="width:15em;border:solid 1px black;padding:1em;background-color:silver;">
<?php echo field('a').field('b').field('c'); ?>
<fieldset>sessionkey:<input type="text" name="sessionkey" value="HlglRskGghwf" /></fieldset>
<input type="submit" value="Go" />
</div></form>
</body>
</html>
|