0) { //we found the town: //add town to coords array: $coords[$i] = array(); $coords[$i]['town'] = $currTown; $coords[$i]['lat'] = mysql_result($result, 0, 'lat'); $coords[$i]['lng'] = mysql_result($result, 0, 'lng'); $id = mysql_result($result, 0, 'id'); //store the town's id $i++; //update provider in Towns $result = mysql_query("UPDATE Towns SET provider='$provider' WHERE id='$id'"); //check if it was down last time $result = mysql_query("SELECT id FROM DownNow WHERE id='$id'"); if(mysql_numrows($result) > 0) { //was down last time $result = mysql_query("Update DownNow SET downdate=NOW() WHERE id='$id'"); $isNew = false; } else { //new outage //add DownNow record $result = mysql_query("INSERT INTO DownNow VALUES ('$id',NOW())"); $isNew = true; } //add/update Outages record: $result = mysql_query("SELECT downcount FROM Outages WHERE id='$id'"); if(mysql_numrows($result) > 0) { //it's in Outages already $count = mysql_result($result, 0, 'downcount'); if($isNew == true) { $count++; //new outage, increment downcount $query = "UPDATE Outages SET downcount='$count', lastoutage=NOW() WHERE id='$id'"; $result = mysql_query($query); //execute the update } } else { //isn't in Outages yet, add it $result = mysql_query("INSERT INTO Outages VALUES ('$id',1,NOW(),NULL)"); } } //found town else{ print("\t\tnotFound.push(new Array());\n"); print("\t\tnotFound[notFound.length-1].push('" . $currTown . "');\n"); print("\t\tnotFound[notFound.length-1].push('" . $provider . "');\n"); } } //foreach $towns return $coords; } //GeocodeTowns() function ParseBHE() { $url = "http://www.bhe.com/about/outages/full_list.cfm"; $data = implode("", file($url)); $towns = array(); $i = 0; preg_match_all ("//", $data, $matches); foreach($matches[0] as $match) { preg_match ("/\)\">([^`]*?)<\/span>/", $match, $temp); $towns[$i] = trim(strtoupper($temp['1'])); $i++; } return $towns; } function ParseCMP() { $url = "http://www3.cmpco.com/outage/index.aspx"; $data = implode("", file($url)); $towns = array(); $i = 0; preg_match_all ("/