<?php
|
|
$_SERVER ['REMOTE_ADDR'];
|
how to print ipaddreess
|
In local server it shows some problem while getting ipaddress
|
|
so go to xampp- apache- conf-
httpd.confic- use notepad open
|
|
listen search, find next - listen 80- listen 127.0.0.1:80
write, then ur problem is over
|
|
stop apache ,after 5 seconds use
|
|
how to block ip address
|
|
<?php
|
|
$ipadress
=$_SERVER ['REMOTE_ADDR'];
|
how to show my ip adress
|
$i_blocked = array('127.0.0.1', '10.0.0.10');
|
store some ipaddress using array to one variable
|
?>
|
|
<?php
|
|
require
'confinc.php';
|
using template get the values like bootstrap
|
foreach($ipadress
as $ip){
|
using foreach convert the variable name
|
echo $ip. '<br>';
|
prints the present ip, we not use the function , we use the
function in confinc page , get that using require
|
}
|
|
?>
|
|
<?php
|
|
require
'confinc.php';
|
prints the present ip, we not use the function , we use the
function in confinc page , get that using require
|
foreach($ip_blocked
as $ip){
|
convet just for understanidng way
|
if ($ip == $ipadress) {
|
compares the ip adreess which is in blocked list
|
die (' your ip adress ' .$ip_address.' has been blocked!');
|
it wil not execute the next statements
|
}
|
if it there, it wil not the execute the next statements use die
|
}
|
|
?>
|
|
| how to get ip adress | |
|
|
if ipadress is not come if customer using proxy
another ip
// Function to get the client ip addressfunction get_client_ip_env() { $ipaddress = ''; if (getenv('HTTP_CLIENT_IP')) $ipaddress = getenv('HTTP_CLIENT_IP'); else if(getenv('HTTP_X_FORWARDED_FOR')) $ipaddress = getenv('HTTP_X_FORWARDED_FOR'); else if(getenv('HTTP_X_FORWARDED')) $ipaddress = getenv('HTTP_X_FORWARDED'); else if(getenv('HTTP_FORWARDED_FOR')) $ipaddress = getenv('HTTP_FORWARDED_FOR'); else if(getenv('HTTP_FORWARDED')) $ipaddress = getenv('HTTP_FORWARDED'); else if(getenv('REMOTE_ADDR')) $ipaddress = getenv('REMOTE_ADDR'); else $ipaddress = 'UNKNOWN'; return $ipaddress;}how to get the ipaddress if used proxy
get the ipadress of website |
|
| $_SERVER ['REMOTE_ADDR']; |
| array |
| require |
| foreach |
| foreach |
| if |
| die |
|
|||||||||
No comments:
Post a Comment