[phpcvsview-cvs-updates] phpcvsview func_FileView.php,NONE,1.1 cvsview.php,1.11,1.12 func_DirListing
Status: Pre-Alpha
Brought to you by:
bcheesem
From: Brian C. <bch...@us...> - 2004-10-02 05:54:17
|
Update of /cvsroot/phpcvsview/phpcvsview In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16622 Modified Files: cvsview.php func_DirListing.php func_FileAnnotation.php func_FileHistory.php phpcvs.php Added Files: func_FileView.php Log Message: Basic TEXT file viewing is operational. Altered the date handling for the differential dates to work off GMT. We now see the correct time differences. Index: func_FileHistory.php =================================================================== RCS file: /cvsroot/phpcvsview/phpcvsview/func_FileHistory.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** func_FileHistory.php 2 Oct 2004 01:46:19 -0000 1.1 --- func_FileHistory.php 2 Oct 2004 04:52:10 -0000 1.2 *************** *** 48,52 **** $HREF = str_replace("//", "/", "$ScriptName?mp=$ModPath"); $DateTime = strtotime($Revision["date"]); ! echo "<hr>\n"; echo "<b>Revision</b> ".$Revision["Revision"]." -"; echo " (<a href=\"$HREF&fv&dt=$DateTime\">view</a>)"; --- 48,52 ---- $HREF = str_replace("//", "/", "$ScriptName?mp=$ModPath"); $DateTime = strtotime($Revision["date"]); ! echo "<a name=\"$DateTime\"><hr>\n"; echo "<b>Revision</b> ".$Revision["Revision"]." -"; echo " (<a href=\"$HREF&fv&dt=$DateTime\">view</a>)"; *************** *** 55,59 **** echo strtotime($CVSServer->FILES[0]["Revisions"][$Revision["PrevRevision"]]["date"])."\">diff to previous</a>)"; echo " (<a href=\"$HREF&fa=".$Revision["Revision"]."\">annotate</a>)<br>\n"; ! echo "<b>Last Checkin:</b> ".strftime("%A %d %b %Y %T -0000", strtotime($Revision["date"]))." (".CalculateDateDiff(strtotime($Revision["date"]), time())." ago)<br>\n"; echo "<b>Branch:</b> ".$Revision["Branches"]."<br>\n"; echo "<b>Date:</b> ".strftime("%B %d, %Y", $DateTime)."<br>\n"; --- 55,59 ---- echo strtotime($CVSServer->FILES[0]["Revisions"][$Revision["PrevRevision"]]["date"])."\">diff to previous</a>)"; echo " (<a href=\"$HREF&fa=".$Revision["Revision"]."\">annotate</a>)<br>\n"; ! echo "<b>Last Checkin:</b> ".strftime("%A %d %b %Y %T -0000", strtotime($Revision["date"]))." (".CalculateDateDiff(strtotime($Revision["date"]), strtotime(gmdate("M d Y H:i:s")))." ago)<br>\n"; echo "<b>Branch:</b> ".$Revision["Branches"]."<br>\n"; echo "<b>Date:</b> ".strftime("%B %d, %Y", $DateTime)."<br>\n"; Index: phpcvs.php =================================================================== RCS file: /cvsroot/phpcvsview/phpcvsview/phpcvs.php,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** phpcvs.php 2 Oct 2004 01:47:17 -0000 1.11 --- phpcvs.php 2 Oct 2004 04:52:10 -0000 1.12 *************** *** 70,73 **** --- 70,74 ---- var $CURRENT_FILE; // The current file we are building up. var $ANNOTATION = array(); // An array of the lines in the file which has been annotated. + var $FILECONTENTS = ""; // A string to store the lines of the file contents in. /** *************** *** 143,146 **** --- 144,196 ---- } + // *************************************************************************** + // Function: processClearSticky() + // Author: Brian A Cheeseman. + // Parameters: string - Line of response text. + // Return Value: boolean - Are we expecting more responses to come in? + // *************************************************************************** + function processClearSticky($LineOfText) + { + $this->SOCKET->readLine(); + return true; + } + + // *************************************************************************** + // Function: processSetStaticDirectory() + // Author: Brian A Cheeseman. + // Parameters: string - Line of response text. + // Return Value: boolean - Are we expecting more responses to come in? + // *************************************************************************** + function processSetStaticDirectory($LineOfText) + { + $this->SOCKET->readLine(); + return true; + } + + // *************************************************************************** + // Function: processModTime() + // Author: Brian A Cheeseman. + // Parameters: string - Line of response text. + // Return Value: boolean - Are we expecting more responses to come in? + // *************************************************************************** + function processModTime($LineOfText) + { + return true; + } + + // *************************************************************************** + // Function: processCreated() + // Author: Brian A Cheeseman. + // Parameters: string - Line of response text. + // Return Value: boolean - Are we expecting more responses to come in? + // *************************************************************************** + function processCreated($LineOfText) + { + $this->SOCKET->readLine(); + $this->SOCKET->readLine(); + $this->SOCKET->readLine(); + return false; + } + /** * *************** *** 590,593 **** --- 640,694 ---- } + // *************************************************************************** + // Function: sendExpandModules() + // Author: Brian A Cheeseman. + // Parameters: None. + // Return Value: boolean - Successfully sent. + // *************************************************************************** + function sendExpandModules() + { + if ($this->ALLOWED_REQUESTS["expand-modules"] == true) { + if ($this->SOCKET->write("expand-modules\n") != true) { + return false; + } + } + $this->processResponse(); + return true; + } + + // *************************************************************************** + // Function: sendExportFile() + // Author: Brian A Cheeseman. + // Parameters: None. + // Return Value: boolean - Successfully sent. + // *************************************************************************** + function sendExportFile() + { + if ($this->ALLOWED_REQUESTS["export"] == true) { + if ($this->SOCKET->write("export\n") != true) { + return false; + } + } + $this->processResponse(); + + // Here the first line is the length, the remaining (upto the 'ok') + // is the content of the file. + if ($this->FINAL_RESPONSE) { + $ReadLine = $this->SOCKET->readLine(); + $ReadLine = $this->SOCKET->readLine(); + $Counter = 0; + while($ReadLine != "ok"){ + $this->FILECONTENTS .= $ReadLine."\n"; + $ReadLine = $this->SOCKET->readLine(); + } // while + + return true; + } + else + { + return false; + } + } + /** * Helper Methods. *************** *** 873,876 **** --- 974,1045 ---- return true; } + + // *************************************************************************** + // Function: ExportFile() + // Author: Brian A Cheeseman. + // Parameters: string - Name of file to export. + // integer - Date/Time of revision to export. + // Return Value: boolean - Were we successful. + // *************************************************************************** + function ExportFile($FileName, $DateTime) + { + $this->sendCVSROOT(); + $this->sendValidResponses(); + $this->sendValidRequests(); + + if (strncmp($FileName, "/", 1) == 0) { + $FName = substr($FileName, 1); + } + else + { + $FName = $FileName; + } + + if (!$this->sendUseUnchanged()) { + return false; + } + + if (!$this->sendArgument($FName)) { + return false; + } + + if (!$this->sendDirectory(".")) { + return false; + } + + if (!$this->sendExpandModules()) { + return false; + } + + if (!$this->sendArgument("-N")) { + return false; + } + + if (!$this->sendArgument("-D")) { + return false; + } + + if (!$this->sendArgument(strftime("%d %b %Y %T -0000", $DateTime))) { + return false; + } + + if (!$this->sendArgument("--")) { + return false; + } + + if (!$this->sendArgument($FName)) { + return false; + } + + if (!$this->sendDirectory(".")) { + return false; + } + + if (!$this->sendExportFile()) { + return false; + } + + return true; + } } Index: func_DirListing.php =================================================================== RCS file: /cvsroot/phpcvsview/phpcvsview/func_DirListing.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** func_DirListing.php 2 Oct 2004 02:53:35 -0000 1.2 --- func_DirListing.php 2 Oct 2004 04:52:10 -0000 1.3 *************** *** 95,99 **** $HREF = str_replace("//", "/", "$ScriptName?mp=$ModPath/".$File["Name"]); $DateTime = strtotime($File["Revisions"][$File["Head"]]["date"]); ! $AGE = CalculateDateDiff($DateTime, time()); echo " <tr bgcolor=\"$BGColor\" valign=\"top\">\n"; echo " <td align=\"center\" valign=\"center\"><a href=\"$HREF&fh\"><img border=\"0\" src=\"$ScriptPath/images/file.png\"></a></td>\n"; --- 95,99 ---- $HREF = str_replace("//", "/", "$ScriptName?mp=$ModPath/".$File["Name"]); $DateTime = strtotime($File["Revisions"][$File["Head"]]["date"]); ! $AGE = CalculateDateDiff($DateTime, strtotime(gmdate("M d Y H:i:s"))); echo " <tr bgcolor=\"$BGColor\" valign=\"top\">\n"; echo " <td align=\"center\" valign=\"center\"><a href=\"$HREF&fh\"><img border=\"0\" src=\"$ScriptPath/images/file.png\"></a></td>\n"; --- NEW FILE: func_FileView.php --- <?php /** * This source code is distributed under the terms as layed out in the * GNU General Public License. * * Purpose: To provide File View Page. * * @author Brian A Cheeseman <bch...@us...> * @version $Id: func_FileView.php,v 1.1 2004/10/02 04:52:10 bcheesem Exp $ * @copyright 2003-2004 Brian A Cheeseman **/ function DisplayFileContents($File, $Revision = "") { global $ModPath, $CVSROOT, $PServer, $UserName, $Password, $ScriptName, $HTMLTitle, $HTMLHeading, $HTMLTblHdBg, $HTMLTblCell1, $HTMLTblCell2; // Calculate the path from the $ScriptName variable. $ScriptPath = substr($ScriptName, 0, strrpos($ScriptName, "/")); if ($ScriptPath == "") { $ScriptPath = "/"; } // Create our CVS connection object and set the required properties. $CVSServer = new CVS_PServer($CVSROOT, $PServer, $UserName, $Password); // Start the output process. echo GetPageHeader($HTMLTitle, $HTMLHeading); // 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 $ModPath. $CVSServer->RLog($ModPath); // "Export" the file. $Response = $CVSServer->ExportFile($File, $Revision); if ($Response !== true) { return; } // Start the output for the file. $Dirs = explode("/", $ModPath); echo "Navigate to: <a href=\"$ScriptName\">Root</a> "; $intCount = 1; while($intCount < count($Dirs)){ echo "/ <a href=\"$ScriptName?mp=".ImplodeToPath($Dirs, "/", $intCount); if ($intCount == (count($Dirs) - 1)) { echo "&fh#$Revision"; } else { echo "/"; } echo "\">".$Dirs[$intCount]."</a> "; $intCount++; } // while echo "<br>\n"; // Display the file contents. echo "<hr>\n"; if (strpos($File, ".php")) { echo highlight_string($CVSServer->FILECONTENTS, true); } else { $search = array('<', '>', '\n'); $replace = array("<", ">", ""); echo "<pre>\n"; echo str_replace($search, $replace, $CVSServer->FILECONTENTS)."\n"; echo "</pre>\n"; } // Close the connection. $CVSServer->Disconnect(); } else { echo "ERROR: Could not connect to the PServer.<br>\n"; } } ?> Index: cvsview.php =================================================================== RCS file: /cvsroot/phpcvsview/phpcvsview/cvsview.php,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** cvsview.php 2 Oct 2004 01:46:18 -0000 1.11 --- cvsview.php 2 Oct 2004 04:52:10 -0000 1.12 *************** *** 37,40 **** --- 37,41 ---- require_once 'func_FileHistory.php'; require_once 'func_FileAnnotation.php'; + require_once 'func_FileView.php'; *************** *** 57,61 **** else { ! DisplayDirListing(); } } --- 58,68 ---- else { ! if (isset($_GET["fv"])) { ! DisplayFileContents($ModPath, $_GET["dt"]); ! } ! else ! { ! DisplayDirListing(); ! } } } Index: func_FileAnnotation.php =================================================================== RCS file: /cvsroot/phpcvsview/phpcvsview/func_FileAnnotation.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** func_FileAnnotation.php 2 Oct 2004 01:46:19 -0000 1.1 --- func_FileAnnotation.php 2 Oct 2004 04:52:10 -0000 1.2 *************** *** 54,58 **** foreach ($CVSServer->ANNOTATION as $Annotation) { - $result = str_replace($search, $replace, $email); echo "<tr bgcolor=\"$BGColor\"><td nowrap><pre>".$Annotation["Revision"]."</pre></td><td nowrap><pre>".$Annotation["Author"]; echo "</pre></td><td nowrap><pre>".$Annotation["Date"]."</pre></td><td nowrap><pre>".str_replace($search, $replace, $Annotation["Line"])."</pre></td></tr>\n"; --- 54,57 ---- |