]>
git.p6c8.net - devedit.git/blob - modules/Command.pm
4 # Dev-Editor - Module Command
6 # Execute Dev-Editor's commands
8 # Author: Patrick Canterino <patrick@patshaping.de>
9 # Last modified: 2004-12-10
20 use POSIX qw(strftime);
30 my $script = $ENV{'SCRIPT_NAME'};
31 my $users = eval("getpwuid(0)") && eval("getgrgid(0)");
33 my %dispatch = ('show' => \
&exec_show
,
34 'beginedit' => \
&exec_beginedit
,
35 'canceledit' => \
&exec_canceledit
,
36 'endedit' => \
&exec_endedit
,
37 'mkdir' => \
&exec_mkdir
,
38 'mkfile' => \
&exec_mkfile
,
39 'upload' => \
&exec_upload
,
40 'copy' => \
&exec_copy
,
41 'rename' => \
&exec_rename
,
42 'remove' => \
&exec_remove
,
43 'chprop' => \
&exec_chprop
,
44 'unlock' => \
&exec_unlock
,
45 'about' => \
&exec_about
50 use base
qw(Exporter);
52 @EXPORT = qw(exec_command);
56 # Execute the specified command
58 # Params: 1. Command to execute
59 # 2. Reference to user input hash
60 # 3. Reference to config hash
62 # Return: Output of the command (Scalar Reference)
66 my ($command,$data,$config) = @_;
68 foreach(keys(%dispatch))
70 if(lc($_) eq lc($command))
72 my $output = &{$dispatch{$_}}($data,$config);
77 return error
($config->{'errors'}->{'cmd_unknown'},'/',{COMMAND
=> $command});
82 # View a directory or a file
84 # Params: 1. Reference to user input hash
85 # 2. Reference to config hash
87 # Return: Output of the command (Scalar Reference)
91 my ($data,$config) = @_;
92 my $physical = $data->{'physical'};
93 my $virtual = $data->{'virtual'};
94 my $upper_path = upper_path
($virtual);
95 my $uselist = $data->{'uselist'};
97 my $tpl = new Template
;
101 # Create directory listing
103 return error
($config->{'errors'}->{'no_dir_access'},$upper_path) unless(-r
$physical && -x
$physical);
105 my $direntries = dir_read
($physical);
106 return error
($config->{'dir_read_fail'},$upper_path,{DIR
=> $virtual}) unless($direntries);
108 my $files = $direntries->{'files'};
109 my $dirs = $direntries->{'dirs'};
111 my $dir_writeable = -w
$physical;
115 # Create the link to the upper directory
116 # (only if we are not in the root directory)
118 unless($virtual eq "/")
120 my @stat = stat($physical."/..");
122 my $udtpl = new Template
;
123 $udtpl->read_file($config->{'templates'}->{'dirlist_up'});
125 $udtpl->fillin("UPPER_DIR",encode_entities
($upper_path));
126 $udtpl->fillin("DATE",encode_entities
(strftime
($config->{'timeformat'},localtime($stat[9]))));
128 $dirlist .= $udtpl->get_template;
133 foreach my $dir(@
$dirs)
135 my $phys_path = $physical."/".$dir;
136 my $virt_path = encode_entities
($virtual.$dir."/");
138 my @stat = stat($phys_path);
140 my $dtpl = new Template
;
141 $dtpl->read_file($config->{'templates'}->{'dirlist_dir'});
143 $dtpl->fillin("DIR",$virt_path);
144 $dtpl->fillin("DIR_NAME",$dir);
145 $dtpl->fillin("DATE",encode_entities
(strftime
($config->{'timeformat'},localtime($stat[9]))));
146 $dtpl->fillin("URL",equal_url
($config->{'httproot'},$virt_path));
148 $dtpl->parse_if_block("readable",-r
$phys_path && -x
$phys_path);
149 $dtpl->parse_if_block("users",$users && -o
$phys_path);
151 $dirlist .= $dtpl->get_template;
156 foreach my $file(@
$files)
158 my $phys_path = $physical."/".$file;
159 my $virt_path = encode_entities
($virtual.$file);
161 my @stat = stat($phys_path);
162 my $in_use = $uselist->in_use($virtual.$file);
163 my $too_large = $config->{'max_file_size'} && $stat[7] > $config->{'max_file_size'};
165 my $ftpl = new Template
;
166 $ftpl->read_file($config->{'templates'}->{'dirlist_file'});
168 $ftpl->fillin("FILE",$virt_path);
169 $ftpl->fillin("FILE_NAME",$file);
170 $ftpl->fillin("SIZE",$stat[7]);
171 $ftpl->fillin("DATE",encode_entities
(strftime
($config->{'timeformat'},localtime($stat[9]))));
172 $ftpl->fillin("URL",equal_url
($config->{'httproot'},$virt_path));
174 $ftpl->parse_if_block("not_readable",not -r
$phys_path);
175 $ftpl->parse_if_block("binary",-B
$phys_path);
176 $ftpl->parse_if_block("readonly",not -w
$phys_path);
178 $ftpl->parse_if_block("viewable",-r
$phys_path && -T
$phys_path && not $too_large);
179 $ftpl->parse_if_block("editable",(-r
$phys_path && -w
$phys_path && -T
$phys_path && not $too_large) && not $in_use);
181 $ftpl->parse_if_block("in_use",$in_use);
182 $ftpl->parse_if_block("unused",not $in_use);
184 $ftpl->parse_if_block("too_large",$config->{'max_file_size'} && $stat[7] > $config->{'max_file_size'});
186 $ftpl->parse_if_block("users",$users && -o
$phys_path);
188 $dirlist .= $ftpl->get_template;
191 $tpl->read_file($config->{'templates'}->{'dirlist'});
193 $tpl->fillin("DIRLIST",$dirlist);
194 $tpl->fillin("DIR",$virtual);
195 $tpl->fillin("SCRIPT",$script);
196 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
198 $tpl->parse_if_block("dir_writeable",$dir_writeable);
204 return error
($config->{'errors'}->{'no_view'},$upper_path) unless(-r
$physical);
206 # Check on binary files
207 # We have to do it in this way, or empty files
208 # will be recognized as binary files
214 return error
($config->{'errors'}->{'binary'},$upper_path);
220 if($config->{'max_file_size'} && -s
$physical > $config->{'max_file_size'})
222 return error
($config->{'errors'}->{'file_too_large'},$upper_path,{SIZE
=> $config->{'max_file_size'}})
226 my $content = file_read
($physical);
227 $$content =~ s/\015\012|\012|\015/\n/g;
229 $tpl->read_file($config->{'templates'}->{'viewfile'});
231 $tpl->fillin("FILE",$virtual);
232 $tpl->fillin("DIR",$upper_path);
233 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
234 $tpl->fillin("SCRIPT",$script);
236 $tpl->parse_if_block("editable",-w
$physical && $uselist->unused($virtual));
238 $tpl->fillin("CONTENT",encode_entities
($$content));
243 my $output = header
(-type
=> "text/html");
244 $output .= $tpl->get_template;
251 # Lock a file and display a form to edit it
253 # Params: 1. Reference to user input hash
254 # 2. Reference to config hash
256 # Return: Output of the command (Scalar Reference)
258 sub exec_beginedit
($$)
260 my ($data,$config) = @_;
261 my $physical = $data->{'physical'};
262 my $virtual = $data->{'virtual'};
263 my $dir = upper_path
($virtual);
264 my $uselist = $data->{'uselist'};
266 return error
($config->{'errors'}->{'editdir'},$dir) if(-d
$physical);
267 return error
($config->{'errors'}->{'in_use'}, $dir,{FILE
=> $virtual}) if($uselist->in_use($virtual));
268 return error
($config->{'errors'}->{'no_edit'},$dir) unless(-r
$physical && -w
$physical);
270 # Check on binary files
276 return error
($config->{'errors'}->{'binary'},$dir);
280 if($config->{'max_file_size'} && -s
$physical > $config->{'max_file_size'})
282 return error
($config->{'errors'}->{'file_too_large'},$dir,{SIZE
=> $config->{'max_file_size'}})
288 $uselist->add_file($virtual);
291 my $content = file_read
($physical);
292 $$content =~ s/\015\012|\012|\015/\n/g;
294 my $tpl = new Template
;
295 $tpl->read_file($config->{'templates'}->{'editfile'});
297 $tpl->fillin("FILE",$virtual);
298 $tpl->fillin("DIR",$dir);
299 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
300 $tpl->fillin("SCRIPT",$script);
301 $tpl->fillin("CONTENT",encode_entities
($$content));
303 my $output = header
(-type
=> "text/html");
304 $output .= $tpl->get_template;
315 # Params: 1. Reference to user input hash
316 # 2. Reference to config hash
318 # Return: Output of the command (Scalar Reference)
320 sub exec_canceledit
($$)
322 my ($data,$config) = @_;
323 my $virtual = $data->{'virtual'};
325 file_unlock
($data->{'uselist'},$virtual);
326 return devedit_reload
({command
=> 'show', file
=> upper_path
($virtual)});
331 # Save a file, unlock it and return to directory view
333 # Params: 1. Reference to user input hash
334 # 2. Reference to config hash
336 # Return: Output of the command (Scalar Reference)
340 my ($data,$config) = @_;
341 my $physical = $data->{'physical'};
342 my $virtual = $data->{'virtual'};
343 my $dir = upper_path
($virtual);
344 my $content = $data->{'cgi'}->param('filecontent');
345 my $uselist = $data->{'uselist'};
347 # We already unlock the file at the beginning of the subroutine,
348 # because if we have to abort this routine, the file keeps locked.
349 # No other user of Dev-Editor will access the file during this
350 # routine because of the concept of File::UseList.
352 file_unlock
($uselist,$virtual);
356 $content =~ s/\015\012|\012|\015/\n/g;
358 if($data->{'cgi'}->param('encode_iso'))
360 # Encode all ISO-8859-1 special chars
362 $content = encode_entities
($content,"\200-\377");
365 if($data->{'cgi'}->param('saveas') && $data->{'new_physical'} ne '' && $data->{'new_virtual'} ne '')
367 # Create the new filename
369 $physical = $data->{'new_physical'};
370 $virtual = $data->{'new_virtual'};
372 # Check if someone else is editing the new file
374 return error
($config->{'errors'}->{'in_use'},$dir,{FILE
=> $virtual}) if($uselist->in_use($virtual));
377 return error
($config->{'errors'}->{'editdir'},$dir) if(-d
$physical);
378 return error
($config->{'errors'}->{'no_edit'},$dir) if(-e
$physical && !(-r
$physical && -w
$physical));
379 return error
($config->{'errors'}->{'text_to_binary'},$dir) unless(-T
$physical);
381 if(file_save
($physical,\
$content))
383 # Saving of the file was successful!
385 return devedit_reload
({command
=> 'show', file
=> $dir});
389 return error
($config->{'errors'}->{'edit_failed'},$dir,{FILE
=> $virtual});
395 # Create a file and return to directory view
397 # Params: 1. Reference to user input hash
398 # 2. Reference to config hash
400 # Return: Output of the command (Scalar Reference)
404 my ($data,$config) = @_;
405 my $new_physical = $data->{'new_physical'};
406 my $new_virtual = $data->{'new_virtual'};
407 my $dir = upper_path
($new_virtual);
408 $new_virtual = encode_entities
($new_virtual);
412 return error
($config->{'errors'}->{'file_exists'},$dir,{FILE
=> $new_virtual}) if(-e
$new_physical);
414 file_create
($new_physical) or return error
($config->{'errors'}->{'mkfile_failed'},$dir,{FILE
=> $new_virtual});
415 return devedit_reload
({command
=> 'show', file
=> $dir});
419 my $tpl = new Template
;
420 $tpl->read_file($config->{'templates'}->{'mkfile'});
422 $tpl->fillin("DIR","/");
423 $tpl->fillin("SCRIPT",$script);
425 my $output = header
(-type
=> "text/html");
426 $output .= $tpl->get_template;
434 # Create a directory and return to directory view
436 # Params: 1. Reference to user input hash
437 # 2. Reference to config hash
439 # Return: Output of the command (Scalar Reference)
443 my ($data,$config) = @_;
444 my $new_physical = $data->{'new_physical'};
445 my $new_virtual = $data->{'new_virtual'};
446 my $dir = upper_path
($new_virtual);
447 $new_virtual = encode_entities
($new_virtual);
449 return error
($config->{'errors'}->{'file_exists'},$dir,{FILE
=> $new_virtual}) if(-e
$new_physical);
453 mkdir($new_physical,0777) or return error
($config->{'errors'}->{'mkdir_failed'},$dir,{DIR
=> $new_virtual});
454 return devedit_reload
({command
=> 'show', file
=> $dir});
458 my $tpl = new Template
;
459 $tpl->read_file($config->{'templates'}->{'mkdir'});
461 $tpl->fillin("DIR","/");
462 $tpl->fillin("SCRIPT",$script);
464 my $output = header
(-type
=> "text/html");
465 $output .= $tpl->get_template;
475 # Params: 1. Reference to user input hash
476 # 2. Reference to config hash
478 # Return: Output of the command (Scalar Reference)
482 my ($data,$config) = @_;
483 my $physical = $data->{'physical'};
484 my $virtual = $data->{'virtual'};
485 my $cgi = $data->{'cgi'};
487 return error
($config->{'errors'}->{'no_directory'},upper_path
($virtual),{FILE
=> $virtual}) unless(-d
$physical);
488 return error
($config->{'errors'}->{'dir_no_create'},$virtual,{DIR
=> $virtual}) unless(-w
$physical);
490 if(my $uploaded_file = $cgi->param('uploaded_file'))
492 # Process file upload
494 my $filename = file_name
($uploaded_file);
495 my $file_phys = $physical."/".$filename;
496 my $file_virt = $virtual.$filename;
498 return error
($config->{'errors'}->{'file_exists'},$virtual,{FILE
=> $file_virt}) if(-e
$file_phys && not $cgi->param('overwrite'));
500 my $ascii = $cgi->param('ascii');
501 my $handle = $cgi->upload('uploaded_file');
505 open(FILE
,">".$file_phys) or return error
($config->{'errors'}->{'mkfile_failed'},$virtual,{FILE
=> $file_virt});
506 binmode(FILE
) unless($ascii);
508 # Read transferred file and write it to disk
510 read($handle, my $data, -s
$handle);
511 $data =~ s/\015\012|\012|\015/\n/g if($ascii); # Replace line separators if transferring in ASCII mode
516 return devedit_reload
({command
=> "show", file
=> $virtual});
520 my $tpl = new Template
;
521 $tpl->read_file($config->{'templates'}->{'upload'});
523 $tpl->fillin("DIR",$virtual);
524 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
525 $tpl->fillin("SCRIPT",$script);
527 my $output = header
(-type
=> "text/html");
528 $output .= $tpl->get_template;
536 # Copy a file and return to directory view
538 # Params: 1. Reference to user input hash
539 # 2. Reference to config hash
541 # Return: Output of the command (Scalar Reference)
545 my ($data,$config) = @_;
546 my $physical = $data->{'physical'};
547 my $virtual = encode_entities
($data->{'virtual'});
548 my $dir = upper_path
($virtual);
549 my $new_physical = $data->{'new_physical'};
551 return error
($config->{'errors'}->{'dircopy'},upper_path
($virtual)) if(-d
$physical);
552 return error
($config->{'errors'}->{'no_copy'},upper_path
($virtual)) unless(-r
$physical);
556 my $new_virtual = $data->{'new_virtual'};
557 my $new_dir = upper_path
($new_virtual);
558 $new_virtual = encode_entities
($new_virtual);
562 return error
($config->{'errors'}->{'exist_edited'},$new_dir,{FILE
=> $new_virtual}) if($data->{'uselist'}->in_use($data->{'new_virtual'}));
566 return error
($config->{'errors'}->{'dir_replace'},$new_dir);
568 elsif(not $data->{'cgi'}->param('confirmed'))
570 my $tpl = new Template
;
571 $tpl->read_file($config->{'templates'}->{'confirm_replace'});
573 $tpl->fillin("FILE",$virtual);
574 $tpl->fillin("NEW_FILE",$new_virtual);
575 $tpl->fillin("NEW_FILENAME",file_name
($new_virtual));
576 $tpl->fillin("NEW_DIR",$new_dir);
577 $tpl->fillin("DIR",$dir);
579 $tpl->fillin("COMMAND","copy");
580 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
581 $tpl->fillin("SCRIPT",$script);
583 my $output = header
(-type
=> "text/html");
584 $output .= $tpl->get_template;
590 copy
($physical,$new_physical) or return error
($config->{'errors'}->{'copy_failed'},$dir,{FILE
=> $virtual, NEW_FILE
=> $new_virtual});
591 return devedit_reload
({command
=> 'show', file
=> $new_dir});
595 my $tpl = new Template
;
596 $tpl->read_file($config->{'templates'}->{'copyfile'});
598 $tpl->fillin("FILE",$virtual);
599 $tpl->fillin("DIR",$dir);
600 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
601 $tpl->fillin("SCRIPT",$script);
603 my $output = header
(-type
=> "text/html");
604 $output .= $tpl->get_template;
612 # Rename/move a file and return to directory view
614 # Params: 1. Reference to user input hash
615 # 2. Reference to config hash
617 # Return: Output of the command (Scalar Reference)
621 my ($data,$config) = @_;
622 my $physical = $data->{'physical'};
623 my $virtual = $data->{'virtual'};
624 my $dir = upper_path
($virtual);
625 my $new_physical = $data->{'new_physical'};
627 return error
($config->{'errors'}->{'rename_root'},"/") if($virtual eq "/");
628 return error
($config->{'errors'}->{'no_rename'},$dir) unless(-w upper_path
($physical));
629 return error
($config->{'errors'}->{'in_use'},$dir,{FILE
=> $virtual}) if($data->{'uselist'}->in_use($virtual));
633 my $new_virtual = $data->{'new_virtual'};
634 my $new_dir = upper_path
($new_virtual);
635 $new_virtual = encode_entities
($new_virtual);
639 return error
($config->{'errors'}->{'exist_edited'},$new_dir,{FILE
=> $new_virtual}) if($data->{'uselist'}->in_use($data->{'new_virtual'}));
643 return error
($config->{'errors'}->{'dir_replace'},$new_dir);
645 elsif(not $data->{'cgi'}->param('confirmed'))
647 my $tpl = new Template
;
648 $tpl->read_file($config->{'templates'}->{'confirm_replace'});
650 $tpl->fillin("FILE",$virtual);
651 $tpl->fillin("NEW_FILE",$new_virtual);
652 $tpl->fillin("NEW_FILENAME",file_name
($new_virtual));
653 $tpl->fillin("NEW_DIR",$new_dir);
654 $tpl->fillin("DIR",$dir);
656 $tpl->fillin("COMMAND","rename");
657 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
658 $tpl->fillin("SCRIPT",$script);
660 my $output = header
(-type
=> "text/html");
661 $output .= $tpl->get_template;
667 rename($physical,$new_physical) or return error
($config->{'errors'}->{'rename_failed'},$dir,{FILE
=> $virtual, NEW_FILE
=> $new_virtual});
668 return devedit_reload
({command
=> 'show', file
=> $new_dir});
672 my $tpl = new Template
;
673 $tpl->read_file($config->{'templates'}->{'renamefile'});
675 $tpl->fillin("FILE",$virtual);
676 $tpl->fillin("DIR",$dir);
677 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
678 $tpl->fillin("SCRIPT",$script);
680 my $output = header
(-type
=> "text/html");
681 $output .= $tpl->get_template;
689 # Remove a file or a directory and return to directory view
691 # Params: 1. Reference to user input hash
692 # 2. Reference to config hash
694 # Return: Output of the command (Scalar Reference)
698 my ($data,$config) = @_;
699 my $physical = $data->{'physical'};
700 my $virtual = $data->{'virtual'};
701 my $dir = upper_path
($virtual);
703 return error
($config->{'errors'}->{'remove_root'},"/") if($virtual eq "/");
704 return error
($config->{'errors'}->{'no_delete'},$dir) unless(-w upper_path
($physical));
710 if($data->{'cgi'}->param('confirmed'))
713 return devedit_reload
({command
=> 'show', file
=> $dir});
717 my $tpl = new Template
;
718 $tpl->read_file($config->{'templates'}->{'confirm_rmdir'});
720 $tpl->fillin("DIR",$virtual);
721 $tpl->fillin("UPPER_DIR",$dir);
722 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
723 $tpl->fillin("SCRIPT",$script);
725 my $output = header
(-type
=> "text/html");
726 $output .= $tpl->get_template;
735 return error
($config->{'errors'}->{'in_use'},$dir,{FILE
=> $virtual}) if($data->{'uselist'}->in_use($virtual));
737 if($data->{'cgi'}->param('confirmed'))
739 unlink($physical) or return error
($config->{'errors'}->{'delete_failed'},$dir,{FILE
=> $virtual});
740 return devedit_reload
({command
=> 'show', file
=> $dir});
744 my $tpl = new Template
;
745 $tpl->read_file($config->{'templates'}->{'confirm_rmfile'});
747 $tpl->fillin("FILE",$virtual);
748 $tpl->fillin("DIR",$dir);
749 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
750 $tpl->fillin("SCRIPT",$script);
752 my $output = header
(-type
=> "text/html");
753 $output .= $tpl->get_template;
762 # Change the mode and the group of a file or a directory
764 # Params: 1. Reference to user input hash
765 # 2. Reference to config hash
767 # Return: Output of the command (Scalar Reference)
771 my ($data,$config) = @_;
772 my $physical = $data->{'physical'};
773 my $virtual = $data->{'virtual'};
774 my $dir = upper_path
($virtual);
775 my $cgi = $data->{'cgi'};
776 my $mode = $cgi->param('mode');
777 my $group = $cgi->param('group');
781 # System supports user and groups
785 # Not the root directory
797 chmod(oct($mode),$physical);
802 # Change the group using the `chgrp` system command
804 return error
($config->{'errors'}->{'invalid_group'},$dir,{GROUP
=> encode_entities
($group)}) unless($group =~ /^[a-z0-9_]+[a-z0-9_-]*$/i);
805 system("chgrp",$group,$physical);
808 return devedit_reload
({command
=> 'show', file
=> $dir});
814 my @stat = stat($physical);
818 my $tpl = new Template
;
819 $tpl->read_file($config->{'templates'}->{'chprop'});
821 # Insert file properties into the template
823 $tpl->fillin("MODE_OCTAL",substr(sprintf("%04o",$mode),-4));
824 $tpl->fillin("MODE_STRING",mode_string
($mode));
825 $tpl->fillin("GID",$gid);
827 if(my $group = getgrgid($gid))
829 $tpl->fillin("GROUP",encode_entities
($group));
830 $tpl->parse_if_block("group_detected",1);
834 $tpl->parse_if_block("group_detected",0);
837 # Insert other information
839 $tpl->fillin("FILE",$virtual);
840 $tpl->fillin("DIR",$dir);
841 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
842 $tpl->fillin("SCRIPT",$script);
844 my $output = header
(-type
=> "text/html");
845 $output .= $tpl->get_template;
852 return error
($config->{'errors'}->{'not_owner'},$dir,{FILE
=> $virtual});
857 return error
($config->{'errors'}->{'chprop_root'},"/");
862 return error
($config->{'errors'}->{'no_users'},$dir,{FILE
=> $virtual});
868 # Remove a file from the list of used files and
869 # return to directory view
871 # Params: 1. Reference to user input hash
872 # 2. Reference to config hash
874 # Return: Output of the command (Scalar Reference)
878 my ($data,$config) = @_;
879 my $virtual = $data->{'virtual'};
880 my $uselist = $data->{'uselist'};
881 my $dir = upper_path
($virtual);
883 return devedit_reload
({command
=> 'show', file
=> $dir}) if($uselist->unused($virtual));
885 if($data->{'cgi'}->param('confirmed'))
887 file_unlock
($uselist,$virtual);
888 return devedit_reload
({command
=> 'show', file
=> $dir});
892 my $tpl = new Template
;
893 $tpl->read_file($config->{'templates'}->{'confirm_unlock'});
895 $tpl->fillin("FILE",$virtual);
896 $tpl->fillin("DIR",$dir);
897 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
898 $tpl->fillin("SCRIPT",$script);
900 my $output = header
(-type
=> "text/html");
901 $output .= $tpl->get_template;
909 # Display some information about Dev-Editor
911 # Params: 1. Reference to user input hash
912 # 2. Reference to config hash
914 # Return: Output of the command (Scalar Reference)
918 my ($data,$config) = @_;
920 my $tpl = new Template
;
921 $tpl->read_file($config->{'templates'}->{'about'});
923 $tpl->fillin("SCRIPT",$script);
925 # Dev-Editor's version number
927 $tpl->fillin("VERSION",$data->{'version'});
929 # Some path information
931 $tpl->fillin("SCRIPT_PHYS",encode_entities
($ENV{'SCRIPT_FILENAME'}));
932 $tpl->fillin("CONFIG_PATH",encode_entities
($data->{'configfile'}));
933 $tpl->fillin("FILE_ROOT", encode_entities
($config->{'fileroot'}));
934 $tpl->fillin("HTTP_ROOT", encode_entities
($config->{'httproot'}));
938 $tpl->fillin("PERL_PROG",encode_entities
($^X
));
939 $tpl->fillin("PERL_VER",sprintf("%vd",$^V
));
941 # Information about the server
943 $tpl->fillin("HTTPD",encode_entities
($ENV{'SERVER_SOFTWARE'}));
944 $tpl->fillin("OS",$^O
);
945 $tpl->fillin("TIME",encode_entities
(strftime
($config->{'timeformat'},localtime)));
947 # Process information
949 $tpl->fillin("PID",$$);
951 # Check if the functions getpwuid() and getgrgid() are available
955 # Dev-Editor is running on a system which allows users and groups
956 # So we display the user and the group of our process
958 my $uid = POSIX
::getuid
;
959 my $gid = POSIX
::getgid
;
961 $tpl->parse_if_block("users",1);
963 # ID's of user and group
965 $tpl->fillin("UID",$uid);
966 $tpl->fillin("GID",$gid);
968 # Names of user and group
970 if(my $user = getpwuid($uid))
972 $tpl->fillin("USER",encode_entities
($user));
973 $tpl->parse_if_block("user_detected",1);
977 $tpl->parse_if_block("user_detected",0);
980 if(my $group = getgrgid($gid))
982 $tpl->fillin("GROUP",encode_entities
($group));
983 $tpl->parse_if_block("group_detected",1);
987 $tpl->parse_if_block("group_detected",0);
992 $tpl->fillin("UMASK",sprintf("%04o",umask));
996 $tpl->parse_if_block("users",0);
999 my $output = header
(-type
=> "text/html");
1000 $output .= $tpl->get_template;
1005 # it's true, baby ;-)
patrick-canterino.de