Changeset 2364 in ExiteCMS for branches/PLi-Fusion/includes/secureimage-1.0.3/securimage.php
- Timestamp:
- 07/29/10 17:16:11 (22 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PLi-Fusion/includes/secureimage-1.0.3/securimage.php
r1986 r2364 18 18 * License along with this library; if not, write to the Free Software 19 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA<br /><br /> 20 * 21 * Any modifications to the library should be indicated clearly in the source code 20 * 21 * Any modifications to the library should be indicated clearly in the source code 22 22 * to inform users that the changes are not a part of the original software.<br /><br /> 23 23 * … … 121 121 var $charset = 'ABCDEFGHKLMNPRSTUVWYZ23456789'; 122 122 //var $charset = '0123456789'; 123 123 124 124 /** 125 125 * Create codes using this word list … … 128 128 */ 129 129 var $wordlist_file = ''; 130 130 131 131 /** 132 132 * True to use a word list file instead of a random code … … 363 363 var $audio_path = './audio/'; 364 364 365 /** 366 * Captcha expiry timeout in seconds. 367 * 368 * @since 1.0.3 369 * @var string 370 */ 371 var $timeout = 300; 372 373 365 374 366 375 //END USER CONFIGURATION … … 423 432 die('no session available!'); 424 433 } 425 434 426 435 // we use random colors to make it even more difficult 427 436 $this->image_bg_color = $this->getHexColor(); … … 445 454 return $clr; 446 455 } 447 456 448 457 /** 449 458 * Generate a code and output the image to the browser. … … 693 702 { 694 703 $this->code = false; 695 704 696 705 if ($this->use_wordlist && is_readable($this->wordlist_file)) { 697 706 $this->code = $this->readCodeFromFile(); 698 707 } 699 708 700 709 if ($this->code == false) { 701 710 $this->code = $this->generateCode($this->code_length); 702 711 } 703 712 704 713 $this->saveData(); 705 714 } … … 721 730 return $code; 722 731 } 723 732 724 733 /** 725 734 * Reads a word list file to get a code … … 733 742 $fp = @fopen($this->wordlist_file, 'r'); 734 743 if (!$fp) return false; 735 744 736 745 $fsize = filesize($this->wordlist_file); 737 746 if ($fsize < 32) return false; // too small of a list to be effective 738 747 739 748 if ($fsize < 128) { 740 749 $max = $fsize; // still pretty small but changes the range of seeking … … 742 751 $max = 128; 743 752 } 744 753 745 754 fseek($fp, rand(0, $fsize - $max), SEEK_SET); 746 755 $data = fread($fp, 128); // read a random 128 bytes from file 747 756 fclose($fp); 748 757 749 758 $start = strpos($data, "\n", rand(0, 100)) + 1; // random start position 750 759 $end = strpos($data, "\n", $start) - 1; // find end of word 751 760 752 761 return strtolower(substr($data, $start, $end - $start)); // return substring in 128 bytes 753 762 } … … 822 831 { 823 832 $_SESSION['securimage_code_value'] = strtolower($this->code); 833 $_SESSION['securimage_code_timestamp'] = time(); 824 834 } 825 835 … … 834 844 if ( isset($_SESSION['securimage_code_value']) && !empty($_SESSION['securimage_code_value']) ) { 835 845 if ( $_SESSION['securimage_code_value'] == strtolower(trim($this->code_entered)) ) { 836 $this->correct_code = true; 837 $_SESSION['securimage_code_value'] = ''; 846 if (isset($_SESSION['securimage_code_timestamp']) && (time() - $_SESSION['securimage_code_timestamp']) < $this->timeout) { 847 $this->correct_code = true; 848 $_SESSION['securimage_code_value'] = ''; 849 } else { 850 $this->correct_code = false; 851 } 838 852 } else { 839 853 $this->correct_code = false; … … 906 920 $file['size'] = $data['ChunkSize'] + 8; 907 921 $file['data'] = $body; 908 922 909 923 if ( ($p = strpos($file['data'], 'LIST')) !== false) { 910 924 // If the LIST data is not at the end of the file, this will probably break your sound file … … 914 928 $file['size'] = $file['size'] - (strlen($file['data']) - $p); 915 929 } 916 930 917 931 $files[] = $file; 918 932 $data = null;
Note: See TracChangeset
for help on using the changeset viewer.
