user_login;
$userid = $current_user_info->ID;

date_default_timezone_set(‘UTC’);

$now = date(‘Y-m-d H:i:s’);

$now_timestr = strtotime($now);

$outdate_timestr = $now_timestr – (120 * 60);

$outdate_date = date(‘Y-m-d H:i:s’, $outdate_timestr);

$outdate_id = AutoSearchExpireGateCode(“$outdate_date”, $mysql_host, $mysql_user, $mysql_pass, $mysql_db_ivaohk);

for($i=0; $i <= sizeof($outdate_id); $i++){ ForceReleaseGateCode($outdate_id[$i][0], "IVAO HK", "-1", $mysql_host, $mysql_user, $mysql_pass, $mysql_db_ivaohk); break; } // IMPORT GET PARAMETERS IN ARRAY FORMAT $myvar = load_qstrings(); $action = $_POST['action']; // Get POST parameters if ($myvar['action'] == "cancelgate"){ $gate_id = $myvar['gate_id']; if ($username == NULL || $userid == NULL || $gate_id == "null") // Confirm user logged in $validate = true; else $validate = true; print"

“;

if ($validate) { // if validate result is true, do force remove
$cancel_request = CancelRequestedGate($gate_id, $username, $userid, $mysql_host, $mysql_user, $mysql_pass, $mysql_db_ivaohk);

if($cancel_request == -1){
print”

Operation not permitted, SSR Code assigned to this callsign. Please contact Hong Kong ATC !

“;
}
elseif($cancel_request == -2){
print”
Operation not permitted, you are not the Gate requestor !

“;
}
else {
print”
Processing…


“;
}
}
else {
echo ““;
}
print”



“;
}
elseif ($action == “gen_gate”){
$callsign = $_POST[‘callsign’];
$apron_code = $_POST[‘apron_code’];
$aircraft_code = $_POST[‘aircraft_code’];

$callsign = strtoupper($callsign);

if ($username == NULL || $userid == NULL) // Confirm user logged in
$validate = false;
if ($callsign == NULL || strlen($callsign) > 10 || $apron_code == NULL || $aircraft_code == NULL) // Validate user input
$validate = false;
else
$validate = true;

print”


“;

date_default_timezone_set(‘UTC’);

$now = date(‘Y-m-d H:i:s’);

$now_timestr = strtotime($now);

$outdate_timestr = $now_timestr – (120 * 60);

$outdate_date = date(‘Y-m-d H:i:s’, $outdate_timestr);

$outdate_id = AutoSearchExpireGateCode(“$outdate_date”, $mysql_host, $mysql_user, $mysql_pass, $mysql_db_ivaohk);

for($i=0; $i <= sizeof($outdate_id); $i++){ ForceReleaseGateCode($outdate_id[$i][0], "IVAO HK", "-1", $mysql_host, $mysql_user, $mysql_pass, $mysql_db_ivaohk); break; } if ($validate) { // if validate result is true, do gen gate steps $chk_callsign = ChkCallsignSq($callsign, $mysql_host, $mysql_user, $mysql_pass, $mysql_db_ivaohk); if ($chk_callsign == -1) { print"

Operation not permitted, SSR Code assigned to this callsign. Please contact Hong Kong ATC !

“;
}
else {
$gen_gate = GenGateCode($apron_code, $aircraft_code, $mysql_host, $mysql_user, $mysql_pass, $mysql_db_ivaohk);

$gate_id = $gen_gate[0];
$gate_code = $gen_gate[1];

if($apron_code >= 81 && $apron_code <= 89) $airport = "VHHH"; elseif ($apron_code >= 91 && $apron_code <= 95) $airport = "VHHX"; elseif ($apron_code >= 97 && $apron_code <= 99) $airport = "VMMC"; $add_gate = AddRequestedGateCode($airport, $gate_id, $gate_code, $callsign, $username, $userid, $mysql_host, $mysql_user, $mysql_pass, $mysql_db_ivaohk); if($add_gate < 0){ print"

ERROR Operation !

The following reasons may caused the error :
– Database I/O error
– No more gate available
– Aircraft already have Gate
– The Apron type not support the aircraft category you selected


“;
}
else {
print”
Processing…


“;
}

}
}
else { // re-print the user input
print”
Request Departure Gate – Input Error !

Callsign   From :   Aircraft Type:

“;
} //End validate

} // End action
else {
print”

Callsign   From :   Aircraft Type:

“; //End print
} //End if (action) statement

print”

“;
}

?>