diff options
author | Seb Sauvage <sebsauvage@sebsauvage.net> | 2012-02-06 17:35:44 +0100 |
---|---|---|
committer | Emilien Klein <emilien@klein.st> | 2012-02-06 17:35:44 +0100 |
commit | a689efafc8260f53ed67fbe5d67e013ea41c3923 (patch) | |
tree | 59c73f7935879c77cdf59d38a0e02db643583250 /index.php | |
parent | a22e60cc0abb0547af8d792dec15f59bf77b5630 (diff) | |
download | Shaarli-a689efafc8260f53ed67fbe5d67e013ea41c3923.tar.gz Shaarli-a689efafc8260f53ed67fbe5d67e013ea41c3923.tar.zst Shaarli-a689efafc8260f53ed67fbe5d67e013ea41c3923.zip |
Version 0.0.38 beta:legacy
- Corrected: Corrected the tag encoding (there was a bug when selecting a second tag which contains accented characters).
- Changed: The “Daily” page now automatically skips empty days.
- Added: Automatic creation of the tmp directory with proper rights (for RainTPL).
- Added: When you click the key to see only private links, it turns yellow.
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 36 |
1 files changed, 30 insertions, 6 deletions
@@ -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 | |||
30 | ini_set('memory_limit', '128M'); // Try to set max upload file size and read (May not work on some hosts). | 30 | ini_set('memory_limit', '128M'); // Try to set max upload file size and read (May not work on some hosts). |
31 | ini_set('post_max_size', '16M'); | 31 | ini_set('post_max_size', '16M'); |
32 | ini_set('upload_max_filesize', '16M'); | 32 | ini_set('upload_max_filesize', '16M'); |
33 | define('shaarli_version','0.0.38 beta'); | ||
33 | define('PHPPREFIX','<?php /* '); // Prefix to encapsulate data in php code. | 34 | define('PHPPREFIX','<?php /* '); // Prefix to encapsulate data in php code. |
34 | define('PHPSUFFIX',' */ ?>'); // Suffix to encapsulate data in php code. | 35 | define('PHPSUFFIX',' */ ?>'); // Suffix to encapsulate data in php code. |
35 | checkphpversion(); | 36 | checkphpversion(); |
@@ -58,8 +59,8 @@ header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); | |||
58 | header("Cache-Control: no-store, no-cache, must-revalidate"); | 59 | header("Cache-Control: no-store, no-cache, must-revalidate"); |
59 | header("Cache-Control: post-check=0, pre-check=0", false); | 60 | header("Cache-Control: post-check=0, pre-check=0", false); |
60 | header("Pragma: no-cache"); | 61 | header("Pragma: no-cache"); |
61 | define('shaarli_version','0.0.37 beta'); | ||
62 | if (!is_dir($GLOBALS['config']['DATADIR'])) { mkdir($GLOBALS['config']['DATADIR'],0705); chmod($GLOBALS['config']['DATADIR'],0705); } | 62 | if (!is_dir($GLOBALS['config']['DATADIR'])) { mkdir($GLOBALS['config']['DATADIR'],0705); chmod($GLOBALS['config']['DATADIR'],0705); } |
63 | if (!is_dir('tmp')) { mkdir('tmp',0705); chmod('tmp',0705); } // For RainTPL temporary files. | ||
63 | if (!is_file($GLOBALS['config']['DATADIR'].'/.htaccess')) { file_put_contents($GLOBALS['config']['DATADIR'].'/.htaccess',"Allow from none\nDeny from all\n"); } // Protect data files. | 64 | if (!is_file($GLOBALS['config']['DATADIR'].'/.htaccess')) { file_put_contents($GLOBALS['config']['DATADIR'].'/.htaccess',"Allow from none\nDeny from all\n"); } // Protect data files. |
64 | if ($GLOBALS['config']['ENABLE_LOCALCACHE']) | 65 | if ($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) |