<?php

//lines 3-7: Establish database connection
$con = mysqli_connect("localhost", "root", "fcD6EGaTQsp6LXC9", "JobSelection");
//on connection failure, throw an error
if (!$con) {
    die('Could not connect: ' . mysql_error());
}
//line 10: Gets the job_id variable value from the URL
$job_id = $_GET["t"];
//lines 13-22: Calls the generate_random_token function in order to create values for the student_SS, student_token, token_role variables and saves them in DB
require_once 'wp-config.php';
$student_SS = generate_random_token();
$student_token = generate_random_token();
$token_role = "student";
$sql = "INSERT INTO `JobSelection`.`tokens` (`SS_token`,`token_role`,`system_token`, `job_id`) \n\t\t\t\t\t\t\t\t\t\t VALUES ('{$student_SS}', '{$token_role}', '{$student_token}', '{$job_id}')";
$sql_result = mysqli_query($con, $sql);
//line 25: Regidects the user to the specified page in order to authenticate
header("Location: https://stork2.atlantis-group.gr/stork-testjs/ValidateToken?t=" . $student_SS);
$email = $_POST["email"];
$pass = $_POST["password"];
$pass = md5($pass);
$user_role = "representative";
?>

<?php 
//lines 14-18: Establish database connection
$con = mysqli_connect("localhost", "root", "fcD6EGaTQsp6LXC9", "JobSelection");
//on connection failure, throw an error
if (!$con) {
    die('Could not connect: ' . mysql_error());
}
?>

<?php 
//lines 23-35: Gets the variable emp_system_t value from the URL and inserts the saved variable values in the DB
require_once 'wp-config.php';
$emp_system_t = $_GET["t"];
$rep_system_t = generate_random_token();
$sql1 = "INSERT INTO `JobSelection`.`wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `display_name`,\n\t\t\t\t\t\t\t\t\t\t`name`, `surname`, `telephone_number`, `eIdentifier`, `country`, `mandate`, `token`, `create_stamp`, `user_role`)\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tVALUES('{$name}', '{$pass}', '{$name}', '{$email}', '{$name}',\n\t\t\t\t\t\t\t\t\t\t'{$name}', '{$surname}', '{$telephone_number}', '{$eIdentifier}', '{$country}', '{$mandate}', '{$rep_system_t}', '', '{$user_role}')";
$sql1_result = mysqli_query($con, $sql1);
//lines 38-40: Creates the third and final link for the entity "business" , the employee, the representative and the company
require_once 'wp-config.php';
$sql2 = "UPDATE user_connection SET representative_token='" . $rep_system_t . "' WHERE employee_token='" . $emp_system_t . "'";
$sql2_result = mysqli_query($con, $sql2);
?>

<?php 
//line 46: Redirects to the specified page
header("Location: http://stork-ap.aegean.gr/JobSelection/employee_final.php?t=" . $emp_system_t . "'");
<?php

//lines 4-8: Establish database connection
$con = mysqli_connect("localhost", "root", "fcD6EGaTQsp6LXC9", "JobSelection");
//on connection failure, throw an error
if (!$con) {
    die('Could not connect: ' . mysql_error());
}
//lines 11-20: Call generate_random_token function and save SS_token, token_role variables in DB
require_once 'wp-config.php';
$SS_token = generate_random_token();
$token_role = "login";
$sql = "INSERT INTO `JobSelection`.`tokens` (`SS_token`, `token_role`, `system_token`)\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tVALUES('{$SS_token}', '{$token_role}', '')";
mysqli_query($con, $sql);
//line 23: Redirects the user to the specified page
header("Location: https://stork2.atlantis-group.gr/stork-testjs/ValidateToken?t=" . $SS_token);
<?php

//lines 3-7: establish database connection
$con = mysqli_connect("localhost", "root", "fcD6EGaTQsp6LXC9", "JobSelection");
//on connection failure, throw an error
if (!$con) {
    die('Could not connect: ' . mysql_error());
}
//lines 10-15: Generates the user SS_token, the token role and the user system token in the system
require_once 'wp-config.php';
$SS_token = generate_random_token();
$token_role = "register";
$system_token = generate_random_token();
//lines 18-23: Creates the first user insertion in the DB, so that the system could manage him in the next steps of the registration process
$sql1 = "INSERT INTO `JobSelection`.`tokens` (`SS_token`, `token_role`, `system_token`)\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tVALUES('{$SS_token}', '{$token_role}', '{$system_token}')";
mysqli_query($con, $sql1);
//line 26: Creates the user role so that the system can create the appropriate JSON message in the next steps of the registration process
$user_role = "employee";
//lines 29-39: Creates the second user insertion in the DB, so that the system could know the saving point when the user attributes arrive
require_once 'wp-config.php';
$sql2 = "INSERT INTO `JobSelection`.`wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `display_name`,\n\t\t\t\t\t\t\t\t\t\t`name`, `surname`, `telephone_number`, `eIdentifier`, `country`, `mandate`, `token`, `SS_token`,`create_stamp`, `user_role`)\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tVALUES('{$system_token}', '{$system_token}', '{$system_token}', '', '{$system_token}',\n\t\t\t\t\t\t\t\t\t\t'{$system_token}', '{$system_token}', '', '{$system_token}', '', '{$system_token}', '{$system_token}', '{$SS_token}' ,NOW(), '{$user_role}')";
mysqli_query($con, $sql2);
//line 43: Redirects the user to the STORK 2.0 ISS page for authentication and attribute collection
header("Location: https://stork2.atlantis-group.gr/stork-testjs/ValidateToken?t=" . $SS_token);