update UI version check via AutoUpdate class in Froxlor.checkUpdate()
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -31,12 +31,11 @@ use Froxlor\Cron\TaskId;
|
|||||||
use Froxlor\Database\Database;
|
use Froxlor\Database\Database;
|
||||||
use Froxlor\Database\IntegrityCheck;
|
use Froxlor\Database\IntegrityCheck;
|
||||||
use Froxlor\FroxlorLogger;
|
use Froxlor\FroxlorLogger;
|
||||||
use Froxlor\Http\HttpClient;
|
use Froxlor\Install\AutoUpdate;
|
||||||
use Froxlor\Settings;
|
use Froxlor\Settings;
|
||||||
use Froxlor\SImExporter;
|
use Froxlor\SImExporter;
|
||||||
use Froxlor\System\Cronjob;
|
use Froxlor\System\Cronjob;
|
||||||
use Froxlor\System\Crypt;
|
use Froxlor\System\Crypt;
|
||||||
use Froxlor\UI\Response;
|
|
||||||
use PDO;
|
use PDO;
|
||||||
use RecursiveDirectoryIterator;
|
use RecursiveDirectoryIterator;
|
||||||
use RecursiveIteratorIterator;
|
use RecursiveIteratorIterator;
|
||||||
@@ -62,74 +61,51 @@ class Froxlor extends ApiCommand
|
|||||||
define('UPDATE_URI', "https://version.froxlor.org/Froxlor/api/" . $this->version);
|
define('UPDATE_URI', "https://version.froxlor.org/Froxlor/api/" . $this->version);
|
||||||
|
|
||||||
if ($this->isAdmin() && $this->getUserDetail('change_serversettings')) {
|
if ($this->isAdmin() && $this->getUserDetail('change_serversettings')) {
|
||||||
if (function_exists('curl_version')) {
|
|
||||||
// log our actions
|
|
||||||
$this->logger()->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "[API] checking for updates");
|
|
||||||
|
|
||||||
// check for new version
|
// log our actions
|
||||||
try {
|
$this->logger()->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "[API] checking for updates");
|
||||||
$latestversion = 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) {
|
// check for new version
|
||||||
$_version = $latestversion[0];
|
$aucheck = AutoUpdate::checkVersion();
|
||||||
$_message = isset($latestversion[1]) ? $latestversion[1] : '';
|
|
||||||
$_link = isset($latestversion[2]) ? $latestversion[2] : '';
|
|
||||||
|
|
||||||
// add the branding so debian guys are not gettings confused
|
if ($aucheck == 1) {
|
||||||
// about their version-number
|
// anzeige über version-status mit ggfls. formular
|
||||||
$version_label = $_version . $this->branding;
|
// zum update schritt #1 -> download
|
||||||
$version_link = $_link;
|
$text = 'There is a newer version available: "' . AutoUpdate::getFromResult('version') . '" (Your current version is: ' . $this->version . ')';
|
||||||
$message_addinfo = $_message;
|
return $this->response([
|
||||||
|
'isnewerversion' => (int) !AutoUpdate::getFromResult('has_latest'),
|
||||||
// not numeric -> error-message
|
'version' => AutoUpdate::getFromResult('version'),
|
||||||
if (!preg_match('/^((\d+\\.)(\d+\\.)(\d+\\.)?(\d+)?(\-(svn|dev|rc)(\d+))?)$/', $_version)) {
|
'message' => $text,
|
||||||
// check for customized version to not output
|
'link' => AutoUpdate::getFromResult('url'),
|
||||||
// "There is a newer version of froxlor" besides the error-message
|
'additional_info' => AutoUpdate::getFromResult('info')
|
||||||
$isnewerversion = -1;
|
]);
|
||||||
} elseif (\Froxlor\Froxlor::versionCompare2($this->version, $_version) == -1) {
|
} else if ($aucheck < 0 || $aucheck > 1) {
|
||||||
// there is a newer version - yay
|
// errors
|
||||||
$isnewerversion = 1;
|
if ($aucheck < 0) {
|
||||||
|
$errmsg = AutoUpdate::getLastError();
|
||||||
|
} else {
|
||||||
|
if ($aucheck == 3) {
|
||||||
|
$errmsg = lng('error.customized_version');
|
||||||
} else {
|
} else {
|
||||||
// nothing new
|
$errmsg = lng('error.autoupdate_' . $aucheck);
|
||||||
$isnewerversion = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// anzeige über version-status mit ggfls. formular
|
|
||||||
// zum update schritt #1 -> download
|
|
||||||
if ($isnewerversion == 1) {
|
|
||||||
$text = 'There is a newer version available: "' . $_version . '" (Your current version is: ' . $this->version . ')';
|
|
||||||
return $this->response([
|
|
||||||
'isnewerversion' => $isnewerversion,
|
|
||||||
'version' => $_version,
|
|
||||||
'message' => $text,
|
|
||||||
'link' => $version_link,
|
|
||||||
'additional_info' => $message_addinfo
|
|
||||||
]);
|
|
||||||
} elseif ($isnewerversion == 0) {
|
|
||||||
// all good
|
|
||||||
return $this->response([
|
|
||||||
'isnewerversion' => $isnewerversion,
|
|
||||||
'version' => $version_label,
|
|
||||||
'message' => "",
|
|
||||||
'link' => $version_link,
|
|
||||||
'additional_info' => $message_addinfo
|
|
||||||
]);
|
|
||||||
} else {
|
|
||||||
Response::standardError('customized_version', '', true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return $this->response([
|
||||||
|
'isnewerversion' => 0,
|
||||||
|
'version' => $this->version,
|
||||||
|
'message' => $errmsg,
|
||||||
|
'link' => '',
|
||||||
|
'additional_info' => ''
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
return $this->response([
|
||||||
|
'isnewerversion' => 0,
|
||||||
|
'version' => $this->version,
|
||||||
|
'message' => lng('update.noupdatesavail'),
|
||||||
|
'link' => '',
|
||||||
|
'additional_info' => ''
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
return $this->response([
|
|
||||||
'isnewerversion' => 0,
|
|
||||||
'version' => $this->version . $this->branding,
|
|
||||||
'message' => 'Version-check not available due to missing php-curl extension',
|
|
||||||
'link' => UPDATE_URI . '/pretty',
|
|
||||||
'additional_info' => ""
|
|
||||||
], 502);
|
|
||||||
}
|
}
|
||||||
throw new Exception("Not allowed to execute given command.", 403);
|
throw new Exception("Not allowed to execute given command.", 403);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ use Froxlor\Http\HttpClient;
|
|||||||
class AutoUpdate
|
class AutoUpdate
|
||||||
{
|
{
|
||||||
// define update-uri
|
// define update-uri
|
||||||
const UPDATE_URI = "https://version.froxlor.org/froxlor/api2/";
|
const UPDATE_URI = "https://version.froxlor.org/froxlor/api/v2/";
|
||||||
const RELEASE_URI = "https://autoupdate.froxlor.org/froxlor-{version}.zip";
|
const RELEASE_URI = "https://autoupdate.froxlor.org/froxlor-{version}.zip";
|
||||||
const CHECKSUM_URI = "https://autoupdate.froxlor.org/froxlor-{version}.zip.sha256";
|
const CHECKSUM_URI = "https://autoupdate.froxlor.org/froxlor-{version}.zip.sha256";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user