Changeset 522
- Timestamp:
- Apr 15, 2013, 11:08:49 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 8 added
- 1 deleted
- 3 edited
- 18 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Global.php
r521 r522 1 1 <?php 2 3 $Revision =4 2 5 3 /* @var $System System */ … … 23 21 include_once(dirname(__FILE__).'/Form/Form.php'); 24 22 include_once(dirname(__FILE__).'/../form_classes.php'); 25 26 23 27 24 // Application modules 28 25 include_once(dirname(__FILE__).'/../Modules/Error/Error.php'); … … 44 41 include_once(dirname(__FILE__).'/../Modules/Meals/Meals.php'); 45 42 include_once(dirname(__FILE__).'/../Modules/NetworkTopology/NetworkTopology.php'); 43 include_once(dirname(__FILE__).'/../Modules/NetworkConfig/NetworkConfig.php'); 44 include_once(dirname(__FILE__).'/../Modules/NetworkConfigLinux/NetworkConfigLinux.php'); 45 include_once(dirname(__FILE__).'/../Modules/NetworkConfigRouterOS/NetworkConfigRouterOS.php'); 46 46 47 47 class System extends Module -
trunk/Common/Version.php
r521 r522 1 1 <?php 2 2 3 $Revision = 52 1; // Subversion revision3 $Revision = 522; // Subversion revision 4 4 $DatabaseRevision = 517; // SQL structure revision 5 $ReleaseTime = '2013-04-1 4';5 $ReleaseTime = '2013-04-15'; 6 6 7 7 ?> -
trunk/Modules/NetworkConfig/Generate.php
r521 r522 2 2 3 3 if(isset($_SERVER['REMOTE_ADDR'])) die(); 4 include('../../Common/Global.php'); 5 $Database = &$System->Database; 4 include_once(dirname(__FILE__).'/../../Common/Global.php'); 6 5 7 6 $Now = time(); 8 $DbResult = $ Database->select('NetworkConfiguration', '*, UNIX_TIMESTAMP(LastTime)', '(Changed = 1) AND (Enabled = 1)');7 $DbResult = $System->Database->select('NetworkConfiguration', '*, UNIX_TIMESTAMP(LastTime)', '(Changed = 1) AND (Enabled = 1)'); 9 8 while($Service = $DbResult->fetch_assoc()) 10 9 { 11 10 if($Service['UNIX_TIMESTAMP(LastTime)'] < (time() - $Service['Period'])) 12 11 { 13 $ Database->update('NetworkConfiguration', 'Id='.$Service['Id'], array('Changed' => 2));12 $System->Database->update('NetworkConfiguration', 'Id='.$Service['Id'], array('Changed' => 2)); 14 13 $ExecutionStart = time(); 15 14 //echo($Service['Caption'].'...'); … … 25 24 //echo("Done\n"); 26 25 $ExecutionTime = time() - $ExecutionStart; 27 $ Database->update('NetworkConfiguration', 'Id='.$Service['Id'], array('Changed' => 0, 'LastTime' => 'NOW()', 'ExecutionTime' => $ExecutionTime));28 $ Database->update('NetworkConfiguration', 'Id='.$Service['Id'], array('Log' => implode("\n", $Output)));26 $System->Database->update('NetworkConfiguration', 'Id='.$Service['Id'], array('Changed' => 0, 'LastTime' => 'NOW()', 'ExecutionTime' => $ExecutionTime)); 27 $System->Database->update('NetworkConfiguration', 'Id='.$Service['Id'], array('Log' => implode("\n", $Output))); 29 28 } 30 29 } -
trunk/Modules/NetworkConfigRouterOS/Generators/AddressPortability.php
r521 r522 2 2 3 3 if(isset($_SERVER['REMOTE_ADDR'])) die(); 4 include ('../../Common/Global.php');5 include ('../routerboard.php');4 include_once(dirname(__FILE__).'/../../../Common/Global.php'); 5 include_once(dirname(__FILE__).'/../Routerboard.php'); 6 6 $Path = array('ip', 'dhcp-server', 'lease'); 7 7 … … 18 18 $Routerboard->Timeout = $Config['MainRouter']['ConnectTimeout']; 19 19 20 $DbResult3 = $ Database->query('SELECT * FROM `NetworkSubnet` WHERE `Member` = 0 GROUP BY `DHCP`');20 $DbResult3 = $System->Database->query('SELECT * FROM `NetworkSubnet` WHERE `Member` = 0 GROUP BY `DHCP`'); 21 21 while($Subnet = $DbResult3->fetch_assoc()) 22 22 { … … 31 31 $Properties['expires-after'] = time() - (24 * 3600 - ConvertExpireTime2($Properties['expires-after'])); 32 32 echo('MAC: '.$Properties['active-mac-address']."\n"); 33 $DbRows2 = $ Database->query('SELECT `Id` FROM `NetworkInterface` WHERE `MAC`="'.$Properties['active-mac-address'].'"');33 $DbRows2 = $System->Database->query('SELECT `Id` FROM `NetworkInterface` WHERE `MAC`="'.$Properties['active-mac-address'].'"'); 34 34 if($DbRows2->num_rows > 0) 35 35 { 36 36 $Interface = $DbRows2->fetch_assoc(); 37 37 $InterfaceId = $Interface['Id']; 38 $DbRows2 = $ Database->query('SELECT `Id` FROM `NetworkInterfacePortable` WHERE `NetworkInterface`='.$InterfaceId);38 $DbRows2 = $System->Database->query('SELECT `Id` FROM `NetworkInterfacePortable` WHERE `NetworkInterface`='.$InterfaceId); 39 39 if($DbRows2->num_rows > 0) 40 40 { 41 $ Database->update('NetworkInterfacePortable', '`Time` < "'.TimeToMysqlDateTime($Properties['expires-after']).'" AND `NetworkInterface`='.$InterfaceId, array('DynamicIP' => $Properties['active-address'], 'Update' => 1));42 } else $ Database->insert('NetworkInterfacePortable', array('NetworkInterface' => $InterfaceId, 'DynamicIP' => $Properties['active-address'], 'Time' => TimeToMysqlDateTime($Properties['expires-after']), 'Update' => 1));41 $System->Database->update('NetworkInterfacePortable', '`Time` < "'.TimeToMysqlDateTime($Properties['expires-after']).'" AND `NetworkInterface`='.$InterfaceId, array('DynamicIP' => $Properties['active-address'], 'Update' => 1)); 42 } else $System->Database->insert('NetworkInterfacePortable', array('NetworkInterface' => $InterfaceId, 'DynamicIP' => $Properties['active-address'], 'Time' => TimeToMysqlDateTime($Properties['expires-after']), 'Update' => 1)); 43 43 } else echo('Not registred'."\n"); 44 44 //print_r($Properties); … … 52 52 $MangleRule = array(); 53 53 $NATRule = array(); 54 $DbRows = $ Database->query('SELECT NetworkDevice.Name AS DeviceName, NetworkInterface.Name AS InterfaceName, DynamicIP FROM `NetworkInterfacePortable` JOIN NetworkInterface ON NetworkInterface.Id=NetworkInterfacePortable.NetworkInterface JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE `Update`=1');54 $DbRows = $System->Database->query('SELECT NetworkDevice.Name AS DeviceName, NetworkInterface.Name AS InterfaceName, DynamicIP FROM `NetworkInterfacePortable` JOIN NetworkInterface ON NetworkInterface.Id=NetworkInterfacePortable.NetworkInterface JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE `Update`=1'); 55 55 while($Portable = $DbRows->fetch_assoc()) 56 56 { … … 68 68 $Routerboard->ExecuteBatch($NATRule); 69 69 $Routerboard->ExecuteBatch($MangleRule); 70 $ Database->query('UPDATE NetworkInterfacePortable SET Update=0');70 $System->Database->query('UPDATE NetworkInterfacePortable SET Update=0'); 71 71 72 72 ?> -
trunk/Modules/NetworkConfigRouterOS/Generators/Common.php
r521 r522 1 1 <?php 2 2 3 include_once( '../../Common/NetworkAddress.php');3 include_once(dirname(__FILE__).'/../../../Common/NetworkAddress.php'); 4 4 5 5 function GetMarkByComment($Comment) -
trunk/Modules/NetworkConfigRouterOS/Generators/DHCP.php
r521 r522 2 2 3 3 if(isset($_SERVER['REMOTE_ADDR'])) die(); 4 include ('../../Common/Global.php');5 include ('../routerboard.php');4 include_once(dirname(__FILE__).'/../../../Common/Global.php'); 5 include_once(dirname(__FILE__).'/../Routerboard.php'); 6 6 $Path = array('ip', 'dhcp-server', 'lease'); 7 $Database = &$System->Database;8 7 9 8 $Routerboard = new Routerboard(); … … 12 11 $Routerboard->Debug = true; 13 12 14 $DbResult = $ Database->query('SELECT * FROM `NetworkSubnet` WHERE `Configure`=1');13 $DbResult = $System->Database->query('SELECT * FROM `NetworkSubnet` WHERE `Configure`=1'); 15 14 while($Subnet = $DbResult->fetch_assoc()) 16 15 { … … 19 18 $Items = array(); 20 19 $Server = 'dhcp'.$Subnet['Id']; 21 $DbResult2 = $ Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM `NetworkInterface` LEFT JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE '.20 $DbResult2 = $System->Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM `NetworkInterface` LEFT JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE '. 22 21 ' CompareNetworkPrefix(INET_ATON(LocalIP), INET_ATON("'.$Subnet['AddressRange'].'"), '.$Subnet['Mask'].') AND (`MAC` != "00:00:00:00:00:00") ORDER BY `LocalIP`'); 23 22 while($Interface = $DbResult2->fetch_assoc()) -
trunk/Modules/NetworkConfigRouterOS/Generators/DNS.php
r521 r522 2 2 3 3 if(isset($_SERVER['REMOTE_ADDR'])) die(); 4 include('../../Common/Global.php'); 5 $Database = &$System->Database; 4 include_once(dirname(__FILE__).'/../../../Common/Global.php'); 6 5 7 6 $BaseDomain = 'zdechov.net'; … … 122 121 123 122 // Local records 124 $DbResult = $ Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM NetworkInterface JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE NetworkInterface.LocalIP <> ""');123 $DbResult = $System->Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM NetworkInterface JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE NetworkInterface.LocalIP <> ""'); 125 124 while($Interface = $DbResult->fetch_assoc()) 126 125 { … … 131 130 132 131 // External records in internal server 133 $DbResult = $ Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM NetworkInterface JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE NetworkInterface.ExternalIP <> ""');132 $DbResult = $System->Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM NetworkInterface JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE NetworkInterface.ExternalIP <> ""'); 134 133 while($Interface = $DbResult->fetch_assoc()) 135 134 { … … 151 150 152 151 // Domain aliases 153 $DbResult = $ Database->select('NetworkDomainAlias', '*');152 $DbResult = $System->Database->select('NetworkDomainAlias', '*'); 154 153 while($Alias = $DbResult->fetch_assoc()) 155 154 { … … 177 176 ); 178 177 179 $DbResult = $ Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM NetworkInterface JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE NetworkInterface.ExternalIP != ""');178 $DbResult = $System->Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM NetworkInterface JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE NetworkInterface.ExternalIP != ""'); 180 179 while($Interface = $DbResult->fetch_assoc()) 181 180 { … … 186 185 187 186 // Domain alias 188 $DbResult = $ Database->query('SELECT NetworkDomainAlias.* FROM `NetworkDomainAlias`');187 $DbResult = $System->Database->query('SELECT NetworkDomainAlias.* FROM `NetworkDomainAlias`'); 189 188 // JOIN `NetworkDevice` ON NetworkDomainAlias.Target LIKE NetworkDevice.Name AND NetworkInterface.ExternalIP != ""'); 190 189 while($Alias = $DbResult->fetch_assoc()) … … 215 214 216 215 // Hosts 217 $DbResult = $ Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM NetworkInterface JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE NetworkInterface.LocalIP != ""');216 $DbResult = $System->Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM NetworkInterface JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE NetworkInterface.LocalIP != ""'); 218 217 while($Interface = $DbResult->fetch_assoc()) 219 218 { … … 224 223 225 224 // Domain alias 226 $DbResult = $ Database->query('SELECT NetworkDomainAlias.* FROM `NetworkDomainAlias`');225 $DbResult = $System->Database->query('SELECT NetworkDomainAlias.* FROM `NetworkDomainAlias`'); 227 226 // JOIN `hosts` ON NetworkDomainAlias.Target LIKE hosts.name AND hosts.czfree_ip != ""'); 228 227 while($Alias = $DbResult->fetch_assoc()) … … 252 251 253 252 // Hosts 254 $DbResult = $ Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM NetworkInterface JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE NetworkInterface.LocalIP != ""');253 $DbResult = $System->Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM NetworkInterface JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE NetworkInterface.LocalIP != ""'); 255 254 while($Interface = $DbResult->fetch_assoc()) 256 255 { … … 262 261 263 262 // Domain alias 264 $DbResult = $ Database->query('SELECT NetworkDomainAlias.* FROM `NetworkDomainAlias`');263 $DbResult = $System->Database->query('SELECT NetworkDomainAlias.* FROM `NetworkDomainAlias`'); 265 264 // JOIN `hosts` ON NetworkDomainAlias.Target LIKE hosts.name AND hosts.czfree_ip != ""'); 266 265 while($Alias = $DbResult->fetch_assoc()) -
trunk/Modules/NetworkConfigRouterOS/Generators/FirewallFilter.php
r521 r522 2 2 3 3 if(isset($_SERVER['REMOTE_ADDR'])) die(); 4 include ('../../Common/Global.php');5 include ('../routerboard.php');6 include ('common.php');4 include_once(dirname(__FILE__).'/../../../Common/Global.php'); 5 include_once(dirname(__FILE__).'/../Routerboard.php'); 6 include_once('Common.php'); 7 7 $Path = array('ip', 'firewall', 'filter'); 8 $Database = &$System->Database;9 8 10 9 $Routerboard = new Routerboard($Config['MainRouter']['HostName']); … … 44 43 45 44 // Insert blocked addresses 46 $DbResult = $ Database->query('SELECT Member.*, Subject.Name FROM Member JOIN Subject ON Member.Subject = Subject.Id WHERE Member.Blocked=1');45 $DbResult = $System->Database->query('SELECT Member.*, Subject.Name FROM Member JOIN Subject ON Member.Subject = Subject.Id WHERE Member.Blocked=1'); 47 46 while($Member = $DbResult->fetch_assoc()) 48 47 { 49 48 echo($Member['Name'].': '); 50 49 // Hosts 51 $DbResult2 = $ Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName 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');50 $DbResult2 = $System->Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName 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'); 52 51 while($Interface = $DbResult2->fetch_assoc()) 53 52 { … … 61 60 62 61 // Subnets 63 $DbResult2 = $ Database->select('NetworkSubnet', '*', 'Member='.$Member['Id']);62 $DbResult2 = $System->Database->select('NetworkSubnet', '*', 'Member='.$Member['Id']); 64 63 while($Subnet = $DbResult2->fetch_assoc()) 65 64 { -
trunk/Modules/NetworkConfigRouterOS/Generators/FirewallMangle.php
r521 r522 5 5 $ClassesEnabled = 1; 6 6 $SessionDisable = true; 7 include ('../../Common/Global.php');8 include ('../routerboard.php');9 include ('common.php');7 include_once(dirname(__FILE__).'/../../../Common/Global.php'); 8 include_once(dirname(__FILE__).'/../Routerboard.php'); 9 include_once('Common.php'); 10 10 $PathFirewall = array('ip', 'firewall', 'mangle'); 11 $Database = &$System->Database;12 11 13 12 $Routerboard = new Routerboard(); … … 24 23 25 24 // Divide rules by subnet number 26 $DbResult = $ Database->query('SELECT `Id`, `Name`, `AddressRange`, `Mask` FROM `NetworkSubnet` WHERE `Member` IS NULL');25 $DbResult = $System->Database->query('SELECT `Id`, `Name`, `AddressRange`, `Mask` FROM `NetworkSubnet` WHERE `Member` IS NULL'); 27 26 while($Subnet = $DbResult->fetch_assoc()) 28 27 { … … 34 33 35 34 // Process users 36 $DbResult = $ Database->query('SELECT `Member`.*, `Subject`.`Name` FROM `Member` '.35 $DbResult = $System->Database->query('SELECT `Member`.*, `Subject`.`Name` FROM `Member` '. 37 36 'LEFT JOIN `Subject` ON `Subject`.`Id` = `Member`.`Subject` '. 38 37 'WHERE `Member`.`Blocked` = 0'); … … 42 41 echo('Uživatel '.$Member['Name'].': '); 43 42 44 $DbResult2 = $ Database->select('NetworkDevice', '*', '`Used` = 1 AND `Member` = '.$Member['Id']);43 $DbResult2 = $System->Database->select('NetworkDevice', '*', '`Used` = 1 AND `Member` = '.$Member['Id']); 45 44 while($Device = $DbResult2->fetch_assoc()) 46 45 { 47 $DbResult3 = $ Database->select('NetworkInterface', '*', '`Device` = '.$Device['Id'].' AND `LocalIP` != ""');46 $DbResult3 = $System->Database->select('NetworkInterface', '*', '`Device` = '.$Device['Id'].' AND `LocalIP` != ""'); 48 47 while($Interface = $DbResult3->fetch_assoc()) 49 48 { … … 59 58 } 60 59 61 $DbResult2 = $ Database->select('NetworkSubnet', '*', '`Member`='.$Member['Id']);60 $DbResult2 = $System->Database->select('NetworkSubnet', '*', '`Member`='.$Member['Id']); 62 61 while($Subnet = $DbResult2->fetch_assoc()) 63 62 { -
trunk/Modules/NetworkConfigRouterOS/Generators/FirewallNAT.php
r521 r522 2 2 3 3 if(isset($_SERVER['REMOTE_ADDR'])) die(); 4 include ('../../Common/Global.php');5 include ('../routerboard.php');6 include ('common.php');4 include_once(dirname(__FILE__).'/../../../Common/Global.php'); 5 include_once(dirname(__FILE__).'/../Routerboard.php'); 6 include_once('Common.php'); 7 7 $Path = array('ip', 'firewall', 'nat'); 8 $Database = &$System->Database;9 8 10 9 $Routerboard = new Routerboard($Config['MainRouter']['HostName']); … … 37 36 //$Items[] = array('chain' => 'inet-in', 'dst-address' => '172.16.1.1/30', 'action' => 'accept', 'comment' => 'Local_subnet'); 38 37 39 $DbResult = $ Database->query('SELECT `Member`.*, `Subject`.`Name` FROM `Member` '.38 $DbResult = $System->Database->query('SELECT `Member`.*, `Subject`.`Name` FROM `Member` '. 40 39 'LEFT JOIN `Subject` ON `Subject`.`Id` = `Member`.`Subject` '. 41 40 'WHERE `Member`.`Blocked` = 0'); … … 44 43 echo($Member['Name'].': '); 45 44 // Hosts 46 $DbResult2 = $ Database->query('SELECT `NetworkInterface`.*, `NetworkDevice`.`Name` AS `DeviceName`, `NetworkDevice`.`InboundNATPriority` FROM `NetworkInterface`'.45 $DbResult2 = $System->Database->query('SELECT `NetworkInterface`.*, `NetworkDevice`.`Name` AS `DeviceName`, `NetworkDevice`.`InboundNATPriority` FROM `NetworkInterface`'. 47 46 ' LEFT JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` WHERE (`NetworkInterface`.`ExternalIP` <> "")'. 48 47 ' AND (`NetworkDevice`.`Member` = '.$Member['Id'].') AND (`NetworkInterface`.`LocalIP` != `NetworkInterface`.`ExternalIP`) ORDER BY `id` DESC'); … … 65 64 66 65 // Subnets 67 $DbResult2 = $ Database->select('NetworkSubnet', '*', '`Member`='.$Member['Id']);66 $DbResult2 = $System->Database->select('NetworkSubnet', '*', '`Member`='.$Member['Id']); 68 67 while($Subnet = $DbResult2->fetch_assoc()) 69 68 { … … 115 114 /* 116 115 // Route public addresses localy 117 $DbResult = $ Database->query('SELECT Member.*, Subject.Name FROM Member JOIN Subject ON Member.Subject = Subject.Id');116 $DbResult = $System->Database->query('SELECT Member.*, Subject.Name FROM Member JOIN Subject ON Member.Subject = Subject.Id'); 118 117 while($Member = $DbResult->fetch_assoc()) 119 118 { 120 119 echo($Member['Name'].': '); 121 120 // Hosts 122 $DbResult2 = $ Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName 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');121 $DbResult2 = $System->Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName 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'); 123 122 while($Interface = $DbResult2->fetch_assoc()) 124 123 { -
trunk/Modules/NetworkConfigRouterOS/Generators/Netwatch.php
r521 r522 2 2 3 3 if(isset($_SERVER['REMOTE_ADDR'])) die(); 4 include ('../../Common/Global.php');5 include ('../routerboard.php');4 include_once(dirname(__FILE__).'/../../../Common/Global.php'); 5 include_once(dirname(__FILE__).'/../Routerboard.php'); 6 6 $Path = array('tool', 'netwatch'); 7 $Database = &$System->Database;8 7 9 8 $Routerboard = new Routerboard(); … … 12 11 $Routerboard->Debug = true; 13 12 14 $DbResult3 = $ Database->query('SELECT DISTINCT (`DHCP`) FROM `NetworkSubnet` WHERE `Configure` = 1'); // WHERE `Member` = 0');13 $DbResult3 = $System->Database->query('SELECT DISTINCT (`DHCP`) FROM `NetworkSubnet` WHERE `Configure` = 1'); // WHERE `Member` = 0'); 15 14 while($Router = $DbResult3->fetch_assoc()) 16 15 { … … 18 17 $Routerboard->HostName = $Router['DHCP']; 19 18 $Items = array(); 20 $DbResult = $ Database->query('SELECT * FROM `NetworkSubnet` WHERE (`Configure` = 1) AND (`DHCP`="'.$Router['DHCP'].'")');19 $DbResult = $System->Database->query('SELECT * FROM `NetworkSubnet` WHERE (`Configure` = 1) AND (`DHCP`="'.$Router['DHCP'].'")'); 21 20 while($Subnet = $DbResult->fetch_assoc()) 22 21 { 23 22 $I = explode('.', $Subnet['AddressRange']); 24 23 $I = $I[2]; 25 $DbResult2 = $ Database->query('SELECT `NetworkInterface`.*, `NetworkDevice`.`Name` AS `DeviceName` FROM `NetworkInterface`'.24 $DbResult2 = $System->Database->query('SELECT `NetworkInterface`.*, `NetworkDevice`.`Name` AS `DeviceName` FROM `NetworkInterface`'. 26 25 ' LEFT JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` WHERE CompareNetworkPrefix(INET_ATON(`LocalIP`), INET_ATON("'.$Subnet['AddressRange'].'"), '.$Subnet['Mask'].')'. 27 26 ' AND (`NetworkDevice`.`Used` = 1) ORDER BY `NetworkInterface`.`LocalIP`'); -
trunk/Modules/NetworkConfigRouterOS/Generators/NetwatchImport.php
r521 r522 2 2 3 3 if(isset($_SERVER['REMOTE_ADDR'])) die(); 4 include ('../../Common/Global.php');5 include ('../routerboard.php');6 include ('common.php');4 include_once(dirname(__FILE__).'/../../../Common/Global.php'); 5 include_once(dirname(__FILE__).'/../Routerboard.php'); 6 include_once('Common.php'); 7 7 $Path = array('tool', 'netwatch'); 8 8 $Period = 60; // every 60 seconds 9 $Database = &$System->Database;10 9 11 10 while(1) … … 13 12 $StartTime = time(); 14 13 15 $DbResult3 = $ Database->query('SELECT DHCP, AddressRange, Mask FROM `NetworkSubnet` WHERE (`Configure` = 1) AND (`Member` IS NULL) GROUP BY DHCP');14 $DbResult3 = $System->Database->query('SELECT DHCP, AddressRange, Mask FROM `NetworkSubnet` WHERE (`Configure` = 1) AND (`Member` IS NULL) GROUP BY DHCP'); 16 15 //echo($DbResult3->num_rows); 17 16 while($Subnet = $DbResult3->fetch_assoc()) … … 38 37 } 39 38 40 $DbResult = $ Database->update('NetworkInterface', '`LocalIP` = "'.$Properties['host'].'"', $Values);39 $DbResult = $System->Database->update('NetworkInterface', '`LocalIP` = "'.$Properties['host'].'"', $Values); 41 40 } 42 41 } 43 42 44 43 // Update device online state 45 $DbResult = $ Database->select('NetworkDevice', 'Id', '`Used`=1');44 $DbResult = $System->Database->select('NetworkDevice', 'Id', '`Used`=1'); 46 45 while($Device = $DbResult->fetch_assoc()) 47 46 { 48 $DbResult2 = $ Database->select('NetworkInterface', 'SUM(`Online`) AS `SumOnline`', '`Device`='.$Device['Id']);47 $DbResult2 = $System->Database->select('NetworkInterface', 'SUM(`Online`) AS `SumOnline`', '`Device`='.$Device['Id']); 49 48 $DbRow = $DbResult2->fetch_array(); 50 49 if($DbRow['SumOnline'] > 0) $Online = 1; … … 52 51 $Values = array('Online' => $Online); 53 52 if($Online == 1) $Values['LastOnline'] = 'NOW()'; 54 $ Database->update('NetworkDevice', 'Id='.$Device['Id'], $Values);53 $System->Database->update('NetworkDevice', 'Id='.$Device['Id'], $Values); 55 54 } 56 55 57 56 // Update interface online statistics 58 $DbResult = $ Database->select('NetworkInterface', 'Id', '`Online` = 1');57 $DbResult = $System->Database->select('NetworkInterface', 'Id', '`Online` = 1'); 59 58 while($Interface = $DbResult->fetch_assoc()) 60 59 { 61 $DbResult2 = $ Database->select('NetworkInterfaceStat', '*', '(`NetworkInterface`="'.$Interface['Id'].'") AND (`Time` = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');62 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)');63 else $ Database->query('UPDATE `NetworkInterfaceStat` SET `PingCount` = `PingCount` + 1 WHERE (`NetworkInterface`="'.$Interface['Id'].'") AND (`Time` = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');60 $DbResult2 = $System->Database->select('NetworkInterfaceStat', '*', '(`NetworkInterface`="'.$Interface['Id'].'") AND (`Time` = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))'); 61 if($DbResult2->num_rows == 0) $System->Database->query('REPLACE INTO `NetworkInterfaceStat` (`NetworkInterface`, `Time`, `PingCount`) VALUES ("'.$Interface['Id'].'", DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"), 1)'); 62 else $System->Database->query('UPDATE `NetworkInterfaceStat` SET `PingCount` = `PingCount` + 1 WHERE (`NetworkInterface`="'.$Interface['Id'].'") AND (`Time` = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))'); 64 63 } 65 64 -
trunk/Modules/NetworkConfigRouterOS/Generators/Queue.php
r521 r522 5 5 $ClassesEnabled = 1; 6 6 $SessionDisable = true; 7 include ('../../Common/Global.php');8 include ('../routerboard.php');9 include ('common.php');7 include_once(dirname(__FILE__).'/../../../Common/Global.php'); 8 include_once(dirname(__FILE__).'/../Routerboard.php'); 9 include_once('Common.php'); 10 10 $PathQueue = array('queue', 'tree'); 11 $Database = &$System->Database;12 11 13 12 $Routerboard = new Routerboard(); … … 48 47 49 48 // Divide rules by subnet number 50 $DbResult = $ Database->query('SELECT `Id`, `Name`, `AddressRange`, `Mask` FROM `NetworkSubnet`');49 $DbResult = $System->Database->query('SELECT `Id`, `Name`, `AddressRange`, `Mask` FROM `NetworkSubnet`'); 51 50 // Slow free internet 52 51 $PacketMark = GetMarkByComment('free-out'); … … 56 55 57 56 // Process users 58 $DbResult = $ Database->query('SELECT `Member`.*, `Subject`.`Name` FROM `Member` LEFT JOIN `Subject` ON `Subject`.`Id` = `Member`.`Subject` WHERE `Member`.`Blocked`=0');57 $DbResult = $System->Database->query('SELECT `Member`.*, `Subject`.`Name` FROM `Member` LEFT JOIN `Subject` ON `Subject`.`Id` = `Member`.`Subject` WHERE `Member`.`Blocked`=0'); 59 58 while($Member = $DbResult->fetch_assoc()) 60 59 { … … 62 61 63 62 echo('Zákazník '.$Member['Name']."\n"); 64 $DbResult4 = $ Database->query('SELECT `Service`.*, `ServiceCustomerRel`.`Id` AS `RelId` FROM `ServiceCustomerRel` JOIN `Service` ON `Service`.`Id` = `ServiceCustomerRel`.`Service` '.63 $DbResult4 = $System->Database->query('SELECT `Service`.*, `ServiceCustomerRel`.`Id` AS `RelId` FROM `ServiceCustomerRel` JOIN `Service` ON `Service`.`Id` = `ServiceCustomerRel`.`Service` '. 65 64 'WHERE (`ServiceCustomerRel`.`Customer` = '.$Member['Id'].') AND (`ServiceCustomerRel`.`Action` IS NULL)'); 66 65 while($Service = $DbResult4->fetch_assoc()) … … 75 74 76 75 $Filter = '(`Used` = 1) AND (`Service` = '.$Service['RelId'].')'; 77 $DbResult2 = $ Database->select('NetworkDevice', 'COUNT(*)', $Filter);76 $DbResult2 = $System->Database->select('NetworkDevice', 'COUNT(*)', $Filter); 78 77 $Row = $DbResult2->fetch_row(); 79 78 $HostCount = $Row[0]; … … 88 87 } 89 88 90 $DbResult2 = $ Database->select('NetworkDevice', '*', $Filter);89 $DbResult2 = $System->Database->select('NetworkDevice', '*', $Filter); 91 90 while($Device = $DbResult2->fetch_assoc()) 92 91 { 93 $DbResult3 = $ Database->select('NetworkInterface', '*', '`Device` = '.$Device['Id'].' AND `LocalIP` != ""');92 $DbResult3 = $System->Database->select('NetworkInterface', '*', '`Device` = '.$Device['Id'].' AND `LocalIP` != ""'); 94 93 while($Interface = $DbResult3->fetch_assoc()) 95 94 { … … 107 106 } 108 107 109 $DbResult2 = $ Database->select('NetworkSubnet', '*', '`Service`='.$Service['RelId']);108 $DbResult2 = $System->Database->select('NetworkSubnet', '*', '`Service`='.$Service['RelId']); 110 109 while($Subnet = $DbResult2->fetch_assoc()) 111 110 { -
trunk/Modules/NetworkConfigRouterOS/Routerboard2.php
r521 r522 1 1 <?php 2 2 3 include_once(' ssh.php');3 include_once('SSH.php'); 4 4 5 5 class Routerboard extends SSH -
trunk/Readme.txt
r515 r522 18 18 3) Neverzované složky s daty 19 19 20 finance/doklady - účetní doklady21 20 files - úložiště souborů 22 21 galerie - fotogalerie obrázků 23 files - načtené soubory přes web24 22 25 23 4) Práva složek … … 27 25 webcam - vlastníka nastavit na apache 28 26 files - vlastníka nastavit na apache 29 finance/doklady - vlastníka nastavit na apache30 27 31 28
Note:
See TracChangeset
for help on using the changeset viewer.