Ignore:
Timestamp:
Jan 8, 2016, 11:00:11 PM (9 years ago)
Author:
chronos
Message:
  • Modified: Network configure actions now can be executed through cmd.php interface using "php cmd.php config <action>".
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/NetworkConfigAirOS/Generators/Signal.php

    r753 r781  
    11<?php
    22
    3 if(array_key_exists('REMOTE_ADDR', $_SERVER)) die();
    4 include_once(dirname(__FILE__).'/../../../Application/System.php');
    53include_once(dirname(__FILE__).'/SSHClient.php');
    6 $System = new System();
    7 $System->ShowPage = false;
    8 $System->Run();
    94
    10 function ReadWirelessRegistration()
     5class ConfigAirOSSignal extends NetworkConfigItem
    116{
    12   global $System, $Config;
     7  function ReadWirelessRegistration()
     8  {
     9    $Time = time();
    1310
    14   $Time = time();
     11    // Load netwatch status from all DHCP routers
     12    $DbResult3 = $this->Database->query('SELECT `Id`, `LoginName`, `LoginPassword`, '.
     13        '(SELECT `LocalIP` FROM `NetworkInterface` WHERE `NetworkInterface`.`Device` = `NetworkDevice`.`Id` LIMIT 1) AS `LocalIP` '.
     14        'FROM `NetworkDevice` WHERE (`API` = 2) AND (`Used` = 1)');
     15    while($Device = $DbResult3->fetch_assoc())
     16    {
     17      echo($Device['LocalIP']."\n");
     18      $SSHClient = new SSHClient($Device['LocalIP'], $Device['LoginName'], $Device['LoginPassword']);
     19      $Result = $SSHClient->Execute('wstalist');
     20      print_r($Result);
     21      $Array = json_decode(implode("\n", $Result), true);
     22      print_r($Array);
     23      foreach($Array as $Properties)
     24      {
     25        $DbResult = $this->Database->select('NetworkInterface', 'Id', '`MAC`="'.$Properties['mac'].'"');
     26        if($DbResult->num_rows > 0)
     27        {
     28          $DbRow = $DbResult->fetch_assoc();
     29          $Interface = $DbRow['Id'];
     30        } else $Interface = null;
    1531
    16   // Load netwatch status from all DHCP routers
    17   $DbResult3 = $System->Database->query('SELECT `Id`, `LoginName`, `LoginPassword`, '.
    18     '(SELECT `LocalIP` FROM `NetworkInterface` WHERE `NetworkInterface`.`Device` = `NetworkDevice`.`Id` LIMIT 1) AS `LocalIP` '.
    19     'FROM `NetworkDevice` WHERE (`API` = 2) AND (`Used` = 1)');
    20   while($Device = $DbResult3->fetch_assoc())
    21   {
    22     echo($Device['LocalIP']."\n");
    23     $SSHClient = new SSHClient($Device['LocalIP'], $Device['LoginName'], $Device['LoginPassword']);
    24     $Result = $SSHClient->Execute('wstalist');
    25     print_r($Result);
    26     $Array = json_decode(implode("\n", $Result), true);
    27     print_r($Array);
    28     foreach($Array as $Properties)
    29     {
    30       $DbResult = $System->Database->select('NetworkInterface', 'Id', 'MAC="'.$Properties['mac'].'"');
    31       if($DbResult->num_rows > 0)
    32       {
    33         $DbRow = $DbResult->fetch_assoc();
    34         $Interface = $DbRow['Id'];
    35       } else $Interface = null;
    36 
    37       $Strength = $Properties['signal'];
    38       $RateRx = $Properties['rx'];
    39       $RateTx = $Properties['tx'];
    40       $System->Database->insert('NetworkSignal', array('MAC' => $Properties['mac'],
    41         'Value' => $Strength, 'RateRx' => $RateRx, 'RateTx' => $RateTx,
    42         'Time' => TimeToMysqlDateTime($Time), 'Interface' => $Interface, 'Device' => $Device['Id']));
     32        $Strength = $Properties['signal'];
     33        $RateRx = $Properties['rx'];
     34        $RateTx = $Properties['tx'];
     35        $this->Database->insert('NetworkSignal', array('MAC' => $Properties['mac'],
     36            'Value' => $Strength, 'RateRx' => $RateRx, 'RateTx' => $RateTx,
     37            'Time' => TimeToMysqlDateTime($Time), 'Interface' => $Interface, 'Device' => $Device['Id']));
     38      }
    4339    }
    4440  }
     41
     42  function Run()
     43  {
     44    RepeatFunction(60 * 60, array($this, 'ReadWirelessRegistration'));
     45  }
    4546}
    46 
    47 RepeatFunction(60 * 60, 'ReadWirelessRegistration');
Note: See TracChangeset for help on using the changeset viewer.