]>
git.p6c8.net - devedit.git/blob - devedit.pl
a525ec058320a174d45fc15f4b6e31b2fa52287d
1 #!C:/Programme/Perl/bin/perl.exe -w
6 # Dev-Editor's main program
8 # Author: Patrick Canterino <patshaping@gmx.net>
9 # Last modified: 2004-01-16
13 use CGI
:: Carp
qw(fatalsToBrowser) ;
25 use constant CONFIGFILE
=> 'devedit.dat' ;
27 # Read the configuration file
29 my $config = read_config
( CONFIGFILE
);
31 # Read the most important form data
35 my $command = $cgi -> param ( 'command' ) || 'show' ;
36 my $file = $cgi -> param ( 'file' ) || '/' ;
37 my $curdir = $cgi -> param ( 'curdir' ) || '' ;
38 my $newfile = $cgi -> param ( 'newfile' ) || '' ;
40 # Create physical and virtual path for the new file
41 # This section has to be optimized - ugh!
43 my $new_physical = '' ;
48 $curdir = upper_path
( $file ) if ( $curdir eq '' );
49 my $path = clean_path
( $curdir . $newfile );
51 # Extract file and directory name...
53 my $file = file_name
( $path );
54 my $dir = upper_path
( $path );
56 # ... check if the directory exists ...
58 unless (- d clean_path
( $config ->{ 'fileroot' }. "/" . $dir ))
60 abort
( "The directory where you want to create this file or directory doesn't exist." );
63 # ... and check if the path is above the root directory
65 unless (( $new_physical , $new_virtual ) = check_path
( $config ->{ 'fileroot' }, $dir ))
67 abort
( "You aren't allowed to create files and directories above the virtual root directory." );
70 # Create the physical and the virtual path
72 $new_physical = File
:: Spec
-> canonpath ( $new_physical . "/" . $file );
73 $new_virtual .= $file ;
76 # This check has to be performed first, or abs_path() will be confused
78 if (- e clean_path
( $config ->{ 'fileroot' }. "/" . $file ))
80 if ( my ( $physical , $virtual ) = check_path
( $config ->{ 'fileroot' }, $file ))
82 # Create a File::UseList object and load the list
84 my $uselist = new File
:: UseList
( listfile
=> $config ->{ 'uselist_file' },
85 lockfile
=> $config ->{ 'lock_file' },
86 timeout
=> $config ->{ 'lock_timeout' });
88 $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'})." );
91 # Create a hash with data submitted by user
92 # (the CGI and the File::UseList object will also be included)
94 my %data = ( physical
=> $physical ,
96 new_physical
=> $new_physical ,
97 new_virtual
=> $new_virtual ,
101 my $output = exec_command
( $command , \
%data , $config ); # Execute the command...
103 $uselist -> unlock ; # ... unlock the list with files in use...
104 print $ $output ; # ... and print the output of the command
108 abort
( "Accessing files and directories above the virtual root directory is forbidden." );
113 abort
( "File/directory does not exist." );
patrick-canterino.de