if(is_null($a)) {
$a = new App;
}
-
+
if(is_null($db)) {
@include(".htconfig.php");
require_once("include/dba.php");
return;
}
- // Test
$lockpath = get_lockpath();
if ($lockpath != '') {
$pidfile = new pidfile($lockpath, 'onepoll'.$contact_id);
- if($pidfile->is_already_running()) {
+ if ($pidfile->is_already_running()) {
logger("onepoll: Already running for contact ".$contact_id);
+ if ($pidfile->running_time() > 9*60) {
+ $pidfile->kill();
+ logger("killed stale process");
+ }
exit;
}
}
-
$d = datetime_convert();
// Only poll from those with suitable relationships,
- // and which have a polling address and ignore Diaspora since
+ // and which have a polling address and ignore Diaspora since
// we are unable to match those posts with a Diaspora GUID and prevent duplicates.
- $contacts = q("SELECT `contact`.* FROM `contact`
+ $contacts = q("SELECT `contact`.* FROM `contact`
WHERE ( `rel` = %d OR `rel` = %d ) AND `poll` != ''
AND NOT `network` IN ( '%s', '%s', '%s' )
AND `contact`.`id` = %d
- AND `self` = 0 AND `contact`.`blocked` = 0 AND `contact`.`readonly` = 0
+ AND `self` = 0 AND `contact`.`blocked` = 0 AND `contact`.`readonly` = 0
AND `contact`.`archive` = 0 LIMIT 1",
intval(CONTACT_IS_SHARING),
intval(CONTACT_IS_FRIEND),
return;
}
- if(! strstr($handshake_xml,'<?xml')) {
+ if(! strstr($handshake_xml,'<')) {
logger('poller: response from ' . $url . ' did not contain XML.');
mark_for_death($contact);
}
elseif($contact['network'] === NETWORK_MAIL || $contact['network'] === NETWORK_MAIL2) {
- logger("onepoll: mail: Fetching", LOGGER_DEBUG);
+ logger("Mail: Fetching", LOGGER_DEBUG);
$mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
if($mail_disabled)
return;
- logger("onepoll: Mail: Enabled", LOGGER_DEBUG);
+ logger("Mail: Enabled", LOGGER_DEBUG);
$mbox = null;
$x = q("SELECT `prvkey` FROM `user` WHERE `uid` = %d LIMIT 1",
intval($mailconf[0]['id']),
intval($importer_uid)
);
- }
+ logger("Mail: Connected to " . $mailconf[0]['user']);
+ } else
+ logger("Mail: Connection error ".$mailconf[0]['user']." ".print_r(imap_errors()));
}
if($mbox) {
}
}
}
- }
+ } else
+ logger("Mail: no mails for ".$mailconf[0]['user']);
+
+ logger("Mail: closing connection for ".$mailconf[0]['user']);
imap_close($mbox);
}
}
if($xml) {
logger('poller: received xml : ' . $xml, LOGGER_DATA);
- if((! strstr($xml,'<?xml')) && (! strstr($xml,'<rss'))) {
+ if(! strstr($xml,'<')) {
logger('poller: post_handshake: response from ' . $url . ' did not contain XML.');
$r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d",
dbesc(datetime_convert()),
// load current friends if possible.
- if($contact['poco']) {
- $r = q("SELECT count(*) as total from glink
+ if($contact['poco']) {
+ $r = q("SELECT count(*) as total from glink
where `cid` = %d and updated > UTC_TIMESTAMP() - INTERVAL 1 DAY",
intval($contact['id'])
);
}
if (array_search(__file__,get_included_files())===0){
- onepoll_run($argv,$argc);
+ onepoll_run($_SERVER["argv"],$_SERVER["argc"]);
killme();
}