aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorFriendika <info@friendika.com>2011-01-28 18:50:20 -0800
committerFriendika <info@friendika.com>2011-01-28 18:50:20 -0800
commit26cc2e02fe6e075cd35a3069edbc006219f5b435 (patch)
treeb687508bd7247100ac0dd51ecf36aed9ea97d5cd /include
parent5d77bd9489763721b8f3e4a51c8cef1181276157 (diff)
parent302acda0890a472916b759e6340ce77d9803f105 (diff)
downloadvolse-hubzilla-26cc2e02fe6e075cd35a3069edbc006219f5b435.tar.gz
volse-hubzilla-26cc2e02fe6e075cd35a3069edbc006219f5b435.tar.bz2
volse-hubzilla-26cc2e02fe6e075cd35a3069edbc006219f5b435.zip
Merge branch 'fabrixxm-master'
Conflicts: boot.php
Diffstat (limited to 'include')
-rw-r--r--include/directory.php36
-rw-r--r--include/notifier.php76
-rw-r--r--include/poller.php44
-rw-r--r--include/queue.php35
4 files changed, 118 insertions, 73 deletions
diff --git a/include/directory.php b/include/directory.php
index 5f835dc4b..2c9daa5ea 100644
--- a/include/directory.php
+++ b/include/directory.php
@@ -1,17 +1,22 @@
<?php
-
- require_once("boot.php");
-
- $a = new App;
-
- @include(".htconfig.php");
- require_once("dba.php");
- $db = new dba($db_host, $db_user, $db_pass, $db_data);
- unset($db_host, $db_user, $db_pass, $db_data);
-
+require_once("boot.php");
+
+function directory_run($argv, $argc){
+ global $a, $db;
+
+ if(is_null($a)){
+ $a = new App;
+ }
+
+ if(is_null($db)){
+ @include(".htconfig.php");
+ require_once("dba.php");
+ $db = new dba($db_host, $db_user, $db_pass, $db_data);
+ unset($db_host, $db_user, $db_pass, $db_data);
+ };
if($argc != 2)
- exit;
+ return;
load_config('system');
@@ -20,9 +25,14 @@
$dir = get_config('system','directory_submit_url');
if(! strlen($dir))
- exit;
+ return;
fetch_url($dir . '?url=' . bin2hex($argv[1]));
- exit;
+ return;
+}
+if (array_search(__file__,get_included_files())===0){
+ directory_run($argv,$argc);
+ killme();
+}
diff --git a/include/notifier.php b/include/notifier.php
index 4efdad4ce..dd5d55ed0 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -1,14 +1,19 @@
<?php
-
- require_once("boot.php");
-
- $a = new App;
-
- @include(".htconfig.php");
- require_once("dba.php");
- $db = new dba($db_host, $db_user, $db_pass, $db_data);
- unset($db_host, $db_user, $db_pass, $db_data);
-
+require_once("boot.php");
+
+function notifier_run($argv, $argc){
+ global $a, $db;
+
+ if(is_null($a)){
+ $a = new App;
+ }
+
+ if(is_null($db)){
+ @include(".htconfig.php");
+ require_once("dba.php");
+ $db = new dba($db_host, $db_user, $db_pass, $db_data);
+ unset($db_host, $db_user, $db_pass, $db_data);
+ };
require_once("session.php");
require_once("datetime.php");
@@ -16,7 +21,7 @@
require_once('include/bbcode.php');
if($argc < 3)
- exit;
+ return;
$a->set_baseurl(get_config('system','url'));
@@ -29,8 +34,9 @@
case 'mail':
default:
$item_id = intval($argv[2]);
- if(! $item_id)
- killme();
+ if(! $item_id){
+ return;
+ }
break;
}
@@ -42,22 +48,24 @@
$message = q("SELECT * FROM `mail` WHERE `id` = %d LIMIT 1",
intval($item_id)
);
- if(! count($message))
- killme();
+ if(! count($message)){
+ return;
+ }
$uid = $message[0]['uid'];
$recipients[] = $message[0]['contact-id'];
$item = $message[0];
}
else {
- // find ancestors
+ // find ancestors
$r = q("SELECT `parent`, `uid`, `edited` FROM `item` WHERE `id` = %d LIMIT 1",
intval($item_id)
);
- if(! count($r))
- killme();
-
+ if(! count($r)){
+ return;
+ }
+
$parent_id = $r[0]['parent'];
$uid = $r[0]['uid'];
$updated = $r[0]['edited'];
@@ -66,8 +74,9 @@
intval($parent_id)
);
- if(! count($items))
- killme();
+ if(! count($items)){
+ return;
+ }
}
$r = q("SELECT `contact`.*, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`, `user`.`page-flags`
@@ -78,9 +87,9 @@
if(count($r))
$owner = $r[0];
- else
- killme();
-
+ else {
+ return;
+ }
$hub = get_config('system','huburl');
// If this is a public conversation, notify the feed hub
@@ -150,8 +159,9 @@
$r = q("SELECT * FROM `contact` WHERE `id` IN ( $conversant_str ) AND `blocked` = 0 AND `pending` = 0");
- if( ! count($r))
- killme();
+ if( ! count($r)){
+ return;
+ }
$contacts = $r;
}
@@ -248,9 +258,9 @@
$r = q("SELECT * FROM `contact` WHERE `id` IN ( %s ) AND `blocked` = 0 ",
dbesc($recip_str)
);
- if(! count($r))
- killme();
-
+ if(! count($r)){
+ return;
+ }
// delivery loop
require_once('include/salmon.php');
@@ -360,5 +370,11 @@
}
}
- killme();
+ return;
+}
+if (array_search(__file__,get_included_files())===0){
+ echo "run!";
+ notifier_run($argv,$argc);
+ killme();
+}
diff --git a/include/poller.php b/include/poller.php
index 024b9fbcd..1003b2f08 100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -1,14 +1,19 @@
<?php
-
-
- require_once('boot.php');
-
- $a = new App;
-
- @include('.htconfig.php');
- require_once('dba.php');
- $db = new dba($db_host, $db_user, $db_pass, $db_data);
- unset($db_host, $db_user, $db_pass, $db_data);
+require_once("boot.php");
+
+function poller_run($argv, $argc){
+ global $a, $db;
+
+ if(is_null($a)){
+ $a = new App;
+ }
+
+ if(is_null($db)){
+ @include(".htconfig.php");
+ require_once("dba.php");
+ $db = new dba($db_host, $db_user, $db_pass, $db_data);
+ unset($db_host, $db_user, $db_pass, $db_data);
+ };
require_once('session.php');
require_once('datetime.php');
@@ -19,11 +24,12 @@
$a->set_baseurl(get_config('system','url'));
logger('poller: start');
-
+
// run queue delivery process in the background
$php_path = ((x($a->config,'php_path') && strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
- proc_close(proc_open("\"$php_path\" \"include/queue.php\" &", array(), $foo));
+ //proc_close(proc_open("\"$php_path\" \"include/queue.php\" &", array(), $foo));
+ proc_run($php_path,"include/queue.php");
$hub_update = false;
@@ -46,8 +52,9 @@
$sql_extra
AND `self` = 0 AND `blocked` = 0 AND `readonly` = 0 ORDER BY RAND()");
- if(! count($contacts))
- killme();
+ if(! count($contacts)){
+ return;
+ }
foreach($contacts as $contact) {
@@ -265,7 +272,10 @@
// loop - next contact
}
- killme();
-
-
+ return;
+}
+if (array_search(__file__,get_included_files())===0){
+ poller_run($argv,$argc);
+ killme();
+}
diff --git a/include/queue.php b/include/queue.php
index 96ddfa81b..d4fc7dbd6 100644
--- a/include/queue.php
+++ b/include/queue.php
@@ -1,5 +1,5 @@
<?php
-
+require_once("boot.php");
function update_queue_time($id) {
logger('queue: requeue item ' . $id);
@@ -16,14 +16,19 @@ function remove_queue_item($id) {
);
}
- require_once("boot.php");
-
- $a = new App;
+function queue_run($argv, $argc){
+ global $a, $db;
- @include(".htconfig.php");
- require_once("dba.php");
- $db = new dba($db_host, $db_user, $db_pass, $db_data);
- unset($db_host, $db_user, $db_pass, $db_data);
+ if(is_null($a)){
+ $a = new App;
+ }
+
+ if(is_null($db)){
+ @include(".htconfig.php");
+ require_once("dba.php");
+ $db = new dba($db_host, $db_user, $db_pass, $db_data);
+ unset($db_host, $db_user, $db_pass, $db_data);
+ };
require_once("session.php");
@@ -50,9 +55,9 @@ function remove_queue_item($id) {
$r = q("SELECT `id` FROM `queue` WHERE `last` < UTC_TIMESTAMP() - INTERVAL 15 MINUTE ");
- if(! count($r))
- killme();
-
+ if(! count($r)){
+ return;
+ }
// delivery loop
require_once('include/salmon.php');
@@ -118,7 +123,11 @@ function remove_queue_item($id) {
}
}
- killme();
+ return;
- // NOTREACHED
+}
+if (array_search(__file__,get_included_files())===0){
+ queue_run($argv,$argc);
+ killme();
+}