]> git.mxchange.org Git - friendica.git/blobdiff - mod/dfrn_confirm.php
Merge pull request #4527 from annando/fix-no-constant-update
[friendica.git] / mod / dfrn_confirm.php
index 9e5f0f3d54b3c64c7fe188f6ec8acd16c2645224..d5264aa056e7954b02ccdf97842aeca414084a88 100644 (file)
@@ -26,11 +26,14 @@ use Friendica\Core\Worker;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
 use Friendica\Model\Group;
+use Friendica\Model\Item;
 use Friendica\Model\User;
 use Friendica\Network\Probe;
 use Friendica\Protocol\Diaspora;
 use Friendica\Util\Crypto;
+use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
+use Friendica\Util\XML;
 
 require_once 'include/enotify.php';
 require_once 'include/items.php';
@@ -221,7 +224,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
                         *
                         */
 
-                       $res = Network::postURL($dfrn_confirm, $params, null, $redirects, 120);
+                       $res = Network::post($dfrn_confirm, $params, null, $redirects, 120);
 
                        logger(' Confirm: received data: ' . $res, LOGGER_DATA);
 
@@ -252,7 +255,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
                                return;
                        }
 
-                       $xml = parse_xml_string($res);
+                       $xml = XML::parseString($res);
                        $status = (int) $xml->status;
                        $message = unxmlify($xml->message);   // human readable text of what may have gone wrong.
                        switch ($status) {
@@ -324,8 +327,8 @@ function dfrn_confirm_post(App $a, $handsfree = null)
                                `network` = '%s' WHERE `id` = %d
                        ",
                                intval($new_relation),
-                               dbesc(datetime_convert()),
-                               dbesc(datetime_convert()),
+                               dbesc(DateTimeFormat::utcNow()),
+                               dbesc(DateTimeFormat::utcNow()),
                                intval($duplex),
                                intval($hidden),
                                dbesc(NETWORK_DFRN),
@@ -375,8 +378,8 @@ function dfrn_confirm_post(App $a, $handsfree = null)
                                `rel` = %d
                                WHERE `id` = %d
                        ",
-                               dbesc(datetime_convert()),
-                               dbesc(datetime_convert()),
+                               dbesc(DateTimeFormat::utcNow()),
+                               dbesc(DateTimeFormat::utcNow()),
                                dbesc($addr),
                                dbesc($notify),
                                dbesc($poll),
@@ -438,7 +441,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
                                        $arr['deny_cid']  = $user['deny_cid'];
                                        $arr['deny_gid']  = $user['deny_gid'];
 
-                                       $i = item_store($arr);
+                                       $i = Item::insert($arr);
                                        if ($i) {
                                                Worker::add(PRIORITY_HIGH, "Notifier", "activity", $i);
                                        }
@@ -493,7 +496,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
                $user = dba::selectFirst('user', [], ['nickname' => $node]);
                if (!DBM::is_result($user)) {
                        $message = L10n::t('No user record found for \'%s\' ', $node);
-                       Network::xmlStatus(3, $message); // failure
+                       System::xmlExit(3, $message); // failure
                        // NOTREACHED
                }
 
@@ -503,7 +506,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
 
                if (!strstr($my_prvkey, 'PRIVATE KEY')) {
                        $message = L10n::t('Our site encryption key is apparently messed up.');
-                       Network::xmlStatus(3, $message);
+                       System::xmlExit(3, $message);
                }
 
                // verify everything
@@ -514,7 +517,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
 
                if (!strlen($decrypted_source_url)) {
                        $message = L10n::t('Empty site URL was provided or URL could not be decrypted by us.');
-                       Network::xmlStatus(3, $message);
+                       System::xmlExit(3, $message);
                        // NOTREACHED
                }
 
@@ -530,7 +533,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
                        if (!DBM::is_result($contact)) {
                                // this is either a bogus confirmation (?) or we deleted the original introduction.
                                $message = L10n::t('Contact record was not found for you on our site.');
-                               Network::xmlStatus(3, $message);
+                               System::xmlExit(3, $message);
                                return; // NOTREACHED
                        }
                }
@@ -544,7 +547,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
 
                if (!$foreign_pubkey) {
                        $message = L10n::t('Site public key not available in contact record for URL %s.', $decrypted_source_url);
-                       Network::xmlStatus(3, $message);
+                       System::xmlExit(3, $message);
                }
 
                $decrypted_dfrn_id = "";
@@ -560,7 +563,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
 
                if (dba::exists('contact', ['dfrn-id' => $decrypted_dfrn_id])) {
                        $message = L10n::t('The ID provided by your system is a duplicate on our system. It should work if you try again.');
-                       Network::xmlStatus(1, $message); // Birthday paradox - duplicate dfrn-id
+                       System::xmlExit(1, $message); // Birthday paradox - duplicate dfrn-id
                        // NOTREACHED
                }
 
@@ -571,7 +574,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
                );
                if (!DBM::is_result($r)) {
                        $message = L10n::t('Unable to set your contact credentials on our system.');
-                       Network::xmlStatus(3, $message);
+                       System::xmlExit(3, $message);
                }
 
                // It's possible that the other person also requested friendship.
@@ -616,8 +619,8 @@ function dfrn_confirm_post(App $a, $handsfree = null)
                        `network` = '%s' WHERE `id` = %d
                ",
                        intval($new_relation),
-                       dbesc(datetime_convert()),
-                       dbesc(datetime_convert()),
+                       dbesc(DateTimeFormat::utcNow()),
+                       dbesc(DateTimeFormat::utcNow()),
                        intval($duplex),
                        intval($forum),
                        intval($prv),
@@ -626,7 +629,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
                );
                if (!DBM::is_result($r)) {      // indicates schema is messed up or total db failure
                        $message = L10n::t('Unable to update your contact profile details on our system');
-                       Network::xmlStatus(3, $message);
+                       System::xmlExit(3, $message);
                }
 
                // Otherwise everything seems to have worked and we are almost done. Yay!
@@ -700,14 +703,14 @@ function dfrn_confirm_post(App $a, $handsfree = null)
                                        $arr['deny_cid']  = $user['deny_cid'];
                                        $arr['deny_gid']  = $user['deny_gid'];
 
-                                       $i = item_store($arr);
+                                       $i = Item::insert($arr);
                                        if ($i) {
                                                Worker::add(PRIORITY_HIGH, "Notifier", "activity", $i);
                                        }
                                }
                        }
                }
-               Network::xmlStatus(0); // Success
+               System::xmlExit(0); // Success
                return; // NOTREACHED
                ////////////////////// End of this scenario ///////////////////////////////////////////////
        }