moveme: first successful relocated user
This commit is contained in:
parent
dbc6cbe024
commit
1a3a5ee8d9
53
.gitignore
vendored
53
.gitignore
vendored
|
@ -1,26 +1,27 @@
|
||||||
favicon.*
|
favicon.*
|
||||||
.htconfig.php
|
.htconfig.php
|
||||||
\#*
|
\#*
|
||||||
include/jquery-1.4.2.min.js
|
include/jquery-1.4.2.min.js
|
||||||
*.log
|
*.log
|
||||||
*.out
|
*.out
|
||||||
*.version*
|
*.version*
|
||||||
favicon.*
|
favicon.*
|
||||||
home.html
|
home.html
|
||||||
addon
|
addon
|
||||||
*~
|
*~
|
||||||
|
|
||||||
#ignore documentation, it should be newly built
|
#ignore documentation, it should be newly built
|
||||||
doc/api
|
doc/api
|
||||||
|
|
||||||
#ignore reports, should be generted with every build
|
#ignore reports, should be generted with every build
|
||||||
report/
|
report/
|
||||||
|
|
||||||
#ignore config files from eclipse, we don't want IDE files in our repository
|
#ignore config files from eclipse, we don't want IDE files in our repository
|
||||||
.project
|
.project
|
||||||
.buildpath
|
.buildpath
|
||||||
.externalToolBuilders
|
.externalToolBuilders
|
||||||
.settings
|
.settings
|
||||||
#ignore OSX .DS_Store files
|
#ignore OSX .DS_Store files
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
/nbproject/private/
|
14
boot.php
14
boot.php
|
@ -385,7 +385,7 @@ if(! class_exists('App')) {
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
|
|
||||||
global $default_timezone;
|
global $default_timezone, $argv, $argc;
|
||||||
|
|
||||||
$this->timezone = ((x($default_timezone)) ? $default_timezone : 'UTC');
|
$this->timezone = ((x($default_timezone)) ? $default_timezone : 'UTC');
|
||||||
|
|
||||||
|
@ -428,6 +428,9 @@ if(! class_exists('App')) {
|
||||||
if(isset($path) && strlen($path) && ($path != $this->path))
|
if(isset($path) && strlen($path) && ($path != $this->path))
|
||||||
$this->path = $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(
|
set_include_path(
|
||||||
"include/$this->hostname" . PATH_SEPARATOR
|
"include/$this->hostname" . PATH_SEPARATOR
|
||||||
|
@ -436,6 +439,7 @@ if(! class_exists('App')) {
|
||||||
. 'library/phpsec' . PATH_SEPARATOR
|
. 'library/phpsec' . PATH_SEPARATOR
|
||||||
. 'library/langdet' . PATH_SEPARATOR
|
. 'library/langdet' . PATH_SEPARATOR
|
||||||
. '.' );
|
. '.' );
|
||||||
|
|
||||||
|
|
||||||
if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,2) === "q=") {
|
if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,2) === "q=") {
|
||||||
$this->query_string = substr($_SERVER['QUERY_STRING'],2);
|
$this->query_string = substr($_SERVER['QUERY_STRING'],2);
|
||||||
|
@ -1501,9 +1505,15 @@ if(! function_exists('proc_run')) {
|
||||||
|
|
||||||
if(count($args) && $args[0] === 'php')
|
if(count($args) && $args[0] === 'php')
|
||||||
$args[0] = ((x($a->config,'php_path')) && (strlen($a->config['php_path'])) ? $a->config['php_path'] : '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]);
|
$args[$x] = escapeshellarg($args[$x]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$cmdline = implode($args," ");
|
$cmdline = implode($args," ");
|
||||||
if(get_config('system','proc_windows'))
|
if(get_config('system','proc_windows'))
|
||||||
proc_close(proc_open('cmd /c start /b ' . $cmdline,array(),$foo));
|
proc_close(proc_open('cmd /c start /b ' . $cmdline,array(),$foo));
|
||||||
|
|
|
@ -232,6 +232,7 @@ function q($sql) {
|
||||||
|
|
||||||
if($db && $db->connected) {
|
if($db && $db->connected) {
|
||||||
$stmt = vsprintf($sql,$args);
|
$stmt = vsprintf($sql,$args);
|
||||||
|
//logger("dba: q: $stmt", LOGGER_ALL);
|
||||||
if($stmt === false)
|
if($stmt === false)
|
||||||
logger('dba: vsprintf error: ' . print_r(debug_backtrace(),true), LOGGER_DEBUG);
|
logger('dba: vsprintf error: ' . print_r(debug_backtrace(),true), LOGGER_DEBUG);
|
||||||
return $db->q($stmt);
|
return $db->q($stmt);
|
||||||
|
|
|
@ -3,7 +3,7 @@ require_once("boot.php");
|
||||||
require_once('include/queue_fn.php');
|
require_once('include/queue_fn.php');
|
||||||
require_once('include/html2plain.php');
|
require_once('include/html2plain.php');
|
||||||
|
|
||||||
function delivery_run($argv, $argc){
|
function delivery_run(&$argv, &$argc){
|
||||||
global $a, $db;
|
global $a, $db;
|
||||||
|
|
||||||
if(is_null($a)){
|
if(is_null($a)){
|
||||||
|
|
|
@ -2168,9 +2168,10 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
function local_delivery($importer,$data) {
|
function local_delivery($importer,$data) {
|
||||||
|
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
|
logger(__function__, LOGGER_TRACE);
|
||||||
|
|
||||||
if($importer['readonly']) {
|
if($importer['readonly']) {
|
||||||
// We aren't receiving stuff from this person. But we will quietly ignore them
|
// We aren't receiving stuff from this person. But we will quietly ignore them
|
||||||
// rather than a blatant "go away" message.
|
// 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['confirm'] = notags(unxmlify($base['confirm'][0]['data']));
|
||||||
$newloc['notify'] = notags(unxmlify($base['notify'][0]['data']));
|
$newloc['notify'] = notags(unxmlify($base['notify'][0]['data']));
|
||||||
$newloc['poll'] = notags(unxmlify($base['poll'][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['pubkey'] = notags(unxmlify($base['pubkey'][0]['data']));
|
||||||
$newloc['prvkey'] = notags(unxmlify($base['prvkey'][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
|
// update contact
|
||||||
$r = q("SELECT photo, url FROM contact WHERE WHERE id=%d AND uid=%d;",
|
$r = q("SELECT photo, url FROM contact WHERE id=%d AND uid=%d;",
|
||||||
intval($importer['importer_uid']),
|
intval($importer['id']),
|
||||||
intval($importer['id']));
|
intval($importer['importer_uid']));
|
||||||
|
if ($r === false)
|
||||||
|
return 1;
|
||||||
$old = $r[0];
|
$old = $r[0];
|
||||||
|
|
||||||
$x = q("UPDATE contact SET
|
$x = q("UPDATE contact SET
|
||||||
|
@ -2344,7 +2348,7 @@ function local_delivery($importer,$data) {
|
||||||
confirm = '%s',
|
confirm = '%s',
|
||||||
notify = '%s',
|
notify = '%s',
|
||||||
poll = '%s',
|
poll = '%s',
|
||||||
site-pubkey = '%s'
|
`site-pubkey` = '%s'
|
||||||
WHERE id=%d AND uid=%d;",
|
WHERE id=%d AND uid=%d;",
|
||||||
dbesc($newloc['name']),
|
dbesc($newloc['name']),
|
||||||
dbesc($newloc['photo']),
|
dbesc($newloc['photo']),
|
||||||
|
@ -2355,10 +2359,12 @@ function local_delivery($importer,$data) {
|
||||||
dbesc($newloc['confirm']),
|
dbesc($newloc['confirm']),
|
||||||
dbesc($newloc['notify']),
|
dbesc($newloc['notify']),
|
||||||
dbesc($newloc['poll']),
|
dbesc($newloc['poll']),
|
||||||
dbesc($newloc['site-pubkey']),
|
dbesc($newloc['sitepubkey']),
|
||||||
intval($importer['importer_uid']),
|
intval($importer['id']),
|
||||||
intval($importer['id']));
|
intval($importer['importer_uid']));
|
||||||
|
|
||||||
|
if ($x === false)
|
||||||
|
return 1;
|
||||||
// update items
|
// update items
|
||||||
$fields = array(
|
$fields = array(
|
||||||
'owner-link' => array($old['url'], $newloc['url']),
|
'owner-link' => array($old['url'], $newloc['url']),
|
||||||
|
@ -2366,12 +2372,15 @@ function local_delivery($importer,$data) {
|
||||||
'owner-avatar' => array($old['photo'], $newloc['photo']),
|
'owner-avatar' => array($old['photo'], $newloc['photo']),
|
||||||
'author-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",
|
$x = q("UPDATE item SET `%s`='%s' WHERE `%s`='%s' AND uid=%d",
|
||||||
$n, dbesc($f[1]),
|
$n, dbesc($f[1]),
|
||||||
$n, dbesc($f[0]),
|
$n, dbesc($f[0]),
|
||||||
intval($importer['importer_uid']));
|
intval($importer['importer_uid']));
|
||||||
|
if ($x === false)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
// merge with current record, current contents have priority
|
// merge with current record, current contents have priority
|
||||||
// update record, set url-updated
|
// update record, set url-updated
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once("boot.php");
|
require_once("boot.php");
|
||||||
require_once('include/queue_fn.php');
|
require_once('include/queue_fn.php');
|
||||||
require_once('include/html2plain.php');
|
require_once('include/html2plain.php');
|
||||||
|
@ -206,7 +205,7 @@ function notifier_run($argv, $argc){
|
||||||
// fill this in with a single salmon slap if applicable
|
// fill this in with a single salmon slap if applicable
|
||||||
$slap = '';
|
$slap = '';
|
||||||
|
|
||||||
if(! ($mail || $fsuggest)) {
|
if(! ($mail || $fsuggest || $relocate)) {
|
||||||
|
|
||||||
require_once('include/group.php');
|
require_once('include/group.php');
|
||||||
|
|
||||||
|
@ -415,22 +414,30 @@ function notifier_run($argv, $argc){
|
||||||
|
|
||||||
$sugg_template = get_markup_template('atom_relocate.tpl');
|
$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(
|
$atom .= replace_macros($sugg_template, array(
|
||||||
'$name' => xmlfy($owner['name']),
|
'$name' => xmlify($owner['name']),
|
||||||
'$photo' => xmlfy($owner['photo']),
|
'$photo' => xmlify($owner['photo']),
|
||||||
'$thumb' => xmlfy($owner['thumb']),
|
'$thumb' => xmlify($owner['thumb']),
|
||||||
'$micro' => xmlfy($owner['micro']),
|
'$micro' => xmlify($owner['micro']),
|
||||||
'$url' => xmlfy($owner['url']),
|
'$url' => xmlify($owner['url']),
|
||||||
'$request' => xmlfy($owner['request']),
|
'$request' => xmlify($owner['request']),
|
||||||
'$confirm' => xmlfy($owner['confirm']),
|
'$confirm' => xmlify($owner['confirm']),
|
||||||
'$notify' => xmlfy($owner['notify']),
|
'$notify' => xmlify($owner['notify']),
|
||||||
'$poll' => xmlfy($owner['poll']),
|
'$poll' => xmlify($owner['poll']),
|
||||||
'$site-pubkey' => xmlfy(get_config('system','site_pubkey')),
|
'$sitepubkey' => xmlify(get_config('system','site_pubkey')),
|
||||||
//'$pubkey' => xmlfy($owner['pubkey']),
|
//'$pubkey' => xmlify($owner['pubkey']),
|
||||||
//'$prvkey' => xmlfy($owner['prvkey']),
|
//'$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 {
|
else {
|
||||||
|
@ -525,7 +532,7 @@ function notifier_run($argv, $argc){
|
||||||
if(count($r)) {
|
if(count($r)) {
|
||||||
|
|
||||||
foreach($r as $contact) {
|
foreach($r as $contact) {
|
||||||
if((! $mail) && (! $fsuggest) && (! $followup) && (! $contact['self'])) {
|
if((! $mail) && (! $fsuggest) && (! $followup) && (!$relocate) && (! $contact['self'])) {
|
||||||
if(($contact['network'] === NETWORK_DIASPORA) && ($public_message))
|
if(($contact['network'] === NETWORK_DIASPORA) && ($public_message))
|
||||||
continue;
|
continue;
|
||||||
q("insert into deliverq ( `cmd`,`item`,`contact` ) values ('%s', %d, %d )",
|
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.
|
// 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.
|
// 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'];
|
$this_batch[] = $contact['id'];
|
||||||
|
|
||||||
|
@ -577,7 +584,7 @@ function notifier_run($argv, $argc){
|
||||||
|
|
||||||
$deliver_status = 0;
|
$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']) {
|
switch($contact['network']) {
|
||||||
case NETWORK_DFRN:
|
case NETWORK_DFRN:
|
||||||
|
@ -934,6 +941,7 @@ function notifier_run($argv, $argc){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (array_search(__file__,get_included_files())===0){
|
if (array_search(__file__,get_included_files())===0){
|
||||||
notifier_run($argv,$argc);
|
notifier_run($argv,$argc);
|
||||||
killme();
|
killme();
|
||||||
|
|
|
@ -228,7 +228,7 @@ function import_account(&$a, $file) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// send relocate messages
|
// 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"));
|
info(t("Done. You can now login with your username and password"));
|
||||||
goaway( $a->get_baseurl() ."/login");
|
goaway( $a->get_baseurl() ."/login");
|
||||||
|
|
|
@ -6,7 +6,7 @@ require_once('include/event.php');
|
||||||
|
|
||||||
|
|
||||||
function dfrn_notify_post(&$a) {
|
function dfrn_notify_post(&$a) {
|
||||||
|
logger(__function__, LOGGER_TRACE);
|
||||||
$dfrn_id = ((x($_POST,'dfrn_id')) ? notags(trim($_POST['dfrn_id'])) : '');
|
$dfrn_id = ((x($_POST,'dfrn_id')) ? notags(trim($_POST['dfrn_id'])) : '');
|
||||||
$dfrn_version = ((x($_POST,'dfrn_version')) ? (float) $_POST['dfrn_version'] : 2.0);
|
$dfrn_version = ((x($_POST,'dfrn_version')) ? (float) $_POST['dfrn_version'] : 2.0);
|
||||||
$challenge = ((x($_POST,'challenge')) ? notags(trim($_POST['challenge'])) : '');
|
$challenge = ((x($_POST,'challenge')) ? notags(trim($_POST['challenge'])) : '');
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<dfrn:confirm>$confirm</dfrn:confirm>
|
<dfrn:confirm>$confirm</dfrn:confirm>
|
||||||
<dfrn:notify>$notify</dfrn:notify>
|
<dfrn:notify>$notify</dfrn:notify>
|
||||||
<dfrn:poll>$poll</dfrn:poll>
|
<dfrn:poll>$poll</dfrn:poll>
|
||||||
<dfrn:site-pubkey>$site-pubkey</dfrn:site-pubkey>
|
<dfrn:sitepubkey>$sitepubkey</dfrn:sitepubkey>
|
||||||
|
|
||||||
|
|
||||||
</dfrn:relocate>
|
</dfrn:relocate>
|
||||||
|
|
Loading…
Reference in a new issue