Changeset 873 for trunk/Modules/NetworkConfigRouterOS/Generators/Queue.php
- Timestamp:
- Apr 6, 2020, 11:17:40 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/NetworkConfigRouterOS/Generators/Queue.php
r869 r873 48 48 function CheckName($Name, &$UsedNames) 49 49 { 50 if (in_array($Name, $UsedNames)) die("\n".'Duplicate name: '.$Name);50 if (in_array($Name, $UsedNames)) die("\n".'Duplicate name: '.$Name); 51 51 else $UsedNames[] = $Name; 52 52 } … … 189 189 $DbResult = $this->Database->query('SELECT `Member`.*, `Subject`.`Name` FROM `Member` '. 190 190 'LEFT JOIN `Subject` ON `Subject`.`Id` = `Member`.`Subject` WHERE `Member`.`Blocked`=0'); 191 while ($Member = $DbResult->fetch_assoc())191 while ($Member = $DbResult->fetch_assoc()) 192 192 { 193 193 $ServiceIndex = 1; … … 198 198 'WHERE (`ServiceCustomerRel`.`Customer` = '.$Member['Id'].') AND (`ServiceCustomerRel`.`ChangeAction` IS NULL) '. 199 199 'AND (`Service`.`InternetSpeedMax` > 0) AND (`Service`.`InternetSpeedMin` > 0)'); 200 while ($Service = $DbResult4->fetch_assoc())200 while ($Service = $DbResult4->fetch_assoc()) 201 201 { 202 202 echo('Služba '.$Service['Name'].': '); … … 231 231 $Row = $DbResult2->fetch_row(); 232 232 $HostCount = $Row[0]; 233 if ($HostCount > 0)233 if ($HostCount > 0) 234 234 { 235 235 $HostSpeedIn = round($SpeedIn / $HostCount); … … 242 242 243 243 $DbResult2 = $this->Database->select('NetworkDevice', '*', $Filter); 244 while ($Device = $DbResult2->fetch_assoc())244 while ($Device = $DbResult2->fetch_assoc()) 245 245 { 246 246 $DbResult3 = $this->Database->select('NetworkInterface', '*', '`Device` = '.$Device['Id'].' AND `LocalIP` != ""'); 247 while ($Interface = $DbResult3->fetch_assoc())247 while ($Interface = $DbResult3->fetch_assoc()) 248 248 { 249 249 $DeviceName = $Device['Name']; 250 if ($Interface['Name'] != '') $DeviceName .= '-'.$Interface['Name'];250 if ($Interface['Name'] != '') $DeviceName .= '-'.$Interface['Name']; 251 251 $DeviceName = RouterOSIdent($DeviceName); 252 252 echo($DeviceName.', '); … … 258 258 259 259 $DbResult2 = $this->Database->select('NetworkSubnet', '*', '`Service`='.$Service['RelId']); 260 while ($Subnet = $DbResult2->fetch_assoc())260 while ($Subnet = $DbResult2->fetch_assoc()) 261 261 { 262 262 $SubnetName = RouterOSIdent('subnet-'.$Subnet['Name']); … … 329 329 { 330 330 $MinSpeed = 0; 331 foreach ($this->Devices[$DeviceId]['Childs'] as $DeviceChild)331 foreach ($this->Devices[$DeviceId]['Childs'] as $DeviceChild) 332 332 { 333 333 $this->UpdateMinSpeed($DeviceChild); … … 335 335 } 336 336 $this->Devices[$DeviceId]['MinSpeed'] = $MinSpeed; 337 if ($this->Devices[$DeviceId]['DeviceCount'] > 0)337 if ($this->Devices[$DeviceId]['DeviceCount'] > 0) 338 338 $this->Devices[$DeviceId]['MinSpeed'] += round($this->Devices[$DeviceId]['InternetSpeedMin'] / $this->Devices[$DeviceId]['DeviceCount']); 339 339 } … … 349 349 'LEFT JOIN `ServiceCustomerRel` ON `ServiceCustomerRel`.`Id`=`NetworkDevice`.`Service` '. 350 350 'LEFT JOIN `Service` ON `Service`.`Id` = `ServiceCustomerRel`.`Service`'); 351 while ($Device = $DbResult->fetch_assoc())351 while ($Device = $DbResult->fetch_assoc()) 352 352 { 353 353 $Device['Interfaces'] = array(); … … 364 364 $Interfaces = array(); 365 365 $DbResult = $this->Database->query('SELECT `Device`,`Name`,`Id` FROM `NetworkInterface`'); 366 while ($Interface = $DbResult->fetch_assoc())366 while ($Interface = $DbResult->fetch_assoc()) 367 367 { 368 368 $Interface['Links'] = array(); … … 376 376 '`NetworkLink`.`Interface2`,`NetworkLinkType`.`MaxRealSpeed` FROM `NetworkLink` '. 377 377 'LEFT JOIN `NetworkLinkType` ON `NetworkLinkType`.`Id`=`NetworkLink`.`Type`'); 378 while ($Link = $DbResult->fetch_assoc())378 while ($Link = $DbResult->fetch_assoc()) 379 379 { 380 380 $Links[$Link['Id']] = $Link; … … 388 388 $this->Devices[$RootDeviceId]['Calculated'] = true; 389 389 390 while (count($DevicesToCheck) > 0)390 while (count($DevicesToCheck) > 0) 391 391 { 392 392 //echo('Pass'."\n"); 393 393 $NewDevicesToCheck = array(); 394 foreach ($DevicesToCheck as $DeviceId)394 foreach ($DevicesToCheck as $DeviceId) 395 395 { 396 396 //echo($this->Devices[$DeviceId]['Name'].': '); 397 foreach ($this->Devices[$DeviceId]['Interfaces'] as $InterfaceId)397 foreach ($this->Devices[$DeviceId]['Interfaces'] as $InterfaceId) 398 398 { 399 foreach ($Interfaces[$InterfaceId]['Links'] as $LinkId)399 foreach ($Interfaces[$InterfaceId]['Links'] as $LinkId) 400 400 { 401 401 $Link = $Links[$LinkId]; 402 402 $Interface2Id = $Link['Interface1']; 403 if ($Interface2Id == $InterfaceId) $Interface2Id = $Links[$LinkId]['Interface2'];403 if ($Interface2Id == $InterfaceId) $Interface2Id = $Links[$LinkId]['Interface2']; 404 404 405 405 $Device2Id = $Interfaces[$Interface2Id]['Device']; 406 if ($this->Devices[$Device2Id]['Calculated'] == false)406 if ($this->Devices[$Device2Id]['Calculated'] == false) 407 407 { 408 408 $this->Devices[$Device2Id]['Calculated'] = true; 409 409 $NewMaxSpeed = $this->Devices[$DeviceId]['MaxSpeed']; 410 if ($NewMaxSpeed > $Link['MaxRealSpeed'])410 if ($NewMaxSpeed > $Link['MaxRealSpeed']) 411 411 $NewMaxSpeed = $Link['MaxRealSpeed']; 412 412 //echo($this->Devices[$Device2Id]['Name'].' '.$Device2Id.', '); … … 431 431 432 432 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'].', '); 436 436 } 437 437 echo("\n"); … … 455 455 $DbResult3 = $this->Database->select('NetworkInterface', '*', '`Device` = '.$DeviceId.' AND `LocalIP` != ""'); 456 456 $IntCount = $DbResult3->num_rows; 457 while ($Interface = $DbResult3->fetch_assoc())457 while ($Interface = $DbResult3->fetch_assoc()) 458 458 { 459 459 $InterfaceName = $Device['Name']; 460 if ($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name'];460 if ($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name']; 461 461 else $InterfaceName .= '-'; 462 462 $InterfaceName = RouterOSIdent($InterfaceName); … … 469 469 470 470 // Process childs 471 foreach ($Device['Childs'] as $DeviceChild)471 foreach ($Device['Childs'] as $DeviceChild) 472 472 { 473 473 $this->BuildQueueItems($DeviceChild, $LimitDevice); … … 505 505 506 506 $DbResult = $this->Database->select('Service', '*', '(`ChangeAction` IS NULL) AND (`Id`='.TARIFF_FREE.')'); 507 if ($DbResult->num_rows == 1)507 if ($DbResult->num_rows == 1) 508 508 { 509 509 $Service = $DbResult->fetch_array();
Note:
See TracChangeset
for help on using the changeset viewer.