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.
This commit is contained in:
parent
9f237f7dba
commit
54abed8457
2
boot.php
2
boot.php
@ -347,7 +347,7 @@ define ( 'HUBLOC_FLAGS_DELETED', 0x1000);
|
|||||||
|
|
||||||
define ( 'XCHAN_FLAGS_HIDDEN', 0x0001);
|
define ( 'XCHAN_FLAGS_HIDDEN', 0x0001);
|
||||||
define ( 'XCHAN_FLAGS_ORPHAN', 0x0002);
|
define ( 'XCHAN_FLAGS_ORPHAN', 0x0002);
|
||||||
|
define ( 'XCHAN_FLAGS_CENSORED', 0x0004);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Traficlights for Administration of HubLoc
|
* Traficlights for Administration of HubLoc
|
||||||
|
@ -1848,3 +1848,9 @@ function design_tools() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* case insensitive in_array() */
|
||||||
|
|
||||||
|
function in_arrayi($needle, $haystack) {
|
||||||
|
return in_array(strtolower($needle), array_map('strtolower', $haystack));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -1404,6 +1404,16 @@ function import_directory_profile($hash,$profile) {
|
|||||||
|
|
||||||
$arr['xprof_keywords'] = implode(' ',$clean);
|
$arr['xprof_keywords'] = implode(' ',$clean);
|
||||||
|
|
||||||
|
// Self censored, make it so
|
||||||
|
// These are not translated, so the German "erwachsenen" keyword will not censor the directory profile. Only the English form - "adult".
|
||||||
|
|
||||||
|
if(in_arrayi('nsfw',$clean) || in_arrayi('adult',$clean)) {
|
||||||
|
q("update xchan set xchan_flags = (xchan_flags | %d) where xchan_hash = '%s' limit 1",
|
||||||
|
intval(XCHAN_FLAGS_CENSORED)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$r = q("select * from xprof where xprof_hash = '%s' limit 1",
|
$r = q("select * from xprof where xprof_hash = '%s' limit 1",
|
||||||
dbesc($hash)
|
dbesc($hash)
|
||||||
);
|
);
|
||||||
|
@ -41,6 +41,8 @@ function dirsearch_content(&$a) {
|
|||||||
$agege = ((x($_REQUEST,'agege')) ? intval($_REQUEST['agege']) : 0 );
|
$agege = ((x($_REQUEST,'agege')) ? intval($_REQUEST['agege']) : 0 );
|
||||||
$agele = ((x($_REQUEST,'agele')) ? intval($_REQUEST['agele']) : 0 );
|
$agele = ((x($_REQUEST,'agele')) ? intval($_REQUEST['agele']) : 0 );
|
||||||
$kw = ((x($_REQUEST,'kw')) ? intval($_REQUEST['kw']) : 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']) : '');
|
$sync = ((x($_REQUEST,'sync')) ? datetime_convert('UTC','UTC',$_REQUEST['sync']) : '');
|
||||||
$sort_order = ((x($_REQUEST,'order')) ? $_REQUEST['order'] : '');
|
$sort_order = ((x($_REQUEST,'order')) ? $_REQUEST['order'] : '');
|
||||||
@ -99,12 +101,14 @@ function dirsearch_content(&$a) {
|
|||||||
|
|
||||||
$logic = ((strlen($sql_extra)) ? 0 : 1);
|
$logic = ((strlen($sql_extra)) ? 0 : 1);
|
||||||
|
|
||||||
|
$safesql = (($safe) ? " and not ( xchan_flags & " . intval(XCHAN_FLAGS_CENSORED) . " ) " : '');
|
||||||
|
|
||||||
if($limit)
|
if($limit)
|
||||||
$qlimit = " LIMIT $limit ";
|
$qlimit = " LIMIT $limit ";
|
||||||
else {
|
else {
|
||||||
$qlimit = " LIMIT " . intval($startrec) . " , " . intval($perpage);
|
$qlimit = " LIMIT " . intval($startrec) . " , " . intval($perpage);
|
||||||
if($return_total) {
|
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_HIDDEN),
|
||||||
intval(XCHAN_FLAGS_ORPHAN)
|
intval(XCHAN_FLAGS_ORPHAN)
|
||||||
);
|
);
|
||||||
@ -135,7 +139,7 @@ function dirsearch_content(&$a) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
else {
|
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_HIDDEN),
|
||||||
intval(XCHAN_FLAGS_ORPHAN)
|
intval(XCHAN_FLAGS_ORPHAN)
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user