<?php
  // cards_usefocus.php
  // Help out cards_usefocus.html
  if (isset($_POST['gamedate']) && isset($_POST['myanswer'])) {
    if ($_POST['myanswer'] == '' && file_exists(strtolower(str_replace("+","_",str_replace(" ","_",str_replace(":","_",str_replace("(","_",str_replace(")","_",urldecode($_POST['gamedate']))))))) . ".html")) {
    $cis=file_get_contents(strtolower(str_replace("+","_",str_replace(" ","_",str_replace(":","_",str_replace("(","_",str_replace(")","_",urldecode($_POST['gamedate']))))))) . ".html");
    unlink(strtolower(str_replace("+","_",str_replace(" ","_",str_replace(":","_",str_replace("(","_",str_replace(")","_",urldecode($_POST['gamedate']))))))) . ".html");
    echo "<html><head><title>Listening for 1 seconds ...</title></head><body><p style=display:none;>" . $cis . "</p></body></html>";
    } else if ($_POST['myanswer'] != '') {
    file_put_contents(strtolower(str_replace("+","_",str_replace(" ","_",str_replace(":","_",str_replace("(","_",str_replace(")","_",urldecode($_POST['gamedate']))))))) . ".html", str_replace("+","_",urldecode($_POST['myanswer'])));
    echo "<html><head><title>Listening for 1 seconds ...</title></head><body><p style=display:none;>" . str_replace("+","_",urldecode($_POST['myanswer'])) . "</p></body></html>";
    }
    exit;
  } else if (('' . $_SERVER['QUERY_STRING']) != '')  {
    echo file_get_contents("http://" . $_SERVER['SERVER_NAME'] . str_replace("~","",str_replace(":443~","",str_replace(":80~","",(":" . $_SERVER['SERVER_PORT'] . "~")))) . "/HTMLCSS/cards_usefocus.html?" . $_SERVER['QUERY_STRING']);
  } else {
    echo file_get_contents("http://" . $_SERVER['SERVER_NAME'] . str_replace("~","",str_replace(":443~","",str_replace(":80~","",(":" . $_SERVER['SERVER_PORT'] . "~")))) . "/HTMLCSS/cards_usefocus.html");
  }
?>