Update of /cvsroot/phpcvsview/phpcvsview
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13668
Modified Files:
cvsview.php
Added Files:
func_FileDownload.php
Log Message:
- Added download functionality to the File Revision History view.
--- NEW FILE: func_FileDownload.php ---
<?php
/**
* This source code is distributed under the terms as layed out in the
* GNU General Public License.
*
* Purpose: To provide File Download capability.
*
* @author Brian A Cheeseman <bch...@us...>
* @version $Id
* @copyright 2003-2004 Brian A Cheeseman
**/
include_once("phpcvsmime.php");
function DownloadFile($File, $Revision = "")
{
global $config, $env, $MIME_TYPES;
// Calculate the path from the $env['script_name'] variable.
$env['script_path'] = substr($env['script_name'], 0, strrpos($env['script_name'], "/"));
if ($env['script_path'] == ""){
$env['script_path'] = "/";
}
// Create our CVS connection object and set the required properties.
$CVSServer = new CVS_PServer($config['cvsroot'], $config['pserver'], $config['username'], $config['password']);
// Connect to the CVS server.
if ($CVSServer->Connect() === true) {
// Authenticate against the server.
$Response = $CVSServer->Authenticate();
if ($Response !== true) {
return;
}
// Get a RLOG of the module path specified in $env['mod_path'].
$CVSServer->RLog($env['mod_path']);
// "Export" the file.
$Response = $CVSServer->ExportFile($File, $Revision);
if ($Response !== true) {
return;
}
// Get the mime type for the file.
$FileExt = substr($File, strrpos($File, ".")+1);
$MimeType = $MIME_TYPES[$FileExt];
if ($MimeType == "") {
$MimeType = "text/plain";
}
// Send the appropriate http header.
header("Content-Type: $MimeType");
// Send the file contents.
echo $CVSServer->FILECONTENTS;
echo "<br />File Extension: $FileExt<br />";
echo "MIME TYPE IS: $MimeType";
// Close the connection.
$CVSServer->Disconnect();
}
}
?>
Index: cvsview.php
===================================================================
RCS file: /cvsroot/phpcvsview/phpcvsview/cvsview.php,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** cvsview.php 6 Oct 2004 08:36:02 -0000 1.16
--- cvsview.php 19 Dec 2004 10:27:04 -0000 1.17
***************
*** 38,41 ****
--- 38,42 ----
require_once 'func_FileAnnotation.php';
require_once 'func_FileView.php';
+ require_once 'func_FileDownload.php';
***************
*** 58,62 ****
DisplayFileContents($env['mod_path'], $_GET["dt"]);
} else {
! DisplayDirListing();
}
}
--- 59,69 ----
DisplayFileContents($env['mod_path'], $_GET["dt"]);
} else {
! if (isset($_GET["fd"])) {
! DownloadFile($env['mod_path'], $_GET["dt"]);
! }
! else
! {
! DisplayDirListing();
! }
}
}
|