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/wp-conte.../plugins/flow-flo.../libs/cakephp/core
File: functions.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
use Cake\Core\Configure;
[14] Fix | Delete
[15] Fix | Delete
if (!defined('DS')) {
[16] Fix | Delete
/**
[17] Fix | Delete
* Define DS as short form of DIRECTORY_SEPARATOR.
[18] Fix | Delete
*/
[19] Fix | Delete
define('DS', DIRECTORY_SEPARATOR);
[20] Fix | Delete
}
[21] Fix | Delete
[22] Fix | Delete
if (!function_exists('h')) {
[23] Fix | Delete
/**
[24] Fix | Delete
* Convenience method for htmlspecialchars.
[25] Fix | Delete
*
[26] Fix | Delete
* @param mixed $text Text to wrap through htmlspecialchars. Also works with arrays, and objects.
[27] Fix | Delete
* Arrays will be mapped and have all their elements escaped. Objects will be string cast if they
[28] Fix | Delete
* implement a `__toString` method. Otherwise the class name will be used.
[29] Fix | Delete
* Other scalar types will be returned unchanged.
[30] Fix | Delete
* @param bool $double Encode existing html entities.
[31] Fix | Delete
* @param string|null $charset Character set to use when escaping. Defaults to config value in `mb_internal_encoding()`
[32] Fix | Delete
* or 'UTF-8'.
[33] Fix | Delete
* @return mixed Wrapped text.
[34] Fix | Delete
* @link https://book.cakephp.org/3/en/core-libraries/global-constants-and-functions.html#h
[35] Fix | Delete
*/
[36] Fix | Delete
function h($text, $double = true, $charset = null)
[37] Fix | Delete
{
[38] Fix | Delete
if (is_string($text)) {
[39] Fix | Delete
//optimize for strings
[40] Fix | Delete
} elseif (is_array($text)) {
[41] Fix | Delete
$texts = [];
[42] Fix | Delete
foreach ($text as $k => $t) {
[43] Fix | Delete
$texts[$k] = h($t, $double, $charset);
[44] Fix | Delete
}
[45] Fix | Delete
[46] Fix | Delete
return $texts;
[47] Fix | Delete
} elseif (is_object($text)) {
[48] Fix | Delete
if (method_exists($text, '__toString')) {
[49] Fix | Delete
$text = (string)$text;
[50] Fix | Delete
} else {
[51] Fix | Delete
$text = '(object)' . get_class($text);
[52] Fix | Delete
}
[53] Fix | Delete
} elseif ($text === null || is_scalar($text)) {
[54] Fix | Delete
return $text;
[55] Fix | Delete
}
[56] Fix | Delete
[57] Fix | Delete
static $defaultCharset = false;
[58] Fix | Delete
if ($defaultCharset === false) {
[59] Fix | Delete
$defaultCharset = mb_internal_encoding();
[60] Fix | Delete
if ($defaultCharset === null) {
[61] Fix | Delete
$defaultCharset = 'UTF-8';
[62] Fix | Delete
}
[63] Fix | Delete
}
[64] Fix | Delete
if (is_string($double)) {
[65] Fix | Delete
deprecationWarning(
[66] Fix | Delete
'Passing charset string for 2nd argument is deprecated. ' .
[67] Fix | Delete
'Use the 3rd argument instead.'
[68] Fix | Delete
);
[69] Fix | Delete
$charset = $double;
[70] Fix | Delete
$double = true;
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
return htmlspecialchars($text, ENT_QUOTES | ENT_SUBSTITUTE, $charset ?: $defaultCharset, $double);
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
if (!function_exists('pluginSplit')) {
[79] Fix | Delete
/**
[80] Fix | Delete
* Splits a dot syntax plugin name into its plugin and class name.
[81] Fix | Delete
* If $name does not have a dot, then index 0 will be null.
[82] Fix | Delete
*
[83] Fix | Delete
* Commonly used like
[84] Fix | Delete
* ```
[85] Fix | Delete
* list($plugin, $name) = pluginSplit($name);
[86] Fix | Delete
* ```
[87] Fix | Delete
*
[88] Fix | Delete
* @param string $name The name you want to plugin split.
[89] Fix | Delete
* @param bool $dotAppend Set to true if you want the plugin to have a '.' appended to it.
[90] Fix | Delete
* @param string|null $plugin Optional default plugin to use if no plugin is found. Defaults to null.
[91] Fix | Delete
* @return array Array with 2 indexes. 0 => plugin name, 1 => class name.
[92] Fix | Delete
* @link https://book.cakephp.org/3/en/core-libraries/global-constants-and-functions.html#pluginSplit
[93] Fix | Delete
*/
[94] Fix | Delete
function pluginSplit($name, $dotAppend = false, $plugin = null)
[95] Fix | Delete
{
[96] Fix | Delete
if (strpos($name, '.') !== false) {
[97] Fix | Delete
$parts = explode('.', $name, 2);
[98] Fix | Delete
if ($dotAppend) {
[99] Fix | Delete
$parts[0] .= '.';
[100] Fix | Delete
}
[101] Fix | Delete
[102] Fix | Delete
return $parts;
[103] Fix | Delete
}
[104] Fix | Delete
[105] Fix | Delete
return [$plugin, $name];
[106] Fix | Delete
}
[107] Fix | Delete
[108] Fix | Delete
}
[109] Fix | Delete
[110] Fix | Delete
if (!function_exists('namespaceSplit')) {
[111] Fix | Delete
/**
[112] Fix | Delete
* Split the namespace from the classname.
[113] Fix | Delete
*
[114] Fix | Delete
* Commonly used like `list($namespace, $className) = namespaceSplit($class);`.
[115] Fix | Delete
*
[116] Fix | Delete
* @param string $class The full class name, ie `Cake\Core\App`.
[117] Fix | Delete
* @return array Array with 2 indexes. 0 => namespace, 1 => classname.
[118] Fix | Delete
*/
[119] Fix | Delete
function namespaceSplit($class)
[120] Fix | Delete
{
[121] Fix | Delete
$pos = strrpos($class, '\\');
[122] Fix | Delete
if ($pos === false) {
[123] Fix | Delete
return ['', $class];
[124] Fix | Delete
}
[125] Fix | Delete
[126] Fix | Delete
return [substr($class, 0, $pos), substr($class, $pos + 1)];
[127] Fix | Delete
}
[128] Fix | Delete
[129] Fix | Delete
}
[130] Fix | Delete
[131] Fix | Delete
if (!function_exists('pr')) {
[132] Fix | Delete
/**
[133] Fix | Delete
* print_r() convenience function.
[134] Fix | Delete
*
[135] Fix | Delete
* In terminals this will act similar to using print_r() directly, when not run on cli
[136] Fix | Delete
* print_r() will also wrap `<pre>` tags around the output of given variable. Similar to debug().
[137] Fix | Delete
*
[138] Fix | Delete
* This function returns the same variable that was passed.
[139] Fix | Delete
*
[140] Fix | Delete
* @param mixed $var Variable to print out.
[141] Fix | Delete
* @return mixed the same $var that was passed to this function
[142] Fix | Delete
* @link https://book.cakephp.org/3/en/core-libraries/global-constants-and-functions.html#pr
[143] Fix | Delete
* @see debug()
[144] Fix | Delete
*/
[145] Fix | Delete
function pr($var)
[146] Fix | Delete
{
[147] Fix | Delete
if (!Configure::read('debug')) {
[148] Fix | Delete
return $var;
[149] Fix | Delete
}
[150] Fix | Delete
[151] Fix | Delete
$template = (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') ? '<pre class="pr">%s</pre>' : "\n%s\n\n";
[152] Fix | Delete
printf($template, trim(print_r($var, true)));
[153] Fix | Delete
[154] Fix | Delete
return $var;
[155] Fix | Delete
}
[156] Fix | Delete
[157] Fix | Delete
}
[158] Fix | Delete
[159] Fix | Delete
if (!function_exists('pj')) {
[160] Fix | Delete
/**
[161] Fix | Delete
* json pretty print convenience function.
[162] Fix | Delete
*
[163] Fix | Delete
* In terminals this will act similar to using json_encode() with JSON_PRETTY_PRINT directly, when not run on cli
[164] Fix | Delete
* will also wrap `<pre>` tags around the output of given variable. Similar to pr().
[165] Fix | Delete
*
[166] Fix | Delete
* This function returns the same variable that was passed.
[167] Fix | Delete
*
[168] Fix | Delete
* @param mixed $var Variable to print out.
[169] Fix | Delete
* @return mixed the same $var that was passed to this function
[170] Fix | Delete
* @see pr()
[171] Fix | Delete
* @link https://book.cakephp.org/3/en/core-libraries/global-constants-and-functions.html#pj
[172] Fix | Delete
*/
[173] Fix | Delete
function pj($var)
[174] Fix | Delete
{
[175] Fix | Delete
if (!Configure::read('debug')) {
[176] Fix | Delete
return $var;
[177] Fix | Delete
}
[178] Fix | Delete
[179] Fix | Delete
$template = (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') ? '<pre class="pj">%s</pre>' : "\n%s\n\n";
[180] Fix | Delete
printf($template, trim(json_encode($var, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)));
[181] Fix | Delete
[182] Fix | Delete
return $var;
[183] Fix | Delete
}
[184] Fix | Delete
[185] Fix | Delete
}
[186] Fix | Delete
[187] Fix | Delete
if (!function_exists('env')) {
[188] Fix | Delete
/**
[189] Fix | Delete
* Gets an environment variable from available sources, and provides emulation
[190] Fix | Delete
* for unsupported or inconsistent environment variables (i.e. DOCUMENT_ROOT on
[191] Fix | Delete
* IIS, or SCRIPT_NAME in CGI mode). Also exposes some additional custom
[192] Fix | Delete
* environment information.
[193] Fix | Delete
*
[194] Fix | Delete
* @param string $key Environment variable name.
[195] Fix | Delete
* @param string|bool|null $default Specify a default value in case the environment variable is not defined.
[196] Fix | Delete
* @return string|bool|null Environment variable setting.
[197] Fix | Delete
* @link https://book.cakephp.org/3/en/core-libraries/global-constants-and-functions.html#env
[198] Fix | Delete
*/
[199] Fix | Delete
function env($key, $default = null)
[200] Fix | Delete
{
[201] Fix | Delete
if ($key === 'HTTPS') {
[202] Fix | Delete
if (isset($_SERVER['HTTPS'])) {
[203] Fix | Delete
return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off');
[204] Fix | Delete
}
[205] Fix | Delete
[206] Fix | Delete
return (strpos((string)env('SCRIPT_URI'), 'https://') === 0);
[207] Fix | Delete
}
[208] Fix | Delete
[209] Fix | Delete
if ($key === 'SCRIPT_NAME' && env('CGI_MODE') && isset($_ENV['SCRIPT_URL'])) {
[210] Fix | Delete
$key = 'SCRIPT_URL';
[211] Fix | Delete
}
[212] Fix | Delete
[213] Fix | Delete
$val = null;
[214] Fix | Delete
if (isset($_SERVER[$key])) {
[215] Fix | Delete
$val = $_SERVER[$key];
[216] Fix | Delete
} elseif (isset($_ENV[$key])) {
[217] Fix | Delete
$val = $_ENV[$key];
[218] Fix | Delete
} elseif (getenv($key) !== false) {
[219] Fix | Delete
$val = getenv($key);
[220] Fix | Delete
}
[221] Fix | Delete
[222] Fix | Delete
if ($key === 'REMOTE_ADDR' && $val === env('SERVER_ADDR')) {
[223] Fix | Delete
$addr = env('HTTP_PC_REMOTE_ADDR');
[224] Fix | Delete
if ($addr !== null) {
[225] Fix | Delete
$val = $addr;
[226] Fix | Delete
}
[227] Fix | Delete
}
[228] Fix | Delete
[229] Fix | Delete
if ($val !== null) {
[230] Fix | Delete
return $val;
[231] Fix | Delete
}
[232] Fix | Delete
[233] Fix | Delete
switch ($key) {
[234] Fix | Delete
case 'DOCUMENT_ROOT':
[235] Fix | Delete
$name = env('SCRIPT_NAME');
[236] Fix | Delete
$filename = env('SCRIPT_FILENAME');
[237] Fix | Delete
$offset = 0;
[238] Fix | Delete
if (!strpos($name, '.php')) {
[239] Fix | Delete
$offset = 4;
[240] Fix | Delete
}
[241] Fix | Delete
[242] Fix | Delete
return substr($filename, 0, -(strlen($name) + $offset));
[243] Fix | Delete
case 'PHP_SELF':
[244] Fix | Delete
return str_replace(env('DOCUMENT_ROOT'), '', env('SCRIPT_FILENAME'));
[245] Fix | Delete
case 'CGI_MODE':
[246] Fix | Delete
return (PHP_SAPI === 'cgi');
[247] Fix | Delete
}
[248] Fix | Delete
[249] Fix | Delete
return $default;
[250] Fix | Delete
}
[251] Fix | Delete
[252] Fix | Delete
}
[253] Fix | Delete
[254] Fix | Delete
if (!function_exists('triggerWarning')) {
[255] Fix | Delete
/**
[256] Fix | Delete
* Triggers an E_USER_WARNING.
[257] Fix | Delete
*
[258] Fix | Delete
* @param string $message The warning message.
[259] Fix | Delete
* @return void
[260] Fix | Delete
*/
[261] Fix | Delete
function triggerWarning($message)
[262] Fix | Delete
{
[263] Fix | Delete
$stackFrame = 1;
[264] Fix | Delete
$trace = debug_backtrace();
[265] Fix | Delete
if (isset($trace[$stackFrame])) {
[266] Fix | Delete
$frame = $trace[$stackFrame];
[267] Fix | Delete
$frame += ['file' => '[internal]', 'line' => '??'];
[268] Fix | Delete
$message = sprintf(
[269] Fix | Delete
'%s - %s, line: %s',
[270] Fix | Delete
$message,
[271] Fix | Delete
$frame['file'],
[272] Fix | Delete
$frame['line']
[273] Fix | Delete
);
[274] Fix | Delete
}
[275] Fix | Delete
trigger_error($message, E_USER_WARNING);
[276] Fix | Delete
}
[277] Fix | Delete
}
[278] Fix | Delete
[279] Fix | Delete
if (!function_exists('deprecationWarning')) {
[280] Fix | Delete
/**
[281] Fix | Delete
* Helper method for outputting deprecation warnings
[282] Fix | Delete
*
[283] Fix | Delete
* @param string $message The message to output as a deprecation warning.
[284] Fix | Delete
* @param int $stackFrame The stack frame to include in the error. Defaults to 1
[285] Fix | Delete
* as that should point to application/plugin code.
[286] Fix | Delete
* @return void
[287] Fix | Delete
*/
[288] Fix | Delete
function deprecationWarning($message, $stackFrame = 1)
[289] Fix | Delete
{
[290] Fix | Delete
if (!(error_reporting() & E_USER_DEPRECATED)) {
[291] Fix | Delete
return;
[292] Fix | Delete
}
[293] Fix | Delete
[294] Fix | Delete
$trace = debug_backtrace();
[295] Fix | Delete
if (isset($trace[$stackFrame])) {
[296] Fix | Delete
$frame = $trace[$stackFrame];
[297] Fix | Delete
$frame += ['file' => '[internal]', 'line' => '??'];
[298] Fix | Delete
[299] Fix | Delete
$message = sprintf(
[300] Fix | Delete
'%s - %s, line: %s' . "\n" .
[301] Fix | Delete
' You can disable deprecation warnings by setting `Error.errorLevel` to' .
[302] Fix | Delete
' `E_ALL & ~E_USER_DEPRECATED` in your config/app.php.',
[303] Fix | Delete
$message,
[304] Fix | Delete
$frame['file'],
[305] Fix | Delete
$frame['line']
[306] Fix | Delete
);
[307] Fix | Delete
}
[308] Fix | Delete
[309] Fix | Delete
trigger_error($message, E_USER_DEPRECATED);
[310] Fix | Delete
}
[311] Fix | Delete
}
[312] Fix | Delete
[313] Fix | Delete
if (!function_exists('getTypeName')) {
[314] Fix | Delete
/**
[315] Fix | Delete
* Returns the objects class or var type of it's not an object
[316] Fix | Delete
*
[317] Fix | Delete
* @param mixed $var Variable to check
[318] Fix | Delete
* @return string Returns the class name or variable type
[319] Fix | Delete
*/
[320] Fix | Delete
function getTypeName($var)
[321] Fix | Delete
{
[322] Fix | Delete
return is_object($var) ? get_class($var) : gettype($var);
[323] Fix | Delete
}
[324] Fix | Delete
}
[325] Fix | Delete
[326] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function