1) { $pinfo=" " . explode("<",$ppbits[1])[0] . " "; } $xzd=(($xxlat - $sun_declination)); $zd=explode(".",("" . $xzd))[0]; $zm=floor(($xzd - $zd) * 60.0); $zs=(($xzd - $zd) * 3600.0) - ($zm * 60.0); $blurb="

Position of the Sun

On " . $dateis . " UTC" . $pinfo . "Transit Time: " . $transit_time . $latpos . $longpos . "" . str_replace("-","",$zd) . "°" . $zm . "' " . "" . str_replace("-","",$zd) . "°" . $zm . "' " . "" . str_replace("-","",$latd) . "°" . $latm . "' " . "" . str_replace("-","",$longd) . "°" . $longm . "' "; if (file_exists("PHP/SunAngle/sun_angle_now_at.php")) { file_put_contents("PHP/SunAngle/sun_angle_data.txt", $blurb); } else if (file_exists("SunAngle/sun_angle_now_at.php")) { file_put_contents("SunAngle/sun_angle_data.txt", $blurb); } else if (file_exists("PHP/SunAngle/sun_angle_now_at.php")) { file_put_contents("PHP/SunAngle/sun_angle_data.txt", $blurb); } else if (file_exists("sun_angle_now_at.php")) { file_put_contents("sun_angle_data.txt", $blurb); } //echo $blurb; } function oururldecodeget($what) { global $latis, $longis, $latd, $latm, $lats, $longd, $longm, $longs; if (isset($_GET[$what])) { if ($what == "latitude") { $latd=explode(".",urldecode($_GET['latitude']))[0]; $latm=floor((urldecode($_GET['latitude']) - $latd) * 60.0); $lats=((urldecode($_GET['latitude']) - $latd) * 3600.0) - ($latm * 60.0); } if ($what == "longitude") { $longd=explode(".",urldecode($_GET['longitude']))[0]; $longm=floor((urldecode($_GET['longitude']) - $longd) * 60.0); $longs=((urldecode($_GET['longitude']) - $longd) * 3600.0) - ($longm * 60.0); } return urldecode($_GET[$what]); } if ($what == "latitude" && isset($_GET['latd'])) { $latd=explode(" ",urldecode($_GET['latd']))[0]; $latm=0.00; $lats=0.00; if (isset($_GET['latm'])) $latm=urldecode($_GET['latm']); if (isset($_GET['lats'])) $lats=urldecode($_GET['lats']); $latis=$latd + ($latm / 60.0) + ($lats / 3600.0); return $latd + ($latm / 60.0) + ($lats / 3600.0); } if ($what == "place" && isset($_GET['latd'])) { if (strpos(urldecode($_GET['latd']), " ") !== false) { return str_replace(explode(" ", urldecode($_GET['latd']))[0] . " ","",urldecode($_GET['latd'])); } } if ($what == "longitude" && isset($_GET['longd'])) { $longd=urldecode($_GET['longd']); $longm=0.00; $longs=0.00; if (isset($_GET['longm'])) $longm=urldecode($_GET['longm']); if (isset($_GET['longs'])) $longs=urldecode($_GET['longs']); $longis=$longd + ($longm / 60.0) + ($longs / 3600.0); return $longd + ($longm / 60.0) + ($longs / 3600.0); } else if ($what == "longitude" && isset($_GET['latd'])) { $longd=0.00; $longm=0.00; $longs=0.00; return 0.0000; } return ""; } function oururldecodepost($what) { global $latis, $longis, $latd, $latm, $lats, $longd, $longm, $longs; if (isset($_POST[$what])) { if ($what == "latitude") { $latd=explode(".",urldecode($_POST['latitude']))[0]; $latm=floor((urldecode($_POST['latitude']) - $latd) * 60.0); $lats=((urldecode($_POST['latitude']) - $latd) * 3600.0) - ($latm * 60.0); } if ($what == "longitude") { $longd=explode(".",urldecode($_POST['longitude']))[0]; $longm=floor((urldecode($_POST['longitude']) - $longd) * 60.0); $longs=((urldecode($_POST['longitude']) - $longd) * 3600.0) - ($longm * 60.0); } return urldecode($_POST[$what]); } if ($what == "place" && isset($_POST['latd'])) { if (strpos(urldecode($_POST['latd']), " ") !== false) { return str_replace(explode(" ", urldecode($_POST['latd']))[0] . " ","",urldecode($_POST['latd'])); } } if ($what == "latitude" && isset($_POST['latd'])) { $latd=explode(" ",urldecode($_POST['latd']))[0]; $latm=0.00; $lats=0.00; if (isset($_POST['latm'])) $latm=urldecode($_POST['latm']); if (isset($_POST['lats'])) $lats=urldecode($_POST['lats']); $latis=$latd + ($latm / 60.0) + ($lats / 3600.0); return $latd + ($latm / 60.0) + ($lats / 3600.0); } if ($what == "longitude" && isset($_POST['longd'])) { $longd=urldecode($_POST['longd']); $longm=0.00; $longs=0.00; if (isset($_POST['longm'])) $longm=urldecode($_POST['longm']); if (isset($_POST['longs'])) $longs=urldecode($_POST['longs']); $longis=$longd + ($longm / 60.0) + ($longs / 3600.0); return $longd + ($longm / 60.0) + ($longs / 3600.0); } else if ($what == "longitude" && isset($_POST['latd'])) { $longd=0.00; $longm=0.00; $longs=0.00; return 0.0000; } return ""; } function ourissetpost($what) { if (isset($_POST[$what])) return true; if (($what == "latitude" || $what == "place") && isset($_POST['latd'])) { if ($what == "place" && strpos(urldecode($_POST['latd']), " ") === false) return false; return true; } if ($what == "longitude" && isset($_POST['longd'])) return true; if ($what == "longitude" && isset($_POST['latd'])) return true; return false; } function ourissetget($what) { if (isset($_GET[$what])) return true; if (($what == "latitude" || $what == "place") && isset($_GET['latd'])) { if ($what == "place" && strpos(urldecode($_GET['latd']), " ") === false) return false; return true; } if ($what == "longitude" && isset($_GET['longd'])) return true; if ($what == "longitude" && isset($_GET['latd'])) return true; return false; } function mb($din) { $rdin=$din; $rdin=str_replace("-01-", "-January-", $rdin); $rdin=str_replace("-02-", "-February-", $rdin); $rdin=str_replace("-03-", "-March-", $rdin); $rdin=str_replace("-04-", "-April-", $rdin); $rdin=str_replace("-05-", "-May-", $rdin); $rdin=str_replace("-06-", "-June-", $rdin); $rdin=str_replace("-07-", "-July-", $rdin); $rdin=str_replace("-08-", "-August-", $rdin); $rdin=str_replace("-09-", "-September-", $rdin); $rdin=str_replace("-10-", "-October-", $rdin); $rdin=str_replace("-11-", "-November-", $rdin); $rdin=str_replace("-12-", "-December-", $rdin); return $rdin; } function zp($dis) { global $yyyy, $mnthis, $dythis, $dmol; $ddis=explode("-", $dis); if (sizeof($ddis) != 3) return $dis; $yyyy=$ddis[0]; $mnthis=$ddis[1]; $dythis=$ddis[2]; if (strlen($ddis[1]) == 1 && strlen($ddis[2]) == 1) { $dmol=$ddis[0] . "-0" . $ddis[1] . "-0" . $ddis[2]; return $dmol; } else if (strlen($ddis[1]) == 1) { $dmol=$ddis[0] . "-0" . $ddis[1] . "-" . $ddis[2]; return $dmol; } else if (strlen($ddis[2]) == 1) { $dmol=$ddis[0] . "-" . $ddis[1] . "-0" . $ddis[2]; return $dmol; } $dmol=$dis; return $dis; } function sun_declination($indate) { global $sun_declination; $lday=0; $ayear=explode("-", $indate)[0]; $amonth=explode("-", $indate)[1]; $adate=explode("-", $indate)[2]; if (($ayear % 4) == 0) $lday=1; $sar=[0, 31, (59 + $lday), (80 + $lday), (120 + $lday), (151 + $lday), (181 + $lday), (212 + $lday), (243 + $lday), (273 + $lday), (304 + $lday), (334 + $lday)]; $hmdhp=$sar[-1 + $amonth] - 1 + $adate + 10; $dts=(360.0 / (365 + $lday)); $hdm=($hmdhp * $dts); $sun_declination=0.0 - (23.44 * cos($hdm * pi() / 180.0)); return $sun_declination; } $results=""; $vis=""; $sun_declination=0.00; $dmol=""; $ttspanfix=""; $yyyy = "yyyy"; $mnthis = "mnthis"; $dythis = "dythis"; $dateis = "2006-12-12"; $gdatenow=""; $pdatenow=""; $latis = "0.000000"; // 31.7667; $longis = "0.000000"; //35.2333; $tzis="GMT"; $sundecis=0.0; $refresh=""; $resextra=""; $preres=""; $diagram=""; $ilat="0"; $latd="0"; $latm="0"; $lats="0"; $longd="0"; $longm="0"; $longs="0"; if (ourissetget('place')) { $preres=" "; } else if (ourissetpost('place')) { $preres=" "; } if (isset($_GET['timezone'])) { $tzis=urldecode($_GET['timezone']); } else if (isset($_POST['timezone'])) { $tzis=urldecode($_POST['timezone']); } else if (ourissetget('latitude')) { $refresh=" document.getElementById('isubmit').click(); "; $resextra=$preres; if (strpos($_SERVER['HTTP_REFERER'], "sun_angle_now") !== false || (!isset($_GET['mv']) && !isset($_POST['mv']))) { $resextra.=" "; } else { $refresh=""; } if (!isset($_GET['dmdates'])) $gdatenow=zp(date("Y-m-d")); } else if (ourissetpost('latitude')) { $refresh=" document.getElementById('isubmit').click(); "; $resextra=$preres; if (strpos($_SERVER['HTTP_REFERER'], "sun_angle_now") !== false || (!isset($_GET['mv']) && !isset($_POST['mv']))) { $resextra.=" "; } else { $refresh=""; } if (!isset($_POST['dmdates'])) $pdatenow=zp(date("Y-m-d")); } if (ourissetget('place')) { $preres="    for: " . oururldecodeget('place') . "
"; } else if (ourissetpost('place')) { $preres="    for: " . oururldecodepost('place') . "
"; } date_default_timezone_set($tzis); if (!isset($_GET['dmdates']) && !isset($_POST['dmdates']) && (ourissetget('latitude') || ourissetpost('latitude'))) { $vis=" style='display:none;'"; //$diagram="

