-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathproxy.php
More file actions
51 lines (39 loc) · 1.36 KB
/
proxy.php
File metadata and controls
51 lines (39 loc) · 1.36 KB
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
43
44
45
46
47
48
49
50
51
<?php
/**
* This is a proxy PHP scripts which takes the request from the user and forwards
* it to our server, where the PHP code is executed.
*
* This proxy script is required when the browser does not support cross domain requests
* or when your website is using https.
*
* @author Nils Reimers, www.php-einfach.de
*/
$url = 'http://execute.php-einfach.de:9999/execute.php?'.$_SERVER['QUERY_STRING'];
$send_cookies = false;
$send_session = false;
$ch = curl_init( $url );
if (isset($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'post' ) {
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $_POST );
}
if ( $send_cookies ) {
$cookie = array();
foreach ( $_COOKIE as $key => $value ) {
$cookie[] = $key . '=' . $value;
}
if ( $send_session ) {
$cookie[] = SID;
}
$cookie = implode( '; ', $cookie );
curl_setopt( $ch, CURLOPT_COOKIE, $cookie );
}
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
// curl_setopt( $ch, CURLOPT_HEADER, true );
curl_setopt( $ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] );
$contents = curl_exec( $ch );
// list( $header, $contents ) = preg_split( '/([\n][\n])\\1/', curl_exec( $ch ), 2 );
// $status = curl_getinfo( $ch );
curl_close( $ch );
print($contents);
?>