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

    r870 r873  
    66
    77  $DbResult = $Database->query('SELECT `Id` FROM `NetworkMark` WHERE `Comment`="'.$Comment.'"');
    8   if($DbResult->num_rows > 0)
     8  if ($DbResult->num_rows > 0)
    99  {
    1010    $DbRow = $DbResult->fetch_assoc();
    11     return($DbRow['Id']);
     11    return ($DbRow['Id']);
    1212  } else
    1313  {
    1414    $DbResult = $Database->query('INSERT INTO `NetworkMark` (`Comment`) VALUES ("'.$Comment.'")');
    15     return($Database->insert_id);
     15    return ($Database->insert_id);
    1616  }
    1717}
     
    2222
    2323  $DbResult = $Database->query('SELECT `Id` FROM `NetworkMangleSubgroup` WHERE `AddressRange`="'.$AddressRange.'"');
    24   if($DbResult->num_rows > 0)
     24  if ($DbResult->num_rows > 0)
    2525  {
    2626    $DbRow = $DbResult->fetch_assoc();
    27     return($DbRow['Id']);
     27    return ($DbRow['Id']);
    2828  } else
    2929  {
    3030    $DbResult = $Database->query('INSERT INTO `NetworkMangleSubgroup` (`AddressRange`) VALUES ("'.$AddressRange.'")');
    31     return($Database->insert_id);
     31    return ($Database->insert_id);
    3232  }
    3333}
     
    3838
    3939  $Found = false;
    40   foreach($Tree['Items'] as $Index => $Node)
     40  foreach ($Tree['Items'] as $Index => $Node)
    4141  {
    42     if($Node['Address']->Contain($Address))
     42    if ($Node['Address']->Contain($Address))
    4343    {
    4444      InsertToAddressTreeIPv4($Tree['Items'][$Index], $Address, $Name, true);
     
    4646    }
    4747  }
    48   if($Found == false)
     48  if ($Found == false)
    4949  {
    50     if($InterSubnets and ($Tree['Address']->Prefix < $Config['MainRouter']['MangleRuleSubgroupMinPrefix']) and
     50    if ($InterSubnets and ($Tree['Address']->Prefix < $Config['MainRouter']['MangleRuleSubgroupMinPrefix']) and
    5151    ($Address->Prefix > ($Tree['Address']->Prefix + 1)))
    5252    {
     
    6262      // Should be existed items placed under new node?
    6363      $Found = false;
    64       foreach($Tree['Items'] as $Index => $Node)
     64      foreach ($Tree['Items'] as $Index => $Node)
    6565      {
    66         if(($Node['Address']->Address == $NewNode['Address']->Address) and
     66        if (($Node['Address']->Address == $NewNode['Address']->Address) and
    6767        ($Node['Address']->Prefix == $NewNode['Address']->Prefix)) $Found = true;
    6868
    69         if($Address->Contain($Node['Address']))
     69        if ($Address->Contain($Node['Address']))
    7070        {
    7171          $NewNode['Items'][] = $Node;
     
    7373        }
    7474      }
    75       if($Found == false) $Tree['Items'][] = $NewNode;
     75      if ($Found == false) $Tree['Items'][] = $NewNode;
    7676    }
    7777  }
     
    8383
    8484  $Found = false;
    85   foreach($Tree['Items'] as $Index => $Node)
     85  foreach ($Tree['Items'] as $Index => $Node)
    8686  {
    87     if($Node['Address']->Contain($Address))
     87    if ($Node['Address']->Contain($Address))
    8888    {
    8989      InsertToAddressTreeIPv6($Tree['Items'][$Index], $Address, $Name, true);
     
    9191    }
    9292  }
    93   if($Found == false)
     93  if ($Found == false)
    9494  {
    95     if($InterSubnets and ($Tree['Address']->Prefix < $Config['MainRouter']['MangleRuleSubgroupMinPrefix']) and
     95    if ($InterSubnets and ($Tree['Address']->Prefix < $Config['MainRouter']['MangleRuleSubgroupMinPrefix']) and
    9696    ($Address->Prefix > ($Tree['Address']->Prefix + 1)))
    9797    {
     
    107107      // Should be existed items placed under new node?
    108108      $Found = false;
    109       foreach($Tree['Items'] as $Index => $Node)
     109      foreach ($Tree['Items'] as $Index => $Node)
    110110      {
    111         if(($Node['Address']->Address == $NewNode['Address']->Address) and
     111        if (($Node['Address']->Address == $NewNode['Address']->Address) and
    112112        ($Node['Address']->Prefix == $NewNode['Address']->Prefix)) $Found = true;
    113113
    114         if($Address->Contain($Node['Address']))
     114        if ($Address->Contain($Node['Address']))
    115115        {
    116116          $NewNode['Items'][] = $Node;
     
    118118        }
    119119      }
    120       if($Found == false) $Tree['Items'][] = $NewNode;
     120      if ($Found == false) $Tree['Items'][] = $NewNode;
    121121    }
    122122  }
     
    126126{
    127127  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)
    129129  {
    130130    ShowSubnetNode($Item, $Indent + 1);
Note: See TracChangeset for help on using the changeset viewer.