<?php
// clicktheslideshow.php
// RJM Programming - October, 2015
// As required, set off a Visual Synopsis by clicking the slideshow

$htmlcontent="";
$what="'a'";
$thingtodo="ais[0].click();";
if (isset($_POST['somehtmlurl'])) {
  $htmlcontent=@file_get_contents(urldecode($_POST['somehtmlurl']));
  if (strpos(substr($htmlcontent,0,10), "<") === false) {
    $htmlcontent='<!doctype html><html><body onload=" location.href=' . "'" . urldecode($_POST['somehtmlurl']) . "'; " . '"></body></html>';
  } 
  if (strpos($htmlcontent,  " onmouseover=") !== false) $what="'img'";
  $lookforomo=explode(' onmouseover="', $htmlcontent);
  if (sizeof($lookforomo) > 1) {
      $postlookforomo=explode('"', $lookforomo[-1 + sizeof($lookforomo)]);
      $thingtodo=str_replace("this.","ais[0].",$postlookforomo[0]);
  }
} else if (isset($_GET['somehtmlurl'])) {
  $htmlcontent=@file_get_contents(urldecode($_GET['somehtmlurl']));
  if (strpos(substr($htmlcontent,0,10), "<") === false) {
    $htmlcontent='<!doctype html><html><body onload=" location.href=' . "'" . urldecode($_GET['somehtmlurl']) . "'; " . '"></body></html>';
  } 
  if (strpos($htmlcontent,  " onmouseover=") !== false) $what="'img'";
  $lookforomo=explode(' onmouseover="', $htmlcontent);
  if (sizeof($lookforomo) > 1) {
      $postlookforomo=explode('"', $lookforomo[-1 + sizeof($lookforomo)]);
      $thingtodo=str_replace("this.","ais[0].",$postlookforomo[0]);
  }
} 
if (isset($_POST['somebodyhtml'])) {
  $lookforss=explode('/"><img itemprop=', urldecode($_POST['somebodyhtml']));
  //echo "bwhere " . sizeof($lookforss);
  //exit;
  if (sizeof($lookforss) > 1) {
    $prelookforss=explode('href="', $lookforss[0]);
    $htmlcontent=@file_get_contents(urldecode($prelookforss[sizeof($prelookforss) - 1]) . "/");
    if (strpos($htmlcontent,  " onmouseover=") !== false) $what="'img'";
    $htmlcontent = str_replace("</s" . "cript>", "\n var what=" . $what . "; \n function firstaclick() { var ais=document.getElementsByTagName(what); if (ais.length > 0) {  ais[0].click();   } if (what != 'a') {  setTimeout(firstaclick, 5000);  } } setTimeout(firstaclick, 1000); \n</s" . "cript>", str_replace(' src="', ' src="' . urldecode($prelookforss[sizeof($prelookforss) - 1]) . "/", $htmlcontent));
  $lookforomo=explode(' onmouseover="', $htmlcontent);
  if (sizeof($lookforomo) > 1) {
      $postlookforomo=explode('"', $lookforomo[-1 + sizeof($lookforomo)]);
      $thingtodo=str_replace("this.","ais[0].",$postlookforomo[0]);
  }
  } else if (strpos(urldecode($_POST['somebodyhtml']), "<html") !== false) {
    if (strpos(urldecode($_POST['somebodyhtml']),  " onmouseover=") !== false) $what="'img'";
    $htmlcontent=@file_get_contents(urldecode($_POST['somebodyhtml']));
  $lookforomo=explode(' onmouseover="', $htmlcontent);
  if (sizeof($lookforomo) > 1) {
      $postlookforomo=explode('"', $lookforomo[-1 + sizeof($lookforomo)]);
      $thingtodo=str_replace("this.","ais[0].",$postlookforomo[0]);
  }
  } else {
    if (strpos(urldecode($_POST['somebodyhtml']),  " onmouseover=") !== false) {
  $lookforomo=explode(' onmouseover="', urldecode($_POST['somebodyhtml']));
  if (sizeof($lookforomo) > 1) {
      $postlookforomo=explode('"', $lookforomo[-1 + sizeof($lookforomo)]);
      $thingtodo=str_replace("this.","ais[0].",$postlookforomo[0]);
  }
      $what="'img'";
      $htmlcontent = "<!doctype html><html><head><scr" . "ipt type='text/javascript'>  var what=" . $what . "; \n function firstaclick() { var ais=document.getElementsByTagName(what); if (ais.length > 0) {  ais[0].click();   } if (what != 'a') {  setTimeout(firstaclick, 5000);  }  } </sc" . "ript><body onload='if (1 == 1) { firstaclick(); }'>" . urldecode($_POST['somebodyhtml']) . "</body></html>";
    } else {
      $htmlcontent = "<!doctype html><html><head><scr" . "ipt type='text/javascript'>  var what=" . $what . "; \n function firstaclick() { var ais=document.getElementsByTagName(what); if (ais.length > 0) {  ais[0].click();   } if (what != 'a') {  setTimeout(firstaclick, 5000);  }  } </sc" . "ript><body onload='if (1 == 2) { firstaclick(); }'>" . urldecode($_POST['somebodyhtml']) . "</body></html>";
    }
  }
} else if (isset($_GET['somebodyhtml'])) {
  $lookforss=explode('/"><img itemprop=', urldecode($_GET['somebodyhtml']));
  //echo "awhere " . sizeof($lookforss);
  //exit;
  if (sizeof($lookforss) > 1) {
    $prelookforss=explode('href="', $lookforss[0]);
  //echo "aaawhere " . urldecode($prelookforss[sizeof($prelookforss) - 1]) . "/";
  //exit;
    $htmlcontent=@file_get_contents(urldecode($prelookforss[sizeof($prelookforss) - 1]) . "/");
    $htmlcontent = str_replace("</s" . "cript>", "\n  var what=" . $what . "; \n function firstaclick() { var ais=document.getElementsByTagName(what); if (ais.length > 0) {  ais[0].click();   } if (what != 'a') {  setTimeout(firstaclick, 5000);  }  } setTimeout(firstaclick, 1000); \n</s" . "cript>", str_replace(' src="', ' src="' . urldecode($prelookforss[sizeof($prelookforss) - 1]) . "/", $htmlcontent));
  $lookforomo=explode(' onmouseover="', $htmlcontent);
  if (sizeof($lookforomo) > 1) {
      $postlookforomo=explode('"', $lookforomo[-1 + sizeof($lookforomo)]);
      $thingtodo=str_replace("this.","ais[0].",$postlookforomo[0]);
  }
  //echo "where";
  //exit;
  } else if (strpos(urldecode($_GET['somebodyhtml']), "<html") !== false) {
    if (strpos(urldecode($_GET['somebodyhtml']),  " onmouseover=") !== false) $what="'img'";
    $htmlcontent=@file_get_contents(urldecode($_GET['somebodyhtml']));
  $lookforomo=explode(' onmouseover="', $htmlcontent);
  if (sizeof($lookforomo) > 1) {
      $postlookforomo=explode('"', $lookforomo[-1 + sizeof($lookforomo)]);
      $thingtodo=str_replace("this.","ais[0].",$postlookforomo[0]);
  }
  //echo "xwhere";
  //exit;
  } else {
    if (strpos(urldecode($_GET['somebodyhtml']),  " onmouseover=") !== false) {
  $lookforomo=explode(' onmouseover="', urldecode($_GET['somebodyhtml']));
  if (sizeof($lookforomo) > 1) {
  //echo "here";
  //exit;
      $postlookforomo=explode('"', $lookforomo[-1 + sizeof($lookforomo)]);
      $thingtodo=str_replace("this.","ais[0].",$postlookforomo[0]);
  } //else {
  //echo "there";
  //exit;
 // }
     $what="'img'";
      $htmlcontent = "<!doctype html><html><head><scr" . "ipt type='text/javascript'> var what=" . $what . "; \n function firstaclick() { var ais=document.getElementsByTagName(what); if (ais.length > 0) {  ais[0].click();   } if (what != 'a') {  setTimeout(firstaclick, 5000);  }  } </sc" . "ript><body onload='if (1 == 1) { firstaclick(); }'>" . urldecode($_GET['somebodyhtml']) . "</body></html>";
    } else {
      $htmlcontent = "<!doctype html><html><head><scr" . "ipt type='text/javascript'> var what=" . $what . "; \n function firstaclick() { var ais=document.getElementsByTagName(what); if (ais.length > 0) {  ais[0].click();   } if (what != 'a') {  setTimeout(firstaclick, 5000);  }  } </sc" . "ript><body onload='if (1 == 2) { firstaclick(); }'>" . urldecode($_GET['somebodyhtml']) . "</body></html>";
  //echo "zthere";
  //exit;
    }
  }
} else if (strpos($_SERVER['QUERY_STRING'], 'somebodyhtml=') !== false) {
  $prel=explode('somebodyhtml=', $_SERVER['QUERY_STRING']);
  $lookforss=explode('/"><img itemprop=', urldecode($prel[1]));
 // echo "aawhere " . sizeof($lookforss);
 // exit;
  if (sizeof($lookforss) > 1) {
    $prelookforss=explode('href="', $lookforss[0]);
  //echo "aawhere " . urldecode($prelookforss[sizeof($prelookforss) - 1]) . "/";
  //exit;
    $htmlcontent=@file_get_contents(urldecode($prelookforss[sizeof($prelookforss) - 1]) . "/");
    $htmlcontent = str_replace("</s" . "cript>", "\n  var what=" . $what . "; \n function firstaclick() { var ais=document.getElementsByTagName(what); if (ais.length > 0) {  ais[0].click();   } if (what != 'a') {  setTimeout(firstaclick, 5000);  }  } setTimeout(firstaclick, 1000); \n</s" . "cript>", str_replace(' src="', ' src="' . urldecode($prelookforss[sizeof($prelookforss) - 1]) . "/", $htmlcontent));
  $lookforomo=explode(' onmouseover="', $htmlcontent);
  if (sizeof($lookforomo) > 1) {
      $postlookforomo=explode('"', $lookforomo[-1 + sizeof($lookforomo)]);
      $thingtodo=str_replace("this.","ais[0].",$postlookforomo[0]);
  }
 // echo "aawhere";
 // exit;
  } else if (strpos(urldecode($prel[1]), "<html") !== false) {
    if (strpos(urldecode($prel[1]),  " onmouseover=") !== false) $what="'img'";
    $htmlcontent=@file_get_contents(urldecode($prel[1]));
  $lookforomo=explode(' onmouseover="', $htmlcontent);
  if (sizeof($lookforomo) > 1) {
      $postlookforomo=explode('"', $lookforomo[-1 + sizeof($lookforomo)]);
      $thingtodo=str_replace("this.","ais[0].",$postlookforomo[0]);
  }
//  echo "aaxwhere";
//  exit;
  } else {
    if (strpos(urldecode($prel[1]),  " onmouseover=") !== false) {
  $lookforomo=explode(' onmouseover="', urldecode($prel[1]));
  if (sizeof($lookforomo) > 1) {
//  echo "aahere";
//  exit;
      $postlookforomo=explode('"', $lookforomo[-1 + sizeof($lookforomo)]);
      $thingtodo=str_replace("this.","ais[0].",$postlookforomo[0]);
  } // else {
  //echo "there";
  //exit;
  //}
     $what="'img'";
      $htmlcontent = "<!doctype html><html><head><scr" . "ipt type='text/javascript'> var what=" . $what . "; \n function firstaclick() { var ais=document.getElementsByTagName(what); if (ais.length > 0) {  ais[0].click();   } if (what != 'a') {  setTimeout(firstaclick, 5000);  }  } </sc" . "ript><body onload='if (1 == 1) { firstaclick(); }'>" . urldecode($prel[1]) . "</body></html>";
    } else {
      $htmlcontent = "<!doctype html><html><head><scr" . "ipt type='text/javascript'> var what=" . $what . "; \n function firstaclick() { var ais=document.getElementsByTagName(what); if (ais.length > 0) {  ais[0].click();   } if (what != 'a') {  setTimeout(firstaclick, 5000);  }  } </sc" . "ript><body onload='if (1 == 2) { firstaclick(); }'>" . urldecode($prel[1]) . "</body></html>";
  //echo "zthere";
  //exit;
    }
  }
} else if ($htmlcontent != "") {
  $lookforss=explode('/"><img itemprop=', $htmlcontent);
  if (sizeof($lookforss) > 1) {
    $prelookforss=explode('href="', $lookforss[0]);
    //$htmlcontent=@file_get_contents(urldecode($prelookforss[sizeof($prelookforss) - 1]) . "/");
    $htmlcontent = str_replace("</s" . "cript>", "\n  var what=" . $what . "; \n function firstaclick() { var ais=document.getElementsByTagName(what); if (ais.length > 0) {  ais[0].click();   } if (what != 'a') {  setTimeout(firstaclick, 5000);  }  } setTimeout(firstaclick, 1000); \n</s" . "cript>", str_replace(' src="', ' src="' . urldecode($prelookforss[sizeof($prelookforss) - 1]) . "/", $htmlcontent));
  } else if (strpos($htmlcontent, "<html") !== false) {
    if (strpos($htmlcontent,  " onmouseover=") !== false) $what="'img'";
    //$htmlcontent=@file_get_contents($htmlcontent);
    $htmlcontent = str_replace("</s" . "cript>", "\n  var what=" . $what . "; \n function firstaclick() { var ais=document.getElementsByTagName(what); if (ais.length > 0) {  ais[0].click();   } if (what != 'a') {  setTimeout(firstaclick, 5000);  }  } setTimeout(firstaclick, 1000); \n</s" . "cript>", $htmlcontent);
  } else {
    if (strpos($htmlcontent,  " onmouseover=") !== false) $what="'img'";
    //$htmlcontent = "<!doctype html><html><head><scr" . "ipt type='text/javascript'> var what=" . $what . "; \n function firstaclick() { var ais=document.getElementsByTagName(what); if (ais.length > 0) {  ais[0].click();   } if (what != 'a') {  setTimeout(firstaclick, 5000);  }  } </sc" . "ript><body onload='firstaclick();'>" . $htmlcontent . "</body></html>";
    $htmlcontent = str_replace("</s" . "cript>", "\n  var what=" . $what . "; \n function firstaclick() { var ais=document.getElementsByTagName(what); if (ais.length > 0) {  ais[0].click();   } if (what != 'a') {  setTimeout(firstaclick, 5000);  }  } setTimeout(firstaclick, 1000); \n</s" . "cript>", $htmlcontent);
  }
  $lookforomo=explode(' onmouseover="', $htmlcontent);
  if (sizeof($lookforomo) > 1) {
      $postlookforomo=explode('"', $lookforomo[-1 + sizeof($lookforomo)]);
      $thingtodo=str_replace("this.","ais[0].",$postlookforomo[0]);
  }
}

if (strlen($htmlcontent) > 0) {
  if (strpos($htmlcontent, "<html") === false) {
    $htmlcontent = "<!doctype html><html><head><scr" . "ipt type='text/javascript'> var what='a'; \n function firstaclick() { var ais=document.getElementsByTagName(what); if (ais.length > 0) {  ais[0].click();   } if (what != 'a') {  setTimeout(firstaclick, 5000);  }  } </sc" . "ript><body onload='firstaclick();'>" . $htmlcontent . "</body></html>";
  }
}

if (($what != "'a'" && strpos($htmlcontent, "='a'") !== false) || strpos($htmlcontent, " onmouseover=") !== false || $thingtodo != "ais[0].click();") {
  $htmlcontent = str_replace("ais[0].click();", $thingtodo, str_replace(" onmouseover=", " onclick=", str_replace("='a'", "=" . $what . "", $htmlcontent)));
}

echo str_replace(' id="i', ' style="width:640px;height:400px;" id="i', str_replace('margin-left:', 'width:640px;height:400px;margin-left:', $htmlcontent));
?>