I’ve got KirklandWeather.com up and going for some time now, but I’d like to start moving toward PHP.
I’ve setup up PHP on my server and got it working great.
Now I’ve been experimenting with sample PHP code samples. I’ve downloaded http://www.joske-online.be/downloads/clientraw-with-graphs.zip which is a PHP based version of the original CarterLake design which is similar to what I’m using on my live site now.
I’m running into problems getting the Weather Display clientraw.txt data to populate.
The index.php file is calling: <?php include 'readclraw.php';?> In that file is Kevin Reed’s extraction routines:
<?php //========================================================================= // // WD Clientraw Datafile Extraction Routines // // Written by: Kevin Reed // http://www.tnet.com/weather // // Purpose: // // These will read using PHP the three possible clientraw datafiles // from a local or remote location and allow the user to parse out // the various data elements they want. // //========================================================================= // // Functions // //========================================================================= // You may not have this... just comment out if you don't //$PHPCOUNTER = $_SERVER['DOCUMENT_ROOT']."/cgi/phpcounter/counter.php";
// Function get_raw
// This function reads the file pointed at by $rawfile and extracts the
// data by returning an array of what it found. If it found nothing
// it returns -9999 in the first element of the returned array.
//
function get_raw( $rawfile ) {
$rawdata = array();
$fd = fopen($rawfile, “r”);
if ($fd) {
$rawcontents = ‘’;
while (! feof ($fd) ) {
$rawcontents .= fread($fd, 8192);
}
fclose($fd);
$delimiter = " ";
$rawdata = explode ($delimiter, $rawcontents);
} else {
$rawdata[0]= -9999;
}
return $rawdata;
}
//=========================================================================
//
// Start of Main Module
//
//=========================================================================
$hostloc = “…/”;
$clientraw = get_raw(“${hostloc}clientraw.txt”);
$clientrawextra = get_raw(“${hostloc}clientrawextra.txt”);
$clientrawdaily = get_raw (“${hostloc}clientrawdaily.txt”);
$location = $clientraw[32];
$location = str_replace(‘_’,’ ‘,$location);
$location = str_replace(’-‘,’ ',$location);
No matter what I try, the routines aren’t bringing in the data from clientraw.txt. I placed a copy of the clientraw.txt in the same folder and a folder below. In both cases the index.php page renders, but without WD data.
Here’s a temporary site http://kirklandweather.com/weather/clientraw/index.php
Any suggestions?