]> git.sven.stormbind.net Git - sven/scripts.git/blob - bposearch/search.php
Ignore timeouts on the envertech portal
[sven/scripts.git] / bposearch / search.php
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
3 <head>
4   <title>bpo package search</title>
5 </head>
6 <body>
7 <?php
8
9 /**************************************/
10 //function block
11
12
13 function sendtheform () {
14   echo "<form action=\"search.php\" method=\"POST\">\n";
15   echo "<H1>bpo package search</H1>\n";
16   echo "<input type=\"text\" name=\"query\" size=\"40\" maxlength=\"40\">\n";
17   echo "<td valign=\"top\"><input type=\"submit\" name=\"send\" value=\"send\"></td>\n";
18   echo "</form>\n";
19 }
20
21
22 function performsearch () {
23   $query = $_POST["query"]; 
24   echo "<p>";
25    echo "Server performed a query with the keyword \"$query\"<br>";
26    echo "</p>"; 
27
28    $parts = array("main","contrib","non-free");
29    foreach ($parts as $value) {
30
31    echo "<h1>Results for packages listed in $value:</h1>\n";
32
33     $sourcesfile = file_get_contents("$value/Sources");
34     $sourcesarray = explode("\n", $sourcesfile);
35
36     for ($i = 0; $i < count($sourcesarray); $i++) {
37         if (eregi("^Package:.*$query.*", $sourcesarray[$i])) {
38                      $pver=findnextver($i, $sourcesarray);
39                      $pdir=findnextdir($i, $sourcesarray);
40                      echo "<p>\n";
41                      echo "$sourcesarray[$i]<br>\n";
42                      echo "$pver<br>\n";
43                      echo "<a href=\"http://www.backports.org/debian/$pdir\">http://www.backports.org/debian/$pdir/</a><br>\n";
44                      echo "</p>\n";
45         }
46     }
47    }
48 }
49
50 function findnextver ($startpos, $sourcesarray) {
51    for ($i = $startpos; $i < count($sourcesarray); $i++) {
52         if (eregi("^Version:.*", $sourcesarray[$i])) {
53                 return $sourcesarray[$i];
54         }
55    }
56 }
57
58 function findnextdir ($startpos, $sourcesarray) {
59    for ($i = $startpos; $i < count($sourcesarray); $i++) {
60         if (eregi("^Directory:.*", $sourcesarray[$i])) {
61                 $dirsplit = explode(" ", $sourcesarray[$i]);
62                 return $dirsplit[1]; 
63         }
64    }         
65 }
66
67
68 //function block end
69 /*********************************************/
70
71 //check if someone has hit the send button
72 if ($_POST["send"] == "send") {
73   $invalidquery = "0";
74
75   //check if the query field is empty
76   if (empty($_POST['query'])) {
77         $invalidquery = "1";
78   }
79
80   //check if we've a reason to believe the query is invalid
81   if ($invalidquery == "0") {
82     performsearch();
83   } else {
84     sendtheerror($invalidreason);
85   }
86
87 } else {
88 //nothing send to us so print the search form
89 sendtheform();
90 }
91 ?>
92
93 </body>
94 </html>