diff --git a/.gitignore b/.gitignore
index 5fe71a7a87..358114a444 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,26 +1,27 @@
-favicon.*
-.htconfig.php
-\#*
-include/jquery-1.4.2.min.js
-*.log
-*.out
-*.version*
-favicon.*
-home.html
-addon
-*~
-
-#ignore documentation, it should be newly built
-doc/api
-
-#ignore reports, should be generted with every build
-report/
-
-#ignore config files from eclipse, we don't want IDE files in our repository
-.project
-.buildpath
-.externalToolBuilders
-.settings
-#ignore OSX .DS_Store files
-.DS_Store
-
+favicon.*
+.htconfig.php
+\#*
+include/jquery-1.4.2.min.js
+*.log
+*.out
+*.version*
+favicon.*
+home.html
+addon
+*~
+
+#ignore documentation, it should be newly built
+doc/api
+
+#ignore reports, should be generted with every build
+report/
+
+#ignore config files from eclipse, we don't want IDE files in our repository
+.project
+.buildpath
+.externalToolBuilders
+.settings
+#ignore OSX .DS_Store files
+.DS_Store
+
+/nbproject/private/
\ No newline at end of file
diff --git a/boot.php b/boot.php
index ad6c29b828..71304e53e2 100644
--- a/boot.php
+++ b/boot.php
@@ -385,7 +385,7 @@ if(! class_exists('App')) {
function __construct() {
- global $default_timezone;
+ global $default_timezone, $argv, $argc;
$this->timezone = ((x($default_timezone)) ? $default_timezone : 'UTC');
@@ -428,6 +428,9 @@ if(! class_exists('App')) {
if(isset($path) && strlen($path) && ($path != $this->path))
$this->path = $path;
}
+ if (is_array($argv) && $argc>1 && !x($_SERVER,'SERVER_NAME') && substr(end($argv), 0, 4)=="http" ) {
+ $this->set_baseurl(array_pop($argv) );
+ }
set_include_path(
"include/$this->hostname" . PATH_SEPARATOR
@@ -436,6 +439,7 @@ if(! class_exists('App')) {
. 'library/phpsec' . PATH_SEPARATOR
. 'library/langdet' . PATH_SEPARATOR
. '.' );
+
if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,2) === "q=") {
$this->query_string = substr($_SERVER['QUERY_STRING'],2);
@@ -1501,9 +1505,15 @@ if(! function_exists('proc_run')) {
if(count($args) && $args[0] === 'php')
$args[0] = ((x($a->config,'php_path')) && (strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
- for($x = 0; $x < count($args); $x ++)
+
+ // add baseurl to args. cli scripts can't construct it
+ $args[] = $a->get_baseurl();
+
+ for($x = 0; $x < count($args); $x ++)
$args[$x] = escapeshellarg($args[$x]);
+
+
$cmdline = implode($args," ");
if(get_config('system','proc_windows'))
proc_close(proc_open('cmd /c start /b ' . $cmdline,array(),$foo));
diff --git a/include/dba.php b/include/dba.php
index 63b75c4948..9f2dab5191 100644
--- a/include/dba.php
+++ b/include/dba.php
@@ -232,6 +232,7 @@ function q($sql) {
if($db && $db->connected) {
$stmt = vsprintf($sql,$args);
+ //logger("dba: q: $stmt", LOGGER_ALL);
if($stmt === false)
logger('dba: vsprintf error: ' . print_r(debug_backtrace(),true), LOGGER_DEBUG);
return $db->q($stmt);
diff --git a/include/delivery.php b/include/delivery.php
index 14226e4fba..d879deedb5 100644
--- a/include/delivery.php
+++ b/include/delivery.php
@@ -3,7 +3,7 @@ require_once("boot.php");
require_once('include/queue_fn.php');
require_once('include/html2plain.php');
-function delivery_run($argv, $argc){
+function delivery_run(&$argv, &$argc){
global $a, $db;
if(is_null($a)){
diff --git a/include/items.php b/include/items.php
index 0ca385c44a..4266734842 100755
--- a/include/items.php
+++ b/include/items.php
@@ -2168,9 +2168,10 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
}
function local_delivery($importer,$data) {
-
$a = get_app();
+ logger(__function__, LOGGER_TRACE);
+
if($importer['readonly']) {
// We aren't receiving stuff from this person. But we will quietly ignore them
// rather than a blatant "go away" message.
@@ -2322,16 +2323,19 @@ function local_delivery($importer,$data) {
$newloc['confirm'] = notags(unxmlify($base['confirm'][0]['data']));
$newloc['notify'] = notags(unxmlify($base['notify'][0]['data']));
$newloc['poll'] = notags(unxmlify($base['poll'][0]['data']));
- $newloc['site-pubkey'] = notags(unxmlify($base['site-pubkey'][0]['data']));
+ $newloc['sitepubkey'] = notags(unxmlify($base['sitepubkey'][0]['data']));
+ /** relocated user must have original key pair */
/*$newloc['pubkey'] = notags(unxmlify($base['pubkey'][0]['data']));
$newloc['prvkey'] = notags(unxmlify($base['prvkey'][0]['data']));*/
- log("items:relocate contact ".print_r($newloc, true), LOGGER_DEBUG);
+ logger("items:relocate contact ".print_r($newloc, true).print_r($importer, true), LOGGER_DEBUG);
// update contact
- $r = q("SELECT photo, url FROM contact WHERE WHERE id=%d AND uid=%d;",
- intval($importer['importer_uid']),
- intval($importer['id']));
+ $r = q("SELECT photo, url FROM contact WHERE id=%d AND uid=%d;",
+ intval($importer['id']),
+ intval($importer['importer_uid']));
+ if ($r === false)
+ return 1;
$old = $r[0];
$x = q("UPDATE contact SET
@@ -2344,7 +2348,7 @@ function local_delivery($importer,$data) {
confirm = '%s',
notify = '%s',
poll = '%s',
- site-pubkey = '%s'
+ `site-pubkey` = '%s'
WHERE id=%d AND uid=%d;",
dbesc($newloc['name']),
dbesc($newloc['photo']),
@@ -2355,10 +2359,12 @@ function local_delivery($importer,$data) {
dbesc($newloc['confirm']),
dbesc($newloc['notify']),
dbesc($newloc['poll']),
- dbesc($newloc['site-pubkey']),
- intval($importer['importer_uid']),
- intval($importer['id']));
-
+ dbesc($newloc['sitepubkey']),
+ intval($importer['id']),
+ intval($importer['importer_uid']));
+
+ if ($x === false)
+ return 1;
// update items
$fields = array(
'owner-link' => array($old['url'], $newloc['url']),
@@ -2366,12 +2372,15 @@ function local_delivery($importer,$data) {
'owner-avatar' => array($old['photo'], $newloc['photo']),
'author-avatar' => array($old['photo'], $newloc['photo']),
);
- foreach ($fields as $n=>$f)
+ foreach ($fields as $n=>$f){
$x = q("UPDATE item SET `%s`='%s' WHERE `%s`='%s' AND uid=%d",
$n, dbesc($f[1]),
$n, dbesc($f[0]),
intval($importer['importer_uid']));
-
+ if ($x === false)
+ return 1;
+ }
+
// TODO
// merge with current record, current contents have priority
// update record, set url-updated
diff --git a/include/notifier.php b/include/notifier.php
index 88c90a856f..1d2c26fb2d 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -1,5 +1,4 @@
xmlfy($owner['name']),
- '$photo' => xmlfy($owner['photo']),
- '$thumb' => xmlfy($owner['thumb']),
- '$micro' => xmlfy($owner['micro']),
- '$url' => xmlfy($owner['url']),
- '$request' => xmlfy($owner['request']),
- '$confirm' => xmlfy($owner['confirm']),
- '$notify' => xmlfy($owner['notify']),
- '$poll' => xmlfy($owner['poll']),
- '$site-pubkey' => xmlfy(get_config('system','site_pubkey')),
- //'$pubkey' => xmlfy($owner['pubkey']),
- //'$prvkey' => xmlfy($owner['prvkey']),
+ '$name' => xmlify($owner['name']),
+ '$photo' => xmlify($owner['photo']),
+ '$thumb' => xmlify($owner['thumb']),
+ '$micro' => xmlify($owner['micro']),
+ '$url' => xmlify($owner['url']),
+ '$request' => xmlify($owner['request']),
+ '$confirm' => xmlify($owner['confirm']),
+ '$notify' => xmlify($owner['notify']),
+ '$poll' => xmlify($owner['poll']),
+ '$sitepubkey' => xmlify(get_config('system','site_pubkey')),
+ //'$pubkey' => xmlify($owner['pubkey']),
+ //'$prvkey' => xmlify($owner['prvkey']),
));
- $recipients_relocate = q("SELECT * FROM contacts WHERE uid = %d AND self = 0 AND network = '%s'" , intval($uid), NETWORK_DFRN);
-
+ $recipients_relocate = q("SELECT * FROM contact WHERE uid = %d AND self = 0 AND network = '%s'" , intval($uid), NETWORK_DFRN);
}
else {
@@ -525,7 +532,7 @@ function notifier_run($argv, $argc){
if(count($r)) {
foreach($r as $contact) {
- if((! $mail) && (! $fsuggest) && (! $followup) && (! $contact['self'])) {
+ if((! $mail) && (! $fsuggest) && (! $followup) && (!$relocate) && (! $contact['self'])) {
if(($contact['network'] === NETWORK_DIASPORA) && ($public_message))
continue;
q("insert into deliverq ( `cmd`,`item`,`contact` ) values ('%s', %d, %d )",
@@ -562,7 +569,7 @@ function notifier_run($argv, $argc){
// potentially more than one recipient. Start a new process and space them out a bit.
// we will deliver single recipient types of message and email recipients here.
- if((! $mail) && (! $fsuggest) && (! $followup)) {
+ if((! $mail) && (! $fsuggest) && (!$relocate) && (! $followup)) {
$this_batch[] = $contact['id'];
@@ -577,7 +584,7 @@ function notifier_run($argv, $argc){
$deliver_status = 0;
- logger("main delivery by notifier: followup=$followup mail=$mail fsuggest=$fsuggest");
+ logger("main delivery by notifier: followup=$followup mail=$mail fsuggest=$fsuggest relocate=$relocate");
switch($contact['network']) {
case NETWORK_DFRN:
@@ -934,6 +941,7 @@ function notifier_run($argv, $argc){
return;
}
+
if (array_search(__file__,get_included_files())===0){
notifier_run($argv,$argc);
killme();
diff --git a/include/uimport.php b/include/uimport.php
index 9427931687..e43f331dc9 100644
--- a/include/uimport.php
+++ b/include/uimport.php
@@ -228,7 +228,7 @@ function import_account(&$a, $file) {
}
// send relocate messages
- proc_run('php', 'include/notifier.php', 'relocate' , $newuid);
+ //proc_run('php', 'include/notifier.php', 'relocate' , $newuid);
info(t("Done. You can now login with your username and password"));
goaway( $a->get_baseurl() ."/login");
diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php
index e55da55722..b50602b6bd 100644
--- a/mod/dfrn_notify.php
+++ b/mod/dfrn_notify.php
@@ -6,7 +6,7 @@ require_once('include/event.php');
function dfrn_notify_post(&$a) {
-
+ logger(__function__, LOGGER_TRACE);
$dfrn_id = ((x($_POST,'dfrn_id')) ? notags(trim($_POST['dfrn_id'])) : '');
$dfrn_version = ((x($_POST,'dfrn_version')) ? (float) $_POST['dfrn_version'] : 2.0);
$challenge = ((x($_POST,'challenge')) ? notags(trim($_POST['challenge'])) : '');
diff --git a/view/atom_relocate.tpl b/view/atom_relocate.tpl
index f7f8db97b1..3976a0037f 100644
--- a/view/atom_relocate.tpl
+++ b/view/atom_relocate.tpl
@@ -10,7 +10,7 @@
$confirm
$notify
$poll
- $site-pubkey
+ $sitepubkey