<?php
-require_once("boot.php");
-require_once('include/queue_fn.php');
-require_once('include/html2plain.php');
-require_once("include/Scrape.php");
-require_once('include/diaspora.php');
-require_once("include/ostatus.php");
-require_once("include/dfrn.php");
-function delivery_run(&$argv, &$argc){
- global $a, $db;
-
- if (is_null($a)) {
- $a = new App;
- }
-
- 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);
- }
+use Friendica\App;
+use Friendica\Core\Config;
- require_once("include/session.php");
- require_once("include/datetime.php");
- require_once('include/items.php');
- require_once('include/bbcode.php');
- require_once('include/email.php');
+require_once 'include/queue_fn.php';
+require_once 'include/html2plain.php';
+require_once 'include/probe.php';
+require_once 'include/diaspora.php';
+require_once 'include/ostatus.php';
+require_once 'include/dfrn.php';
- load_config('config');
- load_config('system');
+function delivery_run(&$argv, &$argc){
+ global $a;
- load_hooks();
+ require_once 'include/datetime.php';
+ require_once 'include/items.php';
+ require_once 'include/bbcode.php';
+ require_once 'include/email.php';
if ($argc < 3) {
return;
}
- $a->set_baseurl(get_config('system','url'));
-
logger('delivery: invoked: '. print_r($argv,true), LOGGER_DEBUG);
$cmd = $argv[1];
$contact_id = intval($argv[$x]);
- /// @todo When switching completely to the worker we won't need this anymore
- // Some other process may have delivered this item already.
-
- $r = q("SELECT * FROM `deliverq` WHERE `cmd` = '%s' AND `item` = %d AND `contact` = %d LIMIT 1",
- dbesc($cmd),
- dbesc($item_id),
- dbesc($contact_id)
- );
- if (!dbm::is_result($r)) {
- continue;
- }
-
- if ($a->maxload_reached()) {
- return;
- }
-
- // It's ours to deliver. Remove it from the queue.
-
- q("DELETE FROM `deliverq` WHERE `cmd` = '%s' AND `item` = %d AND `contact` = %d",
- dbesc($cmd),
- dbesc($item_id),
- dbesc($contact_id)
- );
-
if (!$item_id || !$contact_id) {
continue;
}
$uid = $item_id;
} else {
// find ancestors
- $r = q("SELECT * FROM `item` WHERE `id` = %d and visible = 1 and moderated = 0 LIMIT 1",
+ $r = q("SELECT * FROM `item` WHERE `id` = %d AND visible = 1 AND moderated = 0 LIMIT 1",
intval($item_id)
);
$updated = $r[0]['edited'];
$items = q("SELECT `item`.*, `sign`.`signed_text`,`sign`.`signature`,`sign`.`signer`
- FROM `item` LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id` WHERE `parent` = %d and visible = 1 and moderated = 0 ORDER BY `id` ASC",
+ FROM `item` LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id` WHERE `parent` = %d AND visible = 1 AND moderated = 0 ORDER BY `id` ASC",
intval($parent_id)
);
$public_message = true;
if (!($mail || $fsuggest || $relocate)) {
- require_once('include/group.php');
+ require_once 'include/group.php';
$parent = $items[0];
// If we are setup as a soapbox we aren't accepting top level posts from this person
- if (($x[0]['page-flags'] == PAGE_SOAPBOX) AND $top_level) {
+ if (($x[0]['page-flags'] == PAGE_SOAPBOX) && $top_level) {
break;
}
logger('mod-delivery: local delivery');
logger('notifier: dfrn_delivery to '.$contact["url"].' with guid '.$target_item["guid"].' returns '.$deliver_status);
- if ($deliver_status == (-1)) {
+ if ($deliver_status < 0) {
logger('notifier: delivery failed: queuing message');
add_to_queue($contact['id'],NETWORK_DFRN,$atom);
$headers .= "References: <".iri2msgid($it["parent-uri"]).">";
// If Threading is enabled, write down the correct parent
- if (($it["thr-parent"] != "") and ($it["thr-parent"] != $it["parent-uri"]))
+ if (($it["thr-parent"] != "") && ($it["thr-parent"] != $it["parent-uri"]))
$headers .= " <".iri2msgid($it["thr-parent"]).">";
$headers .= "\n";
dbesc($it['parent-uri']),
intval($uid));
- if (dbm::is_result($r) AND ($r[0]['title'] != '')) {
+ if (dbm::is_result($r) && ($r[0]['title'] != '')) {
$subject = $r[0]['title'];
} else {
$r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($it['parent-uri']),
intval($uid));
- if (dbm::is_result($r) AND ($r[0]['title'] != ''))
+ if (dbm::is_result($r) && ($r[0]['title'] != ''))
$subject = $r[0]['title'];
}
}
return;
}
-
-if (array_search(__file__,get_included_files())===0){
- delivery_run($_SERVER["argv"],$_SERVER["argc"]);
- killme();
-}