Jump to content

Recommended Posts

I have managed to fetch the IP's, but it wont ip ban the person, from the script i have, here take a look:

 

<?

include "header2.php";
include "_menu.php";
include "_home.php";
include "_block_user.php";
if ($melding) {
	echo "<div class=\"window\">";
	echo "<div class=\"mainTitle\">Ban user!</div>";
	echo "<div class=\"mainText\">";
	echo "$melding";
	echo "</div></div>";
} else {	
?>
<div class="window">
<div class="mainTitle">Ban user <?php echo $b_user; ?></div>
<div class="mainText">

	<?
	if ($moderator > 1) {
		$lijstIp = "SELECT * FROM users WHERE username='$b_user'";
		$resultLijstIp = mysql_query($lijstIp);
		$data = $data = mysql_fetch_array($resultLijstIp);
		?>

			<? echo $b_user." - ".$data[ip]; ?><br/><br/>
			<form action=block_user.php method=post>
				<?php
				if (!$data[ip]) {
					//geen ip bekend
					echo "Ip:<br/>";
					echo "<input type=text name=ip><br/><br/>";
				} elseif ($data[ip]) {
					//ip bekend
					echo "<input type=hidden name=ip value=$data[ip]>";
				}
				?>
				Reason (In english): <br/>
				<textarea name=reason></textarea><br/>
				<input type=hidden name=user value=<?php echo $b_user; ?>><br/><br/>
				<input type=submit value=Ban! name=hehe>
			</form>
		<?php
	} else {
		echo "You are not allowed to see this area!";
	}
	?>

</div>
</div>
<?
}
include "footer.php";
?>

 

And this is the _block_user that is included:

 

<?php

if ($ip and $reason and $user) {
	if ($moderator > 1) {
	$opdracht = "insert INTO ip_block values('0','$ip','$reason', '$user')";
	$resultaat = mysql_query($opdracht);
	if ($resultaat) {
		$melding = "User succesfully blocked, $user can't acces the game anymore!";	
	}		
	}
}

?>

 

In my database, i have and empty table called "ip_block" with rows; id, ip, reason and username!

 

and i store the IP's in the table "users"

 

what is wrong, i dont even get an error :S

 

Thanks alot anyway!

 

~iSpeedDevil!

Link to comment
https://forums.phpfreaks.com/topic/124713-i-wanna-ip-ban-people-on-my-game/
Share on other sites

I think you missed extract($_POST); above the if condition in _block_user.php...

but i do not recomment you to use it...

try

if ($_POST['ip'] and $_POST['reason'] and $_POST['user']) {

instead od extract...

 

Tip: check some html rules like writing html attributes...

Going to bed now, post if you success...

It is so easy to get a new IP address, that most 13 year olds on this planet know how to get one (and I just checked with an 11 year old and even he knows that you cannot stop someone from playing a game by banning their IP address) that you would be wasting your time trying to make an IP ban system work.

 

You need an email verified registration and login member system, where you can disable accounts/email addresses. This at least requires a banned member to obtain a new email address and create a new account to get back into your game.

As PFMaBiSmAd said its so easy to get a new ip these days but its also easy to ge a new email address! There isnt really much you can do to block a person from coming to your site, infact i got completely ip banned from a site because i called the admin a lier when they said "they" had coded a script and i knew it to be false 2 secods later i had a new account and i sent the admin an email this of cause was after:

 

Sever ip ban

Account ban

If you still want to do that here is something i came up with a couple years ago

 

<?php

public function checkBan()
{
	$ip = $_SERVER['REMOTE_ADDR'];

	$sql = "SELECT * FROM banned WHERE ip='$ip'";

	$check = $this->query($sql);

	if (mysql_num_rows($check) == 0)
	{
		return;
	} else {
		header ("Location: banned.php");
	}
}


?>

 

stick that into a class and call it from where ever.  also notice i had a seperate function for the mysql_query()...

 

change it how you need to.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.