aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2016-05-29 16:10:32 +0200
committerArthurHoaro <arthur@hoa.ro>2016-06-11 09:30:56 +0200
commitda10377b3c263d96a46cf9101c202554343d2cd0 (patch)
treed91d1fcdbd79367418007add4d135d3f84e57a04
parenteeea1c3daa87f133c57c96fa17ed26b02c392636 (diff)
downloadShaarli-da10377b3c263d96a46cf9101c202554343d2cd0.tar.gz
Shaarli-da10377b3c263d96a46cf9101c202554343d2cd0.tar.zst
Shaarli-da10377b3c263d96a46cf9101c202554343d2cd0.zip
Rename configuration keys and fix GLOBALS in templates
-rw-r--r--application/ApplicationUtils.php19
-rw-r--r--application/PageBuilder.php25
-rw-r--r--application/Updater.php21
-rw-r--r--application/config/ConfigJson.php33
-rw-r--r--application/config/ConfigManager.php83
-rw-r--r--application/config/ConfigPhp.php45
-rw-r--r--index.php202
-rw-r--r--tests/ApplicationUtilsTest.php40
-rw-r--r--tests/Updater/UpdaterTest.php97
-rw-r--r--tests/config/ConfigJsonTest.php38
-rw-r--r--tests/config/ConfigManagerTest.php6
-rw-r--r--tests/utils/config/configJson.json.php33
-rw-r--r--tests/utils/config/configUpdateDone.json.php4
-rw-r--r--tests/utils/config/configUpdater.php15
-rw-r--r--tpl/configure.html4
-rw-r--r--tpl/daily.html2
-rw-r--r--tpl/dailyrss.html2
-rw-r--r--tpl/editlink.html4
18 files changed, 350 insertions, 323 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 @@
8class ConfigJson implements ConfigIO 8class 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)
diff --git a/index.php b/index.php
index aad65559..9546ee15 100644
--- a/index.php
+++ b/index.php
@@ -107,13 +107,13 @@ if (isset($_COOKIE['shaarli']) && !is_session_id_valid($_COOKIE['shaarli'])) {
107 107
108$conf = ConfigManager::getInstance(); 108$conf = ConfigManager::getInstance();
109 109
110RainTPL::$tpl_dir = $conf->get('config.RAINTPL_TPL'); // template directory 110RainTPL::$tpl_dir = $conf->get('path.raintpl_tpl'); // template directory
111RainTPL::$cache_dir = $conf->get('config.RAINTPL_TMP'); // cache directory 111RainTPL::$cache_dir = $conf->get('path.raintpl_tmp'); // cache directory
112 112
113$pluginManager = PluginManager::getInstance(); 113$pluginManager = PluginManager::getInstance();
114$pluginManager->load($conf->get('config.ENABLED_PLUGINS')); 114$pluginManager->load($conf->get('general.enabled_plugins'));
115 115
116date_default_timezone_set($conf->get('timezone', 'UTC')); 116date_default_timezone_set($conf->get('general.timezone', 'UTC'));
117 117
118ob_start(); // Output buffering for the page cache. 118ob_start(); // Output buffering for the page cache.
119 119
@@ -133,20 +133,20 @@ header("Cache-Control: post-check=0, pre-check=0", false);
133header("Pragma: no-cache"); 133header("Pragma: no-cache");
134 134
135// Handling of old config file which do not have the new parameters. 135// Handling of old config file which do not have the new parameters.
136if (! $conf->exists('title')) { 136if (! $conf->exists('general.title')) {
137 $conf->set('title', 'Shared links on '. escape(index_url($_SERVER))); 137 $conf->set('general.title', 'Shared links on '. escape(index_url($_SERVER)));
138} 138}
139if (! $conf->exists('timezone')) { 139if (! $conf->exists('general.timezone')) {
140 $conf->set('timezone', date_default_timezone_get()); 140 $conf->set('general.timezone', date_default_timezone_get());
141} 141}
142if (! $conf->exists('disablesessionprotection')) { 142if (! $conf->exists('security.session_protection_disabled')) {
143 $conf->set('disablesessionprotection', false); 143 $conf->set('security.session_protection_disabled', false);
144} 144}
145if (! $conf->exists('privateLinkByDefault')) { 145if (! $conf->exists('general.default_private_links')) {
146 $conf->set('privateLinkByDefault', false); 146 $conf->set('general.default_private_links', false);
147} 147}
148if (! $conf->exists('titleLink')) { 148if (! $conf->exists('general.header_link')) {
149 $conf->set('titleLink', '?'); 149 $conf->set('general.header_link', '?');
150} 150}
151 151
152if (! is_file($conf->getConfigFile())) { 152if (! is_file($conf->getConfigFile())) {
@@ -171,12 +171,12 @@ if (! is_file($conf->getConfigFile())) {
171} 171}
172 172
173// FIXME! Update these value with Updater and escpae it during the install/config save. 173// FIXME! Update these value with Updater and escpae it during the install/config save.
174$conf->set('title', escape($conf->get('title'))); 174$conf->set('general.title', escape($conf->get('general.title')));
175$conf->set('titleLink', escape($conf->get('titleLink'))); 175$conf->set('general.header_link', escape($conf->get('general.header_link')));
176$conf->set('redirector', escape($conf->get('redirector'))); 176$conf->set('extras.redirector', escape($conf->get('extras.redirector')));
177 177
178// a token depending of deployment salt, user password, and the current ip 178// a token depending of deployment salt, user password, and the current ip
179define('STAY_SIGNED_IN_TOKEN', sha1($conf->get('hash') . $_SERVER['REMOTE_ADDR'] . $conf->get('salt'))); 179define('STAY_SIGNED_IN_TOKEN', sha1($conf->get('credentials.hash') . $_SERVER['REMOTE_ADDR'] . $conf->get('credentials.salt')));
180 180
181// Sniff browser language and set date format accordingly. 181// Sniff browser language and set date format accordingly.
182if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { 182if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
@@ -191,12 +191,12 @@ header('Content-Type: text/html; charset=utf-8'); // We use UTF-8 for proper int
191function setup_login_state() { 191function setup_login_state() {
192 $conf = ConfigManager::getInstance(); 192 $conf = ConfigManager::getInstance();
193 193
194 if ($conf->get('config.OPEN_SHAARLI')) { 194 if ($conf->get('extras.open_shaarli')) {
195 return true; 195 return true;
196 } 196 }
197 $userIsLoggedIn = false; // By default, we do not consider the user as logged in; 197 $userIsLoggedIn = false; // By default, we do not consider the user as logged in;
198 $loginFailure = false; // If set to true, every attempt to authenticate the user will fail. This indicates that an important condition isn't met. 198 $loginFailure = false; // If set to true, every attempt to authenticate the user will fail. This indicates that an important condition isn't met.
199 if (! $conf->exists('login')) { 199 if (! $conf->exists('credentials.login')) {
200 $userIsLoggedIn = false; // Shaarli is not configured yet. 200 $userIsLoggedIn = false; // Shaarli is not configured yet.
201 $loginFailure = true; 201 $loginFailure = true;
202 } 202 }
@@ -209,7 +209,7 @@ function setup_login_state() {
209 } 209 }
210 // If session does not exist on server side, or IP address has changed, or session has expired, logout. 210 // If session does not exist on server side, or IP address has changed, or session has expired, logout.
211 if (empty($_SESSION['uid']) 211 if (empty($_SESSION['uid'])
212 || ($conf->get('disablesessionprotection') == false && $_SESSION['ip'] != allIPs()) 212 || ($conf->get('security.session_protection_disabled') == false && $_SESSION['ip'] != allIPs())
213 || time() >= $_SESSION['expires_on']) 213 || time() >= $_SESSION['expires_on'])
214 { 214 {
215 logout(); 215 logout();
@@ -266,7 +266,7 @@ function fillSessionInfo() {
266 $conf = ConfigManager::getInstance(); 266 $conf = ConfigManager::getInstance();
267 $_SESSION['uid'] = sha1(uniqid('',true).'_'.mt_rand()); // Generate unique random number (different than phpsessionid) 267 $_SESSION['uid'] = sha1(uniqid('',true).'_'.mt_rand()); // Generate unique random number (different than phpsessionid)
268 $_SESSION['ip']=allIPs(); // We store IP address(es) of the client to make sure session is not hijacked. 268 $_SESSION['ip']=allIPs(); // We store IP address(es) of the client to make sure session is not hijacked.
269 $_SESSION['username']= $conf->get('login'); 269 $_SESSION['username']= $conf->get('credentials.login');
270 $_SESSION['expires_on']=time()+INACTIVITY_TIMEOUT; // Set session expiration. 270 $_SESSION['expires_on']=time()+INACTIVITY_TIMEOUT; // Set session expiration.
271} 271}
272 272
@@ -274,14 +274,14 @@ function fillSessionInfo() {
274function check_auth($login,$password) 274function check_auth($login,$password)
275{ 275{
276 $conf = ConfigManager::getInstance(); 276 $conf = ConfigManager::getInstance();
277 $hash = sha1($password . $login . $conf->get('salt')); 277 $hash = sha1($password . $login . $conf->get('credentials.salt'));
278 if ($login == $conf->get('login') && $hash == $conf->get('hash')) 278 if ($login == $conf->get('credentials.login') && $hash == $conf->get('credentials.hash'))
279 { // Login/password is correct. 279 { // Login/password is correct.
280 fillSessionInfo(); 280 fillSessionInfo();
281 logm($conf->get('config.LOG_FILE'), $_SERVER['REMOTE_ADDR'], 'Login successful'); 281 logm($conf->get('path.log'), $_SERVER['REMOTE_ADDR'], 'Login successful');
282 return True; 282 return True;
283 } 283 }
284 logm($conf->get('config.LOG_FILE'), $_SERVER['REMOTE_ADDR'], 'Login failed for user '.$login); 284 logm($conf->get('path.log'), $_SERVER['REMOTE_ADDR'], 'Login failed for user '.$login);
285 return False; 285 return False;
286} 286}
287 287
@@ -307,14 +307,14 @@ function logout() {
307// ------------------------------------------------------------------------------------------ 307// ------------------------------------------------------------------------------------------
308// Brute force protection system 308// Brute force protection system
309// Several consecutive failed logins will ban the IP address for 30 minutes. 309// Several consecutive failed logins will ban the IP address for 30 minutes.
310if (!is_file($conf->get('config.IPBANS_FILENAME', 'data/ipbans.php'))) { 310if (!is_file($conf->get('path.ban_file', 'data/ipbans.php'))) {
311 // FIXME! globals 311 // FIXME! globals
312 file_put_contents( 312 file_put_contents(
313 $conf->get('config.IPBANS_FILENAME', 'data/ipbans.php'), 313 $conf->get('path.ban_file', 'data/ipbans.php'),
314 "<?php\n\$GLOBALS['IPBANS']=".var_export(array('FAILURES'=>array(),'BANS'=>array()),true).";\n?>" 314 "<?php\n\$GLOBALS['IPBANS']=".var_export(array('FAILURES'=>array(),'BANS'=>array()),true).";\n?>"
315 ); 315 );
316} 316}
317include $conf->get('config.IPBANS_FILENAME', 'data/ipbans.php'); 317include $conf->get('path.ban_file', 'data/ipbans.php');
318// Signal a failed login. Will ban the IP if too many failures: 318// Signal a failed login. Will ban the IP if too many failures:
319function ban_loginFailed() 319function ban_loginFailed()
320{ 320{
@@ -323,14 +323,14 @@ function ban_loginFailed()
323 $gb = $GLOBALS['IPBANS']; 323 $gb = $GLOBALS['IPBANS'];
324 if (!isset($gb['FAILURES'][$ip])) $gb['FAILURES'][$ip]=0; 324 if (!isset($gb['FAILURES'][$ip])) $gb['FAILURES'][$ip]=0;
325 $gb['FAILURES'][$ip]++; 325 $gb['FAILURES'][$ip]++;
326 if ($gb['FAILURES'][$ip] > ($conf->get('config.BAN_AFTER') - 1)) 326 if ($gb['FAILURES'][$ip] > ($conf->get('security.ban_after') - 1))
327 { 327 {
328 $gb['BANS'][$ip] = time() + $conf->get('config.BAN_DURATION', 1800); 328 $gb['BANS'][$ip] = time() + $conf->get('security.ban_after', 1800);
329 logm($conf->get('config.LOG_FILE'), $_SERVER['REMOTE_ADDR'], 'IP address banned from login'); 329 logm($conf->get('path.log'), $_SERVER['REMOTE_ADDR'], 'IP address banned from login');
330 } 330 }
331 $GLOBALS['IPBANS'] = $gb; 331 $GLOBALS['IPBANS'] = $gb;
332 file_put_contents( 332 file_put_contents(
333 $conf->get('config.IPBANS_FILENAME', 'data/ipbans.php'), 333 $conf->get('path.ban_file', 'data/ipbans.php'),
334 "<?php\n\$GLOBALS['IPBANS']=".var_export($gb,true).";\n?>" 334 "<?php\n\$GLOBALS['IPBANS']=".var_export($gb,true).";\n?>"
335 ); 335 );
336} 336}
@@ -344,7 +344,7 @@ function ban_loginOk()
344 unset($gb['FAILURES'][$ip]); unset($gb['BANS'][$ip]); 344 unset($gb['FAILURES'][$ip]); unset($gb['BANS'][$ip]);
345 $GLOBALS['IPBANS'] = $gb; 345 $GLOBALS['IPBANS'] = $gb;
346 file_put_contents( 346 file_put_contents(
347 $conf->get('config.IPBANS_FILENAME', 'data/ipbans.php'), 347 $conf->get('path.ban_file', 'data/ipbans.php'),
348 "<?php\n\$GLOBALS['IPBANS']=".var_export($gb,true).";\n?>" 348 "<?php\n\$GLOBALS['IPBANS']=".var_export($gb,true).";\n?>"
349 ); 349 );
350} 350}
@@ -359,10 +359,10 @@ function ban_canLogin()
359 // User is banned. Check if the ban has expired: 359 // User is banned. Check if the ban has expired:
360 if ($gb['BANS'][$ip]<=time()) 360 if ($gb['BANS'][$ip]<=time())
361 { // Ban expired, user can try to login again. 361 { // Ban expired, user can try to login again.
362 logm($conf->get('config.LOG_FILE'), $_SERVER['REMOTE_ADDR'], 'Ban lifted.'); 362 logm($conf->get('path.log'), $_SERVER['REMOTE_ADDR'], 'Ban lifted.');
363 unset($gb['FAILURES'][$ip]); unset($gb['BANS'][$ip]); 363 unset($gb['FAILURES'][$ip]); unset($gb['BANS'][$ip]);
364 file_put_contents( 364 file_put_contents(
365 $conf->get('config.IPBANS_FILENAME', 'data/ipbans.php'), 365 $conf->get('path.ban_file', 'data/ipbans.php'),
366 "<?php\n\$GLOBALS['IPBANS']=".var_export($gb,true).";\n?>" 366 "<?php\n\$GLOBALS['IPBANS']=".var_export($gb,true).";\n?>"
367 ); 367 );
368 return true; // Ban has expired, user can login. 368 return true; // Ban has expired, user can login.
@@ -479,7 +479,7 @@ if (!isset($_SESSION['tokens'])) $_SESSION['tokens']=array(); // Token are atta
479function getToken() 479function getToken()
480{ 480{
481 $conf = ConfigManager::getInstance(); 481 $conf = ConfigManager::getInstance();
482 $rnd = sha1(uniqid('', true) .'_'. mt_rand() . $conf->get('salt')); // We generate a random string. 482 $rnd = sha1(uniqid('', true) .'_'. mt_rand() . $conf->get('credentials.salt')); // We generate a random string.
483 $_SESSION['tokens'][$rnd]=1; // Store it on the server side. 483 $_SESSION['tokens'][$rnd]=1; // Store it on the server side.
484 return $rnd; 484 return $rnd;
485} 485}
@@ -518,11 +518,11 @@ function showDailyRSS() {
518 // If cached was not found (or not usable), then read the database and build the response: 518 // If cached was not found (or not usable), then read the database and build the response:
519 // Read links from database (and filter private links if used it not logged in). 519 // Read links from database (and filter private links if used it not logged in).
520 $LINKSDB = new LinkDB( 520 $LINKSDB = new LinkDB(
521 $conf->get('config.DATASTORE'), 521 $conf->get('path.datastore'),
522 isLoggedIn(), 522 isLoggedIn(),
523 $conf->get('config.HIDE_PUBLIC_LINKS'), 523 $conf->get('extras.hide_public_links'),
524 $conf->get('redirector'), 524 $conf->get('extras.redirector'),
525 $conf->get('config.REDIRECTOR_URLENCODE') 525 $conf->get('extras.redirector_encode_url')
526 ); 526 );
527 527
528 /* Some Shaarlies may have very few links, so we need to look 528 /* Some Shaarlies may have very few links, so we need to look
@@ -556,7 +556,7 @@ function showDailyRSS() {
556 $pageaddr = escape(index_url($_SERVER)); 556 $pageaddr = escape(index_url($_SERVER));
557 echo '<?xml version="1.0" encoding="UTF-8"?><rss version="2.0">'; 557 echo '<?xml version="1.0" encoding="UTF-8"?><rss version="2.0">';
558 echo '<channel>'; 558 echo '<channel>';
559 echo '<title>Daily - '. $conf->get('title') . '</title>'; 559 echo '<title>Daily - '. $conf->get('general.title') . '</title>';
560 echo '<link>'. $pageaddr .'</link>'; 560 echo '<link>'. $pageaddr .'</link>';
561 echo '<description>Daily shared links</description>'; 561 echo '<description>Daily shared links</description>';
562 echo '<language>en-en</language>'; 562 echo '<language>en-en</language>';
@@ -575,7 +575,7 @@ function showDailyRSS() {
575 // We pre-format some fields for proper output. 575 // We pre-format some fields for proper output.
576 foreach ($linkdates as $linkdate) { 576 foreach ($linkdates as $linkdate) {
577 $l = $LINKSDB[$linkdate]; 577 $l = $LINKSDB[$linkdate];
578 $l['formatedDescription'] = format_description($l['description'], $conf->get('redirector')); 578 $l['formatedDescription'] = format_description($l['description'], $conf->get('extras.redirector'));
579 $l['thumbnail'] = thumbnail($l['url']); 579 $l['thumbnail'] = thumbnail($l['url']);
580 $l_date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $l['linkdate']); 580 $l_date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $l['linkdate']);
581 $l['timestamp'] = $l_date->getTimestamp(); 581 $l['timestamp'] = $l_date->getTimestamp();
@@ -587,11 +587,12 @@ function showDailyRSS() {
587 587
588 // Then build the HTML for this day: 588 // Then build the HTML for this day:
589 $tpl = new RainTPL; 589 $tpl = new RainTPL;
590 $tpl->assign('title', $conf->get('title')); 590 $tpl->assign('title', $conf->get('general.title'));
591 $tpl->assign('daydate', $dayDate->getTimestamp()); 591 $tpl->assign('daydate', $dayDate->getTimestamp());
592 $tpl->assign('absurl', $absurl); 592 $tpl->assign('absurl', $absurl);
593 $tpl->assign('links', $links); 593 $tpl->assign('links', $links);
594 $tpl->assign('rssdate', escape($dayDate->format(DateTime::RSS))); 594 $tpl->assign('rssdate', escape($dayDate->format(DateTime::RSS)));
595 $tpl->assign('hide_timestamps', $conf->get('extras.hide_timestamps', false));
595 $html = $tpl->draw('dailyrss', $return_string=true); 596 $html = $tpl->draw('dailyrss', $return_string=true);
596 597
597 echo $html . PHP_EOL; 598 echo $html . PHP_EOL;
@@ -640,7 +641,7 @@ function showDaily($pageBuilder, $LINKSDB)
640 $taglist = explode(' ',$link['tags']); 641 $taglist = explode(' ',$link['tags']);
641 uasort($taglist, 'strcasecmp'); 642 uasort($taglist, 'strcasecmp');
642 $linksToDisplay[$key]['taglist']=$taglist; 643 $linksToDisplay[$key]['taglist']=$taglist;
643 $linksToDisplay[$key]['formatedDescription'] = format_description($link['description'], $conf->get('redirector')); 644 $linksToDisplay[$key]['formatedDescription'] = format_description($link['description'], $conf->get('extras.redirector'));
644 $linksToDisplay[$key]['thumbnail'] = thumbnail($link['url']); 645 $linksToDisplay[$key]['thumbnail'] = thumbnail($link['url']);
645 $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); 646 $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']);
646 $linksToDisplay[$key]['timestamp'] = $date->getTimestamp(); 647 $linksToDisplay[$key]['timestamp'] = $date->getTimestamp();
@@ -700,15 +701,15 @@ function renderPage()
700{ 701{
701 $conf = ConfigManager::getInstance(); 702 $conf = ConfigManager::getInstance();
702 $LINKSDB = new LinkDB( 703 $LINKSDB = new LinkDB(
703 $conf->get('config.DATASTORE'), 704 $conf->get('path.datastore'),
704 isLoggedIn(), 705 isLoggedIn(),
705 $conf->get('config.HIDE_PUBLIC_LINKS'), 706 $conf->get('extras.hide_public_links'),
706 $conf->get('redirector'), 707 $conf->get('extras.redirector'),
707 $conf->get('config.REDIRECTOR_URLENCODE') 708 $conf->get('extras.redirector_encode_url')
708 ); 709 );
709 710
710 $updater = new Updater( 711 $updater = new Updater(
711 read_updates_file($conf->get('config.UPDATES_FILE')), 712 read_updates_file($conf->get('path.updates')),
712 $LINKSDB, 713 $LINKSDB,
713 isLoggedIn() 714 isLoggedIn()
714 ); 715 );
@@ -716,7 +717,7 @@ function renderPage()
716 $newUpdates = $updater->update(); 717 $newUpdates = $updater->update();
717 if (! empty($newUpdates)) { 718 if (! empty($newUpdates)) {
718 write_updates_file( 719 write_updates_file(
719 $conf->get('config.UPDATES_FILE'), 720 $conf->get('path.updates'),
720 $updater->getDoneUpdates() 721 $updater->getDoneUpdates()
721 ); 722 );
722 } 723 }
@@ -755,7 +756,7 @@ function renderPage()
755 // -------- Display login form. 756 // -------- Display login form.
756 if ($targetPage == Router::$PAGE_LOGIN) 757 if ($targetPage == Router::$PAGE_LOGIN)
757 { 758 {
758 if ($conf->get('config.OPEN_SHAARLI')) { header('Location: ?'); exit; } // No need to login for open Shaarli 759 if ($conf->get('extras.open_shaarli')) { header('Location: ?'); exit; } // No need to login for open Shaarli
759 $token=''; if (ban_canLogin()) $token=getToken(); // Do not waste token generation if not useful. 760 $token=''; if (ban_canLogin()) $token=getToken(); // Do not waste token generation if not useful.
760 $PAGE->assign('token',$token); 761 $PAGE->assign('token',$token);
761 if (isset($_GET['username'])) { 762 if (isset($_GET['username'])) {
@@ -768,7 +769,7 @@ function renderPage()
768 // -------- User wants to logout. 769 // -------- User wants to logout.
769 if (isset($_SERVER['QUERY_STRING']) && startsWith($_SERVER['QUERY_STRING'], 'do=logout')) 770 if (isset($_SERVER['QUERY_STRING']) && startsWith($_SERVER['QUERY_STRING'], 'do=logout'))
770 { 771 {
771 invalidateCaches($conf->get('config.PAGECACHE')); 772 invalidateCaches($conf->get('path.page_cache'));
772 logout(); 773 logout();
773 header('Location: ?'); 774 header('Location: ?');
774 exit; 775 exit;
@@ -868,7 +869,7 @@ function renderPage()
868 // Cache system 869 // Cache system
869 $query = $_SERVER['QUERY_STRING']; 870 $query = $_SERVER['QUERY_STRING'];
870 $cache = new CachedPage( 871 $cache = new CachedPage(
871 $conf->get('config.PAGECACHE'), 872 $conf->get('path.page_cache'),
872 page_url($_SERVER), 873 page_url($_SERVER),
873 startsWith($query,'do='. $targetPage) && !isLoggedIn() 874 startsWith($query,'do='. $targetPage) && !isLoggedIn()
874 ); 875 );
@@ -881,8 +882,8 @@ function renderPage()
881 // Generate data. 882 // Generate data.
882 $feedGenerator = new FeedBuilder($LINKSDB, $feedType, $_SERVER, $_GET, isLoggedIn()); 883 $feedGenerator = new FeedBuilder($LINKSDB, $feedType, $_SERVER, $_GET, isLoggedIn());
883 $feedGenerator->setLocale(strtolower(setlocale(LC_COLLATE, 0))); 884 $feedGenerator->setLocale(strtolower(setlocale(LC_COLLATE, 0)));
884 $feedGenerator->setHideDates($conf->get('config.HIDE_TIMESTAMPS') && !isLoggedIn()); 885 $feedGenerator->setHideDates($conf->get('extras.hide_timestamps') && !isLoggedIn());
885 $feedGenerator->setUsePermalinks(isset($_GET['permalinks']) || !$conf->get('config.ENABLE_RSS_PERMALINKS')); 886 $feedGenerator->setUsePermalinks(isset($_GET['permalinks']) || !$conf->get('general.rss_permalinks'));
886 $pshUrl = $conf->get('config.PUBSUBHUB_URL'); 887 $pshUrl = $conf->get('config.PUBSUBHUB_URL');
887 if (!empty($pshUrl)) { 888 if (!empty($pshUrl)) {
888 $feedGenerator->setPubsubhubUrl($pshUrl); 889 $feedGenerator->setPubsubhubUrl($pshUrl);
@@ -1046,7 +1047,7 @@ function renderPage()
1046 // -------- User wants to change his/her password. 1047 // -------- User wants to change his/her password.
1047 if ($targetPage == Router::$PAGE_CHANGEPASSWORD) 1048 if ($targetPage == Router::$PAGE_CHANGEPASSWORD)
1048 { 1049 {
1049 if ($conf->get('config.OPEN_SHAARLI')) { 1050 if ($conf->get('extras.open_shaarli')) {
1050 die('You are not supposed to change a password on an Open Shaarli.'); 1051 die('You are not supposed to change a password on an Open Shaarli.');
1051 } 1052 }
1052 1053
@@ -1055,12 +1056,12 @@ function renderPage()
1055 if (!tokenOk($_POST['token'])) die('Wrong token.'); // Go away! 1056 if (!tokenOk($_POST['token'])) die('Wrong token.'); // Go away!
1056 1057
1057 // Make sure old password is correct. 1058 // Make sure old password is correct.
1058 $oldhash = sha1($_POST['oldpassword'].$conf->get('login').$conf->get('salt')); 1059 $oldhash = sha1($_POST['oldpassword'].$conf->get('credentials.login').$conf->get('credentials.salt'));
1059 if ($oldhash!= $conf->get('hash')) { echo '<script>alert("The old password is not correct.");document.location=\'?do=changepasswd\';</script>'; exit; } 1060 if ($oldhash!= $conf->get('credentials.hash')) { echo '<script>alert("The old password is not correct.");document.location=\'?do=changepasswd\';</script>'; exit; }
1060 // Save new password 1061 // Save new password
1061 // Salt renders rainbow-tables attacks useless. 1062 // Salt renders rainbow-tables attacks useless.
1062 $conf->set('salt', sha1(uniqid('', true) .'_'. mt_rand())); 1063 $conf->set('credentials.salt', sha1(uniqid('', true) .'_'. mt_rand()));
1063 $conf->set('hash', sha1($_POST['setpassword'] . $conf->get('login') . $conf->get('salt'))); 1064 $conf->set('credentials.hash', sha1($_POST['setpassword'] . $conf->get('credentials.login') . $conf->get('credentials.salt')));
1064 try { 1065 try {
1065 $conf->write(isLoggedIn()); 1066 $conf->write(isLoggedIn());
1066 } 1067 }
@@ -1099,15 +1100,15 @@ function renderPage()
1099 ) { 1100 ) {
1100 $tz = $_POST['continent'] . '/' . $_POST['city']; 1101 $tz = $_POST['continent'] . '/' . $_POST['city'];
1101 } 1102 }
1102 $conf->set('timezone', $tz); 1103 $conf->set('general.timezone', $tz);
1103 $conf->set('title', $_POST['title']); 1104 $conf->set('general.title', $_POST['title']);
1104 $conf->set('titleLink', $_POST['titleLink']); 1105 $conf->set('general.header_link', $_POST['titleLink']);
1105 $conf->set('redirector', $_POST['redirector']); 1106 $conf->set('extras.redirector', $_POST['redirector']);
1106 $conf->set('disablesessionprotection', !empty($_POST['disablesessionprotection'])); 1107 $conf->set('security.session_protection_disabled', !empty($_POST['disablesessionprotection']));
1107 $conf->set('privateLinkByDefault', !empty($_POST['privateLinkByDefault'])); 1108 $conf->set('general.default_private_links', !empty($_POST['privateLinkByDefault']));
1108 $conf->set('config.ENABLE_RSS_PERMALINKS', !empty($_POST['enableRssPermalinks'])); 1109 $conf->set('general.rss_permalinks', !empty($_POST['enableRssPermalinks']));
1109 $conf->set('config.ENABLE_UPDATECHECK', !empty($_POST['updateCheck'])); 1110 $conf->set('general.check_updates', !empty($_POST['updateCheck']));
1110 $conf->set('config.HIDE_PUBLIC_LINKS', !empty($_POST['hidePublicLinks'])); 1111 $conf->set('extras.hide_public_links', !empty($_POST['hidePublicLinks']));
1111 try { 1112 try {
1112 $conf->write(isLoggedIn()); 1113 $conf->write(isLoggedIn());
1113 } 1114 }
@@ -1127,15 +1128,15 @@ function renderPage()
1127 else // Show the configuration form. 1128 else // Show the configuration form.
1128 { 1129 {
1129 $PAGE->assign('token',getToken()); 1130 $PAGE->assign('token',getToken());
1130 $PAGE->assign('title', $conf->get('title')); 1131 $PAGE->assign('title', $conf->get('general.title'));
1131 $PAGE->assign('redirector', $conf->get('redirector')); 1132 $PAGE->assign('redirector', $conf->get('extras.redirector'));
1132 list($timezone_form, $timezone_js) = generateTimeZoneForm($conf->get('timezone')); 1133 list($timezone_form, $timezone_js) = generateTimeZoneForm($conf->get('general.timezone'));
1133 $PAGE->assign('timezone_form', $timezone_form); 1134 $PAGE->assign('timezone_form', $timezone_form);
1134 $PAGE->assign('timezone_js',$timezone_js); 1135 $PAGE->assign('timezone_js',$timezone_js);
1135 $PAGE->assign('private_links_default', $conf->get('privateLinkByDefault')); 1136 $PAGE->assign('private_links_default', $conf->get('general.default_private_links', false));
1136 $PAGE->assign('enable_rss_permalinks', $conf->get('config.ENABLE_RSS_PERMALINKS')); 1137 $PAGE->assign('enable_rss_permalinks', $conf->get('general.rss_permalinks', false));
1137 $PAGE->assign('enable_update_check', $conf->get('config.ENABLE_UPDATECHECK')); 1138 $PAGE->assign('enable_update_check', $conf->get('general.check_updates', true));
1138 $PAGE->assign('hide_public_links', $conf->get('config.HIDE_PUBLIC_LINKS')); 1139 $PAGE->assign('hide_public_links', $conf->get('extras.hide_public_links', false));
1139 $PAGE->renderPage('configure'); 1140 $PAGE->renderPage('configure');
1140 exit; 1141 exit;
1141 } 1142 }
@@ -1167,7 +1168,7 @@ function renderPage()
1167 $value['tags']=trim(implode(' ',$tags)); 1168 $value['tags']=trim(implode(' ',$tags));
1168 $LINKSDB[$key]=$value; 1169 $LINKSDB[$key]=$value;
1169 } 1170 }
1170 $LINKSDB->savedb($conf->get('config.PAGECACHE')); 1171 $LINKSDB->savedb($conf->get('path.page_cache'));
1171 echo '<script>alert("Tag was removed from '.count($linksToAlter).' links.");document.location=\'?\';</script>'; 1172 echo '<script>alert("Tag was removed from '.count($linksToAlter).' links.");document.location=\'?\';</script>';
1172 exit; 1173 exit;
1173 } 1174 }
@@ -1184,7 +1185,7 @@ function renderPage()
1184 $value['tags']=trim(implode(' ',$tags)); 1185 $value['tags']=trim(implode(' ',$tags));
1185 $LINKSDB[$key]=$value; 1186 $LINKSDB[$key]=$value;
1186 } 1187 }
1187 $LINKSDB->savedb($conf->get('config.PAGECACHE')); // Save to disk. 1188 $LINKSDB->savedb($conf->get('path.page_cache')); // Save to disk.
1188 echo '<script>alert("Tag was renamed in '.count($linksToAlter).' links.");document.location=\'?searchtags='.urlencode($_POST['totag']).'\';</script>'; 1189 echo '<script>alert("Tag was renamed in '.count($linksToAlter).' links.");document.location=\'?searchtags='.urlencode($_POST['totag']).'\';</script>';
1189 exit; 1190 exit;
1190 } 1191 }
@@ -1235,7 +1236,7 @@ function renderPage()
1235 $pluginManager->executeHooks('save_link', $link); 1236 $pluginManager->executeHooks('save_link', $link);
1236 1237
1237 $LINKSDB[$linkdate] = $link; 1238 $LINKSDB[$linkdate] = $link;
1238 $LINKSDB->savedb($conf->get('config.PAGECACHE')); 1239 $LINKSDB->savedb($conf->get('path.page_cache'));
1239 pubsubhub(); 1240 pubsubhub();
1240 1241
1241 // If we are called from the bookmarklet, we must close the popup: 1242 // If we are called from the bookmarklet, we must close the popup:
@@ -1277,7 +1278,7 @@ function renderPage()
1277 $pluginManager->executeHooks('delete_link', $LINKSDB[$linkdate]); 1278 $pluginManager->executeHooks('delete_link', $LINKSDB[$linkdate]);
1278 1279
1279 unset($LINKSDB[$linkdate]); 1280 unset($LINKSDB[$linkdate]);
1280 $LINKSDB->savedb('config.PAGECACHE'); // save to disk 1281 $LINKSDB->savedb('path.page_cache'); // save to disk
1281 1282
1282 // If we are called from the bookmarklet, we must close the popup: 1283 // If we are called from the bookmarklet, we must close the popup:
1283 if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { echo '<script>self.close();</script>'; exit; } 1284 if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { echo '<script>self.close();</script>'; exit; }
@@ -1391,6 +1392,7 @@ function renderPage()
1391 'http_referer' => (isset($_SERVER['HTTP_REFERER']) ? escape($_SERVER['HTTP_REFERER']) : ''), 1392 'http_referer' => (isset($_SERVER['HTTP_REFERER']) ? escape($_SERVER['HTTP_REFERER']) : ''),
1392 'source' => (isset($_GET['source']) ? $_GET['source'] : ''), 1393 'source' => (isset($_GET['source']) ? $_GET['source'] : ''),
1393 'tags' => $LINKSDB->allTags(), 1394 'tags' => $LINKSDB->allTags(),
1395 'default_private_links' => $conf->get('default_private_links', false),
1394 ); 1396 );
1395 $pluginManager->executeHooks('render_editlink', $data); 1397 $pluginManager->executeHooks('render_editlink', $data);
1396 1398
@@ -1500,7 +1502,7 @@ function renderPage()
1500 } 1502 }
1501 } 1503 }
1502 else { 1504 else {
1503 $conf->set('config.ENABLED_PLUGINS', save_plugin_config($_POST)); 1505 $conf->set('general.enabled_plugins', save_plugin_config($_POST));
1504 } 1506 }
1505 $conf->write(isLoggedIn()); 1507 $conf->write(isLoggedIn());
1506 } 1508 }
@@ -1599,7 +1601,7 @@ function importFile($LINKSDB)
1599 } 1601 }
1600 } 1602 }
1601 } 1603 }
1602 $LINKSDB->savedb($conf->get('config.PAGECACHE')); 1604 $LINKSDB->savedb($conf->get('path.page_cache'));
1603 1605
1604 echo '<script>alert("File '.json_encode($filename).' ('.$filesize.' bytes) was successfully processed: '.$import_count.' links imported.");document.location=\'?\';</script>'; 1606 echo '<script>alert("File '.json_encode($filename).' ('.$filesize.' bytes) was successfully processed: '.$import_count.' links imported.");document.location=\'?\';</script>';
1605 } 1607 }
@@ -1646,7 +1648,7 @@ function buildLinkList($PAGE,$LINKSDB)
1646 1648
1647 // If there is only a single link, we change on-the-fly the title of the page. 1649 // If there is only a single link, we change on-the-fly the title of the page.
1648 if (count($linksToDisplay) == 1) { 1650 if (count($linksToDisplay) == 1) {
1649 $conf->set('pagetitle', $linksToDisplay[$keys[0]]['title'] .' - '. $conf->get('title')); 1651 $conf->set('pagetitle', $linksToDisplay[$keys[0]]['title'] .' - '. $conf->get('general.title'));
1650 } 1652 }
1651 1653
1652 // Select articles according to paging. 1654 // Select articles according to paging.
@@ -1662,7 +1664,7 @@ function buildLinkList($PAGE,$LINKSDB)
1662 while ($i<$end && $i<count($keys)) 1664 while ($i<$end && $i<count($keys))
1663 { 1665 {
1664 $link = $linksToDisplay[$keys[$i]]; 1666 $link = $linksToDisplay[$keys[$i]];
1665 $link['description'] = format_description($link['description'], $conf->get('redirector')); 1667 $link['description'] = format_description($link['description'], $conf->get('extras.redirector'));
1666 $classLi = ($i % 2) != 0 ? '' : 'publicLinkHightLight'; 1668 $classLi = ($i % 2) != 0 ? '' : 'publicLinkHightLight';
1667 $link['class'] = $link['private'] == 0 ? $classLi : 'private'; 1669 $link['class'] = $link['private'] == 0 ? $classLi : 'private';
1668 $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); 1670 $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']);
@@ -1704,7 +1706,7 @@ function buildLinkList($PAGE,$LINKSDB)
1704 'result_count' => count($linksToDisplay), 1706 'result_count' => count($linksToDisplay),
1705 'search_term' => $searchterm, 1707 'search_term' => $searchterm,
1706 'search_tags' => $searchtags, 1708 'search_tags' => $searchtags,
1707 'redirector' => $conf->get('redirector'), // Optional redirector URL. 1709 'redirector' => $conf->get('extras.redirector'), // Optional redirector URL.
1708 'token' => $token, 1710 'token' => $token,
1709 'links' => $linkDisp, 1711 'links' => $linkDisp,
1710 'tags' => $LINKSDB->allTags(), 1712 'tags' => $LINKSDB->allTags(),
@@ -1736,7 +1738,7 @@ function buildLinkList($PAGE,$LINKSDB)
1736function computeThumbnail($url,$href=false) 1738function computeThumbnail($url,$href=false)
1737{ 1739{
1738 $conf = ConfigManager::getInstance(); 1740 $conf = ConfigManager::getInstance();
1739 if (!$conf->get('config.ENABLE_THUMBNAILS')) return array(); 1741 if (!$conf->get('general.enable_thumbnails')) return array();
1740 if ($href==false) $href=$url; 1742 if ($href==false) $href=$url;
1741 1743
1742 // For most hosts, the URL of the thumbnail can be easily deduced from the URL of the link. 1744 // For most hosts, the URL of the thumbnail can be easily deduced from the URL of the link.
@@ -1804,7 +1806,7 @@ function computeThumbnail($url,$href=false)
1804 // So we deport the thumbnail generation in order not to slow down page generation 1806 // So we deport the thumbnail generation in order not to slow down page generation
1805 // (and we also cache the thumbnail) 1807 // (and we also cache the thumbnail)
1806 1808
1807 if (! $conf->get('config.ENABLE_LOCALCACHE')) return array(); // If local cache is disabled, no thumbnails for services which require the use a local cache. 1809 if (! $conf->get('general.enable_localcache')) return array(); // If local cache is disabled, no thumbnails for services which require the use a local cache.
1808 1810
1809 if ($domain=='flickr.com' || endsWith($domain,'.flickr.com') 1811 if ($domain=='flickr.com' || endsWith($domain,'.flickr.com')
1810 || $domain=='vimeo.com' 1812 || $domain=='vimeo.com'
@@ -1827,7 +1829,7 @@ function computeThumbnail($url,$href=false)
1827 $path = parse_url($url,PHP_URL_PATH); 1829 $path = parse_url($url,PHP_URL_PATH);
1828 if ("/talks/" !== substr($path,0,7)) return array(); // This is not a single video URL. 1830 if ("/talks/" !== substr($path,0,7)) return array(); // This is not a single video URL.
1829 } 1831 }
1830 $sign = hash_hmac('sha256', $url, $conf->get('salt')); // We use the salt to sign data (it's random, secret, and specific to each installation) 1832 $sign = hash_hmac('sha256', $url, $conf->get('credentials.salt')); // We use the salt to sign data (it's random, secret, and specific to each installation)
1831 return array('src'=>index_url($_SERVER).'?do=genthumbnail&hmac='.$sign.'&url='.urlencode($url), 1833 return array('src'=>index_url($_SERVER).'?do=genthumbnail&hmac='.$sign.'&url='.urlencode($url),
1832 'href'=>$href,'width'=>'120','style'=>'height:auto;','alt'=>'thumbnail'); 1834 'href'=>$href,'width'=>'120','style'=>'height:auto;','alt'=>'thumbnail');
1833 } 1835 }
@@ -1838,7 +1840,7 @@ function computeThumbnail($url,$href=false)
1838 $ext=strtolower(pathinfo($url,PATHINFO_EXTENSION)); 1840 $ext=strtolower(pathinfo($url,PATHINFO_EXTENSION));
1839 if ($ext=='jpg' || $ext=='jpeg' || $ext=='png' || $ext=='gif') 1841 if ($ext=='jpg' || $ext=='jpeg' || $ext=='png' || $ext=='gif')
1840 { 1842 {
1841 $sign = hash_hmac('sha256', $url, $conf->get('salt')); // We use the salt to sign data (it's random, secret, and specific to each installation) 1843 $sign = hash_hmac('sha256', $url, $conf->get('credentials.salt')); // We use the salt to sign data (it's random, secret, and specific to each installation)
1842 return array('src'=>index_url($_SERVER).'?do=genthumbnail&hmac='.$sign.'&url='.urlencode($url), 1844 return array('src'=>index_url($_SERVER).'?do=genthumbnail&hmac='.$sign.'&url='.urlencode($url),
1843 'href'=>$href,'width'=>'120','style'=>'height:auto;','alt'=>'thumbnail'); 1845 'href'=>$href,'width'=>'120','style'=>'height:auto;','alt'=>'thumbnail');
1844 } 1846 }
@@ -1942,18 +1944,18 @@ function install()
1942 ) { 1944 ) {
1943 $tz = $_POST['continent'].'/'.$_POST['city']; 1945 $tz = $_POST['continent'].'/'.$_POST['city'];
1944 } 1946 }
1945 $conf->set('timezone', $tz); 1947 $conf->set('general.timezone', $tz);
1946 $login = $_POST['setlogin']; 1948 $login = $_POST['setlogin'];
1947 $conf->set('login', $login); 1949 $conf->set('credentials.login', $login);
1948 $salt = sha1(uniqid('', true) .'_'. mt_rand()); 1950 $salt = sha1(uniqid('', true) .'_'. mt_rand());
1949 $conf->set('salt', $salt); 1951 $conf->set('credentials.salt', $salt);
1950 $conf->set('hash', sha1($_POST['setpassword'] . $login . $salt)); 1952 $conf->set('credentials.hash', sha1($_POST['setpassword'] . $login . $salt));
1951 if (!empty($_POST['title'])) { 1953 if (!empty($_POST['title'])) {
1952 $conf->set('title', $_POST['title']); 1954 $conf->set('general.title', $_POST['title']);
1953 } else { 1955 } else {
1954 $conf->set('title', 'Shared links on '.escape(index_url($_SERVER))); 1956 $conf->set('general.title', 'Shared links on '.escape(index_url($_SERVER)));
1955 } 1957 }
1956 $conf->set('config.ENABLE_UPDATECHECK', !empty($_POST['updateCheck'])); 1958 $conf->set('general.check_updates', !empty($_POST['updateCheck']));
1957 try { 1959 try {
1958 // Everything is ok, let's create config file. 1960 // Everything is ok, let's create config file.
1959 $conf->write(isLoggedIn()); 1961 $conf->write(isLoggedIn());
@@ -1999,10 +2001,10 @@ function genThumbnail()
1999{ 2001{
2000 $conf = ConfigManager::getInstance(); 2002 $conf = ConfigManager::getInstance();
2001 // Make sure the parameters in the URL were generated by us. 2003 // Make sure the parameters in the URL were generated by us.
2002 $sign = hash_hmac('sha256', $_GET['url'], $conf->get('salt')); 2004 $sign = hash_hmac('sha256', $_GET['url'], $conf->get('credentials.salt'));
2003 if ($sign!=$_GET['hmac']) die('Naughty boy!'); 2005 if ($sign!=$_GET['hmac']) die('Naughty boy!');
2004 2006
2005 $cacheDir = $conf->get('config.CACHEDIR', 'cache'); 2007 $cacheDir = $conf->get('path.thumbnails_cache', 'cache');
2006 // Let's see if we don't already have the image for this URL in the cache. 2008 // Let's see if we don't already have the image for this URL in the cache.
2007 $thumbname=hash('sha1',$_GET['url']).'.jpg'; 2009 $thumbname=hash('sha1',$_GET['url']).'.jpg';
2008 if (is_file($cacheDir .'/'. $thumbname)) 2010 if (is_file($cacheDir .'/'. $thumbname))
@@ -2212,7 +2214,7 @@ function resizeImage($filepath)
2212if (isset($_SERVER['QUERY_STRING']) && startsWith($_SERVER['QUERY_STRING'], 'do=genthumbnail')) { genThumbnail(); exit; } // Thumbnail generation/cache does not need the link database. 2214if (isset($_SERVER['QUERY_STRING']) && startsWith($_SERVER['QUERY_STRING'], 'do=genthumbnail')) { genThumbnail(); exit; } // Thumbnail generation/cache does not need the link database.
2213if (isset($_SERVER['QUERY_STRING']) && startsWith($_SERVER['QUERY_STRING'], 'do=dailyrss')) { showDailyRSS(); exit; } 2215if (isset($_SERVER['QUERY_STRING']) && startsWith($_SERVER['QUERY_STRING'], 'do=dailyrss')) { showDailyRSS(); exit; }
2214if (!isset($_SESSION['LINKS_PER_PAGE'])) { 2216if (!isset($_SESSION['LINKS_PER_PAGE'])) {
2215 $_SESSION['LINKS_PER_PAGE'] = $conf->get('config.LINKS_PER_PAGE', 20); 2217 $_SESSION['LINKS_PER_PAGE'] = $conf->get('general.links_per_page', 20);
2216} 2218}
2217renderPage(); 2219renderPage();
2218?> 2220?>
diff --git a/tests/ApplicationUtilsTest.php b/tests/ApplicationUtilsTest.php
index cf82b655..f92412ba 100644
--- a/tests/ApplicationUtilsTest.php
+++ b/tests/ApplicationUtilsTest.php
@@ -277,16 +277,16 @@ class ApplicationUtilsTest extends PHPUnit_Framework_TestCase
277 public function testCheckCurrentResourcePermissions() 277 public function testCheckCurrentResourcePermissions()
278 { 278 {
279 $conf = ConfigManager::getInstance(); 279 $conf = ConfigManager::getInstance();
280 $conf->set('config.CACHEDIR', 'cache'); 280 $conf->set('path.thumbnails_cache', 'cache');
281 $conf->set('config.CONFIG_FILE', 'data/config.php'); 281 $conf->set('path.config', 'data/config.php');
282 $conf->set('config.DATADIR', 'data'); 282 $conf->set('path.data_dir', 'data');
283 $conf->set('config.DATASTORE', 'data/datastore.php'); 283 $conf->set('path.datastore', 'data/datastore.php');
284 $conf->set('config.IPBANS_FILENAME', 'data/ipbans.php'); 284 $conf->set('path.ban_file', 'data/ipbans.php');
285 $conf->set('config.LOG_FILE', 'data/log.txt'); 285 $conf->set('path.log', 'data/log.txt');
286 $conf->set('config.PAGECACHE', 'pagecache'); 286 $conf->set('path.page_cache', 'pagecache');
287 $conf->set('config.RAINTPL_TMP', 'tmp'); 287 $conf->set('path.raintpl_tmp', 'tmp');
288 $conf->set('config.RAINTPL_TPL', 'tpl'); 288 $conf->set('path.raintpl_tpl', 'tpl');
289 $conf->set('config.UPDATECHECK_FILENAME', 'data/lastupdatecheck.txt'); 289 $conf->set('path.update_check', 'data/lastupdatecheck.txt');
290 290
291 $this->assertEquals( 291 $this->assertEquals(
292 array(), 292 array(),
@@ -300,16 +300,16 @@ class ApplicationUtilsTest extends PHPUnit_Framework_TestCase
300 public function testCheckCurrentResourcePermissionsErrors() 300 public function testCheckCurrentResourcePermissionsErrors()
301 { 301 {
302 $conf = ConfigManager::getInstance(); 302 $conf = ConfigManager::getInstance();
303 $conf->set('config.CACHEDIR', 'null/cache'); 303 $conf->set('path.thumbnails_cache', 'null/cache');
304 $conf->set('config.CONFIG_FILE', 'null/data/config.php'); 304 $conf->set('path.config', 'null/data/config.php');
305 $conf->set('config.DATADIR', 'null/data'); 305 $conf->set('path.data_dir', 'null/data');
306 $conf->set('config.DATASTORE', 'null/data/store.php'); 306 $conf->set('path.datastore', 'null/data/store.php');
307 $conf->set('config.IPBANS_FILENAME', 'null/data/ipbans.php'); 307 $conf->set('path.ban_file', 'null/data/ipbans.php');
308 $conf->set('config.LOG_FILE', 'null/data/log.txt'); 308 $conf->set('path.log', 'null/data/log.txt');
309 $conf->set('config.PAGECACHE', 'null/pagecache'); 309 $conf->set('path.page_cache', 'null/pagecache');
310 $conf->set('config.RAINTPL_TMP', 'null/tmp'); 310 $conf->set('path.raintpl_tmp', 'null/tmp');
311 $conf->set('config.RAINTPL_TPL', 'null/tpl'); 311 $conf->set('path.raintpl_tpl', 'null/tpl');
312 $conf->set('config.UPDATECHECK_FILENAME', 'null/data/lastupdatecheck.txt'); 312 $conf->set('path.update_check', 'null/data/lastupdatecheck.txt');
313 $this->assertEquals( 313 $this->assertEquals(
314 array( 314 array(
315 '"null/tpl" directory is not readable', 315 '"null/tpl" directory is not readable',
diff --git a/tests/Updater/UpdaterTest.php b/tests/Updater/UpdaterTest.php
index f8de2f70..04883a46 100644
--- a/tests/Updater/UpdaterTest.php
+++ b/tests/Updater/UpdaterTest.php
@@ -10,11 +10,6 @@ require_once 'tests/Updater/DummyUpdater.php';
10class UpdaterTest extends PHPUnit_Framework_TestCase 10class UpdaterTest extends PHPUnit_Framework_TestCase
11{ 11{
12 /** 12 /**
13 * @var array Configuration input set.
14 */
15 private static $configFields;
16
17 /**
18 * @var string Path to test datastore. 13 * @var string Path to test datastore.
19 */ 14 */
20 protected static $testDatastore = 'sandbox/datastore.php'; 15 protected static $testDatastore = 'sandbox/datastore.php';
@@ -22,7 +17,7 @@ class UpdaterTest extends PHPUnit_Framework_TestCase
22 /** 17 /**
23 * @var string Config file path (without extension). 18 * @var string Config file path (without extension).
24 */ 19 */
25 protected static $configFile = 'tests/utils/config/configUpdater'; 20 protected static $configFile = 'tests/utils/config/configJson';
26 21
27 /** 22 /**
28 * @var ConfigManager 23 * @var ConfigManager
@@ -34,51 +29,8 @@ class UpdaterTest extends PHPUnit_Framework_TestCase
34 */ 29 */
35 public function setUp() 30 public function setUp()
36 { 31 {
37 self::$configFields = array(
38 'login' => 'login',
39 'hash' => 'hash',
40 'salt' => 'salt',
41 'timezone' => 'Europe/Paris',
42 'title' => 'title',
43 'titleLink' => 'titleLink',
44 'redirector' => '',
45 'disablesessionprotection' => false,
46 'privateLinkByDefault' => false,
47 'config' => array(
48 'DATADIR' => 'tests/Updater',
49 'PAGECACHE' => 'sandbox/pagecache',
50 'config1' => 'config1data',
51 'config2' => 'config2data',
52 )
53 );
54
55 ConfigManager::$CONFIG_FILE = self::$configFile; 32 ConfigManager::$CONFIG_FILE = self::$configFile;
56 $this->conf = ConfigManager::reset(); 33 $this->conf = ConfigManager::reset();
57 $this->conf->reload();
58 foreach (self::$configFields as $key => $value) {
59 $this->conf->set($key, $value);
60 }
61 $this->conf->write(true);
62 }
63
64 /**
65 * Executed after each test.
66 *
67 * @return void
68 */
69 public function tearDown()
70 {
71 if (is_file('tests/Updater/config.json')) {
72 unlink('tests/Updater/config.json');
73 }
74
75 if (is_file(self::$configFields['config']['DATADIR'] . '/options.php')) {
76 unlink(self::$configFields['config']['DATADIR'] . '/options.php');
77 }
78
79 if (is_file(self::$configFields['config']['DATADIR'] . '/updates.txt')) {
80 unlink(self::$configFields['config']['DATADIR'] . '/updates.txt');
81 }
82 } 34 }
83 35
84 /** 36 /**
@@ -87,9 +39,10 @@ class UpdaterTest extends PHPUnit_Framework_TestCase
87 public function testReadEmptyUpdatesFile() 39 public function testReadEmptyUpdatesFile()
88 { 40 {
89 $this->assertEquals(array(), read_updates_file('')); 41 $this->assertEquals(array(), read_updates_file(''));
90 $updatesFile = self::$configFields['config']['DATADIR'] . '/updates.txt'; 42 $updatesFile = $this->conf->get('path.data_dir') . '/updates.txt';
91 touch($updatesFile); 43 touch($updatesFile);
92 $this->assertEquals(array(), read_updates_file($updatesFile)); 44 $this->assertEquals(array(), read_updates_file($updatesFile));
45 unlink($updatesFile);
93 } 46 }
94 47
95 /** 48 /**
@@ -97,7 +50,7 @@ class UpdaterTest extends PHPUnit_Framework_TestCase
97 */ 50 */
98 public function testReadWriteUpdatesFile() 51 public function testReadWriteUpdatesFile()
99 { 52 {
100 $updatesFile = self::$configFields['config']['DATADIR'] . '/updates.txt'; 53 $updatesFile = $this->conf->get('path.data_dir') . '/updates.txt';
101 $updatesMethods = array('m1', 'm2', 'm3'); 54 $updatesMethods = array('m1', 'm2', 'm3');
102 55
103 write_updates_file($updatesFile, $updatesMethods); 56 write_updates_file($updatesFile, $updatesMethods);
@@ -109,6 +62,7 @@ class UpdaterTest extends PHPUnit_Framework_TestCase
109 write_updates_file($updatesFile, $updatesMethods); 62 write_updates_file($updatesFile, $updatesMethods);
110 $readMethods = read_updates_file($updatesFile); 63 $readMethods = read_updates_file($updatesFile);
111 $this->assertEquals($readMethods, $updatesMethods); 64 $this->assertEquals($readMethods, $updatesMethods);
65 unlink($updatesFile);
112 } 66 }
113 67
114 /** 68 /**
@@ -130,10 +84,15 @@ class UpdaterTest extends PHPUnit_Framework_TestCase
130 */ 84 */
131 public function testWriteUpdatesFileNotWritable() 85 public function testWriteUpdatesFileNotWritable()
132 { 86 {
133 $updatesFile = self::$configFields['config']['DATADIR'] . '/updates.txt'; 87 $updatesFile = $this->conf->get('path.data_dir') . '/updates.txt';
134 touch($updatesFile); 88 touch($updatesFile);
135 chmod($updatesFile, 0444); 89 chmod($updatesFile, 0444);
136 @write_updates_file($updatesFile, array('test')); 90 try {
91 @write_updates_file($updatesFile, array('test'));
92 } catch (Exception $e) {
93 unlink($updatesFile);
94 throw $e;
95 }
137 } 96 }
138 97
139 /** 98 /**
@@ -213,17 +172,15 @@ class UpdaterTest extends PHPUnit_Framework_TestCase
213 */ 172 */
214 public function testUpdateMergeDeprecatedConfig() 173 public function testUpdateMergeDeprecatedConfig()
215 { 174 {
216 // Use writeConfig to create a options.php 175 ConfigManager::$CONFIG_FILE = 'tests/utils/config/configPhp';
217 ConfigManager::$CONFIG_FILE = 'tests/Updater/options'; 176 $this->conf = $this->conf->reset();
218 $this->conf->setConfigIO(new ConfigPhp());
219
220 $invert = !$this->conf->get('privateLinkByDefault');
221 $this->conf->set('privateLinkByDefault', $invert);
222 $this->conf->write(true);
223 177
224 $optionsFile = 'tests/Updater/options.php'; 178 $optionsFile = 'tests/Updater/options.php';
225 $this->assertTrue(is_file($optionsFile)); 179 $options = '<?php
180$GLOBALS[\'privateLinkByDefault\'] = true;';
181 file_put_contents($optionsFile, $options);
226 182
183 // tmp config file.
227 ConfigManager::$CONFIG_FILE = 'tests/Updater/config'; 184 ConfigManager::$CONFIG_FILE = 'tests/Updater/config';
228 185
229 // merge configs 186 // merge configs
@@ -233,7 +190,7 @@ class UpdaterTest extends PHPUnit_Framework_TestCase
233 190
234 // make sure updated field is changed 191 // make sure updated field is changed
235 $this->conf->reload(); 192 $this->conf->reload();
236 $this->assertEquals($invert, $this->conf->get('privateLinkByDefault')); 193 $this->assertTrue($this->conf->get('general.default_private_links'));
237 $this->assertFalse(is_file($optionsFile)); 194 $this->assertFalse(is_file($optionsFile));
238 // Delete the generated file. 195 // Delete the generated file.
239 unlink($this->conf->getConfigFile()); 196 unlink($this->conf->getConfigFile());
@@ -247,7 +204,7 @@ class UpdaterTest extends PHPUnit_Framework_TestCase
247 $updater = new Updater(array(), array(), true); 204 $updater = new Updater(array(), array(), true);
248 $updater->updateMethodMergeDeprecatedConfigFile(); 205 $updater->updateMethodMergeDeprecatedConfigFile();
249 206
250 $this->assertEquals(self::$configFields['login'], $this->conf->get('login')); 207 $this->assertEquals('root', $this->conf->get('credentials.login'));
251 } 208 }
252 209
253 /** 210 /**
@@ -286,9 +243,9 @@ class UpdaterTest extends PHPUnit_Framework_TestCase
286 243
287 // Check JSON config data. 244 // Check JSON config data.
288 $conf->reload(); 245 $conf->reload();
289 $this->assertEquals('root', $conf->get('login')); 246 $this->assertEquals('root', $conf->get('credentials.login'));
290 $this->assertEquals('lala', $conf->get('redirector')); 247 $this->assertEquals('lala', $conf->get('extras.redirector'));
291 $this->assertEquals('data/datastore.php', $conf->get('config.DATASTORE')); 248 $this->assertEquals('data/datastore.php', $conf->get('path.datastore'));
292 $this->assertEquals('1', $conf->get('plugins.WALLABAG_VERSION')); 249 $this->assertEquals('1', $conf->get('plugins.WALLABAG_VERSION'));
293 250
294 rename($configFile . '.save.php', $configFile . '.php'); 251 rename($configFile . '.save.php', $configFile . '.php');
@@ -300,15 +257,11 @@ class UpdaterTest extends PHPUnit_Framework_TestCase
300 */ 257 */
301 public function testConfigToJsonNothingToDo() 258 public function testConfigToJsonNothingToDo()
302 { 259 {
303 $configFile = 'tests/utils/config/configUpdateDone'; 260 $filetime = filemtime($this->conf->getConfigFile());
304 ConfigManager::$CONFIG_FILE = $configFile;
305 $conf = ConfigManager::reset();
306 $conf->reload();
307 $filetime = filemtime($conf->getConfigFile());
308 $updater = new Updater(array(), array(), false); 261 $updater = new Updater(array(), array(), false);
309 $done = $updater->updateMethodConfigToJson(); 262 $done = $updater->updateMethodConfigToJson();
310 $this->assertTrue($done); 263 $this->assertTrue($done);
311 $expected = filemtime($conf->getConfigFile()); 264 $expected = filemtime($this->conf->getConfigFile());
312 $this->assertEquals($expected, $filetime); 265 $this->assertEquals($expected, $filetime);
313 } 266 }
314} 267}
diff --git a/tests/config/ConfigJsonTest.php b/tests/config/ConfigJsonTest.php
index 5b3bce46..0960c729 100644
--- a/tests/config/ConfigJsonTest.php
+++ b/tests/config/ConfigJsonTest.php
@@ -23,9 +23,9 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase
23 public function testRead() 23 public function testRead()
24 { 24 {
25 $conf = $this->configIO->read('tests/utils/config/configJson.json.php'); 25 $conf = $this->configIO->read('tests/utils/config/configJson.json.php');
26 $this->assertEquals('root', $conf['login']); 26 $this->assertEquals('root', $conf['credentials']['login']);
27 $this->assertEquals('lala', $conf['redirector']); 27 $this->assertEquals('lala', $conf['extras']['redirector']);
28 $this->assertEquals('data/datastore.php', $conf['config']['DATASTORE']); 28 $this->assertEquals('tests/utils/config/datastore.php', $conf['path']['datastore']);
29 $this->assertEquals('1', $conf['plugins']['WALLABAG_VERSION']); 29 $this->assertEquals('1', $conf['plugins']['WALLABAG_VERSION']);
30 } 30 }
31 31
@@ -55,10 +55,14 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase
55 { 55 {
56 $dataFile = 'tests/utils/config/configWrite.json.php'; 56 $dataFile = 'tests/utils/config/configWrite.json.php';
57 $data = array( 57 $data = array(
58 'login' => 'root', 58 'credentials' => array(
59 'redirector' => 'lala', 59 'login' => 'root',
60 'config' => array( 60 ),
61 'DATASTORE' => 'data/datastore.php', 61 'path' => array(
62 'datastore' => 'data/datastore.php',
63 ),
64 'extras' => array(
65 'redirector' => 'lala',
62 ), 66 ),
63 'plugins' => array( 67 'plugins' => array(
64 'WALLABAG_VERSION' => '1', 68 'WALLABAG_VERSION' => '1',
@@ -68,19 +72,23 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase
68 // PHP 5.3 doesn't support json pretty print. 72 // PHP 5.3 doesn't support json pretty print.
69 if (defined('JSON_PRETTY_PRINT')) { 73 if (defined('JSON_PRETTY_PRINT')) {
70 $expected = '{ 74 $expected = '{
71 "login": "root", 75 "credentials": {
72 "redirector": "lala", 76 "login": "root"
73 "config": { 77 },
74 "DATASTORE": "data\/datastore.php" 78 "path": {
79 "datastore": "data\/datastore.php"
80 },
81 "extras": {
82 "redirector": "lala"
75 }, 83 },
76 "plugins": { 84 "plugins": {
77 "WALLABAG_VERSION": "1" 85 "WALLABAG_VERSION": "1"
78 } 86 }
79}'; 87}';
80 } else { 88 } else {
81 $expected = '{"login":"root","redirector":"lala","config":{"DATASTORE":"data\/datastore.php"},"plugins":{"WALLABAG_VERSION":"1"}}'; 89 $expected = '{"credentials":{"login":"root"},"path":{"datastore":"data\/datastore.php"},"extras":{"redirector":"lala"},"plugins":{"WALLABAG_VERSION":"1"}}';
82 } 90 }
83 $expected = ConfigJson::$PHP_HEADER . $expected; 91 $expected = ConfigJson::getPhpHeaders() . $expected;
84 $this->assertEquals($expected, file_get_contents($dataFile)); 92 $this->assertEquals($expected, file_get_contents($dataFile));
85 unlink($dataFile); 93 unlink($dataFile);
86 } 94 }
@@ -94,10 +102,10 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase
94 $dest = 'tests/utils/config/configOverwrite.json.php'; 102 $dest = 'tests/utils/config/configOverwrite.json.php';
95 copy($source, $dest); 103 copy($source, $dest);
96 $conf = $this->configIO->read($dest); 104 $conf = $this->configIO->read($dest);
97 $conf['redirector'] = 'blabla'; 105 $conf['extras']['redirector'] = 'blabla';
98 $this->configIO->write($dest, $conf); 106 $this->configIO->write($dest, $conf);
99 $conf = $this->configIO->read($dest); 107 $conf = $this->configIO->read($dest);
100 $this->assertEquals('blabla', $conf['redirector']); 108 $this->assertEquals('blabla', $conf['extras']['redirector']);
101 unlink($dest); 109 unlink($dest);
102 } 110 }
103 111
diff --git a/tests/config/ConfigManagerTest.php b/tests/config/ConfigManagerTest.php
index 7390699c..9ff0f473 100644
--- a/tests/config/ConfigManagerTest.php
+++ b/tests/config/ConfigManagerTest.php
@@ -131,7 +131,7 @@ class ConfigManagerTest extends PHPUnit_Framework_TestCase
131 */ 131 */
132 public function testExistsOk() 132 public function testExistsOk()
133 { 133 {
134 $this->assertTrue($this->conf->exists('login')); 134 $this->assertTrue($this->conf->exists('credentials.login'));
135 $this->assertTrue($this->conf->exists('config.foo')); 135 $this->assertTrue($this->conf->exists('config.foo'));
136 } 136 }
137 137
@@ -163,12 +163,12 @@ class ConfigManagerTest extends PHPUnit_Framework_TestCase
163 public function testReload() 163 public function testReload()
164 { 164 {
165 ConfigManager::$CONFIG_FILE = 'tests/utils/config/configTmp'; 165 ConfigManager::$CONFIG_FILE = 'tests/utils/config/configTmp';
166 $newConf = ConfigJson::$PHP_HEADER . '{ "key": "value" }'; 166 $newConf = ConfigJson::getPhpHeaders() . '{ "key": "value" }';
167 file_put_contents($this->conf->getConfigFile(), $newConf); 167 file_put_contents($this->conf->getConfigFile(), $newConf);
168 $this->conf->reload(); 168 $this->conf->reload();
169 unlink($this->conf->getConfigFile()); 169 unlink($this->conf->getConfigFile());
170 // Previous conf no longer exists, and new values have been loaded. 170 // Previous conf no longer exists, and new values have been loaded.
171 $this->assertFalse($this->conf->exists('login')); 171 $this->assertFalse($this->conf->exists('credentials.login'));
172 $this->assertEquals('value', $this->conf->get('key')); 172 $this->assertEquals('value', $this->conf->get('key'));
173 } 173 }
174} 174}
diff --git a/tests/utils/config/configJson.json.php b/tests/utils/config/configJson.json.php
index 71b59edd..6a841f8a 100644
--- a/tests/utils/config/configJson.json.php
+++ b/tests/utils/config/configJson.json.php
@@ -1,17 +1,28 @@
1<?php /* 1<?php /*
2{ 2{
3 "redirector":"lala", 3 "credentials": {
4 "login":"root", 4 "login":"root",
5 "hash":"hash", 5 "hash":"hash",
6 "salt":"salt", 6 "salt":"salt"
7 "timezone":"Europe\/Paris", 7 },
8 "disablesessionprotection":false, 8 "security": {
9 "privateLinkByDefault":true, 9 "session_protection_disabled":false
10 "title": "Shaarli", 10 },
11 "titleLink": "?", 11 "general": {
12 "timezone":"Europe\/Paris",
13 "default_private_linksheader_link":true,
14 "title": "Shaarli",
15 "header_link": "?"
16 },
17 "extras": {
18 "redirector":"lala"
19 },
12 "config": { 20 "config": {
13 "foo": "bar", 21 "foo": "bar"
14 "DATASTORE": "data\/datastore.php" 22 },
23 "path": {
24 "datastore": "tests\/utils\/config\/datastore.php",
25 "data_dir": "tests\/utils\/config"
15 }, 26 },
16 "plugins": { 27 "plugins": {
17 "WALLABAG_VERSION": 1 28 "WALLABAG_VERSION": 1
diff --git a/tests/utils/config/configUpdateDone.json.php b/tests/utils/config/configUpdateDone.json.php
deleted file mode 100644
index a4e460d1..00000000
--- a/tests/utils/config/configUpdateDone.json.php
+++ /dev/null
@@ -1,4 +0,0 @@
1<?php /*
2{
3 "login": "root"
4}
diff --git a/tests/utils/config/configUpdater.php b/tests/utils/config/configUpdater.php
deleted file mode 100644
index ee4a56b5..00000000
--- a/tests/utils/config/configUpdater.php
+++ /dev/null
@@ -1,15 +0,0 @@
1<?php
2$GLOBALS['login'] = 'login';
3$GLOBALS['hash'] = 'hash';
4$GLOBALS['salt'] = 'salt';
5$GLOBALS['timezone'] = 'Europe/Paris';
6$GLOBALS['title'] = 'title';
7$GLOBALS['titleLink'] = 'titleLink';
8$GLOBALS['redirector'] = '';
9$GLOBALS['disablesessionprotection'] = false;
10$GLOBALS['privateLinkByDefault'] = false;
11$GLOBALS['config']['DATADIR'] = 'tests/Updater';
12$GLOBALS['config']['PAGECACHE'] = 'sandbox/pagecache';
13$GLOBALS['config']['config1'] = 'config1data';
14$GLOBALS['config']['config2'] = 'config2data';
15$GLOBALS['plugins']['WALLABAG_VERSION'] = '2';
diff --git a/tpl/configure.html b/tpl/configure.html
index f99fa45b..ad9a2085 100644
--- a/tpl/configure.html
+++ b/tpl/configure.html
@@ -36,7 +36,7 @@
36 <td><b>Security:</b></td> 36 <td><b>Security:</b></td>
37 <td> 37 <td>
38 <input type="checkbox" name="disablesessionprotection" id="disablesessionprotection" 38 <input type="checkbox" name="disablesessionprotection" id="disablesessionprotection"
39 {if="!empty($GLOBALS['disablesessionprotection'])"}checked{/if}> 39 {if="$private_links_default"}checked{/if}>
40 <label 40 <label
41 for="disablesessionprotection">&nbsp;Disable session cookie hijacking protection (Check this if you get 41 for="disablesessionprotection">&nbsp;Disable session cookie hijacking protection (Check this if you get
42 disconnected often or if your IP address changes often.)</label> 42 disconnected often or if your IP address changes often.)</label>
@@ -60,7 +60,7 @@
60 {if="$enable_rss_permalinks"}checked{/if}/> 60 {if="$enable_rss_permalinks"}checked{/if}/>
61 <label for="enableRssPermalinks"> 61 <label for="enableRssPermalinks">
62 &nbsp;Disable it to use permalinks in RSS feed instead of direct links to your shaared links. Currently <b> 62 &nbsp;Disable it to use permalinks in RSS feed instead of direct links to your shaared links. Currently <b>
63 {if="$GLOBALS['config']['ENABLE_RSS_PERMALINKS']"}enabled{else}disabled{/if}.</b> 63 {if="$enable_rss_permalinks"}enabled{else}disabled{/if}.</b>
64 </label> 64 </label>
65 </td> 65 </td>
66 </tr> 66 </tr>
diff --git a/tpl/daily.html b/tpl/daily.html
index 063dc89a..dde1f376 100644
--- a/tpl/daily.html
+++ b/tpl/daily.html
@@ -53,7 +53,7 @@
53 <img src="../images/squiggle2.png" width="25" height="26" title="permalink" alt="permalink"> 53 <img src="../images/squiggle2.png" width="25" height="26" title="permalink" alt="permalink">
54 </a> 54 </a>
55 </div> 55 </div>
56 {if="!$GLOBALS['config']['HIDE_TIMESTAMPS'] || isLoggedIn()"} 56 {if="!$hide_timestamps || isLoggedIn()"}
57 <div class="dailyEntryLinkdate"> 57 <div class="dailyEntryLinkdate">
58 <a href="?{$link.linkdate|smallHash}">{function="strftime('%c', $link.timestamp)"}</a> 58 <a href="?{$link.linkdate|smallHash}">{function="strftime('%c', $link.timestamp)"}</a>
59 </div> 59 </div>
diff --git a/tpl/dailyrss.html b/tpl/dailyrss.html
index 4133ca3e..b14a3859 100644
--- a/tpl/dailyrss.html
+++ b/tpl/dailyrss.html
@@ -6,7 +6,7 @@
6 <description><![CDATA[ 6 <description><![CDATA[
7 {loop="links"} 7 {loop="links"}
8 <h3><a href="{$value.url}">{$value.title}</a></h3> 8 <h3><a href="{$value.url}">{$value.title}</a></h3>
9 <small>{if="!$GLOBALS['config']['HIDE_TIMESTAMPS']"}{function="strftime('%c', $value.timestamp)"} - {/if}{if="$value.tags"}{$value.tags}{/if}<br> 9 <small>{if="!$hide_timestamps"}{function="strftime('%c', $value.timestamp)"} - {/if}{if="$value.tags"}{$value.tags}{/if}<br>
10 {$value.url}</small><br> 10 {$value.url}</small><br>
11 {if="$value.thumbnail"}{$value.thumbnail}{/if}<br> 11 {if="$value.thumbnail"}{$value.thumbnail}{/if}<br>
12 {if="$value.description"}{$value.formatedDescription}{/if} 12 {if="$value.description"}{$value.formatedDescription}{/if}
diff --git a/tpl/editlink.html b/tpl/editlink.html
index 14a2e6c8..441b5302 100644
--- a/tpl/editlink.html
+++ b/tpl/editlink.html
@@ -25,7 +25,7 @@
25 {$value} 25 {$value}
26 {/loop} 26 {/loop}
27 27
28 {if="($link_is_new && $GLOBALS['privateLinkByDefault']==true) || $link.private == true"} 28 {if="($link_is_new && $default_private_links) || $link.private == true"}
29 <input type="checkbox" checked="checked" name="lf_private" id="lf_private"> 29 <input type="checkbox" checked="checked" name="lf_private" id="lf_private">
30 &nbsp;<label for="lf_private"><i>Private</i></label><br> 30 &nbsp;<label for="lf_private"><i>Private</i></label><br>
31 {else} 31 {else}
@@ -43,12 +43,10 @@
43{if="$source !== 'firefoxsocialapi'"} 43{if="$source !== 'firefoxsocialapi'"}
44{include="page.footer"} 44{include="page.footer"}
45{/if} 45{/if}
46{if="($GLOBALS['config']['OPEN_SHAARLI'] || isLoggedIn())"}
47<script src="inc/awesomplete.min.js#"></script> 46<script src="inc/awesomplete.min.js#"></script>
48<script src="inc/awesomplete-multiple-tags.js#"></script> 47<script src="inc/awesomplete-multiple-tags.js#"></script>
49<script> 48<script>
50 awesompleteUniqueTag('#lf_tags'); 49 awesompleteUniqueTag('#lf_tags');
51</script> 50</script>
52{/if}
53</body> 51</body>
54</html> 52</html>