- Timestamp:
- Dec 30, 2011, 2:22:10 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/database.php
r329 r336 63 63 } else 64 64 { 65 $this->Error = $this->errorInfo[2]; 65 $this->Error = $this->PDO->errorInfo(); 66 $this->Error = $this->Error[2]; 66 67 if(($this->Error != '') and ($this->ShowSQLError == true)) 67 68 echo('<div><strong>SQL Error: </strong>'.$this->Error.'<br />'.$Query.'</div>'); -
trunk/system/generators/netwatch_import.php
r335 r336 12 12 $StartTime = time(); 13 13 14 $DbResult3 = $Database->query('SELECT DISTINCT (`DHCP`), * FROM `NetworkSubnet` WHERE (`Configure` = 1) AND (`Member` IS NULL)'); 15 //echo($DbResult3->num_rows); 16 while($Subnet = $DbResult3->fetch_assoc()) 17 { 18 echo($Subnet['AddressRange'].'/'.$Subnet['Mask'].' on router '.$Subnet['DHCP']."\n"); 19 $Routerboard = new Routerboard(); 20 $Routerboard->UserName = $Config['MainRouter']['UserName']; 21 $Routerboard->Timeout = $Config['MainRouter']['ConnectTimeout']; 22 $Routerboard->HostName = $Subnet['DHCP']; 23 $List = $Routerboard->ListGetPrint($Path, array('host', 'status')); 24 foreach($List as $Properties) 14 $DbResult3 = $Database->query('SELECT DHCP, AddressRange, Mask FROM `NetworkSubnet` WHERE (`Configure` = 1) AND (`Member` IS NULL) GROUP BY DHCP'); 15 //echo($DbResult3->num_rows); 16 while($Subnet = $DbResult3->fetch_assoc()) 25 17 { 26 //echo($Properties['host'].', '); 27 if($Properties['status'] == 'up') 18 echo($Subnet['AddressRange'].'/'.$Subnet['Mask'].' on router '.$Subnet['DHCP']."\n"); 19 $Routerboard = new Routerboard(); 20 $Routerboard->UserName = $Config['MainRouter']['UserName']; 21 $Routerboard->Timeout = $Config['MainRouter']['ConnectTimeout']; 22 $Routerboard->HostName = $Subnet['DHCP']; 23 $List = $Routerboard->ListGetPrint($Path, array('host', 'status')); 24 foreach($List as $Properties) 28 25 { 29 $Online = 1; 30 $Values = array('Online' => $Online, 'LastOnline' => 'NOW()'); 31 //echo($Properties['host']." up\n"); 32 } else 33 { 34 $Online = 0; 35 $Values = array('Online' => $Online); 36 //echo($Properties['host']." down\n"); 26 //echo($Properties['host'].', '); 27 if($Properties['status'] == 'up') 28 { 29 $Online = 1; 30 $Values = array('Online' => $Online, 'LastOnline' => 'NOW()'); 31 //echo($Properties['host']." up\n"); 32 } else 33 { 34 $Online = 0; 35 $Values = array('Online' => $Online); 36 //echo($Properties['host']." down\n"); 37 } 38 39 $DbResult = $Database->update('NetworkInterface', '`LocalIP` = "'.$Properties['host'].'"', $Values); 37 40 } 41 } 38 42 39 $DbResult = $Database->update('NetworkInterface', '`LocalIP` = "'.$Properties['host'].'"', $Values); 43 // Update device online state 44 $DbResult = $Database->select('NetworkDevice', 'Id', '`Used`=1'); 45 while($Device = $DbResult->fetch_assoc()) 46 { 47 $DbResult2 = $Database->select('NetworkInterface', 'SUM(`Online`) AS `SumOnline`', '`Device`='.$Device['Id']); 48 $DbRow = $DbResult2->fetch_array(); 49 if($DbRow['SumOnline'] > 0) $Online = 1; 50 else $Online = 0; 51 $Values = array('Online' => $Online); 52 if($Online == 1) $Values['LastOnline'] = 'NOW()'; 53 $Database->update('NetworkDevice', 'Id='.$Device['Id'], $Values); 40 54 } 41 }42 55 43 // Update device online state 44 $DbResult = $Database->select('NetworkDevice', 'Id', '`Used`=1'); 45 while($Device = $DbResult->fetch_assoc()) 46 { 47 $DbResult2 = $Database->select('NetworkInterface', 'SUM(`Online`) AS `SumOnline`', '`Device`='.$Device['Id']); 48 $DbRow = $DbResult2->fetch_array(); 49 if($DbRow['SumOnline'] > 0) $Online = 1; 50 else $Online = 0; 51 $Values = array('Online' => $Online); 52 if($Online == 1) $Values['LastOnline'] = 'NOW()'; 53 $Database->update('NetworkDevice', 'Id='.$Device['Id'], $Values); 54 } 56 // Update interface online statistics 57 $DbResult = $Database->select('NetworkInterface', 'Id', '`Online` = 1'); 58 while($Interface = $DbResult->fetch_assoc()) 59 { 60 $DbResult2 = $Database->select('NetworkInterfaceStat', '*', '(`NetworkInterface`="'.$Interface['Id'].'") AND (`Time` = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))'); 61 if($DbResult2->num_rows == 0) $Database->query('REPLACE INTO `NetworkInterfaceStat` (`NetworkInterface`, `Time`, `PingCount`) VALUES ("'.$Interface['Id'].'", DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"), 1)'); 62 else $Database->query('UPDATE `NetworkInterfaceStat` SET `PingCount` = `PingCount` + 1 WHERE (`NetworkInterface`="'.$Interface['Id'].'") AND (`Time` = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))'); 63 } 55 64 56 65 $EndTime = time(); … … 62 71 } 63 72 64 // Update interface online statistics65 $DbResult = $Database->select('NetworkInterface', 'Id', '`Online` = 1');66 while($Interface = $DbResult->fetch_assoc())67 {68 $DbResult2 = $Database->select('NetworkInterfaceStat', '*', '(`NetworkInterface`="'.$Interface['Id'].'") AND (`Time` = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');69 if($DbResult2->num_rows == 0) $Database->query('REPLACE INTO `NetworkInterfaceStat` (`NetworkInterface`, `Time`, `PingCount`) VALUES ("'.$Interface['Id'].'", DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))', '1');70 $Database->query('UPDATE `NetworkInterfaceStat` SET `PingCount` = `PingCount` + 1 WHERE (`NetworkInterface`="'.$Interface['Id'].'") AND (`Time` = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');71 }72 73 73 ?> -
trunk/system/generators/queue.php
r317 r336 38 38 $InInterface = 'ifb0'; 39 39 $InetInterface = $Config['MainRouter']['InetInterface']; 40 $FreeInetSpeed = $Finance->Tariffs[ 6]['SpeedMax'];40 $FreeInetSpeed = $Finance->Tariffs[7]['SpeedMax']; 41 41 42 42 $ItemsQueue = array(); … … 116 116 } 117 117 118 //print_r($Items Firewall);118 //print_r($ItemsQueue); 119 119 $Routerboard->ListUpdate($PathQueue, array('name', 'limit-at', 'max-limit', 'parent', 'packet-mark'), $ItemsQueue, array(), true); 120 120
Note:
See TracChangeset
for help on using the changeset viewer.