portdb: added d/l of collection file

This commit is contained in:
Simone Rota 2006-10-16 14:04:36 +02:00
parent 7cb3a602b1
commit c64a840e64

View File

@ -64,7 +64,7 @@ function showCollections() {
echo '<tr class="'.$cl.'">
<td><a href="?a=repo&q='.$repo['collname'].'">'.$repo['collname'].'</a></td>
<td>'.$repo['tot'].'</td>
<td>'.$repo['colltype'].'</td>
<td><a href="?a=getup&q='.$repo['collname'].'">'.$repo['colltype'].'</a></td>
<td>'.nospam($repo['maintainer']).'</td>';
if ($repo['colltype'] == "httpup") {
echo '<td><a href="'.$repo['url'].'">'.$repo['url'].'</a></td></tr>';
@ -91,7 +91,7 @@ function showSearch($singlerepo) {
</form>';
} else {
if ($singlerepo) {
echo "<h2>Ports in repository '$query'</h2>";
echo "<h2>Ports in repository '$query'".' (<a href="?a=getup&q='.$query.'">get httpup/rsync</a>)'."</h2>";
$sql = "select * from ports join collections on collection=collname
where collection = ? order by portname";
} else {
@ -226,14 +226,44 @@ function sendMail($name, $url, $mail, $maint) {
return $mail_obj->send($admin, $headers, $msg);
}
printHeader();
printNav();
function getUp() {
global $db;
$query = sanitize($_GET['q']);
$sql = "select * from collections where collname=?";
$sth = $db->prepare($sql);
$res = $db->execute($sth, array($query));
if (DB::isError($res)) die("Query error");
if ($res->numRows() != 1)
die("Error generating the file");
$coll =& $res->fetchRow();
header('Content-type: text/plain');
header('Content-Disposition: attachment; filename="'.$coll['collname'].".".$coll['colltype'].'"');
echo "# Collection ".$coll['collname'].", by ".$coll['maintainer']."\n";
echo "# File generated by the CRUX portdb http://crux.nu/portdb/"."\n\n";
if ($coll['colltype'] == "httpup") {
echo "ROOT_DIR=/usr/ports/" . $coll['collname']."\n";
echo "URL=" . $coll['url']."\n";
} else {
$ar = explode('::', $coll['url']);
echo "host=" . $ar[0]."\n";
echo "collection=" . $ar[1]."\n";
echo "destination=/usr/ports/" . $coll['collname']."\n";
}
}
$db =& DB::connect($dsn);
if (DB::isError($dbc)) die("Cannot connect to database");
$db->setFetchMode(DB_FETCHMODE_ASSOC);
$action = sanitize($_GET['a']);
if ($action == "getup") {
getUp();
exit(0);
}
printHeader();
printNav();
switch ($action) {
case "index":
showCollections();