X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fonepoll.php;h=6ff7eae422e35063b1746d334cccc836a8fbeb76;hb=1f543176cfb8f9cadb367f2f23753c79e27fb076;hp=73668126a1b7c0a92ece2fd7a499381b7a3b5d6d;hpb=639f94f8b90ce23420be40d9f183e57190a4ecf4;p=friendica.git diff --git a/include/onepoll.php b/include/onepoll.php index 73668126a1..6ff7eae422 100644 --- a/include/onepoll.php +++ b/include/onepoll.php @@ -18,11 +18,11 @@ function onepoll_run(&$argv, &$argc){ } if(is_null($db)) { - @include(".htconfig.php"); - require_once("include/dba.php"); - $db = new dba($db_host, $db_user, $db_pass, $db_data); - unset($db_host, $db_user, $db_pass, $db_data); - }; + @include(".htconfig.php"); + require_once("include/dba.php"); + $db = new dba($db_host, $db_user, $db_pass, $db_data); + unset($db_host, $db_user, $db_pass, $db_data); + }; require_once('include/session.php'); @@ -53,6 +53,9 @@ function onepoll_run(&$argv, &$argc){ if(($argc > 1) && (intval($argv[1]))) $contact_id = intval($argv[1]); + if(($argc > 2) && ($argv[2] == "force")) + $force = true; + if(! $contact_id) { logger('onepoll: no contact'); return; @@ -110,7 +113,7 @@ function onepoll_run(&$argv, &$argc){ // - Check why we don't poll the Diaspora feed at the moment (some guid problem in the items?) // - Check whether this is possible with Redmatrix if ($contact["network"] == NETWORK_DIASPORA) { - if (poco_do_update($contact["last-item"], $contact["success_update"], $contact["failure_update"])) { + if (poco_do_update($contact["created"], $contact["last-item"], $contact["failure_update"], $contact["success_update"])) { $last_updated = poco_last_updated($contact["url"]); $updated = datetime_convert(); if ($last_updated) { @@ -120,23 +123,12 @@ function onepoll_run(&$argv, &$argc){ dbesc($updated), intval($contact['id']) ); - - q("UPDATE `gcontact` SET `updated` = '%s', `last_contact` = '%s' WHERE `nurl` = '%s'", - dbesc($last_updated), - dbesc($updated), - dbesc($contact['nurl']) - ); } else { q("UPDATE `contact` SET `last-update` = '%s', `failure_update` = '%s' WHERE `id` = %d", dbesc($updated), dbesc($updated), intval($contact['id']) ); - - q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `nurl` = '%s'", - dbesc($updated), - dbesc($contact['nurl']) - ); } } return; @@ -176,8 +168,18 @@ function onepoll_run(&$argv, &$argc){ ); // Update the contact entry - if(($contact['network'] === NETWORK_OSTATUS) || ($contact['network'] === NETWORK_DIASPORA) || ($contact['network'] === NETWORK_DFRN)) - update_contact($contact["id"]); + if(($contact['network'] === NETWORK_OSTATUS) || ($contact['network'] === NETWORK_DIASPORA) || ($contact['network'] === NETWORK_DFRN)) { + if (!poco_reachable($contact['url'])) { + logger("Skipping probably dead contact ".$contact['url']); + return; + } + + if (!update_contact($contact["id"])) { + mark_for_death($contact); + return; + } else + unmark_for_death($contact); + } if($contact['network'] === NETWORK_DFRN) { @@ -368,7 +370,7 @@ function onepoll_run(&$argv, &$argc){ ); logger("Mail: Connected to " . $mailconf[0]['user']); } else - logger("Mail: Connection error ".$mailconf[0]['user']." ".print_r(imap_errors())); + logger("Mail: Connection error ".$mailconf[0]['user']." ".print_r(imap_errors(), true)); } if($mbox) { @@ -606,8 +608,10 @@ function onepoll_run(&$argv, &$argc){ return; } - consume_feed($xml,$importer,$contact,$hub,1,1); + logger("Consume feed of contact ".$contact['id']); + + consume_feed($xml,$importer,$contact,$hub,1,1); // do it twice. Ensures that children of parents which may be later in the stream aren't tossed @@ -620,6 +624,11 @@ function onepoll_run(&$argv, &$argc){ if(($contact['network'] === NETWORK_OSTATUS || $contact['network'] == NETWORK_FEED) && (! $contact['hub-verify'])) $hub_update = true; + if ($force) + $hub_update = true; + + logger("Contact ".$contact['id']." returned hub: ".$hub." Network: ".$contact['network']." Relation: ".$contact['rel']." Update: ".$hub_update); + if((strlen($hub)) && ($hub_update) && (($contact['rel'] != CONTACT_IS_FOLLOWER) || $contact['network'] == NETWORK_FEED) ) { logger('poller: hub ' . $hubmode . ' : ' . $hub . ' contact name : ' . $contact['name'] . ' local user : ' . $importer['name']); $hubs = explode(',', $hub); @@ -670,6 +679,6 @@ function onepoll_run(&$argv, &$argc){ } if (array_search(__file__,get_included_files())===0){ - onepoll_run($_SERVER["argv"],$_SERVER["argc"]); - killme(); + onepoll_run($_SERVER["argv"],$_SERVER["argc"]); + killme(); }