function DAProcessDirectory($ReposLoc, $BasePath)
{
    global $env;
    // Create our CVS connection object and set the required properties.
    $CVSServer = new CVS_PServer($env['CVSSettings']['cvsroot'], $env['CVSSettings']['server'], $env['CVSSettings']['username'], $env['CVSSettings']['passwd']);
    // Connect to the CVS server.
    if ($CVSServer->Connect() === true) {
        // Authenticate against the server.
        $Response = $CVSServer->Authenticate();
        if ($Response !== true) {
            return;
        }
        // Create the folder for the BasePath.
        @mkdir($BasePath, 0700);
        // Get a RLOG of the module path specified in $ReposLoc.
        $CVSServer->RLog($ReposLoc);
        $Folders = $CVSServer->FOLDERS;
        $Files = $CVSServer->FILES;
        foreach ($Folders as $folder) {
            if ($folder["Name"] != "Attic") {
                DAProcessDirectory($ReposLoc . $folder["Name"] . "/", $BasePath . "/" . $folder["Name"]);
                set_time_limit(30);
            }
        }
        foreach ($Files as $file) {
            $CVSServer->ExportFile($ReposLoc . $file["Name"], time());
            $filehandle = fopen($BasePath . "/" . $file["Name"], "wb");
            fwrite($filehandle, $CVSServer->FILECONTENTS);
            fclose($filehandle);
            set_time_limit(30);
        }
        $CVSServer->Disconnect();
        // When we leave this function the contents should be in the File System.
    }
}
Esempio n. 2
0
/**
 * This source code is distributed under the terms as layed out in the
 * GNU General Public License.
 *
 * Purpose: To provide Directory Listing Page.
 *
 * Based on phpcvsview
 * @author Brian A Cheeseman <*****@*****.**>
 * @copyright 2003-2005 Brian A Cheeseman
 * 
 * Ported to bitweaver framework by Lester Caine 2006-12-29
 **/
function DisplayDirListing()
{
    global $gBitSmarty, $env;
    // Create our CVS connection object and set the required properties.
    $CVSServer = new CVS_PServer($env['CVSSettings']['cvsroot'], $env['CVSSettings']['server'], $env['CVSSettings']['username'], $env['CVSSettings']['passwd']);
    // Connect to the CVS server.
    if ($CVSServer->Connect() === true) {
        // Authenticate against the server.
        $Response = $CVSServer->Authenticate();
        if ($Response !== true) {
            $gBitSmarty->assign('error', "ERROR: " . $Response);
            return;
        }
        // Get a RLOG of the module path specified in $env['mod_path'].
        $CVSServer->RLog($env['mod_path']);
        // If we are in the Root of the CVS Repository then lets get the Module list.
        if (strlen($env['mod_path']) < 2) {
            $Modules = $CVSServer->getModuleList();
        } else {
            $Modules = false;
        }
        // Do we need the "Back" operation.
        if (strlen($env['mod_path']) > 2) {
            $hrefup = str_replace("//", "/", $env['script_name'] . "?mp=" . substr($env['mod_path'], 0, strrpos(substr($env['mod_path'], 0, -1), "/")) . "/");
            $gBitSmarty->assign('hrefup', $hrefup);
            $gBitSmarty->assign('ParentIcon', $env['script_path'] . '/icons/parent.png');
        }
        $HREF = str_replace("//", "/", $env['script_name'] . "?mp=" . $env['mod_path'] . "/");
        $gBitSmarty->assign('HREF', $HREF);
        $gBitSmarty->assign('DownloadIcon', $env['script_path'] . '/icons/download.png');
        $gBitSmarty->assign('FolderIcon', $env['script_path'] . '/icons/folder.png');
        $gBitSmarty->assign('ModuleIcon', $env['script_path'] . '/icons/module.png');
        $gBitSmarty->assign('FileIcon', $env['script_path'] . '/icons/file.png');
        $gBitSmarty->assign_by_ref('folders', $CVSServer->FOLDERS);
        if ($Modules !== false) {
            $gBitSmarty->assign_by_ref('modules', $Modules);
        }
        $lfiles = array();
        $i = 0;
        foreach ($CVSServer->FILES as $File) {
            $lfiles[$i]['Name'] = $File['Name'];
            $lfiles[$i]['Head'] = $File['Head'];
            $lfiles[$i]['HREF'] = str_replace("//", "/", $env['script_name'] . "?mp=" . $env['mod_path'] . "/" . $File["Name"]);
            $lfiles[$i]['DateTime'] = strtotime($File["Revisions"][$File["Head"]]["date"]);
            $lfiles[$i]['AGE'] = CalculateDateDiff($lfiles[$i]['DateTime'], strtotime(gmdate("M d Y H:i:s")));
            $lfiles[$i]['Author'] = $File["Revisions"][$File["Head"]]["author"];
            $lfiles[$i]['Log'] = $File["Revisions"][$File["Head"]]["LogMessage"];
            $i++;
        }
        $gBitSmarty->assign_by_ref('files', $lfiles);
        $CVSServer->Disconnect();
    } else {
        $gBitSmarty->assign('error', "ERROR: Could not connect to the PServer");
    }
}
Esempio n. 3
0
/**
 * This source code is distributed under the terms as layed out in the
 * GNU General Public License.
 *
 * Purpose: To provide File Listing Page.
 *
 * Based on phpcvsview
 * @author Brian A Cheeseman <*****@*****.**>
 * @copyright 2003-2005 Brian A Cheeseman
 * 
 * Ported to bitweaver framework by Lester Caine 2006-12-29
 * @version $Id$
 **/
