![]() |
|
[PHP] Simple IP Block System - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: PHP (https://sinister.ly/Forum-PHP) +--- Thread: [PHP] Simple IP Block System (/Thread-PHP-Simple-IP-Block-System) Pages:
1
2
|
[PHP] Simple IP Block System - Ex094 - 01-28-2013 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: [/code]
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 ![]() Have fun! RE: [PHP] Simple IP Block System - hackarchives - 01-28-2013 Edit: I read it..It is simple but good one..Good work exo RE: [PHP] Simple IP Block System - bluedog.tar.gz - 01-28-2013 Cool share man, thanks ! RE: [PHP] Simple IP Block System - Ex094 - 01-29-2013 Thank you hackarchives and bluedog Glad you guys liked it!
RE: [PHP] Simple IP Block System - hackarchives - 01-29-2013 Hey do you mind if i create what you have described..I got nothing to do right now :/ RE: [PHP] Simple IP Block System - Ex094 - 01-29-2013 (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 I'll work on something else... Give credits to me that idea was mine ![]() BTW do send me the source code of what you make with that Proxy Detector! RE: [PHP] Simple IP Block System - hackarchives - 01-29-2013 SUre..NO problem .I will release the whole source code RE: [PHP] Simple IP Block System - jNova - 03-26-2014 good bro , if you need any help I'm here :v ! RE: [PHP] Simple IP Block System - ArkPhaze - 04-05-2014 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. RE: [PHP] Simple IP Block System - invisal - 04-07-2014 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. |