<?php
require('../setClassPath.php');
require_once('ui/Component.php');
require_once('util/InputHelper.php');

$helper = InputHelper::getInstance();
$msex = $helper->fullySanitize($_POST['msex']);
$osex = $helper->fullySanitize($_POST['osex']);
$mage = $helper->fullySanitize($_POST['mage']);

if (($msex == '') OR ($osex == '') OR ($mage == '') OR (!is_numeric($mage))) {
    $ref = $_SERVER['HTTP_REFERER'];
    if ($ref) {
        $f = fopen('quizref.txt',"a");
        fwrite($f, date("m/d/y  H:i:s") . ' -  ' . $ref . "\n");
        fclose($f);
    }
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Dating Profile Quiz at Would I Date You</title>
<link type="text/css" rel="stylesheet" href="/css/main.css">
<link type="text/css" rel="stylesheet" href="/css/quiz.css">
<style type="text/css">
.lbl { width: 180px; }
label { width: 180px; }
#qimg { float: right; }
</style>
</head>
<body>
<div id="body">
<div id="widetop">
<h1>Take the Dating Profile Quiz</h1>
<p class="lg">The dating profile quiz will reveal your top dating character traits, as well as the 
    traits you are looking for in a mate.  To begin, just enter the information below.</p>
</div>
  <img src="/i/pquiz.jpg" alt="Dating Profile Quiz" id="qimg">
  <h3>Start the Quiz:</h3>
  <form action="quiz1.html" method="post">
    <table>
      <tr><td class="lbl"><label for="msex">Select your gender:</label></td>
        <td><select name="msex">
        <option value="m" selected>Male</option>
        <option value="f">Female</option>
        </select></td>
      </tr>
      <tr><td class="lbl"><label for="osex">You are seeking a:</label></td>
        <td><select name="osex">
        <option value="m">Male</option>
        <option value="f" selected>Female</option>
        </select></td>
      </tr>
      <tr><td class="lbl"><label for="mage">Enter your age:</label></td>
        <td><input type="text" size="2" maxlength="2" name="mage"></td></tr>
      <tr><td>&nbsp;</td>
        <td><input type="submit" value="Start the Quiz!"></td></tr>
    </table>
  </form>
<?php
$ui = Component::getInstance();
$ui->drawHeader($_SESSION['user']);
$ui->drawFooter();
?>
</div>
</body></html>
<?php
}
else {
    require_once('helper/ForumHelper.php');
    $fhelp = ForumHelper::getInstance();
    $threads = $fhelp->getLatestThreads();
    
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Dating Profile Quiz, Part 1 of 4</title>
<link type="text/css" rel="stylesheet" href="/css/main.css">
<link type="text/css" rel="stylesheet" href="/css/quiz.css">
<link type="text/css" rel="stylesheet" href="/css/threadlink.css">
</head>
<body>
<div id="body">
<div id="widetop">
<h1>Dating Profile Quiz, Part 1 of 4</h1>
<h2>Getting to Know You</h2>
</div>
  
<form action="quiz2.html" method="post">

<?php
    require_once('ui/ForumUI.php');
    $ui = new ForumUI('html');
    $ui->drawThreadLBar($threads);
    echo '<input type="hidden" name="msex" value="' . $msex . '"><input type="hidden" name="osex" value="' . $osex . '"><input type="hidden" name="mage" value="' . $mage . '">';
?>

<table cellspacing="0" id="quiz">
  <tr><th class="q">Which of these movie genres is your favorite?</th></tr>
  <tr><td class="q1 t"><input type="radio" name="q1" value="action"> Action</td></tr>
  <tr><td class="q1"><input type="radio" name="q1" value="comedy"> Comedy</td></tr>
  <tr><td class="q1"><input type="radio" name="q1" value="drama"> Drama</td></tr>
  <tr><td class="q1 b1"><input type="radio" name="q1" value="documentary"> Documentary</td></tr>

  <tr><th class="q">Do you believe opposites attract?</th></tr>
  <tr><td class="q2 t"><input type="radio" name="q10" value="yes"> Yes, definitely</td></tr>
  <tr><td class="q2"><input type="radio" name="q10" value="sometimes"> Sometimes yes, sometimes no</td></tr>
  <tr><td class="q2 b2"><input type="radio" name="q10" value="no"> No, people get along better when they've got things in common</td></tr>

  <tr><th class="q">Name an activity that you typically do on the weekend?</th></tr>
  <tr><td class="q1 t"><input type="radio" name="q3" value="work"> Work</td></tr>
  <tr><td class="q1"><input type="radio" name="q3" value="party"> Party</td></tr>
  <tr><td class="q1"><input type="radio" name="q3" value="book"> Relax and read a book</td></tr>
  <tr><td class="q1 b1"><input type="radio" name="q3" value="sweep"> Sit around wishing for someone to <?= ($msex == 'f' ? 'sweep me off my feet' : 'go out and do stuff with') ?></td></tr>

  <tr><th class="q">Do you earn a large salary?</th></tr>
  <tr><td class="q2 t"><input type="radio" name="q4" value="yes"> Yes</td></tr>
  <tr><td class="q2"><input type="radio" name="q4" value="dontneed"> No, don't need it</td></tr>
  <tr><td class="q2"><input type="radio" name="q4" value="wantto"> No, but I want to</td></tr>
  <tr><td class="q2 b2"><input type="radio" name="q4" value="spouse"> My <?= ($osex == 'f' ? 'wife' : 'husband') ?> will</td></tr>

  <tr><th class="q">What would you do if you spotted an injured animal outside?</th></tr>
  <tr><td class="q1 t"><input type="radio" name="q5" value="inside"> Go inside and try not to think about it</td></tr>
  <tr><td class="q1"><input type="radio" name="q5" value="nurse"> Try to nurse it back to health</td></tr>
  <tr><td class="q1 b1"><input type="radio" name="q5" value="call"> Call the appropriate authorities</td></tr>

  <tr><th class="q"><?= ($osex == 'f' ? 'Would you think it proper to ask your significant other\'s parents for permission before proposing marriage?' : 'Would you think it\'s proper for your significant other to ask for your parents\' permisison before he proposes marriage?') ?></th></tr>
  <tr><td class="q2 t"><input type="radio" name="q6" value="yes"> Yes</td></tr>
  <tr><td class="q2 b2"><input type="radio" name="q6" value="no"> No</td></tr>

  <tr><th class="q">Do you notice the brand labels on other people's clothing?</th></tr>
  <tr><td class="q1 t"><input type="radio" name="q7" value="yes"> Yes</td></tr>
  <tr><td class="q1 b1"><input type="radio" name="q7" value="no"> No</td></tr>

  <tr><th class="q">Are you always open to trying new things in the bedroom?</th></tr>
  <tr><td class="q2 t"><input type="radio" name="q8" value="yes"> Yes</td></tr>
  <tr><td class="q2"><input type="radio" name="q8" value="depends"> It depends on what "new things" means</td></tr>
  <tr><td class="q2"><input type="radio" name="q8" value="dependsshy"> It depends on whether I can overcome my inhibitions</td></tr>
  <tr><td class="q2 b2"><input type="radio" name="q8" value="no"> Usually not</td></tr>

  <tr><th class="q">Do you regularly attend religious services?</th></tr>
  <tr><td class="q1 t"><input type="radio" name="q9" value="yes"> Yes</td></tr>
  <tr><td class="q1"><input type="radio" name="q9" value="notas"> Not as often as I'd like</td></tr>
  <tr><td class="q1 b1"><input type="radio" name="q9" value="no"> No</td></tr>

  <tr><th class="q">Do you enjoy playing any sports?</th></tr>
  <tr><td class="q2 t"><input type="radio" name="q2" value="yes"> Yes</td></tr>
  <tr><td class="q2"><input type="radio" name="q2" value="nobut"> No, but I would like to</td></tr>
  <tr><td class="q2 b2"><input type="radio" name="q2" value="no"> No</td></tr>

  <tr><th class="q">What kind of person catches your interest?</th></tr>
  <tr><td class="q1 t"><input type="radio" name="q41" value="assert"> Assertive and bold</td></tr>
  <tr><td class="q1"><input type="radio" name="q41" value="quiet"> Quiet and mysterious</td></tr>
  <tr><td class="q1"><tr><td class="q1"><input type="radio" name="q41" value="fit"> Physically fit and active</td></tr>
  <tr><td class="q1"><input type="radio" name="q41" value="wealthy"> Wealthy and well-dressed</td></tr>
  <tr><td class="q1 b1"><input type="radio" name="q41" value="modest"> Modest and kind</td></tr>

  <tr><th class="q">Which of these turns you off most?</th></tr>
  <tr><td class="q2 t"><input type="radio" name="q42" value="ambition"> Lack of ambition</td></tr>
  <tr><td class="q2"><input type="radio" name="q42" value="meek"> Meekness and timidity</td></tr>
  <tr><td class="q2"><input type="radio" name="q42" value="energy"> A lack of energy</td></tr>
  <tr><td class="q2"><input type="radio" name="q42" value="intellect"> Lack of intellectual pursuits</td></tr>
  <tr><td class="q2 b2"><input type="radio" name="q42" value="appear"> Not caring about one's appearance</td></tr>

  <tr><td><input type="submit" value="Continue to Part 2"></td></tr>
</table>

</form>


<?php
$ui = Component::getInstance();
$ui->drawHeader($_SESSION['user']);
$ui->drawFooter();
?>
</div>
</body></html>
<?php
}
?>
