Changeset 42 for trunk/lib/Captcha.inc.php
- Timestamp:
- Dec 18, 2005 12:16:03 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Captcha.inc.php
r41 r42 1 <?php 1 <?php 2 2 /** 3 3 * Captcha.inc.php … … 10 10 */ 11 11 class Captcha { 12 12 13 13 var $secret_key = 'some random seed text for the md5'; 14 14 var $ascii_numbers = array( … … 95 95 ) 96 96 ); 97 97 98 98 /** 99 99 * Print ASCII number. … … 109 109 if (preg_match('/[^\d]/', $num)) { 110 110 App::logMsg(sprintf('Bad number: %s', $num), LOG_ERR, __FILE__, __LINE__); 111 111 return false; 112 112 } 113 113 114 114 // Number must be an array of strings. 115 115 $num = preg_split('// ', strval($num), -1, PREG_SPLIT_NO_EMPTY); … … 124 124 $output .= "\n"; 125 125 } 126 126 127 127 return $output; 128 128 } 129 129 130 130 /** 131 131 * Prints a form to enter captcha, including the required hidden hash form. … … 148 148 <?php 149 149 } 150 151 /** 152 * Validate submitted number against ascii captcha. 150 151 /** 152 * Validate submitted number against ascii captcha. 153 153 * Regenerate md5 hash from submitted captcha number and compare with posted hash. 154 154 * … … 164 164 165 165 if ('' == $number . $hash) { 166 166 return false; 167 167 } 168 168 … … 182 182 return rand(1000, 9999); 183 183 } 184 184 185 185 /** 186 186 * Generate md5 hash of number using secret key. … … 196 196 return md5($this->secret_key . $input); 197 197 } 198 198 199 199 } 200 200
Note: See TracChangeset
for help on using the changeset viewer.