Example: !weather brisbane, australia" if (false) { mFunction::commandSend("PRIVMSG $username The number of queries must be from 1 to 9."); } else { $found = false; // mFunction::commandSend("PRIVMSG $username ".chr(2).chr(3)."4Location: '$location' | URLGen: http://www.google.com/search?q=$location".chr(2).chr(3)); if (true) { $num = 1; // this line sets it to get three query } echo "\nNum: $num\n"; $query = urlencode(trim($location)); echo "Query: $query\n\n
"; $sock = @fsockopen("www.wunderground.com",80,$errstr,$errno,20); // this line creates a socket on $sock if(!$sock) { die("ERROR: Socket faild to connect."); // this dies if the socket doesnt connect right } fwrite($sock, "GET /cgi-bin/findweather/getForecast?query=".$query." HTTP/1.1\r\n"); // this sents the GET HTTP command fwrite($sock, "Host: www.wunderground.com\r\n"); // this sends the HOST http command fwrite($sock, "Connection: Close\r\n\r\n"); // this sends to close the connection (HTTP COMMAND) while(!feof($sock)) { $rawhtml .= fgets($sock); // this line adds to $rawhtml (.= means to ADD to a variable, not overwrite it) while the connection is still present } if ($Search = strstr($rawhtml, "

Search Results:

")) { echo "Multiple Options Found.
\n\r"; $found = 2; $result = strstr($rawhtml, ''); $result = str_replace($antiResult, "", $result); $rowTracker = 'class="rowW"'; $rowSpliter = 'html">'; $rowTerminator = '<'; $results = explode($rowTracker, $result); echo "Count: ".count($results); $maxKey = 0; foreach ($results as $key => $place) { if ($key == 0) { } else { $key = $key - 1; $place = substr(strstr($place, $rowSpliter),6); $antiSpliter = strstr($place, $rowTerminator); $place = str_replace($antiSpliter, "", $place); $maxKey = $key; $results[$key] = trim($place); // echo "Place $key: $place
\r\n"; } } unset($results[(count($results) - 1)]); echo "MaxKey: $maxKey"; print_r($results); //echo $result; $Message = "PRIVMSG $username Search Results for '$location': "; $rows = (ceil((count($results) / 5)) - 1); for($inc = 0; $inc <= $rows; $inc++) { $offset = ($inc * 5); $x = $offset; while($x < ($offset + 5)) { $Message .= " $results[$x]"; $x++; } mFunction::commandSend("PRIVMSG $username $Message"); } } else { echo "Location Found.
\n\r"; $found = 1; /* // Location Parse $Place = substr(strstr($rawhtml, "

"),4); $antiPlace = strstr($Place, "

"); $Place = str_replace($antiPlace, "", $Place); // ----- // Time Parse $timeSplit = 'Local Time:'; $timeStart = ''; $timeEnd = ''; $time = str_replace(strstr(substr(strstr(strstr($rawhtml, $timeSplit), $timeStart), 3), $timeEnd), "", substr(strstr(strstr($rawhtml, $timeSplit),$timeStart), 3)); // echo "Time: $time"; // ----- // Temperature Parse $temp = explode('', $rawhtml, 4); unset($temp[0],$temp[1]); $temp[2] = strip_tags(str_replace(strstr($temp[2], ''), "", $temp[2])); $temp[3] = strip_tags(str_replace(strstr($temp[3], ''), "", $temp[3])); $temp = $temp[2]." | ".$temp[3]; // print_r($temp); // ----- // Condition Parse $condStart = '
'; $condEnd = '
'; $cond = str_replace(strstr(substr(strstr($rawhtml, $condStart), 37), $condEnd), "", substr(strstr($rawhtml, $condStart), 37)); // echo "cond: $cond"; // ----- // Humidity Parse $humidSplit = 'Humidity:'; $humidStart = ''; $humidEnd = ''; $humid = str_replace(strstr(substr(strstr(strstr($rawhtml, $humidSplit), $humidStart), 9), $humidEnd), "", substr(strstr(strstr($rawhtml, $humidSplit),$humidStart), 9)); // echo "humid: $humid"; // ----- // Wind Parse $windSplit = 'Wind:'; $windStart = 'metric="km/h">'; $windEnd = ''; $wind = str_replace(strstr(substr(strstr(strstr($rawhtml, $windSplit), $windStart), 14), $windEnd), "", substr(strstr(strstr($rawhtml, $windSplit),$windStart), 14)); // echo "wind: $wind"; // ----- // Pressure Parse $pressSplit = '>Pressure:'; $pressStart = ''; $pressEnd = ''; $press = strip_tags(str_replace(strstr(substr(strstr(strstr($rawhtml, $pressSplit), $pressStart), 3), $pressEnd), "", substr(strstr(strstr($rawhtml, $pressSplit),$pressStart), 3))); // echo "press: $press"; // ----- // Visibility Parse $visibSplit = '>Visibility:'; $visibStart = ''; $visibEnd = ''; $visib = strip_tags(str_replace(strstr(substr(strstr(strstr($rawhtml, $visibSplit), $visibStart), 3), $visibEnd), "", substr(strstr(strstr($rawhtml, $visibSplit),$visibStart), 3))); // echo "visib: $visib"; // ----- // UV Parse $uvSplit = 'UV:'; $uvStart = '>'; $uvEnd = ''; $uv = strip_tags(str_replace(strstr(substr(strstr(strstr($rawhtml, $uvSplit), $uvStart), 1), $uvEnd), "", substr(strstr(strstr($rawhtml, $uvSplit),$uvStart), 1))); // echo "uv: $uv"; // ----- // Cloud Parse $cloudSplit = 'Clouds:'; $cloudStart = ''; $cloudEnd = ' Day Title Parse $forcast = explode('', strstr($rawhtml, "5-Day Forecast")); $forcastTemps = explode('
', $forcast[2]); $days = explode('
', $forcast[1]); unset($forcast, $days[0]); $x = 0; foreach ($days as $key => $day) // 1,3, 4,6 { $offset = ($x * 2); $day = strip_tags($day); if ($x == 5) { $forcastTemp = $forcastTemps[($x + 1)]; $$forcastTemp = str_replace(strstr($forcastTemp, ''), "", $forcastTemp); } else { $forcastTemp = explode('">',$forcastTemps[($x + 1)]); $forcastTemp_1 = str_replace(strstr($forcastTemp[1], "<"), "", $forcastTemp[1]); $forcastTemp_2 = str_replace(strstr($forcastTemp[3], "<"), "", $forcastTemp[3]); $forcastTemp_3 = str_replace(strstr($forcastTemp[4], "<"), "", $forcastTemp[4]); $forcastTemp_4 = str_replace(strstr($forcastTemp[6], "<"), "", $forcastTemp[6]); $forcastTemp = $forcastTemp_1." | ".$forcastTemp_2. " |-:-| ".$forcastTemp_3." | ".$forcastTemp_4; // echo "

\n\rBANG: $BANG

\n\r"; } $forcast[$day] = array('temp' => $forcastTemp, 'cond' => $forcastCond, 'percip' => $forcastPercip); $x++; } // FORCAST -> Data Parse print_r($forcast); // print_r($forcast[3]); } // echo $rawhtml; $definition = explode("
",$rawhtml); // this like explodes (seperates on "); $subWeather = strstr($weather, "
"); $weather = str_replace($subWeather, "", $weather); $stuff = explode("
", $weather); // echo $weather; // print_r($stuff); $location = strip_tags($stuff[0]); $temp = strip_tags($stuff[1]); $condition = strip_tags($stuff[2]); $wind = strip_tags($stuff[3]); $moisture = explode("",$stuff[4],2); $moisture = $moisture[0]; $day1_name = strip_tags(substr(strstr($stuff[4],">"),1)); list($day1_high,$day1_low,$day2_name) = explode(" | ",$stuff[6],3); $day1_forcast = str_replace(strstr(substr(strstr(strstr($stuff[5], 'alt="'), '"'),1), '"'), "", substr(strstr(strstr($stuff[5], 'alt="'), '"'),1)); $day2_name = substr(strstr(strip_tags($day1_low),";"),1); list($day2_high,$day2_low,$day3_name) = explode(" | ",$stuff[8],3); $day2_forcast = str_replace(strstr(substr(strstr(strstr($stuff[7], 'alt="'), '"'),1), '"'), "", substr(strstr(strstr($stuff[7], 'alt="'), '"'),1)); $day3_name = substr(strstr(strip_tags($day2_low),";"),1); list($day3_high,$day3_low,$day4_name) = explode(" | ",$stuff[10],3); $day3_forcast = str_replace(strstr(substr(strstr(strstr($stuff[9], 'alt="'), '"'),1), '"'), "", substr(strstr(strstr($stuff[9], 'alt="'), '"'),1)); $day4_name = substr(strstr(strip_tags($day3_low),";"),1); list($day4_high,$day4_low) = explode(" | ",$stuff[12],2); $day4_forcast = str_replace(strstr(substr(strstr(strstr($stuff[11], 'alt="'), '"'),1), '"'), "", substr(strstr(strstr($stuff[11], 'alt="'), '"'),1)); $low1 = substr(strstr($day1_low, ";"),1); $low2 = str_replace(substr(strstr($day1_low, ";"),1), "", $day1_low); $forcast = array("first" => array("name" => strip_tags($day1_name), "high" => strip_tags($day1_high), "low" => str_replace(substr(strstr($day1_low, ";"),1), "", $day1_low), "condition" => strip_tags($day1_forcast)), "second" => array("name" => strip_tags($day2_name), "high" => strip_tags($day2_high), "low" => str_replace(substr(strstr($day2_low, ";"),1), "", $day2_low), "condition" => strip_tags($day2_forcast)), "third" => array("name" => strip_tags($day3_name), "high" => strip_tags($day3_high), "low" => str_replace(substr(strstr($day3_low, ";"),1), "", $day3_low), "condition" => strip_tags($day3_forcast)), "forth" => array("name" => strip_tags($day4_name), "high" => strip_tags($day4_high), "low" => str_replace(substr(strstr($day4_low, ";"),1), "", $day4_low), "condition" => strip_tags($day4_forcast)), ); print_r($forcast); echo "
Location: ".$location."
\r\nTemp: ".$temp."
\r\nCondition: ".$condition."
\r\nWind: ".$wind."
\r\nMoisture: ".$moisture."

Data:
".$day1_forcast."
Name: " .strip_tags($day1_name)."
High: ".$day1_high."
Low: ".$day1_low."
Forcast: ".$day1_forcast."
Day2: " .strip_tags($day2_name)."
High: ".$day2_high."
Low: ".$day2_low."
Forcast: ".$day2_forcast."
Day3: " .strip_tags($day3_name)."
High: ".$day3_high."
Low: ".$day3_low."
Forcast: ".$day3_forcast."
Day4: " .strip_tags($day4_name)."
High: ".$day4_high."
Low: ".$day4_low."
Forcast: ".$day4_forcast; */ for($i=1;$i<=$num;$i++) { // this counts down hwo many there are // $defParam = explode("", $definition[$i]); // $title = html_entity_decode(strip_tags($defParam[0]),ENT_QUOTES); // $defParam2 = explode("
", $defParam[1]); // $summary = html_entity_decode(strip_tags($defParam2[0]),ENT_QUOTES); // echo "Def Param: ".print_r($defParam2); if (strlen($summary) > 40) { $x = 0; $sumAry = array(); while ($sumAry[$x] > 40) { $sumAry[$x] = substr($summary, ($x * 40), 40)."\r\n"; $x++; } //$summary = implode("\r\n", $sumAry); } } } } } mWeather::Weather("USERNAME", "monroe, wa"); ?>