-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathproxy.php
More file actions
37 lines (30 loc) · 718 Bytes
/
Copy pathproxy.php
File metadata and controls
37 lines (30 loc) · 718 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
32
33
34
35
36
37
<?php
// This application is meant to be run locally and should not be made publicly accessible.
if (!in_array($_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1', '::ffff:127.0.0.1'))) die();
if (!isset($_GET['url'])) {
die();
}
$url = urldecode($_GET['url']);
if (strpos($url, '/..') !== false) {
header('HTTP/1.0 403 Forbidden');
die();
}
if (
strpos($url, 'http://', 0) !== 0 &&
strpos($url, 'https://', 0) !== 0 &&
strpos($url, './samples/', 0) !== 0
) {
die();
}
$content = @file_get_contents($url, false, stream_context_create([
'http' => [
'header' => [
'user-agent: Run-PHP-Code',
],
],
]));
if ($content === false) {
echo 'Import failed.';
} else {
echo $content;
}