Find file
Fetching contributors…
Cannot retrieve contributors at this time
67 lines (49 sloc) 1.75 KB
<?php
// Reporte toutes les erreurs PHP
error_reporting(-1);
ini_set('display_errors', '1');
$base = dirname($_SERVER['SCRIPT_NAME']);
$base_url = 'http://'.$_SERVER['HTTP_HOST'].$base;
$base_dir = dirname(__FILE__).'/';
$file = basename(__FILE__);
$htaccess = fopen($base_dir.'.htaccess', 'w');
fwrite($htaccess, <<<EOF
#
# Generated by $file
#
<IfModule mod_php5.c>
AddHandler php5-script .php .php5
</IfModule>
<IfModule !mod_php5.c>
PHP 1
</IfModule>
<IfModule mod_mime.c>
AddType text/html .php .php5 .xhtml
AddType application/json .json
</IfModule>
# Detect Apache modules
# perl -E 'foreach(@ARGV){print"<IfModule \$_.c>\\nRedirectPermanent /\$_ http://o.mengue.free.fr/ok.txt\\n</IfModule>\\n"}\\n' core mod_log_config mod_logio prefork http_core mod_so mod_alias mod_auth_basic mod_authn_file mod_authz_default mod_authz_groupfile mod_authz_host mod_authz_user mod_autoindex mod_cgi mod_dir mod_env mod_mime mod_negotiation mod_php5 mod_reqtimeout mod_setenvif mod_status
EOF
);
$list_json = fopen($base_dir.'list.json', 'r');
$json = fgets($list_json);
fclose($list_json);
$modules = explode('","', substr($json, 2, -2));
if (function_exists('apache_get_modules')) {
$modules = apache_get_modules();
}
foreach(array_values($modules) as $mod) {
fwrite($htaccess, "<IfModule $mod.c>\n"
." RedirectPermanent $base/$mod $base_url/ok.txt\n"
."</IfModule>\n"
."<IfModule !$mod.c>\n"
." RedirectPermanent $base/$mod $base_url/404!\n"
."</IfModule>\n\n");
}
fclose($htaccess);
$list_json = fopen($base_dir.'list.json', 'w');
fwrite($list_json, '["'.implode('","', $modules).'"]');
fclose($list_json);
header('Content-type: text/plain');
#echo $base_dir;
?>Done.