<?php
   Template::Show('login_temp_head.php');
?>

  <form action="<?php echo url('/registration/BeginCrewTest'); ?>" method="post" enctype="multipart/form-data" class="form-horizontal form-bordered">
    <div style="overflow: auto; height: 400px; margin-bottom: 20px; padding: 5px; padding-top: 0px; padding-bottom: 20px;">

		<div class="form-group">
			<div class="alert alert-info">
				<strong>Hello there!</strong><br>
				Welcome to the <strong><?php echo SITE_NAME; ?> crew entrance exam</strong>. To be apart of something special, you must have what it takes, right? <br>
				But don't worry, this is a simple test, comprised of 10 multiple choice questions. Questions are based on <strong>general knowledge about <?php echo SITE_NAME; ?>,
				IFR flight operations, meteorology, airmanship and navigation. </strong>Each question carries a 10% mark, and a total of 70% is required to pass. Please enter your email address below and click on 'Begin Exam' to start.
        	</div>
        	<div class="alert alert-warning">
			<strong>Important : </strong> <br>
				Integrity and self-descipline are some of the qualities which we expect our pilots to have. Enforcing the same, cheating will be strictly prohibited in this entrance exam.
				The System will automatically mark you as 'Fail' if you attempt to leave this page, or even switch tabs in your browser. The questions must be answered within the given time frame (10 minutes), if not, the system will consider whatever answers you have marked, and if luck permits, you will pass. Otherwise, you will have to wait for the cooling period to finish (12 hours) to retest. Best of luck. See you on the other side!
			</div>

            <label class="col-md-3 control-label">E-Mail</label>
            <div class="col-md-9">
            	<input type="text" name="examinee_email" class="form-control" placeholder="Please enter your current email ID"
			           <?php if($_GET['examinee_email']) {
            		      ?> value="<?php echo $_GET['examinee_email']; ?>" <?php
            	      }
			            ?>>
            </div>
         </div>

		<!--<div class="form-group">-->
		<!--	<label class="col-md-3 control-label" for="example-disabled-input">IP Address</label>-->
		<!--	<div class="col-md-9">-->
		<!--		<input type="text" name="ipaddress" class="form-control" placeholder="<?php echo $_SERVER['REMOTE_ADDR']; ?>" disabled="">-->
		<!--	</div>-->
		<!--</div>-->
		<?php
					$ip = $_SERVER['REMOTE_ADDR'];
					// $details = json_decode(file_get_contents("http://ipinfo.io/{$ip}/json"));
					$url = "http://ipinfo.io/{$ip}/json";
					$ch = curl_init($url);
					curl_setopt($ch, CURLOPT_ENCODING,"");
					curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
					curl_setopt($ch, CURLOPT_HEADER, true);
					curl_setopt($ch, CURLINFO_HEADER_OUT, true);
					curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
					curl_setopt($ch, CURLOPT_FILETIME, true);
					curl_setopt($ch, CURLOPT_USERAGENT,"Mozilla/5.0 (Windows NT 5.1; rv:32.0) Gecko/20100101 Firefox/32.0");
					curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 100);
					curl_setopt($ch, CURLOPT_VERBOSE, true);
					curl_setopt($ch, CURLOPT_AUTOREFERER, true);
					curl_setopt($ch, CURLOPT_TIMEOUT,100);
					curl_setopt($ch, CURLOPT_FAILONERROR,true);
					$details = curl_exec($ch);
					$details = json_decode($details);
					$resultStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
					if ($resultStatus == 200 || $resultStatus == 204) {
						$visitor_country =  $details->city.', '.$details->region.', '.$details->country;

						?>
						<div class="form-group">
							<label class="col-md-3 control-label" for="example-disabled-input">IP Origin</label>
								<div class="col-md-9">
									<input type="text" name="ipaddress" class="form-control" placeholder="<?php echo $visitor_country ?>" disabled="">
								</div>
						</div>
				<?php
					} else if ($resultStatus == 429) {
						$visitor_country = 'Unable to determine location. Error Code '.$resultStatus;
					} else {
						$visitor_country = 'Unable to determine location. Error Code '.$resultStatus;
					}

				?>




         <div class="form-group">
			<div class="col-md-12 text-center text-muted">
				<small><i>Remember, once you're on the exam page, you cannot RELOAD or ABANDON THE EXAM PAGE</i></small>
			</div>
		</div>
         </div>
         <div class="form-group form-actions">
            <div class="col-md-12">
               <button type="submit" class="btn btn-sm btn-primary btn-block"><i class="fa fa-angle-right"></i> Begin exam</button>
            </div>
         </div>

      </form>
<!-- END Login Form -->
</div>
<!-- END Login Block -->
</div>
</div>
</div>
</div>
<!-- Login Container -->
<!-- END Login Container -->
