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/Modules/NetworkConfigRouterOS
Files:
2 added
1 copied

Legend:

Unmodified
Added
Removed
  • 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?>
Note: See TracChangeset for help on using the changeset viewer.