cvs: pearweb /include pear-database.php /public_html get
| From: | Stig Bakken | Date: | Tue, 02 Apr 2002 13:38:21 +0000 |
| Subject: | cvs: pearweb /include pear-database.php /public_html get | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-2990@lists.php.net to get a copy of this message | ||
ssb Tue Apr 2 08:38:21 2002 EDT
Modified files:
/pearweb/include pear-database.php
/pearweb/public_html get
Log:
* support http://pear.php.net/get/Package-version.tar
(no need to have
uncompressed packages, release::HTTPdownload uncompresses on the fly)
Index: pearweb/include/pear-database.php
diff -u pearweb/include/pear-database.php:1.66 pearweb/include/pear-database.php:1.67
--- pearweb/include/pear-database.php:1.66 Tue Apr 2 07:26:06 2002
+++ pearweb/include/pear-database.php Tue Apr 2 08:38:20 2002
@@ -17,7 +17,7 @@
| Tomas V.V.Cox <cox@php.net> |
| Martin Jansen <mj@php.net> |
+----------------------------------------------------------------------+
- $Id: pear-database.php,v 1.66 2002/04/02 12:26:06 ssb Exp $
+ $Id: pear-database.php,v 1.67 2002/04/02 13:38:20 ssb Exp $
*/
require_once "DB/storage.php";
@@ -598,10 +598,10 @@
}
// }}}
- // {{{ NOEXPORT release::HTTPdownload(string, [string], [string])
+ // {{{ NOEXPORT release::HTTPdownload(string, [string], [string], [bool])
// not for xmlrpc export
- function HTTPdownload($package, $version = null, $file = null)
+ function HTTPdownload($package, $version = null, $file = null, $uncompress = false)
{
global $dbh;
$package_id = package::info($package, 'packageid');
@@ -613,8 +613,13 @@
}
if ($file !== null) {
+ if (substr($file, -4) == '.tar') {
+ $file = substr($file, 0, -4) . '.tgz';
+ $uncompress = true;
+ }
$row = $dbh->getRow("SELECT fullpath, release, id FROM files ".
- "WHERE basename = '" . $file . "'",
DB_FETCHMODE_ASSOC);
+ "WHERE basename = ?", array($file),
+ DB_FETCHMODE_ASSOC);
if (PEAR::isError($row)) {
return $row;
} elseif ($row === null) {
@@ -675,8 +680,14 @@
release::logDownload($package_id, $log_release, $log_file);
header('Content-type: application/octet-stream');
- header('Content-disposition: attachment;
filename="'.$basename.'"');
- readfile($path);
+ if ($uncompress) {
+ $tarname = preg_replace('/\.tgz$/', '.tar', $basename);
+ header('Content-disposition: attachment;
filename="'.$tarname.'"');
+ readgzfile($path);
+ } else {
+ header('Content-disposition: attachment;
filename="'.$basename.'"');
+ readfile($path);
+ }
return true;
}
Index: pearweb/public_html/get
diff -u pearweb/public_html/get:1.7 pearweb/public_html/get:1.8
--- pearweb/public_html/get:1.7 Fri Dec 28 22:27:18 2001
+++ pearweb/public_html/get Tue Apr 2 08:38:21 2002
@@ -50,7 +50,7 @@
$ok = false;
switch (sizeof($opts)) {
case 2: {
- if (preg_match('/^([a-zA-Z0-9_]+)-(.*)\.tgz$/', $opts[1], $matches)) {
+ if (preg_match('/^([a-zA-Z0-9_]+)-(.*)\.(tar|tgz)$/', $opts[1], $matches)) {
list(, $package, $version) = $matches;
$ok = release::HTTPdownload($package, $version, $opts[1]);
} else {