Changeset 698 for trunk/Common


Ignore:
Timestamp:
Sep 28, 2014, 10:41:47 PM (10 years ago)
Author:
chronos
Message:
  • Přidáno: Generování reverzních záznamů pro IPv6 DNS.
Location:
trunk/Common
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Common/Global.php

    r682 r698  
    1818include_once(dirname(__FILE__).'/Setup/Setup.php');
    1919include_once(dirname(__FILE__).'/PrefixMultiplier.php');
     20include_once(dirname(__FILE__).'/NetworkAddress.php');
    2021include_once(dirname(__FILE__).'/VCL/General.php');
    2122include_once(dirname(__FILE__).'/VCL/Database.php');
  • trunk/Common/NetworkAddress.php

    r695 r698  
    55  var $Address;
    66  var $Prefix;
    7  
     7
    88  function __construct()
    99  {
     
    1111    $this->Prefix = 0;
    1212  }
    13  
     13
    1414  function GetNetMask()
    1515  {
     
    2121    return(implode('.', array(($this->Address >> 24) & 255, ($this->Address >> 16) & 255, ($this->Address >> 8) & 255, ($this->Address & 255))));
    2222  }
    23  
     23
    2424  function AddressFromString($Value)
    2525  {
     
    2727    $this->Address = ($Parts[0] << 24) | ($Parts[1] << 16) | ($Parts[2] << 8) | $Parts[3];
    2828  }
    29  
     29
    3030  function GetRange()
    3131  {
     
    3737    $To->Address = $From->Address + $HostMask;
    3838    $To->Prefix = 32;
    39     return(array('From' => $From, 'To' => $To));   
     39    return(array('From' => $From, 'To' => $To));
    4040  }
    4141
     
    4949
    5050  function Contain($Address)
    51   {   
     51  {
    5252    $UpperNetmask = $this->GetNetMask();
    5353    if(($this->Prefix < $Address->Prefix) and (($Address->Address & $UpperNetmask) == ($this->Address & $UpperNetmask))) $Result = true;
     
    6262        var $Address;
    6363        var $Prefix;
    64        
     64
    6565        function __construct()
    6666        {
     
    6868                $this->Prefix = 0;
    6969        }
    70        
     70
    7171  function AddressToString()
    7272  {
    7373        return(inet_ntop($this->Address));
    7474  }
    75  
     75
    7676  function AddressFromString($Value)
    7777  {
    7878        $this->Address = inet_pton($Value);
    7979  }
    80        
     80
     81  function GetOctets()
     82  {
     83        $Result = array();
     84        $Data = array_reverse(unpack('C*', $this->Address));
     85        foreach($Data as $Item)
     86        {
     87
     88                $Result[] = dechex($Item & 15);
     89                $Result[] = dechex(($Item >> 4) & 15);
     90        }
     91        return($Result);
     92  }
     93
    8194}
Note: See TracChangeset for help on using the changeset viewer.