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/FirewallMangle.php

    r870 r873  
    77    global $InetInterface, $ItemsFirewall;
    88
    9     foreach($Node['Items'] as $Index => $Item)
    10     {
    11       if(count($Item['Items']) == 0)
     9    foreach ($Node['Items'] as $Index => $Item)
     10    {
     11      if (count($Item['Items']) == 0)
    1212      {
    1313        // Hosts
    1414        $ParentSubnetId = GetSubgroupByRange($Node['Address']->AddressToString().'/'.$Node['Address']->Prefix);
    1515        $Address = $Item['Address']->AddressToString();
    16         if($Item['Address']->Prefix != 32) $Address .= '/'.$Item['Address']->Prefix;
     16        if ($Item['Address']->Prefix != 32) $Address .= '/'.$Item['Address']->Prefix;
    1717
    1818        $PacketMark = GetMarkByComment($Item['Name'].'-out');
     
    2828
    2929        $Address = $Item['Address']->AddressToString();
    30         if($Item['Address']->Prefix != 32) $Address .= '/'.$Item['Address']->Prefix;
     30        if ($Item['Address']->Prefix != 32) $Address .= '/'.$Item['Address']->Prefix;
    3131
    3232        $ItemsFirewall[] = array('chain' => 'inet-'.$ParentSubnetId.'-out', 'src-address' => $Address, 'out-interface' => $InetInterface, 'action' => 'jump', 'jump-target' => 'inet-'.$SubnetId.'-out', 'comment' => $Item['Name'].'-out');
     
    3636      }
    3737    }
    38     if($Node['ForceMark'] == true)
     38    if ($Node['ForceMark'] == true)
    3939    {
    4040      // Mark member subnets
     
    7272    // Divide rules by subnet number
    7373    $DbResult = $this->System->Database->query('SELECT `Id`, `Name`, `AddressRange`, `Mask` FROM `NetworkSubnet` WHERE `Member` IS NULL');
    74     while($Subnet = $DbResult->fetch_assoc())
     74    while ($Subnet = $DbResult->fetch_assoc())
    7575    {
    7676      $NewAddress = new NetworkAddressIPv4();
     
    8484        'LEFT JOIN `Subject` ON `Subject`.`Id` = `Member`.`Subject` '.
    8585        'WHERE `Member`.`Blocked` = 0');
    86     while($Member = $DbResult->fetch_assoc())
     86    while ($Member = $DbResult->fetch_assoc())
    8787    {
    8888      $Member['Name'] = RouterOSIdent($Member['Name'].'-'.$Member['Id'] );
     
    9090
    9191      $DbResult2 = $this->System->Database->select('NetworkDevice', '*', '`Used` = 1 AND `Member` = '.$Member['Id']);
    92       while($Device = $DbResult2->fetch_assoc())
     92      while ($Device = $DbResult2->fetch_assoc())
    9393      {
    9494        $DbResult3 = $this->Database->select('NetworkInterface', '*', '`Device` = '.$Device['Id'].' AND `LocalIP` != ""');
    95         while($Interface = $DbResult3->fetch_assoc())
     95        while ($Interface = $DbResult3->fetch_assoc())
    9696        {
    9797          $Name = $Device['Name'];
    98           if($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
     98          if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
    9999          $Name = RouterOSIdent($Name);
    100100          echo($Name.', ');
     
    107107
    108108      $DbResult2 = $this->Database->select('NetworkSubnet', '*', '(`Member`='.$Member['Id'].') AND (AddressRange != "")');
    109       while($Subnet = $DbResult2->fetch_assoc())
     109      while ($Subnet = $DbResult2->fetch_assoc())
    110110      {
    111111        $Subnet['Name'] = RouterOSIdent('subnet-'.$Subnet['Name']);
     
    114114        $NewAddress->AddressFromString($Subnet['AddressRange']);
    115115        $NewAddress->Prefix = $Subnet['Mask'];
    116         if($Subnet['Member'] != 0) $ForceMark = true;
     116        if ($Subnet['Member'] != 0) $ForceMark = true;
    117117        else $ForceMark = false;
    118118        echo($ForceMark.', ');
     
    169169    $DbResult = $this->System->Database->query('SELECT `Id`, `Name`, `AddressRangeIPv6`, `MaskIPv6` FROM `NetworkSubnet` '.
    170170      'WHERE (`Member` IS NULL) AND (`AddressRangeIPv6` != "")');
    171     while($Subnet = $DbResult->fetch_assoc())
     171    while ($Subnet = $DbResult->fetch_assoc())
    172172    {
    173173      $NewAddress = new NetworkAddressIPv6();
     
    181181        'LEFT JOIN `Subject` ON `Subject`.`Id` = `Member`.`Subject` '.
    182182        'WHERE `Member`.`Blocked` = 0');
    183     while($Member = $DbResult->fetch_assoc())
     183    while ($Member = $DbResult->fetch_assoc())
    184184    {
    185185      $Member['Name'] = RouterOSIdent($Member['Name'].'-'.$Member['Id'] );
     
    187187
    188188      $DbResult2 = $this->System->Database->select('NetworkDevice', '*', '`Used` = 1 AND `Member` = '.$Member['Id']);
    189       while($Device = $DbResult2->fetch_assoc())
     189      while ($Device = $DbResult2->fetch_assoc())
    190190      {
    191191        $DbResult3 = $this->Database->select('NetworkInterface', '*', '`Device` = '.$Device['Id'].' AND `IPv6` != ""');
    192         while($Interface = $DbResult3->fetch_assoc())
     192        while ($Interface = $DbResult3->fetch_assoc())
    193193        {
    194194          $Name = $Device['Name'];
    195           if($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
     195          if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
    196196          $Name = RouterOSIdent($Name);
    197197          echo($Name.', ');
     
    204204
    205205      $DbResult2 = $this->Database->select('NetworkSubnet', '*', '(`Member`='.$Member['Id'].') AND (AddressRangeIPv6 != "")');
    206       while($Subnet = $DbResult2->fetch_assoc())
     206      while ($Subnet = $DbResult2->fetch_assoc())
    207207      {
    208208        $Subnet['Name'] = RouterOSIdent('subnet-'.$Subnet['Name']);
     
    211211        $NewAddress->AddressFromString($Subnet['AddressRangeIPv6']);
    212212        $NewAddress->Prefix = $Subnet['MaskIPv6'];
    213         if($Subnet['Member'] != 0) $ForceMark = true;
     213        if ($Subnet['Member'] != 0) $ForceMark = true;
    214214        else $ForceMark = false;
    215215        echo($ForceMark.', ');
Note: See TracChangeset for help on using the changeset viewer.