]> git.deb.at Git - deb/packages.git/blob - cgi-bin/index.php
Introduce php wrapper for those hosts that don't have perl enabled
[deb/packages.git] / cgi-bin / index.php
1 <?
2
3 function go($script)
4 {
5         $pipes = null;
6         $proc = proc_open("./$script php", array(
7                 0 => array('pipe', 'r'),
8                 1 => array('pipe', 'w'),
9                 2 => array('pipe', 'w')
10                 ), $pipes);
11         foreach ($_GET as $k => $v) {
12                 fwrite($pipes[0], urlencode($k)."=".urlencode($v)."\n");
13         }
14         fclose($pipes[0]);
15         fpassthru($pipes[1]);
16         $stderr = fread($pipes[2], 4096);
17         $exit = proc_close($proc);
18         if ($exit) {
19                 echo "<h1>Error happened, code $exit</h1>\n";
20         }
21         echo "<pre>".htmlspecialchars($stderr);
22         echo "</pre>";
23 }
24 $pi = substr($_SERVER["PATH_INFO"], 1);
25 if ($pi == '') {
26         readfile("index.html");
27         exit;
28 } elseif ($pi == 'search') {
29         go("search_packages.pl");
30 } elseif (substr($pi, 0, 8) == 'package/') {
31         $_GET['searchon'] = 'names';
32         $_GET['keywords'] = substr($pi, 8);
33         $_GET['suite'] = 'all';
34         $_GET['exact'] = 1;
35         go("search_packages.pl");
36 } elseif (substr($pi, 0, 4) == 'src:') {
37         header("Location: http://merkel.debian.org/~jeroen/pdo/source/".urlencode(substr($pi,4)));
38 } elseif (!eregi('[^a-z0-9+.-]', $pi)) {
39         header("Location: http://merkel.debian.org/~jeroen/pdo/package/".urlencode($pi));
40         exit;
41 } else {
42         echo "404 not found";
43 }