diff options
-rw-r--r-- | application/ApplicationUtils.php | 18 | ||||
-rw-r--r-- | application/PageBuilder.php | 16 | ||||
-rw-r--r-- | application/Updater.php | 10 | ||||
-rw-r--r-- | application/config/ConfigManager.php | 58 | ||||
-rw-r--r-- | application/config/ConfigPhp.php | 48 | ||||
-rw-r--r-- | index.php | 106 | ||||
-rw-r--r-- | tests/ApplicationUtilsTest.php | 40 | ||||
-rw-r--r-- | tests/Updater/UpdaterTest.php | 12 | ||||
-rw-r--r-- | tests/config/ConfigJsonTest.php | 22 | ||||
-rw-r--r-- | tests/utils/config/configJson.json.php | 10 |
10 files changed, 173 insertions, 167 deletions
diff --git a/application/ApplicationUtils.php b/application/ApplicationUtils.php index c5a157b9..e67b2902 100644 --- a/application/ApplicationUtils.php +++ b/application/ApplicationUtils.php | |||
@@ -145,7 +145,7 @@ class ApplicationUtils | |||
145 | 'application', | 145 | 'application', |
146 | 'inc', | 146 | 'inc', |
147 | 'plugins', | 147 | 'plugins', |
148 | $conf->get('path.raintpl_tpl'), | 148 | $conf->get('resource.raintpl_tpl'), |
149 | ) as $path) { | 149 | ) as $path) { |
150 | if (! is_readable(realpath($path))) { | 150 | if (! is_readable(realpath($path))) { |
151 | $errors[] = '"'.$path.'" directory is not readable'; | 151 | $errors[] = '"'.$path.'" directory is not readable'; |
@@ -154,10 +154,10 @@ class ApplicationUtils | |||
154 | 154 | ||
155 | // Check cache and data directories are readable and writeable | 155 | // Check cache and data directories are readable and writeable |
156 | foreach (array( | 156 | foreach (array( |
157 | $conf->get('path.thumbnails_cache'), | 157 | $conf->get('resource.thumbnails_cache'), |
158 | $conf->get('path.data_dir'), | 158 | $conf->get('resource.data_dir'), |
159 | $conf->get('path.page_cache'), | 159 | $conf->get('resource.page_cache'), |
160 | $conf->get('path.raintpl_tmp'), | 160 | $conf->get('resource.raintpl_tmp'), |
161 | ) as $path) { | 161 | ) as $path) { |
162 | if (! is_readable(realpath($path))) { | 162 | if (! is_readable(realpath($path))) { |
163 | $errors[] = '"'.$path.'" directory is not readable'; | 163 | $errors[] = '"'.$path.'" directory is not readable'; |
@@ -170,10 +170,10 @@ class ApplicationUtils | |||
170 | // Check configuration files are readable and writeable | 170 | // Check configuration files are readable and writeable |
171 | foreach (array( | 171 | foreach (array( |
172 | $conf->getConfigFileExt(), | 172 | $conf->getConfigFileExt(), |
173 | $conf->get('path.datastore'), | 173 | $conf->get('resource.datastore'), |
174 | $conf->get('path.ban_file'), | 174 | $conf->get('resource.ban_file'), |
175 | $conf->get('path.log'), | 175 | $conf->get('resource.log'), |
176 | $conf->get('path.update_check'), | 176 | $conf->get('resource.update_check'), |
177 | ) as $path) { | 177 | ) as $path) { |
178 | if (! is_file(realpath($path))) { | 178 | if (! is_file(realpath($path))) { |
179 | # the file may not exist yet | 179 | # the file may not exist yet |
diff --git a/application/PageBuilder.php b/application/PageBuilder.php index 843cc0dc..88dbfa8a 100644 --- a/application/PageBuilder.php +++ b/application/PageBuilder.php | |||
@@ -41,17 +41,17 @@ class PageBuilder | |||
41 | try { | 41 | try { |
42 | $version = ApplicationUtils::checkUpdate( | 42 | $version = ApplicationUtils::checkUpdate( |
43 | shaarli_version, | 43 | shaarli_version, |
44 | $this->conf->get('path.update_check'), | 44 | $this->conf->get('resource.update_check'), |
45 | $this->conf->get('general.check_updates_interval'), | 45 | $this->conf->get('updates.check_updates_interval'), |
46 | $this->conf->get('general.check_updates'), | 46 | $this->conf->get('updates.check_updates'), |
47 | isLoggedIn(), | 47 | isLoggedIn(), |
48 | $this->conf->get('general.check_updates_branch') | 48 | $this->conf->get('updates.check_updates_branch') |
49 | ); | 49 | ); |
50 | $this->tpl->assign('newVersion', escape($version)); | 50 | $this->tpl->assign('newVersion', escape($version)); |
51 | $this->tpl->assign('versionError', ''); | 51 | $this->tpl->assign('versionError', ''); |
52 | 52 | ||
53 | } catch (Exception $exc) { | 53 | } catch (Exception $exc) { |
54 | logm($this->conf->get('path.log'), $_SERVER['REMOTE_ADDR'], $exc->getMessage()); | 54 | logm($this->conf->get('resource.log'), $_SERVER['REMOTE_ADDR'], $exc->getMessage()); |
55 | $this->tpl->assign('newVersion', ''); | 55 | $this->tpl->assign('newVersion', ''); |
56 | $this->tpl->assign('versionError', escape($exc->getMessage())); | 56 | $this->tpl->assign('versionError', escape($exc->getMessage())); |
57 | } | 57 | } |
@@ -80,9 +80,9 @@ class PageBuilder | |||
80 | $this->tpl->assign('pagetitle', $this->conf->get('pagetitle')); | 80 | $this->tpl->assign('pagetitle', $this->conf->get('pagetitle')); |
81 | } | 81 | } |
82 | $this->tpl->assign('shaarlititle', $this->conf->get('title', 'Shaarli')); | 82 | $this->tpl->assign('shaarlititle', $this->conf->get('title', 'Shaarli')); |
83 | $this->tpl->assign('openshaarli', $this->conf->get('extras.open_shaarli', false)); | 83 | $this->tpl->assign('openshaarli', $this->conf->get('security.open_shaarli', false)); |
84 | $this->tpl->assign('showatom', $this->conf->get('extras.show_atom', false)); | 84 | $this->tpl->assign('showatom', $this->conf->get('feed.show_atom', false)); |
85 | $this->tpl->assign('hide_timestamps', $this->conf->get('extras.hide_timestamps', false)); | 85 | $this->tpl->assign('hide_timestamps', $this->conf->get('privacy.hide_timestamps', false)); |
86 | if (!empty($GLOBALS['plugin_errors'])) { | 86 | if (!empty($GLOBALS['plugin_errors'])) { |
87 | $this->tpl->assign('plugin_errors', $GLOBALS['plugin_errors']); | 87 | $this->tpl->assign('plugin_errors', $GLOBALS['plugin_errors']); |
88 | } | 88 | } |
diff --git a/application/Updater.php b/application/Updater.php index b8940e41..fd45d17f 100644 --- a/application/Updater.php +++ b/application/Updater.php | |||
@@ -114,8 +114,8 @@ class Updater | |||
114 | */ | 114 | */ |
115 | public function updateMethodMergeDeprecatedConfigFile() | 115 | public function updateMethodMergeDeprecatedConfigFile() |
116 | { | 116 | { |
117 | if (is_file($this->conf->get('path.data_dir') . '/options.php')) { | 117 | if (is_file($this->conf->get('resource.data_dir') . '/options.php')) { |
118 | include $this->conf->get('path.data_dir') . '/options.php'; | 118 | include $this->conf->get('resource.data_dir') . '/options.php'; |
119 | 119 | ||
120 | // Load GLOBALS into config | 120 | // Load GLOBALS into config |
121 | $allowedKeys = array_merge(ConfigPhp::$ROOT_KEYS); | 121 | $allowedKeys = array_merge(ConfigPhp::$ROOT_KEYS); |
@@ -126,7 +126,7 @@ class Updater | |||
126 | } | 126 | } |
127 | } | 127 | } |
128 | $this->conf->write($this->isLoggedIn); | 128 | $this->conf->write($this->isLoggedIn); |
129 | unlink($this->conf->get('path.data_dir').'/options.php'); | 129 | unlink($this->conf->get('resource.data_dir').'/options.php'); |
130 | } | 130 | } |
131 | 131 | ||
132 | return true; | 132 | return true; |
@@ -143,7 +143,7 @@ class Updater | |||
143 | $link['tags'] = implode(' ', array_unique(LinkFilter::tagsStrToArray($link['tags'], true))); | 143 | $link['tags'] = implode(' ', array_unique(LinkFilter::tagsStrToArray($link['tags'], true))); |
144 | $this->linkDB[$link['linkdate']] = $link; | 144 | $this->linkDB[$link['linkdate']] = $link; |
145 | } | 145 | } |
146 | $this->linkDB->savedb($this->conf->get('path.page_cache')); | 146 | $this->linkDB->savedb($this->conf->get('resource.page_cache')); |
147 | return true; | 147 | return true; |
148 | } | 148 | } |
149 | 149 | ||
@@ -207,7 +207,7 @@ class Updater | |||
207 | try { | 207 | try { |
208 | $this->conf->set('general.title', escape($this->conf->get('general.title'))); | 208 | $this->conf->set('general.title', escape($this->conf->get('general.title'))); |
209 | $this->conf->set('general.header_link', escape($this->conf->get('general.header_link'))); | 209 | $this->conf->set('general.header_link', escape($this->conf->get('general.header_link'))); |
210 | $this->conf->set('extras.redirector', escape($this->conf->get('extras.redirector'))); | 210 | $this->conf->set('redirector.url', escape($this->conf->get('redirector.url'))); |
211 | $this->conf->write($this->isLoggedIn); | 211 | $this->conf->write($this->isLoggedIn); |
212 | } catch (Exception $e) { | 212 | } catch (Exception $e) { |
213 | error_log($e->getMessage()); | 213 | error_log($e->getMessage()); |
diff --git a/application/config/ConfigManager.php b/application/config/ConfigManager.php index 5aafc89d..ff41772a 100644 --- a/application/config/ConfigManager.php +++ b/application/config/ConfigManager.php | |||
@@ -186,8 +186,8 @@ class ConfigManager | |||
186 | 'general.timezone', | 186 | 'general.timezone', |
187 | 'general.title', | 187 | 'general.title', |
188 | 'general.header_link', | 188 | 'general.header_link', |
189 | 'general.default_private_links', | 189 | 'privacy.default_private_links', |
190 | 'extras.redirector', | 190 | 'redirector.url', |
191 | ); | 191 | ); |
192 | 192 | ||
193 | // Only logged in user can alter config. | 193 | // Only logged in user can alter config. |
@@ -287,39 +287,43 @@ class ConfigManager | |||
287 | */ | 287 | */ |
288 | protected function setDefaultValues() | 288 | protected function setDefaultValues() |
289 | { | 289 | { |
290 | $this->setEmpty('path.data_dir', 'data'); | 290 | $this->setEmpty('resource.data_dir', 'data'); |
291 | $this->setEmpty('path.config', 'data/config.php'); | 291 | $this->setEmpty('resource.config', 'data/config.php'); |
292 | $this->setEmpty('path.datastore', 'data/datastore.php'); | 292 | $this->setEmpty('resource.datastore', 'data/datastore.php'); |
293 | $this->setEmpty('path.ban_file', 'data/ipbans.php'); | 293 | $this->setEmpty('resource.ban_file', 'data/ipbans.php'); |
294 | $this->setEmpty('path.updates', 'data/updates.txt'); | 294 | $this->setEmpty('resource.updates', 'data/updates.txt'); |
295 | $this->setEmpty('path.log', 'data/log.txt'); | 295 | $this->setEmpty('resource.log', 'data/log.txt'); |
296 | $this->setEmpty('path.update_check', 'data/lastupdatecheck.txt'); | 296 | $this->setEmpty('resource.update_check', 'data/lastupdatecheck.txt'); |
297 | $this->setEmpty('path.raintpl_tpl', 'tpl/'); | 297 | $this->setEmpty('resource.raintpl_tpl', 'tpl/'); |
298 | $this->setEmpty('path.raintpl_tmp', 'tmp/'); | 298 | $this->setEmpty('resource.raintpl_tmp', 'tmp/'); |
299 | $this->setEmpty('path.thumbnails_cache', 'cache'); | 299 | $this->setEmpty('resource.thumbnails_cache', 'cache'); |
300 | $this->setEmpty('path.page_cache', 'pagecache'); | 300 | $this->setEmpty('resource.page_cache', 'pagecache'); |
301 | 301 | ||
302 | $this->setEmpty('security.ban_after', 4); | 302 | $this->setEmpty('security.ban_after', 4); |
303 | $this->setEmpty('security.ban_duration', 1800); | 303 | $this->setEmpty('security.ban_duration', 1800); |
304 | $this->setEmpty('security.session_protection_disabled', false); | 304 | $this->setEmpty('security.session_protection_disabled', false); |
305 | $this->setEmpty('security.open_shaarli', false); | ||
305 | 306 | ||
306 | $this->setEmpty('general.check_updates', false); | ||
307 | $this->setEmpty('general.rss_permalinks', true); | ||
308 | $this->setEmpty('general.links_per_page', 20); | ||
309 | $this->setEmpty('general.default_private_links', false); | ||
310 | $this->setEmpty('general.enable_thumbnails', true); | ||
311 | $this->setEmpty('general.enable_localcache', true); | ||
312 | $this->setEmpty('general.check_updates_branch', 'stable'); | ||
313 | $this->setEmpty('general.check_updates_interval', 86400); | ||
314 | $this->setEmpty('general.header_link', '?'); | 307 | $this->setEmpty('general.header_link', '?'); |
308 | $this->setEmpty('general.links_per_page', 20); | ||
315 | $this->setEmpty('general.enabled_plugins', array('qrcode')); | 309 | $this->setEmpty('general.enabled_plugins', array('qrcode')); |
316 | 310 | ||
317 | $this->setEmpty('extras.show_atom', false); | 311 | $this->setEmpty('updates.check_updates', false); |
318 | $this->setEmpty('extras.hide_public_links', false); | 312 | $this->setEmpty('updates.check_updates_branch', 'stable'); |
319 | $this->setEmpty('extras.hide_timestamps', false); | 313 | $this->setEmpty('updates.check_updates_interval', 86400); |
320 | $this->setEmpty('extras.open_shaarli', false); | 314 | |
321 | $this->setEmpty('extras.redirector', ''); | 315 | $this->setEmpty('feed.rss_permalinks', true); |
322 | $this->setEmpty('extras.redirector_encode_url', true); | 316 | $this->setEmpty('feed.show_atom', false); |
317 | |||
318 | $this->setEmpty('privacy.default_private_links', false); | ||
319 | $this->setEmpty('privacy.hide_public_links', false); | ||
320 | $this->setEmpty('privacy.hide_timestamps', false); | ||
321 | |||
322 | $this->setEmpty('thumbnail.enable_thumbnails', true); | ||
323 | $this->setEmpty('thumbnail.enable_localcache', true); | ||
324 | |||
325 | $this->setEmpty('redirector.url', ''); | ||
326 | $this->setEmpty('redirector.encode_url', true); | ||
323 | 327 | ||
324 | $this->setEmpty('plugins', array()); | 328 | $this->setEmpty('plugins', array()); |
325 | } | 329 | } |
diff --git a/application/config/ConfigPhp.php b/application/config/ConfigPhp.php index b122f4f1..27187b66 100644 --- a/application/config/ConfigPhp.php +++ b/application/config/ConfigPhp.php | |||
@@ -34,38 +34,38 @@ class ConfigPhp implements ConfigIO | |||
34 | 'credentials.login' => 'login', | 34 | 'credentials.login' => 'login', |
35 | 'credentials.hash' => 'hash', | 35 | 'credentials.hash' => 'hash', |
36 | 'credentials.salt' => 'salt', | 36 | 'credentials.salt' => 'salt', |
37 | 'path.data_dir' => 'config.DATADIR', | 37 | 'resource.data_dir' => 'config.DATADIR', |
38 | 'path.config' => 'config.CONFIG_FILE', | 38 | 'resource.config' => 'config.CONFIG_FILE', |
39 | 'path.datastore' => 'config.DATASTORE', | 39 | 'resource.datastore' => 'config.DATASTORE', |
40 | 'path.updates' => 'config.UPDATES_FILE', | 40 | 'resource.updates' => 'config.UPDATES_FILE', |
41 | 'path.log' => 'config.LOG_FILE', | 41 | 'resource.log' => 'config.LOG_FILE', |
42 | 'path.update_check' => 'config.UPDATECHECK_FILENAME', | 42 | 'resource.update_check' => 'config.UPDATECHECK_FILENAME', |
43 | 'path.raintpl_tpl' => 'config.RAINTPL_TPL', | 43 | 'resource.raintpl_tpl' => 'config.RAINTPL_TPL', |
44 | 'path.raintpl_tmp' => 'config.RAINTPL_TMP', | 44 | 'resource.raintpl_tmp' => 'config.RAINTPL_TMP', |
45 | 'path.thumbnails_cache' => 'config.CACHEDIR', | 45 | 'resource.thumbnails_cache' => 'config.CACHEDIR', |
46 | 'path.page_cache' => 'config.PAGECACHE', | 46 | 'resource.page_cache' => 'config.PAGECACHE', |
47 | 'path.ban_file' => 'config.IPBANS_FILENAME', | 47 | 'resource.ban_file' => 'config.IPBANS_FILENAME', |
48 | 'security.session_protection_disabled' => 'disablesessionprotection', | 48 | 'security.session_protection_disabled' => 'disablesessionprotection', |
49 | 'security.ban_after' => 'config.BAN_AFTER', | 49 | 'security.ban_after' => 'config.BAN_AFTER', |
50 | 'security.ban_duration' => 'config.BAN_DURATION', | 50 | 'security.ban_duration' => 'config.BAN_DURATION', |
51 | 'general.title' => 'title', | 51 | 'general.title' => 'title', |
52 | 'general.timezone' => 'timezone', | 52 | 'general.timezone' => 'timezone', |
53 | 'general.header_link' => 'titleLink', | 53 | 'general.header_link' => 'titleLink', |
54 | 'general.check_updates' => 'config.ENABLE_UPDATECHECK', | 54 | 'updates.check_updates' => 'config.ENABLE_UPDATECHECK', |
55 | 'general.check_updates_branch' => 'config.UPDATECHECK_BRANCH', | 55 | 'updates.check_updates_branch' => 'config.UPDATECHECK_BRANCH', |
56 | 'general.check_updates_interval' => 'config.UPDATECHECK_INTERVAL', | 56 | 'updates.check_updates_interval' => 'config.UPDATECHECK_INTERVAL', |
57 | 'general.default_private_links' => 'privateLinkByDefault', | 57 | 'privacy.default_private_links' => 'privateLinkByDefault', |
58 | 'general.rss_permalinks' => 'config.ENABLE_RSS_PERMALINKS', | 58 | 'feed.rss_permalinks' => 'config.ENABLE_RSS_PERMALINKS', |
59 | 'general.links_per_page' => 'config.LINKS_PER_PAGE', | 59 | 'general.links_per_page' => 'config.LINKS_PER_PAGE', |
60 | 'general.enable_thumbnails' => 'config.ENABLE_THUMBNAILS', | 60 | 'thumbnail.enable_thumbnails' => 'config.ENABLE_THUMBNAILS', |
61 | 'general.enable_localcache' => 'config.ENABLE_LOCALCACHE', | 61 | 'thumbnail.enable_localcache' => 'config.ENABLE_LOCALCACHE', |
62 | 'general.enabled_plugins' => 'config.ENABLED_PLUGINS', | 62 | 'general.enabled_plugins' => 'config.ENABLED_PLUGINS', |
63 | 'extras.redirector' => 'redirector', | 63 | 'redirector.url' => 'redirector', |
64 | 'extras.redirector_encode_url' => 'config.REDIRECTOR_URLENCODE', | 64 | 'redirector.encode_url' => 'config.REDIRECTOR_URLENCODE', |
65 | 'extras.show_atom' => 'config.SHOW_ATOM', | 65 | 'feed.show_atom' => 'config.SHOW_ATOM', |
66 | 'extras.hide_public_links' => 'config.HIDE_PUBLIC_LINKS', | 66 | 'privacy.hide_public_links' => 'config.HIDE_PUBLIC_LINKS', |
67 | 'extras.hide_timestamps' => 'config.HIDE_TIMESTAMPS', | 67 | 'privacy.hide_timestamps' => 'config.HIDE_TIMESTAMPS', |
68 | 'extras.open_shaarli' => 'config.OPEN_SHAARLI', | 68 | 'security.open_shaarli' => 'config.OPEN_SHAARLI', |
69 | ); | 69 | ); |
70 | 70 | ||
71 | /** | 71 | /** |
@@ -108,8 +108,8 @@ if (isset($_COOKIE['shaarli']) && !is_session_id_valid($_COOKIE['shaarli'])) { | |||
108 | $conf = new ConfigManager(); | 108 | $conf = new ConfigManager(); |
109 | $conf->setEmpty('general.timezone', date_default_timezone_get()); | 109 | $conf->setEmpty('general.timezone', date_default_timezone_get()); |
110 | $conf->setEmpty('general.title', 'Shared links on '. escape(index_url($_SERVER))); | 110 | $conf->setEmpty('general.title', 'Shared links on '. escape(index_url($_SERVER))); |
111 | RainTPL::$tpl_dir = $conf->get('path.raintpl_tpl'); // template directory | 111 | RainTPL::$tpl_dir = $conf->get('resource.raintpl_tpl'); // template directory |
112 | RainTPL::$cache_dir = $conf->get('path.raintpl_tmp'); // cache directory | 112 | RainTPL::$cache_dir = $conf->get('resource.raintpl_tmp'); // cache directory |
113 | 113 | ||
114 | $pluginManager = new PluginManager($conf); | 114 | $pluginManager = new PluginManager($conf); |
115 | $pluginManager->load($conf->get('general.enabled_plugins')); | 115 | $pluginManager->load($conf->get('general.enabled_plugins')); |
@@ -172,7 +172,7 @@ header('Content-Type: text/html; charset=utf-8'); // We use UTF-8 for proper int | |||
172 | */ | 172 | */ |
173 | function setup_login_state($conf) | 173 | function setup_login_state($conf) |
174 | { | 174 | { |
175 | if ($conf->get('extras.open_shaarli')) { | 175 | if ($conf->get('security.open_shaarli')) { |
176 | return true; | 176 | return true; |
177 | } | 177 | } |
178 | $userIsLoggedIn = false; // By default, we do not consider the user as logged in; | 178 | $userIsLoggedIn = false; // By default, we do not consider the user as logged in; |
@@ -273,10 +273,10 @@ function check_auth($login, $password, $conf) | |||
273 | if ($login == $conf->get('credentials.login') && $hash == $conf->get('credentials.hash')) | 273 | if ($login == $conf->get('credentials.login') && $hash == $conf->get('credentials.hash')) |
274 | { // Login/password is correct. | 274 | { // Login/password is correct. |
275 | fillSessionInfo($conf); | 275 | fillSessionInfo($conf); |
276 | logm($conf->get('path.log'), $_SERVER['REMOTE_ADDR'], 'Login successful'); | 276 | logm($conf->get('resource.log'), $_SERVER['REMOTE_ADDR'], 'Login successful'); |
277 | return true; | 277 | return true; |
278 | } | 278 | } |
279 | logm($conf->get('path.log'), $_SERVER['REMOTE_ADDR'], 'Login failed for user '.$login); | 279 | logm($conf->get('resource.log'), $_SERVER['REMOTE_ADDR'], 'Login failed for user '.$login); |
280 | return false; | 280 | return false; |
281 | } | 281 | } |
282 | 282 | ||
@@ -302,14 +302,14 @@ function logout() { | |||
302 | // ------------------------------------------------------------------------------------------ | 302 | // ------------------------------------------------------------------------------------------ |
303 | // Brute force protection system | 303 | // Brute force protection system |
304 | // Several consecutive failed logins will ban the IP address for 30 minutes. | 304 | // Several consecutive failed logins will ban the IP address for 30 minutes. |
305 | if (!is_file($conf->get('path.ban_file', 'data/ipbans.php'))) { | 305 | if (!is_file($conf->get('resource.ban_file', 'data/ipbans.php'))) { |
306 | // FIXME! globals | 306 | // FIXME! globals |
307 | file_put_contents( | 307 | file_put_contents( |
308 | $conf->get('path.ban_file', 'data/ipbans.php'), | 308 | $conf->get('resource.ban_file', 'data/ipbans.php'), |
309 | "<?php\n\$GLOBALS['IPBANS']=".var_export(array('FAILURES'=>array(),'BANS'=>array()),true).";\n?>" | 309 | "<?php\n\$GLOBALS['IPBANS']=".var_export(array('FAILURES'=>array(),'BANS'=>array()),true).";\n?>" |
310 | ); | 310 | ); |
311 | } | 311 | } |
312 | include $conf->get('path.ban_file', 'data/ipbans.php'); | 312 | include $conf->get('resource.ban_file', 'data/ipbans.php'); |
313 | /** | 313 | /** |
314 | * Signal a failed login. Will ban the IP if too many failures: | 314 | * Signal a failed login. Will ban the IP if too many failures: |
315 | * | 315 | * |
@@ -324,11 +324,11 @@ function ban_loginFailed($conf) | |||
324 | if ($gb['FAILURES'][$ip] > ($conf->get('security.ban_after') - 1)) | 324 | if ($gb['FAILURES'][$ip] > ($conf->get('security.ban_after') - 1)) |
325 | { | 325 | { |
326 | $gb['BANS'][$ip] = time() + $conf->get('security.ban_after', 1800); | 326 | $gb['BANS'][$ip] = time() + $conf->get('security.ban_after', 1800); |
327 | logm($conf->get('path.log'), $_SERVER['REMOTE_ADDR'], 'IP address banned from login'); | 327 | logm($conf->get('resource.log'), $_SERVER['REMOTE_ADDR'], 'IP address banned from login'); |
328 | } | 328 | } |
329 | $GLOBALS['IPBANS'] = $gb; | 329 | $GLOBALS['IPBANS'] = $gb; |
330 | file_put_contents( | 330 | file_put_contents( |
331 | $conf->get('path.ban_file', 'data/ipbans.php'), | 331 | $conf->get('resource.ban_file', 'data/ipbans.php'), |
332 | "<?php\n\$GLOBALS['IPBANS']=".var_export($gb,true).";\n?>" | 332 | "<?php\n\$GLOBALS['IPBANS']=".var_export($gb,true).";\n?>" |
333 | ); | 333 | ); |
334 | } | 334 | } |
@@ -345,7 +345,7 @@ function ban_loginOk($conf) | |||
345 | unset($gb['FAILURES'][$ip]); unset($gb['BANS'][$ip]); | 345 | unset($gb['FAILURES'][$ip]); unset($gb['BANS'][$ip]); |
346 | $GLOBALS['IPBANS'] = $gb; | 346 | $GLOBALS['IPBANS'] = $gb; |
347 | file_put_contents( | 347 | file_put_contents( |
348 | $conf->get('path.ban_file', 'data/ipbans.php'), | 348 | $conf->get('resource.ban_file', 'data/ipbans.php'), |
349 | "<?php\n\$GLOBALS['IPBANS']=".var_export($gb,true).";\n?>" | 349 | "<?php\n\$GLOBALS['IPBANS']=".var_export($gb,true).";\n?>" |
350 | ); | 350 | ); |
351 | } | 351 | } |
@@ -365,10 +365,10 @@ function ban_canLogin($conf) | |||
365 | // User is banned. Check if the ban has expired: | 365 | // User is banned. Check if the ban has expired: |
366 | if ($gb['BANS'][$ip]<=time()) | 366 | if ($gb['BANS'][$ip]<=time()) |
367 | { // Ban expired, user can try to login again. | 367 | { // Ban expired, user can try to login again. |
368 | logm($conf->get('path.log'), $_SERVER['REMOTE_ADDR'], 'Ban lifted.'); | 368 | logm($conf->get('resource.log'), $_SERVER['REMOTE_ADDR'], 'Ban lifted.'); |
369 | unset($gb['FAILURES'][$ip]); unset($gb['BANS'][$ip]); | 369 | unset($gb['FAILURES'][$ip]); unset($gb['BANS'][$ip]); |
370 | file_put_contents( | 370 | file_put_contents( |
371 | $conf->get('path.ban_file', 'data/ipbans.php'), | 371 | $conf->get('resource.ban_file', 'data/ipbans.php'), |
372 | "<?php\n\$GLOBALS['IPBANS']=".var_export($gb,true).";\n?>" | 372 | "<?php\n\$GLOBALS['IPBANS']=".var_export($gb,true).";\n?>" |
373 | ); | 373 | ); |
374 | return true; // Ban has expired, user can login. | 374 | return true; // Ban has expired, user can login. |
@@ -533,11 +533,11 @@ function showDailyRSS($conf) { | |||
533 | // If cached was not found (or not usable), then read the database and build the response: | 533 | // If cached was not found (or not usable), then read the database and build the response: |
534 | // Read links from database (and filter private links if used it not logged in). | 534 | // Read links from database (and filter private links if used it not logged in). |
535 | $LINKSDB = new LinkDB( | 535 | $LINKSDB = new LinkDB( |
536 | $conf->get('path.datastore'), | 536 | $conf->get('resource.datastore'), |
537 | isLoggedIn(), | 537 | isLoggedIn(), |
538 | $conf->get('extras.hide_public_links'), | 538 | $conf->get('privacy.hide_public_links'), |
539 | $conf->get('extras.redirector'), | 539 | $conf->get('redirector.url'), |
540 | $conf->get('extras.redirector_encode_url') | 540 | $conf->get('redirector.encode_url') |
541 | ); | 541 | ); |
542 | 542 | ||
543 | /* Some Shaarlies may have very few links, so we need to look | 543 | /* Some Shaarlies may have very few links, so we need to look |
@@ -590,7 +590,7 @@ function showDailyRSS($conf) { | |||
590 | // We pre-format some fields for proper output. | 590 | // We pre-format some fields for proper output. |
591 | foreach ($linkdates as $linkdate) { | 591 | foreach ($linkdates as $linkdate) { |
592 | $l = $LINKSDB[$linkdate]; | 592 | $l = $LINKSDB[$linkdate]; |
593 | $l['formatedDescription'] = format_description($l['description'], $conf->get('extras.redirector')); | 593 | $l['formatedDescription'] = format_description($l['description'], $conf->get('redirector.url')); |
594 | $l['thumbnail'] = thumbnail($conf, $l['url']); | 594 | $l['thumbnail'] = thumbnail($conf, $l['url']); |
595 | $l_date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $l['linkdate']); | 595 | $l_date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $l['linkdate']); |
596 | $l['timestamp'] = $l_date->getTimestamp(); | 596 | $l['timestamp'] = $l_date->getTimestamp(); |
@@ -607,7 +607,7 @@ function showDailyRSS($conf) { | |||
607 | $tpl->assign('absurl', $absurl); | 607 | $tpl->assign('absurl', $absurl); |
608 | $tpl->assign('links', $links); | 608 | $tpl->assign('links', $links); |
609 | $tpl->assign('rssdate', escape($dayDate->format(DateTime::RSS))); | 609 | $tpl->assign('rssdate', escape($dayDate->format(DateTime::RSS))); |
610 | $tpl->assign('hide_timestamps', $conf->get('extras.hide_timestamps', false)); | 610 | $tpl->assign('hide_timestamps', $conf->get('privacy.hide_timestamps', false)); |
611 | $html = $tpl->draw('dailyrss', $return_string=true); | 611 | $html = $tpl->draw('dailyrss', $return_string=true); |
612 | 612 | ||
613 | echo $html . PHP_EOL; | 613 | echo $html . PHP_EOL; |
@@ -657,7 +657,7 @@ function showDaily($pageBuilder, $LINKSDB, $conf, $pluginManager) | |||
657 | $taglist = explode(' ',$link['tags']); | 657 | $taglist = explode(' ',$link['tags']); |
658 | uasort($taglist, 'strcasecmp'); | 658 | uasort($taglist, 'strcasecmp'); |
659 | $linksToDisplay[$key]['taglist']=$taglist; | 659 | $linksToDisplay[$key]['taglist']=$taglist; |
660 | $linksToDisplay[$key]['formatedDescription'] = format_description($link['description'], $conf->get('extras.redirector')); | 660 | $linksToDisplay[$key]['formatedDescription'] = format_description($link['description'], $conf->get('redirector.url')); |
661 | $linksToDisplay[$key]['thumbnail'] = thumbnail($conf, $link['url']); | 661 | $linksToDisplay[$key]['thumbnail'] = thumbnail($conf, $link['url']); |
662 | $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); | 662 | $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); |
663 | $linksToDisplay[$key]['timestamp'] = $date->getTimestamp(); | 663 | $linksToDisplay[$key]['timestamp'] = $date->getTimestamp(); |
@@ -726,15 +726,15 @@ function showLinkList($PAGE, $LINKSDB, $conf, $pluginManager) { | |||
726 | function renderPage($conf, $pluginManager) | 726 | function renderPage($conf, $pluginManager) |
727 | { | 727 | { |
728 | $LINKSDB = new LinkDB( | 728 | $LINKSDB = new LinkDB( |
729 | $conf->get('path.datastore'), | 729 | $conf->get('resource.datastore'), |
730 | isLoggedIn(), | 730 | isLoggedIn(), |
731 | $conf->get('extras.hide_public_links'), | 731 | $conf->get('privacy.hide_public_links'), |
732 | $conf->get('extras.redirector'), | 732 | $conf->get('redirector.url'), |
733 | $conf->get('extras.redirector_encode_url') | 733 | $conf->get('redirector.encode_url') |
734 | ); | 734 | ); |
735 | 735 | ||
736 | $updater = new Updater( | 736 | $updater = new Updater( |
737 | read_updates_file($conf->get('path.updates')), | 737 | read_updates_file($conf->get('resource.updates')), |
738 | $LINKSDB, | 738 | $LINKSDB, |
739 | $conf, | 739 | $conf, |
740 | isLoggedIn() | 740 | isLoggedIn() |
@@ -743,7 +743,7 @@ function renderPage($conf, $pluginManager) | |||
743 | $newUpdates = $updater->update(); | 743 | $newUpdates = $updater->update(); |
744 | if (! empty($newUpdates)) { | 744 | if (! empty($newUpdates)) { |
745 | write_updates_file( | 745 | write_updates_file( |
746 | $conf->get('path.updates'), | 746 | $conf->get('resource.updates'), |
747 | $updater->getDoneUpdates() | 747 | $updater->getDoneUpdates() |
748 | ); | 748 | ); |
749 | } | 749 | } |
@@ -782,7 +782,7 @@ function renderPage($conf, $pluginManager) | |||
782 | // -------- Display login form. | 782 | // -------- Display login form. |
783 | if ($targetPage == Router::$PAGE_LOGIN) | 783 | if ($targetPage == Router::$PAGE_LOGIN) |
784 | { | 784 | { |
785 | if ($conf->get('extras.open_shaarli')) { header('Location: ?'); exit; } // No need to login for open Shaarli | 785 | if ($conf->get('security.open_shaarli')) { header('Location: ?'); exit; } // No need to login for open Shaarli |
786 | $token=''; if (ban_canLogin($conf)) $token=getToken($conf); // Do not waste token generation if not useful. | 786 | $token=''; if (ban_canLogin($conf)) $token=getToken($conf); // Do not waste token generation if not useful. |
787 | $PAGE->assign('token',$token); | 787 | $PAGE->assign('token',$token); |
788 | if (isset($_GET['username'])) { | 788 | if (isset($_GET['username'])) { |
@@ -795,7 +795,7 @@ function renderPage($conf, $pluginManager) | |||
795 | // -------- User wants to logout. | 795 | // -------- User wants to logout. |
796 | if (isset($_SERVER['QUERY_STRING']) && startsWith($_SERVER['QUERY_STRING'], 'do=logout')) | 796 | if (isset($_SERVER['QUERY_STRING']) && startsWith($_SERVER['QUERY_STRING'], 'do=logout')) |
797 | { | 797 | { |
798 | invalidateCaches($conf->get('path.page_cache')); | 798 | invalidateCaches($conf->get('resource.page_cache')); |
799 | logout(); | 799 | logout(); |
800 | header('Location: ?'); | 800 | header('Location: ?'); |
801 | exit; | 801 | exit; |
@@ -895,7 +895,7 @@ function renderPage($conf, $pluginManager) | |||
895 | // Cache system | 895 | // Cache system |
896 | $query = $_SERVER['QUERY_STRING']; | 896 | $query = $_SERVER['QUERY_STRING']; |
897 | $cache = new CachedPage( | 897 | $cache = new CachedPage( |
898 | $conf->get('path.page_cache'), | 898 | $conf->get('resource.page_cache'), |
899 | page_url($_SERVER), | 899 | page_url($_SERVER), |
900 | startsWith($query,'do='. $targetPage) && !isLoggedIn() | 900 | startsWith($query,'do='. $targetPage) && !isLoggedIn() |
901 | ); | 901 | ); |
@@ -908,8 +908,8 @@ function renderPage($conf, $pluginManager) | |||
908 | // Generate data. | 908 | // Generate data. |
909 | $feedGenerator = new FeedBuilder($LINKSDB, $feedType, $_SERVER, $_GET, isLoggedIn()); | 909 | $feedGenerator = new FeedBuilder($LINKSDB, $feedType, $_SERVER, $_GET, isLoggedIn()); |
910 | $feedGenerator->setLocale(strtolower(setlocale(LC_COLLATE, 0))); | 910 | $feedGenerator->setLocale(strtolower(setlocale(LC_COLLATE, 0))); |
911 | $feedGenerator->setHideDates($conf->get('extras.hide_timestamps') && !isLoggedIn()); | 911 | $feedGenerator->setHideDates($conf->get('privacy.hide_timestamps') && !isLoggedIn()); |
912 | $feedGenerator->setUsePermalinks(isset($_GET['permalinks']) || !$conf->get('general.rss_permalinks')); | 912 | $feedGenerator->setUsePermalinks(isset($_GET['permalinks']) || !$conf->get('feed.rss_permalinks')); |
913 | $pshUrl = $conf->get('config.PUBSUBHUB_URL'); | 913 | $pshUrl = $conf->get('config.PUBSUBHUB_URL'); |
914 | if (!empty($pshUrl)) { | 914 | if (!empty($pshUrl)) { |
915 | $feedGenerator->setPubsubhubUrl($pshUrl); | 915 | $feedGenerator->setPubsubhubUrl($pshUrl); |
@@ -1072,7 +1072,7 @@ function renderPage($conf, $pluginManager) | |||
1072 | // -------- User wants to change his/her password. | 1072 | // -------- User wants to change his/her password. |
1073 | if ($targetPage == Router::$PAGE_CHANGEPASSWORD) | 1073 | if ($targetPage == Router::$PAGE_CHANGEPASSWORD) |
1074 | { | 1074 | { |
1075 | if ($conf->get('extras.open_shaarli')) { | 1075 | if ($conf->get('security.open_shaarli')) { |
1076 | die('You are not supposed to change a password on an Open Shaarli.'); | 1076 | die('You are not supposed to change a password on an Open Shaarli.'); |
1077 | } | 1077 | } |
1078 | 1078 | ||
@@ -1128,12 +1128,12 @@ function renderPage($conf, $pluginManager) | |||
1128 | $conf->set('general.timezone', $tz); | 1128 | $conf->set('general.timezone', $tz); |
1129 | $conf->set('general.title', escape($_POST['title'])); | 1129 | $conf->set('general.title', escape($_POST['title'])); |
1130 | $conf->set('general.header_link', escape($_POST['titleLink'])); | 1130 | $conf->set('general.header_link', escape($_POST['titleLink'])); |
1131 | $conf->set('extras.redirector', escape($_POST['redirector'])); | 1131 | $conf->set('redirector.url', escape($_POST['redirector'])); |
1132 | $conf->set('security.session_protection_disabled', !empty($_POST['disablesessionprotection'])); | 1132 | $conf->set('security.session_protection_disabled', !empty($_POST['disablesessionprotection'])); |
1133 | $conf->set('general.default_private_links', !empty($_POST['privateLinkByDefault'])); | 1133 | $conf->set('privacy.default_private_links', !empty($_POST['privateLinkByDefault'])); |
1134 | $conf->set('general.rss_permalinks', !empty($_POST['enableRssPermalinks'])); | 1134 | $conf->set('feed.rss_permalinks', !empty($_POST['enableRssPermalinks'])); |
1135 | $conf->set('general.check_updates', !empty($_POST['updateCheck'])); | 1135 | $conf->set('updates.check_updates', !empty($_POST['updateCheck'])); |
1136 | $conf->set('extras.hide_public_links', !empty($_POST['hidePublicLinks'])); | 1136 | $conf->set('privacy.hide_public_links', !empty($_POST['hidePublicLinks'])); |
1137 | try { | 1137 | try { |
1138 | $conf->write(isLoggedIn()); | 1138 | $conf->write(isLoggedIn()); |
1139 | } | 1139 | } |
@@ -1154,14 +1154,14 @@ function renderPage($conf, $pluginManager) | |||
1154 | { | 1154 | { |
1155 | $PAGE->assign('token',getToken($conf)); | 1155 | $PAGE->assign('token',getToken($conf)); |
1156 | $PAGE->assign('title', $conf->get('general.title')); | 1156 | $PAGE->assign('title', $conf->get('general.title')); |
1157 | $PAGE->assign('redirector', $conf->get('extras.redirector')); | 1157 | $PAGE->assign('redirector', $conf->get('redirector.url')); |
1158 | list($timezone_form, $timezone_js) = generateTimeZoneForm($conf->get('general.timezone')); | 1158 | list($timezone_form, $timezone_js) = generateTimeZoneForm($conf->get('general.timezone')); |
1159 | $PAGE->assign('timezone_form', $timezone_form); | 1159 | $PAGE->assign('timezone_form', $timezone_form); |
1160 | $PAGE->assign('timezone_js',$timezone_js); | 1160 | $PAGE->assign('timezone_js',$timezone_js); |
1161 | $PAGE->assign('private_links_default', $conf->get('general.default_private_links', false)); | 1161 | $PAGE->assign('private_links_default', $conf->get('privacy.default_private_links', false)); |
1162 | $PAGE->assign('enable_rss_permalinks', $conf->get('general.rss_permalinks', false)); | 1162 | $PAGE->assign('enable_rss_permalinks', $conf->get('feed.rss_permalinks', false)); |
1163 | $PAGE->assign('enable_update_check', $conf->get('general.check_updates', true)); | 1163 | $PAGE->assign('enable_update_check', $conf->get('updates.check_updates', true)); |
1164 | $PAGE->assign('hide_public_links', $conf->get('extras.hide_public_links', false)); | 1164 | $PAGE->assign('hide_public_links', $conf->get('privacy.hide_public_links', false)); |
1165 | $PAGE->renderPage('configure'); | 1165 | $PAGE->renderPage('configure'); |
1166 | exit; | 1166 | exit; |
1167 | } | 1167 | } |
@@ -1193,7 +1193,7 @@ function renderPage($conf, $pluginManager) | |||
1193 | $value['tags']=trim(implode(' ',$tags)); | 1193 | $value['tags']=trim(implode(' ',$tags)); |
1194 | $LINKSDB[$key]=$value; | 1194 | $LINKSDB[$key]=$value; |
1195 | } | 1195 | } |
1196 | $LINKSDB->savedb($conf->get('path.page_cache')); | 1196 | $LINKSDB->savedb($conf->get('resource.page_cache')); |
1197 | echo '<script>alert("Tag was removed from '.count($linksToAlter).' links.");document.location=\'?\';</script>'; | 1197 | echo '<script>alert("Tag was removed from '.count($linksToAlter).' links.");document.location=\'?\';</script>'; |
1198 | exit; | 1198 | exit; |
1199 | } | 1199 | } |
@@ -1210,7 +1210,7 @@ function renderPage($conf, $pluginManager) | |||
1210 | $value['tags']=trim(implode(' ',$tags)); | 1210 | $value['tags']=trim(implode(' ',$tags)); |
1211 | $LINKSDB[$key]=$value; | 1211 | $LINKSDB[$key]=$value; |
1212 | } | 1212 | } |
1213 | $LINKSDB->savedb($conf->get('path.page_cache')); // Save to disk. | 1213 | $LINKSDB->savedb($conf->get('resource.page_cache')); // Save to disk. |
1214 | echo '<script>alert("Tag was renamed in '.count($linksToAlter).' links.");document.location=\'?searchtags='.urlencode($_POST['totag']).'\';</script>'; | 1214 | echo '<script>alert("Tag was renamed in '.count($linksToAlter).' links.");document.location=\'?searchtags='.urlencode($_POST['totag']).'\';</script>'; |
1215 | exit; | 1215 | exit; |
1216 | } | 1216 | } |
@@ -1261,7 +1261,7 @@ function renderPage($conf, $pluginManager) | |||
1261 | $pluginManager->executeHooks('save_link', $link); | 1261 | $pluginManager->executeHooks('save_link', $link); |
1262 | 1262 | ||
1263 | $LINKSDB[$linkdate] = $link; | 1263 | $LINKSDB[$linkdate] = $link; |
1264 | $LINKSDB->savedb($conf->get('path.page_cache')); | 1264 | $LINKSDB->savedb($conf->get('resource.page_cache')); |
1265 | pubsubhub($conf); | 1265 | pubsubhub($conf); |
1266 | 1266 | ||
1267 | // If we are called from the bookmarklet, we must close the popup: | 1267 | // If we are called from the bookmarklet, we must close the popup: |
@@ -1303,7 +1303,7 @@ function renderPage($conf, $pluginManager) | |||
1303 | $pluginManager->executeHooks('delete_link', $LINKSDB[$linkdate]); | 1303 | $pluginManager->executeHooks('delete_link', $LINKSDB[$linkdate]); |
1304 | 1304 | ||
1305 | unset($LINKSDB[$linkdate]); | 1305 | unset($LINKSDB[$linkdate]); |
1306 | $LINKSDB->savedb('path.page_cache'); // save to disk | 1306 | $LINKSDB->savedb('resource.page_cache'); // save to disk |
1307 | 1307 | ||
1308 | // If we are called from the bookmarklet, we must close the popup: | 1308 | // If we are called from the bookmarklet, we must close the popup: |
1309 | if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { echo '<script>self.close();</script>'; exit; } | 1309 | if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { echo '<script>self.close();</script>'; exit; } |
@@ -1629,7 +1629,7 @@ function importFile($LINKSDB, $conf) | |||
1629 | } | 1629 | } |
1630 | } | 1630 | } |
1631 | } | 1631 | } |
1632 | $LINKSDB->savedb($conf->get('path.page_cache')); | 1632 | $LINKSDB->savedb($conf->get('resource.page_cache')); |
1633 | 1633 | ||
1634 | echo '<script>alert("File '.json_encode($filename).' ('.$filesize.' bytes) was successfully processed: '.$import_count.' links imported.");document.location=\'?\';</script>'; | 1634 | echo '<script>alert("File '.json_encode($filename).' ('.$filesize.' bytes) was successfully processed: '.$import_count.' links imported.");document.location=\'?\';</script>'; |
1635 | } | 1635 | } |
@@ -1693,7 +1693,7 @@ function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager) | |||
1693 | while ($i<$end && $i<count($keys)) | 1693 | while ($i<$end && $i<count($keys)) |
1694 | { | 1694 | { |
1695 | $link = $linksToDisplay[$keys[$i]]; | 1695 | $link = $linksToDisplay[$keys[$i]]; |
1696 | $link['description'] = format_description($link['description'], $conf->get('extras.redirector')); | 1696 | $link['description'] = format_description($link['description'], $conf->get('redirector.url')); |
1697 | $classLi = ($i % 2) != 0 ? '' : 'publicLinkHightLight'; | 1697 | $classLi = ($i % 2) != 0 ? '' : 'publicLinkHightLight'; |
1698 | $link['class'] = $link['private'] == 0 ? $classLi : 'private'; | 1698 | $link['class'] = $link['private'] == 0 ? $classLi : 'private'; |
1699 | $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); | 1699 | $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); |
@@ -1735,7 +1735,7 @@ function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager) | |||
1735 | 'result_count' => count($linksToDisplay), | 1735 | 'result_count' => count($linksToDisplay), |
1736 | 'search_term' => $searchterm, | 1736 | 'search_term' => $searchterm, |
1737 | 'search_tags' => $searchtags, | 1737 | 'search_tags' => $searchtags, |
1738 | 'redirector' => $conf->get('extras.redirector'), // Optional redirector URL. | 1738 | 'redirector' => $conf->get('redirector.url'), // Optional redirector URL. |
1739 | 'token' => $token, | 1739 | 'token' => $token, |
1740 | 'links' => $linkDisp, | 1740 | 'links' => $linkDisp, |
1741 | 'tags' => $LINKSDB->allTags(), | 1741 | 'tags' => $LINKSDB->allTags(), |
@@ -1773,7 +1773,7 @@ function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager) | |||
1773 | */ | 1773 | */ |
1774 | function computeThumbnail($conf, $url, $href = false) | 1774 | function computeThumbnail($conf, $url, $href = false) |
1775 | { | 1775 | { |
1776 | if (!$conf->get('general.enable_thumbnails')) return array(); | 1776 | if (!$conf->get('thumbnail.enable_thumbnails')) return array(); |
1777 | if ($href==false) $href=$url; | 1777 | if ($href==false) $href=$url; |
1778 | 1778 | ||
1779 | // For most hosts, the URL of the thumbnail can be easily deduced from the URL of the link. | 1779 | // For most hosts, the URL of the thumbnail can be easily deduced from the URL of the link. |
@@ -1841,7 +1841,7 @@ function computeThumbnail($conf, $url, $href = false) | |||
1841 | // So we deport the thumbnail generation in order not to slow down page generation | 1841 | // So we deport the thumbnail generation in order not to slow down page generation |
1842 | // (and we also cache the thumbnail) | 1842 | // (and we also cache the thumbnail) |
1843 | 1843 | ||
1844 | if (! $conf->get('general.enable_localcache')) return array(); // If local cache is disabled, no thumbnails for services which require the use a local cache. | 1844 | if (! $conf->get('thumbnail.enable_localcache')) return array(); // If local cache is disabled, no thumbnails for services which require the use a local cache. |
1845 | 1845 | ||
1846 | if ($domain=='flickr.com' || endsWith($domain,'.flickr.com') | 1846 | if ($domain=='flickr.com' || endsWith($domain,'.flickr.com') |
1847 | || $domain=='vimeo.com' | 1847 | || $domain=='vimeo.com' |
@@ -1996,7 +1996,7 @@ function install($conf) | |||
1996 | } else { | 1996 | } else { |
1997 | $conf->set('general.title', 'Shared links on '.escape(index_url($_SERVER))); | 1997 | $conf->set('general.title', 'Shared links on '.escape(index_url($_SERVER))); |
1998 | } | 1998 | } |
1999 | $conf->set('general.check_updates', !empty($_POST['updateCheck'])); | 1999 | $conf->set('updates.check_updates', !empty($_POST['updateCheck'])); |
2000 | try { | 2000 | try { |
2001 | // Everything is ok, let's create config file. | 2001 | // Everything is ok, let's create config file. |
2002 | $conf->write(isLoggedIn()); | 2002 | $conf->write(isLoggedIn()); |
@@ -2047,7 +2047,7 @@ function genThumbnail($conf) | |||
2047 | $sign = hash_hmac('sha256', $_GET['url'], $conf->get('credentials.salt')); | 2047 | $sign = hash_hmac('sha256', $_GET['url'], $conf->get('credentials.salt')); |
2048 | if ($sign!=$_GET['hmac']) die('Naughty boy!'); | 2048 | if ($sign!=$_GET['hmac']) die('Naughty boy!'); |
2049 | 2049 | ||
2050 | $cacheDir = $conf->get('path.thumbnails_cache', 'cache'); | 2050 | $cacheDir = $conf->get('resource.thumbnails_cache', 'cache'); |
2051 | // Let's see if we don't already have the image for this URL in the cache. | 2051 | // Let's see if we don't already have the image for this URL in the cache. |
2052 | $thumbname=hash('sha1',$_GET['url']).'.jpg'; | 2052 | $thumbname=hash('sha1',$_GET['url']).'.jpg'; |
2053 | if (is_file($cacheDir .'/'. $thumbname)) | 2053 | if (is_file($cacheDir .'/'. $thumbname)) |
diff --git a/tests/ApplicationUtilsTest.php b/tests/ApplicationUtilsTest.php index 3da72639..c37a94f0 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 = new ConfigManager(''); | 279 | $conf = new ConfigManager(''); |
280 | $conf->set('path.thumbnails_cache', 'cache'); | 280 | $conf->set('resource.thumbnails_cache', 'cache'); |
281 | $conf->set('path.config', 'data/config.php'); | 281 | $conf->set('resource.config', 'data/config.php'); |
282 | $conf->set('path.data_dir', 'data'); | 282 | $conf->set('resource.data_dir', 'data'); |
283 | $conf->set('path.datastore', 'data/datastore.php'); | 283 | $conf->set('resource.datastore', 'data/datastore.php'); |
284 | $conf->set('path.ban_file', 'data/ipbans.php'); | 284 | $conf->set('resource.ban_file', 'data/ipbans.php'); |
285 | $conf->set('path.log', 'data/log.txt'); | 285 | $conf->set('resource.log', 'data/log.txt'); |
286 | $conf->set('path.page_cache', 'pagecache'); | 286 | $conf->set('resource.page_cache', 'pagecache'); |
287 | $conf->set('path.raintpl_tmp', 'tmp'); | 287 | $conf->set('resource.raintpl_tmp', 'tmp'); |
288 | $conf->set('path.raintpl_tpl', 'tpl'); | 288 | $conf->set('resource.raintpl_tpl', 'tpl'); |
289 | $conf->set('path.update_check', 'data/lastupdatecheck.txt'); | 289 | $conf->set('resource.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 = new ConfigManager(''); | 302 | $conf = new ConfigManager(''); |
303 | $conf->set('path.thumbnails_cache', 'null/cache'); | 303 | $conf->set('resource.thumbnails_cache', 'null/cache'); |
304 | $conf->set('path.config', 'null/data/config.php'); | 304 | $conf->set('resource.config', 'null/data/config.php'); |
305 | $conf->set('path.data_dir', 'null/data'); | 305 | $conf->set('resource.data_dir', 'null/data'); |
306 | $conf->set('path.datastore', 'null/data/store.php'); | 306 | $conf->set('resource.datastore', 'null/data/store.php'); |
307 | $conf->set('path.ban_file', 'null/data/ipbans.php'); | 307 | $conf->set('resource.ban_file', 'null/data/ipbans.php'); |
308 | $conf->set('path.log', 'null/data/log.txt'); | 308 | $conf->set('resource.log', 'null/data/log.txt'); |
309 | $conf->set('path.page_cache', 'null/pagecache'); | 309 | $conf->set('resource.page_cache', 'null/pagecache'); |
310 | $conf->set('path.raintpl_tmp', 'null/tmp'); | 310 | $conf->set('resource.raintpl_tmp', 'null/tmp'); |
311 | $conf->set('path.raintpl_tpl', 'null/tpl'); | 311 | $conf->set('resource.raintpl_tpl', 'null/tpl'); |
312 | $conf->set('path.update_check', 'null/data/lastupdatecheck.txt'); | 312 | $conf->set('resource.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 5ed2df6c..6bdce08b 100644 --- a/tests/Updater/UpdaterTest.php +++ b/tests/Updater/UpdaterTest.php | |||
@@ -38,7 +38,7 @@ class UpdaterTest extends PHPUnit_Framework_TestCase | |||
38 | public function testReadEmptyUpdatesFile() | 38 | public function testReadEmptyUpdatesFile() |
39 | { | 39 | { |
40 | $this->assertEquals(array(), read_updates_file('')); | 40 | $this->assertEquals(array(), read_updates_file('')); |
41 | $updatesFile = $this->conf->get('path.data_dir') . '/updates.txt'; | 41 | $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt'; |
42 | touch($updatesFile); | 42 | touch($updatesFile); |
43 | $this->assertEquals(array(), read_updates_file($updatesFile)); | 43 | $this->assertEquals(array(), read_updates_file($updatesFile)); |
44 | unlink($updatesFile); | 44 | unlink($updatesFile); |
@@ -49,7 +49,7 @@ class UpdaterTest extends PHPUnit_Framework_TestCase | |||
49 | */ | 49 | */ |
50 | public function testReadWriteUpdatesFile() | 50 | public function testReadWriteUpdatesFile() |
51 | { | 51 | { |
52 | $updatesFile = $this->conf->get('path.data_dir') . '/updates.txt'; | 52 | $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt'; |
53 | $updatesMethods = array('m1', 'm2', 'm3'); | 53 | $updatesMethods = array('m1', 'm2', 'm3'); |
54 | 54 | ||
55 | write_updates_file($updatesFile, $updatesMethods); | 55 | write_updates_file($updatesFile, $updatesMethods); |
@@ -83,7 +83,7 @@ class UpdaterTest extends PHPUnit_Framework_TestCase | |||
83 | */ | 83 | */ |
84 | public function testWriteUpdatesFileNotWritable() | 84 | public function testWriteUpdatesFileNotWritable() |
85 | { | 85 | { |
86 | $updatesFile = $this->conf->get('path.data_dir') . '/updates.txt'; | 86 | $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt'; |
87 | touch($updatesFile); | 87 | touch($updatesFile); |
88 | chmod($updatesFile, 0444); | 88 | chmod($updatesFile, 0444); |
89 | try { | 89 | try { |
@@ -189,7 +189,7 @@ $GLOBALS[\'privateLinkByDefault\'] = true;'; | |||
189 | 189 | ||
190 | // make sure updated field is changed | 190 | // make sure updated field is changed |
191 | $this->conf->reload(); | 191 | $this->conf->reload(); |
192 | $this->assertTrue($this->conf->get('general.default_private_links')); | 192 | $this->assertTrue($this->conf->get('privacy.default_private_links')); |
193 | $this->assertFalse(is_file($optionsFile)); | 193 | $this->assertFalse(is_file($optionsFile)); |
194 | // Delete the generated file. | 194 | // Delete the generated file. |
195 | unlink($this->conf->getConfigFileExt()); | 195 | unlink($this->conf->getConfigFileExt()); |
@@ -243,8 +243,8 @@ $GLOBALS[\'privateLinkByDefault\'] = true;'; | |||
243 | // Check JSON config data. | 243 | // Check JSON config data. |
244 | $this->conf->reload(); | 244 | $this->conf->reload(); |
245 | $this->assertEquals('root', $this->conf->get('credentials.login')); | 245 | $this->assertEquals('root', $this->conf->get('credentials.login')); |
246 | $this->assertEquals('lala', $this->conf->get('extras.redirector')); | 246 | $this->assertEquals('lala', $this->conf->get('redirector.url')); |
247 | $this->assertEquals('data/datastore.php', $this->conf->get('path.datastore')); | 247 | $this->assertEquals('data/datastore.php', $this->conf->get('resource.datastore')); |
248 | $this->assertEquals('1', $this->conf->get('plugins.WALLABAG_VERSION')); | 248 | $this->assertEquals('1', $this->conf->get('plugins.WALLABAG_VERSION')); |
249 | 249 | ||
250 | rename($configFile . '.save.php', $configFile . '.php'); | 250 | rename($configFile . '.save.php', $configFile . '.php'); |
diff --git a/tests/config/ConfigJsonTest.php b/tests/config/ConfigJsonTest.php index 0960c729..359e9112 100644 --- a/tests/config/ConfigJsonTest.php +++ b/tests/config/ConfigJsonTest.php | |||
@@ -24,8 +24,8 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase | |||
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['credentials']['login']); | 26 | $this->assertEquals('root', $conf['credentials']['login']); |
27 | $this->assertEquals('lala', $conf['extras']['redirector']); | 27 | $this->assertEquals('lala', $conf['redirector']['url']); |
28 | $this->assertEquals('tests/utils/config/datastore.php', $conf['path']['datastore']); | 28 | $this->assertEquals('tests/utils/config/datastore.php', $conf['resource']['datastore']); |
29 | $this->assertEquals('1', $conf['plugins']['WALLABAG_VERSION']); | 29 | $this->assertEquals('1', $conf['plugins']['WALLABAG_VERSION']); |
30 | } | 30 | } |
31 | 31 | ||
@@ -58,11 +58,11 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase | |||
58 | 'credentials' => array( | 58 | 'credentials' => array( |
59 | 'login' => 'root', | 59 | 'login' => 'root', |
60 | ), | 60 | ), |
61 | 'path' => array( | 61 | 'resource' => array( |
62 | 'datastore' => 'data/datastore.php', | 62 | 'datastore' => 'data/datastore.php', |
63 | ), | 63 | ), |
64 | 'extras' => array( | 64 | 'redirector' => array( |
65 | 'redirector' => 'lala', | 65 | 'url' => 'lala', |
66 | ), | 66 | ), |
67 | 'plugins' => array( | 67 | 'plugins' => array( |
68 | 'WALLABAG_VERSION' => '1', | 68 | 'WALLABAG_VERSION' => '1', |
@@ -75,18 +75,18 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase | |||
75 | "credentials": { | 75 | "credentials": { |
76 | "login": "root" | 76 | "login": "root" |
77 | }, | 77 | }, |
78 | "path": { | 78 | "resource": { |
79 | "datastore": "data\/datastore.php" | 79 | "datastore": "data\/datastore.php" |
80 | }, | 80 | }, |
81 | "extras": { | 81 | "redirector": { |
82 | "redirector": "lala" | 82 | "url": "lala" |
83 | }, | 83 | }, |
84 | "plugins": { | 84 | "plugins": { |
85 | "WALLABAG_VERSION": "1" | 85 | "WALLABAG_VERSION": "1" |
86 | } | 86 | } |
87 | }'; | 87 | }'; |
88 | } else { | 88 | } else { |
89 | $expected = '{"credentials":{"login":"root"},"path":{"datastore":"data\/datastore.php"},"extras":{"redirector":"lala"},"plugins":{"WALLABAG_VERSION":"1"}}'; | 89 | $expected = '{"credentials":{"login":"root"},"resource":{"datastore":"data\/datastore.php"},"redirector":{"url":"lala"},"plugins":{"WALLABAG_VERSION":"1"}}'; |
90 | } | 90 | } |
91 | $expected = ConfigJson::getPhpHeaders() . $expected; | 91 | $expected = ConfigJson::getPhpHeaders() . $expected; |
92 | $this->assertEquals($expected, file_get_contents($dataFile)); | 92 | $this->assertEquals($expected, file_get_contents($dataFile)); |
@@ -102,10 +102,10 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase | |||
102 | $dest = 'tests/utils/config/configOverwrite.json.php'; | 102 | $dest = 'tests/utils/config/configOverwrite.json.php'; |
103 | copy($source, $dest); | 103 | copy($source, $dest); |
104 | $conf = $this->configIO->read($dest); | 104 | $conf = $this->configIO->read($dest); |
105 | $conf['extras']['redirector'] = 'blabla'; | 105 | $conf['redirector']['url'] = 'blabla'; |
106 | $this->configIO->write($dest, $conf); | 106 | $this->configIO->write($dest, $conf); |
107 | $conf = $this->configIO->read($dest); | 107 | $conf = $this->configIO->read($dest); |
108 | $this->assertEquals('blabla', $conf['extras']['redirector']); | 108 | $this->assertEquals('blabla', $conf['redirector']['url']); |
109 | unlink($dest); | 109 | unlink($dest); |
110 | } | 110 | } |
111 | 111 | ||
diff --git a/tests/utils/config/configJson.json.php b/tests/utils/config/configJson.json.php index 6a841f8a..c54882c3 100644 --- a/tests/utils/config/configJson.json.php +++ b/tests/utils/config/configJson.json.php | |||
@@ -10,17 +10,19 @@ | |||
10 | }, | 10 | }, |
11 | "general": { | 11 | "general": { |
12 | "timezone":"Europe\/Paris", | 12 | "timezone":"Europe\/Paris", |
13 | "default_private_linksheader_link":true, | ||
14 | "title": "Shaarli", | 13 | "title": "Shaarli", |
15 | "header_link": "?" | 14 | "header_link": "?" |
16 | }, | 15 | }, |
17 | "extras": { | 16 | "privacy": { |
18 | "redirector":"lala" | 17 | "default_private_links":true |
18 | }, | ||
19 | "redirector": { | ||
20 | "url":"lala" | ||
19 | }, | 21 | }, |
20 | "config": { | 22 | "config": { |
21 | "foo": "bar" | 23 | "foo": "bar" |
22 | }, | 24 | }, |
23 | "path": { | 25 | "resource": { |
24 | "datastore": "tests\/utils\/config\/datastore.php", | 26 | "datastore": "tests\/utils\/config\/datastore.php", |
25 | "data_dir": "tests\/utils\/config" | 27 | "data_dir": "tests\/utils\/config" |
26 | }, | 28 | }, |