header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type');
header('Access-Control-Max-Age: 31536000');
-
+
exit;
}
// CORS headers
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Content-Type');
-
+
$method = 'POST';
}
}
// 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'))
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);
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);
}
// Built-in stream functions
else {
// HTTP parameters
- $parameters = array('http' => array(
+ $parameters = ['http' => [
'method' => 'POST',
'content' => $data
- )
- );
+ ]
+ ];
$parameters['http']['header'] = $headers;
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
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