[phpcvsview-cvs-updates] phpcvsview phpcvs.php,1.23,1.24
Status: Pre-Alpha
Brought to you by:
bcheesem
From: Sijis A. <si...@us...> - 2005-02-24 06:33:27
|
Update of /cvsroot/phpcvsview/phpcvsview In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15103 Modified Files: phpcvs.php Log Message: - added debug variable and made changes accordingly to handle new variable - added default value to array index branches to remove undefined errors given - fixed logic/error for 'diff to previous' link on initial revision of file - minor cosmetic fixes Index: phpcvs.php =================================================================== RCS file: /cvsroot/phpcvsview/phpcvsview/phpcvs.php,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** phpcvs.php 4 Feb 2005 04:21:52 -0000 1.23 --- phpcvs.php 24 Feb 2005 06:33:15 -0000 1.24 *************** *** 1,3 **** --- 1,4 ---- <?php + error_reporting(E_ALL); /** *************** *** 9,13 **** * @author Brian A Cheeseman <bch...@us...> * @version $Id$ ! * @copyright 2003-2004 Brian A Cheeseman **/ --- 10,14 ---- * @author Brian A Cheeseman <bch...@us...> * @version $Id$ ! * @copyright 2003-2005 Brian A Cheeseman **/ *************** *** 59,63 **** "E" => "processE", "F" => "processF", ! "MT" => "processMT"); var $ALLOWED_REQUESTS = array(); // A hashed array of requests we are allowed to send. --- 60,65 ---- "E" => "processE", "F" => "processF", ! "MT" => "processMT" ! ); var $ALLOWED_REQUESTS = array(); // A hashed array of requests we are allowed to send. *************** *** 73,76 **** --- 75,79 ---- var $FILECONTENTS = ""; // A string to store the lines of the file contents in. var $INITIALISED = false; // A boolean to indicate whether we have already sent the Root/ValidRequests/ValidResponses. + var $DEBUG = false; // A boolean to enable/disable debug output /** *************** *** 284,288 **** // Define our constant array to provide a lookup table for the conversion // of the clear password to cipher text. ! $NewChars = array( '!' => 'x', '8' => '_', 'N' => '[', 'g' => 'I', '"' => '5', '9' => 'A', 'O' => '#', 'h' => 'c', --- 287,291 ---- // Define our constant array to provide a lookup table for the conversion // of the clear password to cipher text. ! $NewChars = array( '!' => 'x', '8' => '_', 'N' => '[', 'g' => 'I', '"' => '5', '9' => 'A', 'O' => '#', 'h' => 'c', *************** *** 363,387 **** // Send the start of authentication request. if ($this->SOCKET->write("BEGIN AUTH REQUEST\n") != true) { ! return false; } // Send the path to the repository we are attempting to connect to. if ($this->SOCKET->write($this->CVS_REPOSITORY."\n") != true) { ! return false; } // Send the user name to authenticate with. if ($this->SOCKET->write($this->CVS_USERNAME."\n") != true) { ! return false; } // Transform and send the password matching the username above. if ($this->SOCKET->write("A".$this->TransformPW($this->CVS_PASSWORD)."\n") != true) { ! return false; } // Send the terminator for the authentication request. if ($this->SOCKET->write("END AUTH REQUEST\n") != true) { ! return false; } --- 366,390 ---- // Send the start of authentication request. if ($this->SOCKET->write("BEGIN AUTH REQUEST\n") != true) { ! return false; } // Send the path to the repository we are attempting to connect to. if ($this->SOCKET->write($this->CVS_REPOSITORY."\n") != true) { ! return false; } // Send the user name to authenticate with. if ($this->SOCKET->write($this->CVS_USERNAME."\n") != true) { ! return false; } // Transform and send the password matching the username above. if ($this->SOCKET->write("A".$this->TransformPW($this->CVS_PASSWORD)."\n") != true) { ! return false; } // Send the terminator for the authentication request. if ($this->SOCKET->write("END AUTH REQUEST\n") != true) { ! return false; } *************** *** 389,393 **** $response = $this->SOCKET->readLine(); if ($response == true && strncmp($response, "I LOVE YOU", 10) == 0) { ! return true; } else { // Retrieve the error message from the PServer. --- 392,396 ---- $response = $this->SOCKET->readLine(); if ($response == true && strncmp($response, "I LOVE YOU", 10) == 0) { ! return true; } else { // Retrieve the error message from the PServer. *************** *** 396,408 **** $line = $this->SOCKET->readLine(); if (strncmp($line, "E ", 2) == 0) { ! $errorMsg .= substr($line, 2); } if (strncmp($line, "error", 5) == 0) { ! $this->SOCKET->disconnect(); } } if ($errorMsg == "") { ! return false; } else { return $errorMsg; --- 399,411 ---- $line = $this->SOCKET->readLine(); if (strncmp($line, "E ", 2) == 0) { ! $errorMsg .= substr($line, 2); } if (strncmp($line, "error", 5) == 0) { ! $this->SOCKET->disconnect(); } } if ($errorMsg == "") { ! return false; } else { return $errorMsg; *************** *** 417,443 **** // Return Value: boolean - Successfully sent. // *************************************************************************** ! function processResponse($Debug = false) { $this->MESSAGE_CONTENT = ""; $this->STDERR = ""; $KeepGoing = true; ! if ($Debug) { ! echo "<pre>"; ! } while($KeepGoing){ $ResponseLine = $this->SOCKET->readLine(); $Response = explode(" ", $ResponseLine); ! if ($Debug) { ! echo $ResponseLine."\n"; } if ($Response[0] != "") { $Func = $this->ALLOWED_RESPONSES[$Response[0]]; ! if (method_exists($this, $Func)) { ! $KeepGoing = $this->$Func($ResponseLine); } } } ! if ($Debug) { ! echo "</pre>"; } } --- 420,445 ---- // Return Value: boolean - Successfully sent. // *************************************************************************** ! function processResponse() { $this->MESSAGE_CONTENT = ""; $this->STDERR = ""; $KeepGoing = true; ! $debugMsg = ""; ! while($KeepGoing){ $ResponseLine = $this->SOCKET->readLine(); $Response = explode(" ", $ResponseLine); ! if ($this->DEBUG) { ! $debugMsg .= $ResponseLine."\n"; } if ($Response[0] != "") { $Func = $this->ALLOWED_RESPONSES[$Response[0]]; ! if (method_exists($this, $Func)) { ! $KeepGoing = $this->$Func($ResponseLine); } } } ! if ($this->DEBUG) { ! CVS_PServer::debug($debug); } } *************** *** 452,456 **** { if ($this->SOCKET->write("Root ".$this->CVS_REPOSITORY."\n") != true) { ! return false; } return true; --- 454,458 ---- { if ($this->SOCKET->write("Root ".$this->CVS_REPOSITORY."\n") != true) { ! return false; } return true; *************** *** 488,492 **** // Send the command to the pserver. if ($this->SOCKET->write("Valid-responses".$ValidResponses."\n") != true) { ! return false; } return true; --- 490,494 ---- // Send the command to the pserver. if ($this->SOCKET->write("Valid-responses".$ValidResponses."\n") != true) { ! return false; } return true; *************** *** 502,506 **** { if ($this->SOCKET->write("valid-requests\n") != true) { ! return false; } $this->processResponse(); --- 504,508 ---- { if ($this->SOCKET->write("valid-requests\n") != true) { ! return false; } $this->processResponse(); *************** *** 517,523 **** { if ($this->ALLOWED_REQUESTS["UseUnchanged"] == true) { ! if ($this->SOCKET->write("UseUnchanged\n") != true) { ! return false; ! } } return true; --- 519,525 ---- { if ($this->ALLOWED_REQUESTS["UseUnchanged"] == true) { ! if ($this->SOCKET->write("UseUnchanged\n") != true) { ! return false; ! } } return true; *************** *** 533,539 **** { if ($this->ALLOWED_REQUESTS["Argument"] == true) { ! if ($this->SOCKET->write("Argument $ArgToSend\n") != true) { ! return false; ! } } return true; --- 535,541 ---- { if ($this->ALLOWED_REQUESTS["Argument"] == true) { ! if ($this->SOCKET->write("Argument $ArgToSend\n") != true) { ! return false; ! } } return true; *************** *** 549,555 **** { if ($this->ALLOWED_REQUESTS["rlog"] == true) { ! if ($this->SOCKET->write("rlog\n") != true) { ! return false; ! } } return true; --- 551,557 ---- { if ($this->ALLOWED_REQUESTS["rlog"] == true) { ! if ($this->SOCKET->write("rlog\n") != true) { ! return false; ! } } return true; *************** *** 566,572 **** if ($this->ALLOWED_REQUESTS["Directory"] == true) { if (strncmp($Directory, "/", 1) == 0) { ! $Directory = substr($Directory, 1); } ! if ($this->SOCKET->write("Directory $Directory\n") == true) { $Line = $this->CVS_REPOSITORY; if ($Directory != ".") { --- 568,574 ---- if ($this->ALLOWED_REQUESTS["Directory"] == true) { if (strncmp($Directory, "/", 1) == 0) { ! $Directory = substr($Directory, 1); } ! if ($this->SOCKET->write("Directory $Directory\n") == true) { $Line = $this->CVS_REPOSITORY; if ($Directory != ".") { *************** *** 578,582 **** } else { return false; ! } } return true; --- 580,584 ---- } else { return false; ! } } return true; *************** *** 592,598 **** { if ($this->ALLOWED_REQUESTS["Static-directory"] == true) { ! if ($this->SOCKET->write("Static-directory\n") != true) { ! return false; ! } } return true; --- 594,600 ---- { if ($this->ALLOWED_REQUESTS["Static-directory"] == true) { ! if ($this->SOCKET->write("Static-directory\n") != true) { ! return false; ! } } return true; *************** *** 618,624 **** } ! if ($this->SOCKET->write("Entry /$FName/$Version/$Conflict/$Options/$TagOrDate\n") != true) { ! return false; ! } } return true; --- 620,626 ---- } ! if ($this->SOCKET->write("Entry /$FName/$Version/$Conflict/$Options/$TagOrDate\n") != true) { ! return false; ! } } return true; *************** *** 636,647 **** $SlashPos = strrpos($Name, "/"); if ($SlashPos !== false) { ! $BaseFileName = substr($Name, $SlashPos+1); } else { $BaseFileName = $Name; } ! if ($this->SOCKET->write("Unchanged $BaseFileName\n") != true) { ! return false; ! } } return true; --- 638,649 ---- $SlashPos = strrpos($Name, "/"); if ($SlashPos !== false) { ! $BaseFileName = substr($Name, $SlashPos+1); } else { $BaseFileName = $Name; } ! if ($this->SOCKET->write("Unchanged $BaseFileName\n") != true) { ! return false; ! } } return true; *************** *** 657,663 **** { if ($this->ALLOWED_REQUESTS["annotate"] == true) { ! if ($this->SOCKET->write("annotate\n") != true) { ! return false; ! } } return true; --- 659,665 ---- { if ($this->ALLOWED_REQUESTS["annotate"] == true) { ! if ($this->SOCKET->write("annotate\n") != true) { ! return false; ! } } return true; *************** *** 673,679 **** { if ($this->ALLOWED_REQUESTS["expand-modules"] == true) { ! if ($this->SOCKET->write("expand-modules\n") != true) { ! return false; ! } } $this->processResponse(); --- 675,681 ---- { if ($this->ALLOWED_REQUESTS["expand-modules"] == true) { ! if ($this->SOCKET->write("expand-modules\n") != true) { ! return false; ! } } $this->processResponse(); *************** *** 690,696 **** { if ($this->ALLOWED_REQUESTS["export"] == true) { ! if ($this->SOCKET->write("export\n") != true) { ! return false; ! } } $this->processResponse(); --- 692,698 ---- { if ($this->ALLOWED_REQUESTS["export"] == true) { ! if ($this->SOCKET->write("export\n") != true) { ! return false; ! } } $this->processResponse(); *************** *** 769,773 **** if (strncmp($Folder, "/", 1) == 0) { ! $Directory = substr($Folder, 1); } else { $Directory = $Folder; --- 771,775 ---- if (strncmp($Folder, "/", 1) == 0) { ! $Directory = substr($Folder, 1); } else { $Directory = $Folder; *************** *** 775,783 **** if (!$this->sendArgument($Directory)) { ! return false; } if (!$this->sendRLog()) { ! return false; } --- 777,785 ---- if (!$this->sendArgument($Directory)) { ! return false; } if (!$this->sendRLog()) { ! return false; } *************** *** 785,793 **** if (!($this->FINAL_RESPONSE)) { ! return $this->RLog(substr($Folder, 1)); } if ($Folder == "") { ! $Folder = "/"; } --- 787,795 ---- if (!($this->FINAL_RESPONSE)) { ! return $this->RLog(substr($Folder, 1)); } if ($Folder == "") { ! $Folder = "/"; } *************** *** 810,814 **** $TempLine = substr($Line, 10+strlen($this->CVS_REPOSITORY.$Folder)); if (strncmp($TempLine, "/", 1) == 0) { ! $TempLine = substr($TempLine, 1); } if (($SlashPos = strpos($TempLine, "/")) > 0) { --- 812,816 ---- $TempLine = substr($Line, 10+strlen($this->CVS_REPOSITORY.$Folder)); if (strncmp($TempLine, "/", 1) == 0) { ! $TempLine = substr($TempLine, 1); } if (($SlashPos = strpos($TempLine, "/")) > 0) { *************** *** 844,848 **** // Lets continue, but only if we have a CurrentDecode type of 2 (ie a file). if ($CurrentDecode == 2) { ! // Process for the remaining file attributes. // Head version of file. --- 846,850 ---- // Lets continue, but only if we have a CurrentDecode type of 2 (ie a file). if ($CurrentDecode == 2) { ! // Process for the remaining file attributes. // Head version of file. *************** *** 855,858 **** --- 857,861 ---- if (strncmp($Line, "branch:", 7) == 0) { $this->FILES[$FileCount]["Branch"] = trim(substr($Line, 8)); + //$this->FILES[$FileCount]["Branch"] = (strlen($Line) > 7) ? trim(substr($Line, 8)) : "Main"; $LineProcessed = true; } *************** *** 872,876 **** // Process the symbolic names. if (strncmp($Line, "symbolic names:", 15) == 0) { ! $LineProcessed = true; } --- 875,879 ---- // Process the symbolic names. if (strncmp($Line, "symbolic names:", 15) == 0) { ! $LineProcessed = true; } *************** *** 886,890 **** // Process the Keyword Substitution. if (strncmp($Line, "keyword substitution:", 21) == 0) { ! $this->FILES[$FileCount]["KeywordSubst"] = trim(substr($Line, 22)); $LineProcessed = true; } --- 889,893 ---- // Process the Keyword Substitution. if (strncmp($Line, "keyword substitution:", 21) == 0) { ! $this->FILES[$FileCount]["KeywordSubst"] = trim(substr($Line, 22)); $LineProcessed = true; } *************** *** 892,896 **** // Process the Total Revisions. if (strncmp($Line, "total revisions:", 16) == 0) { ! $TempLine = substr($Line, 17); $this->FILES[$FileCount]["TotalRevs"] = trim(substr($TempLine, 0, strpos($TempLine, ";"))); $this->FILES[$FileCount]["SelectedRevs"] = trim(substr($TempLine, strpos($TempLine, ";")+22)); --- 895,899 ---- // Process the Total Revisions. if (strncmp($Line, "total revisions:", 16) == 0) { ! $TempLine = substr($Line, 17); $this->FILES[$FileCount]["TotalRevs"] = trim(substr($TempLine, 0, strpos($TempLine, ";"))); $this->FILES[$FileCount]["SelectedRevs"] = trim(substr($TempLine, strpos($TempLine, ";")+22)); *************** *** 900,904 **** // Process the description. if (strncmp($Line, "description:", 12) == 0) { ! $this->FILES[$FileCount]["Description"] = trim(substr($Line, 13)); $LineProcessed = true; } --- 903,907 ---- // Process the description. if (strncmp($Line, "description:", 12) == 0) { ! $this->FILES[$FileCount]["Description"] = trim(substr($Line, 13)); $LineProcessed = true; } *************** *** 906,920 **** // Process the individual revision information. if (strncmp($Line, "-------------", 13) == 0) { ! $LineProcessed = true; } // Get this revision number. if (strncmp($Line, "revision", 8) == 0) { ! $CurrentRevision = substr($Line, 9); $this->FILES[$FileCount]["Revisions"]["$CurrentRevision"]["Revision"] = $CurrentRevision; $this->FILES[$FileCount]["Revisions"]["$CurrentRevision"]["LogMessage"] = ""; if ($PreviousRevision != "") { $this->FILES[$FileCount]["Revisions"]["$PreviousRevision"]["PrevRevision"] = $CurrentRevision; } $PreviousRevision = $CurrentRevision; $LineProcessed = true; --- 909,933 ---- // Process the individual revision information. if (strncmp($Line, "-------------", 13) == 0) { ! $LineProcessed = true; } // Get this revision number. if (strncmp($Line, "revision", 8) == 0) { ! $CurrentRevision = substr($Line, 9); $this->FILES[$FileCount]["Revisions"]["$CurrentRevision"]["Revision"] = $CurrentRevision; $this->FILES[$FileCount]["Revisions"]["$CurrentRevision"]["LogMessage"] = ""; + + // hack: set branches default for current version + $this->FILES[$FileCount]["Revisions"]["$CurrentRevision"]["Branches"] = "Main"; + if ($PreviousRevision != "") { $this->FILES[$FileCount]["Revisions"]["$PreviousRevision"]["PrevRevision"] = $CurrentRevision; } + + // temporary solution for initial file revision not having a previous version to create a diff + if ($CurrentRevision == "1.1") { + $this->FILES[$FileCount]["Revisions"]["$CurrentRevision"]["PrevRevision"] = ""; + } + $PreviousRevision = $CurrentRevision; $LineProcessed = true; *************** *** 923,927 **** // Get the Date, Author, State and Lines of this revision. if (strncmp($Line, "date:", 5) == 0) { ! $Segment = explode(";", $Line); foreach($Segment as $Part){ $SepPos = trim(strpos($Part, ":")); --- 936,940 ---- // Get the Date, Author, State and Lines of this revision. if (strncmp($Line, "date:", 5) == 0) { ! $Segment = explode(";", $Line); foreach($Segment as $Part){ $SepPos = trim(strpos($Part, ":")); *************** *** 936,940 **** if (strncmp($Line, "branches:", 9) == 0) { $this->FILES[$FileCount]["Revisions"]["$CurrentRevision"]["Branches"] = trim(substr($Line, 10)); ! $LineProcessed = true; } --- 949,954 ---- if (strncmp($Line, "branches:", 9) == 0) { $this->FILES[$FileCount]["Revisions"]["$CurrentRevision"]["Branches"] = trim(substr($Line, 10)); ! //$this->FILES[$FileCount]["Revisions"]["$CurrentRevision"]["Branches"] = (strlen($Line) > 9) ? trim(substr($Line, 10)) : "Main"; ! $LineProcessed = true; } *************** *** 948,956 **** if (!$LineProcessed) { if (strlen($this->FILES[$FileCount]["Revisions"]["$CurrentRevision"]["LogMessage"]) > 0) { ! $this->FILES[$FileCount]["Revisions"]["$CurrentRevision"]["LogMessage"] .= "\n"; } $Line = trim($Line); if ($Line != "") { ! $this->FILES[$FileCount]["Revisions"]["$CurrentRevision"]["LogMessage"] .= trim($Line); } } --- 962,970 ---- if (!$LineProcessed) { if (strlen($this->FILES[$FileCount]["Revisions"]["$CurrentRevision"]["LogMessage"]) > 0) { ! $this->FILES[$FileCount]["Revisions"]["$CurrentRevision"]["LogMessage"] .= "\n"; } $Line = trim($Line); if ($Line != "") { ! $this->FILES[$FileCount]["Revisions"]["$CurrentRevision"]["LogMessage"] .= trim($Line); } } *************** *** 976,989 **** if (!$this->sendUseUnchanged()) { ! return false; } if (!$this->sendArgument("--")) { ! return false; } $SlashPos = strrpos($Name, "/"); if ($SlashPos > -1) { ! $Directory = substr($Name, 0, $SlashPos); } else { $Directory = "/"; --- 990,1003 ---- if (!$this->sendUseUnchanged()) { ! return false; } if (!$this->sendArgument("--")) { ! return false; } $SlashPos = strrpos($Name, "/"); if ($SlashPos > -1) { ! $Directory = substr($Name, 0, $SlashPos); } else { $Directory = "/"; *************** *** 991,1015 **** if (!$this->sendDirectory($Directory)) { ! return false; } if (!$this->sendStaticDirectory()) { ! return false; } if (!$this->sendEntry($Name, $Revision)) { ! return false; } if (!$this->sendUnchanged($Name)) { ! return false; } if (!$this->sendDirectory(".")) { ! return false; } if (strncmp($Name, "/", 1) == 0) { ! $Arg = substr($Name, 1); } else { $Arg = $Name; --- 1005,1029 ---- if (!$this->sendDirectory($Directory)) { ! return false; } if (!$this->sendStaticDirectory()) { ! return false; } if (!$this->sendEntry($Name, $Revision)) { ! return false; } if (!$this->sendUnchanged($Name)) { ! return false; } if (!$this->sendDirectory(".")) { ! return false; } if (strncmp($Name, "/", 1) == 0) { ! $Arg = substr($Name, 1); } else { $Arg = $Name; *************** *** 1017,1025 **** if (!$this->sendArgument($Arg)) { ! return false; } if (!$this->sendAnnotate()) { ! return false; } --- 1031,1039 ---- if (!$this->sendArgument($Arg)) { ! return false; } if (!$this->sendAnnotate()) { ! return false; } *************** *** 1060,1064 **** if (strncmp($FileName, "/", 1) == 0) { ! $FName = substr($FileName, 1); } else { $FName = $FileName; --- 1074,1078 ---- if (strncmp($FileName, "/", 1) == 0) { ! $FName = substr($FileName, 1); } else { $FName = $FileName; *************** *** 1066,1110 **** 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 %H:%M:%S -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; } --- 1080,1124 ---- 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 %H:%M:%S -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; } *************** *** 1133,1140 **** foreach ($Lines as $Line) { if (strncmp($Line, '#', 1) != 0) { ! // Process the line. $Elements = explode(" ", $Line); if (count($Elements) > 1) { ! $Results[$Elements[0]] = $Elements[1]; } } --- 1147,1154 ---- foreach ($Lines as $Line) { if (strncmp($Line, '#', 1) != 0) { ! // Process the line. $Elements = explode(" ", $Line); if (count($Elements) > 1) { ! $Results[$Elements[0]] = $Elements[1]; } } *************** *** 1226,1230 **** // Return Value: void - none. // *************************************************************************** ! function debug($foo, $bar = ""){ echo "<pre>"; switch($bar){ --- 1240,1245 ---- // Return Value: void - none. // *************************************************************************** ! function debug($foo, $bar = "") ! { echo "<pre>"; switch($bar){ *************** *** 1237,1242 **** break; case "print_r": - default: echo print_r($foo); } echo '</pre>'; --- 1252,1258 ---- break; case "print_r": echo print_r($foo); + default: + echo $foo; } echo '</pre>'; |