Changeset 682


Ignore:
Timestamp:
Aug 5, 2014, 10:49:06 PM (10 years ago)
Author:
chronos
Message:
  • Upraveno: Funkce RepeatFunction přesunuta do Global.php.
  • Upraveno: Nezaznamenávat chyby potlačené symbolem @.
  • Upraveno: Nezobrazovat HTML chyby při spuštění z konzole.
  • Opraveno: Pokud není navázáno spojení s RouterboardAPI, tak nepokračuj se zasíláním povelů.
  • Upraveno: NetwatchImport přepracován na načítání přes RouterboardAPI.
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/Version.php

    r680 r682  
    11<?php
    22
    3 $Revision = 680; // Subversion revision
     3$Revision = 682; // Subversion revision
    44$DatabaseRevision = 679; // SQL structure revision
    5 $ReleaseTime = strtotime('2014-07-27');
     5$ReleaseTime = strtotime('2014-08-05');
  • trunk/Common/Global.php

    r679 r682  
    433433  return($PathItems);
    434434}
     435
     436function RepeatFunction($Period, $Function)
     437{
     438  while(1)
     439  {
     440    $StartTime = time();
     441    $Function();
     442    $EndTime = time();
     443    $Delay = $Period - ($EndTime - $StartTime);
     444    if($Delay < 0) $Delay = 0;
     445
     446    echo('Waiting '.$Delay.' seconds...'."\n");
     447    sleep($Delay);
     448  }
     449}
  • trunk/Modules/Error/Error.php

    r586 r682  
    66  var $ShowError;
    77  var $UserErrors;
    8    
     8
    99  function __construct($System)
    1010  {
     
    2121    $this->UserErrors = E_ALL;  //E_ERROR | E_WARNING | E_PARSE;
    2222  }
    23  
     23
    2424  function DoInstall()
    2525  {
     
    2828  function DoUnInstall()
    2929  {
    30   } 
    31  
     30  }
     31
    3232  function DoStart()
    3333  {
     
    3636    set_exception_handler(array($this, 'ExceptionHandler'));
    3737  }
    38  
     38
    3939  function Stop()
    4040  {
     
    4343        parent::Stop();
    4444  }
    45  
     45
    4646  function ErrorHandler($Number, $Message, $FileName, $LineNumber, $Variables)
    4747  {
     
    6060      1024 => 'User Notice'
    6161    );
    62  
     62
    6363    if(($this->UserErrors & $Number))
    6464    {
     65      // Error was suppressed with the @-operator
     66      if(0 === error_reporting())
     67      {
     68        return false;
     69      }
    6570      $Backtrace = debug_backtrace();
    6671      $Backtrace[0]['function'] = $Message;
     
    6974      $Backtrace[0]['line'] = $LineNumber;
    7075      $this->Report($Backtrace);
    71       if((E_ERROR | E_PARSE) & $Number) die(); 
     76      if((E_ERROR | E_PARSE) & $Number) die();
    7277    }
    7378  }
    74  
    75   function ExceptionHandler(Exception $Exception) 
     79
     80  function ExceptionHandler(Exception $Exception)
    7681  {
    77     $Backtrace = $Exception->getTrace();   
     82    $Backtrace = $Exception->getTrace();
    7883    array_unshift($Backtrace, array(
    7984      'function' => $Exception->getMessage(),
     
    8489    die();
    8590  }
    86  
     91
    8792  function Report($Backtrace)
    8893  {
    89     $Date = date('Y-m-d H:i:s');               
     94    $Date = date('Y-m-d H:i:s');
    9095    $Error = '# '.$Date."\n";
    9196    foreach($Backtrace as $Item)
     
    9398      if(!array_key_exists('line', $Item)) $Item['line'] = '';
    9499      if(!array_key_exists('file', $Item)) $Item['file'] = '';
    95    
     100
    96101      $Error .= ' '.$Item['file'].'('.$Item['line'].")\t".$Item['function'];
    97102      $Arguments = '';
     
    107112    }
    108113    $Error .= "\n";
    109      
     114
    110115    $this->System->ModuleManager->Modules['Log']->NewRecord('Error', 'Log', $Error);
    111    
     116
    112117    //if($Config['Web']['ErrorLogFile'] != '')
    113118    // error_log($Error, 3, $Config['Web']['ErrorLogFile']);
     
    117122    if($this->ShowError == true)
    118123    {
    119       echo('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>'."\n".
     124      if(array_key_exists('REMOTE_ADDR', $_SERVER))
     125      {
     126        echo('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>'."\n".
    120127          '<meta http-equiv="Content-Language" content="cs">'."\n".
    121128          '<meta http-equiv="Content-Type" content="text/html; charset='.$this->Encoding.'"></head><body>'."\n".
    122129          'Došlo k vnitřní chybě!<br/> O chybě byl uvědoměn správce webu a chybu brzy odstraní.<br/><br/>');
    123       echo('<pre>'.$Error.'</pre><br/>');                       // V případě ladění chybu i zobraz
    124       echo('</body></html>');
    125     }   
     130        echo('<pre>'.$Error.'</pre><br/>');                     // V případě ladění chybu i zobraz
     131        echo('</body></html>');
     132      } else
     133      {
     134        echo($Error);
     135      }
     136    }
    126137  }
    127138}
  • trunk/Modules/NetworkConfigRouterOS/Generators/NetwatchImport.php

    r667 r682  
    77$System->Run();
    88
    9 $Path = array('tool', 'netwatch');
    10 $Period = 60; // every 60 seconds
     9function NetwatchImport()
     10{
     11  global $System, $Config;
    1112
    12 
    13 while(1)
    14 {
    1513  $StartTime = time();
    1614
     
    2725  {
    2826    echo($Subnet['AddressRange'].'/'.$Subnet['Mask'].' on router '.$Subnet['DHCP']."\n");
    29     $Routerboard = new Routerboard();
    30     $Routerboard->UserName = $Config['MainRouter']['UserName'];
    31     $Routerboard->Timeout = $Config['MainRouter']['ConnectTimeout'];
    32     $Routerboard->HostName = $Subnet['DHCP'];
    33     $List = $Routerboard->ListGetPrint($Path, array('host', 'status'));
     27    $Routerboard = new RouterosAPI();
     28    $Routerboard->Connect($Subnet['DHCP'], $Config['API']['UserName'], $Config['API']['Password']);
     29    if(!$Routerboard->Connected) continue;
     30    $Routerboard->Write('/tool/netwatch/getall', false);
     31    $Routerboard->Write('=.proplist=host,status');
     32    $Read = $Routerboard->Read(false);
     33    $List = $Routerboard->ParseResponse($Read);
    3434    foreach($List as $Properties)
    3535    {
     
    9696      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"))');
    9797  }
    98 
    99   $EndTime = time();
    100   $Delay = $Period - ($EndTime - $StartTime);
    101   if($Delay < 0) $Delay = 0;
    102 
    103   echo('Waiting '.$Delay.' seconds...'."\n");
    104   sleep($Delay);
    10598}
    10699
     100RepeatFunction(60, 'NetwatchImport');
  • trunk/Modules/NetworkConfigRouterOS/Generators/Signal.php

    r679 r682  
    77$System->Run();
    88
    9 function RepeatFunction($Period, $Function)
    10 {
    11   while(1)
    12   {
    13     $StartTime = time();
    14     $Function();
    15     $EndTime = time();
    16     $Delay = $Period - ($EndTime - $StartTime);
    17     if($Delay < 0) $Delay = 0;
    18 
    19     echo('Waiting '.$Delay.' seconds...'."\n");
    20     sleep($Delay);
    21   }
    22 }
    23 
    249function ReadWirelessRegistration()
    2510{
    2611  global $System, $Config;
    2712
    28   $Path = array('interface', 'wireless', 'registration-table');
    2913  $Time = time();
    3014
     
    4024    //$Routerboard->Port = 8729;
    4125    $Routerboard->Connect($Device['LocalIP'], $Config['API']['UserName'], $Config['API']['Password']);
     26    if(!$Routerboard->Connected) continue;
    4227    $Routerboard->Write('/interface/wireless/registration-table/getall', false);
    4328    $Routerboard->Write('=.proplist=signal-strength,mac-address,rx-rate,tx-rate', false);
  • trunk/Modules/NetworkConfigRouterOS/RouterboardAPI.php

    r677 r682  
    5050        $IP = 'ssl://'.$IP;
    5151    }
    52 
    5352    $this->Socket = @fsockopen($IP, $this->Port, $this->ErrorNo, $this->ErrorStr, $this->Timeout);
    5453    if($this->Socket)
     
    146145  function Read($Parse = true)
    147146  {
     147    $Line = '';
    148148    $Response = array();
    149149    while (true) {
  • trunk/style/new/style.css

    r607 r682  
    178178  width: auto;
    179179}
    180 
    181180
    182181.SystemMessage h3
Note: See TracChangeset for help on using the changeset viewer.