]>
git.p6c8.net - devedit.git/blob - modules/Command.pm
26bc5c826b3aca9cbfdad89611cdc1f6a7d9c2f1
4 # Dev-Editor - Module Command
6 # Execute Dev-Editor's commands
8 # Author: Patrick Canterino <patshaping@gmx.net>
9 # Last modified: 2004-11-23
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 $uselist = $data->{'uselist'};
94 my $tpl = new Template
;
98 # Create directory listing
100 return error
($config->{'errors'}->{'no_dir_access'},upper_path
($virtual)) unless(-r
$physical && -x
$physical);
102 my $direntries = dir_read
($physical);
103 return error
($config->{'dir_read_fail'},upper_path
($virtual),{DIR
=> $virtual}) unless($direntries);
105 my $files = $direntries->{'files'};
106 my $dirs = $direntries->{'dirs'};
110 # Create the link to the upper directory
111 # (only if we are not in the root directory)
113 unless($virtual eq "/")
115 my @stat = stat($physical."/..");
117 my $udtpl = new Template
;
118 $udtpl->read_file($config->{'templates'}->{'dirlist_up'});
120 $udtpl->fillin("UPPER_DIR",encode_entities
(upper_path
($virtual)));
121 $udtpl->fillin("DATE",encode_entities
(strftime
($config->{'timeformat'},localtime($stat[9]))));
123 $dirlist .= $udtpl->get_template;
128 foreach my $dir(@
$dirs)
130 my $phys_path = $physical."/".$dir;
131 my $virt_path = encode_entities
($virtual.$dir."/");
133 my @stat = stat($phys_path);
135 my $dtpl = new Template
;
136 $dtpl->read_file($config->{'templates'}->{'dirlist_dir'});
138 $dtpl->fillin("DIR",$virt_path);
139 $dtpl->fillin("DIR_NAME",$dir);
140 $dtpl->fillin("DATE",encode_entities
(strftime
($config->{'timeformat'},localtime($stat[9]))));
141 $dtpl->fillin("URL",equal_url
($config->{'httproot'},$virt_path));
143 $dtpl->parse_if_block("readable",-r
$phys_path && -x
$phys_path);
144 $dtpl->parse_if_block("users",$users && -o
$phys_path);
146 $dirlist .= $dtpl->get_template;
151 foreach my $file(@
$files)
153 my $phys_path = $physical."/".$file;
154 my $virt_path = encode_entities
($virtual.$file);
156 my @stat = stat($phys_path);
157 my $in_use = $uselist->in_use($virtual.$file);
159 my $ftpl = new Template
;
160 $ftpl->read_file($config->{'templates'}->{'dirlist_file'});
162 $ftpl->fillin("FILE",$virt_path);
163 $ftpl->fillin("FILE_NAME",$file);
164 $ftpl->fillin("SIZE",$stat[7]);
165 $ftpl->fillin("DATE",encode_entities
(strftime
($config->{'timeformat'},localtime($stat[9]))));
166 $ftpl->fillin("URL",equal_url
($config->{'httproot'},$virt_path));
168 $ftpl->parse_if_block("not_readable",not -r
$phys_path);
169 $ftpl->parse_if_block("binary",-B
$phys_path);
170 $ftpl->parse_if_block("readonly",not -w
$phys_path);
172 $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
($virtual)) 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
($virtual));
213 my $size = (stat($physical))[7];
215 if($config->{'max_file_size'} && $size > $config->{'max_file_size'})
217 return error
($config->{'errors'}->{'file_too_large'},upper_path
($virtual),{SIZE
=> $config->{'max_file_size'}})
221 my $content = file_read
($physical);
222 $$content =~ s/\015\012|\012|\015/\n/g;
224 $tpl->read_file($config->{'templates'}->{'viewfile'});
226 $tpl->fillin("FILE",$virtual);
227 $tpl->fillin("DIR",upper_path
($virtual));
228 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
229 $tpl->fillin("SCRIPT",$script);
231 $tpl->parse_if_block("editable",-r
$physical && -w
$physical && -T
$physical && not ($config->{'max_file_size'} && $size > $config->{'max_file_size'}) && $uselist->unused($virtual));
233 $tpl->fillin("CONTENT",encode_entities
($$content));
238 my $output = header
(-type
=> "text/html");
239 $output .= $tpl->get_template;
246 # Lock a file and display a form to edit it
248 # Params: 1. Reference to user input hash
249 # 2. Reference to config hash
251 # Return: Output of the command (Scalar Reference)
253 sub exec_beginedit
($$)
255 my ($data,$config) = @_;
256 my $physical = $data->{'physical'};
257 my $virtual = $data->{'virtual'};
258 my $dir = upper_path
($virtual);
259 my $uselist = $data->{'uselist'};
261 return error
($config->{'errors'}->{'editdir'},$dir) if(-d
$physical);
262 return error
($config->{'errors'}->{'in_use'}, $dir,{FILE
=> $virtual}) if($uselist->in_use($virtual));
263 return error
($config->{'errors'}->{'noedit'}, $dir) unless(-r
$physical && -w
$physical);
265 # Check on binary files
271 return error
($config->{'errors'}->{'binary'},$dir);
275 if($config->{'max_file_size'} && (-s
$physical) > $config->{'max_file_size'})
277 return error
($config->{'errors'}->{'file_too_large'},$dir,{SIZE
=> $config->{'max_file_size'}})
283 $uselist->add_file($virtual);
286 my $content = file_read
($physical);
287 $$content =~ s/\015\012|\012|\015/\n/g;
289 my $tpl = new Template
;
290 $tpl->read_file($config->{'templates'}->{'editfile'});
292 $tpl->fillin("FILE",$virtual);
293 $tpl->fillin("DIR",$dir);
294 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
295 $tpl->fillin("SCRIPT",$script);
296 $tpl->fillin("CONTENT",encode_entities
($$content));
298 my $output = header
(-type
=> "text/html");
299 $output .= $tpl->get_template;
310 # Params: 1. Reference to user input hash
311 # 2. Reference to config hash
313 # Return: Output of the command (Scalar Reference)
315 sub exec_canceledit
($$)
317 my ($data,$config) = @_;
318 my $virtual = $data->{'virtual'};
320 file_unlock
($data->{'uselist'},$virtual);
321 return devedit_reload
({command
=> 'show', file
=> upper_path
($virtual)});
326 # Save a file, unlock it and return to directory view
328 # Params: 1. Reference to user input hash
329 # 2. Reference to config hash
331 # Return: Output of the command (Scalar Reference)
335 my ($data,$config) = @_;
336 my $physical = $data->{'physical'};
337 my $virtual = $data->{'virtual'};
338 my $dir = upper_path
($virtual);
339 my $content = $data->{'cgi'}->param('filecontent');
340 my $uselist = $data->{'uselist'};
342 # We already unlock the file at the beginning of the
343 # subroutine, because if we have to abort this routine,
344 # the file keeps locked.
345 # Nobody else will access the file during this routine
346 # because of the concept of File::UseList.
348 file_unlock
($uselist,$virtual);
352 $content =~ s/\015\012|\012|\015/\n/g;
354 if($data->{'cgi'}->param('encode_iso'))
356 # Encode all ISO-8859-1 special chars
358 $content = encode_entities
($content,"\200-\377");
361 if($data->{'cgi'}->param('saveas') && $data->{'new_physical'} ne '' && $data->{'new_virtual'} ne '')
363 # Create the new filename
365 $physical = $data->{'new_physical'};
366 $virtual = $data->{'new_virtual'};
368 # Check if someone else is editing the new file
370 return error
($config->{'errors'}->{'in_use'},$dir,{FILE
=> $virtual}) if($uselist->in_use($virtual));
373 return error
($config->{'errors'}->{'text_to_binary'},$dir) unless(-T
$physical);
374 return error
($config->{'errors'}->{'editdir'},$dir) if(-d
$physical);
375 return error
($config->{'errors'}->{'noedit'}, $dir) if(-e
$physical && !(-r
$physical && -w
$physical));
377 if(file_save
($physical,\
$content))
379 # Saving of the file was successful - so unlock it!
381 return devedit_reload
({command
=> 'show', file
=> $dir});
385 return error
($config->{'errors'}->{'edit_failed'},$dir,{FILE
=> $virtual});
391 # Create a file and return to directory view
393 # Params: 1. Reference to user input hash
394 # 2. Reference to config hash
396 # Return: Output of the command (Scalar Reference)
400 my ($data,$config) = @_;
401 my $new_physical = $data->{'new_physical'};
402 my $new_virtual = $data->{'new_virtual'};
403 my $dir = upper_path
($new_virtual);
404 $new_virtual = encode_entities
($new_virtual);
408 return error
($config->{'errors'}->{'file_exists'},$dir,{FILE
=> $new_virtual}) if(-e
$new_physical);
410 file_create
($new_physical) or return error
($config->{'errors'}->{'mkfile_failed'},$dir,{FILE
=> $new_virtual});
411 return devedit_reload
({command
=> 'show', file
=> $dir});
415 my $tpl = new Template
;
416 $tpl->read_file($config->{'templates'}->{'mkfile'});
418 $tpl->fillin("DIR","/");
419 $tpl->fillin("SCRIPT",$script);
421 my $output = header
(-type
=> "text/html");
422 $output .= $tpl->get_template;
430 # Create a directory and return to directory view
432 # Params: 1. Reference to user input hash
433 # 2. Reference to config hash
435 # Return: Output of the command (Scalar Reference)
439 my ($data,$config) = @_;
440 my $new_physical = $data->{'new_physical'};
441 my $new_virtual = $data->{'new_virtual'};
442 my $dir = upper_path
($new_virtual);
443 $new_virtual = encode_entities
($new_virtual);
445 return error
($config->{'errors'}->{'file_exists'},$dir,{FILE
=> $new_virtual}) if(-e
$new_physical);
449 mkdir($new_physical,0777) or return error
($config->{'errors'}->{'mkdir_failed'},$dir,{DIR
=> $new_virtual});
450 return devedit_reload
({command
=> 'show', file
=> $dir});
454 my $tpl = new Template
;
455 $tpl->read_file($config->{'templates'}->{'mkdir'});
457 $tpl->fillin("DIR","/");
458 $tpl->fillin("SCRIPT",$script);
460 my $output = header
(-type
=> "text/html");
461 $output .= $tpl->get_template;
471 # Params: 1. Reference to user input hash
472 # 2. Reference to config hash
474 # Return: Output of the command (Scalar Reference)
478 my ($data,$config) = @_;
479 my $physical = $data->{'physical'};
480 my $virtual = $data->{'virtual'};
481 my $cgi = $data->{'cgi'};
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'}) if(-d
$physical);
544 return error
($config->{'errors'}->{'nocopy'}) 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');
775 my $oct_mode = $mode;
776 $oct_mode = "0".$oct_mode if(length($oct_mode) == 3);
777 $oct_mode = oct($oct_mode);
779 chmod($oct_mode,$physical);
784 return error
($config->{'errors'}->{'invalid_group'},$dir,{GROUP
=> encode_entities
($group)}) unless($group =~ /^[a-z0-9_]+[a-z0-9_-]*$/i);
785 system("chgrp",$group,$physical);
788 return devedit_reload
({command
=> 'show', file
=> $dir});
794 my @stat = stat($physical);
797 my $mode_oct = substr(sprintf("%04o",$mode),-4);
800 my $tpl = new Template
;
801 $tpl->read_file($config->{'templates'}->{'chprop'});
803 # Insert file properties into the template
805 $tpl->fillin("MODE_OCTAL",$mode_oct);
806 $tpl->fillin("MODE_STRING",mode_string
($mode));
807 $tpl->fillin("GID",$gid);
809 if(my $group = getgrgid($gid))
811 $tpl->fillin("GROUP",encode_entities
($group));
812 $tpl->parse_if_block("group_detected",1);
816 $tpl->parse_if_block("group_detected",0);
819 # Insert other information
821 $tpl->fillin("FILE",$virtual);
822 $tpl->fillin("DIR",$dir);
823 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
824 $tpl->fillin("SCRIPT",$script);
826 my $output = header
(-type
=> "text/html");
827 $output .= $tpl->get_template;
834 return error
($config->{'errors'}->{'not_owner'},$dir,{FILE
=> $virtual});
839 return error
($config->{'errors'}->{'no_users'},$dir,{FILE
=> $virtual});
845 # Remove a file from the list of used files and
846 # return to directory view
848 # Params: 1. Reference to user input hash
849 # 2. Reference to config hash
851 # Return: Output of the command (Scalar Reference)
855 my ($data,$config) = @_;
856 my $virtual = $data->{'virtual'};
857 my $uselist = $data->{'uselist'};
859 return devedit_reload
({command
=> 'show', file
=> upper_path
($virtual)}) if($uselist->unused($virtual));
861 if($data->{'cgi'}->param('confirmed'))
863 file_unlock
($uselist,$virtual);
864 return devedit_reload
({command
=> 'show', file
=> upper_path
($virtual)});
868 my $tpl = new Template
;
869 $tpl->read_file($config->{'templates'}->{'confirm_unlock'});
871 $tpl->fillin("FILE",$virtual);
872 $tpl->fillin("DIR",upper_path
($virtual));
873 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
874 $tpl->fillin("SCRIPT",$script);
876 my $output = header
(-type
=> "text/html");
877 $output .= $tpl->get_template;
885 # Display some information about Dev-Editor
887 # Params: 1. Reference to user input hash
888 # 2. Reference to config hash
890 # Return: Output of the command (Scalar Reference)
894 my ($data,$config) = @_;
896 my $tpl = new Template
;
897 $tpl->read_file($config->{'templates'}->{'about'});
899 $tpl->fillin("SCRIPT",$script);
901 # Dev-Editor's version number
903 $tpl->fillin("VERSION",$data->{'version'});
905 # Some path information
907 $tpl->fillin("SCRIPT_PHYS",encode_entities
($ENV{'SCRIPT_FILENAME'}));
908 $tpl->fillin("CONFIG_PATH",encode_entities
($data->{'configfile'}));
909 $tpl->fillin("FILE_ROOT", encode_entities
($config->{'fileroot'}));
910 $tpl->fillin("HTTP_ROOT", encode_entities
($config->{'httproot'}));
914 $tpl->fillin("PERL_PROG",encode_entities
($^X
));
915 $tpl->fillin("PERL_VER",sprintf("%vd",$^V
));
917 # Information about the server
919 $tpl->fillin("HTTPD",encode_entities
($ENV{'SERVER_SOFTWARE'}));
920 $tpl->fillin("OS",$^O
);
921 $tpl->fillin("TIME",encode_entities
(strftime
($config->{'timeformat'},localtime)));
923 # Process information
925 $tpl->fillin("PID",$$);
927 # Check if the functions getpwuid() and getgrgid() are available
931 # Dev-Editor is running on a system which allows users and groups
932 # So we display the user and the group of our process
934 my $uid = POSIX
::getuid
;
935 my $gid = POSIX
::getgid
;
937 $tpl->parse_if_block("users",1);
939 # ID's of user and group
941 $tpl->fillin("UID",$uid);
942 $tpl->fillin("GID",$gid);
944 # Names of user and group
946 if(my $user = getpwuid($uid))
948 $tpl->fillin("USER",encode_entities
($user));
949 $tpl->parse_if_block("user_detected",1);
953 $tpl->parse_if_block("user_detected",0);
956 if(my $group = getgrgid($gid))
958 $tpl->fillin("GROUP",encode_entities
($group));
959 $tpl->parse_if_block("group_detected",1);
963 $tpl->parse_if_block("group_detected",0);
968 $tpl->fillin("UMASK",sprintf("%04o",umask));
972 $tpl->parse_if_block("users",0);
975 my $output = header
(-type
=> "text/html");
976 $output .= $tpl->get_template;
981 # it's true, baby ;-)
patrick-canterino.de