[phpcvsview-cvs-updates] phpcvsview phpcvs.php,1.6,1.7
Status: Pre-Alpha
Brought to you by:
bcheesem
From: Brian C. <bch...@us...> - 2004-09-26 12:59:50
|
Update of /cvsroot/phpcvsview/phpcvsview In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7851 Modified Files: phpcvs.php Log Message: First stage of complete class rewrite completed. Index: phpcvs.php =================================================================== RCS file: /cvsroot/phpcvsview/phpcvsview/phpcvs.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** phpcvs.php 23 Aug 2003 13:49:40 -0000 1.6 --- phpcvs.php 26 Sep 2004 12:59:39 -0000 1.7 *************** *** 11,23 **** * @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. /** --- 11,111 ---- * @copyright 2003 Brian A Cheeseman **/ + + require_once 'Net/Socket.php'; + + class CVS_PServer { 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_PORT; // Port number the PServer listener is running on. + var $CVS_TIMEOUT; // Timeout in seconds for all socket operations. var $CVS_VALID_REQUESTS; // List of valid requests the PServer accepts. + var $SOCKET; // The socket handle for communicating with the PServer. + var $ALLOWED_RESPONSES = array(); // A hashed array of responses that we are capable of + // processing and the contents is the name of the function + // to process it through. + var $ALLOWED_REQUESTS = array(); // A hashed array of requests we are allowed to send. + var $FINAL_RESPONSE; // A state variable for tracking whether the final response + // in a chain of lines was a success or failure. + var $STDERR; // Standard Error output. (Does not mean that an error occured). + var $MESSAGE_CONTENT; // Message contents. (Standard Out) + var $FOLDERS = array(); // An array of the folders in the current module. + var $FILES = array(); // An array of the files in the current module. + var $CURRENT_FOLDER; // The current folder we are building up. + var $CURRENT_FILE; // The current file we are building up. + + /** + * Allowed Response Decoding functions. + **/ + + // *************************************************************************** + // Function: processOk() + // Author: Brian A Cheeseman. + // Parameters: string - Line of response text. + // Return Value: boolean - Are we expecting more responses to come in? + // *************************************************************************** + function processOk($LineOfText) + { + $this->FINAL_RESPONSE = true; + return false; + } ! // *************************************************************************** ! // Function: processError() ! // Author: Brian A Cheeseman. ! // Parameters: string - Line of response text. ! // Return Value: boolean - Are we expecting more responses to come in? ! // *************************************************************************** ! function processError($LineOfText) ! { ! $this->FINAL_RESPONSE = false; ! return false; ! } ! ! // *************************************************************************** ! // Function: processValidRequests() ! // Author: Brian A Cheeseman. ! // Parameters: string - Line of response text. ! // Return Value: boolean - Are we expecting more responses to come in? ! // *************************************************************************** ! function processValidRequests($LineOfText) ! { ! // Start tokenising the list of Valid Requests. ! $Token = strtok($LineOfText, " "); ! ! // Skip the first token, as it is the response identifier. ! $Token = strtok(" "); ! while($Token !== false){ ! $this->ALLOWED_REQUESTS[$Token] = true; ! $Token = strtok(" "); ! } // while ! return true; ! } ! ! // *************************************************************************** ! // Function: processE() ! // Author: Brian A Cheeseman. ! // Parameters: string - Line of response text. ! // Return Value: boolean - Are we expecting more responses to come in? ! // *************************************************************************** ! function processE($LineOfText) ! { ! $this->STDERR .= substr($LineOfText, 2) . "\n"; ! return true; ! } ! ! // *************************************************************************** ! // Function: processM() ! // Author: Brian A Cheeseman. ! // Parameters: string - Line of response text. ! // Return Value: boolean - Are we expecting more responses to come in? ! // *************************************************************************** ! function processM($LineOfText) ! { ! $this->MESSAGE_CONTENT .= substr($LineOfText, 2) . "\n"; ! return true; ! } /** *************** *** 26,40 **** * **/ ! ! function phpcvs($Repository = '', ! $PServer = '', ! $UserName = '', ! $Password = '') { ! $this->CVS_REPOSITORY = $Repository; ! $this->CVS_PSERVER = $PServer; ! $this->CVS_USERNAME = $UserName; ! $this->CVS_PASSWORD = $Password; ! $this->SOCKET_HANDLE = -1; } --- 114,158 ---- * **/ ! function CVS_PServer() { ! $this->CVS_REPOSITORY = ''; ! $this->CVS_PSERVER = ''; ! $this->CVS_PORT = 2401; ! $this->CVS_USERNAME = ''; ! $this->CVS_PASSWORD = ''; ! $this->SOCKET = new Net_Socket(); ! ! $this->ALLOWED_RESPONSES["ok"] = "processOk"; ! $this->ALLOWED_RESPONSES["error"] = "processError"; ! $this->ALLOWED_RESPONSES["Valid-requests"] = "processValidRequests"; ! $this->ALLOWED_RESPONSES["Checked-in"] = "processCheckedIn"; ! $this->ALLOWED_RESPONSES["New-entry"] = "processNewEntry"; ! $this->ALLOWED_RESPONSES["Checksum"] = "processChecksum"; ! $this->ALLOWED_RESPONSES["Copy-file"] = "processCopyFile"; ! $this->ALLOWED_RESPONSES["Updated"] = "processUpdated"; ! $this->ALLOWED_RESPONSES["Created"] = "processCreated"; ! $this->ALLOWED_RESPONSES["Update-existing"] = "processUpdateExisting"; ! $this->ALLOWED_RESPONSES["Merged"] = "processMerged"; ! $this->ALLOWED_RESPONSES["Patched"] = "processPatched"; ! $this->ALLOWED_RESPONSES["Rcs-diff"] = "processRcsDiff"; ! $this->ALLOWED_RESPONSES["Mode"] = "processMode"; ! $this->ALLOWED_RESPONSES["Mod-time"] = "processModTime"; ! $this->ALLOWED_RESPONSES["Removed"] = "processRemoved"; ! $this->ALLOWED_RESPONSES["Remove-entry"] = "processRemoveEntry"; ! $this->ALLOWED_RESPONSES["Set-static-directory"] = "processSetStaticDirectory"; ! $this->ALLOWED_RESPONSES["Clear-static-directory"] = "processClearStaticDirectory"; ! $this->ALLOWED_RESPONSES["Set-sticky"] = "processSetSticky"; ! $this->ALLOWED_RESPONSES["Clear-sticky"] = "processClearSticky"; ! $this->ALLOWED_RESPONSES["Template"] = "processTemplate"; ! $this->ALLOWED_RESPONSES["Set-checkin-prog"] = "processSetCheckinProg"; ! $this->ALLOWED_RESPONSES["Set-update-prog"] = "processSetUpdateProg"; ! $this->ALLOWED_RESPONSES["Notified"] = "processNotified"; ! $this->ALLOWED_RESPONSES["Module-expansion"] = "processModuleExpansion"; ! $this->ALLOWED_RESPONSES["Wrapper-rcsOption"] = "processWrapperRcsOption"; ! $this->ALLOWED_RESPONSES["M"] = "processM"; ! $this->ALLOWED_RESPONSES["Mbinary"] = "processMBinary"; ! $this->ALLOWED_RESPONSES["E"] = "processE"; ! $this->ALLOWED_RESPONSES["F"] = "processF"; ! $this->ALLOWED_RESPONSES["MT"] = "processMT"; } *************** *** 44,48 **** * **/ - function get_Repository() { return $this->CVS_REPOSITORY; --- 162,165 ---- *************** *** 66,70 **** * **/ - function set_Repository($NewRepository) { $this->CVS_REPOSITORY = $NewRepository; --- 183,186 ---- *************** *** 92,382 **** * **/ ! ! function EncodePW(&$ClearPW) { $NewChars = array( ! '!' => 120, '"' => 53, '%' => 109, '&' => 72, '\'' => 108, ! '(' => 70, ')' => 64, '*' => 76, '+' => 67, ',' => 116, ! '-' => 74, '.' => 68, '/' => 87, '0' => 111, '1' => 52, ! '2' => 75, '3' => 119, '4' => 49, '5' => 34, '6' => 82, ! '7' => 81, '8' => 95, '9' => 65, ':' => 112, ';' => 86, ! '<' => 118, '=' => 110, '>' => 122, '?' => 105, 'A' => 57, ! 'B' => 83, 'C' => 43, 'D' => 46, 'E' => 102, 'F' => 40, ! 'G' => 89, 'H' => 38, 'I' => 103, 'J' => 45, 'K' => 50, ! 'L' => 42, 'M' => 123, 'N' => 91, 'O' => 35, 'P' => 125, ! 'Q' => 55, 'R' => 54, 'S' => 66, 'T' => 124, 'U' => 126, ! 'V' => 59, 'W' => 47, 'X' => 92, 'Y' => 71, 'Z' => 115, ! 'a' => 121, 'b' => 117, 'c' => 104, 'd' => 101, 'e' => 100, ! 'f' => 69, 'g' => 73, 'h' => 99, 'i' => 63, 'j' => 94, ! 'k' => 93, 'l' => 39, 'm' => 37, 'n' => 61, 'o' => 48, ! 'p' => 58, 'q' => 113, 'r' => 32, 's' => 90, 't' => 44, ! 'u' => 98, 'v' => 60, 'w' => 51, 'x' => 33, 'y' => 97, ! 'z' => 62, '_' => 56); $CryptPW = ''; for ($i=0; $i<strlen($ClearPW); $i++) { ! $ch = substr($ClearPW, $i, 1); ! $CryptPW .= chr($NewChars[$ch]); } return $CryptPW; ! } ! 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() { ! if ($this->SOCKET_HANDLE > 0) { ! $SendCMD = "Root ".$this->CVS_REPOSITORY."\n"; ! 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"; ! $SendCMD .= " Patched Rcs-diff Mode Mod-time Removed Remove-entry"; ! $SendCMD .= " Set-static-directory Clear-static-directory Set-sticky"; ! $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 = "/") { ! $SeenThis = ""; ! $Elements = array(); ! if ($this->SOCKET_HANDLE > -1) { ! $SendCMD = "UseUnchanged\nCase\nArgument $Module\nrlog\n"; ! fputs($this->SOCKET_HANDLE, $SendCMD); ! $RecvLN = ""; ! while(strncmp($RecvLN, "ok", 2) != 0){ ! $RecvLN = fgets($this->SOCKET_HANDLE); ! 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); ! if (strpos($FileName, '/') > 0) { ! $DirName = substr($FileName, 0, strpos($FileName, '/')+1); ! if (strpos($SeenThis, $DirName) === false) { ! $Elements[$DirName] = "DIR"; ! $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; ! while(strpos($RecvLN, "M ======") === false){ ! $RecvLN = fgets($this->SOCKET_HANDLE, 8192); ! if (strncmp($RecvLN, "M head:", 7) == 0) { ! $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) { ! $Elements[$FileName2]["BRANCH"] = substr($RecvLN, 10, strlen($RecvLN)-10); ! } // End of if (strncmp($RecvLN, "M branch:", 9) == 0) ! if (strncmp($RecvLN, "M -----", 7) == 0) { ! while(strncmp($RecvLN, "M revision ", 11) != 0) { ! $RecvLN = fgets($this->SOCKET_HANDLE, 8192); ! } // End of while(strncmp($RecvLN, "M revision ", 11) != 0) ! $Rev = substr($RecvLN, 11, strlen($RecvLN)-11); ! $HeadRev = $Elements[$FileName2]["HEAD"]; ! if (strcmp(trim($Rev), trim($HeadRev)) == 0) { ! $RecvLN = fgets($this->SOCKET_HANDLE, 8192); ! $Elements[$FileName2]["DATE"] = strtotime(substr($RecvLN, 8, 19)); ! $RecvLN = substr($RecvLN, 38, strLen($RecvLN)-38); ! $Elements[$FileName2]["AUTHOR"] = substr($RecvLN, 0, strpos($RecvLN, ";")); ! $Elements[$FileName2]["LOG"] = ""; ! $RecvLN = fgets($this->SOCKET_HANDLE, 8192); ! while((strpos($RecvLN, "M ======") === false) && (strpos($RecvLN, "M ------") === false)){ ! if (strlen(trim($RecvLN)) > 1) { ! if (strncmp($RecvLN, "M branches:", 11) != 0) { ! $Elements[$FileName2]["LOG"] .= substr($RecvLN, 2, strlen($RecvLN)-1); ! } // End of if (strncmp($RecvLN, "M branches:", 11) == 0) ! } // End of if (strlen(trim($RecvLN)) > 1) ! $RecvLN = fgets($this->SOCKET_HANDLE, 8192); ! } // End of while ((strpos($RecvLN, "M ======") === false) && (strpos($RecvLN, "M ------") === false)) ! } // End of if (strcmp(trim($Rev), trim($HeadRev)) == 0) ! } // End of if (strncmp($RecvLN, "M -----", 7) == 0) ! } // End of while(strpos($RecvLN, "M ======") === false) ! } // End of if (strpos($FileName, '/') > 0) ! } // End of if (strncmp($FileName, "M RCS file", 10) == 0) ! } // End of if (strncmp($RecvLN, "M \n", 3) == 0) ! } // End of while(strncmp($RecvLN, "ok", 2) != 0) ! } // End of if ($this->SOCKET_HANDLE > -1) ! return $Elements; ! } // End of function RLOGDir(). ! function RLOGFile($File, $Module = "/") { ! $SeenThis = ""; ! $Elements = array(); ! if ($this->SOCKET_HANDLE > -1) { ! $SendCMD = "UseUnchanged\nCase\nArgument ".$Module.$File."\nrlog\n"; ! fputs($this->SOCKET_HANDLE, $SendCMD); ! $RecvLN = ""; ! $CurrentRevision = ""; ! $RevisionCounter = 0; ! $Elements["CODE"] = ""; ! while(strncmp($RecvLN, "ok", 2) != 0){ ! if (strncmp("M revision", $RecvLN, 10) == 0) { ! $RevisionCounter = $RevisionCounter + 1; ! $CurrentRevision = substr($RecvLN, 11, strlen($RecvLN)-11); ! $Elements[$RevisionCounter]["Revision"] = $CurrentRevision; ! $RecvLN = fgets($this->SOCKET_HANDLE); ! 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); ! $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"); ! strtok(" :\t\n"); ! 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) ! $Elements[0]["TotalRevisions"] = $RevisionCounter; ! } // End of if ($this->SOCKET_HANDLE > -1) ! return $Elements; ! } // End of function RLOGFile(); ! 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); ! while(strncmp($RecvLN, "MT", 2) == 0){ ! $RecvLN = fgets($this->SOCKET_HANDLE); ! 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. ! } else { ! // We are logging into a remote PServer repository. } } --- 208,668 ---- * **/ ! ! // *************************************************************************** ! // Function: TransformPW() ! // Author: Brian A Cheeseman. ! // Parameters: $ClearPW - The clear text password to be transformed. ! // Return Value: string - The cipher text of the clear test password. ! // *************************************************************************** ! function TransformPW($ClearPW) { ! ! // 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', ! '%' => 'm', ':' => 'p', 'P' => '}', 'i' => '?', ! '&' => 'H', ';' => 'V', 'Q' => '7', 'j' => '^', ! '\'' => 'l', '<' => 'v', 'R' => '6', 'k' => ']', ! '(' => 'F', '=' => 'n', 'S' => 'B', 'l' => '\'', ! ')' => '@', '>' => 'z', 'T' => '|', 'm' => '%', ! '*' => 'L', '?' => 'i', 'U' => '~', 'n' => '=', ! '+' => 'C', 'A' => '9', 'V' => ';', 'o' => '0', ! ',' => 't', 'B' => 'S', 'W' => '/', 'p' => ':', ! '-' => 'J', 'C' => '+', 'X' => '\\', 'q' => 'q', ! '.' => 'D', 'D' => '.', 'Y' => 'G', 'r' => ' ', ! '/' => 'W', 'E' => 'f', 'Z' => 's', 's' => 'Z', ! '0' => 'o', 'F' => '(', '_' => '8', 't' => ',', ! '1' => '4', 'G' => 'Y', 'a' => 'y', 'u' => 'b', ! '2' => 'K', 'H' => '&', 'b' => 'u', 'v' => '<', ! '3' => 'w', 'I' => 'g', 'c' => 'h', 'w' => '3', ! '4' => '1', 'J' => '-', 'd' => 'e', 'x' => '!', ! '5' => '"', 'K' => '2', 'e' => 'd', 'y' => 'a', ! '6' => 'R', 'L' => '*', 'f' => 'E', 'z' => '>', ! '7' => 'Q', 'M' => '{'); + // Initialise the cipher text password local storage variable. $CryptPW = ''; + + // Loop through each char in the clear text password and add + // the appropriate character from the lookup table to the + // cipher text password variable. for ($i=0; $i<strlen($ClearPW); $i++) { ! $CryptPW .= $NewChars[substr($ClearPW, $i, 1)]; } + + // Return the cipher text password to the calling code. return $CryptPW; ! } // End of function TransformPW ! ! // *************************************************************************** ! // Function: Connect() ! // Author: Brian A Cheeseman. ! // Parameters: None. ! // Return Value: boolean - Were we successful in connecting? ! // *************************************************************************** ! function Connect() { ! // Do we have the name of the server to connect to? ! if ($this->CVS_PSERVER != "") { ! // Yes, attempt to connect to the server. ! $retval = $this->SOCKET->connect($this->CVS_PSERVER, $this->CVS_PORT, false, $this->CVS_TIMEOUT); ! // Return to the calling code the fact that we are connected. ! return $retval; ! } ! else ! { ! // We need a server name to connect, so return a false. return false; ! } // End of if ($this->CVS_PSERVER != "") ! } // End of function Connect ! // *************************************************************************** ! // Function: Disconnect() ! // Author: Brian A Cheeseman. ! // Parameters: None. ! // Return Value: boolean - Were we successful in connecting? ! // *************************************************************************** ! function Disconnect() { ! $retval = $this->SOCKET->disconnect(); ! return $retval; ! } // End of function Disconnect ! // *************************************************************************** ! // Function: Authenticate() ! // Author: Brian A Cheeseman. ! // Parameters: None. ! // Return Value: boolean - Are we authenticated. ! // *************************************************************************** ! function Authenticate() { ! // 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; ! } ! ! // Read the next line to determine if we were successful. ! $response = $this->SOCKET->readLine(); ! if ($response == true && strncmp($response, "I LOVE YOU", 10) == 0) { ! return true; ! } ! else ! { ! // Retrieve the error message from the PServer. ! $errorMsg = ""; ! while(!$this->SOCKET->eof()){ ! $line = $this->SOCKET->readLine(); ! if (strncmp($line, "E ", 2) == 0) { ! $errorMsg .= substr($line, 2); ! } ! if (strncmp($line, "error", 5) == 0) { ! $this->SOCKET->disconnect(); ! } ! } // End of while(!$this->SOCKET->eof()) ! if ($errorMsg == "") { ! return false; ! } ! else ! { ! return $errorMsg; ! } // End of if ($errorMsg == "") ! } // End of if ($response == true && strncmp($response, "I LOVE YOU", 10) == 0) ! } // End of function Authenticate ! ! // *************************************************************************** ! // Function: processResponse() ! // Author: Brian A Cheeseman. ! // Parameters: None. ! // Return Value: boolean - Successfully sent. ! // *************************************************************************** ! function processResponse() ! { ! $this->MESSAGE_CONTENT = ""; ! $this->STDERR = ""; ! $KeepGoing = true; ! while($KeepGoing){ ! $ResponseLine = $this->SOCKET->readLine(); ! $Response = strtok($ResponseLine, " "); ! if ($Response != "") { ! $Func = $this->ALLOWED_RESPONSES[$Response]; ! if (method_exists($this, $Func)) { ! $KeepGoing = $this->$Func($ResponseLine); ! } ! } ! } // while ! } ! ! // *************************************************************************** ! // Function: sendCVSROOT() ! // Author: Brian A Cheeseman. ! // Parameters: None. ! // Return Value: boolean - Successfully sent. ! // *************************************************************************** ! function sendCVSROOT() ! { ! if ($this->SOCKET->write("Root ".$this->CVS_REPOSITORY."\n") != true) { ! return false; ! } ! return true; ! } ! // *************************************************************************** ! // Function: sendValidResponses() ! // Author: Brian A Cheeseman. ! // Parameters: None. ! // Return Value: boolean - Successfully sent. ! // *************************************************************************** ! function sendValidResponses() ! { ! // Build our list of responses we can process into the format required ! // for the cvs pserver. ! $ValidResponses = ""; ! foreach ($this->ALLOWED_RESPONSES as $name => $value) ! { ! $ValidResponses .= " ".$name; ! } ! ! // Send the command to the pserver. ! if ($this->SOCKET->write("Valid-responses".$ValidResponses."\n") != true) { ! return false; ! } ! return true; ! } ! // *************************************************************************** ! // Function: sendValidRequests() ! // Author: Brian A Cheeseman. ! // Parameters: None. ! // Return Value: boolean - Successfully sent and processed. ! // *************************************************************************** ! function sendValidRequests() ! { ! if ($this->SOCKET->write("valid-requests\n") != true) { ! return false; ! } ! $this->processResponse(); ! return true; ! } ! // *************************************************************************** ! // Function: sendUseUnchanged() ! // Author: Brian A Cheeseman. ! // Parameters: None. ! // Return Value: boolean - Successfully sent. ! // *************************************************************************** ! function sendUseUnchanged() ! { ! if ($this->ALLOWED_REQUESTS["UseUnchanged"] == true) { ! if ($this->SOCKET->write("UseUnchanged\n") != true) { ! return false; ! } ! } ! return true; ! } ! // *************************************************************************** ! // Function: sendArgument() ! // Author: Brian A Cheeseman. ! // Parameters: string - Value of argument to send. ! // Return Value: boolean - Successfully sent. ! // *************************************************************************** ! function sendArgument($ArgToSend) ! { ! if ($this->ALLOWED_REQUESTS["Argument"] == true) { ! if ($this->SOCKET->write("Argument $ArgToSend\n") != true) { ! return false; ! } ! } ! return true; ! } ! ! // *************************************************************************** ! // Function: sendRLog() ! // Author: Brian A Cheeseman. ! // Parameters: None. ! // Return Value: boolean - Successfully sent. ! // *************************************************************************** ! function sendRLog() ! { ! if ($this->ALLOWED_REQUESTS["rlog"] == true) { ! if ($this->SOCKET->write("rlog\n") != true) { ! return false; ! } ! } ! return true; ! } ! ! /** ! * Helper Methods. ! **/ ! ! // *************************************************************************** ! // Function: RLogDirectory() ! // Author: Brian A Cheeseman. ! // Parameters: string - Directory to get the RLog for. ! // Return Value: boolean - Were we successful. ! // *************************************************************************** ! function RLog($Folder) ! { ! $this->sendCVSROOT(); ! $this->sendValidResponses(); ! $this->sendValidRequests(); ! ! if (!$this->sendUseUnchanged()) { ! return false; ! } ! ! if (!$this->sendArgument($Folder)) { ! return false; ! } ! ! if (!$this->sendRLog()) { ! return false; ! } ! ! $this->processResponse(); ! ! if (!($this->FINAL_RESPONSE)) { ! return $this->RLog(substr($Folder, 1)); ! } ! ! if ($Folder == "") { ! $Folder = "/"; ! } ! ! $DirCount = -1; ! $FileCount = -1; ! $SeenFolders = ""; ! $CurrentDecode = 0; ! $FileRevision = -1; ! $CurrentRevision = ""; ! $LineProcessed = false; ! if ($this->FINAL_RESPONSE) { ! $Responses = explode("\n", $this->MESSAGE_CONTENT); ! // Iterate through each line. ! foreach ($Responses as $Line) ! { ! $LineProcessed = false; ! // Are we dealing with a file or a folder? ! if (strncmp($Line, "RCS file: ", 10) == 0) { ! // We have the file/dir name, so we can now determine what we are dealing with. ! $TempLine = substr($Line, 10+strlen($this->CVS_REPOSITORY.$Folder)); ! if (strncmp($TempLine, "/", 1) == 0) { ! $TempLine = substr($TempLine, 1); ! } ! if (($SlashPos = strpos($TempLine, "/")) > 0) { ! // We have a folder. ! $FolderName = substr($TempLine, 0, $SlashPos); ! if (strpos($SeenFolders, $FolderName) === false) { ! $DirCount++; ! $this->FOLDERS[$DirCount]["Name"] = $FolderName; ! $SeenFolders .= " " . $FolderName; ! $CurrentDecode = 1; ! $CurrentRevision = ""; ! $LineProcessed = true; ! } ! } ! else ! { ! // We have a file. ! $FileCount++; ! $FileName = substr($TempLine, 0, -2); ! $this->FILES[$FileCount]["Name"] = $FileName; ! $CurrentDecode = 2; ! $LineProcessed = true; ! } ! } ! // 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. ! if (strncmp($Line, "head:", 5) == 0) { ! $this->FILES[$FileCount]["Head"] = trim(substr($Line, 6)); ! $LineProcessed = true; ! } ! ! // Default branch. ! if (strncmp($Line, "branch:", 7) == 0) { ! $this->FILES[$FileCount]["Branch"] = trim(substr($Line, 8)); ! $LineProcessed = true; ! } ! ! // Locking Mechanism. ! if (strncmp($Line, "locks:", 6) == 0) { ! $this->FILES[$FileCount]["Locks"] = trim(substr($Line, 7)); ! $LineProcessed = true; ! } ! ! // Access list. ! if (strncmp($Line, "access list:", 12) == 0) { ! $this->FILES[$FileCount]["Access"] = trim(substr($Line, 13)); ! $LineProcessed = true; ! } ! ! // Process the symbolic names. ! if (strncmp($Line, "symbolic names:", 15) == 0) { ! $LineProcessed = true; ! } ! ! if (strncmp($Line, "\t", 1) == 0) { ! $TempLine = substr($Line, 1); ! $SymbolName = trim(substr($TempLine, 0, strpos($TempLine, ":"))); ! $SymbolValue = trim(substr($TempLine, strpos($TempLine, ":")+1)); ! $this->FILES[$FileCount]["Symbols"]["$SymbolName"] = $SymbolValue; ! $this->FILES[$FileCount]["Symbols"]["$SymbolValue"] = $SymbolName; ! $LineProcessed = true; ! } ! ! // Process the Keyword Substitution. ! if (strncmp($Line, "keyword substitution:", 21) == 0) { ! $this->FILES[$FileCount]["KeywordSubst"] = trim(substr($Line, 22)); ! $LineProcessed = true; ! } ! ! // 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)); ! $LineProcessed = true; ! } ! ! // Process the description. ! if (strncmp($Line, "description:", 12) == 0) { ! $this->FILES[$FileCount]["Description"] = trim(substr($Line, 13)); ! $LineProcessed = true; ! } ! ! // 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"] = ""; ! $LineProcessed = true; ! } ! ! // Get the Date, Author, State and Lines of this revision. ! if (strncmp($Line, "date:", 5) == 0) { ! $Segment = strtok($Line, ";"); ! while(!($Segment === false)){ ! $SepPos = trim(strpos($Segment, ":")); ! $Name = trim(substr($Segment, 0, $SepPos)); ! $Value = trim(substr($Segment, $SepPos+1)); ! $this->FILES[$FileCount]["Revisions"]["$CurrentRevision"]["$Name"] = $Value; ! $Segment = strtok(";"); ! } // while ! $LineProcessed = true; ! } ! ! // Get the current revisions branch. ! if (strncmp($Line, "branches:", 9) == 0) { ! $this->FILES[$FileCount]["Revisions"]["$CurrentRevision"]["Branches"] = trim(substr($Line, 10)); ! $LineProcessed = true; ! } ! ! // Deal with the new file seperator. ! if (strncmp($Line, "=============", 13) == 0) { ! $CurrentDecode = 0; ! $LineProcessed = true; ! } ! ! // Deal with the blank lines. ! ! // Get any lines not already processed and assume they are the log message. ! if (!$LineProcessed) { ! if (strlen($this->FILES[$FileCount]["Revisions"]["$CurrentRevision"]["LogMessage"]) > 0) { ! $this->FILES[$FileCount]["Revisions"]["$CurrentRevision"]["LogMessage"] .= "\n"; ! } ! $this->FILES[$FileCount]["Revisions"]["$CurrentRevision"]["LogMessage"] .= trim($Line); ! } ! } ! } } } |