mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +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
|
@ -288,7 +288,7 @@ class Model extends Overloadable {
|
|||
* Default association keys
|
||||
*
|
||||
* @var array
|
||||
* @access protected
|
||||
* @access protected
|
||||
*/
|
||||
var $__associationKeys = array(
|
||||
'belongsTo' => array('className', 'conditions', 'order', 'foreignKey', 'counterCache'),
|
||||
|
@ -301,7 +301,7 @@ class Model extends Overloadable {
|
|||
* Holds provided/generated association key names and other data for all associations
|
||||
*
|
||||
* @var array
|
||||
* @access protected
|
||||
* @access protected
|
||||
*/
|
||||
var $__associations = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany');
|
||||
|
||||
|
@ -309,7 +309,7 @@ class Model extends Overloadable {
|
|||
* The last inserted ID of the data that this model created
|
||||
*
|
||||
* @var integer
|
||||
* @access protected
|
||||
* @access protected
|
||||
*/
|
||||
var $__insertID = null;
|
||||
|
||||
|
@ -317,7 +317,7 @@ class Model extends Overloadable {
|
|||
* The number of records returned by the last query
|
||||
*
|
||||
* @var integer
|
||||
* @access protected
|
||||
* @access protected
|
||||
*/
|
||||
var $__numRows = null;
|
||||
|
||||
|
@ -325,7 +325,7 @@ class Model extends Overloadable {
|
|||
* The number of records affected by the last query
|
||||
*
|
||||
* @var integer
|
||||
* @access protected
|
||||
* @access protected
|
||||
*/
|
||||
var $__affectedRows = null;
|
||||
|
||||
|
@ -424,7 +424,7 @@ class Model extends Overloadable {
|
|||
* Handles custom method calls, like findBy<field> for DB models,
|
||||
* and custom RPC calls for remote data sources.
|
||||
*
|
||||
* @param string $method Name of method to call.
|
||||
* @param string $method Name of method to call.
|
||||
* @param array $params Parameters for the method.
|
||||
* @return unknown
|
||||
* @access protected
|
||||
|
@ -478,12 +478,12 @@ class Model extends Overloadable {
|
|||
/**
|
||||
* Turn off associations on the fly.
|
||||
*
|
||||
* Example: Turn off the associated Model Supportrequest,
|
||||
* to temporarily lighten the User model:
|
||||
* <code>
|
||||
* $this->User->unbindModel( array('hasMany' => array('Supportrequest')) );
|
||||
* </code>
|
||||
*
|
||||
* Example: Turn off the associated Model Supportrequest,
|
||||
* to temporarily lighten the User model:
|
||||
* <code>
|
||||
* $this->User->unbindModel( array('hasMany' => array('Supportrequest')) );
|
||||
* </code>
|
||||
*
|
||||
* @link http://cakebaker.wordpress.com/2006/02/22/new-feature-bindmodelunbindmodel/
|
||||
* @param array $params
|
||||
* @return boolean Always true
|
||||
|
@ -777,7 +777,7 @@ class Model extends Overloadable {
|
|||
$this->id = false;
|
||||
unset ($this->data);
|
||||
$this->data = array();
|
||||
|
||||
|
||||
$cols = $this->loadInfo();
|
||||
if (array_key_exists('default', $cols->value[0])) {
|
||||
$count = count($cols->value);
|
||||
|
@ -787,7 +787,7 @@ class Model extends Overloadable {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!empty($data) && $data !== null) {
|
||||
$this->set($data);
|
||||
}
|
||||
|
@ -1265,7 +1265,7 @@ class Model extends Overloadable {
|
|||
$this->behaviors[$b[$i]]->afterFind($this, $results);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$return = $this->afterFind($results);
|
||||
|
||||
if (isset($this->__backAssociation)) {
|
||||
|
|
|
@ -43,7 +43,7 @@ class Security extends Object{
|
|||
function &getInstance() {
|
||||
static $instance = array();
|
||||
if (!$instance) {
|
||||
$instance[0] = &new Security;
|
||||
$instance[0] =& new Security;
|
||||
}
|
||||
return $instance[0];
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ class Security extends Object{
|
|||
* @return unknown
|
||||
*/
|
||||
function inactiveMins() {
|
||||
$_this =& Security::getInstance();
|
||||
switch(CAKE_SECURITY) {
|
||||
case 'high':
|
||||
return 10;
|
||||
|
@ -81,9 +82,10 @@ class Security extends Object{
|
|||
* @param unknown_type $authKey
|
||||
* @return unknown
|
||||
*/
|
||||
function validateAuthKey($authKey) {
|
||||
return true;
|
||||
}
|
||||
function validateAuthKey($authKey) {
|
||||
$_this =& Security::getInstance();
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
|
@ -91,31 +93,32 @@ class Security extends Object{
|
|||
* @param unknown_type $type
|
||||
* @return unknown
|
||||
*/
|
||||
function hash($string, $type = 'sha1') {
|
||||
$type = strtolower($type);
|
||||
if ($type == 'sha1') {
|
||||
if (function_exists('sha1')) {
|
||||
$return = sha1($string);
|
||||
return $return;
|
||||
} else {
|
||||
$type = 'sha256';
|
||||
}
|
||||
}
|
||||
function hash($string, $type = 'sha1') {
|
||||
$_this =& Security::getInstance();
|
||||
$type = strtolower($type);
|
||||
if ($type == 'sha1') {
|
||||
if (function_exists('sha1')) {
|
||||
$return = sha1($string);
|
||||
return $return;
|
||||
} else {
|
||||
$type = 'sha256';
|
||||
}
|
||||
}
|
||||
|
||||
if ($type == 'sha256') {
|
||||
if (function_exists('mhash')) {
|
||||
$return = bin2hex(mhash(MHASH_SHA256, $string));
|
||||
return $return;
|
||||
} else {
|
||||
$type = 'md5';
|
||||
if ($type == 'sha256') {
|
||||
if (function_exists('mhash')) {
|
||||
$return = bin2hex(mhash(MHASH_SHA256, $string));
|
||||
return $return;
|
||||
} else {
|
||||
$type = 'md5';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($type == 'md5') {
|
||||
$return = md5($string);
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
if ($type == 'md5') {
|
||||
$return = md5($string);
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
|
@ -123,22 +126,23 @@ class Security extends Object{
|
|||
* @param unknown_type $key
|
||||
* @return unknown
|
||||
*/
|
||||
function cipher($text, $key) {
|
||||
if (!defined('CIPHER_SEED')) {
|
||||
//This is temporary will change later
|
||||
define('CIPHER_SEED', '76859309657453542496749683645');
|
||||
}
|
||||
srand (CIPHER_SEED);
|
||||
$out = '';
|
||||
function cipher($text, $key) {
|
||||
$_this =& Security::getInstance();
|
||||
if (!defined('CIPHER_SEED')) {
|
||||
//This is temporary will change later
|
||||
define('CIPHER_SEED', '76859309657453542496749683645');
|
||||
}
|
||||
srand (CIPHER_SEED);
|
||||
$out = '';
|
||||
|
||||
for($i = 0; $i < strlen($text); $i++) {
|
||||
for($j = 0; $j < ord(substr($key, $i % strlen($key), 1)); $j++) {
|
||||
$toss = rand(0, 255);
|
||||
}
|
||||
$mask = rand(0, 255);
|
||||
$out .= chr(ord(substr($text, $i, 1)) ^ $mask);
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
for($i = 0; $i < strlen($text); $i++) {
|
||||
for($j = 0; $j < ord(substr($key, $i % strlen($key), 1)); $j++) {
|
||||
$toss = rand(0, 255);
|
||||
}
|
||||
$mask = rand(0, 255);
|
||||
$out .= chr(ord(substr($text, $i, 1)) ^ $mask);
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Add table
Reference in a new issue