00001 <?php 00002 00003 /****************************************************************** 00004 00005 Projectname: CAPTCHA class 00006 Version: 2.0 00007 Author: Pascal Rehfeldt <Pascal@Pascal-Rehfeldt.com> 00008 Last modified: 15. January 2006 00009 00010 * GNU General Public License (Version 2, June 1991) 00011 * 00012 * This program is free software; you can redistribute 00013 * it and/or modify it under the terms of the GNU 00014 * General Public License as published by the Free 00015 * Software Foundation; either version 2 of the License, 00016 * or (at your option) any later version. 00017 * 00018 * This program is distributed in the hope that it will 00019 * be useful, but WITHOUT ANY WARRANTY; without even the 00020 * implied warranty of MERCHANTABILITY or FITNESS FOR A 00021 * PARTICULAR PURPOSE. See the GNU General Public License 00022 * for more details. 00023 00024 Description: 00025 This class can generate CAPTCHAs, see README for more details! 00026 00027 ******************************************************************/ 00028 00029 class error 00030 { 00031 00032 var $errors; 00033 00034 function error () 00035 { 00036 00037 $this->errors = array(); 00038 00039 } //error 00040 00041 function addError ($errormsg) 00042 { 00043 00044 $this->errors[] = $errormsg; 00045 00046 } //addError 00047 00048 function displayError () 00049 { 00050 displayerror('Error! Could not generate captcha.<br />' . join($this->errors, '<br />')); 00051 /* 00052 $iheight = count($this->errors) * 20 + 10; 00053 $iheight = ($iheight < 130) ? 130 : $iheight; 00054 00055 $image = imagecreate(600, $iheight); 00056 00057 $errorsign = imagecreatefromjpeg('gfx/errorsign.jpg'); 00058 imagecopy($image, $errorsign, 1, 1, 1, 1, 180, 120); 00059 00060 $bgcolor = imagecolorallocate($image, 255, 255, 255); 00061 00062 $stringcolor = imagecolorallocate($image, 0, 0, 0); 00063 00064 for ($i = 0; $i < count($this->errors); $i++) 00065 { 00066 00067 $imx = ($i == 0) ? $i * 20 + 5 : $i * 20; 00068 00069 00070 $msg = 'Error[' . $i . ']: ' . $this->errors[$i]; 00071 00072 imagestring($image, 5, 190, $imx, $msg, $stringcolor); 00073 00074 } 00075 00076 imagepng($image); 00077 00078 imagedestroy($image);*/ 00079 00080 } //displayError 00081 00082 function isError () 00083 { 00084 00085 if (count($this->errors) == 0) 00086 { 00087 00088 return FALSE; 00089 00090 } 00091 else 00092 { 00093 00094 return TRUE; 00095 00096 } 00097 00098 } //isError 00099 00100 } //class: error 00101