]> git.mxchange.org Git - friendica.git/blobdiff - include/onepoll.php
redundant log entry
[friendica.git] / include / onepoll.php
index 722ebe846b56e4496bce873e9f9e0d69651100aa..700498efc8b17f480e27d443b58c351a2f900ace 100644 (file)
@@ -25,6 +25,7 @@ function onepoll_run($argv, $argc){
        require_once('include/email.php');
        require_once('include/socgraph.php');
        require_once('include/pidfile.php');
+       require_once('include/queue_fn.php');
 
        load_config('config');
        load_config('system');
@@ -53,6 +54,7 @@ function onepoll_run($argv, $argc){
                logger('onepoll: no contact');
                return;
        }
+       
 
        $d = datetime_convert();
 
@@ -84,14 +86,13 @@ function onepoll_run($argv, $argc){
 
        $contact = $contacts[0];
 
-
        $xml = false;
 
        $t = $contact['last-update'];
 
        if($contact['subhub']) {
-               $interval = get_config('system','pushpoll_frequency');
-               $contact['priority'] = (($interval !== false) ? intval($interval) : 3);
+               $poll_interval = get_config('system','pushpoll_frequency');
+               $contact['priority'] = (($poll_interval !== false) ? intval($poll_interval) : 3);
                $hub_update = false;
 
                if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 day"))
@@ -135,15 +136,18 @@ function onepoll_run($argv, $argc){
                        . '&perm=' . $perm ;
 
                $handshake_xml = fetch_url($url);
+               $html_code = $a->get_curl_code();
 
                logger('onepoll: handshake with url ' . $url . ' returns xml: ' . $handshake_xml, LOGGER_DATA);
 
 
-               if(! $handshake_xml) {
+               if((! strlen($handshake_xml)) || ($html_code >= 400) || (! $html_code)) {
                        logger("poller: $url appears to be dead - marking for death ");
+
                        // dead connection - might be a transient event, or this might
                        // mean the software was uninstalled or the domain expired. 
                        // Will keep trying for one month.
+
                        mark_for_death($contact);
 
                        // set the last-update so we don't keep polling
@@ -152,16 +156,19 @@ function onepoll_run($argv, $argc){
                                intval($contact['id'])
                        );
 
-                       continue;
+                       return;
                }
 
                if(! strstr($handshake_xml,'<?xml')) {
                        logger('poller: response from ' . $url . ' did not contain XML.');
+
+                       mark_for_death($contact);
+
                        $r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d LIMIT 1",
                                dbesc(datetime_convert()),
                                intval($contact['id'])
                        );
-                       continue;
+                       return;
                }
 
 
@@ -188,7 +195,7 @@ function onepoll_run($argv, $argc){
                }
 
                if((intval($res->status) != 0) || (! strlen($res->challenge)) || (! strlen($res->dfrn_id)))
-                       continue;
+                       return;
 
                if(((float) $res->dfrn_version > 2.21) && ($contact['poco'] == '')) {
                        q("update contact set poco = '%s' where id = %d limit 1",
@@ -221,7 +228,7 @@ function onepoll_run($argv, $argc){
                if($final_dfrn_id != $orig_id) {
                        logger('poller: ID did not decode: ' . $contact['id'] . ' orig: ' . $orig_id . ' final: ' . $final_dfrn_id);    
                        // did not decode properly - cannot trust this site 
-                       continue;
+                       return;
                }
 
                $postvars['dfrn_id'] = $idtosend;
@@ -251,7 +258,7 @@ function onepoll_run($argv, $argc){
                // Are we allowed to import from this person?
 
                if($contact['rel'] == CONTACT_IS_FOLLOWER || $contact['blocked'] || $contact['readonly'])
-                       continue;
+                       return;
 
                $xml = fetch_url($contact['poll']);
        }
@@ -261,7 +268,7 @@ function onepoll_run($argv, $argc){
 
                $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
                if($mail_disabled)
-                       continue;
+                       return;
 
                logger("onepoll: Mail: Enabled", LOGGER_DEBUG);
 
@@ -452,13 +459,13 @@ function onepoll_run($argv, $argc){
 
        if($xml) {
                logger('poller: received xml : ' . $xml, LOGGER_DATA);
-                       if(! strstr($xml,'<?xml')) {
+                       if((! strstr($xml,'<?xml')) && (! strstr($xml,'<rss'))) {
                        logger('poller: post_handshake: response from ' . $url . ' did not contain XML.');
                        $r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d LIMIT 1",
                                dbesc(datetime_convert()),
                                intval($contact['id'])
                        );
-                       continue;
+                       return;
                }
 
 
@@ -473,6 +480,9 @@ function onepoll_run($argv, $argc){
                if($contact['network'] === NETWORK_DFRN || $contact['blocked'] || $contact['readonly'])
                        $hubmode = 'unsubscribe';
 
+               if($contact['network'] === NETWORK_OSTATUS && (! $contact['hub-verify']))
+                       $hub_update = true;
+
                if((strlen($hub)) && ($hub_update) && ($contact['rel'] != CONTACT_IS_FOLLOWER)) {
                        logger('poller: hub ' . $hubmode . ' : ' . $hub . ' contact name : ' . $contact['name'] . ' local user : ' . $importer['name']);
                        $hubs = explode(',', $hub);
@@ -506,7 +516,7 @@ function onepoll_run($argv, $argc){
        }
        if(count($r)) {
                if(! $r[0]['total']) {
-                       poco_load($contact['id'],$importer_uid,$contact['poco']);
+                       poco_load($contact['id'],$importer_uid,0,$contact['poco']);
                }
        }