NOAA-style Climate Reports
\n";
$now_month = sprintf("%02d",$now['mon']);
$now_year = $now['year'];
$prior_month = $now['mon'] - 1;
$prior_year = $now['year'];
$last_year = $prior_year -1;
if ($prior_month < 1) {$prior_month = 12; $prior_year--;}
$prior_month = sprintf("%02d",$prior_month);
print "\n";
print "\n";
if ($Naming == 'WL') { // check for month/year rollover and update
if(! file_exists("$NOAAdir/NOAA$prior_year-$prior_month.TXT") and
file_exists($LastMonthFile) ) {
print "\n";
if (copy($LastMonthFile,"$NOAAdir/NOAA$prior_year-$prior_month.TXT")) {
print "\n";
} else {
print "\n";
}
}
if(! file_exists("$NOAAdir/NOAA$last_year.TXT") and
file_exists($LastYearFile) ) {
print "\n";
if (copy($LastYearFile,"$NOAAdir/NOAA$last_year.TXT")) {
print "\n";
} else {
print "\n";
}
}
}
$months = array( "01"=>"Jan", "02"=>"Feb", "03"=>"Mar",
"04"=>"Apr", "05"=>"May", "06"=>"Jun",
"07"=>"Jul", "08"=>"Aug", "09"=>"Sep",
"10"=>"Oct", "11"=>"Nov", "12"=>"Dec"
);
if ($handle = opendir("$NOAAdir")) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$files[] = $file;
}
}
closedir($handle);
sort($files);
$lastyear = '';
echo "\n";
// set up the files and find the first and last year for reports
$first_year = "";
foreach ($files as $key => $file) {
if ($Naming == 'WL') {
$year = substr($file,4,4);
} elseif ($Naming == 'VWS') {
$year = substr($file,0,4);
}
if (! preg_match("/^\d{4}$/",$year) ) { continue;} //make sure year is numeric
$filesfound["$file"] = 1;
if (!$first_year) { $first_year = $year; }
$last_year = $year;
}
if (! $first_year) {
echo "Sorry... no NOAA-style reports found.
";
echo "