• Welcome to Valhalla Legends Archive.
 
Main Menu

IPBan :

Started by Crazy_X, December 21, 2003, 11:20 PM

Previous topic - Next topic

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.

Forged

#1
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
QuoteI wish my grass was Goth so it would cut itself

AssassinRC

Or MySQL. Just a thought.

Forged

Mysql would be the same thing with extra code...
QuoteI wish my grass was Goth so it would cut itself

Archangel.

<?
if (ereg("IP Here",$REMOTE_ADDR))
{
echo "your banned ."; exit(); }
?>
aka: Archangel, i can't login into the account or request the password, weird problem.

CrAzY

Hmmm, I'll Right you a Script.

<?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");
}

?>



I think I may have messed up, if I did, some one correct me.  (Sorry, in a hurry to go some where.)
CrAzY

Banana fanna fo fanna

Yeah there isn't a loop.

Archangel.

I will write u a better one... just wait 20 min lol..
aka: Archangel, i can't login into the account or request the password, weird problem.

Archangel.

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"); }
   ?>
aka: Archangel, i can't login into the account or request the password, weird problem.

Banana fanna fo fanna


Arta

Using gethostbyaddr() will make your page load very slowly if it can't find the name. It takes ages to time out.