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/smart-sl.../Nextend/Framewor...
File: Api.php
<?php
[0] Fix | Delete
[1] Fix | Delete
[2] Fix | Delete
namespace Nextend\Framework;
[3] Fix | Delete
[4] Fix | Delete
[5] Fix | Delete
use Exception;
[6] Fix | Delete
use Joomla\CMS\Http\Http;
[7] Fix | Delete
use Nextend\Framework\Misc\Base64;
[8] Fix | Delete
use Nextend\Framework\Misc\HttpClient;
[9] Fix | Delete
use Nextend\Framework\Notification\Notification;
[10] Fix | Delete
use Nextend\Framework\Platform\Platform;
[11] Fix | Delete
use Nextend\Framework\Request\Request;
[12] Fix | Delete
use Nextend\Framework\Url\Url;
[13] Fix | Delete
[14] Fix | Delete
class Api {
[15] Fix | Delete
[16] Fix | Delete
private static $api = 'https://api.nextendweb.com/v1/';
[17] Fix | Delete
[18] Fix | Delete
public static function getApiUrl() {
[19] Fix | Delete
[20] Fix | Delete
return self::$api;
[21] Fix | Delete
}
[22] Fix | Delete
[23] Fix | Delete
public static function api($posts, $returnUrl = false) {
[24] Fix | Delete
[25] Fix | Delete
$api = self::getApiUrl();
[26] Fix | Delete
[27] Fix | Delete
$posts_default = array(
[28] Fix | Delete
'platform' => Platform::getName()
[29] Fix | Delete
);
[30] Fix | Delete
[31] Fix | Delete
$posts = $posts + $posts_default;
[32] Fix | Delete
[33] Fix | Delete
if ($returnUrl) {
[34] Fix | Delete
return $api . '?' . http_build_query($posts, '', '&');
[35] Fix | Delete
}
[36] Fix | Delete
$request = wp_remote_post($api, array(
[37] Fix | Delete
'timeout' => 20,
[38] Fix | Delete
'body' => $posts
[39] Fix | Delete
));
[40] Fix | Delete
if (is_wp_error($request)) {
[41] Fix | Delete
foreach ($request->get_error_messages() as $errorMessage) {
[42] Fix | Delete
Notification::error($errorMessage);
[43] Fix | Delete
}
[44] Fix | Delete
[45] Fix | Delete
return null;
[46] Fix | Delete
} else {
[47] Fix | Delete
$data = wp_remote_retrieve_body($request);
[48] Fix | Delete
$headers = wp_remote_retrieve_headers($request);
[49] Fix | Delete
$contentType = $headers['content-type'];
[50] Fix | Delete
}
[51] Fix | Delete
[52] Fix | Delete
[53] Fix | Delete
switch ($contentType) {
[54] Fix | Delete
case 'text/html; charset=UTF-8':
[55] Fix | Delete
[56] Fix | Delete
Notification::error(sprintf('Unexpected response from the API.<br>Contact us (support@nextendweb.com) with the following log:') . '<br><textarea style="width: 100%;height:200px;font-size:8px;">' . Base64::encode($data) . '</textarea>');
[57] Fix | Delete
[58] Fix | Delete
return array(
[59] Fix | Delete
'status' => 'ERROR_HANDLED'
[60] Fix | Delete
);
[61] Fix | Delete
break;
[62] Fix | Delete
case 'application/json':
[63] Fix | Delete
return json_decode($data, true);
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
return $data;
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
private static function parseHeaders(array $headers, $header = null) {
[70] Fix | Delete
$output = array();
[71] Fix | Delete
if ('HTTP' === substr($headers[0], 0, 4)) {
[72] Fix | Delete
list(, $output['status'], $output['status_text']) = explode(' ', $headers[0]);
[73] Fix | Delete
unset($headers[0]);
[74] Fix | Delete
}
[75] Fix | Delete
foreach ($headers as $v) {
[76] Fix | Delete
$h = preg_split('/:\s*/', $v);
[77] Fix | Delete
if (count($h) >= 2) {
[78] Fix | Delete
$output[strtolower($h[0])] = $h[1];
[79] Fix | Delete
}
[80] Fix | Delete
}
[81] Fix | Delete
if (null !== $header) {
[82] Fix | Delete
if (isset($output[strtolower($header)])) {
[83] Fix | Delete
return $output[strtolower($header)];
[84] Fix | Delete
}
[85] Fix | Delete
[86] Fix | Delete
return null;
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
return $output;
[90] Fix | Delete
}
[91] Fix | Delete
}
[92] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function