- if(-o $physical)
- {
- # We own this file
-
- if($mode || $group)
- {
- if($mode)
- {
- # Change the mode
-
- chmod(oct($mode),$physical);
- }
-
- if($group)
- {
- # Change the group using the `chgrp` system command
-
- return error($config->{'errors'}->{'invalid_group'},$dir,{GROUP => encode_entities($group)}) unless($group =~ /^[a-z0-9_]+[a-z0-9_-]*$/i);
- system("chgrp",$group,$physical);
- }
-
- return devedit_reload({command => 'show', file => $dir});
- }
- else
- {
- # Display the form
-
- my @stat = stat($physical);
- my $mode = $stat[2];
- my $gid = $stat[5];
-
- my $tpl = new Template;
- $tpl->read_file($config->{'templates'}->{'chprop'});
-
- # Insert file properties into the template
-
- $tpl->fillin("MODE_OCTAL",substr(sprintf("%04o",$mode),-4));
- $tpl->fillin("MODE_STRING",mode_string($mode));
- $tpl->fillin("GID",$gid);
-
- if(my $group = getgrgid($gid))
- {
- $tpl->fillin("GROUP",encode_entities($group));
- $tpl->parse_if_block("group_detected",1);
- }
- else
- {
- $tpl->parse_if_block("group_detected",0);
- }
-
- # Insert other information
-
- $tpl->fillin("FILE",$virtual);
- $tpl->fillin("DIR",$dir);
- $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
- $tpl->fillin("SCRIPT",$script);
-
- my $output = header(-type => "text/html");
- $output .= $tpl->get_template;
-
- return \$output;
- }
- }
- else
- {
- return error($config->{'errors'}->{'not_owner'},$dir,{FILE => $virtual});
- }