File: darkproxy.php

package info (click to toggle)
darkstat 3.0.715-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 816 kB
  • sloc: ansic: 6,542; sh: 355; makefile: 172; php: 15
file content (30 lines) | stat: -rw-r--r-- 907 bytes parent folder | download | duplicates (6)
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
<?php
# copyright (c) 2011 Malte S. Stretz
#
# This is a simple proxy script to test the proper implementation of
# relative hrefs in combination with eg. lighttpd 1.4 which doesn't
# support the features of mod_proxy_core yet.
#
# You may use, modify and redistribute this file under the terms of the
# GNU General Public License version 2. (see COPYING.GPL)
# Feel free to relicense this code under any Open Source License
# approved by the Open Source Initiative.

$darkstat = "http://localhost:667";

if ($_SERVER['PATH_INFO'] == '') {
  header("Status: 303 Move!", true);
  header("Location: " . $_SERVER['PHP_SELF'] . "/", true);
  exit;
}

function header_cb($proxy, $h) {
  header($h);
  return strlen($h);
}

$proxy = curl_init();
curl_setopt($proxy, CURLOPT_URL, $darkstat . $_SERVER['PATH_INFO']);
curl_setopt($proxy, CURLOPT_HEADERFUNCTION, 'header_cb'); 
curl_exec($proxy);
curl_close($proxy);