-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdebuggateway.php
42 lines (36 loc) · 1.55 KB
/
debuggateway.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/*
* The debug gateway is a simple gateway that calls the real gateway and then checks if
* the outgoing message is correctly formatted. If not, it wraps the message into a correctly
* formatted message, so that even fatal errors are caught. It is highly recommended
* the the real gateway be called directly for production use.
*
* This gateway requires CURL to work properly
*/
//Guess gateway location (you may change this manually)
$path = str_replace('//','/',str_replace("%2F","/",str_replace('%5C', '/', rawurlencode (dirname($_SERVER['PHP_SELF'])))));
$gatewayUrl = 'http://' . $_SERVER['HTTP_HOST'] . $path . '/gateway.php';
$gatewayUrl = str_replace('//gateway', '/gateway', $gatewayUrl);
$sessionName = ini_get('session.name');
if(isset($_GET[$sessionName]))
{
//Add session id
$gatewayUrl .= '?' . $sessionName . '=' . $_GET[$sessionName];
}
$data = $GLOBALS['HTTP_RAW_POST_DATA'];
define('AMFPHP_BASE', realpath(dirname(__FILE__)) . "/amf-core/");
define('AMFPHP_CLIENT_BASE', realpath(dirname(__FILE__)) . "/browser/client/");
include_once(AMFPHP_CLIENT_BASE . 'AMFClient.php');
$client = new AMFClient($gatewayUrl);
$result = $client->doRequest($data);
if($data == NULL || $data == "")
{
echo "<p>cURL and the debug gateway are installed correctly. You may now connect to the debug gateway from Flash.</p><p><a href='http://www.amfphp.org/docs'>View the amfphp documentation</p>";
die();
}
if($result === FALSE)
{
$result = $client->sendError($data, $client->getLastError());
}
$client->send($result);
?>