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

    r869 r873  
    4848  function CheckName($Name, &$UsedNames)
    4949  {
    50     if(in_array($Name, $UsedNames)) die("\n".'Duplicate name: '.$Name);
     50    if (in_array($Name, $UsedNames)) die("\n".'Duplicate name: '.$Name);
    5151      else $UsedNames[] = $Name;
    5252  }
     
    189189    $DbResult = $this->Database->query('SELECT `Member`.*, `Subject`.`Name` FROM `Member` '.
    190190      'LEFT JOIN `Subject` ON `Subject`.`Id` = `Member`.`Subject` WHERE `Member`.`Blocked`=0');
    191     while($Member = $DbResult->fetch_assoc())
     191    while ($Member = $DbResult->fetch_assoc())
    192192    {
    193193      $ServiceIndex = 1;
     
    198198        'WHERE (`ServiceCustomerRel`.`Customer` = '.$Member['Id'].') AND (`ServiceCustomerRel`.`ChangeAction` IS NULL) '.
    199199        'AND (`Service`.`InternetSpeedMax` > 0) AND (`Service`.`InternetSpeedMin` > 0)');
    200       while($Service = $DbResult4->fetch_assoc())
     200      while ($Service = $DbResult4->fetch_assoc())
    201201      {
    202202        echo('Služba '.$Service['Name'].': ');
     
    231231        $Row = $DbResult2->fetch_row();
    232232        $HostCount = $Row[0];
    233         if($HostCount > 0)
     233        if ($HostCount > 0)
    234234        {
    235235          $HostSpeedIn = round($SpeedIn / $HostCount);
     
    242242
    243243        $DbResult2 = $this->Database->select('NetworkDevice', '*', $Filter);
    244         while($Device = $DbResult2->fetch_assoc())
     244        while ($Device = $DbResult2->fetch_assoc())
    245245        {
    246246          $DbResult3 = $this->Database->select('NetworkInterface', '*', '`Device` = '.$Device['Id'].' AND `LocalIP` != ""');
    247           while($Interface = $DbResult3->fetch_assoc())
     247          while ($Interface = $DbResult3->fetch_assoc())
    248248          {
    249249            $DeviceName = $Device['Name'];
    250             if($Interface['Name'] != '') $DeviceName .= '-'.$Interface['Name'];
     250            if ($Interface['Name'] != '') $DeviceName .= '-'.$Interface['Name'];
    251251            $DeviceName = RouterOSIdent($DeviceName);
    252252            echo($DeviceName.', ');
     
    258258
    259259        $DbResult2 = $this->Database->select('NetworkSubnet', '*', '`Service`='.$Service['RelId']);
    260         while($Subnet = $DbResult2->fetch_assoc())
     260        while ($Subnet = $DbResult2->fetch_assoc())
    261261        {
    262262          $SubnetName = RouterOSIdent('subnet-'.$Subnet['Name']);
     
    329329  {
    330330    $MinSpeed = 0;
    331     foreach($this->Devices[$DeviceId]['Childs'] as $DeviceChild)
     331    foreach ($this->Devices[$DeviceId]['Childs'] as $DeviceChild)
    332332    {
    333333      $this->UpdateMinSpeed($DeviceChild);
     
    335335    }
    336336    $this->Devices[$DeviceId]['MinSpeed'] = $MinSpeed;
    337     if($this->Devices[$DeviceId]['DeviceCount'] > 0)
     337    if ($this->Devices[$DeviceId]['DeviceCount'] > 0)
    338338      $this->Devices[$DeviceId]['MinSpeed'] += round($this->Devices[$DeviceId]['InternetSpeedMin'] / $this->Devices[$DeviceId]['DeviceCount']);
    339339  }
     
    349349      'LEFT JOIN `ServiceCustomerRel` ON `ServiceCustomerRel`.`Id`=`NetworkDevice`.`Service` '.
    350350      'LEFT JOIN `Service` ON `Service`.`Id` = `ServiceCustomerRel`.`Service`');
    351     while($Device = $DbResult->fetch_assoc())
     351    while ($Device = $DbResult->fetch_assoc())
    352352    {
    353353      $Device['Interfaces'] = array();
     
    364364    $Interfaces = array();
    365365    $DbResult = $this->Database->query('SELECT `Device`,`Name`,`Id` FROM `NetworkInterface`');
    366     while($Interface = $DbResult->fetch_assoc())
     366    while ($Interface = $DbResult->fetch_assoc())
    367367    {
    368368      $Interface['Links'] = array();
     
    376376      '`NetworkLink`.`Interface2`,`NetworkLinkType`.`MaxRealSpeed` FROM `NetworkLink` '.
    377377      'LEFT JOIN `NetworkLinkType` ON `NetworkLinkType`.`Id`=`NetworkLink`.`Type`');
    378     while($Link = $DbResult->fetch_assoc())
     378    while ($Link = $DbResult->fetch_assoc())
    379379    {
    380380      $Links[$Link['Id']] = $Link;
     
    388388    $this->Devices[$RootDeviceId]['Calculated'] = true;
    389389
    390     while(count($DevicesToCheck) > 0)
     390    while (count($DevicesToCheck) > 0)
    391391    {
    392392      //echo('Pass'."\n");
    393393      $NewDevicesToCheck = array();
    394       foreach($DevicesToCheck as $DeviceId)
     394      foreach ($DevicesToCheck as $DeviceId)
    395395      {
    396396        //echo($this->Devices[$DeviceId]['Name'].': ');
    397         foreach($this->Devices[$DeviceId]['Interfaces'] as $InterfaceId)
     397        foreach ($this->Devices[$DeviceId]['Interfaces'] as $InterfaceId)
    398398        {
    399           foreach($Interfaces[$InterfaceId]['Links'] as $LinkId)
     399          foreach ($Interfaces[$InterfaceId]['Links'] as $LinkId)
    400400          {
    401401            $Link = $Links[$LinkId];
    402402            $Interface2Id = $Link['Interface1'];
    403             if($Interface2Id == $InterfaceId) $Interface2Id = $Links[$LinkId]['Interface2'];
     403            if ($Interface2Id == $InterfaceId) $Interface2Id = $Links[$LinkId]['Interface2'];
    404404
    405405            $Device2Id = $Interfaces[$Interface2Id]['Device'];
    406             if($this->Devices[$Device2Id]['Calculated'] == false)
     406            if ($this->Devices[$Device2Id]['Calculated'] == false)
    407407            {
    408408              $this->Devices[$Device2Id]['Calculated'] = true;
    409409              $NewMaxSpeed = $this->Devices[$DeviceId]['MaxSpeed'];
    410               if($NewMaxSpeed > $Link['MaxRealSpeed'])
     410              if ($NewMaxSpeed > $Link['MaxRealSpeed'])
    411411                $NewMaxSpeed = $Link['MaxRealSpeed'];
    412412              //echo($this->Devices[$Device2Id]['Name'].' '.$Device2Id.', ');
     
    431431
    432432    echo('Not linked network devices: ');
    433     foreach($this->Devices as $Device)
    434     {
    435       if($Device['MaxSpeed'] == 0) echo($Device['Name'].', ');
     433    foreach ($this->Devices as $Device)
     434    {
     435      if ($Device['MaxSpeed'] == 0) echo($Device['Name'].', ');
    436436    }
    437437    echo("\n");
     
    455455    $DbResult3 = $this->Database->select('NetworkInterface', '*', '`Device` = '.$DeviceId.' AND `LocalIP` != ""');
    456456    $IntCount = $DbResult3->num_rows;
    457     while($Interface = $DbResult3->fetch_assoc())
     457    while ($Interface = $DbResult3->fetch_assoc())
    458458    {
    459459      $InterfaceName = $Device['Name'];
    460       if($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name'];
     460      if ($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name'];
    461461        else $InterfaceName .= '-';
    462462      $InterfaceName = RouterOSIdent($InterfaceName);
     
    469469
    470470    // Process childs
    471     foreach($Device['Childs'] as $DeviceChild)
     471    foreach ($Device['Childs'] as $DeviceChild)
    472472    {
    473473      $this->BuildQueueItems($DeviceChild, $LimitDevice);
     
    505505
    506506    $DbResult = $this->Database->select('Service', '*', '(`ChangeAction` IS NULL) AND (`Id`='.TARIFF_FREE.')');
    507     if($DbResult->num_rows == 1)
     507    if ($DbResult->num_rows == 1)
    508508    {
    509509      $Service = $DbResult->fetch_array();
Note: See TracChangeset for help on using the changeset viewer.