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:
@@ -43,8 +43,11 @@ if ($page == 'overview') {
|
|||||||
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "checking auto-update");
|
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "checking auto-update");
|
||||||
|
|
||||||
// check for new version
|
// 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);
|
$latestversion = explode('|', $latestversion);
|
||||||
|
|
||||||
if (is_array($latestversion) && count($latestversion) >= 1) {
|
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");
|
$this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "[API] checking for updates");
|
||||||
|
|
||||||
// check for new version
|
// 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);
|
$latestversion = explode('|', $latestversion);
|
||||||
|
|
||||||
if (is_array($latestversion) && count($latestversion) >= 1) {
|
if (is_array($latestversion) && count($latestversion) >= 1) {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class HttpClient
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function urlGet($url, $follow_location = true)
|
public static function urlGet($url, $follow_location = true, $timeout = 10)
|
||||||
{
|
{
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
@@ -19,6 +19,7 @@ class HttpClient
|
|||||||
if ($follow_location) {
|
if ($follow_location) {
|
||||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||||
}
|
}
|
||||||
|
curl_setopt($ch, CURLOPT_TIMEOUT, (int)$timeout);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
$output = curl_exec($ch);
|
$output = curl_exec($ch);
|
||||||
if ($output === false) {
|
if ($output === false) {
|
||||||
|
|||||||
Reference in New Issue
Block a user