unknowncheats uc-forum.com ucdownloads ucdownloads.com

Go Back   UC-Tutorials - Multiplayer Game Hacking and Cheat Tutorials > Web / Scripting > PHP

- Sponsored Advertisement -
http://www.myfpscheats.com/


Reply
 
Thread Tools Display Modes
  #1  
Old 12-23-2006, 08:05 AM
zero_tolerance zero_tolerance is offline
Senior Member
 
Join Date: Dec 2006
Posts: 289
Default Basic IP Ban script

By Rich

Okay, I wrote this quick little thing for the site I'm currently making. All it really does is grab the user's IP and then check it against a list of banned users. If the IP matches a banned one, then it stops them from viewing the site and gives them a message. The code is quite basic, but I'll explain some anyway.

PHP Code:
<?php
    $ip 
getenv('REMOTE_ADDR');
    
$email "your@mail.com"

    
$banzored1 "000.000.000"
    
$banzored2 "000.000.000"
    
$banzored3 "000.000.000"


    
if($ip == $banzored1 || $ip == $banzored2 || $ip == $banzored3)
    { 
        echo 
"You have been banned from this website. <br> If there is some mistake, contact the admin at <br> $email."
        
exit;
    }
?>
Pretty simple stuff, but it does the job. Let's explain it a little.

- $ip = getenv('REMOTE_ADDR'); - I'm assigning the person's IP to the variable $ip. $ip is used when checking the IP against the banned list.
- $email = "your@mail.com" - Change your@mail.com to your e-mail. This gives people a chance to contact you in case of a mistake.
- $banzored1 = "000.000.000" - Change the 0's to the person's IP you wish to ban. That assigns the banned person's IP to the variable. It is the same with banzored1 to 3.
- if($ip == $banzored1 || $ip == $banzored2 || $ip == $banzored3) - Here we're checking the $ip variable (where we stored the persons IP) against a list of banned IPs. If it matches, it echos and will not let them view the site. If it does not match, the user will be allowed to view the site normally.

----

Simple but it works. You can have as many IP's in the $banzored lists as you want. Just remember to assign to the variable and check it in our if statement.

Maybe some more stuff from me coming soon.
Reply With Quote
Reply

  • Submit Thread to Digg
  • Submit Thread to del.icio.us
  • Submit Thread to StumbleUpon
  • Submit Thread to Google
  • Submit Thread to Facebook
  • Submit Thread to My Yahoo!
  • Submit Thread to MySpace
  • Submit Thread to Twitter
  • Submit Thread to Reddit

Tags
ban, basic, script

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



All times are GMT. The time now is 03:36 PM.