PHP Classes

File: example_2.php

Recommend this page to a friend!
  Classes of Costin Trifan   AbsCaptcha   example_2.php   Download  
File: example_2.php
Role: Example script
Content type: text/plain
Description: Example 2
Class: AbsCaptcha
Generate CAPTCHA validation images
Author: By
Last change:
Date: 14 years ago
Size: 1,071 bytes
 

Contents

Class file image Download
<?php
/**
* TEST CAPTCHA CLASS
*/
    # No cache headers
   
header("Expires: Mon, 05 June 2001 05:06:07 GMT");
     
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
   
header('Cache-Control: pre-check=0, post-check=0, max-age=0');
   
header("Cache-Control: no-cache, must-revalidate");
   
header("Pragma: no-cache");

   
session_start(); # REQUIRED

// INCLUDE THE CAPTCHA CLASS
   
require("class.AbsCaptcha.php");

// SET THE PATH TO THE DIRECTORY WHERE TO STORE THE IMAGE
   
$dir = $_SERVER['DOCUMENT_ROOT'].'/Projects/Captcha/captcha/';

// INSTANTIATE THE CLASS :: change the background and the foreground color

   
$c = new AbsCaptcha('x_session_captcha', $dir, 'captcha', array(0,0,0), array(255,255,255));

// GENERATE IMAGE
   
$c->GenerateCaptcha();

// DISPLAY THE IMAGE
   
echo '<img src="captcha/'.$c->GetImageName().'" width="'.$c->GetImageWidth().'" height="'.$c->GetImageHeight().'" />';

// DISPLAY THE CODE FROM THE IMAGE
   
echo '<p>code: '.$c->GetCaptchaCode().'</p>';


// uncomment to clear the session.
// session_destroy();
?>