Changeset 658
- Timestamp:
- May 26, 2014, 1:00:20 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Application/Version.php
r657 r658 1 1 <?php 2 2 3 $Revision = 65 7; // Subversion revision3 $Revision = 658; // Subversion revision 4 4 $DatabaseRevision = 657; // SQL structure revision 5 5 $ReleaseTime = strtotime('2014-05-25'); -
trunk/Modules/NetworkConfigRouterOS/Generators/NetwatchImport.php
r657 r658 14 14 $StartTime = time(); 15 15 16 // Load netwatch status from all DHCP routers 16 // Load netwatch status from all DHCP routers 17 17 $DbResult3 = $System->Database->query('SELECT `DHCP`, `AddressRange`, `Mask` FROM `NetworkSubnet` '. 18 18 'WHERE (`Configure` = 1) AND (`Member` IS NULL) GROUP BY DHCP'); … … 29 29 if($Properties['status'] == 'up') $Online = 1; 30 30 else $Online = 0; 31 32 $DbResult = $System->Database->select('NetworkInterface', ' Online', '`LocalIP` = "'.$Properties['host'].'";');31 32 $DbResult = $System->Database->select('NetworkInterface', '`Id`,`Online`', '`LocalIP` = "'.$Properties['host'].'";'); 33 33 while($DbRow = $DbResult->fetch_assoc()) 34 34 { 35 35 $LastOnline = $DbRow['Online']; 36 $Interface = $DbRow[' NetworkInterface'];37 36 $Interface = $DbRow['Id']; 37 38 38 // Record state changes 39 39 if($Online != $LastOnline) 40 { 40 { 41 41 $System->Database->insert('NetworkInterfaceUpDown', array( 42 42 'Interface' => $Interface, 'State' => $Online, 'Time' => TimeToMysqlDateTime($StartTime))); 43 43 } 44 } ;45 44 } 45 46 46 if($Online) 47 47 { 48 $DbResult = $System->Database->update('NetworkInterface', '`LocalIP` = "'.$Properties['host'].'"', 48 $DbResult = $System->Database->update('NetworkInterface', '`LocalIP` = "'.$Properties['host'].'"', 49 49 array('Online' => 1, 'LastOnline' => TimeToMysqlDateTime($StartTime))); 50 } 50 } 51 51 } 52 } 52 } 53 53 $DbResult = $System->Database->update('NetworkInterface', '`LastOnline` < "'.TimeToMysqlDateTime($StartTime).'"', array('Online' => 0)); 54 54 … … 67 67 { 68 68 $DbResult2 = $System->Database->select('NetworkInterfaceStat', '*', '(`NetworkInterface`="'.$Interface['Id'].'") AND (`Time` = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))'); 69 if($DbResult2->num_rows == 0) $System->Database->query('REPLACE INTO `NetworkInterfaceStat` (`NetworkInterface`, `Time`, `PingCount`) VALUES ("'.$Interface['Id'].'", DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"), 1)'); 69 if($DbResult2->num_rows == 0) $System->Database->query('REPLACE INTO `NetworkInterfaceStat` (`NetworkInterface`, `Time`, `PingCount`) VALUES ("'.$Interface['Id'].'", DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"), 1)'); 70 70 else $System->Database->query('UPDATE `NetworkInterfaceStat` SET `PingCount` = `PingCount` + 1 WHERE (`NetworkInterface`="'.$Interface['Id'].'") AND (`Time` = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))'); 71 71 } -
trunk/Modules/NetworkConfigRouterOS/NetworkConfigRouterOS.php
r657 r658 16 16 $this->Dependencies = array('NetworkConfig'); 17 17 } 18 18 19 19 function DoInstall() 20 20 { 21 21 } 22 22 23 23 function DoUnInstall() 24 24 { … … 34 34 'Interface' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní', 'Default' => '', 'ReadOnly' => true), 35 35 'State' => array('Type' => 'Boolean', 'Caption' => 'Stav', 'Default' => '', 'ReadOnly' => true), 36 'Duration' => array('Type' => 'Time', 'Caption' => 'Trvání', 'Default' => '', 'ReadOnly' => true, 37 'SQL' => 'TIMEDIFF(`Time`,'. 38 '(SELECT `Time` FROM `NetworkInterfaceUpDown` AS `TA` WHERE (`TA`.`Time` > `TX`.`Time`) '. 39 'AND (`TA`.`Interface`=`TX`.`Interface`) ORDER BY `TA`.`Time` LIMIT 1))'), 36 40 ), 37 41 )); -
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.