aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/bbcode.php2
-rw-r--r--include/checksites.php61
-rw-r--r--include/hubloc.php11
-rw-r--r--include/notifier.php57
-rw-r--r--include/poller.php3
5 files changed, 91 insertions, 43 deletions
diff --git a/include/bbcode.php b/include/bbcode.php
index 66bf6b5ec..db5824237 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -437,7 +437,7 @@ function bb_observer($Text) {
// BBcode 2 HTML was written by WAY2WEB.net
- // extended to work with Mistpark/Friendica/Red - Mike Macgirvin
+ // extended to work with Mistpark/Friendica/Redmatrix/Hubzilla - Mike Macgirvin
function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false) {
diff --git a/include/checksites.php b/include/checksites.php
new file mode 100644
index 000000000..e14837255
--- /dev/null
+++ b/include/checksites.php
@@ -0,0 +1,61 @@
+<?php /** @file */
+
+require_once('boot.php');
+require_once('include/cli_startup.php');
+require_once('include/zot.php');
+require_once('include/hubloc.php');
+
+
+
+function checksites_run($argv, $argc){
+
+
+ cli_startup();
+ $a = get_app();
+
+ logger('checksites: start');
+
+ if(($argc > 1) && ($argv[1]))
+ $site_id = $argv[1];
+
+ if($site_id)
+ $sql_options = " and site_url = '" . dbesc($argv[1]) . "' ";
+
+ $days = intval(get_config('system','sitecheckdays'));
+ if($days < 1)
+ $days = 30;
+
+ $r = q("select * from site where site_dead = 0 and site_update < %s - INTERVAL %s $sql_options ",
+ db_utcnow(), db_quoteinterval($days . ' DAY')
+ );
+
+ if(! $r)
+ return;
+
+ foreach($r as $rr) {
+ if(! strcasecmp($rr['site_url'],z_root()))
+ continue;
+
+ $x = ping_site($rr['site_url']);
+ if($x['success']) {
+ logger('checksites: ' . $rr['site_url']);
+ q("update site set site_update = '%s' where site_url = '%s' ",
+ dbesc(datetime_convert()),
+ dbesc($rr['site_url'])
+ );
+ }
+ else {
+ logger('marking dead site: ' . $x['message']);
+ q("update site set site_dead = 1 where site_url = '%s' ",
+ dbesc($rr['site_url'])
+ );
+ }
+ }
+
+ return;
+}
+
+if (array_search(__file__,get_included_files())===0){
+ checksites_run($argv,$argc);
+ killme();
+}
diff --git a/include/hubloc.php b/include/hubloc.php
index 8bd6d8d68..674a3885f 100644
--- a/include/hubloc.php
+++ b/include/hubloc.php
@@ -291,13 +291,18 @@ function ping_site($url) {
$ret['message'] = 'no answer from ' . $url;
return $ret;
}
- $packet_result = $r['body'];
+ $packet_result = json_decode($r['body'],true);
if(! $packet_result['success']) {
$ret['message'] = 'packet failure from ' . $url;
return $ret;
}
- $ret['success'] = true;
- return $ret;
+ if($packet_result['success']) {
+ $ret['success'] = true;
+ }
+ else {
+ $ret['message'] = 'unknown error from ' . $url;
+ }
+ return $ret;
}
diff --git a/include/notifier.php b/include/notifier.php
index 62aea4106..e16f80ecf 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -486,20 +486,6 @@ function notifier_run($argv, $argc){
if($details) {
foreach($details as $d) {
- // If the recipient is federated from a traditional network they won't be able to
- // handle nomadic identity. If we're publishing from a site that they aren't
- // directly connected with, ignore them.
-
- // FIXME: make sure we run through a notifier loop on the hub they're connected
- // with if this post comes in from a different hub - so that we will deliver to them.
-
- // On the down side, these channels will stop working if the hub they connected with
- // goes down permanently, as they are (doh) not nomadic.
-
- if(($d['xchan_instance_url']) && ($d['xchan_instance_url'] != z_root()))
- continue;
-
-
$recip_list[] = $d['xchan_addr'] . ' (' . $d['xchan_hash'] . ')';
if($private)
$env_recips[] = array('guid' => $d['xchan_guid'],'guid_sig' => $d['xchan_guid_sig'],'hash' => $d['xchan_hash']);
@@ -526,31 +512,10 @@ function notifier_run($argv, $argc){
// Now we have collected recipients (except for external mentions, FIXME)
// Let's reduce this to a set of hubs.
- logger('notifier: hub choice: ' . intval($relay_to_owner) . ' ' . intval($private) . ' ' . $cmd, LOGGER_DEBUG);
-
- // FIXME: I think we need to remove the private bit or this clause will never execute. Needs more coffee to think it through.
- // We may in fact have to send it to clones in case the one we pick recently died.
-
- if($relay_to_owner && (! $private) && ($cmd !== 'relay')) {
-
- // If sending a followup to the post owner, only send it to one channel clone - to avoid race conditions.
- // In this case we'll pick the most recently contacted hub, as their primary might be down and the most
- // recently contacted has the best chance of being alive.
-
- // For private posts or uplinks we have to do things differently as only the sending clone will have the recipient list.
- // We have to send to all clone channels of the owner to find out who has the definitive list. Posts with
- // item_private set (but no ACL list) will return empty recipients (except for the sender and owner) in
- // collect_recipients() above. The end result is we should get only one delivery per delivery chain if we
- // aren't the owner or author.
-
-
- $r = q("select * from hubloc
- where hubloc_hash in (" . implode(',',$recipients) . ") order by hubloc_connected desc limit 1");
- }
- else {
- $r = q("select * from hubloc where hubloc_hash in (" . implode(',',$recipients) . ")
- and hubloc_error = 0 and hubloc_deleted = 0");
- }
+ $r = q("select * from hubloc where hubloc_hash in (" . implode(',',$recipients) . ")
+ and hubloc_error = 0 and hubloc_deleted = 0"
+ );
+
if(! $r) {
logger('notifier: no hubs');
@@ -559,6 +524,15 @@ function notifier_run($argv, $argc){
$hubs = $r;
+ $dead_hubs = array();
+
+ $dh = q("select site_url from site where site_dead = 1");
+ if(dh) {
+ foreach($dh as $dead) {
+ $dead_hubs[] = $dead['site_url'];
+ }
+ }
+
/**
* Reduce the hubs to those that are unique. For zot hubs, we need to verify uniqueness by the sitekey, since it may have been
@@ -574,6 +548,11 @@ function notifier_run($argv, $argc){
foreach($hubs as $hub) {
+ if(in_array($hub['hubloc_url'],$dead_hubs)) {
+ logger('skipping dead hub: ' . $hub['hubloc_url'], LOGGER_DEBUG);
+ continue;
+ }
+
if($hub['hubloc_network'] == 'zot') {
if(! in_array($hub['hubloc_sitekey'],$keys)) {
$hublist[] = $hub['hubloc_host'];
diff --git a/include/poller.php b/include/poller.php
index a1b25bf41..72f22d946 100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -175,7 +175,10 @@ function poller_run($argv, $argc){
logger('regdir: ' . print_r(z_fetch_url(get_directory_primary() . '/regdir?f=&url=' . urlencode(z_root()) . '&realm=' . urlencode(get_directory_realm())),true));
}
+ // Check for dead sites
+ proc_run('php', 'include/checksites.php');
+ // update searchable doc indexes
proc_run('php', 'include/importdoc.php');
/**