-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.php
More file actions
31 lines (28 loc) · 777 Bytes
/
Copy pathapi.php
File metadata and controls
31 lines (28 loc) · 777 Bytes
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
<?php
// set response header to be JSON type
// with character set UTF-8
header('Content-Type: application/json; charset=UTF-8');
$xhr = isset($_SERVER['HTTP_X_REQUESTED_WITH']) ? strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) : null;
//var_dump($xhr) ;die();
if ($xhr === 'xmlhttprequest')
{
// param uri passed by .htaccess
$uri = isset($_GET['uri']) ? $_GET['uri'] : '';
// if uri exists
if ($uri)
{
include __DIR__ .'/autoload.php';
$cp = new ProjectApp\ContextProcessor();
$cp->process($uri);
echo json_encode($cp->getOutputAsArray());
}
else
{
echo json_encode(array('error'=>'Illegal request!!!!!'));
}
}
else
{
echo json_encode(array('error'=>'Illegal request '));
// echo "hello";
}