aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php34
1 files changed, 8 insertions, 26 deletions
diff --git a/index.php b/index.php
index ed18c7f9..d0dd5306 100644
--- a/index.php
+++ b/index.php
@@ -702,16 +702,13 @@ function showRSS()
702 $cached = $cache->cachedVersion(); if (!empty($cached)) { echo $cached; exit; } 702 $cached = $cache->cachedVersion(); if (!empty($cached)) { echo $cached; exit; }
703 703
704 // If cached was not found (or not usable), then read the database and build the response: 704 // If cached was not found (or not usable), then read the database and build the response:
705 $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']); 705 $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']); // Read links from database (and filter private links if user it not logged in).
706 706
707 // Optionally filter the results: 707 // Optionally filter the results:
708 $linksToDisplay=array(); 708 $linksToDisplay=array();
709 if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']); 709 if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']);
710 else if (!empty($_GET['searchtags'])) $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags'])); 710 else if (!empty($_GET['searchtags'])) $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags']));
711 else $linksToDisplay = $LINKSDB; 711 else $linksToDisplay = $LINKSDB;
712
713 if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
714 $linksToDisplay = array();
715 712
716 $nblinksToDisplay = 50; // Number of links to display. 713 $nblinksToDisplay = 50; // Number of links to display.
717 if (!empty($_GET['nb'])) // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links. 714 if (!empty($_GET['nb'])) // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links.
@@ -780,7 +777,7 @@ function showATOM()
780 $cached = $cache->cachedVersion(); if (!empty($cached)) { echo $cached; exit; } 777 $cached = $cache->cachedVersion(); if (!empty($cached)) { echo $cached; exit; }
781 // If cached was not found (or not usable), then read the database and build the response: 778 // If cached was not found (or not usable), then read the database and build the response:
782 779
783 $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']); 780 $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']); // Read links from database (and filter private links if used it not logged in).
784 781
785 782
786 // Optionally filter the results: 783 // Optionally filter the results:
@@ -788,9 +785,6 @@ function showATOM()
788 if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']); 785 if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']);
789 else if (!empty($_GET['searchtags'])) $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags'])); 786 else if (!empty($_GET['searchtags'])) $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags']));
790 else $linksToDisplay = $LINKSDB; 787 else $linksToDisplay = $LINKSDB;
791
792 if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
793 $linksToDisplay = array();
794 788
795 $nblinksToDisplay = 50; // Number of links to display. 789 $nblinksToDisplay = 50; // Number of links to display.
796 if (!empty($_GET['nb'])) // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links. 790 if (!empty($_GET['nb'])) // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links.
@@ -865,7 +859,7 @@ function showDailyRSS()
865 $cache = new pageCache(pageUrl(),startsWith($query,'do=dailyrss') && !isLoggedIn()); 859 $cache = new pageCache(pageUrl(),startsWith($query,'do=dailyrss') && !isLoggedIn());
866 $cached = $cache->cachedVersion(); if (!empty($cached)) { echo $cached; exit; } 860 $cached = $cache->cachedVersion(); if (!empty($cached)) { echo $cached; exit; }
867 // If cached was not found (or not usable), then read the database and build the response: 861 // If cached was not found (or not usable), then read the database and build the response:
868 $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']); 862 $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']); // Read links from database (and filter private links if used it not logged in).
869 863
870 /* Some Shaarlies may have very few links, so we need to look 864 /* Some Shaarlies may have very few links, so we need to look
871 back in time (rsort()) until we have enough days ($nb_of_days). 865 back in time (rsort()) until we have enough days ($nb_of_days).
@@ -933,7 +927,7 @@ function showDailyRSS()
933// "Daily" page. 927// "Daily" page.
934function showDaily() 928function showDaily()
935{ 929{
936 $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']); 930 $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']); // Read links from database (and filter private links if used it not logged in).
937 931
938 932
939 $day=Date('Ymd',strtotime('-1 day')); // Yesterday, in format YYYYMMDD. 933 $day=Date('Ymd',strtotime('-1 day')); // Yesterday, in format YYYYMMDD.
@@ -951,8 +945,6 @@ function showDaily()
951 } 945 }
952 946
953 $linksToDisplay=$LINKSDB->filterDay($day); 947 $linksToDisplay=$LINKSDB->filterDay($day);
954 if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
955 $linksToDisplay = array();
956 // We pre-format some fields for proper output. 948 // We pre-format some fields for proper output.
957 foreach($linksToDisplay as $key=>$link) 949 foreach($linksToDisplay as $key=>$link)
958 { 950 {
@@ -1001,7 +993,7 @@ function showDaily()
1001// Render HTML page (according to URL parameters and user rights) 993// Render HTML page (according to URL parameters and user rights)
1002function renderPage() 994function renderPage()
1003{ 995{
1004 $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']); 996 $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']); // Read links from database (and filter private links if used it not logged in).
1005 997
1006 // -------- Display login form. 998 // -------- Display login form.
1007 if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=login')) 999 if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=login'))
@@ -1031,9 +1023,6 @@ function renderPage()
1031 if (!empty($_GET['searchterm'])) $links = $LINKSDB->filterFulltext($_GET['searchterm']); 1023 if (!empty($_GET['searchterm'])) $links = $LINKSDB->filterFulltext($_GET['searchterm']);
1032 elseif (!empty($_GET['searchtags'])) $links = $LINKSDB->filterTags(trim($_GET['searchtags'])); 1024 elseif (!empty($_GET['searchtags'])) $links = $LINKSDB->filterTags(trim($_GET['searchtags']));
1033 else $links = $LINKSDB; 1025 else $links = $LINKSDB;
1034
1035 if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
1036 $links = array();
1037 1026
1038 $body=''; 1027 $body='';
1039 $linksToDisplay=array(); 1028 $linksToDisplay=array();
@@ -1061,8 +1050,7 @@ function renderPage()
1061 if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=tagcloud')) 1050 if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=tagcloud'))
1062 { 1051 {
1063 $tags= $LINKSDB->allTags(); 1052 $tags= $LINKSDB->allTags();
1064 if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn()) 1053
1065 $tags = array();
1066 // We sort tags alphabetically, then choose a font size according to count. 1054 // We sort tags alphabetically, then choose a font size according to count.
1067 // First, find max value. 1055 // First, find max value.
1068 $maxcount=0; foreach($tags as $key=>$value) $maxcount=max($maxcount,$value); 1056 $maxcount=0; foreach($tags as $key=>$value) $maxcount=max($maxcount,$value);
@@ -1583,7 +1571,7 @@ HTML;
1583function importFile() 1571function importFile()
1584{ 1572{
1585 if (!(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'])) { die('Not allowed.'); } 1573 if (!(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'])) { die('Not allowed.'); }
1586 $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']); 1574 $LINKSDB = new LinkDB(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']); // Read links from database (and filter private links if used it not logged in).
1587 $filename=$_FILES['filetoupload']['name']; 1575 $filename=$_FILES['filetoupload']['name'];
1588 $filesize=$_FILES['filetoupload']['size']; 1576 $filesize=$_FILES['filetoupload']['size'];
1589 $data=file_get_contents($_FILES['filetoupload']['tmp_name']); 1577 $data=file_get_contents($_FILES['filetoupload']['tmp_name']);
@@ -1675,16 +1663,12 @@ function buildLinkList($PAGE,$LINKSDB)
1675 if (isset($_GET['searchterm'])) // Fulltext search 1663 if (isset($_GET['searchterm'])) // Fulltext search
1676 { 1664 {
1677 $linksToDisplay = $LINKSDB->filterFulltext(trim($_GET['searchterm'])); 1665 $linksToDisplay = $LINKSDB->filterFulltext(trim($_GET['searchterm']));
1678 if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
1679 $linksToDisplay = array();
1680 $search_crits=htmlspecialchars(trim($_GET['searchterm'])); 1666 $search_crits=htmlspecialchars(trim($_GET['searchterm']));
1681 $search_type='fulltext'; 1667 $search_type='fulltext';
1682 } 1668 }
1683 elseif (isset($_GET['searchtags'])) // Search by tag 1669 elseif (isset($_GET['searchtags'])) // Search by tag
1684 { 1670 {
1685 $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags'])); 1671 $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags']));
1686 if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
1687 $linksToDisplay = array();
1688 $search_crits=explode(' ',trim($_GET['searchtags'])); 1672 $search_crits=explode(' ',trim($_GET['searchtags']));
1689 $search_type='tags'; 1673 $search_type='tags';
1690 } 1674 }
@@ -1700,9 +1684,6 @@ function buildLinkList($PAGE,$LINKSDB)
1700 } 1684 }
1701 $search_type='permalink'; 1685 $search_type='permalink';
1702 } 1686 }
1703 // We chose to disable all private links and the user isn't logged in, do not return any link.
1704 else if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
1705 $linksToDisplay = array();
1706 else 1687 else
1707 $linksToDisplay = $LINKSDB; // Otherwise, display without filtering. 1688 $linksToDisplay = $LINKSDB; // Otherwise, display without filtering.
1708 1689
@@ -1779,6 +1760,7 @@ function buildLinkList($PAGE,$LINKSDB)
1779 $PAGE->assign('redirector',empty($GLOBALS['redirector']) ? '' : $GLOBALS['redirector']); // Optional redirector URL. 1760 $PAGE->assign('redirector',empty($GLOBALS['redirector']) ? '' : $GLOBALS['redirector']); // Optional redirector URL.
1780 $PAGE->assign('token',$token); 1761 $PAGE->assign('token',$token);
1781 $PAGE->assign('links',$linkDisp); 1762 $PAGE->assign('links',$linkDisp);
1763 $PAGE->assign('tags', $LINKSDB->allTags());
1782 return; 1764 return;
1783} 1765}
1784 1766