<?php
// craters.php
// Craters on Earth
// RJM Programming
// Thanks to https://en.wikipedia.org/wiki/List_of_impact_craters_on_Earth
// params=58_27_N_109_30_W_&amp;title=Carswell


 $cont=file_get_contents("http://en.wikipedia.org/wiki/List_of_impact_craters_on_Earth");

 $junk="";
 $areg="";
 $delm="";
 
 $datais="";
 $dataarray=explode("&amp;title=", $cont);
 
 
 for ($i=1; $i<sizeof($dataarray); $i++) {
   $titleis=str_replace("_"," ",explode('"', $dataarray[$i])[0]);
   $rest=explode('=', $dataarray[-1 + $i])[-1 + sizeof(explode('=', $dataarray[-1 + $i]))];
   $nlats=explode('_N_', $rest);
   if (sizeof($nlats) > 1) {
     $lbits=explode('_', $nlats[0]);
     $factor=1.0;
     $latis=0.0;
     for ($ii=0; $ii<sizeof($lbits); $ii++) {
      $latis += ($lbits[$ii] / ($factor));
      $factor *= 60.0;
     }
     $rest=$nlats[1] . " ";
   } else {
     $lbits=explode('_', explode('_S_', $rest)[0]);
     $factor=-1.0;
     $latis=0.0;
     for ($ii=0; $ii<sizeof($lbits); $ii++) {
      $latis += ($lbits[$ii] / ($factor));
      $factor *= 60.0;
     }
     $rest=explode('_S_', $rest)[1] . " ";
   }

   $nlongs=explode('_E_', $rest);
   if (sizeof($nlongs) > 1) {
     $lbits=explode('_', $nlongs[0]);
     $factor=1.0;
     $longis=0.0;
     for ($ii=0; $ii<sizeof($lbits); $ii++) {
      $longis += ($lbits[$ii] / ($factor));
      $factor *= 60.0;
     }
   } else {
     $lbits=explode('_', explode('_W_', $rest)[0]);
     $factor=-1.0;
     $longis=0.0;
     for ($ii=0; $ii<sizeof($lbits); $ii++) {
      $longis += ($lbits[$ii] / ($factor));
      $factor *= 60.0;
     }
   }


   if ($i < 7 || 1 == 1) {
     $junk .= $delm . str_replace("+","%20",urlencode($titleis)) . "_crater";
     $areg .= $delm . "http." . str_replace("+","%20",urlencode($titleis)) . "_crater";
     $datais .= ", [" . str_replace("+","",$latis) . "," . str_replace("+","",$longis) . ",~" . str_replace("%2B","%20",str_replace("+","%20",urlencode($titleis))) . "~]";
     $delm=",";
   }
 }
  
 $htmlis="<!doctype html>
<html>
<head>
<title>Meteorite Craters on Earth - RJM Programming - October, 2018 - Thanks to https://en.wikipedia.org/wiki/List_of_impact_craters_on_Earth</title>
<style>
 #tdnmap #nmap { width: 450px; }
 #tdgmap #gmap { calc(100% - 450px); }
</style>
<script type='text/javascript'>
  function dowh() {
    var rwis=document.body.getBoundingClientRect();
    var wis=Math.floor(eval(rwis.right) - eval(rwis.left) - 450);
    document.getElementById('height').value='' + Math.floor(eval('312.0') * eval(('' + wis).replace('px','')) / eval('500.0'));
    document.getElementById('width').value='' + Math.floor(eval('500.0') * eval(('' + wis).replace('px','')) / eval('500.0'));
    document.getElementById('gmap').style.width='' + document.getElementById('width').value + 'px';
    document.getElementById('tdgmap').style.width='' + document.getElementById('width').value + 'px';
    location.href='#tab';
  }
</script>
</head>
<body onload=\" dowh(); document.getElementById('isubmit').click(); document.getElementById('jsubmit').click();\">
<h1>Meteorite Craters on Earth</h1>
<h3>RJM Programming - October, 2018 - Thanks to <a target=_blank href='//en.wikipedia.org/wiki/List_of_impact_craters_on_Earth' title='List of impact craters on Earth'>List of impact craters on Earth</a></h3>
<form onsubmit=\"document.getElementById('tab').style.display='table'; document.getElementById('tdgmap').style.display='table-cell'; document.getElementById('gmap').style.display='inline-block'; return true;\" style='display:none;' target='gmap' method='POST' id='mygform' action='//www.rjmprogramming.com.au/PHP/GeoChart/geo_chart.php'>
<input type=hidden id=title name=title value='Meteorite Craters on Earth'></input>
<input type=hidden name=onclick value='y'></input>
<input type=hidden name=arexplaces value='y'></input>
<input type=hidden id=aregeographicals name=aregeographicals value='" . $areg . "'></input>
<input type=hidden id=junk name=junk value='" . $junk . "'></input>
<input type=hidden id=country name=country value='Places'></input>
<input type=hidden id=popularity name=popularity value=''></input>
<input type=hidden id=width name=width value=\"500\"></input>
<input type=hidden id=height name=height value=\"312\"></input>
<input type=hidden name=data value='" . str_replace("]",",2]",str_replace(",","|",substr($datais,1))) . "'></input>
<input style=display:none; type='submit' id='jsubmit' value='Show'></input>
</form>
<form onsubmit=\"document.getElementById('tab').style.display='table'; document.getElementById('tdnmap').style.display='table-cell'; document.getElementById('nmap').style.display='inline-block'; return true;\" style='display:none;' target='nmap' method='POST' id='mynform' action='//www.rjmprogramming.com.au/PHP/Map/map.php'>
<input type=hidden id=title name=title value='Meteorite Craters on Earth'></input>
<input type=hidden name=onclick value='y'></input>
<input type=hidden id=label name=label value=\"['Lat',\"></input>
<input type=hidden id=value name=value value=\"'Lon','Name']\"></input>
<input type=hidden name=data value='" . $datais . "'></input>
<input style=display:none; type='submit' id='isubmit' value='Show'></input>
</form>
<table id='tab' style='display:none;width:100%;height:900px;'><tr><td id='tdgmap' style='display:none;height:900px;'>
<iframe name='gmap' id='gmap' style='display:none;height:900px;' src='//www.rjmprogramming.com.au/About_Us.html'></iframe>
</td><td id='tdnmap' style='display:none;width:450px;width:100%;height:900px;'>
<iframe name='nmap' id='nmap' style='display:none;width:450px;height:900px;' src='//www.rjmprogramming.com.au/About_Us.html'></iframe>
</td></tr></table>
</body>
</html>
";
 
 
 
 echo $htmlis;
 
?>

 