]> git.deb.at Git - deb/packages.git/blob - cgi-bin/index.php
ttxgettext: Handle UTF-8 input
[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
25 $SUITES = array('oldstable', 'stable', 'testing', 'unstable', 'experimental');
26 $pi = substr($_SERVER["PATH_INFO"], 1);
27 $elems = explode('/', $pi);
28 if ($pi == "") {
29         readfile("index.html");
30         exit;
31 } elseif ($pi == 'search') {
32         go("search_packages.pl");
33 } elseif ($elems[0] == 'package' && count($elems) == 2) {
34         $_GET['searchon'] = 'names';
35         $_GET['keywords'] = $elems[1];
36         $_GET['suite'] = 'all';
37         $_GET['exact'] = 1;
38         go("search_packages.pl");
39 } elseif ($elems[0] == 'source' && count($elems) == 2) {
40         $_GET['searchon'] = 'sourcenames';
41         $_GET['keywords'] = $elems[1];
42         $_GET['suite'] = 'all';
43         $_GET['exact'] = 1;
44         go("search_packages.pl");
45 } elseif (in_array($elems[0], $SUITES) && count($elems) == 2) {
46         $_GET['package'] = $elems[1];
47         $_GET['suite'] = $elems[0];
48         go("show_package.pl");
49 } elseif (in_array($elems[0], $SUITES) && count($elems) == 3) {
50         header("Location: http://merkel.debian.org/~jeroen/pdo/$elems[0]/".urlencode($elems[2]));
51         exit;
52 } elseif (substr($pi, 0, 4) == 'src:') {
53         header("Location: http://merkel.debian.org/~jeroen/pdo/source/".urlencode(substr($pi,4)));
54         exit;
55 } elseif (!eregi('[^a-z0-9+.-]', $pi)) {
56         header("Location: http://merkel.debian.org/~jeroen/pdo/package/".urlencode($pi));
57         exit;
58 } else {
59         echo "404 not found";
60 }