aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2016-01-12 19:50:48 +0100
committerArthurHoaro <arthur@hoa.ro>2016-02-15 20:30:24 +0100
commit510377d2cb4b12d1a421e8a88bd7edb86f223451 (patch)
tree6cea29c199fc1b29ccfb78f902313019f6f9d95e /index.php
parent268a2e52659964fb7d033a1bb4d1490bf8cc49bf (diff)
downloadShaarli-510377d2cb4b12d1a421e8a88bd7edb86f223451.tar.gz
Shaarli-510377d2cb4b12d1a421e8a88bd7edb86f223451.tar.zst
Shaarli-510377d2cb4b12d1a421e8a88bd7edb86f223451.zip
Introduce the Updater class which
* contains methods designed to be run once. * is able to upgrade the datastore or the configuration. * is based on methods names, stored in a text file with ';' separator (updates.txt). * begins with existing function 'mergeDeprecatedConfigFile()' (options.php).
Diffstat (limited to 'index.php')
-rw-r--r--index.php33
1 files changed, 23 insertions, 10 deletions
diff --git a/index.php b/index.php
index 31dcbf0f..a5d8b7bd 100644
--- a/index.php
+++ b/index.php
@@ -44,6 +44,9 @@ $GLOBALS['config']['DATASTORE'] = $GLOBALS['config']['DATADIR'].'/datastore.php'
44// Banned IPs 44// Banned IPs
45$GLOBALS['config']['IPBANS_FILENAME'] = $GLOBALS['config']['DATADIR'].'/ipbans.php'; 45$GLOBALS['config']['IPBANS_FILENAME'] = $GLOBALS['config']['DATADIR'].'/ipbans.php';
46 46
47// Processed updates file.
48$GLOBALS['config']['UPDATES_FILE'] = $GLOBALS['config']['DATADIR'].'/updates.txt';
49
47// Access log 50// Access log
48$GLOBALS['config']['LOG_FILE'] = $GLOBALS['config']['DATADIR'].'/log.txt'; 51$GLOBALS['config']['LOG_FILE'] = $GLOBALS['config']['DATADIR'].'/log.txt';
49 52
@@ -61,7 +64,6 @@ $GLOBALS['config']['CACHEDIR'] = 'cache';
61// Atom & RSS feed cache directory 64// Atom & RSS feed cache directory
62$GLOBALS['config']['PAGECACHE'] = 'pagecache'; 65$GLOBALS['config']['PAGECACHE'] = 'pagecache';
63 66
64
65/* 67/*
66 * Global configuration 68 * Global configuration
67 */ 69 */
@@ -159,6 +161,7 @@ require_once 'application/Utils.php';
159require_once 'application/Config.php'; 161require_once 'application/Config.php';
160require_once 'application/PluginManager.php'; 162require_once 'application/PluginManager.php';
161require_once 'application/Router.php'; 163require_once 'application/Router.php';
164require_once 'application/Updater.php';
162 165
163// Ensure the PHP version is supported 166// Ensure the PHP version is supported
164try { 167try {
@@ -1110,6 +1113,25 @@ function renderPage()
1110 $GLOBALS['redirector'] 1113 $GLOBALS['redirector']
1111 ); 1114 );
1112 1115
1116 $updater = new Updater(
1117 read_updates_file($GLOBALS['config']['UPDATES_FILE']),
1118 $GLOBALS,
1119 $LINKSDB,
1120 isLoggedIn()
1121 );
1122 try {
1123 $newUpdates = $updater->update();
1124 if (! empty($newUpdates)) {
1125 write_updates_file(
1126 $GLOBALS['config']['UPDATES_FILE'],
1127 $updater->getDoneUpdates()
1128 );
1129 }
1130 }
1131 catch(Exception $e) {
1132 die($e->getMessage());
1133 }
1134
1113 $PAGE = new pageBuilder; 1135 $PAGE = new pageBuilder;
1114 1136
1115 // Determine which page will be rendered. 1137 // Determine which page will be rendered.
@@ -2515,15 +2537,6 @@ function resizeImage($filepath)
2515 return true; 2537 return true;
2516} 2538}
2517 2539
2518try {
2519 mergeDeprecatedConfig($GLOBALS, isLoggedIn());
2520} catch(Exception $e) {
2521 error_log(
2522 'ERROR while merging deprecated options.php file.' . PHP_EOL .
2523 $e->getMessage()
2524 );
2525}
2526
2527if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=genthumbnail')) { genThumbnail(); exit; } // Thumbnail generation/cache does not need the link database. 2540if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=genthumbnail')) { genThumbnail(); exit; } // Thumbnail generation/cache does not need the link database.
2528if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=rss')) { showRSS(); exit; } 2541if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=rss')) { showRSS(); exit; }
2529if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=atom')) { showATOM(); exit; } 2542if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=atom')) { showATOM(); exit; }