]>
git.p6c8.net - devedit.git/blob - modules/Command.pm
f2b1a04f4b9031c038129b674f2580ccb1d65d1c
4 # Dev-Editor - Module Command
6 # Execute Dev-Editor's commands
8 # Author: Patrick Canterino <patshaping@gmx.net>
9 # Last modified: 2004-11-25
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'}));
174 $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);
176 $ftpl->parse_if_block("in_use",$in_use);
177 $ftpl->parse_if_block("unused",not $in_use);
179 $ftpl->parse_if_block("too_large",$config->{'max_file_size'} && $stat[7] > $config->{'max_file_size'});
181 $ftpl->parse_if_block("users",$users && -o
$phys_path);
183 $dirlist .= $ftpl->get_template;
186 $tpl->read_file($config->{'templates'}->{'dirlist'});
188 $tpl->fillin("DIRLIST",$dirlist);
189 $tpl->fillin("DIR",$virtual);
190 $tpl->fillin("SCRIPT",$script);
191 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
197 return error
($config->{'errors'}->{'noview'},$upper_path) unless(-r
$physical);
199 # Check on binary files
200 # We have to do it in this way, or empty files
201 # will be recognized as binary files
207 return error
($config->{'errors'}->{'binary'},$upper_path);
213 if($config->{'max_file_size'} && -s
$physical > $config->{'max_file_size'})
215 return error
($config->{'errors'}->{'file_too_large'},$upper_path,{SIZE
=> $config->{'max_file_size'}})
219 my $content = file_read
($physical);
220 $$content =~ s/\015\012|\012|\015/\n/g;
222 $tpl->read_file($config->{'templates'}->{'viewfile'});
224 $tpl->fillin("FILE",$virtual);
225 $tpl->fillin("DIR",$upper_path);
226 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
227 $tpl->fillin("SCRIPT",$script);
229 $tpl->parse_if_block("editable",-w
$physical && $uselist->unused($virtual));
231 $tpl->fillin("CONTENT",encode_entities
($$content));
236 my $output = header
(-type
=> "text/html");
237 $output .= $tpl->get_template;
244 # Lock a file and display a form to edit it
246 # Params: 1. Reference to user input hash
247 # 2. Reference to config hash
249 # Return: Output of the command (Scalar Reference)
251 sub exec_beginedit
($$)
253 my ($data,$config) = @_;
254 my $physical = $data->{'physical'};
255 my $virtual = $data->{'virtual'};
256 my $dir = upper_path
($virtual);
257 my $uselist = $data->{'uselist'};
259 return error
($config->{'errors'}->{'editdir'},$dir) if(-d
$physical);
260 return error
($config->{'errors'}->{'in_use'}, $dir,{FILE
=> $virtual}) if($uselist->in_use($virtual));
261 return error
($config->{'errors'}->{'noedit'}, $dir) unless(-r
$physical && -w
$physical);
263 # Check on binary files
269 return error
($config->{'errors'}->{'binary'},$dir);
273 if($config->{'max_file_size'} && -s
$physical > $config->{'max_file_size'})
275 return error
($config->{'errors'}->{'file_too_large'},$dir,{SIZE
=> $config->{'max_file_size'}})
281 $uselist->add_file($virtual);
284 my $content = file_read
($physical);
285 $$content =~ s/\015\012|\012|\015/\n/g;
287 my $tpl = new Template
;
288 $tpl->read_file($config->{'templates'}->{'editfile'});
290 $tpl->fillin("FILE",$virtual);
291 $tpl->fillin("DIR",$dir);
292 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
293 $tpl->fillin("SCRIPT",$script);
294 $tpl->fillin("CONTENT",encode_entities
($$content));
296 my $output = header
(-type
=> "text/html");
297 $output .= $tpl->get_template;
308 # Params: 1. Reference to user input hash
309 # 2. Reference to config hash
311 # Return: Output of the command (Scalar Reference)
313 sub exec_canceledit
($$)
315 my ($data,$config) = @_;
316 my $virtual = $data->{'virtual'};
318 file_unlock
($data->{'uselist'},$virtual);
319 return devedit_reload
({command
=> 'show', file
=> upper_path
($virtual)});
324 # Save a file, unlock it and return to directory view
326 # Params: 1. Reference to user input hash
327 # 2. Reference to config hash
329 # Return: Output of the command (Scalar Reference)
333 my ($data,$config) = @_;
334 my $physical = $data->{'physical'};
335 my $virtual = $data->{'virtual'};
336 my $dir = upper_path
($virtual);
337 my $content = $data->{'cgi'}->param('filecontent');
338 my $uselist = $data->{'uselist'};
340 # We already unlock the file at the beginning of the
341 # subroutine, because if we have to abort this routine,
342 # the file keeps locked.
343 # Nobody else will access the file during this routine
344 # because of the concept of File::UseList.
346 file_unlock
($uselist,$virtual);
350 $content =~ s/\015\012|\012|\015/\n/g;
352 if($data->{'cgi'}->param('encode_iso'))
354 # Encode all ISO-8859-1 special chars
356 $content = encode_entities
($content,"\200-\377");
359 if($data->{'cgi'}->param('saveas') && $data->{'new_physical'} ne '' && $data->{'new_virtual'} ne '')
361 # Create the new filename
363 $physical = $data->{'new_physical'};
364 $virtual = $data->{'new_virtual'};
366 # Check if someone else is editing the new file
368 return error
($config->{'errors'}->{'in_use'},$dir,{FILE
=> $virtual}) if($uselist->in_use($virtual));
371 return error
($config->{'errors'}->{'text_to_binary'},$dir) unless(-T
$physical);
372 return error
($config->{'errors'}->{'editdir'},$dir) if(-d
$physical);
373 return error
($config->{'errors'}->{'noedit'}, $dir) if(-e
$physical && !(-r
$physical && -w
$physical));
375 if(file_save
($physical,\
$content))
377 # Saving of the file was successful - so unlock it!
379 return devedit_reload
({command
=> 'show', file
=> $dir});
383 return error
($config->{'errors'}->{'edit_failed'},$dir,{FILE
=> $virtual});
389 # Create a file and return to directory view
391 # Params: 1. Reference to user input hash
392 # 2. Reference to config hash
394 # Return: Output of the command (Scalar Reference)
398 my ($data,$config) = @_;
399 my $new_physical = $data->{'new_physical'};
400 my $new_virtual = $data->{'new_virtual'};
401 my $dir = upper_path
($new_virtual);
402 $new_virtual = encode_entities
($new_virtual);
406 return error
($config->{'errors'}->{'file_exists'},$dir,{FILE
=> $new_virtual}) if(-e
$new_physical);
408 file_create
($new_physical) or return error
($config->{'errors'}->{'mkfile_failed'},$dir,{FILE
=> $new_virtual});
409 return devedit_reload
({command
=> 'show', file
=> $dir});
413 my $tpl = new Template
;
414 $tpl->read_file($config->{'templates'}->{'mkfile'});
416 $tpl->fillin("DIR","/");
417 $tpl->fillin("SCRIPT",$script);
419 my $output = header
(-type
=> "text/html");
420 $output .= $tpl->get_template;
428 # Create a directory and return to directory view
430 # Params: 1. Reference to user input hash
431 # 2. Reference to config hash
433 # Return: Output of the command (Scalar Reference)
437 my ($data,$config) = @_;
438 my $new_physical = $data->{'new_physical'};
439 my $new_virtual = $data->{'new_virtual'};
440 my $dir = upper_path
($new_virtual);
441 $new_virtual = encode_entities
($new_virtual);
443 return error
($config->{'errors'}->{'file_exists'},$dir,{FILE
=> $new_virtual}) if(-e
$new_physical);
447 mkdir($new_physical,0777) or return error
($config->{'errors'}->{'mkdir_failed'},$dir,{DIR
=> $new_virtual});
448 return devedit_reload
({command
=> 'show', file
=> $dir});
452 my $tpl = new Template
;
453 $tpl->read_file($config->{'templates'}->{'mkdir'});
455 $tpl->fillin("DIR","/");
456 $tpl->fillin("SCRIPT",$script);
458 my $output = header
(-type
=> "text/html");
459 $output .= $tpl->get_template;
469 # Params: 1. Reference to user input hash
470 # 2. Reference to config hash
472 # Return: Output of the command (Scalar Reference)
476 my ($data,$config) = @_;
477 my $physical = $data->{'physical'};
478 my $virtual = $data->{'virtual'};
479 my $cgi = $data->{'cgi'};
481 return error
($config->{'errors'}->{'no_directory'},upper_path
($virtual),{FILE
=> $virtual}) unless(-d
$physical);
483 if(my $uploaded_file = $cgi->param('uploaded_file'))
485 # Process file upload
487 my $filename = file_name
($uploaded_file);
488 my $file_phys = $physical."/".$filename;
489 my $file_virt = $virtual.$filename;
491 return error
($config->{'errors'}->{'file_exists'},$virtual,{FILE
=> $file_virt}) if(-e
$file_phys && not $cgi->param('overwrite'));
493 my $ascii = $cgi->param('ascii');
494 my $handle = $cgi->upload('uploaded_file');
498 open(FILE
,">".$file_phys) or return error
($config->{'errors'}->{'mkfile_failed'},$virtual,{FILE
=> $file_virt});
499 binmode(FILE
) unless($ascii);
501 # Read transferred file and write it to disk
503 read($handle, my $data, -s
$handle);
504 $data =~ s/\015\012|\012|\015/\n/g if($ascii); # Replace line separators if transferring in ASCII mode
509 return devedit_reload
({command
=> "show", file
=> $virtual});
513 my $tpl = new Template
;
514 $tpl->read_file($config->{'templates'}->{'upload'});
516 $tpl->fillin("DIR",$virtual);
517 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
518 $tpl->fillin("SCRIPT",$script);
520 my $output = header
(-type
=> "text/html");
521 $output .= $tpl->get_template;
529 # Copy a file and return to directory view
531 # Params: 1. Reference to user input hash
532 # 2. Reference to config hash
534 # Return: Output of the command (Scalar Reference)
538 my ($data,$config) = @_;
539 my $physical = $data->{'physical'};
540 my $virtual = encode_entities
($data->{'virtual'});
541 my $new_physical = $data->{'new_physical'};
543 return error
($config->{'errors'}->{'dircopy'},upper_path
($virtual)) if(-d
$physical);
544 return error
($config->{'errors'}->{'nocopy'},upper_path
($virtual)) unless(-r
$physical);
548 my $new_virtual = $data->{'new_virtual'};
549 my $dir = upper_path
($new_virtual);
550 $new_virtual = encode_entities
($new_virtual);
554 return error
($config->{'errors'}->{'exist_edited'},$dir,{FILE
=> $new_virtual}) if($data->{'uselist'}->in_use($data->{'new_virtual'}));
558 return error
($config->{'errors'}->{'dir_replace'},$dir);
560 elsif(not $data->{'cgi'}->param('confirmed'))
562 my $tpl = new Template
;
563 $tpl->read_file($config->{'templates'}->{'confirm_replace'});
565 $tpl->fillin("FILE",$virtual);
566 $tpl->fillin("NEW_FILE",$new_virtual);
567 $tpl->fillin("NEW_FILENAME",file_name
($new_virtual));
568 $tpl->fillin("NEW_DIR",$dir);
569 $tpl->fillin("DIR",upper_path
($virtual));
571 $tpl->fillin("COMMAND","copy");
572 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
573 $tpl->fillin("SCRIPT",$script);
575 my $output = header
(-type
=> "text/html");
576 $output .= $tpl->get_template;
582 copy
($physical,$new_physical) or return error
($config->{'errors'}->{'copy_failed'},upper_path
($virtual),{FILE
=> $virtual, NEW_FILE
=> $new_virtual});
583 return devedit_reload
({command
=> 'show', file
=> $dir});
587 my $tpl = new Template
;
588 $tpl->read_file($config->{'templates'}->{'copyfile'});
590 $tpl->fillin("FILE",$virtual);
591 $tpl->fillin("DIR",upper_path
($virtual));
592 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
593 $tpl->fillin("SCRIPT",$script);
595 my $output = header
(-type
=> "text/html");
596 $output .= $tpl->get_template;
604 # Rename/move a file and return to directory view
606 # Params: 1. Reference to user input hash
607 # 2. Reference to config hash
609 # Return: Output of the command (Scalar Reference)
613 my ($data,$config) = @_;
614 my $physical = $data->{'physical'};
615 my $virtual = $data->{'virtual'};
616 my $new_physical = $data->{'new_physical'};
618 return error
($config->{'errors'}->{'rename_root'},"/") if($virtual eq "/");
619 return error
($config->{'errors'}->{'in_use'},upper_path
($virtual),{FILE
=> $virtual}) if($data->{'uselist'}->in_use($virtual));
623 my $new_virtual = $data->{'new_virtual'};
624 my $dir = upper_path
($new_virtual);
625 $new_virtual = encode_entities
($new_virtual);
629 return error
($config->{'errors'}->{'exist_edited'},$dir,{FILE
=> $new_virtual}) if($data->{'uselist'}->in_use($data->{'new_virtual'}));
633 return error
($config->{'errors'}->{'dir_replace'},$dir);
635 elsif(not $data->{'cgi'}->param('confirmed'))
637 my $tpl = new Template
;
638 $tpl->read_file($config->{'templates'}->{'confirm_replace'});
640 $tpl->fillin("FILE",$virtual);
641 $tpl->fillin("NEW_FILE",$new_virtual);
642 $tpl->fillin("NEW_FILENAME",file_name
($new_virtual));
643 $tpl->fillin("NEW_DIR",$dir);
644 $tpl->fillin("DIR",upper_path
($virtual));
646 $tpl->fillin("COMMAND","rename");
647 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
648 $tpl->fillin("SCRIPT",$script);
650 my $output = header
(-type
=> "text/html");
651 $output .= $tpl->get_template;
657 rename($physical,$new_physical) or return error
($config->{'errors'}->{'rename_failed'},upper_path
($virtual),{FILE
=> $virtual, NEW_FILE
=> $new_virtual});
658 return devedit_reload
({command
=> 'show', file
=> $dir});
662 my $tpl = new Template
;
663 $tpl->read_file($config->{'templates'}->{'renamefile'});
665 $tpl->fillin("FILE",$virtual);
666 $tpl->fillin("DIR",upper_path
($virtual));
667 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
668 $tpl->fillin("SCRIPT",$script);
670 my $output = header
(-type
=> "text/html");
671 $output .= $tpl->get_template;
679 # Remove a file or a directory and return to directory view
681 # Params: 1. Reference to user input hash
682 # 2. Reference to config hash
684 # Return: Output of the command (Scalar Reference)
688 my ($data,$config) = @_;
689 my $physical = $data->{'physical'};
690 my $virtual = $data->{'virtual'};
692 return error
($config->{'errors'}->{'remove_root'},"/") if($virtual eq "/");
698 if($data->{'cgi'}->param('confirmed'))
701 return devedit_reload
({command
=> 'show', file
=> upper_path
($virtual)});
705 my $tpl = new Template
;
706 $tpl->read_file($config->{'templates'}->{'confirm_rmdir'});
708 $tpl->fillin("DIR",$virtual);
709 $tpl->fillin("UPPER_DIR",upper_path
($virtual));
710 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
711 $tpl->fillin("SCRIPT",$script);
713 my $output = header
(-type
=> "text/html");
714 $output .= $tpl->get_template;
723 return error
($config->{'errors'}->{'in_use'},upper_path
($virtual),{FILE
=> $virtual}) if($data->{'uselist'}->in_use($virtual));
725 if($data->{'cgi'}->param('confirmed'))
727 unlink($physical) or return error
($config->{'errors'}->{'delete_failed'},upper_path
($virtual),{FILE
=> $virtual});
728 return devedit_reload
({command
=> 'show', file
=> upper_path
($virtual)});
732 my $tpl = new Template
;
733 $tpl->read_file($config->{'templates'}->{'confirm_rmfile'});
735 $tpl->fillin("FILE",$virtual);
736 $tpl->fillin("DIR",upper_path
($virtual));
737 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
738 $tpl->fillin("SCRIPT",$script);
740 my $output = header
(-type
=> "text/html");
741 $output .= $tpl->get_template;
750 # Change the mode and the group of a file or a directory
752 # Params: 1. Reference to user input hash
753 # 2. Reference to config hash
755 # Return: Output of the command (Scalar Reference)
759 my ($data,$config) = @_;
760 my $physical = $data->{'physical'};
761 my $virtual = $data->{'virtual'};
762 my $dir = upper_path
($virtual);
763 my $cgi = $data->{'cgi'};
764 my $mode = $cgi->param('mode');
765 my $group = $cgi->param('group');
769 # System supports user and groups
781 my $oct_mode = $mode;
782 $oct_mode = "0".$oct_mode if(length($oct_mode) == 3);
783 $oct_mode = oct($oct_mode);
785 chmod($oct_mode,$physical);
790 # Change the group using the `chgrp` system command
792 return error
($config->{'errors'}->{'invalid_group'},$dir,{GROUP
=> encode_entities
($group)}) unless($group =~ /^[a-z0-9_]+[a-z0-9_-]*$/i);
793 system("chgrp",$group,$physical);
796 return devedit_reload
({command
=> 'show', file
=> $dir});
802 my @stat = stat($physical);
805 my $mode_oct = substr(sprintf("%04o",$mode),-4);
808 my $tpl = new Template
;
809 $tpl->read_file($config->{'templates'}->{'chprop'});
811 # Insert file properties into the template
813 $tpl->fillin("MODE_OCTAL",$mode_oct);
814 $tpl->fillin("MODE_STRING",mode_string
($mode));
815 $tpl->fillin("GID",$gid);
817 if(my $group = getgrgid($gid))
819 $tpl->fillin("GROUP",encode_entities
($group));
820 $tpl->parse_if_block("group_detected",1);
824 $tpl->parse_if_block("group_detected",0);
827 # Insert other information
829 $tpl->fillin("FILE",$virtual);
830 $tpl->fillin("DIR",$dir);
831 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
832 $tpl->fillin("SCRIPT",$script);
834 my $output = header
(-type
=> "text/html");
835 $output .= $tpl->get_template;
842 return error
($config->{'errors'}->{'not_owner'},$dir,{FILE
=> $virtual});
847 return error
($config->{'errors'}->{'no_users'},$dir,{FILE
=> $virtual});
853 # Remove a file from the list of used files and
854 # return to directory view
856 # Params: 1. Reference to user input hash
857 # 2. Reference to config hash
859 # Return: Output of the command (Scalar Reference)
863 my ($data,$config) = @_;
864 my $virtual = $data->{'virtual'};
865 my $uselist = $data->{'uselist'};
867 return devedit_reload
({command
=> 'show', file
=> upper_path
($virtual)}) if($uselist->unused($virtual));
869 if($data->{'cgi'}->param('confirmed'))
871 file_unlock
($uselist,$virtual);
872 return devedit_reload
({command
=> 'show', file
=> upper_path
($virtual)});
876 my $tpl = new Template
;
877 $tpl->read_file($config->{'templates'}->{'confirm_unlock'});
879 $tpl->fillin("FILE",$virtual);
880 $tpl->fillin("DIR",upper_path
($virtual));
881 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
882 $tpl->fillin("SCRIPT",$script);
884 my $output = header
(-type
=> "text/html");
885 $output .= $tpl->get_template;
893 # Display some information about Dev-Editor
895 # Params: 1. Reference to user input hash
896 # 2. Reference to config hash
898 # Return: Output of the command (Scalar Reference)
902 my ($data,$config) = @_;
904 my $tpl = new Template
;
905 $tpl->read_file($config->{'templates'}->{'about'});
907 $tpl->fillin("SCRIPT",$script);
909 # Dev-Editor's version number
911 $tpl->fillin("VERSION",$data->{'version'});
913 # Some path information
915 $tpl->fillin("SCRIPT_PHYS",encode_entities
($ENV{'SCRIPT_FILENAME'}));
916 $tpl->fillin("CONFIG_PATH",encode_entities
($data->{'configfile'}));
917 $tpl->fillin("FILE_ROOT", encode_entities
($config->{'fileroot'}));
918 $tpl->fillin("HTTP_ROOT", encode_entities
($config->{'httproot'}));
922 $tpl->fillin("PERL_PROG",encode_entities
($^X
));
923 $tpl->fillin("PERL_VER",sprintf("%vd",$^V
));
925 # Information about the server
927 $tpl->fillin("HTTPD",encode_entities
($ENV{'SERVER_SOFTWARE'}));
928 $tpl->fillin("OS",$^O
);
929 $tpl->fillin("TIME",encode_entities
(strftime
($config->{'timeformat'},localtime)));
931 # Process information
933 $tpl->fillin("PID",$$);
935 # Check if the functions getpwuid() and getgrgid() are available
939 # Dev-Editor is running on a system which allows users and groups
940 # So we display the user and the group of our process
942 my $uid = POSIX
::getuid
;
943 my $gid = POSIX
::getgid
;
945 $tpl->parse_if_block("users",1);
947 # ID's of user and group
949 $tpl->fillin("UID",$uid);
950 $tpl->fillin("GID",$gid);
952 # Names of user and group
954 if(my $user = getpwuid($uid))
956 $tpl->fillin("USER",encode_entities
($user));
957 $tpl->parse_if_block("user_detected",1);
961 $tpl->parse_if_block("user_detected",0);
964 if(my $group = getgrgid($gid))
966 $tpl->fillin("GROUP",encode_entities
($group));
967 $tpl->parse_if_block("group_detected",1);
971 $tpl->parse_if_block("group_detected",0);
976 $tpl->fillin("UMASK",sprintf("%04o",umask));
980 $tpl->parse_if_block("users",0);
983 my $output = header
(-type
=> "text/html");
984 $output .= $tpl->get_template;
989 # it's true, baby ;-)
patrick-canterino.de