FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


IP Banning





leos4h
Is the a script where i can login and ban/unban ips?
NG
hey member me its dean of msn and heres the script this maybe help full

Code:
Step 1
To use the below code, simply past one of the codes in a file named ban.php

Then at the top of each html page or one of your header files put:

require('ban.php')

This script will ban the person(s) from viewing the site.
 
Step 2
<?php
// For a single user ban
$ban_ip = 'xxx.xxx.xxx.xxx'; // ip address of the person you want to ban

// DO NOT EDIT BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING
$visitor_ip = $_SERVER['REMOTE_ADDR']; // the ip address of the visitor
if($visitor_ip == $ban_ip)
{
die("You are banned from this site!");
}

// For a multiple user ban
$ban_ip = "xxx.xxx.xxx.1,xxx.xxx.xxx.2"); // put ip addresses, separated by commas
// DO NOT EDIT BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING
$visitor_ip = $_SERVER['REMOTE_ADDR'];
$ip_list = explode(",", $ban_ip);
foreach($ip_list as $ip)
{
if($visitor_ip == $ip)
{
die("You are banned from this site!");
}
}

?>


if this doesnt work tell me because i hav another one in html
leos4h
leos4h wrote:
Is the a script where i can login and ban/unban ips?


Needs an admin area
AftershockVibe
Just a quick note, in case you didn't know, that there are IP blocking tools on most control panel systems that come with hosting.

I'd suggest you use this if you have it as it is done through the actual HTTP server and therefore allows them no access whatsoever.
leos4h
I want one for my staff to login so they can login and ban/unban members as im not going to give my ftp password out
PatTheGreat42
You trust your staff enough to dictate who can access your site, and therefore your entire customer base, but not enough to look at files?
martindecorte
Anyway, you can make a form easily with php/mysql.
- create a login page
- when the admin is logged in, he fills in a form with the ip to ban/unban
- when he sends the form, an sql transaction (insert/delete) is executed

Then you'll have a database containing the banned ip's. You then just need to adapt NG's solution, to use your database.

Weren't I to fast ?
leos4h
riiiiiiiiiiiight
Related topics
Too much spam
PHP IP Ban
How can I...
News management system...
Ip Banning Using Php
Just curious..
cpanel help
IP Banning...
News Script
Uploader v6,Shoutbox,Simple Gallery,Simple Directory indexer
News system
Block Proxy's
Chat box
.: User login systems for your site :. CHEAP AND EASY!
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.