Hi all.
I think some of you might be familiar with the kids who feel all hardcore because they know php injection and put themselves on the #1 spot of the high score list or even flood it.
When I got the script for the high score I added ip logging in it. So the one posting high score also posts his ip. So I have the bad ip’s and now I only need to block them but I have no clue how.
The idea: I would like to put all the blocked ip’s in a separate php page that would look something like this I think:
$bad_ip = array('255.255.255.250','255.255.255.251','255.255.255.252','255.255.255.253','255.255.255.254','255.255.255.255');
Then I would have to change the high score script. Before posting the high score, “high_score.php” should get the bad_ip variable from “bad_ip.php”. If it sees that the current high score submitter has one of the bad ip’s then it should block him (optional: a message saying for example: “go to bed kid”).
Below is the high score code:
<?php
session_start();
function redirect($url) {
die('<meta http-equiv="refresh" content="0;URL='.$url.'">');
}
if(isset($_POST["userName"])){
$userName = $_POST["userName"];
$time = time();
// $ip = $_SERVER["REMOTE_ADDR"];
$scoreDate = date("Y-m-d H:i:s",$time);
if (!$_SERVER['REQUEST_METHOD'] == "POST" || !$userName){
$myScoreDB = -1;
$addFlag = " : tried to add: ".$myScore;
}else{
$myScoreDB = $myScore;
}
if ($_SERVER['REQUEST_METHOD'] != "POST"){
$myScoreDB = -1;
$addFlag = " : tried to add: ".$myScore;
}
$sql = "insert into firewall_scores (userName,userScore,scoreDate,scoreFrom,ip) values ('$userName',$myScoreDB,'$scoreDate','".$_SERVER['HTTP_REFERER']." : ".$_SERVER['REQUEST_METHOD']." : ".$scoreValid.$addFlag."','".$_SERVER['REMOTE_ADDR']."')";
$conn = mysql_connect("localhost", "xxxx", "xxxxxxxx");
$dbName = "data";
mysql_select_db($dbName,$conn);
if (mysql_query($sql,$conn)){
echo "&scoreIn=1";
exit;
}else{
echo "&scoreIn=0";
echo "&scoreError=".mysql_error();
exit;
}
}
?>
So could somebody please help? I’ve read various posts on what to do but I have no idea where to add the code. All help is appreciated.
Thanks