]> git.p6c8.net - devedit.git/blob - modules/Command.pm
64f49008c29f371a611a3bd3f11bbcc99542c17a
[devedit.git] / modules / Command.pm
1 package Command;
2
3 #
4 # Dev-Editor - Module Command
5 #
6 # Execute Dev-Editor's commands
7 #
8 # Author: Patrick Canterino <patshaping@gmx.net>
9 # Last modified: 2004-07-03
10 #
11
12 use strict;
13
14 use vars qw(@EXPORT);
15
16 use File::Access;
17 use File::Copy;
18 use File::Path;
19
20 use POSIX qw(strftime);
21 use Tool;
22
23 use CGI qw(header);
24 use HTML::Entities;
25 use Output;
26 use Template;
27
28 use Data::Dumper;
29
30 my $script = $ENV{'SCRIPT_NAME'};
31
32 my %dispatch = ('show' => \&exec_show,
33 'beginedit' => \&exec_beginedit,
34 'canceledit' => \&exec_canceledit,
35 'endedit' => \&exec_endedit,
36 'mkdir' => \&exec_mkdir,
37 'mkfile' => \&exec_mkfile,
38 'upload' => \&exec_upload,
39 'copy' => \&exec_copy,
40 'rename' => \&exec_rename,
41 'remove' => \&exec_remove,
42 'unlock' => \&exec_unlock,
43 'about' => \&exec_about
44 );
45
46 ### Export ###
47
48 use base qw(Exporter);
49
50 @EXPORT = qw(exec_command);
51
52 # exec_command()
53 #
54 # Execute the specified command
55 #
56 # Params: 1. Command to execute
57 # 2. Reference to user input hash
58 # 3. Reference to config hash
59 #
60 # Return: Output of the command (Scalar Reference)
61
62 sub exec_command($$$)
63 {
64 my ($command,$data,$config) = @_;
65
66 return error($config->{'errors'}->{'cmd_unknown'},'/',{COMMAND => $command}) unless($dispatch{$command});
67
68 my $output = &{$dispatch{$command}}($data,$config);
69 return $output;
70 }
71
72 # exec_show()
73 #
74 # View a directory or a file
75 #
76 # Params: 1. Reference to user input hash
77 # 2. Reference to config hash
78 #
79 # Return: Output of the command (Scalar Reference)
80
81 sub exec_show($$)
82 {
83 my ($data,$config) = @_;
84 my $physical = $data->{'physical'};
85 my $virtual = $data->{'virtual'};
86
87 my $tpl = new Template;
88
89 if(-d $physical)
90 {
91 # Create directory listing
92
93 my $direntries = dir_read($physical);
94 return error($config->{'dir_read_failed'},upper_path($virtual),{DIR => '$virtual'}) unless($direntries);
95
96 my $files = $direntries->{'files'};
97 my $dirs = $direntries->{'dirs'};
98
99 my $dirlist = "";
100
101 # Create the link to the upper directory
102 # (only if we are not in the root directory)
103
104 unless($virtual eq "/")
105 {
106 my @stat = stat($physical."/..");
107
108 my $udtpl = new Template;
109 $udtpl->read_file($config->{'templates'}->{'dirlist_up'});
110
111 $udtpl->fillin("UPPER_DIR",encode_entities(upper_path($virtual)));
112 $udtpl->fillin("DATE",strftime($config->{'timeformat'},localtime($stat[9])));
113
114 $dirlist .= $udtpl->get_template;
115 }
116
117 # Directories
118
119 foreach my $dir(@$dirs)
120 {
121 my @stat = stat($physical."/".$dir);
122 my $virt_path = encode_entities($virtual.$dir."/");
123
124 my $dtpl = new Template;
125 $dtpl->read_file($config->{'templates'}->{'dirlist_dir'});
126
127 $dtpl->fillin("DIR",$virt_path);
128 $dtpl->fillin("DIR_NAME",$dir);
129 $dtpl->fillin("DATE",strftime($config->{'timeformat'},localtime($stat[9])));
130 $dtpl->fillin("URL",equal_url($config->{'httproot'},$virt_path));
131
132 $dirlist .= $dtpl->get_template;
133 }
134
135 # Files
136
137 foreach my $file(@$files)
138 {
139 my $phys_path = $physical."/".$file;
140 my $virt_path = encode_entities($virtual.$file);
141
142 my @stat = stat($phys_path);
143 my $in_use = $data->{'uselist'}->in_use($virtual.$file);
144
145 my $ftpl = new Template;
146 $ftpl->read_file($config->{'templates'}->{'dirlist_file'});
147
148 $ftpl->fillin("FILE",$virt_path);
149 $ftpl->fillin("FILE_NAME",$file);
150 $ftpl->fillin("SIZE",$stat[7]);
151 $ftpl->fillin("DATE",strftime($config->{'timeformat'},localtime($stat[9])));
152 $ftpl->fillin("URL",equal_url($config->{'httproot'},$virt_path));
153
154 $ftpl->parse_if_block("not_readable",not -r $phys_path);
155 $ftpl->parse_if_block("binary",-B $phys_path);
156 $ftpl->parse_if_block("readonly",not -w $phys_path);
157
158 $ftpl->parse_if_block("viewable",-r $phys_path && -T $phys_path && not ($config->{'max_file_size'} && $stat[7] > $config->{'max_file_size'}));
159
160 $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);
161
162 $ftpl->parse_if_block("in_use",$in_use);
163 $ftpl->parse_if_block("unused",not $in_use);
164
165 $ftpl->parse_if_block("too_large",$config->{'max_file_size'} && $stat[7] > $config->{'max_file_size'});
166
167 $dirlist .= $ftpl->get_template;
168 }
169
170 $tpl->read_file($config->{'templates'}->{'dirlist'});
171
172 $tpl->fillin("DIRLIST",$dirlist);
173 $tpl->fillin("DIR",$virtual);
174 $tpl->fillin("SCRIPT",$script);
175 $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
176 }
177 else
178 {
179 # View a file
180
181 return error($config->{'errors'}->{'noview'},upper_path($virtual)) unless(-r $physical);
182
183 # Check on binary files
184 # We have to do it in this way, or empty files
185 # will be recognized as binary files
186
187 unless(-T $physical)
188 {
189 # Binary file
190
191 return error($config->{'errors'}->{'binary'},upper_path($virtual));
192 }
193 else
194 {
195 # Text file
196
197 if($config->{'max_file_size'} && (stat($physical))[7] > $config->{'max_file_size'})
198 {
199 return error($config->{'errors'}->{'file_too_large'},upper_path($virtual),{SIZE => $config->{'max_file_size'}})
200 }
201 else
202 {
203 my $content = file_read($physical);
204 $$content =~ s/\015\012|\012|\015/\n/g;
205
206 $tpl->read_file($config->{'templates'}->{'viewfile'});
207
208 $tpl->fillin("FILE",$virtual);
209 $tpl->fillin("DIR",upper_path($virtual));
210 $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
211 $tpl->fillin("SCRIPT",$script);
212 $tpl->fillin("CONTENT",encode_entities($$content));
213 }
214 }
215 }
216
217 my $output = header(-type => "text/html");
218 $output .= $tpl->get_template;
219
220 return \$output;
221 }
222
223 # exec_beginedit
224 #
225 # Lock a file and display a form to edit it
226 #
227 # Params: 1. Reference to user input hash
228 # 2. Reference to config hash
229 #
230 # Return: Output of the command (Scalar Reference)
231
232 sub exec_beginedit($$)
233 {
234 my ($data,$config) = @_;
235 my $physical = $data->{'physical'};
236 my $virtual = $data->{'virtual'};
237 my $uselist = $data->{'uselist'};
238
239 return error($config->{'errors'}->{'editdir'},upper_path($virtual)) if(-d $physical);
240 return error($config->{'errors'}->{'in_use'},upper_path($virtual),{FILE => $virtual}) if($uselist->in_use($virtual));
241 return error($config->{'errors'}->{'noedit'},upper_path($virtual)) unless(-r $physical && -w $physical);
242
243 # Check on binary files
244
245 unless(-T $physical)
246 {
247 # Binary file
248
249 return error($config->{'errors'}->{'binary'},upper_path($virtual));
250 }
251 else
252 {
253 if($config->{'max_file_size'} && (stat($physical))[7] > $config->{'max_file_size'})
254 {
255 return error($config->{'errors'}->{'file_too_large'},upper_path($virtual),{SIZE => $config->{'max_file_size'}})
256 }
257 else
258 {
259 # Text file
260
261 $uselist->add_file($virtual);
262 $uselist->save;
263
264 my $content = file_read($physical);
265 $$content =~ s/\015\012|\012|\015/\n/g;
266
267 my $tpl = new Template;
268 $tpl->read_file($config->{'templates'}->{'editfile'});
269
270 $tpl->fillin("FILE",$virtual);
271 $tpl->fillin("DIR",upper_path($virtual));
272 $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
273 $tpl->fillin("SCRIPT",$script);
274 $tpl->fillin("CONTENT",encode_entities($$content));
275
276 my $output = header(-type => "text/html");
277 $output .= $tpl->get_template;
278
279 return \$output;
280 }
281 }
282 }
283
284 # exec_canceledit()
285 #
286 # Abort file editing
287 #
288 # Params: 1. Reference to user input hash
289 # 2. Reference to config hash
290 #
291 # Return: Output of the command (Scalar Reference)
292
293 sub exec_canceledit($$)
294 {
295 my ($data,$config) = @_;
296 my $virtual = $data->{'virtual'};
297
298 file_unlock($data->{'uselist'},$virtual);
299 return devedit_reload({command => 'show', file => upper_path($virtual)});
300 }
301
302 # exec_endedit()
303 #
304 # Save a file, unlock it and return to directory view
305 #
306 # Params: 1. Reference to user input hash
307 # 2. Reference to config hash
308 #
309 # Return: Output of the command (Scalar Reference)
310
311 sub exec_endedit($$)
312 {
313 my ($data,$config) = @_;
314 my $physical = $data->{'physical'};
315 my $virtual = $data->{'virtual'};
316 my $content = $data->{'cgi'}->param('filecontent');
317 my $uselist = $data->{'uselist'};
318
319 # Normalize newlines
320
321 $content =~ s/\015\012|\012|\015/\n/g;
322
323 if($data->{'cgi'}->param('encode_iso'))
324 {
325 # Encode all ISO-8859-1 special chars
326
327 $content = encode_entities($content,"\200-\377");
328 }
329
330 if($data->{'cgi'}->param('saveas'))
331 {
332 # Create the new filename
333
334 $physical = $data->{'new_physical'};
335 $virtual = $data->{'new_virtual'};
336
337 # Check if someone else is editing the new file
338
339 return error($config->{'errors'}->{'in_use'},upper_path($virtual),{FILE => $virtual}) if($uselist->in_use($virtual));
340 }
341
342 return error($config->{'errors'}->{'editdir'},upper_path($virtual)) if(-d $physical);
343 return error($config->{'errors'}->{'noedit'}, upper_path($virtual)) unless(-r $physical && -w $physical);
344
345 if(file_save($physical,\$content))
346 {
347 # Saving of the file was successful - so unlock it!
348
349 file_unlock($uselist,$data->{'virtual'});
350 # ^^^^^^^^^^^^^^^^^^
351 # Maybe the user saved the file using another filename...
352 # But we have to unlock the original file!
353
354 return devedit_reload({command => 'show', file => upper_path($virtual)});
355 }
356 else
357 {
358 return error($config->{'errors'}->{'edit_failed'},upper_path($virtual),{FILE => $virtual});
359 }
360 }
361
362 # exec_mkfile()
363 #
364 # Create a file and return to directory view
365 #
366 # Params: 1. Reference to user input hash
367 # 2. Reference to config hash
368 #
369 # Return: Output of the command (Scalar Reference)
370
371 sub exec_mkfile($$)
372 {
373 my ($data,$config) = @_;
374 my $new_physical = $data->{'new_physical'};
375 my $new_virtual = $data->{'new_virtual'};
376 my $dir = upper_path($new_virtual);
377 $new_virtual = encode_entities($new_virtual);
378
379 return error($config->{'errors'}->{'file_exists'},$dir,{FILE => $new_virtual}) if(-e $new_physical);
380
381 file_create($new_physical) or return error($config->{'errors'}->{'mkfile_failed'},$dir,{FILE => $new_virtual});
382 return devedit_reload({command => 'show', file => $dir});
383 }
384
385 # exec_mkdir()
386 #
387 # Create a directory and return to directory view
388 #
389 # Params: 1. Reference to user input hash
390 # 2. Reference to config hash
391 #
392 # Return: Output of the command (Scalar Reference)
393
394 sub exec_mkdir($$)
395 {
396 my ($data,$config) = @_;
397 my $new_physical = $data->{'new_physical'};
398 my $new_virtual = $data->{'new_virtual'};
399 my $dir = upper_path($new_virtual);
400 $new_virtual = encode_entities($new_virtual);
401
402 return error($config->{'errors'}->{'file_exists'},$dir,{FILE => $new_virtual}) if(-e $new_physical);
403
404 mkdir($new_physical,0777) or return error($config->{'errors'}->{'mkdir_failed'},$dir,{DIR => $new_virtual});
405 return devedit_reload({command => 'show', file => $dir});
406 }
407
408 # exec_upload()
409 #
410 # Upload a file
411 #
412 # Params: 1. Reference to user input hash
413 # 2. Reference to config hash
414 #
415 # Return: Output of the command (Scalar Reference)
416
417 sub exec_upload($$)
418 {
419 my ($data,$config) = @_;
420 my $physical = $data->{'physical'};
421 my $virtual = $data->{'virtual'};
422 my $cgi = $data->{'cgi'};
423
424 if(my $uploaded_file = $cgi->param('uploaded_file'))
425 {
426 # Process file upload
427
428 my $filename = file_name($uploaded_file);
429 my $file_phys = $physical."/".$filename;
430 my $file_virt = $virtual."".$filename;
431
432 return error($config->{'errors'}->{'file_exists'},$virtual,{FILE => $file_virt}) if(-e $file_phys);
433
434 my $ascii = $cgi->param('ascii');
435 my $handle = $cgi->upload('uploaded_file');
436
437 local *FILE;
438
439 open(FILE,">$file_phys") or return error($config->{'errors'}->{'mkfile_failed'},$virtual,{FILE => $file_virt});
440 binmode(FILE) unless($ascii);
441
442 # Read transferred file and write it to disk
443
444 read($handle, my $data, -s $handle);
445 $data =~ s/\015\012|\012|\015/\n/g if($ascii); # Replace line separators if transferring in ASCII mode
446 print FILE $data;
447
448 close(FILE);
449
450 return devedit_reload({command => "show", file => $virtual});
451 }
452 else
453 {
454 my $tpl = new Template;
455 $tpl->read_file($config->{'templates'}->{'upload'});
456
457 $tpl->fillin("DIR",$virtual);
458 $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
459 $tpl->fillin("SCRIPT",$script);
460
461 my $output = header(-type => "text/html");
462 $output .= $tpl->get_template;
463
464 return \$output;
465 }
466 }
467
468 # exec_copy()
469 #
470 # Copy a file and return to directory view
471 #
472 # Params: 1. Reference to user input hash
473 # 2. Reference to config hash
474 #
475 # Return: Output of the command (Scalar Reference)
476
477 sub exec_copy($$)
478 {
479 my ($data,$config) = @_;
480 my $physical = $data->{'physical'};
481 my $virtual = encode_entities($data->{'virtual'});
482 my $new_physical = $data->{'new_physical'};
483
484 return error($config->{'errors'}->{'nocopy'}) unless(-r $physical);
485
486 if($new_physical)
487 {
488 my $new_virtual = $data->{'new_virtual'};
489 my $dir = upper_path($new_virtual);
490 $new_virtual = encode_entities($new_virtual);
491
492 if(-e $new_physical)
493 {
494 return error($config->{'errors'}->{'exist_edited'},$dir,{FILE => $new_virtual}) if($data->{'uselist'}->in_use($data->{'new_virtual'}));
495
496 if(-d $new_physical)
497 {
498 return error($config->{'errors'}->{'dircopy'});
499 }
500 elsif(not $data->{'cgi'}->param('confirmed'))
501 {
502 my $tpl = new Template;
503 $tpl->read_file($config->{'templates'}->{'confirm_replace'});
504
505 $tpl->fillin("FILE",$virtual);
506 $tpl->fillin("NEW_FILE",$new_virtual);
507 $tpl->fillin("NEW_FILENAME",file_name($new_virtual));
508 $tpl->fillin("NEW_DIR",$dir);
509 $tpl->fillin("DIR",upper_path($virtual));
510
511 $tpl->fillin("COMMAND","copy");
512 $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
513 $tpl->fillin("SCRIPT",$script);
514
515 my $output = header(-type => "text/html");
516 $output .= $tpl->get_template;
517
518 return \$output;
519 }
520 }
521
522 copy($physical,$new_physical) or return error($config->{'errors'}->{'copy_failed'},upper_path($virtual),{FILE => $virtual, NEW_FILE => $new_virtual});
523 return devedit_reload({command => 'show', file => $dir});
524 }
525 else
526 {
527 my $tpl = new Template;
528 $tpl->read_file($config->{'templates'}->{'copyfile'});
529
530 $tpl->fillin("FILE",$virtual);
531 $tpl->fillin("DIR",upper_path($virtual));
532 $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
533 $tpl->fillin("SCRIPT",$script);
534
535 my $output = header(-type => "text/html");
536 $output .= $tpl->get_template;
537
538 return \$output;
539 }
540 }
541
542 # exec_rename()
543 #
544 # Rename/move a file and return to directory view
545 #
546 # Params: 1. Reference to user input hash
547 # 2. Reference to config hash
548 #
549 # Return: Output of the command (Scalar Reference)
550
551 sub exec_rename($$)
552 {
553 my ($data,$config) = @_;
554 my $physical = $data->{'physical'};
555 my $virtual = $data->{'virtual'};
556 my $new_physical = $data->{'new_physical'};
557
558 return error($config->{'errors'}->{'in_use'},upper_path($virtual),{FILE => $virtual}) if($data->{'uselist'}->in_use($virtual));
559
560 if($new_physical)
561 {
562 my $new_virtual = $data->{'new_virtual'};
563 my $dir = upper_path($new_virtual);
564 $new_virtual = encode_entities($new_virtual);
565
566 if(-e $new_physical)
567 {
568 return error($config->{'errors'}->{'exist_edited'},$dir,{FILE => $new_virtual}) if($data->{'uselist'}->in_use($data->{'new_virtual'}));
569
570 if(-d $new_physical)
571 {
572 return error($config->{'errors'}->{'dircopy'});
573 }
574 elsif(not $data->{'cgi'}->param('confirmed'))
575 {
576 my $tpl = new Template;
577 $tpl->read_file($config->{'templates'}->{'confirm_replace'});
578
579 $tpl->fillin("FILE",$virtual);
580 $tpl->fillin("NEW_FILE",$new_virtual);
581 $tpl->fillin("NEW_FILENAME",file_name($new_virtual));
582 $tpl->fillin("NEW_DIR",$dir);
583 $tpl->fillin("DIR",upper_path($virtual));
584
585 $tpl->fillin("COMMAND","rename");
586 $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
587 $tpl->fillin("SCRIPT",$script);
588
589 my $output = header(-type => "text/html");
590 $output .= $tpl->get_template;
591
592 return \$output;
593 }
594 }
595
596 rename($physical,$new_physical) or return error($config->{'errors'}->{'rename_failed'},upper_path($virtual),{FILE => $virtual, NEW_FILE => $new_virtual});
597 return devedit_reload({command => 'show', file => $dir});
598 }
599 else
600 {
601 my $tpl = new Template;
602 $tpl->read_file($config->{'templates'}->{'renamefile'});
603
604 $tpl->fillin("FILE",$virtual);
605 $tpl->fillin("DIR",upper_path($virtual));
606 $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
607 $tpl->fillin("SCRIPT",$script);
608
609 my $output = header(-type => "text/html");
610 $output .= $tpl->get_template;
611
612 return \$output;
613 }
614 }
615
616 # exec_remove()
617 #
618 # Remove a file or a directory and return to directory view
619 #
620 # Params: 1. Reference to user input hash
621 # 2. Reference to config hash
622 #
623 # Return: Output of the command (Scalar Reference)
624
625 sub exec_remove($$)
626 {
627 my ($data,$config) = @_;
628 my $physical = $data->{'physical'};
629 my $virtual = $data->{'virtual'};
630
631 if(-d $physical)
632 {
633 # Remove a directory
634
635 if($data->{'cgi'}->param('confirmed'))
636 {
637 rmtree($physical);
638 return devedit_reload({command => 'show', file => upper_path($virtual)});
639 }
640 else
641 {
642 my $tpl = new Template;
643 $tpl->read_file($config->{'templates'}->{'confirm_rmdir'});
644
645 $tpl->fillin("DIR",$virtual);
646 $tpl->fillin("UPPER_DIR",upper_path($virtual));
647 $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
648 $tpl->fillin("SCRIPT",$script);
649
650 my $output = header(-type => "text/html");
651 $output .= $tpl->get_template;
652
653 return \$output;
654 }
655 }
656 else
657 {
658 # Remove a file
659
660 return error($config->{'errors'}->{'in_use'},upper_path($virtual),{FILE => $virtual}) if($data->{'uselist'}->in_use($virtual));
661
662 if($data->{'cgi'}->param('confirmed'))
663 {
664 unlink($physical) or return error($config->{'errors'}->{'delete_failed'},upper_path($virtual),{FILE => $virtual});
665 return devedit_reload({command => 'show', file => upper_path($virtual)});
666 }
667 else
668 {
669 my $tpl = new Template;
670 $tpl->read_file($config->{'templates'}->{'confirm_rmfile'});
671
672 $tpl->fillin("FILE",$virtual);
673 $tpl->fillin("DIR",upper_path($virtual));
674 $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
675 $tpl->fillin("SCRIPT",$script);
676
677 my $output = header(-type => "text/html");
678 $output .= $tpl->get_template;
679
680 return \$output;
681 }
682 }
683 }
684
685 # exec_unlock()
686 #
687 # Remove a file from the list of used files and
688 # return to directory view
689 #
690 # Params: 1. Reference to user input hash
691 # 2. Reference to config hash
692 #
693 # Return: Output of the command (Scalar Reference)
694
695 sub exec_unlock($$)
696 {
697 my ($data,$config) = @_;
698 my $virtual = $data->{'virtual'};
699
700 if($data->{'cgi'}->param('confirmed'))
701 {
702 file_unlock($data->{'uselist'},$virtual);
703 return devedit_reload({command => 'show', file => upper_path($virtual)});
704 }
705 else
706 {
707 my $tpl = new Template;
708 $tpl->read_file($config->{'templates'}->{'confirm_unlock'});
709
710 $tpl->fillin("FILE",$virtual);
711 $tpl->fillin("DIR",upper_path($virtual));
712 $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
713 $tpl->fillin("SCRIPT",$script);
714
715 my $output = header(-type => "text/html");
716 $output .= $tpl->get_template;
717
718 return \$output;
719 }
720 }
721
722 # exec_about()
723 #
724 # Display some information about Dev-Editor
725 #
726 # Params: 1. Reference to user input hash
727 # 2. Reference to config hash
728 #
729 # Return: Output of the command (Scalar Reference)
730
731 sub exec_about($$)
732 {
733 my ($data,$config) = @_;
734
735 my $tpl = new Template;
736 $tpl->read_file($config->{'templates'}->{'about'});
737
738 $tpl->fillin("SCRIPT",$script);
739
740 # Dev-Editor's version number
741
742 $tpl->fillin("VERSION",$data->{'version'});
743
744 # Some path information
745
746 $tpl->fillin("SCRIPT_PHYS",$ENV{'SCRIPT_FILENAME'});
747 $tpl->fillin("CONFIG_PATH",$data->{'configfile'});
748 $tpl->fillin("FILE_ROOT",$config->{'fileroot'});
749 $tpl->fillin("HTTP_ROOT",$config->{'httproot'});
750
751 # Perl
752
753 $tpl->fillin("PERL_PROG",$^X);
754 $tpl->fillin("PERL_VER",sprintf("%vd",$^V));
755
756 # Information about the server
757
758 $tpl->fillin("HTTPD",$ENV{'SERVER_SOFTWARE'});
759 $tpl->fillin("OS",$^O);
760 $tpl->fillin("TIME",strftime($config->{'timeformat'},localtime));
761
762 # Process information
763
764 $tpl->fillin("PID",$$);
765
766 # Check if the functions getpwuid() and getgrgid() are available
767
768 if(eval("getpwuid(0)") && eval("getgrgid(0)"))
769 {
770 # Dev-Editor is running on a system which allows users and groups
771 # So we display the user and the group of our process
772
773 $tpl->parse_if_block("users",1);
774
775 # ID's of user and group
776
777 $tpl->fillin("UID",$<);
778 $tpl->fillin("GID",$();
779
780 # Names of user and group
781
782 $tpl->fillin("USER",getpwuid($<));
783 $tpl->fillin("GROUP",getgrgid($());
784 }
785 else
786 {
787 $tpl->parse_if_block("users",0);
788 }
789
790 my $output = header(-type => "text/html");
791 $output .= $tpl->get_template;
792
793 return \$output;
794 }
795
796 # it's true, baby ;-)
797
798 1;
799
800 #
801 ### End ###

patrick-canterino.de