1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
$response2 = '; <<>> DiG 9.2.4 <<>> axfr uuk ;; global options: printc uk. 28800 IN SOA agnd1.ax.nt. rot.ax.nt. 2006031001 604800 3600 uk. 28800 IN NS ag1.ax.ne. 28800 IN NS ag2.axa.n. G-010-NSR.uk. 28800 IN A 10.10.15.24 gr-ab-0-ce.u. 28800 IN A 10.10.19.9 gb-ae-03-s1.u. 28800 IN A 1.1.19.40 ';
$response = `dig axfr uk`;
print_r($response);
if(preg_match_all('/([^ ]+) [0-9]+ [a-z]+ [a-z]+ ([0-9.]+)/i', $response2 ou $response, $matches, PREG_SET_ORDER)){
foreach($matches as $match){
$select = "SELECT hostname FROM equipment_list WHERE hostname='$match[1]'";
$result = mysql_query($select);
$result1 = mysql_fetch_row($result);
//$del=0;
//if($match[1]==$result1[0]){
// $del=1;}
if($result1[0]==$match[1]){
$requete="UPDATE equipment_list SET address_IP='$match[2]' WHERE hostname='$match[1]'";
}
else {
$requete = "INSERT INTO equipment_list (hostname,address_IP) VALUES ('$match[1]','$match[2]')";
}
mysql_query($requete); // exécution de la requete
} |
Partager