<?php
// stparam.php
// Help out stparam.html
// RJM Programming
// January, 2021

 $numgoes="0";
 $tdcnt=1;
 $findings="";
 if (isset($_POST['tacount' . $tdcnt])) {
   while (isset($_POST['tacount' . $tdcnt])) {
    $findings.='<input type=hidden id=dacount' . $tdcnt . ' value="' . str_replace("+"," ",urldecode($_POST['dacount' . $tdcnt])) . '"></input>';
    $xx=str_replace('"','',str_replace("+"," ",urldecode($_POST['tacount' . $tdcnt])));
    if (strpos($xx, '"data:') !== false) {
      $xxs=explode('"data:', $xx);
      for ($i=1; $i<sizeof($xxs); $i++) {
        $xx=str_replace(explode('"', $xxs[$i])[0], str_replace(" ","+",explode('"', $xxs[$i])[0]), $xx);
      }
      $xxs=explode("'data:", $xx);
      for ($i=1; $i<sizeof($xxs); $i++) {
        $xx=str_replace(explode('"', $xxs[$i])[0], str_replace(" ","+",explode("'", $xxs[$i])[0]), $xx);
      }
    }
    $findings.='<textarea style=display:none; id=tacount' . $tdcnt . '>' . $xx . '</textarea>';
    $tdcnt++;
   }
 }
 
 foreach ( $_POST as $key => $value ) {
    if (strpos($key, "iplay") !== false) {
      $numgoes=explode("iplay", $key)[1];
      if ($numgoes == "") { $numgoes="0"; }
      $findings.='<input type=hidden id=abscissa value=' . $numgoes . '></input>';
    } else if ($key == "playonce") {
      $numgoes="1";
      $findings.='<input type=hidden id=abscissa value=' . $numgoes . '></input>';
    } else if ($key == "playtwice") {
      $numgoes="2";
      $findings.='<input type=hidden id=abscissa value=' . $numgoes . '></input>';
    }
 }

 if (file_exists("stparam.html")) {
   if (str_replace("?","",('' . $_SERVER['QUERY_STRING'])) != '') {
   echo str_replace("</body>", $findings . "</body>", file_get_contents("HTTP://www.rjmprogramming.com.au/HTMLCSS/stparam.html?" . $_SERVER['QUERY_STRING']));
   } else { 
   echo str_replace("</body>", $findings . "</body>", file_get_contents("stparam.html"));
   }
 }
 exit;
?>