<?php
// read_exif_off_image_rotate.php
// RJM Programming
// August, 2016
// Thanks to http://www.v-nessa.net/2010/08/02/using-php-to-extract-image-exif-data

// http://localhost:8888/read_exif_off_image_rotate.php?image=HTTP://localhost:8888/mysterytrip/IMG_1125.JPG#myh1

set_time_limit(320);

function great_circle_distance($talis, $gnolis, $latis, $longis) {
  $ourdist=0.0;
  $rgnol=(($gnolis) * pi() / 180.0);
  $rtal=(($talis) * pi() / 180.0);
  $rlong=(($longis) * pi() / 180.0);
  $rlat=(($latis) * pi() / 180.0);


  $deltalong = abs(((($gnolis)-($longis)) * pi() / 180.0));


  $acof = (sin($rtal) * sin($rlat)) + (cos($rtal) * cos($rlat) * cos($deltalong)); // via http://en.wikipedia.org/wiki/Great-circle_distance ... thanks

  $ourdist = (round((acos($acof) * 6371000.0) + 0.00001) * 100) / 100;
  return $ourdist;
}

$aside="<font size=1 id=aside></font>";
$doaside="";

$iwidth=0;
$iheight=0;
$csswh="";


$image="";
$ximage="";
$exifbit="Exif";

$fsuffix="";
$dprefix="";
$dsuffix="";

if (!isset($_GET['mystery']) && !isset($_POST['mystery'])) {
$fsuffix='<input name=mystery type=hidden value=y></input>';
if (isset($_GET['image'])) {
  $image = str_replace("+", " ", urldecode($_GET['image']));
} else if (isset($_POST['image'])) {
  $image = urldecode($_POST['image']);
  $doaside="\n prefetch('" . $image . "'); \n";
} else if (file_exists("/Applications/MAMP/htdocs/clouds.jpg")) {
  $image = "/Applications/MAMP/htdocs/clouds.jpg";
}
} else { 
if (isset($_GET['image'])) {
  $dprefix="You can score by clicking headings and answering prompts correctly.  There are image distance hover hints and other click hints and there is the <a style='text-decoration:underline;cursor:pointer;' onclick='giveanswer();'>Ready to Give Up Now</a> link.<div id=topdiv style=display:none;>";
  $dsuffix="</div>";
  $image = str_replace("+", " ", urldecode($_GET['image']));
  $doaside="\n prefetch('" . $image . "'); \n";
} else if (isset($_POST['image'])) {
  $dprefix="You can score by clicking headings and answering prompts correctly.  There are image distance hover hints and other click hints and there is the <a style='text-decoration:underline;cursor:pointer;' onclick='giveanswer();'>Ready to Give Up Now</a> link.<div id=topdiv style=display:none;>";
  $dsuffix="</div>";
  $image = urldecode($_POST['image']);
  $doaside="\n prefetch('" . $image . "'); \n";
}
}

if ($image != "") {
  list($width, $height, $type, $attr) = getimagesize($image);
  //$iwidth=$width;
  //$iheight=$height;
  //$csswh=" width:" . $iwidth . "px; height:" . $iheight . "px; ";
  $csswh=" width: calc(100% - 10px); height: calc(100% - 220px); text-align: right; margin-right: 20px;  } form { position: absolute; left:50px; top: calc(100% - 45px); width:100%; height:40px; ";
  //$csswh="";
}

