X-Git-Url: https://git.sven.stormbind.net/?a=blobdiff_plain;f=bposearch%2Fsearch.php;fp=bposearch%2Fsearch.php;h=efc07b572649da18036617ef28ecacc3472a4d4d;hb=8a4b76f8e7c04607b3dc3155d4b98007c946d74e;hp=0000000000000000000000000000000000000000;hpb=8e9fb924b34bb14a0ce4475b03853d4b526abc33;p=sven%2Fscripts.git
diff --git a/bposearch/search.php b/bposearch/search.php
new file mode 100644
index 0000000..efc07b5
--- /dev/null
+++ b/bposearch/search.php
@@ -0,0 +1,94 @@
+
+
+
+ bpo package search
+
+
+\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();
+}
+?>
+
+
+