-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmvg.php
More file actions
35 lines (30 loc) · 833 Bytes
/
Copy pathmvg.php
File metadata and controls
35 lines (30 loc) · 833 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
<?php
if (!isset($_GET['urlToOpen'])) {
http_response_code(400);
echo json_encode(["error" => "Missing URL"]);
exit;
}
$url = filter_var($_GET['urlToOpen'], FILTER_SANITIZE_URL);
if (!filter_var($url, FILTER_VALIDATE_URL)) {
http_response_code(400);
echo json_encode(["error" => "Invalid URL"]);
exit;
}
// API-Call
// You can replace `MyCustomPHPProxy` with your own name for the User Agent
$options = [
"http" => [
"header" => "User-Agent: MyCustomPHPProxy\r\n",
"timeout" => 10
]
];
$context = stream_context_create($options);
$response = @file_get_contents($url, false, $context);
if ($response === FALSE) {
http_response_code(500);
echo json_encode(["error" => "Failed to fetch data"]);
} else {
header("Content-Type: application/json");
echo $response;
}
?>