"; } else if (isset($_GET['beingcalled']) || isset($_POST['beingcalled'])) { $vis=" style='display:none;'"; //$diagram="
"; } if (isset($_GET['dmdates']) || $gdatenow != "") { if ($gdatenow != "") { $dateis=$gdatenow; } else { $dateis=zp(urldecode($_GET['dmdates'])); } if (str_replace("now","",$dateis) == "") { $dateis=zp(date("Y-m-d")); } if (ourissetget('latitude') && ourissetget('longitude')) { $latis=oururldecodeget('latitude'); $ilat=round($latis); if (!isset($_GET['dmdates']) && !isset($_POST['dmdates']) && (ourissetget('latitude') || ourissetpost('latitude'))) { //$vis=" style='display:none;'"; $diagram="

---->
---->
---->

"; } else if (isset($_GET['beingcalled']) || isset($_POST['beingcalled'])) { //$vis=" style='display:none;'"; $diagram="

---->
---->
---->

"; } else { $diagram="

---->
---->
---->

"; } $sunaltis=(90.0 + $latis - sun_declination($dateis)); // thanks to http://www.pveducation.org/pvcdrom/properties-of-sunlight/elevation-angle if ($sunaltis > 90.0) $sunaltis=(180.0 - $sunaltis); $longis=oururldecodeget('longitude'); $sun_info = date_sun_info(strtotime($dateis), $latis, $longis); $results.="
"; foreach ($sun_info as $key => $val) { if ($key == "sunrise") { $results.=$preres . "    at (latitude, longitude): ($latis, $longis)
    on: " . mb($dateis) . "
    $key: " . date("H:i:s", $val) . " " . $tzis . "
