[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path Zen Cart 源代码 password_funcs.php
<?php
/**
* password_funcs functions
*
* @package functions
* @copyright Copyright 2003-2014 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version GIT: $Id: Author: Ian Wilson Wed Feb 19 15:57:35 2014 +0000 Modified in v1.5.3 $
*/
// //
// This function validates a plain text password with an encrpyted password
function zen_validate_password($plain, $encrypted, $userRef = NULL)
{
$zcPassword = zcPassword::getInstance(PHP_VERSION);
return $zcPassword->validatePassword($plain, $encrypted);
}
// //
// This function makes a new password from a plaintext password.
function zen_encrypt_password($plain)
{
$password = '';
return $rand_value;
}
/**
* Returns entropy using a hash of various available methods for obtaining
* random data.
* The default hash method is "sha1" and the default size is 32.
*
* @param string $hash
* the hash method to use while generating the hash.
* @param int $size
* the size of random data to use while generating the hash.
* @return string the randomized salt
*/
function zen_get_entropy($hash = 'sha1', $size = 32)
{
$data = null;
if (! in_array($hash, hash_algos()))
$hash = 'sha1';
if (! is_int($size))
$size = (int)$size;
// Use openssl if available
if (function_exists('openssl_random_pseudo_bytes')) {
// echo('Attempting to create entropy using openssl');
$entropy = openssl_random_pseudo_bytes($size, $strong);
if ($strong)
$data = $entropy;
unset($strong, $entropy);
}
// Use mcrypt with /dev/urandom if available
if ($data === null && function_exists('mcrypt_create_iv') && (
// There is a bug in Windows + IIS in older versions of PHP
(
strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' || version_compare(PHP_VERSION, '5.3.7', '>='))))
{
// echo('Attempting to create entropy using mcrypt');
$entropy = mcrypt_create_iv($size, MCRYPT_DEV_URANDOM);
if ($entropy !== FALSE)
$data = $entropy;
unset($entropy);
}
if ($data === null) {
// Fall back to using /dev/urandom if available
$fp = @fopen('/dev/urandom', 'rb');
if ($fp !== FALSE) {
// echo('Attempting to create entropy using /dev/urandom');
$entropy = @fread($fp, $size);
@fclose($fp);
if (strlen($entropy) == $size)
$data = $entropy;
unset($fp, $entropy);
}
}
// Final fallback (mixture of various methods)
if ($data === null) {
// echo('Attempting to create entropy using FINAL FALLBACK');
if (!defined('DIR_FS_ROOT')) define('DIR_FS_ROOT', DIR_FS_CATALOG);
$filename = DIR_FS_ROOT . 'includes/configure.php';
$stat = @stat($filename);
if ($stat === FALSE) {
$stat = array(
'microtime' => microtime()
);
}
$stat ['mt_rand'] = mt_rand();
$stat ['file_hash'] = hash_file($hash, $filename, TRUE);
// Attempt to get a random value on windows
// http://msdn.microsoft.com/en-us/library/aa388176(VS.85).aspx
if (@class_exists('COM')) {
try {
$CAPI_Util = new COM('CAPICOM.Utilities.1');
$entropy = $CAPI_Util->GetRandom($size, 0);
if ($entropy) {
// echo('Adding random data to entropy using CAPICOM.Utilities');
$stat ['CAPICOM_Utilities_random'] = md5($entropy, TRUE);
}
unset($CAPI_Util, $entropy);
} catch ( Exception $ex ) {
}
}
// echo('Adding random data to entropy using file information and contents');
@shuffle($stat);
foreach ( $stat as $value ) {
$data .= $value;
}
unset($filename, $value, $stat);
}