function DisplayFileHistory()
{
    global $gBitSmarty, $env, $CVSServer;
    // Create our CVS connection object and set the required properties.
    $CVSServer = new CVS_PServer($env['CVSSettings']['cvsroot'], $env['CVSSettings']['server'], $env['CVSSettings']['username'], $env['CVSSettings']['passwd']);
    // 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 $env['mod_path'].
        $CVSServer->RLog($env['mod_path']);
        $Files = $CVSServer->FILES;
        $HREF = str_replace('//', '/', $env['script_name'] . '?mp=' . $env['mod_path']);
        $gBitSmarty->assign('HREF', $HREF);
        $history = array();
        $i = 0;
        foreach ($CVSServer->FILES[0]["Revisions"] as $Revision) {
            $DateTime = strtotime($Revision["date"]);
            $history[$i]['Revision'] = $Revision["Revision"];
            $history[$i]['DateTime'] = $DateTime;
            if (isset($Revision["PrevRevision"]) and $Revision["PrevRevision"] != '') {
                $history[$i]['PrevRevision'] = $Revision["PrevRevision"];
                if (isset($Revision["lines"])) {
                    $history[$i]['lines'] = $Revision["lines"];
                }
            }
            $history[$i]['Last'] = strftime("%A %d %b %Y %T -0000", $DateTime) . ' (' . CalculateDateDiff($DateTime, strtotime(gmdate("M d Y H:i:s"))) . ' ago)';
            $history[$i]['Branches'] = $Revision["Branches"];
            $history[$i]['date'] = strftime("%B %d, %Y", $DateTime);
            $history[$i]['time'] = strftime("%H:%M:%S", $DateTime);
            $history[$i]['author'] = $Revision["author"];
            $history[$i]['state'] = $Revision["state"];
            $history[$i]['LogMessage'] = $Revision["LogMessage"];
            $i++;
        }
        $gBitSmarty->assign_by_ref('histories', $history);
        $revs = array();
        foreach ($CVSServer->FILES[0]["Revisions"] as $Revision) {
            $revs[] = $Revision["Revision"];
        }
        $gBitSmarty->assign_by_ref('revs', $revs);
        $CVSServer->Disconnect();
    } else {
        $gBitSmarty->assign('errors', "ERROR: Could not connect to the PServer.");
    }
}
Esempio n. 4
0
/**
 * This source code is distributed under the terms as layed out in the
 * GNU General Public License.
 *
 * Purpose: To provide File Download capability.
 *
 * Based on phpcvsview
 * @author Brian A Cheeseman <*****@*****.**>
 * @copyright 2003-2005 Brian A Cheeseman
 * 
 * Ported to bitweaver framework by Lester Caine 2006-12-29
 * @version $Id$
 **/
