source: Dev/branches/rest-dojo-ui/client/dojox/data/demos/openSearchProxy.php @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

  • Property svn:executable set to *
File size: 1.1 KB
Line 
1<?php
2// A simple proxy for testing the OpenSearchStore
3// Note, this simple proxy requires a curl-enabled PHP install
4if(!$_GET['url']){ return; }
5
6$url = str_replace(array(';;;;', '%%%%'), array('?', '&'), $_GET['url']);
7if(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
Note: See TracBrowser for help on using the repository browser.