]>
git.p6c8.net - devedit.git/blob - modules/Command.pm
4 # Dev-Editor - Module Command
6 # Execute Dev-Editor's commands
8 # Author: Patrick Canterino <patshaping@gmx.net>
9 # Last modified: 2004-11-24
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'};
111 # Create the link to the upper directory
112 # (only if we are not in the root directory)
114 unless($virtual eq "/")
116 my @stat = stat($physical."/..");
118 my $udtpl = new Template
;
119 $udtpl->read_file($config->{'templates'}->{'dirlist_up'});
121 $udtpl->fillin("UPPER_DIR",encode_entities
($upper_path));
122 $udtpl->fillin("DATE",encode_entities
(strftime
($config->{'timeformat'},localtime($stat[9]))));
124 $dirlist .= $udtpl->get_template;
129 foreach my $dir(@
$dirs)
131 my $phys_path = $physical."/".$dir;
132 my $virt_path = encode_entities
($virtual.$dir."/");
134 my @stat = stat($phys_path);
136 my $dtpl = new Template
;
137 $dtpl->read_file($config->{'templates'}->{'dirlist_dir'});
139 $dtpl->fillin("DIR",$virt_path);
140 $dtpl->fillin("DIR_NAME",$dir);
141 $dtpl->fillin("DATE",encode_entities
(strftime
($config->{'timeformat'},localtime($stat[9]))));
142 $dtpl->fillin("URL",equal_url
($config->{'httproot'},$virt_path));
144 $dtpl->parse_if_block("readable",-r
$phys_path && -x
$phys_path);
145 $dtpl->parse_if_block("users",$users && -o
$phys_path);
147 $dirlist .= $dtpl->get_template;
152 foreach my $file(@
$files)
154 my $phys_path = $physical."/".$file;
155 my $virt_path = encode_entities
($virtual.$file);
157 my @stat = stat($phys_path);
158 my $in_use = $uselist->in_use($virtual.$file);
160 my $ftpl = new Template
;
161 $ftpl->read_file($config->{'templates'}->{'dirlist_file'});
163 $ftpl->fillin("FILE",$virt_path);
164 $ftpl->fillin("FILE_NAME",$file);
165 $ftpl->fillin("SIZE",$stat[7]);
166 $ftpl->fillin("DATE",encode_entities
(strftime
($config->{'timeformat'},localtime($stat[9]))));
167 $ftpl->fillin("URL",equal_url
($config->{'httproot'},$virt_path));
169 $ftpl->parse_if_block("not_readable",not -r
$phys_path);
170 $ftpl->parse_if_block("binary",-B
$phys_path);
171 $ftpl->parse_if_block("readonly",not -w
$phys_path);
173 $ftpl->parse_if_block("viewable",-r
$phys_path && -T
$phys_path && not ($config->{'max_file_size'} && $stat[7] > $config->{'max_file_size'}));
175 $ftpl->parse_if_block("editable",-r
$phys_path && -w
$phys_path && -T
$phys_path && not ($config->{'max_file_size'} && $stat[7] > $config->{'max_file_size'}) && not $in_use);
177 $ftpl->parse_if_block("in_use",$in_use);
178 $ftpl->parse_if_block("unused",not $in_use);
180 $ftpl->parse_if_block("too_large",$config->{'max_file_size'} && $stat[7] > $config->{'max_file_size'});
182 $ftpl->parse_if_block("users",$users && -o
$phys_path);
184 $dirlist .= $ftpl->get_template;
187 $tpl->read_file($config->{'templates'}->{'dirlist'});
189 $tpl->fillin("DIRLIST",$dirlist);
190 $tpl->fillin("DIR",$virtual);
191 $tpl->fillin("SCRIPT",$script);
192 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
198 return error
($config->{'errors'}->{'noview'},$upper_path) unless(-r
$physical);
200 # Check on binary files
201 # We have to do it in this way, or empty files
202 # will be recognized as binary files
208 return error
($config->{'errors'}->{'binary'},$upper_path);
214 my $size = -s
$physical;
216 if($config->{'max_file_size'} && $size > $config->{'max_file_size'})
218 return error
($config->{'errors'}->{'file_too_large'},$upper_path,{SIZE
=> $config->{'max_file_size'}})
222 my $content = file_read
($physical);
223 $$content =~ s/\015\012|\012|\015/\n/g;
225 $tpl->read_file($config->{'templates'}->{'viewfile'});
227 $tpl->fillin("FILE",$virtual);
228 $tpl->fillin("DIR",$upper_path);
229 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
230 $tpl->fillin("SCRIPT",$script);
232 $tpl->parse_if_block("editable",-r
$physical && -w
$physical && -T
$physical && not ($config->{'max_file_size'} && $size > $config->{'max_file_size'}) && $uselist->unused($virtual));
234 $tpl->fillin("CONTENT",encode_entities
($$content));
239 my $output = header
(-type
=> "text/html");
240 $output .= $tpl->get_template;
247 # Lock a file and display a form to edit it
249 # Params: 1. Reference to user input hash
250 # 2. Reference to config hash
252 # Return: Output of the command (Scalar Reference)
254 sub exec_beginedit
($$)
256 my ($data,$config) = @_;
257 my $physical = $data->{'physical'};
258 my $virtual = $data->{'virtual'};
259 my $dir = upper_path
($virtual);
260 my $uselist = $data->{'uselist'};
262 return error
($config->{'errors'}->{'editdir'},$dir) if(-d
$physical);
263 return error
($config->{'errors'}->{'in_use'}, $dir,{FILE
=> $virtual}) if($uselist->in_use($virtual));
264 return error
($config->{'errors'}->{'noedit'}, $dir) unless(-r
$physical && -w
$physical);
266 # Check on binary files
272 return error
($config->{'errors'}->{'binary'},$dir);
276 if($config->{'max_file_size'} && (-s
$physical) > $config->{'max_file_size'})
278 return error
($config->{'errors'}->{'file_too_large'},$dir,{SIZE
=> $config->{'max_file_size'}})
284 $uselist->add_file($virtual);
287 my $content = file_read
($physical);
288 $$content =~ s/\015\012|\012|\015/\n/g;
290 my $tpl = new Template
;
291 $tpl->read_file($config->{'templates'}->{'editfile'});
293 $tpl->fillin("FILE",$virtual);
294 $tpl->fillin("DIR",$dir);
295 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
296 $tpl->fillin("SCRIPT",$script);
297 $tpl->fillin("CONTENT",encode_entities
($$content));
299 my $output = header
(-type
=> "text/html");
300 $output .= $tpl->get_template;
311 # Params: 1. Reference to user input hash
312 # 2. Reference to config hash
314 # Return: Output of the command (Scalar Reference)
316 sub exec_canceledit
($$)
318 my ($data,$config) = @_;
319 my $virtual = $data->{'virtual'};
321 file_unlock
($data->{'uselist'},$virtual);
322 return devedit_reload
({command
=> 'show', file
=> upper_path
($virtual)});
327 # Save a file, unlock it and return to directory view
329 # Params: 1. Reference to user input hash
330 # 2. Reference to config hash
332 # Return: Output of the command (Scalar Reference)
336 my ($data,$config) = @_;
337 my $physical = $data->{'physical'};
338 my $virtual = $data->{'virtual'};
339 my $dir = upper_path
($virtual);
340 my $content = $data->{'cgi'}->param('filecontent');
341 my $uselist = $data->{'uselist'};
343 # We already unlock the file at the beginning of the
344 # subroutine, because if we have to abort this routine,
345 # the file keeps locked.
346 # Nobody else will access the file during this routine
347 # because of the concept of File::UseList.
349 file_unlock
($uselist,$virtual);
353 $content =~ s/\015\012|\012|\015/\n/g;
355 if($data->{'cgi'}->param('encode_iso'))
357 # Encode all ISO-8859-1 special chars
359 $content = encode_entities
($content,"\200-\377");
362 if($data->{'cgi'}->param('saveas') && $data->{'new_physical'} ne '' && $data->{'new_virtual'} ne '')
364 # Create the new filename
366 $physical = $data->{'new_physical'};
367 $virtual = $data->{'new_virtual'};
369 # Check if someone else is editing the new file
371 return error
($config->{'errors'}->{'in_use'},$dir,{FILE
=> $virtual}) if($uselist->in_use($virtual));
374 return error
($config->{'errors'}->{'text_to_binary'},$dir) unless(-T
$physical);
375 return error
($config->{'errors'}->{'editdir'},$dir) if(-d
$physical);
376 return error
($config->{'errors'}->{'noedit'}, $dir) if(-e
$physical && !(-r
$physical && -w
$physical));
378 if(file_save
($physical,\
$content))
380 # Saving of the file was successful - so unlock it!
382 return devedit_reload
({command
=> 'show', file
=> $dir});
386 return error
($config->{'errors'}->{'edit_failed'},$dir,{FILE
=> $virtual});
392 # Create a file and return to directory view
394 # Params: 1. Reference to user input hash
395 # 2. Reference to config hash
397 # Return: Output of the command (Scalar Reference)
401 my ($data,$config) = @_;
402 my $new_physical = $data->{'new_physical'};
403 my $new_virtual = $data->{'new_virtual'};
404 my $dir = upper_path
($new_virtual);
405 $new_virtual = encode_entities
($new_virtual);
409 return error
($config->{'errors'}->{'file_exists'},$dir,{FILE
=> $new_virtual}) if(-e
$new_physical);
411 file_create
($new_physical) or return error
($config->{'errors'}->{'mkfile_failed'},$dir,{FILE
=> $new_virtual});
412 return devedit_reload
({command
=> 'show', file
=> $dir});
416 my $tpl = new Template
;
417 $tpl->read_file($config->{'templates'}->{'mkfile'});
419 $tpl->fillin("DIR","/");
420 $tpl->fillin("SCRIPT",$script);
422 my $output = header
(-type
=> "text/html");
423 $output .= $tpl->get_template;
431 # Create a directory and return to directory view
433 # Params: 1. Reference to user input hash
434 # 2. Reference to config hash
436 # Return: Output of the command (Scalar Reference)
440 my ($data,$config) = @_;
441 my $new_physical = $data->{'new_physical'};
442 my $new_virtual = $data->{'new_virtual'};
443 my $dir = upper_path
($new_virtual);
444 $new_virtual = encode_entities
($new_virtual);
446 return error
($config->{'errors'}->{'file_exists'},$dir,{FILE
=> $new_virtual}) if(-e
$new_physical);
450 mkdir($new_physical,0777) or return error
($config->{'errors'}->{'mkdir_failed'},$dir,{DIR
=> $new_virtual});
451 return devedit_reload
({command
=> 'show', file
=> $dir});
455 my $tpl = new Template
;
456 $tpl->read_file($config->{'templates'}->{'mkdir'});
458 $tpl->fillin("DIR","/");
459 $tpl->fillin("SCRIPT",$script);
461 my $output = header
(-type
=> "text/html");
462 $output .= $tpl->get_template;
472 # Params: 1. Reference to user input hash
473 # 2. Reference to config hash
475 # Return: Output of the command (Scalar Reference)
479 my ($data,$config) = @_;
480 my $physical = $data->{'physical'};
481 my $virtual = $data->{'virtual'};
482 my $cgi = $data->{'cgi'};
484 return error
($config->{'errors'}->{'no_directory'},upper_path
($virtual),{FILE
=> $virtual}) unless(-d
$physical);
486 if(my $uploaded_file = $cgi->param('uploaded_file'))
488 # Process file upload
490 my $filename = file_name
($uploaded_file);
491 my $file_phys = $physical."/".$filename;
492 my $file_virt = $virtual."".$filename;
494 return error
($config->{'errors'}->{'file_exists'},$virtual,{FILE
=> $file_virt}) if(-e
$file_phys && not $cgi->param('overwrite'));
496 my $ascii = $cgi->param('ascii');
497 my $handle = $cgi->upload('uploaded_file');
501 open(FILE
,">$file_phys") or return error
($config->{'errors'}->{'mkfile_failed'},$virtual,{FILE
=> $file_virt});
502 binmode(FILE
) unless($ascii);
504 # Read transferred file and write it to disk
506 read($handle, my $data, -s
$handle);
507 $data =~ s/\015\012|\012|\015/\n/g if($ascii); # Replace line separators if transferring in ASCII mode
512 return devedit_reload
({command
=> "show", file
=> $virtual});
516 my $tpl = new Template
;
517 $tpl->read_file($config->{'templates'}->{'upload'});
519 $tpl->fillin("DIR",$virtual);
520 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
521 $tpl->fillin("SCRIPT",$script);
523 my $output = header
(-type
=> "text/html");
524 $output .= $tpl->get_template;
532 # Copy a file and return to directory view
534 # Params: 1. Reference to user input hash
535 # 2. Reference to config hash
537 # Return: Output of the command (Scalar Reference)
541 my ($data,$config) = @_;
542 my $physical = $data->{'physical'};
543 my $virtual = encode_entities
($data->{'virtual'});
544 my $new_physical = $data->{'new_physical'};
546 return error
($config->{'errors'}->{'dircopy'}) if(-d
$physical);
547 return error
($config->{'errors'}->{'nocopy'}) unless(-r
$physical);
551 my $new_virtual = $data->{'new_virtual'};
552 my $dir = upper_path
($new_virtual);
553 $new_virtual = encode_entities
($new_virtual);
557 return error
($config->{'errors'}->{'exist_edited'},$dir,{FILE
=> $new_virtual}) if($data->{'uselist'}->in_use($data->{'new_virtual'}));
561 return error
($config->{'errors'}->{'dir_replace'},$dir);
563 elsif(not $data->{'cgi'}->param('confirmed'))
565 my $tpl = new Template
;
566 $tpl->read_file($config->{'templates'}->{'confirm_replace'});
568 $tpl->fillin("FILE",$virtual);
569 $tpl->fillin("NEW_FILE",$new_virtual);
570 $tpl->fillin("NEW_FILENAME",file_name
($new_virtual));
571 $tpl->fillin("NEW_DIR",$dir);
572 $tpl->fillin("DIR",upper_path
($virtual));
574 $tpl->fillin("COMMAND","copy");
575 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
576 $tpl->fillin("SCRIPT",$script);
578 my $output = header
(-type
=> "text/html");
579 $output .= $tpl->get_template;
585 copy
($physical,$new_physical) or return error
($config->{'errors'}->{'copy_failed'},upper_path
($virtual),{FILE
=> $virtual, NEW_FILE
=> $new_virtual});
586 return devedit_reload
({command
=> 'show', file
=> $dir});
590 my $tpl = new Template
;
591 $tpl->read_file($config->{'templates'}->{'copyfile'});
593 $tpl->fillin("FILE",$virtual);
594 $tpl->fillin("DIR",upper_path
($virtual));
595 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
596 $tpl->fillin("SCRIPT",$script);
598 my $output = header
(-type
=> "text/html");
599 $output .= $tpl->get_template;
607 # Rename/move a file and return to directory view
609 # Params: 1. Reference to user input hash
610 # 2. Reference to config hash
612 # Return: Output of the command (Scalar Reference)
616 my ($data,$config) = @_;
617 my $physical = $data->{'physical'};
618 my $virtual = $data->{'virtual'};
619 my $new_physical = $data->{'new_physical'};
621 return error
($config->{'errors'}->{'rename_root'},"/") if($virtual eq "/");
622 return error
($config->{'errors'}->{'in_use'},upper_path
($virtual),{FILE
=> $virtual}) if($data->{'uselist'}->in_use($virtual));
626 my $new_virtual = $data->{'new_virtual'};
627 my $dir = upper_path
($new_virtual);
628 $new_virtual = encode_entities
($new_virtual);
632 return error
($config->{'errors'}->{'exist_edited'},$dir,{FILE
=> $new_virtual}) if($data->{'uselist'}->in_use($data->{'new_virtual'}));
636 return error
($config->{'errors'}->{'dir_replace'},$dir);
638 elsif(not $data->{'cgi'}->param('confirmed'))
640 my $tpl = new Template
;
641 $tpl->read_file($config->{'templates'}->{'confirm_replace'});
643 $tpl->fillin("FILE",$virtual);
644 $tpl->fillin("NEW_FILE",$new_virtual);
645 $tpl->fillin("NEW_FILENAME",file_name
($new_virtual));
646 $tpl->fillin("NEW_DIR",$dir);
647 $tpl->fillin("DIR",upper_path
($virtual));
649 $tpl->fillin("COMMAND","rename");
650 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
651 $tpl->fillin("SCRIPT",$script);
653 my $output = header
(-type
=> "text/html");
654 $output .= $tpl->get_template;
660 rename($physical,$new_physical) or return error
($config->{'errors'}->{'rename_failed'},upper_path
($virtual),{FILE
=> $virtual, NEW_FILE
=> $new_virtual});
661 return devedit_reload
({command
=> 'show', file
=> $dir});
665 my $tpl = new Template
;
666 $tpl->read_file($config->{'templates'}->{'renamefile'});
668 $tpl->fillin("FILE",$virtual);
669 $tpl->fillin("DIR",upper_path
($virtual));
670 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
671 $tpl->fillin("SCRIPT",$script);
673 my $output = header
(-type
=> "text/html");
674 $output .= $tpl->get_template;
682 # Remove a file or a directory and return to directory view
684 # Params: 1. Reference to user input hash
685 # 2. Reference to config hash
687 # Return: Output of the command (Scalar Reference)
691 my ($data,$config) = @_;
692 my $physical = $data->{'physical'};
693 my $virtual = $data->{'virtual'};
695 return error
($config->{'errors'}->{'remove_root'},"/") if($virtual eq "/");
701 if($data->{'cgi'}->param('confirmed'))
704 return devedit_reload
({command
=> 'show', file
=> upper_path
($virtual)});
708 my $tpl = new Template
;
709 $tpl->read_file($config->{'templates'}->{'confirm_rmdir'});
711 $tpl->fillin("DIR",$virtual);
712 $tpl->fillin("UPPER_DIR",upper_path
($virtual));
713 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
714 $tpl->fillin("SCRIPT",$script);
716 my $output = header
(-type
=> "text/html");
717 $output .= $tpl->get_template;
726 return error
($config->{'errors'}->{'in_use'},upper_path
($virtual),{FILE
=> $virtual}) if($data->{'uselist'}->in_use($virtual));
728 if($data->{'cgi'}->param('confirmed'))
730 unlink($physical) or return error
($config->{'errors'}->{'delete_failed'},upper_path
($virtual),{FILE
=> $virtual});
731 return devedit_reload
({command
=> 'show', file
=> upper_path
($virtual)});
735 my $tpl = new Template
;
736 $tpl->read_file($config->{'templates'}->{'confirm_rmfile'});
738 $tpl->fillin("FILE",$virtual);
739 $tpl->fillin("DIR",upper_path
($virtual));
740 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
741 $tpl->fillin("SCRIPT",$script);
743 my $output = header
(-type
=> "text/html");
744 $output .= $tpl->get_template;
753 # Change the mode and the group of a file or a directory
755 # Params: 1. Reference to user input hash
756 # 2. Reference to config hash
758 # Return: Output of the command (Scalar Reference)
762 my ($data,$config) = @_;
763 my $physical = $data->{'physical'};
764 my $virtual = $data->{'virtual'};
765 my $dir = upper_path
($virtual);
766 my $cgi = $data->{'cgi'};
767 my $mode = $cgi->param('mode');
768 my $group = $cgi->param('group');
772 # System supports user and groups
784 my $oct_mode = $mode;
785 $oct_mode = "0".$oct_mode if(length($oct_mode) == 3);
786 $oct_mode = oct($oct_mode);
788 chmod($oct_mode,$physical);
793 # Change the group using the `chgrp` system command
795 return error
($config->{'errors'}->{'invalid_group'},$dir,{GROUP
=> encode_entities
($group)}) unless($group =~ /^[a-z0-9_]+[a-z0-9_-]*$/i);
796 system("chgrp",$group,$physical);
799 return devedit_reload
({command
=> 'show', file
=> $dir});
805 my @stat = stat($physical);
808 my $mode_oct = substr(sprintf("%04o",$mode),-4);
811 my $tpl = new Template
;
812 $tpl->read_file($config->{'templates'}->{'chprop'});
814 # Insert file properties into the template
816 $tpl->fillin("MODE_OCTAL",$mode_oct);
817 $tpl->fillin("MODE_STRING",mode_string
($mode));
818 $tpl->fillin("GID",$gid);
820 if(my $group = getgrgid($gid))
822 $tpl->fillin("GROUP",encode_entities
($group));
823 $tpl->parse_if_block("group_detected",1);
827 $tpl->parse_if_block("group_detected",0);
830 # Insert other information
832 $tpl->fillin("FILE",$virtual);
833 $tpl->fillin("DIR",$dir);
834 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
835 $tpl->fillin("SCRIPT",$script);
837 my $output = header
(-type
=> "text/html");
838 $output .= $tpl->get_template;
845 return error
($config->{'errors'}->{'not_owner'},$dir,{FILE
=> $virtual});
850 return error
($config->{'errors'}->{'no_users'},$dir,{FILE
=> $virtual});
856 # Remove a file from the list of used files and
857 # return to directory view
859 # Params: 1. Reference to user input hash
860 # 2. Reference to config hash
862 # Return: Output of the command (Scalar Reference)
866 my ($data,$config) = @_;
867 my $virtual = $data->{'virtual'};
868 my $uselist = $data->{'uselist'};
870 return devedit_reload
({command
=> 'show', file
=> upper_path
($virtual)}) if($uselist->unused($virtual));
872 if($data->{'cgi'}->param('confirmed'))
874 file_unlock
($uselist,$virtual);
875 return devedit_reload
({command
=> 'show', file
=> upper_path
($virtual)});
879 my $tpl = new Template
;
880 $tpl->read_file($config->{'templates'}->{'confirm_unlock'});
882 $tpl->fillin("FILE",$virtual);
883 $tpl->fillin("DIR",upper_path
($virtual));
884 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
885 $tpl->fillin("SCRIPT",$script);
887 my $output = header
(-type
=> "text/html");
888 $output .= $tpl->get_template;
896 # Display some information about Dev-Editor
898 # Params: 1. Reference to user input hash
899 # 2. Reference to config hash
901 # Return: Output of the command (Scalar Reference)
905 my ($data,$config) = @_;
907 my $tpl = new Template
;
908 $tpl->read_file($config->{'templates'}->{'about'});
910 $tpl->fillin("SCRIPT",$script);
912 # Dev-Editor's version number
914 $tpl->fillin("VERSION",$data->{'version'});
916 # Some path information
918 $tpl->fillin("SCRIPT_PHYS",encode_entities
($ENV{'SCRIPT_FILENAME'}));
919 $tpl->fillin("CONFIG_PATH",encode_entities
($data->{'configfile'}));
920 $tpl->fillin("FILE_ROOT", encode_entities
($config->{'fileroot'}));
921 $tpl->fillin("HTTP_ROOT", encode_entities
($config->{'httproot'}));
925 $tpl->fillin("PERL_PROG",encode_entities
($^X
));
926 $tpl->fillin("PERL_VER",sprintf("%vd",$^V
));
928 # Information about the server
930 $tpl->fillin("HTTPD",encode_entities
($ENV{'SERVER_SOFTWARE'}));
931 $tpl->fillin("OS",$^O
);
932 $tpl->fillin("TIME",encode_entities
(strftime
($config->{'timeformat'},localtime)));
934 # Process information
936 $tpl->fillin("PID",$$);
938 # Check if the functions getpwuid() and getgrgid() are available
942 # Dev-Editor is running on a system which allows users and groups
943 # So we display the user and the group of our process
945 my $uid = POSIX
::getuid
;
946 my $gid = POSIX
::getgid
;
948 $tpl->parse_if_block("users",1);
950 # ID's of user and group
952 $tpl->fillin("UID",$uid);
953 $tpl->fillin("GID",$gid);
955 # Names of user and group
957 if(my $user = getpwuid($uid))
959 $tpl->fillin("USER",encode_entities
($user));
960 $tpl->parse_if_block("user_detected",1);
964 $tpl->parse_if_block("user_detected",0);
967 if(my $group = getgrgid($gid))
969 $tpl->fillin("GROUP",encode_entities
($group));
970 $tpl->parse_if_block("group_detected",1);
974 $tpl->parse_if_block("group_detected",0);
979 $tpl->fillin("UMASK",sprintf("%04o",umask));
983 $tpl->parse_if_block("users",0);
986 my $output = header
(-type
=> "text/html");
987 $output .= $tpl->get_template;
992 # it's true, baby ;-)
patrick-canterino.de