<?php
  $surlprefix=str_replace("index.php", "", str_replace("indexslideshow.php", "", str_replace("phpidea.php", "", "//" . $_SERVER['SERVER_NAME'] . explode("#", explode("?", $_SERVER['REQUEST_URI'])[0])[0])));
  $sothers="";
  $tdid=''; //' id="tdfirst" ';
  $stitle=""; //"Please sign it";
  if (isset($_GET['title'])) { $stitle=str_replace("+"," ",urldecode($_GET['title'])); } 
  $scnt=0;
  $sscnt=1;
  $whsbits="";
  $zerobit="";
  $slo=-1;
  $smodebit="";
  $spush="";
  if (isset($_GET['exif'])) {  // //www.rjmprogramming.com.au/PHP/read_exif_off_image_rotate.php?image=
  $surlprefix=str_replace("//www.rjmprogramming.com.au/", "../", $surlprefix);
  $smodetemplate="\n  if (smode != '0') document.getElementById('row').innerHTML+='<td><span style=\"color:red;font-size:14px;\"><b>--&gt;</b></span></td><td><iframe onclick=\"onck(this);\" id=\"i1\" src=\"//www.rjmprogramming.com.au/PHP/read_exif_off_image_rotate.php?image=http://localhost:8888/please_sign_2.jpg\" title=\"Please Sign It\"></iframe></td>'; \n";
  } else {
  $smodetemplate="\n  if (smode != '0') document.getElementById('row').innerHTML+='<td><span style=\"color:red;font-size:14px;\"><b>--&gt;</b></span></td><td><img onclick=\"onck(this);\" id=\"i1\" src=\"http://localhost:8888/please_sign_2.jpg\" title=\"Please Sign It\" /></td>'; \n";
  }

  if (!file_exists("index.htm") && !file_exists("index.html")) {
     foreach (glob("*-[0-9]*of.[jJgGpP][pPiInN]*") as $ifil) {
       $ibits=explode("-", $ifil);
       if (sizeof($ibits) > 1) {
         $proposedstitle=str_replace("_", " ", $ibits[0]);
         if ($proposedstitle != $stitle) {
           if ($stitle == "") {
             $stitle=$proposedstitle;
           } else if (strpos($sothers, $proposedstitle) === false) {
             $spush.="\n firstones.push(" . $scnt . "); \n";
             $spush.="\n lastones.push(" . (-1 + $scnt) . "); \n";
             $sothers.="<br><a id='apre" . $sscnt . "' href='#s" . $scnt . "' title=\"Movie'ize Here vs Follow Red Right Arrows with Bottom Scrollbar\" onclick='prehavealook(this); havealook(-" . $scnt . ");'>" . $proposedstitle . "</a>";
             $sscnt++;
           }
         }
         if (isset($_GET['exif'])) {  // //www.rjmprogramming.com.au/PHP/read_exif_off_image_rotate.php?image=
         list($width, $height, $type, $attr) = getimagesize($ifil);
         $zerobit=" style=\"width:" . $width . "px;height:" . $height . "px;\" ";
         $smodebit.="\n  if (smode != '0') document.getElementById('row').innerHTML+='<td style=\"width:" . $width . "px;height:" . $height . "px;\"><span style=\"color:red;font-size:14px;\"><b>--&gt;</b></span></td><td style=\"width:" . $width . "px;height:" . $height . "px;\"><iframe style=\"width:" . $width . "px;height:" . $height . "px;\" onclick=\"onck(this);\" id=\"i" . $scnt . "\" src=\"//www.rjmprogramming.com.au/PHP/read_exif_off_image_rotate.php?image=" . urlencode($surlprefix . $ifil) . "\" title=\"" . $proposedstitle . "\"></iframe></td>'; \n";
         } else {
         $smodebit.="\n  if (smode != '0') document.getElementById('row').innerHTML+='<td><span style=\"color:red;font-size:14px;\"><b>--&gt;</b></span></td><td><img onclick=\"onck(this);\" id=\"i" . $scnt . "\" src=\"" . $surlprefix . $ifil . "\" title=\"" . $proposedstitle . "\" /></td>'; \n";
         }
         $spush.="\n uarraydatauri.push('" . $surlprefix . $ifil . "'); \n";
         $scnt++;
       }
     }
     foreach (glob("*-[0-9]*.[jJgGpP][pPiInN]*") as $ifil) {
       if (strpos($spush, "'" . $surlprefix . $ifil . "'") === false) {
       $ibits=explode("-", $ifil);
       if (sizeof($ibits) > 1) {
         $proposedstitle=str_replace("_", " ", $ibits[0]);
         if ($proposedstitle != $stitle) {
           if ($stitle == "") {
             $stitle=$proposedstitle;
           } else if (strpos($sothers, $proposedstitle) === false) {
             $spush.="\n firstones.push(" . $scnt . "); \n";
             $spush.="\n lastones.push(" . (-1 + $scnt) . "); \n";
             $sothers.="<br><a id='apre" . $sscnt . "' href='#s" . $scnt . "' title=\"Movie'ize Here vs Follow Red Right Arrows with Bottom Scrollbar\" onclick='prehavealook(this); havealook(-" . $scnt . ");'>" . $proposedstitle . "</a>";
             $sscnt++;
           }
         }
         if (isset($_GET['exif'])) {
         list($width, $height, $type, $attr) = getimagesize($ifil);
         $zerobit=" style=\"width:" . $width . "px;height:" . $height . "px;\" ";
         $smodebit.="\n  if (smode != '0') document.getElementById('row').innerHTML+='<td<?php echo $tdid; ?> style=\"width:" . $width . "px;height:" . $height . "px;\"><span style=\"color:red;font-size:14px;\"><b>--&gt;</b></span></td><td style=\"width:" . $width . "px;height:" . $height . "px;\"><iframe style=\"width:" . $width . "px;height:" . $height . "px;\" onclick=\"onck(this);\" id=\"i" . $scnt . "\" src=\"//www.rjmprogramming.com.au/PHP/read_exif_off_image_rotate.php?image=" . urlencode($surlprefix . $ifil) . "\" title=\"" . $proposedstitle . "\"></iframe></td>'; \n";
         $tdid="";
         } else {
         $smodebit.="\n  if (smode != '0') document.getElementById('row').innerHTML+='<td><span style=\"color:red;font-size:14px;\"><b>--&gt;</b></span></td><td><img onclick=\"onck(this);\" id=\"i" . $scnt . "\" src=\"" . $surlprefix . $ifil . "\" title=\"" . $proposedstitle . "\" /></td>'; \n";
         }
         $spush.="\n uarraydatauri.push('" . $surlprefix . $ifil . "'); \n";
         $scnt++;
       }
       }
     }
  }
?>
<html> 
<head> 
<title><?php echo $stitle; ?> - via RJM Programming Slideshow Presentation</title> 
<?php 
if (1 == 1 && isset($_GET['exif'])) {  // //www.rjmprogramming.com.au/PHP/read_exif_off_image_rotate.php?image=
 echo "
<style>
 iframe { width: 100%; height: 100%; }
 td { vertical-align: top; }
</style>
";
}
?>
<script type="text/javascript"> 
 var smode = location.search.split('smode=')[1] ? location.search.split('smode=')[1].split('&')[0] : '1'; 
 var ttl = ' ... click to have this slide stay longer'; 
 var nextone=0, inextone=1, jnextone=0, lastast=0; 
 var whs=[<?php echo $whsbits; ?>];
 var lastones=[], firstones=[0];
 var lastone=<?php echo (-1 + $scnt); ?>; 
 var haveseen=0; 
 var aminterested=0, dt=''; 
 var doit=1, uarraydatauri=[]; 
 
<?php
   echo $spush; 
   echo "\n lastones.push(" . (-1 + $scnt) . "); \n";
?>


 function onck(that) { 
   doit = 0; 
 } 

 function prehavealook(obackto) { 
   if (obackto.id == 'apre0' && document.URL.indexOf('exif=') != -1) {
    document.getElementById('s0').style.width=document.getElementById('i0').style.width;
    document.getElementById('s0').style.height=document.getElementById('i0').style.height;
   }
   lastast=eval(obackto.id.replace('apre',''));
   lastone=lastones[lastast];
 }
 
 function havealook(backto) { 
   if (smode == '0') { 
   if (eval(backto) <= 0) {  location.href=document.URL.replace('smode=0','smode=1'); }
   document.getElementById('i' + nextone).src=uarraydatauri[jnextone]; 
   document.title=dt + " Slide " + inextone + " of " + eval(lastone + 1); 
   if (dt == '') {  document.getElementById('myh1').innerHTML='Slideshow Data URI version below';  document.getElementById('som').innerHTML='Start of Movie'; dt=document.getElementById('i' + nextone).title; } else if (inextone == 1) { document.getElementById('som').innerHTML='Start of Movie';  } else { document.getElementById('som').innerHTML='';  }  
   inextone=eval(eval(inextone % eval(1 + lastone)) + 1); jnextone=eval(-1 + inextone); 
   } else { 
   var thissrc=''; 
   var prefix=''; 
   if (doit == 0) { 
   doit = 1; 
   } else { 
   if (aminterested != 0 || eval(backto) <= 0) { 
   var cit = document.getElementById('s0'); 
   if (nextone == lastone) { 
     thissrc = document.getElementById('i' + nextone).src; 
     cit.innerHTML = prefix + "<<?php if (isset($_GET['exif'])) { echo 'iframe' . str_replace('"',"'",$zerobit); } else { echo 'img'; } ?> onclick='onck(this);' id='j" + nextone + "' src='<?php if (isset($_GET['exif'])) { echo ''; } else { echo ''; } ?>" + <?php if (isset($_GET['exif'])) { echo 'thissrc'; } else { echo 'thissrc'; } ?> + "' title='" + document.getElementById('i' + nextone).title + ttl + "' <?php if (isset($_GET['exif'])) { echo '></iframe>'; } else { echo '/>'; } ?>"; 
     nextone = firstones[lastast]; //0; 
   } else { 
     thissrc = document.getElementById('i' + nextone).src; 
     if (eval(backto) > 0 && nextone == 0) { 
        prefix = 'Start of Movie: '; 
     } 
     cit.innerHTML = prefix + "<<?php if (isset($_GET['exif'])) { echo 'iframe' . str_replace('"',"'",$zerobit); } else { echo 'img'; } ?> onclick='onck(this);' id='j" + nextone + "' src='<?php if (isset($_GET['exif'])) { echo ''; } else { echo ''; } ?>" + <?php if (isset($_GET['exif'])) { echo 'thissrc'; } else { echo 'thissrc'; } ?> + "' title='" + document.getElementById('i' + nextone).title + ttl + "' <?php if (isset($_GET['exif'])) { echo '></iframe>'; } else { echo '/>'; } ?>"; 
     nextone = nextone + 1; 
     if (nextone > 1) haveseen = 1; 
   } 
   if (eval(backto) <= 0) { 
     nextone = Math.abs(backto); 
     aminterested = 1; 
   } 
   } 
   var nnext = eval(nextone + 0); 
   var llast = eval(lastone + 1); 
   if (nnext >= 1 && nnext <= llast) { 
     nnext = nnext; 
   } else if (prefix != '') { 
     nnext = 1;   
   } else if (aminterested != 0 && haveseen == 1) { 
     nnext = llast; 
   } else if (aminterested != 0) { 
     nnext = 1; 
   } else if (nnext == 0) { 
     nnext = 1; 
   } 
   document.title=document.getElementById('i' + nextone).title + " Slide " + nnext + " of " + llast; 
   } 
   } 
 } 
 function ol() { 
 <?php 
  echo $smodebit;
?>
 } 
 
 function changeto(tvis) {
   if (tvis.toLowerCase().indexOf('exif') == 0) {
    if (document.URL.indexOf('?') == -1) { 
     location.href=document.URL.split('#')[0] + '?exif=y';
    } else {
     location.href=document.URL.split('#')[0] + '&exif=y';
    }
   } else {
    if (document.URL.indexOf('exif=') != -1) { 
     location.href=document.URL.split('#')[0].replace('exif=', 'exTif=');
    } else {
     location.href=document.URL.split('#')[0] + '&eHuhxif=y';
    }
   }
 }
 
 window.setInterval(function(){havealook(1)},2000);  
 </script> 
 </head> 
 <body onload="if (document.URL.indexOf('exif=') != -1) { document.getElementById('selmode').value='Exif Slideshow'; if (document.getElementById('tdfirst')) { document.getElementById('s0').style.width=document.getElementById('tdfirst').style.width; document.getElementById('s0').style.height=document.getElementById('tdfirst').style.height; } } document.title=document.title + ' ' + lastone; ol(); "> 
 <h1 id=myh1><?php echo $stitle; ?> <select id=selmode onchange="changeto(this.value);"><option value="Slideshow">Slideshow</option><option value="Exif Slideshow">Exif Slideshow</option></select> version below<h1><h4> ... optionally get content via web browser (Windows right click, Mac OS X two finger gesture) ... <span id=som></span></h4><br> 
 <table> 
 <tr id=row> 
 <td<?php echo $zerobit; ?>><span id='s0'><a id='apre0' href='#' title="Movie'ize Here vs Follow Red Right Arrows with Bottom Scrollbar" onclick='prehavealook(this); havealook(0);'>@</a><?php echo $sothers; ?></span><span style="color:red;font-size:14px;"><b>--&gt;</b></span></td><!--td><img onclick="onck(this);" id="i0" src="http://localhost:8888/please_sign_1.jpg" title="Please Sign It" /></td--> 
 </tr>
 </table>
</body>
</html>
