From c65ea0b97b2dc6fcefa0d2da489f32bdd7d05b65 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 5 Sep 2013 22:00:06 -0700 Subject: public site list (will take a few days to populate, assuming folks have updated their site access policy which old sites do not have) --- mod/dirsearch.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'mod/dirsearch.php') diff --git a/mod/dirsearch.php b/mod/dirsearch.php index 524f55cc1..7bf430bec 100644 --- a/mod/dirsearch.php +++ b/mod/dirsearch.php @@ -22,6 +22,12 @@ function dirsearch_content(&$a) { json_return_and_die($ret); } + if(argc > 1 && argv(1) === 'sites') { + $ret = list_public_sites(); + json_return_and_die($ret); + } + + $name = ((x($_REQUEST,'name')) ? $_REQUEST['name'] : ''); $hub = ((x($_REQUEST,'hub')) ? $_REQUEST['hub'] : ''); $address = ((x($_REQUEST,'address')) ? $_REQUEST['address'] : ''); @@ -163,3 +169,33 @@ function dirsearch_content(&$a) { json_return_and_die($ret); } + + +function list_public_sites() { + $r = q("select * from site where site_access != 0 order by rand()"); + $ret = array('success' => false); + + if($r) { + $ret['success'] = true; + $ret['sites'] = array(); + foreach($r as $rr) { + + if($rr['site_access'] == ACCESS_FREE) + $access = 'free'; + elseif($rr['site_access'] == ACCESS_PAID) + $access = 'paid'; + else + $access = 'private'; + + if($rr['site_register'] == REGISTER_OPEN) + $register = 'open'; + elseif($rr['site_register'] == REGISTER_APPROVE) + $register = 'approve'; + else + $register = 'closed'; + + $ret['sites'][] = array('url' => $rr['site_url'], 'access' => $access, 'register' => $register); + } + } + return $ret; +} \ No newline at end of file -- cgit v1.2.3 From 2c53017fb5fc250f3b8a9fa9fa33ff6ef0dd341f Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 5 Sep 2013 22:23:57 -0700 Subject: function name --- mod/dirsearch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod/dirsearch.php') diff --git a/mod/dirsearch.php b/mod/dirsearch.php index 7bf430bec..064c3f287 100644 --- a/mod/dirsearch.php +++ b/mod/dirsearch.php @@ -22,7 +22,7 @@ function dirsearch_content(&$a) { json_return_and_die($ret); } - if(argc > 1 && argv(1) === 'sites') { + if(argc() > 1 && argv(1) === 'sites') { $ret = list_public_sites(); json_return_and_die($ret); } -- cgit v1.2.3 From 75dfcf9c4f558de41798166329dd5b6e4bf35fd0 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 9 Sep 2013 13:45:51 -0700 Subject: quick fix to directory --- mod/dirsearch.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mod/dirsearch.php') diff --git a/mod/dirsearch.php b/mod/dirsearch.php index 064c3f287..6034fdc12 100644 --- a/mod/dirsearch.php +++ b/mod/dirsearch.php @@ -113,11 +113,11 @@ function dirsearch_content(&$a) { if($mtime) { $qlimit = ''; - $sql_extra .= " and xchan_hash in ( select ud_hash from updates where ud_date > '" . dbesc($mtime) . "' ) "; +// $sql_extra .= " and xchan_hash in ( select ud_hash from updates where ud_date > '" . dbesc($mtime) . "' ) "; } if($sort_order == 'date') - $order = " order by ud_date desc "; + $order = ""; // " order by ud_date desc "; elseif($sort_order == 'reverse') $order = " order by xchan_name desc "; else @@ -125,7 +125,7 @@ function dirsearch_content(&$a) { - $r = q("SELECT xchan.*, xprof.*, updates.* from xchan left join xprof on xchan_hash = xprof_hash left join updates on xchan_hash = ud_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 ) $order $qlimit ", intval(XCHAN_FLAGS_HIDDEN), intval(XCHAN_FLAGS_ORPHAN) ); -- cgit v1.2.3 From 129a119c84d87bffe099cea7ac5b0ed511c26f80 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 15 Sep 2013 03:48:43 -0700 Subject: implement what I hope will now be the server side of directory sync, add viewsrc to item_photo_menu, and log what changed in import_xchan update objects so we can find out why there are so many updates when nothing _obvious_ has changed that should trigger it. --- mod/dirsearch.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'mod/dirsearch.php') diff --git a/mod/dirsearch.php b/mod/dirsearch.php index 6034fdc12..04d77a298 100644 --- a/mod/dirsearch.php +++ b/mod/dirsearch.php @@ -41,6 +41,7 @@ function dirsearch_content(&$a) { $agege = ((x($_REQUEST,'agege')) ? intval($_REQUEST['agege']) : 0 ); $agele = ((x($_REQUEST,'agele')) ? intval($_REQUEST['agele']) : 0 ); + $sync = ((x($_REQUEST,'sync')) ? datetime_convert('UTC','UTC',$_REQUEST['sync']) : ''); $sort_order = ((x($_REQUEST,'order')) ? $_REQUEST['order'] : ''); // TODO - a meta search which joins all of these things to one search string @@ -82,6 +83,7 @@ function dirsearch_content(&$a) { $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']) : ''); @@ -124,11 +126,19 @@ function dirsearch_content(&$a) { $order = " order by xchan_name asc "; + if($sync) { - $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 ", - intval(XCHAN_FLAGS_HIDDEN), - intval(XCHAN_FLAGS_ORPHAN) - ); + $r = q("select xchan.*, updates.* from xchan left join updates on ud_hash = xchan_hash where ud_date >= '%s' and ud_guid != '' order by ud_date desc", + dbesc($sync) + ); + + } + 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 ", + intval(XCHAN_FLAGS_HIDDEN), + intval(XCHAN_FLAGS_ORPHAN) + ); + } $ret['page'] = $page + 1; $ret['records'] = count($r); @@ -145,6 +155,7 @@ function dirsearch_content(&$a) { $entry['hash'] = $rr['xchan_hash']; $entry['updated'] = (($rr['ud_date']) ? $rr['ud_date'] : '0000-00-00 00:00:00'); + $entry['update_guid'] = (($rr['ud_guid']) ? $rr['ud_guid'] : ''); $entry['url'] = $rr['xchan_url']; $entry['photo'] = $rr['xchan_photo_m']; $entry['address'] = $rr['xchan_addr']; -- cgit v1.2.3 From d3aa31be4d84764e4d119343d8bc5eba5a84272b Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 17 Sep 2013 22:27:51 -0700 Subject: site sellpage links --- mod/dirsearch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod/dirsearch.php') diff --git a/mod/dirsearch.php b/mod/dirsearch.php index 04d77a298..a285d9b8c 100644 --- a/mod/dirsearch.php +++ b/mod/dirsearch.php @@ -205,7 +205,7 @@ function list_public_sites() { else $register = 'closed'; - $ret['sites'][] = array('url' => $rr['site_url'], 'access' => $access, 'register' => $register); + $ret['sites'][] = array('url' => $rr['site_url'], 'access' => $access, 'register' => $register, 'sellpage' => $rr['site_sellpage']); } } return $ret; -- cgit v1.2.3 From f7acc94bfedae6f23e0bc883541ca23132e95a06 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 17 Sep 2013 22:52:46 -0700 Subject: provide the back-end for a directory tag cloud --- mod/dirsearch.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'mod/dirsearch.php') diff --git a/mod/dirsearch.php b/mod/dirsearch.php index a285d9b8c..0a4d0ed2b 100644 --- a/mod/dirsearch.php +++ b/mod/dirsearch.php @@ -175,7 +175,15 @@ function dirsearch_content(&$a) { } $ret['results'] = $entries; - + if(! $sync) { + $k = dir_tagadelic(24); + if($k) { + $ret['keywords'] = array(); + foreach($k as $kv) { + $ret['keywords'][] = array('term' => $kv[0],'weight' => $kv[1]); + } + } + } } json_return_and_die($ret); -- cgit v1.2.3 From e4d2e2200e04c8df699d9a8efade661123ef7ac8 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 18 Sep 2013 17:47:26 -0700 Subject: add "tiered" access policy, add tagcloud to directory pages --- mod/dirsearch.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'mod/dirsearch.php') diff --git a/mod/dirsearch.php b/mod/dirsearch.php index 0a4d0ed2b..a522cd541 100644 --- a/mod/dirsearch.php +++ b/mod/dirsearch.php @@ -40,6 +40,7 @@ function dirsearch_content(&$a) { $keywords = ((x($_REQUEST,'keywords')) ? $_REQUEST['keywords'] : ''); $agege = ((x($_REQUEST,'agege')) ? intval($_REQUEST['agege']) : 0 ); $agele = ((x($_REQUEST,'agele')) ? intval($_REQUEST['agele']) : 0 ); + $kw = ((x($_REQUEST,'kw')) ? intval($_REQUEST['kw']) : 0 ); $sync = ((x($_REQUEST,'sync')) ? datetime_convert('UTC','UTC',$_REQUEST['sync']) : ''); $sort_order = ((x($_REQUEST,'order')) ? $_REQUEST['order'] : ''); @@ -175,12 +176,12 @@ function dirsearch_content(&$a) { } $ret['results'] = $entries; - if(! $sync) { - $k = dir_tagadelic(24); + if(($kw) && (! $sync)) { + $k = dir_tagadelic($kw); if($k) { $ret['keywords'] = array(); foreach($k as $kv) { - $ret['keywords'][] = array('term' => $kv[0],'weight' => $kv[1]); + $ret['keywords'][] = array('term' => $kv[0],'weight' => $kv[1], 'normalise' => $kv[2]); } } } @@ -203,6 +204,8 @@ function list_public_sites() { $access = 'free'; elseif($rr['site_access'] == ACCESS_PAID) $access = 'paid'; + elseif($rr['site_access'] == ACCESS_TIERED) + $access = 'tiered'; else $access = 'private'; -- cgit v1.2.3 From 54abed8457c504e69e3d139238d2ff09b0ec6cc8 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 19 Sep 2013 19:50:13 -0700 Subject: 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. --- mod/dirsearch.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'mod/dirsearch.php') 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) ); -- cgit v1.2.3 From 6cb81f6e474c3b904e5c759ee96e7fac115050e9 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 19 Sep 2013 21:36:22 -0700 Subject: use &safe=-1 for unsafe only --- mod/dirsearch.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'mod/dirsearch.php') diff --git a/mod/dirsearch.php b/mod/dirsearch.php index a92134942..fc0ac4fe3 100644 --- a/mod/dirsearch.php +++ b/mod/dirsearch.php @@ -41,6 +41,7 @@ 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 ); @@ -101,7 +102,9 @@ function dirsearch_content(&$a) { $logic = ((strlen($sql_extra)) ? 0 : 1); - $safesql = (($safe) ? " and not ( xchan_flags & " . intval(XCHAN_FLAGS_CENSORED) . " ) " : ''); + $safesql = (($safe > 0) ? " and not ( xchan_flags & " . intval(XCHAN_FLAGS_CENSORED) . " ) " : ''); + if($safe < 0) + $safesql = " and ( xchan_flags & " . intval(XCHAN_FLAGS_CENSORED) . " ) "; if($limit) $qlimit = " LIMIT $limit "; -- cgit v1.2.3 From cdfb5f9dc740734fbd95363a026ab44ae1dd9d94 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 22 Sep 2013 20:38:24 -0700 Subject: adult channel setting --- mod/dirsearch.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mod/dirsearch.php') diff --git a/mod/dirsearch.php b/mod/dirsearch.php index fc0ac4fe3..3fec691be 100644 --- a/mod/dirsearch.php +++ b/mod/dirsearch.php @@ -102,9 +102,9 @@ function dirsearch_content(&$a) { $logic = ((strlen($sql_extra)) ? 0 : 1); - $safesql = (($safe > 0) ? " and not ( xchan_flags & " . intval(XCHAN_FLAGS_CENSORED) . " ) " : ''); + $safesql = (($safe > 0) ? " and not ( xchan_flags & " . intval(XCHAN_FLAGS_CENSORED|XCHAN_FLAGS_SELFCENSORED) . " ) " : ''); if($safe < 0) - $safesql = " and ( xchan_flags & " . intval(XCHAN_FLAGS_CENSORED) . " ) "; + $safesql = " and ( xchan_flags & " . intval(XCHAN_FLAGS_CENSORED|XCHAN_FLAGS_SELFCENSORED) . " ) "; if($limit) $qlimit = " LIMIT $limit "; -- cgit v1.2.3 From 49882c13a4fb67da29862034ddcfd9a55757f2ee Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 29 Sep 2013 22:24:37 -0700 Subject: there's our directory sync packet (aka transaction log). Now we just have to pass them around and act on them. --- mod/dirsearch.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'mod/dirsearch.php') diff --git a/mod/dirsearch.php b/mod/dirsearch.php index 3fec691be..a7e785c1b 100644 --- a/mod/dirsearch.php +++ b/mod/dirsearch.php @@ -135,11 +135,21 @@ function dirsearch_content(&$a) { if($sync) { - - $r = q("select xchan.*, updates.* from xchan left join updates on ud_hash = xchan_hash where ud_date >= '%s' and ud_guid != '' order by ud_date desc", + $spkt = array('transactions' => array()); + $r = q("select * from updates where ud_date >= '%s' and ud_guid != '' order by ud_date desc", dbesc($sync) ); - + if($r) { + foreach($r as $rr) { + $spkt['transactions'][] = array( + 'hash' => $rr['ud_hash'], + 'address' => $rr['ud_addr'], + 'transaction_id' => $rr['ud_guid'], + 'timestamp' => $rr['ud_date'] + ); + } + } + 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 not ( xchan_flags & %d ) and not ( xchan_flags & %d ) $safesql $order $qlimit ", @@ -183,7 +193,7 @@ function dirsearch_content(&$a) { } $ret['results'] = $entries; - if(($kw) && (! $sync)) { + if($kw) { $k = dir_tagadelic($kw); if($k) { $ret['keywords'] = array(); -- cgit v1.2.3 From e992cfeca9a80583b7cde12776fcfe279be02996 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 30 Sep 2013 18:33:27 -0700 Subject: directory sync - this will either work, or it won't work, or it will possibly recurse and blow up the matrix. Hard to say. Do you feel lucky? Well do ya' ... punk? Rule #1 - don't mess with anything unless it's blowing up the matrix. If it doesn't blow up the matrix, but doesn't work, just let it go and let's figure out what it is doing and what it isn't doing. The flow is as follows: Once a day go out to all the directory servers besides yourself and grab a list of updates. This happens in the poller. If we've never seen them before add them to the updates table. The poller also looks to see if we're a directory server and have updates that haven't yet been processed. It calls onedirsync.php to process each one. If we contact the channel to update and don't find anything (we're just doing a basic zot_finger), set a ud_last timestamp. If this is set we will only try once a day for seven days. Then we stop trying to update. This will probably cause a spike the first time through because you haven't seen any updates before, but we spread out the load over your delivery interval. --- mod/dirsearch.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'mod/dirsearch.php') diff --git a/mod/dirsearch.php b/mod/dirsearch.php index a7e785c1b..bb068a431 100644 --- a/mod/dirsearch.php +++ b/mod/dirsearch.php @@ -121,13 +121,9 @@ function dirsearch_content(&$a) { } } - if($mtime) { - $qlimit = ''; -// $sql_extra .= " and xchan_hash in ( select ud_hash from updates where ud_date > '" . dbesc($mtime) . "' ) "; - } if($sort_order == 'date') - $order = ""; // " order by ud_date desc "; + $order = ""; // Not currently implemented elseif($sort_order == 'reverse') $order = " order by xchan_name desc "; else @@ -141,11 +137,13 @@ function dirsearch_content(&$a) { ); if($r) { foreach($r as $rr) { + $flags = (($rr['ud_flags'] & UPDATE_FLAGS_DELETED) ? array('deleted') : array()); $spkt['transactions'][] = array( 'hash' => $rr['ud_hash'], 'address' => $rr['ud_addr'], 'transaction_id' => $rr['ud_guid'], - 'timestamp' => $rr['ud_date'] + 'timestamp' => $rr['ud_date'], + 'flags' => $flags ); } } -- cgit v1.2.3 From 2353e6d23f54902d3b2b9e3fd46f1baa6e803450 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 30 Sep 2013 19:28:59 -0700 Subject: small fixes --- mod/dirsearch.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'mod/dirsearch.php') diff --git a/mod/dirsearch.php b/mod/dirsearch.php index bb068a431..14307f274 100644 --- a/mod/dirsearch.php +++ b/mod/dirsearch.php @@ -45,7 +45,16 @@ function dirsearch_content(&$a) { // by default use a safe search $safe = ((x($_REQUEST,'safe')) ? intval($_REQUEST['safe']) : 1 ); - $sync = ((x($_REQUEST,'sync')) ? datetime_convert('UTC','UTC',$_REQUEST['sync']) : ''); + + if(array_key_exists('sync',$_REQUEST)) { + if($_REQUEST['sync']) + $sync = datetime_convert('UTC','UTC',$_REQUEST['sync']); + else + $sync = datetime_convert('UTC','UTC','2010-01-01 01:01:00'); + } + else + $sync = false; + $sort_order = ((x($_REQUEST,'order')) ? $_REQUEST['order'] : ''); // TODO - a meta search which joins all of these things to one search string -- cgit v1.2.3