'application',
'inc',
'plugins',
- $conf->get('path.raintpl_tpl'),
+ $conf->get('resource.raintpl_tpl'),
) as $path) {
if (! is_readable(realpath($path))) {
$errors[] = '"'.$path.'" directory is not readable';
// Check cache and data directories are readable and writeable
foreach (array(
- $conf->get('path.thumbnails_cache'),
- $conf->get('path.data_dir'),
- $conf->get('path.page_cache'),
- $conf->get('path.raintpl_tmp'),
+ $conf->get('resource.thumbnails_cache'),
+ $conf->get('resource.data_dir'),
+ $conf->get('resource.page_cache'),
+ $conf->get('resource.raintpl_tmp'),
) as $path) {
if (! is_readable(realpath($path))) {
$errors[] = '"'.$path.'" directory is not readable';
// Check configuration files are readable and writeable
foreach (array(
$conf->getConfigFileExt(),
- $conf->get('path.datastore'),
- $conf->get('path.ban_file'),
- $conf->get('path.log'),
- $conf->get('path.update_check'),
+ $conf->get('resource.datastore'),
+ $conf->get('resource.ban_file'),
+ $conf->get('resource.log'),
+ $conf->get('resource.update_check'),
) as $path) {
if (! is_file(realpath($path))) {
# the file may not exist yet
try {
$version = ApplicationUtils::checkUpdate(
shaarli_version,
- $this->conf->get('path.update_check'),
- $this->conf->get('general.check_updates_interval'),
- $this->conf->get('general.check_updates'),
+ $this->conf->get('resource.update_check'),
+ $this->conf->get('updates.check_updates_interval'),
+ $this->conf->get('updates.check_updates'),
isLoggedIn(),
- $this->conf->get('general.check_updates_branch')
+ $this->conf->get('updates.check_updates_branch')
);
$this->tpl->assign('newVersion', escape($version));
$this->tpl->assign('versionError', '');
} 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('versionError', escape($exc->getMessage()));
}
$this->tpl->assign('pagetitle', $this->conf->get('pagetitle'));
}
$this->tpl->assign('shaarlititle', $this->conf->get('title', 'Shaarli'));
- $this->tpl->assign('openshaarli', $this->conf->get('extras.open_shaarli', false));
- $this->tpl->assign('showatom', $this->conf->get('extras.show_atom', false));
- $this->tpl->assign('hide_timestamps', $this->conf->get('extras.hide_timestamps', false));
+ $this->tpl->assign('openshaarli', $this->conf->get('security.open_shaarli', false));
+ $this->tpl->assign('showatom', $this->conf->get('feed.show_atom', false));
+ $this->tpl->assign('hide_timestamps', $this->conf->get('privacy.hide_timestamps', false));
if (!empty($GLOBALS['plugin_errors'])) {
$this->tpl->assign('plugin_errors', $GLOBALS['plugin_errors']);
}
*/
public function updateMethodMergeDeprecatedConfigFile()
{
- if (is_file($this->conf->get('path.data_dir') . '/options.php')) {
- include $this->conf->get('path.data_dir') . '/options.php';
+ if (is_file($this->conf->get('resource.data_dir') . '/options.php')) {
+ include $this->conf->get('resource.data_dir') . '/options.php';
// Load GLOBALS into config
$allowedKeys = array_merge(ConfigPhp::$ROOT_KEYS);
}
}
$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;
$link['tags'] = implode(' ', array_unique(LinkFilter::tagsStrToArray($link['tags'], true)));
$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;
}
try {
$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('extras.redirector', escape($this->conf->get('extras.redirector')));
+ $this->conf->set('redirector.url', escape($this->conf->get('redirector.url')));
$this->conf->write($this->isLoggedIn);
} catch (Exception $e) {
error_log($e->getMessage());
'general.timezone',
'general.title',
'general.header_link',
- 'general.default_private_links',
- 'extras.redirector',
+ 'privacy.default_private_links',
+ 'redirector.url',
);
// Only logged in user can alter config.
*/
protected function setDefaultValues()
{
- $this->setEmpty('path.data_dir', 'data');
- $this->setEmpty('path.config', 'data/config.php');
- $this->setEmpty('path.datastore', 'data/datastore.php');
- $this->setEmpty('path.ban_file', 'data/ipbans.php');
- $this->setEmpty('path.updates', 'data/updates.txt');
- $this->setEmpty('path.log', 'data/log.txt');
- $this->setEmpty('path.update_check', 'data/lastupdatecheck.txt');
- $this->setEmpty('path.raintpl_tpl', 'tpl/');
- $this->setEmpty('path.raintpl_tmp', 'tmp/');
- $this->setEmpty('path.thumbnails_cache', 'cache');
- $this->setEmpty('path.page_cache', 'pagecache');
+ $this->setEmpty('resource.data_dir', 'data');
+ $this->setEmpty('resource.config', 'data/config.php');
+ $this->setEmpty('resource.datastore', 'data/datastore.php');
+ $this->setEmpty('resource.ban_file', 'data/ipbans.php');
+ $this->setEmpty('resource.updates', 'data/updates.txt');
+ $this->setEmpty('resource.log', 'data/log.txt');
+ $this->setEmpty('resource.update_check', 'data/lastupdatecheck.txt');
+ $this->setEmpty('resource.raintpl_tpl', 'tpl/');
+ $this->setEmpty('resource.raintpl_tmp', 'tmp/');
+ $this->setEmpty('resource.thumbnails_cache', 'cache');
+ $this->setEmpty('resource.page_cache', 'pagecache');
$this->setEmpty('security.ban_after', 4);
$this->setEmpty('security.ban_duration', 1800);
$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.links_per_page', 20);
$this->setEmpty('general.enabled_plugins', array('qrcode'));
- $this->setEmpty('extras.show_atom', false);
- $this->setEmpty('extras.hide_public_links', false);
- $this->setEmpty('extras.hide_timestamps', false);
- $this->setEmpty('extras.open_shaarli', false);
- $this->setEmpty('extras.redirector', '');
- $this->setEmpty('extras.redirector_encode_url', true);
+ $this->setEmpty('updates.check_updates', false);
+ $this->setEmpty('updates.check_updates_branch', 'stable');
+ $this->setEmpty('updates.check_updates_interval', 86400);
+
+ $this->setEmpty('feed.rss_permalinks', 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());
}
'credentials.login' => 'login',
'credentials.hash' => 'hash',
'credentials.salt' => 'salt',
- 'path.data_dir' => 'config.DATADIR',
- 'path.config' => 'config.CONFIG_FILE',
- 'path.datastore' => 'config.DATASTORE',
- 'path.updates' => 'config.UPDATES_FILE',
- 'path.log' => 'config.LOG_FILE',
- 'path.update_check' => 'config.UPDATECHECK_FILENAME',
- 'path.raintpl_tpl' => 'config.RAINTPL_TPL',
- 'path.raintpl_tmp' => 'config.RAINTPL_TMP',
- 'path.thumbnails_cache' => 'config.CACHEDIR',
- 'path.page_cache' => 'config.PAGECACHE',
- 'path.ban_file' => 'config.IPBANS_FILENAME',
+ 'resource.data_dir' => 'config.DATADIR',
+ 'resource.config' => 'config.CONFIG_FILE',
+ 'resource.datastore' => 'config.DATASTORE',
+ 'resource.updates' => 'config.UPDATES_FILE',
+ 'resource.log' => 'config.LOG_FILE',
+ 'resource.update_check' => 'config.UPDATECHECK_FILENAME',
+ 'resource.raintpl_tpl' => 'config.RAINTPL_TPL',
+ 'resource.raintpl_tmp' => 'config.RAINTPL_TMP',
+ 'resource.thumbnails_cache' => 'config.CACHEDIR',
+ 'resource.page_cache' => 'config.PAGECACHE',
+ 'resource.ban_file' => 'config.IPBANS_FILENAME',
'security.session_protection_disabled' => 'disablesessionprotection',
'security.ban_after' => 'config.BAN_AFTER',
'security.ban_duration' => 'config.BAN_DURATION',
'general.title' => 'title',
'general.timezone' => 'timezone',
'general.header_link' => 'titleLink',
- 'general.check_updates' => 'config.ENABLE_UPDATECHECK',
- 'general.check_updates_branch' => 'config.UPDATECHECK_BRANCH',
- 'general.check_updates_interval' => 'config.UPDATECHECK_INTERVAL',
- 'general.default_private_links' => 'privateLinkByDefault',
- 'general.rss_permalinks' => 'config.ENABLE_RSS_PERMALINKS',
+ 'updates.check_updates' => 'config.ENABLE_UPDATECHECK',
+ 'updates.check_updates_branch' => 'config.UPDATECHECK_BRANCH',
+ 'updates.check_updates_interval' => 'config.UPDATECHECK_INTERVAL',
+ 'privacy.default_private_links' => 'privateLinkByDefault',
+ 'feed.rss_permalinks' => 'config.ENABLE_RSS_PERMALINKS',
'general.links_per_page' => 'config.LINKS_PER_PAGE',
- 'general.enable_thumbnails' => 'config.ENABLE_THUMBNAILS',
- 'general.enable_localcache' => 'config.ENABLE_LOCALCACHE',
+ 'thumbnail.enable_thumbnails' => 'config.ENABLE_THUMBNAILS',
+ 'thumbnail.enable_localcache' => 'config.ENABLE_LOCALCACHE',
'general.enabled_plugins' => 'config.ENABLED_PLUGINS',
- 'extras.redirector' => 'redirector',
- 'extras.redirector_encode_url' => 'config.REDIRECTOR_URLENCODE',
- 'extras.show_atom' => 'config.SHOW_ATOM',
- 'extras.hide_public_links' => 'config.HIDE_PUBLIC_LINKS',
- 'extras.hide_timestamps' => 'config.HIDE_TIMESTAMPS',
- 'extras.open_shaarli' => 'config.OPEN_SHAARLI',
+ 'redirector.url' => 'redirector',
+ 'redirector.encode_url' => 'config.REDIRECTOR_URLENCODE',
+ 'feed.show_atom' => 'config.SHOW_ATOM',
+ 'privacy.hide_public_links' => 'config.HIDE_PUBLIC_LINKS',
+ 'privacy.hide_timestamps' => 'config.HIDE_TIMESTAMPS',
+ 'security.open_shaarli' => 'config.OPEN_SHAARLI',
);
/**
$conf = new ConfigManager();
$conf->setEmpty('general.timezone', date_default_timezone_get());
$conf->setEmpty('general.title', 'Shared links on '. escape(index_url($_SERVER)));
-RainTPL::$tpl_dir = $conf->get('path.raintpl_tpl'); // template directory
-RainTPL::$cache_dir = $conf->get('path.raintpl_tmp'); // cache directory
+RainTPL::$tpl_dir = $conf->get('resource.raintpl_tpl'); // template directory
+RainTPL::$cache_dir = $conf->get('resource.raintpl_tmp'); // cache directory
$pluginManager = new PluginManager($conf);
$pluginManager->load($conf->get('general.enabled_plugins'));
*/
function setup_login_state($conf)
{
- if ($conf->get('extras.open_shaarli')) {
+ if ($conf->get('security.open_shaarli')) {
return true;
}
$userIsLoggedIn = false; // By default, we do not consider the user as logged in;
if ($login == $conf->get('credentials.login') && $hash == $conf->get('credentials.hash'))
{ // Login/password is correct.
fillSessionInfo($conf);
- logm($conf->get('path.log'), $_SERVER['REMOTE_ADDR'], 'Login successful');
+ logm($conf->get('resource.log'), $_SERVER['REMOTE_ADDR'], 'Login successful');
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;
}
// ------------------------------------------------------------------------------------------
// Brute force protection system
// 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
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?>"
);
}
-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:
*
if ($gb['FAILURES'][$ip] > ($conf->get('security.ban_after') - 1))
{
$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;
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?>"
);
}
unset($gb['FAILURES'][$ip]); unset($gb['BANS'][$ip]);
$GLOBALS['IPBANS'] = $gb;
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?>"
);
}
// User is banned. Check if the ban has expired:
if ($gb['BANS'][$ip]<=time())
{ // 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]);
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?>"
);
return true; // Ban has expired, user can login.
// 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).
$LINKSDB = new LinkDB(
- $conf->get('path.datastore'),
+ $conf->get('resource.datastore'),
isLoggedIn(),
- $conf->get('extras.hide_public_links'),
- $conf->get('extras.redirector'),
- $conf->get('extras.redirector_encode_url')
+ $conf->get('privacy.hide_public_links'),
+ $conf->get('redirector.url'),
+ $conf->get('redirector.encode_url')
);
/* Some Shaarlies may have very few links, so we need to look
// We pre-format some fields for proper output.
foreach ($linkdates as $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_date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $l['linkdate']);
$l['timestamp'] = $l_date->getTimestamp();
$tpl->assign('absurl', $absurl);
$tpl->assign('links', $links);
$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);
echo $html . PHP_EOL;
$taglist = explode(' ',$link['tags']);
uasort($taglist, 'strcasecmp');
$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']);
$date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']);
$linksToDisplay[$key]['timestamp'] = $date->getTimestamp();
function renderPage($conf, $pluginManager)
{
$LINKSDB = new LinkDB(
- $conf->get('path.datastore'),
+ $conf->get('resource.datastore'),
isLoggedIn(),
- $conf->get('extras.hide_public_links'),
- $conf->get('extras.redirector'),
- $conf->get('extras.redirector_encode_url')
+ $conf->get('privacy.hide_public_links'),
+ $conf->get('redirector.url'),
+ $conf->get('redirector.encode_url')
);
$updater = new Updater(
- read_updates_file($conf->get('path.updates')),
+ read_updates_file($conf->get('resource.updates')),
$LINKSDB,
$conf,
isLoggedIn()
$newUpdates = $updater->update();
if (! empty($newUpdates)) {
write_updates_file(
- $conf->get('path.updates'),
+ $conf->get('resource.updates'),
$updater->getDoneUpdates()
);
}
// -------- Display login form.
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.
$PAGE->assign('token',$token);
if (isset($_GET['username'])) {
// -------- User wants to 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();
header('Location: ?');
exit;
// Cache system
$query = $_SERVER['QUERY_STRING'];
$cache = new CachedPage(
- $conf->get('path.page_cache'),
+ $conf->get('resource.page_cache'),
page_url($_SERVER),
startsWith($query,'do='. $targetPage) && !isLoggedIn()
);
// Generate data.
$feedGenerator = new FeedBuilder($LINKSDB, $feedType, $_SERVER, $_GET, isLoggedIn());
$feedGenerator->setLocale(strtolower(setlocale(LC_COLLATE, 0)));
- $feedGenerator->setHideDates($conf->get('extras.hide_timestamps') && !isLoggedIn());
- $feedGenerator->setUsePermalinks(isset($_GET['permalinks']) || !$conf->get('general.rss_permalinks'));
+ $feedGenerator->setHideDates($conf->get('privacy.hide_timestamps') && !isLoggedIn());
+ $feedGenerator->setUsePermalinks(isset($_GET['permalinks']) || !$conf->get('feed.rss_permalinks'));
$pshUrl = $conf->get('config.PUBSUBHUB_URL');
if (!empty($pshUrl)) {
$feedGenerator->setPubsubhubUrl($pshUrl);
// -------- User wants to change his/her password.
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.');
}
$conf->set('general.timezone', $tz);
$conf->set('general.title', escape($_POST['title']));
$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('general.default_private_links', !empty($_POST['privateLinkByDefault']));
- $conf->set('general.rss_permalinks', !empty($_POST['enableRssPermalinks']));
- $conf->set('general.check_updates', !empty($_POST['updateCheck']));
- $conf->set('extras.hide_public_links', !empty($_POST['hidePublicLinks']));
+ $conf->set('privacy.default_private_links', !empty($_POST['privateLinkByDefault']));
+ $conf->set('feed.rss_permalinks', !empty($_POST['enableRssPermalinks']));
+ $conf->set('updates.check_updates', !empty($_POST['updateCheck']));
+ $conf->set('privacy.hide_public_links', !empty($_POST['hidePublicLinks']));
try {
$conf->write(isLoggedIn());
}
{
$PAGE->assign('token',getToken($conf));
$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'));
$PAGE->assign('timezone_form', $timezone_form);
$PAGE->assign('timezone_js',$timezone_js);
- $PAGE->assign('private_links_default', $conf->get('general.default_private_links', false));
- $PAGE->assign('enable_rss_permalinks', $conf->get('general.rss_permalinks', false));
- $PAGE->assign('enable_update_check', $conf->get('general.check_updates', true));
- $PAGE->assign('hide_public_links', $conf->get('extras.hide_public_links', false));
+ $PAGE->assign('private_links_default', $conf->get('privacy.default_private_links', false));
+ $PAGE->assign('enable_rss_permalinks', $conf->get('feed.rss_permalinks', false));
+ $PAGE->assign('enable_update_check', $conf->get('updates.check_updates', true));
+ $PAGE->assign('hide_public_links', $conf->get('privacy.hide_public_links', false));
$PAGE->renderPage('configure');
exit;
}
$value['tags']=trim(implode(' ',$tags));
$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>';
exit;
}
$value['tags']=trim(implode(' ',$tags));
$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>';
exit;
}
$pluginManager->executeHooks('save_link', $link);
$LINKSDB[$linkdate] = $link;
- $LINKSDB->savedb($conf->get('path.page_cache'));
+ $LINKSDB->savedb($conf->get('resource.page_cache'));
pubsubhub($conf);
// If we are called from the bookmarklet, we must close the popup:
$pluginManager->executeHooks('delete_link', $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 (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { echo '<script>self.close();</script>'; exit; }
}
}
}
- $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>';
}
while ($i<$end && $i<count($keys))
{
$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';
$link['class'] = $link['private'] == 0 ? $classLi : 'private';
$date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']);
'result_count' => count($linksToDisplay),
'search_term' => $searchterm,
'search_tags' => $searchtags,
- 'redirector' => $conf->get('extras.redirector'), // Optional redirector URL.
+ 'redirector' => $conf->get('redirector.url'), // Optional redirector URL.
'token' => $token,
'links' => $linkDisp,
'tags' => $LINKSDB->allTags(),
*/
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;
// For most hosts, the URL of the thumbnail can be easily deduced from the URL of the link.
// So we deport the thumbnail generation in order not to slow down page generation
// (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')
|| $domain=='vimeo.com'
} else {
$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 {
// Everything is ok, let's create config file.
$conf->write(isLoggedIn());
$sign = hash_hmac('sha256', $_GET['url'], $conf->get('credentials.salt'));
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.
$thumbname=hash('sha1',$_GET['url']).'.jpg';
if (is_file($cacheDir .'/'. $thumbname))
public function testCheckCurrentResourcePermissions()
{
$conf = new ConfigManager('');
- $conf->set('path.thumbnails_cache', 'cache');
- $conf->set('path.config', 'data/config.php');
- $conf->set('path.data_dir', 'data');
- $conf->set('path.datastore', 'data/datastore.php');
- $conf->set('path.ban_file', 'data/ipbans.php');
- $conf->set('path.log', 'data/log.txt');
- $conf->set('path.page_cache', 'pagecache');
- $conf->set('path.raintpl_tmp', 'tmp');
- $conf->set('path.raintpl_tpl', 'tpl');
- $conf->set('path.update_check', 'data/lastupdatecheck.txt');
+ $conf->set('resource.thumbnails_cache', 'cache');
+ $conf->set('resource.config', 'data/config.php');
+ $conf->set('resource.data_dir', 'data');
+ $conf->set('resource.datastore', 'data/datastore.php');
+ $conf->set('resource.ban_file', 'data/ipbans.php');
+ $conf->set('resource.log', 'data/log.txt');
+ $conf->set('resource.page_cache', 'pagecache');
+ $conf->set('resource.raintpl_tmp', 'tmp');
+ $conf->set('resource.raintpl_tpl', 'tpl');
+ $conf->set('resource.update_check', 'data/lastupdatecheck.txt');
$this->assertEquals(
array(),
public function testCheckCurrentResourcePermissionsErrors()
{
$conf = new ConfigManager('');
- $conf->set('path.thumbnails_cache', 'null/cache');
- $conf->set('path.config', 'null/data/config.php');
- $conf->set('path.data_dir', 'null/data');
- $conf->set('path.datastore', 'null/data/store.php');
- $conf->set('path.ban_file', 'null/data/ipbans.php');
- $conf->set('path.log', 'null/data/log.txt');
- $conf->set('path.page_cache', 'null/pagecache');
- $conf->set('path.raintpl_tmp', 'null/tmp');
- $conf->set('path.raintpl_tpl', 'null/tpl');
- $conf->set('path.update_check', 'null/data/lastupdatecheck.txt');
+ $conf->set('resource.thumbnails_cache', 'null/cache');
+ $conf->set('resource.config', 'null/data/config.php');
+ $conf->set('resource.data_dir', 'null/data');
+ $conf->set('resource.datastore', 'null/data/store.php');
+ $conf->set('resource.ban_file', 'null/data/ipbans.php');
+ $conf->set('resource.log', 'null/data/log.txt');
+ $conf->set('resource.page_cache', 'null/pagecache');
+ $conf->set('resource.raintpl_tmp', 'null/tmp');
+ $conf->set('resource.raintpl_tpl', 'null/tpl');
+ $conf->set('resource.update_check', 'null/data/lastupdatecheck.txt');
$this->assertEquals(
array(
'"null/tpl" directory is not readable',
public function testReadEmptyUpdatesFile()
{
$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);
$this->assertEquals(array(), read_updates_file($updatesFile));
unlink($updatesFile);
*/
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');
write_updates_file($updatesFile, $updatesMethods);
*/
public function testWriteUpdatesFileNotWritable()
{
- $updatesFile = $this->conf->get('path.data_dir') . '/updates.txt';
+ $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
touch($updatesFile);
chmod($updatesFile, 0444);
try {
// make sure updated field is changed
$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));
// Delete the generated file.
unlink($this->conf->getConfigFileExt());
// Check JSON config data.
$this->conf->reload();
$this->assertEquals('root', $this->conf->get('credentials.login'));
- $this->assertEquals('lala', $this->conf->get('extras.redirector'));
- $this->assertEquals('data/datastore.php', $this->conf->get('path.datastore'));
+ $this->assertEquals('lala', $this->conf->get('redirector.url'));
+ $this->assertEquals('data/datastore.php', $this->conf->get('resource.datastore'));
$this->assertEquals('1', $this->conf->get('plugins.WALLABAG_VERSION'));
rename($configFile . '.save.php', $configFile . '.php');
{
$conf = $this->configIO->read('tests/utils/config/configJson.json.php');
$this->assertEquals('root', $conf['credentials']['login']);
- $this->assertEquals('lala', $conf['extras']['redirector']);
- $this->assertEquals('tests/utils/config/datastore.php', $conf['path']['datastore']);
+ $this->assertEquals('lala', $conf['redirector']['url']);
+ $this->assertEquals('tests/utils/config/datastore.php', $conf['resource']['datastore']);
$this->assertEquals('1', $conf['plugins']['WALLABAG_VERSION']);
}
'credentials' => array(
'login' => 'root',
),
- 'path' => array(
+ 'resource' => array(
'datastore' => 'data/datastore.php',
),
- 'extras' => array(
- 'redirector' => 'lala',
+ 'redirector' => array(
+ 'url' => 'lala',
),
'plugins' => array(
'WALLABAG_VERSION' => '1',
"credentials": {
"login": "root"
},
- "path": {
+ "resource": {
"datastore": "data\/datastore.php"
},
- "extras": {
- "redirector": "lala"
+ "redirector": {
+ "url": "lala"
},
"plugins": {
"WALLABAG_VERSION": "1"
}
}';
} 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;
$this->assertEquals($expected, file_get_contents($dataFile));
$dest = 'tests/utils/config/configOverwrite.json.php';
copy($source, $dest);
$conf = $this->configIO->read($dest);
- $conf['extras']['redirector'] = 'blabla';
+ $conf['redirector']['url'] = 'blabla';
$this->configIO->write($dest, $conf);
$conf = $this->configIO->read($dest);
- $this->assertEquals('blabla', $conf['extras']['redirector']);
+ $this->assertEquals('blabla', $conf['redirector']['url']);
unlink($dest);
}
},
"general": {
"timezone":"Europe\/Paris",
- "default_private_linksheader_link":true,
"title": "Shaarli",
"header_link": "?"
},
- "extras": {
- "redirector":"lala"
+ "privacy": {
+ "default_private_links":true
+ },
+ "redirector": {
+ "url":"lala"
},
"config": {
"foo": "bar"
},
- "path": {
+ "resource": {
"datastore": "tests\/utils\/config\/datastore.php",
"data_dir": "tests\/utils\/config"
},