mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-07 12:36:25 +00:00
Making changes to Security class
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3353 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
905117bbc6
commit
36ae60d0e7
2 changed files with 61 additions and 57 deletions
|
@ -43,7 +43,7 @@ class Security extends Object{
|
||||||
function &getInstance() {
|
function &getInstance() {
|
||||||
static $instance = array();
|
static $instance = array();
|
||||||
if (!$instance) {
|
if (!$instance) {
|
||||||
$instance[0] = &new Security;
|
$instance[0] =& new Security;
|
||||||
}
|
}
|
||||||
return $instance[0];
|
return $instance[0];
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ class Security extends Object{
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function inactiveMins() {
|
function inactiveMins() {
|
||||||
|
$_this =& Security::getInstance();
|
||||||
switch(CAKE_SECURITY) {
|
switch(CAKE_SECURITY) {
|
||||||
case 'high':
|
case 'high':
|
||||||
return 10;
|
return 10;
|
||||||
|
@ -81,9 +82,10 @@ class Security extends Object{
|
||||||
* @param unknown_type $authKey
|
* @param unknown_type $authKey
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function validateAuthKey($authKey) {
|
function validateAuthKey($authKey) {
|
||||||
return true;
|
$_this =& Security::getInstance();
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
|
@ -91,31 +93,32 @@ class Security extends Object{
|
||||||
* @param unknown_type $type
|
* @param unknown_type $type
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function hash($string, $type = 'sha1') {
|
function hash($string, $type = 'sha1') {
|
||||||
$type = strtolower($type);
|
$_this =& Security::getInstance();
|
||||||
if ($type == 'sha1') {
|
$type = strtolower($type);
|
||||||
if (function_exists('sha1')) {
|
if ($type == 'sha1') {
|
||||||
$return = sha1($string);
|
if (function_exists('sha1')) {
|
||||||
return $return;
|
$return = sha1($string);
|
||||||
} else {
|
return $return;
|
||||||
$type = 'sha256';
|
} else {
|
||||||
}
|
$type = 'sha256';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($type == 'sha256') {
|
if ($type == 'sha256') {
|
||||||
if (function_exists('mhash')) {
|
if (function_exists('mhash')) {
|
||||||
$return = bin2hex(mhash(MHASH_SHA256, $string));
|
$return = bin2hex(mhash(MHASH_SHA256, $string));
|
||||||
return $return;
|
return $return;
|
||||||
} else {
|
} else {
|
||||||
$type = 'md5';
|
$type = 'md5';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type == 'md5') {
|
if ($type == 'md5') {
|
||||||
$return = md5($string);
|
$return = md5($string);
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
|
@ -123,22 +126,23 @@ class Security extends Object{
|
||||||
* @param unknown_type $key
|
* @param unknown_type $key
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function cipher($text, $key) {
|
function cipher($text, $key) {
|
||||||
if (!defined('CIPHER_SEED')) {
|
$_this =& Security::getInstance();
|
||||||
//This is temporary will change later
|
if (!defined('CIPHER_SEED')) {
|
||||||
define('CIPHER_SEED', '76859309657453542496749683645');
|
//This is temporary will change later
|
||||||
}
|
define('CIPHER_SEED', '76859309657453542496749683645');
|
||||||
srand (CIPHER_SEED);
|
}
|
||||||
$out = '';
|
srand (CIPHER_SEED);
|
||||||
|
$out = '';
|
||||||
|
|
||||||
for($i = 0; $i < strlen($text); $i++) {
|
for($i = 0; $i < strlen($text); $i++) {
|
||||||
for($j = 0; $j < ord(substr($key, $i % strlen($key), 1)); $j++) {
|
for($j = 0; $j < ord(substr($key, $i % strlen($key), 1)); $j++) {
|
||||||
$toss = rand(0, 255);
|
$toss = rand(0, 255);
|
||||||
}
|
}
|
||||||
$mask = rand(0, 255);
|
$mask = rand(0, 255);
|
||||||
$out .= chr(ord(substr($text, $i, 1)) ^ $mask);
|
$out .= chr(ord(substr($text, $i, 1)) ^ $mask);
|
||||||
}
|
}
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
Loading…
Add table
Reference in a new issue