]>
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: 10-04-2003
13 use CGI
:: Carp
qw(fatalsToBrowser) ;
31 fileroot => 'D:/Server/WWW/dokumente',
33 timeformat => ' %d . %m . %Y %H : %M ',
34 uselist_file => 'uselist',
35 lock_file => 'uselist.lock',
41 # Read the most important form data
45 my $command = $cgi ->param('command') || 'show';
46 my $file = $cgi ->param('file') || '/';
47 my $curdir = $cgi ->param('curdir') || '';
48 my $newfile = $cgi ->param('newfile') || '';
50 # Create physical and virtual path for the new file
51 # This section has to be optimized - ugh!
53 my $new_physical = '';
58 $curdir = upper_path( $file ) if( $curdir eq '');
59 my $path = clean_path( $curdir . $newfile );
61 # Extract file and directory name...
63 my $file = file_name( $path );
64 my $dir = upper_path( $path );
66 # ... check if the directory exists ...
68 unless(-d clean_path( $config {'fileroot'}."/". $dir ))
70 abort("The directory where you want to create this file or directory doesn't exist.");
73 # ... and check if the path is above the root directory
75 unless(( $new_physical , $new_virtual ) = check_path( $config {'fileroot'}, $dir ))
77 abort("You aren't allowed to create files and directories above the virtual root directory.");
80 # Create the physical and the virtual path
82 $new_physical = File::Spec->canonpath( $new_physical ."/". $file );
83 $new_virtual .= $file ;
86 # This check has to be performed first, or abs_path() will be confused
88 if(-e clean_path( $config {'fileroot'}."/". $file ))
90 if(my ( $physical , $virtual ) = check_path( $config {'fileroot'}, $file ))
92 # Copied from old Dev-Editor (great idea)
94 my %dispatch = ('show' => \&exec_show,
95 'beginedit' => \&exec_beginedit,
96 'canceledit' => \&exec_unlock,
97 'endedit' => \&exec_endedit,
98 'mkdir' => \&exec_mkdir,
99 'mkfile' => \&exec_mkfile,
100 'workwithfile' => \&exec_workwithfile,
101 'copy' => \&exec_copy,
102 'rename' => \&exec_rename,
103 'remove' => \&exec_remove,
104 'unlock' => \&exec_unlock
107 # Create a File::UseList object and load the list
109 my $uselist = new File::UseList(listfile => $config {'uselist_file'},
110 lockfile => $config {'lock_file'},
111 timeout => $config {'lock_timeout'});
113 $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'}).");
116 # Create a hash with data submitted by user
117 # (the CGI and the File::UseList object will also be included)
119 my %data = (physical => $physical ,
121 new_physical => $new_physical ,
122 new_virtual => $new_virtual ,
126 unless( $dispatch { $command })
129 abort("Unknown command: $command ");
132 my $output = &{ $dispatch { $command }}(\ %data ,\ %config ); # Execute the command...
134 $uselist ->unlock; # ... unlock the list with used files...
135 print $ $output ; # ... and print the output of the command
139 abort("Accessing files and directories above the virtual root directory is forbidden.");
144 abort("File/directory does not exist.");
patrick-canterino.de