Changeset 522


Ignore:
Timestamp:
Apr 15, 2013, 11:08:49 PM (12 years ago)
Author:
chronos
Message:
  • Upraveno: Skritpy generátorů nastavení routerů přetvořeny na aplikační moduly NetworkConfig.
Location:
trunk
Files:
8 added
1 deleted
3 edited
18 copied

Legend:

Unmodified
Added
Removed
  • trunk/Common/Global.php

    r521 r522  
    11<?php
    2 
    3 $Revision =
    42
    53/* @var $System System */
     
    2321include_once(dirname(__FILE__).'/Form/Form.php');
    2422include_once(dirname(__FILE__).'/../form_classes.php');
    25 
    26  
     23 
    2724// Application modules
    2825include_once(dirname(__FILE__).'/../Modules/Error/Error.php');
     
    4441include_once(dirname(__FILE__).'/../Modules/Meals/Meals.php');
    4542include_once(dirname(__FILE__).'/../Modules/NetworkTopology/NetworkTopology.php');
     43include_once(dirname(__FILE__).'/../Modules/NetworkConfig/NetworkConfig.php');
     44include_once(dirname(__FILE__).'/../Modules/NetworkConfigLinux/NetworkConfigLinux.php');
     45include_once(dirname(__FILE__).'/../Modules/NetworkConfigRouterOS/NetworkConfigRouterOS.php');
    4646
    4747class System extends Module
  • trunk/Common/Version.php

    r521 r522  
    11<?php
    22
    3 $Revision = 521; // Subversion revision
     3$Revision = 522; // Subversion revision
    44$DatabaseRevision = 517; // SQL structure revision
    5 $ReleaseTime = '2013-04-14';
     5$ReleaseTime = '2013-04-15';
    66
    77?>
  • trunk/Modules/NetworkConfig/Generate.php

    r521 r522  
    22
    33if(isset($_SERVER['REMOTE_ADDR'])) die();
    4 include('../../Common/Global.php');
    5 $Database = &$System->Database;
     4include_once(dirname(__FILE__).'/../../Common/Global.php');
    65
    76$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)');
    98while($Service = $DbResult->fetch_assoc())
    109{
    1110  if($Service['UNIX_TIMESTAMP(LastTime)'] < (time() - $Service['Period']))
    1211  {
    13     $Database->update('NetworkConfiguration', 'Id='.$Service['Id'], array('Changed' => 2));
     12    $System->Database->update('NetworkConfiguration', 'Id='.$Service['Id'], array('Changed' => 2));
    1413    $ExecutionStart = time();
    1514    //echo($Service['Caption'].'...');
     
    2524    //echo("Done\n");
    2625    $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)));
    2928  }
    3029}
  • trunk/Modules/NetworkConfigRouterOS/Generators/AddressPortability.php

    r521 r522  
    22
    33if(isset($_SERVER['REMOTE_ADDR'])) die();
    4 include('../../Common/Global.php');
    5 include('../routerboard.php');
     4include_once(dirname(__FILE__).'/../../../Common/Global.php');
     5include_once(dirname(__FILE__).'/../Routerboard.php');
    66$Path = array('ip', 'dhcp-server', 'lease');
    77
     
    1818$Routerboard->Timeout = $Config['MainRouter']['ConnectTimeout'];
    1919
    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`');
    2121while($Subnet = $DbResult3->fetch_assoc())
    2222{
     
    3131      $Properties['expires-after'] = time() - (24 * 3600 - ConvertExpireTime2($Properties['expires-after']));
    3232      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'].'"');
    3434      if($DbRows2->num_rows > 0)
    3535      {
    3636        $Interface = $DbRows2->fetch_assoc();
    3737        $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);
    3939        if($DbRows2->num_rows > 0)
    4040        {
    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));
    4343      } else echo('Not registred'."\n");
    4444      //print_r($Properties);
     
    5252$MangleRule = array();
    5353$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');
    5555while($Portable = $DbRows->fetch_assoc())
    5656{
     
    6868$Routerboard->ExecuteBatch($NATRule);
    6969$Routerboard->ExecuteBatch($MangleRule);
    70 $Database->query('UPDATE NetworkInterfacePortable SET Update=0');
     70$System->Database->query('UPDATE NetworkInterfacePortable SET Update=0');
    7171
    7272?>
  • trunk/Modules/NetworkConfigRouterOS/Generators/Common.php

    r521 r522  
    11<?php
    22
    3 include_once('../../Common/NetworkAddress.php');
     3include_once(dirname(__FILE__).'/../../../Common/NetworkAddress.php');
    44
    55function GetMarkByComment($Comment)
  • trunk/Modules/NetworkConfigRouterOS/Generators/DHCP.php

    r521 r522  
    22
    33if(isset($_SERVER['REMOTE_ADDR'])) die();
    4 include('../../Common/Global.php');
    5 include('../routerboard.php');
     4include_once(dirname(__FILE__).'/../../../Common/Global.php');
     5include_once(dirname(__FILE__).'/../Routerboard.php');
    66$Path = array('ip', 'dhcp-server', 'lease');
    7 $Database = &$System->Database;
    87
    98$Routerboard = new Routerboard();
     
    1211$Routerboard->Debug = true;
    1312
    14 $DbResult = $Database->query('SELECT * FROM `NetworkSubnet` WHERE `Configure`=1');
     13$DbResult = $System->Database->query('SELECT * FROM `NetworkSubnet` WHERE `Configure`=1');
    1514while($Subnet = $DbResult->fetch_assoc())
    1615{
     
    1918  $Items = array();
    2019  $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 '.
    2221  ' CompareNetworkPrefix(INET_ATON(LocalIP), INET_ATON("'.$Subnet['AddressRange'].'"), '.$Subnet['Mask'].') AND (`MAC` != "00:00:00:00:00:00") ORDER BY `LocalIP`');
    2322  while($Interface = $DbResult2->fetch_assoc())
  • trunk/Modules/NetworkConfigRouterOS/Generators/DNS.php

    r521 r522  
    22
    33if(isset($_SERVER['REMOTE_ADDR'])) die();
    4 include('../../Common/Global.php');
    5 $Database = &$System->Database;
     4include_once(dirname(__FILE__).'/../../../Common/Global.php');
    65
    76$BaseDomain = 'zdechov.net';
     
    122121
    123122// 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 <> ""');
    125124while($Interface = $DbResult->fetch_assoc())
    126125{
     
    131130
    132131// 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 <> ""');
    134133while($Interface = $DbResult->fetch_assoc())
    135134{
     
    151150
    152151// Domain aliases
    153 $DbResult = $Database->select('NetworkDomainAlias', '*');
     152$DbResult = $System->Database->select('NetworkDomainAlias', '*');
    154153while($Alias = $DbResult->fetch_assoc())
    155154{
     
    177176);
    178177
    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 != ""');
    180179while($Interface = $DbResult->fetch_assoc())
    181180{
     
    186185
    187186// Domain alias
    188 $DbResult = $Database->query('SELECT NetworkDomainAlias.* FROM `NetworkDomainAlias`');
     187$DbResult = $System->Database->query('SELECT NetworkDomainAlias.* FROM `NetworkDomainAlias`');
    189188// JOIN `NetworkDevice` ON NetworkDomainAlias.Target LIKE NetworkDevice.Name AND NetworkInterface.ExternalIP != ""');
    190189while($Alias = $DbResult->fetch_assoc())
     
    215214
    216215// 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 != ""');
    218217while($Interface = $DbResult->fetch_assoc())
    219218{
     
    224223
    225224// Domain alias
    226 $DbResult = $Database->query('SELECT NetworkDomainAlias.* FROM `NetworkDomainAlias`');
     225$DbResult = $System->Database->query('SELECT NetworkDomainAlias.* FROM `NetworkDomainAlias`');
    227226// JOIN `hosts` ON NetworkDomainAlias.Target LIKE hosts.name AND hosts.czfree_ip != ""');
    228227while($Alias = $DbResult->fetch_assoc())
     
    252251
    253252// 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 != ""');
    255254while($Interface = $DbResult->fetch_assoc())
    256255{
     
    262261
    263262// Domain alias
    264 $DbResult = $Database->query('SELECT NetworkDomainAlias.* FROM `NetworkDomainAlias`');
     263$DbResult = $System->Database->query('SELECT NetworkDomainAlias.* FROM `NetworkDomainAlias`');
    265264// JOIN `hosts` ON NetworkDomainAlias.Target LIKE hosts.name AND hosts.czfree_ip != ""');
    266265while($Alias = $DbResult->fetch_assoc())
  • trunk/Modules/NetworkConfigRouterOS/Generators/FirewallFilter.php

    r521 r522  
    22
    33if(isset($_SERVER['REMOTE_ADDR'])) die();
    4 include('../../Common/Global.php');
    5 include('../routerboard.php');
    6 include('common.php');
     4include_once(dirname(__FILE__).'/../../../Common/Global.php');
     5include_once(dirname(__FILE__).'/../Routerboard.php');
     6include_once('Common.php');
    77$Path = array('ip', 'firewall', 'filter');
    8 $Database = &$System->Database;
    98
    109$Routerboard = new Routerboard($Config['MainRouter']['HostName']);
     
    4443
    4544// 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');
    4746while($Member = $DbResult->fetch_assoc())
    4847{
    4948  echo($Member['Name'].': ');
    5049  // 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');
    5251  while($Interface = $DbResult2->fetch_assoc())
    5352  {
     
    6160
    6261  // Subnets
    63   $DbResult2 = $Database->select('NetworkSubnet', '*', 'Member='.$Member['Id']);
     62  $DbResult2 = $System->Database->select('NetworkSubnet', '*', 'Member='.$Member['Id']);
    6463  while($Subnet = $DbResult2->fetch_assoc())
    6564  {   
  • trunk/Modules/NetworkConfigRouterOS/Generators/FirewallMangle.php

    r521 r522  
    55$ClassesEnabled = 1;
    66$SessionDisable = true;
    7 include('../../Common/Global.php');
    8 include('../routerboard.php');
    9 include('common.php');
     7include_once(dirname(__FILE__).'/../../../Common/Global.php');
     8include_once(dirname(__FILE__).'/../Routerboard.php');
     9include_once('Common.php');
    1010$PathFirewall = array('ip', 'firewall', 'mangle');
    11 $Database = &$System->Database;
    1211
    1312$Routerboard = new Routerboard();
     
    2423
    2524// 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');
    2726while($Subnet = $DbResult->fetch_assoc())
    2827{
     
    3433
    3534// Process users
    36 $DbResult = $Database->query('SELECT `Member`.*, `Subject`.`Name` FROM `Member` '.
     35$DbResult = $System->Database->query('SELECT `Member`.*, `Subject`.`Name` FROM `Member` '.
    3736  'LEFT JOIN `Subject` ON `Subject`.`Id` = `Member`.`Subject` '.
    3837  'WHERE `Member`.`Blocked` = 0');
     
    4241  echo('Uživatel '.$Member['Name'].': ');
    4342
    44   $DbResult2 = $Database->select('NetworkDevice', '*', '`Used` = 1 AND `Member` = '.$Member['Id']);
     43  $DbResult2 = $System->Database->select('NetworkDevice', '*', '`Used` = 1 AND `Member` = '.$Member['Id']);
    4544  while($Device = $DbResult2->fetch_assoc())
    4645  {
    47     $DbResult3 = $Database->select('NetworkInterface', '*', '`Device` = '.$Device['Id'].' AND `LocalIP` != ""');
     46    $DbResult3 = $System->Database->select('NetworkInterface', '*', '`Device` = '.$Device['Id'].' AND `LocalIP` != ""');
    4847    while($Interface = $DbResult3->fetch_assoc())
    4948    {
     
    5958  }
    6059 
    61   $DbResult2 = $Database->select('NetworkSubnet', '*', '`Member`='.$Member['Id']);
     60  $DbResult2 = $System->Database->select('NetworkSubnet', '*', '`Member`='.$Member['Id']);
    6261  while($Subnet = $DbResult2->fetch_assoc())
    6362  {
  • trunk/Modules/NetworkConfigRouterOS/Generators/FirewallNAT.php

    r521 r522  
    22
    33if(isset($_SERVER['REMOTE_ADDR'])) die();
    4 include('../../Common/Global.php');
    5 include('../routerboard.php');
    6 include('common.php');
     4include_once(dirname(__FILE__).'/../../../Common/Global.php');
     5include_once(dirname(__FILE__).'/../Routerboard.php');
     6include_once('Common.php');
    77$Path = array('ip', 'firewall', 'nat');
    8 $Database = &$System->Database;
    98
    109$Routerboard = new Routerboard($Config['MainRouter']['HostName']);
     
    3736//$Items[] = array('chain' => 'inet-in', 'dst-address' => '172.16.1.1/30', 'action' => 'accept', 'comment' => 'Local_subnet');
    3837
    39 $DbResult = $Database->query('SELECT `Member`.*, `Subject`.`Name` FROM `Member` '.
     38$DbResult = $System->Database->query('SELECT `Member`.*, `Subject`.`Name` FROM `Member` '.
    4039  'LEFT JOIN `Subject` ON `Subject`.`Id` = `Member`.`Subject` '.
    4140  'WHERE `Member`.`Blocked` = 0');
     
    4443  echo($Member['Name'].': ');
    4544  // 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`'.
    4746  ' LEFT JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` WHERE (`NetworkInterface`.`ExternalIP` <> "")'.
    4847  ' AND (`NetworkDevice`.`Member` = '.$Member['Id'].') AND (`NetworkInterface`.`LocalIP` != `NetworkInterface`.`ExternalIP`) ORDER BY `id` DESC');
     
    6564
    6665  // Subnets
    67   $DbResult2 = $Database->select('NetworkSubnet', '*', '`Member`='.$Member['Id']);
     66  $DbResult2 = $System->Database->select('NetworkSubnet', '*', '`Member`='.$Member['Id']);
    6867  while($Subnet = $DbResult2->fetch_assoc())
    6968  {   
     
    115114/*
    116115// 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');
    118117while($Member = $DbResult->fetch_assoc())
    119118{
    120119  echo($Member['Name'].': ');
    121120  // 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');
    123122  while($Interface = $DbResult2->fetch_assoc())
    124123  {
  • trunk/Modules/NetworkConfigRouterOS/Generators/Netwatch.php

    r521 r522  
    22
    33if(isset($_SERVER['REMOTE_ADDR'])) die();
    4 include('../../Common/Global.php');
    5 include('../routerboard.php');
     4include_once(dirname(__FILE__).'/../../../Common/Global.php');
     5include_once(dirname(__FILE__).'/../Routerboard.php');
    66$Path = array('tool', 'netwatch');
    7 $Database = &$System->Database;
    87
    98$Routerboard = new Routerboard();
     
    1211$Routerboard->Debug = true;
    1312
    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');
    1514while($Router = $DbResult3->fetch_assoc())
    1615{
     
    1817  $Routerboard->HostName = $Router['DHCP'];
    1918  $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'].'")');
    2120  while($Subnet = $DbResult->fetch_assoc())
    2221  {
    2322    $I = explode('.', $Subnet['AddressRange']);
    2423    $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`'.
    2625    ' LEFT JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` WHERE CompareNetworkPrefix(INET_ATON(`LocalIP`), INET_ATON("'.$Subnet['AddressRange'].'"), '.$Subnet['Mask'].')'.
    2726    ' AND (`NetworkDevice`.`Used` = 1) ORDER BY `NetworkInterface`.`LocalIP`');
  • trunk/Modules/NetworkConfigRouterOS/Generators/NetwatchImport.php

    r521 r522  
    22
    33if(isset($_SERVER['REMOTE_ADDR'])) die();
    4 include('../../Common/Global.php');
    5 include('../routerboard.php');
    6 include('common.php');
     4include_once(dirname(__FILE__).'/../../../Common/Global.php');
     5include_once(dirname(__FILE__).'/../Routerboard.php');
     6include_once('Common.php');
    77$Path = array('tool', 'netwatch');
    88$Period = 60; // every 60 seconds
    9 $Database = &$System->Database;
    109
    1110while(1)
     
    1312  $StartTime = time();
    1413
    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');
    1615  //echo($DbResult3->num_rows);
    1716  while($Subnet = $DbResult3->fetch_assoc())
     
    3837      }
    3938
    40       $DbResult = $Database->update('NetworkInterface', '`LocalIP` = "'.$Properties['host'].'"', $Values);
     39      $DbResult = $System->Database->update('NetworkInterface', '`LocalIP` = "'.$Properties['host'].'"', $Values);
    4140    }
    4241  }
    4342
    4443  // Update device online state
    45   $DbResult = $Database->select('NetworkDevice', 'Id', '`Used`=1');
     44  $DbResult = $System->Database->select('NetworkDevice', 'Id', '`Used`=1');
    4645  while($Device = $DbResult->fetch_assoc())
    4746  {
    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']);
    4948    $DbRow = $DbResult2->fetch_array();
    5049    if($DbRow['SumOnline'] > 0) $Online = 1;
     
    5251    $Values = array('Online' => $Online);
    5352    if($Online == 1) $Values['LastOnline'] = 'NOW()';
    54     $Database->update('NetworkDevice', 'Id='.$Device['Id'], $Values);
     53    $System->Database->update('NetworkDevice', 'Id='.$Device['Id'], $Values);
    5554  }
    5655
    5756  // Update interface online statistics
    58   $DbResult = $Database->select('NetworkInterface', 'Id', '`Online` = 1');
     57  $DbResult = $System->Database->select('NetworkInterface', 'Id', '`Online` = 1');
    5958  while($Interface = $DbResult->fetch_assoc())
    6059  {
    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"))');
    6463  }
    6564
  • trunk/Modules/NetworkConfigRouterOS/Generators/Queue.php

    r521 r522  
    55$ClassesEnabled = 1;
    66$SessionDisable = true;
    7 include('../../Common/Global.php');
    8 include('../routerboard.php');
    9 include('common.php');
     7include_once(dirname(__FILE__).'/../../../Common/Global.php');
     8include_once(dirname(__FILE__).'/../Routerboard.php');
     9include_once('Common.php');
    1010$PathQueue = array('queue', 'tree');
    11 $Database = &$System->Database;
    1211
    1312$Routerboard = new Routerboard();
     
    4847
    4948// 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`');
    5150// Slow free internet
    5251$PacketMark = GetMarkByComment('free-out');
     
    5655
    5756// 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');
    5958while($Member = $DbResult->fetch_assoc())
    6059{
     
    6261
    6362  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` '.
    6564    'WHERE (`ServiceCustomerRel`.`Customer` = '.$Member['Id'].') AND (`ServiceCustomerRel`.`Action` IS NULL)');
    6665  while($Service = $DbResult4->fetch_assoc())
     
    7574
    7675    $Filter = '(`Used` = 1) AND (`Service` = '.$Service['RelId'].')';
    77     $DbResult2 = $Database->select('NetworkDevice', 'COUNT(*)', $Filter);
     76    $DbResult2 = $System->Database->select('NetworkDevice', 'COUNT(*)', $Filter);
    7877    $Row = $DbResult2->fetch_row();
    7978    $HostCount = $Row[0];
     
    8887    }
    8988
    90     $DbResult2 = $Database->select('NetworkDevice', '*', $Filter);
     89    $DbResult2 = $System->Database->select('NetworkDevice', '*', $Filter);
    9190    while($Device = $DbResult2->fetch_assoc())
    9291    {
    93       $DbResult3 = $Database->select('NetworkInterface', '*', '`Device` = '.$Device['Id'].' AND `LocalIP` != ""');
     92      $DbResult3 = $System->Database->select('NetworkInterface', '*', '`Device` = '.$Device['Id'].' AND `LocalIP` != ""');
    9493      while($Interface = $DbResult3->fetch_assoc())
    9594      {
     
    107106    }
    108107 
    109     $DbResult2 = $Database->select('NetworkSubnet', '*', '`Service`='.$Service['RelId']);
     108    $DbResult2 = $System->Database->select('NetworkSubnet', '*', '`Service`='.$Service['RelId']);
    110109    while($Subnet = $DbResult2->fetch_assoc())
    111110    {
  • trunk/Modules/NetworkConfigRouterOS/Routerboard2.php

    r521 r522  
    11<?php
    22
    3 include_once('ssh.php');
     3include_once('SSH.php');
    44
    55class Routerboard extends SSH
  • trunk/Readme.txt

    r515 r522  
    18183) Neverzované složky s daty
    1919
    20   finance/doklady - účetní doklady
    2120  files - úložiště souborů
    2221  galerie - fotogalerie obrázků
    23   files - načtené soubory přes web
    2422
    25234) Práva složek
     
    2725  webcam - vlastníka nastavit na apache
    2826  files - vlastníka nastavit na apache
    29   finance/doklady - vlastníka nastavit na apache
    3027
    3128 
Note: See TracChangeset for help on using the changeset viewer.