PluginProbe
LWS Tools / trunk
LWS Tools vtrunk
trunk 1.0 1.0.1 2.0 2.1 2.1.5 2.2 2.2.1 2.3 2.3.1 2.4 2.4.1 2.4.2 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5 2.6 2.6.1 2.6.1.5 2.6.2 2.6.3 2.6.4
lws-tools / view / update_htaccess.php

update_htaccess.php in LWS Tools trunk, at view/update_htaccess.php

48 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 $hta = '';
3 foreach ($opts as $opt => $value) {
4 if ($value) {
5 switch ($opt) {
6 case 'autoindex':
7 $hta .= "Options +Indexes\n";
8 break;
9
10 case 'authorid':
11 $hta .= "RewriteRule ^author/(.+) \"-\" [F]\n";
12 break;
13
14 case 'comments':
15 $hta .= "<If \"%{REQUEST_FILENAME} =~ /wp-comments-post.php/ && ( %{HTTP_USER_AGENT} == '' || %{HTTP_REFERER} == '' )\">\n RewriteRule wp-comments-post\\.php$ \"-\" [F]\n</If>\n";
16 break;
17
18 case 'sqlfiles':
19 $hta .= "RewriteRule (.+)\\.sql$ \"-\" [F]\n";
20 break;
21
22 case 'readmelicense':
23 $hta .= "RewriteRule (license\\.txt|readme\\.html)$ \"-\" [F]\n";
24 break;
25
26 case 'xmlrpc':
27 $hta .= "RewriteRule xmlrpc\\.php$ \"-\" [F]\n";
28 break;
29
30 case 'phpuploads':
31 $hta .= "<If \"%{REQUEST_URI} =~ m#wp-content/uploads/.+\\.php#\">\n SetHandler !\n</If>\n";
32 break;
33 }
34 }
35 }
36 $hta = <<<EOD
37 # BEGIN WP MANAGER
38 # Règles ajoutées par LWS Wordpress Manager, ne pas éditer à la main
39 # Rules added by LWS Wordpress Manager, do not edit by hand
40 $hta# END WP MANAGER
41
42 EOD;
43 if (is_file(ABSPATH . '.htaccess')) {
44 $file = file_get_contents(ABSPATH . '.htaccess');
45 $file = preg_replace("/(# BEGIN WP MANAGER)([\S\s]*?)(# END WP MANAGER)/", $hta, $file);
46 file_put_contents(ABSPATH . '.htaccess', $file);
47 }
48