Changeset 861
- Timestamp:
- Oct 2, 2019, 12:15:16 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/NetworkConfigRouterOS/Generators/DHCP.php
r860 r861 28 28 $Name = $Interface['DeviceName']; 29 29 if($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 30 $Items[] = array('mac-address' => $Interface['MAC'], 'address' => $Interface['LocalIP'], 'server' => $Server, 'comment' => $Name, 'lease-time' => ' 24h');30 $Items[] = array('mac-address' => $Interface['MAC'], 'address' => $Interface['LocalIP'], 'server' => $Server, 'comment' => $Name, 'lease-time' => '1d'); 31 31 } 32 32 -
trunk/Modules/NetworkConfigRouterOS/Generators/NetwatchImport.php
r860 r861 43 43 44 44 $Queries = array(); 45 $QueriesInsert = array(); 46 $QueriesUpdate = array(); 45 47 foreach($Interfaces as $Index => $Interface) 46 48 { 47 49 // Update last online time if still online 48 50 if($Interface['NewOnline']) 49 $Queries[] = $this->Database->GetUpdate('NetworkInterface', '`Id` = "'.$Interface['Id'].'"',51 $Queries[] = $this->Database->GetUpdate('NetworkInterface', '`Id` = '.$Interface['Id'], 50 52 array('LastOnline' => TimeToMysqlDateTime($StartTime))); 51 53 … … 53 55 { 54 56 // Online state changed 55 $Queries [] = 'INSERT INTO `NetworkInterfaceUpDown` (`Interface`,56 `State`, `Time`, `Duration`) VALUES ('.$Interface['Id'].', '.$Interface['NewOnline'].', "'.57 $QueriesInsert[] = 'INSERT INTO `NetworkInterfaceUpDown` (`Interface`,'. 58 '`State`, `Time`, `Duration`) VALUES ('.$Interface['Id'].', '.$Interface['NewOnline'].', "'. 57 59 TimeToMysqlDateTime($StartTime).'", NULL)'; 58 60 // Update previous record duration in UpDown table 59 $Queries [] = 'UPDATE `NetworkInterfaceUpDown` AS `TM` SET `Duration` = TIMESTAMPDIFF(SECOND, '.61 $QueriesUpdate[] = 'UPDATE `NetworkInterfaceUpDown` AS `TM` SET `Duration` = TIMESTAMPDIFF(SECOND, '. 60 62 '`TM`.`Time`, (SELECT `Time` FROM (SELECT * FROM `NetworkInterfaceUpDown`) AS `TA` WHERE (`TA`.`Time` > `TM`.`Time`) '. 61 63 'AND (`TA`.`Interface`=`TM`.`Interface`) ORDER BY `TA`.`Time` ASC LIMIT 1)) '. … … 65 67 } 66 68 } 69 echo("transakce insert\n"); 70 $this->Database->Transaction($QueriesInsert); 71 echo("done\n"); 67 72 echo("transakce\n"); 68 73 $this->Database->Transaction($Queries); 74 echo("done\n"); 75 echo("transakce\n"); 76 $this->Database->Transaction($QueriesUpdate); 69 77 echo("done\n"); 70 78 -
trunk/Modules/NetworkConfigRouterOS/RouterboardAPI.php
r738 r861 54 54 { 55 55 socket_set_timeout($this->Socket, $this->Timeout); 56 $this->Write('/login'); 56 $this->Write('/login', false); 57 $this->Write('=name=' . $Login, false); 58 $this->Write('=password='.$Password); 57 59 $Response = $this->Read(false); 58 if ((count($Response) > 1) and ($Response[0] == '!done')) { 59 if (preg_match_all('/[^=]+/i', $Response[1], $Matches)) { 60 if ($Matches[0][0] == 'ret' && strlen($Matches[0][1]) == 32) { 61 $this->Write('/login', false); 62 $this->Write('=name=' . $Login, false); 63 $this->Write('=response=00'.md5(chr(0).$Password.pack('H*', $Matches[0][1]))); 64 $Response = $this->Read(false); 65 if((count($Response) > 0) and ($Response[0] == '!done')) $this->Connected = true; 66 } 67 } 68 } 60 if((count($Response) > 0) and ($Response[0] == '!done')) $this->Connected = true; 69 61 if(!$this->Connected) fclose($this->Socket); 70 62 } -
trunk/Packages/Common/Database.php
r858 r861 96 96 //echo('a'.$this->ShowSQLQuery.'<'.$QueryStartTime.', '.microtime_float()); 97 97 if(($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true)) 98 $Duration = ' ; '.round(microtime_float() - $QueryStartTime, 4). ' s'; 99 if($this->LogSQLQuery == true) 98 { 99 $Time = round(microtime_float() - $QueryStartTime, 4); 100 $Duration = ' ; '.$Time. ' s'; 101 } 102 if(($this->LogSQLQuery == true) and ($Time != 0)) 100 103 file_put_contents($this->LogFile, $Query.$Duration."\n", FILE_APPEND); 101 104 if($this->ShowSQLQuery == true) … … 222 225 public function Transaction($Queries) 223 226 { 224 $this->PDO->beginTransaction(); 225 foreach ($Queries as $Query) 226 { 227 $Statement = $this->PDO->prepare($Query); 228 $Statement->execute(); 229 } 230 $this->PDO->commit(); 227 //echo('|'."\n"); 228 $this->PDO->beginTransaction(); 229 foreach ($Queries as $Query) 230 { 231 //echo('|'.$Query."\n"); 232 $Statement = $this->PDO->prepare($Query); 233 $Statement->execute(); 234 } 235 $this->PDO->commit(); 231 236 } 232 237 }
Note:
See TracChangeset
for help on using the changeset viewer.