summaryrefslogtreecommitdiffstats
path: root/examples/ajax-broker/ajax.php
diff options
context:
space:
mode:
Diffstat (limited to 'examples/ajax-broker/ajax.php')
-rw-r--r--examples/ajax-broker/ajax.php42
1 files changed, 0 insertions, 42 deletions
diff --git a/examples/ajax-broker/ajax.php b/examples/ajax-broker/ajax.php
deleted file mode 100644
index 26953e3..0000000
--- a/examples/ajax-broker/ajax.php
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-
-session_save_path(__DIR__ .'/../../broker-sessions');
-require_once $_SERVER['DOCUMENT_ROOT'] . '/src/Broker.php';
-
-$command = $_REQUEST['command'];
-$broker = new Jasny\SSO\Broker('http://127.0.0.1:9000/examples/server/', 'BrokerApi', 'BrokerApi');
-
-if (!empty($_REQUEST['token'])) $broker->token = $_REQUEST['token'];
-
-if (empty($_REQUEST['command'])) {
- header("Content-Type: application/json");
- header("HTTP/1.1 406 Not Acceptable");
- echo json_encode(['error' => 'Command not specified']);
- exit();
-} elseif (realpath($_SERVER["SCRIPT_FILENAME"]) == realpath(__FILE__)) {
- error_log('executing: '. $_REQUEST['command']);
-
- try {
- $result = $broker->$_REQUEST['command']();
- header("Content-Type: application/json");
- error_log('result: ' . json_encode($result));
- echo json_encode($result);
- } catch (Exception $ex) {
- $errorCode = $ex->getCode();
- error_log('error code' . $errorCode);
-
- header("Content-Type: application/json");
- if ($errorCode == 401) header("HTTP/1.1 401 Unauthorized");
- if ($errorCode == 406) header("HTTP/1.1 406 Not Acceptable");
-
- echo json_encode(['error' => $ex->getMessage()]);
- exit();
- }
-} else {
- error_log('nothing to execute');
-
- header("Content-Type: application/json");
- header("HTTP/1.1 406 Not Acceptable");
- echo json_encode(['error' => 'Command not supported']);
- exit();
-}