-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquery-proxy.php
More file actions
27 lines (20 loc) · 873 Bytes
/
query-proxy.php
File metadata and controls
27 lines (20 loc) · 873 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
<?php
/**
* Proxy Requests via the origin because CORS
*
* $referrer is so they can track who is making the queries
*/
$config = file_get_contents("config.js");
preg_match_all('/\{.*\}/sm', $config, $json);
$base = json_decode( $json[0][0] )->datastore_search_sql;
$referrer = hash("md5",implode("",array($_SERVER['REQUEST_SCHEME']."://", $_SERVER['HTTP_HOST'], $_SERVER['SCRIPT_NAME'])));
$ch = curl_init($base.rawurlencode($_GET['sql'])."&referrer=$referrer");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, false);
$result = curl_exec($ch);
$responseInfo = curl_getinfo ( $ch );
curl_close($ch);
http_response_code($responseInfo['http_code']);
header(sprintf('contet-type: %s', $responseInfo['content_type']));
header(sprintf('contet-length: %s', $responseInfo['download_content_length']));
echo $result;