- Timestamp:
- Apr 6, 2020, 11:17:40 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/NetworkConfigRouterOS/Generators/FirewallMangle.php
r870 r873 7 7 global $InetInterface, $ItemsFirewall; 8 8 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) 12 12 { 13 13 // Hosts 14 14 $ParentSubnetId = GetSubgroupByRange($Node['Address']->AddressToString().'/'.$Node['Address']->Prefix); 15 15 $Address = $Item['Address']->AddressToString(); 16 if ($Item['Address']->Prefix != 32) $Address .= '/'.$Item['Address']->Prefix;16 if ($Item['Address']->Prefix != 32) $Address .= '/'.$Item['Address']->Prefix; 17 17 18 18 $PacketMark = GetMarkByComment($Item['Name'].'-out'); … … 28 28 29 29 $Address = $Item['Address']->AddressToString(); 30 if ($Item['Address']->Prefix != 32) $Address .= '/'.$Item['Address']->Prefix;30 if ($Item['Address']->Prefix != 32) $Address .= '/'.$Item['Address']->Prefix; 31 31 32 32 $ItemsFirewall[] = array('chain' => 'inet-'.$ParentSubnetId.'-out', 'src-address' => $Address, 'out-interface' => $InetInterface, 'action' => 'jump', 'jump-target' => 'inet-'.$SubnetId.'-out', 'comment' => $Item['Name'].'-out'); … … 36 36 } 37 37 } 38 if ($Node['ForceMark'] == true)38 if ($Node['ForceMark'] == true) 39 39 { 40 40 // Mark member subnets … … 72 72 // Divide rules by subnet number 73 73 $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()) 75 75 { 76 76 $NewAddress = new NetworkAddressIPv4(); … … 84 84 'LEFT JOIN `Subject` ON `Subject`.`Id` = `Member`.`Subject` '. 85 85 'WHERE `Member`.`Blocked` = 0'); 86 while ($Member = $DbResult->fetch_assoc())86 while ($Member = $DbResult->fetch_assoc()) 87 87 { 88 88 $Member['Name'] = RouterOSIdent($Member['Name'].'-'.$Member['Id'] ); … … 90 90 91 91 $DbResult2 = $this->System->Database->select('NetworkDevice', '*', '`Used` = 1 AND `Member` = '.$Member['Id']); 92 while ($Device = $DbResult2->fetch_assoc())92 while ($Device = $DbResult2->fetch_assoc()) 93 93 { 94 94 $DbResult3 = $this->Database->select('NetworkInterface', '*', '`Device` = '.$Device['Id'].' AND `LocalIP` != ""'); 95 while ($Interface = $DbResult3->fetch_assoc())95 while ($Interface = $DbResult3->fetch_assoc()) 96 96 { 97 97 $Name = $Device['Name']; 98 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];98 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 99 99 $Name = RouterOSIdent($Name); 100 100 echo($Name.', '); … … 107 107 108 108 $DbResult2 = $this->Database->select('NetworkSubnet', '*', '(`Member`='.$Member['Id'].') AND (AddressRange != "")'); 109 while ($Subnet = $DbResult2->fetch_assoc())109 while ($Subnet = $DbResult2->fetch_assoc()) 110 110 { 111 111 $Subnet['Name'] = RouterOSIdent('subnet-'.$Subnet['Name']); … … 114 114 $NewAddress->AddressFromString($Subnet['AddressRange']); 115 115 $NewAddress->Prefix = $Subnet['Mask']; 116 if ($Subnet['Member'] != 0) $ForceMark = true;116 if ($Subnet['Member'] != 0) $ForceMark = true; 117 117 else $ForceMark = false; 118 118 echo($ForceMark.', '); … … 169 169 $DbResult = $this->System->Database->query('SELECT `Id`, `Name`, `AddressRangeIPv6`, `MaskIPv6` FROM `NetworkSubnet` '. 170 170 'WHERE (`Member` IS NULL) AND (`AddressRangeIPv6` != "")'); 171 while ($Subnet = $DbResult->fetch_assoc())171 while ($Subnet = $DbResult->fetch_assoc()) 172 172 { 173 173 $NewAddress = new NetworkAddressIPv6(); … … 181 181 'LEFT JOIN `Subject` ON `Subject`.`Id` = `Member`.`Subject` '. 182 182 'WHERE `Member`.`Blocked` = 0'); 183 while ($Member = $DbResult->fetch_assoc())183 while ($Member = $DbResult->fetch_assoc()) 184 184 { 185 185 $Member['Name'] = RouterOSIdent($Member['Name'].'-'.$Member['Id'] ); … … 187 187 188 188 $DbResult2 = $this->System->Database->select('NetworkDevice', '*', '`Used` = 1 AND `Member` = '.$Member['Id']); 189 while ($Device = $DbResult2->fetch_assoc())189 while ($Device = $DbResult2->fetch_assoc()) 190 190 { 191 191 $DbResult3 = $this->Database->select('NetworkInterface', '*', '`Device` = '.$Device['Id'].' AND `IPv6` != ""'); 192 while ($Interface = $DbResult3->fetch_assoc())192 while ($Interface = $DbResult3->fetch_assoc()) 193 193 { 194 194 $Name = $Device['Name']; 195 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];195 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 196 196 $Name = RouterOSIdent($Name); 197 197 echo($Name.', '); … … 204 204 205 205 $DbResult2 = $this->Database->select('NetworkSubnet', '*', '(`Member`='.$Member['Id'].') AND (AddressRangeIPv6 != "")'); 206 while ($Subnet = $DbResult2->fetch_assoc())206 while ($Subnet = $DbResult2->fetch_assoc()) 207 207 { 208 208 $Subnet['Name'] = RouterOSIdent('subnet-'.$Subnet['Name']); … … 211 211 $NewAddress->AddressFromString($Subnet['AddressRangeIPv6']); 212 212 $NewAddress->Prefix = $Subnet['MaskIPv6']; 213 if ($Subnet['Member'] != 0) $ForceMark = true;213 if ($Subnet['Member'] != 0) $ForceMark = true; 214 214 else $ForceMark = false; 215 215 echo($ForceMark.', ');
Note:
See TracChangeset
for help on using the changeset viewer.