Changeset 657


Ignore:
Timestamp:
May 25, 2014, 8:29:03 PM (10 years ago)
Author:
chronos
Message:
  • Přidáno: Záznam změn online stavu dostupnosti rozhraní do tabulky.
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/FormClasses.php

    r647 r657  
    760760    'Filter' => '1',
    761761  ),
    762   'TFinanceInvoiceItemListInvoice' => array(
     762  'TNetworkInterfaceUpDown' => array(
     763    'Type' => 'ManyToOne',
     764    'Table' => 'NetworkInterfaceUpDown',
     765    'Id' => 'Id',
     766    'Ref' => 'Interface',
     767    'Filter' => '1',
     768  ),
     769        'TFinanceInvoiceItemListInvoice' => array(
    763770    'Type' => 'ManyToOne',
    764771    'Table' => 'FinanceInvoiceItem',
  • trunk/Application/System.php

    r634 r657  
    1313  /** @var Database */
    1414  var $Database;
    15   var $Modules; 
     15  var $Modules;
    1616  /** @var Type */
    1717  var $Type;
     
    3838    if(substr($this->RootURLFolder, -10, 10) == '/index.php')
    3939      $this->RootURLFolder = substr($this->RootURLFolder, 0, -10);
    40   } 
    41  
     40  }
     41
    4242  function RegisterPage($Path, $Handler)
    4343  {
     
    4848      foreach($Path as $PathItem)
    4949      {
    50         $Page = &$Page[$PathItem];       
     50        $Page = &$Page[$PathItem];
    5151      }
    5252      if(!is_array($Page)) $Page = array('' => $Page);
     
    5454    } else $this->Pages[$Path] = $Handler;
    5555  }
    56  
     56
    5757  function UnregisterPage($Path)
    5858  {
    59     unset($this->Pages[$Path]); 
    60   }
    61  
     59    unset($this->Pages[$Path]);
     60  }
     61
    6262  function SearchPage($PathItems, $Pages)
    6363  {
     
    6666    if(array_key_exists($PathItem, $Pages))
    6767    {
    68       if(is_array($Pages[$PathItem])) 
     68      if(is_array($Pages[$PathItem]))
    6969      {
    7070        array_shift($PathItems);
     
    7373    } else return('');
    7474  }
    75  
     75
    7676  function PageNotFound()
    7777  {
    7878    return('Page '.implode('/', $this->PathItems).' not found.');
    7979  }
    80  
     80
    8181  function ShowPage()
    8282  {
    8383        /* @var $Page Page */
    84     $ClassName = $this->SearchPage($this->PathItems, $this->Pages);     
    85     if($ClassName != '') 
     84    $ClassName = $this->SearchPage($this->PathItems, $this->Pages);
     85    if($ClassName != '')
    8686    {
    8787      $Page = new $ClassName($this);
     
    9292    }
    9393  }
    94  
     94
    9595  function ModulePresent($Name)
    9696  {
     
    103103    $this->Modules[get_class($Module)] = $Module;
    104104  }
    105  
     105
    106106  function HumanDate($Time)
    107107  {
    108108    return(date('j.n.Y', $Time));
    109109  }
    110  
     110
    111111  function Link($Target)
    112112  {
    113113    return($this->RootURLFolder.$Target);
    114114  }
    115  
     115
    116116  function ShowAction($Id)
    117117  {
     
    136136        global $Database, $ScriptTimeStart, $ConfigFileName, $Mail, $Type,
    137137      $DatabaseRevision, $Config;
    138  
     138
    139139    date_default_timezone_set('Europe/Prague');
    140140    mb_internal_encoding("UTF-8");
    141141    $ScriptTimeStart = GetMicrotime();
    142  
     142
    143143    // SQL injection hack protection
    144144    foreach($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item);
     
    147147    if(isset($_SERVER['REMOTE_ADDR'])) session_start();
    148148
    149     $ConfigFileName = dirname(__FILE__).'/../config.php';     
    150     if(file_exists($ConfigFileName)) 
     149    $ConfigFileName = dirname(__FILE__).'/../config.php';
     150    if(file_exists($ConfigFileName))
    151151      $this->ConfigManager->LoadFromFile($ConfigFileName);
    152152    //$this->Config = $this->ConfigManager->GetAsArray();
    153153    $this->Config = &$Config;
    154    
    155     try { 
    156       $this->Database->Connect($this->Config['Database']['Host'], $this->Config['Database']['User'], 
     154
     155    try {
     156      $this->Database->Connect($this->Config['Database']['Host'], $this->Config['Database']['User'],
    157157        $this->Config['Database']['Password'], $this->Config['Database']['Database']);
    158158      $this->Database->Prefix = $this->Config['Database']['Prefix'];
     
    166166      $this->RootURLFolder = $this->Config['Web']['RootFolder'];
    167167    $this->FormManager->Root = $this->RootURLFolder;
    168  
     168
    169169    $this->RegisterPageBar('Top');
    170  
    171     $Database = $this->Database; 
    172     RegisterFormClasses($this->FormManager); 
    173  
     170
     171    $Database = $this->Database;
     172    RegisterFormClasses($this->FormManager);
     173
    174174    // Register and start existing modules
    175175    $this->Setup = new Setup($this);
     
    183183      $this->PathItems = ProcessURL();
    184184      $this->ShowPage();
    185     }   
    186   }
    187  
     185    }
     186  }
     187
    188188  function RegisterPageBar($Name)
    189189  {
     
    206206  var $FullTitle = 'Stránka nenalezena';
    207207  var $ShortTitle = 'Stránka nenalezena';
    208  
     208
    209209  function __construct($System)
    210210  {
     
    215215  function Show()
    216216  {
    217     Header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found'); 
     217    Header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
    218218    return('<h3 align="center">Požadovaná stránka neexistuje.</h3>');
    219219  }
  • trunk/Application/Version.php

    r656 r657  
    11<?php
    22
    3 $Revision = 656; // Subversion revision
    4 $DatabaseRevision = 656; // SQL structure revision
    5 $ReleaseTime = strtotime('2014-05-16');
     3$Revision = 657; // Subversion revision
     4$DatabaseRevision = 657; // SQL structure revision
     5$ReleaseTime = strtotime('2014-05-25');
  • trunk/Common/AppModule.php

    r613 r657  
    335335  function LoadModulesFromDir($Directory)
    336336  {
    337     $List = scandir($Directory);
     337        $List = scandir($Directory);     
    338338    foreach($List as $Item)
    339339    {
     
    349349  function LoadModules()
    350350  {
    351     if(method_exists($this->OnLoadModules[0], $this->OnLoadModules[1]))
     351        if(method_exists($this->OnLoadModules[0], $this->OnLoadModules[1]))
    352352      $this->OnLoadModules();
    353353    else $this->LoadModulesFromDir(dirname(__FILE__).'/../Modules');
  • trunk/Common/Setup/Updates.php

    r656 r657  
    706706}
    707707
     708function UpdateTo657($Manager)
     709{
     710        $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkInterfaceUpDown` (
     711  `Id` int(11) NOT NULL AUTO_INCREMENT,
     712  `Time` datetime NOT NULL,
     713  `Interface` int(11) NOT NULL,
     714  `State` int(11) NOT NULL,
     715  PRIMARY KEY (`Id`),
     716  KEY `Interface` (`Interface`)
     717) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;');
     718  $Manager->Execute('ALTER TABLE `NetworkInterfaceUpDown`
     719    ADD CONSTRAINT `NetworkInterfaceUpDown_ibfk_1` FOREIGN KEY (`Interface`) REFERENCES `NetworkInterface` (`Id`);');
     720  $Manager->Execute("INSERT INTO `Action` (
     721`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,`Group` ,`Icon` ,`PermissionOperation` ,
     722`Enable`) VALUES (NULL , '', 'Změny stavu rozhraní', '1', '/is/?t=NetworkInterfaceUpDown&a=list', NULL , NULL , NULL , '1'
     723);");
     724  $ActionId = $Manager->Database->insert_id;
     725  $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
     726    "VALUES (NULL , 'Změny stavu rozhraní', 4, '".$ActionId."', '1');");
     727}
     728
    708729class Updates
    709730{
     
    745766      645 => array('Revision' => 646, 'Function' => 'UpdateTo646'),
    746767      646 => array('Revision' => 647, 'Function' => 'UpdateTo647'),
     768      647 => array('Revision' => 657, 'Function' => 'UpdateTo657'),
    747769    ));
    748770  }
  • trunk/Modules/Network/Network.php

    r647 r657  
    230230        'Links1' => array('Type' => 'TNetworkLinkListInterface1', 'Caption' => 'Propojení 1', 'Default' => ''),
    231231        'Links2' => array('Type' => 'TNetworkLinkListInterface2', 'Caption' => 'Propojení 2', 'Default' => ''),
     232        'UpDown' => array('Type' => 'TNetworkInterfaceUpDown', 'Caption' => 'Změny stavu', 'Default' => ''),
    232233      ),
    233234    ));
  • trunk/Modules/NetworkConfigRouterOS/Generators/NetwatchImport.php

    r626 r657  
    1515
    1616  // Load netwatch status from all DHCP routers
    17   $DbResult3 = $System->Database->query('SELECT DHCP, AddressRange, Mask FROM `NetworkSubnet` WHERE (`Configure` = 1) AND (`Member` IS NULL) GROUP BY DHCP');
     17  $DbResult3 = $System->Database->query('SELECT `DHCP`, `AddressRange`, `Mask` FROM `NetworkSubnet` '.
     18                'WHERE (`Configure` = 1) AND (`Member` IS NULL) GROUP BY DHCP');
    1819  while($Subnet = $DbResult3->fetch_assoc())
    1920  {
     
    2627    foreach($List as $Properties)
    2728    {
    28       if($Properties['status'] == 'up')
     29      if($Properties['status'] == 'up') $Online = 1;
     30        else $Online = 0;
     31       
     32      $DbResult = $System->Database->select('NetworkInterface', 'Online', '`LocalIP` = "'.$Properties['host'].'";');
     33      while($DbRow = $DbResult->fetch_assoc())
     34      {
     35        $LastOnline = $DbRow['Online'];
     36        $Interface = $DbRow['NetworkInterface'];
     37       
     38        // Record state changes
     39        if($Online != $LastOnline)
     40        {     
     41          $System->Database->insert('NetworkInterfaceUpDown', array(
     42                  'Interface' => $Interface, 'State' => $Online, 'Time' => TimeToMysqlDateTime($StartTime)));
     43        }
     44      };
     45       
     46      if($Online)
    2947      {
    3048        $DbResult = $System->Database->update('NetworkInterface', '`LocalIP` = "'.$Properties['host'].'"',
  • trunk/Modules/NetworkConfigRouterOS/NetworkConfigRouterOS.php

    r617 r657  
    2727  function DoStart()
    2828  {
     29    $this->System->FormManager->RegisterClass('NetworkInterfaceUpDown', array(
     30      'Title' => 'Změny stavu rozhraní',
     31      'Table' => 'NetworkInterfaceUpDown',
     32      'Items' => array(
     33        'Time' => array('Type' => 'DateTime', 'Caption' => 'Čas', 'Default' => '', 'ReadOnly' => true),
     34        'Interface' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní', 'Default' => '', 'ReadOnly' => true),
     35        'State' => array('Type' => 'Boolean', 'Caption' => 'Stav', 'Default' => '', 'ReadOnly' => true),
     36      ),
     37    ));
    2938  }
    3039}
Note: See TracChangeset for help on using the changeset viewer.