-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathajax_proxy.php
More file actions
30 lines (24 loc) · 1018 Bytes
/
ajax_proxy.php
File metadata and controls
30 lines (24 loc) · 1018 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
<?php
if (isset($_POST['submit_action_url']) && isset($_POST['rnd']) &&
($url = $_POST['submit_action_url'])) {
// Composing GET-request from POST...
$data = '';
foreach ($_POST as $key => $val)
if ($key && ($key != 'submit_action_url') && $val)
$data.= "&$key=".urlencode($val); // we could also URLEncode $key, but it's anyway impossible for key to have spaces.
$url.= '?'.ltrim($data, '&'); // $url is prepared.
// we can also proxy UserAgent, AcceptTypes etc, if it will be required one day...
$data = @file_get_contents($url);
// pass http codes we got from remote server, as is...
if ($http_response_header)
foreach ($http_response_header as $a)
if ($a) {
header($a);
/* This is how to generate HTTP status code only...
$a = explode(':', $a, 2);
if (!isset($a[1]) && preg_match('/HTTP\/[0-9\.]+\s+([0-9]+)/', $a[0], $a))
http_response_code((int)$a[1]); // pass HTTP code we got to
*/
}
print $data;
}