Changeset 851
- Timestamp:
- Oct 14, 2017, 12:18:10 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/NetworkConfigRouterOS/Generators/Signal.php
r781 r851 6 6 { 7 7 $Time = time(); 8 $Queries = array(); 8 9 9 10 // Load netwatch status from all DHCP routers … … 31 32 $DbRow = $DbResult->fetch_assoc(); 32 33 $Interface = $DbRow['Id']; 33 } else $Interface = null;34 } else $Interface = 'NULL'; 34 35 35 36 if(strpos($Properties['signal-strength'], '@') === false) … … 42 43 else $Strength = $Parts[0]; 43 44 } 44 $RateRx = substr($Properties['rx-rate'], 0, -3); // without MHz45 $RateTx = substr($Properties['tx-rate'], 0, -3); // without MHz46 $ this->Database->insert('NetworkSignal', array('MAC' => $Properties['mac-address'],47 'Value' => $Strength, 'RateRx' => $RateRx, 'RateTx' => $RateTx,48 'Time' => TimeToMysqlDateTime($Time), 'Interface' => $Interface, 'Device' => $Device['Id']));45 $RateRx = $this->StripUnits($Properties['rx-rate']); 46 $RateTx = $this->StripUnits($Properties['tx-rate']); 47 $Queries[] = 'INSERT INTO `NetworkSignal` (`MAC`, `Value`, `RateRx`, `RateTx`, `Time`, `Interface`, `Device`) VALUES '. 48 '("'.$Properties['mac-address'].'", '.$Strength.', '.$RateRx.', '.$RateTx.', "'. 49 TimeToMysqlDateTime($Time).'", '.$Interface.', '.$Device['Id'].')'; 49 50 /* 50 51 $DbResult = $this->Database->select('Measure', 'Id', '`Name` = "'.$Properties['mac-address'].'"'); … … 63 64 } 64 65 } 66 $this->Database->Transaction($Queries); 67 } 68 69 function StripUnits($Value) 70 { 71 if (strpos($Value, '-') !== false) $Value = substr($Value, 0, strpos($Value, '-') - 1); // without channel info 72 if (substr($Value, -3, 3) == "MHz") $Value = substr($Value, 0, -3); // without MHz unit 73 if (substr($Value, -4, 4) == "Mbps") $Value = substr($Value, 0, -4); // without Mbps unit 74 if (substr($Value, -3, 3) == "Mbp") $Value = substr($Value, 0, -3); // without Mbp unit 75 if (substr($Value, -1, 1) == "M") $Value = substr($Value, 0, -1); // without M unit 76 return($Value); 65 77 } 66 78 -
trunk/Packages/Common/Database.php
r841 r851 202 202 { 203 203 } 204 205 public function Transaction($Queries) 206 { 207 $this->PDO->beginTransaction(); 208 foreach ($Queries as $Query) 209 { 210 $Statement = $this->PDO->prepare($Query); 211 $Statement->execute(); 212 } 213 $this->PDO->commit(); 214 } 204 215 } 205 216
Note:
See TracChangeset
for help on using the changeset viewer.