diff options
author | ArthurHoaro <arthur@hoa.ro> | 2015-06-09 14:58:54 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2015-06-09 14:58:54 +0200 |
commit | a037ac6963f111d0c9d5e4faa55f805edd93d91b (patch) | |
tree | 66eef392b29083cd6ec8857e12614b68ed033a5d /index.php | |
parent | cbecab773526b0c39f3cffa1d4595b5caa781bda (diff) | |
download | Shaarli-a037ac6963f111d0c9d5e4faa55f805edd93d91b.tar.gz Shaarli-a037ac6963f111d0c9d5e4faa55f805edd93d91b.tar.zst Shaarli-a037ac6963f111d0c9d5e4faa55f805edd93d91b.zip |
Do not load links if they're hidden (also fix shaarli/Shaarli#202)
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 28 |
1 files changed, 8 insertions, 20 deletions
@@ -794,6 +794,12 @@ class linkdb implements Iterator, Countable, ArrayAccess | |||
794 | // Read database from disk to memory | 794 | // Read database from disk to memory |
795 | private function readdb() | 795 | private function readdb() |
796 | { | 796 | { |
797 | // Public links are hidden and user not logged in => nothing to show | ||
798 | if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn()) { | ||
799 | $this->links = array(); | ||
800 | return; | ||
801 | } | ||
802 | |||
797 | // Read data | 803 | // Read data |
798 | $this->links=(file_exists($GLOBALS['config']['DATASTORE']) ? unserialize(gzinflate(base64_decode(substr(file_get_contents($GLOBALS['config']['DATASTORE']),strlen(PHPPREFIX),-strlen(PHPSUFFIX))))) : array() ); | 804 | $this->links=(file_exists($GLOBALS['config']['DATASTORE']) ? unserialize(gzinflate(base64_decode(substr(file_get_contents($GLOBALS['config']['DATASTORE']),strlen(PHPPREFIX),-strlen(PHPSUFFIX))))) : array() ); |
799 | // Note that gzinflate is faster than gzuncompress. See: http://www.php.net/manual/en/function.gzdeflate.php#96439 | 805 | // Note that gzinflate is faster than gzuncompress. See: http://www.php.net/manual/en/function.gzdeflate.php#96439 |
@@ -948,9 +954,6 @@ function showRSS() | |||
948 | if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']); | 954 | if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']); |
949 | else if (!empty($_GET['searchtags'])) $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags'])); | 955 | else if (!empty($_GET['searchtags'])) $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags'])); |
950 | else $linksToDisplay = $LINKSDB; | 956 | else $linksToDisplay = $LINKSDB; |
951 | |||
952 | if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn()) | ||
953 | $linksToDisplay = array(); | ||
954 | 957 | ||
955 | $nblinksToDisplay = 50; // Number of links to display. | 958 | $nblinksToDisplay = 50; // Number of links to display. |
956 | if (!empty($_GET['nb'])) // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links. | 959 | if (!empty($_GET['nb'])) // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links. |
@@ -1027,9 +1030,6 @@ function showATOM() | |||
1027 | if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']); | 1030 | if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']); |
1028 | else if (!empty($_GET['searchtags'])) $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags'])); | 1031 | else if (!empty($_GET['searchtags'])) $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags'])); |
1029 | else $linksToDisplay = $LINKSDB; | 1032 | else $linksToDisplay = $LINKSDB; |
1030 | |||
1031 | if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn()) | ||
1032 | $linksToDisplay = array(); | ||
1033 | 1033 | ||
1034 | $nblinksToDisplay = 50; // Number of links to display. | 1034 | $nblinksToDisplay = 50; // Number of links to display. |
1035 | if (!empty($_GET['nb'])) // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links. | 1035 | if (!empty($_GET['nb'])) // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links. |
@@ -1190,8 +1190,7 @@ function showDaily() | |||
1190 | } | 1190 | } |
1191 | 1191 | ||
1192 | $linksToDisplay=$LINKSDB->filterDay($day); | 1192 | $linksToDisplay=$LINKSDB->filterDay($day); |
1193 | if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn()) | 1193 | |
1194 | $linksToDisplay = array(); | ||
1195 | // We pre-format some fields for proper output. | 1194 | // We pre-format some fields for proper output. |
1196 | foreach($linksToDisplay as $key=>$link) | 1195 | foreach($linksToDisplay as $key=>$link) |
1197 | { | 1196 | { |
@@ -1270,9 +1269,6 @@ function renderPage() | |||
1270 | if (!empty($_GET['searchterm'])) $links = $LINKSDB->filterFulltext($_GET['searchterm']); | 1269 | if (!empty($_GET['searchterm'])) $links = $LINKSDB->filterFulltext($_GET['searchterm']); |
1271 | elseif (!empty($_GET['searchtags'])) $links = $LINKSDB->filterTags(trim($_GET['searchtags'])); | 1270 | elseif (!empty($_GET['searchtags'])) $links = $LINKSDB->filterTags(trim($_GET['searchtags'])); |
1272 | else $links = $LINKSDB; | 1271 | else $links = $LINKSDB; |
1273 | |||
1274 | if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn()) | ||
1275 | $links = array(); | ||
1276 | 1272 | ||
1277 | $body=''; | 1273 | $body=''; |
1278 | $linksToDisplay=array(); | 1274 | $linksToDisplay=array(); |
@@ -1300,8 +1296,7 @@ function renderPage() | |||
1300 | if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=tagcloud')) | 1296 | if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=tagcloud')) |
1301 | { | 1297 | { |
1302 | $tags= $LINKSDB->allTags(); | 1298 | $tags= $LINKSDB->allTags(); |
1303 | if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn()) | 1299 | |
1304 | $tags = array(); | ||
1305 | // We sort tags alphabetically, then choose a font size according to count. | 1300 | // We sort tags alphabetically, then choose a font size according to count. |
1306 | // First, find max value. | 1301 | // First, find max value. |
1307 | $maxcount=0; foreach($tags as $key=>$value) $maxcount=max($maxcount,$value); | 1302 | $maxcount=0; foreach($tags as $key=>$value) $maxcount=max($maxcount,$value); |
@@ -1914,16 +1909,12 @@ function buildLinkList($PAGE,$LINKSDB) | |||
1914 | if (isset($_GET['searchterm'])) // Fulltext search | 1909 | if (isset($_GET['searchterm'])) // Fulltext search |
1915 | { | 1910 | { |
1916 | $linksToDisplay = $LINKSDB->filterFulltext(trim($_GET['searchterm'])); | 1911 | $linksToDisplay = $LINKSDB->filterFulltext(trim($_GET['searchterm'])); |
1917 | if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn()) | ||
1918 | $linksToDisplay = array(); | ||
1919 | $search_crits=htmlspecialchars(trim($_GET['searchterm'])); | 1912 | $search_crits=htmlspecialchars(trim($_GET['searchterm'])); |
1920 | $search_type='fulltext'; | 1913 | $search_type='fulltext'; |
1921 | } | 1914 | } |
1922 | elseif (isset($_GET['searchtags'])) // Search by tag | 1915 | elseif (isset($_GET['searchtags'])) // Search by tag |
1923 | { | 1916 | { |
1924 | $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags'])); | 1917 | $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags'])); |
1925 | if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn()) | ||
1926 | $linksToDisplay = array(); | ||
1927 | $search_crits=explode(' ',trim($_GET['searchtags'])); | 1918 | $search_crits=explode(' ',trim($_GET['searchtags'])); |
1928 | $search_type='tags'; | 1919 | $search_type='tags'; |
1929 | } | 1920 | } |
@@ -1939,9 +1930,6 @@ function buildLinkList($PAGE,$LINKSDB) | |||
1939 | } | 1930 | } |
1940 | $search_type='permalink'; | 1931 | $search_type='permalink'; |
1941 | } | 1932 | } |
1942 | // We chose to disable all private links and the user isn't logged in, do not return any link. | ||
1943 | else if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn()) | ||
1944 | $linksToDisplay = array(); | ||
1945 | else | 1933 | else |
1946 | $linksToDisplay = $LINKSDB; // Otherwise, display without filtering. | 1934 | $linksToDisplay = $LINKSDB; // Otherwise, display without filtering. |
1947 | 1935 | ||