[Phpcvsview-cvs-updates] phpcvsview cvsview.php,1.1,1.2 footer.php,1.1,1.2 header.php,1.1,1.2 phpcvs
Status: Pre-Alpha
Brought to you by:
bcheesem
From: <bch...@us...> - 2003-04-07 08:24:14
|
Update of /cvsroot/phpcvsview/phpcvsview In directory sc8-pr-cvs1:/tmp/cvs-serv2905 Modified Files: cvsview.php footer.php header.php phpcvs.php phpcvsmime.php test.php Log Message: Cleaned up the source code for the project. Index: cvsview.php =================================================================== RCS file: /cvsroot/phpcvsview/phpcvsview/cvsview.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** cvsview.php 6 Apr 2003 08:06:18 -0000 1.1 --- cvsview.php 7 Apr 2003 08:23:56 -0000 1.2 *************** *** 2,5 **** --- 2,8 ---- /** + * This source code is distributed under the terms as layed out in the + * GNU General Public License. + * * Purpose: To provide the main entry point in accessing a CVS repository * *************** *** 9,19 **** **/ ! $REPOS = ""; ! $CVSROOT = "/cvsroot/d/de/denet/"; ! //$CVSROOT = "/cvsroot/p/ph/phpcvsview/"; $PServer = "cvs.sourceforge.net"; $UserName = "anonymous"; $Password = ""; $ScriptName = $_SERVER['PHP_SELF']; --- 12,41 ---- **/ ! /** ! * ! * phpCVSView Configuration Parameters. ! * ! **/ ! ! // The CVSROOT path to access. For sourceforge you need the usual expansion ! // of the path based on the project name. ! $CVSROOT = "/cvsroot/p/ph/phpcvsview/"; ! ! // The hostname (or IP Address) of the server providing the PServer services. $PServer = "cvs.sourceforge.net"; + + // The username to pass to the PServer for authentication purposes. $UserName = "anonymous"; + + // The password associated with the username above for authentication process. $Password = ""; + /** + * + * End of phpCVSView Configuration Parameters. + * + **/ + + $REPOS = ""; $ScriptName = $_SERVER['PHP_SELF']; *************** *** 27,37 **** list($b_dec, $b_sec) = explode(" ", $b); return $b_sec - $a_sec + $b_dec - $a_dec; ! } ! function DisplayDirListing () { global $REPOS, $CVSROOT, $PServer, $UserName, $Password, $ScriptName; - $CVSServer = new phpcvs($CVSROOT, $PServer, $UserName, $Password); - echo GetPageHeader("phpCVSView CVS Repository", "phpCVSView CVS Repository"); if ($CVSServer->ConnectTcpAndLogon()) { --- 49,57 ---- list($b_dec, $b_sec) = explode(" ", $b); return $b_sec - $a_sec + $b_dec - $a_dec; ! } // End of function microtime_diff($a, $b) ! function DisplayDirListing() { global $REPOS, $CVSROOT, $PServer, $UserName, $Password, $ScriptName; $CVSServer = new phpcvs($CVSROOT, $PServer, $UserName, $Password); echo GetPageHeader("phpCVSView CVS Repository", "phpCVSView CVS Repository"); if ($CVSServer->ConnectTcpAndLogon()) { *************** *** 61,65 **** if (strcmp($BGColor, "#FFFFFF") == 0) { $BGColor = "#CCCCFF"; ! } else { $BGColor = "#FFFFFF"; } // End of if (strcmp($BGColor, "#FFFFFF") == 0) --- 81,85 ---- if (strcmp($BGColor, "#FFFFFF") == 0) { $BGColor = "#CCCCFF"; ! } else { // Else of if (strcmp($BGColor, "#FFFFFF") == 0) $BGColor = "#FFFFFF"; } // End of if (strcmp($BGColor, "#FFFFFF") == 0) *************** *** 79,83 **** if (strcmp($BGColor, "#FFFFFF") == 0) { $BGColor = "#CCCCFF"; ! } else { $BGColor = "#FFFFFF"; } // End of if (strcmp($BGColor, "#FFFFFF") == 0) --- 99,103 ---- if (strcmp($BGColor, "#FFFFFF") == 0) { $BGColor = "#CCCCFF"; ! } else { // End of if (strcmp($BGColor, "#FFFFFF") == 0) $BGColor = "#FFFFFF"; } // End of if (strcmp($BGColor, "#FFFFFF") == 0) *************** *** 87,91 **** echo "<HR>"; $CVSServer->DisconnectTcp(); ! } else { echo "Connection Failed."; } // End of if ($CVSServer->ConnectTcpAndLogon()) --- 107,111 ---- echo "<HR>"; $CVSServer->DisconnectTcp(); ! } else { // Else of if ($CVSServer->ConnectTcpAndLogon()) echo "Connection Failed."; } // End of if ($CVSServer->ConnectTcpAndLogon()) *************** *** 95,101 **** function DisplayFileHistory($FileName) { global $REPOS, $CVSROOT, $PServer, $UserName, $Password, $ScriptName; - $CVSServer = new phpcvs($CVSROOT, $PServer, $UserName, $Password); - echo GetPageHeader("phpCVSView CVS Repository", "phpCVSView CVS Repository"); if ($CVSServer->ConnectTcpAndLogon()) { --- 115,119 ---- *************** *** 104,111 **** $CVSServer->SendValidRequests(); $Elements = $CVSServer->RLOGFile($FileName, $REPOS); - echo "<H3>Revision History for '".$REPOS.$_GET["ShowHist"]."'</H3>"; - - // List each revision with a HorizRule between them. for ($i = 1; $i <= $Elements[0]["TotalRevisions"]; $i++) { echo "<HR>\n"; --- 122,126 ---- *************** *** 113,122 **** echo "[<A HREF=\"$ScriptName?CVSROOT=$REPOS&ShowFile=".$FileName."&Rev=".$Elements[$i]["Revision"]."\">View"; echo "</a>] "; - echo "[<A HREF=\"$ScriptName?CVSROOT=$REPOS&DownloadFile=".$FileName."&Rev=".$Elements[$i]["Revision"]."\">Download"; echo "</a>]"; - echo "<BR>\n"; - echo "Branch: Yet to identify.<BR>\n"; echo "Date: ".$Elements[$i]["Date"]."<BR>\n"; --- 128,134 ---- *************** *** 124,139 **** echo "Author: ".$Elements[$i]["Author"]."<BR>\n"; echo "State: ".$Elements[$i]["State"]."<BR>\n"; - if (($i + 1) < $Elements[0]["TotalRevisions"]) { echo "Changes since ".$Elements[$i+1]["Revision"].": "; echo "+".$Elements[$i]["LinesAdd"]." -".$Elements[$i]["LinesSub"]."<br>\n"; ! } echo "<pre>".str_replace("\n", "<BR>", $Elements[$i]["Log"])."</pre>"; ! } echo "<HR>\n"; - - $CVSServer->DisconnectTcp(); ! } else { echo "ERROR: Unable to connect to the CVS PServer.<BR>"; } // End of if ($CVSServer->ConnectTcpAndLogon()) --- 136,148 ---- echo "Author: ".$Elements[$i]["Author"]."<BR>\n"; echo "State: ".$Elements[$i]["State"]."<BR>\n"; if (($i + 1) < $Elements[0]["TotalRevisions"]) { echo "Changes since ".$Elements[$i+1]["Revision"].": "; echo "+".$Elements[$i]["LinesAdd"]." -".$Elements[$i]["LinesSub"]."<br>\n"; ! } // End of if (($i + 1) < $Elements[0]["TotalRevisions"]) echo "<pre>".str_replace("\n", "<BR>", $Elements[$i]["Log"])."</pre>"; ! } // End of for ($i = 1; $i <= $Elements[0]["TotalRevisions"]; $i++) echo "<HR>\n"; $CVSServer->DisconnectTcp(); ! } else { // Else of if ($CVSServer->ConnectTcpAndLogon()) echo "ERROR: Unable to connect to the CVS PServer.<BR>"; } // End of if ($CVSServer->ConnectTcpAndLogon()) *************** *** 143,149 **** function DisplayFile() { global $REPOS, $CVSROOT, $PServer, $UserName, $Password, $FileToView, $FileRev; - $CVSServer = new phpcvs($CVSROOT, $PServer, $UserName, $Password); - echo GetPageHeader("phpCVSView CVS Repository", "phpCVSView CVS Repository"); if ($CVSServer->ConnectTcpAndLogon()) { --- 152,156 ---- *************** *** 153,158 **** echo "<H3>File Contents for Revision ".$FileRev." of '".$REPOS.$FileToView."'</H3>"; $Elements = $CVSServer->ViewFile($FileToView, $FileRev, $REPOS); - - // Format and Display the output. if (strpos($FileToView, ".php")) { $OutText = highlight_string($Elements["CONTENT"], true); --- 160,163 ---- *************** *** 160,178 **** $OutText = str_replace("</code>", "</pre>", $OutText); echo $OutText; ! } else { $Find = array("\r", "\n", " ", "\t"); $Repl = array("", "<BR>", " ", " "); echo "<pre>".str_replace($Find, $Repl, $Elements["CONTENT"])."</pre>"; ! } $CVSServer->DisconnectTcp(); ! } echo GetPageFooter(); ! } function DownloadFile() { global $REPOS, $CVSROOT, $PServer, $UserName, $Password, $FileToDownload, $FileRev, $MIME_TYPE; - $CVSServer = new phpcvs($CVSROOT, $PServer, $UserName, $Password); - if ($CVSServer->ConnectTcpAndLogon()) { $CVSServer->SendRoot(); --- 165,181 ---- $OutText = str_replace("</code>", "</pre>", $OutText); echo $OutText; ! } else { // Else of if (strpos($FileToView, ".php")) $Find = array("\r", "\n", " ", "\t"); $Repl = array("", "<BR>", " ", " "); echo "<pre>".str_replace($Find, $Repl, $Elements["CONTENT"])."</pre>"; ! } // End of if (strpos($FileToView, ".php")) $CVSServer->DisconnectTcp(); ! } // End of if ($CVSServer->ConnectTcpAndLogon()) echo GetPageFooter(); ! } // End of function DisplayFile() function DownloadFile() { global $REPOS, $CVSROOT, $PServer, $UserName, $Password, $FileToDownload, $FileRev, $MIME_TYPE; $CVSServer = new phpcvs($CVSROOT, $PServer, $UserName, $Password); if ($CVSServer->ConnectTcpAndLogon()) { $CVSServer->SendRoot(); *************** *** 180,228 **** $CVSServer->SendValidRequests(); $Elements = $CVSServer->ViewFile($FileToDownload, $FileRev, $REPOS); - - // Send the file to the client. - // $Elements["CONTENT"]; $PeriodPos = strrchr($FileToDownload, "."); $FileExt = substr($FileToDownload, $PeriodPos, strlen($FileToDownload)-$PeriodPos); if (isset($MIME_TYPE["$FileExt"])) { $ContentType = $MIME_TYPE["$FileExt"]; ! } else { $ContentType = "text/plain"; ! } header("content-type: ".$ContentType); echo $Elements["CONTENT"]; - $CVSServer->DisconnectTcp(); ! } ! } if (isset($_GET["CVSROOT"])) { $REPOS = $_GET["CVSROOT"]; ! } else { $REPOS = "/"; ! } ! $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. DisplayFileHistory($_GET["ShowHist"]); ! } else { if (isset($_GET["DownloadFile"])) { $FileToDownload = $_GET["DownloadFile"]; $FileRev = $_GET["Rev"]; DownloadFile(); ! } else { // Here we will just show the current file listing. DisplayDirListing(); ! } ! } ! } --- 183,223 ---- $CVSServer->SendValidRequests(); $Elements = $CVSServer->ViewFile($FileToDownload, $FileRev, $REPOS); $PeriodPos = strrchr($FileToDownload, "."); $FileExt = substr($FileToDownload, $PeriodPos, strlen($FileToDownload)-$PeriodPos); if (isset($MIME_TYPE["$FileExt"])) { $ContentType = $MIME_TYPE["$FileExt"]; ! } else { // Else of if (isset($MIME_TYPE["$FileExt"])) $ContentType = "text/plain"; ! } // End of if (isset($MIME_TYPE["$FileExt"])) header("content-type: ".$ContentType); echo $Elements["CONTENT"]; $CVSServer->DisconnectTcp(); ! } // End of if ($CVSServer->ConnectTcpAndLogon()) ! } // End of function DownloadFile() if (isset($_GET["CVSROOT"])) { $REPOS = $_GET["CVSROOT"]; ! } else { // Else of if (isset($_GET["CVSROOT"])) $REPOS = "/"; ! } // End of if (isset($_GET["CVSROOT"])) $REPOS = str_replace("//", "/", $REPOS); if (isset($_GET["ShowFile"])) { $FileToView = $_GET["ShowFile"]; $FileRev = $_GET["Rev"]; DisplayFile(); ! } else { // Else of if (isset($_GET["ShowFile"])) if (isset($_GET["ShowHist"])) { DisplayFileHistory($_GET["ShowHist"]); ! } else { // Else of if (isset($_GET["ShowHist"])) if (isset($_GET["DownloadFile"])) { $FileToDownload = $_GET["DownloadFile"]; $FileRev = $_GET["Rev"]; DownloadFile(); ! } else { // Else of if (isset($_GET["DownloadFile"])) // Here we will just show the current file listing. DisplayDirListing(); ! } // End of if (isset($_GET["DownloadFile"])) ! } // End of if (isset($_GET["ShowHist"])) ! } // End of if (isset($_GET["ShowFile"])) Index: footer.php =================================================================== RCS file: /cvsroot/phpcvsview/phpcvsview/footer.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** footer.php 6 Apr 2003 08:06:14 -0000 1.1 --- footer.php 7 Apr 2003 08:23:56 -0000 1.2 *************** *** 2,5 **** --- 2,8 ---- /** + * This source code is distributed under the terms as layed out in the + * GNU General Public License. + * * Purpose: To provide the HTML page footer code * *************** *** 10,21 **** function GetPageFooter() { - // Here we will generate the HTML page footer. global $StartTime; $EndTime = microtime(); $PageFoot = "This page was created in ".number_format(microtime_diff($StartTime, $EndTime), 3)." seconds."; $PageFoot .= "</BODY></HTML>"; - return $PageFoot; ! } ?> --- 13,22 ---- function GetPageFooter() { global $StartTime; $EndTime = microtime(); $PageFoot = "This page was created in ".number_format(microtime_diff($StartTime, $EndTime), 3)." seconds."; $PageFoot .= "</BODY></HTML>"; return $PageFoot; ! } // End of function GetPageFooter() ?> Index: header.php =================================================================== RCS file: /cvsroot/phpcvsview/phpcvsview/header.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** header.php 6 Apr 2003 08:06:16 -0000 1.1 --- header.php 7 Apr 2003 08:23:58 -0000 1.2 *************** *** 2,5 **** --- 2,8 ---- /** + * This source code is distributed under the terms as layed out in the + * GNU General Public License. + * * Purpose: To provide the HTML page header code * *************** *** 12,24 **** global $StartTime; $StartTime = microtime(); - // Here we will generate the HTML page header. $PageHead = "<HTML>"; ! if (isset($Title)) { $PageHead .= "<HEAD><TITLE>$Title</TITLE></HEAD>"; ! } $PageHead .= "<BODY>"; ! if (isset($Heading)) { $PageHead .= "<DIV ALIGN=\"center\"><H1>$Heading</H1></DIV>"; ! } $PageHead .= "Welcome to our CVS Repository viewer. This page has been dynamically"; $PageHead .= " created with '<a href=\"http://phpcvsview.sourceforge.net/\">phpCVS"; --- 15,26 ---- global $StartTime; $StartTime = microtime(); $PageHead = "<HTML>"; ! if ($Title != "") { $PageHead .= "<HEAD><TITLE>$Title</TITLE></HEAD>"; ! } // End of if ($Title != "") $PageHead .= "<BODY>"; ! if ($Heading != "") { $PageHead .= "<DIV ALIGN=\"center\"><H1>$Heading</H1></DIV>"; ! } // End of if ($Header != "") $PageHead .= "Welcome to our CVS Repository viewer. This page has been dynamically"; $PageHead .= " created with '<a href=\"http://phpcvsview.sourceforge.net/\">phpCVS"; *************** *** 26,32 **** $PageHead .= "ers.sourceforge.net\">Brian Cheeseman</a>. <BR><BR>Please feel free"; $PageHead .= " to browse our source code.<BR><BR>"; - return $PageHead; ! } ?> --- 28,33 ---- $PageHead .= "ers.sourceforge.net\">Brian Cheeseman</a>. <BR><BR>Please feel free"; $PageHead .= " to browse our source code.<BR><BR>"; return $PageHead; ! } // End of function GetPageHeader($Title="", $Heading="") ?> Index: phpcvs.php =================================================================== RCS file: /cvsroot/phpcvsview/phpcvsview/phpcvs.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** phpcvs.php 6 Apr 2003 06:46:51 -0000 1.4 --- phpcvs.php 7 Apr 2003 08:23:59 -0000 1.5 *************** *** 2,20 **** /** * Purpose: To provide the main class required to access a CVS repository * * @author Brian A Cheeseman <br...@bc...> * @version $Id$ ! * @copyright 2002 ARECOM International **/ class phpcvs { ! var $CVS_REPOSITORY; ! var $CVS_USERNAME; ! var $CVS_PASSWORD; ! var $CVS_PSERVER; ! var $CVS_VALID_REQUESTS; ! var $SOCKET_HANDLE; /** --- 2,23 ---- /** + * This source code is distributed under the terms as layed out in the + * GNU General Public License. + * * Purpose: To provide the main class required to access a CVS repository * * @author Brian A Cheeseman <br...@bc...> * @version $Id$ ! * @copyright 2003 Brian A Cheeseman **/ class phpcvs { ! var $CVS_REPOSITORY; // Storage of the CVS Repository file system path. ! var $CVS_USERNAME; // Username to use when authenticating with the PServer. ! var $CVS_PASSWORD; // Password for the account above. ! var $CVS_PSERVER; // Hostname of the server running the PServer. ! var $CVS_VALID_REQUESTS; // List of valid requests the PServer accepts. ! var $SOCKET_HANDLE; // The socket handle for communicating with the PServer. /** *************** *** 34,38 **** $this->CVS_PASSWORD = $Password; $this->SOCKET_HANDLE = -1; - $this->SHOW_CVSROOT = true; } --- 37,40 ---- *************** *** 42,46 **** * **/ ! function get_Repository() { return $this->CVS_REPOSITORY; --- 44,48 ---- * **/ ! function get_Repository() { return $this->CVS_REPOSITORY; *************** *** 120,173 **** function ConnectTcpAndLogon() { - // Report All Errors back to this script. error_reporting(E_ALL); - - // Get the TCP Port. - $CVSPort = getservbyname('cvs', 'tcp'); - - // Create the Socket to communicate through. $this->SOCKET_HANDLE = fsockopen($this->CVS_PSERVER, 2401); - - // Check and see if we have a socket. if ($this->SOCKET_HANDLE < 0) { return false; ! } ! ! // Could we connect. if ($this->SOCKET_HANDLE < 1) { return false; ! } ! ! // Cool, we have a valid connection to the PServer, so we can now ! // authenticate with the server. ! ! // Encrypt the password. $CPassword = "A".$this->EncodePW($this->CVS_PASSWORD); - - // Build the string to send to the PServer. $Request = "BEGIN AUTH REQUEST\n".$this->CVS_REPOSITORY."\n"; $Request .= $this->CVS_USERNAME."\n".$CPassword."\n"; $Request .= "END AUTH REQUEST\n"; - - // Send this command to the backend PServer. fputs($this->SOCKET_HANDLE, $Request); fflush($this->SOCKET_HANDLE); - - // Read the response to see if our credentials were OK. $Response = fgets($this->SOCKET_HANDLE, 11); - - // Generate the return value. if (strcmp($Response, "I LOVE YOU") == 0) { return true; ! } else { return false; ! } ! } function DisconnectTcp() { - // Close off the socket to the PServer. fclose($this->SOCKET_HANDLE); $this->SOCKET_HANDLE = -1; ! } function SendRoot() { --- 122,151 ---- function ConnectTcpAndLogon() { error_reporting(E_ALL); $this->SOCKET_HANDLE = fsockopen($this->CVS_PSERVER, 2401); if ($this->SOCKET_HANDLE < 0) { return false; ! } // End of if ($this->SOCKET_HANDLE < 0) if ($this->SOCKET_HANDLE < 1) { return false; ! } // End of if ($this->SOCKET_HANDLE < 1) $CPassword = "A".$this->EncodePW($this->CVS_PASSWORD); $Request = "BEGIN AUTH REQUEST\n".$this->CVS_REPOSITORY."\n"; $Request .= $this->CVS_USERNAME."\n".$CPassword."\n"; $Request .= "END AUTH REQUEST\n"; fputs($this->SOCKET_HANDLE, $Request); fflush($this->SOCKET_HANDLE); $Response = fgets($this->SOCKET_HANDLE, 11); if (strcmp($Response, "I LOVE YOU") == 0) { return true; ! } else { // Else of if (strcmp($Response, "I LOVE YOU") == 0) return false; ! } // End of if (strcmp($Response, "I LOVE YOU") == 0) ! } // End of function ConnectTcpAndLogon() { function DisconnectTcp() { fclose($this->SOCKET_HANDLE); $this->SOCKET_HANDLE = -1; ! } // End of function DisconnectTcp() function SendRoot() { *************** *** 176,186 **** fputs($this->SOCKET_HANDLE, $SendCMD); return true; ! } return false; ! } function SendValidResponses() { if ($this->SOCKET_HANDLE > 0) { - // Build the String to send out the socket. $SendCMD = "Valid-responses ok error Valid-requests Checked-in New-entry"; $SendCMD .= " Checksum Copy-file Updated Created Update-existing Merged"; --- 154,163 ---- fputs($this->SOCKET_HANDLE, $SendCMD); return true; ! } // End of if ($this->SOCKET_HANDLE > 0) return false; ! } // End of function SendRoot() function SendValidResponses() { if ($this->SOCKET_HANDLE > 0) { $SendCMD = "Valid-responses ok error Valid-requests Checked-in New-entry"; $SendCMD .= " Checksum Copy-file Updated Created Update-existing Merged"; *************** *** 189,223 **** $SendCMD .= " Clear-sticky Template Set-checkin-prog Set-update-prog"; $SendCMD .= " Notified Module-expansion Wrapper-rcsOption M Mbinary E F MT\n"; - - // Send the command to the backend PServer. fputs($this->SOCKET_HANDLE, $SendCMD); - - // return success. return true; ! } return false; ! } function SendValidRequests() { if ($this->SOCKET_HANDLE > 0) { - // Build the String to send out the socket. $SendCMD = "valid-requests\n"; - - // Send the Command to the backend PServer. fputs($this->SOCKET_HANDLE, $SendCMD); - - // OK, Now wait for the response from the server. $RecvCMD = fgets($this->SOCKET_HANDLE, 8192); - - // Clear off the OK message from the buffer. $dummy = fgets($this->SOCKET_HANDLE); - - // Lets transfer the allowable messages into our message above. - // Although at this stage I will skip this and add it in later. - return true; ! } return false; ! } function RLOGDir($Module = "/") { --- 166,185 ---- $SendCMD .= " Clear-sticky Template Set-checkin-prog Set-update-prog"; $SendCMD .= " Notified Module-expansion Wrapper-rcsOption M Mbinary E F MT\n"; fputs($this->SOCKET_HANDLE, $SendCMD); return true; ! } // End of if ($this->SOCKET_HANDLE > 0) return false; ! } // End of function SendValidResponses() function SendValidRequests() { if ($this->SOCKET_HANDLE > 0) { $SendCMD = "valid-requests\n"; fputs($this->SOCKET_HANDLE, $SendCMD); $RecvCMD = fgets($this->SOCKET_HANDLE, 8192); $dummy = fgets($this->SOCKET_HANDLE); return true; ! } // End of if ($this->SOCKET_HANDLE > 0) return false; ! } // End of function SendValidRequests() function RLOGDir($Module = "/") { *************** *** 226,246 **** if ($this->SOCKET_HANDLE > -1) { $SendCMD = "UseUnchanged\nCase\nArgument $Module\nrlog\n"; - - // Send this command to the PServer. fputs($this->SOCKET_HANDLE, $SendCMD); - - // Lets start receiving the response from the PServer. $RecvLN = ""; while(strncmp($RecvLN, "ok", 2) != 0){ $RecvLN = fgets($this->SOCKET_HANDLE); - - // 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); - if (strpos($FileName, '/') > 0) { - // This is a Directory, and not a file. $DirName = substr($FileName, 0, strpos($FileName, '/')+1); if (strpos($SeenThis, $DirName) === false) { --- 188,200 ---- *************** *** 248,253 **** $SeenThis .= $DirName; } // End of if (strpos($SeenThis, $DirName) === false) ! } else { ! // This is a file. $FileName2 = substr($FileName, 0, strlen($FileName)-3); $Elements[$FileName2]["FILENAME"] = $FileName2; --- 202,206 ---- $SeenThis .= $DirName; } // End of if (strpos($SeenThis, $DirName) === false) ! } else { // Else of if (strpos($FileName, '/') > 0) $FileName2 = substr($FileName, 0, strlen($FileName)-3); $Elements[$FileName2]["FILENAME"] = $FileName2; *************** *** 255,267 **** $RecvLN = fgets($this->SOCKET_HANDLE, 8192); if (strncmp($RecvLN, "M head:", 7) == 0) { - // This contains the HEAD revision. $Elements[$FileName2]["HEAD"] = substr($RecvLN, 8, strlen($RecvLN)-9); } // End of if (strncmp($RecvLN, "M head:", 7) == 0) if (strncmp($RecvLN, "M branch:", 9) == 0) { - // This contains the Branch revision. $Elements[$FileName2]["BRANCH"] = substr($RecvLN, 10, strlen($RecvLN)-10); } // End of if (strncmp($RecvLN, "M branch:", 9) == 0) if (strncmp($RecvLN, "M -----", 7) == 0) { - // This subsection contains the description and other revision based information. while(strncmp($RecvLN, "M revision ", 11) != 0) { $RecvLN = fgets($this->SOCKET_HANDLE, 8192); --- 208,217 ---- *************** *** 300,308 **** if ($this->SOCKET_HANDLE > -1) { $SendCMD = "UseUnchanged\nCase\nArgument ".$Module.$File."\nrlog\n"; - - // Send this command to the PServer. fputs($this->SOCKET_HANDLE, $SendCMD); - - // Lets start receiving the response from the PServer. $RecvLN = ""; $CurrentRevision = ""; --- 250,254 ---- *************** *** 310,322 **** $Elements["CODE"] = ""; while(strncmp($RecvLN, "ok", 2) != 0){ - // if we have a line beginning with 'M revision' then this is a new revision. if (strncmp("M revision", $RecvLN, 10) == 0) { - // New Revision details. $RevisionCounter = $RevisionCounter + 1; $CurrentRevision = substr($RecvLN, 11, strlen($RecvLN)-11); $Elements[$RevisionCounter]["Revision"] = $CurrentRevision; $RecvLN = fgets($this->SOCKET_HANDLE); - - // This line contains the Date, Author, State, and Line Counts. strtok($RecvLN, " :;\n\t"); strtok(" :;\t\n"); --- 256,264 ---- *************** *** 330,397 **** $Elements[$RevisionCounter]["LinesAdd"] = substr(strtok(" :;\n\t"), 1); $Elements[$RevisionCounter]["LinesSub"] = substr(strtok(" :;\n\t"), 1); - - // The following lines up until we get minuses or equals is the revision log. $RecvLN = fgets($this->SOCKET_HANDLE); $Elements[$RevisionCounter]["Log"] = ""; while((strncmp("M ----------------------------", $RecvLN, 30) != 0) && (strncmp("M ============================", $RecvLN, 30) != 0)){ - // Add the text to the log. $Elements[$RevisionCounter]["Log"] .= substr($RecvLN, 2); $RecvLN = fgets($this->SOCKET_HANDLE); ! } // while ! } ! ! // if we have a line beginning with 'M RCS file' then we have the full file system path of the file. if (strncmp("M RCS file", $RecvLN, 10) == 0) { - // Pull out the Full RCS filename. strtok($RecvLN, " :\t\n"); strtok(" :\t\n"); strtok(" :\t\n"); $Elements[0]["RCSFile"] = strtok(" :\t\n"); ! } ! ! // if we have a line beginning with 'M head' then we have the head revision number for this file. if (strncmp("M head", $RecvLN, 6) == 0) { - // Pull out the head revision. strtok($RecvLN, " :\t\n"); strtok(" :\t\n"); $Elements[0]["HeadRev"] = strtok(" :\t\n"); ! } ! ! // if we have a line beginning with 'M branch' then we have the name of the head branch. if (strncmp("M branch", $RecvLN, 8) == 0) { - // Pull out the head branch. strtok($RecvLN, " :\t\n"); strtok(" :\t\n"); $Elements[0]["HeadBranch"] = strtok(" :\t\n"); ! } ! ! // if we have a line beginning with 'M locks' then we have the locking scheme in use by this CVS server. if (strncmp("M locks", $RecvLN, 7) == 0) { - // Pull out the locking methodology. strtok($RecvLN, " :\t\n"); strtok(" :\t\n"); $Elements[0]["Locks"] = strtok(" :\t\n"); ! } ! ! // if we have a line beginning with 'M access list' then we have the current accessing list. if (strncmp("M access list", $RecvLN, 13) == 0) { - // Pull out the accessing list. strtok($RecvLN, " :\t\n"); strtok(" :\t\n"); strtok(" :\t\n"); $Elements[0]["AccessList"] = strtok(" :\t\n"); ! } ! ! // if we have a line beginning with 'M symbolic names' then we have the list of symbolic names for this file. if (strncmp("M symbolic names", $RecvLN, 16) == 0) { - // Pull out the symbolic names. strtok($RecvLN, " :\t\n"); strtok(" :\t\n"); strtok(" :\t\n"); $Elements[0]["SymNames"] = strtok(" :\t\n"); ! } ! ! // if we have a line beginning with 'M keyword substitution' then we have the keywork substitutions. if (strncmp("M keywork substitutions", $RecvLN, 23) == 0) { strtok($RecvLN, " :\t\n"); --- 272,320 ---- $Elements[$RevisionCounter]["LinesAdd"] = substr(strtok(" :;\n\t"), 1); $Elements[$RevisionCounter]["LinesSub"] = substr(strtok(" :;\n\t"), 1); $RecvLN = fgets($this->SOCKET_HANDLE); + while (strncmp("M branches", $RecvLN, 10) == 0) { + $Elements[$RevisionCounter]["Branches"] = substr($RecvLN, 11, strlen($RecvLN)-11); + $RecvLN = fgets($this->SOCKET_HANDLE); + } // End of while (strncmp("M branches", $RecvLN, 10) == 0) $Elements[$RevisionCounter]["Log"] = ""; while((strncmp("M ----------------------------", $RecvLN, 30) != 0) && (strncmp("M ============================", $RecvLN, 30) != 0)){ $Elements[$RevisionCounter]["Log"] .= substr($RecvLN, 2); $RecvLN = fgets($this->SOCKET_HANDLE); ! } // End of while looking for end of section (revision) ! } // End of if (strncmp("M revision", $RecvLN, 10) == 0) if (strncmp("M RCS file", $RecvLN, 10) == 0) { strtok($RecvLN, " :\t\n"); strtok(" :\t\n"); strtok(" :\t\n"); $Elements[0]["RCSFile"] = strtok(" :\t\n"); ! } // End of if (strncmp("M RCS file", $RecvLN, 10) == 0) if (strncmp("M head", $RecvLN, 6) == 0) { strtok($RecvLN, " :\t\n"); strtok(" :\t\n"); $Elements[0]["HeadRev"] = strtok(" :\t\n"); ! } // End of if (strncmp("M head", $RecvLN, 6) == 0) if (strncmp("M branch", $RecvLN, 8) == 0) { strtok($RecvLN, " :\t\n"); strtok(" :\t\n"); $Elements[0]["HeadBranch"] = strtok(" :\t\n"); ! } // End of if (strncmp("M branch", $RecvLN, 8) == 0) if (strncmp("M locks", $RecvLN, 7) == 0) { strtok($RecvLN, " :\t\n"); strtok(" :\t\n"); $Elements[0]["Locks"] = strtok(" :\t\n"); ! } // End of if (strncmp("M locks", $RecvLN, 7) == 0) if (strncmp("M access list", $RecvLN, 13) == 0) { strtok($RecvLN, " :\t\n"); strtok(" :\t\n"); strtok(" :\t\n"); $Elements[0]["AccessList"] = strtok(" :\t\n"); ! } // End of if (strncmp("M access list", $RecvLN, 13) == 0) if (strncmp("M symbolic names", $RecvLN, 16) == 0) { strtok($RecvLN, " :\t\n"); strtok(" :\t\n"); strtok(" :\t\n"); $Elements[0]["SymNames"] = strtok(" :\t\n"); ! } // End of if (strncmp("M symbolic names", $RecvLN, 16) == 0) if (strncmp("M keywork substitutions", $RecvLN, 23) == 0) { strtok($RecvLN, " :\t\n"); *************** *** 399,405 **** strtok(" :\t\n"); $Elements[0]["KeywrdSubst"] = strtok(" :\t\n"); ! } ! ! $Elements["CODE"] .= substr($RecvLN, 2, strlen($RecvLN)-2); $RecvLN = fgets($this->SOCKET_HANDLE); } // End of while(strncmp($RecvLN, "ok", 2) != 0) --- 322,326 ---- strtok(" :\t\n"); $Elements[0]["KeywrdSubst"] = strtok(" :\t\n"); ! } // End of if (strncmp("M keywork substitutions", $RecvLN, 23) == 0) $RecvLN = fgets($this->SOCKET_HANDLE); } // End of while(strncmp($RecvLN, "ok", 2) != 0) *************** *** 410,443 **** 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); --- 331,355 ---- function ViewFile($File, $Revision, $Module="/") { if (strncmp($Module, "/", 1) == 0) { $Module = substr($Module, 1, strlen($Module)-1); ! } // End of if (strncmp($Module, "/", 1) == 0) $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) $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); $Elements = ""; $RecvLN = ""; while(strncmp($RecvLN, "ok", 2) != 0){ if (strncmp($RecvLN, "Clear-sticky ", 13) == 0) { $RecvLN = fgets($this->SOCKET_HANDLE, 8192); ! } // End of if (strncmp($RecvLN, "Clear-sticky ", 13) == 0) if (strncmp($RecvLN, "Set-static-directory ", 21) == 0) { $RecvLN = fgets($this->SOCKET_HANDLE, 8192); ! } // End of if (strncmp($RecvLN, "Set-static-directory ", 21) == 0) if (strncmp($RecvLN, "Mod-time", 8) == 0) { $Elements["DATETIME"] = substr($RecvLN, 9, strlen($RecvLN)-9); $RecvLN = fgets($this->SOCKET_HANDLE); *************** *** 446,473 **** if (strncmp($RecvLN, "MT -updated", 11) == 0) { $RecvLN = ""; ! } ! } // while ! } if (strncmp($RecvLN, "Created", 7) == 0) { - - // 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; $Elements["CONTENT"] = fread($this->SOCKET_HANDLE, $TotalBytes); ! } $RecvLN = fgets($this->SOCKET_HANDLE); } // End of while(strncmp($RecvLN, "ok", 2) != 0) - return $Elements; ! } function CVSLogon() { - // Here we will login to the CVS PServer (or local filesystem if the - // CVSPSERVER variable is a blank string). if ($this->CVS_PSERVER == '') { // We are logging into a locally connected filesystem. --- 358,378 ---- if (strncmp($RecvLN, "MT -updated", 11) == 0) { $RecvLN = ""; ! } // End of if (strncmp($RecvLN, "MT -updated", 11) == 0) ! } // End of while(strncmp($RecvLN, "MT", 2) == 0) ! } // End of if (strncmp($RecvLN, "Mod-time", 8) == 0) if (strncmp($RecvLN, "Created", 7) == 0) { $RecvLN = fgets($this->SOCKET_HANDLE); $RecvLN = fgets($this->SOCKET_HANDLE); $RecvLN = fgets($this->SOCKET_HANDLE); $RecvLN = fgets($this->SOCKET_HANDLE); $TotalBytes = $RecvLN + 0; $Elements["CONTENT"] = fread($this->SOCKET_HANDLE, $TotalBytes); ! } // End of if (strncmp($RecvLN, "Created", 7) == 0) $RecvLN = fgets($this->SOCKET_HANDLE); } // End of while(strncmp($RecvLN, "ok", 2) != 0) return $Elements; ! } // End of function ViewFile($File, $Revision, $Module="/") function CVSLogon() { if ($this->CVS_PSERVER == '') { // We are logging into a locally connected filesystem. Index: phpcvsmime.php =================================================================== RCS file: /cvsroot/phpcvsview/phpcvsview/phpcvsmime.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** phpcvsmime.php 6 Apr 2003 06:50:06 -0000 1.2 --- phpcvsmime.php 7 Apr 2003 08:23:59 -0000 1.3 *************** *** 2,9 **** /** ! * * * @version $Id$ ! * @copyright 2002 ARECOM International **/ --- 2,13 ---- /** ! * This source code is distributed under the terms as layed out in the ! * GNU General Public License. ! * ! * Purpose: To provide the mime translations required for downloading * + * @author Brian A Cheeseman <br...@bc...> * @version $Id$ ! * @copyright 2003 Brian A Cheeseman **/ Index: test.php =================================================================== RCS file: /cvsroot/phpcvsview/phpcvsview/test.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test.php 6 Apr 2003 06:46:51 -0000 1.4 --- test.php 7 Apr 2003 08:23:59 -0000 1.5 *************** *** 9,14 **** $REPOS = ""; ! $CVSROOT = "/cvsroot/d/de/denet/"; ! //$CVSROOT = "/cvsroot/p/ph/phpcvsview/"; $PServer = "cvs.sourceforge.net"; $UserName = "anonymous"; --- 9,14 ---- $REPOS = ""; ! //$CVSROOT = "/cvsroot/d/de/denet/"; ! $CVSROOT = "/cvsroot/p/ph/phpcvsview/"; $PServer = "cvs.sourceforge.net"; $UserName = "anonymous"; |