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/flowflow/core/src/settings
File: LASettingsUtils.php
<?php namespace la\core\settings;
[0] Fix | Delete
if ( ! defined( 'WPINC' ) ) die;
[1] Fix | Delete
[2] Fix | Delete
/**
[3] Fix | Delete
* Flow-Flow.
[4] Fix | Delete
*
[5] Fix | Delete
* @package FlowFlow
[6] Fix | Delete
* @author Looks Awesome <email@looks-awesome.com>
[7] Fix | Delete
[8] Fix | Delete
* @link http://looks-awesome.com
[9] Fix | Delete
* @copyright Looks Awesome
[10] Fix | Delete
*/
[11] Fix | Delete
class LASettingsUtils {
[12] Fix | Delete
const YEP = 'yep';
[13] Fix | Delete
const NOPE = 'nope';
[14] Fix | Delete
[15] Fix | Delete
private static $length = [ 1, 60, 3600, 86400, 604800, 2630880, 31570560, 315705600 ];
[16] Fix | Delete
private static $USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36';
[17] Fix | Delete
[18] Fix | Delete
public static function YepNope2ClassicStyleSafe($array, $key, $not_parsed_result = false){
[19] Fix | Delete
if (is_object($array)) $array = (array) $array;
[20] Fix | Delete
return isset($array[$key]) ? self::YepNope2ClassicStyle($array[$key], $not_parsed_result) : $not_parsed_result;
[21] Fix | Delete
}
[22] Fix | Delete
[23] Fix | Delete
public static function YepNope2ClassicStyle($str, $not_parsed_result = false) {
[24] Fix | Delete
if (isset($str)){
[25] Fix | Delete
return ($str == self::YEP);
[26] Fix | Delete
}
[27] Fix | Delete
return $not_parsed_result;
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
public static function notYepNope2ClassicStyleSafe($array, $key, $not_parsed_result = true){
[31] Fix | Delete
if (is_object($array)) $array = (array) $array;
[32] Fix | Delete
return isset($array[$key]) ? self::notYepNope2ClassicStyle($array[$key], $not_parsed_result) : $not_parsed_result;
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
public static function notYepNope2ClassicStyle($str, $not_parsed_result = true) {
[36] Fix | Delete
if (isset($str)){
[37] Fix | Delete
return ($str == self::NOPE);
[38] Fix | Delete
}
[39] Fix | Delete
return $not_parsed_result;
[40] Fix | Delete
}
[41] Fix | Delete
[42] Fix | Delete
public static function classicStyleDate($date, $style = 'classicStyleDate'){
[43] Fix | Delete
if ($style == 'agoStyleDate'){
[44] Fix | Delete
return '';
[45] Fix | Delete
}
[46] Fix | Delete
if (FF_USE_WP && $style == 'wpStyleDate'){
[47] Fix | Delete
$wpDateFormat = get_option('date_format') . ' ' . get_option('time_format');
[48] Fix | Delete
return date_i18n($wpDateFormat, $date);
[49] Fix | Delete
}
[50] Fix | Delete
$cur_time = time();
[51] Fix | Delete
$diff = $cur_time - $date;
[52] Fix | Delete
/** @noinspection PhpStatementHasEmptyBodyInspection */
[53] Fix | Delete
for ($i = sizeof(self::$length) - 1; ( $i >= 0) && ( ($no = $diff / self::$length[$i]) <= 1); $i--) ;
[54] Fix | Delete
if ($i < 0) $i = 0;
[55] Fix | Delete
[56] Fix | Delete
if ($i > 5)
[57] Fix | Delete
return FF_USE_WP ? date_i18n("M j Y",$date) : strftime('%h %e %Y', $date);
[58] Fix | Delete
return FF_USE_WP ? date_i18n("M j H:i",$date) : strftime('%h %e %H:%M', $date);
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
public static function get($url, $timeout = 60, $header = false, $log = true, $followLocation = true, $useIpv4 = true){
[62] Fix | Delete
$c = curl_init();
[63] Fix | Delete
curl_setopt($c, CURLOPT_USERAGENT, self::$USER_AGENT);
[64] Fix | Delete
curl_setopt($c, CURLOPT_URL,$url);
[65] Fix | Delete
curl_setopt($c, CURLOPT_POST, 0);
[66] Fix | Delete
curl_setopt($c, CURLOPT_FAILONERROR, true);
[67] Fix | Delete
[68] Fix | Delete
// Enable if you have 'Network is unreachable' error
[69] Fix | Delete
if ($useIpv4) curl_setopt( $c, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
[70] Fix | Delete
if ($followLocation) curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
[71] Fix | Delete
curl_setopt($c, CURLOPT_AUTOREFERER, true);
[72] Fix | Delete
curl_setopt($c, CURLOPT_RETURNTRANSFER,true);
[73] Fix | Delete
curl_setopt($c, CURLOPT_VERBOSE, false);
[74] Fix | Delete
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
[75] Fix | Delete
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
[76] Fix | Delete
curl_setopt($c, CURLOPT_SSL_VERIFYHOST, false);
[77] Fix | Delete
if (isset($_COOKIE['XDEBUG_SESSION']) && $_COOKIE['XDEBUG_SESSION'] == 'PHPSTORM')
[78] Fix | Delete
curl_setopt($c, CURLOPT_COOKIE, 'XDEBUG_SESSION=PHPSTORM');
[79] Fix | Delete
if ($timeout != null) curl_setopt($c, CURLOPT_TIMEOUT, $timeout);
[80] Fix | Delete
curl_setopt($c, CURLOPT_CONNECTTIMEOUT_MS, 5000);
[81] Fix | Delete
if (is_array($header)) curl_setopt($c, CURLOPT_HTTPHEADER, $header);
[82] Fix | Delete
$page = ($followLocation) ? curl_exec($c) : self::curl_exec_follow($c);
[83] Fix | Delete
$error = curl_error($c);
[84] Fix | Delete
$errors = [];
[85] Fix | Delete
if (strlen($error) > 0){
[86] Fix | Delete
if ($log) {
[87] Fix | Delete
if (isset($_REQUEST['debug'])) {
[88] Fix | Delete
echo 'DEBUG:: <br>';
[89] Fix | Delete
var_dump($error);
[90] Fix | Delete
echo '<br>';
[91] Fix | Delete
var_dump(debug_backtrace());
[92] Fix | Delete
echo 'URL: ' . $url;
[93] Fix | Delete
echo '<br>-------<br>';
[94] Fix | Delete
error_log(print_r($error, true));
[95] Fix | Delete
error_log(print_r(debug_backtrace(), true));
[96] Fix | Delete
error_log($url);
[97] Fix | Delete
}
[98] Fix | Delete
}
[99] Fix | Delete
if (strpos($error, 'Failed to connect') !== false && strpos($error, 'Network is unreachable') !== false){
[100] Fix | Delete
curl_setopt($c, CURLOPT_FAILONERROR, false);
[101] Fix | Delete
$page = ($followLocation) ? curl_exec($c) : self::curl_exec_follow($c);
[102] Fix | Delete
$error2 = curl_error($c);
[103] Fix | Delete
if (strlen($error2) > 0){
[104] Fix | Delete
$error .= '. Please, enable "USE IPV4 PROTOCOL" option at the settings tab.';
[105] Fix | Delete
$errors[] = [ 'msg' => $error, 'url' => $url ];
[106] Fix | Delete
error_log('FFFeedUtils line 110 :: ' . $error);
[107] Fix | Delete
error_log('FFFeedUtils line 111 :: ' . $error2);
[108] Fix | Delete
}
[109] Fix | Delete
curl_close($c);
[110] Fix | Delete
return [ 'response' => $page, 'errors' => $errors ];
[111] Fix | Delete
}
[112] Fix | Delete
$errors[] = [ 'msg' => $error, 'url' => $url ];
[113] Fix | Delete
}
[114] Fix | Delete
curl_close($c);
[115] Fix | Delete
return [ 'response' => $page, 'errors' => $errors ];
[116] Fix | Delete
}
[117] Fix | Delete
[118] Fix | Delete
/**
[119] Fix | Delete
* @param int $templateWidth
[120] Fix | Delete
* @param int $originalWidth
[121] Fix | Delete
* @param int $originalHeight
[122] Fix | Delete
* @return int|string
[123] Fix | Delete
*/
[124] Fix | Delete
public static function getScaleHeight($templateWidth, $originalWidth, $originalHeight){
[125] Fix | Delete
if (isset($originalWidth) && isset($originalHeight) && !empty($originalWidth)){
[126] Fix | Delete
$k = $templateWidth / $originalWidth;
[127] Fix | Delete
return (int)round( $originalHeight * $k );
[128] Fix | Delete
}
[129] Fix | Delete
return '';
[130] Fix | Delete
}
[131] Fix | Delete
[132] Fix | Delete
private static function curl_exec_follow($ch, &$maxRedirect = null) {
[133] Fix | Delete
$mr = $maxRedirect === null ? 5 : intval($maxRedirect);
[134] Fix | Delete
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
[135] Fix | Delete
[136] Fix | Delete
if ($mr > 0) {
[137] Fix | Delete
$original_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
[138] Fix | Delete
$newUrl = $original_url;
[139] Fix | Delete
[140] Fix | Delete
$rch = curl_copy_handle($ch);
[141] Fix | Delete
[142] Fix | Delete
curl_setopt($rch, CURLOPT_HEADER, true);
[143] Fix | Delete
curl_setopt($rch, CURLOPT_NOBODY, true);
[144] Fix | Delete
curl_setopt($rch, CURLOPT_FORBID_REUSE, false);
[145] Fix | Delete
do {
[146] Fix | Delete
curl_setopt($rch, CURLOPT_URL, $newUrl);
[147] Fix | Delete
$header = curl_exec($rch);
[148] Fix | Delete
if (curl_errno($rch)) {
[149] Fix | Delete
$code = 0;
[150] Fix | Delete
} else {
[151] Fix | Delete
$code = curl_getinfo($rch, CURLINFO_HTTP_CODE);
[152] Fix | Delete
if ($code == 301 || $code == 302) {
[153] Fix | Delete
preg_match('/Location:(.*?)\n/i', $header, $matches);
[154] Fix | Delete
$newUrl = trim(array_pop($matches));
[155] Fix | Delete
[156] Fix | Delete
// if no scheme is present then the new url is a
[157] Fix | Delete
// relative path and thus needs some extra care
[158] Fix | Delete
if(!preg_match("/^https?:/i", $newUrl)){
[159] Fix | Delete
$newUrl = $original_url . $newUrl;
[160] Fix | Delete
}
[161] Fix | Delete
} else {
[162] Fix | Delete
$code = 0;
[163] Fix | Delete
}
[164] Fix | Delete
}
[165] Fix | Delete
} while ($code && --$mr);
[166] Fix | Delete
[167] Fix | Delete
curl_close($rch);
[168] Fix | Delete
[169] Fix | Delete
if (!$mr) {
[170] Fix | Delete
if ($maxRedirect === null)
[171] Fix | Delete
trigger_error('Too many redirects.', E_USER_WARNING);
[172] Fix | Delete
else
[173] Fix | Delete
$maxRedirect = 0;
[174] Fix | Delete
[175] Fix | Delete
return false;
[176] Fix | Delete
}
[177] Fix | Delete
curl_setopt($ch, CURLOPT_URL, $newUrl);
[178] Fix | Delete
}
[179] Fix | Delete
return curl_exec($ch);
[180] Fix | Delete
}
[181] Fix | Delete
}
[182] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function