-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathup.php
More file actions
61 lines (42 loc) · 1.54 KB
/
up.php
File metadata and controls
61 lines (42 loc) · 1.54 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
52
53
54
55
56
57
58
59
60
61
<?php
define('HOSTNAME', 'http://localhost:8123/up/');
session_start();
// Change these configuration options if needed, see above descriptions for info.
$enable_jsonp = false;
$enable_native = false;
$valid_url_regex = '/.*/';
// ############################################################################
$path = $_GET['path'];
$url = HOSTNAME . $path;
$ch = curl_init($url);
$client_headers = array();
$client_headers[] = 'X-Forwarded-For: ' . $_SERVER['REMOTE_ADDR'];
curl_setopt($ch, CURLOPT_HTTPHEADER, $client_headers);
if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
$postText = trim(file_get_contents('php://input'));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postText);
}
$cookie = array();
foreach ($_COOKIE as $key => $value) {
$cookie[] = $key . '=' . $value;
}
$cookie[] = SID;
$cookie = implode('; ', $cookie);
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
//curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
list($header, $contents) = preg_split('/([\r\n][\r\n])\\1/', curl_exec($ch), 2);
$status = curl_getinfo($ch);
curl_close($ch);
// Split header text into an array.
$header_text = preg_split('/[\r\n]+/', $header);
// Propagate headers to response.
foreach ($header_text as $header) {
if (preg_match('/^(?:Content-Type|Content-Language|Set-Cookie):/i', $header)) {
header($header);
}
}
print $contents;