X-Git-Url: https://git.mxchange.org/?p=friendica-addons.git;a=blobdiff_plain;f=jappixmini%2Fproxy.php;fp=jappixmini%2Fproxy.php;h=c4e3a03ca2f7bea462dc7da7e12fdbebac33b684;hp=a9f6db44611f6076eed4e982c9e74675decaf8e2;hb=dbe8118e406510d85404d9577f83d68782cfe2a0;hpb=39dd3dffe07efd69fa1ac6d0bd243c7fc0e3a66f diff --git a/jappixmini/proxy.php b/jappixmini/proxy.php index a9f6db44..c4e3a03c 100644 --- a/jappixmini/proxy.php +++ b/jappixmini/proxy.php @@ -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(''); 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":""});'); else