Recent Changes - Search:

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,

Assignment2Ken

Online version: http://ernie.art.yale.edu/~kenmeier/inmylifetime

Source code:

<html>

<head>

        <title>Then+Now</title>

<style type="text/css">

body {
        margin: 25px 0px 0px 35px;
        padding: 0px 0px 0px 0px;
        text-align: left;
        color: #444;
        background: #fff url(blue.gif) repeat-x;
        font: 10px georgia, times new roman, serif;
        line-height: 18px;
        width: 800px;
        }

hr {
        border: 0;
ΚΚ  width: 80%;
        color: #cc0000;
        height: 2px;
        }       
       
table, td {
        color: #bbb;
        font: 9px georgia, times new roman, serif;
        }

h1 {
        color: #444;
        font: 21px georgia, times new roman, serif;
        line-height: 24px;
        }
 
h2 {
        color: #444;
        font: 9px georgia, times new roman, serif;
        }

h3 {
        color: #444;
        font: 9px georgia, times new roman, serif;
        letter-spacing: 2px;
        text-transform: uppercase;
        font-weight: bold;
        }

h4 {
        color: #444;
        font: 18px georgia, times new roman, serif;
        line-height: 28px;
        }

h5 {
        color: #444;
        font: 48px georgia, times new roman, serif;
        line-height: 6px;
        }

A:link {
        color: #cc0000;
        text-decoration: none;
        }

A:visited {
        color: #cc0000;
        text-decoration: none;
        }
       
A:active {
        color: #cc0000;
        text-decoration: none;
        }
       
A:hover {
        color: #ff2a00;
        border-bottom: 1px #ff2a00 solid;
        }
       
form {
    margin: 0;
    padding: 0;
        }

</style>

</head>

<body>

<!--<h1>InMyLifetime<font color=#cc0000">&deg;</font></h1>

<form action="inmylifetime.php" method="get">
       
        Age &nbsp; <input type="text" name="age" size="3" maxlength="2"> &nbsp; &nbsp;
       
        Zip &nbsp; <input type="text" name="zip" size="6" maxlength="5"> &nbsp;
       
        <input type="submit" name="submit" value="Go">
       
</form> -->

<?php

        // U S E R  I N P U T
       
        $age = $_REQUEST["age"];
        $zip = $_REQUEST["zip"];
       
        // W E A T H E R  D A T A

        // Load feed
        $xmlContents = file_get_contents("http://xml.weather.yahoo.com/forecastrss?p=06103");
        $xmlContents = str_replace("yweather:", "", $xmlContents);
        $xmlContents = str_replace("geo:", "", $xmlContents);

        // Load into SimpleXML
        $xml = simplexml_load_string($xmlContents);

        // Load specific data 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;
       
        $lat = $item->lat; // Latitude, e.g. "37.39"
        $long = $item->long; // Longitude, e.g. "122.03"
       
        // 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
       
        // <yweather:forecast> nodes are within the item nodes, one per each forecasted day. So this will be an array.
        $forecasts = $item->forecast;

        // Display forecast
       
        for ($forecastNum = 0; $forecastNum < count($forecasts); $forecastNum++) {

        $thisForecast = $forecasts[$forecastNum];

        $forecastDay = $thisForecast["day"];
        $forecastDate = $thisForecast["date"];
        $forecastLow = $thisForecast["low"];
        $forecastHigh = $thisForecast["high"];
        $forecastConditionText = strtolower($thisForecast["text"]);
        $forecastConditionCode = $thisForecast["code"];
       
        $forecastAvg = (($forecastHigh + $forecastLow) / 2);
        $forecastMean = intval($forecastAvg);
       
        echo "<h4>It is currently $temp&deg; on ";
        echo date('l, F d');
        echo ".<br/>";
//      echo "</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
//      echo "Weather Forecast for ";
//      echo "<b>$city, $region</b>";
//      echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
        echo "Expect conditions to be $forecastConditionText and around $forecastMean&deg; on average.</h4>";
//      echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
//      echo "<font color=#cc0000>High</font> $forecastHigh&deg;";
//      echo "High $forecastHigh&deg;<br/>";
//      echo "&nbsp;&nbsp;&nbsp;";
//      echo "<font color=#3399ff>Low</font> $forecastLow&deg;</h4>";
//      echo "Low $forecastLow&deg;</h4>";
       
        }
       
