Login   Register  
PHP Classes
elePHPant
Icontem

File: action.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Giorgos  >  Form Spam Bot Blocker  >  action.php  >  Download  
File: action.php
Role: Example script
Content type: text/plain
Description: an example of a protected form submission
Class: Form Spam Bot Blocker
Generate forms that prevent submission by robots
Author: By
Last change: v0.3
Date: 2007-05-03 02:11
Size: 1,319 bytes
 

Contents

Class file image Download
<?php
require_once("fsbb.php");
$blocker=new formSpamBotBlocker();
$blocker->setTimeWindow(2,30); // set the min and max time in seconds for a form to be submitted
$blocker->setTrap(true,"mail"); // called here, because it has been called on the form page as well (same trap name!)
$param=false;
$nospam=false;
    if (
$_POST$param=$_POST;
    elseif (
$_GET$param=$_GET;
    if (!
$param) die("This script requires some POST or GET parameters from <a href=\"example.php\">example.php</a>");
$nospam=$blocker->checkTags($param);
$submissions=$_SESSION[$blocker->sesName];    
?>
<html>
<head></head>
<body>
<?php
    
if ($nospam==false) print "<p>This was an INVALID submission. You have acted like a spambot!</p>";
    else print 
"<p>This was a VALID submission. Your message is: ".@$param['message']."</p>";
    if (
$submissions) print "<p>You have submitted ".$submissions." time(s). Reload this page to check...</p>";
?>
<p>The names of the elements generated by the class as an array:<br />
<?php print_r ($blocker->getTagNames()); ?>
</p>
<p>The $_SESSION array generated by the class (if $hasSession==true):<br />
<?php 
if ($blocker->hasSessionprint_r ($_SESSION);
else print 
"Session based methods have not been enabled";
?>
</p>
<br /><a href="example.php">return to example</a>
</body>
</html>