aboutsummaryrefslogtreecommitdiffstats
path: root/mod/dirsearch.php
diff options
context:
space:
mode:
Diffstat (limited to 'mod/dirsearch.php')
-rw-r--r--mod/dirsearch.php88
1 files changed, 56 insertions, 32 deletions
diff --git a/mod/dirsearch.php b/mod/dirsearch.php
index e292553ad..a88db0a2c 100644
--- a/mod/dirsearch.php
+++ b/mod/dirsearch.php
@@ -4,7 +4,7 @@ require_once('include/dir_fns.php');
function dirsearch_init(&$a) {
- $a->set_pager_itemspage(80);
+ $a->set_pager_itemspage(60);
}
@@ -64,6 +64,9 @@ 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 );
+ $forums = ((array_key_exists('pubforums',$_REQUEST)) ? intval($_REQUEST['pubforums']) : 0);
+
+
// by default use a safe search
$safe = ((x($_REQUEST,'safe'))); // ? intval($_REQUEST['safe']) : 1 );
@@ -108,6 +111,10 @@ function dirsearch_content(&$a) {
if($keywords)
$sql_extra .= dir_query_build($joiner,'xprof_keywords',$keywords);
+ if($forums)
+ $sql_extra .= dir_flag_build($joiner,'xprof_flags',XCHAN_FLAGS_PUBFORUM, $forums);
+
+
// we only support an age range currently. You must set both agege
// (greater than or equal) and agele (less than or equal)
@@ -122,7 +129,7 @@ function dirsearch_content(&$a) {
}
- $perpage = (($_REQUEST['n']) ? $_REQUEST['n'] : 80);
+ $perpage = (($_REQUEST['n']) ? $_REQUEST['n'] : 60);
$page = (($_REQUEST['p']) ? intval($_REQUEST['p'] - 1) : 0);
$startrec = (($page+1) * $perpage) - $perpage;
$limit = (($_REQUEST['limit']) ? intval($_REQUEST['limit']) : 0);
@@ -151,16 +158,16 @@ function dirsearch_content(&$a) {
}
- $safesql = (($safe > 0) ? " and not ( xchan_flags & " . intval(XCHAN_FLAGS_CENSORED|XCHAN_FLAGS_SELFCENSORED) . " ) " : '');
+ $safesql = (($safe > 0) ? " and not ( xchan_flags & " . intval(XCHAN_FLAGS_CENSORED|XCHAN_FLAGS_SELFCENSORED) . " )>0 " : '');
if($safe < 0)
- $safesql = " and ( xchan_flags & " . intval(XCHAN_FLAGS_CENSORED|XCHAN_FLAGS_SELFCENSORED) . " ) ";
+ $safesql = " and ( xchan_flags & " . intval(XCHAN_FLAGS_CENSORED|XCHAN_FLAGS_SELFCENSORED) . " )>0 ";
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 xchan_network = 'zot' and not ( xchan_flags & %d) and not ( xchan_flags & %d ) and not ( xchan_flags & %d ) $safesql ",
+ $r = q("SELECT COUNT(xchan_hash) AS `total` FROM xchan left join xprof on xchan_hash = xprof_hash where $logic $sql_extra and xchan_network = 'zot' and not ( xchan_flags & %d)>0 and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 $safesql ",
intval(XCHAN_FLAGS_HIDDEN),
intval(XCHAN_FLAGS_ORPHAN),
intval(XCHAN_FLAGS_DELETED)
@@ -176,10 +183,11 @@ function dirsearch_content(&$a) {
$order = " order by xchan_name asc ";
elseif($sort_order == 'reverse')
$order = " order by xchan_name desc ";
+ elseif($sort_order == 'reversedate')
+ $order = " order by xchan_name_date asc ";
else
$order = " order by xchan_name_date desc ";
-
if($sync) {
$spkt = array('transactions' => array());
$r = q("select * from updates where ud_date >= '%s' and ud_guid != '' order by ud_date desc",
@@ -205,7 +213,7 @@ function dirsearch_content(&$a) {
json_return_and_die($spkt);
}
else {
- $r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash where ( $logic $sql_extra ) and xchan_network = 'zot' and not ( xchan_flags & %d ) and not ( xchan_flags & %d ) and not ( xchan_flags & %d ) $safesql $order $qlimit ",
+ $r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash where ( $logic $sql_extra ) and xchan_network = 'zot' and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 and not ( xchan_flags & %d )>0 $safesql $order $qlimit ",
intval(XCHAN_FLAGS_HIDDEN),
intval(XCHAN_FLAGS_ORPHAN),
intval(XCHAN_FLAGS_DELETED)
@@ -226,6 +234,8 @@ function dirsearch_content(&$a) {
$entry['name'] = $rr['xchan_name'];
$entry['hash'] = $rr['xchan_hash'];
+ $entry['public_forum'] = (($rr['xchan_flags'] & XCHAN_FLAGS_PUBFORUM) ? true : false);
+
$entry['url'] = $rr['xchan_url'];
$entry['photo_l'] = $rr['xchan_photo_l'];
$entry['photo'] = $rr['xchan_photo_m'];
@@ -271,6 +281,11 @@ function dir_query_build($joiner,$field,$s) {
return $ret;
}
+function dir_flag_build($joiner,$field,$bit,$s) {
+ return dbesc($joiner) . " ( " . dbesc('xchan_flags') . " & " . intval($bit) . " ) " . ((intval($s)) ? '>' : '=' ) . " 0 ";
+}
+
+
function dir_parse_query($s) {
$ret = array();
@@ -280,35 +295,44 @@ function dir_parse_query($s) {
if($all) {
foreach($all as $q) {
- if($q === 'and') {
- $curr['logic'] = 'and';
- continue;
- }
- if($q === 'or') {
- $curr['logic'] = 'or';
- continue;
- }
- if($q === 'not') {
- $curr['logic'] .= ' not';
- continue;
- }
- if(strpos($q,'=')) {
- if(! isset($curr['logic']))
+ if($quoted_string === false) {
+ if($q === 'and') {
+ $curr['logic'] = 'and';
+ continue;
+ }
+ if($q === 'or') {
$curr['logic'] = 'or';
- $curr['field'] = trim(substr($q,0,strpos($q,'=')));
- $curr['value'] = trim(substr($q,strpos($q,'=')+1));
- if(strpos($curr['value'],'"') !== false) {
- $quoted_string = true;
- $curr['value'] = substr($curr['value'],strpos($curr['value'],'"')+1);
+ continue;
}
- else {
- $ret[] = $curr;
- $curr = array();
- $continue;
+ if($q === 'not') {
+ $curr['logic'] .= ' not';
+ continue;
+ }
+ if(strpos($q,'=')) {
+ if(! isset($curr['logic']))
+ $curr['logic'] = 'or';
+ $curr['field'] = trim(substr($q,0,strpos($q,'=')));
+ $curr['value'] = trim(substr($q,strpos($q,'=')+1));
+ if($curr['value'][0] == '"' && $curr['value'][strlen($curr['value'])-1] != '"') {
+ $quoted_string = true;
+ $curr['value'] = substr($curr['value'],1);
+ continue;
+ }
+ elseif($curr['value'][0] == '"' && $curr['value'][strlen($curr['value'])-1] == '"') {
+ $curr['value'] = substr($curr['value'],1,strlen($curr['value'])-2);
+ $ret[] = $curr;
+ $curr = array();
+ continue;
+ }
+ else {
+ $ret[] = $curr;
+ $curr = array();
+ continue;
+ }
}
}
- elseif($quoted_string) {
- if(strpos($q,'"') !== false) {
+ else {
+ if($q[strlen($q)-1] == '"') {
$curr['value'] .= ' ' . str_replace('"','',trim($q));
$ret[] = $curr;
$curr = array();