Hi,
I have a few wordpress websites that I host for my clients because of the number of attacks they have been receiving lately I have implemented a .htaccess file to block any ip address that's not in the whitelist, the problem I face is everytime the client moves from location to location or there ip address changes I have to update the .htaccess file with there new ip.
I'm trying to build a script where they can access a url with a key in and submit there new ip address the php script would then read the .htaccess and add the new ip, however the 'echos' in the file seem not to be echoing any information to screen and I'm faced with a blank white screen can anyone give me any ideas on how to do this or have alook at the script below I have wrote.
<?php
if (isset($_GET('key')) && $_GET('key') = '78J89ke93k93HJ883j003') {
$htaccess = '.htaccess';
//read the entire file
$str = file_get_contents($htaccess);
//delete deny from all from file
$str = str_replace('deny from all', '', $str);
$ip = 'allow from ' . $_get('ip'); //'allow from 92.27.111.112';
$str .= $ip;
//re add deny from all to end of file
$str .= "\n" . 'deny from all';
if(file_put_contents($htaccess, $str)){
echo 'IP ' . $ip . ' Added to .htaccess file';
}
} else {
echo 'Invalid Key';
}
?>