Ignore:
Timestamp:
Apr 6, 2020, 11:17:40 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Improved code format.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/NetworkConfigRouterOS/Generators/AddressPortability.php

    r738 r873  
    11<?php
    22
    3 if(isset($_SERVER['REMOTE_ADDR'])) die();
     3if (isset($_SERVER['REMOTE_ADDR'])) die();
    44include_once(dirname(__FILE__).'/../../../Common/Global.php');
    55include_once(dirname(__FILE__).'/../Routerboard.php');
     
    1111{
    1212  $TimeParts = explode(':', $Time);
    13   return($TimeParts[0] * 3600 + $TimeParts[1] * 60 + $TimeParts[2]);
     13  return ($TimeParts[0] * 3600 + $TimeParts[1] * 60 + $TimeParts[2]);
    1414}
    1515
     
    1919
    2020$DbResult3 = $System->Database->query('SELECT * FROM `NetworkSubnet` WHERE `Member` = 0 GROUP BY `DHCP`');
    21 while($Subnet = $DbResult3->fetch_assoc())
     21while ($Subnet = $DbResult3->fetch_assoc())
    2222{
    2323  echo($Subnet['AddressRange'].'/'.$Subnet['Mask'].' on router '.$Subnet['DHCP']."\n");
    2424  $Routerboard->HostName = $Subnet['DHCP'];
    2525  $List = $Routerboard->ListGet($Path, array('address', 'active-mac-address', 'active-address', 'expires-after', 'server', 'dynamic'));
    26   foreach($List as $Properties)
     26  foreach ($List as $Properties)
    2727  {
    28     if($Properties['dynamic'] == 'true')
     28    if ($Properties['dynamic'] == 'true')
    2929    //and ($Properties['address'] != $Properties['active-address']))
    3030    {
     
    3232      echo('MAC: '.$Properties['active-mac-address']."\n");
    3333      $DbRows2 = $System->Database->query('SELECT `Id` FROM `NetworkInterface` WHERE `MAC`="'.$Properties['active-mac-address'].'"');
    34       if($DbRows2->num_rows > 0)
     34      if ($DbRows2->num_rows > 0)
    3535      {
    3636        $Interface = $DbRows2->fetch_assoc();
    3737        $InterfaceId = $Interface['Id'];
    3838        $DbRows2 = $System->Database->query('SELECT `Id` FROM `NetworkInterfacePortable` WHERE `NetworkInterface`='.$InterfaceId);
    39         if($DbRows2->num_rows > 0)
     39        if ($DbRows2->num_rows > 0)
    4040        {
    4141          $System->Database->update('NetworkInterfacePortable', '`Time` < "'.TimeToMysqlDateTime($Properties['expires-after']).'" AND `NetworkInterface`='.$InterfaceId, array('DynamicIP' => $Properties['active-address'], 'Update' => 1));
     
    5353$NATRule = array();
    5454$DbRows = $System->Database->query('SELECT NetworkDevice.Name AS DeviceName, NetworkInterface.Name AS InterfaceName, DynamicIP FROM `NetworkInterfacePortable` JOIN NetworkInterface ON NetworkInterface.Id=NetworkInterfacePortable.NetworkInterface JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE `Update`=1');
    55 while($Portable = $DbRows->fetch_assoc())
     55while ($Portable = $DbRows->fetch_assoc())
    5656{
    5757  $Name = $Portable['DeviceName'];
    58   if($Portable['InterfaceName'] != '') $Name .= '-'.$Portable['InterfaceName'];
     58  if ($Portable['InterfaceName'] != '') $Name .= '-'.$Portable['InterfaceName'];
    5959  array_push($NATRule, implode(' ', $PathNAT).' set [find comment="'.$Name.'-in"] to-addresses='.$Portable['DynamicIP']);
    6060  array_push($NATRule, implode(' ', $PathNAT).' set [find comment="'.$Name.'-out"] src-address='.$Portable['DynamicIP']);
Note: See TracChangeset for help on using the changeset viewer.