[ Index ] |
|
Code source de e107 0.7.8 |
1 <?php 2 /* 3 + ----------------------------------------------------------------------------+ 4 | e107 website system 5 | 6 | ©Steve Dunstan 2001-2002 7 | http://e107.org 8 | jalist@e107.org 9 | 10 | Released under the terms and conditions of the 11 | GNU General Public License (http://gnu.org). 12 | 13 | $Source: /cvsroot/e107/e107_0.7/e107_handlers/secure_img_handler.php,v $ 14 | $Revision: 1.9 $ 15 | $Date: 2006/10/16 22:46:52 $ 16 | $Author: e107coders $ 17 +----------------------------------------------------------------------------+ 18 */ 19 20 if (!defined('e107_INIT')) { exit; } 21 22 class secure_image { 23 var $random_number; 24 25 function secure_image() { 26 list($usec, $sec) = explode(" ", microtime()); 27 $this->random_number = str_replace(".", "", $sec.$usec); 28 } 29 30 function create_code() { 31 global $pref, $sql, $IMAGES_DIRECTORY, $HANDLERS_DIRECTORY; 32 33 require_once ('e107_class.php'); 34 $e107 = new e107(false, false); 35 $e107->set_paths(); 36 37 $imgpy = str_replace($HANDLERS_DIRECTORY, "", $e107->file_path); 38 39 $imgp = $imgpy.$IMAGES_DIRECTORY; 40 mt_srand ((double)microtime() * 1000000); 41 $maxran = 1000000; 42 $rand_num = mt_rand(0, $maxran); 43 $datekey = date("r"); 44 $rcode = hexdec(md5($_SERVER['HTTP_USER_AGENT'] . serialize($pref). $rand_num . $datekey)); 45 $code = substr($rcode, 2, 6); 46 $recnum = $this->random_number; 47 $del_time = time()+1200; 48 $sql->db_Insert("tmp", "'{$recnum}',{$del_time},'{$code},{$imgp}'"); 49 return $recnum; 50 } 51 52 function verify_code($rec_num, $checkstr) { 53 global $sql, $tp; 54 if ($sql->db_Select("tmp", "tmp_info", "tmp_ip = '".$tp -> toDB($rec_num)."'")) { 55 $row = $sql->db_Fetch(); 56 $sql->db_Delete("tmp", "tmp_ip = '".$tp -> toDB($rec_num)."'"); 57 list($code, $path) = explode(",", $row[0]); 58 return ($checkstr == $code); 59 } 60 return FALSE; 61 } 62 63 function r_image() { 64 global $HANDLERS_DIRECTORY; 65 $code = $this->create_code(); 66 return "<img src='".e_BASE.$HANDLERS_DIRECTORY."secure_img_render.php?{$code}' alt='' />"; 67 } 68 } 69 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Apr 1 01:23:32 2007 | par Balluche grâce à PHPXref 0.7 |