<?php
// emoji_clothing_game.php
// July, 2023
// RJM Programming
// Using experimental_drag_and_drop.htm for Emoji Clothing Game
// https://www-rjmprogramming-com-au.translate.goog/HTMLCSS/emoji_clothing_game.php?_x_tr_sch=http&_x_tr_sl=en&_x_tr_tl=de&_x_tr_hl=en

 $hlang='';
 if (isset($_GET['lang'])) {
   $hlang=strtolower(explode('_', explode('-', str_replace('+', ' ', urldecode($_GET['lang'])))[0])[0]);
 } else if (isset($_POST['lang'])) {
   $hlang=strtolower(explode('_', explode('-', str_replace('+', ' ', urldecode($_POST['lang'])))[0])[0]);
 }
 
 if (strlen($hlang) >= 2 && strlen($hlang) < 10) {
   if (isset($_GET['top']) && isset($_GET['left']) && isset($_GET['width']) && isset($_GET['height'])) {
   if (5 == 5) {
   echo '<html><body onload="top.window.open(' . "'//www-rjmprogramming-com-au.translate.goog/HTMLCSS/emoji_clothing_game.php?_x_tr_sch=http&_x_tr_sl=en&_x_tr_tl=" . $hlang . "&_x_tr_hl=en','_blank','top=" . $_GET['top'] . ",left=" . $_GET['left'] . ",width=" . $_GET['width'] . ",height=" . $_GET['height'] . "');" . '"></body></html>';
   exit;
   }
   } else {
   header('Location: //www-rjmprogramming-com-au.translate.goog/HTMLCSS/emoji_clothing_game.php?_x_tr_sch=http&_x_tr_sl=en&_x_tr_tl=' . $hlang . '&_x_tr_hl=en');
   exit;
   }
 }

 $scorebit='';
 $recallit='./emoji_clothing_game.php';
 if (strpos($_SERVER['SERVER_NAME'], 'rjmprogramming.com.au') === false) {
   if (strpos($_SERVER['SERVER_NAME'], 'localhost') === false) {
     echo $_SERVER['SERVER_NAME'];
     exit;
   }
 }
 if (isset($_GET['score']) && isset($_GET['secs'])) {
   $scorebit="Score " . explode('.',$_GET['score'])[0] . '/' . $_GET['secs'];
   if (strpos($recallit, "?") !== false) {
   $recallit.='&score=' . explode('.',$_GET['score'])[0] . '/' . $_GET['secs'];
   } else {
   $recallit.='?score=' . explode('.',$_GET['score'])[0] . '/' . $_GET['secs'];
   }
 }
 
 // Thanks to https://emojipedia.org/objects
 $tandh='<div class="mb-4" data-emoji-category="clothing-appearance"><h2 class="text-left mb-3">Clothing &amp; Appearance</h2><div class="flex flex-row flex-wrap justify-center md:justify-start items-center"><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="party" href="/ribbon">🎀</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="party" href="/reminder-ribbon">🎗️</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="study" href="/glasses">👓</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="walk" href="/sunglasses">🕶️</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="work" href="/goggles">🥽</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="work" href="/lab-coat">🥼</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="work" href="/safety-vest">🦺</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="meeting" href="/necktie">👔</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="sport" href="/t-shirt">👕</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="walk" href="/jeans">👖</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="recuperation" href="/scarf">🧣</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="cleaning" href="/gloves">🧤</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="walk" href="/coat">🧥</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="walk" href="/socks">🧦</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="party" href="/dress">👗</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="wedding" href="/kimono">👘</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="wedding" href="/sari">🥻</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="sport" href="/one-piece-swimsuit">🩱</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="dressing" href="/briefs">🩲</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="walk" href="/shorts">🩳</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="swimming" href="/bikini">👙</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="dressing" href="/womans-clothes">👚</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="oops" title="ceremony" href="/folding-hand-fan">🪭</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="shopping" href="/purse">👛</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="shopping" href="/handbag">👜</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="work" href="/clutch-bag">👝</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="shopping" href="/shopping-bags">🛍️</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="holiday" href="/backpack">🎒</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="holiday" href="/thong-sandal">🩴</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="walk" href="/mans-shoe">👞</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="sport" href="/running-shoe">👟</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="work" href="/hiking-boot">🥾</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="walk" href="/flat-shoe">🥿</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="party" href="/high-heeled-shoe">👠</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="dressing" href="/womans-sandal">👡</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="dancing" href="/ballet-shoes">🩰</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="meeting" href="/womans-boot">👢</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="oops" title="dressing" href="/hair-pick">🪮</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="party" href="/crown">👑</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="party" href="/womans-hat">👒</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="party" href="/top-hat">🎩</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="ceremony" href="/graduation-cap">🎓</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="sport" href="/billed-cap">🧢</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="work" href="/military-helmet">🪖</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="work" href="/rescue-workers-helmet">⛑️</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="prayer" href="/prayer-beads">📿</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="party" href="/lipstick">💄</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="wedding" href="/ring">💍</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="ceremony" href="/gem-stone">💎</a><a class="Emoji_emoji__P7Lkz __variable_2bc503 " data-src="" title="walk" href="/white-cane">🦯</a></div></div>';
 
 $ideanum=1;
 $nineideas=[''];
 $nineideassofar=" \n";
 $choosefrom=explode('</a>', $tandh);
 $delm="\n";
 
 while (sizeof($nineideas) < 9) {
    $thisroom=$delm;
    while (strpos($nineideassofar, ' ' . $thisroom) !== false) {
     $rv=rand(0, (-1 + sizeof($choosefrom)));
     if (strpos($choosefrom[$rv], '"oops"') !== false) {
     $thisroom=$delm;
     } else {
     $thisemoji=explode('>', $choosefrom[$rv])[-1 + sizeof(explode('>', $choosefrom[$rv]))]; // . substr(explode('"', explode(' href="', $choosefrom[$rv])[1])[0],1);
     $thisroom=explode('"', explode(' title="', $choosefrom[$rv])[1])[0];
     }
    }
    //echo "774";
    //exit;
    if ($ideanum == 1) {
    //echo "77";
    //exit;
      $nineideassofar="1 " . $thisroom . "\n" . $thisemoji . "\n";
      $nineideas[0]=$nineideassofar; //"1 " . $thisroom . "\n" . $thisemoji; 
      //echo '' . $nineideas[0];
      //exit;
      //$nineideassofar='' . $nineideas[-1 + $ideanum];
      $delm=substr($nineideassofar,2);
      $ideanum++;
    } else {
      array_push($nineideas, '' . $ideanum . " " . $thisroom . "\n" . $thisemoji . "\n");
      $nineideassofar.="\n" . $nineideas[-1 + $ideanum];
      $ideanum++;
    }
 }
 $typedescstuff=$nineideassofar;
 //echo str_replace("\n","<br>",$typedescstuff);
 //exit;
 
 if (5 == 7) {
 // Thanks to https://www.enneagraminstitute.com/type-descriptions and https://www.psychologyjunkie.com/enneagram-famous-people/
 $typedescstuff="1 MERCURY

2 VENUS

3 EARTH
Moon#//upload.wikimedia.org/wikipedia/commons/thumb/f/f7/Far_side_of_the_Moon.png/220px-Far_side_of_the_Moon.png

4 MARS
Phobos#//upload.wikimedia.org/wikipedia/commons/thumb/5/5c/Phobos_colour_2008.jpg/220px-Phobos_colour_2008.jpg,Deimos#//upload.wikimedia.org/wikipedia/commons/thumb/8/86/NASA-Deimos-MarsMoon-20090221.jpg/220px-NASA-Deimos-MarsMoon-20090221.jpg

5 JUPITER
Io#//upload.wikimedia.org/wikipedia/commons/thumb/c/cc/Io%2C_Earth_%26_Moon_size_comparison.jpg/220px-Io%2C_Earth_%26_Moon_size_comparison.jpg,Europa#//upload.wikimedia.org/wikipedia/commons/thumb/1/1c/Europa_in_natural_color.png/275px-Europa_in_natural_color.png,Ganymede#//upload.wikimedia.org/wikipedia/commons/thumb/7/76/Ganymede%2C_Earth_%26_Moon_size_comparison.jpg/250px-Ganymede%2C_Earth_%26_Moon_size_comparison.jpg,Callisto#//upload.wikimedia.org/wikipedia/commons/thumb/2/2f/Callisto_-_July_8_1979_%2838926064465%29.jpg/220px-Callisto_-_July_8_1979_%2838926064465%29.jpg

6 SATURN
Titan#//upload.wikimedia.org/wikipedia/commons/thumb/f/fe/Titan_in_true_color_by_Kevin_M._Gill.jpg/220px-Titan_in_true_color_by_Kevin_M._Gill.jpg,Iapetus#//upload.wikimedia.org/wikipedia/commons/thumb/c/c9/Iapetus_as_seen_by_the_Cassini_probe_-_20071008.jpg/220px-Iapetus_as_seen_by_the_Cassini_probe_-_20071008.jpg,Rhea#//upload.wikimedia.org/wikipedia/commons/thumb/a/ab/PIA07763_Rhea_full_globe5.jpg/220px-PIA07763_Rhea_full_globe5.jpg,Dione#//upload.wikimedia.org/wikipedia/commons/thumb/d/d0/Dione_in_natural_light_%28cropped%29.jpg/220px-Dione_in_natural_light_%28cropped%29.jpg,Tethys#//upload.wikimedia.org/wikipedia/commons/thumb/b/bc/PIA18317-SaturnMoon-Tethys-Cassini-20150411.jpg/220px-PIA18317-SaturnMoon-Tethys-Cassini-20150411.jpg,Mimas#//upload.wikimedia.org/wikipedia/commons/thumb/b/bc/Mimas_Cassini.jpg/220px-Mimas_Cassini.jpg,Enceladus#//upload.wikimedia.org/wikipedia/commons/thumb/8/83/PIA17202_-_Approaching_Enceladus.jpg/280px-PIA17202_-_Approaching_Enceladus.jpg
 
7 URANUS
Titania#//upload.wikimedia.org/wikipedia/commons/thumb/4/44/Titania_Earth_Moon_Comparison.png/250px-Titania_Earth_Moon_Comparison.png,Oberon#//upload.wikimedia.org/wikipedia/commons/thumb/6/6d/Oberon_in_true_color_by_Kevin_M._Gill.jpg/220px-Oberon_in_true_color_by_Kevin_M._Gill.jpg,Miranda#//upload.wikimedia.org/wikipedia/commons/thumb/e/e1/PIA18185_Miranda%27s_Icy_Face.jpg/220px-PIA18185_Miranda%27s_Icy_Face.jpg,Cressida#//upload.wikimedia.org/wikipedia/commons/2/2d/Cressida_enhanced_Southern_skies-2.png,Umbriel#//upload.wikimedia.org/wikipedia/commons/thumb/7/72/Umbriel_Earth_Moon_Comparison.png/250px-Umbriel_Earth_Moon_Comparison.png,Ariel#//upload.wikimedia.org/wikipedia/commons/thumb/9/92/Ariel_Earth_Moon_Comparison.png/250px-Ariel_Earth_Moon_Comparison.png

8 NEPTUNE
Naiad#//upload.wikimedia.org/wikipedia/commons/thumb/f/f3/Naiad_Voyager.png/220px-Naiad_Voyager.png,Thalassa#//upload.wikimedia.org/wikipedia/commons/thumb/5/5c/Neptune_Trio.jpg/220px-Neptune_Trio.jpg,Despina#//upload.wikimedia.org/wikipedia/commons/thumb/5/5f/Despina.jpg/220px-Despina.jpg,Galatea#//upload.wikimedia.org/wikipedia/commons/thumb/d/d8/Galatea_moon.jpg/220px-Galatea_moon.jpg,Larissa#//upload.wikimedia.org/wikipedia/commons/thumb/5/5b/Larissa_1.jpg/220px-Larissa_1.jpg,Proteus#//upload.wikimedia.org/wikipedia/commons/thumb/8/83/Proteus_%28Voyager_2%29.jpg/220px-Proteus_%28Voyager_2%29.jpg,Triton#//upload.wikimedia.org/wikipedia/commons/thumb/a/a6/Triton_moon_mosaic_Voyager_2_%28large%29.jpg/300px-Triton_moon_mosaic_Voyager_2_%28large%29.jpg,Nereid#//upload.wikimedia.org/wikipedia/commons/b/b0/Nereid-Voyager2.jpg,Halimede#//upload.wikimedia.org/wikipedia/commons/thumb/0/02/Halimede.jpg/250px-Halimede.jpg,Sao#//upload.wikimedia.org/wikipedia/commons/thumb/7/7a/Sao_VLT-FORS1_2002-09-03_annotated.gif/250px-Sao_VLT-FORS1_2002-09-03_annotated.gif,Laomedeia#//upload.wikimedia.org/wikipedia/commons/thumb/0/05/Laomedeia_VLT-FORS1_2002-09-03_annotated.gif/250px-Laomedeia_VLT-FORS1_2002-09-03_annotated.gif,Psamathe#//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Psamathe_feat.jpg/250px-Psamathe_feat.jpg,Neso#//upload.wikimedia.org/wikipedia/commons/thumb/f/f0/Neso_VLT-FORS1_2002-09-03_annotated.gif/250px-Neso_VLT-FORS1_2002-09-03_annotated.gif

9 PLUTO
Charon#//upload.wikimedia.org/wikipedia/commons/thumb/2/2e/Charon_in_True_Color_-_High-Res.jpg/220px-Charon_in_True_Color_-_High-Res.jpg,Styx#//upload.wikimedia.org/wikipedia/commons/thumb/3/38/Styx_%28moon%29.jpg/220px-Styx_%28moon%29.jpg,Nix#//upload.wikimedia.org/wikipedia/commons/thumb/5/51/Nix_best_view.jpg/220px-Nix_best_view.jpg,Kerberos#//upload.wikimedia.org/wikipedia/commons/thumb/2/23/Kerberos_%28moon%29.jpg/220px-Kerberos_%28moon%29.jpg,Hydra#//upload.wikimedia.org/wikipedia/commons/thumb/9/94/Hydra_reprocessed.png/220px-Hydra_reprocessed.png";

  }

  $thisis=file_get_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'emoji_clothing_game.php');
  $lastotherde='';
  $categorizations=[];
  $wikistuffs=explode("\n", $typedescstuff);
  $wikidesignations=[];
  $wikidescriptions=[];
  $crandlist='';
  $randlist=[];
  $thisde='';
  $otherde='';
  for ($i=0; $i<sizeof($wikistuffs); $i++) {
    if (trim($wikistuffs[$i]) == '') {
    if ($thisde != '') {
    array_push($categorizations, $thisde);
    //array_push($wikidesignations, $thisde);
    //array_push($wikidescriptions, '');
    }
    $thisde='';
    } else if (trim($wikistuffs[$i]) != '') {
    if (trim($wikistuffs[$i]) != '' && trim($wikistuffs[$i]) == strtolower(trim($wikistuffs[$i])) && strpos($wikistuffs[$i], ' ') !== false && substr(($wikistuffs[$i] . ' '),0,1) !== ' ') {
    $thisde=substr($wikistuffs[$i],2);
    //echo $thisde;
    //exit;
    } else if ($thisde != '') {
    $otherde=$thisde; // . ' ... ' . $wikistuffs[$i];
    array_push($categorizations, $otherde);
    $thisde='';
    //} else {    
    if (trim($otherde) != '') {
    $cwikistuffs=explode(',', trim($wikistuffs[$i]));
    for ($ii=0; $ii<sizeof($cwikistuffs); $ii++) {
    //echo $cwikistuffs[0];
    //exit;
    if (1 == 2) {
    if (strpos(($cwikistuffs[$ii] . ''), ' ') === false) {
       $bio=file_get_contents('http://en.wikipedia.org/wiki/' . str_replace(' ','_',explode('#',$cwikistuffs[$ii])[0]) . '');
       $biois=explode('<img src="', $bio);
       if (sizeof($biois) > 1) {
       //file_put_contents('x.x', file_get_contents('x.x') . "\n" . 'http://en.wikipedia.org/wiki/' . str_replace(' ','_',explode('#',$cwikistuffs[$ii])[0]) . '_(moon)');
         $thisis=str_replace(($cwikistuffs[$ii] . ''), $cwikistuffs[$ii] . '' . explode('"', $biois[1])[0], $thisis);
         //file_put_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'emoji_clothing_game.php', $thisis); 
         //$cwikistuffs[$ii].='' . explode('"', $biois[1])[0];
       }
    } else if (strpos($cwikistuffs[$ii], ' ') !== false) {
       $bio=file_get_contents('http://en.wikipedia.org/wiki/' . str_replace(' ','_',$cwikistuffs[$ii]) . '');
       $biois=explode('<img src="', $bio);
       if (sizeof($biois) > 1) {
         $thisis=str_replace($cwikistuffs[$ii], $cwikistuffs[$ii] . '#' . explode('"', $biois[1])[0], $thisis);
         //file_put_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'emoji_clothing_game.php', $thisis); 
         //$cwikistuffs[$ii].='#' . explode('"', $biois[1])[0];
       }
    }
    }
    array_push($wikidesignations, $cwikistuffs[$ii]);
    array_push($wikidescriptions, $otherde);
    }
    $otherde='';
    }
    }
    }
  }
  
  //echo "1 " . sizeof($wikidesignations) . ' ' . sizeof($categorizations) . ' ' . sizeof($wikidescriptions);
  //exit;
  
  $randmode=rand(0,1);
  $goodlist=',Mercury,Venus,';
  $badlist=',Mercury,Venus,';
  
  while (strlen($goodlist) == strlen($badlist)) {
  $goodlist=',Mercury,Venus,';
  $badlist=',Mercury,Venus,';
  
  $correctans=rand(0,8);
  $sofar=';';
  for ($i=0; $i<9; $i++) {
    $j=rand(0, (-1 + sizeof($wikidesignations)));
    if ($crandlist == '') {
      $crandlist='' . $j;
      $sofar.=$wikidescriptions[$j] . ';';
      if (strpos($goodlist, $wikidescriptions[$j]) === false) {   $goodlist.=$wikidescriptions[$j] . ',';     }
    } else if (strpos((',' . $crandlist . ','), (',' . $j . ',')) !== false) { // || strpos($sofar, ';' . $wikidescriptions[$j] . ';') !== false) {
      while (strpos((',' . $crandlist . ','), (',' . $j . ',')) !== false) { // || strpos($sofar, ';' . $wikidescriptions[$j] . ';') !== false) {
        $j=rand(0, (-1 + sizeof($wikidesignations)));
      }
      $crandlist.=',' . $j;
      $sofar.=$wikidescriptions[$j] . ';';
      if (strpos($goodlist, $wikidescriptions[$j]) === false) {   $goodlist.=$wikidescriptions[$j] . ',';     }
    } else {
      if (strpos($sofar, ';' . $wikidescriptions[$j] . ';') !== false) { $badlist.=$wikidescriptions[$j] . ','; }
      $crandlist.=',' . $j;
      $sofar.=$wikidescriptions[$j] . ';';
      if (strpos($goodlist, $wikidescriptions[$j]) === false) {   $goodlist.=$wikidescriptions[$j] . ',';     }
    }
  }
  }  
  
  $sofar=';';
  $ccrandlist='';
  for ($i=1; $i<=9; $i++) {
    $j=rand(1, 9);
    if ($ccrandlist == '') {
      $ccrandlist='' . $j;
      $sofar.='' . $j . ';';
    } else if (strpos((',' . $ccrandlist . ','), (',' . $j . ',')) !== false) {
      while (strpos((',' . $ccrandlist . ','), (',' . $j . ',')) !== false) {
        $j=rand(1, 9);
      }
      $ccrandlist.=',' . $j;
      $sofar.='' . $j . ';';
    } else {
      $ccrandlist.=',' . $j;
      $sofar.='' . $j . ';';
    }
  }
  
  $randlist=explode(',', "0,1,2,3,4,5,6,7,8"); //$crandlist);
  //$randlist=explode(',', $crandlist);
  //$rrandlist=explode(',', $ccrandlist);
  $rrandlist=explode(',', "1,2,3,4,5,6,7,8,9"); //$crandlist);

  
  $callbackurl='./emoji_clothing_game.php';
  if (strpos($_SERVER['SERVER_NAME'], 'rjmprogramming.com.au') === false) {
   if (strpos($_SERVER['SERVER_NAME'], 'localhost') === false) {
     echo $_SERVER['SERVER_NAME'];
     exit;
   }
  }
  $templategame=file_get_contents('./experimental_drag_and_drop.htm');

  for ($i=1; $i<=9; $i++) {
    $templategame=str_replace('>' . $i . '<', '>##' . $rrandlist[-1 + $i] . '<', $templategame);
  }
  
  $templategame=str_replace('>##', '>', $templategame);
  $templategame=str_replace('<table ', '<table cellspacing=8 cellpadding=8 ', $templategame);

  $templategame=str_replace('</h4>', '<input type=hidden id="callback" value="' . $callbackurl . '"></input></h4>', $templategame);
  $templategame=str_replace('>Game<', '>Emoji Clo' . 'thing Game <font size=1>... drag to matching correct activity type or emoji to score</font><', $templategame);
  $templategame=str_replace('></h3>', '>' . $scorebit . '</h3>', $templategame);
  $thepsource=explode('f0;">', explode("</p>", $templategame)[0])[-1 + sizeof(explode('f0;">', explode("</p>", $templategame)[0]))];

  $templategame=str_replace(', 2023<', ', 2023 ... thanks to <a target=_blank href=https://wikipedia.org>Wikipedia</a><', $templategame);
  $templategame=str_replace('>Reset example<', ' style="display:none;">Reset example<', $templategame);
  
  //echo $crandlist . "\n" . $thepsource . "\n" . $correctans . "\n";
  //exit;
  //echo $crandlist . "\n";
  //echo "" . $randlist[$correctans] . "\n" . $wikidescriptions[$correctans] . "\n" . $wikidesignations[$correctans];
  //exit;
  
  //file_put_contents('x.x', '' . $randmode . "\n" . $crandlist . "\n" . $thepsource . "\n" . $correctans . "\n" . $crandlist . "\n" . $randlist[$correctans] . "\n" . $wikidescriptions[$correctans] . "\n" . $wikidesignations[$correctans]);
  
  if ($randmode == 0) {  // designation up top and descriptions in drop zone
    $jkh=0;
    while (strpos($badlist, ',' . explode(' ... ', $wikidescriptions[$correctans])[0] . ',') !== false) {
      $jkh++;
      $correctans=rand(0,8);
      if ($jkh > 20) { header('Location: ' . $recallit); exit;   }
    }
    $templategame=str_replace('>' . (1 + $correctans) . '<', ' data-answer="' . explode(' ... ', $wikidescriptions[$correctans])[0] . '">' . $categorizations[$correctans] . '<', $templategame);
 if (1 == 1) {
    if (strpos($wikidesignations[$correctans], '#') !== false) {
    $templategame=str_replace(' style="background-color:#f0f0f0;"', ' ', $templategame);
    $templategame=str_replace('>' . $thepsource . '<', ' data-answer="' . explode(' ... ', $wikidescriptions[$correctans])[0] . '" style="background-color:#f0f0f0;background:URL(' . str_replace('http:','',explode('#', $wikidesignations[$correctans])[1]) . '); background-repeat: no-repeat; background-size: contain;background-position: center right;border:5px dashed pink;" alt="f0;">&nbsp;<br>' . explode('#', $wikidesignations[$correctans])[0] . '<br>&nbsp;<', $templategame);
    } else if (1 == 1) {
    $templategame=str_replace('>' . $thepsource . '<', ' data-answer="' . explode(' ... ', $wikidescriptions[$correctans])[0] . '">' . explode('#', $wikidesignations[$correctans])[0] . '<', $templategame);
    } else {
    $templategame=str_replace('>' . $thepsource . '<', ' data-answer=" ">' . explode('#', $wikidesignations[$correctans])[0] . '<', $templategame);
    }
 }
    for ($i=1; $i<=9; $i++) {
       if ((-1 + $i) != $correctans) {
    if (3 == 7) {
    $templategame=str_replace('>' . $i . '</td', ' data-answer="' . explode(' ... ', $categorizations[-1 + $i])[0] . '">' . $categorizations[-1 + $i] . '</td', $templategame);
    } else {
    $templategame=str_replace('>' . $i . '</td', ' data-answer="">' . $categorizations[-1 + $i] . '</td', $templategame);
    }
       } else {
    $templategame=str_replace('>' . $i . '</td', ' data-answer="' . explode(' ... ', $wikidescriptions[-1 + $i])[0] . '">' . $categorizations[-1 + $i] . '</td', $templategame);
       }
    }
    //file_put_contents('x.x', $templategame);
    $fgds=explode(' data-answer=" "', explode('<table', $templategame)[1]);
    if (sizeof($fgds) == 2) {
    //echo "N" . sizeof($fgds) . ' ' . explode('<', $fgds[1])[0];
    //exit;
    $templategame=str_replace(' data-answer=" "', ' data-answer="' . explode('<', substr($fgds[1],1))[0] . '"', $templategame);
    } //else if (sizeof($fgds) > 2) {
    //echo "n" . sizeof($fgds);
    //exit;
    //}
    $templategame=str_replace(' contenteditable=', ' data-contenteditable=', $templategame);
    echo str_replace('background-color:#f0f0f0;', 'background-color:#ffffbf; border-radius:5px; text-shadow:-1px 1px 1px #ff2d95;  ', str_replace(' dotted green;', ' dotted green; border-radius:5px; background-color:#D7E5F0;  text-shadow:-1px 1px 1px #ff2d95;  text-align:center; ', str_replace(' 2em', ' 1em', str_replace('0.5rem;', '0.2rem; margin-top:-20px; text-align:center; ', str_replace('Correct answer was ', 'One answer we thought of was ', str_replace('display:NONE;', 'display:inline-block;', str_replace('<head>', '<head><meta charset="UTF-8"/>', str_replace('<t' . 'd ', '<t' . 'd translate="yes" ', str_replace(' dotted green;', ' dotted green; font-size:26px; } #source { font-size:40px; ', $templategame)))))))));
  } else { // description up top and designations in drop zone
    while (strpos($badlist, ',' . explode(' ... ', $wikidescriptions[$correctans])[0] . ',') !== false) {
      $jkh++;
      $correctans=rand(0,8);
      if ($jkh > 20) { header('Location: ' . $recallit); exit;   }
    }
    if (strpos($wikidesignations[$correctans], '#') !== false) {
    $templategame=str_replace(' style="background-color:#f0f0f0;"', ' ', $templategame);
    $templategame=str_replace('>' . (1 + $correctans) . '<', ' data-answer="' . explode('#', $wikidesignations[$correctans])[0] . '" style="background-color:#f0f0f0;background:URL(' . str_replace('http:','',explode('#', $wikidesignations[$correctans])[1]) . '); background-repeat: no-repeat; background-size: contain;background-position: center right;" alt="f0;">' . explode('#', $wikidesignations[$correctans])[0] . '<', $templategame);
    } else if (1 == 6) {
    $templategame=str_replace('>' . (1 + $correctans) . '<', ' data-answer="' . explode('#', $wikidesignations[$correctans])[0] . '">' . explode('#', $wikidesignations[$correctans])[0] . '<', $templategame);
    } else {
    $templategame=str_replace('>' . (1 + $correctans) . '<', ' data-answer=" ">' . explode('#', $wikidesignations[$correctans])[0] . '<', $templategame);
    }
    if (strpos($wikidesignations[$correctans], '#') !== false && 1 == 7) {
    $templategame=str_replace('>' . $thepsource . '<', ' data-answer="' . explode('#',$wikidesignations[$correctans])[0] . '" style="background:URL(' . str_replace('http:','',explode('#', $wikidesignations[$correctans])[1]) . '); background-repeat: no-repeat; background-size: contain;background-position: center right;border:5px dashed pink;" alt="f0;">&nbsp;<br>' . $wikidescriptions[$correctans] . '<br>&nbsp;<', $templategame);
    } else {
    $templategame=str_replace(' style="border:5px dashed pink;background-color:#f0f0f0;"', ' ', $templategame);
    $templategame=str_replace('>' . $thepsource . '<', ' style="border:5px dashed pink;background-color:#f0f0f0;" data-answer="' . explode('#', $wikidesignations[$correctans])[0] . '">' . $wikidescriptions[$correctans] . '<', $templategame);
    }
    for ($i=1; $i<=9; $i++) {
       if ((-1 + $i) != $correctans) {
    if (strpos($wikidesignations[$randlist[-1 + $i]], '#') !== false) {
    $templategame=str_replace('>' . $i . '</td', ' data-answer="q" style="background:URL(' . str_replace('http:','',explode('#', $wikidesignations[$randlist[-1 + $i]])[1]) . '); background-repeat: no-repeat; background-size: contain;background-position: center right;" alt="f0;">' . explode('#', $wikidesignations[$randlist[-1 + $i]])[0] . '</td', $templategame);
    } else {
    $templategame=str_replace('>' . $i . '</td', ' data-answer="">' . explode('#', $wikidesignations[$randlist[-1 + $i]])[0] . '</td', $templategame);
    }
       }
    }
    //file_put_contents('xx.xx', $templategame);
    $fgds=explode(' data-answer=" "', explode('<table', $templategame)[1]);
    if (sizeof($fgds) == 2) {
    //echo "N" . sizeof($fgds) . ' ' . explode('<', $fgds[1])[0];
    //exit;
    $templategame=str_replace(' data-answer=" "', ' data-answer="' . explode('<', substr($fgds[1],1))[0] . '"', $templategame);
    } //else if (sizeof($fgds) > 2) {
    //echo "n" . sizeof($fgds);
    //exit;
    //}
    $templategame=str_replace(' contenteditable=', ' data-contenteditable=', $templategame);
    echo str_replace('background-color:#f0f0f0;', 'background-color:#ffffbf; border-radius:5px; text-shadow:-1px 1px 1px #ff2d95;  ', str_replace(' dotted green;', ' dotted green; border-radius:5px; background-color:#D7E5F0;  text-shadow:-1px 1px 1px #ff2d95;   text-align:center; ', str_replace(' 2em', ' 1em', str_replace('0.5rem;', '0.2rem; margin-top:-20px; text-align:center; ', str_replace('Correct answer was ', 'One answer we thought of was ', str_replace('display:NONE;', 'display:inline-block;', str_replace('<head>', '<head><meta charset="UTF-8"/>', str_replace(' i' . 'd="source" ', ' i' . 'd="source" translate="yes" ', str_replace(' dotted green;', ' dotted green; font-size:40px; } #source { font-size:26px; ', $templategame)))))))));
  }
  

?>
