Hello,
i hope someone can help me, im trying to write to teh middle of a file because the contents at the end and at the start cant be changed.. here is what my php code looks like...
/* ban data starts here
if ($placeban == "yes"){
$ban = 'deny from $REMOTE_ADDR
</LIMIT>';
$htaccess = fopen ("/var/www/html/.htaccess", "r+");
echo ereg_replace ("</LIMIT>", "$ban", $htaccess);
$fp = fwrite($htaccess,chr(13));
$fp = fwrite($htaccess,"$ban,");
fclose($htaccess);
echo "- Cannot Proccess";
exit;
}
ban data ends here */
ok that probably looks completely funny to you, "which wouldnt surprise me because it dosnt work" 🙂
basically i want to add an IP into the htaccess file.. here is what the htaccess file looks like before it has been written to.
<LIMIT GET PUT POST>
order allow,deny
allow from all
deny from 111.111.111.111
</LIMIT>
ok, so 111.111.111.111 represents an IP address, so thats where i add there IP address to ban them. however, the IP must be added before "</LIMIT>
and after "allow from all"
so can anyone help me out with an example on how to do this?
Kind Regards
ryza