forked from volpino/wikipedia-timeline
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproxy.php
More file actions
35 lines (28 loc) · 748 Bytes
/
proxy.php
File metadata and controls
35 lines (28 loc) · 748 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
// Set your return content type
#header('Content-type: application/xml');
ini_set('user_agent', 'Sonet-lab');
//allowed hosts
$allowed = array("wikipedia.org", "toolserver.org", "wikimedia.org");
if (!isset($_GET["url"]))
die();
// Website url to open
$daurl = $_GET["url"];
$tmp = explode(".", parse_url($daurl, PHP_URL_HOST));
if (!in_array($tmp[count($tmp)-2].".".$tmp[count($tmp)-1], $allowed))
die();
// Get that website's content
$content = file_get_contents($daurl);
// serve it!
if (!(strpos($http_response_header[0], "200"))) {
if (strpos($http_response_header[0], "404")) {
echo "No results found!";
}
else {
echo "Error: ".$http_response_header[0];
}
}
else {
echo $content;
}
?>