[Phpcvsview-cvs-updates] phpcvsview phpcvs.php,1.2,1.3 test.php,1.2,1.3
Status: Pre-Alpha
Brought to you by:
bcheesem
|
From: <bch...@us...> - 2003-03-22 05:38:55
|
Update of /cvsroot/phpcvsview/phpcvsview
In directory sc8-pr-cvs1:/tmp/cvs-serv19186
Modified Files:
phpcvs.php test.php
Log Message:
Added basic file viewing to the class and test page.
Index: phpcvs.php
===================================================================
RCS file: /cvsroot/phpcvsview/phpcvsview/phpcvs.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** phpcvs.php 22 Mar 2003 02:10:31 -0000 1.2
--- phpcvs.php 22 Mar 2003 05:38:52 -0000 1.3
***************
*** 237,241 ****
// Determine if it is local dir or a subdir.
if (strncmp($RecvLN, "M \n", 3) == 0) {
! $FileName = fgets($this->SOCKET_HANDLE, 13+strlen($this->CVS_REPOSITORY.$Module));
if (strncmp($FileName, "M RCS file", 10) == 0) {
$FileName = fgets($this->SOCKET_HANDLE, 8192);
--- 237,241 ----
// Determine if it is local dir or a subdir.
if (strncmp($RecvLN, "M \n", 3) == 0) {
! $FileName = fgets($this->SOCKET_HANDLE, 12+strlen($this->CVS_REPOSITORY.$Module));
if (strncmp($FileName, "M RCS file", 10) == 0) {
$FileName = fgets($this->SOCKET_HANDLE, 8192);
***************
*** 312,315 ****
--- 312,377 ----
return $Elements;
} // End of function RLOGFile();
+
+ function ViewFile($File, $Revision, $Module="/") {
+ // Here we will export a copy of a given file, returning a series of "Strings".
+ if (strncmp($Module, "/", 1) == 0) {
+ $Module = substr($Module, 1, strlen($Module)-1);
+ }
+
+ $SendCMD = "UseUnchanged\nCase\nArgument ".$Module.$File."\nDirectory .\n".$this->CVS_REPOSITORY."\nexpand-modules\n";
+ fputs($this->SOCKET_HANDLE, $SendCMD);
+
+ $RecvLN = "ABCD";
+ while(strncmp($RecvLN, "ok", 2) != 0){
+ $RecvLN = fgets($this->SOCKET_HANDLE);
+ } // End of while(strncmp($RecvLN, "ok", 2) != 0)
+
+ // Send the checkout command.
+ $SendCMD = "Argument -n\nArgument -l\nArgument -N\nArgument -P\nArgument -r\nArgument ".$Revision."\nArgument ".$Module.$File."\nDirectory .\n".$this->CVS_REPOSITORY."\nco\n";
+ fputs($this->SOCKET_HANDLE, $SendCMD);
+
+ // Clear out the Return Elements, in preparation for returning the information.
+ $Elements = "";
+
+ $RecvLN = "";
+ while(strncmp($RecvLN, "ok", 2) != 0){
+ if (strncmp($RecvLN, "Clear-sticky ", 13) == 0) {
+ $RecvLN = fgets($this->SOCKET_HANDLE, 8192);
+ }
+ if (strncmp($RecvLN, "Set-static-directory ", 21) == 0) {
+ $RecvLN = fgets($this->SOCKET_HANDLE, 8192);
+ }
+ if (strncmp($RecvLN, "Mod-time", 8) == 0) {
+ // We had the Date and time this revision was modified.
+ $Elements["DATETIME"] = substr($RecvLN, 9, strlen($RecvLN)-9);
+ $RecvLN = fgets($this->SOCKET_HANDLE);
+ while(strncmp($RecvLN, "MT", 2) == 0){
+ $RecvLN = fgets($this->SOCKET_HANDLE);
+ if (strncmp($RecvLN, "MT -updated", 11) == 0) {
+ $RecvLN = "";
+ }
+ } // while
+ }
+ if (strncmp($RecvLN, "Created", 7) == 0) {
+
+ echo "We are getting the file contents.<br>";
+
+ // We are getting the file from the Server.
+ $RecvLN = fgets($this->SOCKET_HANDLE);
+ $RecvLN = fgets($this->SOCKET_HANDLE);
+ $RecvLN = fgets($this->SOCKET_HANDLE);
+ $RecvLN = fgets($this->SOCKET_HANDLE);
+
+ // RecvLN Holds the length of the file as a string
+ $TotalBytes = $RecvLN + 0;
+ echo "Number of bytes = $RecvLN<br>";
+ echo "Number of bytes = $TotalBytes<br>";
+ $Elements["CONTENT"] = fread($this->SOCKET_HANDLE, $TotalBytes);
+ }
+ $RecvLN = fgets($this->SOCKET_HANDLE);
+ } // End of while(strncmp($RecvLN, "ok", 2) != 0)
+
+ return $Elements;
+ }
function CVSLogon() {
Index: test.php
===================================================================
RCS file: /cvsroot/phpcvsview/phpcvsview/test.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** test.php 22 Mar 2003 02:10:31 -0000 1.2
--- test.php 22 Mar 2003 05:38:52 -0000 1.3
***************
*** 9,13 ****
$REPOS = "";
! $CVSROOT = "/cvsroot/d/de/denet";
$PServer = "cvs.sourceforge.net";
$UserName = "anonymous";
--- 9,13 ----
$REPOS = "";
! $CVSROOT = "/cvsroot/d/de/denet/";
$PServer = "cvs.sourceforge.net";
$UserName = "anonymous";
***************
*** 88,94 ****
--- 88,116 ----
$CVSServer->SendValidRequests();
$Elements = $CVSServer->RLOG ($REPOS);
+
+
+ $CVSServer->DisconnectTcp();
} // End of if ($CVSServer->ConnectTcpAndLogon())
} // End of function DisplayFileHistory()
+ function DisplayFile() {
+ global $REPOS, $CVSROOT, $PServer, $UserName, $Password, $FileToView, $FileRev;
+
+ $CVSServer = new phpcvs($CVSROOT, $PServer, $UserName, $Password);
+
+ if ($CVSServer->ConnectTcpAndLogon()) {
+ $CVSServer->SendRoot();
+ $CVSServer->SendValidResponses();
+ $CVSServer->SendValidRequests();
+ echo "<H1>File Contents for Revision ".$FileRev." of '".$REPOS.$FileToView."'</H1>";
+ $Elements = $CVSServer->ViewFile($FileToView, $FileRev, $REPOS);
+ $FileOut = "";
+
+ echo "<PRE>".$Elements["CONTENT"]."</PRE>";
+
+ $CVSServer->DisconnectTcp();
+ }
+ }
+
if (isset($_GET["CVSROOT"])) {
$REPOS = $_GET["CVSROOT"];
***************
*** 97,106 ****
}
if (isset($_GET["ShowFile"])) {
// Here we will show the contents of a file.
} else {
if (isset($_GET["ShowHist"])) {
// Here we will show the Revision History of a given file.
! echo "<H1>Revision History for '".$_GET["CVSROOT"].$_GET["ShowHist"]."'</H1>";
} else {
// Here we will just show the current file listing.
--- 119,133 ----
}
+ $REPOS = str_replace("//", "/", $REPOS);
+
if (isset($_GET["ShowFile"])) {
// Here we will show the contents of a file.
+ $FileToView = $_GET["ShowFile"];
+ $FileRev = $_GET["Rev"];
+ DisplayFile();
} else {
if (isset($_GET["ShowHist"])) {
// Here we will show the Revision History of a given file.
! echo "<H1>Revision History for '".$REPOS.$_GET["ShowHist"]."'</H1>";
} else {
// Here we will just show the current file listing.
***************
*** 109,113 ****
}
- $REPOS = str_replace("//", "/", $REPOS);
--- 136,139 ----
|