]> git.mxchange.org Git - friendica.git/blobdiff - mod/dfrn_poll.php
Merge branch 'ajaxcomms'
[friendica.git] / mod / dfrn_poll.php
index 20fdc8f79c0159ea79759ed206e025961c8347e9..334e103079da11956134602988bceaabdd183a1a 100644 (file)
@@ -1,11 +1,14 @@
 <?php
 
+
+
 require_once('include/items.php');
 require_once('include/auth.php');
 
 
 function dfrn_poll_init(&$a) {
 
+
        $dfrn_id         = ((x($_GET,'dfrn_id'))         ? $_GET['dfrn_id']              : '');
        $type            = ((x($_GET,'type'))            ? $_GET['type']                 : 'data');
        $last_update     = ((x($_GET,'last_update'))     ? $_GET['last_update']          : '');
@@ -23,8 +26,9 @@ function dfrn_poll_init(&$a) {
        }
 
        if(($dfrn_id === '') && (! x($_POST,'dfrn_id')) && ($a->argc > 1)) {
+               logger('dfrn_poll: public feed request from ' . $_SERVER['REMOTE_ADDR'] );
                header("Content-type: application/atom+xml");
-               $o = get_feed_for($a, '*', $a->argv[1],$last_update);
+               $o = get_feed_for($a, '', $a->argv[1],$last_update);
                echo $o;
                killme();
        }
@@ -70,6 +74,7 @@ function dfrn_poll_init(&$a) {
                                if((int) $xml->status == 1) {
                                        $_SESSION['authenticated'] = 1;
                                        $_SESSION['visitor_id'] = $r[0]['id'];
+                                       $_SESSION['visitor_home'] = $r[0]['url'];
                                        notice( $r[0]['username'] . t(' welcomes ') . $r[0]['name'] . EOL);
                                        // Visitors get 1 day session.
                                        $session_id = session_id();
@@ -96,18 +101,18 @@ function dfrn_poll_init(&$a) {
                                dbesc($sec)
                        );
                        if(! count($r)) {
-                               xml_status(3);
+                               xml_status(3, 'No ticket');
                                // NOTREACHED
                        }
                        $orig_id = $r[0]['dfrn_id'];
-                       if(strpos(':',$orig_id))
+                       if(strpos($orig_id, ':'))
                                $orig_id = substr($orig_id,2);
 
                        $c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
                                intval($r[0]['cid'])
                        );
                        if(! count($c)) {
-                               xml_status(3);
+                               xml_status(3, 'No profile');
                        }
                        $contact = $c[0];
 
@@ -131,9 +136,9 @@ function dfrn_poll_init(&$a) {
                                $final_dfrn_id = substr($final_dfrn_id,2);
 
                        if($final_dfrn_id != $orig_id) {
-
+                               logger('profile_check: ' . $final_dfrn_id . ' != ' . $orig_id, LOGGER_DEBUG);
                                // did not decode properly - cannot trust this site 
-                               xml_status(3);
+                               xml_status(3, 'Bad decryption');
                        }
 
                        header("Content-type: text/xml");
@@ -353,6 +358,8 @@ function dfrn_poll_content(&$a) {
                }
                else {
                        $status = 1;
+                       $challenge = '';
+                       $encrypted_id = '';
                }
 
                if(($type === 'profile') && (strlen($sec))) {
@@ -381,6 +388,7 @@ function dfrn_poll_content(&$a) {
                                if(((int) $xml->status == 0) && ($xml->challenge == $hash)  && ($xml->sec == $sec)) {
                                        $_SESSION['authenticated'] = 1;
                                        $_SESSION['visitor_id'] = $r[0]['id'];
+                                       $_SESSION['visitor_home'] = $r[0]['url'];
                                        notice( $r[0]['username'] . t(' welcomes ') . $r[0]['name'] . EOL);
                                        // Visitors get 1 day session.
                                        $session_id = session_id();