1 | <?php |
---|
2 | // A simple proxy for testing the OpenSearchStore |
---|
3 | // Note, this simple proxy requires a curl-enabled PHP install |
---|
4 | if(!$_GET['url']){ return; } |
---|
5 | |
---|
6 | $url = str_replace(array(';;;;', '%%%%'), array('?', '&'), $_GET['url']); |
---|
7 | if(stripos($url, "http://intertwingly.net/") === 0 || |
---|
8 | stripos($url, "http://www.intertwingly.net/") === 0 || |
---|
9 | stripos($url, "http://www.shutterpoint.com/") === 0 || |
---|
10 | stripos($url, "http://technorati.com/") === 0){ |
---|
11 | $ch = curl_init($url); |
---|
12 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
---|
13 | $results = curl_exec($ch); |
---|
14 | header('HTTP/1.1 ' . curl_getinfo($ch, CURLINFO_HTTP_CODE) . ' OK'); |
---|
15 | if($_GET['osd'] === 'true'){ |
---|
16 | $xml = new SimpleXMLElement($results); |
---|
17 | if($xml->Url){ |
---|
18 | foreach($xml->Url as $url){ |
---|
19 | $url['template'] = $_SERVER['SCRIPT_NAME'].'?url='.str_replace(array('?', '&'), array(';;;;', '%%%%'), $url['template']); |
---|
20 | } |
---|
21 | header('Content-Type: text/xml'); |
---|
22 | print $xml->asXML(); |
---|
23 | } |
---|
24 | }else{ |
---|
25 | header('Content-Type: '.curl_getinfo($ch, CURLINFO_CONTENT_TYPE)); |
---|
26 | print $results; |
---|
27 | } |
---|
28 | }else{ |
---|
29 | header("HTTP/1.0 403 Forbidden"); |
---|
30 | header("Status: 403 Forbidden"); |
---|
31 | print "Provided URL not allowed by this demo proxy."; |
---|
32 | } |
---|
33 | |
---|