$xsl = "xsl/bpo-rss.xsl";
$pfile = "debian/dists/woody/all/source/Sources.gz";
$matches = 0;
$allmatch = 0;
global $arch, $matches, $allmatch, $pkg, $version;
$_GET['search'] = preg_replace("/\?/", "\?", $_GET['search']);
$_GET['search'] = preg_replace("/\*/", "\*", $_GET['search']);
$_GET['search'] = preg_replace("/\+/", "\+", $_GET['search']);
if ($_GET['search']) {
$xml = "You searched for " . $_GET['search'] ."";
$fd = popen("gzip -dc $pfile 2>&1", "r");
while (!feof($fd)) {
$buffer = fgets($fd, 4096);
if (preg_match("/^Binary: (.*)$/", $buffer, $match)) {
$binary = $match[1];
if (preg_match("/".$_GET['search']."/", $binary)) {
$matches = 1;
$allmatch ++;
$pkg = $binary;
} else {
$matches = 0;
}
} elseif (preg_match("/^Package: (.*)$/", $buffer, $match)) {
$package = $match[1];
} elseif (preg_match("/^Version: (.*)$/", $buffer, $match)) {
$version = $match[1];
} elseif (preg_match("/^Architecture: (.*)$/", $buffer, $match)) {
$arch = $match[1];
} else {
if ($matches) {
$xml .= "Packages: $pkg
".
"Source Package: $package
".
"Version: $version
".
"Architecture: $arch
".
" deb http://www.backports.org/debian/ woody $package
".
"";
$matches = 0;
}
}
}
if ($allmatch >> 1) {
$xml .= "
Found $allmatch Packages.";
} elseif ($allmatch == 1) {
$xml .= "Found $allmatch Package.";
} elseif ($allmatch == 0) {
$xml .= "Sorry, no packages found.";
}
} else {
$xml = "This is an completely invalid query-format. No donut for you. ".
"Just go back to ".
"backports and thou may find what thou are seeking for.";
}
$outxml = "\nBackports.org - SearchSearch". $xml ."";
$xslfd=fopen($xsl, "r");
$inxsl = fread( $xslfd, filesize($xsl));
//print "$inxsl
$outxml";
fclose($xslfd);
$arguments = array(
'/_xml' => $outxml,
'/_xsl' => $inxsl
);
$xh = xslt_create();
xslt_set_encoding( $xh, "UTF-8");
print xslt_process( $xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments);
?>