]>
git.p6c8.net - devedit.git/blob - devedit.pl
1 #!C:/Programme/Perl/bin/perl.exe -w
6 # Dev-Editor's main program
8 # Author: Patrick Canterino <patshaping@gmx.net>
9 # Last modified: 2003-12-02
13 use CGI
:: Carp
qw(fatalsToBrowser) ;
28 fileroot => 'D:/Server/WWW/dokumente/devedit-test',
29 httproot => '/devedit-test/',
30 timeformat => ' %d . %m . %Y %H : %M ',
31 uselist_file => 'uselist',
32 lock_file => 'uselist.lock',
38 # Read the most important form data
42 my $command = $cgi ->param('command') || 'show';
43 my $file = $cgi ->param('file') || '/';
44 my $curdir = $cgi ->param('curdir') || '';
45 my $newfile = $cgi ->param('newfile') || '';
47 # Create physical and virtual path for the new file
48 # This section has to be optimized - ugh!
50 my $new_physical = '';
55 $curdir = upper_path( $file ) if( $curdir eq '');
56 my $path = clean_path( $curdir . $newfile );
58 # Extract file and directory name...
60 my $file = file_name( $path );
61 my $dir = upper_path( $path );
63 # ... check if the directory exists ...
65 unless(-d clean_path( $config {'fileroot'}."/". $dir ))
67 abort("The directory where you want to create this file or directory doesn't exist.");
70 # ... and check if the path is above the root directory
72 unless(( $new_physical , $new_virtual ) = check_path( $config {'fileroot'}, $dir ))
74 abort("You aren't allowed to create files and directories above the virtual root directory.");
77 # Create the physical and the virtual path
79 $new_physical = File::Spec->canonpath( $new_physical ."/". $file );
80 $new_virtual .= $file ;
83 # This check has to be performed first, or abs_path() will be confused
85 if(-e clean_path( $config {'fileroot'}."/". $file ))
87 if(my ( $physical , $virtual ) = check_path( $config {'fileroot'}, $file ))
89 # Create a File::UseList object and load the list
91 my $uselist = new File::UseList(listfile => $config {'uselist_file'},
92 lockfile => $config {'lock_file'},
93 timeout => $config {'lock_timeout'});
95 $uselist ->lock or abort("Locking of $config {'uselist_file'} failed. Try it again in a moment. If the problem persists, ask someone to recreate the lock file ( $config {'lock_file'}).");
98 # Create a hash with data submitted by user
99 # (the CGI and the File::UseList object will also be included)
101 my %data = (physical => $physical ,
103 new_physical => $new_physical ,
104 new_virtual => $new_virtual ,
108 my $output = exec_command( $command ,\ %data ,\ %config ); # Execute the command...
110 $uselist ->unlock; # ... unlock the list with files in use...
111 print $ $output ; # ... and print the output of the command
115 abort("Accessing files and directories above the virtual root directory is forbidden.");
120 abort("File/directory does not exist.");
patrick-canterino.de