Rename configuration key for better sections

This commit is contained in:
ArthurHoaro 2016-06-11 09:08:02 +02:00
parent 51def0d849
commit 894a3c4bf3
10 changed files with 173 additions and 167 deletions

View file

@ -145,7 +145,7 @@ public static function checkResourcePermissions($conf)
'application', 'application',
'inc', 'inc',
'plugins', 'plugins',
$conf->get('path.raintpl_tpl'), $conf->get('resource.raintpl_tpl'),
) as $path) { ) as $path) {
if (! is_readable(realpath($path))) { if (! is_readable(realpath($path))) {
$errors[] = '"'.$path.'" directory is not readable'; $errors[] = '"'.$path.'" directory is not readable';
@ -154,10 +154,10 @@ public static function checkResourcePermissions($conf)
// Check cache and data directories are readable and writeable // Check cache and data directories are readable and writeable
foreach (array( foreach (array(
$conf->get('path.thumbnails_cache'), $conf->get('resource.thumbnails_cache'),
$conf->get('path.data_dir'), $conf->get('resource.data_dir'),
$conf->get('path.page_cache'), $conf->get('resource.page_cache'),
$conf->get('path.raintpl_tmp'), $conf->get('resource.raintpl_tmp'),
) as $path) { ) as $path) {
if (! is_readable(realpath($path))) { if (! is_readable(realpath($path))) {
$errors[] = '"'.$path.'" directory is not readable'; $errors[] = '"'.$path.'" directory is not readable';
@ -170,10 +170,10 @@ public static function checkResourcePermissions($conf)
// Check configuration files are readable and writeable // Check configuration files are readable and writeable
foreach (array( foreach (array(
$conf->getConfigFileExt(), $conf->getConfigFileExt(),
$conf->get('path.datastore'), $conf->get('resource.datastore'),
$conf->get('path.ban_file'), $conf->get('resource.ban_file'),
$conf->get('path.log'), $conf->get('resource.log'),
$conf->get('path.update_check'), $conf->get('resource.update_check'),
) as $path) { ) as $path) {
if (! is_file(realpath($path))) { if (! is_file(realpath($path))) {
# the file may not exist yet # the file may not exist yet

View file

@ -41,17 +41,17 @@ private function initialize()
try { try {
$version = ApplicationUtils::checkUpdate( $version = ApplicationUtils::checkUpdate(
shaarli_version, shaarli_version,
$this->conf->get('path.update_check'), $this->conf->get('resource.update_check'),
$this->conf->get('general.check_updates_interval'), $this->conf->get('updates.check_updates_interval'),
$this->conf->get('general.check_updates'), $this->conf->get('updates.check_updates'),
isLoggedIn(), isLoggedIn(),
$this->conf->get('general.check_updates_branch') $this->conf->get('updates.check_updates_branch')
); );
$this->tpl->assign('newVersion', escape($version)); $this->tpl->assign('newVersion', escape($version));
$this->tpl->assign('versionError', ''); $this->tpl->assign('versionError', '');
} catch (Exception $exc) { } catch (Exception $exc) {
logm($this->conf->get('path.log'), $_SERVER['REMOTE_ADDR'], $exc->getMessage()); logm($this->conf->get('resource.log'), $_SERVER['REMOTE_ADDR'], $exc->getMessage());
$this->tpl->assign('newVersion', ''); $this->tpl->assign('newVersion', '');
$this->tpl->assign('versionError', escape($exc->getMessage())); $this->tpl->assign('versionError', escape($exc->getMessage()));
} }
@ -80,9 +80,9 @@ private function initialize()
$this->tpl->assign('pagetitle', $this->conf->get('pagetitle')); $this->tpl->assign('pagetitle', $this->conf->get('pagetitle'));
} }
$this->tpl->assign('shaarlititle', $this->conf->get('title', 'Shaarli')); $this->tpl->assign('shaarlititle', $this->conf->get('title', 'Shaarli'));
$this->tpl->assign('openshaarli', $this->conf->get('extras.open_shaarli', false)); $this->tpl->assign('openshaarli', $this->conf->get('security.open_shaarli', false));
$this->tpl->assign('showatom', $this->conf->get('extras.show_atom', false)); $this->tpl->assign('showatom', $this->conf->get('feed.show_atom', false));
$this->tpl->assign('hide_timestamps', $this->conf->get('extras.hide_timestamps', false)); $this->tpl->assign('hide_timestamps', $this->conf->get('privacy.hide_timestamps', false));
if (!empty($GLOBALS['plugin_errors'])) { if (!empty($GLOBALS['plugin_errors'])) {
$this->tpl->assign('plugin_errors', $GLOBALS['plugin_errors']); $this->tpl->assign('plugin_errors', $GLOBALS['plugin_errors']);
} }

View file

@ -114,8 +114,8 @@ public function getDoneUpdates()
*/ */
public function updateMethodMergeDeprecatedConfigFile() public function updateMethodMergeDeprecatedConfigFile()
{ {
if (is_file($this->conf->get('path.data_dir') . '/options.php')) { if (is_file($this->conf->get('resource.data_dir') . '/options.php')) {
include $this->conf->get('path.data_dir') . '/options.php'; include $this->conf->get('resource.data_dir') . '/options.php';
// Load GLOBALS into config // Load GLOBALS into config
$allowedKeys = array_merge(ConfigPhp::$ROOT_KEYS); $allowedKeys = array_merge(ConfigPhp::$ROOT_KEYS);
@ -126,7 +126,7 @@ public function updateMethodMergeDeprecatedConfigFile()
} }
} }
$this->conf->write($this->isLoggedIn); $this->conf->write($this->isLoggedIn);
unlink($this->conf->get('path.data_dir').'/options.php'); unlink($this->conf->get('resource.data_dir').'/options.php');
} }
return true; return true;
@ -143,7 +143,7 @@ public function updateMethodRenameDashTags()
$link['tags'] = implode(' ', array_unique(LinkFilter::tagsStrToArray($link['tags'], true))); $link['tags'] = implode(' ', array_unique(LinkFilter::tagsStrToArray($link['tags'], true)));
$this->linkDB[$link['linkdate']] = $link; $this->linkDB[$link['linkdate']] = $link;
} }
$this->linkDB->savedb($this->conf->get('path.page_cache')); $this->linkDB->savedb($this->conf->get('resource.page_cache'));
return true; return true;
} }
@ -207,7 +207,7 @@ public function escapeUnescapedConfig()
try { try {
$this->conf->set('general.title', escape($this->conf->get('general.title'))); $this->conf->set('general.title', escape($this->conf->get('general.title')));
$this->conf->set('general.header_link', escape($this->conf->get('general.header_link'))); $this->conf->set('general.header_link', escape($this->conf->get('general.header_link')));
$this->conf->set('extras.redirector', escape($this->conf->get('extras.redirector'))); $this->conf->set('redirector.url', escape($this->conf->get('redirector.url')));
$this->conf->write($this->isLoggedIn); $this->conf->write($this->isLoggedIn);
} catch (Exception $e) { } catch (Exception $e) {
error_log($e->getMessage()); error_log($e->getMessage());

View file

@ -186,8 +186,8 @@ public function write($isLoggedIn)
'general.timezone', 'general.timezone',
'general.title', 'general.title',
'general.header_link', 'general.header_link',
'general.default_private_links', 'privacy.default_private_links',
'extras.redirector', 'redirector.url',
); );
// Only logged in user can alter config. // Only logged in user can alter config.
@ -287,39 +287,43 @@ protected static function setConfig($settings, $value, &$conf)
*/ */
protected function setDefaultValues() protected function setDefaultValues()
{ {
$this->setEmpty('path.data_dir', 'data'); $this->setEmpty('resource.data_dir', 'data');
$this->setEmpty('path.config', 'data/config.php'); $this->setEmpty('resource.config', 'data/config.php');
$this->setEmpty('path.datastore', 'data/datastore.php'); $this->setEmpty('resource.datastore', 'data/datastore.php');
$this->setEmpty('path.ban_file', 'data/ipbans.php'); $this->setEmpty('resource.ban_file', 'data/ipbans.php');
$this->setEmpty('path.updates', 'data/updates.txt'); $this->setEmpty('resource.updates', 'data/updates.txt');
$this->setEmpty('path.log', 'data/log.txt'); $this->setEmpty('resource.log', 'data/log.txt');
$this->setEmpty('path.update_check', 'data/lastupdatecheck.txt'); $this->setEmpty('resource.update_check', 'data/lastupdatecheck.txt');
$this->setEmpty('path.raintpl_tpl', 'tpl/'); $this->setEmpty('resource.raintpl_tpl', 'tpl/');
$this->setEmpty('path.raintpl_tmp', 'tmp/'); $this->setEmpty('resource.raintpl_tmp', 'tmp/');
$this->setEmpty('path.thumbnails_cache', 'cache'); $this->setEmpty('resource.thumbnails_cache', 'cache');
$this->setEmpty('path.page_cache', 'pagecache'); $this->setEmpty('resource.page_cache', 'pagecache');
$this->setEmpty('security.ban_after', 4); $this->setEmpty('security.ban_after', 4);
$this->setEmpty('security.ban_duration', 1800); $this->setEmpty('security.ban_duration', 1800);
$this->setEmpty('security.session_protection_disabled', false); $this->setEmpty('security.session_protection_disabled', false);
$this->setEmpty('security.open_shaarli', false);
$this->setEmpty('general.check_updates', false);
$this->setEmpty('general.rss_permalinks', true);
$this->setEmpty('general.links_per_page', 20);
$this->setEmpty('general.default_private_links', false);
$this->setEmpty('general.enable_thumbnails', true);
$this->setEmpty('general.enable_localcache', true);
$this->setEmpty('general.check_updates_branch', 'stable');
$this->setEmpty('general.check_updates_interval', 86400);
$this->setEmpty('general.header_link', '?'); $this->setEmpty('general.header_link', '?');
$this->setEmpty('general.links_per_page', 20);
$this->setEmpty('general.enabled_plugins', array('qrcode')); $this->setEmpty('general.enabled_plugins', array('qrcode'));
$this->setEmpty('extras.show_atom', false); $this->setEmpty('updates.check_updates', false);
$this->setEmpty('extras.hide_public_links', false); $this->setEmpty('updates.check_updates_branch', 'stable');
$this->setEmpty('extras.hide_timestamps', false); $this->setEmpty('updates.check_updates_interval', 86400);
$this->setEmpty('extras.open_shaarli', false);
$this->setEmpty('extras.redirector', ''); $this->setEmpty('feed.rss_permalinks', true);
$this->setEmpty('extras.redirector_encode_url', true); $this->setEmpty('feed.show_atom', false);
$this->setEmpty('privacy.default_private_links', false);
$this->setEmpty('privacy.hide_public_links', false);
$this->setEmpty('privacy.hide_timestamps', false);
$this->setEmpty('thumbnail.enable_thumbnails', true);
$this->setEmpty('thumbnail.enable_localcache', true);
$this->setEmpty('redirector.url', '');
$this->setEmpty('redirector.encode_url', true);
$this->setEmpty('plugins', array()); $this->setEmpty('plugins', array());
} }

View file

@ -34,38 +34,38 @@ class ConfigPhp implements ConfigIO
'credentials.login' => 'login', 'credentials.login' => 'login',
'credentials.hash' => 'hash', 'credentials.hash' => 'hash',
'credentials.salt' => 'salt', 'credentials.salt' => 'salt',
'path.data_dir' => 'config.DATADIR', 'resource.data_dir' => 'config.DATADIR',
'path.config' => 'config.CONFIG_FILE', 'resource.config' => 'config.CONFIG_FILE',
'path.datastore' => 'config.DATASTORE', 'resource.datastore' => 'config.DATASTORE',
'path.updates' => 'config.UPDATES_FILE', 'resource.updates' => 'config.UPDATES_FILE',
'path.log' => 'config.LOG_FILE', 'resource.log' => 'config.LOG_FILE',
'path.update_check' => 'config.UPDATECHECK_FILENAME', 'resource.update_check' => 'config.UPDATECHECK_FILENAME',
'path.raintpl_tpl' => 'config.RAINTPL_TPL', 'resource.raintpl_tpl' => 'config.RAINTPL_TPL',
'path.raintpl_tmp' => 'config.RAINTPL_TMP', 'resource.raintpl_tmp' => 'config.RAINTPL_TMP',
'path.thumbnails_cache' => 'config.CACHEDIR', 'resource.thumbnails_cache' => 'config.CACHEDIR',
'path.page_cache' => 'config.PAGECACHE', 'resource.page_cache' => 'config.PAGECACHE',
'path.ban_file' => 'config.IPBANS_FILENAME', 'resource.ban_file' => 'config.IPBANS_FILENAME',
'security.session_protection_disabled' => 'disablesessionprotection', 'security.session_protection_disabled' => 'disablesessionprotection',
'security.ban_after' => 'config.BAN_AFTER', 'security.ban_after' => 'config.BAN_AFTER',
'security.ban_duration' => 'config.BAN_DURATION', 'security.ban_duration' => 'config.BAN_DURATION',
'general.title' => 'title', 'general.title' => 'title',
'general.timezone' => 'timezone', 'general.timezone' => 'timezone',
'general.header_link' => 'titleLink', 'general.header_link' => 'titleLink',
'general.check_updates' => 'config.ENABLE_UPDATECHECK', 'updates.check_updates' => 'config.ENABLE_UPDATECHECK',
'general.check_updates_branch' => 'config.UPDATECHECK_BRANCH', 'updates.check_updates_branch' => 'config.UPDATECHECK_BRANCH',
'general.check_updates_interval' => 'config.UPDATECHECK_INTERVAL', 'updates.check_updates_interval' => 'config.UPDATECHECK_INTERVAL',
'general.default_private_links' => 'privateLinkByDefault', 'privacy.default_private_links' => 'privateLinkByDefault',
'general.rss_permalinks' => 'config.ENABLE_RSS_PERMALINKS', 'feed.rss_permalinks' => 'config.ENABLE_RSS_PERMALINKS',
'general.links_per_page' => 'config.LINKS_PER_PAGE', 'general.links_per_page' => 'config.LINKS_PER_PAGE',
'general.enable_thumbnails' => 'config.ENABLE_THUMBNAILS', 'thumbnail.enable_thumbnails' => 'config.ENABLE_THUMBNAILS',
'general.enable_localcache' => 'config.ENABLE_LOCALCACHE', 'thumbnail.enable_localcache' => 'config.ENABLE_LOCALCACHE',
'general.enabled_plugins' => 'config.ENABLED_PLUGINS', 'general.enabled_plugins' => 'config.ENABLED_PLUGINS',
'extras.redirector' => 'redirector', 'redirector.url' => 'redirector',
'extras.redirector_encode_url' => 'config.REDIRECTOR_URLENCODE', 'redirector.encode_url' => 'config.REDIRECTOR_URLENCODE',
'extras.show_atom' => 'config.SHOW_ATOM', 'feed.show_atom' => 'config.SHOW_ATOM',
'extras.hide_public_links' => 'config.HIDE_PUBLIC_LINKS', 'privacy.hide_public_links' => 'config.HIDE_PUBLIC_LINKS',
'extras.hide_timestamps' => 'config.HIDE_TIMESTAMPS', 'privacy.hide_timestamps' => 'config.HIDE_TIMESTAMPS',
'extras.open_shaarli' => 'config.OPEN_SHAARLI', 'security.open_shaarli' => 'config.OPEN_SHAARLI',
); );
/** /**

106
index.php
View file

@ -108,8 +108,8 @@
$conf = new ConfigManager(); $conf = new ConfigManager();
$conf->setEmpty('general.timezone', date_default_timezone_get()); $conf->setEmpty('general.timezone', date_default_timezone_get());
$conf->setEmpty('general.title', 'Shared links on '. escape(index_url($_SERVER))); $conf->setEmpty('general.title', 'Shared links on '. escape(index_url($_SERVER)));
RainTPL::$tpl_dir = $conf->get('path.raintpl_tpl'); // template directory RainTPL::$tpl_dir = $conf->get('resource.raintpl_tpl'); // template directory
RainTPL::$cache_dir = $conf->get('path.raintpl_tmp'); // cache directory RainTPL::$cache_dir = $conf->get('resource.raintpl_tmp'); // cache directory
$pluginManager = new PluginManager($conf); $pluginManager = new PluginManager($conf);
$pluginManager->load($conf->get('general.enabled_plugins')); $pluginManager->load($conf->get('general.enabled_plugins'));
@ -172,7 +172,7 @@ function stripslashes_deep($value) { $value = is_array($value) ? array_map('stri
*/ */
function setup_login_state($conf) function setup_login_state($conf)
{ {
if ($conf->get('extras.open_shaarli')) { if ($conf->get('security.open_shaarli')) {
return true; return true;
} }
$userIsLoggedIn = false; // By default, we do not consider the user as logged in; $userIsLoggedIn = false; // By default, we do not consider the user as logged in;
@ -273,10 +273,10 @@ function check_auth($login, $password, $conf)
if ($login == $conf->get('credentials.login') && $hash == $conf->get('credentials.hash')) if ($login == $conf->get('credentials.login') && $hash == $conf->get('credentials.hash'))
{ // Login/password is correct. { // Login/password is correct.
fillSessionInfo($conf); fillSessionInfo($conf);
logm($conf->get('path.log'), $_SERVER['REMOTE_ADDR'], 'Login successful'); logm($conf->get('resource.log'), $_SERVER['REMOTE_ADDR'], 'Login successful');
return true; return true;
} }
logm($conf->get('path.log'), $_SERVER['REMOTE_ADDR'], 'Login failed for user '.$login); logm($conf->get('resource.log'), $_SERVER['REMOTE_ADDR'], 'Login failed for user '.$login);
return false; return false;
} }
@ -302,14 +302,14 @@ function logout() {
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
// Brute force protection system // Brute force protection system
// Several consecutive failed logins will ban the IP address for 30 minutes. // Several consecutive failed logins will ban the IP address for 30 minutes.
if (!is_file($conf->get('path.ban_file', 'data/ipbans.php'))) { if (!is_file($conf->get('resource.ban_file', 'data/ipbans.php'))) {
// FIXME! globals // FIXME! globals
file_put_contents( file_put_contents(
$conf->get('path.ban_file', 'data/ipbans.php'), $conf->get('resource.ban_file', 'data/ipbans.php'),
"<?php\n\$GLOBALS['IPBANS']=".var_export(array('FAILURES'=>array(),'BANS'=>array()),true).";\n?>" "<?php\n\$GLOBALS['IPBANS']=".var_export(array('FAILURES'=>array(),'BANS'=>array()),true).";\n?>"
); );
} }
include $conf->get('path.ban_file', 'data/ipbans.php'); include $conf->get('resource.ban_file', 'data/ipbans.php');
/** /**
* Signal a failed login. Will ban the IP if too many failures: * Signal a failed login. Will ban the IP if too many failures:
* *
@ -324,11 +324,11 @@ function ban_loginFailed($conf)
if ($gb['FAILURES'][$ip] > ($conf->get('security.ban_after') - 1)) if ($gb['FAILURES'][$ip] > ($conf->get('security.ban_after') - 1))
{ {
$gb['BANS'][$ip] = time() + $conf->get('security.ban_after', 1800); $gb['BANS'][$ip] = time() + $conf->get('security.ban_after', 1800);
logm($conf->get('path.log'), $_SERVER['REMOTE_ADDR'], 'IP address banned from login'); logm($conf->get('resource.log'), $_SERVER['REMOTE_ADDR'], 'IP address banned from login');
} }
$GLOBALS['IPBANS'] = $gb; $GLOBALS['IPBANS'] = $gb;
file_put_contents( file_put_contents(
$conf->get('path.ban_file', 'data/ipbans.php'), $conf->get('resource.ban_file', 'data/ipbans.php'),
"<?php\n\$GLOBALS['IPBANS']=".var_export($gb,true).";\n?>" "<?php\n\$GLOBALS['IPBANS']=".var_export($gb,true).";\n?>"
); );
} }
@ -345,7 +345,7 @@ function ban_loginOk($conf)
unset($gb['FAILURES'][$ip]); unset($gb['BANS'][$ip]); unset($gb['FAILURES'][$ip]); unset($gb['BANS'][$ip]);
$GLOBALS['IPBANS'] = $gb; $GLOBALS['IPBANS'] = $gb;
file_put_contents( file_put_contents(
$conf->get('path.ban_file', 'data/ipbans.php'), $conf->get('resource.ban_file', 'data/ipbans.php'),
"<?php\n\$GLOBALS['IPBANS']=".var_export($gb,true).";\n?>" "<?php\n\$GLOBALS['IPBANS']=".var_export($gb,true).";\n?>"
); );
} }
@ -365,10 +365,10 @@ function ban_canLogin($conf)
// User is banned. Check if the ban has expired: // User is banned. Check if the ban has expired:
if ($gb['BANS'][$ip]<=time()) if ($gb['BANS'][$ip]<=time())
{ // Ban expired, user can try to login again. { // Ban expired, user can try to login again.
logm($conf->get('path.log'), $_SERVER['REMOTE_ADDR'], 'Ban lifted.'); logm($conf->get('resource.log'), $_SERVER['REMOTE_ADDR'], 'Ban lifted.');
unset($gb['FAILURES'][$ip]); unset($gb['BANS'][$ip]); unset($gb['FAILURES'][$ip]); unset($gb['BANS'][$ip]);
file_put_contents( file_put_contents(
$conf->get('path.ban_file', 'data/ipbans.php'), $conf->get('resource.ban_file', 'data/ipbans.php'),
"<?php\n\$GLOBALS['IPBANS']=".var_export($gb,true).";\n?>" "<?php\n\$GLOBALS['IPBANS']=".var_export($gb,true).";\n?>"
); );
return true; // Ban has expired, user can login. return true; // Ban has expired, user can login.
@ -533,11 +533,11 @@ function showDailyRSS($conf) {
// If cached was not found (or not usable), then read the database and build the response: // If cached was not found (or not usable), then read the database and build the response:
// Read links from database (and filter private links if used it not logged in). // Read links from database (and filter private links if used it not logged in).
$LINKSDB = new LinkDB( $LINKSDB = new LinkDB(
$conf->get('path.datastore'), $conf->get('resource.datastore'),
isLoggedIn(), isLoggedIn(),
$conf->get('extras.hide_public_links'), $conf->get('privacy.hide_public_links'),
$conf->get('extras.redirector'), $conf->get('redirector.url'),
$conf->get('extras.redirector_encode_url') $conf->get('redirector.encode_url')
); );
/* Some Shaarlies may have very few links, so we need to look /* Some Shaarlies may have very few links, so we need to look
@ -590,7 +590,7 @@ function showDailyRSS($conf) {
// We pre-format some fields for proper output. // We pre-format some fields for proper output.
foreach ($linkdates as $linkdate) { foreach ($linkdates as $linkdate) {
$l = $LINKSDB[$linkdate]; $l = $LINKSDB[$linkdate];
$l['formatedDescription'] = format_description($l['description'], $conf->get('extras.redirector')); $l['formatedDescription'] = format_description($l['description'], $conf->get('redirector.url'));
$l['thumbnail'] = thumbnail($conf, $l['url']); $l['thumbnail'] = thumbnail($conf, $l['url']);
$l_date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $l['linkdate']); $l_date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $l['linkdate']);
$l['timestamp'] = $l_date->getTimestamp(); $l['timestamp'] = $l_date->getTimestamp();
@ -607,7 +607,7 @@ function showDailyRSS($conf) {
$tpl->assign('absurl', $absurl); $tpl->assign('absurl', $absurl);
$tpl->assign('links', $links); $tpl->assign('links', $links);
$tpl->assign('rssdate', escape($dayDate->format(DateTime::RSS))); $tpl->assign('rssdate', escape($dayDate->format(DateTime::RSS)));
$tpl->assign('hide_timestamps', $conf->get('extras.hide_timestamps', false)); $tpl->assign('hide_timestamps', $conf->get('privacy.hide_timestamps', false));
$html = $tpl->draw('dailyrss', $return_string=true); $html = $tpl->draw('dailyrss', $return_string=true);
echo $html . PHP_EOL; echo $html . PHP_EOL;
@ -657,7 +657,7 @@ function showDaily($pageBuilder, $LINKSDB, $conf, $pluginManager)
$taglist = explode(' ',$link['tags']); $taglist = explode(' ',$link['tags']);
uasort($taglist, 'strcasecmp'); uasort($taglist, 'strcasecmp');
$linksToDisplay[$key]['taglist']=$taglist; $linksToDisplay[$key]['taglist']=$taglist;
$linksToDisplay[$key]['formatedDescription'] = format_description($link['description'], $conf->get('extras.redirector')); $linksToDisplay[$key]['formatedDescription'] = format_description($link['description'], $conf->get('redirector.url'));
$linksToDisplay[$key]['thumbnail'] = thumbnail($conf, $link['url']); $linksToDisplay[$key]['thumbnail'] = thumbnail($conf, $link['url']);
$date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']);
$linksToDisplay[$key]['timestamp'] = $date->getTimestamp(); $linksToDisplay[$key]['timestamp'] = $date->getTimestamp();
@ -726,15 +726,15 @@ function showLinkList($PAGE, $LINKSDB, $conf, $pluginManager) {
function renderPage($conf, $pluginManager) function renderPage($conf, $pluginManager)
{ {
$LINKSDB = new LinkDB( $LINKSDB = new LinkDB(
$conf->get('path.datastore'), $conf->get('resource.datastore'),
isLoggedIn(), isLoggedIn(),
$conf->get('extras.hide_public_links'), $conf->get('privacy.hide_public_links'),
$conf->get('extras.redirector'), $conf->get('redirector.url'),
$conf->get('extras.redirector_encode_url') $conf->get('redirector.encode_url')
); );
$updater = new Updater( $updater = new Updater(
read_updates_file($conf->get('path.updates')), read_updates_file($conf->get('resource.updates')),
$LINKSDB, $LINKSDB,
$conf, $conf,
isLoggedIn() isLoggedIn()
@ -743,7 +743,7 @@ function renderPage($conf, $pluginManager)
$newUpdates = $updater->update(); $newUpdates = $updater->update();
if (! empty($newUpdates)) { if (! empty($newUpdates)) {
write_updates_file( write_updates_file(
$conf->get('path.updates'), $conf->get('resource.updates'),
$updater->getDoneUpdates() $updater->getDoneUpdates()
); );
} }
@ -782,7 +782,7 @@ function renderPage($conf, $pluginManager)
// -------- Display login form. // -------- Display login form.
if ($targetPage == Router::$PAGE_LOGIN) if ($targetPage == Router::$PAGE_LOGIN)
{ {
if ($conf->get('extras.open_shaarli')) { header('Location: ?'); exit; } // No need to login for open Shaarli if ($conf->get('security.open_shaarli')) { header('Location: ?'); exit; } // No need to login for open Shaarli
$token=''; if (ban_canLogin($conf)) $token=getToken($conf); // Do not waste token generation if not useful. $token=''; if (ban_canLogin($conf)) $token=getToken($conf); // Do not waste token generation if not useful.
$PAGE->assign('token',$token); $PAGE->assign('token',$token);
if (isset($_GET['username'])) { if (isset($_GET['username'])) {
@ -795,7 +795,7 @@ function renderPage($conf, $pluginManager)
// -------- User wants to logout. // -------- User wants to logout.
if (isset($_SERVER['QUERY_STRING']) && startsWith($_SERVER['QUERY_STRING'], 'do=logout')) if (isset($_SERVER['QUERY_STRING']) && startsWith($_SERVER['QUERY_STRING'], 'do=logout'))
{ {
invalidateCaches($conf->get('path.page_cache')); invalidateCaches($conf->get('resource.page_cache'));
logout(); logout();
header('Location: ?'); header('Location: ?');
exit; exit;
@ -895,7 +895,7 @@ function renderPage($conf, $pluginManager)
// Cache system // Cache system
$query = $_SERVER['QUERY_STRING']; $query = $_SERVER['QUERY_STRING'];
$cache = new CachedPage( $cache = new CachedPage(
$conf->get('path.page_cache'), $conf->get('resource.page_cache'),
page_url($_SERVER), page_url($_SERVER),
startsWith($query,'do='. $targetPage) && !isLoggedIn() startsWith($query,'do='. $targetPage) && !isLoggedIn()
); );
@ -908,8 +908,8 @@ function renderPage($conf, $pluginManager)
// Generate data. // Generate data.
$feedGenerator = new FeedBuilder($LINKSDB, $feedType, $_SERVER, $_GET, isLoggedIn()); $feedGenerator = new FeedBuilder($LINKSDB, $feedType, $_SERVER, $_GET, isLoggedIn());
$feedGenerator->setLocale(strtolower(setlocale(LC_COLLATE, 0))); $feedGenerator->setLocale(strtolower(setlocale(LC_COLLATE, 0)));
$feedGenerator->setHideDates($conf->get('extras.hide_timestamps') && !isLoggedIn()); $feedGenerator->setHideDates($conf->get('privacy.hide_timestamps') && !isLoggedIn());
$feedGenerator->setUsePermalinks(isset($_GET['permalinks']) || !$conf->get('general.rss_permalinks')); $feedGenerator->setUsePermalinks(isset($_GET['permalinks']) || !$conf->get('feed.rss_permalinks'));
$pshUrl = $conf->get('config.PUBSUBHUB_URL'); $pshUrl = $conf->get('config.PUBSUBHUB_URL');
if (!empty($pshUrl)) { if (!empty($pshUrl)) {
$feedGenerator->setPubsubhubUrl($pshUrl); $feedGenerator->setPubsubhubUrl($pshUrl);
@ -1072,7 +1072,7 @@ function renderPage($conf, $pluginManager)
// -------- User wants to change his/her password. // -------- User wants to change his/her password.
if ($targetPage == Router::$PAGE_CHANGEPASSWORD) if ($targetPage == Router::$PAGE_CHANGEPASSWORD)
{ {
if ($conf->get('extras.open_shaarli')) { if ($conf->get('security.open_shaarli')) {
die('You are not supposed to change a password on an Open Shaarli.'); die('You are not supposed to change a password on an Open Shaarli.');
} }
@ -1128,12 +1128,12 @@ function renderPage($conf, $pluginManager)
$conf->set('general.timezone', $tz); $conf->set('general.timezone', $tz);
$conf->set('general.title', escape($_POST['title'])); $conf->set('general.title', escape($_POST['title']));
$conf->set('general.header_link', escape($_POST['titleLink'])); $conf->set('general.header_link', escape($_POST['titleLink']));
$conf->set('extras.redirector', escape($_POST['redirector'])); $conf->set('redirector.url', escape($_POST['redirector']));
$conf->set('security.session_protection_disabled', !empty($_POST['disablesessionprotection'])); $conf->set('security.session_protection_disabled', !empty($_POST['disablesessionprotection']));
$conf->set('general.default_private_links', !empty($_POST['privateLinkByDefault'])); $conf->set('privacy.default_private_links', !empty($_POST['privateLinkByDefault']));
$conf->set('general.rss_permalinks', !empty($_POST['enableRssPermalinks'])); $conf->set('feed.rss_permalinks', !empty($_POST['enableRssPermalinks']));
$conf->set('general.check_updates', !empty($_POST['updateCheck'])); $conf->set('updates.check_updates', !empty($_POST['updateCheck']));
$conf->set('extras.hide_public_links', !empty($_POST['hidePublicLinks'])); $conf->set('privacy.hide_public_links', !empty($_POST['hidePublicLinks']));
try { try {
$conf->write(isLoggedIn()); $conf->write(isLoggedIn());
} }
@ -1154,14 +1154,14 @@ function renderPage($conf, $pluginManager)
{ {
$PAGE->assign('token',getToken($conf)); $PAGE->assign('token',getToken($conf));
$PAGE->assign('title', $conf->get('general.title')); $PAGE->assign('title', $conf->get('general.title'));
$PAGE->assign('redirector', $conf->get('extras.redirector')); $PAGE->assign('redirector', $conf->get('redirector.url'));
list($timezone_form, $timezone_js) = generateTimeZoneForm($conf->get('general.timezone')); list($timezone_form, $timezone_js) = generateTimeZoneForm($conf->get('general.timezone'));
$PAGE->assign('timezone_form', $timezone_form); $PAGE->assign('timezone_form', $timezone_form);
$PAGE->assign('timezone_js',$timezone_js); $PAGE->assign('timezone_js',$timezone_js);
$PAGE->assign('private_links_default', $conf->get('general.default_private_links', false)); $PAGE->assign('private_links_default', $conf->get('privacy.default_private_links', false));
$PAGE->assign('enable_rss_permalinks', $conf->get('general.rss_permalinks', false)); $PAGE->assign('enable_rss_permalinks', $conf->get('feed.rss_permalinks', false));
$PAGE->assign('enable_update_check', $conf->get('general.check_updates', true)); $PAGE->assign('enable_update_check', $conf->get('updates.check_updates', true));
$PAGE->assign('hide_public_links', $conf->get('extras.hide_public_links', false)); $PAGE->assign('hide_public_links', $conf->get('privacy.hide_public_links', false));
$PAGE->renderPage('configure'); $PAGE->renderPage('configure');
exit; exit;
} }
@ -1193,7 +1193,7 @@ function renderPage($conf, $pluginManager)
$value['tags']=trim(implode(' ',$tags)); $value['tags']=trim(implode(' ',$tags));
$LINKSDB[$key]=$value; $LINKSDB[$key]=$value;
} }
$LINKSDB->savedb($conf->get('path.page_cache')); $LINKSDB->savedb($conf->get('resource.page_cache'));
echo '<script>alert("Tag was removed from '.count($linksToAlter).' links.");document.location=\'?\';</script>'; echo '<script>alert("Tag was removed from '.count($linksToAlter).' links.");document.location=\'?\';</script>';
exit; exit;
} }
@ -1210,7 +1210,7 @@ function renderPage($conf, $pluginManager)
$value['tags']=trim(implode(' ',$tags)); $value['tags']=trim(implode(' ',$tags));
$LINKSDB[$key]=$value; $LINKSDB[$key]=$value;
} }
$LINKSDB->savedb($conf->get('path.page_cache')); // Save to disk. $LINKSDB->savedb($conf->get('resource.page_cache')); // Save to disk.
echo '<script>alert("Tag was renamed in '.count($linksToAlter).' links.");document.location=\'?searchtags='.urlencode($_POST['totag']).'\';</script>'; echo '<script>alert("Tag was renamed in '.count($linksToAlter).' links.");document.location=\'?searchtags='.urlencode($_POST['totag']).'\';</script>';
exit; exit;
} }
@ -1261,7 +1261,7 @@ function renderPage($conf, $pluginManager)
$pluginManager->executeHooks('save_link', $link); $pluginManager->executeHooks('save_link', $link);
$LINKSDB[$linkdate] = $link; $LINKSDB[$linkdate] = $link;
$LINKSDB->savedb($conf->get('path.page_cache')); $LINKSDB->savedb($conf->get('resource.page_cache'));
pubsubhub($conf); pubsubhub($conf);
// If we are called from the bookmarklet, we must close the popup: // If we are called from the bookmarklet, we must close the popup:
@ -1303,7 +1303,7 @@ function renderPage($conf, $pluginManager)
$pluginManager->executeHooks('delete_link', $LINKSDB[$linkdate]); $pluginManager->executeHooks('delete_link', $LINKSDB[$linkdate]);
unset($LINKSDB[$linkdate]); unset($LINKSDB[$linkdate]);
$LINKSDB->savedb('path.page_cache'); // save to disk $LINKSDB->savedb('resource.page_cache'); // save to disk
// If we are called from the bookmarklet, we must close the popup: // If we are called from the bookmarklet, we must close the popup:
if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { echo '<script>self.close();</script>'; exit; } if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { echo '<script>self.close();</script>'; exit; }
@ -1629,7 +1629,7 @@ function importFile($LINKSDB, $conf)
} }
} }
} }
$LINKSDB->savedb($conf->get('path.page_cache')); $LINKSDB->savedb($conf->get('resource.page_cache'));
echo '<script>alert("File '.json_encode($filename).' ('.$filesize.' bytes) was successfully processed: '.$import_count.' links imported.");document.location=\'?\';</script>'; echo '<script>alert("File '.json_encode($filename).' ('.$filesize.' bytes) was successfully processed: '.$import_count.' links imported.");document.location=\'?\';</script>';
} }
@ -1693,7 +1693,7 @@ function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager)
while ($i<$end && $i<count($keys)) while ($i<$end && $i<count($keys))
{ {
$link = $linksToDisplay[$keys[$i]]; $link = $linksToDisplay[$keys[$i]];
$link['description'] = format_description($link['description'], $conf->get('extras.redirector')); $link['description'] = format_description($link['description'], $conf->get('redirector.url'));
$classLi = ($i % 2) != 0 ? '' : 'publicLinkHightLight'; $classLi = ($i % 2) != 0 ? '' : 'publicLinkHightLight';
$link['class'] = $link['private'] == 0 ? $classLi : 'private'; $link['class'] = $link['private'] == 0 ? $classLi : 'private';
$date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']);
@ -1735,7 +1735,7 @@ function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager)
'result_count' => count($linksToDisplay), 'result_count' => count($linksToDisplay),
'search_term' => $searchterm, 'search_term' => $searchterm,
'search_tags' => $searchtags, 'search_tags' => $searchtags,
'redirector' => $conf->get('extras.redirector'), // Optional redirector URL. 'redirector' => $conf->get('redirector.url'), // Optional redirector URL.
'token' => $token, 'token' => $token,
'links' => $linkDisp, 'links' => $linkDisp,
'tags' => $LINKSDB->allTags(), 'tags' => $LINKSDB->allTags(),
@ -1773,7 +1773,7 @@ function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager)
*/ */
function computeThumbnail($conf, $url, $href = false) function computeThumbnail($conf, $url, $href = false)
{ {
if (!$conf->get('general.enable_thumbnails')) return array(); if (!$conf->get('thumbnail.enable_thumbnails')) return array();
if ($href==false) $href=$url; if ($href==false) $href=$url;
// For most hosts, the URL of the thumbnail can be easily deduced from the URL of the link. // 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)
// So we deport the thumbnail generation in order not to slow down page generation // So we deport the thumbnail generation in order not to slow down page generation
// (and we also cache the thumbnail) // (and we also cache the thumbnail)
if (! $conf->get('general.enable_localcache')) return array(); // If local cache is disabled, no thumbnails for services which require the use a local cache. if (! $conf->get('thumbnail.enable_localcache')) return array(); // If local cache is disabled, no thumbnails for services which require the use a local cache.
if ($domain=='flickr.com' || endsWith($domain,'.flickr.com') if ($domain=='flickr.com' || endsWith($domain,'.flickr.com')
|| $domain=='vimeo.com' || $domain=='vimeo.com'
@ -1996,7 +1996,7 @@ function install($conf)
} else { } else {
$conf->set('general.title', 'Shared links on '.escape(index_url($_SERVER))); $conf->set('general.title', 'Shared links on '.escape(index_url($_SERVER)));
} }
$conf->set('general.check_updates', !empty($_POST['updateCheck'])); $conf->set('updates.check_updates', !empty($_POST['updateCheck']));
try { try {
// Everything is ok, let's create config file. // Everything is ok, let's create config file.
$conf->write(isLoggedIn()); $conf->write(isLoggedIn());
@ -2047,7 +2047,7 @@ function genThumbnail($conf)
$sign = hash_hmac('sha256', $_GET['url'], $conf->get('credentials.salt')); $sign = hash_hmac('sha256', $_GET['url'], $conf->get('credentials.salt'));
if ($sign!=$_GET['hmac']) die('Naughty boy!'); if ($sign!=$_GET['hmac']) die('Naughty boy!');
$cacheDir = $conf->get('path.thumbnails_cache', 'cache'); $cacheDir = $conf->get('resource.thumbnails_cache', 'cache');
// Let's see if we don't already have the image for this URL in the cache. // Let's see if we don't already have the image for this URL in the cache.
$thumbname=hash('sha1',$_GET['url']).'.jpg'; $thumbname=hash('sha1',$_GET['url']).'.jpg';
if (is_file($cacheDir .'/'. $thumbname)) if (is_file($cacheDir .'/'. $thumbname))

View file

@ -277,16 +277,16 @@ public function testCheckSupportedPHPVersion52()
public function testCheckCurrentResourcePermissions() public function testCheckCurrentResourcePermissions()
{ {
$conf = new ConfigManager(''); $conf = new ConfigManager('');
$conf->set('path.thumbnails_cache', 'cache'); $conf->set('resource.thumbnails_cache', 'cache');
$conf->set('path.config', 'data/config.php'); $conf->set('resource.config', 'data/config.php');
$conf->set('path.data_dir', 'data'); $conf->set('resource.data_dir', 'data');
$conf->set('path.datastore', 'data/datastore.php'); $conf->set('resource.datastore', 'data/datastore.php');
$conf->set('path.ban_file', 'data/ipbans.php'); $conf->set('resource.ban_file', 'data/ipbans.php');
$conf->set('path.log', 'data/log.txt'); $conf->set('resource.log', 'data/log.txt');
$conf->set('path.page_cache', 'pagecache'); $conf->set('resource.page_cache', 'pagecache');
$conf->set('path.raintpl_tmp', 'tmp'); $conf->set('resource.raintpl_tmp', 'tmp');
$conf->set('path.raintpl_tpl', 'tpl'); $conf->set('resource.raintpl_tpl', 'tpl');
$conf->set('path.update_check', 'data/lastupdatecheck.txt'); $conf->set('resource.update_check', 'data/lastupdatecheck.txt');
$this->assertEquals( $this->assertEquals(
array(), array(),
@ -300,16 +300,16 @@ public function testCheckCurrentResourcePermissions()
public function testCheckCurrentResourcePermissionsErrors() public function testCheckCurrentResourcePermissionsErrors()
{ {
$conf = new ConfigManager(''); $conf = new ConfigManager('');
$conf->set('path.thumbnails_cache', 'null/cache'); $conf->set('resource.thumbnails_cache', 'null/cache');
$conf->set('path.config', 'null/data/config.php'); $conf->set('resource.config', 'null/data/config.php');
$conf->set('path.data_dir', 'null/data'); $conf->set('resource.data_dir', 'null/data');
$conf->set('path.datastore', 'null/data/store.php'); $conf->set('resource.datastore', 'null/data/store.php');
$conf->set('path.ban_file', 'null/data/ipbans.php'); $conf->set('resource.ban_file', 'null/data/ipbans.php');
$conf->set('path.log', 'null/data/log.txt'); $conf->set('resource.log', 'null/data/log.txt');
$conf->set('path.page_cache', 'null/pagecache'); $conf->set('resource.page_cache', 'null/pagecache');
$conf->set('path.raintpl_tmp', 'null/tmp'); $conf->set('resource.raintpl_tmp', 'null/tmp');
$conf->set('path.raintpl_tpl', 'null/tpl'); $conf->set('resource.raintpl_tpl', 'null/tpl');
$conf->set('path.update_check', 'null/data/lastupdatecheck.txt'); $conf->set('resource.update_check', 'null/data/lastupdatecheck.txt');
$this->assertEquals( $this->assertEquals(
array( array(
'"null/tpl" directory is not readable', '"null/tpl" directory is not readable',

View file

@ -38,7 +38,7 @@ public function setUp()
public function testReadEmptyUpdatesFile() public function testReadEmptyUpdatesFile()
{ {
$this->assertEquals(array(), read_updates_file('')); $this->assertEquals(array(), read_updates_file(''));
$updatesFile = $this->conf->get('path.data_dir') . '/updates.txt'; $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
touch($updatesFile); touch($updatesFile);
$this->assertEquals(array(), read_updates_file($updatesFile)); $this->assertEquals(array(), read_updates_file($updatesFile));
unlink($updatesFile); unlink($updatesFile);
@ -49,7 +49,7 @@ public function testReadEmptyUpdatesFile()
*/ */
public function testReadWriteUpdatesFile() public function testReadWriteUpdatesFile()
{ {
$updatesFile = $this->conf->get('path.data_dir') . '/updates.txt'; $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
$updatesMethods = array('m1', 'm2', 'm3'); $updatesMethods = array('m1', 'm2', 'm3');
write_updates_file($updatesFile, $updatesMethods); write_updates_file($updatesFile, $updatesMethods);
@ -83,7 +83,7 @@ public function testWriteEmptyUpdatesFile()
*/ */
public function testWriteUpdatesFileNotWritable() public function testWriteUpdatesFileNotWritable()
{ {
$updatesFile = $this->conf->get('path.data_dir') . '/updates.txt'; $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
touch($updatesFile); touch($updatesFile);
chmod($updatesFile, 0444); chmod($updatesFile, 0444);
try { try {
@ -189,7 +189,7 @@ public function testUpdateMergeDeprecatedConfig()
// make sure updated field is changed // make sure updated field is changed
$this->conf->reload(); $this->conf->reload();
$this->assertTrue($this->conf->get('general.default_private_links')); $this->assertTrue($this->conf->get('privacy.default_private_links'));
$this->assertFalse(is_file($optionsFile)); $this->assertFalse(is_file($optionsFile));
// Delete the generated file. // Delete the generated file.
unlink($this->conf->getConfigFileExt()); unlink($this->conf->getConfigFileExt());
@ -243,8 +243,8 @@ public function testConfigToJson()
// Check JSON config data. // Check JSON config data.
$this->conf->reload(); $this->conf->reload();
$this->assertEquals('root', $this->conf->get('credentials.login')); $this->assertEquals('root', $this->conf->get('credentials.login'));
$this->assertEquals('lala', $this->conf->get('extras.redirector')); $this->assertEquals('lala', $this->conf->get('redirector.url'));
$this->assertEquals('data/datastore.php', $this->conf->get('path.datastore')); $this->assertEquals('data/datastore.php', $this->conf->get('resource.datastore'));
$this->assertEquals('1', $this->conf->get('plugins.WALLABAG_VERSION')); $this->assertEquals('1', $this->conf->get('plugins.WALLABAG_VERSION'));
rename($configFile . '.save.php', $configFile . '.php'); rename($configFile . '.save.php', $configFile . '.php');

View file

@ -24,8 +24,8 @@ public function testRead()
{ {
$conf = $this->configIO->read('tests/utils/config/configJson.json.php'); $conf = $this->configIO->read('tests/utils/config/configJson.json.php');
$this->assertEquals('root', $conf['credentials']['login']); $this->assertEquals('root', $conf['credentials']['login']);
$this->assertEquals('lala', $conf['extras']['redirector']); $this->assertEquals('lala', $conf['redirector']['url']);
$this->assertEquals('tests/utils/config/datastore.php', $conf['path']['datastore']); $this->assertEquals('tests/utils/config/datastore.php', $conf['resource']['datastore']);
$this->assertEquals('1', $conf['plugins']['WALLABAG_VERSION']); $this->assertEquals('1', $conf['plugins']['WALLABAG_VERSION']);
} }
@ -58,11 +58,11 @@ public function testWriteNew()
'credentials' => array( 'credentials' => array(
'login' => 'root', 'login' => 'root',
), ),
'path' => array( 'resource' => array(
'datastore' => 'data/datastore.php', 'datastore' => 'data/datastore.php',
), ),
'extras' => array( 'redirector' => array(
'redirector' => 'lala', 'url' => 'lala',
), ),
'plugins' => array( 'plugins' => array(
'WALLABAG_VERSION' => '1', 'WALLABAG_VERSION' => '1',
@ -75,18 +75,18 @@ public function testWriteNew()
"credentials": { "credentials": {
"login": "root" "login": "root"
}, },
"path": { "resource": {
"datastore": "data\/datastore.php" "datastore": "data\/datastore.php"
}, },
"extras": { "redirector": {
"redirector": "lala" "url": "lala"
}, },
"plugins": { "plugins": {
"WALLABAG_VERSION": "1" "WALLABAG_VERSION": "1"
} }
}'; }';
} else { } else {
$expected = '{"credentials":{"login":"root"},"path":{"datastore":"data\/datastore.php"},"extras":{"redirector":"lala"},"plugins":{"WALLABAG_VERSION":"1"}}'; $expected = '{"credentials":{"login":"root"},"resource":{"datastore":"data\/datastore.php"},"redirector":{"url":"lala"},"plugins":{"WALLABAG_VERSION":"1"}}';
} }
$expected = ConfigJson::getPhpHeaders() . $expected; $expected = ConfigJson::getPhpHeaders() . $expected;
$this->assertEquals($expected, file_get_contents($dataFile)); $this->assertEquals($expected, file_get_contents($dataFile));
@ -102,10 +102,10 @@ public function testOverwrite()
$dest = 'tests/utils/config/configOverwrite.json.php'; $dest = 'tests/utils/config/configOverwrite.json.php';
copy($source, $dest); copy($source, $dest);
$conf = $this->configIO->read($dest); $conf = $this->configIO->read($dest);
$conf['extras']['redirector'] = 'blabla'; $conf['redirector']['url'] = 'blabla';
$this->configIO->write($dest, $conf); $this->configIO->write($dest, $conf);
$conf = $this->configIO->read($dest); $conf = $this->configIO->read($dest);
$this->assertEquals('blabla', $conf['extras']['redirector']); $this->assertEquals('blabla', $conf['redirector']['url']);
unlink($dest); unlink($dest);
} }

View file

@ -10,17 +10,19 @@
}, },
"general": { "general": {
"timezone":"Europe\/Paris", "timezone":"Europe\/Paris",
"default_private_linksheader_link":true,
"title": "Shaarli", "title": "Shaarli",
"header_link": "?" "header_link": "?"
}, },
"extras": { "privacy": {
"redirector":"lala" "default_private_links":true
},
"redirector": {
"url":"lala"
}, },
"config": { "config": {
"foo": "bar" "foo": "bar"
}, },
"path": { "resource": {
"datastore": "tests\/utils\/config\/datastore.php", "datastore": "tests\/utils\/config\/datastore.php",
"data_dir": "tests\/utils\/config" "data_dir": "tests\/utils\/config"
}, },