This kind of protection is already build in IP.Board.
If you would like to add extra protection to your forum you should add extra security on server program level and not on php script level which would only make your forum slower.
You could add modules to Apache/PHP like mod_security, mod_suhosin and mod_evasive.
Also modyfing the standard settings of php.ini will help make your server more secure.