]> git.p6c8.net - devedit.git/blob - devedit.pl
Version 1.1:
[devedit.git] / devedit.pl
1 #!C:/Programme/Perl/bin/perl.exe -w
2
3 #
4 # Dev-Editor
5 #
6 # Dev-Editor's main program
7 #
8 # Author: Patrick Canterino <patshaping@gmx.net>
9 # Last modified: 09-22-2003
10 #
11
12 use strict;
13 use CGI::Carp qw(fatalsToBrowser);
14
15 use lib 'modules';
16
17 use CGI;
18 use Command;
19 use File::UseList;
20 use Output;
21 use Tool;
22
23 our $VERSION = '0.7';
24
25 ### Settings ###
26
27 our %config = (
28 fileroot => 'D:/Server/WWW/Root',
29 httproot => '/',
30 uselist_file => 'uselist',
31 lock_file => 'uselist.lock',
32 lock_timeout => '10'
33 );
34
35 ### End Settings ###
36
37 # Read the most important form data
38
39 my $cgi = new CGI;
40
41 my $command = $cgi->param('command') || 'show';
42 my $file = $cgi->param('file') || '/';
43
44 # This check has to be performed first, or abs_path() will be confused
45
46 if(-e clean_path($config{'fileroot'}."/".$file))
47 {
48 if(my ($physical,$virtual) = check_path($config{'fileroot'},$file))
49 {
50 # Copied from old Dev-Editor (great idea)
51
52 my %dispatch = ('show' => \&exec_show,
53 'beginedit' => \&exec_beginedit,
54 'canceledit' => \&exec_unlock,
55 'endedit' => \&exec_endedit,
56 # 'mkdir' => \&exec_mkdir,
57 # 'mkfile' => \&exec_mkfile,
58 'workwithfile' => \&exec_workwithfile,
59 # 'copy' => \&exec_copy,
60 # 'rename' => \&exec_rename,
61 'remove' => \&exec_remove,
62 'unlock' => \&exec_unlock
63 );
64
65 # Create a File::UseList object and load the list
66
67 my $uselist = new File::UseList(listfile => $config{'uselist_file'},
68 lockfile => $config{'lock_file'},
69 timeout => $config{'lock_timeout'});
70
71 $uselist->lock or abort("Locking failed. Try it again in a moment. If the problem persists, ask someone to recreate the lockfile ($config{'lock_file'}).");
72 $uselist->load;
73
74 # Create a hash with data submitted by user
75 # (the CGI and the File::UseList objects will also be included)
76
77 my %data = (physical => $physical,
78 virtual => $virtual,
79 new_physical => '',
80 new_virtual => '',
81 uselist => $uselist,
82 cgi => $cgi);
83
84 unless($dispatch{$command})
85 {
86 $uselist->unlock;
87 abort("Unknown command: $command");
88 }
89
90 my $output = &{$dispatch{$command}}(\%data,\%config); # Execute the command...
91
92 $uselist->unlock; # ... unlock the list with used files...
93 print $$output; # ... and print the output of the command
94 }
95 else
96 {
97 abort("Accessing files and directories above the virtual root directory is forbidden.");
98 }
99 }
100 else
101 {
102 abort("File/directory does not exist.");
103 }
104
105 #
106 ### End ###

patrick-canterino.de