Ignore:
Timestamp:
Apr 7, 2020, 8:52:35 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Improved code formatting.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Common/NetworkAddress.php

    r7 r10  
    1414  function GetNetMask()
    1515  {
    16     return(0xffffffff ^ ((1 << (32 - $this->Prefix)) - 1));
     16    return 0xffffffff ^ ((1 << (32 - $this->Prefix)) - 1);
    1717  }
    1818
    1919  function AddressToString()
    2020  {
    21     return(implode('.', array(($this->Address >> 24) & 255, ($this->Address >> 16) & 255, ($this->Address >> 8) & 255, ($this->Address & 255))));
     21    return implode('.', array(($this->Address >> 24) & 255, ($this->Address >> 16) & 255, ($this->Address >> 8) & 255, ($this->Address & 255)));
    2222  }
    2323
     
    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
     
    4343  {
    4444    $this->Prefix = $NewPrefix;
    45     if($this->Prefix > 32) $this->Prefix = 32;
    46     if($this->Prefix < 0) $this->Prefix = 0;
     45    if ($this->Prefix > 32) $this->Prefix = 32;
     46    if ($this->Prefix < 0) $this->Prefix = 0;
    4747    $this->Address = $this->Address & $this->GetNetMask();
    4848  }
     
    5151  {
    5252    $UpperNetmask = $this->GetNetMask();
    53     if(($this->Prefix < $Address->Prefix) and (($Address->Address & $UpperNetmask) == ($this->Address & $UpperNetmask))) $Result = true;
     53    if (($this->Prefix < $Address->Prefix) and (($Address->Address & $UpperNetmask) == ($this->Address & $UpperNetmask))) $Result = true;
    5454      else $Result = false;
    5555    //echo($Address->AddressToString().'/'.$Address->Prefix.' in '.$this->AddressToString().'/'.$this->Prefix.' '.$Result."\n");
    56     return($Result);
     56    return $Result;
    5757  }
    5858}
     
    7171  function AddressToString()
    7272  {
    73     return(inet_ntop($this->Address));
     73    return inet_ntop($this->Address);
    7474  }
    7575
     
    8383    $Result = array();
    8484    $Data = array_reverse(unpack('C*', $this->Address));
    85     foreach($Data as $Item)
     85    foreach ($Data as $Item)
    8686    {
    8787
     
    8989      $Result[] = dechex(($Item >> 4) & 15);
    9090    }
    91     return($Result);
     91    return $Result;
    9292  }
    9393
Note: See TracChangeset for help on using the changeset viewer.