diff --git a/admin/intro.php b/admin/intro.php index d6b8e5f95..70c724331 100644 --- a/admin/intro.php +++ b/admin/intro.php @@ -60,58 +60,6 @@ if ($counter > 0) } } -// 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').' '; @@ -223,7 +171,6 @@ $template->assign( '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&site=1&quick_sync=1&pwg_token='.get_pwg_token(), ) ); diff --git a/admin/maintenance.php b/admin/maintenance.php index 3c2f0233c..69d870e72 100644 --- a/admin/maintenance.php +++ b/admin/maintenance.php @@ -186,6 +186,58 @@ DELETE 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 @@ $template->assign( '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', diff --git a/admin/themes/default/template/intro.tpl b/admin/themes/default/template/intro.tpl index b4677fb8c..aa152d651 100644 --- a/admin/themes/default/template/intro.tpl +++ b/admin/themes/default/template/intro.tpl @@ -132,7 +132,6 @@ jQuery().ready(function(){ {'Quick Local Synchronization'|translate} {/if} -
{'Check for upgrade'|@translate} {if isset($SUBSCRIBE_BASE_URL)}
{'Subscribe %s to Piwigo Announcements Newsletter'|@translate:$EMAIL} diff --git a/admin/themes/default/template/maintenance.tpl b/admin/themes/default/template/maintenance.tpl index 48fd4ca8a..040653261 100644 --- a/admin/themes/default/template/maintenance.tpl +++ b/admin/themes/default/template/maintenance.tpl @@ -43,7 +43,7 @@
{'Environment'|@translate}