Pull in darkstat-3.0.718
[darkstat-debian] / contrib / darkproxy.php
1 <?php
2 # copyright (c) 2011 Malte S. Stretz
3 #
4 # This is a simple proxy script to test the proper implementation of
5 # relative hrefs in combination with eg. lighttpd 1.4 which doesn't
6 # support the features of mod_proxy_core yet.
7 #
8 # You may use, modify and redistribute this file under the terms of the
9 # GNU General Public License version 2. (see COPYING.GPL)
10 # Feel free to relicense this code under any Open Source License
11 # approved by the Open Source Initiative.
12
13 $darkstat = "http://localhost:667";
14
15 if ($_SERVER['PATH_INFO'] == '') {
16 header("Status: 303 Move!", true);
17 header("Location: " . $_SERVER['PHP_SELF'] . "/", true);
18 exit;
19 }
20
21 function header_cb($proxy, $h) {
22 header($h);
23 return strlen($h);
24 }
25
26 $proxy = curl_init();
27 curl_setopt($proxy, CURLOPT_URL, $darkstat . $_SERVER['PATH_INFO']);
28 curl_setopt($proxy, CURLOPT_HEADERFUNCTION, 'header_cb');
29 curl_exec($proxy);
30 curl_close($proxy);