Properly hide all links

>searchtags
This commit is contained in:
feula 2015-05-11 19:55:59 +02:00
parent 569ffb59d4
commit 59c90f5808

View file

@ -943,8 +943,12 @@ function showRSS()
// Optionally filter the results: // Optionally filter the results:
$linksToDisplay=array(); $linksToDisplay=array();
if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']); if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']);
elseif (!empty($_GET['searchtags'])) $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags'])); else if (!empty($_GET['searchtags'])) $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags']));
else $linksToDisplay = $LINKSDB; else $linksToDisplay = $LINKSDB;
if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
$linksToDisplay = array();
$nblinksToDisplay = 50; // Number of links to display. $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. if (!empty($_GET['nb'])) // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links.
{ {
@ -1018,8 +1022,12 @@ function showATOM()
// Optionally filter the results: // Optionally filter the results:
$linksToDisplay=array(); $linksToDisplay=array();
if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']); if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']);
elseif (!empty($_GET['searchtags'])) $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags'])); else if (!empty($_GET['searchtags'])) $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags']));
else $linksToDisplay = $LINKSDB; else $linksToDisplay = $LINKSDB;
if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
$linksToDisplay = array();
$nblinksToDisplay = 50; // Number of links to display. $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. if (!empty($_GET['nb'])) // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links.
{ {
@ -1179,6 +1187,8 @@ function showDaily()
} }
$linksToDisplay=$LINKSDB->filterDay($day); $linksToDisplay=$LINKSDB->filterDay($day);
if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
$linksToDisplay = array();
// We pre-format some fields for proper output. // We pre-format some fields for proper output.
foreach($linksToDisplay as $key=>$link) foreach($linksToDisplay as $key=>$link)
{ {
@ -1257,6 +1267,10 @@ function renderPage()
if (!empty($_GET['searchterm'])) $links = $LINKSDB->filterFulltext($_GET['searchterm']); if (!empty($_GET['searchterm'])) $links = $LINKSDB->filterFulltext($_GET['searchterm']);
elseif (!empty($_GET['searchtags'])) $links = $LINKSDB->filterTags(trim($_GET['searchtags'])); elseif (!empty($_GET['searchtags'])) $links = $LINKSDB->filterTags(trim($_GET['searchtags']));
else $links = $LINKSDB; else $links = $LINKSDB;
if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
$links = array();
$body=''; $body='';
$linksToDisplay=array(); $linksToDisplay=array();
@ -1271,6 +1285,7 @@ function renderPage()
$linksToDisplay[]=$link; // Add to array. $linksToDisplay[]=$link; // Add to array.
} }
} }
$PAGE = new pageBuilder; $PAGE = new pageBuilder;
$PAGE->assign('linkcount',count($LINKSDB)); $PAGE->assign('linkcount',count($LINKSDB));
$PAGE->assign('linksToDisplay',$linksToDisplay); $PAGE->assign('linksToDisplay',$linksToDisplay);
@ -1282,6 +1297,8 @@ function renderPage()
if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=tagcloud')) if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=tagcloud'))
{ {
$tags= $LINKSDB->allTags(); $tags= $LINKSDB->allTags();
if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
$tags = array();
// We sort tags alphabetically, then choose a font size according to count. // We sort tags alphabetically, then choose a font size according to count.
// First, find max value. // First, find max value.
$maxcount=0; foreach($tags as $key=>$value) $maxcount=max($maxcount,$value); $maxcount=0; foreach($tags as $key=>$value) $maxcount=max($maxcount,$value);
@ -1880,12 +1897,16 @@ function buildLinkList($PAGE,$LINKSDB)
if (isset($_GET['searchterm'])) // Fulltext search if (isset($_GET['searchterm'])) // Fulltext search
{ {
$linksToDisplay = $LINKSDB->filterFulltext(trim($_GET['searchterm'])); $linksToDisplay = $LINKSDB->filterFulltext(trim($_GET['searchterm']));
if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
$linksToDisplay = array();
$search_crits=htmlspecialchars(trim($_GET['searchterm'])); $search_crits=htmlspecialchars(trim($_GET['searchterm']));
$search_type='fulltext'; $search_type='fulltext';
} }
elseif (isset($_GET['searchtags'])) // Search by tag elseif (isset($_GET['searchtags'])) // Search by tag
{ {
$linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags'])); $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags']));
if ($GLOBALS['config']['HIDE_PUBLIC_LINKS'] && !isLoggedIn())
$linksToDisplay = array();
$search_crits=explode(' ',trim($_GET['searchtags'])); $search_crits=explode(' ',trim($_GET['searchtags']));
$search_type='tags'; $search_type='tags';
} }