time() // Version 1.03 - 18-Jan-2022 - fix for extract of source HTML Charset to use // Version 1.04 - 27-Dec-2022 - fixes for PHP 8.1 // Version 1.05 - 09-Feb-2023 - fixes for PHP 8.2 and Notice errata // $Version = "V1.05 - 09-Feb-2023"; // // Settings: // --------- start of settings ---------- // // Go to http://weather.gc.ca/lightning/index_e.html // Click on the desired area page. // You should see a lightning page with an url like // http://weather.gc.ca/lightning/index_e.html?id=XXX // copy the three letter area id=XXX into $lightningID = 'XXX'; below // $lightningID = 'NAT'; // set to default Site for lightning (same as id=xxx on EC website) // // available sites: NAT ARC PAC WRN ONT QUE ATL $defaultLang = 'en'; // set to 'fr' for french default language // // set to 'en' for english default language // $lightningCacheName = 'ec-lightning.txt'; // note: will be changed to -en.txt or // -fr.txt depending on language choice and stored in $lightningDir $lightningDir = './radar/'; // directory for storing lightning-XXX-0.png to lightning-XXX-6.png images // note: relative to document root. $lightningWidth = 620; // width of images to output in pixels. default=620 // $refetchSeconds = 300; // look for new images from EC every 5 minutes (300 seconds) // NOTE: EC may take up to 20 minutes to publish new images $noLightningMinutes = 25; // minutes to wait before declaring the image site as 'N/O -not operational' // $aniSec = 1; // number of seconds between animations // $charsetOutput = 'ISO-8859-1'; // default character encoding of output // ---------- end of settings ----------- //------------------------------------------------ // overrides from Settings.php if available global $SITE; if (isset($SITE['eclightningID'])) {$lightningID = $SITE['eclightningID'];} if (isset($SITE['defaultlang'])) {$defaultLang = $SITE['defaultlang'];} if (isset($SITE['charset'])) {$charsetOutput = strtoupper($SITE['charset']); } // end of overrides from Settings.php if available // // ---------- main code ----------------- if (isset($_REQUEST['sce']) && strtolower($_REQUEST['sce']) == 'view' ) { //--self downloader -- $filenameReal = __FILE__; $download_size = filesize($filenameReal); header('Pragma: public'); header('Cache-Control: private'); header('Cache-Control: no-cache, must-revalidate'); header("Content-type: text/plain,charset=ISO-8859-1"); header("Accept-Ranges: bytes"); header("Content-Length: $download_size"); header('Connection: close'); readfile($filenameReal); exit; } //error_reporting(E_ALL); // uncomment to turn on full error reporting $hasUrlFopenSet = ini_get('allow_url_fopen'); if(!$hasUrlFopenSet) { print "

Warning: PHP does not have 'allow_url_fopen = on;' --
image fetch by ec-lightning.php is not possible.

\n"; print "

To fix, add the statement:

allow_url_fopen = on;\n\n
to your php.ini file to enable ec-lightning.php operation.

\n"; return; } $t = pathinfo(__FILE__); // get our program name for the HTML comments $Program = $t['basename']; $Status = "\n"; $printIt = true; if(isset($_REQUEST['inc']) && strtolower($_REQUEST['inc']) == 'y' or (isset($doInclude) and $doInclude)) {$doInclude = true;} if(isset($doPrint)) { $printIt = $doPrint; } if(! isset($doInclude)) {$doInclude = false; } if(isset($_REQUEST['id'])) { $lightningID = strtoupper($_REQUEST['id']); } $lightningID = preg_replace('|[^A-Z]+|s','',$lightningID); // Make sure only alpha in siteID if(strlen($lightningID) <> 3) { print "

Sorry... area id '$lightningID' is not a valid EC area site name.

