Changeset 241 for trunk/system/routerboard.php
- Timestamp:
- Aug 2, 2009, 4:56:48 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/system/routerboard.php
r240 r241 109 109 } 110 110 111 function ListGetPrint($Path, $Properties, $Conditions = array()) 112 { 113 $ConditionList = ''; 114 foreach($Conditions as $Index => $Item) 115 { 116 $ConditionList .= $Index.'="'.$Item.'" '; 117 } 118 $ConditionList = substr($ConditionList, 0, -1); 119 if(trim($ConditionList) != '') 120 $ConditionList = ' where '.$ConditionList; 121 122 $Result = $this->Execute(implode(' ', $Path).' print terse'.$ConditionList); 123 $List = array(); 124 foreach($Result as $ResultLine) 125 { 126 $ResultLineParts = explode(' ', $ResultLine); 127 $ListItem = array(); 128 foreach($ResultLineParts as $ResultLinePart) 129 { 130 $Value = explode('=', $ResultLinePart); 131 if(in_array($Value[0], $Properties)) 132 { 133 if(count($Value) > 1) 134 { 135 if($Value[1]{0} == '"') $Value[1] = substr($Value[1], 1, -1); 136 //if(strlen($Value[1]) > 0) 137 $ListItem[$Value[0]] = $Value[1]; 138 } else $ListItem[$Value[0]] = ''; 139 } 140 } 141 if(count($ListItem) > 0) $List[] = $ListItem; 142 } 143 return($List); 144 } 145 111 146 function ListEraseAll($Path) 112 147 { … … 114 149 } 115 150 116 function ListUpdate($Path, $Properties, $Values, $Condition = array()) 117 { 118 $List = $this->ListGet($Path, $Properties, $Condition); 151 function ListUpdate($Path, $Properties, $Values, $Condition = array(), $UsePrint = false) 152 { 153 if($UsePrint == 0) $List = $this->ListGet($Path, $Properties, $Condition); 154 else $List = $this->ListGetPrint($Path, $Properties, $Condition); 119 155 $Commands = array(); 120 156 … … 129 165 $Values[$Index] = $Item; 130 166 } 131 167 foreach($List as $Index => $Item) 168 { 169 foreach($Properties as $Property) 170 { 171 if(!array_key_exists($Property, $Item)) 172 $Item[$Property] = ''; 173 } 174 $List[$Index] = $Item; 175 } 176 177 // Sort properties 178 foreach($Values as $Index => $Item) 179 { 180 ksort($Values[$Index]); 181 } 182 foreach($List as $Index => $Item) 183 { 184 ksort($List[$Index]); 185 } 132 186 print_r($List); 133 187 print_r($Values); … … 144 198 } 145 199 $Prop = substr($Prop, 0, -1); 146 $Commands[] = implode(' ', $Path).' remove [find '.$Prop.']'; 200 if(trim($Prop) != '') 201 $Commands[] = implode(' ', $Path).' remove [find '.$Prop.']'; 147 202 } 148 203 }
Note:
See TracChangeset
for help on using the changeset viewer.