[ Index ] |
|
Code source de Zen Cart E-Commerce Shopping Cart 1.3.7.1 |
1 <?php 2 // 3 // +----------------------------------------------------------------------+ 4 // |zen-cart Open Source E-commerce | 5 // +----------------------------------------------------------------------+ 6 // | Copyright (c) 2003 The zen-cart developers | 7 // | | 8 // | http://www.zen-cart.com/index.php | 9 // | | 10 // | Portions Copyright (c) 2003 osCommerce | 11 // +----------------------------------------------------------------------+ 12 // | This source file is subject to version 2.0 of the GPL license, | 13 // | that is bundled with this package in the file LICENSE, and is | 14 // | available through the world-wide-web at the following url: | 15 // | http://www.zen-cart.com/license/2_0.txt. | 16 // | If you did not receive a copy of the zen-cart license and are unable | 17 // | to obtain it through the world-wide-web, please send a note to | 18 // | license@zen-cart.com so we can mail you a copy immediately. | 19 // +----------------------------------------------------------------------+ 20 // $Id: password_funcs.php 2386 2005-11-17 23:09:03Z drbyte $ 21 // 22 23 //// 24 // This function validates a plain text password with an encrpyted password 25 function zen_validate_password($plain, $encrypted) { 26 if (zen_not_null($plain) && zen_not_null($encrypted)) { 27 // split apart the hash / salt 28 $stack = explode(':', $encrypted); 29 30 if (sizeof($stack) != 2) return false; 31 32 if (md5($stack[1] . $plain) == $stack[0]) { 33 return true; 34 } 35 } 36 37 return false; 38 } 39 40 //// 41 // This function makes a new password from a plaintext password. 42 function zen_encrypt_password($plain) { 43 $password = ''; 44 45 for ($i=0; $i<10; $i++) { 46 $password .= zen_rand(); 47 } 48 49 $salt = substr(md5($password), 0, 2); 50 51 $password = md5($salt . $plain) . ':' . $salt; 52 53 return $password; 54 } 55 56 //// 57 // This function comes up with a plaintext word. 58 // You can then pass this word over to zen_encrypt_password or another similar function 59 function zen_create_random_value($length, $type = 'mixed') { 60 if ( ($type != 'mixed') && ($type != 'chars') && ($type != 'digits')) return false; 61 62 $rand_value = ''; 63 while (strlen($rand_value) < $length) { 64 if ($type == 'digits') { 65 $char = zen_rand(0,9); 66 } else { 67 $char = chr(zen_rand(0,255)); 68 } 69 if ($type == 'mixed') { 70 if (eregi('^[a-z0-9]$', $char)) $rand_value .= $char; 71 } elseif ($type == 'chars') { 72 if (eregi('^[a-z]$', $char)) $rand_value .= $char; 73 } elseif ($type == 'digits') { 74 if (ereg('^[0-9]$', $char)) $rand_value .= $char; 75 } 76 } 77 78 return $rand_value; 79 } 80 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 16:45:43 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |