<?php
// what_is_the_english_word.php
// RJM Programming
// February, 2022
set_time_limit(58);

$midbit=rand(0,19876754);
$gretv='';

function oururldecode($inue) {
  global $gretv;
  $retv=urldecode($inue);
  $retsare=explode("localhost", $inue);
  if (sizeof($retsare) > 1) {
    $retv=str_replace($retsare[0] . 'localhost' . explode('#', explode('?', explode('/', $retsare[1])[0])[0])[0] . '/', $_SERVER['DOCUMENT_ROOT'], $retv);
  }
  $gretv=$retv;
  return $retv;
}

//file_put_contents('x.x', $_SERVER['SERVER_NAME']);
if (isset($_GET['imagetest']) && strpos($_SERVER['SERVER_NAME'], 'localhost') !== false) {
if (function_exists(imagecreatetruecolor)) {
  //file_put_contents('xx.xx', (urldecode($_GET['imagetest'])));
  $im = imagecreatetruecolor(120, 10);
  $text_color = imagecolorallocate($im, 233, 14, 91);
  imagestring($im, 1, 5, 5,  'A Simple Text String', $text_color);
  // Output the image
  if (strpos(oururldecode($_GET['imagetest']), '.') === false) {
  if (file_exists(dirname(__FILE__) . "/" . "imagetest.jpg")) { unlink(dirname(__FILE__) . "/" . "imagetest.jpg");  }
  $gretv=dirname(__FILE__) . "/" . "imagetest.jpg";
  imagejpeg($im, dirname(__FILE__) . "/" . "imagetest.jpg");
  } else if (strpos(strtolower(oururldecode($_GET['imagetest'])), '.gif') !== false) {
  //file_put_contents('xxx.xxx', $_SERVER['SERVER_NAME']);
  if (file_exists(oururldecode($_GET['imagetest']))) { unlink(oururldecode($_GET['imagetest']));  }
  imagegif($im, oururldecode($_GET['imagetest']));
  //file_put_contents('xxxx.xxxx', $_SERVER['SERVER_NAME']);
  } else if (strpos(strtolower(oururldecode($_GET['imagetest'])), '.bmp') !== false) {
  if (file_exists(oururldecode($_GET['imagetest']))) { unlink(oururldecode($_GET['imagetest']));  }
  imagebmp($im, oururldecode($_GET['imagetest']), true);
  } else if (strpos(strtolower(oururldecode($_GET['imagetest'])), '.png') !== false) {
  if (file_exists(oururldecode($_GET['imagetest']))) { unlink(oururldecode($_GET['imagetest']));  }
  imagepng($im, oururldecode($_GET['imagetest']));
  } else if (strpos(strtolower(oururldecode($_GET['imagetest'])), '.jp') !== false) {
  if (file_exists(oururldecode($_GET['imagetest']))) { unlink(oururldecode($_GET['imagetest']));  }
  imagejpeg($im, oururldecode($_GET['imagetest']));
  }
  // Free up memory
  imagedestroy($im);
  if (file_exists($gretv)) {
  unlink($gretv);
  echo "<html><body onload=\"window.close();\"></body></html>";
  }
  //sleep(25);
  //unlink(oururldecode($_GET['imgtest']));
} else { echo "<html><body onload=\"window.close();\"></body></html>"; } 
  exit;
}
 
$doaudio=''; 
$stufftosay='';  
$formstufftosay="";
$divstufftosay="";
$kh="";
if (isset($_GET['doaudio']) || isset($_POST['doaudio'])) {
  if (isset($_GET['iam'])) {
  $kh="&doaudio=" . $_GET['iam']; // . '&iam=' . $_GET['iam'];
  } else {
  $kh="&doaudio=" . $_GET['doaudio'];;
  }
}
//$speakerblurb='';
$speakerblurb="<a id=asay title='Will be trying HTTP://localhost:8888/what_is_the_english_word.php (MAMP) way to use say audio off command line ... double click to change the local web server URL here' style=cursor:pointer;text-decoration:none; ondblclick=relocalize(); onclick=\" if (this.title.indexOf('did not find') != -1) { relocalize(); } else { document.getElementById('speaker').innerHTML='<input id=doaudio name=doaudio type=hidden value=" . $_GET['doaudio'] . "></input>';  maybeaudio(0); } \">&#128266;</a>";
if (PHP_OS == "Darwin") { 
  $stufftosay='';  
  if (isset($_GET['audio']) || isset($_POST['audio'])) {
   if (isset($_GET['audio'])) {
     $doaudio=trim(str_replace('+',' ',urldecode($_GET['audio'])));
   } else if (isset($_POST['audio'])) {
     $doaudio=trim(str_replace('+',' ',urldecode($_POST['audio'])));
   } 
  }
  if (trim($doaudio) != '' || isset($_GET['doaudio']) || isset($_POST['doaudio'])) {
  $divstufftosay="<input id=doaudio name=doaudio type=hidden value=" . $_GET['doaudio'] . "></input>";
  if (isset($_GET['audio']) || isset($_POST['audio'])) {
   if (isset($_GET['audio'])) {
     $stufftosay=trim(str_replace('+',' ',urldecode($_GET['audio'])));
   } else if (isset($_POST['audio'])) {
     $stufftosay=trim(str_replace('+',' ',urldecode($_POST['audio'])));
   } 
   if ($stufftosay != '') {
     while (file_exists('what_is_the_english_word.blurb')) {
       sleep(2);
     }
     file_put_contents('what_is_the_english_word.blurb', '');
     //file_put_contents('what_is_the_english_word.b', '' . $_GET['audio'] . ' ... ' . $_GET['doaudio']);
     if (strpos($stufftosay, "Player,") === false && ($_GET['audio'] != '' && $_GET['doaudio'] != '')) { exec('say "' . $stufftosay . '"');  }
     if (file_exists('what_is_the_english_word.blurb')) {
       unlink('what_is_the_english_word.blurb');
     }
     if (isset($_GET['andthatisit']) || isset($_POST['andthatisit'])) {
       exit;
     }
   }
  }
  }
}

$h1prefix="";
$h1itprefix="";
$seloh="&nbsp;<select onclick=\" event.stopPropagation(); \" onchange=\" if (this.value.length != 0) { top.setgl('-' + this.value);   this.value='';  } \" id=isel style=display:none;width:15px;><option value=''> </option></select>";
$ddname="";
if (isset($_GET['myname'])) {
 $ddname="<input type=hidden name=myname value='" . str_replace(',&nbsp;,',',',str_replace(', ,',',',str_replace(',,',',',trim(str_replace('&nbsp;',' ',str_replace('+',' ',urldecode($_GET['myname'])))) . ''))) . "'></input>";
}
$score=0;
$goes=0;
$blurb='';
$dblurb="Score: 0/0";
$totalj=0;
$fortyeight="48";
$fortyeighti="";
$fortyeightj="";
$ob="";
$okp="";
$sh3="";
$aic="Am I Correct?";
$bc="background-color:yellow;";
if (isset($_GET['fortyeight'])) {
  $fortyeight=$_GET['fortyeight'];
  $fortyeighti="<input type=hidden name=fortyeight value='" . $fortyeight . "'></input>";
  $fortyeightj="&fortyeight=" . $fortyeight;
  $aic="Correct?";
  $ob=" onblur=\" if (this.value.trim() != '' && eval('' + this.value.length) >= eval('' + document.getElementById('wl').innerHTML)) { document.getElementById('subm').style.backgroundColor='orange'; document.getElementById('subm').click(); } \" ";
  $okp=" onkeydown=\" return isitnum(event); \" title=\"Type numerics to focus on that player number textbox.\" ";
  $sh3=" style='display:none;'";
  $bc="background:linear-gradient(270deg, #00D7B9, #B95DD7 50%, #FFB367 100%);"; //linear-gradient(180deg, cornflowerblue, purple);";
  if (isset($_GET['audio'])) {
  $fortyeightj.='&audio=' . $_GET['audio'];
  }
  if (isset($_GET['andthatisit'])) {
  $fortyeightj.='&andthatisit=' . $_GET['andthatisit'];
  }
  if (isset($_GET['myname'])) {
  $fortyeightj="&fortyeight=" . $fortyeight . '&myname=' . $_GET['myname'];
  $h1itprefix=str_replace(',&nbsp;,',',',str_replace(', ,',',',str_replace(',,',',',trim(str_replace('&nbsp;',' ',str_replace('+',' ',urldecode($_GET['myname'])))) . ', '))) . "What Is " . $_GET['length'] . " Letter English Word With " . $_GET['letter'] . " position " . $_GET['position'] . '?';
  $h1prefix="<span style='border:1px dashed transparent;' contenteditable=true title='Your name?' id=sname onblur=\" document.getElementById('dname').innerHTML=newh1('<input type=hidden id=myname name=myname value=' + String.fromCharCode(39) + this.innerHTML.split('&')[0] + String.fromCharCode(39) + '></input>');  \">" . str_replace(',&nbsp;,',',',str_replace(', ,',',',str_replace(',,',',',trim(str_replace('&nbsp;',' ',str_replace('+',' ',urldecode($_GET['myname'])))) . ', '))) . "</span>";
  } else {
  $h1prefix="<span style='border:1px dashed pink;' contenteditable=true title='Your name?' id=sname onblur=\" document.getElementById('dname').innerHTML=newh1('<input type=hidden id=myname name=myname value=' + String.fromCharCode(39) + this.innerHTML.split('&')[0] + String.fromCharCode(39) + '></input>');  \"></span>";
  }
}

if (isset($_GET['numplayers'])) {
  $preifs="<html>
<head>
<title>What Is The English Word - RJM Programming - February, 2022</title>
<meta id='myviewport' name='viewport' content='width=device-width, initial-scale=1, minimum-scale=0.1, maximum-scale=8, user-scalable=yes' >
<script type='text/javascript' src='apple_script_url.js'></script>
<script type='text/javascript'>
 var gl=-1;
 var doclick=false;
 var xwoisme=null;
 var wast='HTTP://localhost:8888/what_is_the_english_word.php (MAMP)';
 
 function relocalize() {
   var onewast=wast.split(' ')[0];
   if (document.getElementById('asay').title.indexOf('did not find, ') != -1) {
     onewast=document.getElementById('asay').split('did not find, ')[1].split(' ')[0];
   }
   var pwast=prompt('Tell me where what_is_the_english_word.php is located in a macOS local web server with access to say command line commnd.', onewast);
   if (pwast == null) { pwast=''; }
   if (pwast != '' && pwast != onewast && pwast.indexOf('localhost') >= 7) {
     if (pwast.toLowerCase().indexOf('.php') == -1) { if (pwast.slice(-1) == '/') { pwast+='what_is_the_english_word.php';  } else { pwast+='/what_is_the_english_word.php';  }  }
      if (('' + localStorage.getItem('what_is_the_english_word')).replace(/^null$/g,'') != '') {
       localStorage.removeItem('what_is_the_english_word');
       localStorage.setItem('what_is_the_english_word', pwast);
      }
      location.href=document.URL;
   }
 }
 
 function setgl(inv) {
   gl=eval(('' + inv).replace('-',''));
   if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) && ('' + inv).indexOf('-') != -1) { doclick=true; } else { doclick=false; }
   if (document.getElementById('isel' + gl)) {  document.getElementById('isel' + gl).style.display='inline-block'; } 
   //location.href='#if' + inv;
 }
 
 function newh1(inin) {
   var theclue='';
   var spansare=document.getElementsByTagName('span');
   var honeis=document.getElementsByTagName('h1');
   var ablurb=((honeis[0].innerText || honeis[0].contentWindow || honeis[0].contentDocument)).split('?')[0] + '?';
   for (var iuh=0; iuh<spansare.length; iuh++) {
     if (spansare[iuh].indexOf('&nbsp;&nbsp;') != -1 && spansare[iuh].indexOf('...') != -1) { theclue=spansare[iuh].split('&nbsp;&nbsp;')[1].split('...')[0].trim();  }
   }
   top.setopt(location.hash.replace('#',''), ablurb + '  Clue: ' + theclue);
   return inin;
 }
 
 function setopt(jnv, inv) {
   var ik=1;
   while (document.getElementById('isel' + ik)) {
     if (document.getElementById('isel' + ik).innerHTML.indexOf(' value=\"' + jnv + '\">') != -1) {
       document.getElementById('isel' + ik).innerHTML=document.getElementById('isel' + ik).innerHTML.replace(document.getElementById('isel' + ik).innerHTML.split(' value=\"' + jnv + '\"')[1].split('</option>')[0] + '<', '>' + inv + '<');
     } else if (eval('' + jnv) == 1) {
       document.getElementById('isel' + ik).innerHTML=document.getElementById('isel' + ik).innerHTML.replace('</option>', '</option>' + '<option value=\"' + jnv + '\">' + inv + '</option>');
     } else if (document.getElementById('isel' + ik).innerHTML.indexOf(' value=\"' + eval(1 + eval('' + jnv)) + '\">') != -1) {
       document.getElementById('isel' + ik).innerHTML=document.getElementById('isel' + ik).innerHTML.replace('<option value=\"' + eval(1 + eval('' + jnv)) + '\">', '<option value=\"' + jnv + '\">' + inv + '</option>' + '<option value=\"' + eval(1 + eval('' + jnv)) + '\">');
     } else if (document.getElementById('isel' + ik).innerHTML.indexOf(' value=\"' + eval(-1 + eval('' + jnv)) + '\">') != -1) {
       document.getElementById('isel' + ik).innerHTML=document.getElementById('isel' + ik).innerHTML.replace(document.getElementById('isel' + ik).innerHTML.split(' value=\"' + eval(-1 + eval('' + jnv)) + '\">')[1].split('</option>')[0] + '</option>', document.getElementById('isel' + ik).innerHTML.split(' value=\"' + eval(-1 + eval('' + jnv)) + '\">')[1].split('</option>')[0] + '</option>' + '<option value=\"' + jnv + '\">' + inv + '</option>');
     } else {
       document.getElementById('isel' + ik).innerHTML+='<option value=\"' + jnv + '\">' + inv + '</option>';
     }
     ik++;
   }   
 }
 
 function tisitnum(event) {
  if (eval('' + event.keyCode) >= 48 && eval('' + event.keyCode) <= 57) {
    top.setgl(eval(-48 + eval('' + event.keyCode)));
    return false;
  }
  return true; 
 }
  
 function everyh() {
    var mygl=gl;
    var iframes = document.getElementsByTagName('iframe');
    if (eval('' + iframes.length) > 0) {
     var rn=Math.floor(Math.random() * eval('' + iframes.length));
     if (eval('' + gl) >= 1 && eval('' + gl) <= eval('' + iframes.length)) { 
       rn=eval(-1 + eval('' + gl));   
       gl=-1; 
       var elmntq = iframes[rn].contentWindow.document.getElementById('q');
       var elmnt = iframes[rn].contentWindow.document.getElementById('youranswer');
       if (elmnt) { 
    if (elmntq.innerHTML == '?' && document.getElementById('if' + mygl) && (1 == 1 || navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i))) {
    //alert(document.getElementById('playerth').innerHTML);
    elmntq.innerHTML += '&nbsp;&nbsp;<font size=1>' + document.getElementById('playerth').innerHTML.replace('Player','').replace('>' + mygl + '<','><') + '</font>';
    //document.getElementById('if' + mygl).scrollIntoView(); //location.href='#if' + mygl;
    //alert('1 ' + document.getElementById('if' + mygl));
    //var rect=document.getElementById('if' + mygl).getBoundingClientRect();
    //alert('' + rect.top);
    //document.getElementById('playerth').style.top=('' + eval(window.scrollY) + 'px').replace('-','');
    //document.getElementById('playerth').style.bottom=('' + eval(window.scrollY + rect.height) + 'px').replace('-','');
    //document.getElementById('playerth').scrollIntoView(); 
    }
         if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) { location.href='#if' + mygl; } 
         if (doclick && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) { elmnt.click(); doclick=false;  }  
         elmnt.focus();
       }
       gl=-1;
     }
    }
    setTimeout(everyh, 200);
  }
  
  function tonl() {
    if (!navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) { 
      setgl(1); 
    } else if (document.getElementById('isel1')) {
      document.getElementById('isel1').style.display='inline-block';
    }
    if (!navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
    var rect=document.getElementById('playerth').getBoundingClientRect();
    document.getElementById('playerth').style.left='' + rect.left + 'px';
    document.getElementById('playerth').style.left='' + rect.x + 'px';
    document.getElementById('playerth').style.right='' + eval(rect.left + rect.width) + 'px';
    document.getElementById('playerth').style.width='' + rect.width + 'px';
    if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
    //document.getElementById('playerth').style.position='absolute';
    document.getElementById('playerth').style.position='fixed';
    //document.getElementById('playerth').style.height='100%';
    document.getElementById('playerth').style.height='' + rect.height + 'px';
    //document.getElementById('playerth').style.overflow='auto';
    //document.getElementById('playerth').style.top='200px';
    //document.getElementById('playerth').style.bottom=('' + eval(200 + rect.height) + 'px').replace('-','');
    document.getElementById('playerth').style.top=('' + rect.y + 'px').replace('-','');
    document.getElementById('playerth').style.bottom=('' + eval(rect.y + rect.height) + 'px').replace('-','');
    //document.getElementById('playerth').style.overflowY='scroll';
    //document.getElementById('playerth').style.overflowX='hidden';
    } else {
    document.getElementById('playerth').style.position='fixed';
    document.getElementById('playerth').style.height='' + rect.height + 'px';
    document.getElementById('playerth').style.top=('' + rect.y + 'px').replace('-','');
    document.getElementById('playerth').style.bottom=('' + eval(rect.y + rect.height) + 'px').replace('-','');
    }
    document.getElementById('playerth').style.borderRadius='100px';
    document.getElementById('playerth').style.border='1px dashed lightgray';
    document.getElementById('playerth').style.marginLeft='15%';
    document.getElementById('playerth').style.width='70%';
    document.getElementById('playerth').style.textAlign='left';
    //document.getElementById('playerth').style.overflowY='scroll';
    //document.getElementById('playerth').style.overflowX='hidden';
    //document.getElementById('playerth').style.zIndex='99';
    //document.getElementById('playerth').style.opacity='0.8';
    //alert(document.getElementById('playerth').outerHTML);
    }
  }
  
  setTimeout(everyh, 5000);
</script>
</head><body onload=tonl(); style='background-color:yellow;'><table style='width:100%;background:linear-gradient(180deg, lightgreen, lightblue 50%, yellow);' border=20><tr><th id=playerth colspan=2>Player </TH></tr><tr><th>Number</th><th><a target=_self style='cursor:pointer;text-decoration:none;' title=Reload href=./what_is_the_english_word.php>Game</a></th></tr></table></body></html>";
  for ($ih=1; $ih<=$_GET['numplayers']; $ih++) {
     $preifs=str_replace("</table>", "<tr><td style='font-size:28px;width:10%;border-radius:100px;cursor:pointer;text-decoration:none;text-align:center;background-color:lightblue;' onclick=' top.setgl(" . $ih . "); ' id=ltd" . $ih . " title=\"Click numeric to focus on that player number textbox.\">" . $ih . str_replace('=isel','=isel' . $ih,$seloh) . "<td><iframe id=if" . $ih . " src='./what_is_the_english_word.php?fortyeight=12&iam=" . $ih . $kh . "#" . $ih . "' style='width:100%;height:200px;'></iframe></table>", $preifs); 
     $preifs=str_replace("</TH>", "&nbsp;&nbsp;&nbsp;<span style='font-size:18px;width:12%;border-radius:100px;cursor:pointer;text-decoration:none;text-align:center;background-color:lightblue;' onclick=' top.setgl(" . $ih . "); ' id=std" . $ih . " title=\"Click numeric to focus on that player number textbox.\">" . $ih . "</span></TH>", $preifs); 
  }
  echo $preifs;
  exit;
}

function ask() {
  global $score, $goes, $blurb, $fortyeightj, $kh;
  $letters=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
  $rl=rand(0,25);
  $lr=rand(5,12);
  $pr=rand(1,$lr);
  header('Location: ' . str_replace(":80/","/",str_replace(":443/","/","http://" . $_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT'] . "" . explode('?',$_SERVER['REQUEST_URI'])[0] . '?position=' . $pr . $kh . '&length=' . $lr . '&letter=' . $letters[$rl] . '&score=' . $score . '&goes=' . $goes . $fortyeightj . '&blurb=' . urlencode($blurb))));
  exit;
}

if (isset($_GET['youranswer']) && isset($_GET['theanswer'])) {
  if (isset($_GET['score'])) { $score=$_GET['score'];  }
  if (isset($_GET['goes'])) { $goes=$_GET['goes'];  }
  if (isset($_GET['blurb'])) { $dblurb=str_replace('+',' ',urldecode($_GET['blurb']));  }
  $goes++;
  $blurb=str_replace('+',' ',urldecode($_GET['explanation'])) . "<font title='Thanks to The Free Dictionary, if you click' style=cursor:pointer;text-decoration:underline; onclick=\"maybestatusaudio(0); window.open('//www.thefreedictionary.com/" . $_GET['theanswer'] . "', '_blank', 'top=100,left=100,width=500,height=600');  \" color=blue>" . $_GET['theanswer'] . "</font> ... Score: " . $score . "/" . $goes;
  if (trim(strtolower($_GET['youranswer'])) == trim(strtolower($_GET['theanswer']))) {
    $score++;
    $blurb="Congratulations! ... Score: " . $score . "/" . $goes;
  }
  ask();
} else if (isset($_GET['letter']) && isset($_GET['length']) && isset($_GET['position'])) {
  if (isset($_GET['score'])) { $score=$_GET['score'];  }
  if (isset($_GET['goes'])) { $goes=$_GET['goes'];  }
  if (isset($_GET['blurb'])) { $dblurb=str_replace('+',' ',urldecode($_GET['blurb']));  }
  $h1itprefix="What Is " . $_GET['length'] . " Letter English Word With " . $_GET['letter'] . " position " . $_GET['position'] . '?';
  $w14a=$_GET['letter'];
  $wzero="";
  $wz="";
  $dwz="_";
  for ($ii=1; $ii<=$_GET['length']; $ii++) {
    if ($ii == $_GET['position']) {
      $wzero.=$w14a;
      $wz.=$w14a;
    } else {
      $wzero.="0";
      $wz.=$dwz;
      if ($dwz == "_") { $dwz="-";  } else {  $dwz="_";  }
    }
  }
  $w10d="";
  $jj=0;
  while (strpos($w10d, ' ') === false) {
    $w10d = file_get_contents(str_replace(":80/","/",str_replace(":443/","/","http://" . $_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT'] . "/PHP/surprise.php?min=" . (1 + $_GET['length']) . "&max=" . (1 + $_GET['length']) . "&hastobe=" . $wzero . "&needclue=y&youllneverfindthis=y")));
    $jj++;
    $totalj++;
    if ($totalj > 100) { 
        exit; //header('Location: ' . str_replace(":80/","/",str_replace(":443/","/","http://" . $_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT'] . "" . explode('?',$_SERVER['REQUEST_URI'])[0])));
    }
    if ($jj > 10) { ask(); }
    sleep(2);
  }
  
  if (PHP_OS == "Darwin") { 
  $stufftosay='';
  if (isset($_GET['audio']) || isset($_POST['audio'])) {
   if (isset($_GET['audio'])) {
     $doaudio=trim(str_replace('+',' ',urldecode($_GET['audio'])));
   } else if (isset($_POST['audio'])) {
     $doaudio=trim(str_replace('+',' ',urldecode($_POST['audio'])));
   } 
  }
  if (trim($doaudio) != '' || isset($_GET['doaudio']) || isset($_POST['doaudio'])) {
  if (isset($_GET['audio']) || isset($_POST['audio']) || 1 == 1) {
   if (isset($_GET['audio'])) {
     $stufftosay=trim(str_replace('+',' ',urldecode($_GET['audio'])));
   } else if (isset($_POST['audio'])) {
     $stufftosay=trim(str_replace('+',' ',urldecode($_POST['audio'])));
   } 
   if ($stufftosay == '') {
     if (isset($_GET['iam'])) {
     $stufftosay='Player ' . $_GET['iam'] . ', your clue is ' . trim(substr($w10d, strlen(explode(' ',$w10d)[0]))) . '. ' . $h1itprefix . '. Your clue is ' . trim(substr($w10d, strlen(explode(' ',$w10d)[0]))) . '.';
     } else if (isset($_POST['iam'])) {
     $stufftosay='Player ' . $_POST['iam'] . ', your clue is ' .trim(substr($w10d, strlen(explode(' ',$w10d)[0]))) . '. ' . $h1itprefix . '. Your clue is ' . trim(substr($w10d, strlen(explode(' ',$w10d)[0]))) . '.';
     } else {
     $stufftosay='Player, your clue is ' . trim(substr($w10d, strlen(explode(' ',$w10d)[0]))) . '. ' . $h1itprefix . '. Your clue is ' . trim(substr($w10d, strlen(explode(' ',$w10d)[0]))) . '.';
     }
   } else if (isset($_GET['doaudio'])) {
     if ($_GET['doaudio'] != '') {
       $stufftosay='Player ' . $_GET['doaudio'] . ', your clue is ' . trim(substr($w10d, strlen(explode(' ',$w10d)[0]))) . '. ' . $h1itprefix . '. Your clue is ' . trim(substr($w10d, strlen(explode(' ',$w10d)[0]))) . '.';
     }
   }
   if ($stufftosay != '') {
     $formstufftosay='<input id=audio name=audio type=hidden value="' . $stufftosay . '"></input>';
     while (file_exists('what_is_the_english_word.blurb')) {
       sleep(2);
     }
     file_put_contents('what_is_the_english_word.blurb', '');
     if (strpos($stufftosay, "Player,") === false && ($_GET['audio'] != '' && $_GET['doaudio'] != '')) { exec('say "' . $stufftosay . '"');  }
     if (file_exists('what_is_the_english_word.blurb')) {
       unlink('what_is_the_english_word.blurb');
     }
   }   
  }
  if ($stufftosay != '' && (isset($_GET['andthatisit']) || isset($_POST['andthatisit']))) {
    exit;
  }
  }
  }
  
   if ($stufftosay == '') {
     if (isset($_GET['iam'])) {
     $stufftosay='Player ' . $_GET['iam'] . ', your clue is ' . trim(substr($w10d, strlen(explode(' ',$w10d)[0]))) . '. ' . $h1itprefix . '. Your clue is ' . trim(substr($w10d, strlen(explode(' ',$w10d)[0]))) . '.';
     } else if (isset($_POST['iam'])) {
     $stufftosay='Player ' . $_POST['iam'] . ', your clue is ' .trim(substr($w10d, strlen(explode(' ',$w10d)[0]))) . '. ' . $h1itprefix . '. Your clue is ' . trim(substr($w10d, strlen(explode(' ',$w10d)[0]))) . '.';
     } else {
     $stufftosay='Player, your clue is ' . trim(substr($w10d, strlen(explode(' ',$w10d)[0]))) . '. ' . $h1itprefix . '. Your clue is ' . trim(substr($w10d, strlen(explode(' ',$w10d)[0]))) . '.';
     }
   }
  
  echo "<html>
<head><title>What Is The English Word - RJM Programming - February, 2022</title>
<meta id='myviewport' name='viewport' content='width=device-width, initial-scale=1, minimum-scale=0.1, maximum-scale=8, user-scalable=yes' >
<style>
  #subm:active { background-color:orange; }
  #subm:focus { background-color:lightgreen; }
</style>
<script type='text/javascript' src='apple_script_url.js'></script>
<script type='text/javascript'>
 var adoaudio='';
 var donelist='';
 var localhostvalid=false;
 var imgw=-1;
 var imgh=-1;
 var ywoisme=null;
 var wast='HTTP://localhost:8888/what_is_the_english_word.php (MAMP)';
 var hlbit='HTTP://localhost:8888/what_is_the_english_word.php';
 
 if (('' + localStorage.getItem('what_is_the_english_word')).replace(/^null$/g,'') != '') {
   hlbit=localStorage.getItem('what_is_the_english_word');
 }
 
 function relocalize() {
   var onewast=wast.split(' ')[0];
   if (document.getElementById('asay').title.indexOf('did not find, ') != -1) {
     onewast=document.getElementById('asay').split('did not find, ')[1].split(' ')[0];
   }
   var pwast=prompt('Tell me where what_is_the_english_word.php is located in a macOS local web server with access to say command line commnd.', onewast);
   if (pwast == null) { pwast=''; }
   if (pwast != '' && pwast != onewast && pwast.indexOf('localhost') >= 7) {
     if (pwast.toLowerCase().indexOf('.php') == -1) { if (pwast.slice(-1) == '/') { pwast+='what_is_the_english_word.php';  } else { pwast+='/what_is_the_english_word.php';  }  }
      if (('' + localStorage.getItem('what_is_the_english_word')).replace(/^null$/g,'') != '') {
       localStorage.removeItem('what_is_the_english_word');
       localStorage.setItem('what_is_the_english_word', pwast);
      }
      location.href=document.URL;
   }
 }
 
 function isitnum(event) {
  if (eval('' + event.keyCode) >= 48 && eval('' + event.keyCode) <= 57) {
    top.setgl(eval(-48 + eval('' + event.keyCode)));
    return false;
  }
  return true;
 }
 
 function presetopt(theclue) {
  if (('' + location.hash).replace('#','') != '') {
   var honeis=document.getElementsByTagName('h1');
   var ablurb=((honeis[0].innerText || honeis[0].contentWindow || honeis[0].contentDocument)).split('?')[0] + '?';
   top.setopt(location.hash.replace('#',''), ablurb + '  Clue: ' + theclue);
  }
 }
 
 function newh1(inin) {
   var theclue='';
   //alert(location.hash.replace('#',''));
   var spansare=document.getElementsByTagName('span');
   var honeis=document.getElementsByTagName('h1');
   var ablurb=((honeis[0].innerText || honeis[0].contentWindow || honeis[0].contentDocument)).split('?')[0] + '?';
   //alert(ablurb);
   for (var iuh=0; iuh<spansare.length; iuh++) {
     if (spansare[iuh].innerHTML.indexOf('&nbsp;&nbsp;') != -1 && spansare[iuh].innerHTML.indexOf('...') != -1) { theclue=spansare[iuh].innerHTML.split('&nbsp;&nbsp;')[1].split('...')[0].trim();  }
   }
   //alert(theclue);
   top.setopt(location.hash.replace('#',''), ablurb + '  Clue: ' + theclue);
   return inin;
 }
 
 function onf(ino, lh) {
   if (lh != '' && window.top) {
     if (top.document.getElementById('isel' + lh)) {
       top.document.getElementById('isel' + lh).style.display='inline-block';
     }
   }
 }
 
 function maybestatusaudio(isclick) {
     //alert((document.getElementsByTagName('h4')[0].innerText || document.getElementsByTagName('h4')[0].contentWindow || document.getElementsByTagName('h4')[0].contentDocument));
   if (document.URL.indexOf('doaudio=') != -1) {
     //alert((document.getElementsByTagName('h4')[0].innerText || document.getElementsByTagName('h4')[0].contentWindow || document.getElementsByTagName('h4')[0].contentDocument));
     if (document.URL.indexOf('localhost') == -1 || !isclick) {
     //alert((document.getElementsByTagName('h4')[0].innerText || document.getElementsByTagName('h4')[0].contentWindow || document.getElementsByTagName('h4')[0].contentDocument).replace(/\\\"/g,''));
     if (donelist.indexOf('' + (document.getElementsByTagName('h4')[0].innerText || document.getElementsByTagName('h4')[0].contentWindow || document.getElementsByTagName('h4')[0].contentDocument).replace(/\\\"/g,'')) == -1) {
     donelist+='' + (document.getElementsByTagName('h4')[0].innerText || document.getElementsByTagName('h4')[0].contentWindow || document.getElementsByTagName('h4')[0].contentDocument).replace(/\\\"/g,'');
     //alert('HTTP://localhost:8888/what_is_the_english_word.php?audio=' + encodeURIComponent((document.getElementsByTagName('h4')[0].innerText || document.getElementsByTagName('h4')[0].contentWindow || document.getElementsByTagName('h4')[0].contentDocument).replace(/\\\"/g,'')));
     xwoisme=window.open(hlbit + '?doaudio=' + (('' + location.hash).replace('#','') + '1').substring(0,1) + '&audio=' + encodeURIComponent((document.getElementsByTagName('h4')[0].innerText || document.getElementsByTagName('h4')[0].contentWindow || document.getElementsByTagName('h4')[0].contentDocument).replace(/\\\"/g,'')),'_blank','top=250,left=50,width=50,height=50');
     setTimeout(xwoismeclose, 5000);
     }
     }
   }
   return true;
 }
 
 function xwoismeclose() {
   xwoisme.close();
   xwoisme=null;
 }
 
 function maybeaudio(isclick) {
   //alert(56);
   if (!isclick) {
     adoaudio='&doaudio=" . $_GET['doaudio'] . "';
   }
   if (!isclick && document.getElementById('speaker').innerHTML != '' && !document.getElementById('audio') && document.getElementById('prespeaker')) {
   //alert(156);
     document.getElementById('prespeaker').innerHTML='<input id=audio name=audio type=hidden value=\"" . $stufftosay . "\"></input>';
     //if (document.getElementById('speaker').innerHTML == '') { document.getElementById('prespeaker').innerHTML='<input id=doaudio name=doaudio type=hidden value=\"' + (('' + location.hash).replace('#','') + '1').substring(0,1) + '\"></input>';  }
   }
   //alert(\"" . $stufftosay . "\");
   if ((window.self !== window.top && document.URL.indexOf('doaudio=') != -1) || (document.getElementById('speaker').innerHTML != '' && document.getElementById('audio'))) {
   //alert(document.URL);
     if (document.getElementById('audio')) {
     document.getElementById('audio').value=\"" . $stufftosay . "\"; 
     }
     if (document.URL.indexOf('localhost') == -1 || !isclick) {
     if (donelist.indexOf(\"" . str_replace('Player 1, ','',str_replace('Player ' . $_GET['doaudio'] . ', ','',str_replace('Player,','',$stufftosay))) . "\") == -1) {
     var predl='Player ' + (('' + location.hash).replace('#','') + '1').substring(0,1) + ', ' + \"" . str_replace('Player ' . $_GET['doaudio'] . ', ','',str_replace('Player,','',$stufftosay)) . "\";
     if ((predl.indexOf('Player,') == -1 || window.self === window.top) && predl.indexOf('Player " . $_GET['doaudio'] . "') != -1) {
     //alert(predl);
     donelist+='Player ' + (('' + location.hash).replace('#','') + '1').substring(0,1) + ', ' + \"" . str_replace('Player ' . $_GET['doaudio'] . ', ','',str_replace('Player,','',$stufftosay)) . "\";
     var zwoisme=window.open(hlbit + '?doaudio=' + (('' + location.hash).replace('#','') + '1').substring(0,1) + '&audio=' + encodeURIComponent('Player ' + (('' + location.hash).replace('#','') + '1').substring(0,1) + ', ' + \"" . str_replace('Player ' . $_GET['doaudio'] . ', ','',str_replace('Player,','',$stufftosay)) . "\"),'_blank','top=250,left=50,width=50,height=50');
     zwoisme.close();
     }
     }
     }
   }
   return true;
 }
 
 function lhostlook() {
   if (hlbit != 'HTTP://localhost:8888/what_is_the_english_word.php' && hlbit != 'HTTP://localhost:8888/what_is_the_english_word.php (MAMP)') {
     document.getElementById('asay').title=document.getElementById('asay').title.replace('HTTP://localhost:8888/what_is_the_english_word.php (MAMP)', hlbit).replace('HTTP://localhost:8888/what_is_the_english_word.php', hlbit);
   }
   if (document.URL.indexOf('localhost') == -1) {
     var midbit='' + '" . $midbit . "';
        if (!navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) && ('' + inv).indexOf('-') != -1) { 
     ywoisme=window.open(hlbit + '?imagetest=imagetest' + midbit + '.jpg','_blank','top=250,left=50,width=50,height=50');
     setTimeout(yw, 2000); //ywoisme.close();
        }
   }
 }
 
 function yw() {
   if (ywoisme.closed) {
     console.log('found');
     document.getElementById('asay').title=document.getElementById('asay').title.replace('Will be trying ', 'Will be trying the found ');
   } else {
     document.getElementById('asay').title=document.getElementById('asay').title.replace('Will be trying ', 'Will be trying, but did not find, ');
     console.log('not found');
     ywoisme.close();
   }
   ywoisme=null;
 }
</script>
</head><body style='" . $bc . "' onload=\" lhostlook();  document.getElementById('youranswer').focus(); if (window.self !== window.top) { maybeaudio(0); presetopt('" . substr($w10d, strlen(explode(' ',$w10d)[0])) . "'); } \">
<h1" . str_replace(",&nbsp;</span>W",", </span>w",str_replace(", </span>W",", </span>w",">" . $h1prefix . "What Is <span id=wl>")) . $_GET['length'] . "</span> Letter English Word With \"" . $_GET['letter'] . "\" position " . $_GET['position'] . "<span title='" . substr($w10d, strlen(explode(' ',$w10d)[0])) . "' id=q>?</span></h1>
<h3" . $sh3 . ">RJM Programming <a title='How many players?' style='cursor:pointer;text-decoration:underline;' onclick=\" var hm=prompt('How many players?  Maximum is 9.','1'); if (hm == null) { hm=''; } if (hm.trim().replace('1','') != '') { location.href=document.URL.split('?')[0].split('#')[0] + '?fortyeight=12&numplayers=' + encodeURIComponent((hm + ' ').substring(0,1).trim()) + adoaudio;  } \">&#10133;</a> February, 2022&nbsp;&nbsp;" . $speakerblurb . "</h3>
<h4>" . $dblurb . "</h4>
<form onsubmit='return maybeaudio(1);' style='font-size:" . $fortyeight . "px;background-color:pink;padding: 5 5 5 5;width:100%;text-align:center;' method=GET action=./what_is_the_english_word.php>
<input type=hidden name=score value=" . $score . "></input>" . $fortyeighti . "
<input type=hidden name=theanswer value=" . explode(' ',$w10d)[0] . "></input>
<input type=hidden name=explanation value='" . "Sorry, last answer for " . $_GET['length'] . " Letter English Word With \"" . $_GET['letter'] . "\" at position " . $_GET['position'] . " with clue \"" . trim(substr($w10d, strlen(explode(' ',$w10d)[0])))  . "\" was " . "'></input>
<input type=hidden name=goes value=" . $goes . "></input><span style=font-size:" . $fortyeight . "px;>&nbsp;&nbsp;" . substr($w10d, strlen(explode(' ',$w10d)[0])) . " ... &nbsp;&nbsp;</span><input onclick=\" onf(this,('' + location.hash).replace('#',''));\" style=display:inline-block;font-size:" . $fortyeight . "px;width:30%; type=text" . $ob . $okp . " id=youranswer name=youranswer placeholder='" . $wz . "' value=''></input><span>&nbsp;&nbsp;</span><input id=subm onclick=\" this.style.cursor='progress'; document.body.style.cursor='progress';  \" style=display:inline-block;font-size:" . $fortyeight . "px; type=submit value='" . $aic . "'></input>
<div id=prespeaker style=display:none;>" . $formstufftosay . "</div><div id=speaker style=display:none;>" . $divstufftosay . "</div><div id=dname style=display:none;>" . $ddname . "</div></form>
<div id=fdiv></div></body></html>
";
  
} else {
 ask();
}


?>
