'$today' and time_stamp < '$tomorrow' group by remote_host"; $q3->query($dl206Count); while($q3->next_record()){ $num_206s = $q3->f("num_206s"); $ipAddress = $q3->f("remote_host"); //clear vars $org_name = ""; $org_id = ""; $country = ""; //get all IPs for this assoc with 2 or more if($num_206s >= $ipNumber){ //grab IP information from whois $this_whois = shell_exec("whois $ipAddress"); $parse_whois = explode("\n", $this_whois); foreach($parse_whois as $single_line){ //echo("$single_line\n\n\n"); if(stristr($single_line, "OrgName") || stristr($single_line, "org:")){ $org_name_array = explode(":", $single_line); $org_name = trim($org_name_array[1]); } elseif(stristr($single_line, "OrgID") || stristr($single_line, "netname")){ $org_id_array = explode(":",$single_line); $org_id = trim($org_id_array[1]); } elseif(stristr($single_line, "Country")){ $country_array = explode(":",$single_line); $country = trim($country_array[1]); } } //check for update or insert $q4 = new DB($squid); $query="select download_id from downloads where date = '$today' and ip_address = '$ipAddress' and download_name ='$download_file'"; $q4->query($query); if($q4->next_record()){ $download_id = $q4->f("download_id"); $query2 = "update downloads set num_requests = $num_206s, org_name = '$org_name' org_id = '$org_id', country = '$country' where download_id = $download_id"; } else{ $query2 = "insert into downloads (date,ip_address,download_name,num_requests,org_name,org_id,country) values ('$today','$ipAddress','$download_file',$num_206s,'$org_name','$org_id','$country'"; } $q5 = new DB($squid); //$q5->query($query2); echo("$today, $ipAddress, $download_file, $num_206s, $org_name, $org_id, $country\n"); } } } ?>