]> git.mxchange.org Git - friendica.git/blobdiff - mod/dfrn_poll.php
Replace system.proc_windows config by PHP_OS test
[friendica.git] / mod / dfrn_poll.php
index 3e5aa5b1c7bb285df46ad0298418624bfaacf127..d6bc1727e70f6d04b020e1e6c38f6e9907ce7650 100644 (file)
@@ -49,7 +49,7 @@ function dfrn_poll_init(App $a)
 
        if (($dfrn_id === '') && (!x($_POST, 'dfrn_id'))) {
                if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
-                       Network::httpStatusExit(403);
+                       System::httpExit(403);
                }
 
                $user = '';
@@ -58,7 +58,7 @@ function dfrn_poll_init(App $a)
                                dbesc($a->argv[1])
                        );
                        if (!$r) {
-                               Network::httpStatusExit(404);
+                               System::httpExit(404);
                        }
 
                        $hidewall = ($r[0]['hidewall'] && !local_user());
@@ -119,6 +119,7 @@ function dfrn_poll_init(App $a)
                                        $_SESSION['visitor_home'] = $r[0]['url'];
                                        $_SESSION['visitor_handle'] = $r[0]['addr'];
                                        $_SESSION['visitor_visiting'] = $r[0]['uid'];
+                                       $_SESSION['my_url'] = $r[0]['url'];
                                        if (!$quiet) {
                                                info(L10n::t('%1$s welcomes %2$s', $r[0]['username'], $r[0]['name']) . EOL);
                                        }
@@ -140,12 +141,12 @@ function dfrn_poll_init(App $a)
 
        if ($type === 'profile-check' && $dfrn_version < 2.2) {
                if ((strlen($challenge)) && (strlen($sec))) {
-                       q("DELETE FROM `profile_check` WHERE `expire` < " . intval(time()));
+                       dba::delete('profile_check', ["`expire` < ?", time()]);
                        $r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1",
                                dbesc($sec)
                        );
                        if (!DBM::is_result($r)) {
-                               Network::xmlExit(3, 'No ticket');
+                               System::xmlExit(3, 'No ticket');
                                // NOTREACHED
                        }
 
@@ -158,7 +159,7 @@ function dfrn_poll_init(App $a)
                                intval($r[0]['cid'])
                        );
                        if (!DBM::is_result($c)) {
-                               Network::xmlExit(3, 'No profile');
+                               System::xmlExit(3, 'No profile');
                        }
 
                        $contact = $c[0];
@@ -185,7 +186,7 @@ function dfrn_poll_init(App $a)
                        if ($final_dfrn_id != $orig_id) {
                                logger('profile_check: ' . $final_dfrn_id . ' != ' . $orig_id, LOGGER_DEBUG);
                                // did not decode properly - cannot trust this site
-                               Network::xmlExit(3, 'Bad decryption');
+                               System::xmlExit(3, 'Bad decryption');
                        }
 
                        header("Content-type: text/xml");
@@ -205,14 +206,14 @@ function dfrn_poll_init(App $a)
                                        break;
                        }
 
-                       q("DELETE FROM `profile_check` WHERE `expire` < " . intval(time()));
+                       dba::delete('profile_check', ["`expire` < ?", time()]);
                        $r = q("SELECT * FROM `profile_check` WHERE `dfrn_id` = '%s' ORDER BY `expire` DESC",
                                dbesc($dfrn_id));
                        if (DBM::is_result($r)) {
-                               Network::xmlExit(1);
+                               System::xmlExit(1);
                                return; // NOTREACHED
                        }
-                       Network::xmlExit(0);
+                       System::xmlExit(0);
                        return; // NOTREACHED
                }
        }
@@ -232,12 +233,12 @@ function dfrn_poll_post(App $a)
                if (strlen($challenge) && strlen($sec)) {
                        logger('dfrn_poll: POST: profile-check');
 
-                       q("DELETE FROM `profile_check` WHERE `expire` < " . intval(time()));
+                       dba::delete('profile_check', ["`expire` < ?", time()]);
                        $r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1",
                                dbesc($sec)
                        );
                        if (!DBM::is_result($r)) {
-                               Network::xmlExit(3, 'No ticket');
+                               System::xmlExit(3, 'No ticket');
                                // NOTREACHED
                        }
 
@@ -250,7 +251,7 @@ function dfrn_poll_post(App $a)
                                intval($r[0]['cid'])
                        );
                        if (!DBM::is_result($c)) {
-                               Network::xmlExit(3, 'No profile');
+                               System::xmlExit(3, 'No profile');
                        }
 
                        $contact = $c[0];
@@ -277,7 +278,7 @@ function dfrn_poll_post(App $a)
                        if ($final_dfrn_id != $orig_id) {
                                logger('profile_check: ' . $final_dfrn_id . ' != ' . $orig_id, LOGGER_DEBUG);
                                // did not decode properly - cannot trust this site
-                               Network::xmlExit(3, 'Bad decryption');
+                               System::xmlExit(3, 'Bad decryption');
                        }
 
                        header("Content-type: text/xml");
@@ -305,11 +306,7 @@ function dfrn_poll_post(App $a)
        $type = $r[0]['type'];
        $last_update = $r[0]['last_update'];
 
-       $r = q("DELETE FROM `challenge` WHERE `dfrn-id` = '%s' AND `challenge` = '%s'",
-               dbesc($dfrn_id),
-               dbesc($challenge)
-       );
-
+       dba::delete('challenge', ['dfrn-id' => $dfrn_id, 'challenge' => $challenge]);
 
        $sql_extra = '';
        switch ($direction) {
@@ -414,7 +411,7 @@ function dfrn_poll_content(App $a)
 
                $status = 0;
 
-               $r = q("DELETE FROM `challenge` WHERE `expire` < " . intval(time()));
+               dba::delete('challenge', ["`expire` < ?", time()]);
 
                if ($type !== 'profile') {
                        $r = q("INSERT INTO `challenge` ( `challenge`, `dfrn-id`, `expire` , `type`, `last_update` )
@@ -539,6 +536,7 @@ function dfrn_poll_content(App $a)
                                        $_SESSION['visitor_id'] = $r[0]['id'];
                                        $_SESSION['visitor_home'] = $r[0]['url'];
                                        $_SESSION['visitor_visiting'] = $r[0]['uid'];
+                                       $_SESSION['my_url'] = $r[0]['url'];
                                        if (!$quiet) {
                                                info(L10n::t('%1$s welcomes %2$s', $r[0]['username'], $r[0]['name']) . EOL);
                                        }