Changeset 267 for trunk/global.php
- Timestamp:
- Dec 21, 2009, 10:48:41 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/global.php
r247 r267 10 10 include('config.php'); 11 11 include('database.php'); 12 include('error.php');12 //include('error.php'); 13 13 include_once('code.php'); 14 14 $Database = new Database($Config['Database']['Host'], $Config['Database']['User'], $Config['Database']['Password'], $Config['Database']['Database']); … … 233 233 } 234 234 235 function ToVpnIp($Host)236 {237 if($Host['external_ip'] == '')238 {239 $Parts = explode('.', $Host['IP']);240 return('172.16.'.$Parts[2].'.'.$Parts[3]);241 } else242 {243 return($Host['external_ip']);244 }245 }246 247 235 function TimeToMysqlDateTime($Time) 248 236 { … … 264 252 } 265 253 266 function ToCzfreeIp($Host)267 {268 $Parts = explode('.', $Host['external_ip']);269 if($Host['name'] == 'CENTRALA') return('10.144.1.1');270 else return('10.144.200.'.$Parts[3]);271 }272 273 254 function HumanDate($Time) 274 255 { … … 280 261 281 262 // Zobrazení číselný seznamu stránek 282 function PagesList($URL, $Page,$TotalCount,$CountPerPage)283 { 284 $Count = ceil($TotalCount /$CountPerPage);263 function PagesList($URL, $Page, $TotalCount, $CountPerPage) 264 { 265 $Count = ceil($TotalCount / $CountPerPage); 285 266 $Around = 10; 286 267 $Result = ''; … … 328 309 $RemoteAddr = GetRemoteAddress(); 329 310 $RemoteAddr = explode('.', $RemoteAddr); 330 return(!(($RemoteAddr[0] == 1 92) and ($RemoteAddr[1] == 168)));311 return(!(($RemoteAddr[0] == 10) and ($RemoteAddr[1] == 145))); 331 312 } 332 313 … … 351 332 } 352 333 353 function IPv4ToInt32($IP)354 {355 $Parts = explode('.', $IP);356 return(($Parts[0] << 24) | ($Parts[1] << 16) | ($Parts[2] << 8) | $Parts[3]);357 }358 359 function Int32ToIPv4($Value)360 {361 return(implode('.', array(($Value >> 24) & 255, ($Value >> 16) & 255, ($Value >> 8) & 255, ($Value & 255))));362 }363 364 function CIDRToAddressRange($Subnet, $Mask)365 {366 $SubnetBinary = IPv4ToInt32($Subnet);367 $Hostmask = (1 << (32 - $Mask)) - 1;368 $Netmask = 0xffffffff ^ $Hostmask;369 $From = $SubnetBinary & $Netmask;370 $To = $From + $Hostmask;371 return(array('From' => Int32ToIPv4($From), 'To' => Int32ToIPv4($To)));372 }373 374 function IsAddressInSubnet($Address, $Subnet, $Mask)375 {376 $AddressBinary = IPv4ToInt32($Address);377 $SubnetBinary = IPv4ToInt32($Subnet);378 $Netmask = 0xffffffff ^ ((1 << (32 - $Mask)) - 1);379 if(($AddressBinary & $Netmask) == ($SubnetBinary & $Netmask)) return(true);380 else return(false);381 }382 383 334 function RouterOSIdent($Name) 384 335 { … … 391 342 function NotBlank($Text) 392 343 { 393 if($Text == '') return(' '); else return($Text); 344 if($Text == '') return(' '); 345 else return($Text); 394 346 } 395 347
Note:
See TracChangeset
for help on using the changeset viewer.