<?php

/*
   Local moon rise/set table for current year.

   This program is local to Waterloo, NY, USA
   Latitude  = +42.901692
   Longitude = -76.85157 (West)
   Time Zone = -05:00    (West)

   This can be changed for your own local use.

   AUTHOR   : Jay Tanner
   LANGUAGE : PHP v8.2.12
   LICENSE  : Public Domain
*/

  
$label   'Waterloo-New-York-USA'// Cannot contain commas or spaces.
  
$year    date('Y');
  
$lat     '42.901692';
  
$lon     '-76.85157';
  
$tz_sign '-1';
  
$tz      '5.00';

// Generate table
  
$table   Moon_Rise_Set ($label$year$lat$lon$tz_sign$tz);

  print
"<!DOCTYPE HTML>
<head>
<title>Moon Rise/Set Times For 
$year</title>
</head>
<body>
<!-- Yellow source code view link. --->
<table width='550' align='bottom' cellspacing='1' cellpadding='3'>
<!-- Yellow source code view link. --->
<tr>
<td colspan='1' style='background:transparent; color:black; font-size:10pt;
                       text-align:left;'>
<a href='View-Source-Code.php' target='_blank'
   style='font-family:Verdana; color:black; background:yellow;
         text-decoration:none; border:1px solid black; padding:4px;
         border-radius:4px;'>
         &nbsp;<span style='font-weight:normal;'>View/Copy PHP Source Code</span>&nbsp;</a>
</td>
</tr>
</table>

<pre style='font-family:monospace; font-size:11pt; font-weight:bold;'>
Moon Rise/Set Table - PHP Program by Jay Tanner                                                        Computations via:
$table
</pre>
<br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br>
</body>
"
;



/*
   ###########################################################################
   This function returns a table of moonrise and moonset times for an entire
   year at a specified location and time zone.

   Program by Jay Tanner

   Computations done via:
   Astronomical Applications Dept.
   U. S. Naval Observatory
   Washington, DC  20392-5420
   ###########################################################################
*/

   
function Moon_Rise_Set ($label$year$lat$lon$tz_sign$tz)
{
   
$label   trim($label);
   
$year    trim($year);
   
$lat     trim($lat);
   
$lon     trim($lon);
   
$tz_sign trim($tz_sign);
   
$tz      trim($tz);

   
$URL "https://aa.usno.navy.mil/calculated/rstt/year?ID=AA"
        
"&year=$year&task=1&lat=$lat&lon=$lon&label=$label&tz=$tz&tz_sign=$tz_sign&submit=Get+Data";

// exit("$URL");
   
$F File_Get_Contents($URL);

   
$Q '<pre style="text-align: left; margin-left: auto; margin-right: auto;">';
   
$i StrPos($F$Q);
   
$j StrPos($F,'</pre>');

   
$table '';

// -----------------------
// Isolate rise/set table.

   
if ($i !== FALSE) {$table substr($F$i+70$j-$i);}

   
$table Str_Replace('o  ,    o  , ''&deg;  &#39;    &deg;  &#39; '$table);
   
$table Str_Replace('</div>'''$table);
   
$table substr($table0StrLen($table) - 6);
   
$table Str_Replace("</pre>"''$table);


   return 
RTrim($table);
}


?>