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/core/Configur.../Engine
File: JsonConfig.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 3.0.0
[11] Fix | Delete
* @license https://opensource.org/licenses/mit-license.php MIT License
[12] Fix | Delete
*/
[13] Fix | Delete
namespace Cake\Core\Configure\Engine;
[14] Fix | Delete
[15] Fix | Delete
use Cake\Core\Configure\ConfigEngineInterface;
[16] Fix | Delete
use Cake\Core\Configure\FileConfigTrait;
[17] Fix | Delete
use Cake\Core\Exception\Exception;
[18] Fix | Delete
[19] Fix | Delete
/**
[20] Fix | Delete
* JSON engine allows Configure to load configuration values from
[21] Fix | Delete
* files containing JSON strings.
[22] Fix | Delete
*
[23] Fix | Delete
* An example JSON file would look like::
[24] Fix | Delete
*
[25] Fix | Delete
* ```
[26] Fix | Delete
* {
[27] Fix | Delete
* "debug": false,
[28] Fix | Delete
* "App": {
[29] Fix | Delete
* "namespace": "MyApp"
[30] Fix | Delete
* },
[31] Fix | Delete
* "Security": {
[32] Fix | Delete
* "salt": "its-secret"
[33] Fix | Delete
* }
[34] Fix | Delete
* }
[35] Fix | Delete
* ```
[36] Fix | Delete
*/
[37] Fix | Delete
class JsonConfig implements ConfigEngineInterface
[38] Fix | Delete
{
[39] Fix | Delete
use FileConfigTrait;
[40] Fix | Delete
[41] Fix | Delete
/**
[42] Fix | Delete
* File extension.
[43] Fix | Delete
*
[44] Fix | Delete
* @var string
[45] Fix | Delete
*/
[46] Fix | Delete
protected $_extension = '.json';
[47] Fix | Delete
[48] Fix | Delete
/**
[49] Fix | Delete
* Constructor for JSON Config file reading.
[50] Fix | Delete
*
[51] Fix | Delete
* @param string|null $path The path to read config files from. Defaults to CONFIG.
[52] Fix | Delete
*/
[53] Fix | Delete
public function __construct($path = null)
[54] Fix | Delete
{
[55] Fix | Delete
if ($path === null) {
[56] Fix | Delete
$path = CONFIG;
[57] Fix | Delete
}
[58] Fix | Delete
$this->_path = $path;
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
/**
[62] Fix | Delete
* Read a config file and return its contents.
[63] Fix | Delete
*
[64] Fix | Delete
* Files with `.` in the name will be treated as values in plugins. Instead of
[65] Fix | Delete
* reading from the initialized path, plugin keys will be located using Plugin::path().
[66] Fix | Delete
*
[67] Fix | Delete
* @param string $key The identifier to read from. If the key has a . it will be treated
[68] Fix | Delete
* as a plugin prefix.
[69] Fix | Delete
* @return array Parsed configuration values.
[70] Fix | Delete
* @throws \Cake\Core\Exception\Exception When files don't exist or when
[71] Fix | Delete
* files contain '..' (as this could lead to abusive reads) or when there
[72] Fix | Delete
* is an error parsing the JSON string.
[73] Fix | Delete
*/
[74] Fix | Delete
public function read($key)
[75] Fix | Delete
{
[76] Fix | Delete
$file = $this->_getFilePath($key, true);
[77] Fix | Delete
[78] Fix | Delete
$values = json_decode(file_get_contents($file), true);
[79] Fix | Delete
if (json_last_error() !== JSON_ERROR_NONE) {
[80] Fix | Delete
throw new Exception(sprintf(
[81] Fix | Delete
'Error parsing JSON string fetched from config file "%s.json": %s',
[82] Fix | Delete
$key,
[83] Fix | Delete
json_last_error_msg()
[84] Fix | Delete
));
[85] Fix | Delete
}
[86] Fix | Delete
if (!is_array($values)) {
[87] Fix | Delete
throw new Exception(sprintf(
[88] Fix | Delete
'Decoding JSON config file "%s.json" did not return an array',
[89] Fix | Delete
$key
[90] Fix | Delete
));
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
return $values;
[94] Fix | Delete
}
[95] Fix | Delete
[96] Fix | Delete
/**
[97] Fix | Delete
* Converts the provided $data into a JSON string that can be used saved
[98] Fix | Delete
* into a file and loaded later.
[99] Fix | Delete
*
[100] Fix | Delete
* @param string $key The identifier to write to. If the key has a . it will
[101] Fix | Delete
* be treated as a plugin prefix.
[102] Fix | Delete
* @param array $data Data to dump.
[103] Fix | Delete
* @return bool Success
[104] Fix | Delete
*/
[105] Fix | Delete
public function dump($key, array $data)
[106] Fix | Delete
{
[107] Fix | Delete
$filename = $this->_getFilePath($key);
[108] Fix | Delete
[109] Fix | Delete
return file_put_contents($filename, json_encode($data, JSON_PRETTY_PRINT)) > 0;
[110] Fix | Delete
}
[111] Fix | Delete
}
[112] Fix | Delete
[113] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function