Login Register






Thread Rating:
  • 0 Vote(s) - 0 Average


[PHP] Simple IP Block System filter_list
Author
Message
[PHP] Simple IP Block System #1
PHP Code:
<html>
<
head>
    <
title>IP Block System By Exo94</title>
</
head>
<
body>
<?
php
///////////////////////////
//Simple IP Block System //
//    Coded By Exo94     //
//   Hackcommunity.com   //
// http://www.gigadev.tk //
///////////////////////////
//Advance version to come//
//        SOON!          //
///////////////////////////

// List of IPs that you don't want to access your website
$ip_list = array('Add your ip here to test');

//Get hostname of the visiting user
$user_ip $_SERVER['REMOTE_HOST'];

//Resolve Hostname of the user
$res_host gethostbyname($user_ip);

//Store all the IPs in the array in a Variable
foreach ($ip_list as $black_list) {

//If the IP of the visiting guest is a match with the IP List (Array), He'll be redirected to another website.
//Replace the URL with your redirect location
    
if($res_host == $black_list) {

//Code to redirect user to another website and not letting him access your site if his IP matches the one in the Array
        
header('Location: http://www.your_redirect_page.com');

    } else {

//If guest IP is not a match with the listed one, He'll be led to the index 
//page of your website, Either it's a login form or anything else that you have entered the url of.
//Replace the URL with the one where you want to redirect the user
        
header('Location: http://www.gigadev.tk')
    }
}
?>
</body>
</html> 

For now this is it but I'll be working on a more advance one which will:
1) Have a Login Form
2) IP Logger
3) Proxy Detector
4) Blocks user if enters wrong user and pass for the first time
5) Detects Country IP
6) Will append IP's from a text file to the array making it user friendly and easy to manage block list

7) Might have a Admin Panel if I cover the major topics of PHP in time
and more they'll come into me mind Smile

Have fun!
[/code]
My Blog: http://www.procurity.wordpress.com
Donations: 1HLjiSbnWMpeQU46eUVCrYdbkrtduX7snG

Reply

RE: [PHP] Simple IP Block System #2
Edit: I read it..It is simple but good one..Good work exo

Reply

RE: [PHP] Simple IP Block System #3
Cool share man, thanks !

Reply

RE: [PHP] Simple IP Block System #4
Thank you hackarchives and bluedog Smile Glad you guys liked it!
My Blog: http://www.procurity.wordpress.com
Donations: 1HLjiSbnWMpeQU46eUVCrYdbkrtduX7snG

Reply

RE: [PHP] Simple IP Block System #5
Hey do you mind if i create what you have described..I got nothing to do right now :/

Reply

RE: [PHP] Simple IP Block System #6
(01-29-2013, 01:30 PM)hackarchives Wrote: Hey do you mind if i create what you have described..I got nothing to do right now :/
Sure why not Smile I'll work on something else... Give credits to me that idea was mine Tongue
BTW do send me the source code of what you make with that Proxy Detector!
My Blog: http://www.procurity.wordpress.com
Donations: 1HLjiSbnWMpeQU46eUVCrYdbkrtduX7snG

Reply

RE: [PHP] Simple IP Block System #7
SUre..NO problem .I will release the whole source code

Reply

RE: [PHP] Simple IP Block System #8
good bro , if you need any help I'm here :v !

Reply

RE: [PHP] Simple IP Block System #9
Why wouldn't you just use array_search?
Code:
<?php

$arr = array(
  'one',
  'two',
  'three'
);

echo array_search('one', $arr) !== FALSE ? 'Found' : 'Not Found', PHP_EOL;
echo array_search('five', $arr) !== FALSE ? 'Found' : 'Not Found', PHP_EOL;

?>

Also, header() calls should be put before ANY output. In this case it might be better to just use exit() if you need to have it embodied within the HTML, or return if this is an included script.

Read the documentation on header()...

http://www.php.net/manual/en/function.header.php
Quote:Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include, or require, functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file.
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]

Reply

RE: [PHP] Simple IP Block System #10
Always use exit() after you do header redirection or else
people still able to access the page you are trying to
block.

Noted that without exit() after header, you will send
the content of HTML along with the header to redirect.
Client can choose not to redirect and render the HTML.

Reply







Users browsing this thread: 1 Guest(s)