Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ExeBy/smexe_ro.../var/softacul.../modx
File: modhashing.class.php
<?php
[0] Fix | Delete
/*
[1] Fix | Delete
* MODX Revolution
[2] Fix | Delete
*
[3] Fix | Delete
* Copyright 2006-2014 by MODX, LLC.
[4] Fix | Delete
* All rights reserved.
[5] Fix | Delete
*
[6] Fix | Delete
* This program is free software; you can redistribute it and/or modify it under
[7] Fix | Delete
* the terms of the GNU General Public License as published by the Free Software
[8] Fix | Delete
* Foundation; either version 2 of the License, or (at your option) any later
[9] Fix | Delete
* version.
[10] Fix | Delete
*
[11] Fix | Delete
* This program is distributed in the hope that it will be useful, but WITHOUT
[12] Fix | Delete
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
[13] Fix | Delete
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
[14] Fix | Delete
* details.
[15] Fix | Delete
*
[16] Fix | Delete
* You should have received a copy of the GNU General Public License along with
[17] Fix | Delete
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
[18] Fix | Delete
* Place, Suite 330, Boston, MA 02111-1307 USA
[19] Fix | Delete
*/
[20] Fix | Delete
[21] Fix | Delete
/**
[22] Fix | Delete
* This file contains the modHashing service class definition and the modHash abstract implementation class.
[23] Fix | Delete
* @package modx
[24] Fix | Delete
* @subpackage hashing
[25] Fix | Delete
*/
[26] Fix | Delete
/**
[27] Fix | Delete
* The modX hashing service class.
[28] Fix | Delete
*
[29] Fix | Delete
* @package modx
[30] Fix | Delete
* @subpackage hashing
[31] Fix | Delete
*/
[32] Fix | Delete
[33] Fix | Delete
class modHashing {
[34] Fix | Delete
/**
[35] Fix | Delete
* A reference to an xPDO instance communicating with this service instance.
[36] Fix | Delete
*
[37] Fix | Delete
* Though this is typically a modX instance, an xPDO instance must work for new installs.
[38] Fix | Delete
* @var xPDO
[39] Fix | Delete
*/
[40] Fix | Delete
public $modx= null;
[41] Fix | Delete
/**
[42] Fix | Delete
* An array of options for the hashing service.
[43] Fix | Delete
* @var array
[44] Fix | Delete
*/
[45] Fix | Delete
public $options= array();
[46] Fix | Delete
/**
[47] Fix | Delete
* An array of loaded modHash implementations.
[48] Fix | Delete
* @var array
[49] Fix | Delete
*/
[50] Fix | Delete
protected $_hashes= array();
[51] Fix | Delete
[52] Fix | Delete
/**
[53] Fix | Delete
* Constructs a new instance of the modHashing service class.
[54] Fix | Delete
*
[55] Fix | Delete
* @param xPDO &$modx A reference to an modX (or xPDO) instance.
[56] Fix | Delete
* @param array|null $options An array of options for the hashing service.
[57] Fix | Delete
*/
[58] Fix | Delete
function __construct(xPDO &$modx, $options= array()) {
[59] Fix | Delete
$this->modx= & $modx;
[60] Fix | Delete
if (is_array($options)) {
[61] Fix | Delete
$this->options = $options;
[62] Fix | Delete
}
[63] Fix | Delete
}
[64] Fix | Delete
[65] Fix | Delete
/**
[66] Fix | Delete
* Get an option for the MODX hashing service.
[67] Fix | Delete
*
[68] Fix | Delete
* Searches for local options and then prefixes keys with encrypt_ to look for
[69] Fix | Delete
* MODX System Settings.
[70] Fix | Delete
*
[71] Fix | Delete
* @param string $key The option key to get a value for.
[72] Fix | Delete
* @param array|null $options An optional array of options to look in first.
[73] Fix | Delete
* @param mixed $default An optional default value to return if no value is set.
[74] Fix | Delete
* @return mixed The option value or the specified default if not found.
[75] Fix | Delete
*/
[76] Fix | Delete
public function getOption($key, $options = null, $default = null) {
[77] Fix | Delete
if (is_array($options) && array_key_exists($key, $options)) {
[78] Fix | Delete
$option = $options[$key];
[79] Fix | Delete
} elseif (array_key_exists($key, $this->options)) {
[80] Fix | Delete
$option = $this->options[$key];
[81] Fix | Delete
} else {
[82] Fix | Delete
$option = $this->modx->getOption('hashing_' . $key, $this->options, $default);
[83] Fix | Delete
}
[84] Fix | Delete
return $option;
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
/**
[88] Fix | Delete
* Get a hash implementation instance.
[89] Fix | Delete
*
[90] Fix | Delete
* The implementation is made available as a member variable of the modHashing service.
[91] Fix | Delete
*
[92] Fix | Delete
* @param string $key A key string identifying the instance; must be a valid PHP variable name.
[93] Fix | Delete
* @param string $class A valid fully-qualified modHash derivative class name
[94] Fix | Delete
* @param array|null $options An optional array of hash options.
[95] Fix | Delete
* @return modHash|null A reference to a modHash instance or null if could not be instantiated.
[96] Fix | Delete
*/
[97] Fix | Delete
public function getHash($key, $class, $options = array()) {
[98] Fix | Delete
$className = $this->modx->loadClass($class, '', false, true);
[99] Fix | Delete
if ($className) {
[100] Fix | Delete
if (empty($key)) $key = strtolower(str_replace('mod', '', $className));
[101] Fix | Delete
if (!array_key_exists($key, $this->_hashes)) {
[102] Fix | Delete
$hash = new $className($this, $options);
[103] Fix | Delete
if ($hash instanceof $className) {
[104] Fix | Delete
$this->_hashes[$key] = $hash;
[105] Fix | Delete
$this->$key =& $this->_hashes[$key];
[106] Fix | Delete
}
[107] Fix | Delete
}
[108] Fix | Delete
if (array_key_exists($key, $this->_hashes)) {
[109] Fix | Delete
return $this->_hashes[$key];
[110] Fix | Delete
}
[111] Fix | Delete
}
[112] Fix | Delete
return null;
[113] Fix | Delete
}
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
/**
[117] Fix | Delete
* Defines the interface for a modHash implementation.
[118] Fix | Delete
*
[119] Fix | Delete
* @abstract Implement a derivative of this class to define an actual hash algorithm implementation.
[120] Fix | Delete
* @package modx
[121] Fix | Delete
* @subpackage hashing
[122] Fix | Delete
*/
[123] Fix | Delete
abstract class modHash {
[124] Fix | Delete
/**
[125] Fix | Delete
* A reference to the modHashing service hosting this modHash instance.
[126] Fix | Delete
* @var modHashing
[127] Fix | Delete
*/
[128] Fix | Delete
public $host= null;
[129] Fix | Delete
/**
[130] Fix | Delete
* An array of options for the modHash implementation.
[131] Fix | Delete
* @var array
[132] Fix | Delete
*/
[133] Fix | Delete
public $options= array();
[134] Fix | Delete
[135] Fix | Delete
/**
[136] Fix | Delete
* Constructs a new instance of the modHash class.
[137] Fix | Delete
*
[138] Fix | Delete
* @param modHashing $host A reference to the modHashing instance
[139] Fix | Delete
* @param array|null $options An optional array of configuration options
[140] Fix | Delete
* @return modHash A new derivative instance of the modHash class
[141] Fix | Delete
*/
[142] Fix | Delete
function __construct(modHashing &$host, $options= array()) {
[143] Fix | Delete
$this->host =& $host;
[144] Fix | Delete
if (is_array($options)) {
[145] Fix | Delete
$this->options = $options;
[146] Fix | Delete
}
[147] Fix | Delete
}
[148] Fix | Delete
[149] Fix | Delete
/**
[150] Fix | Delete
* Get an option for this modHash implementation
[151] Fix | Delete
*
[152] Fix | Delete
* Searches for local options and then prefixes keys with hashing_ to look for
[153] Fix | Delete
* MODX System Settings.
[154] Fix | Delete
*
[155] Fix | Delete
* @param string $key The option key to get a value for.
[156] Fix | Delete
* @param array|null $options An optional array of options to look in first.
[157] Fix | Delete
* @param mixed $default An optional default value to return if no value is set.
[158] Fix | Delete
* @return mixed The option value or the specified default if not found.
[159] Fix | Delete
*/
[160] Fix | Delete
[161] Fix | Delete
public function getOption($key, $options = null, $default = null) {
[162] Fix | Delete
if (is_array($options) && array_key_exists($key, $options)) {
[163] Fix | Delete
$option = $options[$key];
[164] Fix | Delete
} else {
[165] Fix | Delete
$option = $this->host->getOption($key, $this->options, $default);
[166] Fix | Delete
}
[167] Fix | Delete
return $option;
[168] Fix | Delete
}
[169] Fix | Delete
[170] Fix | Delete
/**
[171] Fix | Delete
* Generate a hash of the given string using the provided options.
[172] Fix | Delete
*
[173] Fix | Delete
* @abstract
[174] Fix | Delete
* @param string $string A string to generate a secure hash from.
[175] Fix | Delete
* @param array $options An array of options to be passed to the hash implementation.
[176] Fix | Delete
* @return mixed The hash result or false on failure.
[177] Fix | Delete
*/
[178] Fix | Delete
public abstract function hash($string, array $options = array());
[179] Fix | Delete
}
[180] Fix | Delete
[181] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function