"; } else if ($key == "transit") { if (!isset($_GET['nowrite']) && !isset($_POST['nowrite'])) helpforothers($sunaltis, $latis, $longis, (date("H:i:s", $val) . " " . $tzis)); $ttspanfix=" if (parent.document) { if (parent.document.getElementById('ttspan')) { parent.document.getElementById('ttspan').innerHTML='" . date("H:i:s", $val) . " " . $tzis . "'; } } "; $results.="    " . $key . ": " . date("H:i:s", $val) . " " . $tzis . " when sun is elevated at " . $sunaltis . " degrees" . $diagram . "
"; } else { $results.="    $key: " . date("H:i:s", $val) . " " . $tzis . "
"; } } $results.="
"; } $yyyy=explode("-", $dateis)[0]; $mnthis=(-1 + explode("-", $dateis)[1]); $dythis=explode("-", $dateis)[2]; } else if (isset($_POST['dmdates']) || $pdatenow != "") { if ($pdatenow != "") { $dateis=$pdatenow; } else { $dateis=zp(urldecode($_POST['dmdates'])); } if (str_replace("now","",$dateis) == "") { $dateis=zp(date("Y-m-d")); } if (ourissetpost('latitude') && ourissetpost('longitude')) { $latis=oururldecodepost('latitude'); $ilat=round($latis); if (!isset($_GET['dmdates']) && !isset($_POST['dmdates']) && (ourissetget('latitude') || ourissetpost('latitude'))) { //$vis=" style='display:none;'"; $diagram="