// How to figure out today's month and day

$todayDay = intval(date("j"));
$todayMonth = intval(date("n"));

// How to read a file line by line (without loading the whole thing into memory first):

// Open the text file
$file = fopen("myfile.txt", "r");

echo "<h3><br/>Mean Temperatures On This Date</h3>";

// Make sure the file opened successfully
if ($file) {

        // Repeat the following as long as we haven't reached the end of the file
        while (!feof($file)) {
       
                // Load one line (always the next line of the file) into a string
                $thisLine = fgets($file);

                // echo $thisLine;
               
                // Divide the line (a string) into its comma-separated columns (an array)
                $thisLineColumns = explode(",", $thisLine);

                // Assign the columns to more meaningful variable names  
                $thisYear = intval($thisLineColumns[3]);
                $thisMonth = intval($thisLineColumns[4]);
                $thisDay = intval($thisLineColumns[5]);
                $thisTmax = intval($thisLineColumns[6]);
                $thisTmin = intval($thisLineColumns[7]);
                $thisTmean = intval($thisLineColumns[9]);
               
                // See if this line matches today's month and day
                if (($thisDay == $todayDay) and ($thisMonth == $todayMonth)) {
               
                        // Eventually draw a bar or something, for now just display the data
                        echo "$thisYear: $thisTmean &nbsp;&nbsp; ";
               
                }
       
        }
       
        // We are here because we've reached the end of the file (feof returned true). Close the file.
        fclose($file);
       
}

?>

