1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <title>bpo package search</title>
9 /**************************************/
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";
22 function performsearch () {
23 $query = $_POST["query"];
25 echo "Server performed a query with the keyword \"$query\"<br>";
28 $parts = array("main","contrib","non-free");
29 foreach ($parts as $value) {
31 echo "<h1>Results for packages listed in $value:</h1>\n";
33 $sourcesfile = file_get_contents("$value/Sources");
34 $sourcesarray = explode("\n", $sourcesfile);
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);
41 echo "$sourcesarray[$i]<br>\n";
43 echo "<a href=\"http://www.backports.org/debian/$pdir\">http://www.backports.org/debian/$pdir/</a><br>\n";
50 function findnextver ($startpos, $sourcesarray) {
51 for ($i = $startpos; $i < count($sourcesarray); $i++) {
52 if (eregi("^Version:.*", $sourcesarray[$i])) {
53 return $sourcesarray[$i];
58 function findnextdir ($startpos, $sourcesarray) {
59 for ($i = $startpos; $i < count($sourcesarray); $i++) {
60 if (eregi("^Directory:.*", $sourcesarray[$i])) {
61 $dirsplit = explode(" ", $sourcesarray[$i]);
69 /*********************************************/
71 //check if someone has hit the send button
72 if ($_POST["send"] == "send") {
75 //check if the query field is empty
76 if (empty($_POST['query'])) {
80 //check if we've a reason to believe the query is invalid
81 if ($invalidquery == "0") {
84 sendtheerror($invalidreason);
88 //nothing send to us so print the search form