---->
---->
---->

"; } else if (isset($_GET['beingcalled']) || isset($_POST['beingcalled'])) { //$vis=" style='display:none;'"; $diagram="

---->
---->
---->

"; } else { $diagram="

---->
---->
---->

"; } $sunaltis=(90.0 + $latis - sun_declination($dateis)); // thanks to http://www.pveducation.org/pvcdrom/properties-of-sunlight/elevation-angle if ($sunaltis > 90.0) $sunaltis=(180.0 - $sunaltis); $longis=oururldecodepost('longitude'); $sun_info = date_sun_info(strtotime($dateis), $latis, $longis); $results.="
"; foreach ($sun_info as $key => $val) { if ($key == "sunrise") { $results.=$preres . "    at (latitude, longitude): ($latis, $longis)
    on: " . mb($dateis) . "
    $key: " . date("H:i:s", $val) . " " . $tzis . "
"; } else if ($key == "transit") { if (!isset($_GET['nowrite']) && !isset($_POST['nowrite'])) helpforothers($sunaltis, $latis, $longis, (date("H:i:s", $val) . " " . $tzis)); $ttspanfix=" if (parent.document) { if (parent.document.getElementById('ttspan')) { parent.document.getElementById('ttspan').innerHTML='" . date("H:i:s", $val) . " " . $tzis . "'; } } "; $results.="    " . $key . ": " . date("H:i:s", $val) . " " . $tzis . " when sun is elevated at " . $sunaltis . " degrees" . $diagram . "
"; } else { $results.="    $key: " . date("H:i:s", $val) . " " . $tzis . "
"; } } $results.="
"; } $yyyy=explode("-", $dateis)[0]; $mnthis=(-1 + explode("-", $dateis)[1]); $dythis=explode("-", $dateis)[2]; } echo " Sun Information - RJM Programming - January, 2018 ... Thanks to http://php.net/manual/en/function.date-sun-info.php var today=new Date(); var yyyy = today.getFullYear(); var mnthis = today.getMonth(); var dythis = today.getDate(); var selc = 0; var geolocation = null; function errorHandler(err) { if (err.code == 1) { if (1 == 2) alert('Access is denied'); } } function showLocation( position ) { document.getElementById('latitude').value = '' + position.coords.latitude; document.getElementById('longitude').value = '' + position.coords.longitude; } function getLocation() { if (selc == 0) { selc=1; geolocation = navigator.geolocation; geolocation.getCurrentPosition(showLocation, errorHandler, {maximumAge: 75000}); } } function ol() { if (parent.document) { if (parent.document.getElementById('nnspan')) { if (document.getElementById('nnnspan')) { if (document.getElementById('nnnspan').innerHTML.length > 0 && parent.document.getElementById('nnspan').innerHTML.length == 0) { document.getElementById('nnnspan').innerHTML=''; } else if (document.getElementById('nnnspan').innerHTML.length > 0 && parent.document.getElementById('nnspan').innerHTML.length > 0) { if (document.getElementById('nnnspan').innerHTML.trim() != parent.document.getElementById('nnspan').innerHTML.trim()) { parent.document.getElementById('nnspan').innerHTML=document.getElementById('nnnspan').innerHTML; } } } } } " . $ttspanfix . " var tzis='' + Intl.DateTimeFormat().resolvedOptions().timeZone; /" . "/ Thanks to https://stackoverflow.com/questions/22618056/javascript-timezone-information-how-to-get-america-los-angeles-or-equivalent/22625076#22625076 if (tzis != '') { document.getElementById('timezone').value=tzis; " . $refresh . " } document.getElementById('myform').action=document.URL.split('#')[0].split('?')[0]; var dprefix='0', mprefix='0', i, months=['','January','February','March','April','May','June','July','August','September','October','November','December']; for (i=eval('' + yyyy) + 1; i>(eval('' + yyyy) - 100); i--) { if (i == " . $yyyy . ") { document.getElementById('dmdates').value='' + i; document.getElementById('syears').innerHTML+=''; } else { document.getElementById('syears').innerHTML+=''; } } for (i=1; i<=12; i++) { if (eval(-1 + i) == " . $mnthis . ") { document.getElementById('dmdates').value+='-' + mprefix + i; document.getElementById('smonths').innerHTML+=''; } else { document.getElementById('smonths').innerHTML+=''; } if (i == 9) mprefix=''; } for (i=1; i<=31; i++) { if (i == " . $dythis . ") { document.getElementById('dmdates').value+='-' + mprefix + i; document.getElementById('sdays').innerHTML+=''; } else { document.getElementById('sdays').innerHTML+=''; } if (i == 9) dprefix=''; } getLocation(); } function dc(sois) { if (sois.value != '') { var paro=null, lastc=sois.id.slice(-1); if (sois.id.indexOf('year') != -1) { paro=document.getElementById(sois.id.replace('s','dm').replace('year','date')); if (paro.value == '') { if (document.getElementById(sois.id.replace('year' + lastc,'month' + lastc)).value == '') { document.getElementById(sois.id.replace('year' + lastc,'month' + lastc)).value='01'; } if (document.getElementById(sois.id.replace('year' + lastc,'day' + lastc)).value == '') { document.getElementById(sois.id.replace('year' + lastc,'day' + lastc)).value='01'; } } paro.value=sois.value + '-' + document.getElementById(sois.id.replace('year' + lastc,'month' + lastc)).value + '-' + document.getElementById(sois.id.replace('year' + lastc,'day' + lastc)).value; } else if (sois.id.indexOf('month') != -1) { paro=document.getElementById(sois.id.replace('s','dm').replace('month','date')); if (paro.value == '') { if (document.getElementById(sois.id.replace('month' + lastc,'day' + lastc)).value == '') { document.getElementById(sois.id.replace('month' + lastc,'day' + lastc)).value='01'; } if (document.getElementById(sois.id.replace('month' + lastc,'year' + lastc)).value == '') { document.getElementById(sois.id.replace('month' + lastc,'year' + lastc)).value='' + yyyy; } } paro.value=document.getElementById(sois.id.replace('month' + lastc,'year' + lastc)).value + '-' + sois.value + '-' + document.getElementById(sois.id.replace('month' + lastc,'day' + lastc)).value; } else if (sois.id.indexOf('day') != -1) { paro=document.getElementById(sois.id.replace('s','dm').replace('day','date')); if (paro.value == '') { if (document.getElementById(sois.id.replace('day' + lastc,'month' + lastc)).value == '') { document.getElementById(sois.id.replace('day' + lastc,'month' + lastc)).value='01'; } if (document.getElementById(sois.id.replace('day' + lastc,'year' + lastc)).value == '') { document.getElementById(sois.id.replace('day' + lastc,'year' + lastc)).value='' + yyyy; } } paro.value=document.getElementById(sois.id.replace('day' + lastc,'year' + lastc)).value + '-' + document.getElementById(sois.id.replace('day' + lastc,'month' + lastc)).value + '-' + sois.value; } } } function checkthings() { return true; } function dhdf() { document.getElementById('dhead').style.display='block'; document.getElementById('dfoot').style.display='block'; } window.onload=ol;

Sun Information

RJM Programming - January, 2018 ... Thanks to http://php.net/manual/en/function.date-sun-info.php

" . $results . "
Date: Timezone: Latitude: Longitude:

" . $resextra . "
"; ?>