Ignore:
Timestamp:
Aug 2, 2009, 12:19:41 PM (15 years ago)
Author:
george
Message:
  • Přidáno: Podpora pro zasílání dat po menších balících pro třídu Routerboard.
  • Upraveno: Generování NATu uzpůsobeno pro třídu Routerboard.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/system/routerboard.php

    r239 r240  
    99  var $Password;
    1010  var $PrivateKey = 'id_dsa';
     11  var $MaxBurstLineCount = 100;
    1112 
    1213  function __construct($HostName = 'localhost', $UserName = 'admin', $Password = '')
     
    1819
    1920  function Execute($Commands)
     21  {
     22    $Output = array();
     23    if(is_array($Commands))
     24    {
     25      $I = 0;
     26      $Batch = array();
     27      while($I < count($Commands))
     28      {
     29        if(($I % $this->MaxBurstLineCount) == 0)
     30        {
     31          if(count($Batch) > 0)
     32            $Output = array_merge($Output, $this->ExecuteBatch(implode(';', $Batch)));
     33          $Batch = array();
     34        }
     35        $Batch[] = $Commands[$I];
     36        $I++;
     37      }
     38      if(count($Batch) > 0)
     39       $Output = array_merge($Output, $this->ExecuteBatch(implode(';', $Batch)));
     40    } else
     41      $Output = array_merge($Output, $this->ExecuteBatch($Commands));
     42    return($Output);
     43  }
     44 
     45  function ExecuteBatch($Commands)
    2046  {   
    21     if(is_array($Commands)) $Commands = implode(';', $Commands);
    2247    $Commands = trim($Commands);
    2348    if($Commands != '')
     
    2752      $Commands = str_replace('$', '\$', $Commands);
    2853      $Command = $this->SSHPath.' -o ConnectTimeout='.$this->Timeout.' -l '.$this->UserName.' -i '.$this->PrivateKey.' '.$this->HostName.' "'.$Commands.'"';
    29       //echo($Command);
     54      echo($Command);
    3055      exec($Command, $Output);
    3156    } else $Output = '';
    32     //print_r($Output);
     57    print_r($Output);
    3358    return($Output);
    3459  }
     
    76101      {
    77102        $Value = explode('=', $ResultLinePart);
    78         $ListItem[$Properties[$Value[0]]] = $Value[1];
     103        if(count($Value) > 1) $ListItem[$Properties[$Value[0]]] = $Value[1];
     104          else $ListItem[$Properties[$Value[0]]] = '';
    79105      }
    80106      $List[] = $ListItem;
     
    91117  {
    92118    $List = $this->ListGet($Path, $Properties, $Condition);
    93     //print_r($List);
    94     //print_r($Values);
    95119    $Commands = array();
     120   
     121    // Add empty properties to values
     122    foreach($Values as $Index => $Item)
     123    {
     124      foreach($Properties as $Property)
     125      {
     126        if(!array_key_exists($Property, $Item))
     127           $Item[$Property] = '';
     128      }
     129      $Values[$Index] = $Item;     
     130    }
     131   
     132    print_r($List);
     133    print_r($Values);
    96134   
    97135    // Erase all items not existed in $Values
     
    103141        foreach($ListItem as $Index => $Property)
    104142        {
    105           $Prop .= $Index.'="'.$Property.'" ';
     143          if($Property != '') $Prop .= $Index.'="'.$Property.'" ';
    106144        }
    107145        $Prop = substr($Prop, 0, -1);
     
    118156        foreach($ListItem as $Index => $Property)
    119157        {
    120           $Prop .= $Index.'='.$Property.' ';
     158          if($Property != '') $Prop .= $Index.'="'.$Property.'" ';
    121159        }
    122160        $Prop = substr($Prop, 0, -1);
     
    124162      }
    125163    }
    126     //print_r($Commands);
     164    print_r($Commands);
    127165    return($this->Execute($Commands));   
    128166  }
Note: See TracChangeset for help on using the changeset viewer.