]>
git.p6c8.net - devedit.git/blob - modules/Command.pm
4e7e365fb409cf938df686984ae76f9eb6e37c08
4 # Dev-Editor - Module Command
6 # Execute Dev-Editor's commands
8 # Author: Patrick Canterino <patshaping@gmx.net>
9 # Last modified: 2004-10-30
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 my $direntries = dir_read
($physical);
101 return error
($config->{'dir_read_failed'},upper_path
($virtual),{DIR
=> '$virtual'}) unless($direntries);
103 my $files = $direntries->{'files'};
104 my $dirs = $direntries->{'dirs'};
108 # Create the link to the upper directory
109 # (only if we are not in the root directory)
111 unless($virtual eq "/")
113 my @stat = stat($physical."/..");
115 my $udtpl = new Template
;
116 $udtpl->read_file($config->{'templates'}->{'dirlist_up'});
118 $udtpl->fillin("UPPER_DIR",encode_entities
(upper_path
($virtual)));
119 $udtpl->fillin("DATE",strftime
($config->{'timeformat'},localtime($stat[9])));
121 $dirlist .= $udtpl->get_template;
126 foreach my $dir(@
$dirs)
128 my @stat = stat($physical."/".$dir);
129 my $virt_path = encode_entities
($virtual.$dir."/");
131 my $dtpl = new Template
;
132 $dtpl->read_file($config->{'templates'}->{'dirlist_dir'});
134 $dtpl->fillin("DIR",$virt_path);
135 $dtpl->fillin("DIR_NAME",$dir);
136 $dtpl->fillin("DATE",strftime
($config->{'timeformat'},localtime($stat[9])));
137 $dtpl->fillin("URL",equal_url
($config->{'httproot'},$virt_path));
139 $dtpl->parse_if_block("users",$users && -o
$physical."/".$dir);
141 $dirlist .= $dtpl->get_template;
146 foreach my $file(@
$files)
148 my $phys_path = $physical."/".$file;
149 my $virt_path = encode_entities
($virtual.$file);
151 my @stat = stat($phys_path);
152 my $in_use = $uselist->in_use($virtual.$file);
154 my $ftpl = new Template
;
155 $ftpl->read_file($config->{'templates'}->{'dirlist_file'});
157 $ftpl->fillin("FILE",$virt_path);
158 $ftpl->fillin("FILE_NAME",$file);
159 $ftpl->fillin("SIZE",$stat[7]);
160 $ftpl->fillin("DATE",strftime
($config->{'timeformat'},localtime($stat[9])));
161 $ftpl->fillin("URL",equal_url
($config->{'httproot'},$virt_path));
163 $ftpl->parse_if_block("not_readable",not -r
$phys_path);
164 $ftpl->parse_if_block("binary",-B
$phys_path);
165 $ftpl->parse_if_block("readonly",not -w
$phys_path);
167 $ftpl->parse_if_block("viewable",-r
$phys_path && -T
$phys_path && not ($config->{'max_file_size'} && $stat[7] > $config->{'max_file_size'}));
169 $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);
171 $ftpl->parse_if_block("in_use",$in_use);
172 $ftpl->parse_if_block("unused",not $in_use);
174 $ftpl->parse_if_block("too_large",$config->{'max_file_size'} && $stat[7] > $config->{'max_file_size'});
176 $ftpl->parse_if_block("users",$users && -o
$phys_path);
178 $dirlist .= $ftpl->get_template;
181 $tpl->read_file($config->{'templates'}->{'dirlist'});
183 $tpl->fillin("DIRLIST",$dirlist);
184 $tpl->fillin("DIR",$virtual);
185 $tpl->fillin("SCRIPT",$script);
186 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
192 return error
($config->{'errors'}->{'noview'},upper_path
($virtual)) unless(-r
$physical);
194 # Check on binary files
195 # We have to do it in this way, or empty files
196 # will be recognized as binary files
202 return error
($config->{'errors'}->{'binary'},upper_path
($virtual));
208 my $size = (stat($physical))[7];
210 if($config->{'max_file_size'} && $size > $config->{'max_file_size'})
212 return error
($config->{'errors'}->{'file_too_large'},upper_path
($virtual),{SIZE
=> $config->{'max_file_size'}})
216 my $content = file_read
($physical);
217 $$content =~ s/\015\012|\012|\015/\n/g;
219 $tpl->read_file($config->{'templates'}->{'viewfile'});
221 $tpl->fillin("FILE",$virtual);
222 $tpl->fillin("DIR",upper_path
($virtual));
223 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
224 $tpl->fillin("SCRIPT",$script);
226 $tpl->parse_if_block("editable",-r
$physical && -w
$physical && -T
$physical && not ($config->{'max_file_size'} && $size > $config->{'max_file_size'}) && $uselist->unused($virtual));
228 $tpl->fillin("CONTENT",encode_entities
($$content));
233 my $output = header
(-type
=> "text/html");
234 $output .= $tpl->get_template;
241 # Lock a file and display a form to edit it
243 # Params: 1. Reference to user input hash
244 # 2. Reference to config hash
246 # Return: Output of the command (Scalar Reference)
248 sub exec_beginedit
($$)
250 my ($data,$config) = @_;
251 my $physical = $data->{'physical'};
252 my $virtual = $data->{'virtual'};
253 my $uselist = $data->{'uselist'};
255 return error
($config->{'errors'}->{'editdir'},upper_path
($virtual)) if(-d
$physical);
256 return error
($config->{'errors'}->{'in_use'},upper_path
($virtual),{FILE
=> $virtual}) if($uselist->in_use($virtual));
257 return error
($config->{'errors'}->{'noedit'},upper_path
($virtual)) unless(-r
$physical && -w
$physical);
259 # Check on binary files
265 return error
($config->{'errors'}->{'binary'},upper_path
($virtual));
269 if($config->{'max_file_size'} && (stat($physical))[7] > $config->{'max_file_size'})
271 return error
($config->{'errors'}->{'file_too_large'},upper_path
($virtual),{SIZE
=> $config->{'max_file_size'}})
277 $uselist->add_file($virtual);
280 my $content = file_read
($physical);
281 $$content =~ s/\015\012|\012|\015/\n/g;
283 my $tpl = new Template
;
284 $tpl->read_file($config->{'templates'}->{'editfile'});
286 $tpl->fillin("FILE",$virtual);
287 $tpl->fillin("DIR",upper_path
($virtual));
288 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
289 $tpl->fillin("SCRIPT",$script);
290 $tpl->fillin("CONTENT",encode_entities
($$content));
292 my $output = header
(-type
=> "text/html");
293 $output .= $tpl->get_template;
304 # Params: 1. Reference to user input hash
305 # 2. Reference to config hash
307 # Return: Output of the command (Scalar Reference)
309 sub exec_canceledit
($$)
311 my ($data,$config) = @_;
312 my $virtual = $data->{'virtual'};
314 file_unlock
($data->{'uselist'},$virtual);
315 return devedit_reload
({command
=> 'show', file
=> upper_path
($virtual)});
320 # Save a file, unlock it and return to directory view
322 # Params: 1. Reference to user input hash
323 # 2. Reference to config hash
325 # Return: Output of the command (Scalar Reference)
329 my ($data,$config) = @_;
330 my $physical = $data->{'physical'};
331 my $virtual = $data->{'virtual'};
332 my $content = $data->{'cgi'}->param('filecontent');
333 my $uselist = $data->{'uselist'};
335 # We already unlock the file at the beginning of the
336 # subroutine, because if we have to abort this routine,
337 # the file keeps locked.
338 # Nobody else will access the file during this routine
339 # because of the concept of File::UseList.
341 file_unlock
($uselist,$virtual);
345 $content =~ s/\015\012|\012|\015/\n/g;
347 if($data->{'cgi'}->param('encode_iso'))
349 # Encode all ISO-8859-1 special chars
351 $content = encode_entities
($content,"\200-\377");
354 if($data->{'cgi'}->param('saveas') && $data->{'new_physical'} ne '' && $data->{'new_virtual'} ne '')
356 # Create the new filename
358 $physical = $data->{'new_physical'};
359 $virtual = $data->{'new_virtual'};
361 # Check if someone else is editing the new file
363 return error
($config->{'errors'}->{'in_use'},upper_path
($virtual),{FILE
=> $virtual}) if($uselist->in_use($virtual));
366 return error
($config->{'errors'}->{'text_to_binary'},upper_path
($virtual)) unless(-T
$physical);
367 return error
($config->{'errors'}->{'editdir'},upper_path
($virtual)) if(-d
$physical);
368 return error
($config->{'errors'}->{'noedit'}, upper_path
($virtual)) if(-e
$physical && !(-r
$physical && -w
$physical));
370 if(file_save
($physical,\
$content))
372 # Saving of the file was successful - so unlock it!
374 return devedit_reload
({command
=> 'show', file
=> upper_path
($virtual)});
378 return error
($config->{'errors'}->{'edit_failed'},upper_path
($virtual),{FILE
=> $virtual});
384 # Create a file and return to directory view
386 # Params: 1. Reference to user input hash
387 # 2. Reference to config hash
389 # Return: Output of the command (Scalar Reference)
393 my ($data,$config) = @_;
394 my $new_physical = $data->{'new_physical'};
395 my $new_virtual = $data->{'new_virtual'};
396 my $dir = upper_path
($new_virtual);
397 $new_virtual = encode_entities
($new_virtual);
401 return error
($config->{'errors'}->{'file_exists'},$dir,{FILE
=> $new_virtual}) if(-e
$new_physical);
403 file_create
($new_physical) or return error
($config->{'errors'}->{'mkfile_failed'},$dir,{FILE
=> $new_virtual});
404 return devedit_reload
({command
=> 'show', file
=> $dir});
408 my $tpl = new Template
;
409 $tpl->read_file($config->{'templates'}->{'mkfile'});
411 $tpl->fillin("DIR","/");
412 $tpl->fillin("SCRIPT",$script);
414 my $output = header
(-type
=> "text/html");
415 $output .= $tpl->get_template;
423 # Create a directory and return to directory view
425 # Params: 1. Reference to user input hash
426 # 2. Reference to config hash
428 # Return: Output of the command (Scalar Reference)
432 my ($data,$config) = @_;
433 my $new_physical = $data->{'new_physical'};
434 my $new_virtual = $data->{'new_virtual'};
435 my $dir = upper_path
($new_virtual);
436 $new_virtual = encode_entities
($new_virtual);
438 return error
($config->{'errors'}->{'file_exists'},$dir,{FILE
=> $new_virtual}) if(-e
$new_physical);
442 mkdir($new_physical,0777) or return error
($config->{'errors'}->{'mkdir_failed'},$dir,{DIR
=> $new_virtual});
443 return devedit_reload
({command
=> 'show', file
=> $dir});
447 my $tpl = new Template
;
448 $tpl->read_file($config->{'templates'}->{'mkdir'});
450 $tpl->fillin("DIR","/");
451 $tpl->fillin("SCRIPT",$script);
453 my $output = header
(-type
=> "text/html");
454 $output .= $tpl->get_template;
464 # Params: 1. Reference to user input hash
465 # 2. Reference to config hash
467 # Return: Output of the command (Scalar Reference)
471 my ($data,$config) = @_;
472 my $physical = $data->{'physical'};
473 my $virtual = $data->{'virtual'};
474 my $cgi = $data->{'cgi'};
476 if(my $uploaded_file = $cgi->param('uploaded_file'))
478 # Process file upload
480 my $filename = file_name
($uploaded_file);
481 my $file_phys = $physical."/".$filename;
482 my $file_virt = $virtual."".$filename;
484 return error
($config->{'errors'}->{'file_exists'},$virtual,{FILE
=> $file_virt}) if(-e
$file_phys && not $cgi->param('overwrite'));
486 my $ascii = $cgi->param('ascii');
487 my $handle = $cgi->upload('uploaded_file');
491 open(FILE
,">$file_phys") or return error
($config->{'errors'}->{'mkfile_failed'},$virtual,{FILE
=> $file_virt});
492 binmode(FILE
) unless($ascii);
494 # Read transferred file and write it to disk
496 read($handle, my $data, -s
$handle);
497 $data =~ s/\015\012|\012|\015/\n/g if($ascii); # Replace line separators if transferring in ASCII mode
502 return devedit_reload
({command
=> "show", file
=> $virtual});
506 my $tpl = new Template
;
507 $tpl->read_file($config->{'templates'}->{'upload'});
509 $tpl->fillin("DIR",$virtual);
510 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
511 $tpl->fillin("SCRIPT",$script);
513 my $output = header
(-type
=> "text/html");
514 $output .= $tpl->get_template;
522 # Copy a file and return to directory view
524 # Params: 1. Reference to user input hash
525 # 2. Reference to config hash
527 # Return: Output of the command (Scalar Reference)
531 my ($data,$config) = @_;
532 my $physical = $data->{'physical'};
533 my $virtual = encode_entities
($data->{'virtual'});
534 my $new_physical = $data->{'new_physical'};
536 return error
($config->{'errors'}->{'dircopy'}) if(-d
$physical);
537 return error
($config->{'errors'}->{'nocopy'}) unless(-r
$physical);
541 my $new_virtual = $data->{'new_virtual'};
542 my $dir = upper_path
($new_virtual);
543 $new_virtual = encode_entities
($new_virtual);
547 return error
($config->{'errors'}->{'exist_edited'},$dir,{FILE
=> $new_virtual}) if($data->{'uselist'}->in_use($data->{'new_virtual'}));
551 return error
($config->{'errors'}->{'dir_replace'},$dir);
553 elsif(not $data->{'cgi'}->param('confirmed'))
555 my $tpl = new Template
;
556 $tpl->read_file($config->{'templates'}->{'confirm_replace'});
558 $tpl->fillin("FILE",$virtual);
559 $tpl->fillin("NEW_FILE",$new_virtual);
560 $tpl->fillin("NEW_FILENAME",file_name
($new_virtual));
561 $tpl->fillin("NEW_DIR",$dir);
562 $tpl->fillin("DIR",upper_path
($virtual));
564 $tpl->fillin("COMMAND","copy");
565 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
566 $tpl->fillin("SCRIPT",$script);
568 my $output = header
(-type
=> "text/html");
569 $output .= $tpl->get_template;
575 copy
($physical,$new_physical) or return error
($config->{'errors'}->{'copy_failed'},upper_path
($virtual),{FILE
=> $virtual, NEW_FILE
=> $new_virtual});
576 return devedit_reload
({command
=> 'show', file
=> $dir});
580 my $tpl = new Template
;
581 $tpl->read_file($config->{'templates'}->{'copyfile'});
583 $tpl->fillin("FILE",$virtual);
584 $tpl->fillin("DIR",upper_path
($virtual));
585 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
586 $tpl->fillin("SCRIPT",$script);
588 my $output = header
(-type
=> "text/html");
589 $output .= $tpl->get_template;
597 # Rename/move a file and return to directory view
599 # Params: 1. Reference to user input hash
600 # 2. Reference to config hash
602 # Return: Output of the command (Scalar Reference)
606 my ($data,$config) = @_;
607 my $physical = $data->{'physical'};
608 my $virtual = $data->{'virtual'};
609 my $new_physical = $data->{'new_physical'};
611 return error
($config->{'errors'}->{'rename_root'},"/") if($virtual eq "/");
612 return error
($config->{'errors'}->{'in_use'},upper_path
($virtual),{FILE
=> $virtual}) if($data->{'uselist'}->in_use($virtual));
616 my $new_virtual = $data->{'new_virtual'};
617 my $dir = upper_path
($new_virtual);
618 $new_virtual = encode_entities
($new_virtual);
622 return error
($config->{'errors'}->{'exist_edited'},$dir,{FILE
=> $new_virtual}) if($data->{'uselist'}->in_use($data->{'new_virtual'}));
626 return error
($config->{'errors'}->{'dir_replace'},$dir);
628 elsif(not $data->{'cgi'}->param('confirmed'))
630 my $tpl = new Template
;
631 $tpl->read_file($config->{'templates'}->{'confirm_replace'});
633 $tpl->fillin("FILE",$virtual);
634 $tpl->fillin("NEW_FILE",$new_virtual);
635 $tpl->fillin("NEW_FILENAME",file_name
($new_virtual));
636 $tpl->fillin("NEW_DIR",$dir);
637 $tpl->fillin("DIR",upper_path
($virtual));
639 $tpl->fillin("COMMAND","rename");
640 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
641 $tpl->fillin("SCRIPT",$script);
643 my $output = header
(-type
=> "text/html");
644 $output .= $tpl->get_template;
650 rename($physical,$new_physical) or return error
($config->{'errors'}->{'rename_failed'},upper_path
($virtual),{FILE
=> $virtual, NEW_FILE
=> $new_virtual});
651 return devedit_reload
({command
=> 'show', file
=> $dir});
655 my $tpl = new Template
;
656 $tpl->read_file($config->{'templates'}->{'renamefile'});
658 $tpl->fillin("FILE",$virtual);
659 $tpl->fillin("DIR",upper_path
($virtual));
660 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
661 $tpl->fillin("SCRIPT",$script);
663 my $output = header
(-type
=> "text/html");
664 $output .= $tpl->get_template;
672 # Remove a file or a directory and return to directory view
674 # Params: 1. Reference to user input hash
675 # 2. Reference to config hash
677 # Return: Output of the command (Scalar Reference)
681 my ($data,$config) = @_;
682 my $physical = $data->{'physical'};
683 my $virtual = $data->{'virtual'};
685 return error
($config->{'errors'}->{'remove_root'},"/") if($virtual eq "/");
691 if($data->{'cgi'}->param('confirmed'))
694 return devedit_reload
({command
=> 'show', file
=> upper_path
($virtual)});
698 my $tpl = new Template
;
699 $tpl->read_file($config->{'templates'}->{'confirm_rmdir'});
701 $tpl->fillin("DIR",$virtual);
702 $tpl->fillin("UPPER_DIR",upper_path
($virtual));
703 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
704 $tpl->fillin("SCRIPT",$script);
706 my $output = header
(-type
=> "text/html");
707 $output .= $tpl->get_template;
716 return error
($config->{'errors'}->{'in_use'},upper_path
($virtual),{FILE
=> $virtual}) if($data->{'uselist'}->in_use($virtual));
718 if($data->{'cgi'}->param('confirmed'))
720 unlink($physical) or return error
($config->{'errors'}->{'delete_failed'},upper_path
($virtual),{FILE
=> $virtual});
721 return devedit_reload
({command
=> 'show', file
=> upper_path
($virtual)});
725 my $tpl = new Template
;
726 $tpl->read_file($config->{'templates'}->{'confirm_rmfile'});
728 $tpl->fillin("FILE",$virtual);
729 $tpl->fillin("DIR",upper_path
($virtual));
730 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
731 $tpl->fillin("SCRIPT",$script);
733 my $output = header
(-type
=> "text/html");
734 $output .= $tpl->get_template;
743 # Change the mode and the group of a file or a directory
745 # Params: 1. Reference to user input hash
746 # 2. Reference to config hash
748 # Return: Output of the command (Scalar Reference)
752 my ($data,$config) = @_;
753 my $physical = $data->{'physical'};
754 my $virtual = $data->{'virtual'};
755 my $dir = upper_path
($virtual);
756 my $cgi = $data->{'cgi'};
757 my $mode = $cgi->param('mode');
758 my $group = $cgi->param('group');
768 my $oct_mode = $mode;
769 $oct_mode = "0".$oct_mode if(length($oct_mode) == 3);
770 $oct_mode = oct($oct_mode);
772 chmod($oct_mode,$physical);
777 return error
($config->{'errors'}->{'invalid_group'},$dir,{GROUP
=> $group}) unless($group =~ /^[a-z0-9_]+[a-z0-9_-]*$/i);
778 system("chgrp",$group,$physical);
781 return devedit_reload
({command
=> 'show', file
=> $dir});
785 my @stat = stat($physical);
788 my $mode_oct = substr(sprintf("%04o",$mode),-4);
790 my $group = getgrgid($gid);
792 my $tpl = new Template
;
793 $tpl->read_file($config->{'templates'}->{'chprop'});
795 $tpl->fillin("MODE_OCTAL",$mode_oct);
796 $tpl->fillin("MODE_STRING",mode_string
($mode));
797 $tpl->fillin("GID",$gid);
798 $tpl->fillin("GROUP",$group);
800 $tpl->fillin("FILE",$virtual);
801 $tpl->fillin("DIR",$dir);
802 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
803 $tpl->fillin("SCRIPT",$script);
805 my $output = header
(-type
=> "text/html");
806 $output .= $tpl->get_template;
813 return error
($config->{'errors'}->{'not_owner'},$dir,{FILE
=> $virtual});
818 return error
($config->{'errors'}->{'no_users'},$dir,{FILE
=> $virtual});
824 # Remove a file from the list of used files and
825 # return to directory view
827 # Params: 1. Reference to user input hash
828 # 2. Reference to config hash
830 # Return: Output of the command (Scalar Reference)
834 my ($data,$config) = @_;
835 my $virtual = $data->{'virtual'};
836 my $uselist = $data->{'uselist'};
838 return devedit_reload
({command
=> 'show', file
=> upper_path
($virtual)}) if($uselist->unused($virtual));
840 if($data->{'cgi'}->param('confirmed'))
842 file_unlock
($uselist,$virtual);
843 return devedit_reload
({command
=> 'show', file
=> upper_path
($virtual)});
847 my $tpl = new Template
;
848 $tpl->read_file($config->{'templates'}->{'confirm_unlock'});
850 $tpl->fillin("FILE",$virtual);
851 $tpl->fillin("DIR",upper_path
($virtual));
852 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
853 $tpl->fillin("SCRIPT",$script);
855 my $output = header
(-type
=> "text/html");
856 $output .= $tpl->get_template;
864 # Display some information about Dev-Editor
866 # Params: 1. Reference to user input hash
867 # 2. Reference to config hash
869 # Return: Output of the command (Scalar Reference)
873 my ($data,$config) = @_;
875 my $tpl = new Template
;
876 $tpl->read_file($config->{'templates'}->{'about'});
878 $tpl->fillin("SCRIPT",$script);
880 # Dev-Editor's version number
882 $tpl->fillin("VERSION",$data->{'version'});
884 # Some path information
886 $tpl->fillin("SCRIPT_PHYS",$ENV{'SCRIPT_FILENAME'});
887 $tpl->fillin("CONFIG_PATH",$data->{'configfile'});
888 $tpl->fillin("FILE_ROOT",$config->{'fileroot'});
889 $tpl->fillin("HTTP_ROOT",$config->{'httproot'});
893 $tpl->fillin("PERL_PROG",$^X
);
894 $tpl->fillin("PERL_VER",sprintf("%vd",$^V
));
896 # Information about the server
898 $tpl->fillin("HTTPD",$ENV{'SERVER_SOFTWARE'});
899 $tpl->fillin("OS",$^O
);
900 $tpl->fillin("TIME",strftime
($config->{'timeformat'},localtime));
902 # Process information
904 $tpl->fillin("PID",$$);
906 # Check if the functions getpwuid() and getgrgid() are available
910 # Dev-Editor is running on a system which allows users and groups
911 # So we display the user and the group of our process
915 my $uid = POSIX
::getuid
;
916 my $gid = POSIX
::getgid
;
918 $tpl->parse_if_block("users",1);
920 # ID's of user and group
922 $tpl->fillin("UID",$uid);
923 $tpl->fillin("GID",$gid);
925 # Names of user and group
927 $tpl->fillin("USER",getpwuid($uid));
928 $tpl->fillin("GROUP",getgrgid($gid));
932 $tpl->parse_if_block("users",0);
935 my $output = header
(-type
=> "text/html");
936 $output .= $tpl->get_template;
941 # it's true, baby ;-)
patrick-canterino.de