2 require_once("boot.php");
4 function update_queue_time($id) {
5 logger('queue: requeue item ' . $id);
6 q("UPDATE `queue` SET `last` = '%s' WHERE `id` = %d LIMIT 1",
7 dbesc(datetime_convert()),
12 function remove_queue_item($id) {
13 logger('queue: remove queue item ' . $id);
14 q("DELETE FROM `queue` WHERE `id` = %d LIMIT 1",
19 function queue_run($argv, $argc){
27 @include(".htconfig.php");
28 require_once("dba.php");
29 $db = new dba($db_host, $db_user, $db_pass, $db_data);
30 unset($db_host, $db_user, $db_pass, $db_data);
34 require_once("session.php");
35 require_once("datetime.php");
36 require_once('include/items.php');
37 require_once('include/bbcode.php');
39 $a->set_baseurl(get_config('system','url'));
43 logger('queue: start');
45 $r = q("SELECT `queue`.*, `contact`.`name`, `contact`.`uid` FROM `queue`
46 LEFT JOIN `contact` ON `queue`.`cid` = `contact`.`id`
47 WHERE `queue`.`created` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
50 logger('Removing expired queue item for ' . $rr['name'] . ', uid=' . $rr['uid']);
51 logger('Expired queue data :' . $rr['content'], LOGGER_DATA);
53 q("DELETE FROM `queue` WHERE `created` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
56 $r = q("SELECT `id` FROM `queue` WHERE `last` < UTC_TIMESTAMP() - INTERVAL 15 MINUTE ");
63 require_once('include/salmon.php');
65 foreach($r as $q_item) {
66 $qi = q("SELECT * FROM `queue` WHERE `id` = %d LIMIT 1",
72 $c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
76 remove_queue_item($q_item['id']);
79 if(in_array($c[0]['notify'],$deadguys)) {
80 logger('queue: skipping known dead url: ' . $c[0]['notify']);
81 update_queue_time($q_item['id']);
85 $u = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
89 remove_queue_item($q_item['id']);
93 $data = $qi[0]['content'];
99 switch($contact['network']) {
101 logger('queue: dfrndelivery: item ' . $q_item['id'] . ' for ' . $contact['name']);
102 $deliver_status = dfrn_deliver($owner,$contact,$data);
104 if($deliver_status == (-1)) {
105 update_queue_time($q_item['id']);
106 $deadguys[] = $contact['notify'];
109 remove_queue_item($q_item['id']);
113 if($contact['notify']) {
114 logger('queue: slapdelivery: item ' . $q_item['id'] . ' for ' . $contact['name']);
115 $deliver_status = slapper($owner,$contact['notify'],$data);
117 if($deliver_status == (-1))
118 update_queue_time($q_item['id']);
120 remove_queue_item($q_item['id']);
130 if (array_search(__file__,get_included_files())===0){
131 queue_run($argv,$argc);