Update of /cvsroot/phpcvsview/phpcvsview
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22893
Modified Files:
cvsview.php phpcvs.php
Added Files:
func_ArchiveDownload.php
Log Message:
Added package download capability for folders within the CVS repository. Need to look at ways to improve the performance, as it takes a while to export the source and then generate the .tar.gz file. I can see issues with php runtime timeouts.
--- NEW FILE: func_ArchiveDownload.php ---
<?php
/**
* This source code is distributed under the terms as layed out in the
* GNU General Public License.
*
* Purpose: To provide Archive Downloads.
*
* @author Brian A Cheeseman <bch...@us...>
* @version $Id: func_ArchiveDownload.php,v 1.1 2005/02/04 04:21:52 bcheesem Exp $
* @copyright 2003-2005 Brian A Cheeseman
**/
require_once("Archive/Tar.php");
function DAProcessDirectory($ReposLoc, $BasePath)
{
global $env;
// Create our CVS connection object and set the required properties.
$CVSServer = new CVS_PServer($env['CVSSettings']['cvsroot'], $env['CVSSettings']['server'], $env['CVSSettings']['username'], $env['CVSSettings']['password']);
// Connect to the CVS server.
if ($CVSServer->Connect() === true) {
// Authenticate against the server.
$Response = $CVSServer->Authenticate();
if ($Response !== true) {
return;
}
// Create the folder for the BasePath.
@mkdir($BasePath, 0700);
// Get a RLOG of the module path specified in $ReposLoc.
$CVSServer->RLog($ReposLoc);
$Folders = $CVSServer->FOLDERS;
$Files = $CVSServer->FILES;
foreach ($Folders as $folder)
{
if ($folder["Name"] != "Attic") {
DAProcessDirectory($ReposLoc.$folder["Name"]."/", $BasePath."/".$folder["Name"]);
}
}
foreach ($Files as $file)
{
$CVSServer->ExportFile($ReposLoc.$file["Name"], time());
$filehandle = fopen($BasePath."/".$file["Name"], "wb");
fwrite($filehandle, $CVSServer->FILECONTENTS);
fclose($filehandle);
}
$CVSServer->Disconnect();
// When we leave this function the contents should be in the File System.
}
}
function DownloadArchive()
{
global $config, $env, $lang;
// Get a unique string to create a directory for storing this request.
$jobpath = $config['TempFileLocation']."/".md5(uniqid(rand(), true));
mkdir($jobpath, 0700);
$buildpath = $jobpath."/".$config['CVSROOT'];
mkdir($buildpath, 0700);
$ReposFolders = explode("/", $env['mod_path']);
if (count($ReposFolders) > 0 && $ReposFolders[count($ReposFolders) - 2] != "") {
$buildpath .= "/".$ReposFolders[count($ReposFolders) - 2];
}
// Export the source tree.
DAProcessDirectory($env['mod_path'], $buildpath);
// Create the tar file.
$FileName = $jobpath."/".$config['CVSROOT'].".tar.gz";
$tar = new Archive_Tar($FileName, "gz");
$cwd = getcwd();
chdir($jobpath);
$tar->create($config['CVSROOT']);
chdir($cwd);
header('Content-Type: application/x-tar');
header("Content-Disposition: attachment; filename=\"".$config['CVSROOT'].".tar.gz\"");
header("Content-Length: " . filesize($FileName));
$tarfile = fopen($FileName, "rb");
// Dump the contents of the file to the client.
fpassthru($tarfile);
}
?>
Index: cvsview.php
===================================================================
RCS file: /cvsroot/phpcvsview/phpcvsview/cvsview.php,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** cvsview.php 3 Feb 2005 23:47:29 -0000 1.23
--- cvsview.php 4 Feb 2005 04:21:52 -0000 1.24
***************
*** 72,75 ****
--- 72,76 ----
require_once 'func_FileDownload.php';
require_once 'func_DiffFile.php';
+ require_once 'func_ArchiveDownload.php';
***************
*** 93,97 ****
DisplayFileDiff($_GET["r1"], $_GET["r2"]);
} else {
! DisplayDirListing();
}
}
--- 94,102 ----
DisplayFileDiff($_GET["r1"], $_GET["r2"]);
} else {
! if (isset($_GET["dp"])) {
! DownloadArchive();
! } else {
! DisplayDirListing();
! }
}
}
Index: phpcvs.php
===================================================================
RCS file: /cvsroot/phpcvsview/phpcvsview/phpcvs.php,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** phpcvs.php 2 Feb 2005 07:14:49 -0000 1.22
--- phpcvs.php 4 Feb 2005 04:21:52 -0000 1.23
***************
*** 1056,1059 ****
--- 1056,1061 ----
$this->INITIALISED = true;
}
+
+ $this->FILECONTENTS = "";
if (strncmp($FileName, "/", 1) == 0) {
|