Simply add the following before the area where you process the form. This supposes two things, the first is that you already have a session of mysql open and secondly, that your form is on the same page, just change the correct section as needed. SQL can be found beneath the PHP.
PHP Code:
$ip = $_SERVER['REMOTE_ADDR'] $klb = "select count from hax where ip = '$ip'"; $blk = mysql_query($klb); $bln = mysql_num_rows($blk); if($bln != ''){echo "<p>HAX! BLOCKED!</p>"; $cnt = mysql_result($blk,0); $cnt += 1; $up = "update hax set count = $cnt where ip = '$ip'"; $pu = mysql_query($up); exit; } $ref = $_SERVER['HTTP_REFERER']; if($ref != "http://".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF']){ $ver = "select count from hax where ip = '$ip'"; $rev = mysql_query($ver); $cnt = mysql_result($rev, 0); if($cnt != ''){ $cnt += 1; $up = "update hax set count = $cnt where ip = '$ip'"; $pu = mysql_query($up); } else{ $mk = "insert into hax values('$ip','1')"; $km = mysql_query($mk); } echo "<p>HAX! IP LOGGED!</p>"; exit; }
Code:
CREATE TABLE IF NOT EXISTS `hax` (
`ip` varchar(15) NOT NULL,
`count` int(11) unsigned NOT NULL default '0',
PRIMARY KEY (`ip`)
)
I'd like to note, the reason I have count is so you can report it better, if you check once and day and suddenly it jumped from none to 500 then their ISP should act quickly. Secondly, don't test this script unless you're sure of your IP so you can remove it.
__________________
PHP Code:
<?php echo "Hello World"; ?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Last edited by Arenlor; 11-18-2007 at 11:08 PM..
Reason: Fixed a typo which wasn't there o.O
|