\n"; return; } if (isset($_REQUEST['cache']) && (strtolower($_REQUEST['cache']) == 'no') ) { $forceRefresh = true; } else { $forceRefresh = false; } if (isset($doAutoPlay)) { $autoPlay = $doAutoPlay; } elseif (isset($_REQUEST['play']) && (strtolower($_REQUEST['play']) == 'no') ) { $autoPlay = false; } else { $autoPlay = true; } if (isset($_REQUEST['imgonly']) && (strtolower($_REQUEST['imgonly']) == 'y')) { $imageOnly = true; // just return the latest thumbnail image after processing $printIt = false; // and don't spoil the image with any other stuff } else { $imageOnly = false; } if (isset($_REQUEST['lang'])) { $Lang = strtolower($_REQUEST['lang']); } if (isset($doLang)) {$Lang = $doLang;}; if (! isset($Lang)) {$Lang = $defaultLang;}; if ($Lang == 'fr') { $LMode = 'f'; $ECLNAME = "Environnement Canada"; $ECLHEAD = 'Carte canadienne du risque de foudre'; $ECLNO = 'N/O - Non opérationnel'; $ECLNoJS = 'Pour voir l\'animation, il faut que JavaScript soit en fonction.'; $ECLPlay = 'Animer - Pause'; $ECLPrev = 'Image précédente'; $ECLNext = 'Prochaine image'; } else { $Lang = 'en'; $LMode = 'e'; $ECLNAME = "Environment Canada"; $ECLHEAD = 'Canadian Lightning Danger Map'; $ECLNO = 'N/O - Non-operational'; $ECLNoJS = 'Please enable JavaScript to view the animation.'; $ECLPlay = 'Play - Stop'; $ECLPrev = 'Previous'; $ECLNext = 'Next'; } $lightningCacheName = preg_replace('|.txt$|',"-$Lang.txt",$lightningCacheName); // if (isset($_SERVER['DOCUMENT_ROOT'])) { $ROOTDIR = $_SERVER['DOCUMENT_ROOT']; } else { $ROOTDIR = '.'; } $cacheDir = $lightningDir; $imageDir = $lightningDir; $Status .= "\n\n"; date_default_timezone_set( @date_default_timezone_get()); $Status .= "\n"; $ECLSizes = array ( // image sizes w,h 'NAT' => '850,633', 'ARC' => '850,646', 'PAC' => '667,700', 'WRN' => '795,700', 'ONT' => '764,700', 'QUE' => '622,700', 'ATL' => '792,700', ); if ( !isset($ECLSizes[$lightningID]) ) { print "

Error: id=$lightningID is not known.

\n"; print "

Use one of the following as id: "; foreach ($ECLSizes as $key => $val) { print "$key "; } print " and retry.

\n"; return; } list($ECLbaseW,$ECLbaseH) = explode(',',$ECLSizes[$lightningID]); $new_width = $lightningWidth; $new_height = round($ECLbaseH * ($lightningWidth / $ECLbaseW),0); $thumb_width = 290; $thumb_height = round($ECLbaseH * (290 / $ECLbaseW),0); // all settings and overrides now loaded ... begin processing $Status .= "\n"; $lightningCacheName = preg_replace('|.txt$|',"-".$lightningID.".txt",$lightningCacheName); $RawImgURL = "https://weather.gc.ca"; $ECLURL = 'https://weather.gc.ca/lightning/index_' . $LMode . '.html?id=' . $lightningID; if($Lang == 'fr') { $RawImgURL = preg_replace('|weather|i','meteo',$RawImgURL); $ECLURL = preg_replace('|weather|i','meteo',$ECLURL); $Status .= "\n"; } $RealCacheName = $cacheDir . $lightningCacheName; $reloadImages = false; // assume we don't have to reload unless a newer image set is around if(file_exists($RealCacheName)) { $lastCacheTime = filemtime($RealCacheName); } else { $lastCacheTime = time(); $forceRefresh = true; } $lastCacheTimeHM = gmdate("Y-m-d H:i:s",$lastCacheTime) . " UTC"; $NOWgmtHM = gmdate("Y-m-d H:i:s",time()) . " UTC"; $diffSecs = time() - $lastCacheTime; $Status .= "\n"; if(isset($_GET['force']) | isset($_GET['cache'])) {$refetchSeconds = 0;} if($diffSecs > $refetchSeconds) {$forceRefresh = true;} $Status .= "\n"; // refresh cached copy of page if needed // fetch/cache code by Tom at carterlake.org if (! $forceRefresh) { $Status .= "\n"; $site = implode('', file($RealCacheName)); $forceRefresh = true; } else { $Status .= "\n"; $site = ECL_fetchUrlWithoutHang($ECLURL,false); $fp = fopen($RealCacheName, "w"); if (strlen($site) and $fp) { $write = fputs($fp, $site); fclose($fp); $Status .= "\n"; $reloadImages = true; } else { $Status .= "\n"; $Status .= "\n"; $Status .= "\n"; } } if(!file_exists($RealCacheName)) { print "

