\n"; echo "

bpo package search

\n"; echo "\n"; echo "\n"; echo "\n"; } function performsearch () { $query = $_POST["query"]; echo "

"; echo "Server performed a query with the keyword \"$query\"
"; echo "

"; $parts = array("main","contrib","non-free"); foreach ($parts as $value) { echo "

Results for packages listed in $value:

\n"; $sourcesfile = file_get_contents("$value/Sources"); $sourcesarray = explode("\n", $sourcesfile); for ($i = 0; $i < count($sourcesarray); $i++) { if (eregi("^Package:.*$query.*", $sourcesarray[$i])) { $pver=findnextver($i, $sourcesarray); $pdir=findnextdir($i, $sourcesarray); echo "

\n"; echo "$sourcesarray[$i]
\n"; echo "$pver
\n"; echo "http://www.backports.org/debian/$pdir/
\n"; echo "

\n"; } } } } function findnextver ($startpos, $sourcesarray) { for ($i = $startpos; $i < count($sourcesarray); $i++) { if (eregi("^Version:.*", $sourcesarray[$i])) { return $sourcesarray[$i]; } } } function findnextdir ($startpos, $sourcesarray) { for ($i = $startpos; $i < count($sourcesarray); $i++) { if (eregi("^Directory:.*", $sourcesarray[$i])) { $dirsplit = explode(" ", $sourcesarray[$i]); return $dirsplit[1]; } } } //function block end /*********************************************/ //check if someone has hit the send button if ($_POST["send"] == "send") { $invalidquery = "0"; //check if the query field is empty if (empty($_POST['query'])) { $invalidquery = "1"; } //check if we've a reason to believe the query is invalid if ($invalidquery == "0") { performsearch(); } else { sendtheerror($invalidreason); } } else { //nothing send to us so print the search form sendtheform(); } ?>