Ignore:
Timestamp:
Oct 4, 2009, 7:56:50 AM (15 years ago)
Author:
george
Message:
  • Upraveno: Generování SQL změn a filtr na 192.168.0.0/16.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/temp/renumbering.php

    r251 r255  
    3434    $Output = '';
    3535
    36     $DbResult = $this->Database->query('SELECT * FROM NetworkSubnet');
     36    $DbResult = $this->Database->query('SELECT * FROM NetworkSubnet WHERE CompareNetworkPrefix(INET_ATON("192.168.0.0"), INET_ATON(AddressRange), 16)');
     37    $Output .= 'UPDATE NetworkInterface SET CZFreeIP = LocalIP<br>';
    3738    while($Subnet = $DbResult->fetch_assoc())
    3839    {
    39       $Output .= 'Podsíť '.$Subnet['Name'].': '.$Subnet['AddressRange'].'/'.$Subnet['Mask'].' => '.$this->SubnetTable[$Subnet['Id']]['AddressRange'].'/'.$this->SubnetTable[$Subnet['Id']]['Mask'].'<br>';
    40       $DbResult2 = $this->Database->query('SELECT NetworkInterface.LocalIP, NetworkDevice.Name FROM NetworkInterface JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE CompareNetworkPrefix(INET_ATON(NetworkInterface.LocalIP), INET_ATON("'.$Subnet['AddressRange'].'"), '.$Subnet['Mask'].')  ORDER BY NetworkInterface.LocalIP');
     40      $Output .= '-- Podsíť '.$Subnet['Name'].': '.$Subnet['AddressRange'].'/'.$Subnet['Mask'].' => '.$this->SubnetTable[$Subnet['Id']]['AddressRange'].'/'.$this->SubnetTable[$Subnet['Id']]['Mask'].'<br>';
     41      $DbResult2 = $this->Database->query('SELECT NetworkInterface.Id, NetworkInterface.LocalIP, NetworkDevice.Name FROM NetworkInterface JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE CompareNetworkPrefix(INET_ATON(NetworkInterface.LocalIP), INET_ATON("'.$Subnet['AddressRange'].'"), '.$Subnet['Mask'].')  ORDER BY NetworkInterface.LocalIP');
    4142      $NextIP = IPv4ToInt32($this->SubnetTable[$Subnet['Id']]['AddressRange']) + 1;
    4243      while($Interface = $DbResult2->fetch_assoc())
    4344      {
    44         $Output .= '&nbsp;&nbsp;&nbsp;'.$Interface['Name'].': '.$Interface['LocalIP'].' => '.Int32ToIPv4($NextIP).'<br>';
     45        $Output .= '-- '.$Interface['Name'].': '.$Interface['LocalIP'].' => '.Int32ToIPv4($NextIP).'<br>';
     46        $Output .= 'UPDATE NetworkInterface SET LocalIP = "'.Int32ToIPv4($NextIP).'" WHERE Id='.$Interface['Id'].';<br>';
    4547        $NextIP++;       
    4648      }
Note: See TracChangeset for help on using the changeset viewer.