function DownloadFile($File, $Revision = "")
{
    global $env, $MIME_TYPES;
    // Create our CVS connection object and set the required properties.
    $CVSServer = new CVS_PServer($env['CVSSettings']['cvsroot'], $env['CVSSettings']['server'], $env['CVSSettings']['username'], $env['CVSSettings']['passwd']);
    // 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 $env['mod_path'].
        $CVSServer->RLog($env['mod_path']);
        // "Export" the file.
        $Response = $CVSServer->ExportFile($File, $Revision);
        if ($Response !== true) {
            return;
        }
        // Get the mime type for the file.
        $FileExt = substr($File, strrpos($File, '.') + 1);
        $MimeType = $MIME_TYPES[$FileExt];
        if ($MimeType == '') {
            $MimeType = 'text/plain';
        }
        // Send the appropriate http header.
        header('Content-Type: ' . $MimeType);
        // Send the file contents.
        echo $CVSServer->FILECONTENTS;
        echo '<br />File Extension: ' . $FileExt;
        echo '<br />Mime Type is: ' . $MimeType;
        // Close the connection.
        $CVSServer->Disconnect();
    } else {
        echo '<h2>ERROR: Could not connect to the PServer.</h2>';
    }
}
Esempio n. 5
0
function DisplayFileContents($File, $Revision = "")
{
    global $gBitSmarty, $config, $env;
    // Create our CVS connection object and set the required properties.
    $CVSServer = new CVS_PServer($env['CVSSettings']['cvsroot'], $env['CVSSettings']['server'], $env['CVSSettings']['username'], $env['CVSSettings']['passwd']);
    // Check and see if this file and version has already been viewed and exists in the cache.
    $CachedFileName = $config['Cache']['Location'];
    if ($config['Cache']['Enable']) {
        if (!file_exists($CachedFileName)) {
            mkdir($CachedFileName, 0750);
        }
        $CachedFileName .= "/" . str_replace("/", "_", $File) . ",{$Revision}";
    }
    if (file_exists($CachedFileName) && $config['Cache']['Enable']) {
        $fd = fopen($CachedFileName, "r");
        if ($fd !== false) {
            fpassthru($fd);
            fclose($fd);
        }
    } else {
        // 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 $env['mod_path'].
            $CVSServer->RLog($env['mod_path']);
            // "Export" the file.
            $Response = $CVSServer->ExportFile($File, $Revision);
            if ($Response !== true) {
                return;
            }
            /*	
            			if ($config['GeSHi']['Enable']) {
            				// Create the GeSHi instance and parse the output.
            				// TODO: setup code to auto identify the highlighting class to use for current file.
            				$FileExt = substr($File, strrpos($File, '.')+1);
            				$Language = guess_highlighter($FileExt);
            				if (is_array($Language)) {
            					$Language = $Language[0];
            				}
            				
            				$geshi = new GeSHi($CVSServer->FILECONTENTS, $Language, $config['GeSHi']['HighlightersPath']);
            				$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
            				$geshi->set_line_style('background: #fcfcfc;'); 
            				$geshi->set_tab_width(4);
            				$hlcontent = $geshi->parse_code();
            	
            				// Store in the current cache.		
            				if ($config['Cache']['Enable']) {
            					$fd = fopen($CachedFileName, "w");
            					if ($fd !== false) {
            						fwrite($fd, '<p class="source">'.$hlcontent.'</p>');
            						fclose($fd);
            					}
            				}		
            
            				// Display the file contents.
            				echo '<p class="source">';
            				echo $hlcontent;
            				echo '</p>';
            			}
            			else
            			{
            
            				$search = array('<', '>', '\n', '\t');
            				$replace = array('&lt;', '&gt;', '', ' ');
            				$content = str_replace($search, $replace, $CVSServer->FILECONTENTS);
            				$source = explode('\n', $content);
            				$soure_size = sizeof($source);
            				
            				if ($config['Cache']['Enable']) {
            					$fd = fopen($CachedFileName, "w");
            					if ($fd !== false) {
            						fwrite($fd, "<pre>\n");
            					}
            				}
            				else
            				{
            					$fd = false;
            				}
            
            				echo "<pre>\n";
            				for($i = 1; $i <= $soure_size; $i++) {
            					$line = '<a name="'.$i.'" class="numberedLine">&nbsp;'.str_repeat('&nbsp;', strlen($soure_size) - strlen($i)). $i.'.</a> ' . $source[$i-1] . "\n";
            					if ($fd !== false) {
            						fwrite($fd, $line);
            					}
            					echo $line;
            				}
            
            				if ($fd !== false) {
            					fwrite($fd, "</pre>\n");
            				}
            				echo "</pre>\n";
            			}
            */
            // Close the connection.
            $CVSServer->Disconnect();
        } else {
            $gBitSmarty->assign('error', "ERROR: Could not connect to the PServer.");
        }
    }
}
Esempio n. 6
0
/**
 * This source code is distributed under the terms as layed out in the
 * GNU General Public License.
 *
 * Purpose: To provide File Diff Page.
 *
 * Based on phpcvsview
 * @author Brian A Cheeseman <*****@*****.**>
 * @copyright 2003-2005 Brian A Cheeseman
 * 
 * Ported to bitweaver framework by Lester Caine 2006-12-29
 * @version $Id$
 **/
