diff options
author | Mike Macgirvin <mike@macgirvin.com> | 2010-08-01 05:46:51 -0700 |
---|---|---|
committer | Mike Macgirvin <mike@macgirvin.com> | 2010-08-01 05:46:51 -0700 |
commit | 3fd4b4264ef8c418bbf78edaa02f7e4e32f5022e (patch) | |
tree | 641803dc59dcd8440e252e5133424fde2a835636 /include/poller.php | |
parent | a4a46d82df14d5bcc6812a8e2b9f24eb78141e4e (diff) | |
download | volse-hubzilla-3fd4b4264ef8c418bbf78edaa02f7e4e32f5022e.tar.gz volse-hubzilla-3fd4b4264ef8c418bbf78edaa02f7e4e32f5022e.tar.bz2 volse-hubzilla-3fd4b4264ef8c418bbf78edaa02f7e4e32f5022e.zip |
set frequency of poll per contact, other misc fixes (photo now has contact-id)
Diffstat (limited to 'include/poller.php')
-rw-r--r-- | include/poller.php | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/include/poller.php b/include/poller.php index dad50ab9a..e0b4d79b2 100644 --- a/include/poller.php +++ b/include/poller.php @@ -17,7 +17,7 @@ require_once('include/items.php'); if($argc < 2) exit; - +dbg(3); $a->set_baseurl($argv[1]); $contacts = q("SELECT * FROM `contact` WHERE `dfrn-id` != '' AND `self` = 0 AND `blocked` = 0 AND `readonly` = 0 ORDER BY RAND()"); @@ -27,6 +27,39 @@ if($argc < 2) foreach($contacts as $contact) { + if($contact['priority']) { + + $update = false; + $t = $contact['last-update']; + + switch ($contact['priority']) { + case 5: + if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', t . " + 1 month")) + $update = true; + break; + case 4: + if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', t . " + 1 week")) + $update = true; + break; + case 3: + if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', t . " + 1 day")) + $update = true; + break; + case 2: + if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', t . " + 12 hour")) + $update = true; + break; + case 1: + default: + if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', t . " + 1 hour")) + $update = true; + break; + } + if(! $update) + continue; + } + + $importer_uid = $contact['uid']; $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1", @@ -44,7 +77,8 @@ if($argc < 2) $url = $contact['poll'] . '?dfrn_id=' . $contact['dfrn-id'] . '&type=data&last_update=' . $last_update ; $xml = fetch_url($url); - +echo "URL: " . $url; +echo "XML: " . $xml; if(! $xml) continue; @@ -61,12 +95,19 @@ if($argc < 2) openssl_public_decrypt($challenge,$postvars['challenge'],$contact['pubkey']); $xml = post_url($contact['poll'],$postvars); - if(! strlen($xml)) - continue; echo "XML response:" . $xml . "\r\n"; echo "Length:" . strlen($xml) . "\r\n"; + if(! strlen($xml)) { + // an empty response may mean there's nothing new - record the fact that we checked + $r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d LIMIT 1", + dbesc(datetime_convert()), + intval($contact['id']) + ); + continue; + } + $feed = new SimplePie(); $feed->set_raw_data($xml); $feed->enable_order_by_date(false); |