Changeset 37 for system/statistic/known_mac.php
Legend:
- Unmodified
- Added
- Removed
-
system
-
Property svn:ignore
set to
nohup.out
-
Property svn:ignore
set to
-
system/statistic
-
Property svn:ignore
set to
nohup.out
-
Property svn:ignore
set to
-
system/statistic/known_mac.php
r1 r37 1 <? 2 include_once(' /a/html/is/db.php');3 DB_Init('localhost','root','','statistic');1 <?php 2 include_once('../html/global.php'); 3 $Database->select_db('statistic'); 4 4 5 5 while(1) 6 6 { 7 DB_Delete('ip_conntrack', '1');7 $Database->delete('ip_conntrack', '1'); 8 8 $File = fopen('/proc/net/arp', 'r'); 9 9 fgets($File); // Title row … … 20 20 if($Mac != '00:00:00:00:00:00') 21 21 { 22 DB_Select('known_mac', '*', 'ip="'.$Ip.'" AND mac="'.$Mac.'" AND interface="'.$Interface.'"');23 if( DB_NumRows() == 0) DB_Insert('known_mac', array('ip' => $Ip, 'mac' => $Mac, 'interface' => $Interface, 'first_time' => 'NOW()', 'last_time' => 'NOW()'));24 else DB_Update('known_mac', 'ip="'.$Ip.'" AND mac="'.$Mac.'" AND interface="'.$Interface.'"', array('last_time' => 'NOW()'));22 $DbResult = $Database->select('known_mac', '*', 'ip="'.$Ip.'" AND mac="'.$Mac.'" AND interface="'.$Interface.'"'); 23 if($DbResult->num_rows == 0) $Database->insert('known_mac', array('ip' => $Ip, 'mac' => $Mac, 'interface' => $Interface, 'first_time' => 'NOW()', 'last_time' => 'NOW()')); 24 else $Database->update('known_mac', 'ip="'.$Ip.'" AND mac="'.$Mac.'" AND interface="'.$Interface.'"', array('last_time' => 'NOW()')); 25 25 } 26 26 } … … 28 28 } 29 29 fclose($File); 30 DB_Query('OPTIMIZE TABLE known_mac');30 $Database->query('OPTIMIZE TABLE known_mac'); 31 31 Sleep(50); // ARP cache timeout = 60 seconds 32 32 }
Note:
See TracChangeset
for help on using the changeset viewer.