X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=index.php;h=81ab7676fec90ee0b05ef1614dc2c41811c0d385;hb=6a6f6c32e5876a347a806cc43d25596b9257765b;hp=62d29f2c34e5b7a0c835ca5971f71911c95c5b66;hpb=90e5bd65c9d4a5d3d5cedfeaa1314f2a15df5227;p=github%2Fshaarli%2FShaarli.git diff --git a/index.php b/index.php index 62d29f2c..81ab7676 100644 --- a/index.php +++ b/index.php @@ -1,6 +1,6 @@ /shaarli/ define('WEB_PATH', substr($_SERVER["REQUEST_URI"], 0, 1+strrpos($_SERVER["REQUEST_URI"], '/', 0))); @@ -305,39 +306,13 @@ function setup_login_state() { } $userIsLoggedIn = setup_login_state(); -// Checks if an update is available for Shaarli. -// (at most once a day, and only for registered user.) -// Output: '' = no new version. -// other= the available version. -function checkUpdate() -{ - if (!isLoggedIn()) return ''; // Do not check versions for visitors. - if (empty($GLOBALS['config']['ENABLE_UPDATECHECK'])) return ''; // Do not check if the user doesn't want to. - - // Get latest version number at most once a day. - if (!is_file($GLOBALS['config']['UPDATECHECK_FILENAME']) || (filemtime($GLOBALS['config']['UPDATECHECK_FILENAME'])', '', str_replace('tpl = new RainTPL; - $this->tpl->assign('newversion', escape(checkUpdate())); + + try { + $version = ApplicationUtils::checkUpdate( + shaarli_version, + $GLOBALS['config']['UPDATECHECK_FILENAME'], + $GLOBALS['config']['UPDATECHECK_INTERVAL'], + $GLOBALS['config']['ENABLE_UPDATECHECK'], + isLoggedIn(), + $GLOBALS['config']['UPDATECHECK_BRANCH'] + ); + $this->tpl->assign('newVersion', escape($version)); + $this->tpl->assign('versionError', ''); + + } catch (Exception $exc) { + logm($exc->getMessage()); + $this->tpl->assign('newVersion', ''); + $this->tpl->assign('versionError', escape($exc->getMessage())); + } + $this->tpl->assign('feedurl', escape(index_url($_SERVER))); $searchcrits = ''; // Search criteria if (!empty($_GET['searchtags'])) { @@ -1955,6 +1948,7 @@ function buildLinkList($PAGE,$LINKSDB) // Fill all template fields. $data = array( + 'pagetitle' => $GLOBALS['pagetitle'], 'linkcount' => count($LINKSDB), 'previous_page_url' => $previous_page_url, 'next_page_url' => $next_page_url,