diff options
Diffstat (limited to 'application')
-rw-r--r-- | application/ApplicationUtils.php | 19 | ||||
-rw-r--r-- | application/PageBuilder.php | 25 | ||||
-rw-r--r-- | application/Updater.php | 21 | ||||
-rw-r--r-- | application/config/ConfigJson.php | 33 | ||||
-rw-r--r-- | application/config/ConfigManager.php | 83 | ||||
-rw-r--r-- | application/config/ConfigPhp.php | 45 |
6 files changed, 150 insertions, 76 deletions
diff --git a/application/ApplicationUtils.php b/application/ApplicationUtils.php index ed9abc39..37deb4b3 100644 --- a/application/ApplicationUtils.php +++ b/application/ApplicationUtils.php | |||
@@ -144,20 +144,19 @@ class ApplicationUtils | |||
144 | 'application', | 144 | 'application', |
145 | 'inc', | 145 | 'inc', |
146 | 'plugins', | 146 | 'plugins', |
147 | $conf->get('config.RAINTPL_TPL'), | 147 | $conf->get('path.raintpl_tpl'), |
148 | ) as $path) { | 148 | ) as $path) { |
149 | if (! is_readable(realpath($path))) { | 149 | if (! is_readable(realpath($path))) { |
150 | $errors[] = '"'.$path.'" directory is not readable'; | 150 | $errors[] = '"'.$path.'" directory is not readable'; |
151 | } | 151 | } |
152 | } | 152 | } |
153 | 153 | ||
154 | $datadir = $conf->get('config.DATADIR'); | ||
155 | // Check cache and data directories are readable and writeable | 154 | // Check cache and data directories are readable and writeable |
156 | foreach (array( | 155 | foreach (array( |
157 | $conf->get('config.CACHEDIR'), | 156 | $conf->get('path.thumbnails_cache'), |
158 | $datadir, | 157 | $conf->get('path.data_dir'), |
159 | $conf->get('config.PAGECACHE'), | 158 | $conf->get('path.page_cache'), |
160 | $conf->get('config.RAINTPL_TMP'), | 159 | $conf->get('path.raintpl_tmp'), |
161 | ) as $path) { | 160 | ) as $path) { |
162 | if (! is_readable(realpath($path))) { | 161 | if (! is_readable(realpath($path))) { |
163 | $errors[] = '"'.$path.'" directory is not readable'; | 162 | $errors[] = '"'.$path.'" directory is not readable'; |
@@ -170,10 +169,10 @@ class ApplicationUtils | |||
170 | // Check configuration files are readable and writeable | 169 | // Check configuration files are readable and writeable |
171 | foreach (array( | 170 | foreach (array( |
172 | $conf->getConfigFile(), | 171 | $conf->getConfigFile(), |
173 | $conf->get('config.DATASTORE'), | 172 | $conf->get('path.datastore'), |
174 | $conf->get('config.IPBANS_FILENAME'), | 173 | $conf->get('path.ban_file'), |
175 | $conf->get('config.LOG_FILE'), | 174 | $conf->get('path.log'), |
176 | $conf->get('config.UPDATECHECK_FILENAME'), | 175 | $conf->get('path.update_check'), |
177 | ) as $path) { | 176 | ) as $path) { |
178 | if (! is_file(realpath($path))) { | 177 | if (! is_file(realpath($path))) { |
179 | # the file may not exist yet | 178 | # the file may not exist yet |
diff --git a/application/PageBuilder.php b/application/PageBuilder.php index 1d3ba9e8..04454865 100644 --- a/application/PageBuilder.php +++ b/application/PageBuilder.php | |||
@@ -34,17 +34,17 @@ class PageBuilder | |||
34 | try { | 34 | try { |
35 | $version = ApplicationUtils::checkUpdate( | 35 | $version = ApplicationUtils::checkUpdate( |
36 | shaarli_version, | 36 | shaarli_version, |
37 | $conf->get('config.UPDATECHECK_FILENAME'), | 37 | $conf->get('path.update_check'), |
38 | $conf->get('config.UPDATECHECK_INTERVAL'), | 38 | $conf->get('general.check_updates_interval'), |
39 | $conf->get('config.ENABLE_UPDATECHECK'), | 39 | $conf->get('general.check_updates'), |
40 | isLoggedIn(), | 40 | isLoggedIn(), |
41 | $conf->get('config.UPDATECHECK_BRANCH') | 41 | $conf->get('general.check_updates_branch') |
42 | ); | 42 | ); |
43 | $this->tpl->assign('newVersion', escape($version)); | 43 | $this->tpl->assign('newVersion', escape($version)); |
44 | $this->tpl->assign('versionError', ''); | 44 | $this->tpl->assign('versionError', ''); |
45 | 45 | ||
46 | } catch (Exception $exc) { | 46 | } catch (Exception $exc) { |
47 | logm($conf->get('config.LOG_FILE'), $_SERVER['REMOTE_ADDR'], $exc->getMessage()); | 47 | logm($conf->get('path.log'), $_SERVER['REMOTE_ADDR'], $exc->getMessage()); |
48 | $this->tpl->assign('newVersion', ''); | 48 | $this->tpl->assign('newVersion', ''); |
49 | $this->tpl->assign('versionError', escape($exc->getMessage())); | 49 | $this->tpl->assign('versionError', escape($exc->getMessage())); |
50 | } | 50 | } |
@@ -63,20 +63,19 @@ class PageBuilder | |||
63 | $this->tpl->assign('scripturl', index_url($_SERVER)); | 63 | $this->tpl->assign('scripturl', index_url($_SERVER)); |
64 | $this->tpl->assign('pagetitle', 'Shaarli'); | 64 | $this->tpl->assign('pagetitle', 'Shaarli'); |
65 | $this->tpl->assign('privateonly', !empty($_SESSION['privateonly'])); // Show only private links? | 65 | $this->tpl->assign('privateonly', !empty($_SESSION['privateonly'])); // Show only private links? |
66 | if ($conf->exists('title')) { | 66 | if ($conf->exists('general.title')) { |
67 | $this->tpl->assign('pagetitle', $conf->get('title')); | 67 | $this->tpl->assign('pagetitle', $conf->get('general.title')); |
68 | } | 68 | } |
69 | if ($conf->exists('titleLink')) { | 69 | if ($conf->exists('general.header_link')) { |
70 | $this->tpl->assign('titleLink', $conf->get('titleLink')); | 70 | $this->tpl->assign('titleLink', $conf->get('general.header_link')); |
71 | } | 71 | } |
72 | if ($conf->exists('pagetitle')) { | 72 | if ($conf->exists('pagetitle')) { |
73 | $this->tpl->assign('pagetitle', $conf->get('pagetitle')); | 73 | $this->tpl->assign('pagetitle', $conf->get('pagetitle')); |
74 | } | 74 | } |
75 | $this->tpl->assign('shaarlititle', $conf->get('title', 'Shaarli')); | 75 | $this->tpl->assign('shaarlititle', $conf->get('title', 'Shaarli')); |
76 | $this->tpl->assign('openshaarli', $conf->get('config.OPEN_SHAARLI', false)); | 76 | $this->tpl->assign('openshaarli', $conf->get('extras.open_shaarli', false)); |
77 | $this->tpl->assign('showatom', $conf->get('config.SHOW_ATOM', false)); | 77 | $this->tpl->assign('showatom', $conf->get('extras.show_atom', false)); |
78 | $this->tpl->assign('hide_timestamps', $conf->get('config.HIDE_TIMESTAMPS', false)); | 78 | $this->tpl->assign('hide_timestamps', $conf->get('extras.hide_timestamps', false)); |
79 | // FIXME! Globals | ||
80 | if (!empty($GLOBALS['plugin_errors'])) { | 79 | if (!empty($GLOBALS['plugin_errors'])) { |
81 | $this->tpl->assign('plugin_errors', $GLOBALS['plugin_errors']); | 80 | $this->tpl->assign('plugin_errors', $GLOBALS['plugin_errors']); |
82 | } | 81 | } |
diff --git a/application/Updater.php b/application/Updater.php index 8552850c..31630ff5 100644 --- a/application/Updater.php +++ b/application/Updater.php | |||
@@ -109,8 +109,8 @@ class Updater | |||
109 | { | 109 | { |
110 | $conf = ConfigManager::getInstance(); | 110 | $conf = ConfigManager::getInstance(); |
111 | 111 | ||
112 | if (is_file($conf->get('config.DATADIR') . '/options.php')) { | 112 | if (is_file($conf->get('path.data_dir') . '/options.php')) { |
113 | include $conf->get('config.DATADIR') . '/options.php'; | 113 | include $conf->get('path.data_dir') . '/options.php'; |
114 | 114 | ||
115 | // Load GLOBALS into config | 115 | // Load GLOBALS into config |
116 | $allowedKeys = array_merge(ConfigPhp::$ROOT_KEYS); | 116 | $allowedKeys = array_merge(ConfigPhp::$ROOT_KEYS); |
@@ -121,7 +121,7 @@ class Updater | |||
121 | } | 121 | } |
122 | } | 122 | } |
123 | $conf->write($this->isLoggedIn); | 123 | $conf->write($this->isLoggedIn); |
124 | unlink($conf->get('config.DATADIR').'/options.php'); | 124 | unlink($conf->get('path.data_dir').'/options.php'); |
125 | } | 125 | } |
126 | 126 | ||
127 | return true; | 127 | return true; |
@@ -139,14 +139,15 @@ class Updater | |||
139 | $link['tags'] = implode(' ', array_unique(LinkFilter::tagsStrToArray($link['tags'], true))); | 139 | $link['tags'] = implode(' ', array_unique(LinkFilter::tagsStrToArray($link['tags'], true))); |
140 | $this->linkDB[$link['linkdate']] = $link; | 140 | $this->linkDB[$link['linkdate']] = $link; |
141 | } | 141 | } |
142 | $this->linkDB->savedb($conf->get('config.PAGECACHE')); | 142 | $this->linkDB->savedb($conf->get('path.page_cache')); |
143 | return true; | 143 | return true; |
144 | } | 144 | } |
145 | 145 | ||
146 | /** | 146 | /** |
147 | * Move old configuration in PHP to the new config system in JSON format. | 147 | * Move old configuration in PHP to the new config system in JSON format. |
148 | * | 148 | * |
149 | * Will rename 'config.php' into 'config.save.php' and create 'config.json'. | 149 | * Will rename 'config.php' into 'config.save.php' and create 'config.json.php'. |
150 | * It will also convert legacy setting keys to the new ones. | ||
150 | */ | 151 | */ |
151 | public function updateMethodConfigToJson() | 152 | public function updateMethodConfigToJson() |
152 | { | 153 | { |
@@ -164,15 +165,21 @@ class Updater | |||
164 | $conf->setConfigIO($configJson); | 165 | $conf->setConfigIO($configJson); |
165 | $conf->reload(); | 166 | $conf->reload(); |
166 | 167 | ||
168 | $legacyMap = array_flip(ConfigPhp::$LEGACY_KEYS_MAPPING); | ||
167 | foreach (ConfigPhp::$ROOT_KEYS as $key) { | 169 | foreach (ConfigPhp::$ROOT_KEYS as $key) { |
168 | $conf->set($key, $oldConfig[$key]); | 170 | $conf->set($legacyMap[$key], $oldConfig[$key]); |
169 | } | 171 | } |
170 | 172 | ||
171 | // Set sub config keys (config and plugins) | 173 | // Set sub config keys (config and plugins) |
172 | $subConfig = array('config', 'plugins'); | 174 | $subConfig = array('config', 'plugins'); |
173 | foreach ($subConfig as $sub) { | 175 | foreach ($subConfig as $sub) { |
174 | foreach ($oldConfig[$sub] as $key => $value) { | 176 | foreach ($oldConfig[$sub] as $key => $value) { |
175 | $conf->set($sub .'.'. $key, $value); | 177 | if (isset($legacyMap[$sub .'.'. $key])) { |
178 | $configKey = $legacyMap[$sub .'.'. $key]; | ||
179 | } else { | ||
180 | $configKey = $sub .'.'. $key; | ||
181 | } | ||
182 | $conf->set($configKey, $value); | ||
176 | } | 183 | } |
177 | } | 184 | } |
178 | 185 | ||
diff --git a/application/config/ConfigJson.php b/application/config/ConfigJson.php index cbafbf6d..94693c86 100644 --- a/application/config/ConfigJson.php +++ b/application/config/ConfigJson.php | |||
@@ -8,29 +8,15 @@ | |||
8 | class ConfigJson implements ConfigIO | 8 | class ConfigJson implements ConfigIO |
9 | { | 9 | { |
10 | /** | 10 | /** |
11 | * The JSON data is wrapped in a PHP file for security purpose. | ||
12 | * This way, even if the file is accessible, credentials and configuration won't be exposed. | ||
13 | * | ||
14 | * @var string PHP start tag and comment tag. | ||
15 | */ | ||
16 | public static $PHP_HEADER; | ||
17 | |||
18 | public function __construct() | ||
19 | { | ||
20 | // The field can't be initialized directly with concatenation before PHP 5.6. | ||
21 | self::$PHP_HEADER = '<?php /*'. PHP_EOL; | ||
22 | } | ||
23 | |||
24 | /** | ||
25 | * @inheritdoc | 11 | * @inheritdoc |
26 | */ | 12 | */ |
27 | function read($filepath) | 13 | function read($filepath) |
28 | { | 14 | { |
29 | if (! file_exists($filepath) || ! is_readable($filepath)) { | 15 | if (! is_readable($filepath)) { |
30 | return array(); | 16 | return array(); |
31 | } | 17 | } |
32 | $data = file_get_contents($filepath); | 18 | $data = file_get_contents($filepath); |
33 | $data = str_replace(self::$PHP_HEADER, '', $data); | 19 | $data = str_replace(self::getPhpHeaders(), '', $data); |
34 | $data = json_decode($data, true); | 20 | $data = json_decode($data, true); |
35 | if ($data === null) { | 21 | if ($data === null) { |
36 | $error = json_last_error(); | 22 | $error = json_last_error(); |
@@ -46,7 +32,7 @@ class ConfigJson implements ConfigIO | |||
46 | { | 32 | { |
47 | // JSON_PRETTY_PRINT is available from PHP 5.4. | 33 | // JSON_PRETTY_PRINT is available from PHP 5.4. |
48 | $print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0; | 34 | $print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0; |
49 | $data = self::$PHP_HEADER . json_encode($conf, $print); | 35 | $data = self::getPhpHeaders() . json_encode($conf, $print); |
50 | if (!file_put_contents($filepath, $data)) { | 36 | if (!file_put_contents($filepath, $data)) { |
51 | throw new IOException( | 37 | throw new IOException( |
52 | $filepath, | 38 | $filepath, |
@@ -63,4 +49,17 @@ class ConfigJson implements ConfigIO | |||
63 | { | 49 | { |
64 | return '.json.php'; | 50 | return '.json.php'; |
65 | } | 51 | } |
52 | |||
53 | /** | ||
54 | * The JSON data is wrapped in a PHP file for security purpose. | ||
55 | * This way, even if the file is accessible, credentials and configuration won't be exposed. | ||
56 | * | ||
57 | * Note: this isn't a static field because concatenation isn't supported in field declaration before PHP 5.6. | ||
58 | * | ||
59 | * @return string PHP start tag and comment tag. | ||
60 | */ | ||
61 | public static function getPhpHeaders() | ||
62 | { | ||
63 | return '<?php /*'. PHP_EOL; | ||
64 | } | ||
66 | } | 65 | } |
diff --git a/application/config/ConfigManager.php b/application/config/ConfigManager.php index 70456737..a663a071 100644 --- a/application/config/ConfigManager.php +++ b/application/config/ConfigManager.php | |||
@@ -116,6 +116,11 @@ class ConfigManager | |||
116 | */ | 116 | */ |
117 | public function get($setting, $default = '') | 117 | public function get($setting, $default = '') |
118 | { | 118 | { |
119 | // During the ConfigIO transition, map legacy settings to the new ones. | ||
120 | if ($this->configIO instanceof ConfigPhp && isset(ConfigPhp::$LEGACY_KEYS_MAPPING[$setting])) { | ||
121 | $setting = ConfigPhp::$LEGACY_KEYS_MAPPING[$setting]; | ||
122 | } | ||
123 | |||
119 | $settings = explode('.', $setting); | 124 | $settings = explode('.', $setting); |
120 | $value = self::getConfig($settings, $this->loadedConfig); | 125 | $value = self::getConfig($settings, $this->loadedConfig); |
121 | if ($value === self::$NOT_FOUND) { | 126 | if ($value === self::$NOT_FOUND) { |
@@ -142,6 +147,11 @@ class ConfigManager | |||
142 | throw new Exception('Invalid setting key parameter. String expected, got: '. gettype($setting)); | 147 | throw new Exception('Invalid setting key parameter. String expected, got: '. gettype($setting)); |
143 | } | 148 | } |
144 | 149 | ||
150 | // During the ConfigIO transition, map legacy settings to the new ones. | ||
151 | if ($this->configIO instanceof ConfigPhp && isset(ConfigPhp::$LEGACY_KEYS_MAPPING[$setting])) { | ||
152 | $setting = ConfigPhp::$LEGACY_KEYS_MAPPING[$setting]; | ||
153 | } | ||
154 | |||
145 | $settings = explode('.', $setting); | 155 | $settings = explode('.', $setting); |
146 | self::setConfig($settings, $value, $this->loadedConfig); | 156 | self::setConfig($settings, $value, $this->loadedConfig); |
147 | if ($write) { | 157 | if ($write) { |
@@ -160,6 +170,11 @@ class ConfigManager | |||
160 | */ | 170 | */ |
161 | public function exists($setting) | 171 | public function exists($setting) |
162 | { | 172 | { |
173 | // During the ConfigIO transition, map legacy settings to the new ones. | ||
174 | if ($this->configIO instanceof ConfigPhp && isset(ConfigPhp::$LEGACY_KEYS_MAPPING[$setting])) { | ||
175 | $setting = ConfigPhp::$LEGACY_KEYS_MAPPING[$setting]; | ||
176 | } | ||
177 | |||
163 | $settings = explode('.', $setting); | 178 | $settings = explode('.', $setting); |
164 | $value = self::getConfig($settings, $this->loadedConfig); | 179 | $value = self::getConfig($settings, $this->loadedConfig); |
165 | if ($value === self::$NOT_FOUND) { | 180 | if ($value === self::$NOT_FOUND) { |
@@ -183,8 +198,15 @@ class ConfigManager | |||
183 | { | 198 | { |
184 | // These fields are required in configuration. | 199 | // These fields are required in configuration. |
185 | $mandatoryFields = array( | 200 | $mandatoryFields = array( |
186 | 'login', 'hash', 'salt', 'timezone', 'title', 'titleLink', | 201 | 'credentials.login', |
187 | 'redirector', 'disablesessionprotection', 'privateLinkByDefault' | 202 | 'credentials.hash', |
203 | 'credentials.salt', | ||
204 | 'security.session_protection_disabled', | ||
205 | 'general.timezone', | ||
206 | 'general.title', | ||
207 | 'general.header_link', | ||
208 | 'general.default_private_links', | ||
209 | 'extras.redirector', | ||
188 | ); | 210 | ); |
189 | 211 | ||
190 | // Only logged in user can alter config. | 212 | // Only logged in user can alter config. |
@@ -265,75 +287,78 @@ class ConfigManager | |||
265 | protected function setDefaultValues() | 287 | protected function setDefaultValues() |
266 | { | 288 | { |
267 | // Data subdirectory | 289 | // Data subdirectory |
268 | $this->setEmpty('config.DATADIR', 'data'); | 290 | $this->setEmpty('path.data_dir', 'data'); |
269 | 291 | ||
270 | // Main configuration file | 292 | // Main configuration file |
271 | $this->setEmpty('config.CONFIG_FILE', 'data/config.php'); | 293 | $this->setEmpty('path.config', 'data/config.php'); |
272 | 294 | ||
273 | // Link datastore | 295 | // Link datastore |
274 | $this->setEmpty('config.DATASTORE', 'data/datastore.php'); | 296 | $this->setEmpty('path.datastore', 'data/datastore.php'); |
275 | 297 | ||
276 | // Banned IPs | 298 | // Banned IPs |
277 | $this->setEmpty('config.IPBANS_FILENAME', 'data/ipbans.php'); | 299 | $this->setEmpty('path.ban_file', 'data/ipbans.php'); |
278 | 300 | ||
279 | // Processed updates file. | 301 | // Processed updates file. |
280 | $this->setEmpty('config.UPDATES_FILE', 'data/updates.txt'); | 302 | $this->setEmpty('path.updates', 'data/updates.txt'); |
281 | 303 | ||
282 | // Access log | 304 | // Access log |
283 | $this->setEmpty('config.LOG_FILE', 'data/log.txt'); | 305 | $this->setEmpty('path.log', 'data/log.txt'); |
284 | 306 | ||
285 | // For updates check of Shaarli | 307 | // For updates check of Shaarli |
286 | $this->setEmpty('config.UPDATECHECK_FILENAME', 'data/lastupdatecheck.txt'); | 308 | $this->setEmpty('path.update_check', 'data/lastupdatecheck.txt'); |
287 | 309 | ||
288 | // Set ENABLE_UPDATECHECK to disabled by default. | 310 | // Set ENABLE_UPDATECHECK to disabled by default. |
289 | $this->setEmpty('config.ENABLE_UPDATECHECK', false); | 311 | $this->setEmpty('general.check_updates', false); |
290 | 312 | ||
291 | // RainTPL cache directory (keep the trailing slash!) | 313 | // RainTPL cache directory (keep the trailing slash!) |
292 | $this->setEmpty('config.RAINTPL_TMP', 'tmp/'); | 314 | $this->setEmpty('path.raintpl_tmp', 'tmp/'); |
293 | // Raintpl template directory (keep the trailing slash!) | 315 | // Raintpl template directory (keep the trailing slash!) |
294 | $this->setEmpty('config.RAINTPL_TPL', 'tpl/'); | 316 | $this->setEmpty('path.raintpl_tpl', 'tpl/'); |
295 | 317 | ||
296 | // Thumbnail cache directory | 318 | // Thumbnail cache directory |
297 | $this->setEmpty('config.CACHEDIR', 'cache'); | 319 | $this->setEmpty('path.thumbnails_cache', 'cache'); |
298 | 320 | ||
299 | // Atom & RSS feed cache directory | 321 | // Atom & RSS feed cache directory |
300 | $this->setEmpty('config.PAGECACHE', 'pagecache'); | 322 | $this->setEmpty('path.page_cache', 'pagecache'); |
301 | 323 | ||
302 | // Ban IP after this many failures | 324 | // Ban IP after this many failures |
303 | $this->setEmpty('config.BAN_AFTER', 4); | 325 | $this->setEmpty('security.ban_after', 4); |
304 | // Ban duration for IP address after login failures (in seconds) | 326 | // Ban duration for IP address after login failures (in seconds) |
305 | $this->setEmpty('config.BAN_DURATION', 1800); | 327 | $this->setEmpty('security.ban_after', 1800); |
306 | 328 | ||
307 | // Feed options | 329 | // Feed options |
308 | // Enable RSS permalinks by default. | 330 | // Enable RSS permalinks by default. |
309 | // This corresponds to the default behavior of shaarli before this was added as an option. | 331 | // This corresponds to the default behavior of shaarli before this was added as an option. |
310 | $this->setEmpty('config.ENABLE_RSS_PERMALINKS', true); | 332 | $this->setEmpty('general.rss_permalinks', true); |
311 | // If true, an extra "ATOM feed" button will be displayed in the toolbar | 333 | // If true, an extra "ATOM feed" button will be displayed in the toolbar |
312 | $this->setEmpty('config.SHOW_ATOM', false); | 334 | $this->setEmpty('extras.show_atom', false); |
313 | 335 | ||
314 | // Link display options | 336 | // Link display options |
315 | $this->setEmpty('config.HIDE_PUBLIC_LINKS', false); | 337 | $this->setEmpty('extras.hide_public_links', false); |
316 | $this->setEmpty('config.HIDE_TIMESTAMPS', false); | 338 | $this->setEmpty('extras.hide_timestamps', false); |
317 | $this->setEmpty('config.LINKS_PER_PAGE', 20); | 339 | $this->setEmpty('general.links_per_page', 20); |
340 | |||
341 | // Private checkbox is checked by default | ||
342 | $this->setEmpty('general.default_private_links', false); | ||
318 | 343 | ||
319 | // Open Shaarli (true): anyone can add/edit/delete links without having to login | 344 | // Open Shaarli (true): anyone can add/edit/delete links without having to login |
320 | $this->setEmpty('config.OPEN_SHAARLI', false); | 345 | $this->setEmpty('extras.open_shaarli', false); |
321 | 346 | ||
322 | // Thumbnails | 347 | // Thumbnails |
323 | // Display thumbnails in links | 348 | // Display thumbnails in links |
324 | $this->setEmpty('config.ENABLE_THUMBNAILS', true); | 349 | $this->setEmpty('general.enable_thumbnails', true); |
325 | // Store thumbnails in a local cache | 350 | // Store thumbnails in a local cache |
326 | $this->setEmpty('config.ENABLE_LOCALCACHE', true); | 351 | $this->setEmpty('general.enable_localcache', true); |
327 | 352 | ||
328 | // Update check frequency for Shaarli. 86400 seconds=24 hours | 353 | // Update check frequency for Shaarli. 86400 seconds=24 hours |
329 | $this->setEmpty('config.UPDATECHECK_BRANCH', 'stable'); | 354 | $this->setEmpty('general.check_updates_branch', 'stable'); |
330 | $this->setEmpty('config.UPDATECHECK_INTERVAL', 86400); | 355 | $this->setEmpty('general.check_updates_interval', 86400); |
331 | 356 | ||
332 | $this->setEmpty('redirector', ''); | 357 | $this->setEmpty('extras.redirector', ''); |
333 | $this->setEmpty('config.REDIRECTOR_URLENCODE', true); | 358 | $this->setEmpty('extras.redirector_encode_url', true); |
334 | 359 | ||
335 | // Enabled plugins. | 360 | // Enabled plugins. |
336 | $this->setEmpty('config.ENABLED_PLUGINS', array('qrcode')); | 361 | $this->setEmpty('general.enabled_plugins', array('qrcode')); |
337 | 362 | ||
338 | // Initialize plugin parameters array. | 363 | // Initialize plugin parameters array. |
339 | $this->setEmpty('plugins', array()); | 364 | $this->setEmpty('plugins', array()); |
diff --git a/application/config/ConfigPhp.php b/application/config/ConfigPhp.php index f99073af..b122f4f1 100644 --- a/application/config/ConfigPhp.php +++ b/application/config/ConfigPhp.php | |||
@@ -24,6 +24,51 @@ class ConfigPhp implements ConfigIO | |||
24 | ); | 24 | ); |
25 | 25 | ||
26 | /** | 26 | /** |
27 | * Map legacy config keys with the new ones. | ||
28 | * If ConfigPhp is used, getting <newkey> will actually look for <legacykey>. | ||
29 | * The Updater will use this array to transform keys when switching to JSON. | ||
30 | * | ||
31 | * @var array current key => legacy key. | ||
32 | */ | ||
33 | public static $LEGACY_KEYS_MAPPING = array( | ||
34 | 'credentials.login' => 'login', | ||
35 | 'credentials.hash' => 'hash', | ||
36 | 'credentials.salt' => 'salt', | ||
37 | 'path.data_dir' => 'config.DATADIR', | ||
38 | 'path.config' => 'config.CONFIG_FILE', | ||
39 | 'path.datastore' => 'config.DATASTORE', | ||
40 | 'path.updates' => 'config.UPDATES_FILE', | ||
41 | 'path.log' => 'config.LOG_FILE', | ||
42 | 'path.update_check' => 'config.UPDATECHECK_FILENAME', | ||
43 | 'path.raintpl_tpl' => 'config.RAINTPL_TPL', | ||
44 | 'path.raintpl_tmp' => 'config.RAINTPL_TMP', | ||
45 | 'path.thumbnails_cache' => 'config.CACHEDIR', | ||
46 | 'path.page_cache' => 'config.PAGECACHE', | ||
47 | 'path.ban_file' => 'config.IPBANS_FILENAME', | ||
48 | 'security.session_protection_disabled' => 'disablesessionprotection', | ||
49 | 'security.ban_after' => 'config.BAN_AFTER', | ||
50 | 'security.ban_duration' => 'config.BAN_DURATION', | ||
51 | 'general.title' => 'title', | ||
52 | 'general.timezone' => 'timezone', | ||
53 | 'general.header_link' => 'titleLink', | ||
54 | 'general.check_updates' => 'config.ENABLE_UPDATECHECK', | ||
55 | 'general.check_updates_branch' => 'config.UPDATECHECK_BRANCH', | ||
56 | 'general.check_updates_interval' => 'config.UPDATECHECK_INTERVAL', | ||
57 | 'general.default_private_links' => 'privateLinkByDefault', | ||
58 | 'general.rss_permalinks' => 'config.ENABLE_RSS_PERMALINKS', | ||
59 | 'general.links_per_page' => 'config.LINKS_PER_PAGE', | ||
60 | 'general.enable_thumbnails' => 'config.ENABLE_THUMBNAILS', | ||
61 | 'general.enable_localcache' => 'config.ENABLE_LOCALCACHE', | ||
62 | 'general.enabled_plugins' => 'config.ENABLED_PLUGINS', | ||
63 | 'extras.redirector' => 'redirector', | ||
64 | 'extras.redirector_encode_url' => 'config.REDIRECTOR_URLENCODE', | ||
65 | 'extras.show_atom' => 'config.SHOW_ATOM', | ||
66 | 'extras.hide_public_links' => 'config.HIDE_PUBLIC_LINKS', | ||
67 | 'extras.hide_timestamps' => 'config.HIDE_TIMESTAMPS', | ||
68 | 'extras.open_shaarli' => 'config.OPEN_SHAARLI', | ||
69 | ); | ||
70 | |||
71 | /** | ||
27 | * @inheritdoc | 72 | * @inheritdoc |
28 | */ | 73 | */ |
29 | function read($filepath) | 74 | function read($filepath) |