// Banned IPs
$GLOBALS['config']['IPBANS_FILENAME'] = $GLOBALS['config']['DATADIR'].'/ipbans.php';
+// Processed updates file.
+$GLOBALS['config']['UPDATES_FILE'] = $GLOBALS['config']['DATADIR'].'/updates.txt';
+
// Access log
$GLOBALS['config']['LOG_FILE'] = $GLOBALS['config']['DATADIR'].'/log.txt';
// For updates check of Shaarli
$GLOBALS['config']['UPDATECHECK_FILENAME'] = $GLOBALS['config']['DATADIR'].'/lastupdatecheck.txt';
+// Set ENABLE_UPDATECHECK to disabled by default.
+$GLOBALS['config']['ENABLE_UPDATECHECK'] = false;
+
// RainTPL cache directory (keep the trailing slash!)
$GLOBALS['config']['RAINTPL_TMP'] = 'tmp/';
// Raintpl template directory (keep the trailing slash!)
// Atom & RSS feed cache directory
$GLOBALS['config']['PAGECACHE'] = 'pagecache';
-
/*
* Global configuration
*/
//);
$GLOBALS['config']['ENABLED_PLUGINS'] = array('qrcode');
-//$GLOBALS['plugins']['WALLABAG_URL'] = 'https://demo.wallabag.org/';
+// Initialize plugin parameters array.
+$GLOBALS['plugins'] = array();
// PubSubHubbub support. Put an empty string to disable, or put your hub url here to enable.
$GLOBALS['config']['PUBSUBHUB_URL'] = '';
require_once 'application/Config.php';
require_once 'application/PluginManager.php';
require_once 'application/Router.php';
+require_once 'application/Updater.php';
// Ensure the PHP version is supported
try {
// a token depending of deployment salt, user password, and the current ip
define('STAY_SIGNED_IN_TOKEN', sha1($GLOBALS['hash'].$_SERVER["REMOTE_ADDR"].$GLOBALS['salt']));
-autoLocale(); // Sniff browser language and set date format accordingly.
+autoLocale($_SERVER['HTTP_ACCEPT_LANGUAGE']); // Sniff browser language and set date format accordingly.
header('Content-Type: text/html; charset=utf-8'); // We use UTF-8 for proper international characters handling.
//==================================================================================================
}
$userIsLoggedIn = setup_login_state();
-
-// ------------------------------------------------------------------------------------------
-// Sniff browser language to display dates in the right format automatically.
-// (Note that is may not work on your server if the corresponding local is not installed.)
-function autoLocale()
-{
- $attempts = array('en_US'); // Default if browser does not send HTTP_ACCEPT_LANGUAGE
- if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) // e.g. "fr,fr-fr;q=0.8,en;q=0.5,en-us;q=0.3"
- { // (It's a bit crude, but it works very well. Preferred language is always presented first.)
- if (preg_match('/([a-z]{2})-?([a-z]{2})?/i',$_SERVER['HTTP_ACCEPT_LANGUAGE'],$matches)) {
- $loc = $matches[1] . (!empty($matches[2]) ? '_' . strtoupper($matches[2]) : '');
- $attempts = array($loc.'.UTF-8', $loc, str_replace('_', '-', $loc).'.UTF-8', str_replace('_', '-', $loc),
- $loc . '_' . strtoupper($loc).'.UTF-8', $loc . '_' . strtoupper($loc),
- $loc . '_' . $loc.'.UTF-8', $loc . '_' . $loc, $loc . '-' . strtoupper($loc).'.UTF-8',
- $loc . '-' . strtoupper($loc), $loc . '-' . $loc.'.UTF-8', $loc . '-' . $loc);
- }
- }
- setlocale(LC_TIME, $attempts); // LC_TIME = Set local for date/time format only.
-}
-
// ------------------------------------------------------------------------------------------
// PubSubHubbub protocol support (if enabled) [UNTESTED]
// (Source: http://aldarone.fr/les-flux-rss-shaarli-et-pubsubhubbub/ )
$GLOBALS['redirector']
);
+ $updater = new Updater(
+ read_updates_file($GLOBALS['config']['UPDATES_FILE']),
+ $GLOBALS,
+ $LINKSDB,
+ isLoggedIn()
+ );
+ try {
+ $newUpdates = $updater->update();
+ if (! empty($newUpdates)) {
+ write_updates_file(
+ $GLOBALS['config']['UPDATES_FILE'],
+ $updater->getDoneUpdates()
+ );
+ }
+ }
+ catch(Exception $e) {
+ die($e->getMessage());
+ }
+
$PAGE = new pageBuilder;
// Determine which page will be rendered.
// Call plugin hooks for header, footer and includes, specifying which page will be rendered.
// Then assign generated data to RainTPL.
$common_hooks = array(
+ 'includes',
'header',
'footer',
- 'includes',
);
$pluginManager = PluginManager::getInstance();
foreach($common_hooks as $name) {
// We sort tags alphabetically, then choose a font size according to count.
// First, find max value.
- $maxcount=0; foreach($tags as $key=>$value) $maxcount=max($maxcount,$value);
- ksort($tags);
+ $maxcount = 0;
+ foreach ($tags as $value) {
+ $maxcount = max($maxcount, $value);
+ }
+
+ // Sort tags alphabetically: case insensitive, support locale if avalaible.
+ uksort($tags, function($a, $b) {
+ // Collator is part of PHP intl.
+ if (class_exists('Collator')) {
+ $c = new Collator(setlocale(LC_ALL, 0));
+ return $c->compare($a, $b);
+ } else {
+ return strcasecmp($a, $b);
+ }
+ });
+
$tagList=array();
foreach($tags as $key=>$value)
- // Tag font size scaling: default 15 and 30 logarithm bases affect scaling, 22 and 6 are arbitrary font sizes for max and min sizes.
+ // Tag font size scaling: default 15 and 30 logarithm bases affect scaling, 22 and 6 are arbitrary font sizes for max and min sizes.
{
$tagList[$key] = array('count'=>$value,'size'=>log($value, 15) / log($maxcount, 30) * (22-6) + 6);
}
}
// Remove multiple spaces.
$tags = trim(preg_replace('/\s\s+/', ' ', $_POST['lf_tags']));
+ // Remove first '-' char in tags.
+ $tags = preg_replace('/(^| )\-/', '$1', $tags);
// Remove duplicates.
$tags = implode(' ', array_unique(explode(' ', $tags)));
$linkdate = $_POST['lf_linkdate'];
);
// TODO: do not handle exceptions/errors in JS.
- echo '<script>alert("'. $e->getMessage() .'");document.location=\'?do=pluginsadmin\';</script>';
+ echo '<script>alert("'. $e->getMessage() .'");document.location=\'?do='. Router::$PAGE_PLUGINSADMIN .'\';</script>';
exit;
}
header('Location: ?do='. Router::$PAGE_PLUGINSADMIN);
return true;
}
-try {
- mergeDeprecatedConfig($GLOBALS, isLoggedIn());
-} catch(Exception $e) {
- error_log(
- 'ERROR while merging deprecated options.php file.' . PHP_EOL .
- $e->getMessage()
- );
-}
-
if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=genthumbnail')) { genThumbnail(); exit; } // Thumbnail generation/cache does not need the link database.
if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=rss')) { showRSS(); exit; }
if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=atom')) { showATOM(); exit; }