aboutsummaryrefslogtreecommitdiffstats
path: root/mod/dirsearch.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-09-19 19:50:13 -0700
committerfriendica <info@friendica.com>2013-09-19 19:50:13 -0700
commit54abed8457c504e69e3d139238d2ff09b0ec6cc8 (patch)
treeac20175cdf23219c3d307d99fd37af00c802edb2 /mod/dirsearch.php
parent9f237f7dba8f41fc243225d556a47164ee155635 (diff)
downloadvolse-hubzilla-54abed8457c504e69e3d139238d2ff09b0ec6cc8.tar.gz
volse-hubzilla-54abed8457c504e69e3d139238d2ff09b0ec6cc8.tar.bz2
volse-hubzilla-54abed8457c504e69e3d139238d2ff09b0ec6cc8.zip
provide a "safe search" backend and allow for self-censorship using nsfw or adult profile keywords. Eventually the directories will be forced to mark adult profiles and sync this knowledge between them. At the moment there's no way to do an unsafe search, but we really just need a checkbox and pass the value through directory to dirsearch on the back end, and some will want this as a pconfig.
Diffstat (limited to 'mod/dirsearch.php')
-rw-r--r--mod/dirsearch.php8
1 files changed, 6 insertions, 2 deletions
diff --git a/mod/dirsearch.php b/mod/dirsearch.php
index a522cd541..a92134942 100644
--- a/mod/dirsearch.php
+++ b/mod/dirsearch.php
@@ -41,6 +41,8 @@ function dirsearch_content(&$a) {
$agege = ((x($_REQUEST,'agege')) ? intval($_REQUEST['agege']) : 0 );
$agele = ((x($_REQUEST,'agele')) ? intval($_REQUEST['agele']) : 0 );
$kw = ((x($_REQUEST,'kw')) ? intval($_REQUEST['kw']) : 0 );
+ // by default use a safe search
+ $safe = ((x($_REQUEST,'safe')) ? intval($_REQUEST['safe']) : 1 );
$sync = ((x($_REQUEST,'sync')) ? datetime_convert('UTC','UTC',$_REQUEST['sync']) : '');
$sort_order = ((x($_REQUEST,'order')) ? $_REQUEST['order'] : '');
@@ -99,12 +101,14 @@ function dirsearch_content(&$a) {
$logic = ((strlen($sql_extra)) ? 0 : 1);
+ $safesql = (($safe) ? " and not ( xchan_flags & " . intval(XCHAN_FLAGS_CENSORED) . " ) " : '');
+
if($limit)
$qlimit = " LIMIT $limit ";
else {
$qlimit = " LIMIT " . intval($startrec) . " , " . intval($perpage);
if($return_total) {
- $r = q("SELECT COUNT(xchan_hash) AS `total` FROM xchan left join xprof on xchan_hash = xprof_hash where $logic $sql_extra and not ( xchan_flags & %d) and not ( xchan_flags & %d ) ",
+ $r = q("SELECT COUNT(xchan_hash) AS `total` FROM xchan left join xprof on xchan_hash = xprof_hash where $logic $sql_extra and not ( xchan_flags & %d) and not ( xchan_flags & %d ) $safesql ",
intval(XCHAN_FLAGS_HIDDEN),
intval(XCHAN_FLAGS_ORPHAN)
);
@@ -135,7 +139,7 @@ function dirsearch_content(&$a) {
}
else {
- $r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash where $logic $sql_extra and not ( xchan_flags & %d ) and not ( xchan_flags & %d ) $order $qlimit ",
+ $r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash where $logic $sql_extra and not ( xchan_flags & %d ) and not ( xchan_flags & %d ) $safesql $order $qlimit ",
intval(XCHAN_FLAGS_HIDDEN),
intval(XCHAN_FLAGS_ORPHAN)
);