check if connection error
This commit is contained in:
parent
ee2e67f490
commit
4bbb98fb98
@ -12,7 +12,7 @@ class Http
|
||||
{
|
||||
public static function getData($url, $headers = [])
|
||||
{
|
||||
global $http_proxy,$http_proxyauth;
|
||||
global $http_proxy, $http_proxyauth, $admin;
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, 0);
|
||||
@ -31,12 +31,15 @@ class Http
|
||||
$error_msg = curl_error($ch);
|
||||
}
|
||||
curl_close($ch);
|
||||
if($admin && $error_msg){
|
||||
r2(U . 'dashboard', 'd', $error_msg);
|
||||
}
|
||||
return ($server_output) ? $server_output : $error_msg;
|
||||
}
|
||||
|
||||
public static function postJsonData($url, $array_post, $headers = [], $basic = null)
|
||||
{
|
||||
global $http_proxy,$http_proxyauth;
|
||||
global $http_proxy, $http_proxyauth, $admin;
|
||||
$headers[] = 'Content-Type: application/json';
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
@ -62,13 +65,16 @@ class Http
|
||||
$error_msg = curl_error($ch);
|
||||
}
|
||||
curl_close($ch);
|
||||
if($admin && $error_msg){
|
||||
r2(U . 'dashboard', 'd', $error_msg);
|
||||
}
|
||||
return ($server_output) ? $server_output : $error_msg;
|
||||
}
|
||||
|
||||
|
||||
public static function postData($url, $array_post, $headers = [], $basic = null)
|
||||
{
|
||||
global $http_proxy,$http_proxyauth;
|
||||
global $http_proxy, $http_proxyauth, $admin;
|
||||
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
@ -94,6 +100,9 @@ class Http
|
||||
$error_msg = curl_error($ch);
|
||||
}
|
||||
curl_close($ch);
|
||||
if($admin && $error_msg){
|
||||
r2(U . 'dashboard', 'd', $error_msg);
|
||||
}
|
||||
return ($server_output) ? $server_output : $error_msg;
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,12 @@ if ($admin['user_type'] != 'Admin') {
|
||||
|
||||
$cache = File::pathFixer('system/cache/plugin_repository.json');
|
||||
if (file_exists($cache) && time() - filemtime($cache) < (24 * 60 * 60)) {
|
||||
$json = json_decode(file_get_contents($cache), true);
|
||||
$txt = file_get_contents($cache);
|
||||
$json = json_decode($txt, true);
|
||||
if(empty($json['plugins']) && empty($json['payment_gateway'])){
|
||||
unlink($cache);
|
||||
r2(U . 'dashboard', 'd', $txt);
|
||||
}
|
||||
} else {
|
||||
$data = Http::getData($plugin_repository);
|
||||
file_put_contents($cache, $data);
|
||||
|
Loading…
x
Reference in New Issue
Block a user