Merge branch '3.6-release'
[friendica-addons.git] / jappixmini / proxy.php
index a9f6db44611f6076eed4e982c9e74675decaf8e2..c4e3a03ca2f7bea462dc7da7e12fdbebac33b684 100644 (file)
@@ -46,7 +46,7 @@ if($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
        header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
        header('Access-Control-Allow-Headers: Content-Type');
        header('Access-Control-Max-Age: 31536000');
-       
+
        exit;
 }
 
@@ -58,7 +58,7 @@ if($data) {
        // CORS headers
        header('Access-Control-Allow-Origin: *');
        header('Access-Control-Allow-Headers: Content-Type');
-       
+
        $method = 'POST';
 }
 
@@ -76,7 +76,7 @@ else {
 }
 
 // HTTP headers
-$headers = array('User-Agent: Jappix (BOSH PHP Proxy)', 'Connection: keep-alive', 'Content-Type: text/xml; charset=utf-8', 'Content-Length: '.strlen($data));
+$headers = ['User-Agent: Jappix (BOSH PHP Proxy)', 'Connection: keep-alive', 'Content-Type: text/xml; charset=utf-8', 'Content-Length: '.strlen($data)];
 
 // CURL is better if available
 if(function_exists('curl_init'))
@@ -91,7 +91,7 @@ $use_curl = false;
 if($use_curl) {
        // Initialize CURL
        $connection = curl_init($HOST_BOSH);
-       
+
        // Set the CURL settings
        curl_setopt($connection, CURLOPT_HEADER, 0);
        curl_setopt($connection, CURLOPT_POST, 1);
@@ -104,7 +104,7 @@ if($use_curl) {
        curl_setopt($connection, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($connection, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1);
-       
+
        // Get the CURL output
        $output = curl_exec($connection);
 }
@@ -112,11 +112,11 @@ if($use_curl) {
 // Built-in stream functions
 else {
        // HTTP parameters
-       $parameters = array('http' => array(
+       $parameters = ['http' => [
                                        'method' => 'POST',
                                        'content' => $data
-                                     )
-                     );
+                                     ]
+                     ];
 
        $parameters['http']['header'] = $headers;
 
@@ -148,7 +148,7 @@ header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
 if($method == 'POST') {
        // XML header
        header('Content-Type: text/xml; charset=utf-8');
-       
+
        if(!$output)
                echo('<body xmlns=\'http://jabber.org/protocol/httpbind\' type=\'terminate\'/>');
        else
@@ -159,10 +159,10 @@ if($method == 'POST') {
 if($method == 'GET') {
        // JSON header
        header('Content-type: application/json');
-       
+
        // Encode output to JSON
        $json_output = json_encode($output);
-       
+
        if(($output == false) || ($output == '') || ($json_output == 'null'))
                echo($callback.'({"reply":"<body xmlns=\'http:\/\/jabber.org\/protocol\/httpbind\' type=\'terminate\'\/>"});');
        else