Ignore:
Timestamp:
May 26, 2014, 1:00:20 AM (10 years ago)
Author:
chronos
Message:
  • Přidáno: V tabulce změn stavu síťových rozhraní zobrazovat také dobu trvání.
  • Opraveno: Neprováděly se skripty využívající třídu Routerboard.
  • Opraveno: Načítání stavu rozhraní z RouterOS.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/NetworkConfigRouterOS/Routerboard.php

    r656 r658  
    3939      if(count($Batch) > 0)
    4040       $Output = array_merge($Output, $this->ExecuteBatch(implode(';', $Batch)));
    41     } else 
     41    } else
    4242      $Output = array_merge($Output, $this->ExecuteBatch($Commands));
    4343    return($Output);
    4444  }
    45  
     45
    4646  function ExecuteBatch($Commands)
    47   {   
     47  {
    4848    $Commands = trim($Commands);
    4949    if($Commands != '')
     
    5151      $Commands = addslashes($Commands);
    5252      $Commands = str_replace('$', '\$', $Commands);
    53       //$Commands = str_replace(' ', '\ ', $Commands); 
     53      //$Commands = str_replace(' ', '\ ', $Commands);
    5454      $Command = $this->SSHPath.' -o ConnectTimeout='.$this->Timeout.' -l '.$this->UserName.' -i '.$this->PrivateKey.' '.$this->HostName.' "'.$Commands.'"';
    5555      if($this->Debug) echo($Command);
    5656      $Output = array();
    57       //exec($Command, $Output);
     57      exec($Command, $Output);
    5858    } else $Output = '';
    5959    if($this->Debug) print_r($Output);
     
    121121    $ConditionList = substr($ConditionList, 0, -1);
    122122    if(trim($ConditionList) != '')
    123       $ConditionList = ' where '.$ConditionList;   
     123      $ConditionList = ' where '.$ConditionList;
    124124
    125125    $Result = $this->Execute(implode(' ', $Path).' print terse'.$ConditionList);
     
    134134        if(in_array($Value[0], $Properties))
    135135        {
    136           if(count($Value) > 1) 
     136          if(count($Value) > 1)
    137137          {
    138             if($Value[1]{0} == '"') $Value[1] = substr($Value[1], 1, -1);           
     138            if($Value[1]{0} == '"') $Value[1] = substr($Value[1], 1, -1);
    139139            //if(strlen($Value[1]) > 0)
    140140            $ListItem[$Value[0]] = $Value[1];
     
    151151    $this->Execute(implode(' ', $Path).' { remove [find] }');
    152152  }
    153  
     153
    154154  function ListUpdate($Path, $Properties, $Values, $Condition = array(), $UsePrint = false)
    155155  {
    156156    // Get current list from routerboard
    157     if($UsePrint == 0) 
     157    if($UsePrint == 0)
    158158    {
    159159      $List = $this->ListGet($Path, $Properties, $Condition);
     
    167167        }
    168168      }
    169     } else 
    170     {
    171       $List = $this->ListGetPrint($Path, $Properties, $Condition);     
     169    } else
     170    {
     171      $List = $this->ListGetPrint($Path, $Properties, $Condition);
    172172    }
    173173    $Commands = array();
    174    
     174
    175175    // Add empty properties to values
    176176    foreach($Values as $Index => $Item)
     
    181181           $Item[$Property] = '';
    182182      }
    183       $Values[$Index] = $Item;     
     183      $Values[$Index] = $Item;
    184184    }
    185185    foreach($List as $Index => $Item)
     
    190190           $Item[$Property] = '';
    191191      }
    192       $List[$Index] = $Item;     
    193     }
    194    
     192      $List[$Index] = $Item;
     193    }
     194
    195195    // Sort properties
    196196    foreach($Values as $Index => $Item)
     
    204204    if($this->Debug) print_r($List);
    205205    if($this->Debug) print_r($Values);
    206        
     206
    207207    // Erase all items not existed in $Values
    208208    foreach($List as $Index => $ListItem)
     
    213213        foreach($ListItem as $Index => $Property)
    214214        {
    215           if($Property != '') 
     215          if($Property != '')
    216216          {
    217217            if(($Property == 'yes') or ($Property == 'no')) $Prop .= $Index.'='.$Property.' ';
     
    224224      }
    225225    }
    226    
     226
    227227    // Add new items
    228228    foreach($Values as $ListItem)
     
    240240    }
    241241    if($this->Debug) print_r($Commands);
    242     return($this->Execute($Commands));   
     242    return($this->Execute($Commands));
    243243  }
    244244}
Note: See TracChangeset for help on using the changeset viewer.