From: Arthur Date: Mon, 15 Feb 2016 19:36:42 +0000 (+0100) Subject: Merge pull request #442 from ArthurHoaro/updater X-Git-Tag: v0.6.4~15 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=854ea372553d6ef8174cae320801e5ff3a101a87;hp=-c;p=github%2Fshaarli%2FShaarli.git Merge pull request #442 from ArthurHoaro/updater Introduce the Updater class which --- 854ea372553d6ef8174cae320801e5ff3a101a87 diff --combined index.php index 9785c419,a5d8b7bd..d88f4346 --- a/index.php +++ b/index.php @@@ -44,15 -44,15 +44,18 @@@ $GLOBALS['config']['DATASTORE'] = $GLOB // Banned IPs $GLOBALS['config']['IPBANS_FILENAME'] = $GLOBALS['config']['DATADIR'].'/ipbans.php'; + // Processed updates file. + $GLOBALS['config']['UPDATES_FILE'] = $GLOBALS['config']['DATADIR'].'/updates.txt'; + // Access log $GLOBALS['config']['LOG_FILE'] = $GLOBALS['config']['DATADIR'].'/log.txt'; // For updates check of Shaarli $GLOBALS['config']['UPDATECHECK_FILENAME'] = $GLOBALS['config']['DATADIR'].'/lastupdatecheck.txt'; +// Set ENABLE_UPDATECHECK to disabled by default. +$GLOBALS['config']['ENABLE_UPDATECHECK'] = false; + // RainTPL cache directory (keep the trailing slash!) $GLOBALS['config']['RAINTPL_TMP'] = 'tmp/'; // Raintpl template directory (keep the trailing slash!) @@@ -64,7 -64,6 +67,6 @@@ $GLOBALS['config']['CACHEDIR'] = 'cache // Atom & RSS feed cache directory $GLOBALS['config']['PAGECACHE'] = 'pagecache'; - /* * Global configuration */ @@@ -114,8 -113,7 +116,8 @@@ $GLOBALS['config']['UPDATECHECK_INTERVA //); $GLOBALS['config']['ENABLED_PLUGINS'] = array('qrcode'); -//$GLOBALS['plugins']['WALLABAG_URL'] = 'https://demo.wallabag.org/'; +// Initialize plugin parameters array. +$GLOBALS['plugins'] = array(); // PubSubHubbub support. Put an empty string to disable, or put your hub url here to enable. $GLOBALS['config']['PUBSUBHUB_URL'] = ''; @@@ -163,6 -161,7 +165,7 @@@ require_once 'application/Utils.php' require_once 'application/Config.php'; require_once 'application/PluginManager.php'; require_once 'application/Router.php'; + require_once 'application/Updater.php'; // Ensure the PHP version is supported try { @@@ -1114,6 -1113,25 +1117,25 @@@ function renderPage( $GLOBALS['redirector'] ); + $updater = new Updater( + read_updates_file($GLOBALS['config']['UPDATES_FILE']), + $GLOBALS, + $LINKSDB, + isLoggedIn() + ); + try { + $newUpdates = $updater->update(); + if (! empty($newUpdates)) { + write_updates_file( + $GLOBALS['config']['UPDATES_FILE'], + $updater->getDoneUpdates() + ); + } + } + catch(Exception $e) { + die($e->getMessage()); + } + $PAGE = new pageBuilder; // Determine which page will be rendered. @@@ -1123,9 -1141,9 +1145,9 @@@ // Call plugin hooks for header, footer and includes, specifying which page will be rendered. // Then assign generated data to RainTPL. $common_hooks = array( + 'includes', 'header', 'footer', - 'includes', ); $pluginManager = PluginManager::getInstance(); foreach($common_hooks as $name) { @@@ -2519,15 -2537,6 +2541,6 @@@ function resizeImage($filepath return true; } - try { - mergeDeprecatedConfig($GLOBALS, isLoggedIn()); - } catch(Exception $e) { - error_log( - 'ERROR while merging deprecated options.php file.' . PHP_EOL . - $e->getMessage() - ); - } - if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=genthumbnail')) { genThumbnail(); exit; } // Thumbnail generation/cache does not need the link database. if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=rss')) { showRSS(); exit; } if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=atom')) { showATOM(); exit; }