diff --git a/portdb/portdb/index.php b/portdb/portdb/index.php index 21fc20a..e25ac26 100755 --- a/portdb/portdb/index.php +++ b/portdb/portdb/index.php @@ -64,7 +64,7 @@ function showCollections() { echo ' '.$repo['collname'].' '.$repo['tot'].' - '.$repo['colltype'].' + '.$repo['colltype'].' '.nospam($repo['maintainer']).''; if ($repo['colltype'] == "httpup") { echo ''.$repo['url'].''; @@ -91,7 +91,7 @@ function showSearch($singlerepo) { '; } else { if ($singlerepo) { - echo "

Ports in repository '$query'

"; + echo "

Ports in repository '$query'".' (get httpup/rsync)'."

"; $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();