aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php36
1 files changed, 30 insertions, 6 deletions
diff --git a/index.php b/index.php
index 936d6129..2611e04e 100644
--- a/index.php
+++ b/index.php
@@ -1,5 +1,5 @@
1<?php 1<?php
2// Shaarli 0.0.37 beta - Shaare your links... 2// Shaarli 0.0.38 beta - Shaare your links...
3// The personal, minimalist, super-fast, no-database delicious clone. By sebsauvage.net 3// The personal, minimalist, super-fast, no-database delicious clone. By sebsauvage.net
4// http://sebsauvage.net/wiki/doku.php?id=php:shaarli 4// http://sebsauvage.net/wiki/doku.php?id=php:shaarli
5// Licence: http://www.opensource.org/licenses/zlib-license.php 5// Licence: http://www.opensource.org/licenses/zlib-license.php
@@ -30,6 +30,7 @@ ini_set('max_input_time','60'); // High execution time in case of problematic i
30ini_set('memory_limit', '128M'); // Try to set max upload file size and read (May not work on some hosts). 30ini_set('memory_limit', '128M'); // Try to set max upload file size and read (May not work on some hosts).
31ini_set('post_max_size', '16M'); 31ini_set('post_max_size', '16M');
32ini_set('upload_max_filesize', '16M'); 32ini_set('upload_max_filesize', '16M');
33define('shaarli_version','0.0.38 beta');
33define('PHPPREFIX','<?php /* '); // Prefix to encapsulate data in php code. 34define('PHPPREFIX','<?php /* '); // Prefix to encapsulate data in php code.
34define('PHPSUFFIX',' */ ?>'); // Suffix to encapsulate data in php code. 35define('PHPSUFFIX',' */ ?>'); // Suffix to encapsulate data in php code.
35checkphpversion(); 36checkphpversion();
@@ -58,8 +59,8 @@ header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
58header("Cache-Control: no-store, no-cache, must-revalidate"); 59header("Cache-Control: no-store, no-cache, must-revalidate");
59header("Cache-Control: post-check=0, pre-check=0", false); 60header("Cache-Control: post-check=0, pre-check=0", false);
60header("Pragma: no-cache"); 61header("Pragma: no-cache");
61define('shaarli_version','0.0.37 beta');
62if (!is_dir($GLOBALS['config']['DATADIR'])) { mkdir($GLOBALS['config']['DATADIR'],0705); chmod($GLOBALS['config']['DATADIR'],0705); } 62if (!is_dir($GLOBALS['config']['DATADIR'])) { mkdir($GLOBALS['config']['DATADIR'],0705); chmod($GLOBALS['config']['DATADIR'],0705); }
63if (!is_dir('tmp')) { mkdir('tmp',0705); chmod('tmp',0705); } // For RainTPL temporary files.
63if (!is_file($GLOBALS['config']['DATADIR'].'/.htaccess')) { file_put_contents($GLOBALS['config']['DATADIR'].'/.htaccess',"Allow from none\nDeny from all\n"); } // Protect data files. 64if (!is_file($GLOBALS['config']['DATADIR'].'/.htaccess')) { file_put_contents($GLOBALS['config']['DATADIR'].'/.htaccess',"Allow from none\nDeny from all\n"); } // Protect data files.
64if ($GLOBALS['config']['ENABLE_LOCALCACHE']) 65if ($GLOBALS['config']['ENABLE_LOCALCACHE'])
65{ 66{
@@ -531,6 +532,7 @@ class pageBuilder
531 $this->tpl->assign('version',shaarli_version); 532 $this->tpl->assign('version',shaarli_version);
532 $this->tpl->assign('scripturl',indexUrl()); 533 $this->tpl->assign('scripturl',indexUrl());
533 $this->tpl->assign('pagetitle','Shaarli'); 534 $this->tpl->assign('pagetitle','Shaarli');
535 $this->tpl->assign('privateonly',!empty($_SESSION['privateonly'])); // Show only private links ?
534 if (!empty($GLOBALS['title'])) $this->tpl->assign('pagetitle',$GLOBALS['title']); 536 if (!empty($GLOBALS['title'])) $this->tpl->assign('pagetitle',$GLOBALS['title']);
535 if (!empty($GLOBALS['pagetitle'])) $this->tpl->assign('pagetitle',$GLOBALS['pagetitle']); 537 if (!empty($GLOBALS['pagetitle'])) $this->tpl->assign('pagetitle',$GLOBALS['pagetitle']);
536 $this->tpl->assign('shaarlititle',empty($GLOBALS['title']) ? 'Shaarli': $GLOBALS['title'] ); 538 $this->tpl->assign('shaarlititle',empty($GLOBALS['title']) ? 'Shaarli': $GLOBALS['title'] );
@@ -746,6 +748,20 @@ class linkdb implements Iterator, Countable, ArrayAccess
746 arsort($tags); // Sort tags by usage (most used tag first) 748 arsort($tags); // Sort tags by usage (most used tag first)
747 return $tags; 749 return $tags;
748 } 750 }
751
752 // Returns the list of days containing articles (oldest first)
753 // Output: An array containing days (in format YYYYMMDD).
754 public function days()
755 {
756 $linkdays=array();
757 foreach(array_keys($this->links) as $day)
758 {
759 $linkdays[substr($day,0,8)]=0;
760 }
761 $linkdays=array_keys($linkdays);
762 sort($linkdays);
763 return $linkdays;
764 }
749} 765}
750 766
751// ------------------------------------------------------------------------------------------ 767// ------------------------------------------------------------------------------------------
@@ -998,7 +1014,7 @@ function renderPage()
998 // Get previous URL (http_referer) and add the tag to the searchtags parameters in query. 1014 // Get previous URL (http_referer) and add the tag to the searchtags parameters in query.
999 if (empty($_SERVER['HTTP_REFERER'])) { header('Location: ?searchtags='.urlencode($_GET['addtag'])); exit; } // In case browser does not send HTTP_REFERER 1015 if (empty($_SERVER['HTTP_REFERER'])) { header('Location: ?searchtags='.urlencode($_GET['addtag'])); exit; } // In case browser does not send HTTP_REFERER
1000 parse_str(parse_url($_SERVER['HTTP_REFERER'],PHP_URL_QUERY), $params); 1016 parse_str(parse_url($_SERVER['HTTP_REFERER'],PHP_URL_QUERY), $params);
1001 $params['searchtags'] = (empty($params['searchtags']) ? trim($_GET['addtag']) : trim($params['searchtags']).' '.urlencode(trim($_GET['addtag']))); 1017 $params['searchtags'] = (empty($params['searchtags']) ? trim($_GET['addtag']) : trim($params['searchtags']).' '.trim($_GET['addtag']));
1002 unset($params['page']); // We also remove page (keeping the same page has no sense, since the results are different) 1018 unset($params['page']); // We also remove page (keeping the same page has no sense, since the results are different)
1003 header('Location: ?'.http_build_query($params)); 1019 header('Location: ?'.http_build_query($params));
1004 exit; 1020 exit;
@@ -1049,10 +1065,18 @@ function renderPage()
1049 { 1065 {
1050 $day=Date('Ymd',strtotime('-1 day')); // Yesterday, in format YYYYMMDD. 1066 $day=Date('Ymd',strtotime('-1 day')); // Yesterday, in format YYYYMMDD.
1051 if (isset($_GET['day'])) $day=$_GET['day']; 1067 if (isset($_GET['day'])) $day=$_GET['day'];
1052
1053 $previousday = Date('Ymd',strtotime('-1 day',strtotime($day)));
1054 $nextday = Date('Ymd',strtotime('+1 day',strtotime($day)));
1055 1068
1069 $days = $LINKSDB->days();
1070 $i = array_search($day,$days);
1071 if ($i==false) { $i=count($days)-1; $day=$days[$i]; }
1072 $previousday='';
1073 $nextday='';
1074 if ($i!==false)
1075 {
1076 if ($i>1) $previousday=$days[$i-1];
1077 if ($i<count($days)-1) $nextday=$days[$i+1];
1078 }
1079
1056 $linksToDisplay=$LINKSDB->filterDay($day); 1080 $linksToDisplay=$LINKSDB->filterDay($day);
1057 // We pre-format some fields for proper output. 1081 // We pre-format some fields for proper output.
1058 foreach($linksToDisplay as $key=>$link) 1082 foreach($linksToDisplay as $key=>$link)