Web Hosting Deals Holiday Logo Design Webcam Chat Website Header Templates Register domain Search Engine Optimisation Web Hosting
Go Back   Talk Mania Forum > Programming / Scripting / Coding

Programming / Scripting / Coding Got a question about : PHP / Perl / Java / JavaScript / CGI Scripts / JavaScript coding. Ask here! We'll get you the answers !

 Image
Buy Sell Downloads

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-04-2007, 01:28 AM
Junior Member
 
Join Date: Feb 2007
Posts: 20
-=sIN=- is on a distinguished road
[PHP] IP Ban

1. Create a file called ban.php and add this sctip to it.

PHP Code:
<?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!");
}

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

?>
2. Add this code to any page you what the ip banned from

PHP Code:
<?php
include('ban.php');
?>

Reply With Quote
  #2 (permalink)  
Old 02-04-2007, 01:56 PM
Junior Member
 
Join Date: Feb 2007
Posts: 9
tutorialstation is on a distinguished road
Alternately user in_array function rather than foreach function

PHP Code:
$visitor_ip $_SERVER['REMOTE_ADDR'];
$ip_list explode(","$ban_ip);

if(
in_array($visitor_ip$ip_list))
{
die(
"You are banned from this site!");

Reply With Quote
  #3 (permalink)  
Old 03-06-2007, 11:22 PM
Junior Member
 
Join Date: Mar 2007
Posts: 6
ticom is on a distinguished road
PHP Code:
<?php
include('ban.php');
?>
Make sure you put that piece of code at top of the site you want to ban them from, the code above the script are not blocked!
Reply With Quote
  #4 (permalink)  
Old 03-11-2007, 02:17 PM
Junior Member
 
Join Date: Oct 2006
Posts: 10
Phoinx is on a distinguished road
I will keep that in mind
Reply With Quote
  #5 (permalink)  
Old 03-15-2007, 06:19 PM
Junior Member
 
Join Date: Mar 2007
Posts: 11
Santa is on a distinguished road
thank you was looking for that

Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT +2. The time now is 02:25 AM.


Fake ID

Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC8
Forums Copyright © Talk-Mania.com