]>
git.p6c8.net - devedit.git/blob - devedit.pl
ef2e7b57347e205860e157d0f6391a81c1cdc844
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-04-25
13 use CGI
::Carp
qw(fatalsToBrowser);
15 use vars
qw($VERSION);
26 $VERSION = '2.0 (CVS)';
28 use constant CONFIGFILE => 'devedit.dat';
30 # Read the configuration file
32 my $config = read_config(CONFIGFILE);
33 error_template($config->{'templates'}->{'error'}); # Yes, I'm lazy...
35 # Read the most important form data
39 my $command = $cgi->param('command') || 'show';
40 my $file = $cgi->param('file') || '/';
41 my $curdir = $cgi->param('curdir') || '';
42 my $newfile = $cgi->param('newfile') || '';
44 # Create physical and virtual path for the new file
45 # This section has to be optimized - ugh!
47 my $new_physical = '';
52 $curdir = upper_path($file) if($curdir eq '');
53 my $path = clean_path($curdir.$newfile);
55 # Extract file and directory name...
57 my $file = file_name($path);
58 my $dir = upper_path($path);
60 # ... check if the directory exists ...
62 unless(-d clean_path($config->{'fileroot'}."/".$dir))
64 abort($config->{'errors'}->{'dir_not_exist'});
67 # ... and check if the path is above the root directory
69 unless(($new_physical,$new_virtual) = check_path($config->{'fileroot'},$dir))
71 abort($config->{'errors'}->{'create_ar'});
74 # Create the physical and the virtual path
76 $new_physical = File::Spec->canonpath($new_physical."/".$file);
77 $new_virtual .= $file;
80 # This check has to be performed first, or abs_path() will be confused
82 if(-e clean_path($config->{'fileroot'}."/".$file))
84 if(my ($physical,$virtual) = check_path($config->{'fileroot'},$file))
86 # Create a File::UseList object and load the list
88 my $uselist = new File::UseList(listfile => $config->{'uselist_file'},
89 lockfile => $config->{'lock_file'},
90 timeout => $config->{'lock_timeout'});
92 $uselist->lock or abort($config->{'errors'}->{'lock_failed'},{USELIST => $config->{'uselist_file'}, LOCK_FILE => $config->{'lock_file'}});
95 # Create a hash with data submitted by user
96 # (some other necessary information will also be included)
98 my %data = (physical => $physical,
100 new_physical => $new_physical,
101 new_virtual => $new_virtual,
105 configfile => CONFIGFILE);
107 my $output = exec_command($command,\%data,$config); # Execute the command...
109 $uselist->unlock; # ... unlock the list with files in use...
110 print $$output; # ... and print the output of the command
114 abort($config->{'errors'}->{'above_root'});
119 abort($config->{'errors'}->{'not_exist'});
patrick-canterino.de