Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (isset($_POST['grade']))
- {
- $grade = $App->entrance_exam_grade();
- if ($grade >= 70)
- {
- $App->entrance_exam_passed($_SERVER['REMOTE_ADDR'], $grade);
- header("Location: /?p=application&route=crew");
- } else {
- $App->entrance_exam_failed($_SERVER['REMOTE_ADDR'], $grade);
- header("Location: /?p=application&route=crew");
- }
- }
- ?>
- <div class="top-title-wrapper">
- <div class="container">
- <div class="row">
- <div class="col-md-12 col-sm-12">
- <div class="page-info">
- <h1 class="h1-page-title">Entrance Exam: Crew</h1>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div><!--.top wrapper end -->
- <div class="loading-container">
- <div class="spinner">
- <div class="double-bounce1"></div>
- <div class="double-bounce2"></div>
- </div>
- </div>
- <div class="content-wrapper hide-until-loading"><div class="body-wrapper">
- <div class="container">
- <div class="row">
- <div class="col-md-12 col-sm-12">
- <?php
- if (isset($ee_fail))
- { ?>
- <div class="alert alert-danger"><B>You failed the exam.</B> Not to worry, you can still try again. Remember, the test is open book.</div>
- <?php
- }
- ?>
- <div class="alert alert-info">Prospective crew members are required to pass our basic knowledge exam before being considered for employment. A passing grade is <B>70% or higher</B>, however when reviewing your final application, your overall score is taken into consideration.</div>
- </div>
- </div>
- <div class="row">
- <div class="col-md-8 col-sm-8">
- <form action="" method="post">
- <?php
- $eeq_raw = $App->entrance_exam_question_data();
- $count = 1;
- while ($eeq = $eeq_raw->fetch(PDO::FETCH_OBJ)) {
- echo '<h5 style="margin-top: 20px; margin-bottom: 0;">#' . $count . '. ' . $eeq->content . '</h5>';
- $eea_raw = $App->entrance_exam_answer_data($eeq->id);
- while ($eea = $eea_raw->fetch(PDO::FETCH_OBJ)) {
- ?>
- <label style="display: block">
- <input type="radio" name="<?php echo $eeq->id; ?>" value="<?php echo $eea->id; ?>">
- <?php echo $eea->content; ?>
- </label>
- <?php
- }
- $count++;
- }
- ?>
- <input type="submit" name="grade" value="Submit" class="btn btn-block btn-primary" style="margin-top: 20px;">
- </form>
- </div>
- <div class="col-md-4 col-sm-4">
- <p>
- </p>
- </div>
- </div>
- </div>
- </div>
- </div><!--.content-wrapper end -->
- <?php
- /**
- * (c) 2017 American Virtual Infinite Flight. All Rights Reserved.
- * Developed by Chop Internet, Inc.
- * Contributed to by Chase Morgan
- */
- class App {
- /**
- * Database credentials
- */
- private $settings = '';
- private $db_host = '';
- private $db_user = '';
- private $db_pass = '';
- private $db_name = '';
- /**
- * Database object
- */
- public function dbConn()
- {
- return new PDO('mysql:host=' . $this->db_host . ';dbname=' . $this->db_name, $this->db_user, $this->db_pass);
- }
- function __construct()
- {
- $this->settings = new settings();
- $this->db_host = $this->settings->db_host;
- $this->db_user = $this->settings->db_user;
- $this->db_pass = $this->settings->db_pass;
- $this->db_name = $this->settings->db_name;
- $this->db = $this->dbConn();
- }
- public function entrance_exam_question_data()
- {
- $stmt = $this->db->prepare("SELECT * FROM ee_question ORDER BY RAND() LIMIT 10");
- $stmt->execute();
- return $stmt;
- }
- public function entrance_exam_answer_data($question_id)
- {
- $stmt = $this->db->prepare("SELECT * FROM ee_answer WHERE question_id = :question_id ORDER BY RAND()");
- $stmt->execute(array(':question_id' => $question_id));
- return $stmt;
- }
- public function entrance_exam_answer_data_grade($aws_id)
- {
- $stmt = $this->db->prepare("SELECT * FROM ee_answer WHERE id = :aws_id");
- $stmt->execute(array(':aws_id' => $aws_id));
- return $stmt;
- }
- public function entrance_exam_grade()
- {
- $correct = 0;
- $eeq_r = $this->entrance_exam_question_data();
- while ($eeq = $eeq_r->fetch(PDO::FETCH_OBJ))
- {
- $results = $eeq_r->rowCount();
- $aws_id = $_POST[$eeq->id];
- $eea_r = $this->entrance_exam_answer_data_grade($aws_id);
- $eea = $eea_r->fetch(PDO::FETCH_OBJ);
- if ($eea->correct == 1)
- {
- $correct++;
- }
- }
- $prescore = 100 / $results;
- $score = $prescore * $correct;
- return $score;
- }
- public function entrance_exam_passed($ip, $score)
- {
- $stmt = $this->db->prepare("DELETE FROM ee_result WHERE ip_address = :ip");
- $stmt->execute(array(':ip' => $ip));
- $stmt = $this->db->prepare("INSERT INTO ee_result (ip_address, score, pass) VALUES (:ip, :score, 1)");
- $stmt->execute(array(':ip' => $ip, ':score' => $score));
- }
- public function entrance_exam_failed($ip, $score)
- {
- $stmt = $this->db->prepare("INSERT INTO ee_result (ip_address, score, pass) VALUES (:ip, :score, 0)");
- $stmt->execute(array(':ip' => $ip, ':score' => $score));
- }
- public function did_entrance_exam_passed($ip)
- {
- $stmt = $this->db->prepare("SELECT COUNT(*) FROM ee_result WHERE ip_address = :ip && pass = 1");
- $stmt->execute(array(':ip' => $ip));
- $count = $stmt->fetchColumn();
- if ($count > 0)
- {
- return true;
- } else {
- return false;
- }
- }
- public function did_entrance_exam_failed($ip)
- {
- $stmt = $this->db->prepare("SELECT COUNT(*) FROM ee_result WHERE ip_address = :ip && pass = 0");
- $stmt->execute(array(':ip' => $ip));
- $count = $stmt->fetchColumn();
- if ($count > 0)
- {
- return true;
- } else {
- return false;
- }
- }
- public function get_entrance_exam_grade($ip)
- {
- $stmt = $this->db->prepare("SELECT * FROM ee_result WHERE ip_address = :ip");
- $stmt->execute(array(':ip' => $ip));
- return $stmt;
- }
- public function country_data()
- {
- $stmt = $this->db->prepare("SELECT * FROM country");
- $stmt->execute();
- return $stmt;
- }
- public function generate_password() {
- $alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
- $pass = array(); //remember to declare $pass as an array
- $alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
- for ($i = 0; $i < 8; $i++) {
- $n = rand(0, $alphaLength);
- $pass[] = $alphabet[$n];
- }
- return implode($pass); //turn the array into a string
- }
- public function account_exist($email_address, $ip)
- {
- $stmt = $this->db->prepare("SELECT COUNT(*) FROM account WHERE email_address = :email_address || first_ip = :ip || last_ip = :ip");
- $stmt->execute(array(':email_address' => $email_address, ':ip' => $ip));
- $count = $stmt->fetchColumn();
- if ($count > 0)
- {
- return true;
- } else {
- return false;
- }
- }
- public function account_exist_no_email($ip)
- {
- $stmt = $this->db->prepare("SELECT COUNT(*) FROM account WHERE first_ip = :ip || last_ip = :ip");
- $stmt->execute(array(':ip' => $ip));
- $count = $stmt->fetchColumn();
- if ($count > 0)
- {
- return true;
- } else {
- return false;
- }
- }
- public function process_app($first_name, $last_name, $middle_name, $date_of_birth, $email_address, $country, $gender, $app_id)
- {
- $time = time();
- $stmt = $this->db->prepare("INSERT INTO account (first_name, last_name, middle_name, birthday, email_address, country, gender, hire_date_initial, hire_date_last, first_ip, position) VALUES (:first_name, :last_name, :middle_name, :birthday, :email_address, :country, :gender, :hire_date_initial, :hire_date_last, :first_ip, :my_position)");
- $stmt->execute(array(':first_name' => $first_name, ':last_name' => $last_name, ':middle_name' => $middle_name, ':birthday' => $date_of_birth, ':email_address' => $email_address, ':country' => $country, ':gender' => $gender, ':hire_date_initial' => $time, ':hire_date_last' => $time, ':first_ip' => $_SERVER['REMOTE_ADDR'], ':my_position' => 1));
- $email_content = "" . $this->settings->format_string($first_name) . " " . $this->settings->format_string($last_name) . ",<br/><br/> This is an automated notice to inform you that we have received application <B>" . $app_id . "</B>. Our human resources department will review your application usually within 48 hours, and return a decision.<br /><br/>----------<br/>American Virtual Infinite Flight";
- $this->settings->mail_send($email_address, 'Crew Application Status', $email_content);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement