From: Rob H. <for...@us...> - 2001-11-15 19:46:23
|
Update of /cvsroot/sandweb/sandweb/bin In directory usw-pr-cvs1:/tmp/cvs-serv4353/bin Modified Files: sandweb.cgi Log Message: hooked up File object, using file subroutine in sandweb.cgi This implementation is still somewhat raw; $file->get_user() and get_group() return uid/gid instead of full filename. Pretty cool besides that. Index: sandweb.cgi =================================================================== RCS file: /cvsroot/sandweb/sandweb/bin/sandweb.cgi,v retrieving revision 1.62 retrieving revision 1.63 diff -U2 -r1.62 -r1.63 --- sandweb.cgi 2001/10/20 05:43:41 1.62 +++ sandweb.cgi 2001/11/15 19:46:20 1.63 @@ -127,4 +127,11 @@ browse_menu( cookie => $cookie ); } + elsif ( param('action') eq 'file' ) { + # called file manipulator + file( + cookie => $cookie, + filename => param('filename'), + ); + } else { # called an invalid page @@ -273,4 +280,59 @@ ); exit 0; +} + +sub file { + my %args = @_; + my $cookie = $args{'cookie'}; + unless ($cookie) { + &login_menu(); + exit 0; + } + if (! load_prefs()) { + # no existing user config, forward to prefs menu + preferences_menu( cookie => $cookie ); + } + + + my $username = $auth->get_userinfo('username'); + my $template_dir = $config->{'paths'}->{'template_dir'}; + my $users_dir = $config->{'paths'}->{'users_dir'}; + my $repo_type = $userprefs->{'repository'}->{'VCS'}; + my $root = $userprefs->{'repository'}->{'root'}; + my $sandbox = $userprefs->{'paths'}->{'users_dir'}; + + my $location = "$users_dir/$username"; + + my $filename = $args{'filename'}; + my $group; + my $permissions; + my $file_type; + + if (! -f "$location/$filename" ) { + print header; + print "File does not exist.\n"; + print "$location/$filename\n"; + exit 1; + } + + use SandWeb::File; + my $file = SandWeb::File->new( + 'filename' => $filename, + 'location' => $location, + ); +# if ( $command eq 'view' ) { + unless ( $file->get_file_type() eq "Text" ) { + print header; + print "This does not appear to be a text file.\n"; + exit 1; + } + print header; + open (FILE, "$location/$filename"); + print "<pre>"; + foreach my $line (<FILE>) { + print "$line"; + } + print "</pre>"; +# } } |