Changeset 671


Ignore:
Timestamp:
Jul 19, 2014, 1:21:24 AM (10 years ago)
Author:
chronos
Message:
  • Upraveno: Příprava pro sledování signálu bezdrátových spojů.
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/Version.php

    r670 r671  
    11<?php
    22
    3 $Revision = 670; // Subversion revision
    4 $DatabaseRevision = 668; // SQL structure revision
    5 $ReleaseTime = strtotime('2014-07-15');
     3$Revision = 671; // Subversion revision
     4$DatabaseRevision = 671; // SQL structure revision
     5$ReleaseTime = strtotime('2014-07-19');
  • trunk/Common/Setup/Updates.php

    r668 r671  
    759759  $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
    760760    "VALUES (NULL , 'Kontakty', '12', '".$ActionId."', '1');");
    761   $ConatctMenuId = $Manager->Database->insert_id;
     761  $ContactMenuId = $Manager->Database->insert_id;
    762762
    763763  $Manager->Execute("INSERT INTO `Action` (
     
    767767  $ActionId = $Manager->Database->insert_id;
    768768  $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
    769     "VALUES (NULL , 'Druhy kontaktů', ".$ConatctMenuId.", '".$ActionId."', '1');");
     769    "VALUES (NULL , 'Druhy kontaktů', ".$ContactMenuId.", '".$ActionId."', '1');");
    770770
    771771  $Manager->Execute("INSERT INTO `ContactCategory` (`Id` ,`Name`)
     
    797797  $Manager->Execute('INSERT INTO `Module` (`Id` ,`Name` ,`Title`)
    798798VALUES (NULL , "RSS", "RSS kanály");');
     799}
     800
     801function UpdateTo671($Manager)
     802{
     803  $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkSignal` (
     804  `Id` int(11) NOT NULL AUTO_INCREMENT,
     805  `Time` datetime NOT NULL,
     806  `MAC` varchar(17) NOT NULL,
     807  `Interface` int(11) DEFAULT NULL,
     808  `Value` int(11) NOT NULL,
     809  PRIMARY KEY (`Id`),
     810  KEY `Interface` (`Interface`)
     811) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
     812
     813  $Manager->Execute('ALTER TABLE `NetworkSignal`
     814  ADD CONSTRAINT `NetworkSignal_ibfk_1` FOREIGN KEY (`Interface`) REFERENCES `NetworkInterface` (`Id`);');
     815  $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,
     816`Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES (
     817NULL , "", "Signál rozhraní", "1", "/is/?t=NetworkSignal&a=list", NULL , NULL , NULL , "1");');
     818  $ActionId = $Manager->Database->insert_id;
     819  $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
     820    "VALUES (NULL , 'Signál rozhraní', 4, '".$ActionId."', '1');");
     821
     822  $Manager->Execute('ALTER TABLE `NetworkDevice` ADD `API` INT NULL ,ADD INDEX ( `API` ) ;');
     823  $Manager->Execute('CREATE TABLE IF NOT EXISTS `DeviceAPIType` (
     824  `Id` int(11) NOT NULL AUTO_INCREMENT,
     825  `Name` varchar(255) NOT NULL,
     826  PRIMARY KEY (`Id`)
     827) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;');
     828
     829  $Manager->Execute('INSERT INTO `DeviceAPIType` (`Id`, `Name`) VALUES
     830(1, "RouterOS API"),
     831(2, "AirOS");');
     832  $Manager->Execute('ALTER TABLE `NetworkDevice` ADD FOREIGN KEY ( `API` ) REFERENCES `DeviceAPIType` (
     833`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;');
     834
    799835}
    800836
     
    842878      661 => array('Revision' => 662, 'Function' => 'UpdateTo662'),
    843879      662 => array('Revision' => 668, 'Function' => 'UpdateTo668'),
     880      668 => array('Revision' => 671, 'Function' => 'UpdateTo671'),
    844881    ));
    845882  }
  • trunk/Modules/Log/Log.php

    r668 r671  
    6565    $this->FormatHTML = false;
    6666    Header('Content-Type: text/xml');
    67     $Count = 20;
     67    $Count = 100;
    6868
    6969    $Output = '';
  • trunk/Modules/Network/Network.php

    r661 r671  
    228228        'Interface1' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní 1', 'Default' => ''),
    229229        'Interface2' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní 2', 'Default' => ''),
     230      ),
     231    ));
     232    $this->System->FormManager->RegisterClass('NetworkSignal', array(
     233      'Title' => 'Signál rozhraní',
     234      'Table' => 'NetworkSignal',
     235      'Items' => array(
     236        'Time' => array('Type' => 'DateTime', 'Caption' => 'Čas', 'Default' => ''),
     237        'MAC' => array('Type' => 'MacAddress', 'Caption' => 'Fyzická adresa (MAC)', 'Default' => ''),
     238        'Interface' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní', 'Default' => '', 'Null' => true),
     239        'Value' => array('Type' => 'Integer', 'Caption' => 'Signál', 'Default' => '0'),
    230240      ),
    231241    ));
  • trunk/Modules/NetworkConfigRouterOS/Generators/Signal.php

    r666 r671  
    1212  {
    1313    $StartTime = time();
    14     $Function();   
     14    $Function();
    1515    $EndTime = time();
    1616    $Delay = $Period - ($EndTime - $StartTime);
     
    1919    echo('Waiting '.$Delay.' seconds...'."\n");
    2020    sleep($Delay);
    21   }
     21  }      print_r($Properties);
     22
    2223}
    2324
     
    2526{
    2627  global $System, $Config;
    27  
     28
    2829  $Path = array('interface', 'wireless', 'registration-table');
     30  $Time = time();
    2931
    30   // Load netwatch status from all DHCP routers
    31   $DbResult3 = $System->Database->query('SELECT DHCP, AddressRange, Mask FROM `NetworkSubnet` WHERE (`Configure` = 1) AND (`Member` IS NULL) GROUP BY DHCP');
    32   while($Subnet = $DbResult3->fetch_assoc())
     32  // Load netwatch status from all DHCP routers
     33  $DbResult3 = $System->Database->query('SELECT `Id`, '.
     34    '(SELECT `LocalIP` FROM `NetworkInterface` WHERE `NetworkInterface`.`Device` = `NetworkDevice`.`Id` LIMIT 1) AS `LocalIP` '.
     35    'FROM `NetworkDevice` WHERE (`API` = 1) AND (`Used` = 1)');
     36  while($Device = $DbResult3->fetch_assoc())
    3337  {
    34     echo($Subnet['AddressRange'].'/'.$Subnet['Mask'].' on router '.$Subnet['DHCP']."\n");
     38    echo($Device['LocalIP']."\n");
    3539    $Routerboard = new Routerboard();
    3640    $Routerboard->UserName = $Config['MainRouter']['UserName'];
    3741    $Routerboard->Timeout = $Config['MainRouter']['ConnectTimeout'];
    38     $Routerboard->HostName = $Subnet['DHCP'];
    39     $List = $Routerboard->ListGetPrint($Path, array('mac-address', 'signal-strength'));
     42    $Routerboard->HostName = $Device['LocalIP'];
     43    $Routerboard->Debug = true;
     44    $List = $Routerboard->ListGetPrint($Path, array('mac-address', 'signal-strength'), array(), 'stats');
    4045    foreach($List as $Properties)
    4146    {
     47      print_r($Properties);
     48      $DbResult = $System->Database->select('NetworkInterface', 'Id', 'MAC="'.$Properties['mac-address'].'"');
     49      if($DbResult->num_rows > 0)
     50      {
     51        $DbRow = $DbResult->fetch_assoc();
     52        $Interface = $DbRow['Id'];
     53      } else $Interface = null;
     54      $System->Database->insert('NetworkSignal', array('MAC' => $Properties['mac-address'],
     55        'Value' => $Properties['signal-strength'], 'Time' => $Time, 'Interface' => $Interface));
     56      /*
    4257      $DbResult = $System->Database->select('Measure', 'Id', '`Name` = "'.$Properties['mac-address'].'"');
    4358      if($DbResult->num_rows > 0)
     
    5267      $Measure->Load($Id);
    5368      $Measure->AddValue($Properties['signal-strength']);
     69      */
    5470    }
    55   } 
     71  }
    5672}
    5773
  • trunk/Modules/NetworkConfigRouterOS/RouterboardAPI.php

    r548 r671  
    1111  var $Timeout;        // Connection attempt timeout and data read timeout
    1212  var $Socket;             // Variable for storing socket resource
    13  
     13
    1414  function __construct()
    1515  {
     
    4343    if($this->Connected) $this->Disconnect();
    4444    $this->Socket = @fsockopen($IP, $this->Port, $this->ErrorNo, $this->ErrorStr, $this->Timeout);
    45     if($this->Socket) 
     45    if($this->Socket)
    4646    {
    4747      socket_set_timeout($this->Socket, $this->Timeout);
     
    5959        }
    6060      }
    61       if(!$this->Connected) fclose($this->Socket);     
    62     }   
    63   }
    64  
     61      if(!$this->Connected) fclose($this->Socket);
     62    }
     63  }
     64
    6565  function Connect($IP, $Login, $Password)
    6666  {
    67     for($Attempt = 1; $Attempt <= $this->Attempts; $Attempt++) 
     67    for($Attempt = 1; $Attempt <= $this->Attempts; $Attempt++)
    6868    {
    6969      $this->ConnectOnce($IP, $Login, $Password);
     
    182182        $Response[] = $Line;
    183183      }
     184      echo($Line."\n");
    184185      // If we get a !done, make a note of it.
    185186      if ($Line == "!done") $ReceivedDone = true;
     187        else $ReceivedDone = false;
    186188      $Status = socket_get_status($this->Socket);
    187       if ((!$this->Connected && !$Status['unread_bytes']) || 
     189      if ((!$this->Connected && !$Status['unread_bytes']) ||
    188190          ($this->Connected && !$Status['unread_bytes'] && $ReceivedDone))
    189191        break;
     
    195197  function Write($Command, $Param2 = true)
    196198  {
    197     if($Command) 
     199    if($Command)
    198200    {
    199201      $Data = explode("\n", $Command);
    200202      foreach ($Data as $Com) {
    201203        $Com = trim($Com);
    202         fwrite($this->Socket, $this->EncodeLength(strlen($Com)).$Com);       
     204        fwrite($this->Socket, $this->EncodeLength(strlen($Com)).$Com);
    203205      }
    204206      if (gettype($Param2) == 'integer') {
Note: See TracChangeset for help on using the changeset viewer.