]>
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-21
20 use POSIX qw(strftime);
28 my $script = encode_entities
($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
=> encode_entities
($command)});
80 # View a directory or a file
82 # Params: 1. Reference to user input hash
83 # 2. Reference to config hash
85 # Return: Output of the command (Scalar Reference)
89 my ($data,$config) = @_;
90 my $physical = $data->{'physical'};
91 my $virtual = $data->{'virtual'};
92 my $upper_path = encode_entities
(upper_path
($virtual));
93 my $uselist = $data->{'uselist'};
95 my $tpl = new Template
;
99 # Create directory listing
101 return error
($config->{'errors'}->{'no_dir_access'},$upper_path) unless(-r
$physical && -x
$physical);
103 my $direntries = dir_read
($physical);
104 return error
($config->{'dir_read_fail'},$upper_path,{DIR
=> encode_entities
($virtual)}) unless($direntries);
106 my $files = $direntries->{'files'};
107 my $dirs = $direntries->{'dirs'};
109 my $dir_writeable = -w
$physical;
113 # Create the link to the upper directory
114 # (only if we are not in the root directory)
116 unless($virtual eq "/")
118 my @stat = stat($physical."/..");
120 my $udtpl = new Template
;
121 $udtpl->read_file($config->{'templates'}->{'dirlist_up'});
123 $udtpl->fillin("UPPER_DIR",$upper_path);
124 $udtpl->fillin("DATE",encode_entities
(strftime
($config->{'timeformat'},localtime($stat[9]))));
126 $dirlist .= $udtpl->get_template;
131 foreach my $dir(@
$dirs)
133 my $phys_path = $physical."/".$dir;
134 my $virt_path = encode_entities
($virtual.$dir."/");
136 my @stat = stat($phys_path);
138 my $dtpl = new Template
;
139 $dtpl->read_file($config->{'templates'}->{'dirlist_dir'});
141 $dtpl->fillin("DIR",$virt_path);
142 $dtpl->fillin("DIR_NAME",encode_entities
($dir));
143 $dtpl->fillin("DATE",encode_entities
(strftime
($config->{'timeformat'},localtime($stat[9]))));
144 $dtpl->fillin("URL",equal_url
(encode_entities
($config->{'httproot'}),$virt_path));
146 $dtpl->parse_if_block("readable",-r
$phys_path && -x
$phys_path);
147 $dtpl->parse_if_block("users",$users && -o
$phys_path);
149 $dirlist .= $dtpl->get_template;
154 foreach my $file(@
$files)
156 my $phys_path = $physical."/".$file;
157 my $virt_path = encode_entities
($virtual.$file);
159 my @stat = stat($phys_path);
160 my $in_use = $uselist->in_use($virtual.$file);
161 my $too_large = $config->{'max_file_size'} && $stat[7] > $config->{'max_file_size'};
163 my $ftpl = new Template
;
164 $ftpl->read_file($config->{'templates'}->{'dirlist_file'});
166 $ftpl->fillin("FILE",$virt_path);
167 $ftpl->fillin("FILE_NAME",encode_entities
($file));
168 $ftpl->fillin("SIZE",$stat[7]);
169 $ftpl->fillin("DATE",encode_entities
(strftime
($config->{'timeformat'},localtime($stat[9]))));
170 $ftpl->fillin("URL",equal_url
(encode_entities
($config->{'httproot'}),$virt_path));
172 $ftpl->parse_if_block("not_readable",not -r
$phys_path);
173 $ftpl->parse_if_block("binary",-B
$phys_path);
174 $ftpl->parse_if_block("readonly",not -w
$phys_path);
176 $ftpl->parse_if_block("viewable",-r
$phys_path && -T
$phys_path && not $too_large);
177 $ftpl->parse_if_block("editable",(-r
$phys_path && -w
$phys_path && -T
$phys_path && not $too_large) && not $in_use);
179 $ftpl->parse_if_block("in_use",$in_use);
180 $ftpl->parse_if_block("unused",not $in_use);
182 $ftpl->parse_if_block("too_large",$config->{'max_file_size'} && $stat[7] > $config->{'max_file_size'});
184 $ftpl->parse_if_block("users",$users && -o
$phys_path);
186 $dirlist .= $ftpl->get_template;
189 $tpl->read_file($config->{'templates'}->{'dirlist'});
191 $tpl->fillin("DIRLIST",$dirlist);
192 $tpl->fillin("DIR",encode_entities
($virtual));
193 $tpl->fillin("SCRIPT",$script);
194 $tpl->fillin("URL",encode_entities
(equal_url
($config->{'httproot'},$virtual)));
196 $tpl->parse_if_block("dir_writeable",$dir_writeable);
202 return error
($config->{'errors'}->{'no_view'},$upper_path) unless(-r
$physical);
204 # Check on binary files
205 # We have to do it in this way, or empty files
206 # will be recognized as binary files
212 return error
($config->{'errors'}->{'binary'},$upper_path);
218 if($config->{'max_file_size'} && -s
$physical > $config->{'max_file_size'})
220 return error
($config->{'errors'}->{'file_too_large'},$upper_path,{SIZE
=> $config->{'max_file_size'}})
224 my $content = file_read
($physical);
225 $$content =~ s/\015\012|\012|\015/\n/g;
227 $tpl->read_file($config->{'templates'}->{'viewfile'});
229 $tpl->fillin("FILE",encode_entities
($virtual));
230 $tpl->fillin("DIR",$upper_path);
231 $tpl->fillin("URL",encode_entities
(equal_url
($config->{'httproot'},$virtual)));
232 $tpl->fillin("SCRIPT",$script);
234 $tpl->parse_if_block("editable",-w
$physical && $uselist->unused($virtual));
236 $tpl->fillin("CONTENT",encode_entities
($$content));
241 my $output = header
(-type
=> "text/html");
242 $output .= $tpl->get_template;
249 # Lock a file and display a form to edit it
251 # Params: 1. Reference to user input hash
252 # 2. Reference to config hash
254 # Return: Output of the command (Scalar Reference)
256 sub exec_beginedit
($$)
258 my ($data,$config) = @_;
259 my $physical = $data->{'physical'};
260 my $virtual = $data->{'virtual'};
261 my $dir = upper_path
($virtual);
262 my $uselist = $data->{'uselist'};
264 return error
($config->{'errors'}->{'editdir'},$dir) if(-d
$physical);
265 return error
($config->{'errors'}->{'in_use'}, $dir,{FILE
=> $virtual}) if($uselist->in_use($virtual));
266 return error
($config->{'errors'}->{'no_edit'},$dir) unless(-r
$physical && -w
$physical);
268 # Check on binary files
274 return error
($config->{'errors'}->{'binary'},$dir);
278 if($config->{'max_file_size'} && -s
$physical > $config->{'max_file_size'})
280 return error
($config->{'errors'}->{'file_too_large'},$dir,{SIZE
=> $config->{'max_file_size'}})
286 $uselist->add_file($virtual);
289 my $content = file_read
($physical);
290 $$content =~ s/\015\012|\012|\015/\n/g;
292 my $tpl = new Template
;
293 $tpl->read_file($config->{'templates'}->{'editfile'});
295 $tpl->fillin("FILE",$virtual);
296 $tpl->fillin("DIR",$dir);
297 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
298 $tpl->fillin("SCRIPT",$script);
299 $tpl->fillin("CONTENT",encode_entities
($$content));
301 my $output = header
(-type
=> "text/html");
302 $output .= $tpl->get_template;
313 # Params: 1. Reference to user input hash
314 # 2. Reference to config hash
316 # Return: Output of the command (Scalar Reference)
318 sub exec_canceledit
($$)
320 my ($data,$config) = @_;
321 my $virtual = $data->{'virtual'};
323 file_unlock
($data->{'uselist'},$virtual);
324 return devedit_reload
({command
=> 'show', file
=> upper_path
($virtual)});
329 # Save a file, unlock it and return to directory view
331 # Params: 1. Reference to user input hash
332 # 2. Reference to config hash
334 # Return: Output of the command (Scalar Reference)
338 my ($data,$config) = @_;
339 my $physical = $data->{'physical'};
340 my $virtual = $data->{'virtual'};
341 my $dir = upper_path
($virtual);
342 my $content = $data->{'cgi'}->param('filecontent');
343 my $uselist = $data->{'uselist'};
345 # We already unlock the file at the beginning of the subroutine,
346 # because if we have to abort this routine, the file keeps locked.
347 # No other user of Dev-Editor will access the file during this
348 # routine because of the concept of File::UseList.
350 file_unlock
($uselist,$virtual);
354 $content =~ s/\015\012|\012|\015/\n/g;
356 if($data->{'cgi'}->param('encode_iso'))
358 # Encode all ISO-8859-1 special chars
360 $content = encode_entities
($content,"\200-\377");
363 if($data->{'cgi'}->param('saveas') && $data->{'new_physical'} ne '' && $data->{'new_virtual'} ne '')
365 # Create the new filename
367 $physical = $data->{'new_physical'};
368 $virtual = $data->{'new_virtual'};
370 # Check if someone else is editing the new file
372 return error
($config->{'errors'}->{'in_use'},$dir,{FILE
=> $virtual}) if($uselist->in_use($virtual));
375 return error
($config->{'errors'}->{'editdir'},$dir) if(-d
$physical);
376 return error
($config->{'errors'}->{'no_edit'},$dir) if(-e
$physical && !(-r
$physical && -w
$physical));
377 return error
($config->{'errors'}->{'text_to_binary'},$dir) unless(-T
$physical);
379 if(file_save
($physical,\
$content))
381 # Saving of the file was successful!
383 return devedit_reload
({command
=> 'show', file
=> $dir});
387 return error
($config->{'errors'}->{'edit_failed'},$dir,{FILE
=> $virtual});
393 # Create a file and return to directory view
395 # Params: 1. Reference to user input hash
396 # 2. Reference to config hash
398 # Return: Output of the command (Scalar Reference)
402 my ($data,$config) = @_;
403 my $new_physical = $data->{'new_physical'};
404 my $new_virtual = $data->{'new_virtual'};
405 my $dir = upper_path
($new_virtual);
406 $new_virtual = encode_entities
($new_virtual);
410 return error
($config->{'errors'}->{'file_exists'},$dir,{FILE
=> $new_virtual}) if(-e
$new_physical);
412 file_create
($new_physical) or return error
($config->{'errors'}->{'mkfile_failed'},$dir,{FILE
=> $new_virtual});
413 return devedit_reload
({command
=> 'show', file
=> $dir});
417 my $tpl = new Template
;
418 $tpl->read_file($config->{'templates'}->{'mkfile'});
420 $tpl->fillin("DIR","/");
421 $tpl->fillin("SCRIPT",$script);
423 my $output = header
(-type
=> "text/html");
424 $output .= $tpl->get_template;
432 # Create a directory and return to directory view
434 # Params: 1. Reference to user input hash
435 # 2. Reference to config hash
437 # Return: Output of the command (Scalar Reference)
441 my ($data,$config) = @_;
442 my $new_physical = $data->{'new_physical'};
443 my $new_virtual = $data->{'new_virtual'};
444 my $dir = upper_path
($new_virtual);
445 $new_virtual = encode_entities
($new_virtual);
447 return error
($config->{'errors'}->{'file_exists'},$dir,{FILE
=> $new_virtual}) if(-e
$new_physical);
451 mkdir($new_physical,0777) or return error
($config->{'errors'}->{'mkdir_failed'},$dir,{DIR
=> $new_virtual});
452 return devedit_reload
({command
=> 'show', file
=> $dir});
456 my $tpl = new Template
;
457 $tpl->read_file($config->{'templates'}->{'mkdir'});
459 $tpl->fillin("DIR","/");
460 $tpl->fillin("SCRIPT",$script);
462 my $output = header
(-type
=> "text/html");
463 $output .= $tpl->get_template;
473 # Params: 1. Reference to user input hash
474 # 2. Reference to config hash
476 # Return: Output of the command (Scalar Reference)
480 my ($data,$config) = @_;
481 my $physical = $data->{'physical'};
482 my $virtual = $data->{'virtual'};
483 my $cgi = $data->{'cgi'};
485 return error
($config->{'errors'}->{'no_directory'},upper_path
($virtual),{FILE
=> $virtual}) unless(-d
$physical);
486 return error
($config->{'errors'}->{'dir_no_create'},$virtual,{DIR
=> $virtual}) unless(-w
$physical);
488 if(my $uploaded_file = $cgi->param('uploaded_file'))
490 # Process file upload
492 my $filename = file_name
($uploaded_file);
493 my $file_phys = $physical."/".$filename;
494 my $file_virt = $virtual.$filename;
496 return error
($config->{'errors'}->{'in_use'},$virtual,{FILE
=> $file_virt}) if($data->{'uselist'}->in_use($file_virt));
500 return error
($config->{'errors'}->{'dir_replace'},$virtual) if(-d
$file_phys);
501 return error
($config->{'errors'}->{'exist_no_write'},$virtual,{FILE
=> $file_virt}) unless(-w
$file_phys);
502 return error
($config->{'errors'}->{'file_exists'},$virtual,{FILE
=> $file_virt}) unless($cgi->param('overwrite'));
505 my $ascii = $cgi->param('ascii');
506 my $handle = $cgi->upload('uploaded_file');
508 # Read transferred file and write it to disk
510 read($handle, my $data, -s
$handle);
511 $data =~ s/\015\012|\012|\015/\n/g if($ascii); # Replace line separators if transferring in ASCII mode
512 file_save
($file_phys,\
$data,not $ascii) or return error
($config->{'errors'}->{'mkfile_failed'},$virtual,{FILE
=> $file_virt});
514 return devedit_reload
({command
=> "show", file
=> $virtual});
518 my $tpl = new Template
;
519 $tpl->read_file($config->{'templates'}->{'upload'});
521 $tpl->fillin("DIR",$virtual);
522 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
523 $tpl->fillin("SCRIPT",$script);
525 my $output = header
(-type
=> "text/html");
526 $output .= $tpl->get_template;
534 # Copy a file and return to directory view
536 # Params: 1. Reference to user input hash
537 # 2. Reference to config hash
539 # Return: Output of the command (Scalar Reference)
543 my ($data,$config) = @_;
544 my $physical = $data->{'physical'};
545 my $virtual = encode_entities
($data->{'virtual'});
546 my $dir = upper_path
($virtual);
547 my $new_physical = $data->{'new_physical'};
549 return error
($config->{'errors'}->{'dircopy'},$dir) if(-d
$physical);
550 return error
($config->{'errors'}->{'no_copy'},$dir) unless(-r
$physical);
554 my $new_virtual = $data->{'new_virtual'};
555 my $new_dir = upper_path
($new_virtual);
556 $new_virtual = encode_entities
($new_virtual);
560 return error
($config->{'errors'}->{'exist_edited'},$new_dir,{FILE
=> $new_virtual}) if($data->{'uselist'}->in_use($data->{'new_virtual'}));
561 return error
($config->{'errors'}->{'dir_replace'},$new_dir) if(-d
$new_physical);
562 return error
($config->{'errors'}->{'exist_no_write'},$new_dir,{FILE
=> $new_virtual}) unless(-w
$new_physical);
564 if(not $data->{'cgi'}->param('confirmed'))
566 my $tpl = new Template
;
567 $tpl->read_file($config->{'templates'}->{'confirm_replace'});
569 $tpl->fillin("FILE",$virtual);
570 $tpl->fillin("NEW_FILE",$new_virtual);
571 $tpl->fillin("NEW_FILENAME",file_name
($new_virtual));
572 $tpl->fillin("NEW_DIR",$new_dir);
573 $tpl->fillin("DIR",$dir);
575 $tpl->fillin("COMMAND","copy");
576 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
577 $tpl->fillin("SCRIPT",$script);
579 my $output = header
(-type
=> "text/html");
580 $output .= $tpl->get_template;
586 copy
($physical,$new_physical) or return error
($config->{'errors'}->{'copy_failed'},$dir,{FILE
=> $virtual, NEW_FILE
=> $new_virtual});
587 return devedit_reload
({command
=> 'show', file
=> $new_dir});
591 my $tpl = new Template
;
592 $tpl->read_file($config->{'templates'}->{'copyfile'});
594 $tpl->fillin("FILE",$virtual);
595 $tpl->fillin("DIR",$dir);
596 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
597 $tpl->fillin("SCRIPT",$script);
599 my $output = header
(-type
=> "text/html");
600 $output .= $tpl->get_template;
608 # Rename/move a file and return to directory view
610 # Params: 1. Reference to user input hash
611 # 2. Reference to config hash
613 # Return: Output of the command (Scalar Reference)
617 my ($data,$config) = @_;
618 my $physical = $data->{'physical'};
619 my $virtual = $data->{'virtual'};
620 my $dir = upper_path
($virtual);
621 my $new_physical = $data->{'new_physical'};
623 return error
($config->{'errors'}->{'rename_root'},"/") if($virtual eq "/");
624 return error
($config->{'errors'}->{'no_rename'},$dir) unless(-w upper_path
($physical));
625 return error
($config->{'errors'}->{'in_use'},$dir,{FILE
=> $virtual}) if($data->{'uselist'}->in_use($virtual));
629 my $new_virtual = $data->{'new_virtual'};
630 my $new_dir = upper_path
($new_virtual);
631 $new_virtual = encode_entities
($new_virtual);
635 return error
($config->{'errors'}->{'exist_edited'},$new_dir,{FILE
=> $new_virtual}) if($data->{'uselist'}->in_use($data->{'new_virtual'}));
636 return error
($config->{'errors'}->{'dir_replace'},$new_dir) if(-d
$new_physical);
637 return error
($config->{'errors'}->{'exist_no_write'},$new_dir,{FILE
=> $new_virtual}) unless(-w
$new_physical);
639 if(not $data->{'cgi'}->param('confirmed'))
641 my $tpl = new Template
;
642 $tpl->read_file($config->{'templates'}->{'confirm_replace'});
644 $tpl->fillin("FILE",$virtual);
645 $tpl->fillin("NEW_FILE",$new_virtual);
646 $tpl->fillin("NEW_FILENAME",file_name
($new_virtual));
647 $tpl->fillin("NEW_DIR",$new_dir);
648 $tpl->fillin("DIR",$dir);
650 $tpl->fillin("COMMAND","rename");
651 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
652 $tpl->fillin("SCRIPT",$script);
654 my $output = header
(-type
=> "text/html");
655 $output .= $tpl->get_template;
661 rename($physical,$new_physical) or return error
($config->{'errors'}->{'rename_failed'},$dir,{FILE
=> $virtual, NEW_FILE
=> $new_virtual});
662 return devedit_reload
({command
=> 'show', file
=> $new_dir});
666 my $tpl = new Template
;
667 $tpl->read_file($config->{'templates'}->{'renamefile'});
669 $tpl->fillin("FILE",$virtual);
670 $tpl->fillin("DIR",$dir);
671 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
672 $tpl->fillin("SCRIPT",$script);
674 my $output = header
(-type
=> "text/html");
675 $output .= $tpl->get_template;
683 # Remove a file or a directory and return to directory view
685 # Params: 1. Reference to user input hash
686 # 2. Reference to config hash
688 # Return: Output of the command (Scalar Reference)
692 my ($data,$config) = @_;
693 my $physical = $data->{'physical'};
694 my $virtual = $data->{'virtual'};
695 my $dir = upper_path
($virtual);
697 return error
($config->{'errors'}->{'remove_root'},"/") if($virtual eq "/");
698 return error
($config->{'errors'}->{'no_delete'},$dir) unless(-w upper_path
($physical));
704 if($data->{'cgi'}->param('confirmed'))
707 return devedit_reload
({command
=> 'show', file
=> $dir});
711 my $tpl = new Template
;
712 $tpl->read_file($config->{'templates'}->{'confirm_rmdir'});
714 $tpl->fillin("DIR",$virtual);
715 $tpl->fillin("UPPER_DIR",$dir);
716 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
717 $tpl->fillin("SCRIPT",$script);
719 my $output = header
(-type
=> "text/html");
720 $output .= $tpl->get_template;
729 return error
($config->{'errors'}->{'in_use'},$dir,{FILE
=> $virtual}) if($data->{'uselist'}->in_use($virtual));
731 if($data->{'cgi'}->param('confirmed'))
733 unlink($physical) or return error
($config->{'errors'}->{'delete_failed'},$dir,{FILE
=> $virtual});
734 return devedit_reload
({command
=> 'show', file
=> $dir});
738 my $tpl = new Template
;
739 $tpl->read_file($config->{'templates'}->{'confirm_rmfile'});
741 $tpl->fillin("FILE",$virtual);
742 $tpl->fillin("DIR",$dir);
743 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
744 $tpl->fillin("SCRIPT",$script);
746 my $output = header
(-type
=> "text/html");
747 $output .= $tpl->get_template;
756 # Change the mode and the group of a file or a directory
758 # Params: 1. Reference to user input hash
759 # 2. Reference to config hash
761 # Return: Output of the command (Scalar Reference)
765 my ($data,$config) = @_;
766 my $physical = $data->{'physical'};
767 my $virtual = $data->{'virtual'};
768 my $dir = upper_path
($virtual);
770 return error
($config->{'errors'}->{'no_users'},$dir,{FILE
=> $virtual}) unless($users);
771 return error
($config->{'errors'}->{'chprop_root'},"/") if($virtual eq "/");
772 return error
($config->{'errors'}->{'not_owner'},$dir,{FILE
=> $virtual}) unless(-o
$physical);
773 return error
($config->{'errors'}->{'in_use'},$dir,{FILE
=> $virtual}) if($data->{'uselist'}->in_use($virtual));
775 my $cgi = $data->{'cgi'};
776 my $mode = $cgi->param('mode');
777 my $group = $cgi->param('group');
785 chmod(oct($mode),$physical);
790 # Change the group using the `chgrp` system command
792 return error
($config->{'errors'}->{'invalid_group'},$dir,{GROUP
=> encode_entities
($group)}) unless($group =~ /^[a-z0-9_]+[a-z0-9_-]*$/i);
793 system("chgrp",$group,$physical);
796 return devedit_reload
({command
=> 'show', file
=> $dir});
802 my @stat = stat($physical);
806 my $tpl = new Template
;
807 $tpl->read_file($config->{'templates'}->{'chprop'});
809 # Insert file properties into the template
811 $tpl->fillin("MODE_OCTAL",substr(sprintf("%04o",$mode),-4));
812 $tpl->fillin("MODE_STRING",mode_string
($mode));
813 $tpl->fillin("GID",$gid);
815 if(my $group = getgrgid($gid))
817 $tpl->fillin("GROUP",encode_entities
($group));
818 $tpl->parse_if_block("group_detected",1);
822 $tpl->parse_if_block("group_detected",0);
825 # Insert other information
827 $tpl->fillin("FILE",$virtual);
828 $tpl->fillin("DIR",$dir);
829 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
830 $tpl->fillin("SCRIPT",$script);
832 my $output = header
(-type
=> "text/html");
833 $output .= $tpl->get_template;
841 # Remove a file from the list of used files and
842 # return to directory view
844 # Params: 1. Reference to user input hash
845 # 2. Reference to config hash
847 # Return: Output of the command (Scalar Reference)
851 my ($data,$config) = @_;
852 my $virtual = $data->{'virtual'};
853 my $uselist = $data->{'uselist'};
854 my $dir = upper_path
($virtual);
856 return devedit_reload
({command
=> 'show', file
=> $dir}) if($uselist->unused($virtual));
858 if($data->{'cgi'}->param('confirmed'))
860 file_unlock
($uselist,$virtual);
861 return devedit_reload
({command
=> 'show', file
=> $dir});
865 my $tpl = new Template
;
866 $tpl->read_file($config->{'templates'}->{'confirm_unlock'});
868 $tpl->fillin("FILE",$virtual);
869 $tpl->fillin("DIR",$dir);
870 $tpl->fillin("URL",equal_url
($config->{'httproot'},$virtual));
871 $tpl->fillin("SCRIPT",$script);
873 my $output = header
(-type
=> "text/html");
874 $output .= $tpl->get_template;
882 # Display some information about Dev-Editor
884 # Params: 1. Reference to user input hash
885 # 2. Reference to config hash
887 # Return: Output of the command (Scalar Reference)
891 my ($data,$config) = @_;
893 my $tpl = new Template
;
894 $tpl->read_file($config->{'templates'}->{'about'});
896 $tpl->fillin("SCRIPT",$script);
898 # Dev-Editor's version number
900 $tpl->fillin("VERSION",$data->{'version'});
902 # Some path information
904 $tpl->fillin("SCRIPT_PHYS",encode_entities
($ENV{'SCRIPT_FILENAME'}));
905 $tpl->fillin("CONFIG_PATH",encode_entities
($data->{'configfile'}));
906 $tpl->fillin("FILE_ROOT", encode_entities
($config->{'fileroot'}));
907 $tpl->fillin("HTTP_ROOT", encode_entities
($config->{'httproot'}));
911 $tpl->fillin("PERL_PROG",encode_entities
($^X
));
912 $tpl->fillin("PERL_VER", sprintf("%vd",$^V
));
914 # Information about the server
916 $tpl->fillin("HTTPD",encode_entities
($ENV{'SERVER_SOFTWARE'}));
917 $tpl->fillin("OS", encode_entities
($^O
));
918 $tpl->fillin("TIME", encode_entities
(strftime
($config->{'timeformat'},localtime)));
920 # Process information
922 $tpl->fillin("PID",$$);
924 # Check if the functions getpwuid() and getgrgid() are available
928 # Dev-Editor is running on a system which allows users and groups
929 # So we display the user and the group of our process
931 my $uid = POSIX
::getuid
;
932 my $gid = POSIX
::getgid
;
934 $tpl->parse_if_block("users",1);
936 # ID's of user and group
938 $tpl->fillin("UID",$uid);
939 $tpl->fillin("GID",$gid);
941 # Names of user and group
943 if(my $user = getpwuid($uid))
945 $tpl->fillin("USER",encode_entities
($user));
946 $tpl->parse_if_block("user_detected",1);
950 $tpl->parse_if_block("user_detected",0);
953 if(my $group = getgrgid($gid))
955 $tpl->fillin("GROUP",encode_entities
($group));
956 $tpl->parse_if_block("group_detected",1);
960 $tpl->parse_if_block("group_detected",0);
965 $tpl->fillin("UMASK",sprintf("%04o",umask));
969 $tpl->parse_if_block("users",0);
972 my $output = header
(-type
=> "text/html");
973 $output .= $tpl->get_template;
978 # it's true, baby ;-)
patrick-canterino.de