Skip to content
Permalink
Browse files

fixes #1040 move check upgrade action to maintenance page

  • Loading branch information...
plegall committed Jun 27, 2019
1 parent 8e9cb6d commit 22f3e679eec76d9db0c6b15d509e13409edb9021
@@ -60,58 +60,6 @@
}
}
// Check for upgrade : code inspired from punbb
if (isset($_GET['action']) and 'check_upgrade' == $_GET['action'])
{
if (!fetchRemote(PHPWG_URL.'/download/latest_version', $result))
{
$page['errors'][] = l10n('Unable to check for upgrade.');
}
else
{
$versions = array('current' => PHPWG_VERSION);
$lines = @explode("\r\n", $result);
// if the current version is a BSF (development branch) build, we check
// the first line, for stable versions, we check the second line
if (preg_match('/^BSF/', $versions['current']))
{
$versions['latest'] = trim($lines[0]);
// because integer are limited to 4,294,967,296 we need to split BSF
// versions in date.time
foreach ($versions as $key => $value)
{
$versions[$key] =
preg_replace('/BSF_(\d{8})(\d{4})/', '$1.$2', $value);
}
}
else
{
$versions['latest'] = trim($lines[1]);
}
if ('' == $versions['latest'])
{
$page['errors'][] = l10n('Check for upgrade failed for unknown reasons.');
}
// concatenation needed to avoid automatic transformation by release
// script generator
else if ('%'.'PWGVERSION'.'%' == $versions['current'])
{
$page['infos'][] = l10n('You are running on development sources, no check possible.');
}
else if (version_compare($versions['current'], $versions['latest']) < 0)
{
$page['infos'][] = l10n('A new version of Piwigo is available.');
}
else
{
$page['infos'][] = l10n('You are running the latest version of Piwigo.');
}
}
}
if (isset($page['nb_pending_comments']))
{
$message = l10n('User comments').' <i class="icon-chat"></i> ';
@@ -223,7 +171,6 @@
'NB_VIEWS' => number_format_human_readable($nb_views),
'NB_PLUGINS' => count($pwg_loaded_plugins),
'STORAGE_USED' => l10n('%sGB', number_format($du_gb, $du_decimals)),
'U_CHECK_UPGRADE' => PHPWG_ROOT_PATH.'admin.php?action=check_upgrade',
'U_QUICK_SYNC' => PHPWG_ROOT_PATH.'admin.php?page=site_update&amp;site=1&amp;quick_sync=1&amp;pwg_token='.get_pwg_token(),
)
);
@@ -186,6 +186,58 @@
clear_derivative_cache($_GET['type']);
break;
}
case 'check_upgrade':
{
if (!fetchRemote(PHPWG_URL.'/download/latest_version', $result))
{
$page['errors'][] = l10n('Unable to check for upgrade.');
}
else
{
$versions = array('current' => PHPWG_VERSION);
$lines = @explode("\r\n", $result);
// if the current version is a BSF (development branch) build, we check
// the first line, for stable versions, we check the second line
if (preg_match('/^BSF/', $versions['current']))
{
$versions['latest'] = trim($lines[0]);
// because integer are limited to 4,294,967,296 we need to split BSF
// versions in date.time
foreach ($versions as $key => $value)
{
$versions[$key] =
preg_replace('/BSF_(\d{8})(\d{4})/', '$1.$2', $value);
}
}
else
{
$versions['latest'] = trim($lines[1]);
}
if ('' == $versions['latest'])
{
$page['errors'][] = l10n('Check for upgrade failed for unknown reasons.');
}
// concatenation needed to avoid automatic transformation by release
// script generator
else if ('%'.'PWGVERSION'.'%' == $versions['current'])
{
$page['infos'][] = l10n('You are running on development sources, no check possible.');
}
else if (version_compare($versions['current'], $versions['latest']) < 0)
{
$page['infos'][] = l10n('A new version of Piwigo is available.');
}
else
{
$page['infos'][] = l10n('You are running the latest version of Piwigo.');
}
}
}
default :
{
break;
@@ -232,6 +284,7 @@
'PHPWG_URL' => PHPWG_URL,
'PWG_VERSION' => PHPWG_VERSION,
'U_CHECK_UPGRADE' => sprintf($url_format, 'check_upgrade'),
'OS' => PHP_OS,
'PHP_VERSION' => phpversion(),
'DB_ENGINE' => 'MySQL',
@@ -132,7 +132,6 @@ jQuery().ready(function(){
<a href="{$U_QUICK_SYNC}" class="icon-exchange">{'Quick Local Synchronization'|translate}</a>
{/if}

<br><a href="{$U_CHECK_UPGRADE}" class="icon-arrows-cw">{'Check for upgrade'|@translate}</a>

{if isset($SUBSCRIBE_BASE_URL)}
<br><a href="{$SUBSCRIBE_BASE_URL}{$EMAIL}" class="externalLink cluetip icon-mail-alt" title="{'Piwigo Announcements Newsletter'|@translate}|{'Keep in touch with Piwigo project, subscribe to Piwigo Announcement Newsletter. You will receive emails when a new release is available (sometimes including a security bug fix, it\'s important to know and upgrade) and when major events happen to the project. Only a few emails a year.'|@translate|@htmlspecialchars|@nl2br}">{'Subscribe %s to Piwigo Announcements Newsletter'|@translate:$EMAIL}</a>
@@ -43,7 +43,7 @@
<fieldset id="environment">
<legend><i class="icon-cog"></i> {'Environment'|@translate}</legend>
<ul>
<li><a href="{$PHPWG_URL}" class="externalLink">Piwigo</a> {$PWG_VERSION}</li>
<li><a href="{$PHPWG_URL}" class="externalLink">Piwigo</a> {$PWG_VERSION} <a href="{$U_CHECK_UPGRADE}" class="icon-arrows-cw">{'Check for upgrade'|@translate}</a></li>
<li>{'Operating system'|@translate}: {$OS}</li>
<li>PHP: {$PHP_VERSION} (<a href="{$U_PHPINFO}" class="externalLink">{'Show info'|@translate}</a>) [{$PHP_DATATIME}]</li>
<li>{$DB_ENGINE}: {$DB_VERSION} [{$DB_DATATIME}]</li>

0 comments on commit 22f3e67

Please sign in to comment.
You can’t perform that action at this time.