Forum Moderators: coopster

Message Too Old, No Replies

Php write apf fire wall deny host file

         

leoleo

12:00 pm on Apr 3, 2007 (gmt 0)

10+ Year Member



Hello,

can anyone tell me how can php write to apf fire wall deny_host file? I need to add ip to this file.

Anyone got code to share thanks

jatar_k

3:10 pm on Apr 3, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld leoleo,

can you get at the file?

you should be able to just fopen, fwrite, fclose

you may need to have a copy somewhere where php can get at it, edit the file and then push it to the firewall

leoleo

4:06 pm on Apr 3, 2007 (gmt 0)

10+ Year Member



Hello I tried to fpoen and fwrite, it doesn't works... so I need some code or anyone can help thanks alot.

whoisgregg

4:46 pm on Apr 3, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello leoleo,

If you'd like to post the code you tried to use fopen and fwrite with, we'd be happy to take a look at it and point out any issues.

leoleo

6:39 pm on Apr 3, 2007 (gmt 0)

10+ Year Member



This is the code I use, I guess is the path wrong or something I really don't know. I am using plesk control panel and the path is http ://192.168.1.1/etc/apf/deny_hosts.rules. (I think the file cannot be run this way?).

$ip = "\r\n$REMOTE_ADDR" ;
$banip = '/etc/apf/deny_hosts.rules';
$fp = fopen($banip, "a");
$write = fputs($fp, $ip);
fclose($fp);

it doesn't works, any solution? Thanks alot

Or how can I exec the command below. I can't use exec() because of host security issue so it there another way to exe this command?

$apfDeny = "/usr/local/sbin/apf -d $REMOTE_ADDR";

[edited by: eelixduppy at 6:51 pm (utc) on April 3, 2007]
[edit reason] obfuscated IP [/edit]