AAAAhome/academiac/www/administrator/components/com_virtuemart/helpers/vmcrypt.php000060400000013772151372157300024205 0ustar000){ ksort($existingKeys); if(!empty($date)){ $key = ''; foreach($existingKeys as $unixDate=>$values){ if(($unixDate-30) >= $date ){ vmdebug('$unixDate '.$unixDate.' >= $date '.$date); continue; } vmdebug('$unixDate < $date'); //$usedKey = $values; $key = $values['key']; } vmdebug('Use key file ',$key); //include($keyPath .DS. $usedKey.'.php'); } else { $usedKey = end($existingKeys); $key = $usedKey['key']; } vmTime('my time','check'); return $key; } else { $usedKey = date("ymd"); $filename = $keyPath . DS . $usedKey . '.ini'; if (!JFile::exists ($filename)) { $token = JUtility::getHash(JUserHelper::genRandomPassword()); $salt = JUserHelper::getSalt('crypt-md5'); $hashedToken = md5($token . $salt) ; $key = base64_encode($hashedToken); //$options = array('costs'=>VmConfig::get('cryptCost',8)); /*if(!function_exists('password_hash')){ require(JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'password_compat.php'); } if(function_exists('password_hash')){ $key = password_hash($key, PASSWORD_BCRYPT, $options); }*/ $date = JFactory::getDate(); $today = $date->toUnix(); //$key = pack('H*',$key); $content = ';'; $result = JFile::write($filename, $content); vmTime('my time','check'); return $key; } } vmTime('my time','check'); //return pack('H*',$key); } private static function _getEncryptSafepath () { if (!class_exists('ShopFunctions')) require(JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php'); $safePath = ShopFunctions::checkSafePath(); if (empty($safePath)) { return NULL; } $encryptSafePath = $safePath . self::ENCRYPT_SAFEPATH; //echo 'my $encryptSafePath '.$encryptSafePath; //if(!JFolder::exists($encryptSafePath)){ self::createEncryptFolder($encryptSafePath); //} return $encryptSafePath; } private static function createEncryptFolder ($folderName) { //$folderName = self::_getEncryptSafepath (); $exists = JFolder::exists ($folderName); if ($exists) { return TRUE; } $created = JFolder::create ($folderName); if ($created) { return TRUE; } $uri = JFactory::getURI (); $link = $uri->root () . 'administrator/index.php?option=com_virtuemart&view=config'; VmError (JText::sprintf ('COM_VIRTUEMART_CANNOT_STORE_CONFIG', $folderName, '' . $link . '', JText::_ ('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'))); return FALSE; } }