]>
git.p6c8.net - devedit.git/blob - modules/Command.pm
4 # Dev-Editor - Module Command
6 # Execute Dev-Editor's commands
8 # Author: Patrick Canterino <patrick@patshaping.de>
9 # Last modified: 2004-12-13
20 use POSIX qw(strftime);
30 my $script = $ENV{'SCRIPT_NAME'};
31 my $users = eval("getpwuid(0)") && eval("getgrgid(0)");
33 my %dispatch = ('show' => \
&exec_show
,
34 'beginedit' => \
&exec_beginedit
,
35 'canceledit' => \
&exec_canceledit
,
36 'endedit' => \
&exec_endedit
,
37 'mkdir' => \
&exec_mkdir
,
38 'mkfile' => \
&exec_mkfile
,
39 'upload' => \
&exec_upload
,
40 'copy' => \
&exec_copy
,
41 'rename' => \
&exec_rename
,
42 'remove' => \
&exec_remove
,
43 'chprop' => \
&exec_chprop
,
44 'unlock' => \
&exec_unlock
,
45 'about' => \
&exec_about
50 use base
qw(Exporter);
52 @EXPORT = qw(exec_command);
56 # Execute the specified command
58 # Params: 1. Command to execute
59 # 2. Reference to user input hash
60 # 3. Reference to config hash
62 # Return: Output of the command (Scalar Reference)
66 my ($command,$data,$config) = @_;
68 foreach(keys(%dispatch))
70 if(lc($_) eq lc($command))
72 my $output = &{$dispatch{$_}}($data,$config);
77 return error
($config->{'errors'}->{'cmd_unknown'},'/',{COMMAND
=> $command});
82 # View a directory or a file
84 # Params: 1. Reference to user input hash
85 # 2. Reference to config hash
87 # Return: Output of the command (Scalar Reference)
91 my ($data,$config) = @_;
92 my $physical = $data->{'physical'};
93 my $virtual = $data->{'virtual'};
94 my $upper_path = upper_path
($virtual);
95 my $uselist = $data->{'uselist'};
97 my $tpl = new Template
;
101 # Create directory listing
103 return error
($config->{'errors'}->{'no_dir_access'},$upper_path) unless(-r
$physical && -x
$physical);
105 my $direntries = dir_read
($physical);
106 return error
($config->{'dir_read_fail'},$upper_path,{DIR
=> $virtual}) unless($direntries);
108 my $files = $direntries->{'files'};
109 my $dirs = $direntries->{'dirs'};
111 my $dir_writeable = -w
$physical;
115 # Create the link to the upper directory
116 # (only if we are not in the root directory)
118 unless($virtual eq "/")
120 my @stat = stat($physical."/..");
122 my $udtpl = new Template
;
123 $udtpl->read_file($config->{'templates'}->{'dirlist_up'});
125 $udtpl->fillin("UPPER_DIR",encode_entities
($upper_path));
126 $udtpl->fillin("DATE",encode_entities
(strftime
($config->{'timeformat'},localtime($stat[9]))));
128 $dirlist .= $udtpl->get_template;
133 foreach my $dir(@
$dirs)
135 my $phys_path = $physical."/".$dir;
136 my $virt_path = encode_entities
($virtual.$dir."/");
138 my @stat = stat($phys_path);
140 my $dtpl = new Template
;
141 $dtpl->read_file($config->{'templates'}->{'dirlist_dir'});
143 $dtpl->fillin("DIR",$virt_path);
144 $dtpl->fillin("DIR_NAME",$dir);
145 $dtpl->fillin("DATE",encode_entities
(strftime
($config->{'timeformat'},localtime($stat[9]))));
146 $dtpl->fillin("URL",equal_url
($config->{'httproot'},$virt_path));
148 $dtpl->parse_if_block("readable",-r
$phys_path && -x
$phys_path);
149 $dtpl->parse_if_block("users",$users && -o
$phys_path);
151 $dirlist .= $dtpl->get_template;
156 foreach my $file(@
$files)
158 my $phys_path = $physical."/".$file;
159 my $virt_path = encode_entities
($virtual.$file);
161 my @stat = stat($phys_path);
162 my $in_use = $uselist->in_use($virtual.$file);
163 my $too_large = $config->{'max_file_size'} && $stat[7] > $config->{'max_file_size'};
165 my $ftpl = new Template
;
166 $ftpl->read_file($config->{'templates'}->{'dirlist_file'});
168 $ftpl->fillin("FILE",$virt_path);
169 $ftpl->fillin("FILE_NAME",$file);
170 $ftpl->fillin("SIZE",$stat[7]);
171 $ftpl->fillin("DATE",encode_entities
(strftime
($config->{'timeformat'},localtime($stat[9]))));
172 $ftpl->fillin("URL",equal_url
($config->{'httproot'},$virt_path));
174 $ftpl->parse_if_block("not_readable",not -r
$phys_path);
175 $ftpl->parse_if_block("binary",-B
$phys_path);
176 $ftpl->parse_if_block("readonly",not -w
$phys_path);
178 $ftpl->parse_if_block("viewable",-r
$phys_path && -T
$phys_path && not $too_large);
179 $ftpl->parse_if_block("editable",(-r
$phys_path && -w
$phys_path && -T
$phys_path && not $too_large) && not $in_use);
181 $ftpl->parse_if_block("in_use",$in_use);
182 $ftpl->parse_if_block("unused",not $in_use);
184 $ftpl->parse_if_block("too_large",$config->{'max_file_size'} && $stat[7] > $config->{'max_file_size'});
186 $ftpl->parse_if_block("users",$users && -o
$phys_path);
188 $dirlist .= $ftpl->get_template;
191 $tpl->read_file($config->{'templates'}->{'dirlist'});
193 $tpl->fillin("DIRLIST",$dirlist);
194 $tpl->fillin("DIR",$virtual);
195 $tpl->fillin("SCRIPT",$script);
196 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
198 $tpl->parse_if_block("dir_writeable",$dir_writeable);
204 return error
($config->{'errors'}->{'no_view'},$upper_path) unless(-r
$physical);
206 # Check on binary files
207 # We have to do it in this way, or empty files
208 # will be recognized as binary files
214 return error
($config->{'errors'}->{'binary'},$upper_path);
220 if($config->{'max_file_size'} && -s
$physical > $config->{'max_file_size'})
222 return error
($config->{'errors'}->{'file_too_large'},$upper_path,{SIZE
=> $config->{'max_file_size'}})
226 my $content = file_read
($physical);
227 $$content =~ s/\015\012|\012|\015/\n/g;
229 $tpl->read_file($config->{'templates'}->{'viewfile'});
231 $tpl->fillin("FILE",$virtual);
232 $tpl->fillin("DIR",$upper_path);
233 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
234 $tpl->fillin("SCRIPT",$script);
236 $tpl->parse_if_block("editable",-w
$physical && $uselist->unused($virtual));
238 $tpl->fillin("CONTENT",encode_entities
($$content));
243 my $output = header
(-type
=> "text/html");
244 $output .= $tpl->get_template;
251 # Lock a file and display a form to edit it
253 # Params: 1. Reference to user input hash
254 # 2. Reference to config hash
256 # Return: Output of the command (Scalar Reference)
258 sub exec_beginedit
($$)
260 my ($data,$config) = @_;
261 my $physical = $data->{'physical'};
262 my $virtual = $data->{'virtual'};
263 my $dir = upper_path
($virtual);
264 my $uselist = $data->{'uselist'};
266 return error
($config->{'errors'}->{'editdir'},$dir) if(-d
$physical);
267 return error
($config->{'errors'}->{'in_use'}, $dir,{FILE
=> $virtual}) if($uselist->in_use($virtual));
268 return error
($config->{'errors'}->{'no_edit'},$dir) unless(-r
$physical && -w
$physical);
270 # Check on binary files
276 return error
($config->{'errors'}->{'binary'},$dir);
280 if($config->{'max_file_size'} && -s
$physical > $config->{'max_file_size'})
282 return error
($config->{'errors'}->{'file_too_large'},$dir,{SIZE
=> $config->{'max_file_size'}})
288 $uselist->add_file($virtual);
291 my $content = file_read
($physical);
292 $$content =~ s/\015\012|\012|\015/\n/g;
294 my $tpl = new Template
;
295 $tpl->read_file($config->{'templates'}->{'editfile'});
297 $tpl->fillin("FILE",$virtual);
298 $tpl->fillin("DIR",$dir);
299 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
300 $tpl->fillin("SCRIPT",$script);
301 $tpl->fillin("CONTENT",encode_entities
($$content));
303 my $output = header
(-type
=> "text/html");
304 $output .= $tpl->get_template;
315 # Params: 1. Reference to user input hash
316 # 2. Reference to config hash
318 # Return: Output of the command (Scalar Reference)
320 sub exec_canceledit
($$)
322 my ($data,$config) = @_;
323 my $virtual = $data->{'virtual'};
325 file_unlock
($data->{'uselist'},$virtual);
326 return devedit_reload
({command
=> 'show', file
=> upper_path
($virtual)});
331 # Save a file, unlock it and return to directory view
333 # Params: 1. Reference to user input hash
334 # 2. Reference to config hash
336 # Return: Output of the command (Scalar Reference)
340 my ($data,$config) = @_;
341 my $physical = $data->{'physical'};
342 my $virtual = $data->{'virtual'};
343 my $dir = upper_path
($virtual);
344 my $content = $data->{'cgi'}->param('filecontent');
345 my $uselist = $data->{'uselist'};
347 # We already unlock the file at the beginning of the subroutine,
348 # because if we have to abort this routine, the file keeps locked.
349 # No other user of Dev-Editor will access the file during this
350 # routine because of the concept of File::UseList.
352 file_unlock
($uselist,$virtual);
356 $content =~ s/\015\012|\012|\015/\n/g;
358 if($data->{'cgi'}->param('encode_iso'))
360 # Encode all ISO-8859-1 special chars
362 $content = encode_entities
($content,"\200-\377");
365 if($data->{'cgi'}->param('saveas') && $data->{'new_physical'} ne '' && $data->{'new_virtual'} ne '')
367 # Create the new filename
369 $physical = $data->{'new_physical'};
370 $virtual = $data->{'new_virtual'};
372 # Check if someone else is editing the new file
374 return error
($config->{'errors'}->{'in_use'},$dir,{FILE
=> $virtual}) if($uselist->in_use($virtual));
377 return error
($config->{'errors'}->{'editdir'},$dir) if(-d
$physical);
378 return error
($config->{'errors'}->{'no_edit'},$dir) if(-e
$physical && !(-r
$physical && -w
$physical));
379 return error
($config->{'errors'}->{'text_to_binary'},$dir) unless(-T
$physical);
381 if(file_save
($physical,\
$content))
383 # Saving of the file was successful!
385 return devedit_reload
({command
=> 'show', file
=> $dir});
389 return error
($config->{'errors'}->{'edit_failed'},$dir,{FILE
=> $virtual});
395 # Create a file and return to directory view
397 # Params: 1. Reference to user input hash
398 # 2. Reference to config hash
400 # Return: Output of the command (Scalar Reference)
404 my ($data,$config) = @_;
405 my $new_physical = $data->{'new_physical'};
406 my $new_virtual = $data->{'new_virtual'};
407 my $dir = upper_path
($new_virtual);
408 $new_virtual = encode_entities
($new_virtual);
412 return error
($config->{'errors'}->{'file_exists'},$dir,{FILE
=> $new_virtual}) if(-e
$new_physical);
414 file_create
($new_physical) or return error
($config->{'errors'}->{'mkfile_failed'},$dir,{FILE
=> $new_virtual});
415 return devedit_reload
({command
=> 'show', file
=> $dir});
419 my $tpl = new Template
;
420 $tpl->read_file($config->{'templates'}->{'mkfile'});
422 $tpl->fillin("DIR","/");
423 $tpl->fillin("SCRIPT",$script);
425 my $output = header
(-type
=> "text/html");
426 $output .= $tpl->get_template;
434 # Create a directory and return to directory view
436 # Params: 1. Reference to user input hash
437 # 2. Reference to config hash
439 # Return: Output of the command (Scalar Reference)
443 my ($data,$config) = @_;
444 my $new_physical = $data->{'new_physical'};
445 my $new_virtual = $data->{'new_virtual'};
446 my $dir = upper_path
($new_virtual);
447 $new_virtual = encode_entities
($new_virtual);
449 return error
($config->{'errors'}->{'file_exists'},$dir,{FILE
=> $new_virtual}) if(-e
$new_physical);
453 mkdir($new_physical,0777) or return error
($config->{'errors'}->{'mkdir_failed'},$dir,{DIR
=> $new_virtual});
454 return devedit_reload
({command
=> 'show', file
=> $dir});
458 my $tpl = new Template
;
459 $tpl->read_file($config->{'templates'}->{'mkdir'});
461 $tpl->fillin("DIR","/");
462 $tpl->fillin("SCRIPT",$script);
464 my $output = header
(-type
=> "text/html");
465 $output .= $tpl->get_template;
475 # Params: 1. Reference to user input hash
476 # 2. Reference to config hash
478 # Return: Output of the command (Scalar Reference)
482 my ($data,$config) = @_;
483 my $physical = $data->{'physical'};
484 my $virtual = $data->{'virtual'};
485 my $cgi = $data->{'cgi'};
487 return error
($config->{'errors'}->{'no_directory'},upper_path
($virtual),{FILE
=> $virtual}) unless(-d
$physical);
488 return error
($config->{'errors'}->{'dir_no_create'},$virtual,{DIR
=> $virtual}) unless(-w
$physical);
490 if(my $uploaded_file = $cgi->param('uploaded_file'))
492 # Process file upload
494 my $filename = file_name
($uploaded_file);
495 my $file_phys = $physical."/".$filename;
496 my $file_virt = $virtual.$filename;
498 return error
($config->{'errors'}->{'in_use'},$virtual,{FILE
=> $file_virt}) if($data->{'uselist'}->in_use($file_virt));
499 return error
($config->{'errors'}->{'file_exists'},$virtual,{FILE
=> $file_virt}) if(-e
$file_phys && not $cgi->param('overwrite'));
501 my $ascii = $cgi->param('ascii');
502 my $handle = $cgi->upload('uploaded_file');
506 open(FILE
,">".$file_phys) or return error
($config->{'errors'}->{'mkfile_failed'},$virtual,{FILE
=> $file_virt});
507 binmode(FILE
) unless($ascii);
509 # Read transferred file and write it to disk
511 read($handle, my $data, -s
$handle);
512 $data =~ s/\015\012|\012|\015/\n/g if($ascii); # Replace line separators if transferring in ASCII mode
517 return devedit_reload
({command
=> "show", file
=> $virtual});
521 my $tpl = new Template
;
522 $tpl->read_file($config->{'templates'}->{'upload'});
524 $tpl->fillin("DIR",$virtual);
525 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
526 $tpl->fillin("SCRIPT",$script);
528 my $output = header
(-type
=> "text/html");
529 $output .= $tpl->get_template;
537 # Copy a file and return to directory view
539 # Params: 1. Reference to user input hash
540 # 2. Reference to config hash
542 # Return: Output of the command (Scalar Reference)
546 my ($data,$config) = @_;
547 my $physical = $data->{'physical'};
548 my $virtual = encode_entities
($data->{'virtual'});
549 my $dir = upper_path
($virtual);
550 my $new_physical = $data->{'new_physical'};
552 return error
($config->{'errors'}->{'dircopy'},upper_path
($virtual)) if(-d
$physical);
553 return error
($config->{'errors'}->{'no_copy'},upper_path
($virtual)) unless(-r
$physical);
557 my $new_virtual = $data->{'new_virtual'};
558 my $new_dir = upper_path
($new_virtual);
559 $new_virtual = encode_entities
($new_virtual);
563 return error
($config->{'errors'}->{'exist_edited'},$new_dir,{FILE
=> $new_virtual}) if($data->{'uselist'}->in_use($data->{'new_virtual'}));
567 return error
($config->{'errors'}->{'dir_replace'},$new_dir);
569 elsif(not $data->{'cgi'}->param('confirmed'))
571 my $tpl = new Template
;
572 $tpl->read_file($config->{'templates'}->{'confirm_replace'});
574 $tpl->fillin("FILE",$virtual);
575 $tpl->fillin("NEW_FILE",$new_virtual);
576 $tpl->fillin("NEW_FILENAME",file_name
($new_virtual));
577 $tpl->fillin("NEW_DIR",$new_dir);
578 $tpl->fillin("DIR",$dir);
580 $tpl->fillin("COMMAND","copy");
581 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
582 $tpl->fillin("SCRIPT",$script);
584 my $output = header
(-type
=> "text/html");
585 $output .= $tpl->get_template;
591 copy
($physical,$new_physical) or return error
($config->{'errors'}->{'copy_failed'},$dir,{FILE
=> $virtual, NEW_FILE
=> $new_virtual});
592 return devedit_reload
({command
=> 'show', file
=> $new_dir});
596 my $tpl = new Template
;
597 $tpl->read_file($config->{'templates'}->{'copyfile'});
599 $tpl->fillin("FILE",$virtual);
600 $tpl->fillin("DIR",$dir);
601 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
602 $tpl->fillin("SCRIPT",$script);
604 my $output = header
(-type
=> "text/html");
605 $output .= $tpl->get_template;
613 # Rename/move a file and return to directory view
615 # Params: 1. Reference to user input hash
616 # 2. Reference to config hash
618 # Return: Output of the command (Scalar Reference)
622 my ($data,$config) = @_;
623 my $physical = $data->{'physical'};
624 my $virtual = $data->{'virtual'};
625 my $dir = upper_path
($virtual);
626 my $new_physical = $data->{'new_physical'};
628 return error
($config->{'errors'}->{'rename_root'},"/") if($virtual eq "/");
629 return error
($config->{'errors'}->{'no_rename'},$dir) unless(-w upper_path
($physical));
630 return error
($config->{'errors'}->{'in_use'},$dir,{FILE
=> $virtual}) if($data->{'uselist'}->in_use($virtual));
634 my $new_virtual = $data->{'new_virtual'};
635 my $new_dir = upper_path
($new_virtual);
636 $new_virtual = encode_entities
($new_virtual);
640 return error
($config->{'errors'}->{'exist_edited'},$new_dir,{FILE
=> $new_virtual}) if($data->{'uselist'}->in_use($data->{'new_virtual'}));
644 return error
($config->{'errors'}->{'dir_replace'},$new_dir);
646 elsif(not $data->{'cgi'}->param('confirmed'))
648 my $tpl = new Template
;
649 $tpl->read_file($config->{'templates'}->{'confirm_replace'});
651 $tpl->fillin("FILE",$virtual);
652 $tpl->fillin("NEW_FILE",$new_virtual);
653 $tpl->fillin("NEW_FILENAME",file_name
($new_virtual));
654 $tpl->fillin("NEW_DIR",$new_dir);
655 $tpl->fillin("DIR",$dir);
657 $tpl->fillin("COMMAND","rename");
658 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
659 $tpl->fillin("SCRIPT",$script);
661 my $output = header
(-type
=> "text/html");
662 $output .= $tpl->get_template;
668 rename($physical,$new_physical) or return error
($config->{'errors'}->{'rename_failed'},$dir,{FILE
=> $virtual, NEW_FILE
=> $new_virtual});
669 return devedit_reload
({command
=> 'show', file
=> $new_dir});
673 my $tpl = new Template
;
674 $tpl->read_file($config->{'templates'}->{'renamefile'});
676 $tpl->fillin("FILE",$virtual);
677 $tpl->fillin("DIR",$dir);
678 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
679 $tpl->fillin("SCRIPT",$script);
681 my $output = header
(-type
=> "text/html");
682 $output .= $tpl->get_template;
690 # Remove a file or a directory and return to directory view
692 # Params: 1. Reference to user input hash
693 # 2. Reference to config hash
695 # Return: Output of the command (Scalar Reference)
699 my ($data,$config) = @_;
700 my $physical = $data->{'physical'};
701 my $virtual = $data->{'virtual'};
702 my $dir = upper_path
($virtual);
704 return error
($config->{'errors'}->{'remove_root'},"/") if($virtual eq "/");
705 return error
($config->{'errors'}->{'no_delete'},$dir) unless(-w upper_path
($physical));
711 if($data->{'cgi'}->param('confirmed'))
714 return devedit_reload
({command
=> 'show', file
=> $dir});
718 my $tpl = new Template
;
719 $tpl->read_file($config->{'templates'}->{'confirm_rmdir'});
721 $tpl->fillin("DIR",$virtual);
722 $tpl->fillin("UPPER_DIR",$dir);
723 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
724 $tpl->fillin("SCRIPT",$script);
726 my $output = header
(-type
=> "text/html");
727 $output .= $tpl->get_template;
736 return error
($config->{'errors'}->{'in_use'},$dir,{FILE
=> $virtual}) if($data->{'uselist'}->in_use($virtual));
738 if($data->{'cgi'}->param('confirmed'))
740 unlink($physical) or return error
($config->{'errors'}->{'delete_failed'},$dir,{FILE
=> $virtual});
741 return devedit_reload
({command
=> 'show', file
=> $dir});
745 my $tpl = new Template
;
746 $tpl->read_file($config->{'templates'}->{'confirm_rmfile'});
748 $tpl->fillin("FILE",$virtual);
749 $tpl->fillin("DIR",$dir);
750 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
751 $tpl->fillin("SCRIPT",$script);
753 my $output = header
(-type
=> "text/html");
754 $output .= $tpl->get_template;
763 # Change the mode and the group of a file or a directory
765 # Params: 1. Reference to user input hash
766 # 2. Reference to config hash
768 # Return: Output of the command (Scalar Reference)
772 my ($data,$config) = @_;
773 my $physical = $data->{'physical'};
774 my $virtual = $data->{'virtual'};
775 my $dir = upper_path
($virtual);
777 return error
($config->{'errors'}->{'no_users'},$dir,{FILE
=> $virtual}) unless($users);
778 return error
($config->{'errors'}->{'chprop_root'},"/") if($virtual eq "/");
779 return error
($config->{'errors'}->{'not_owner'},$dir,{FILE
=> $virtual}) unless(-o
$physical);
780 return error
($config->{'errors'}->{'in_use'},$dir,{FILE
=> $virtual}) if($data->{'uselist'}->in_use($virtual));
782 my $cgi = $data->{'cgi'};
783 my $mode = $cgi->param('mode');
784 my $group = $cgi->param('group');
792 chmod(oct($mode),$physical);
797 # Change the group using the `chgrp` system command
799 return error
($config->{'errors'}->{'invalid_group'},$dir,{GROUP
=> encode_entities
($group)}) unless($group =~ /^[a-z0-9_]+[a-z0-9_-]*$/i);
800 system("chgrp",$group,$physical);
803 return devedit_reload
({command
=> 'show', file
=> $dir});
809 my @stat = stat($physical);
813 my $tpl = new Template
;
814 $tpl->read_file($config->{'templates'}->{'chprop'});
816 # Insert file properties into the template
818 $tpl->fillin("MODE_OCTAL",substr(sprintf("%04o",$mode),-4));
819 $tpl->fillin("MODE_STRING",mode_string
($mode));
820 $tpl->fillin("GID",$gid);
822 if(my $group = getgrgid($gid))
824 $tpl->fillin("GROUP",encode_entities
($group));
825 $tpl->parse_if_block("group_detected",1);
829 $tpl->parse_if_block("group_detected",0);
832 # Insert other information
834 $tpl->fillin("FILE",$virtual);
835 $tpl->fillin("DIR",$dir);
836 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
837 $tpl->fillin("SCRIPT",$script);
839 my $output = header
(-type
=> "text/html");
840 $output .= $tpl->get_template;
848 # Remove a file from the list of used files and
849 # return to directory view
851 # Params: 1. Reference to user input hash
852 # 2. Reference to config hash
854 # Return: Output of the command (Scalar Reference)
858 my ($data,$config) = @_;
859 my $virtual = $data->{'virtual'};
860 my $uselist = $data->{'uselist'};
861 my $dir = upper_path
($virtual);
863 return devedit_reload
({command
=> 'show', file
=> $dir}) if($uselist->unused($virtual));
865 if($data->{'cgi'}->param('confirmed'))
867 file_unlock
($uselist,$virtual);
868 return devedit_reload
({command
=> 'show', file
=> $dir});
872 my $tpl = new Template
;
873 $tpl->read_file($config->{'templates'}->{'confirm_unlock'});
875 $tpl->fillin("FILE",$virtual);
876 $tpl->fillin("DIR",$dir);
877 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
878 $tpl->fillin("SCRIPT",$script);
880 my $output = header
(-type
=> "text/html");
881 $output .= $tpl->get_template;
889 # Display some information about Dev-Editor
891 # Params: 1. Reference to user input hash
892 # 2. Reference to config hash
894 # Return: Output of the command (Scalar Reference)
898 my ($data,$config) = @_;
900 my $tpl = new Template
;
901 $tpl->read_file($config->{'templates'}->{'about'});
903 $tpl->fillin("SCRIPT",$script);
905 # Dev-Editor's version number
907 $tpl->fillin("VERSION",$data->{'version'});
909 # Some path information
911 $tpl->fillin("SCRIPT_PHYS",encode_entities
($ENV{'SCRIPT_FILENAME'}));
912 $tpl->fillin("CONFIG_PATH",encode_entities
($data->{'configfile'}));
913 $tpl->fillin("FILE_ROOT", encode_entities
($config->{'fileroot'}));
914 $tpl->fillin("HTTP_ROOT", encode_entities
($config->{'httproot'}));
918 $tpl->fillin("PERL_PROG",encode_entities
($^X
));
919 $tpl->fillin("PERL_VER",sprintf("%vd",$^V
));
921 # Information about the server
923 $tpl->fillin("HTTPD",encode_entities
($ENV{'SERVER_SOFTWARE'}));
924 $tpl->fillin("OS",$^O
);
925 $tpl->fillin("TIME",encode_entities
(strftime
($config->{'timeformat'},localtime)));
927 # Process information
929 $tpl->fillin("PID",$$);
931 # Check if the functions getpwuid() and getgrgid() are available
935 # Dev-Editor is running on a system which allows users and groups
936 # So we display the user and the group of our process
938 my $uid = POSIX
::getuid
;
939 my $gid = POSIX
::getgid
;
941 $tpl->parse_if_block("users",1);
943 # ID's of user and group
945 $tpl->fillin("UID",$uid);
946 $tpl->fillin("GID",$gid);
948 # Names of user and group
950 if(my $user = getpwuid($uid))
952 $tpl->fillin("USER",encode_entities
($user));
953 $tpl->parse_if_block("user_detected",1);
957 $tpl->parse_if_block("user_detected",0);
960 if(my $group = getgrgid($gid))
962 $tpl->fillin("GROUP",encode_entities
($group));
963 $tpl->parse_if_block("group_detected",1);
967 $tpl->parse_if_block("group_detected",0);
972 $tpl->fillin("UMASK",sprintf("%04o",umask));
976 $tpl->parse_if_block("users",0);
979 my $output = header
(-type
=> "text/html");
980 $output .= $tpl->get_template;
985 # it's true, baby ;-)
patrick-canterino.de