mirror of
https://github.com/Froxlor/Froxlor.git
synced 2024-09-21 10:27:29 +00:00
set low timeout for version-check and output message if check is not possible (due to connection error, downtime of server, etc.)
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
parent
fa3e3da7ac
commit
55d21e475d
@ -43,8 +43,11 @@ if ($page == 'overview') {
|
||||
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "checking auto-update");
|
||||
|
||||
// check for new version
|
||||
$latestversion = HttpClient::urlGet(UPDATE_URI);
|
||||
|
||||
try {
|
||||
$latestversion = HttpClient::urlGet(UPDATE_URI, true, 3);
|
||||
} catch (\Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error("Version-check currently unavailable, please try again later");
|
||||
}
|
||||
$latestversion = explode('|', $latestversion);
|
||||
|
||||
if (is_array($latestversion) && count($latestversion) >= 1) {
|
||||
|
@ -39,7 +39,11 @@ class Froxlor extends \Froxlor\Api\ApiCommand
|
||||
$this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "[API] checking for updates");
|
||||
|
||||
// check for new version
|
||||
$latestversion = \Froxlor\Http\HttpClient::urlGet(UPDATE_URI);
|
||||
try {
|
||||
$latestversion = \Froxlor\Http\HttpClient::urlGet(UPDATE_URI, true, 3);
|
||||
} catch (\Exception $e) {
|
||||
$latestversion = \Froxlor\Froxlor::getVersion()."|Version-check currently unavailable, please try again later";
|
||||
}
|
||||
$latestversion = explode('|', $latestversion);
|
||||
|
||||
if (is_array($latestversion) && count($latestversion) >= 1) {
|
||||
|
@ -11,7 +11,7 @@ class HttpClient
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function urlGet($url, $follow_location = true)
|
||||
public static function urlGet($url, $follow_location = true, $timeout = 10)
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
@ -19,6 +19,7 @@ class HttpClient
|
||||
if ($follow_location) {
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, (int)$timeout);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
$output = curl_exec($ch);
|
||||
if ($output === false) {
|
||||
|
Loading…
Reference in New Issue
Block a user