Source for file AntiSpam.class.php
Documentation is available at AntiSpam.class.php 
 * This work is hereby released into the Public Domain.  
 * To view a copy of the public domain dedication,  
 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to  
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.  
require_once dirname(__FILE__ ). "/Image.class.php";  
 * String printed on the images are case insensitive.  
 * @package linea21.externals  
   * Construct a new awAntiSpam image  
   * @param string $string A string to display  
    $this->string = (string) $string;  
   * @param int $length String length  
   * @return string String created  
    $letters =  'aAbBCDeEFgGhHJKLmMnNpPqQRsStTuVwWXYZz2345679';  
    for($i =  0; $i <  $length; $i++ ) {  
   * @param int $nois Noise intensity (from 0 to 10)  
    $this->noise = (int) $noise;  
   * Save string value in session  
   * You can use check() to verify the value later  
   * @param string $qName A name that identify the anti-spam image  
  public function save($qName) {  
    $session =  'artichow_'.(string) $qName;  
    $_SESSION[$session] =  $this->string;  
   * @param string $qName A name that identify the anti-spam image  
   * @param string $value User-defined value  
   * @param bool $case TRUE for case insensitive check, FALSE for case sensitive check ? (default to TRUE)  
   * @return bool TRUE if the value is correct, FALSE otherwise  
  public function check($qName, $value, $case =  TRUE) {  
    $session =  'artichow_'.(string) $qName;  
    ($_SESSION[$session] === (string) $value)  
            $sizes =  array(12, 12.5, 13, 13.5, 14, 15, 16, 17, 18, 19);  
            // Set up a temporary driver to allow font size calculations...  
              $fonts[$fontKey], $sizes[$sizeKey]  
              $widths[] =  $driver->getTextWidth($text);  
              $heights[] =  $driver->getTextHeight($text);  
            // ... and get rid of it.  
            $width =  array_sum($widths);  
            $totalWidth =  $width +  10 +  count($texts) *  10;  
            $totalHeight =  $height +  20;  
            $this->setSize($totalWidth, $totalHeight);  
            for($i =  0; $i <  strlen($this->string); $i++ ) {  
                    5 +  array_sum(array_slice($widths, 0, $i)) +  $widths[$i] /  2 +  $i *  10,  
                    10 +  ($height -  $heights[$i]) /  2  
  protected function drawNoise($width, $height) {  
    $points =  $this->noise *  30;  
    for($i =  0; $i <  $points; $i++ ) {  
    // Start session if needed  
 
 
        
       |