diff options
author | Simone Rota <sip@crux.nu> | 2006-10-16 14:04:36 +0200 |
---|---|---|
committer | Simone Rota <sip@crux.nu> | 2006-10-16 14:04:36 +0200 |
commit | c64a840e6459a94542ee663685c194a02fe70ba3 (patch) | |
tree | 8c08d39dfa20a9021fe4d763d538a58dd45260ba | |
parent | 7cb3a602b1620de6a48360edb43cd20deebd9d14 (diff) | |
download | webtools-c64a840e6459a94542ee663685c194a02fe70ba3.tar.gz webtools-c64a840e6459a94542ee663685c194a02fe70ba3.tar.xz |
portdb: added d/l of collection file
-rwxr-xr-x | portdb/portdb/index.php | 38 |
1 files changed, 34 insertions, 4 deletions
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 '<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(); |