-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.*\r
+.htconfig.php\r
+\#*\r
+include/jquery-1.4.2.min.js\r
+*.log\r
+*.out\r
+*.version*\r
+favicon.*\r
+home.html\r
+addon\r
+*~\r
+\r
+#ignore documentation, it should be newly built \r
+doc/api\r
+\r
+#ignore reports, should be generted with every build\r
+report/\r
+\r
+#ignore config files from eclipse, we don't want IDE files in our repository\r
+.project\r
+.buildpath\r
+.externalToolBuilders\r
+.settings\r
+#ignore OSX .DS_Store files \r
+.DS_Store\r
+\r
+/nbproject/private/
\ No newline at end of file
function __construct() {
- global $default_timezone;
+ global $default_timezone, $argv, $argc;
$this->timezone = ((x($default_timezone)) ? $default_timezone : 'UTC');
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
. '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);
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));
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);
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)){
}
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.
$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
confirm = '%s',
notify = '%s',
poll = '%s',
- site-pubkey = '%s'
+ `site-pubkey` = '%s'
WHERE id=%d AND uid=%d;",
dbesc($newloc['name']),
dbesc($newloc['photo']),
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']),
'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
<?php
-
require_once("boot.php");
require_once('include/queue_fn.php');
require_once('include/html2plain.php');
// fill this in with a single salmon slap if applicable
$slap = '';
- if(! ($mail || $fsuggest)) {
+ if(! ($mail || $fsuggest || $relocate)) {
require_once('include/group.php');
$sugg_template = get_markup_template('atom_relocate.tpl');
+ /* get site pubkey. this could be a new installation with no site keys*/
+ $pubkey = get_config('system','site_pubkey');
+ if(! $pubkey) {
+ $res = new_keypair(1024);
+ set_config('system','site_prvkey', $res['prvkey']);
+ set_config('system','site_pubkey', $res['pubkey']);
+ }
+
+
$atom .= replace_macros($sugg_template, array(
- '$name' => 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 {
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 )",
// 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'];
$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:
return;
}
+
if (array_search(__file__,get_included_files())===0){
notifier_run($argv,$argc);
killme();
} \r
\r
// send relocate messages\r
- proc_run('php', 'include/notifier.php', 'relocate' , $newuid);\r
+ //proc_run('php', 'include/notifier.php', 'relocate' , $newuid);\r
\r
info(t("Done. You can now login with your username and password"));\r
goaway( $a->get_baseurl() ."/login");\r
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'])) : '');
<dfrn:confirm>$confirm</dfrn:confirm>
<dfrn:notify>$notify</dfrn:notify>
<dfrn:poll>$poll</dfrn:poll>
- <dfrn:site-pubkey>$site-pubkey</dfrn:site-pubkey>
+ <dfrn:sitepubkey>$sitepubkey</dfrn:sitepubkey>
</dfrn:relocate>