if (strpos((strtolower($image) . "~"), ".zip~") !== false || isset($_GET['mystery']) || isset($_POST['mystery'])) {
  $idata=[""];
  $isdata=[""];
  $zdata=[""];
  $countrydata=[""];
  $countrycodedata=[""];
  $geodata=[""];
  $gdata="";
  $distdata=["0.0"];
  $htmlis="";
  $thisone="";
  $eachone="";
  $lastzd="";
  $bimage=$image;
  $psstate="";
  $pfstate="";
  $pstown="";
  $pftown="";
  $gctprefix="//www.rjmprogramming.com.au/PHP/GeoChart/geo_chart.php?title=Mystery%20Trip&arexplaces=y&width=1000&height=624&country=Places&popularity=Trip&aregeographicals=";
  $gctmiddle="HTTP.0&peninfo="; // HTTP.0%2Chttp.1%2Chttp.2%2Chttp.3%2Chttp.4%2Chttp.5&peninfo=Broome,+Hobart,Tennant Creek,+Cairns,Sydney,+Brisbane
  $gctsuffixlat="&data="; // [-17.961944444444|122.23611111111|~Broome~,7] , [-42.88334|147.31666|~Hobart~,7] , [-19.647222222222|134.19027777778|~Tennant Creek~,2] , [-16.930277777778|145.77027777778|~Cairns~,2] , [-33.86667|151.21666|~Sydney~,1] , [-27.46667|153.03333|~Brisbane~,1]
  $gctsuffixlong="&data="; // [-17.961944444444|122.23611111111|~Broome~,7] , [-42.88334|147.31666|~Hobart~,7] , [-19.647222222222|134.19027777778|~Tennant Creek~,2] , [-16.930277777778|145.77027777778|~Cairns~,2] , [-33.86667|151.21666|~Sydney~,1] , [-27.46667|153.03333|~Brisbane~,1]

  if ($image == "") {
  $tablebits="<h1>Image Trip Start Finish Guessing Game<h1>
<h3>RJM Programming - October, 2018</h3><br><form onsubmit='ons(this); return true;' id=myzform method=POST action='./read_exif_off_image_rotate.php'>
" . $dprefix . "<input id=myzsubmit style='display:none;background-color:yellow;' type=submit value='Having Filled in Below, Ready for Second Player to Play and Guess Start and Finish Places ... click first and allow Second Player to then Turn Around and Play'></input>
<input placeholder='Start address 1' type=text style=display:none; id=formsa1 name=sa1 value=\"" . str_replace("+"," ",$_GET['sa1']) . str_replace("+"," ",$_POST['sa1']) . "\"></input>
<input placeholder='Start address 2' type=text style=display:none; id=formsa2 name=sa2 value=\"" . str_replace("+"," ",$_GET['sa2']) . str_replace("+"," ",$_POST['sa2']) . "\"></input>
<input placeholder='Start town' type=text style=display:none; id=formstown name=stown value=\"" . str_replace("+"," ",$_GET['stown']) . str_replace("+"," ",$_POST['stown']) . "\"></input>
<input placeholder='Start state' type=text style=display:none; id=formsstate name=sstate value=\"" . str_replace("+"," ",$_GET['sstate']) . str_replace("+"," ",$_POST['sstate']) . "\"></input>
<input placeholder='Start country' type=text style=display:none; id=formscountry name=scountry value=\"" . str_replace("+"," ",$_GET['scountry']) . str_replace("+"," ",$_POST['scountry']) . "\"></input>
<input placeholder='Start planet' type=text style=display:none; id=formsplanet name=splanet value=\"" . str_replace("+"," ",$_GET['splanet']) . str_replace("+"," ",$_POST['splanet']) . "\"></input>
<input placeholder='Start elevation' type=text style=display:none; id=formselevation name=selevation value=\"" . str_replace("+"," ",$_GET['selevation']) . str_replace("+"," ",$_POST['selevation']) . "\"></input><br>
<input placeholder='Finish address 1' type=text style=display:none; id=formfa1 name=fa1 value=\"" . str_replace("+"," ",$_GET['fa1']) . str_replace("+"," ",$_POST['fa1']) . "\"></input>
<input placeholder='Finish address 2' type=text style=display:none; id=formfa2 name=fa2 value=\"" . str_replace("+"," ",$_GET['fa2']) . str_replace("+"," ",$_POST['fa2']) . "\"></input>
<input placeholder='Finish town' type=text style=display:none; id=formftown name=ftown value=\"" . str_replace("+"," ",$_GET['ftown']) . str_replace("+"," ",$_POST['ftown']) . "\"></input>
<input placeholder='Finish state' type=text style=display:none; id=formfstate name=fstate value=\"" . str_replace("+"," ",$_GET['fstate']) . str_replace("+"," ",$_POST['fstate']) . "\"></input>
<input placeholder='Finish country' type=text style=display:none; id=formfcountry name=fcountry value=\"" . str_replace("+"," ",$_GET['fcountry']) . str_replace("+"," ",$_POST['fcountry']) . "\"></input>
<input placeholder='Finish planet' type=text style=display:none; id=formfplanet name=fplanet value=\"" . str_replace("+"," ",$_GET['fplanet']) . str_replace("+"," ",$_POST['fplanet']) . "\"></input>
<input placeholder='Finish elevation' type=text style=display:none; id=formfelevation name=felevation value=\"" . str_replace("+"," ",$_GET['felevation']) . str_replace("+"," ",$_POST['felevation']) . "\"></input>
" . $dsuffix . "<br>Zipfile of Images of Trip: <input onblur='scoreit(0,this);' style='width:30%;' id=ximage name=image type=text title='" . $image . "' placeholder='Enter zipfile containing image files' value='" . $bimage . "'></input>
" . $fsuffix . "</form>
<h4 id=score>Score: 0</h4>
<table style='width:100%;background-color:#e0e0e0;'><tbody>
<tr style='background-color:#d0d0d0;'><th colspan=7>Start of Mystery Trip</th><th colspan=7>Finish of Mystery Trip</th></tr>
<tr style='background-color:#d0d0d0;'><th id=xsa1 onclick='scoreit(0,this);'>Address 1</th><th id=xsa2 onclick='scoreit(0,this);'>Address 2</th><th id=xstown onclick='scoreit(0,this);'>Town/City/Suburb</th><th id=xsstate onclick='scoreit(0,this);'>State/Territory</th><th id=xselevation onclick='scoreit(0,this);'>Elevation</th><th id=xscountry onclick='scoreit(0,this);'>Country</th><th><select id='xsplanet' onchange='scoreit(0,this);'><option value=''>Planet</option>
<option value='Mercury'>Mercury</option>
<option value='Venus'>Venus</option>
<option value='Earth'>Earth</option>
<option value='Mars'>Mars</option>
<option value='Jupiter'>Jupiter</option>
<option value='Saturn'>Saturn</option>
<option value='Uranus'>Uranus</option>
<option value='Neptune'>Neptune</option>
<option value='Pluto'>Pluto</option>
</select></th><th id=xfa1 onclick='scoreit(0,this);'>Address 1</th><th id=xfa2 onclick='scoreit(0,this);'>Address 2</th><th id=xftown onclick='scoreit(0,this);'>Town/City/Suburb</th><th id=xfstate onclick='scoreit(0,this);'>State/Territory</th><th id=xfelevation onclick='scoreit(0,this);'>Elevation</th><th id=xfcountry onclick='scoreit(0,this);'>Country</th><th><select id='xfplanet' onchange='scoreit(0,this);'><option value=''>Planet</option>
<option value='Mercury'>Mercury</option>
<option value='Venus'>Venus</option>
<option value='Earth'>Earth</option>
<option value='Mars'>Mars</option>
<option value='Jupiter'>Jupiter</option>
<option value='Saturn'>Saturn</option>
<option value='Uranus'>Uranus</option>
<option value='Neptune'>Neptune</option>
<option value='Pluto'>Pluto</option>
</select></th></tr>
<tr><td colspan=6><textarea rows=10 style='width:100%;height:100%;' id=sd readonly></textarea></td><td colspan=8>
<img SRC='" . $idata[0] . "' title='Click for hint' onclick='givehint();'></img>
</td></tr>
<TR><td colspan=8 style='text-align:right;'>
<img src='" . "" . "'></img>
</td><td colspan=6><textarea rows=10 style='width:100%;height:100%;' id=fd readonly></textarea></td></tr>
<tr style='background-color:#d0d0d0;'><th id=sa1 onclick='scoreit(0,this);'>Address 1</th><th id=sa2 onclick='scoreit(0,this);'>Address 2</th><th id=stown onclick='scoreit(0,this);'>Town/City/Suburb</th><th id=sstate onclick='scoreit(0,this);'>State/Territory</th><th id=selevation onclick='scoreit(0,this);'>Elevation</th><th id=scountry onclick='scoreit(0,this);'>Country</th><th><select id='splanet' onchange='scoreit(0,this);'><option value=''>Planet</option>
<option value='Mercury'>Mercury</option>
<option value='Venus'>Venus</option>
<option value='Earth'>Earth</option>
<option value='Mars'>Mars</option>
<option value='Jupiter'>Jupiter</option>
<option value='Saturn'>Saturn</option>
<option value='Uranus'>Uranus</option>
<option value='Neptune'>Neptune</option>
<option value='Pluto'>Pluto</option>
</select></th><th id=fa1 onclick='scoreit(0,this);'>Address 1</th><th id=fa2 onclick='scoreit(0,this);'>Address 2</th><th id=ftown onclick='scoreit(0,this);'>Town/City/Suburb</th><th id=fstate onclick='scoreit(0,this);'>State/Territory</th><th id=felevation onclick='scoreit(0,this);'>Elevation</th><th id=fcountry onclick='scoreit(0,this);'>Country</th><th><select id='fplanet' onchange='scoreit(0,this);'><option value=''>Planet</option>
<option value='Mercury'>Mercury</option>
<option value='Venus'>Venus</option>
<option value='Earth'>Earth</option>
<option value='Mars'>Mars</option>
<option value='Jupiter'>Jupiter</option>
<option value='Saturn'>Saturn</option>
<option value='Uranus'>Uranus</option>
<option value='Neptune'>Neptune</option>
<option value='Pluto'>Pluto</option>
<tr style='background-color:#d0d0d0;'><th colspan=7>Start of Mystery Trip</th><th colspan=7>Finish of Mystery Trip</th></tr>
</select></th></tr>
</tbody></table>";
          } else {
  $contis=file_get_contents($image);
  $bz="";
  $zipfile="temp" . $bz . ".zip";
  while (file_exists("temp" . $bz . ".zip")) {
       if (("" . $bz) == "") {
         $bz=1;
       } else {
         $bz++;
       }
       $zipfile="temp" . $bz . ".zip";
  }
  file_put_contents($zipfile, $contis);
  $zip = zip_open($zipfile);
  $jj=0;
  $tablebits="";
  if ($zip) {
      while ($zip_entry = zip_read($zip)) {
       $ourfilename=zip_entry_name($zip_entry);
       $nc='';
       $ncc='';
       $geod='';
       $zd='';
       $tn='';
       if (strpos($ourfilename, "_MACOSX/") === false) {
         $finame=explode("/", $ourfilename)[-1 + sizeof(explode("/", $ourfilename))];
         $fname=explode(substr("\\",0,1), $finame)[-1 + sizeof(explode(substr("\\",0,1), $finame))];
         $bz="";
         while (file_exists(fname)) {
          if (("" . $bz) == "") {
            $fname=str_replace("" . $bz . ".", "1.", $fname);
            $bz=1;
          } else {
            $fname=str_replace("" . $bz . ".", "" . ($bz + 1) . ".", $fname);
            $bz++;
          }
         }
         $isc=zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
         if ($jj == 0) {
         $idata[$jj]='data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $ourfilename)[-1 + sizeof(explode(".", $ourfilename))])) . ';base64,' . base64_encode($isc);
  if (strpos($image, "//") === false) {
    $bimage=str_replace(":443/","/",str_replace(":80/","/","http://" . $_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT'] . str_replace("read_exif_off_image_rotate.php", $image, explode("?", explode("#", $_SERVER['REQUEST_URI'])[0])[0])));
  }
  $tablebits="<h1>Image Trip Start Finish Guessing Game<h1>
<h3>RJM Programming - October, 2018</h3><br><form onsubmit='ons(this); return true;' id=myzform method=POST action='./read_exif_off_image_rotate.php'>
" . $dprefix . "<input id=myzsubmit style='display:none;background-color:yellow;' type=submit value='Having Filled in Below, Ready for Second Player to Play and Guess Start and Finish Places ... click first and allow Second Player to then Turn Around and Play'></input>
<input placeholder='Start address 1' type=text style=display:none; id=formsa1 name=sa1 value=\"" . str_replace("+"," ",$_GET['sa1']) . str_replace("+"," ",$_POST['sa1']) . "\"></input>
<input placeholder='Start address 2' type=text style=display:none; id=formsa2 name=sa2 value=\"" . str_replace("+"," ",$_GET['sa2']) . str_replace("+"," ",$_POST['sa2']) . "\"></input>
<input placeholder='Start town' type=text style=display:none; id=formstown name=stown value=\"" . str_replace("+"," ",$_GET['stown']) . str_replace("+"," ",$_POST['stown']) . "\"></input>
<input placeholder='Start state' type=text style=display:none; id=formsstate name=sstate value=\"" . str_replace("+"," ",$_GET['sstate']) . str_replace("+"," ",$_POST['sstate']) . "\"></input>
<input placeholder='Start country' type=text style=display:none; id=formscountry name=scountry value=\"" . str_replace("+"," ",$_GET['scountry']) . str_replace("+"," ",$_POST['scountry']) . "\"></input>
<input placeholder='Start planet' type=text style=display:none; id=formsplanet name=splanet value=\"" . str_replace("+"," ",$_GET['splanet']) . str_replace("+"," ",$_POST['splanet']) . "\"></input>
<input placeholder='Start elevation' type=text style=display:none; id=formselevation name=selevation value=\"" . str_replace("+"," ",$_GET['selevation']) . str_replace("+"," ",$_POST['selevation']) . "\"></input><br>
<input placeholder='Finish address 1' type=text style=display:none; id=formfa1 name=fa1 value=\"" . str_replace("+"," ",$_GET['fa1']) . str_replace("+"," ",$_POST['fa1']) . "\"></input>
<input placeholder='Finish address 2' type=text style=display:none; id=formfa2 name=fa2 value=\"" . str_replace("+"," ",$_GET['fa2']) . str_replace("+"," ",$_POST['fa2']) . "\"></input>
<input placeholder='Finish town' type=text style=display:none; id=formftown name=ftown value=\"" . str_replace("+"," ",$_GET['ftown']) . str_replace("+"," ",$_POST['ftown']) . "\"></input>
<input placeholder='Finish state' type=text style=display:none; id=formfstate name=fstate value=\"" . str_replace("+"," ",$_GET['fstate']) . str_replace("+"," ",$_POST['fstate']) . "\"></input>
<input placeholder='Finish country' type=text style=display:none; id=formfcountry name=fcountry value=\"" . str_replace("+"," ",$_GET['fcountry']) . str_replace("+"," ",$_POST['fcountry']) . "\"></input>
<input placeholder='Finish planet' type=text style=display:none; id=formfplanet name=fplanet value=\"" . str_replace("+"," ",$_GET['fplanet']) . str_replace("+"," ",$_POST['fplanet']) . "\"></input>
<input placeholder='Finish elevation' type=text style=display:none; id=formfelevation name=felevation value=\"" . str_replace("+"," ",$_GET['felevation']) . str_replace("+"," ",$_POST['felevation']) . "\"></input>
" . $dsuffix . "<br>Zipfile of Images of Trip: <input onblur='scoreit(0,this);' style='width:30%;' id=ximage name=image type=text title='" . $image . "' placeholder='Enter zipfile containing image files' value='" . $bimage . "'></input>
" . $fsuffix . "</form>
<h4 id=score>Score: 0/0</h4>
<table style='width:100%;background-color:#e0e0e0;'><tbody>
<tr style='background-color:#d0d0d0;'><th colspan=7>Start of Mystery Trip</th><th colspan=7>Finish of Mystery Trip</th></tr>
<tr style='background-color:#d0d0d0;'><th id=xsa1 onclick='scoreit(0,this);'>Address 1</th><th id=xsa2 onclick='scoreit(0,this);'>Address 2</th><th id=xstown onclick='scoreit(0,this);'>Town/City/Suburb</th><th id=xsstate onclick='scoreit(0,this);'>State/Territory</th><th id=xselevation onclick='scoreit(0,this);'>Elevation</th><th id=xscountry onclick='scoreit(0,this);'>Country</th><th><select id='xsplanet' onchange='scoreit(0,this);'><option value=''>Planet</option>
<option value='Mercury'>Mercury</option>
<option value='Venus'>Venus</option>
<option value='Earth'>Earth</option>
<option value='Mars'>Mars</option>
<option value='Jupiter'>Jupiter</option>
<option value='Saturn'>Saturn</option>
<option value='Uranus'>Uranus</option>
<option value='Neptune'>Neptune</option>
<option value='Pluto'>Pluto</option>
</select></th><th id=xfa1 onclick='scoreit(0,this);'>Address 1</th><th id=xfa2 onclick='scoreit(0,this);'>Address 2</th><th id=xftown onclick='scoreit(0,this);'>Town/City/Suburb</th><th id=xfstate onclick='scoreit(0,this);'>State/Territory</th><th id=xfelevation onclick='scoreit(0,this);'>Elevation</th><th id=xfcountry onclick='scoreit(0,this);'>Country</th><th><select id='xfplanet' onchange='scoreit(0,this);'><option value=''>Planet</option>
<option value='Mercury'>Mercury</option>
<option value='Venus'>Venus</option>
<option value='Earth'>Earth</option>
<option value='Mars'>Mars</option>
<option value='Jupiter'>Jupiter</option>
<option value='Saturn'>Saturn</option>
<option value='Uranus'>Uranus</option>
<option value='Neptune'>Neptune</option>
<option value='Pluto'>Pluto</option>
</select></th></tr>
<tr><td colspan=6><textarea rows=10 style='width:100%;height:100%;' id=sd readonly></textarea></td><td colspan=8>
<img SRC='" . $idata[0] . "' title='Click for hint' onclick='givehint();'></img>
</td></tr>
<TR><td colspan=8 style='text-align:right;'>
<img src='" . "" . "'></img>
</td><td colspan=6><textarea rows=10 style='width:100%;height:100%;' id=fd readonly></textarea></td></tr>
<tr style='background-color:#d0d0d0;'><th id=sa1 onclick='scoreit(0,this);'>Address 1</th><th id=sa2 onclick='scoreit(0,this);'>Address 2</th><th id=stown onclick='scoreit(0,this);'>Town/City/Suburb</th><th id=sstate onclick='scoreit(0,this);'>State/Territory</th><th id=selevation onclick='scoreit(0,this);'>Elevation</th><th id=scountry onclick='scoreit(0,this);'>Country</th><th><select id='splanet' onchange='scoreit(0,this);'><option value=''>Planet</option>
<option value='Mercury'>Mercury</option>
<option value='Venus'>Venus</option>
<option value='Earth'>Earth</option>
<option value='Mars'>Mars</option>
<option value='Jupiter'>Jupiter</option>
<option value='Saturn'>Saturn</option>
<option value='Uranus'>Uranus</option>
<option value='Neptune'>Neptune</option>
<option value='Pluto'>Pluto</option>
</select></th><th id=fa1 onclick='scoreit(0,this);'>Address 1</th><th id=fa2 onclick='scoreit(0,this);'>Address 2</th><th id=ftown onclick='scoreit(0,this);'>Town/City/Suburb</th><th id=fstate onclick='scoreit(0,this);'>State/Territory</th><th id=felevation onclick='scoreit(0,this);'>Elevation</th><th id=fcountry onclick='scoreit(0,this);'>Country</th><th><select id='fplanet' onchange='scoreit(0,this);'><option value=''>Planet</option>
<option value='Mercury'>Mercury</option>
<option value='Venus'>Venus</option>
<option value='Earth'>Earth</option>
<option value='Mars'>Mars</option>
<option value='Jupiter'>Jupiter</option>
<option value='Saturn'>Saturn</option>
<option value='Uranus'>Uranus</option>
<option value='Neptune'>Neptune</option>
<option value='Pluto'>Pluto</option>
<tr style='background-color:#d0d0d0;'><th colspan=7>Start of Mystery Trip</th><th colspan=7>Finish of Mystery Trip</th></tr>
</select></th></tr>
</tbody></table>";
         } else {
         if ($jj > 1) {
         $tablebits=str_replace("<TR>", "\n<tr><td colspan=4></td><td colspan=6><img title=' ' data-z='" . $lastzd . "' " . $isdata[-1 + $jj] . " src='" . $idata[-1 + $jj] . "'></td><td colspan=4></td></tr><TR>", $tablebits);
         }
         array_push($idata, 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $ourfilename)[-1 + sizeof(explode(".", $ourfilename))])) . ';base64,' . base64_encode($isc));
         }
         file_put_contents($fname, $isc);
         $thisone=@file_get_contents(str_replace(":443/","/",str_replace(":80/","/","http://" . $_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT'] . explode("?", explode("#", $_SERVER['REQUEST_URI'])[0])[0] . "?image=" . $fname)));
         // <h1 id='myh1'>Exif for mysterytrip/IMG_1125.JPG<font size=1 id=aside></font></h1><h3>RJM Programming - August, 2016  <a id='ageolocation style='visibility:visible;' href='#mygeolocation'>Geolocation Context for Photograph  on 2018:10:28 10:30:52 with (5.06000017956,2.27500704769) at (-33.9073638889,151.176422222) up at 13.9740066515</a></h3><h4>Thanks to <a target=_blank title=Useful href=http://www.v-nessa.net/2010/08/02/using-php-to-extract-image-exif-data>http://www.v-nessa.net/2010/08/02/using-php-to-extract-image-exif-data</a></h4>
         $rots=explode(" rotate(", $thisone);
         if (sizeof($rots) > 1) {
         if ($jj == 0) {
         $isdata[0]=" style=' -webkit-transform: rotate(" . explode(")", $rots[1])[0] . "); -moz-transform: rotate(" . explode(")", $rots[1])[0] . "); -ms-transform: rotate(" . explode(")", $rots[1])[0] . "); -o-transform: rotate(" . explode(")", $rots[1])[0] . "); transform: rotate(" . explode(")", $rots[1])[0] . "); ' ";
         $zd="";
         if (strpos($thisone,' up at ') !== false) {
           $zd=explode('<',explode(' up at ',$thisone)[1])[0];
         }
         $tablebits=str_replace(" SRC=", " data-z='" . $zd . "' " . $isdata[0] . " SRC=", $tablebits);
         } else {
         array_push($isdata, " style=' -webkit-transform: rotate(" . explode(")", $rots[1])[0] . "); -moz-transform: rotate(" . explode(")", $rots[1])[0] . "); -ms-transform: rotate(" . explode(")", $rots[1])[0] . "); -o-transform: rotate(" . explode(")", $rots[1])[0] . "); transform: rotate(" . explode(")", $rots[1])[0] . "); ' ");
         }
         } else {
         if ($jj > 0) {
         array_push($isdata, "");
         }
         }
         $atitle='';
         if (strpos($thisone, " on ") !== false) {
           $atitle=explode("<", explode(">", explode("'", explode('"', explode(" on ", $thisone)[1])[0])[0])[0])[0];
           $eachone.="\n<span style='display:none;' id=span" . $jj . ">" . $atitle . "</span>";
           $unearest=str_replace(":443/","/",str_replace(":80/","/","http://" . $_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT'] . str_replace("read_exif_off_image_rotate.php", "tz_places.php", explode("?", explode("#", $_SERVER['REQUEST_URI'])[0])[0])) . '?latitude=' . str_replace(',','&longitude=',explode(')',explode(' at (',$thisone)[1])[0])) . '&place=x';
           $retv=file_get_contents($unearest);
           $geod=explode(')',explode(') at (',$thisone)[1])[0];
           
           if (strpos($thisone,' up at ') !== false) {
           $zd=explode('<',explode(' up at ',$thisone)[1])[0];
           }
           if (strpos($retv,' in ') !== '' && strpos($retv,' is ') !== '') {
             $nc=explode(' is ',explode(' in ',$retv)[1])[0];
             $tn = explode(">", explode(' in ',$retv)[0])[-1 + sizeof(explode(">", explode(' in ',$retv)[0]))];
             $tz = new DateTimeZone($tn);
             if ($jj == 0 && sizeof(explode('/', $tn)) == 3) {
                 $psstate=explode('/', $tn)[1];
             }
             if ($jj == 0 && sizeof(explode('/', $tn)) > 1) {
                 $pstown=explode('/', $tn)[-1 + sizeof(explode('/', $tn))];
             }
             $loc = $tz->getLocation(); 
             $ncc=$loc['country_code'];
           }
         } else {
           $eachone.=str_replace("<div id='myh1'>", "", str_replace("<div style=' id","<div id", str_replace("</h", "\n</h", str_replace("</h3>", "</H3>", "<h1 id=hone" . $jj . " style='display:none;' title='" . $atitle . "'" . explode("<h1", str_replace("<h4", "<h4 style='display:none;'",explode("</h4>", $thisone)[0]) . "</h4>")[1]))));
         }
         unlink($fname);
         if ($jj == 0) {
           $geodata[0]=$geod;
           
  $gctmiddle.="0,+0_0"; //"HTTP.0&peninfo="; // HTTP.0%2Chttp.1%2Chttp.2%2Chttp.3%2Chttp.4%2Chttp.5&peninfo=Broome,+Hobart,Tennant Creek,+Cairns,Sydney,+Brisbane
  $gctmiddle=str_replace("&peninfo=", "%2Chttp.0_0&peninfo=", $gctmiddle);
  $gctsuffixlat.=" [" . explode(",",$geod)[0] . "|-179.99|~0~,2] , [" . explode(",",$geod)[0] . "|179.99|~0_0~,2]";  //           &data="; // [-17.961944444444|122.23611111111|~Broome~,7] , [-42.88334|147.31666|~Hobart~,7] , [-19.647222222222|134.19027777778|~Tennant Creek~,2] , [-16.930277777778|145.77027777778|~Cairns~,2] , [-33.86667|151.21666|~Sydney~,1] , [-27.46667|153.03333|~Brisbane~,1]
  $gctsuffixlong.=" [-55.9|" . explode(",",$geod)[1] . "|~0~,2] , [82.9|" . explode(",",$geod)[1] . "|~0_0~,2]";  //           &data="; // [-17.961944444444|122.23611111111|~Broome~,7] , [-42.88334|147.31666|~Hobart~,7] , [-19.647222222222|134.19027777778|~Tennant Creek~,2] , [-16.930277777778|145.77027777778|~Cairns~,2] , [-33.86667|151.21666|~Sydney~,1] , [-27.46667|153.03333|~Brisbane~,1]
           
           $gdata=",[" . $geod . ",~0~]";
           $zdata[0]=$zd;
           $countrydata[0]=$nc;
           $countrycodedata[0]=$ncc;
           $tablebits=str_replace("th id=xscountry onclick=", "th data-ctry='" . $nc . "' data-cc='" . $ncc . "' id=xscountry onclick=", $tablebits);
           $tablebits=str_replace("th id=scountry onclick=", "th data-ctry='" . $nc . "' data-cc='" . $ncc . "' id=scountry onclick=", $tablebits);
           $tablebits=str_replace("th id=xselevation onclick=", "th data-z='" . $zd . "' id=xselevation onclick=", $tablebits);
           $tablebits=str_replace("th id=selevation onclick=", "th data-z='" . $zd . "' id=selevation onclick=", $tablebits);
         } else {
           if ($geodata[-1 + sizeof($geodata)] != "" && $geod != "") {
           $wt=("" . great_circle_distance(explode(",",$geod)[0],explode(",",$geod)[1], explode(",",$geodata[-1 + sizeof($geodata)])[0], explode(",",$geodata[-1 + sizeof($geodata)])[1])) . " metres from previous";
           array_push($distdata, $wt);
           $tablebits=str_replace("><img title=' '", "><img data-z='" . $lastzd . "' title='" . $wt . "' onclick='alert(this.title);'", $tablebits);
           } else {
           array_push($distdata, "0.0 metres from previous");
           $tablebits=str_replace("><img title=' '", "><img data-z='" . $lastzd . "' title='" . "0.0 metres from previous" . "' onclick='alert(this.title);'", $tablebits);
           }
           array_push($geodata, $geod);

  //$gctmiddle.="," . $jj . ",+" . $jj . "_" . $jj; //"HTTP.0&peninfo="; // HTTP.0%2Chttp.1%2Chttp.2%2Chttp.3%2Chttp.4%2Chttp.5&peninfo=Broome,+Hobart,Tennant Creek,+Cairns,Sydney,+Brisbane
  //$gctmiddle=str_replace("&peninfo=", "%2Chttp." . $jj . "%2Chttp." . $jj . "_" . $jj . "&peninfo=", $gctmiddle);
  //$gctsuffixlat.=" , [" . explode(",",$geod)[0] . "|-179.99|~" . $jj . "~,2] , [" . explode(",",$geod)[0] . "|179.99|~" . $jj . "_" . $jj . "~,2]";  //           &data="; // [-17.961944444444|122.23611111111|~Broome~,7] , [-42.88334|147.31666|~Hobart~,7] , [-19.647222222222|134.19027777778|~Tennant Creek~,2] , [-16.930277777778|145.77027777778|~Cairns~,2] , [-33.86667|151.21666|~Sydney~,1] , [-27.46667|153.03333|~Brisbane~,1]
  //$gctsuffixlong.=" , [-55.9|" . explode(",",$geod)[1] . "|~" . $jj . "~,2] , [82.9|" . explode(",",$geod)[1] . "|~" . $jj . "_" . $jj . "~,2]";  //           &data="; // [-17.961944444444|122.23611111111|~Broome~,7] , [-42.88334|147.31666|~Hobart~,7] , [-19.647222222222|134.19027777778|~Tennant Creek~,2] , [-16.930277777778|145.77027777778|~Cairns~,2] , [-33.86667|151.21666|~Sydney~,1] , [-27.46667|153.03333|~Brisbane~,1]

           $gdata.=",[" . $geod . ",~" . $jj . "~]";
           array_push($zdata, $zd);
           array_push($countrydata, $nc);
           array_push($countrydata, $ncc);
         }
         $jj++;
         $lastzd=$zd;
       }
      }
  }

  $gctmiddle.="," . sizeof($distdata) . ",+" . sizeof($distdata) . "_" . sizeof($distdata); //"HTTP.0&peninfo="; // HTTP.0%2Chttp.1%2Chttp.2%2Chttp.3%2Chttp.4%2Chttp.5&peninfo=Broome,+Hobart,Tennant Creek,+Cairns,Sydney,+Brisbane
  $gctmiddle=str_replace("&peninfo=", "%2Chttp." . sizeof($distdata) . "%2Chttp." . sizeof($distdata) . "_" . sizeof($distdata) . "&peninfo=", $gctmiddle);
  $gctsuffixlat.=" , [" . explode(",",$geod)[0] . "|-179.99|~" . sizeof($distdata) . "~,2] , [" . explode(",",$geod)[0] . "|179.99|~" . sizeof($distdata) . "_" . sizeof($distdata) . "~,2]";  //           &data="; // [-17.961944444444|122.23611111111|~Broome~,7] , [-42.88334|147.31666|~Hobart~,7] , [-19.647222222222|134.19027777778|~Tennant Creek~,2] , [-16.930277777778|145.77027777778|~Cairns~,2] , [-33.86667|151.21666|~Sydney~,1] , [-27.46667|153.03333|~Brisbane~,1]
  $gctsuffixlong.=" , [-55.9|" . explode(",",$geod)[1] . "|~" . sizeof($distdata) . "~,2] , [82.9|" . explode(",",$geod)[1] . "|~" . sizeof($distdata) . "_" . sizeof($distdata) . "~,2]";  //           &data="; // [-17.961944444444|122.23611111111|~Broome~,7] , [-42.88334|147.31666|~Hobart~,7] , [-19.647222222222|134.19027777778|~Tennant Creek~,2] , [-16.930277777778|145.77027777778|~Cairns~,2] , [-33.86667|151.21666|~Sydney~,1] , [-27.46667|153.03333|~Brisbane~,1]

  if ($distdata[-1 + sizeof($distdata)] != "") {
             if (sizeof(explode('/', $tn)) == 3) {
                 $pfstate=explode('/', $tn)[1];
             }
             if (sizeof(explode('/', $tn)) > 1) {
                 $pftown=explode('/', $tn)[-1 + sizeof(explode('/', $tn))];
             }
  $tablebits=str_replace(" src=''", " data-z='" . $zd . "' title='" . $distdata[-1 + sizeof($distdata)] . "' onclick='alert(this.title);' " . $isdata[-1 + sizeof($isdata)] . " src='" . $idata[-1 + sizeof($idata)] . "'", $tablebits);
  } else {
             if (sizeof(explode('/', $tn)) == 3) {
                 $pfstate=explode('/', $tn)[1];
             }
             if (sizeof(explode('/', $tn)) > 1) {
                 $pftown=explode('/', $tn)[-1 + sizeof(explode('/', $tn))];
             }
  $tablebits=str_replace(" src=''", " data-z='" . $zd . "' " . $isdata[-1 + sizeof($isdata)] . " src='" . $idata[-1 + sizeof($idata)] . "'", $tablebits);
  }
  if ($nc != "") {
           $tablebits=str_replace("th id=xfcountry onclick=", "th data-ctry='" . $nc . "' data-cc='" . $ncc . "' id=xfcountry onclick=", $tablebits);
           $tablebits=str_replace("th id=fcountry onclick=", "th data-ctry='" . $nc . "' data-cc='" . $ncc . "' id=fcountry onclick=", $tablebits);
           $tablebits=str_replace("th id=xfelevation onclick=", "th data-z='" . $zd . "' id=xfelevation onclick=", $tablebits);
           $tablebits=str_replace("th id=felevation onclick=", "th data-z='" . $zd . "' id=felevation onclick=", $tablebits);
  }
  zip_close($zip);
  unlink($zipfile);
  }
  echo "<html>
  <head>
  <title>Image Trip Start Finish Guessing Game - RJM Programming - October, 2018</title>
  <script type='text/javascript'>
  var score=0;
  var goes=0;
  var sarr=['','','','','','',''];
  var farr=['','','','','','',''];
  var gcturls=[\"" . $gctprefix . $gctmiddle . $gctmiddle . $gctsuffixlat . "\",\"" . $gctprefix . $gctmiddle . $gctmiddle . $gctsuffixlong . "\"];  
  var sa1=\"" . str_replace("+"," ",$_GET['sa1']) . str_replace("+"," ",$_POST['sa1']) . "\";
  var sa2=\"" . str_replace("+"," ",$_GET['sa2']) . str_replace("+"," ",$_POST['sa2']) . "\";
  var stown=\"" . str_replace("+"," ",$_GET['stown']) . str_replace("+"," ",$_POST['stown']) . "\";
  var sstate=\"" . str_replace("+"," ",$_GET['sstate']) . str_replace("+"," ",$_POST['sstate']) . "\";
  var scountry=\"" . str_replace("+"," ",$_GET['scountry']) . str_replace("+"," ",$_POST['scountry']) . "\";
  var splanet=\"" . str_replace("+"," ",$_GET['splanet']) . str_replace("+"," ",$_POST['splanet']) . "\";
  var selevation=\"" . str_replace("+"," ",$_GET['selevation']) . str_replace("+"," ",$_POST['selevation']) . "\";
  var fa1=\"" . str_replace("+"," ",$_GET['fa1']) . str_replace("+"," ",$_POST['fa1']) . "\";
  var fa2=\"" . str_replace("+"," ",$_GET['fa2']) . str_replace("+"," ",$_POST['fa2']) . "\";
  var ftown=\"" . str_replace("+"," ",$_GET['ftown']) . str_replace("+"," ",$_POST['ftown']) . "\";
  var fstate=\"" . str_replace("+"," ",$_GET['fstate']) . str_replace("+"," ",$_POST['fstate']) . "\";
  var fcountry=\"" . str_replace("+"," ",$_GET['fcountry']) . str_replace("+"," ",$_POST['fcountry']) . "\";
  var fplanet=\"" . str_replace("+"," ",$_GET['fplanet']) . str_replace("+"," ",$_POST['fplanet']) . "\";
  var felevation=\"" . str_replace("+"," ",$_GET['felevation']) . str_replace("+"," ",$_POST['felevation']) . "\";


function prefetch(whatgifmaybe) { // thanks to https://stackoverflow.com/questions/69564118/how-to-get-duration-of-gif-image-in-javascript#:~:text=Mainly%20use%20parseGIF()%20%2C%20then,duration%20of%20a%20GIF%20image.
if ((whatgifmaybe.toLowerCase().trim().split('#')[0] + '?').indexOf('.gif?') != -1) {
document.body.style.cursor='progress';
fetch(whatgifmaybe)
  .then(res => res.arrayBuffer())
  .then(ab => isGifAnimated(new Uint8Array(ab)))
  .then(console.log);
}
}

/** @param {Uint8Array} uint8 */
function isGifAnimated (uint8) { // thanks to https://stackoverflow.com/questions/69564118/how-to-get-duration-of-gif-image-in-javascript#:~:text=Mainly%20use%20parseGIF()%20%2C%20then,duration%20of%20a%20GIF%20image.
  let duration = 0;
  for (let i = 0, len = uint8.length; i < len; i++) {
    if (uint8[i] == 0x21
      && uint8[i + 1] == 0xF9
      && uint8[i + 2] == 0x04
      && uint8[i + 7] == 0x00) 
    {
      const delay = (uint8[i + 5] << 8) | (uint8[i + 4] & 0xFF);
      duration += delay < 2 ? 10 : delay;
    }
  }
  //alert('' + eval(duration / 100));
  if (eval(duration / 100) > 0.11) {
    if (document.getElementById('aside')) {
     document.getElementById('aside').innerHTML='  (<?php echo $image; ?> animated GIF duration is ' + eval(duration / 100) + ' seconds)';
    }
  }
  document.body.style.cursor='pointer';
  return duration / 100; // if 0.1 is not an animated GIF
}


  function givehint() {
    var choic=Math.floor(Math.random() * 2);
    if (choic == 1) {
     window.open(gcturls[0],'_blank','top=50,left=50,width=1050,height=1050');
    } else {
     window.open(gcturls[1],'_blank','top=50,left=50,width=1050,height=1050');
    }
  }
  function finalfillin() {
    document.getElementById('sd').value=sa1 + String.fromCharCode(10) + sa2 + String.fromCharCode(10) + stown + String.fromCharCode(10) + sstate + String.fromCharCode(10) + scountry + String.fromCharCode(10) + splanet + String.fromCharCode(10) + selevation + String.fromCharCode(10);
    document.getElementById('fd').value=fa1 + String.fromCharCode(10) + fa2 + String.fromCharCode(10) + ftown + String.fromCharCode(10) + fstate + String.fromCharCode(10) + fcountry + String.fromCharCode(10) + fplanet + String.fromCharCode(10) + felevation + String.fromCharCode(10);
  }
  function fillinta(taid,hoid,vvv,hov) {
    var jsf=0, sf='a1,a2,town,state,country,planet,elevation';
    var sfs=sf.split(',');
    for (var isf=0; isf<sfs.length; isf++) {
      if (hoid.indexOf(sfs[isf]) != -1) {
        if (taid.indexOf('s') == 0) {
          sarr[isf]=vvv;
          if (vvv == hov) {
            document.getElementById(taid).value='';
            for (jsf=0; jsf<sarr.length; jsf++) {
              document.getElementById(taid).value+=sarr[jsf] + String.fromCharCode(10);
            }
          } else {
            sarr[isf]+=' [' + hov + ']';
            document.getElementById(taid).value='';
            for (jsf=0; jsf<sarr.length; jsf++) {
              document.getElementById(taid).value+=sarr[jsf] + String.fromCharCode(10);
            }
          }
        } else if (taid.indexOf('f') == 0) {
          farr[isf]=vvv;
          if (vvv == hov) {
            document.getElementById(taid).value='';
            for (jsf=0; jsf<sarr.length; jsf++) {
              document.getElementById(taid).value+=farr[jsf] + String.fromCharCode(10);
            }
          } else {
            farr[isf]+=' [' + hov + ']';
            document.getElementById(taid).value='';
            for (jsf=0; jsf<sarr.length; jsf++) {
              document.getElementById(taid).value+=farr[jsf] + String.fromCharCode(10);
            }
          }
        }
      }
    }
  }
  function giveanswer() {
   finalfillin();
   window.open(\"//www.rjmprogramming.com.au/PHP/Map/map.php?title=Mystery%20Places&onclick=y&label=['Lat',&value='Lon','Name']&data=" . $gdata . "\",'_blank','top=50,left=20,width=420,height=400');
   window.open('//www.google.com/maps/dir/" . $geodata[0] . "/" . $geodata[-1 + sizeof($geodata)] . "/@" . $geodata[floor(sizeof($geodata) / 2)] . ",17z','_blank','top=500,left=50,width=900,height=500');
  }
  function ons(fo) {
    var inps=fo.innerHTML.split(' id=\"');
    for (var jnps=1; jnps<inps.length; jnps++) {
      if (document.getElementById(inps[jnps].split('\"')[0]).value == '') {
        if (('' + document.getElementById(inps[jnps].split('\"')[0]).placeholder).indexOf(' [') != -1) {
          document.getElementById(inps[jnps].split('\"')[0]).value=('' + document.getElementById(inps[jnps].split('\"')[0]).placeholder).split(' [')[1].split(']')[0];
        }
      }
    }
  }
  function scoreit(letthrough,ho) {
    var versus='';
    eval('versus=' + ho.id.replace('x',''));
    if (ho.id.indexOf('lanet') != -1) {
      document.getElementById('form' + ho.id.replace('x','')).value=ho.value;
      goes++;
      if (versus.toLowerCase() == ho.value.toLowerCase()) {
           score++;
           if (ho.id.indexOf('x') != -1) {
           document.getElementById(ho.id.replace('x','')).value=ho.value;
           } else {
           document.getElementById('x' + ho.id).value=ho.value;
           }
      if (ho.id.indexOf('xs') == 0 || ho.id.indexOf('s') == 0) {
        fillinta('sd',ho.id,ho.value,ho.value);
      } else if (ho.id.indexOf('xf') == 0 || ho.id.indexOf('f') == 0) {
        fillinta('fd',ho.id,ho.value,ho.value);
      }
      }
      document.getElementById('score').innerHTML='Score: ' + score + '/' + goes;
    } else {
      var vv='', def='';
      if (ho.id.indexOf('image') == -1) {
        if (ho.id.indexOf('country') != -1 && versus == '') {
          if (ho.getAttribute('data-ctry') != '') {
            //alert(ho.id.replace('x','') + '=\"' + ho.getAttribute('data-ctry') + '\"');
            eval(ho.id.replace('x','') + '=\"' + ho.getAttribute('data-ctry') + '\"');
            eval('versus=' + ho.id.replace('x',''));
            document.getElementById('form' + ho.id.replace('x','')).value=versus;
            def=versus;
          }
        } else if (ho.id.indexOf('elevation') != -1 && versus == '') {
          if (ho.getAttribute('data-z') != '') {
            //alert(ho.id.replace('x','') + '=\"' + ho.getAttribute('data-z') + '\"');
            eval(ho.id.replace('x','') + '=\"' + ho.getAttribute('data-z') + '\"');
            eval('versus=' + ho.id.replace('x',''));
            document.getElementById('form' + ho.id.replace('x','')).value=versus;
            def=versus;
          }
        }
        ";
      if (isset($_GET['mystery']) || isset($_POST['mystery'])) {
    echo "\n def=''; \n";
      }
    echo "  
      if (letthrough != 0) {
      vv=def;
      } else {
      vv=prompt('Enter value', def);
      }
      if (vv != null) {
        goes++;
        if (ho.id.indexOf('country') != -1 && versus == '' && vv != '') {
          if (ho.getAttribute('data-ctry') != '') {
            //alert(ho.id.replace('x','') + '=\"' + ho.getAttribute('data-ctry') + '\"');
            eval(ho.id.replace('x','') + '=\"' + ho.getAttribute('data-ctry') + '\"');
            eval('versus=' + ho.id.replace('x',''));
            document.getElementById('form' + ho.id.replace('x','')).value=versus;
          }
        } 
        if (versus.toLowerCase() == vv.toLowerCase()) {
         score++;
         if (document.getElementById('topdiv')) {
           if (ho.id.indexOf('x') != -1) {
           document.getElementById(ho.id.replace('x','')).innerHTML=vv;
           ho.innerHTML=vv;
           } else {
           document.getElementById('x' + ho.id).innerHTML=vv;
           ho.innerHTML=vv;
           }
         }
        } else if (versus == '' && document.getElementById('topdiv')) {
        if (ho.id.indexOf('xs') == 0 || ho.id.indexOf('s') == 0) {
        fillinta('sd',ho.id,vv,versus);
        } else if (ho.id.indexOf('xf') == 0 || ho.id.indexOf('f') == 0) {
        fillinta('fd',ho.id,vv,versus);
        }
           if (ho.id.indexOf('x') != -1) {
           document.getElementById(ho.id.replace('x','')).innerHTML=vv;
           ho.innerHTML=vv;
           } else {
           document.getElementById('x' + ho.id).innerHTML=vv;
           ho.innerHTML=vv;
           }
        }
        var vvs=vv.toLowerCase().split(' ');
        var sofar=' ';
        for (var ivvs=0; ivvs<vvs.length; ivvs++) {
          if (sofar.indexOf(' ' + vvs[ivvs] + ' ') == -1) {
            sofar=vvs[ivvs] + ' ';
            if ((' ' + versus.toLowerCase() + ' ').indexOf(' ' + vvs[ivvs] + ' ') != -1) {
              score++;
        if (ho.id.indexOf('xs') == 0 || ho.id.indexOf('s') == 0) {
        fillinta('sd',ho.id,vv,versus);
        } else if (ho.id.indexOf('xf') == 0 || ho.id.indexOf('f') == 0) {
        fillinta('fd',ho.id,vv,versus);
        }
            }
          }
        }
        document.getElementById('score').innerHTML='Score: ' + score + '/' + goes;
      }
      }
      if (vv != null || ho.id.indexOf('image') != -1) {
      if (ho.id.indexOf('image') == -1) {
      document.getElementById('form' + ho.id.replace('x','')).value=vv;
      }
      ";
      if (isset($_GET['mystery']) || isset($_POST['mystery'])) {
    echo "
        if (document.getElementById('ximage').value != '') {
        document.getElementById('formsa1').style.display='inline-block';
        document.getElementById('formsa2').style.display='inline-block';
        document.getElementById('formstown').style.display='inline-block';
        document.getElementById('formsstate').style.display='inline-block';
        document.getElementById('formscountry').style.display='inline-block';
        document.getElementById('formsplanet').style.display='inline-block';
        document.getElementById('formselevation').style.display='inline-block';
        document.getElementById('formfa1').style.display='inline-block';
        document.getElementById('formfa2').style.display='inline-block';
        document.getElementById('formftown').style.display='inline-block';
        document.getElementById('formfstate').style.display='inline-block';
        document.getElementById('formfcountry').style.display='inline-block';
        document.getElementById('formfplanet').style.display='inline-block';
        document.getElementById('formfelevation').style.display='inline-block';
        document.getElementById('myzsubmit').style.display='block';
        }
        ";
      }
    echo "
      }
    }
  }
  </script>
  <style>
   th { border: 2px solid pink; }
   td { padding-top:50px; padding-bottom:50px; border: 2px solid pink; }
  </style>
  </head>
  <body style='background-color:#f0f0f0;'>" . $eachone . $tablebits . "";
      if (!isset($_GET['mystery']) && !isset($_POST['mystery'])) {
        echo "\n <script type='text/javascript'> document.getElementById('sd').style.visibility='hidden';  document.getElementById('fd').style.visibility='hidden';  scoreit(1,document.getElementById('scountry')); scoreit(1,document.getElementById('selevation')); scoreit(1,document.getElementById('fcountry')); scoreit(1,document.getElementById('felevation'));
        if (document.getElementById('formscountry').value != '' && document.getElementById('formsplanet').value == '') {
          document.getElementById('formsplanet').value='Earth';
        }
        if (document.getElementById('formfcountry').value != '' && document.getElementById('formfplanet').value == '') {
          document.getElementById('formfplanet').value='Earth';
        }
        if ('" . $pstown . "' != '') {
        document.getElementById('formstown').placeholder+=' [" . $pstown . "]';
        }
        if ('" . $psstate . "' != '') {
        document.getElementById('formsstate').placeholder+=' [" . $psstate . "]';
        }
        if ('" . $pftown . "' != '') {
        document.getElementById('formftown').placeholder+=' [" . $pftown . "]';
        }
        if ('" . $pfstate . "' != '') {
        document.getElementById('formfstate').placeholder+=' [" . $pfstate . "]';
        }
        if (document.getElementById('ximage').value.toLowerCase().indexOf('.zip') != -1) { var huht=confirm('Would it be okay to show the address fields now, away from the gaze of a second player?'); if (huht) {         
        document.getElementById('formsa1').style.display='inline-block';
        document.getElementById('formsa2').style.display='inline-block';
        document.getElementById('formstown').style.display='inline-block';
        document.getElementById('formsstate').style.display='inline-block';
        document.getElementById('formscountry').style.display='inline-block';
        document.getElementById('formsplanet').style.display='inline-block';
        document.getElementById('formselevation').style.display='inline-block';
        document.getElementById('formfa1').style.display='inline-block';
        document.getElementById('formfa2').style.display='inline-block';
        document.getElementById('formftown').style.display='inline-block';
        document.getElementById('formfstate').style.display='inline-block';
        document.getElementById('formfcountry').style.display='inline-block';
        document.getElementById('formfplanet').style.display='inline-block';
        document.getElementById('formfelevation').style.display='inline-block';
        document.getElementById('myzsubmit').style.display='block';
   }    }  document.getElementById('sd').style.visibility='visible';  document.getElementById('fd').style.visibility='visible';   </script> \n";
      }
    echo "</body></html>";
  exit;
}


$lasts="";
if (isset($_GET['animg'])) {
  $ximage = urldecode($_GET['animg']);
  $exifbit = "Metadata";
  if (!isset($_GET['return'])) $lasts = " setTimeout(preob, 1000); ";
}


$javascript="<scr" . "ipt type='text/javascript'> 

  var image=encodeURIComponent('" . $image . $ximage . "'); 
  var straightaway='';

  function preob() {
     ob(image);
  }

function prefetch(whatgifmaybe) { // thanks to https://stackoverflow.com/questions/69564118/how-to-get-duration-of-gif-image-in-javascript#:~:text=Mainly%20use%20parseGIF()%20%2C%20then,duration%20of%20a%20GIF%20image.
if ((whatgifmaybe.toLowerCase().trim().split('#')[0] + '?').indexOf('.gif?') != -1) {
document.body.style.cursor='progress';
fetch(whatgifmaybe)
  .then(res => res.arrayBuffer())
  .then(ab => isGifAnimated(new Uint8Array(ab)))
  .then(console.log);
}
}

/** @param {Uint8Array} uint8 */
function isGifAnimated (uint8) { // thanks to https://stackoverflow.com/questions/69564118/how-to-get-duration-of-gif-image-in-javascript#:~:text=Mainly%20use%20parseGIF()%20%2C%20then,duration%20of%20a%20GIF%20image.
  let duration = 0;
  for (let i = 0, len = uint8.length; i < len; i++) {
    if (uint8[i] == 0x21
      && uint8[i + 1] == 0xF9
      && uint8[i + 2] == 0x04
      && uint8[i + 7] == 0x00) 
    {
      const delay = (uint8[i + 5] << 8) | (uint8[i + 4] & 0xFF);
      duration += delay < 2 ? 10 : delay;
    }
  }
  //alert('' + eval(duration / 100));
  if (eval(duration / 100) > 0.11) {
    if (document.getElementById('aside')) {
     document.getElementById('aside').innerHTML='  (<?php echo $image; ?> animated GIF duration is ' + eval(duration / 100) + ' seconds)';
    }
  }
  document.body.style.cursor='pointer';
  return duration / 100; // if 0.1 is not an animated GIF
}

  function ob(tv) {
    prefetch(tv);
    if ((tv + '~').toLowerCase().indexOf('.png~') != -1) {
      straightaway='';
      image=encodeURIComponent(tv);
      document.getElementById('myform').target='itwo';
      document.getElementById('isub').value=document.getElementById('isub').value.replace('Exif ','Metadata ');
      setTimeout(anth, 65000);
    } else if ((tv + '~').toLowerCase().indexOf('.jpeg~') != -1 || (tv + '~').toLowerCase().indexOf('.jpg~') != -1) {
      if ((tv + '~').toLowerCase().indexOf('rjmprogramming.com.au') != -1 || (tv + '~').toLowerCase().indexOf('http') == -1) {
      straightaway=document.URL.split('#')[0].split('?')[0] + '?image=' + encodeURIComponent(tv);
      } else {
      straightaway='';
      }
    }
  }

  function anth() {
    var dis=new Date();
    top.document.location.href='//www.rjmprogramming.com.au/PHP/read_exif_off_image_rotate.php?return=' + dis.toGMTString() + '&animg=' + image;
  }

  function doalert() {
    alert('Please click OK in more than 60 seconds to receive report.');
    setTimeout(anth, 6000);
  }
  

  function doone() {
    " . $doaside . "
    var xdis=new Date();
    parent.document.getElementById('ione').src='//www.rjmprogramming.com.au/PHP/read_exif_off_image_rotate.php?return=' + xdis.toGMTString() + '&animg=' + image;
    parent.document.getElementById('ione').style.display='block';
  } 

 " . $lasts . " 
</sc" . "ript> ";

if (isset($_GET['donothing'])) {
 echo "<html></html>";
} else {
$anotheroption="";
if (isset($_GET['viaparent'])) { $anotheroption="<option value='  '>Non Exif</option>"; }
$nform="<br>" . $aside . "<br><iframe id='ione' src='//www.rjmprogramming.com.au/PHP/read_exif_off_image_rotate.php?donothing=y' style='display:none;'></iframe><iframe id='itwo' src='//www.rjmprogramming.com.au/PHP/read_exif_off_image_rotate.php?donothing=y' style='display:none;'></iframe><form target='_self' id='myform' action='./read_exif_off_image_rotate.php' method='POST'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Image <select style='display:inline-block;' onchange=\"if (this.value.length == 2) { top.alinktop=''; top.document.getElementById('dexif').innerHTML=''; top.location.href=top.document.URL.split('index.')[0]+'index-ssmhalf.html';  } else { var zipurl=prompt('Enter image zipfile URL for Mystery Trip game (good for 2 players)','mysterytrip.zip'); if (zipurl != null) { if (zipurl.toLowerCase().indexOf('.zip') != -1) { location.href=document.URL.split('#')[0].split('?')[0] + '?image=' + encodeURIComponent(zipurl);  } } } \"><option value=''>URL</option><option value=' '>zipfile</option>" . $anotheroption . "</select>: <input name='image' id='image' onblur=' ob(this.value); ' type='text' value='" . $ximage . "' style='width:40%;display:inline-block;'></input>&nbsp;&nbsp;<input style='display:inline-block;' id='isub' onclick=' if (straightaway.length != 0) { location.href=straightaway;  } else { setTimeout(doalert,1000); } ' type='submit' value='" . $exifbit . " Information'></input></form>";
$rotbit="";

$htmlis="";
$indiv="";

$maptemplate="//www.rjmprogramming.com.au/PHP/Map/map.php?title=&onclick=y&label=[%27Lat%27,&value=%27Lon%27,%20%27Name%27]&data=,%20[-33.967,151.2422,~~]";
$factor=1.0;
$sbit="";
$various=" ";
$wasvarious="youl" . "lneverfin" . "dthis";

if (isset($_GET['image'])) {
  $image = urldecode($_GET['image']);
} else if (isset($_POST['image'])) {
  $image = urldecode($_POST['image']);
} else if (file_exists("/Applications/MAMP/htdocs/clouds.jpg")) {
  $image = "/Applications/MAMP/htdocs/clouds.jpg";
} else {
  $image="";
  if (file_exists("/tmp/pnginfo.txt") && isset($_GET['return'])) {
       $stuff=@file_get_contents("/tmp/pnginfo.txt");
       echo "<html><head>" . $javascript . "</head><body style=\" opacity:0.6; background: url('" . $image . $ximage . "'); \"><div style='opacity:0.8;'>" . str_replace("\n", "<br>", $stuff)  . "</div>" . $nform . "</body></html>";
       try {
       unlink("/tmp/pnginfo.txt");
       } catch (Exception $ex) { }
  } else {
       echo "<html><head>" . $javascript . "</head><body>" . $nform . "</body></html>";
  }
  exit;
}

$types = array(
1 => "GIF",
2 => "JPEG",
3 => "PNG",
4 => "SWF",
5 => "PSD",
6 => "BMP",
7 => "TIFF",
8 => "TIFF"
);


$imagetype = exif_imagetype($image);

if ($types[$imagetype] == "PNG") {
    if (file_exists("/tmp/pnginfo.txt")) {
      unlink("/tmp/pnginfo.txt");
    }
    exec('echo "/home/virtfs/rjmprogr/usr/local/cpanel/3rdparty/bin/identify -verbose ' . $image . ' > /tmp/pnginfo.tt ; chgrp rjmprogr /tmp/pnginfo.tt ; chown rjmprogr /tmp/pnginfo.tt; mv /tmp/pnginfo.tt /tmp/pnginfo.txt" > /tmp/pnginfo.ksh');
    if (file_exists("/tmp/pnginfo.ksh")) {
    $bcnt=0;
    while (!file_exists("/tmp/pnginfo.txt") || $bcnt < 20) {
      if (file_exists("/tmp/pnginfo.txt")) {
        sleep(5);
        $stuff="";
        $stuff=@file_get_contents("/tmp/pnginfo.txt");

        if (trim($stuff) != "") {
        //unlink("/tmp/pnginfo.txt");
        //header("Location: http://www.rjmprogramming.com.au/PHP/read_exif_off_image_rotate.php?return=y");
        echo "<html><head>" . $javascript . "</head><body onload=' doone(); '><div>" . str_replace("\n", "<br>", $stuff)  . "</div></body></html>";
        try {
        unlink("/tmp/pnginfo.txt");
        } catch (Exception $ex2) { }

        } else {
        echo "<html><head>" . $javascript . "</head><body onload=' doone(); location.href=\"//www.rjmprogramming.com.au/PHP/read_exif_off_image_rotate.php?return=y\"; '><div></div></body></html>";
        }
        $bcnt=21;
        exit;
      } else {
        sleep(6);
      }
      $bcnt++;
    }
    } else {         

        // Imagick Type  // thanks to http://php.net/manual/en/imagick.getimageproperties.php
        // ---------------------------------------------

    $imagick_type = new Imagick($image);
   
        // Open File
        // ---------------------------------------------
       
    $file_to_grab = $image;
   
    $file_handle_for_viewing_image_file = fopen($file_to_grab, 'a+');
   
        // Grab File
        // ---------------------------------------------

    $imagick_type->readImageFile($file_handle_for_viewing_image_file);
   
        // Get Image Properties
        // ---------------------------------------------
       
    $imagick_type_properties = $imagick_type->getImageProperties('*', FALSE);
   
        // Print Image Properties
        // ---------------------------------------------
   
    print("<pre>");
       
    print_r($imagick_type_properties);
   
        // Print Each Individual, Image Property
        // ---------------------------------------------
   
    foreach($imagick_type_properties as $value)
    {
        print("$value --- ");
        print($imagick_type->getImageProperty("$value"));
        print("<br><br>");
    }
               
    print("</pre>");
    }
} else {

if (array_key_exists($imagetype, $types)) {
 $anotheroption="";
 if (isset($_GET['viaparent'])) { $anotheroption="<option value='  '>Non Exif</option>"; }
 $htmlis="<html><head>" . $javascript . "<style> div { font-size:9px; overflow: visible; float:right; " . $csswh . " } </style><meta name='viewport' content='width=device-width, initial-scale=1, minimum-scale=0.25, maximum-scale=8, user-scalable=yes'><title>Exif for " . $image . "</title></head><body style='background-color:pink;'><h1 id='myh1'>Exif <select onchange=\"if (this.value.length == 2) { top.alinktop=''; top.document.getElementById('dexif').innerHTML=''; top.location.href=top.document.URL.split('index.')[0]+'index-ssmhalf.html';  } else { var zipurl=prompt('Enter image zipfile URL for Mystery Trip game (good for 2 players)','mysterytrip.zip'); if (zipurl != null) { if (zipurl.toLowerCase().indexOf('.zip') != -1) { location.href=document.URL.split('#')[0].split('?')[0] + '?image=' + encodeURIComponent(zipurl);  } } } \"><option value=''>for</option><option value=' '>zipfile</option>" . $anotheroption . "</select> " . $image . $aside . "</h1><h3>RJM Programming - August, 2016  <a id='ageolocation style='visibility:hidden;' href='#mygeolocation'>Geolocation Context for Photograph" . $various . "</a></h3><h4>Thanks to <a target=_blank title=Useful href=//www.v-nessa.net/2010/08/02/using-php-to-extract-image-exif-data>http://www.v-nessa.net/2010/08/02/using-php-to-extract-image-exif-data</a></h4><div onclick=\"window.open('" . str_replace("/Applications/MAMP/htdocs/","http://localhost:8888/",$image) . "','_blank','top=5,left=5');\" style='background-color:yellow; background: url(" . str_replace("/Applications/MAMP/htdocs/","http://localhost:8888/",$image) . ") no-repeat; background-position: 5px; background-size: contain;  '><br>" . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Image type of " . $image . " is: " . $types[$imagetype];
 $exif = exif_read_data($image, 0, true);
 foreach ($exif as $key => $section) {
  foreach ($section as $name => $val) {
   if (sizeof($val) > 1) {
   $indiv.="<br>" . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$key.$name: " . $val[0];
   $nthing=0.0;
   $vs=explode("/",$val[0]);
   if (sizeof($vs) == 1) {
     $vs1=1.0;
   } else {
     $vs1=$vs[1];
   }
   if ($key == "GPS" && $name == "GPSAltitude") {
   $vs=explode("/",$val[0]);
   if (sizeof($vs) == 1) {
     $vs1=1.0;
   } else {
     $vs1=$vs[1];
   }
     $various.=" up at " . ($vs[0] / $vs1) / ($factor);
     $htmlis=str_replace($wasvarious, $wasvarious . " up at " . ($vs[0] / $vs1) / ($factor), $htmlis);
   }

   if ($key == "EXIF" && $name == "ShutterSpeedValue") {
   $vs=explode("/",$val[0]);
   if (sizeof($vs) == 1) {
     $vs1=1.0;
   } else {
     $vs1=$vs[1];
   }
     $various.=" with (" . ($vs[0] / $vs1) . ",";
   }

   if ($key == "EXIF" && $name == "ApertureValue") {
   $vs=explode("/",$val[0]);
   if (sizeof($vs) == 1) {
     $vs1=1.0;
   } else {
     $vs1=$vs[1];
   }
     $various.=($vs[0] / $vs1) . ")";
   }


   if ($key == "GPS" && $name == "GPSLatitude") {
     $nthing+=($vs[0] / $vs1) / ($factor);
     $factor*=60; 
   } else if ($key == "GPS" && $name == "GPSLongitude") {
     $nthing+=($vs[0] / $vs1) / ($factor);
     $factor*=60; 
   }
   for ($jj=1; $jj<sizeof($val); $jj++) {
   if ($key == "GPS" && $name == "GPSLatitude") {
   $vs=explode("/",$val[$jj]);
   if (sizeof($vs) == 1) {
     $vs1=1.0;
   } else {
     $vs1=$vs[1];
   }
     $nthing+=($vs[0] / $vs1) / ($factor);
     $factor*=60; 
   } else if ($key == "GPS" && $name == "GPSLongitude") {
   $vs=explode("/",$val[$jj]);
   if (sizeof($vs) == 1) {
     $vs1=1.0;
   } else {
     $vs1=$vs[1];
   }
     $nthing+=($vs[0] / $vs1) / ($factor);
     $factor*=60; 
   }
    $indiv.=',' . $val[$jj];
   }
   if ($key == "GPS" && $name == "GPSLatitude") {
     $maptemplate=str_replace("-33.967", $nthing, $maptemplate);
     $various.=" at (" . $nthing . ",";
   } else if ($key == "GPS" && $name == "GPSLongitude") {
     $maptemplate=str_replace("151.2422", $nthing, $maptemplate);
     $various.=$nthing . ")";
     //$maptemplate=str_replace("&onclick=y", urlencode($various) . "&onclick=y", $maptemplate);
     //$sbit=" <scri" . "pt type='text/javascript'> window.open(\"" . $maptemplate . "\",\"_blank\",\"top=50,left=50,height=500,width=500\"); </sc" . "ript> ";
     $sbit=" <iframe onload=\" location.href='#myh1'; \" id=\"mygeolocation\" title=\"Geolocation context\" src=\"" . $maptemplate . "\"></iframe>";
     $wasvarious="Geolocation Context for Photograph" . $various;
     $htmlis=str_replace("Geolocation Context for Photograph ", "Geolocation Context for Photograph" . $various, str_replace("visibility:hidden", "visibility:visible", $htmlis));
   }
   } else {
   if ($key == "FILE" && $name == "FileName") {
     $maptemplate=str_replace("~~", "~" . urlencode($val) . "~", $maptemplate);
     $maptemplate=str_replace("title=&", "title=" . urlencode($val) . urlencode($various) . "&", $maptemplate);

   } else if ($key == "EXIF" && $name == "ShutterSpeedValue") {
   $vs=explode("/",$val);
   if (sizeof($vs) == 1) {
     $vs1=1.0;
   } else {
     $vs1=$vs[1];
   }
     $various.=" with (" . ($vs[0] / $vs1) . ",";
   

   } else if ($key == "EXIF" && $name == "ApertureValue") {
   $vs=explode("/",$val);
   if (sizeof($vs) == 1) {
     $vs1=1.0;
   } else {
     $vs1=$vs[1];
   }
     $various.=($vs[0] / $vs1) . ")";
   
   } else if ($key == "EXIF" && $name == "DateTimeOriginal") {
     $various.=" on " . $val;
   } else if ($key == "GPS" && $name == "GPSAltitude") {
   $vs=explode("/",$val);
   if (sizeof($vs) == 1) {
     $vs1=1.0;
   } else {
     $vs1=$vs[1];
   }
     $various.=" up at " . ($vs[0] / $vs1) / ($factor);
     $htmlis=str_replace($wasvarious, $wasvarious . " up at " . ($vs[0] / $vs1) / ($factor), $htmlis);
   } else if ($key == "GPS" && $name == "GPSAltitudeRef" && trim($val) != "") {
     $factor=-1.0; 
   } else if ($key == "GPS" && $name == "GPSAltitudeRef" && trim($val) == "") {
     $factor=1.0; 
   } else if ($key == "GPS" && $name == "GPSLatitudeRef" && $val == "S") {
     $factor=-1.0; 
   } else if ($key == "GPS" && $name == "GPSLongitudeRef" && $val == "W") {
     $factor=-1.0; 
   } else if ($key == "GPS" && $name == "GPSLatitudeRef" && $val == "N") {
     $factor=1.0; 
   } else if ($key == "GPS" && $name == "GPSLongitudeRef" && $val == "E") {
     $factor=1.0; 
   }
   $indiv.="<br>" . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$key.$name: $val";
   }
   if (($key.$name) == "IFD0Orientation") {
     if (str_replace(" ","","$val") == "8") {
       //$htmlis="<!doctype html><html><head>" . $javascript . "<meta name='viewport' content='width=device-width, initial-scale=1, minimum-scale=0.1, maximum-scale=8, user-scalable=yes'><title>Exif for " . $image . "</title></head><body style='background-color:yellow; background: url(" . str_replace("/Applications/MAMP/htdocs/","http://localhost:8888/",$image) . "); norepeat; " . $rotbit . "'><h1 id='myh1'>Exif <select onchange=\"var zipurl=prompt('Enter image zipfile URL for Mystery Trip game (good for 2 players)','mysterytrip.zip'); if (zipurl != null) { if (zipurl.toLowerCase().indexOf('.zip') != -1) { location.href=document.URL.split('#')[0].split('?')[0] + '?image=' + encodeURIComponent(zipurl);  } } \"><option value=''>for</option><option value=' '>zipfile</option></select> " . $image . "</h1><h3>RJM Programming - August, 2016</h3><h4>Thanks to <a target=_blank title=Useful href=http://www.v-nessa.net/2010/08/02/using-php-to-extract-image-exif-data>http://www.v-nessa.net/2010/08/02/using-php-to-extract-image-exif-data</a></h4><div><br>" . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Image type of " . $image . " is: " . $types[$imagetype];
       $htmlis=str_replace("; norepeat; ", "; opacity:0.6; norepeat; -webkit-transform: rotate(270deg); -moz-transform: rotate(270deg); -ms-transform: rotate(270deg); -o-transform: rotate(270deg); transform: rotate(270deg); ", $htmlis);
     } else if (str_replace(" ","","$val") == "6") {
       //$htmlis="<!doctype html><html><head>" . $javascript . "<title>Exif for " . $image . "</title></head><body style='background-color:yellow; background: url(" . str_replace("/Applications/MAMP/htdocs/","http://localhost:8888/",$image) . "); norepeat; " . $rotbit . "'><h1>Exif <select onchange=\"var zipurl=prompt('Enter image zipfile URL for Mystery Trip game (good for 2 players)','mysterytrip.zip'); if (zipurl != null) { if (zipurl.toLowerCase().indexOf('.zip') != -1) { location.href=document.URL.split('#')[0].split('?')[0] + '?image=' + encodeURIComponent(zipurl);  } } \"><option value=''>for</option><option value=' '>zipfile</option></select> " . $image . "</h1><h3>RJM Programming - August, 2016</h3><h4>Thanks to <a target=_blank title=Useful href=http://www.v-nessa.net/2010/08/02/using-php-to-extract-image-exif-data>http://www.v-nessa.net/2010/08/02/using-php-to-extract-image-exif-data</a></h4><div><br>" . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Image type of " . $image . " is: " . $types[$imagetype];
       $htmlis=str_replace("; norepeat; ", "; opacity:0.6;  norepeat; -webkit-transform: rotate(90deg); -moz-transform: rotate(90deg); -ms-transform: rotate(90deg); -o-transform: rotate(90deg); transform: rotate(90deg); ", $htmlis);
     } else if (str_replace(" ","","$val") == "3") {
       //$htmlis="<!doctype html><html><head>" . $javascript . "<title>Exif for " . $image . "</title></head><body style='background-color:yellow; background: url(" . str_replace("/Applications/MAMP/htdocs/","http://localhost:8888/",$image) . "); norepeat; " . $rotbit . "'><h1>Exif <select onchange=\"var zipurl=prompt('Enter image zipfile URL for Mystery Trip game (good for 2 players)','mysterytrip.zip'); if (zipurl != null) { if (zipurl.toLowerCase().indexOf('.zip') != -1) { location.href=document.URL.split('#')[0].split('?')[0] + '?image=' + encodeURIComponent(zipurl);  } } \"><option value=''>for</option><option value=' '>zipfile</option></select> " . $image . "</h1><h3>RJM Programming - August, 2016</h3><h4>Thanks to <a target=_blank title=Useful href=http://www.v-nessa.net/2010/08/02/using-php-to-extract-image-exif-data>http://www.v-nessa.net/2010/08/02/using-php-to-extract-image-exif-data</a></h4><div><br>" . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Image type of " . $image . " is: " . $types[$imagetype];
       $htmlis=str_replace("; norepeat; ", "; opacity:0.6;  norepeat; -webkit-transform: rotate(180deg); -moz-transform: rotate(180deg); -ms-transform: rotate(180deg); -o-transform: rotate(180deg); transform: rotate(180deg); ", $htmlis);
     }
   }
  }
 }
 if (str_replace("transXXXform:","",$htmlis) != $htmlis) {
   echo str_replace("</h4><div", "</h4>" . $indiv . "<div", $htmlis) . "</div>" . $nform . $sbit . "</body></html>";
 } else {
   echo $htmlis . $indiv . "</div>" . $nform . $sbit . "</body></html>";
 }
} else {
 echo "<br>" . "Not a valid image type for " . $image . " or Exif functionality not enabled." . $nform;
}
}
}
?>
