Valhalla Legends Forums Archive | Web Development | IPBan :

AuthorMessageTime
Crazy_X
<?php
$banned_ip = array();
$banned_ip[] = '*.*.*.**1';
$banned_ip[] = '*.*.*.**2';
$banned_ip[] = '*.*.*.**3';
$banned_ip[] = '*.*.*.**4';

foreach($banned_ip as $banned) {
$ip = $_SERVER['REMOTE_ADDR'];
if($ip == $banned){
echo "Error 04, Banned.";
exit();
}
}
//blah
?>

Has anyone written anything better? Just wrote this up, excuse me if its been done before but it works for me.
December 22, 2003, 5:20 AM
Forged
If I were you I would write all of the wanted ipbans to a textfile. And then a code that would let you ban new ips from a webpage as opposed to having to login to my ftp and editing my file every time you find another fucker.

&Edited
December 23, 2003, 12:09 AM
AssassinRC
Or MySQL. Just a thought.
December 23, 2003, 12:44 AM
Forged
Mysql would be the same thing with extra code...
December 23, 2003, 12:49 AM
ProjecT
<?
if (ereg("IP Here",$REMOTE_ADDR))
{
echo "your banned ."; exit(); }
?>
December 25, 2003, 6:01 PM
CrAzY
Hmmm, I'll Right you a Script.
[code]
<?php

$db="HelloWorld"; //MySQL Database here
$username="Admin"; //MySQL Username
$password="JohnSmith"; //MySQL Password

@mysql_connect('localhost', $username, $password);
@mysql_select_db($db);

$ip=$_SERVER['REMOTE_ADDR']);
$ip2=mysql_query("Select `ip` From $db");

if($ip==$ip2){
echo("Your IP Is Invalid!")
}else{
echo("All the data of the page go's here");
}

?>
[/code]

I think I may have messed up, if I did, some one correct me. (Sorry, in a hurry to go some where.)
December 26, 2003, 12:07 AM
St0rm.iD
Yeah there isn't a loop.
December 26, 2003, 12:45 AM
ProjecT
I will write u a better one... just wait 20 min lol..
December 27, 2003, 12:54 AM
ProjecT
U can use this to:
<?php
$IP=$_SERVER["REMOTE_ADDR"];
$host = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$host=array("204.22.109.34.router34.isp.net", "216.229.45.11");
$test=$IP.".".$lh;
if(in_array($test, $host) || in_array($host, $IP)) {
header("Location: http://yoursite.com/banned.html"); }
?>
December 27, 2003, 1:03 AM
St0rm.iD
Nope sorry.
December 27, 2003, 4:34 AM
Arta
Using gethostbyaddr() will make your page load very slowly if it can't find the name. It takes ages to time out.
December 27, 2003, 11:01 PM

Search