Sorry. Unable to write $lightningCacheName to '$cacheDir'.
"; print "Make '$cacheDir' writable by PHP for this script to operate properly.

\n"; exit; } if(strlen($site) < 100) { print "

Sorry. Incomplete file received from Environment Canada website.

\n"; exit; } preg_match('|charset="{0,1}([^"]+)"{0,1}\r|i',$site,$matches); if (isset($matches[1])) { $charsetInput = trim(strtoupper($matches[1])); } else { $charsetInput = 'UTF-8'; } $doIconv = ($charsetInput == $charsetOutput)?false:true; // only do iconv() if sets are different $Status .= "\n"; // find the site name // preg_match_all('|(.*)|',$site,$matches); // $Status .= "\n"; $siteTitle = isset($matches[1][0])?$matches[1][0]:''; if($doIconv and !empty($siteTitle)) { $siteTitle = iconv($charsetInput,$charsetOutput.'//TRANSLIT',$siteTitle); } // find the site heading info preg_match_all('|

(.*)

|',$site,$matches); // $Status .= "\n"; $siteHeading = isset($matches[1][0])?$matches[1][0]:''; if($doIconv and !empty($siteHeading)) { $siteHeading = iconv($charsetInput,$charsetOutput.'//TRANSLIT',$siteHeading); } // find the legend info and build our version. $ECLlegend = ''; preg_match('|
\n"; $ECLlegend = "\n" . "\n"; $ECLlegend .= "\n
\n". "\"red\n". "\n
    \n"; foreach ($matches[1] as $i => $val) { if($doIconv) { $tstr = iconv($charsetInput,$charsetOutput.'//TRANSLIT',$val); } else { $tstr = $val; } $ECLlegend .= "
  • $tstr
  • \n"; } $ECLlegend .= "
\n
\n"; $Status .= "\n"; //print $ECLlegend; } // find the string to use for 'enable JavaScript for the animation' if(preg_match_all('|]+>(.*)(.*)

|Uis',$site,$matches) ) { $siteDescription = $matches[1][0]; if($doIconv and !empty($siteDescription)) { $siteDescription = iconv($charsetInput,$charsetOutput.'//TRANSLIT',$siteDescription); } } // find and extract the details about the images available preg_match('|
]+)>|',$site,$matches); $imgList = array(); $imgListText = array(); $rawImgList = array(); $rawImgListText = array(); $rawImgTimes = array(); $total_time = 0; $newestRadarCacheFile = ''; $lastRadarGMTText =''; $newestRadarImgHTML = ''; $numImages = 0; $totalImages = 0; $newestImageIdx = 0; if(isset($matches[1])) { // got the image data.. process it $tstr = $matches[1]; preg_match_all('|(\S+)\="([^"]+)"|U',$tstr,$matches); // $Status .= "\n"; foreach ($matches[1] as $i => $key) { if(preg_match('|data-wxo-anim-(\d+)|',$key,$tmatch) ) { $rawImgList[$tmatch[1]] = $matches[2][$i]; } if(preg_match('|data-wxo-label-(\d+)|',$key,$tmatch) ) { $rawImgListText[$tmatch[1]] = $matches[2][$i]; } if(preg_match('|data-image-count|',$key,$tmatch) ) { $totalImages = $matches[2][$i]; } if(preg_match('|data-image-current|',$key,$tmatch) ) { $newestImageIdx = $matches[2][$i]; } } $Status .= "\n"; } foreach ($rawImgList as $i => $rawImg) { $Status .= "\n"; } if(!isset($newestImageIdx)) {$newestImageIdx = 6; } /* Array ( [data-image-current] => 6 [data-image-count] => 7 [data-wxo-anim-0] => /data/lightning_images/PAC_201610131400.png [data-wxo-label-0] => #1 [data-wxo-anim-1] => /data/lightning_images/PAC_201610131410.png [data-wxo-label-1] => #2 [data-wxo-anim-2] => /data/lightning_images/PAC_201610131420.png [data-wxo-label-2] => #3 [data-wxo-anim-3] => /data/lightning_images/PAC_201610131430.png [data-wxo-label-3] => #4 [data-wxo-anim-4] => /data/lightning_images/PAC_201610131440.png [data-wxo-label-4] => #5 [data-wxo-anim-5] => /data/lightning_images/PAC_201610131450.png [data-wxo-label-5] => #6 [data-wxo-anim-6] => /data/lightning_images/PAC_201610131500.png [data-wxo-label-6] => #7 ) rawImgList Array ( [0] => /data/lightning_images/PAC_201610132030.png [1] => /data/lightning_images/PAC_201610132040.png [2] => /data/lightning_images/PAC_201610132050.png [3] => /data/lightning_images/PAC_201610132100.png [4] => /data/lightning_images/PAC_201610132110.png [5] => /data/lightning_images/PAC_201610132120.png [6] => /data/lightning_images/PAC_201610132130.png ) --> \n"; preg_match('|_(\d+)\.|',$rawImgList[6],$matches); if(isset($matches[1])) { $tYr = substr($matches[1],0,4); $tMo = substr($matches[1],4,2); $tDy = substr($matches[1],6,2); $tHr = substr($matches[1],8,2); $tMi = substr($matches[1],10,2); $newestLightingTime = strtotime("$tYr-$tMo-$tDy $tHr:$tMi:00 GMT"); $Status .= "\n"; } else { $newestLightingTime = time() - $refetchSeconds - 10; } if(file_exists($cacheDir."lightning-{$lightningID}-{$newestImageIdx}.png")) { $newestCacheFileTime = filemtime($cacheDir."lightning-{$lightningID}-{$newestImageIdx}.png"); $Status .= "\n"; } if( !file_exists($cacheDir."lightning-{$lightningID}-{$newestImageIdx}.png") or (file_exists($cacheDir."lightning-{$lightningID}-{$newestImageIdx}.png") and $newestCacheFileTime < $newestLightingTime) ) { $reloadImages = true; } else { $reloadImages = false; } $Status .= "\n"; if ($reloadImages and file_exists($RealCacheName) ) { // do the reload of the image files if needed foreach($rawImgList as $i => $RawImgFile) { $didIt = false; $time_start = ECL_microtime_float(); $lightningCacheFile = "lightning-{$lightningID}-{$i}.png"; $imgURL = $RawImgURL . $RawImgFile; //$Status .= "\n"; $didIt = ECL_download($imgURL,$cacheDir,$lightningCacheFile,$new_width,$new_height); $time_stop = ECL_microtime_float(); $total_time += ($time_stop - $time_start); $time_fetch = sprintf("%01.3f",round($time_stop - $time_start,3)); if ($didIt) { $Status .= "\n"; } else { $Status .= "\n"; } } // end foreach // make thumbnail too for latest image $imgname = "lightning-{$lightningID}-{$newestImageIdx}.png"; // get latest image name $thumbname = str_replace('-'.$newestImageIdx.'.png','-sm.png',$imgname); $time_start = ECL_microtime_float(); $image = imagecreatefrompng ($cacheDir . $imgname);; // fetch our radar if (! $image ) { // oops... no existing image, create a dummy one $image = imagecreate ($new_width, $new_height); //* Create a blank image $bgc = imagecolorallocate ($image, 128, 128, 128); imagefilledrectangle ($image, 0, 0, $new_width, $new_height, $bgc); } $MaxX = imagesx($image); $MaxY = imagesy($image); $image_p = imagecreatetruecolor($thumb_width, $thumb_height); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $thumb_width, $thumb_height, $MaxX, $MaxY); if (time() > ($newestLightingTime + $noLightningMinutes*60 + $refetchSeconds + 15)) { // stale radar if > 25 minutes + refetchTime + 15 seconds old $text_color = imagecolorallocate ($image_p, 192,51,51); $bgcolor = imagecolorallocate ($image, 128, 128, 128); imagefilledrectangle($image_p, 5, 95, 230, 140,$bgcolor); imagestring ($image_p, 5, 15, 100, "$ECLNO", $text_color); imagestring ($image_p, 5, 15, 120, $imgListText[0], $text_color); } imagepng($image_p, $cacheDir . $thumbname); imagedestroy($image); imagedestroy($image_p); $time_stop = ECL_microtime_float(); $total_time += ($time_stop - $time_start); $time_fetch = sprintf("%01.3f",round($time_stop - $time_start,3)); $Status .= "\n"; $Status .= "\n"; } // end if reloadImages // now setup the list of images+text for the page display foreach($rawImgListText as $i => $RawImgText) { if(file_exists($cacheDir."lightning-{$lightningID}-{$i}.png")) { $imgList[$i] = "lightning-{$lightningID}-{$i}.png"; preg_match('|_(\d+)\.|',$rawImgList[$i],$matches); if(isset($matches[1])) { $tYr = substr($matches[1],0,4); $tMo = substr($matches[1],4,2); $tDy = substr($matches[1],6,2); $tHr = substr($matches[1],8,2); $tMi = substr($matches[1],10,2); $rawImgTimes[$i] = "@ $tHr:$tMi UTC"; // $newestLightingTime = strtotime("$tYr-$tMo-$tDy $tHr:$tMi:00 GMT"); } else { $rawImgTimes[$i] = ''; } $imgListText[$i] = $RawImgText . " ". $rawImgTimes[$i]; $numImages++; } } if ($imageOnly) { $ourImg = $cacheDir . "lightning-$lightningID-sm.png"; if (file_exists($ourImg)) { $ourImgSize = filesize($ourImg); $ourImgGMT = filectime($ourImg); header("Content-type: image/png"); // now send to browser header("Content-length: " . $ourImgSize); header("Last-modified: " . gmdate("D, d M Y H:i:s", $ourImgGMT) . ' GMT'); header("Expires: " . gmdate("D, d M Y H:i:s", $ourImgGMT+$refetchSeconds) . ' GMT'); readfile($ourImg); } exit; } // print it out: if ($printIt && ! $doInclude) { //------------------------------------------------ header("Cache-Control: no-cache,no-store, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); $NOWdate = gmdate("D, d M Y H:i:s", time()); header("Expires: $NOWdate GMT"); header("Last-Modified: $NOWdate GMT"); header("Content-type: text/html,charset=\"$charsetOutput\""); ?> <?php print "$siteTitle"; ?> \n"; if ($printIt) { $ECLURL = preg_replace('|&|Ui','&',$ECLURL); // make link XHTML compatible // $Status .= "\n"; print "
\n"; ECL_gen_animation($numImages, $lightningID, $lightningDir,$aniSec); // print $imgHTML; print "

$siteHeading - $ECLNAME

\n
\n"; } if ($printIt && ! $doInclude) {?> \n"; $ch = curl_init(); // initialize a cURL session curl_setopt($ch, CURLOPT_URL, $theURL); // connect to provided URL curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // don't verify peer certificate curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (ec-lightning.php - saratoga-weather.org)'); curl_setopt($ch,CURLOPT_HTTPHEADER, // request LD-JSON format array ( "Accept: text/html,text/plain" )); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $numberOfSeconds); // connection timeout curl_setopt($ch, CURLOPT_TIMEOUT, $numberOfSeconds); // data timeout curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // return the data transfer curl_setopt($ch, CURLOPT_NOBODY, false); // set nobody curl_setopt($ch, CURLOPT_HEADER, true); // include header information // curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // follow Location: redirect // curl_setopt($ch, CURLOPT_MAXREDIRS, 1); // but only one time if (isset($needCookie[$domain])) { curl_setopt($ch, $needCookie[$domain]); // set the cookie for this request curl_setopt($ch, CURLOPT_COOKIESESSION, true); // and ignore prior cookies $Status .= "\n"; } $data = curl_exec($ch); // execute session if(curl_error($ch) <> '') { // IF there is an error $Status .= "\n"; // display error notice } $cinfo = array(); $cinfo = curl_getinfo($ch); // get info on curl exec. /* curl info sample Array ( [url] => http://saratoga-weather.net/clientraw.txt [content_type] => text/plain [http_code] => 200 [header_size] => 266 [request_size] => 141 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.125 [namelookup_time] => 0.016 [connect_time] => 0.063 [pretransfer_time] => 0.063 [size_upload] => 0 [size_download] => 758 [speed_download] => 6064 [speed_upload] => 0 [download_content_length] => 758 [upload_content_length] => -1 [starttransfer_time] => 0.125 [redirect_time] => 0 [redirect_url] => [primary_ip] => 74.208.149.102 [certinfo] => Array ( ) [primary_port] => 80 [local_ip] => 192.168.1.104 [local_port] => 54156 ) */ //$Status .= "\n"; $Status .= "\n"; //$Status .= "\n"; curl_close($ch); // close the cURL session //$Status .= "\n"; $i = strpos($data,"\r\n\r\n"); $headers = substr($data,0,$i); $content = substr($data,$i+4); if($cinfo['http_code'] <> '200') { $Status .= "\n"; } return $data; // return headers+contents } else { // print "\n"; $STRopts = array( 'http'=>array( 'method'=>"GET", 'protocol_version' => 1.1, 'header'=>"Cache-Control: no-cache, must-revalidate\r\n" . "Cache-control: max-age=0\r\n" . "Connection: close\r\n" . "User-agent: Mozilla/5.0 (ec-lightning.php - saratoga-weather.org)\r\n" . "Accept: text/html,text/plain\r\n" ), 'https'=>array( 'method'=>"GET", 'protocol_version' => 1.1, 'header'=>"Cache-Control: no-cache, must-revalidate\r\n" . "Cache-control: max-age=0\r\n" . "Connection: close\r\n" . "User-agent: Mozilla/5.0 (ec-lightning.php - saratoga-weather.org)\r\n" . "Accept: text/html,text/plain\r\n" ) ); $STRcontext = stream_context_create($STRopts); $T_start = ECL_fetch_microtime(); $xml = file_get_contents($url,false,$STRcontext); $T_close = ECL_fetch_microtime(); $headerarray = get_headers($url,0); $theaders = join("\r\n",$headerarray); $xml = $theaders . "\r\n\r\n" . $xml; $ms_total = sprintf("%01.3f",round($T_close - $T_start,3)); $Status .= "\n"; $Status .= "<-- get_headers returns\n".$theaders."\n -->\n"; // print " file() stats: total=$ms_total secs.\n"; $overall_end = time(); $overall_elapsed = $overall_end - $overall_start; $Status .= "\n"; // print "fetch function elapsed= $overall_elapsed secs.\n"; return($xml); } } // end ECL_fetchUrlWithoutHang // --------------------------------------------------------------------------- function ECL_download($file_source,$file_dir, $file_target,$width,$height) { global $Status; // load the source gif and do the overlay, then save the resulting file V2.00 $tIMG = imagecreatetruecolor($width,$height); // Enable blend mode and save full alpha channel imagealphablending($tIMG, true); imagesavealpha($tIMG, true); $fileTargetLarge = $file_dir . str_replace('.png','-large.png',$file_target); ECL_download_image($file_source,$fileTargetLarge); $sceIMG = false; if(file_exists($fileTargetLarge)) { $sceIMG = imagecreatefrompng($fileTargetLarge); } if(!$sceIMG) { $Status .= "\n"; imagedestroy($tIMG); return false; } // imagecopy($tIMG,$sceIMG,0,0,0,0,$width,$height); $MaxX = imagesx($sceIMG); $MaxY = imagesy($sceIMG); $ratio = $MaxX/$width; $new_height = round($MaxY/$ratio,0); imagecopyresampled($tIMG, $sceIMG, 0, 0, 0, 0, $width, $new_height, $MaxX, $MaxY); if(!imagepng($tIMG, $file_dir . $file_target)) { $Status .= "\n"; imagedestroy($tIMG); return false; } imagedestroy($tIMG); return true; } // ------------------------------------------------------------------ function ECL_download_image($file_source, $file_target) { global $Status; $opts = array( 'http'=>array( 'method'=>"GET", 'protocol_version' => 1.1, 'header'=>"Cache-Control: no-cache, must-revalidate\r\n" . "Cache-control: max-age=0\r\n" . "Connection: close\r\n" . "User-agent: Mozilla/5.0 (ec-lightning.php saratoga-weather.org)\r\n" ), 'https'=>array( 'method'=>"GET", 'protocol_version' => 1.1, 'header'=>"Cache-Control: no-cache, must-revalidate\r\n" . "Cache-control: max-age=0\r\n" . "Connection: close\r\n" . "User-agent: Mozilla/5.0 (ec-lightning.php saratoga-weather.org)\r\n" ) ); $context = stream_context_create($opts); $rh = fopen($file_source, 'rb',false,$context); if(!$rh) { $Status .= "\n"; } $wh = fopen($file_target, 'wb'); if(!$wh) { $Status .= "\n"; } if ($rh===false || $wh===false) { // error reading or opening file return true; } while (!feof($rh)) { if (fwrite($wh, fread($rh, 1024)) === FALSE) { $Status .= '\n"; return true; } } fclose($rh); fclose($wh); // No error $Status .= "\n"; return false; } // ------------------------------------------------------------------ function ECL_microtime_float() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } function ECL_gen_animation ( $numImages, $lightningID, $lightningDir, $aniSec) { // generate JavaScript and control buttons for rotating the images global $new_width, $new_height, $siteTitle, $imgListText, $ECLPlay, $ECLPrev, $ECLNext, $ECLNoJS, $siteHeading, $noJSMsg, $ECLNO, $TZ, $TZOffsecSecs, $autoPlay, $ECLlegend, $siteDescription, $newestImageIdx; if ($numImages < 1) { print "

Sorry, no current lightning images for site $lightningID are available.

\n"; return; } if ($numImages > 1) { // generate the animation for 2 or more images ?> $siteDescription

\n"; } ?>


" alt="" width="" height="" id="L_Ath_Slide" title="" />

'') { print "$ECLlegend"; } ?>


" alt="" width=" " height="" title="" />