]> git.mxchange.org Git - friendica.git/blobdiff - mod/dfrn_poll.php
better intro text
[friendica.git] / mod / dfrn_poll.php
index 409ffce56cc2357e746841826e9481824638be94..c627c2b41896bb3ed9717a0d3c1a5f17ed896467 100644 (file)
@@ -15,7 +15,7 @@ function dfrn_poll_init(&$a) {
        if(x($_GET,'last_update'))
                $last_update = $a->config['dfrn_poll_last_update'] = $_GET['last_update'];
 
-       if(($dfrn_id == '') && ($a->argc > 1)) {
+       if(($dfrn_id == '') && (! x($_POST,'dfrn_id')) && ($a->argc > 1)) {
                $o = get_feed_for($a,'*', $a->argv[1],$last_update);
                echo $o;
                killme();
@@ -25,7 +25,7 @@ function dfrn_poll_init(&$a) {
 
                $r = q("SELECT `contact`.*, `user`.`nickname` 
                        FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`
-                       WHERE `issued-id` = '%s' LIMIT 1",
+                       WHERE `dfrn-id` = '%s' LIMIT 1",
                        dbesc($dfrn_id));
                if(count($r)) {
                        $s = fetch_url($r[0]['poll'] . '?dfrn_id=' . $dfrn_id . '&type=profile-check');
@@ -34,7 +34,7 @@ function dfrn_poll_init(&$a) {
                                if((int) $xml->status == 1) {
                                        $_SESSION['authenticated'] = 1;
                                        $_SESSION['visitor_id'] = $r[0]['id'];
-                                       $_SESSION['sysmsg'] .= "Hi {$r[0]['name']}" . EOL;
+                                       notice( t('Hi ') . $r[0]['name'] . EOL);
                                        // Visitors get 1 day session.
                                        $session_id = session_id();
                                        $expire = time() + 86400;
@@ -167,20 +167,22 @@ function dfrn_poll_content(&$a) {
 
                $r = q("SELECT * FROM `contact` WHERE `issued-id` = '%s' AND `blocked` = 0 AND `pending` = 0 LIMIT 1",
                        dbesc($_GET['dfrn_id']));
-               if((! count($r)) || (! strlen($r[0]['prvkey'])))
-                       $status = 1;
+               if((count($r)) && (strlen($r[0]['prvkey']))) {
 
-               $challenge = '';
+                       $challenge = '';
 
-               openssl_private_encrypt($hash,$challenge,$r[0]['prvkey']);
-               $challenge = bin2hex($challenge);
+                       openssl_private_encrypt($hash,$challenge,$r[0]['prvkey']);
+                       $challenge = bin2hex($challenge);
 
-               $encrypted_id = '';
-               $id_str = $_GET['dfrn_id'] . '.' . mt_rand(1000,9999);
-
-               openssl_private_encrypt($id_str,$encrypted_id,$r[0]['prvkey']);
-               $encrypted_id = bin2hex($encrypted_id);
+                       $encrypted_id = '';
+                       $id_str = $_GET['dfrn_id'] . '.' . mt_rand(1000,9999);
 
+                       openssl_private_encrypt($id_str,$encrypted_id,$r[0]['prvkey']);
+                       $encrypted_id = bin2hex($encrypted_id);
+               }
+               else {
+                       $status = 1;  // key not found
+               }
 
                echo '<?xml version="1.0" encoding="UTF-8"?><dfrn_poll><status>' .$status . '</status><dfrn_id>' . $encrypted_id . '</dfrn_id>'
                        . '<challenge>' . $challenge . '</challenge></dfrn_poll>' . "\r\n" ;