Changeset 658 for trunk/Modules/NetworkConfigRouterOS/Routerboard.php
- Timestamp:
- May 26, 2014, 1:00:20 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/NetworkConfigRouterOS/Routerboard.php
r656 r658 39 39 if(count($Batch) > 0) 40 40 $Output = array_merge($Output, $this->ExecuteBatch(implode(';', $Batch))); 41 } else 41 } else 42 42 $Output = array_merge($Output, $this->ExecuteBatch($Commands)); 43 43 return($Output); 44 44 } 45 45 46 46 function ExecuteBatch($Commands) 47 { 47 { 48 48 $Commands = trim($Commands); 49 49 if($Commands != '') … … 51 51 $Commands = addslashes($Commands); 52 52 $Commands = str_replace('$', '\$', $Commands); 53 //$Commands = str_replace(' ', '\ ', $Commands); 53 //$Commands = str_replace(' ', '\ ', $Commands); 54 54 $Command = $this->SSHPath.' -o ConnectTimeout='.$this->Timeout.' -l '.$this->UserName.' -i '.$this->PrivateKey.' '.$this->HostName.' "'.$Commands.'"'; 55 55 if($this->Debug) echo($Command); 56 56 $Output = array(); 57 //exec($Command, $Output);57 exec($Command, $Output); 58 58 } else $Output = ''; 59 59 if($this->Debug) print_r($Output); … … 121 121 $ConditionList = substr($ConditionList, 0, -1); 122 122 if(trim($ConditionList) != '') 123 $ConditionList = ' where '.$ConditionList; 123 $ConditionList = ' where '.$ConditionList; 124 124 125 125 $Result = $this->Execute(implode(' ', $Path).' print terse'.$ConditionList); … … 134 134 if(in_array($Value[0], $Properties)) 135 135 { 136 if(count($Value) > 1) 136 if(count($Value) > 1) 137 137 { 138 if($Value[1]{0} == '"') $Value[1] = substr($Value[1], 1, -1); 138 if($Value[1]{0} == '"') $Value[1] = substr($Value[1], 1, -1); 139 139 //if(strlen($Value[1]) > 0) 140 140 $ListItem[$Value[0]] = $Value[1]; … … 151 151 $this->Execute(implode(' ', $Path).' { remove [find] }'); 152 152 } 153 153 154 154 function ListUpdate($Path, $Properties, $Values, $Condition = array(), $UsePrint = false) 155 155 { 156 156 // Get current list from routerboard 157 if($UsePrint == 0) 157 if($UsePrint == 0) 158 158 { 159 159 $List = $this->ListGet($Path, $Properties, $Condition); … … 167 167 } 168 168 } 169 } else 170 { 171 $List = $this->ListGetPrint($Path, $Properties, $Condition); 169 } else 170 { 171 $List = $this->ListGetPrint($Path, $Properties, $Condition); 172 172 } 173 173 $Commands = array(); 174 174 175 175 // Add empty properties to values 176 176 foreach($Values as $Index => $Item) … … 181 181 $Item[$Property] = ''; 182 182 } 183 $Values[$Index] = $Item; 183 $Values[$Index] = $Item; 184 184 } 185 185 foreach($List as $Index => $Item) … … 190 190 $Item[$Property] = ''; 191 191 } 192 $List[$Index] = $Item; 193 } 194 192 $List[$Index] = $Item; 193 } 194 195 195 // Sort properties 196 196 foreach($Values as $Index => $Item) … … 204 204 if($this->Debug) print_r($List); 205 205 if($this->Debug) print_r($Values); 206 206 207 207 // Erase all items not existed in $Values 208 208 foreach($List as $Index => $ListItem) … … 213 213 foreach($ListItem as $Index => $Property) 214 214 { 215 if($Property != '') 215 if($Property != '') 216 216 { 217 217 if(($Property == 'yes') or ($Property == 'no')) $Prop .= $Index.'='.$Property.' '; … … 224 224 } 225 225 } 226 226 227 227 // Add new items 228 228 foreach($Values as $ListItem) … … 240 240 } 241 241 if($this->Debug) print_r($Commands); 242 return($this->Execute($Commands)); 242 return($this->Execute($Commands)); 243 243 } 244 244 }
Note:
See TracChangeset
for help on using the changeset viewer.