-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
36 lines (36 loc) · 880 Bytes
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
function getRealIpAddr(){
if (!empty($_SERVER['HTTP_CLIENT_IP'])){
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else{
$ip=$_SERVER['REMOTE_ADDR'];
}
return $ip;
}
function findReseverd($ipaddress){
$arr = explode(".",$ipaddress);
//echo $arr[0] ;
if ($arr[0]>=0 && $arr[0]<=127)
$reseverd = 8;
elseif ($arr[0]>=128 && $arr[0]<=191)
$reseverd = 16;
elseif ($arr[0]>=192 && $arr[0]<=223)
$reseverd = 24;
else
$reseverd = 24;
return $reseverd;
}
function findCidr($ipaddress,$reseverd){
$arr = explode(".",$ipaddress);
if ($reseverd=8) {
$firstSet = arr[1];
//$secon
}
$bin = sprintf( "%08d", decbin( $reseverd ));
return $cidr;
}
?>