"; echo 'Preparing to download file
'; $fp = fopen($dat, 'w'); fwrite($fp,$startphp,strlen($startphp)); fclose($fp); $ch = curl_init("http://127.0.0.1:3000/dumpData.html?language=php&view=long"); $fp = fopen($dat, 'a'); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch); fclose($fp); $fp = fopen($dat, 'a'); fwrite($fp,$endphp,strlen($endphp)); fclose($fp); echo 'Done downloading file
'; include $dat; // Start of using array $db = mysql_connect("127.0.0.1", "ntop", "ntop") or die("Error ... check with network team"); mysql_select_db("ntop",$db); foreach ($ntopHash as $key => $value) { $addme = strpos($key,"192.168.7"); $data = array(); if ( $addme !== FALSE ) { array_push($data,$key); array_push($data,$ntopHash[$key]['hostSymIpAddress']); array_push($data,$dat); array_push($data,$ntopHash[$key]['ethAddressString']); array_push($data,$ntopHash[$key]['firstSeen']); array_push($data,$ntopHash[$key]['lastSeen']); array_push($data,$ntopHash[$key]['averageRcvdThpt']); array_push($data,$ntopHash[$key]['averageSentThpt']); array_push($data,$ntopHash[$key]['averageTThpt']); array_push($data,$ntopHash[$key]['icmpSent']); array_push($data,$ntopHash[$key]['icmpRcvd']); array_push($data,$ntopHash[$key]['IP']['FTP']['sendLoc']); array_push($data,$ntopHash[$key]['IP']['FTP']['rcvdLoc']); array_push($data,$ntopHash[$key]['IP']['FTP']['sentRem']); array_push($data,$ntopHash[$key]['IP']['FTP']['rcvdFromRem']); array_push($data,$ntopHash[$key]['IP']['HTTP']['sentLoc']); array_push($data,$ntopHash[$key]['IP']['HTTP']['rcvdLoc']); array_push($data,$ntopHash[$key]['IP']['HTTP']['sentRem']); array_push($data,$ntopHash[$key]['IP']['HTTP']['rcvdFromRem']); array_push($data,$ntopHash[$key]['IP']['DIFFHTTP']['sentLoc']); array_push($data,$ntopHash[$key]['IP']['DIFFHTTP']['rcvdLoc']); array_push($data,$ntopHash[$key]['IP']['DIFFHTTP']['sentRem']); array_push($data,$ntopHash[$key]['IP']['DIFFHTTP']['rcvdFromRem']); array_push($data,$ntopHash[$key]['IP']['DNS']['sentLoc']); array_push($data,$ntopHash[$key]['IP']['DNS']['rcvdLoc']); array_push($data,$ntopHash[$key]['IP']['DNS']['sentRem']); array_push($data,$ntopHash[$key]['IP']['DNS']['rcvdFromRem']); array_push($data,$ntopHash[$key]['IP']['Mail']['sentLoc']); array_push($data,$ntopHash[$key]['IP']['Mail']['rcvdLoc']); array_push($data,$ntopHash[$key]['IP']['Mail']['sentRem']); array_push($data,$ntopHash[$key]['IP']['Mail']['rcvdFromRem']); array_push($data,$ntopHash[$key]['IP']['DHCP-BOOTP']['sentLoc']); array_push($data,$ntopHash[$key]['IP']['DHCP-BOOTP']['rcvdLoc']); array_push($data,$ntopHash[$key]['IP']['DHCP-BOOTP']['sentRem']); array_push($data,$ntopHash[$key]['IP']['DHCP-BOOTP']['rcvdFromRem']); array_push($data,$ntopHash[$key]['IP']['SNMP']['sentLoc']); array_push($data,$ntopHash[$key]['IP']['SNMP']['rcvdLoc']); array_push($data,$ntopHash[$key]['IP']['SNMP']['sentRem']); array_push($data,$ntopHash[$key]['IP']['SNMP']['rcvdFromRem']); array_push($data,$ntopHash[$key]['IP']['NNTP']['sentLoc']); array_push($data,$ntopHash[$key]['IP']['NNTP']['rcvdLoc']); array_push($data,$ntopHash[$key]['IP']['NNTP']['sentRem']); array_push($data,$ntopHash[$key]['IP']['NNTP']['rcvdFromRem']); array_push($data,$ntopHash[$key]['IP']['SSH']['sentLoc']); array_push($data,$ntopHash[$key]['IP']['SSH']['rcvdLoc']); array_push($data,$ntopHash[$key]['IP']['SSH']['sentRem']); array_push($data,$ntopHash[$key]['IP']['SSH']['rcvdFromRem']); array_push($data,$ntopHash[$key]['IP']['Messenger']['sentLoc']); array_push($data,$ntopHash[$key]['IP']['Messenger']['rcvdLoc']); array_push($data,$ntopHash[$key]['IP']['Messenger']['sentRem']); array_push($data,$ntopHash[$key]['IP']['Messenger']['rcvdFromRem']); foreach ( $data as $key => $value ) { $data_table = $data_table . '\'' . $value . '\','; } $data_table = substr($data_table,0,(strlen($data_table)-1)); $sql = "INSERT INTO ntop_daily VALUES ($data_table)"; $result = mysql_query($sql) or die("Error ..... check with network team " . mysql_error()); if ( $result === FALSE ) { exec('/home/mis/email "NTOP Night Update FAILED" "The NTOP nightly update failed" \&/> /dev/null'); } } unset($data_table); unset($data); } mysql_close($db); ?>