Changeset 317 for trunk/system
- Timestamp:
- Jul 15, 2011, 8:26:28 AM (13 years ago)
- Location:
- trunk/system
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/system/generators/firewall_mangle.php
r288 r317 23 23 24 24 // Divide rules by subnet number 25 $DbResult = $Database->query('SELECT `Id`, `Name`, `AddressRange`, `Mask` FROM `NetworkSubnet` WHERE Member=0');25 $DbResult = $Database->query('SELECT `Id`, `Name`, `AddressRange`, `Mask` FROM `NetworkSubnet` WHERE `Member` IS NULL'); 26 26 while($Subnet = $DbResult->fetch_assoc()) 27 27 { -
trunk/system/generators/firewall_nat.php
r315 r317 36 36 //$Items[] = array('chain' => 'inet-in', 'dst-address' => '172.16.1.1/30', 'action' => 'accept', 'comment' => 'Local_subnet'); 37 37 38 $DbResult = $Database->query('SELECT Member.*, Subject.Name FROM Member JOIN Subject ON Member.Subject = Subject.Id');38 $DbResult = $Database->query('SELECT `Member`.*, `Subject`.`Name` FROM `Member` JOIN `Subject` ON `Member`.`Subject` = `Subject`.`Id`'); 39 39 while($Member = $DbResult->fetch_assoc()) 40 40 { 41 41 echo($Member['Name'].': '); 42 42 // Hosts 43 $DbResult2 = $Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName, NetworkDevice.InboundNATPriority FROM NetworkInterface LEFT JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE (NetworkInterface.ExternalIP <> "") AND (NetworkDevice.Member = '.$Member['Id'].') AND (NetworkInterface.LocalIP != NetworkInterface.ExternalIP) ORDER BY id DESC'); 43 $DbResult2 = $Database->query('SELECT `NetworkInterface`.*, `NetworkDevice`.`Name` AS `DeviceName`, `NetworkDevice`.`InboundNATPriority` FROM `NetworkInterface`'. 44 ' LEFT JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` WHERE (`NetworkInterface`.`ExternalIP` <> "")'. 45 ' AND (`NetworkDevice`.`Member` = '.$Member['Id'].') AND (`NetworkInterface`.`LocalIP` != `NetworkInterface`.`ExternalIP`) ORDER BY `id` DESC'); 44 46 while($Interface = $DbResult2->fetch_assoc()) 45 47 { … … 60 62 61 63 // Subnets 62 $DbResult2 = $Database->select('NetworkSubnet', '*', ' Member='.$Member['Id']);64 $DbResult2 = $Database->select('NetworkSubnet', '*', '`Member`='.$Member['Id']); 63 65 while($Subnet = $DbResult2->fetch_assoc()) 64 66 { -
trunk/system/generators/netwatch.php
r301 r317 23 23 $I = explode('.', $Subnet['AddressRange']); 24 24 $I = $I[2]; 25 $DbResult2 = $Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM NetworkInterface LEFT JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE CompareNetworkPrefix(INET_ATON(LocalIP), INET_ATON("'.$Subnet['AddressRange'].'"), '.$Subnet['Mask'].') AND (NetworkDevice.Used = 1) ORDER BY NetworkInterface.LocalIP'); 25 $DbResult2 = $Database->query('SELECT `NetworkInterface`.*, `NetworkDevice`.`Name` AS `DeviceName` FROM `NetworkInterface`'. 26 ' LEFT JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` WHERE CompareNetworkPrefix(INET_ATON(`LocalIP`), INET_ATON("'.$Subnet['AddressRange'].'"), '.$Subnet['Mask'].')'. 27 ' AND (`NetworkDevice`.`Used` = 1) ORDER BY `NetworkInterface`.`LocalIP`'); 26 28 while($Interface = $DbResult2->fetch_assoc()) 27 29 { -
trunk/system/generators/netwatch_import.php
r313 r317 6 6 include('common.php'); 7 7 $Path = array('tool', 'netwatch'); 8 $Period = 60; // every 60 seconds 8 9 9 $DbResult3 = $Database->query('SELECT * FROM `NetworkSubnet` WHERE `Member` = 0'); 10 while(1) 11 { 12 $StartTime = time(); 13 14 $DbResult3 = $Database->query('SELECT * FROM `NetworkSubnet` WHERE `Member` IS NULL'); 15 //echo($DbResult3->num_rows); 10 16 while($Subnet = $DbResult3->fetch_assoc()) 11 17 { … … 39 45 } 40 46 41 $DbResult = $Database->update('NetworkInterface', ' LocalIP= "'.$Properties['host'].'"', $Values);47 $DbResult = $Database->update('NetworkInterface', '`LocalIP` = "'.$Properties['host'].'"', $Values); 42 48 if($Online == 1) 43 49 { 44 $DbResult = $Database->select('NetworkInterface', 'Id', ' LocalIP= "'.$Properties['host'].'"');50 $DbResult = $Database->select('NetworkInterface', 'Id', '`LocalIP` = "'.$Properties['host'].'"'); 45 51 $DbRow = $DbResult->fetch_assoc(); 46 52 $InterfaceId = $DbRow['Id']; 47 $DbResult2 = $Database->select('NetworkInterfaceStat', '*', '( NetworkInterface="'.$InterfaceId.'") AND (Time= DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');48 if($DbResult2->num_rows == 0) $Database->query('REPLACE INTO NetworkInterfaceStat (NetworkInterface, Time) VALUES ("'.$InterfaceId.'", DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');49 $Database->query('UPDATE NetworkInterfaceStat SET PingCount = PingCount + 1 WHERE (NetworkInterface="'.$InterfaceId.'") AND (Time= DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');53 $DbResult2 = $Database->select('NetworkInterfaceStat', '*', '(`NetworkInterface`="'.$InterfaceId.'") AND (`Time` = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))'); 54 if($DbResult2->num_rows == 0) $Database->query('REPLACE INTO `NetworkInterfaceStat` (`NetworkInterface`, `Time`) VALUES ("'.$InterfaceId.'", DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))'); 55 $Database->query('UPDATE `NetworkInterfaceStat` SET `PingCount` = `PingCount` + 1 WHERE (`NetworkInterface`="'.$InterfaceId.'") AND (`Time` = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))'); 50 56 51 57 } … … 55 61 56 62 // Update device online state 57 $DbResult = $Database->select('NetworkDevice', 'Id', ' Used=1');63 $DbResult = $Database->select('NetworkDevice', 'Id', '`Used`=1'); 58 64 while($Device = $DbResult->fetch_assoc()) 59 65 { 60 $DbResult2 = $Database->select('NetworkInterface', 'SUM( Online)', 'Device='.$Device['Id']);66 $DbResult2 = $Database->select('NetworkInterface', 'SUM(`Online`) AS `SumOnline`', '`Device`='.$Device['Id']); 61 67 $DbRow = $DbResult2->fetch_array(); 62 if($DbRow['S UM(Online)'] > 0) $Online = 1; else $Online = 0;68 if($DbRow['SumOnline'] > 0) $Online = 1; else $Online = 0; 63 69 $Database->update('NetworkDevice', 'Id='.$Device['Id'], array('Online' => $Online)); 64 70 if($Online == 1) $Database->update('NetworkDevice', 'Id='.$Device['Id'], array('LastOnline' => 'NOW()')); 65 71 } 66 72 73 $EndTime = time(); 74 $Delay = $Period - ($EndTime - $StartTime); 75 if($Delay < 0) $Delay = 0; 76 77 echo('Waiting '.$Delay.' seconds...'."\n"); 78 sleep($Delay); 79 } 80 67 81 ?> -
trunk/system/generators/queue.php
r266 r317 69 69 $ItemsQueue[] = array('name' => $Member['Name'].'-in', 'limit-at' => $SpeedOut, 'max-limit' => $UserMaxSpeedOut, 'parent' => 'main-in'); 70 70 71 $DbResult2 = $Database->select('NetworkDevice', 'COUNT(*)', ' Used = 1 AND Member='.$Member['Id']);71 $DbResult2 = $Database->select('NetworkDevice', 'COUNT(*)', '(`Used` = 1) AND (`Member`='.$Member['Id'].')'); 72 72 $Row = $DbResult2->fetch_row(); 73 73 $HostCount = $Row[0]; -
trunk/system/routerboard.php
r301 r317 49 49 if($Commands != '') 50 50 { 51 $Output = array();52 51 $Commands = addslashes($Commands); 53 52 $Commands = str_replace('$', '\$', $Commands); 53 //$Commands = str_replace(' ', '\ ', $Commands); 54 54 $Command = $this->SSHPath.' -o ConnectTimeout='.$this->Timeout.' -l '.$this->UserName.' -i '.$this->PrivateKey.' '.$this->HostName.' "'.$Commands.'"'; 55 55 if($this->Debug) echo($Command); 56 $Output = array(); 56 57 exec($Command, $Output); 57 58 } else $Output = '';
Note:
See TracChangeset
for help on using the changeset viewer.