View previous topic :: View next topic |
Author |
Message |
demonhunter -
Joined: 14 Jun 2003 Posts: 79
|
Posted: Wed Dec 10, 2003 10:15 am Post subject: Learn the ABC of Ip Banning |
|
|
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 |
|
|
Anonymoose -
Joined: 09 Sep 2003 Posts: 2192
|
Posted: Thu Dec 11, 2003 1:26 pm Post subject: |
|
|
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 |
|
|
Moxxnixx -
Joined: 21 Jun 2003 Posts: 1226 Location: Florida
|
Posted: Thu Dec 11, 2003 2:28 pm Post subject: |
|
|
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 |
|
|
demonhunter -
Joined: 14 Jun 2003 Posts: 79
|
Posted: Sat Dec 13, 2003 4:26 am Post subject: |
|
|
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 |
|
|
Anonymoose -
Joined: 09 Sep 2003 Posts: 2192
|
Posted: Mon Dec 15, 2003 10:25 am Post subject: |
|
|
So if you made no modifications or improvements to it, you credit the original author. :idea: |
|
Back to top |
|
|
fourtwentymatt -
Joined: 04 Jan 2004 Posts: 6
|
Posted: Sun Jan 04, 2004 9:20 am Post subject: Where is... |
|
|
Where is PHP Admin. Does it come with Abyss webserver ... if so.. where is it? |
|
Back to top |
|
|
Moxxnixx -
Joined: 21 Jun 2003 Posts: 1226 Location: Florida
|
Posted: Sun Jan 04, 2004 1:33 pm Post subject: |
|
|
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 |
|
|
demonhunter -
Joined: 14 Jun 2003 Posts: 79
|
Posted: Mon Jan 05, 2004 7:59 am Post subject: |
|
|
I am not Saying i own that php code anyone can use that |
|
Back to top |
|
|
|