Changeset 873 for trunk/Modules/NetworkConfigRouterOS/Generators/Common.php
- Timestamp:
- Apr 6, 2020, 11:17:40 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/NetworkConfigRouterOS/Generators/Common.php
r870 r873 6 6 7 7 $DbResult = $Database->query('SELECT `Id` FROM `NetworkMark` WHERE `Comment`="'.$Comment.'"'); 8 if ($DbResult->num_rows > 0)8 if ($DbResult->num_rows > 0) 9 9 { 10 10 $DbRow = $DbResult->fetch_assoc(); 11 return ($DbRow['Id']);11 return ($DbRow['Id']); 12 12 } else 13 13 { 14 14 $DbResult = $Database->query('INSERT INTO `NetworkMark` (`Comment`) VALUES ("'.$Comment.'")'); 15 return ($Database->insert_id);15 return ($Database->insert_id); 16 16 } 17 17 } … … 22 22 23 23 $DbResult = $Database->query('SELECT `Id` FROM `NetworkMangleSubgroup` WHERE `AddressRange`="'.$AddressRange.'"'); 24 if ($DbResult->num_rows > 0)24 if ($DbResult->num_rows > 0) 25 25 { 26 26 $DbRow = $DbResult->fetch_assoc(); 27 return ($DbRow['Id']);27 return ($DbRow['Id']); 28 28 } else 29 29 { 30 30 $DbResult = $Database->query('INSERT INTO `NetworkMangleSubgroup` (`AddressRange`) VALUES ("'.$AddressRange.'")'); 31 return ($Database->insert_id);31 return ($Database->insert_id); 32 32 } 33 33 } … … 38 38 39 39 $Found = false; 40 foreach ($Tree['Items'] as $Index => $Node)40 foreach ($Tree['Items'] as $Index => $Node) 41 41 { 42 if ($Node['Address']->Contain($Address))42 if ($Node['Address']->Contain($Address)) 43 43 { 44 44 InsertToAddressTreeIPv4($Tree['Items'][$Index], $Address, $Name, true); … … 46 46 } 47 47 } 48 if ($Found == false)48 if ($Found == false) 49 49 { 50 if ($InterSubnets and ($Tree['Address']->Prefix < $Config['MainRouter']['MangleRuleSubgroupMinPrefix']) and50 if ($InterSubnets and ($Tree['Address']->Prefix < $Config['MainRouter']['MangleRuleSubgroupMinPrefix']) and 51 51 ($Address->Prefix > ($Tree['Address']->Prefix + 1))) 52 52 { … … 62 62 // Should be existed items placed under new node? 63 63 $Found = false; 64 foreach ($Tree['Items'] as $Index => $Node)64 foreach ($Tree['Items'] as $Index => $Node) 65 65 { 66 if (($Node['Address']->Address == $NewNode['Address']->Address) and66 if (($Node['Address']->Address == $NewNode['Address']->Address) and 67 67 ($Node['Address']->Prefix == $NewNode['Address']->Prefix)) $Found = true; 68 68 69 if ($Address->Contain($Node['Address']))69 if ($Address->Contain($Node['Address'])) 70 70 { 71 71 $NewNode['Items'][] = $Node; … … 73 73 } 74 74 } 75 if ($Found == false) $Tree['Items'][] = $NewNode;75 if ($Found == false) $Tree['Items'][] = $NewNode; 76 76 } 77 77 } … … 83 83 84 84 $Found = false; 85 foreach ($Tree['Items'] as $Index => $Node)85 foreach ($Tree['Items'] as $Index => $Node) 86 86 { 87 if ($Node['Address']->Contain($Address))87 if ($Node['Address']->Contain($Address)) 88 88 { 89 89 InsertToAddressTreeIPv6($Tree['Items'][$Index], $Address, $Name, true); … … 91 91 } 92 92 } 93 if ($Found == false)93 if ($Found == false) 94 94 { 95 if ($InterSubnets and ($Tree['Address']->Prefix < $Config['MainRouter']['MangleRuleSubgroupMinPrefix']) and95 if ($InterSubnets and ($Tree['Address']->Prefix < $Config['MainRouter']['MangleRuleSubgroupMinPrefix']) and 96 96 ($Address->Prefix > ($Tree['Address']->Prefix + 1))) 97 97 { … … 107 107 // Should be existed items placed under new node? 108 108 $Found = false; 109 foreach ($Tree['Items'] as $Index => $Node)109 foreach ($Tree['Items'] as $Index => $Node) 110 110 { 111 if (($Node['Address']->Address == $NewNode['Address']->Address) and111 if (($Node['Address']->Address == $NewNode['Address']->Address) and 112 112 ($Node['Address']->Prefix == $NewNode['Address']->Prefix)) $Found = true; 113 113 114 if ($Address->Contain($Node['Address']))114 if ($Address->Contain($Node['Address'])) 115 115 { 116 116 $NewNode['Items'][] = $Node; … … 118 118 } 119 119 } 120 if ($Found == false) $Tree['Items'][] = $NewNode;120 if ($Found == false) $Tree['Items'][] = $NewNode; 121 121 } 122 122 } … … 126 126 { 127 127 echo(str_repeat(' ', $Indent).$Node['Address']->AddressToString().'/'.$Node['Address']->Prefix.' '.$Node['Name']."\n"); 128 foreach ($Node['Items'] as $Index => $Item)128 foreach ($Node['Items'] as $Index => $Item) 129 129 { 130 130 ShowSubnetNode($Item, $Indent + 1);
Note:
See TracChangeset
for help on using the changeset viewer.