You can install rfw , which is the REST API for iptables and works as a server with root privileges. Clients can use any HTTP API without special rights, so you can use curl from PHP to send commands to rfw.
Command example:
PUT /drop/input/eth0/11.22.33.44
which corresponds to:
iptables -I INPUT -i eth0 -s 11.22.33.44 -j DROP
Disclaimer: I started this project.
source share