]> git.mxchange.org Git - friendica.git/commitdiff
moveme: first successful relocated user
authorFabrixxm <fabrix.xm@gmail.com>
Wed, 31 Oct 2012 16:13:45 +0000 (17:13 +0100)
committerFabrixxm <fabrix.xm@gmail.com>
Wed, 31 Oct 2012 16:13:45 +0000 (17:13 +0100)
.gitignore
boot.php
include/dba.php
include/delivery.php
include/items.php
include/notifier.php
include/uimport.php
mod/dfrn_notify.php
view/atom_relocate.tpl

index 5fe71a7a87e6916b164cab5500c810b2d2e4bab7..358114a44481357fd2f6e4a8bb4f134fcde35b85 100644 (file)
@@ -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.*\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
index ad6c29b828a16a31785ad3868696a32451eaaa9f..71304e53e2e84ddaa97a7822dcc445f63f2e57b7 100644 (file)
--- 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));
index 63b75c49483857e421cee382ea5a1b5bdb2a92f2..9f2dab51915e498f4e092cbd7bc4c9ed011c7470 100644 (file)
@@ -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);
index 14226e4fba8a97b3473f12e91a68060ee60af307..d879deedb5a49cdb870a020900d02d7fc028e334 100644 (file)
@@ -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)){
index 0ca385c44a528fb92671c640c4266d047cc75001..426673484229fad6f9c766aa2567030f6f6c6c6c 100755 (executable)
@@ -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
index 88c90a856f06b4412c6a83d803e7770a0d146138..1d2c26fb2df2229277dab49e03d83e995b2a65f8 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 require_once("boot.php");
 require_once('include/queue_fn.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
        $slap = '';
 
-       if(! ($mail || $fsuggest)) {
+       if(! ($mail || $fsuggest || $relocate)) {
 
                require_once('include/group.php');
 
@@ -415,22 +414,30 @@ function notifier_run($argv, $argc){
 
                $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 {
@@ -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();
index 9427931687f81596e31329a05b4f71635e249eb0..e43f331dc97b963d32aa2261c093dc1090b6e379 100644 (file)
@@ -228,7 +228,7 @@ function import_account(&$a, $file) {
     } \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
index e55da557223c8e9708881e331b16664f89092ea8..b50602b6bda6c4cd6de0dac55576ac9302bb3ada 100644 (file)
@@ -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'])) : '');
index f7f8db97b1eb2aa3f12d147327ab867358040f35..3976a0037f2e555bf07226ff8f2d8dda2b5c9085 100644 (file)
@@ -10,7 +10,7 @@
        <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>