Added initial files
This commit is contained in:
32
files/helper.php
Executable file
32
files/helper.php
Executable file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
class Helper
|
||||
{
|
||||
|
||||
function get_IP_address()
|
||||
{
|
||||
foreach (array('HTTP_CLIENT_IP',
|
||||
'HTTP_X_FORWARDED_FOR',
|
||||
'HTTP_X_FORWARDED',
|
||||
'HTTP_X_CLUSTER_CLIENT_IP',
|
||||
'HTTP_FORWARDED_FOR',
|
||||
'HTTP_FORWARDED',
|
||||
'REMOTE_ADDR') as $key){
|
||||
if (array_key_exists($key, $_SERVER) === true){
|
||||
foreach (explode(',', $_SERVER[$key]) as $IPaddress){
|
||||
$IPaddress = trim($IPaddress); // Just to be safe
|
||||
if (filter_var($IPaddress,
|
||||
FILTER_VALIDATE_IP,
|
||||
FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)
|
||||
!== false) {
|
||||
|
||||
return $IPaddress;
|
||||
}
|
||||
}
|
||||
return $IPaddress;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user