<?php
require_once "config.php";

global $DB;

$data_t = $DB->selectPage($totalCount,"SELECT id,mac,ip FROM internet ORDER BY id");
foreach($data_t as $data_k=>$data_v)
{
	if($data_v[mac]=='' && $data_v[ip]!='')
	{
		$err=exec("/usr/sbin/arp -n $data_v[ip] | sed 's/? (//g' | sed 's/) at / /g' | sed 's/ on re0//g' | cut -d ' ' -f 2",$out);
		$err1=exec("/usr/sbin/arp -na | grep $err | sed 's/? (//g' | sed 's/) at / /g' | sed 's/ on re0//g' | cut -d ' ' -f 2",$out1);
		if ($err1==$err)
		{
			$obj["mac"]=$err;
			$DB->query("UPDATE internet set ?a WHERE id=?d",$obj,$data_v[id]);
		}
	}
}
?>