<!-- <h3><br/><br/>Mean Temperatures On This Date</h3>

        <table bgcolor=#F8FEED height=125 width=800 cellspacing=0 cellpadding=0 border=0>
        <tr><td valign=bottom>
        <table height="100%" width=24 cellspacing=4 cellpadding=0 border=0 align=left>
         <tr><td>50</td></tr>
         <tr><td height="50%" bgcolor=red></td></tr>

        <table height="100%" width=24 cellspacing=4 cellpadding=0 border=0 align=left>
         <tr><td>41</td></tr>
         <tr><td height="41%" bgcolor=red></td></tr>
        </table>

        <table height="100%" width=24 cellspacing=4 cellpadding=0 border=0 align=left>
         <tr><td>37</td></tr>
         <tr><td height="37%" bgcolor=red></td></tr>
        </table>

        <table height="100%" width=24 cellspacing=4 cellpadding=0 border=0 align=left>
         <tr><td>46</td></tr>
         <tr><td height="46%" bgcolor=red></td></tr>
        </table>

        <table height="100%" width=24 cellspacing=4 cellpadding=0 border=0 align=left>
         <tr><td>36</td></tr>
         <tr><td height="36%" bgcolor=red></td></tr>
        </table>
       
        <table height="100%" width=24 cellspacing=4 cellpadding=0 border=0 align=left>
         <tr><td>38</td></tr>
         <tr><td height="38%" bgcolor=red></td></tr>
        </table>

        <table height="100%" width=24 cellspacing=4 cellpadding=0 border=0 align=left>
         <tr><td>31</td></tr>
         <tr><td height="31%" bgcolor=red></td></tr>
        </table>

        <table height="100%" width=24 cellspacing=4 cellpadding=0 border=0 align=left>
         <tr><td>43</td></tr>
         <tr><td height="43%" bgcolor=red></td></tr>
        </table>
       
        <table height="100%" width=24 cellspacing=4 cellpadding=0 border=0 align=left>
         <tr><td>38</td></tr>
         <tr><td height="38%" bgcolor=red></td></tr>
        </table>
       
        <table height="100%" width=24 cellspacing=4 cellpadding=0 border=0 align=left>
         <tr><td>31</td></tr>
         <tr><td height="31%" bgcolor=red></td></tr>
        </table>
       
        <table height="100%" width=24 cellspacing=4 cellpadding=0 border=0 align=left>
         <tr><td>49</td></tr>
         <tr><td height="49%" bgcolor=red></td></tr>
        </table>
       
        <table height="100%" width=24 cellspacing=4 cellpadding=0 border=0 align=left>
         <tr><td>44</td></tr>
         <tr><td height="44%" bgcolor=red></td></tr>
        </table>

        <table height="100%" width=24 cellspacing=4 cellpadding=0 border=0 align=left>
         <tr><td>24</td></tr>
         <tr><td height="24%" bgcolor=red></td></tr>
        </table>

        <table height="100%" width=24 cellspacing=4 cellpadding=0 border=0 align=left>
         <tr><td>44</td></tr>
         <tr><td height="44%" bgcolor=red></td></tr>
        </table>
       
        <table height="100%" width=24 cellspacing=4 cellpadding=0 border=0 align=left>
         <tr><td>41</td></tr>
         <tr><td height="41%" bgcolor=red></td></tr>
        </table>
       
        <table height="100%" width=24 cellspacing=4 cellpadding=0 border=0 align=left>
         <tr><td>41</td></tr>
         <tr><td height="41%" bgcolor=red></td></tr>
        </table>

        <table height="100%" width=24 cellspacing=4 cellpadding=0 border=0 align=left>
         <tr><td>44</td></tr>
         <tr><td height="44%" bgcolor=red></td></tr>
        </table>
       
        <table height="100%" width=24 cellspacing=4 cellpadding=0 border=0 align=left>
         <tr><td>45</td></tr>
         <tr><td height="45%" bgcolor=red></td></tr>
        </table>
       
        <table height="100%" width=24 cellspacing=4 cellpadding=0 border=0 align=left>
         <tr><td>37</td></tr>
         <tr><td height="37%" bgcolor=red></td></tr>
        </table>       

        <table height="100%" width=24 cellspacing=4 cellpadding=0 border=0 align=left>
         <tr><td>34</td></tr>
         <tr><td height="34%" bgcolor=red></td></tr>
        </table>       

        <table height="100%" width=24 cellspacing=4 cellpadding=0 border=0 align=left>
         <tr><td>42</td></tr>
         <tr><td height="42%" bgcolor=red></td></tr>
        </table>       

        <table height="100%" width=24 cellspacing=4 cellpadding=0 border=0 align=left>
         <tr><td>42</td></tr>
         <tr><td height="42%" bgcolor=red></td></tr>
        </table>       

        <table height="100%" width=24 cellspacing=4 cellpadding=0 border=0 align=left>
         <tr><td>36</td></tr>
         <tr><td height="36%" bgcolor=red></td></tr>
        </table>       

        <table height="100%" width=24 cellspacing=4 cellpadding=0 border=0 align=left>
         <tr><td>32</td></tr>
         <tr><td height="32%" bgcolor=red></td></tr>
        </table>       

        <table height="100%" width=24 cellspacing=4 cellpadding=0 border=0 align=left>
         <tr><td>29</td></tr>
         <tr><td height="29%" bgcolor=red></td></tr>
        </table>       

        <table height="100%" width=24 cellspacing=4 cellpadding=0 border=0 align=left>
         <tr><td>27</td></tr>
         <tr><td height="27%" bgcolor=red></td></tr>
        </table>       

</td></tr>
</table>

<h2>&nbsp;&nbsp;&nbsp;81&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;82&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;83&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;84&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;85&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;86&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;87&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;88&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;89&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;90&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;91&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;92&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;93&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;94&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;95&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;96&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;97&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;98&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;99&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;00&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;01&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;02&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;03&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;04&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;05&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;06</h2> -->

<?php   

        // C L I M A T E  F E E D

        $xmlContents = file_get_contents("http://news.google.com/news?hl=en&ned=us&q=weather+global+warming+climate+change&ie=UTF-8&output=rss");
        $xml = simplexml_load_string($xmlContents);
        $channel = $xml->channel;
       
        echo "<h3><br/><br/>Current Weather News</h3>";
       
        foreach ($channel->item as $item) {
                $link = $item->link;
                $description = $item->description;
                $title = $item->title;
                $title = str_replace(" - ", " <font color=#bbb></a>&nbsp;&rsaquo; &nbsp;", $title);
                $title .= "</font>";
                echo "<a href=" . $link . ">" . $title . "</a><br/>";
}

?>

<br/><br/><br/><br/>

</body>

</html>

Edit - History - Print - Recent Changes - Search
Page last modified on March 15, 2006, at 02:43 PM