-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproxy.php
More file actions
43 lines (33 loc) · 745 Bytes
/
proxy.php
File metadata and controls
43 lines (33 loc) · 745 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
38
39
40
41
42
43
<?php
// Get the input param
$url = 0;
if(isset($_GET['url'])) {
$url = $_GET['url'];
} elseif(isset($_POST['url'])) {
$url = $_POST['url'];
}
// return if no valid URL
if(!$url) {
echo "Please provide a valid URL";
return;
}
// Defining the default curl options
$defaults = array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => TRUE
);
// Open the curl session
$session = curl_init();
// Intialize
curl_setopt_array($session, $defaults);
// Make the call
$resp = curl_exec($session);
// Honor the content type header
$headers = curl_getinfo($session);
if(isset($headers['content_type'])) {
header("Content-Type: ".$headers['content_type']);
}
// Close the connection
curl_close($session);
echo $resp;
?>