aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Daemon/Onedirsync.php4
-rw-r--r--Zotlabs/Module/Acl.php1
-rw-r--r--Zotlabs/Module/Directory.php1
-rw-r--r--Zotlabs/Module/Dirsearch.php198
-rw-r--r--Zotlabs/Module/Pubsites.php1
-rw-r--r--Zotlabs/Widget/Dirtags.php2
6 files changed, 97 insertions, 110 deletions
diff --git a/Zotlabs/Daemon/Onedirsync.php b/Zotlabs/Daemon/Onedirsync.php
index 01879a470..9ab8ebb54 100644
--- a/Zotlabs/Daemon/Onedirsync.php
+++ b/Zotlabs/Daemon/Onedirsync.php
@@ -5,10 +5,6 @@ namespace Zotlabs\Daemon;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libzotdir;
-require_once('include/zot.php');
-require_once('include/dir_fns.php');
-
-
class Onedirsync {
static public function run($argc, $argv) {
diff --git a/Zotlabs/Module/Acl.php b/Zotlabs/Module/Acl.php
index fb95b0504..862a97bdc 100644
--- a/Zotlabs/Module/Acl.php
+++ b/Zotlabs/Module/Acl.php
@@ -438,7 +438,6 @@ class Acl extends \Zotlabs\Web\Controller {
}
if(! $url) {
- require_once("include/dir_fns.php");
$directory = Libzotdir::find_upstream_directory($dirmode);
$url = $directory['url'] . '/dirsearch';
}
diff --git a/Zotlabs/Module/Directory.php b/Zotlabs/Module/Directory.php
index e1555fc2d..b39887c9e 100644
--- a/Zotlabs/Module/Directory.php
+++ b/Zotlabs/Module/Directory.php
@@ -8,7 +8,6 @@ use Zotlabs\Lib\Libzotdir;
require_once('include/socgraph.php');
-require_once('include/dir_fns.php');
require_once('include/bbcode.php');
require_once('include/html2plain.php');
diff --git a/Zotlabs/Module/Dirsearch.php b/Zotlabs/Module/Dirsearch.php
index 804d7af5c..3cccaca37 100644
--- a/Zotlabs/Module/Dirsearch.php
+++ b/Zotlabs/Module/Dirsearch.php
@@ -4,26 +4,22 @@ namespace Zotlabs\Module;
use App;
use Zotlabs\Web\Controller;
-require_once('include/dir_fns.php');
-
-
-
class Dirsearch extends Controller {
function init() {
App::set_pager_itemspage(30);
-
+
}
-
+
function get() {
-
+
$ret = array('success' => false);
-
+
// logger('request: ' . print_r($_REQUEST,true));
-
-
+
+
$dirmode = intval(get_config('system','directory_mode'));
-
+
if($dirmode == DIRECTORY_MODE_NORMAL) {
$ret['message'] = t('This site is not a directory server');
json_return_and_die($ret);
@@ -31,24 +27,24 @@ class Dirsearch extends Controller {
$access_token = $_REQUEST['t'];
-
+
$token = get_config('system','realm_token');
if($token && $access_token != $token) {
$ret['message'] = t('This directory server requires an access token');
json_return_and_die($ret);
}
-
-
+
+
if(argc() > 1 && argv(1) === 'sites') {
$ret = $this->list_public_sites();
json_return_and_die($ret);
}
-
+
$sql_extra = '';
-
-
+
+
$tables = array('name','address','locale','region','postcode','country','gender','marital','sexual','keywords');
-
+
if($_REQUEST['query']) {
$advanced = $this->dir_parse_query($_REQUEST['query']);
if($advanced) {
@@ -64,9 +60,9 @@ class Dirsearch extends Controller {
}
}
}
-
+
$hash = ((x($_REQUEST['hash'])) ? $_REQUEST['hash'] : '');
-
+
$name = ((x($_REQUEST,'name')) ? $_REQUEST['name'] : '');
$hub = ((x($_REQUEST,'hub')) ? $_REQUEST['hub'] : '');
$address = ((x($_REQUEST,'address')) ? $_REQUEST['address'] : '');
@@ -82,16 +78,16 @@ class Dirsearch extends Controller {
$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);
-
+
if(get_config('system','disable_directory_keywords'))
$kw = 0;
-
-
+
+
// by default use a safe search
$safe = ((x($_REQUEST,'safe'))); // ? intval($_REQUEST['safe']) : 1 );
if ($safe === false)
$safe = 1;
-
+
if(array_key_exists('sync',$_REQUEST)) {
if($_REQUEST['sync'])
$sync = datetime_convert('UTC','UTC',$_REQUEST['sync']);
@@ -100,7 +96,7 @@ class Dirsearch extends Controller {
}
else
$sync = false;
-
+
if(($dirmode == DIRECTORY_MODE_STANDALONE) && (! $hub)) {
$hub = \App::get_hostname();
}
@@ -109,13 +105,13 @@ class Dirsearch extends Controller {
$hub_query = " and xchan_hash in (select hubloc_hash from hubloc where hubloc_host = '" . protect_sprintf(dbesc($hub)) . "') ";
else
$hub_query = '';
-
+
$sort_order = ((x($_REQUEST,'order')) ? $_REQUEST['order'] : '');
-
+
$joiner = ' OR ';
if($_REQUEST['and'])
$joiner = ' AND ';
-
+
if($name)
$sql_extra .= $this->dir_query_build($joiner,'xchan_name',$name);
if($address)
@@ -136,58 +132,58 @@ class Dirsearch extends Controller {
$sql_extra .= $this->dir_query_build($joiner,'xprof_sexual',$sexual);
if($keywords)
$sql_extra .= $this->dir_query_build($joiner,'xprof_keywords',$keywords);
-
-
- // we only support an age range currently. You must set both agege
- // (greater than or equal) and agele (less than or equal)
-
+
+
+ // we only support an age range currently. You must set both agege
+ // (greater than or equal) and agele (less than or equal)
+
if($agele && $agege) {
$sql_extra .= " $joiner ( xprof_age <= " . intval($agele) . " ";
$sql_extra .= " AND xprof_age >= " . intval($agege) . ") ";
}
-
-
+
+
if($hash) {
$sql_extra = " AND xchan_hash like '" . dbesc($hash) . protect_sprintf('%') . "' ";
}
-
-
+
+
$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);
$return_total = ((x($_REQUEST,'return_total')) ? intval($_REQUEST['return_total']) : 0);
-
+
// mtime is not currently working
-
+
$mtime = ((x($_REQUEST,'mtime')) ? datetime_convert('UTC','UTC',$_REQUEST['mtime']) : '');
-
- // ok a separate tag table won't work.
+
+ // ok a separate tag table won't work.
// merge them into xprof
-
+
$ret['success'] = true;
-
+
// If &limit=n, return at most n entries
// If &return_total=1, we count matching entries and return that as 'total_items' for use in pagination.
// By default we return one page (default 80 items maximum) and do not count total entries
-
+
$logic = ((strlen($sql_extra)) ? 'false' : 'true');
-
+
if($hash)
$logic = 'true';
-
+
if($dirmode == DIRECTORY_MODE_STANDALONE) {
$sql_extra .= " and xchan_addr like '%%" . \App::get_hostname() . "' ";
}
-
+
$safesql = (($safe > 0) ? " and xchan_censored = 0 and xchan_selfcensored = 0 " : '');
if($safe < 0)
$safesql = " and ( xchan_censored = 1 OR xchan_selfcensored = 1 ) ";
-
+
if($forums)
$safesql .= " and xchan_pubforum = " . ((intval($forums)) ? '1 ' : '0 ');
-
- if($limit)
+
+ if($limit)
$qlimit = " LIMIT $limit ";
else {
$qlimit = " LIMIT " . intval($perpage) . " OFFSET " . intval($startrec);
@@ -198,24 +194,24 @@ class Dirsearch extends Controller {
}
}
}
-
+
if($sort_order == 'normal') {
$order = " order by xchan_name asc ";
-
- // Start the alphabetic search at 'A'
+
+ // Start the alphabetic search at 'A'
// This will make a handful of channels whose names begin with
// punctuation un-searchable in this mode
-
+
$safesql .= " and ascii(substring(xchan_name FROM 1 FOR 1)) > 64 ";
}
elseif($sort_order == 'reverse')
$order = " order by xchan_name desc ";
elseif($sort_order == 'reversedate')
$order = " order by xchan_name_date asc ";
- else
+ 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",
@@ -228,7 +224,7 @@ class Dirsearch extends Controller {
$flags[] = 'deleted';
if($rr['ud_flags'] & UPDATE_FLAGS_FORCED)
$flags[] = 'forced';
-
+
$spkt['transactions'][] = array(
'hash' => $rr['ud_hash'],
'address' => $rr['ud_addr'],
@@ -245,7 +241,7 @@ class Dirsearch extends Controller {
$spkt['ratings'] = array();
foreach($r as $rr) {
$spkt['ratings'][] = array(
- 'type' => 'rating',
+ 'type' => 'rating',
'encoding' => 'zot',
'channel' => $rr['xlink_xchan'],
'target' => $rr['xlink_link'],
@@ -259,37 +255,37 @@ class Dirsearch extends Controller {
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 ) $hub_query and xchan_network = 'zot6' and xchan_system = 0 and xchan_hidden = 0 and xchan_orphan = 0 and xchan_deleted = 0
+
+ $r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash
+ where ( $logic $sql_extra ) $hub_query and xchan_network = 'zot6' and xchan_system = 0 and xchan_hidden = 0 and xchan_orphan = 0 and xchan_deleted = 0
$safesql $order $qlimit "
);
-
-
-
+
+
+
$ret['page'] = $page + 1;
- $ret['records'] = count($r);
+ $ret['records'] = count($r);
}
-
-
-
+
+
+
if($r) {
-
+
$entries = array();
-
+
foreach($r as $rr) {
-
+
$entry = array();
-
+
$pc = q("select count(xlink_rating) as total_ratings from xlink where xlink_link = '%s' and xlink_rating != 0 and xlink_static = 1 group by xlink_rating",
dbesc($rr['xchan_hash'])
);
-
+
if($pc)
$entry['total_ratings'] = intval($pc[0]['total_ratings']);
else
$entry['total_ratings'] = 0;
-
+
$entry['name'] = $rr['xchan_name'];
$entry['hash'] = $rr['xchan_hash'];
$entry['censored'] = $rr['xchan_censored'];
@@ -313,11 +309,11 @@ class Dirsearch extends Controller {
$entry['homepage'] = $rr['xprof_homepage'];
$entry['hometown'] = $rr['xprof_hometown'];
$entry['keywords'] = $rr['xprof_keywords'];
-
+
$entries[] = $entry;
-
+
}
-
+
$ret['results'] = $entries;
if($kw) {
$k = dir_tagadelic($kw, $hub);
@@ -328,30 +324,30 @@ class Dirsearch extends Controller {
}
}
}
- }
-
+ }
+
json_return_and_die($ret);
}
-
+
function dir_query_build($joiner,$field,$s) {
$ret = '';
if(trim($s))
$ret .= dbesc($joiner) . " " . dbesc($field) . " like '" . protect_sprintf( '%' . dbesc($s) . '%' ) . "' ";
return $ret;
}
-
+
function dir_flag_build($joiner,$field,$bit,$s) {
return dbesc($joiner) . " ( " . dbesc($field) . " & " . intval($bit) . " ) " . ((intval($s)) ? '>' : '=' ) . " 0 ";
}
-
-
+
+
function dir_parse_query($s) {
-
+
$ret = array();
$curr = array();
$all = explode(' ',$s);
$quoted_string = false;
-
+
if($all) {
foreach($all as $q) {
if($quoted_string === false) {
@@ -382,7 +378,7 @@ class Dirsearch extends Controller {
$ret[] = $curr;
$curr = array();
continue;
- }
+ }
else {
$ret[] = $curr;
$curr = array();
@@ -405,15 +401,15 @@ class Dirsearch extends Controller {
logger('dir_parse_query:' . print_r($ret,true),LOGGER_DATA);
return $ret;
}
-
-
-
-
-
-
-
+
+
+
+
+
+
+
function list_public_sites() {
-
+
$rand = db_getfunc('rand');
$realm = get_directory_realm();
if($realm == DIRECTORY_REALM) {
@@ -428,16 +424,16 @@ class Dirsearch extends Controller {
intval(SITE_TYPE_ZOT)
);
}
-
+
$ret = array('success' => false);
-
+
if($r) {
$ret['success'] = true;
$ret['sites'] = array();
$insecure = array();
-
+
foreach($r as $rr) {
-
+
if($rr['site_access'] == ACCESS_FREE)
$access = 'free';
elseif($rr['site_access'] == ACCESS_PAID)
@@ -446,14 +442,14 @@ class Dirsearch extends Controller {
$access = 'tiered';
else
$access = 'private';
-
+
if($rr['site_register'] == REGISTER_OPEN)
$register = 'open';
elseif($rr['site_register'] == REGISTER_APPROVE)
$register = 'approve';
else
$register = 'closed';
-
+
if(strpos($rr['site_url'],'https://') !== false)
$ret['sites'][] = array('url' => $rr['site_url'], 'access' => $access, 'register' => $register, 'sellpage' => $rr['site_sellpage'], 'location' => $rr['site_location'], 'project' => $rr['site_project'], 'version' => $rr['site_version']);
else
diff --git a/Zotlabs/Module/Pubsites.php b/Zotlabs/Module/Pubsites.php
index 4b64d9af6..fd5aeaa72 100644
--- a/Zotlabs/Module/Pubsites.php
+++ b/Zotlabs/Module/Pubsites.php
@@ -6,7 +6,6 @@ use Zotlabs\Lib\Libzotdir;
class Pubsites extends \Zotlabs\Web\Controller {
function get() {
- require_once('include/dir_fns.php');
$dirmode = intval(get_config('system','directory_mode'));
if(($dirmode == DIRECTORY_MODE_PRIMARY) || ($dirmode == DIRECTORY_MODE_STANDALONE)) {
diff --git a/Zotlabs/Widget/Dirtags.php b/Zotlabs/Widget/Dirtags.php
index f211d5942..246c47dde 100644
--- a/Zotlabs/Widget/Dirtags.php
+++ b/Zotlabs/Widget/Dirtags.php
@@ -2,8 +2,6 @@
namespace Zotlabs\Widget;
-require_once('include/dir_fns.php');
-
class Dirtags {
function widget($arr) {