]> git.mxchange.org Git - friendica.git/commitdiff
cleanup to ensure protocol version is passed properly. We will need it if/when any...
authorMike Macgirvin <mike@macgirvin.com>
Wed, 13 Oct 2010 03:29:04 +0000 (20:29 -0700)
committerMike Macgirvin <mike@macgirvin.com>
Wed, 13 Oct 2010 03:29:04 +0000 (20:29 -0700)
include/items.php
include/poller.php
mod/dfrn_confirm.php
mod/dfrn_notify.php
mod/dfrn_poll.php
mod/dfrn_request.php

index ab2fd644a16c692626ae7966b100374566b467a7..7958c78c3617fc6cb311b799885e98f220071e58 100644 (file)
@@ -517,10 +517,10 @@ function dfrn_deliver($contact,$atom,$debugging = false) {
        if($contact['duplex'] && $contact['issued-id'])
                $idtosend = '1:' . $orig_id;            
 
-       $url = $contact['notify'] . '?dfrn_id=' . $idtosend;
+       $url = $contact['notify'] . '?dfrn_id=' . $idtosend . '&dfrn_version=' . DFRN_PROTOCOL_VERSION ;
 
        if($debugging)
-               echo "URL: $url";
+               echo "URL: $url\n";
 
        $xml = fetch_url($url);
 
@@ -560,8 +560,8 @@ function dfrn_deliver($contact,$atom,$debugging = false) {
                return 3;
        }
 
-       $postvars['dfrn_id'] = $idtosend;
-
+       $postvars['dfrn_id']      = $idtosend;
+       $postvars['dfrn_version'] = DFRN_PROTOCOL_VERSION;
 
        if(($contact['rel']) && ($contact['rel'] != REL_FAN) && (! $contact['blocked']) && (! $contact['readonly'])) {
                $postvars['data'] = $atom;
index ff141484bb37a02004991a431231419aa0578f02..bf2803b637e379cc3c986f83e6ec2574a69763e9 100644 (file)
                if(intval($contact['duplex']) && $contact['issued-id'])
                        $idtosend = '1:' . $orig_id;            
 
-               $url = $contact['poll'] . '?dfrn_id=' . $idtosend . '&type=data&last_update=' . $last_update ;
+               $url = $contact['poll'] . '?dfrn_id=' . $idtosend 
+                       . '&dfrn_version=' . DFRN_PROTOCOL_VERSION 
+                       . '&type=data&last_update=' . $last_update ;
+
                $xml = fetch_url($url);
 
                if($debugging) {
-                       echo "URL: " . $url . "\r\n";
-                       echo "XML: " . $xml . "\r\n";
+                       echo "URL: " . $url . "\n";
+                       echo "XML: " . $xml . "\n";
                }
 
                if(! $xml) {
                }
 
                $postvars['dfrn_id'] = $idtosend;
-
+               $postvars['dfrn_version'] = DFRN_PROTOCOL_VERSION;
 
                $xml = post_url($contact['poll'],$postvars);
 
index 265a62b888c5694701d0a87ced0e12b68986234d..3df36182e18ad34cd065b56eea62752b47b0d168 100644 (file)
@@ -109,7 +109,7 @@ function dfrn_confirm_post(&$a) {
                        $params['public_key'] = bin2hex(openssl_encrypt($public_key,'AES-256-CBC',$src_aes_key));
                }
 
-               $params['dfrn_version'] = '2.0';
+               $params['dfrn_version'] = DFRN_PROTOCOL_VERSION ;
                if($duplex == 1)
                        $params['duplex'] = 1;
 
index 4a23da505012229deba47a4137ae5562a2596633..5779b68d2a1d7cbf28f820de0165cca147dce592 100644 (file)
@@ -7,6 +7,7 @@ require_once('include/items.php');
 function dfrn_notify_post(&$a) {
 
        $dfrn_id = notags(trim($_POST['dfrn_id']));
+       $dfrn_version = (float) $_POST['dfrn_version'];
        $challenge = notags(trim($_POST['challenge']));
        $data = $_POST['data'];
 
@@ -374,6 +375,8 @@ function dfrn_notify_content(&$a) {
                // If this is a duplex communication, ours will be the opposite.
 
                $dfrn_id = notags(trim($_GET['dfrn_id']));
+               $dfrn_version = (float) $_GET['dfrn_version'];
+
 
                $direction = (-1);
                if(strpos($dfrn_id,':') == 1) {
@@ -435,7 +438,16 @@ function dfrn_notify_content(&$a) {
                $challenge    = bin2hex($challenge);
                $encrypted_id = bin2hex($encrypted_id);
 
-               echo '<?xml version="1.0" encoding="UTF-8"?><dfrn_notify><status>' . $status . '</status><dfrn_version>2.0</dfrn_version><dfrn_id>' . $encrypted_id . '</dfrn_id><challenge>' . $challenge . '</challenge></dfrn_notify>' . "\r\n" ;
+               header("Content-type: text/xml");
+
+               echo '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n" 
+                       . '<dfrn_notify>' . "\r\n"
+                       . "\t" . '<status>' . $status . '</status>' . "\r\n"
+                       . "\t" . '<dfrn_version>' . DFRN_PROTOCOL_VERSION . '</dfrn_version>' . "\r\n"
+                       . "\t" . '<dfrn_id>' . $encrypted_id . '</dfrn_id>' . "\r\n" 
+                       . "\t" . '<challenge>' . $challenge . '</challenge>' . "\r\n"
+                       . '</dfrn_notify>' . "\r\n" ;
+
                killme();
        }
 
index a65f6555d3a574a557a7c1dd9bc5d9e5cf3cc321..f5a7619834ab3710b1c5432ab2a72274ed80e4ba 100644 (file)
@@ -14,7 +14,7 @@ function dfrn_poll_init(&$a) {
                $type = $_GET['type'];
        if(x($_GET,'last_update'))
                $last_update = $_GET['last_update'];
-       $dfrn_version    = ((x($_GET,'dfrn_version'))    ? $_GET['dfrn_version']    : '1.0');
+       $dfrn_version    = (float) $_GET['dfrn_version'] ;
        $destination_url = ((x($_GET,'destination_url')) ? $_GET['destination_url'] : '');
 
 
@@ -115,11 +115,12 @@ function dfrn_poll_init(&$a) {
 
 function dfrn_poll_post(&$a) {
 
-       $dfrn_id = $_POST['dfrn_id'];
-       $challenge = $_POST['challenge'];
-       $url = $_POST['url'];
+       $dfrn_id      = $_POST['dfrn_id'];
+       $challenge    = $_POST['challenge'];
+       $url          = $_POST['url'];
+       $dfrn_version = (float) $_POST['dfrn_version'];
 
-       $direction = (-1);
+       $direction    = (-1);
        if(strpos($dfrn_id,':') == 1) {
                $direction = intval(substr($dfrn_id,0,1));
                $dfrn_id = substr($dfrn_id,2);
@@ -199,7 +200,7 @@ function dfrn_poll_post(&$a) {
                </reputation>
                ";
                killme();
-               return; // NOTREACHED
+               // NOTREACHED
        }
        else {
                $o = get_feed_for($a,$dfrn_id, $a->argv[1], $last_update, $direction);
@@ -222,6 +223,8 @@ function dfrn_poll_content(&$a) {
        if(x($_GET,'last_update'))
                $last_update = $_GET['last_update'];
 
+       $dfrn_version = (float) $_GET['dfrn_version'];
+
        $direction = (-1);
        if(strpos($dfrn_id,':') == 1) {
                $direction = intval(substr($dfrn_id,0,1));
@@ -293,11 +296,15 @@ function dfrn_poll_content(&$a) {
                else {
                        $status = 1;
                }
-
-               echo '<?xml version="1.0" encoding="UTF-8"?><dfrn_poll><status>' .$status . '</status><dfrn_version>2.0</dfrn_version><dfrn_id>' . $encrypted_id . '</dfrn_id>'
-                       . '<challenge>' . $challenge . '</challenge></dfrn_poll>' . "\r\n" ;
-               session_write_close();
-               exit;           
+               header("Content-type: text/xml");
+               echo '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n"
+                       . '<dfrn_poll>' . "\r\n"
+                       . "\t" . '<status>' .$status . '</status>' . "\r\n"
+                       . "\t" . '<dfrn_version>' . DFRN_PROTOCOL_VERSION . '</dfrn_version>' . "\r\n"
+                       . "\t" . '<dfrn_id>' . $encrypted_id . '</dfrn_id>' . "\r\n"
+                       . "\t" . '<challenge>' . $challenge . '</challenge>' . "\r\n"
+                       . '</dfrn_poll>' . "\r\n" ;
+               killme();
        }
 }
 
index f6a85fbabbebd3abdde7a0ed1ad2e3ea2afd8191..3c16e2560a14851aeb1637f44429e2473650c167 100644 (file)
@@ -197,7 +197,7 @@ function dfrn_request_post(&$a) {
                }
 
 
-               if($network == 'dfrn') {
+               if($network === 'dfrn') {
                        $ret = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' LIMIT 1", 
                                intval($uid),
                                dbesc($url)