Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/flow-flo.../libs/cakephp/cache/Engine
File: XcacheEngine.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
[2] Fix | Delete
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
[3] Fix | Delete
*
[4] Fix | Delete
* Licensed under The MIT License
[5] Fix | Delete
* For full copyright and license information, please see the LICENSE.txt
[6] Fix | Delete
* Redistributions of files must retain the above copyright notice.
[7] Fix | Delete
*
[8] Fix | Delete
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
[9] Fix | Delete
* @link https://cakephp.org CakePHP(tm) Project
[10] Fix | Delete
* @since 1.2.0
[11] Fix | Delete
* @license https://opensource.org/licenses/mit-license.php MIT License
[12] Fix | Delete
*/
[13] Fix | Delete
namespace Cake\Cache\Engine;
[14] Fix | Delete
[15] Fix | Delete
use Cake\Cache\CacheEngine;
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* Xcache storage engine for cache
[19] Fix | Delete
*
[20] Fix | Delete
* @link http://trac.lighttpd.net/xcache/ Xcache
[21] Fix | Delete
* @deprecated 3.6.0 Xcache engine has been deprecated and will be removed in 4.0.0.
[22] Fix | Delete
*/
[23] Fix | Delete
class XcacheEngine extends CacheEngine
[24] Fix | Delete
{
[25] Fix | Delete
/**
[26] Fix | Delete
* The default config used unless overridden by runtime configuration
[27] Fix | Delete
*
[28] Fix | Delete
* - `duration` Specify how long items in this cache configuration last.
[29] Fix | Delete
* - `groups` List of groups or 'tags' associated to every key stored in this config.
[30] Fix | Delete
* handy for deleting a complete group from cache.
[31] Fix | Delete
* - `prefix` Prefix appended to all entries. Good for when you need to share a keyspace
[32] Fix | Delete
* with either another cache config or another application.
[33] Fix | Delete
* - `probability` Probability of hitting a cache gc cleanup. Setting to 0 will disable
[34] Fix | Delete
* cache::gc from ever being called automatically.
[35] Fix | Delete
* - `PHP_AUTH_USER` xcache.admin.user
[36] Fix | Delete
* - `PHP_AUTH_PW` xcache.admin.password
[37] Fix | Delete
*
[38] Fix | Delete
* @var array
[39] Fix | Delete
*/
[40] Fix | Delete
protected $_defaultConfig = [
[41] Fix | Delete
'duration' => 3600,
[42] Fix | Delete
'groups' => [],
[43] Fix | Delete
'prefix' => null,
[44] Fix | Delete
'probability' => 100,
[45] Fix | Delete
'PHP_AUTH_USER' => 'user',
[46] Fix | Delete
'PHP_AUTH_PW' => 'password',
[47] Fix | Delete
];
[48] Fix | Delete
[49] Fix | Delete
/**
[50] Fix | Delete
* Initialize the Cache Engine
[51] Fix | Delete
*
[52] Fix | Delete
* Called automatically by the cache frontend
[53] Fix | Delete
*
[54] Fix | Delete
* @param array $config array of setting for the engine
[55] Fix | Delete
* @return bool True if the engine has been successfully initialized, false if not
[56] Fix | Delete
*/
[57] Fix | Delete
public function init(array $config = [])
[58] Fix | Delete
{
[59] Fix | Delete
if (!extension_loaded('xcache')) {
[60] Fix | Delete
return false;
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
parent::init($config);
[64] Fix | Delete
[65] Fix | Delete
return true;
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
/**
[69] Fix | Delete
* Write data for key into cache
[70] Fix | Delete
*
[71] Fix | Delete
* @param string $key Identifier for the data
[72] Fix | Delete
* @param mixed $value Data to be cached
[73] Fix | Delete
* @return bool True if the data was successfully cached, false on failure
[74] Fix | Delete
*/
[75] Fix | Delete
public function write($key, $value)
[76] Fix | Delete
{
[77] Fix | Delete
$key = $this->_key($key);
[78] Fix | Delete
[79] Fix | Delete
if (!is_numeric($value)) {
[80] Fix | Delete
$value = serialize($value);
[81] Fix | Delete
}
[82] Fix | Delete
[83] Fix | Delete
$duration = $this->_config['duration'];
[84] Fix | Delete
$expires = time() + $duration;
[85] Fix | Delete
xcache_set($key . '_expires', $expires, $duration);
[86] Fix | Delete
[87] Fix | Delete
return xcache_set($key, $value, $duration);
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
/**
[91] Fix | Delete
* Read a key from the cache
[92] Fix | Delete
*
[93] Fix | Delete
* @param string $key Identifier for the data
[94] Fix | Delete
* @return mixed The cached data, or false if the data doesn't exist,
[95] Fix | Delete
* has expired, or if there was an error fetching it
[96] Fix | Delete
*/
[97] Fix | Delete
public function read($key)
[98] Fix | Delete
{
[99] Fix | Delete
$key = $this->_key($key);
[100] Fix | Delete
[101] Fix | Delete
if (xcache_isset($key)) {
[102] Fix | Delete
$time = time();
[103] Fix | Delete
$cachetime = (int)xcache_get($key . '_expires');
[104] Fix | Delete
if ($cachetime < $time || ($time + $this->_config['duration']) < $cachetime) {
[105] Fix | Delete
return false;
[106] Fix | Delete
}
[107] Fix | Delete
[108] Fix | Delete
$value = xcache_get($key);
[109] Fix | Delete
if (is_string($value) && !is_numeric($value)) {
[110] Fix | Delete
$value = unserialize($value);
[111] Fix | Delete
}
[112] Fix | Delete
[113] Fix | Delete
return $value;
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
return false;
[117] Fix | Delete
}
[118] Fix | Delete
[119] Fix | Delete
/**
[120] Fix | Delete
* Increments the value of an integer cached key
[121] Fix | Delete
* If the cache key is not an integer it will be treated as 0
[122] Fix | Delete
*
[123] Fix | Delete
* @param string $key Identifier for the data
[124] Fix | Delete
* @param int $offset How much to increment
[125] Fix | Delete
* @return int|false New incremented value, false otherwise
[126] Fix | Delete
*/
[127] Fix | Delete
public function increment($key, $offset = 1)
[128] Fix | Delete
{
[129] Fix | Delete
$key = $this->_key($key);
[130] Fix | Delete
[131] Fix | Delete
return xcache_inc($key, $offset);
[132] Fix | Delete
}
[133] Fix | Delete
[134] Fix | Delete
/**
[135] Fix | Delete
* Decrements the value of an integer cached key.
[136] Fix | Delete
* If the cache key is not an integer it will be treated as 0
[137] Fix | Delete
*
[138] Fix | Delete
* @param string $key Identifier for the data
[139] Fix | Delete
* @param int $offset How much to subtract
[140] Fix | Delete
* @return int|false New decremented value, false otherwise
[141] Fix | Delete
*/
[142] Fix | Delete
public function decrement($key, $offset = 1)
[143] Fix | Delete
{
[144] Fix | Delete
$key = $this->_key($key);
[145] Fix | Delete
[146] Fix | Delete
return xcache_dec($key, $offset);
[147] Fix | Delete
}
[148] Fix | Delete
[149] Fix | Delete
/**
[150] Fix | Delete
* Delete a key from the cache
[151] Fix | Delete
*
[152] Fix | Delete
* @param string $key Identifier for the data
[153] Fix | Delete
* @return bool True if the value was successfully deleted, false if it didn't exist or couldn't be removed
[154] Fix | Delete
*/
[155] Fix | Delete
public function delete($key)
[156] Fix | Delete
{
[157] Fix | Delete
$key = $this->_key($key);
[158] Fix | Delete
[159] Fix | Delete
return xcache_unset($key);
[160] Fix | Delete
}
[161] Fix | Delete
[162] Fix | Delete
/**
[163] Fix | Delete
* Delete all keys from the cache
[164] Fix | Delete
*
[165] Fix | Delete
* @param bool $check If true no deletes will occur and instead CakePHP will rely
[166] Fix | Delete
* on key TTL values.
[167] Fix | Delete
* Unused for Xcache engine.
[168] Fix | Delete
* @return bool True if the cache was successfully cleared, false otherwise
[169] Fix | Delete
*/
[170] Fix | Delete
public function clear($check)
[171] Fix | Delete
{
[172] Fix | Delete
$this->_auth();
[173] Fix | Delete
$max = xcache_count(XC_TYPE_VAR);
[174] Fix | Delete
for ($i = 0; $i < $max; $i++) {
[175] Fix | Delete
xcache_clear_cache(XC_TYPE_VAR, $i);
[176] Fix | Delete
}
[177] Fix | Delete
$this->_auth(true);
[178] Fix | Delete
[179] Fix | Delete
return true;
[180] Fix | Delete
}
[181] Fix | Delete
[182] Fix | Delete
/**
[183] Fix | Delete
* Returns the `group value` for each of the configured groups
[184] Fix | Delete
* If the group initial value was not found, then it initializes
[185] Fix | Delete
* the group accordingly.
[186] Fix | Delete
*
[187] Fix | Delete
* @return string[]
[188] Fix | Delete
*/
[189] Fix | Delete
public function groups()
[190] Fix | Delete
{
[191] Fix | Delete
$result = [];
[192] Fix | Delete
foreach ($this->_config['groups'] as $group) {
[193] Fix | Delete
$value = xcache_get($this->_config['prefix'] . $group);
[194] Fix | Delete
if (!$value) {
[195] Fix | Delete
$value = 1;
[196] Fix | Delete
xcache_set($this->_config['prefix'] . $group, $value, 0);
[197] Fix | Delete
}
[198] Fix | Delete
$result[] = $group . $value;
[199] Fix | Delete
}
[200] Fix | Delete
[201] Fix | Delete
return $result;
[202] Fix | Delete
}
[203] Fix | Delete
[204] Fix | Delete
/**
[205] Fix | Delete
* Increments the group value to simulate deletion of all keys under a group
[206] Fix | Delete
* old values will remain in storage until they expire.
[207] Fix | Delete
*
[208] Fix | Delete
* @param string $group The group to clear.
[209] Fix | Delete
* @return bool success
[210] Fix | Delete
*/
[211] Fix | Delete
public function clearGroup($group)
[212] Fix | Delete
{
[213] Fix | Delete
return (bool)xcache_inc($this->_config['prefix'] . $group, 1);
[214] Fix | Delete
}
[215] Fix | Delete
[216] Fix | Delete
/**
[217] Fix | Delete
* Populates and reverses $_SERVER authentication values
[218] Fix | Delete
* Makes necessary changes (and reverting them back) in $_SERVER
[219] Fix | Delete
*
[220] Fix | Delete
* This has to be done because xcache_clear_cache() needs to pass Basic Http Auth
[221] Fix | Delete
* (see xcache.admin configuration config)
[222] Fix | Delete
*
[223] Fix | Delete
* @param bool $reverse Revert changes
[224] Fix | Delete
* @return void
[225] Fix | Delete
*/
[226] Fix | Delete
protected function _auth($reverse = false)
[227] Fix | Delete
{
[228] Fix | Delete
static $backup = [];
[229] Fix | Delete
$keys = ['PHP_AUTH_USER' => 'user', 'PHP_AUTH_PW' => 'password'];
[230] Fix | Delete
foreach ($keys as $key => $value) {
[231] Fix | Delete
if ($reverse) {
[232] Fix | Delete
if (isset($backup[$key])) {
[233] Fix | Delete
$_SERVER[$key] = $backup[$key];
[234] Fix | Delete
unset($backup[$key]);
[235] Fix | Delete
} else {
[236] Fix | Delete
unset($_SERVER[$key]);
[237] Fix | Delete
}
[238] Fix | Delete
} else {
[239] Fix | Delete
$value = env($key);
[240] Fix | Delete
if (!empty($value)) {
[241] Fix | Delete
$backup[$key] = $value;
[242] Fix | Delete
}
[243] Fix | Delete
if (!empty($this->_config[$value])) {
[244] Fix | Delete
$_SERVER[$key] = $this->_config[$value];
[245] Fix | Delete
} elseif (!empty($this->_config[$key])) {
[246] Fix | Delete
$_SERVER[$key] = $this->_config[$key];
[247] Fix | Delete
} else {
[248] Fix | Delete
$_SERVER[$key] = $value;
[249] Fix | Delete
}
[250] Fix | Delete
}
[251] Fix | Delete
}
[252] Fix | Delete
}
[253] Fix | Delete
}
[254] Fix | Delete
[255] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function