public function approveRestriction($restrictionId, $restrictionTable, $approval) { //create instance of Database Manager object $dbMan = new DatabaseManager(); //establish connection //if returns false, connection failed if (!$dbMan->establishConnection()) { //database connection error return false; } //if approval is true - change restriction status to active if ($approval) { /* Create new request to get all pending airline restrictions */ $request = new Request('Approve Restriction', $restrictionTable); $request->addParameter('restriction_id', $restrictionId); $request->addParameter('status', 'ACTIVE'); } else { if (!$approval) { /* Create new request to get all pending airline restrictions */ $request = new Request('Delete Restriction', $restrictionTable); $request->addParameter('restriction_id', $restrictionId); } } //transform the command to sql statement $request->transformCommand(); //execute command $results = $dbMan->executeQuery($request); //if results is not null, command was successfully executed. if ($results != null) { //successfully approved return true; } //command was not successfully executed. return false; }
public function removeRestrictionRequest($restrictionId, $restrictionTable) { //create instance of Database Manager object $dbMan = new DatabaseManager(); //establish connection //if returns false, connection failed if (!$dbMan->establishConnection()) { //database connection error return false; } /* Create new request to remove restriction*/ $request = new Request('Delete Restriction', $restrictionTable); $request->addParameter('restriction_id', $restrictionId); //transform the command to sql statement $request->transformCommand(); //execute command $results = $dbMan->executeQuery($request); //if results is not null, command was successfully executed. if ($results != null) { //successfully approved return true; } //command was not successfully executed. return false; }
public function getNonRestrictedRegions() { $regions = array(); $dbMan = new DatabaseManager(); /* Establish connection with database * if the establishConnection function * returns false, a connection error occured*/ if (!$dbMan->establishConnection()) { //database connection error return; } /* Create request to get valid airlines for user_id provided */ $request = new Request('getValidRegions', 'se_Region_Restrictions'); $request->addParameter('user_id', $this->id); /* Transform the Request into an MySQL command*/ $request->transformCommand(); /* Execute command to get valid Regions */ $validRegions = $dbMan->executeQuery($request); //server error if ($validRegions == null) { //request was unsuccessful } else { if ($validRegions->num_rows) { /* Get number of rows returned */ $rows = $validRegions->num_rows; /* For each row - push the region name * onto the $regions array */ for ($i = 0; $i < $rows; ++$i) { $validRegions->data_seek($i); $row = $validRegions->fetch_array(MYSQLI_NUM); /* Push value onto array */ array_push($regions, $row[0]); } } } /* Return Valid Regions */ return $regions; }
function updateUserPassword($userId) { /* Create new instance of database manager */ $dbMan = new DatabaseManager(); /* Establish connection with server */ if (!$dbMan->establishConnection()) { //database connection error return; } /* Create new request to update user password */ $request = new Request('UPDATE', 'se_Users'); $request->addParameter('user_id', $userId); /* If the new passwords entered by the user match */ if ($_POST['MY_ACCOUNT_PASSWORD'] == $_POST['MY_ACCOUNT_VERIFY_PASSWORD']) { $email = $_SESSION['user']->email; $password = $_POST['MY_ACCOUNT_PASSWORD']; $hashedPassword = hash('ripemd128', "g!cT{$email}{$password}"); $request->addParameter('password', $hashedPassword); } else { unmatchedPasswords(); return; } /* Transform request into SQL command */ $request->transformCommand(); /* Results returned from server */ $results = $dbMan->executeQuery($request); //server error if ($results == null) { //request was unsuccessful } else { accountUpdateSuccess(); } }
function getNumberOfPendingAccounts() { $dbMan = new DatabaseManager(); if (!$dbMan->establishConnection()) { //database connection error return; } $request = new Request('SELECT *', 'se_Users'); $request->addParameter('status', 'PENDING_APPROVAL'); $request->transformCommand(); $results = $dbMan->executeQuery($request); if ($results == null) { //request failed } return $rows = $results->num_rows; }
} $regionRadioButton = $_POST['REGION_FLIGHTS']; if ($regionRadioButton == 'delayed') { /* Create new request to get airports by delays */ $request = new Request('getDelaysByRegions', 'se_Flights'); /* Pass in date range variables */ $request->addParameter('startDate', $_POST['REGION_STARTDATE']); $request->addParameter('endDate', $_POST['REGION_ENDDATE']); /* Create layout for table */ $table = '<table class="table table-hover">' . '<thead>' . '<tr>' . '<th>Region</th>' . '<th>Number of Delayed Flights</th>' . '</tr>' . '</thead>' . '<tbody>'; } else { if ($regionRadioButton == 'onTime') { /* Create new request to get airports by delays */ $request = new Request('getOnTimeByRegions', 'se_Flights'); /* Pass in date range variables */ $request->addParameter('startDate', $_POST['REGION_STARTDATE']); $request->addParameter('endDate', $_POST['REGION_ENDDATE']); /* Create layout for table */ $table = '<table class="table table-hover">' . '<thead>' . '<tr>' . '<th>Region</th>' . '<th>Number of On-Time Flights</th>' . '</tr>' . '</thead>' . '<tbody>'; } } /* Transform the request into a command */ $request->transformCommand(); /* database manager executes query */ $results = $dbMan->executeQuery($request); if ($results == null) { //request failed } else { $rows = $results->num_rows; for ($i = 0; $i < $rows; ++$i) { $results->data_seek($i);
$result = $user->approveUser($_POST['denyUser'], false); if ($result) { showBanner('#userDenied'); } else { showBanner('#error'); } } } if ($_SESSION['user']->type == 'SUPER_USER') { $dbMan = new DatabaseManager(); if (!$dbMan->establishConnection()) { //database connection error return; } $request = new Request('SELECT *', 'se_Users'); $request->addParameter('status', 'PENDING_APPROVAL'); $request->transformCommand(); $results = $dbMan->executeQuery($request); if ($results == null) { //request failed } $rows = $results->num_rows; ?> <div id="userApproved" class="alert alert-success" style="display: none;"> <strong><i class="fa fa-check"></i>User Approved.</strong> </div> <div id="userDenied" class="alert alert-danger" style="display: none;"> <strong><i class="fa fa-times"></i>User Denied.</strong> </div> <div id="error" class="alert alert-warning" style="display: none;"> <strong><i class="fa fa-times"></i>Error Occured.</strong>
$dbMan = new DatabaseManager(); $request = ''; if (!$dbMan->establishConnection()) { //database connection error return; } //if the checkbox is checked - get delays by airlines if (isset($_POST['AIRLINE_DELAYS'])) { $request = new Request('getDelaysByAirlines', 'se_Flights'); $request->addParameter('startDate', $_POST['AIRLINE_STARTDATE']); $request->addParameter('endDate', $_POST['AIRLINE_ENDDATE']); $request->transformCommand(); $table = '<table class="table table-hover">' . '<thead>' . '<tr>' . '<th>Airline</th>' . '<th>Number of Delays</th>' . '</tr>' . '</thead>' . '<tbody>'; } else { $request = new Request('getProbabilityOfDelay', 'se_Flights'); $request->addParameter('startDate', $_POST['AIRLINE_STARTDATE']); $request->addParameter('endDate', $_POST['AIRLINE_ENDDATE']); $request->addParameter('region', $_POST['AIRLINE_REGION']); $request->addParameter('airline', $_POST['AIRLINE_NAME']); $request->transformCommand(); $table = '<table class="table table-hover">' . '<thead>' . '<tr>' . '<th>Flight Number</th>' . '<th>Airline Name</th>' . '<th>Departure Date</th>' . '<th>Departure Airport</th>' . '<th>Region</th>' . '<th>Filed Depart Time</th>' . '<th>Flown Depart Time</th>' . '<th>Delayed</th>' . '</tr>' . '</thead>' . '<tbody>'; } $results = $dbMan->executeQuery($request); if ($results == null) { //request failed } else { $rows = $results->num_rows; $total = 0; $delays = 0; for ($i = 0; $i < $rows; ++$i) { $results->data_seek($i);
$table = '<table class="table table-hover">' . '<thead>' . '<tr>' . '<th>Airspace Id</th>' . '<th>Airspace Point 1</th>' . '<th>Airspace Point 2</th>' . '<th>Number of Tracking Messages</th>' . '<th></th>' . '</tr>' . '</thead>' . '<tbody>'; } else { if ($airspaceRadioButton == "rankByDelays") { /* Create new request to get airspaces by flights */ $request = new Request('getAirspacesByDelays', 'se_Airspaces'); /* Pass in date range variables */ $request->addParameter('startDate', $_POST['AIRSPACE_STARTDATE']); $request->addParameter('endDate', $_POST['AIRSPACE_ENDDATE']); /* Create layout for table */ $table = '<table class="table table-hover">' . '<thead>' . '<tr>' . '<th>Airspace Id</th>' . '<th>Airspace Point 1</th>' . '<th>Airspace Point 2</th>' . '<th>Number of Delayed Tracking Messages</th>' . '<th></th>' . '</tr>' . '</thead>' . '<tbody>'; } else { if ($airspaceRadioButton == 'rankByMessages') { /* Create new request to get airspaces by flights */ $request = new Request('getAirspacesByCancelations', 'se_Airspaces'); /* Pass in date range variables */ $request->addParameter('startDate', $_POST['AIRSPACE_STARTDATE']); $request->addParameter('endDate', $_POST['AIRSPACE_ENDDATE']); /* Create layout for table */ $table = '<table class="table table-hover">' . '<thead>' . '<tr>' . '<th>Airspace Id</th>' . '<th>Airspace Point 1</th>' . '<th>Airspace Point 2</th>' . '<th>Number of Cancellation Messages</th>' . '<th></th>' . '</tr>' . '</thead>' . '<tbody>'; } } } } /* Transform the request into a command */ $request->transformCommand(); /* database manager executes query */ $results = $dbMan->executeQuery($request); if ($results == null) { //request failed } else { $rows = $results->num_rows;
$password = $_POST['REQ_PASSWORD']; $verifyPassword = $_POST['REQ_VERIFY_PASSWORD']; //passwords do not match if ($password != $verifyPassword) { echo 'passwords do not match'; return; } $user = new User($email); $user->firstName = $firstName; $user->lastName = $lastName; $user->password = $password; $user->hashedPassword = hash('ripemd128', "g!cT{$user->email}{$user->password}"); $user->type = 'GENERAL_USER'; $user->status = 'PENDING_APPROVAL'; $request = new Request('INSERT', 'se_Users'); $request->addParameter('firstName', $user->firstName); $request->addParameter('lastName', $user->lastName); $request->addParameter('email', $user->email); $request->addParameter('password', $user->hashedPassword); $request->addParameter('type', $user->type); $request->addParameter('status', $user->status); $request->transformCommand(); $result = $dbMan->executeQuery($request); if ($result == null) { //request was unsuccessful echo <<<_END <script type="text/javascript"> \$(document).ready(function(){ \$('#alertRequestFail').show(); }); </script>
$request->addParameter('arrival_airport', $arrivalAirport); /* Create layout for table */ $table = '<table class="table table-hover">' . '<thead>' . '<tr>' . '<th>Flight Number</th>' . '<th>Departure Date</th>' . '<th>Filed Departure Time</th>' . '<th>Flown Departure Time</th>' . '<th>Arrival Date</th>' . '<th>Filed Arrival Time</th>' . '<th>Flown Arrival Time</th>' . '</tr>' . '</thead>' . '<tbody>'; } else { if ($flightRadioButton == 'show_all') { $request = new Request('getAllFlights', 'se_Flights'); $request->addParameter('startDate', $_POST['FLIGHT_STARTDATE']); $request->addParameter('endDate', $_POST['FLIGHT_ENDDATE']); $request->addParameter('depart_airport', $departureAirport); $request->addParameter('arrival_airport', $arrivalAirport); /* Create layout for table */ $table = '<table class="table table-hover">' . '<thead>' . '<tr>' . '<th>Flight Number</th>' . '<th>Departure Date</th>' . '<th>Filed Departure Time</th>' . '<th>Flown Departure Time</th>' . '<th>Arrival Date</th>' . '<th>Filed Arrival Time</th>' . '<th>Flown Arrival Time</th>' . '<th></th>' . '</tr>' . '</thead>' . '<tbody>'; } else { if ($flightRadioButton == 'show_amendments') { $request = new Request('getFlightCancelations', 'se_Flights'); $request->addParameter('startDate', $_POST['FLIGHT_STARTDATE']); $request->addParameter('endDate', $_POST['FLIGHT_ENDDATE']); $request->addParameter('depart_airport', $departureAirport); $request->addParameter('arrival_airport', $arrivalAirport); /* Create layout for table */ $table = '<table class="table table-hover">' . '<thead>' . '<tr>' . '<th>Flight Number</th>' . '<th>Departure Date</th>' . '<th>Filed Departure Time</th>' . '<th>Arrival Date</th>' . '<th>Filed Arrival Time</th>' . '<th>Amendment Message</th>' . '</tr>' . '</thead>' . '<tbody>'; } } } } /* Transform the request into a command */ $request->transformCommand(); $results = $dbMan->executeQuery($request); if ($results == null) { //request failed } else {
/* Create layout for table */ $table = '<table class="table table-hover">' . '<thead>' . '<tr>' . '<th>Flight Number</th>' . '<th>Departure Date</th>' . '<th>Filed Departure Time</th>' . '<th>Flown Departure Time</th>' . '</tr>' . '</thead>' . '<tbody>'; } else { if ($delayRadioButton == 'delayed_arrivals') { $request = new Request('getDelayedArrivalsByAirport', 'se_Airports'); /* Pass in date range variables */ $request->addParameter('startDate', $_POST['AIRPORT_STARTDATE']); $request->addParameter('endDate', $_POST['AIRPORT_ENDDATE']); $request->addParameter('airport', $_POST['AIRPORT_NAME']); /* Create layout for table */ $table = '<table class="table table-hover">' . '<thead>' . '<tr>' . '<th>Flight Number</th>' . '<th>Arrival Date</th>' . '<th>Filed Arrival Time</th>' . '<th>Flown Arrival Time</th>' . '</tr>' . '</thead>' . '<tbody>'; } else { if ($delayRadioButton == 'delayed_percentage') { $request = new Request('getPercentageDelayedDeparturesByAirport', 'se_Airports'); /* Pass in date range variables and airport */ $request->addParameter('startDate', $_POST['AIRPORT_STARTDATE']); $request->addParameter('endDate', $_POST['AIRPORT_ENDDATE']); $request->addParameter('airport', $_POST['AIRPORT_NAME']); /* Create layout for table */ $table = '<table class="table table-hover">' . '<thead>' . '<tr>' . '<th>Flight Number</th>' . '<th>Departure Date</th>' . '<th>Filed Departure Time</th>' . '<th>Flown Departure Time</th>' . '<th></th>' . '</tr>' . '</thead>' . '<tbody>'; } } } } } /* Transform the request into a command */ $request->transformCommand(); /* database manager executes query */ $results = $dbMan->executeQuery($request); if ($results == null) { //request failed
$table = ''; /* if the message date range is posted */ if (isset($_POST['MESSAGE_STARTDATE']) && isset($_POST['MESSAGE_ENDDATE'])) { $dbMan = new DatabaseManager(); $request = ''; if (!$dbMan->establishConnection()) { //database connection error return; } $startDate = $_POST['MESSAGE_STARTDATE']; $endDate = $_POST['MESSAGE_ENDDATE']; $departureAirport = $_POST['MESSAGE_DEPARTING_AIRPORT']; $arrivalAirport = $_POST['MESSAGE_ARRIVAL_AIRPORT']; $table = '<table class="table table-hover">' . '<thead>' . '<tr>' . '<th>Flight Number</th>' . '<th>Message Date</th>' . '<th>Message Time</th>' . '<th>Message Type</th>' . '<th>Message Description</th>' . '</tr>' . '</thead>' . '<tbody>'; $request = new Request('getMessages', 'se_Flights'); $request->addParameter('startDate', $startDate); $request->addParameter('endDate', $endDate); $request->addParameter('depart_airport', $departureAirport); $request->addParameter('arrival_airport', $arrivalAirport); /* Determine what messages to provide in the query results */ /* If the Amendment/Cancelation checkbox is checked */ if (isset($_POST['MESSAGES_AMENDMENTS'])) { $request->addParameter('getAmendments', true); } else { $request->addParameter('getAmendments', false); } /* If the Crossing checkbox is checked */ if (isset($_POST['MESSAGES_CROSSINGS'])) { $request->addParameter('getCrossing', true); } else { $request->addParameter('getCrossing', false);