Skip to content

Instantly share code, notes, and snippets.

@kikiriko200
Last active March 29, 2019 02:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kikiriko200/f598f6124965f5926d97b31204425c0d to your computer and use it in GitHub Desktop.
Save kikiriko200/f598f6124965f5926d97b31204425c0d to your computer and use it in GitHub Desktop.
これにcronで自動更新付の.htaccess作れる筈
<?php
$filename = '.htaccess';
// a+じゃなくてwだったらわざわざ消さなくていいらしい
$fp = fopen($filename,'w');
// EU Deny 配布元
$ip_lists = file_get_contents("https://ipv4.fetus.jp/krfilter.4.apache.txt");
// Headerとかとか。
$ip_set .= "<ifModule mod_headers.c>"."\n";
$ip_set .= "Header always set X-XSS-Protection '1; mode=block'"."\n";
$ip_set .= "</ifModule>"."\n";
// アクセス制限
$ip_set .= "order Allow,Deny"."\n";
$ip_set .= "Allow from all"."\n\n";
$ip_set .= "\n";
$ip_set .= $ip_lists;
$ip_set = mb_convert_encoding($ip_set,'Shift-JIS"');
fwrite($fp,$ip_set);
fclose($fp);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment