X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=index.php;h=5771dd8880043d48ada8b2aa1d36ea77d6fd18e0;hb=7f1dfd1c12a143b324fbe68213a49de0586febfa;hp=96a601dedd99c5a45b858922b470ab5475a20969;hpb=64bc92e3ac8f5e66d2bc14206ede31e6679d8c13;p=github%2Fshaarli%2FShaarli.git diff --git a/index.php b/index.php index 96a601de..5771dd88 100644 --- a/index.php +++ b/index.php @@ -41,8 +41,6 @@ $GLOBALS['config']['HIDE_PUBLIC_LINKS'] = false; if (is_file($GLOBALS['config']['DATADIR'].'/options.php')) require($GLOBALS['config']['DATADIR'].'/options.php'); define('shaarli_version','0.0.45beta'); -define('PHPPREFIX',''); // Suffix to encapsulate data in PHP code. // http://server.com/x/shaarli --> /shaarli/ define('WEB_PATH', substr($_SERVER["REQUEST_URI"], 0, 1+strrpos($_SERVER["REQUEST_URI"], '/', 0))); @@ -700,6 +698,7 @@ function showRSS() // If cached was not found (or not usable), then read the database and build the response: $LINKSDB = new LinkDB( + $GLOBALS['config']['DATASTORE'], isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'], $GLOBALS['config']['HIDE_PUBLIC_LINKS'] ); @@ -710,7 +709,7 @@ function showRSS() if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']); else if (!empty($_GET['searchtags'])) $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags'])); else $linksToDisplay = $LINKSDB; - + $nblinksToDisplay = 50; // Number of links to display. if (!empty($_GET['nb'])) // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links. { @@ -780,6 +779,7 @@ function showATOM() // Read links from database (and filter private links if used it not logged in). $LINKSDB = new LinkDB( + $GLOBALS['config']['DATASTORE'], isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'], $GLOBALS['config']['HIDE_PUBLIC_LINKS'] ); @@ -789,7 +789,7 @@ function showATOM() if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']); else if (!empty($_GET['searchtags'])) $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags'])); else $linksToDisplay = $LINKSDB; - + $nblinksToDisplay = 50; // Number of links to display. if (!empty($_GET['nb'])) // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links. { @@ -866,6 +866,7 @@ function showDailyRSS() // Read links from database (and filter private links if used it not logged in). $LINKSDB = new LinkDB( + $GLOBALS['config']['DATASTORE'], isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'], $GLOBALS['config']['HIDE_PUBLIC_LINKS'] ); @@ -937,6 +938,7 @@ function showDailyRSS() function showDaily() { $LINKSDB = new LinkDB( + $GLOBALS['config']['DATASTORE'], isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'], $GLOBALS['config']['HIDE_PUBLIC_LINKS'] ); @@ -946,16 +948,22 @@ function showDaily() $days = $LINKSDB->days(); $i = array_search($day,$days); - if ($i==false) { $i=count($days)-1; $day=$days[$i]; } + if ($i===false) { $i=count($days)-1; $day=$days[$i]; } $previousday=''; $nextday=''; if ($i!==false) { - if ($i>1) $previousday=$days[$i-1]; + if ($i>=1) $previousday=$days[$i-1]; if ($ifilterDay($day); + try { + $linksToDisplay = $LINKSDB->filterDay($day); + } catch (Exception $exc) { + error_log($exc); + $linksToDisplay = []; + } + // We pre-format some fields for proper output. foreach($linksToDisplay as $key=>$link) { @@ -1006,6 +1014,7 @@ function showDaily() function renderPage() { $LINKSDB = new LinkDB( + $GLOBALS['config']['DATASTORE'], isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'], $GLOBALS['config']['HIDE_PUBLIC_LINKS'] ); @@ -1038,7 +1047,7 @@ function renderPage() if (!empty($_GET['searchterm'])) $links = $LINKSDB->filterFulltext($_GET['searchterm']); elseif (!empty($_GET['searchtags'])) $links = $LINKSDB->filterTags(trim($_GET['searchtags'])); else $links = $LINKSDB; - + $body=''; $linksToDisplay=array(); @@ -1053,7 +1062,7 @@ function renderPage() $linksToDisplay[]=$link; // Add to array. } } - + $PAGE = new pageBuilder; $PAGE->assign('linkcount',count($LINKSDB)); $PAGE->assign('linksToDisplay',$linksToDisplay); @@ -1587,6 +1596,7 @@ function importFile() { if (!(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'])) { die('Not allowed.'); } $LINKSDB = new LinkDB( + $GLOBALS['config']['DATASTORE'], isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'], $GLOBALS['config']['HIDE_PUBLIC_LINKS'] );