Learn the ABC of Ip Banning

 
Post new topic   Reply to topic    Aprelium Forum Index -> Tutorials
View previous topic :: View next topic  
Author Message
demonhunter
-


Joined: 14 Jun 2003
Posts: 79

PostPosted: Wed Dec 10, 2003 10:15 am    Post subject: Learn the ABC of Ip Banning Reply with quote

You need Php Enabled and Mysql on your server to do this:
This tutorial will show you how to ban people by IP address with php and mysql. First you need to go into php my admin and create the follow tables:

--------------------------------------------------------------------------------

CREATE TABLE banip ( ID int(12) NOT NULL auto_increment, IP varchar(25) NOT NULL default '', PRIMARY KEY (ID) ) TYPE=MyISAM;

--------------------------------------------------------------------------------

This is the basic table structure with only two fields, a field for a ID that identifies a unique field and a field for all IP's banned. Now we'll look at the code that actually bans the IP on each. Structure each page you want IP banning this way.

--------------------------------------------------------------------------------

<?php include "connect.php";
//this is the file that connect to sql
$s=$_SERVER["REMOTE_ADDR"];
//draws IP address of visitor
$ipbancheck="SELECT * from banip where IP='$s'";
$ipbancheck2=mysql_query($ipbancheck);
while($ipbancheck3=mysql_fetch_array($ipbancheck2))
{
$IPBANNED=$ipbancheck3[IP];
}
//above lines check to see if user Ip is in banned IPs
if ($IPBANNED)
{
print "You have been banned ";
}
else
{
//put content you want unbanned users to see here
}
?>

--------------------------------------------------------------------------------

Okay, this code should be fairly simple to understand. $_SERVER["REMOTE ADDR"] draws the IP address of the user the next line select from the table of baned IP where a field matches the user's IP. If no fields match the users IP, it comes up blank. The while loop sets the variable IPBANNED equal to the banned IP if the first select statement had any matches and, if the select didn't have any matches, it doesn't set a IPBANNED variable. Then when the the next few lines says if the IPBANNED variable exists, then we shows the 'You have been banned" message, otherwise show the actual page content in the else case
Back to top View user's profile Send private message AIM Address
Anonymoose
-


Joined: 09 Sep 2003
Posts: 2192

PostPosted: Thu Dec 11, 2003 1:26 pm    Post subject: Reply with quote

Nice, but it only works if viewers are trying to access PHP pages.

Also, considering you just asked

demonhunter wrote:
I Need a Good Webhost so i can Setup my server i currently have Cable and ive heard that cable isnt good

demonhunter wrote:
How do install php on my Webserver?

demonhunter wrote:
Hi,I just want to Know how to Make Database for my Web-server is this possible to create a database with username and password?


I find it hard to believe this is your code. Looks awfully similar to this one in fact.

http://www.chipmunk-scripts.com/tutorials/ipbanning.php

How about giving credit where it's due ? 8O
Back to top View user's profile Send private message
Moxxnixx
-


Joined: 21 Jun 2003
Posts: 1226
Location: Florida

PostPosted: Thu Dec 11, 2003 2:28 pm    Post subject: Reply with quote

It's not just similar, it's exactly the same!

demonhunter, It's common courtesy to give credit to the original source if you
copy/paste something from another website...and, in most cases, AFTER you
ask the author for permission first.

I didn't see a "terms of use" on chipmunk's site, but like Anonymoose said,
it's still a good idea to give credit where credit is due.
Back to top View user's profile Send private message Visit poster's website
demonhunter
-


Joined: 14 Jun 2003
Posts: 79

PostPosted: Sat Dec 13, 2003 4:26 am    Post subject: Reply with quote

Did i Make any Modifications to it? No i didnt make any Modifications to it so i placed here so that others can use it to not just using the other one
Back to top View user's profile Send private message AIM Address
Anonymoose
-


Joined: 09 Sep 2003
Posts: 2192

PostPosted: Mon Dec 15, 2003 10:25 am    Post subject: Reply with quote

So if you made no modifications or improvements to it, you credit the original author. :idea:
Back to top View user's profile Send private message
fourtwentymatt
-


Joined: 04 Jan 2004
Posts: 6

PostPosted: Sun Jan 04, 2004 9:20 am    Post subject: Where is... Reply with quote

Where is PHP Admin. Does it come with Abyss webserver ... if so.. where is it?
Back to top View user's profile Send private message Visit poster's website AIM Address
Moxxnixx
-


Joined: 21 Jun 2003
Posts: 1226
Location: Florida

PostPosted: Sun Jan 04, 2004 1:33 pm    Post subject: Reply with quote

phpMyAdmin is popular program used to creation and management of databases
for the MySQL Database Server.
You can go to http://www.phpmyadmin.net to download the latest version.
There is a tutorial for installing it in this section or you can go to http://os17fan.cjb.net/
for an alternate tutorial.
Back to top View user's profile Send private message Visit poster's website
demonhunter
-


Joined: 14 Jun 2003
Posts: 79

PostPosted: Mon Jan 05, 2004 7:59 am    Post subject: Reply with quote

I am not Saying i own that php code anyone can use that
Back to top View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> Tutorials All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group