Skip to content

Commit

Permalink
Add ability to display PHP files in disabled mode ; preserve a block
Browse files Browse the repository at this point in the history
  • Loading branch information
iliajie committed Sep 19, 2022
1 parent db12a06 commit cf6a0ec
Showing 1 changed file with 33 additions and 14 deletions.
47 changes: 33 additions & 14 deletions virtual_feature.pl
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,12 @@ sub feature_setup
'words' => [ '~', '\.php(/|$)' ],
'type' => 1,
'members' => [
{ 'name' => 'try_files',
'words' => [ '$uri', '$fastcgi_script_name', '=404' ],
},
{ 'name' => 'try_files',
'words' => [ '$uri', '$fastcgi_script_name', '=404' ],
},
{ 'name' => 'default_type',
'words' => [ 'application/x-httpd-php' ],
}
],
};
&save_directive($server, [ ], [ $ploc ]);
Expand Down Expand Up @@ -1274,16 +1277,19 @@ sub feature_save_web_php_mode
# Update the port in the config, if changed
if (!$loc) {
&lock_file($server->{'file'});
$loc = { 'name' => 'location',
'words' => [ '~', '\.php(/|$)' ],
'type' => 1,
'members' => [
{ 'name' => 'try_files',
'words' => [ '$uri', '$fastcgi_script_name',
'=404' ],
},
],
};
$loc =
{ 'name' => 'location',
'words' => [ '~', '\.php(/|$)' ],
'type' => 1,
'members' => [
{ 'name' => 'default_type',
'words' => [ 'application/x-httpd-php' ],
},
{ 'name' => 'try_files',
'words' => [ '$uri', '$fastcgi_script_name', '=404' ],
},
],
};
&save_directive($server, [ ], [ $loc ]);
&flush_file_lines($server->{'file'});
&unlock_file($server->{'file'});
Expand All @@ -1300,7 +1306,20 @@ sub feature_save_web_php_mode
# Remove the location block
if ($loc) {
&lock_file($server->{'file'});
&save_directive($server, [ $loc ], [ ]);
my $locdeftype =
{ 'name' => 'location',
'words' => [ '~', '\.php(/|$)' ],
'type' => 1,
'members' => [
{ 'name' => 'default_type',
'words' => [ 'text/plain' ],
},
{ 'name' => 'try_files',
'words' => [ '$uri', '$fastcgi_script_name', '=404' ],
},
],
};
&save_directive($server, [ $loc ], [ $locdeftype ]);
&flush_file_lines($server->{'file'});
&unlock_file($server->{'file'});
&virtual_server::register_post_action(\&print_apply_nginx);
Expand Down

0 comments on commit cf6a0ec

Please sign in to comment.