function DisplayFileDiff($Rev1, $Rev2)
{
    global $env;
    // Create our CVS connection object and set the required properties.
    $CVSServer = new CVS_PServer($env['CVSSettings']['cvsroot'], $env['CVSSettings']['server'], $env['CVSSettings']['username'], $env['CVSSettings']['passwd']);
    // Connect to the CVS server.
    if ($CVSServer->Connect() === true) {
        // Authenticate against the server.
        $Response = $CVSServer->Authenticate();
        if ($Response !== true) {
            return;
        }
        echo '<hr />' . "\n";
        echo '<div id="filediff">' . "\n";
        // Get the DIFF from the server.
        $DiffLines = explode("\n", $CVSServer->getFileDiff($env['mod_path'], $Rev1, $Rev2));
        //		echo "<pre>".implode("\n", $DiffLines)."</pre>";
        // Get a RLOG of the module path specified in $env['mod_path'].
        $CVSServer->RLog($env['mod_path']);
        $DateOfFile = 0;
        foreach ($CVSServer->FILES[0]["Revisions"] as $Revision) {
            if ($Revision["Revision"] == $Rev1) {
                $DateOfFile = strtotime($Revision["date"]);
            }
        }
        $CVSServer->Disconnect();
        $CVSServer = new CVS_PServer($env['CVSSettings']['cvsroot'], $env['CVSSettings']['server'], $env['CVSSettings']['username'], $env['CVSSettings']['passwd']);
        $CVSServer->Connect();
        $CVSServer->Authenticate();
        if ($CVSServer->ExportFile($env['mod_path'], $DateOfFile) !== true) {
            return;
        }
        $FilePatching = array();
        $FileContents = $CVSServer->FILECONTENTS;
        if ($FileContents === false) {
            echo '<h3>ERROR: Getting Revision for file:</h3>' . '<h3>' . $Rev1 . '</h3>';
        }
        $Lines = explode("\n", $FileContents);
        foreach ($Lines as $Line) {
            $FilePatching[] = array('mode' => "o", 'text' => $Line);
        }
        $linenumber = 0;
        while (strpos($DiffLines[$linenumber], "diff") === false) {
            $linenumber++;
        }
        // while
        $linenumber++;
        // We now have the line which starts the diff output.
        $LineOffset = 0;
        while ($linenumber < count($DiffLines)) {
            if (strpos($DiffLines[$linenumber], "a") !== false) {
                // We have added a line or lines.
                $Parts = explode("a", $DiffLines[$linenumber]);
                $InsertLocation = explode(",", $Parts[0]);
                $NewLineLocation = explode(",", $Parts[1]);
                $InsertLength = count($NewLineLocation) == 2 ? $NewLineLocation[1] - $NewLineLocation[0] + 1 : 1;
                for ($LineCounter = 0; $LineCounter < $InsertLength; $LineCounter++) {
                    $TempLine = array('mode' => "+", 'text' => substr($DiffLines[++$linenumber], 2));
                    $FilePatching = InsertIntoArray($FilePatching, $TempLine, $InsertLocation[0] + $LineCounter + 1);
                    $LineOffset++;
                }
            } else {
                if (strpos($DiffLines[$linenumber], "c") !== false) {
                    // We have changed a line or lines.
                    $Parts = explode("c", $DiffLines[$linenumber]);
                    $InsertLocation = explode(",", $Parts[0]);
                    $InsertLength = count($InsertLocation) == 2 ? $InsertLocation[1] - $InsertLocation[0] + 1 : 1;
                    $linenumber += $InsertLength + 1;
                    $NewFileLocation = explode(",", $Parts[1]);
                    $NewLineLength = count($NewFileLocation) == 2 ? $NewFileLocation[1] - $NewFileLocation[0] + 1 : 1;
                    for ($LineCounter = 0; $LineCounter < $InsertLength; $LineCounter++) {
                        if ($LineCounter < $NewLineLength) {
                            $linenumber++;
                            $TempLine = array('mode' => "+", 'text' => substr($DiffLines[$linenumber], 2));
                            $FilePatching = InsertIntoArray($FilePatching, $TempLine, $InsertLocation[0] + $LineCounter + $LineOffset);
                            $LineOffset++;
                        }
                        $FilePatching[$InsertLocation[0] - 2 + $LineCounter + $LineOffset]['mode'] = '-';
                    }
                    for ($LineCounter = $InsertLength; $LineCounter < $NewLineLength; $LineCounter++) {
                        $linenumber++;
                        $TempLine = array('mode' => "+", 'text' => substr($DiffLines[$linenumber], 2));
                        $FilePatching = InsertIntoArray($FilePatching, $TempLine, $InsertLocation[0] + $LineCounter + $LineOffset);
                    }
                } else {
                    if (strpos($DiffLines[$linenumber], "d") !== false) {
                        // we have removed a line or lines.
                        $Parts = explode("d", $DiffLines[$linenumber]);
                        $DeleteLocation = explode(",", $Parts[0]);
                        $OldLineLocation = explode(",", $Parts[1]);
                        $DeleteLength = count($DeleteLocation) == 2 ? $DeleteLocation[1] - $DeleteLocation[0] + 1 : 1;
                        for ($LineCounter = 0; $LineCounter < $DeleteLength; $LineCounter++) {
                            $FilePatching[$OldLineLocation[0] + $LineCounter + $LineOffset]['mode'] = '-';
                            $LineOffset++;
                            $linenumber++;
                        }
                    }
                }
            }
            $linenumber++;
        }
        // while
        $search = array("<", ">", "\n", "\t", " ");
        $replace = array("&lt;", "&gt;", "", "&nbsp;&nbsp;&nbsp;&nbsp;", "&nbsp;");
        foreach ($FilePatching as $Line) {
            echo '	<p class="';
            switch ($Line['mode']) {
                case '+':
                    echo "added";
                    break;
                case '-':
                    echo "removed";
                    break;
                default:
                    echo "normal";
            }
            // switch
            echo '">' . str_replace($search, $replace, $Line['text']) . '</p>' . "\n";
        }
        echo '</div>' . "\n";
        echo '<hr />' . "\n";
        $CVSServer->Disconnect();
    } else {
        echo '<h2>ERROR: Could not connect to the PServer.</h2>';
    }
}