diff --git a/ajax/system/sys_chk_update.php b/ajax/system/sys_chk_update.php
new file mode 100644
index 00000000..2a177148
--- /dev/null
+++ b/ajax/system/sys_chk_update.php
@@ -0,0 +1,26 @@
+ i.fas {
border-bottom-right-radius: 0.35rem;
}
+.cmd-copy {
+ width: 95%;
+ height: 6rem;
+}
diff --git a/app/js/custom.js b/app/js/custom.js
index 6c929c26..d6d4103d 100644
--- a/app/js/custom.js
+++ b/app/js/custom.js
@@ -276,6 +276,63 @@ $('#debugModal').on('shown.bs.modal', function (e) {
});
});
+$('#chkupdateModal').on('shown.bs.modal', function (e) {
+ var csrfToken = $('meta[name=csrf_token]').attr('content');
+ $.post('ajax/system/sys_chk_update.php',{'csrf_token': csrfToken},function(data){
+ var response = JSON.parse(data);
+ var tag = response.tag;
+ var update = response.update;
+ var msg;
+ var msgUpdate = $('#msgUpdate').data('message');
+ var msgLatest = $('#msgLatest').data('message');
+ var msgInstall = $('#msgInstall').data('message');
+ var msgDismiss = $('#js-check-dismiss').data('message');
+ var faCheck = '
';
+ $(".fas.fa-sync-alt").removeClass("fa-spin");
+ if (update === true) {
+ msg = msgUpdate +' '+tag;
+ $("#msg-check-update").html(msg);
+ $("#msg-check-update").append(faCheck);
+ $("#msg-check-update").append("
"+msgInstall+"
"); + $("#js-sys-check-update").removeClass("collapse"); + } else { + msg = msgLatest; + dismiss = $("#js-check-dismiss"); + $("#msg-check-update").html(msg); + $("#msg-check-update").append(faCheck); + $("#js-sys-check-update").remove(); + dismiss.text(msgDismiss); + dismiss.removeClass("btn-outline-secondary"); + dismiss.addClass("btn-primary"); + } + }); +}); + +$('#js-sys-check-update').click(function() { + $('#chkupdateModal').modal('hide'); + $('#cmdupdateModal').modal('show'); +}); + +$('#cmdupdateModal').on('shown.bs.modal', function (e) { + var csrfToken = $('meta[name=csrf_token]').attr('content'); + $.post('ajax/system/sys_perform_update.php',{ + 'csrf_token': csrfToken + },function(data){ + var response = JSON.parse(data); + $('#shellCmd').val(response); + }); +}); + +$('#js-cmd-copy').click(function() { + $('#shellCmd').select(); + document.execCommand('copy'); + var btnCancel = $('#cmdupdateCancel'); + var btnText = btnCancel.data('message'); + btnCancel.text(btnText); + btnCancel.removeClass("btn-outline-secondary"); + btnCancel.addClass("btn-primary"); +}); + $('#hostapdModal').on('shown.bs.modal', function (e) { var seconds = 3; var pct = 0; diff --git a/config/config.php b/config/config.php index 20debf6a..1aff2412 100755 --- a/config/config.php +++ b/config/config.php @@ -31,6 +31,9 @@ define('RASPI_LIGHTTPD_CONFIG', '/etc/lighttpd/lighttpd.conf'); define('RASPI_ACCESS_CHECK_IP', '1.1.1.1'); define('RASPI_ACCESS_CHECK_DNS', 'one.one.one.one'); +// Constant for the GitHub API latest release endpoint +define('RASPI_API_ENDPOINT', 'https://api.github.com/repos/RaspAP/raspap-webgui/releases/latest'); + // Constant for the 5GHz wireless regulatory domain define("RASPI_5GHZ_CHANNEL_MIN", 100); define("RASPI_5GHZ_CHANNEL_MAX", 192); diff --git a/includes/defaults.php b/includes/defaults.php index 0b46f90f..ce0936b5 100755 --- a/includes/defaults.php +++ b/includes/defaults.php @@ -6,7 +6,7 @@ if (!defined('RASPI_CONFIG')) { $defaults = [ 'RASPI_BRAND_TEXT' => 'RaspAP', - 'RASPI_VERSION' => '3.0.1', + 'RASPI_VERSION' => '2.9.9', 'RASPI_CONFIG_NETWORK' => RASPI_CONFIG.'/networking/defaults.json', 'RASPI_CONFIG_PROVIDERS' => 'config/vpn-providers.json', 'RASPI_ADMIN_DETAILS' => RASPI_CONFIG.'/raspap.auth', diff --git a/includes/functions.php b/includes/functions.php index 78d12bae..f909311d 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -899,3 +899,28 @@ function getCountryCodes($locale = 'en', $flag = true) { return $countryData; } +/** + * Compares the current release with the latest available release + * + * @param string $installed + * @param string $latest + * @return boolean + */ +function checkReleaseVersion($installed, $latest) { + $installedArray = explode('.', $installed); + $latestArray = explode('.', $latest); + + // compare segments of the version number + for ($i = 0; $i < max(count($installedArray), count($latestArray)); $i++) { + $installedSegment = (int)($installedArray[$i] ?? 0); + $latestSegment = (int)($latestArray[$i] ?? 0); + + if ($installedSegment < $latestSegment) { + return true; + } elseif ($installedSegment > $latestSegment) { + return false; + } + } + return false; +} + diff --git a/locale/en_US/LC_MESSAGES/messages.po b/locale/en_US/LC_MESSAGES/messages.po index 1eb061bf..8ed58b76 100644 --- a/locale/en_US/LC_MESSAGES/messages.po +++ b/locale/en_US/LC_MESSAGES/messages.po @@ -1457,3 +1457,36 @@ msgstr "Insiders" msgid "Contributing" msgstr "Contributing" +msgid "Check for update" +msgstr "Check for update" + +msgid "New release check in progress..." +msgstr "New release check in progress..." + +msgid "A new release is available: Version" +msgstr "A new release is available: Version" + +msgid "GitHub authentication" +msgstr "GitHub authentication" + +msgid "Updating Insiders requires GitHub authentication." +msgstr "Updating Insiders requires GitHub authentication." + +msgid "Your credentials will be sent to GitHub securely with SSL. However, use caution if your RaspAP install is on a WLAN shared by untrusted users." +msgstr "Your credentials will be sent to GitHub securely with SSL. However, use caution if your RaspAP install is on a WLAN shared by untrusted users." + +msgid "Personal Access Token" +msgstr "Personal Access Token" + +msgid "Please provide a valid token." +msgstr "Please provide a valid token." + +msgid "Get update command" +msgstr "Get update command" + +msgid "Copy the following and execute it in the terminal:" +msgstr "Copy the following and execute it in the terminal:" + +msgid "Copy" +msgstr "Copy" + diff --git a/templates/about.php b/templates/about.php index 6a5e6ed7..4aa95e4b 100755 --- a/templates/about.php +++ b/templates/about.php @@ -36,3 +36,43 @@ require_once 'app/lib/Parsedown.php'; + + + + + + diff --git a/templates/about/general.php b/templates/about/general.php index 2a6da8f3..9e9781e5 100644 --- a/templates/about/general.php +++ b/templates/about/general.php @@ -1,9 +1,19 @@