[Phpcvsview-cvs-updates] phpcvsview phpcvs.php,1.3,1.4 test.php,1.3,1.4
Status: Pre-Alpha
Brought to you by:
bcheesem
From: <bch...@us...> - 2003-04-06 06:46:54
|
Update of /cvsroot/phpcvsview/phpcvsview In directory sc8-pr-cvs1:/tmp/cvs-serv1049 Modified Files: phpcvs.php test.php Log Message: Added File Log to both class and test.php. Added download capability to the File Log screen. Added syntax highlighting to the view file screen for PHP files using the internal highlighter Index: phpcvs.php =================================================================== RCS file: /cvsroot/phpcvsview/phpcvsview/phpcvs.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** phpcvs.php 22 Mar 2003 05:38:52 -0000 1.3 --- phpcvs.php 6 Apr 2003 06:46:51 -0000 1.4 *************** *** 24,31 **** **/ ! function phpcvs( $Repository = '', ! $PServer = '', ! $UserName = '', ! $Password = '') { $this->CVS_REPOSITORY = $Repository; --- 24,31 ---- **/ ! function phpcvs($Repository = '', ! $PServer = '', ! $UserName = '', ! $Password = '') { $this->CVS_REPOSITORY = $Repository; *************** *** 306,312 **** // Lets start receiving the response from the PServer. $RecvLN = ""; while(strncmp($RecvLN, "ok", 2) != 0){ ! $Elements .= substr($RecvLN, 2, strlen($RecvLN)-2); } // End of while(strncmp($RecvLN, "ok", 2) != 0) } // End of if ($this->SOCKET_HANDLE > -1) return $Elements; --- 306,408 ---- // Lets start receiving the response from the PServer. $RecvLN = ""; + $CurrentRevision = ""; + $RevisionCounter = 0; + $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"); ! $Elements[$RevisionCounter]["Date"] = strtok(" ;\n\t"); ! $Elements[$RevisionCounter]["Time"] = strtok(" ;\n\t"); ! strtok(" :;\n\t"); ! $Elements[$RevisionCounter]["Author"] = strtok(" :;\n\t"); ! strtok(" :;\n\t"); ! $Elements[$RevisionCounter]["State"] = strtok(" :;\n\t"); ! strtok(" :;\n\t"); ! $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"); ! strtok(" :\t\n"); ! 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) + $Elements[0]["TotalRevisions"] = $RevisionCounter; } // End of if ($this->SOCKET_HANDLE > -1) return $Elements; *************** *** 355,360 **** 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); --- 451,454 ---- *************** *** 365,370 **** // 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); } --- 459,462 ---- Index: test.php =================================================================== RCS file: /cvsroot/phpcvsview/phpcvsview/test.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test.php 22 Mar 2003 05:38:52 -0000 1.3 --- test.php 6 Apr 2003 06:46:51 -0000 1.4 *************** *** 10,13 **** --- 10,14 ---- $REPOS = ""; $CVSROOT = "/cvsroot/d/de/denet/"; + //$CVSROOT = "/cvsroot/p/ph/phpcvsview/"; $PServer = "cvs.sourceforge.net"; $UserName = "anonymous"; *************** *** 15,18 **** --- 16,20 ---- include("phpcvs.php"); + include("phpcvsmime.php"); function DisplayDirListing () { *************** *** 78,82 **** } // End of function DisplayDirListing() ! function DisplayFileHistory() { global $REPOS, $CVSROOT, $PServer, $UserName, $Password; --- 80,84 ---- } // End of function DisplayDirListing() ! function DisplayFileHistory($FileName) { global $REPOS, $CVSROOT, $PServer, $UserName, $Password; *************** *** 87,94 **** $CVSServer->SendValidResponses(); $CVSServer->SendValidRequests(); ! $Elements = $CVSServer->RLOG ($REPOS); $CVSServer->DisconnectTcp(); } // End of if ($CVSServer->ConnectTcpAndLogon()) } // End of function DisplayFileHistory() --- 89,126 ---- $CVSServer->SendValidResponses(); $CVSServer->SendValidRequests(); ! $Elements = $CVSServer->RLOGFile($FileName, $REPOS); ! ! echo "<code>".str_replace("\n", "<BR>", $Elements["CODE"])."</code>"; ! ! // List each revision with a HorizRule between them. ! for ($i = 1; $i <= $Elements[0]["TotalRevisions"]; $i++) { ! echo "<HR>\n"; ! echo "Revision: ".$Elements[$i]["Revision"]." "; ! echo "[<A HREF=\"/test.php?CVSROOT=$REPOS&ShowFile=".$FileName."&Rev=".$Elements[$i]["Revision"]."\">View"; ! echo "</a>] "; ! ! echo "[<A HREF=\"/test.php?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"; ! echo "Time: ".$Elements[$i]["Time"]."<BR>\n"; ! 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()) } // End of function DisplayFileHistory() *************** *** 105,111 **** 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(); --- 137,180 ---- echo "<H1>File Contents for Revision ".$FileRev." of '".$REPOS.$FileToView."'</H1>"; $Elements = $CVSServer->ViewFile($FileToView, $FileRev, $REPOS); ! // Format and Display the output. ! if (strpos($FileToView, ".php")) { ! $OutText = highlight_string($Elements["CONTENT"], true); ! $OutText = str_replace("<code>", "<pre>", $OutText); ! $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>"; ! } ! // echo "<code>".ereg_replace(" ", " ", ereg_replace("\n", "<BR>", $Elements["CONTENT"]))."</code>"; ! ! $CVSServer->DisconnectTcp(); ! } ! } ! ! function DownloadFile() { ! global $REPOS, $CVSROOT, $PServer, $UserName, $Password, $FileToDownload, $FileRev, $MIME_TYPE; ! ! $CVSServer = new phpcvs($CVSROOT, $PServer, $UserName, $Password); ! ! if ($CVSServer->ConnectTcpAndLogon()) { ! $CVSServer->SendRoot(); ! $CVSServer->SendValidResponses(); ! $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(); *************** *** 130,136 **** // 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. ! DisplayDirListing(); } } --- 199,212 ---- // Here we will show the Revision History of a given file. echo "<H1>Revision History for '".$REPOS.$_GET["ShowHist"]."'</H1>"; + 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(); ! } } } |