]>
git.p6c8.net - devedit.git/blob - modules/Command.pm
da70b349d8e40d7c71b177d4248a3ed173e052c0
4 # Dev-Editor - Module Command
6 # Execute Dev-Editor's commands
8 # Author: Patrick Canterino <patrick@patshaping.de>
9 # Last modified: 2004-11-29
20 use POSIX qw(strftime);
28 my $script = $ENV{'SCRIPT_NAME'};
29 my $users = eval("getpwuid(0)") && eval("getgrgid(0)");
31 my %dispatch = ('show' => \
&exec_show
,
32 'beginedit' => \
&exec_beginedit
,
33 'canceledit' => \
&exec_canceledit
,
34 'endedit' => \
&exec_endedit
,
35 'mkdir' => \
&exec_mkdir
,
36 'mkfile' => \
&exec_mkfile
,
37 'upload' => \
&exec_upload
,
38 'copy' => \
&exec_copy
,
39 'rename' => \
&exec_rename
,
40 'remove' => \
&exec_remove
,
41 'chprop' => \
&exec_chprop
,
42 'unlock' => \
&exec_unlock
,
43 'about' => \
&exec_about
48 use base
qw(Exporter);
50 @EXPORT = qw(exec_command);
54 # Execute the specified command
56 # Params: 1. Command to execute
57 # 2. Reference to user input hash
58 # 3. Reference to config hash
60 # Return: Output of the command (Scalar Reference)
64 my ($command,$data,$config) = @_;
66 foreach(keys(%dispatch))
68 if(lc($_) eq lc($command))
70 my $output = &{$dispatch{$_}}($data,$config);
75 return error
($config->{'errors'}->{'cmd_unknown'},'/',{COMMAND
=> $command});
80 # View a directory or a file
82 # Params: 1. Reference to user input hash
83 # 2. Reference to config hash
85 # Return: Output of the command (Scalar Reference)
89 my ($data,$config) = @_;
90 my $physical = $data->{'physical'};
91 my $virtual = $data->{'virtual'};
92 my $upper_path = upper_path
($virtual);
93 my $uselist = $data->{'uselist'};
95 my $tpl = new Template
;
99 # Create directory listing
101 return error
($config->{'errors'}->{'no_dir_access'},$upper_path) unless(-r
$physical && -x
$physical);
103 my $direntries = dir_read
($physical);
104 return error
($config->{'dir_read_fail'},$upper_path,{DIR
=> $virtual}) unless($direntries);
106 my $files = $direntries->{'files'};
107 my $dirs = $direntries->{'dirs'};
109 my $dir_writeable = -w
$physical;
113 # Create the link to the upper directory
114 # (only if we are not in the root directory)
116 unless($virtual eq "/")
118 my @stat = stat($physical."/..");
120 my $udtpl = new Template
;
121 $udtpl->read_file($config->{'templates'}->{'dirlist_up'});
123 $udtpl->fillin("UPPER_DIR",encode_entities
($upper_path));
124 $udtpl->fillin("DATE",encode_entities
(strftime
($config->{'timeformat'},localtime($stat[9]))));
126 $dirlist .= $udtpl->get_template;
131 foreach my $dir(@
$dirs)
133 my $phys_path = $physical."/".$dir;
134 my $virt_path = encode_entities
($virtual.$dir."/");
136 my @stat = stat($phys_path);
138 my $dtpl = new Template
;
139 $dtpl->read_file($config->{'templates'}->{'dirlist_dir'});
141 $dtpl->fillin("DIR",$virt_path);
142 $dtpl->fillin("DIR_NAME",$dir);
143 $dtpl->fillin("DATE",encode_entities
(strftime
($config->{'timeformat'},localtime($stat[9]))));
144 $dtpl->fillin("URL",equal_url
($config->{'httproot'},$virt_path));
146 $dtpl->parse_if_block("readable",-r
$phys_path && -x
$phys_path);
147 $dtpl->parse_if_block("users",$users && -o
$phys_path);
149 $dirlist .= $dtpl->get_template;
154 foreach my $file(@
$files)
156 my $phys_path = $physical."/".$file;
157 my $virt_path = encode_entities
($virtual.$file);
159 my @stat = stat($phys_path);
160 my $in_use = $uselist->in_use($virtual.$file);
161 my $too_large = $config->{'max_file_size'} && $stat[7] > $config->{'max_file_size'};
163 my $ftpl = new Template
;
164 $ftpl->read_file($config->{'templates'}->{'dirlist_file'});
166 $ftpl->fillin("FILE",$virt_path);
167 $ftpl->fillin("FILE_NAME",$file);
168 $ftpl->fillin("SIZE",$stat[7]);
169 $ftpl->fillin("DATE",encode_entities
(strftime
($config->{'timeformat'},localtime($stat[9]))));
170 $ftpl->fillin("URL",equal_url
($config->{'httproot'},$virt_path));
172 $ftpl->parse_if_block("not_readable",not -r
$phys_path);
173 $ftpl->parse_if_block("binary",-B
$phys_path);
174 $ftpl->parse_if_block("readonly",not -w
$phys_path);
176 $ftpl->parse_if_block("viewable",-r
$phys_path && -T
$phys_path && not $too_large);
177 $ftpl->parse_if_block("editable",-r
$phys_path && -w
$phys_path && -T
$phys_path && not $too_large && not $in_use);
179 $ftpl->parse_if_block("in_use",$in_use);
180 $ftpl->parse_if_block("unused",not $in_use);
182 $ftpl->parse_if_block("too_large",$config->{'max_file_size'} && $stat[7] > $config->{'max_file_size'});
184 $ftpl->parse_if_block("users",$users && -o
$phys_path);
186 $dirlist .= $ftpl->get_template;
189 $tpl->read_file($config->{'templates'}->{'dirlist'});
191 $tpl->fillin("DIRLIST",$dirlist);
192 $tpl->fillin("DIR",$virtual);
193 $tpl->fillin("SCRIPT",$script);
194 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
196 $tpl->parse_if_block("dir_writeable",$dir_writeable);
202 return error
($config->{'errors'}->{'no_view'},$upper_path) unless(-r
$physical);
204 # Check on binary files
205 # We have to do it in this way, or empty files
206 # will be recognized as binary files
212 return error
($config->{'errors'}->{'binary'},$upper_path);
218 if($config->{'max_file_size'} && -s
$physical > $config->{'max_file_size'})
220 return error
($config->{'errors'}->{'file_too_large'},$upper_path,{SIZE
=> $config->{'max_file_size'}})
224 my $content = file_read
($physical);
225 $$content =~ s/\015\012|\012|\015/\n/g;
227 $tpl->read_file($config->{'templates'}->{'viewfile'});
229 $tpl->fillin("FILE",$virtual);
230 $tpl->fillin("DIR",$upper_path);
231 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
232 $tpl->fillin("SCRIPT",$script);
234 $tpl->parse_if_block("editable",-w
$physical && $uselist->unused($virtual));
236 $tpl->fillin("CONTENT",encode_entities
($$content));
241 my $output = header
(-type
=> "text/html");
242 $output .= $tpl->get_template;
249 # Lock a file and display a form to edit it
251 # Params: 1. Reference to user input hash
252 # 2. Reference to config hash
254 # Return: Output of the command (Scalar Reference)
256 sub exec_beginedit
($$)
258 my ($data,$config) = @_;
259 my $physical = $data->{'physical'};
260 my $virtual = $data->{'virtual'};
261 my $dir = upper_path
($virtual);
262 my $uselist = $data->{'uselist'};
264 return error
($config->{'errors'}->{'editdir'},$dir) if(-d
$physical);
265 return error
($config->{'errors'}->{'in_use'}, $dir,{FILE
=> $virtual}) if($uselist->in_use($virtual));
266 return error
($config->{'errors'}->{'no_edit'},$dir) unless(-r
$physical && -w
$physical);
268 # Check on binary files
274 return error
($config->{'errors'}->{'binary'},$dir);
278 if($config->{'max_file_size'} && -s
$physical > $config->{'max_file_size'})
280 return error
($config->{'errors'}->{'file_too_large'},$dir,{SIZE
=> $config->{'max_file_size'}})
286 $uselist->add_file($virtual);
289 my $content = file_read
($physical);
290 $$content =~ s/\015\012|\012|\015/\n/g;
292 my $tpl = new Template
;
293 $tpl->read_file($config->{'templates'}->{'editfile'});
295 $tpl->fillin("FILE",$virtual);
296 $tpl->fillin("DIR",$dir);
297 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
298 $tpl->fillin("SCRIPT",$script);
299 $tpl->fillin("CONTENT",encode_entities
($$content));
301 my $output = header
(-type
=> "text/html");
302 $output .= $tpl->get_template;
313 # Params: 1. Reference to user input hash
314 # 2. Reference to config hash
316 # Return: Output of the command (Scalar Reference)
318 sub exec_canceledit
($$)
320 my ($data,$config) = @_;
321 my $virtual = $data->{'virtual'};
323 file_unlock
($data->{'uselist'},$virtual);
324 return devedit_reload
({command
=> 'show', file
=> upper_path
($virtual)});
329 # Save a file, unlock it and return to directory view
331 # Params: 1. Reference to user input hash
332 # 2. Reference to config hash
334 # Return: Output of the command (Scalar Reference)
338 my ($data,$config) = @_;
339 my $physical = $data->{'physical'};
340 my $virtual = $data->{'virtual'};
341 my $dir = upper_path
($virtual);
342 my $content = $data->{'cgi'}->param('filecontent');
343 my $uselist = $data->{'uselist'};
345 # We already unlock the file at the beginning of the
346 # subroutine, because if we have to abort this routine,
347 # the file keeps locked.
348 # Nobody else will access the file during this routine
349 # because of the concept of File::UseList.
351 file_unlock
($uselist,$virtual);
355 $content =~ s/\015\012|\012|\015/\n/g;
357 if($data->{'cgi'}->param('encode_iso'))
359 # Encode all ISO-8859-1 special chars
361 $content = encode_entities
($content,"\200-\377");
364 if($data->{'cgi'}->param('saveas') && $data->{'new_physical'} ne '' && $data->{'new_virtual'} ne '')
366 # Create the new filename
368 $physical = $data->{'new_physical'};
369 $virtual = $data->{'new_virtual'};
371 # Check if someone else is editing the new file
373 return error
($config->{'errors'}->{'in_use'},$dir,{FILE
=> $virtual}) if($uselist->in_use($virtual));
376 return error
($config->{'errors'}->{'editdir'},$dir) if(-d
$physical);
377 return error
($config->{'errors'}->{'no_edit'},$dir) if(-e
$physical && !(-r
$physical && -w
$physical));
378 return error
($config->{'errors'}->{'text_to_binary'},$dir) unless(-T
$physical);
380 if(file_save
($physical,\
$content))
382 # Saving of the file was successful - so unlock it!
384 return devedit_reload
({command
=> 'show', file
=> $dir});
388 return error
($config->{'errors'}->{'edit_failed'},$dir,{FILE
=> $virtual});
394 # Create a file and return to directory view
396 # Params: 1. Reference to user input hash
397 # 2. Reference to config hash
399 # Return: Output of the command (Scalar Reference)
403 my ($data,$config) = @_;
404 my $new_physical = $data->{'new_physical'};
405 my $new_virtual = $data->{'new_virtual'};
406 my $dir = upper_path
($new_virtual);
407 $new_virtual = encode_entities
($new_virtual);
411 return error
($config->{'errors'}->{'file_exists'},$dir,{FILE
=> $new_virtual}) if(-e
$new_physical);
413 file_create
($new_physical) or return error
($config->{'errors'}->{'mkfile_failed'},$dir,{FILE
=> $new_virtual});
414 return devedit_reload
({command
=> 'show', file
=> $dir});
418 my $tpl = new Template
;
419 $tpl->read_file($config->{'templates'}->{'mkfile'});
421 $tpl->fillin("DIR","/");
422 $tpl->fillin("SCRIPT",$script);
424 my $output = header
(-type
=> "text/html");
425 $output .= $tpl->get_template;
433 # Create a directory and return to directory view
435 # Params: 1. Reference to user input hash
436 # 2. Reference to config hash
438 # Return: Output of the command (Scalar Reference)
442 my ($data,$config) = @_;
443 my $new_physical = $data->{'new_physical'};
444 my $new_virtual = $data->{'new_virtual'};
445 my $dir = upper_path
($new_virtual);
446 $new_virtual = encode_entities
($new_virtual);
448 return error
($config->{'errors'}->{'file_exists'},$dir,{FILE
=> $new_virtual}) if(-e
$new_physical);
452 mkdir($new_physical,0777) or return error
($config->{'errors'}->{'mkdir_failed'},$dir,{DIR
=> $new_virtual});
453 return devedit_reload
({command
=> 'show', file
=> $dir});
457 my $tpl = new Template
;
458 $tpl->read_file($config->{'templates'}->{'mkdir'});
460 $tpl->fillin("DIR","/");
461 $tpl->fillin("SCRIPT",$script);
463 my $output = header
(-type
=> "text/html");
464 $output .= $tpl->get_template;
474 # Params: 1. Reference to user input hash
475 # 2. Reference to config hash
477 # Return: Output of the command (Scalar Reference)
481 my ($data,$config) = @_;
482 my $physical = $data->{'physical'};
483 my $virtual = $data->{'virtual'};
484 my $cgi = $data->{'cgi'};
486 return error
($config->{'errors'}->{'no_directory'},upper_path
($virtual),{FILE
=> $virtual}) unless(-d
$physical);
487 return error
($config->{'errors'}->{'dir_no_create'},$virtual,{DIR
=> $virtual}) unless(-w
$physical);
489 if(my $uploaded_file = $cgi->param('uploaded_file'))
491 # Process file upload
493 my $filename = file_name
($uploaded_file);
494 my $file_phys = $physical."/".$filename;
495 my $file_virt = $virtual.$filename;
497 return error
($config->{'errors'}->{'file_exists'},$virtual,{FILE
=> $file_virt}) if(-e
$file_phys && not $cgi->param('overwrite'));
499 my $ascii = $cgi->param('ascii');
500 my $handle = $cgi->upload('uploaded_file');
504 open(FILE
,">".$file_phys) or return error
($config->{'errors'}->{'mkfile_failed'},$virtual,{FILE
=> $file_virt});
505 binmode(FILE
) unless($ascii);
507 # Read transferred file and write it to disk
509 read($handle, my $data, -s
$handle);
510 $data =~ s/\015\012|\012|\015/\n/g if($ascii); # Replace line separators if transferring in ASCII mode
515 return devedit_reload
({command
=> "show", file
=> $virtual});
519 my $tpl = new Template
;
520 $tpl->read_file($config->{'templates'}->{'upload'});
522 $tpl->fillin("DIR",$virtual);
523 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
524 $tpl->fillin("SCRIPT",$script);
526 my $output = header
(-type
=> "text/html");
527 $output .= $tpl->get_template;
535 # Copy a file and return to directory view
537 # Params: 1. Reference to user input hash
538 # 2. Reference to config hash
540 # Return: Output of the command (Scalar Reference)
544 my ($data,$config) = @_;
545 my $physical = $data->{'physical'};
546 my $virtual = encode_entities
($data->{'virtual'});
547 my $new_physical = $data->{'new_physical'};
549 return error
($config->{'errors'}->{'dircopy'},upper_path
($virtual)) if(-d
$physical);
550 return error
($config->{'errors'}->{'no_copy'},upper_path
($virtual)) unless(-r
$physical);
554 my $new_virtual = $data->{'new_virtual'};
555 my $dir = upper_path
($new_virtual);
556 $new_virtual = encode_entities
($new_virtual);
560 return error
($config->{'errors'}->{'exist_edited'},$dir,{FILE
=> $new_virtual}) if($data->{'uselist'}->in_use($data->{'new_virtual'}));
564 return error
($config->{'errors'}->{'dir_replace'},$dir);
566 elsif(not $data->{'cgi'}->param('confirmed'))
568 my $tpl = new Template
;
569 $tpl->read_file($config->{'templates'}->{'confirm_replace'});
571 $tpl->fillin("FILE",$virtual);
572 $tpl->fillin("NEW_FILE",$new_virtual);
573 $tpl->fillin("NEW_FILENAME",file_name
($new_virtual));
574 $tpl->fillin("NEW_DIR",$dir);
575 $tpl->fillin("DIR",upper_path
($virtual));
577 $tpl->fillin("COMMAND","copy");
578 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
579 $tpl->fillin("SCRIPT",$script);
581 my $output = header
(-type
=> "text/html");
582 $output .= $tpl->get_template;
588 copy
($physical,$new_physical) or return error
($config->{'errors'}->{'copy_failed'},upper_path
($virtual),{FILE
=> $virtual, NEW_FILE
=> $new_virtual});
589 return devedit_reload
({command
=> 'show', file
=> $dir});
593 my $tpl = new Template
;
594 $tpl->read_file($config->{'templates'}->{'copyfile'});
596 $tpl->fillin("FILE",$virtual);
597 $tpl->fillin("DIR",upper_path
($virtual));
598 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
599 $tpl->fillin("SCRIPT",$script);
601 my $output = header
(-type
=> "text/html");
602 $output .= $tpl->get_template;
610 # Rename/move a file and return to directory view
612 # Params: 1. Reference to user input hash
613 # 2. Reference to config hash
615 # Return: Output of the command (Scalar Reference)
619 my ($data,$config) = @_;
620 my $physical = $data->{'physical'};
621 my $virtual = $data->{'virtual'};
622 my $new_physical = $data->{'new_physical'};
624 return error
($config->{'errors'}->{'rename_root'},"/") if($virtual eq "/");
625 return error
($config->{'errors'}->{'no_rename'},upper_path
($virtual)) unless(-w upper_path
($physical));
626 return error
($config->{'errors'}->{'in_use'},upper_path
($virtual),{FILE
=> $virtual}) if($data->{'uselist'}->in_use($virtual));
630 my $new_virtual = $data->{'new_virtual'};
631 my $dir = upper_path
($new_virtual);
632 $new_virtual = encode_entities
($new_virtual);
636 return error
($config->{'errors'}->{'exist_edited'},$dir,{FILE
=> $new_virtual}) if($data->{'uselist'}->in_use($data->{'new_virtual'}));
640 return error
($config->{'errors'}->{'dir_replace'},$dir);
642 elsif(not $data->{'cgi'}->param('confirmed'))
644 my $tpl = new Template
;
645 $tpl->read_file($config->{'templates'}->{'confirm_replace'});
647 $tpl->fillin("FILE",$virtual);
648 $tpl->fillin("NEW_FILE",$new_virtual);
649 $tpl->fillin("NEW_FILENAME",file_name
($new_virtual));
650 $tpl->fillin("NEW_DIR",$dir);
651 $tpl->fillin("DIR",upper_path
($virtual));
653 $tpl->fillin("COMMAND","rename");
654 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
655 $tpl->fillin("SCRIPT",$script);
657 my $output = header
(-type
=> "text/html");
658 $output .= $tpl->get_template;
664 rename($physical,$new_physical) or return error
($config->{'errors'}->{'rename_failed'},upper_path
($virtual),{FILE
=> $virtual, NEW_FILE
=> $new_virtual});
665 return devedit_reload
({command
=> 'show', file
=> $dir});
669 my $tpl = new Template
;
670 $tpl->read_file($config->{'templates'}->{'renamefile'});
672 $tpl->fillin("FILE",$virtual);
673 $tpl->fillin("DIR",upper_path
($virtual));
674 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
675 $tpl->fillin("SCRIPT",$script);
677 my $output = header
(-type
=> "text/html");
678 $output .= $tpl->get_template;
686 # Remove a file or a directory and return to directory view
688 # Params: 1. Reference to user input hash
689 # 2. Reference to config hash
691 # Return: Output of the command (Scalar Reference)
695 my ($data,$config) = @_;
696 my $physical = $data->{'physical'};
697 my $virtual = $data->{'virtual'};
699 return error
($config->{'errors'}->{'remove_root'},"/") if($virtual eq "/");
700 return error
($config->{'errors'}->{'no_delete'},upper_path
($virtual)) unless(-w upper_path
($physical));
706 if($data->{'cgi'}->param('confirmed'))
709 return devedit_reload
({command
=> 'show', file
=> upper_path
($virtual)});
713 my $tpl = new Template
;
714 $tpl->read_file($config->{'templates'}->{'confirm_rmdir'});
716 $tpl->fillin("DIR",$virtual);
717 $tpl->fillin("UPPER_DIR",upper_path
($virtual));
718 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
719 $tpl->fillin("SCRIPT",$script);
721 my $output = header
(-type
=> "text/html");
722 $output .= $tpl->get_template;
731 return error
($config->{'errors'}->{'in_use'},upper_path
($virtual),{FILE
=> $virtual}) if($data->{'uselist'}->in_use($virtual));
733 if($data->{'cgi'}->param('confirmed'))
735 unlink($physical) or return error
($config->{'errors'}->{'delete_failed'},upper_path
($virtual),{FILE
=> $virtual});
736 return devedit_reload
({command
=> 'show', file
=> upper_path
($virtual)});
740 my $tpl = new Template
;
741 $tpl->read_file($config->{'templates'}->{'confirm_rmfile'});
743 $tpl->fillin("FILE",$virtual);
744 $tpl->fillin("DIR",upper_path
($virtual));
745 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
746 $tpl->fillin("SCRIPT",$script);
748 my $output = header
(-type
=> "text/html");
749 $output .= $tpl->get_template;
758 # Change the mode and the group of a file or a directory
760 # Params: 1. Reference to user input hash
761 # 2. Reference to config hash
763 # Return: Output of the command (Scalar Reference)
767 my ($data,$config) = @_;
768 my $physical = $data->{'physical'};
769 my $virtual = $data->{'virtual'};
770 my $dir = upper_path
($virtual);
771 my $cgi = $data->{'cgi'};
772 my $mode = $cgi->param('mode');
773 my $group = $cgi->param('group');
777 # System supports user and groups
789 chmod(oct($mode),$physical);
794 # Change the group using the `chgrp` system command
796 return error
($config->{'errors'}->{'invalid_group'},$dir,{GROUP
=> encode_entities
($group)}) unless($group =~ /^[a-z0-9_]+[a-z0-9_-]*$/i);
797 system("chgrp",$group,$physical);
800 return devedit_reload
({command
=> 'show', file
=> $dir});
806 my @stat = stat($physical);
809 my $mode_oct = substr(sprintf("%04o",$mode),-4);
812 my $tpl = new Template
;
813 $tpl->read_file($config->{'templates'}->{'chprop'});
815 # Insert file properties into the template
817 $tpl->fillin("MODE_OCTAL",$mode_oct);
818 $tpl->fillin("MODE_STRING",mode_string
($mode));
819 $tpl->fillin("GID",$gid);
821 if(my $group = getgrgid($gid))
823 $tpl->fillin("GROUP",encode_entities
($group));
824 $tpl->parse_if_block("group_detected",1);
828 $tpl->parse_if_block("group_detected",0);
831 # Insert other information
833 $tpl->fillin("FILE",$virtual);
834 $tpl->fillin("DIR",$dir);
835 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
836 $tpl->fillin("SCRIPT",$script);
838 my $output = header
(-type
=> "text/html");
839 $output .= $tpl->get_template;
846 return error
($config->{'errors'}->{'not_owner'},$dir,{FILE
=> $virtual});
851 return error
($config->{'errors'}->{'no_users'},$dir,{FILE
=> $virtual});
857 # Remove a file from the list of used files and
858 # return to directory view
860 # Params: 1. Reference to user input hash
861 # 2. Reference to config hash
863 # Return: Output of the command (Scalar Reference)
867 my ($data,$config) = @_;
868 my $virtual = $data->{'virtual'};
869 my $uselist = $data->{'uselist'};
871 return devedit_reload
({command
=> 'show', file
=> upper_path
($virtual)}) if($uselist->unused($virtual));
873 if($data->{'cgi'}->param('confirmed'))
875 file_unlock
($uselist,$virtual);
876 return devedit_reload
({command
=> 'show', file
=> upper_path
($virtual)});
880 my $tpl = new Template
;
881 $tpl->read_file($config->{'templates'}->{'confirm_unlock'});
883 $tpl->fillin("FILE",$virtual);
884 $tpl->fillin("DIR",upper_path
($virtual));
885 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
886 $tpl->fillin("SCRIPT",$script);
888 my $output = header
(-type
=> "text/html");
889 $output .= $tpl->get_template;
897 # Display some information about Dev-Editor
899 # Params: 1. Reference to user input hash
900 # 2. Reference to config hash
902 # Return: Output of the command (Scalar Reference)
906 my ($data,$config) = @_;
908 my $tpl = new Template
;
909 $tpl->read_file($config->{'templates'}->{'about'});
911 $tpl->fillin("SCRIPT",$script);
913 # Dev-Editor's version number
915 $tpl->fillin("VERSION",$data->{'version'});
917 # Some path information
919 $tpl->fillin("SCRIPT_PHYS",encode_entities
($ENV{'SCRIPT_FILENAME'}));
920 $tpl->fillin("CONFIG_PATH",encode_entities
($data->{'configfile'}));
921 $tpl->fillin("FILE_ROOT", encode_entities
($config->{'fileroot'}));
922 $tpl->fillin("HTTP_ROOT", encode_entities
($config->{'httproot'}));
926 $tpl->fillin("PERL_PROG",encode_entities
($^X
));
927 $tpl->fillin("PERL_VER",sprintf("%vd",$^V
));
929 # Information about the server
931 $tpl->fillin("HTTPD",encode_entities
($ENV{'SERVER_SOFTWARE'}));
932 $tpl->fillin("OS",$^O
);
933 $tpl->fillin("TIME",encode_entities
(strftime
($config->{'timeformat'},localtime)));
935 # Process information
937 $tpl->fillin("PID",$$);
939 # Check if the functions getpwuid() and getgrgid() are available
943 # Dev-Editor is running on a system which allows users and groups
944 # So we display the user and the group of our process
946 my $uid = POSIX
::getuid
;
947 my $gid = POSIX
::getgid
;
949 $tpl->parse_if_block("users",1);
951 # ID's of user and group
953 $tpl->fillin("UID",$uid);
954 $tpl->fillin("GID",$gid);
956 # Names of user and group
958 if(my $user = getpwuid($uid))
960 $tpl->fillin("USER",encode_entities
($user));
961 $tpl->parse_if_block("user_detected",1);
965 $tpl->parse_if_block("user_detected",0);
968 if(my $group = getgrgid($gid))
970 $tpl->fillin("GROUP",encode_entities
($group));
971 $tpl->parse_if_block("group_detected",1);
975 $tpl->parse_if_block("group_detected",0);
980 $tpl->fillin("UMASK",sprintf("%04o",umask));
984 $tpl->parse_if_block("users",0);
987 my $output = header
(-type
=> "text/html");
988 $output .= $tpl->get_template;
993 # it's true, baby ;-)
patrick-canterino.de