|
aohavkbs, http://www.tomshw.it/forum/members/buy-glucophage.html glucophage conveniente, tndgogaw, http://www.tomshw.it/forum/members/comprar-zyprexa.html zyprexa conveniente, vtyyhpgn, http://www.tomshw.it/forum/members/comprar-desyrel.html desyrel conveniente, fxjgwxxe, http://www.tomshw.it/forum/members/comprar-cytotec.html cytotec prezzo ridotto, sazxpbxj, |
Assignment2KateGrandma Online version: http://ernie.art.yale.edu/~katehowe/weatherSearch/weathergoogle.html Request page: <html> <head> <title>Untitled-5</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> body { width: $body_width; background-color: $background_color; margin: 0px 0 0 $left_margin; color: $type_color; font-family: 'Courier New'; font-weight: $font_weight; font-size: $font_size; line-height: $line_height; letter-spacing: $letter_spacing; } </style> </head> <body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> <!-- ImageReady Slices (Untitled-5) --> <img src="images/key5.gif" width="1341" height="1025" alt=""> <div id="address" style="position:absolute; left:294 px; top:140px; width:350px; height:300px; z-index:1" class="body"><form action="http://ernie.art.yale.edu/~katehowe/weatherSearch/kate2.php" method="get"> Please enter your zip code <BR> <input type="text" name="userZip"> <br> Please enter your query <br> <input type="text" name="userQuery"> <br> <input type="submit" value="which way does the wind blow?"> </form><br> </div> <!-- End ImageReady Slices --> </body> </html> Response page: <?php // ------- get user data $userZip = $_REQUEST["userZip"]; $userQuery = $_REQUEST["userQuery"]; // ------- send zip to yahoo //-----LOAD THE XML (RSS) FEED // first just load the file as straight data. We need to strip out some yahoo garbage before we can begin. $xmlContents = file_get_contents ("http://xml.weather.yahoo.com/forecastrss?p=$userZip"); $xmlContents = str_replace ("yweather:","",$xmlContents); // str_replace searches and replaces $xmlContents = str_replace ("geo:","",$xmlContents); // now load the string into SimpleXML $xml = simplexml_load_string ($xmlContents); // for convenience, load the data we care about into variables // <channel> node contains some of the info $channel = $xml->channel; // Location name: only the attributes are meaningful $location = $channel->location; $city = $location["city"]; // e.g. "New Haven" $region = $location["region"]; // e.g. "CT" $country = $location["country"]; // e.g. "US" // Units info: only the attributes are meaningful $units = $channel->units; $tempUnits = $units["temperature"]; // e.g. "F" $distanceUnits = $units["distance"]; // e.g. "mi" $pressureUnits = $units["pressure"]; // e.g. "in" $speedUnits = $units["speed"]; // e.g. "mph" // Wind data: only the attributes are meaningful $wind = $channel->wind; $windChill = $wind["chill"]; // e.g. "57" $windDir = $wind["direction"]; // e.g. "350" $windSpeed = $wind["speed"]; // e.g. "7" // Atmosphere data: only the attributes are meaningful $atmosphere = $channel->atmosphere; $humidity = $atmosphere["humidity"]; // e.g. "93"; $visibility = $atmosphere["visibility"]; // e.g. "1609"; $pressure = $atmosphere["pressure"]; // e.g. "30.12"; $rising = $atmosphere["rising"]; // e.g. "0"; // Astronomy data: only the attributes are meaningful $astronomy = $channel->astronomy; $sunrise = $astronomy["sunrise"]; // e.g. "7:02 am"; $sunset = $astronomy["sunset"]; // e.g. "4:51 pm"; // <item> node is within the <channel> node, contains additional info $item = $channel->item; // Condition data: only the attributes are meaningful $condition = $item->condition; $conditionText = $condition["text"]; // e.g. "Mostly Cloudy" (corresponds to code below) $conditionCode = $condition["code"]; // e.g. "26" (47 possibilities) $temp = $condition["temp"]; // e.g. 57 $date = $condition["date"]; // e.g. Tue, 29 Nov 2005 3:56 pm PST /* // ------- forecast variables useful for v 2.0 // <forecast> nodes are within the item nodes,one per forecasted day,sothis will be an array $forecast = $item -> forecast; //---DISPLAY THE FORCAST for ($forecastNum = 0; $forecastNum < count($forecast); $forecastNum++) { $thisForecast = $forecast[$forecastNum]; $forecastDay = $thisForecast ["day"]; $forecastDate = $thisForecast ["date"]; $forecastLow = $thisForecast ["low"]; $forecastHigh = $thisForecast ["high"]; $forecastConditionText = $thisForecast ["text"]; $forecastConditionCode = $thisForecast ["code"]; } */ // ------- send query term to google // now do the Google search // this licence key has been assigned by Google to our class $googleKey = '9d/wzt5QFHLCSb/PTZbmdzBKzmkHnlxO'; // what should we search for? // ----- MAKE THE SOAP CLIENT $client = new SoapClient("http://api.google.com/GoogleSearch.wsdl"); // ----- DO THE REQUEST (using remotemethod invocation) $response = $client -> doGoogleSearch( $googleKey, // the key $userQuery, // the search query 0, // the point in the search resilts where we want to start 10, // the number of search results (max is 10) false, // don't filter out similar results "", // no restricts false, // no SafeSearch filter (for porn) "", // no language restricts "", // not used "" // not used ); // ------- translate weather data into formatting // temp $font_size = $temp / 4; $font_size = $font_size; // wind speed $letter_spacing = $windSpeed / 3; $letter_spacing = $letter_spacing; // pressure if ($pressure < 33 ) { $font_weight = "normal"; } else if (($pressure >= 33) and ($pressure < 66)) { $font_weight = "normal"; } else { $font_weight = "bold"; } // humidity $line_height = $humidity / 2; // condition $condition_colors = array( 0 => '534343', 1 => '066440', 2 => '0a0f4a', 3 => '434448', 4 => '74768c', 5 => 'c3c4c9', 6 => '838599', 7 => 'a7a9c2', 8 => 'a2a2a4', 9 => 'c2b6d5', 10 => '8babbb', 11 => '92b7c0', 12 => '92b7c0', 13 => 'e1d1e2', 14 => 'f1e3ee', 15 => 'd6cae6', 16 => 'f5f2f9', 17 => 'c2bbcd', 18 => '53707b', 19 => 'bf9d4a', 20 => 'e1dde1', 21 => '768f83', 22 => '433654', 23 => '0f6483', 24 => '04b671', 25 => '4bebf5', 26 => '9da1a1', 27 => '404242', 28 => '829293', 29 => '154144', 30 => '97bdbf', 31 => '08247c', 32 => 'fbe102', 33 => '0313b1', 34 => '02d9e6', 35 => 'c0bcc6', 36 => 'f65718', 37 => 'b18371', 38 => '5c8262', 39 => '5c8262', 40 => '558489', 41 => 'f4f8f9', 42 => 'c8e0e3', 43 => 'f4f8f9', 44 => '90cdcc', 45 => '28605f', 46 => 'dbe8e8', 47 => '7fa3a3', ); $background_color = $condition_colors["$conditionCode"]; // visibility $type_color = $background_color; // convert hexadecimal color to rgb value (decimal) $r = hexdec(substr($type_color, 0, 2)); $g = hexdec(substr($type_color, 2, 2)); $b = hexdec(substr($type_color, 4, 2)); // low if ($visibility < 50 ) { // reduce color value for r, g, b $r = $r * 0.3; $g = $g * 0.3; $b = $b * 0.3; // convert back into hex values $r = dechex($r); $g = dechex($g); $b = dechex($b); // combine into single html hex entity $type_color = $r . $g . $b; // med } else if (($visibility >= 50) and ($visibility < 1000)) { $r = $r * 0.6; $g = $g * 0.6; $b = $b * 0.6; $r = dechex($r); $g = dechex($g); $b = dechex($b); $type_color = $r . $g . $b; // high } else { $type_color = "000000"; } //echo $r . '|' . $g . '|' . $b; exit; // sunrise/sunset (day length) $display_sunrise = $sunrise; $sunrise_hour = preg_replace('/(\d\d*):.*/', '\1',$display_sunrise); $sunrise_min = preg_replace('/.*:(\d\d).*/', '\1',$display_sunrise); settype($sunrise_hour, 'integer'); settype($sunrise_min, 'integer'); $sunrise_min = ($sunrise_hour * 60) + $sunrise_min; $left_margin = ($sunrise_min - 300) / 1.5; settype($left_margin, 'integer'); // body width $display_sunset = $sunset; $sunset_hour = preg_replace('/(\d\d*):.*/', '\1',$display_sunset); $sunset_min = preg_replace('/.*:(\d\d).*/', '\1',$display_sunset); settype($sunset_hour, 'integer'); settype($sunset_min, 'integer'); $sunset_min = ($sunset_hour * 60) + $sunset_min; $body_width = ($sunset_min + 420); settype($body_width, 'integer'); // ------- print page header ?> <html> <head> <title>***T*H*U*S***T*H*E***W*I*N*D***B*L*O*W*S***</title> </head> <?php // ------- assemble the style sheet $css_font_size = $font_size . 'px'; $css_letter_spacing = $letter_spacing . 'px'; $css_line_height = $line_height . 'px'; $css_background_color = '#' . $background_color; $css_type_color = '#' . $type_color; $css_left_margin = $left_margin . 'px'; $css_body_width = $body_width . 'px'; echo " <style type=\"text/css\"> body { width: $css_body_width; background-color: $css_background_color; margin: 10px 0 0 $css_left_margin; color: $css_type_color; font-family: 'Courier New'; font-weight: $css_font_weight; font-size: $css_font_size; line-height: $css_line_height; letter-spacing: $css_letter_spacing; } a:link {color: #000000; text-decoration: underline; } .top { background-color: #fff; margin: 0 0 0 0; color: #666; font-family: 'Courier New'; font-weight: $css_font_weight; font-size: 11px; line-height: 12px; letter-spacing: 0; padding: 20px; } </style> <body> <!-- <div class=\"top\"> The weather in $city || || temperature: $temp degrees $tempUnits || condition: $conditionText (code: $conditionCode) || wind: $windSpeed || pressure: $pressure || visibility: $visibility || humidity: $humidity || sunrise: $sunrise || sunset: $sunset || --> </div> "; // ------- display search results with new formatting // ----DISPLAY THE RESULTS // ----BUT FIRST CHECK TO MAKE SURE IT DID RETURN SOME RESULTS if ($response -> estimatedTotalResultsCount > 0) { // display a header with info echo "<h2>"; echo "Current "; echo "“"; // “ is HTML character entity for left curly quote echo $userQuery; echo "”"; // ” is HTML character entity for right curly quote echo " in $city"; echo "</h2>"; echo " (results "; echo $response -> startIndex; echo "–"; // – is HTML character entity for en-dash echo $response -> endIndex; echo " of about "; echo number_format ($response -> estimatedTotalResultsCount); // echo number_format formats the numbers with , every 000 digits echo ")</br>"; // for convenience,load the resultElements node of the SOAP response into a variable $resultsArray = $response->resultElements; //go through the array for ($resultNum = 0; $resultNum < count($resultsArray); $resultNum++) { // assign this reult to a variable for convenience $thisResult = $resultsArray[$resultNum]; // display the count so far echo "<b>". ($resultNum + 1) . ". </b>"; // display a link to the website // start with thee opening <href> tag... echo '<a href="' . $thisResult -> URL . '">'; // if a title is available, show it as a thing to click on if ($thisResult -> title != "") { // != "" means 'does not equal empty' echo $thisResult -> title; } //if there is no title, show the URL as the thing to click on else { echo str_replace ("http://","", $thisResult -> URL); } // finish the link with the closing </a> tag echo "</a>"; // so one ofthese things will be output in the browser // <a href="http://yale.edu"> Yale University </a> // (a href="http://yale.edu"> yale.edu </a> // display snippet if available if ($thisResult -> snippet !="") { echo " "; echo strip_tags ($thisResult -> snippet); } //separate results with a space echo "<br><br>"; } } ?> </body> </html> |