我有我试图让尽可能安全的登录系统。经过十不良企图我想有就有的IP地址被阻止。我怎样才能打开PHP文件,并添加一行到我的块IP地址code?这是我的htaccess文件:
I have a login system that I am trying to make as secure as possible. After ten bad attempts I want to have there ip address blocked. How can I open a file in PHP and add a line to my block ip addresses code? Here is my htaccess file:
#Turn on RewriteEngine
RewriteEngine on
#Don't allow file indexing pages
Options -Indexes
#Follow Symbolic Links
Options +FollowSymLinks
#Set default language and charset
DefaultLanguage en-US
AddDefaultCharset UTF-8
#Set the server timezone
SetEnv TZ America/Vancouver
#Don't need extention for PHP files
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^.]+)$ $1.php [NC,L]
#Block bad IP Addresses
RewriteCond %{REMOTE_ADDR} ^217.172.179.*$ [OR]
RewriteCond %{REMOTE_ADDR} ^217.172.180.*$
RewriteCond %{REQUEST_URI} !/error/blocked.php$ [NC]
RewriteRule ^(.*)$ /error/blocked.php [R,NC,L]
我想的PHP文件中加入一行:
I would like the PHP file to add the line:
RewriteCond %{REMOTE_ADDR} ^IPHERE$ [OR]
在注释块错误的IP地址对的。
right under the comment Block bad IP Addresses.
我不建议直接编辑.htaccess文件。
I wouldn't recommend editing the .htaccess file directly.
相反,在PHP中的文件或数据库表来保存所有被列入黑名单的IP地址,并将其与测试,而不是Apache的身边。
Instead, have a file or a database table to save all of the blacklisted IP addresses, and test against that in PHP, rather than on Apache's side.