Constructor::".strtoupper('data').""; $db = database::getInstance(); $this->dbh = $db->getConnection(); } function read_config($name) { $sth = $this->dbh->prepare("SELECT value FROM ast_config WHERE name=:name"); $sth->bindValue(":name", $name, PDO::PARAM_STR); $sth->execute(); $record = $sth->fetch(PDO::FETCH_OBJ); return $record->value; } function update_config($name, $value) { $sth = $this->dbh->prepare("update ast_config set value = :value where name = :name"); $sth->bindValue(":name", $name, PDO::PARAM_STR); $sth->bindValue(":value", $value, PDO::PARAM_STR); $sth->execute(); } function banner() { $sth = $this->dbh->prepare("SELECT id FROM ast_banners WHERE active"); $sth->execute(); if ($sth->rowCount()) { $x = rand(0, $sth->rowCount() - 1); $sth = $this->dbh->prepare("SELECT * FROM ast_banners WHERE active LIMIT $x, 1"); $sth->execute(); $record = $sth->fetch(PDO::FETCH_OBJ); return $record->image; } else return "/UserFiles/Image/ads/ad-schedule.png"; } // ------------------------------------------------------ // Create lookup- from array // ------------------------------------------------------ function lookup_array($a, $control_name, $selected, $submit=FALSE, $option=LOOKUP_OPTION_NULL, $text="") { if ($submit) echo ""; switch ($option) { case LOOKUP_OPTION_NONE: echo ""; break; case LOOKUP_OPTION_ALL: echo ""; break; case LOOKUP_OPTION_TEXT: echo ""; break; } foreach ($a as $key => $value) { echo ""; } echo ""; } // ------------------------------------------------------ // Create lookup- main code // ------------------------------------------------------ function lookup($sql, $control_name, $selected, $submit, $option, $text, $valuefield, $namefield) { if ($submit) echo ""; switch ($option) { case LOOKUP_OPTION_NONE: echo ""; break; case LOOKUP_OPTION_ALL: echo ""; break; case LOOKUP_OPTION_TEXT: echo ""; break; } $sth = $this->dbh->query($sql); while($sourcelist = $sth->fetch(PDO::FETCH_ASSOC)) { echo ""; } echo ""; } // ------------------------------------------------------ // Create lookup on Service Types // ------------------------------------------------------ function lookup_admin_positions($control_name, $selected, $submit=FALSE, $option=LOOKUP_OPTION_NULL, $text="") { $sql = "SELECT * FROM ast_admin_positions Order By postid ASC"; $this->lookup($sql, $control_name, $selected, $submit, $option, $text, 'postid', 'post'); } // ------------------------------------------------------ // Create lookup on Flight Types // ------------------------------------------------------ function lookup_flighttype($control_name, $selected, $submit=FALSE, $option=LOOKUP_OPTION_NULL, $text="") { $sql = "SELECT * FROM ast_flighttype ORDER BY id ASC"; $this->lookup($sql, $control_name, $selected, $submit, $option, $text, 'log_filter', 'name'); } // ------------------------------------------------------ // Create lookup on Aircraft // ------------------------------------------------------ function lookup_aircraft($control_name, $selected, $submit=FALSE, $option=LOOKUP_OPTION_NULL, $text="") { $sql = "SELECT * FROM ast_aircraft ORDER BY name ASC"; $this->lookup($sql, $control_name, $selected, $submit, $option, $text, 'id', 'name'); } // ------------------------------------------------------ // Create lookup on hub_code // ------------------------------------------------------ function lookup_hub($control_name, $selected, $submit=FALSE, $option=LOOKUP_OPTION_NULL, $text="") { $sql = "SELECT * FROM ast_hubs where type = 1 order by name"; $this->lookup($sql, $control_name, $selected, $submit, $option, $text, 'id', 'name'); } // ------------------------------------------------------ // Create lookup on country_code // ------------------------------------------------------ function lookup_country($control_name, $selected, $submit=FALSE, $option=LOOKUP_OPTION_NULL, $text="") { $sql = "SELECT * FROM fshub_country order by country"; $this->lookup($sql, $control_name, $selected, $submit, $option, $text, 'country', 'country'); } // ------------------------------------------------------ // Create lookup on Cargo Aircraft // ------------------------------------------------------ function lookup_cargo_aircraft($control_name, $selected, $submit=FALSE, $option=LOOKUP_OPTION_NULL, $text="") { $sql = "SELECT * FROM ast_aircraft WHERE cargo_allow = 1 ORDER BY name ASC"; $this->lookup($sql, $control_name, $selected, $submit, $option, $text, 'id', 'name'); } // ------------------------------------------------------ // Create lookup on Fleet names // ------------------------------------------------------ function lookup_fleet($control_name, $selected, $submit=FALSE, $option=LOOKUP_OPTION_NULL, $text="") { $sql = "SELECT * FROM ast_fleet"; $this->lookup($sql, $control_name, $selected, $submit, $option, $text, 'id', 'name'); } // ------------------------------------------------------ // Create lookup on Tour Restrictions // ------------------------------------------------------ function lookup_tour_restrictiontype($control_name, $selected, $submit=FALSE, $option=LOOKUP_OPTION_NULL, $text="") { $sql = "SELECT * FROM ast_tours_restrictions ORDER BY id ASC"; $this->lookup($sql, $control_name, $selected, $submit, $option, $text, 'id', 'code'); } // ------------------------------------------------------ // Create lookup on Service Types // ------------------------------------------------------ function lookup_services($control_name, $selected, $submit=FALSE, $option=LOOKUP_OPTION_NULL, $text="") { $sql = "SELECT * FROM ast_services"; $this->lookup($sql, $control_name, $selected, $submit, $option, $text, 'id', 'name'); } // ------------------------------------------------------ // Create lookup on category // ------------------------------------------------------ function lookup_category($which, $control_name, $selected, $submit=FALSE, $option=LOOKUP_OPTION_NULL, $text="") { switch ($which) { case CATEGORY_APP_STATUS: $sql = "SELECT * FROM ast_category_app_status"; break; case CATEGORY_APP_SOURCE: $sql = "SELECT * FROM ast_category_app_source"; break; case CATEGORY_FAQ: $sql = "SELECT * FROM fshub_category_faq"; break; case CATEGORY_NEWS: $sql = "SELECT * FROM ast_category_news"; break; case CATEGORY_EVENT: $sql = "SELECT * FROM ast_category_events"; break; case CATEGORY_LINKS: $sql = "SELECT * FROM ast_category_links"; break; case CATEGORY_STATUS: $sql = "SELECT * FROM ast_category_status"; break; case CATEGORY_MEM_STATUS: $sql = "SELECT * FROM ast_category_status_update"; break; case CATEGORY_CARGO_TYPE: $sql = "SELECT * FROM ast_category_cargotype"; break; } $this->lookup($sql, $control_name, $selected, $submit, $option, $text, 'id', 'code'); } // ------------------------------------------------------ // Return selected status_change_code // ------------------------------------------------------ function status_change_code($id) { $sth = $this->dbh->prepare("SELECT * FROM ast_category_status_update WHERE id = :code"); $sth->bindValue(":code", $id, PDO::PARAM_INT); $sth->execute(); $record = $sth->fetch(PDO::FETCH_OBJ); return $record->code; } // ------------------------------------------------------ // Return selected image on country code // ------------------------------------------------------ function flag($country) { if (empty($country)) return "../images/flags/blank.png"; else { $sth = $this->dbh->prepare("select * from fshub_country where country = :country"); $sth->bindValue(":country", $country, PDO::PARAM_INT); $sth->execute(); $record = $sth->fetch(PDO::FETCH_OBJ); return "../images/flags/".$record->image; } } // ------------------------------------------------------ // Return hub id if icao is a hub // MOVE TO class.flights.php // ------------------------------------------------------ function is_hub($icao) { $sth = $this->dbh->prepare("SELECT * FROM ast_hubs where icao = :location"); $sth->bindValue(":location", $icao, PDO::PARAM_STR); $sth->execute(); if ($sth->rowCount()) { $record = $sth->fetch(PDO::FETCH_OBJ); return $record->id; } else return 0; } // ------------------------------------------------------ // Return selected icao code from hub id // ------------------------------------------------------ function hub_icao($id) { $sth = $this->dbh->prepare("select * from ast_hubs where id = :hubid"); $sth->bindValue(":hubid", $id, PDO::PARAM_INT); $sth->execute(); $record = $sth->fetch(PDO::FETCH_OBJ); return $record->icao; } // ------------------------------------------------------ // Return selected hub name from hub id // ------------------------------------------------------ function hub_name($id) { $sth = $this->dbh->prepare("select * from ast_hubs where id = :hubid"); $sth->bindValue(":hubid", $id, PDO::PARAM_INT); $sth->execute(); $record = $sth->fetch(PDO::FETCH_OBJ); return $record->name; } // ------------------------------------------------------ // Return selected hub short name from hub id // ------------------------------------------------------ function hub_shortname($id) { $sth = $this->dbh->prepare("select * from ast_hubs where id = :hubid"); $sth->bindValue(":hubid", $id, PDO::PARAM_INT); $sth->execute(); $record = $sth->fetch(PDO::FETCH_OBJ); return $record->shortname; } // ------------------------------------------------------ // Return selected Fleet name // ------------------------------------------------------ function fleet_name($id) { $sth = $this->dbh->prepare("select * from ast_fleet where id = :fleetid"); $sth->bindValue(":fleetid", $id, PDO::PARAM_STR); $sth->execute(); $record = $sth->fetch(PDO::FETCH_OBJ); return $record->name; } // ------------------------------------------------------ // Return selected aircraft record // ------------------------------------------------------ function aircraft_record($id) { if ($id == 0) return "NONE SELECTED"; $sth = $this->dbh->prepare("Select * from fshub_aircraft where id = :aircraftid"); $sth->bindValue(":aircraftid", $id, PDO::PARAM_STR); $sth->execute(); $record = $sth->fetch(PDO::FETCH_OBJ); return $record; } // ------------------------------------------------------ // Return selected aircraft name // ------------------------------------------------------ function aircraft_name($id = 0) { if ($id == 0) return "NONE SELECTED"; $sth = $this->dbh->prepare("Select * from fshub_aircraft where id = :aircraftid"); $sth->bindValue(":aircraftid", $id, PDO::PARAM_STR); $sth->execute(); $record = $sth->fetch(PDO::FETCH_OBJ); return $record->name; } // ------------------------------------------------------ // Return selected aircraft cruise speed // ------------------------------------------------------ function aircraft_cruise($id) { if ($id == 0) return 9999; $sth = $this->dbh->prepare("Select * from fshub_aircraft where id = :aircraftid"); $sth->bindValue(":aircraftid", $id, PDO::PARAM_STR); $sth->execute(); $record = $sth->fetch(PDO::FETCH_OBJ); return $record->cruise; } // ------------------------------------------------------ // Return selected Cargo Route Type // ------------------------------------------------------ function cargo_type($id) { $sth = $this->dbh->prepare("select * from ast_category_cargotype where id = :routeid"); $sth->bindValue(":routeid", $id, PDO::PARAM_INT); $sth->execute(); $record = $sth->fetch(PDO::FETCH_OBJ); return $record->code; } // ------------------------------------------------------ // Return the selected airport record // ------------------------------------------------------ function airport_record($icao) { $sth = $this->dbh->prepare("select * from ast_airports where icao = :icao"); $sth->bindValue(":icao", $icao, PDO::PARAM_STR); $sth->execute(); $record = $sth->fetch(PDO::FETCH_OBJ); return $record; } // ------------------------------------------------------ // Check an airport code exists // MOVe TO class.editor.route.php // ------------------------------------------------------ function icao_code_exists($location) { $sth = $this->dbh->prepare("SELECT * from ast_airports WHERE icao = :icao"); $sth->bindValue(":icao", $location, PDO::PARAM_STR); $sth->execute(); if ($sth->rowCount()) return TRUE; else return FALSE; } // // string strtrmvistl( string str, [int maxlen = 64], // [bool right_justify = false], // [string delimter = "\n"]) // // splits a long string into two chunks (a start and an end chunk) // of a given maximum length and seperates them by a given delimeter. // a second chunk can be right-justified within maxlen. // may be used to 'spread' a string over two lines. // function strtrmvistl($str, $maxlen = 64, $right_justify = true, $delimter = "\n") { if(($len = strlen($str = chop($str))) > ($maxlen = max($maxlen, 12))) { $newstr = substr($str, 0, $maxlen - 3); if($len > ($maxlen - 3)) { $endlen = min(($len - strlen($newstr)), $maxlen - 3); $newstr .= "..." . $delimter; if($right_justify) $newstr .= str_pad('', $maxlen - $endlen - 3, ' '); $newstr .= "..." . substr($str, $len - $endlen); } return($newstr); } return($str); } } ?> Constructor::".strtoupper('rank').""; $db = database::getInstance(); $this->dbh = $db->getConnection(); } function fetch($rankid) { $sth = $this->dbh->prepare("Select * from ast_rank where id = :rankid"); $sth->bindValue(":rankid", $rankid, PDO::PARAM_INT); $sth->execute(); $record = $sth->fetch(PDO::FETCH_OBJ); $this->current = $record->rank; $this->image = "../images/rank/".$record->image; } } class user { var $access; // ------------------------------------------------------- // roster variables // ------------------------------------------------------- var $record; var $pilotid; var $pilotid2; var $hubid; var $hub2id; var $name; var $statusid; var $rankid; var $modeid; var $location; var $route; var $cargoid; var $cargocount; var $cargoleg; var $aircraftid; var $fdate; var $hours; var $flights; var $leave_date; var $leave_ERD; var $promo_req; var $award_hours; var $award_flights; var $award_cargo; var $award_online; var $award_48hr; var $award_service; var $completed_online; var $bonus_48hr; var $completed_48hr; var $joindate; var $email; var $pwd; var $pwdreset; var $password; var $country; var $dob; var $homeport; var $simhistory; var $certs; var $sincelastflight; // var $rank; // ------------------------------------------------------- // Flight/Route Information // ------------------------------------------------------- var $route_array; var $route_str; var $route_count; var $route_start; var $routeflights; // number of flights in the route var $route_flight; var $route_flight_dep; var $route_flight_arr; var $routelegs; // ------------------------------------------------------- // hub data // ------------------------------------------------------- var $hub_name; var $hub_shortname; // ------------------------------------------------------- // location variables // ------------------------------------------------------- var $current_location; // ------------------------------------------------------- // additional info - calculated by pilotid // ------------------------------------------------------- var $age; var $Flights_Total; var $Hours_Total; var $Miles_Total; var $dbh; function __construct() { if (DEBUGMODE) echo "
Constructor::".strtoupper('user')."
"; $db = database::getInstance(); $this->dbh = $db->getConnection(); $this->rank = new rank(); $this->current_location = new airport(); } function get_roster($id) { $sth = $this->dbh->prepare("SELECT *, DATEDIFF(CURDATE() , fdate) AS sincelastflight FROM ast_roster WHERE pilotid = :pilotid"); $sth->bindValue(":pilotid", $id, PDO::PARAM_STR); $sth->execute(); if (!$sth->rowCount() or $id === 'AST000') return FALSE; $sth->setFetchMode(PDO::FETCH_INTO, $this); $sth->fetch(); $this->access = $this->get_access(); $this->set_hub_data(); $this->rank->fetch($this->rankid); $this->current_location->fetch($this->location); $this->age = $this->get_age($this->dob); $this->get_route(); return TRUE; } // ------------------------------------------------------ // Set hub data // ------------------------------------------------------ function set_hub_data() { $sth = $this->dbh->prepare("select * from ast_hubs where id = :hubid"); $sth->bindValue(":hubid", $this->hubid, PDO::PARAM_INT); $sth->execute(); $rec = $sth->fetch(PDO::FETCH_OBJ); $this->hub_name = $rec->name; $this->hub_shortname = $rec->shortname; } function put_roster() { $sth = $this->dbh->prepare("UPDATE ast_roster SET hubid = :hubid, name = :name, email = :email, password = :password, statusid = :statusid, rankid = :rankid, modeid = :modeid, country = :country, flights = :flights, hours = :hours, route = :route, location = :location, certs = :certs, fdate = :fdate, cargoid = :cargoid, cargocount = :cargocount, cargoleg = :cargoleg, aircraftid = :aircraftid, hub2id = :hub2id, completed_online = :completed_online, bonus_48hr = :bonus_48hr, completed_48hr = :completed_48hr, joindate = :joindate, dob = :dob, homeport = :homeport, simhistory = :simhistory, leave_date = :leave_date, leave_ERD = :leave_ERD, promo_req = :promo_req, award_hours = :award_hours, award_flights = :award_flights, award_cargo = :award_cargo, award_online = :award_online, award_48hr = :award_48hr, award_service = :award_service WHERE pilotid = :pilotid"); $sth->bindValue(":hubid", $this->hubid, PDO::PARAM_INT); $sth->bindValue(":name", $this->name, PDO::PARAM_STR); $sth->bindValue(":email", $this->email, PDO::PARAM_STR); $sth->bindValue(":password", $this->password, PDO::PARAM_STR); $sth->bindValue(":statusid", $this->statusid, PDO::PARAM_INT); $sth->bindValue(":rankid", $this->rankid, PDO::PARAM_INT); $sth->bindValue(":modeid", $this->modeid, PDO::PARAM_INT); $sth->bindValue(":country", $this->country, PDO::PARAM_STR); $sth->bindValue(":flights", $this->flights, PDO::PARAM_INT); $sth->bindValue(":hours", $this->hours, PDO::PARAM_STR); $sth->bindValue(":route", $this->route, PDO::PARAM_STR); $sth->bindValue(":location", $this->location, PDO::PARAM_STR); $sth->bindValue(":certs", $this->certs, PDO::PARAM_INT); $sth->bindValue(":fdate", $this->fdate, PDO::PARAM_STR); $sth->bindValue(":cargoid", $this->cargoid, PDO::PARAM_INT); $sth->bindValue(":cargocount", $this->cargocount, PDO::PARAM_INT); $sth->bindValue(":cargoleg", $this->cargoleg, PDO::PARAM_INT); $sth->bindValue(":aircraftid", $this->aircraftid, PDO::PARAM_INT); $sth->bindValue(":hub2id", $this->hub2id, PDO::PARAM_INT); $sth->bindValue(":completed_online", $this->completed_online, PDO::PARAM_INT); $sth->bindValue(":bonus_48hr", $this->bonus_48hr, PDO::PARAM_INT); $sth->bindValue(":completed_48hr", $this->completed_48hr, PDO::PARAM_INT); $sth->bindValue(":joindate", $this->joindate, PDO::PARAM_STR); $sth->bindValue(":dob", $this->dob, PDO::PARAM_STR); $sth->bindValue(":homeport", $this->homeport, PDO::PARAM_STR); $sth->bindValue(":simhistory", $this->simhistory, PDO::PARAM_STR); $sth->bindValue(":leave_date", $this->leave_date, PDO::PARAM_STR); $sth->bindValue(":leave_ERD", $this->leave_ERD, PDO::PARAM_STR); $sth->bindValue(":promo_req", $this->promo_req, PDO::PARAM_INT); $sth->bindValue(":award_hours", $this->award_hours, PDO::PARAM_INT); $sth->bindValue(":award_flights", $this->award_flights, PDO::PARAM_INT); $sth->bindValue(":award_cargo", $this->award_cargo, PDO::PARAM_INT); $sth->bindValue(":award_online", $this->award_online, PDO::PARAM_INT); $sth->bindValue(":award_48hr", $this->award_48hr, PDO::PARAM_INT); $sth->bindValue(":award_service", $this->award_service, PDO::PARAM_INT); $sth->bindValue(":pilotid", $this->pilotid, PDO::PARAM_STR); $sth->execute(); return $sth->rowCount(); } function extra_info($id) { $sth = $this->dbh->prepare("SELECT count(id) as TotalFlights, sum(block_time) as TotalHours, sum(distance) as TotalMiles FROM ast_ft_pirep WHERE pilotid = :pilotid"); $sth->bindValue(":pilotid", $this->pilotid, PDO::PARAM_STR); $sth->execute(); $record = $sth->fetch(PDO::FETCH_OBJ); $this->Flights_Total = $record->TotalFlights; $this->Hours_Total = $record->TotalHours + 0; $this->Miles_Total = $record->TotalMiles; } function get_access() { $sth = $this->dbh->prepare("SELECT MIN(adminid) as aid FROM ast_ops WHERE pilotid = :pilotid GROUP BY pilotid"); $sth->bindValue(":pilotid", $this->pilotid, PDO::PARAM_STR); $sth->execute(); if ($sth->rowCount()) { $rec = $sth->fetch(PDO::FETCH_OBJ); return $rec->aid; } else return 0; } function get_hubadmin() { $sth = $this->dbh->prepare("SELECT * FROM ast_ops WHERE pilotid = :pilotid AND adminid > 10"); $sth->bindValue(":pilotid", $this->pilotid, PDO::PARAM_STR); $sth->execute(); if ($sth->rowCount()) { $rec = $sth->fetch(PDO::FETCH_OBJ); return $rec->hubid; } else return 0; } function get_age($date) { @ini_set('date.timezone' , "UTC"); $dobymd = explode( "-", $date); $year=$dobymd[0]; $month=$dobymd[1]; $day=$dobymd[2]; if ($year == 0 ) return false; $age = date("Y") - $year; if ($month > date("m")) $age--; elseif ($month == date("m")) { if ($day > date("d")) $age--; } return $age; } // ------------------------------------------------------ // Append Event to Personal Log // ------------------------------------------------------ function EventLog_Append($text) { $sth = $this->dbh->prepare("INSERT INTO ast_pilot_log (pilotid, date, event) VALUES (:pilotid, now(), :text)"); $sth->bindValue(":pilotid", $this->pilotid, PDO::PARAM_STR); $sth->bindValue(":text", $text, PDO::PARAM_STR); $sth->execute(); } function recalc_flightHours() { $sth = $this->dbh->prepare("select count(id) as TotalFlights, sum(block_time) as TotalHours from ast_ft_pirep where pilotid = :pilotid"); $sth->bindValue(":pilotid", $this->pilotid, PDO::PARAM_STR); $sth->execute(); $record = $sth->fetch(PDO::FETCH_OBJ); $this->flights = $record->TotalFlights; $this->hours = $record->TotalHours; $this->put_roster(); } // ------------------------------------------------------ // Return current status // ------------------------------------------------------ function status() { $sth = $this->dbh->prepare("Select * from ast_category_status where id = :statusid"); $sth->bindValue(":statusid", $this->statusid, PDO::PARAM_INT); $sth->execute(); $rec = $sth->fetch(PDO::FETCH_OBJ); return $rec->code; } // ------------------------------------------------------ // Return current status image // ------------------------------------------------------ function status_image() { switch ($this->statusid) { case STATUS_ACTIVE: $status_image = "b_green.gif"; if ($this->hours < 30 and $this->sincelastflight > 120) $status_image = "b_yellow.gif"; if ($this->hours >= 30 and $this->sincelastflight > 120) $status_image = "b_yellow.gif"; break; case STATUS_ONLEAVE: $status_image = "b_blue.gif"; break; case STATUS_SUSPENDED: $status_image = "b_red.gif"; break; case STATUS_WITHDRAWN: $status_image = "b_black.gif"; break; case STATUS_ASSOCIATE: $status_image = "b_grey.gif"; break; } return ("../images/icons/".$status_image); } // ------------------------------------------------------ // Return current aircraft name // ------------------------------------------------------ function aircraft_name($id = 0) { if ($this->aircraftid == 0) return "NONE SELECTED"; $sth = $this->dbh->prepare("Select * from ast_aircraft where id = :aircraftid"); $sth->bindValue(":aircraftid", $this->aircraftid, PDO::PARAM_INT); $sth->execute(); $rec = $sth->fetch(PDO::FETCH_OBJ); return $rec->name; } // ------------------------------------------------------ // Return current aircraft type // ------------------------------------------------------ function aircraft_icao() { if ($this->aircraftid == 0) return "NONE SELECTED"; $sth = $this->dbh->prepare("Select * from ast_aircraft where id = :aircraftid"); $sth->bindValue(":aircraftid", $this->aircraftid, PDO::PARAM_INT); $sth->execute(); $rec = $sth->fetch(PDO::FETCH_OBJ); return $rec->icao; } // ------------------------------------------------------ // Return current flight mode // ------------------------------------------------------ function mode() { $modestatus = $this->modeid ? "CARGO" : "PAX"; return $modestatus; } // ------------------------------------------------------ // is current location a hub ? // returns hub id or zero // ------------------------------------------------------ function at_hub() { $sth = $this->dbh->prepare("SELECT * FROM ast_hubs where icao = :location"); $sth->bindValue(":location", $this->location, PDO::PARAM_STR); $sth->execute(); if ($sth->rowCount()) { $rec = $sth->fetch(PDO::FETCH_OBJ); return $rec->id; } else return 0; } // ------------------------------------------------------ // Return user flag image // ------------------------------------------------------ function flag_image() { if (empty($this->country)) return "../images/flags/blank.png"; else { $sth = $this->dbh->prepare("Select * from ast_country where country = :countryid"); $sth->bindValue(":countryid", $this->country, PDO::PARAM_INT); $sth->execute(); $record = $sth->fetch(PDO::FETCH_OBJ); return "../images/flags/".$record->image; } } function email_count() { $sth = $this->dbh->prepare("SELECT * FROM ast_email WHERE sent = 0 AND who = :memberid"); $sth->bindValue(":memberid", $this->pilotid, PDO::PARAM_STR); $sth->execute(); return $sth->rowCount(); } // ------------------------------------------------------ // Clear current route // ------------------------------------------------------ function clear_route() { $this->route = "NONE"; $this->route_str = "NONE"; $this->route_array = ""; $this->routelegs = 0; $this->routeflights = 0; $this->route_count = 0; $this->route_flight = "NONE"; $this->route_flight_dep = "NONE"; $this->route_flight_arr = "NONE"; } // ------------------------------------------------------ // Get current route information and first flight // ------------------------------------------------------ function get_route() { if ($this->route == "NONE") $this->clear_route(); else { $this->route_str = $this->route; $this->route_array = explode("-",$this->route_str); $this->route_count = count($this->route_array); $this->routelegs = $this->route_count; $this->routeflights = $this->routelegs - 1; $this->route_flight_dep = $this->route_array[0]; $this->route_flight_arr = $this->route_array[1]; $this->route_flight = $this->route_flight_dep." - ".$this->route_flight_arr; } } // ------------------------------------------------------ // Add leg to route // ------------------------------------------------------ function add_route($wp) { switch ($this->route_count) { case 0: $this->route = $this->location."-".$wp; break; default: $this->route .= "-".$wp; break; } $this->get_route(); } // ------------------------------------------------------ // Remove first flight from route // ------------------------------------------------------ function remove_route_first() { switch ($this->route_count) { case 2: $this->clear_route(); break; default: for ($i = 1; $i <= $this->route_count - 1; $i++) { if ($i == 1) $this->route = $this->route_array[$i]; else $this->route .= "-".$this->route_array[$i]; } break; } $this->get_route(); } // ------------------------------------------------------ // Remove last flight from route // ------------------------------------------------------ function remove_route_last() { switch ($this->route_count) { case 2: $this->clear_route(); break; default: for ($i = 0; $i < $this->route_count - 1; $i++) { if ($i == 0) $this->route = $this->route_array[$i]; else $this->route .= "-".$this->route_array[$i]; } break; } $this->get_route(); } } ?>Constructor::".strtoupper('pager').""; $db = database::getInstance(); $this->dbh = $db->getConnection(); } public static function getInstance() { if (!self::$m_pInstance) { self::$m_pInstance = new pager(); } return self::$m_pInstance; } function set_sql($sql) { $this->sql = $sql; } function set_numpages() { $sth = $this->dbh->query($this->sql); $this->num_pages = ceil($sth->rowCount() / $this->records_per_page); } function set_current($move) { switch ($move) { case EDITOR_FIRSTPAGE: $this->page = 1; break; case EDITOR_PREVPAGE: $this->page--; break; case EDITOR_NEXTPAGE: $this->page++; break; case EDITOR_LASTPAGE: $this->page = $this->num_pages; break; } $this->page = max($this->page, 1); $this->page = min($this->page, $this->num_pages); $this->start = ($this->page - 1) * $this->records_per_page; $this->start = max($this->start, 0); } public function set_page($value) { $value = is_null($value) ? 1 : $value; $this->page = (int)$value; } public function currentpage() { return (int)$this->page; } public function start() { return (int)$this->start; } public function set_records($value) { $value = is_null($value) ? 10 : $value; $this->records_per_page = (int)$value; } public function records() { return (int)$this->records_per_page; } public function header($title) { echo "
".$title."
"; } public function navigation_noform($header = NULL) { echo ""; echo ""; echo "
"; echo "
"; echo "Items per Page:  "; echo ""; echo "
"; echo "
"; echo ""; echo ""; echo "  Page ".$this->page." of ".$this->num_pages."  "; echo ""; echo ""; echo "
"; echo "
"; echo "".$header.""; echo "
"; echo "
"; } public function no_selection($text = 'There are no entries for this selection.......') { echo "
"; echo "

"; echo $text."

"; echo "
"; } } Constructor::".strtoupper('validate_input').""; $db = database::getInstance(); $this->dbh = $db->getConnection(); } public static function getInstance() { if (!self::$m_pInstance) { self::$m_pInstance = new validate_input(); } return self::$m_pInstance; } function add($variable_name, $field_name, $check_type, $minvalue = NULL, $maxvalue=NULL, $default = NULL) { $this->items[$variable_name] = array('field' => $field_name, 'type' => $check_type, 'default' => $default, 'rangemin' => $minvalue, 'rangemax' => $maxvalue); } function show_items() { echo "
";
    print_r($this->items);
    echo "
"; } function set_error($errstr) { $this->errno = TRUE; $this->error = $errstr; } function clear_error() { $this->errno = FALSE; $this->error = ""; } function GetData($var, $default = NULL) { if (isset($this->Data[$var])) if (is_array($this->Data[$var])) return $this->Data[$var]; else return stripslashes($this->Data[$var]); else return $default; } function GetMode() { if(array_key_exists('PFirst_x', $this->Data)) return EDITOR_FIRSTPAGE; if(array_key_exists('PPrev_x', $this->Data)) return EDITOR_PREVPAGE; if(array_key_exists('PNext_x', $this->Data)) return EDITOR_NEXTPAGE; if(array_key_exists('PLast_x', $this->Data)) return EDITOR_LASTPAGE; if(array_key_exists('Create_x', $this->Data)) return EDITOR_NEW; if(array_key_exists('Edit_x', $this->Data)) return EDITOR_EDIT; if(array_key_exists('Delete_x', $this->Data)) return EDITOR_DELETE; if(array_key_exists('Update_x', $this->Data)) return EDITOR_UPDATE; if(array_key_exists('Save_x', $this->Data)) return EDITOR_SAVE; if(array_key_exists('Preview_x', $this->Data)) return EDITOR_PREVIEW; if(array_key_exists('Publish_x', $this->Data)) return EDITOR_PUBLISH; if(array_key_exists('BookIN_x', $this->Data)) return EDITOR_BOOKIN; if(array_key_exists('BookOUT_x', $this->Data)) return EDITOR_BOOKOUT; if(array_key_exists('Filter_x', $this->Data)) return EDITOR_FILTER; if(array_key_exists('Copy_x', $this->Data)) return EDITOR_COPY; if(array_key_exists('EmailSendALL_x', $this->Data)) return EDITOR_SENDALL; if(array_key_exists('EmailSend_x', $this->Data)) return EDITOR_SEND; if(array_key_exists('EmailPurge_x', $this->Data)) return EDITOR_PURGE; if(array_key_exists('UPLOADINI_x', $this->Data)) return UPLOADINI; if(array_key_exists('UPLOADFSN_x', $this->Data)) return UPLOADFSN; if(array_key_exists('EditRoute_x', $this->Data)) return EDIT_ROUTE; if(array_key_exists('EditPlan_x', $this->Data)) return EDIT_PLAN; if(array_key_exists('PAdd_x', $this->Data)) return EDIT_ADD; if(array_key_exists('PUpdate_x', $this->Data)) return EDIT_UPDATE; if(array_key_exists('PDelete_x', $this->Data)) return EDIT_DELETE; if(array_key_exists('PUp_x', $this->Data)) return EDIT_UP; if(array_key_exists('PDown_x', $this->Data)) return EDIT_DOWN; if(array_key_exists('JumpToHub_x', $this->Data)) return JUMPTOHUB; if(array_key_exists('Cancel_x', $this->Data)) return CANCEL; if(array_key_exists('Reset_x', $this->Data)) return RESET; if(array_key_exists('Submit_x', $this->Data)) return SUBMIT; if(array_key_exists('Register_x', $this->Data)) return REGISTER; if(array_key_exists('Abandon_x', $this->Data)) return ABANDON; if(array_key_exists('Pirep_x', $this->Data)) return PIREP; if(array_key_exists('Resume_x', $this->Data)) return RESUME; if(array_key_exists('Recalc_x', $this->Data)) return RECALC; if(array_key_exists('MemEdit_x', $this->Data)) return MEMBER_EDIT; if(array_key_exists('MemEmail_x', $this->Data)) return MEMBER_EMAIL; if(array_key_exists('MemDelete_x', $this->Data)) return MEMBER_DELETE; if(array_key_exists('MemPromo_x', $this->Data)) return MEMBER_PROMO; if(array_key_exists('ModeCARGO_x', $this->Data)) return MODE_CARGO; if(array_key_exists('ModePAX_x', $this->Data)) return MODE_PAX; if(array_key_exists('Reminder_x', $this->Data)) return REMINDER; if(array_key_exists('Reject_x', $this->Data)) return REJECT; if(array_key_exists('Accept_x', $this->Data)) return ACCEPT; return EDITOR_NOACTION; } function check($t) { $this->errno = FALSE; $this->Data = $t; if (!is_array($this->items)) return; foreach (new ArrayIterator($this->items) as $var=>$opt) { //echo "ITEMS :".$var."
"; switch($opt['type']) { case V_ALPHA: $this->valphanumeric($var, $opt); break; case V_TEXT_SAN: $this->vtext_sanitized($var, $opt); break; case V_TEXT_RAW: $this->vtext_raw($var, $opt); break; case V_INT: $this->vinteger($var, $opt); break; case V_INTDEF: $this->vinteger_default($var, $opt); break; case V_INTZERO: $this->vinteger_zero($var, $opt); break; case V_INTNZ: $this->vinteger_notzero($var, $opt); break; case V_FLOAT: $this->vfloat($var, $opt); break; case V_EMAIL: $this->vemail($var, $opt); break; case V_DATE: $this->vdate($var, $opt); break; case V_ICAO: $this->vicao($var, $opt); break; case V_TIME: $this->vtime($var, $opt); break; case V_ARRAY: $this->varray($var, $opt); break; case V_URL: $this->vurl($var, $opt); break; case V_IP: $this->vip($var, $opt); break; } if ($this->errno) return; } } function vinteger($var, $opt) { if (!isset($this->Data[$var])) { if (ERROR_NOT_ISSET) $this->set_error("FIELD : ".$opt['field'].": is not set."); return; } $rangemin = is_null($opt['rangemin']) ? -65535 : $opt['rangemin']; $rangemax = is_null($opt['rangemax']) ? PHP_INT_MAX : $opt['rangemax']; $options = array('options' => array('min_range' => $rangemin, 'max_range' => $rangemax)); //echo "checking IS INTEGER ".$var." = ".$this->Data[$var]." range ".$rangemin." to ".$rangemax."
"; if (filter_var($this->Data[$var], FILTER_VALIDATE_INT, $options) === FALSE) $this->set_error("FIELD : ".$opt['field']." : is INVALID or out of range [".$rangemin."-".$rangemax."]"); } function vinteger_default($var, $opt) { if (!isset($this->Data[$var])) { if (ERROR_NOT_ISSET) $this->set_error("FIELD : ".$opt['field'].": is not set."); return; } $rangemin = is_null($opt['rangemin']) ? 0 : $opt['rangemin']; $default = is_null($opt['default']) ? 0 : $opt['default']; $options = array('options' => array('default' => $default,'min_range' => $rangemin)); //echo "checking IS INTDEF ".$var." = ".$this->Data[$var]." default ".$default." rangemin ".$rangemin."
"; $this->Data[$var] = filter_var($this->Data[$var], FILTER_VALIDATE_INT, $options); } function vinteger_zero($var, $opt) { if (!isset($this->Data[$var])) { if (ERROR_NOT_ISSET) $this->set_error("FIELD : ".$opt['field'].": is not set."); return; } $rangemin = is_null($opt['rangemin']) ? 0 : $opt['rangemin']; $options = array('options' => array('default' => 0,'min_range' => $rangemin)); //echo "checking IS INTEGER ".$var." = ".$this->Data[$var]." range ".$rangemin." to ".$rangemax."
"; $this->Data[$var] = filter_var($this->Data[$var], FILTER_VALIDATE_INT, $options); } function vinteger_notzero($var, $opt) { if (!isset($this->Data[$var])) { if (ERROR_NOT_ISSET) $this->set_error("FIELD : ".$opt['field'].": is not set."); return; } $rangemin = is_null($opt['rangemin']) ? 1 : $opt['rangemin']; $options = array('options' => array('min_range' => $rangemin)); //echo "checking IS INTEGER NOT ZERO ".$var." = ".$this->Data[$var]." NOTZERO
"; if (filter_var($this->Data[$var], FILTER_VALIDATE_INT, $options) === FALSE) $this->set_error("FIELD : ".$opt['field']." : is INVALID"); } function vfloat($var, $opt) { if (!isset($this->Data[$var])) { if (ERROR_NOT_ISSET) $this->set_error("FIELD : ".$opt['field'].": is not set."); return; } //echo "checking IS FLOAT ".$variable." = ".$testvalue."
"; if (filter_var($this->Data[$var], FILTER_VALIDATE_FLOAT) === FALSE) $this->set_error("FIELD : ".$opt['field']." : is INVALID"); } function valphanumeric($var, $opt) { if (!isset($this->Data[$var])) { if (ERROR_NOT_ISSET) $this->set_error("FIELD : ".$opt['field'].": is not set."); return; } $rangemin = is_null($opt['rangemin']) ? 1 : $opt['rangemin']; $rangemax = is_null($opt['rangemax']) ? 1000 : $opt['rangemax']; //echo "checking IS ALPHANUM ".$var." = ".$this->Data[$var]."
"; if (!ctype_alnum($this->Data[$var])) { $this->set_error("FIELD : ".$opt['field']." : is empty or not alphanumeric."); return; } if (!is_null($opt['rangemin'])) { //echo "checking IS ALPHANUM LENGTH ".$var." = ".$this->Data[$var]." range ".$rangemin." to ".$rangemax."
"; if (strlen($this->Data[$var]) < $rangemin || strlen($this->Data[$var]) > $rangemax) $this->set_error("FIELD : ".$opt['field']." : length not between $rangemin and $rangemax characters."); } } function vtext_sanitized($var, $opt) { if (!isset($this->Data[$var])) { if (ERROR_NOT_ISSET) $this->set_error("FIELD : ".$opt['field'].": is not set."); return; } $rangemin = is_null($opt['rangemin']) ? 1 : $opt['rangemin']; $rangemax = is_null($opt['rangemax']) ? 1000 : $opt['rangemax']; if (empty($this->Data[$var])) { $this->set_error("FIELD : ".$opt['field']." is blank."); return; } $this->Data[$var] = filter_var($this->Data[$var], FILTER_SANITIZE_STRING); } function vtext_raw($var, $opt) { if (!isset($this->Data[$var])) { if (ERROR_NOT_ISSET) $this->set_error("FIELD : ".$opt['field'].": is not set."); return; } $rangemin = is_null($opt['rangemin']) ? 1 : $opt['rangemin']; $rangemax = is_null($opt['rangemax']) ? 1000 : $opt['rangemax']; if (empty($this->Data[$var])) { $this->set_error("FIELD : ".$opt['field']." is blank."); return; } if (!is_null($opt['rangemin'])) { if (strlen($this->Data[$var]) < $rangemin || strlen($this->Data[$var]) > $rangemax) $this->set_error("FIELD : ".$opt['field']." : length not between $rangemin and $rangemax characters."); } } function vemail($var, $opt) { if (!isset($this->Data[$var])) { if (ERROR_NOT_ISSET) $this->set_error("FIELD : ".$opt['field'].": is not set."); return; } //echo "checking IS EMAIL ".$variable." = ".$this->Data[$var]."
"; if (filter_var($this->Data[$var], FILTER_VALIDATE_EMAIL) === FALSE) $this->set_error("FIELD : ".$opt['field']." : is INVALID"); } function vdate($var, $opt) { if (!isset($this->Data[$var])) { if (ERROR_NOT_ISSET) $this->set_error("FIELD : ".$opt['field'].": is not set."); return; } //echo "checking IS DATE ".$variable." = ".$testvalue."
"; $p = explode("-", $this->Data[$var]."-00-00-00"); if (!checkdate ((int)$p[1], (int)$p[2], (int)$p[0])) $this->set_error("FIELD : ".$opt['field']." : is an INVALID date"); } function vtime($var, $opt) { if (!isset($this->Data[$var])) { if (ERROR_NOT_ISSET) $this->set_error("FIELD : ".$opt['field'].": is not set."); return; } //echo "checking IS TIME ".$variable." = ".$testvalue."
"; if (strlen($this->Data[$var]) != 4 || !is_numeric($this->Data[$var])) { $this->set_error("FIELD : ".$opt['field']." : is not a valid time (0000 - 2359)"); return; } $hours = intval($this->Data[$var] / 100); $mins = intval($this->Data[$var] % 100); if ($hours < 0 || $hours > 23) { $this->set_error("FIELD : ".$opt['field']." : is not a valid time (0000 - 2359)"); return; } if ($mins < 0 || $mins > 59) { $this->set_error("FIELD : ".$opt['field']." : is not a valid time (0000 - 2359)"); } } function vicao($var, $opt) { if (!isset($this->Data[$var])) { if (ERROR_NOT_ISSET) $this->set_error("FIELD : ".$opt['field'].": is not set."); return; } //echo "checking IS ICAO ".$variable." = ".$testvalue."
"; if (empty($this->Data[$var])) { $this->set_error("FIELD : ".$opt['field']." is blank : Please enter a valid ICAO airport code."); return; } $sth = $this->dbh->prepare("SELECT * from ast_airports WHERE icao = :icao"); $sth->bindValue(":icao", $this->Data[$var], PDO::PARAM_STR); $sth->execute(); if (!$sth->rowCount()) $this->set_error("FIELD : ".$opt['field']." does not exist! : Please enter a valid ICAO airport code."); } function varray($var, $opt) { if (!isset($this->Data[$var])) { if (ERROR_NOT_ISSET) $this->set_error("FIELD : ".$opt['field'].": is not set."); return; } //echo "checking IS ARRAY ".$var." = ".$this->Data[$var]."
"; if (is_array($this->Data[$var])) { if ($this->Data[$var][0] == 0) { $this->set_error("FIELD : ".$opt['field']." is empty. Please select an Option."); return; } } else $this->set_error("FIELD : ".$opt['field']." is not an array."); } function vurl($var, $opt) { if (!isset($this->Data[$var])) { if (ERROR_NOT_ISSET) $this->set_error("FIELD : ".$opt['field'].": is not set."); return; } //echo "checking IS URL ".$variable." = ".$testvalue."
"; if (filter_var($this->Data[$var], FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED) === FALSE) $this->set_error("FIELD : ".$opt['field']." : is INVALID"); } function vip($var, $opt) { if (!isset($this->Data[$var])) { if (ERROR_NOT_ISSET) $this->set_error("FIELD : ".$opt['field'].": is not set."); return; } //0 holds IP, 1 holds port if exists $test_array = explode(":", $this->Data[$var]); if (count($test_array) == 2) // we have a port number { $rangemin = 0; $rangemax = 65535; $options = array('options' => array('min_range' => $rangemin, 'max_range' => $rangemax)); if (filter_var($test_array[1], FILTER_VALIDATE_INT, $options) === FALSE) $this->set_error("FIELD : ".$opt['field']." : is INVALID or out of range [".$rangemin."-".$rangemax."]"); } if (filter_var($test_array[0], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === FALSE) $this->set_error("FIELD : ".$opt['field']." : is INVALID"); } function show_error() { echo "
"; echo "Error"; echo "USER NOTICE: ".$this->error; echo "
"; } function show_text($t) { echo "
"; echo "Information"; echo $t; echo "
"; } //------------------------------------------------------ // Check number of hours > 0 and < 24 //------------------------------------------------------ //function hours($start, $stop) // { // ---- Calculate Totaltime from Start/Stop times ------ //----- Check times spanning midnight ------------------ // $total = intval($stop) - intval($start); // if ($total < 0) $total = $total + 2400; // if ($total <= 0 || $total >= 2400) // $this->set_error("Block time is outside acceptable limits."); // return intval($total / 100) + (($total % 100) / 60); // decimal hours // } //------------------------------------------------------ // Check number of hours > 0 and < 24 // ---- Calculate Totaltime from Start/Stop times ------ //----- Check times spanning midnight ------------------ //------------------------------------------------------ function hours($start, $stop) { $tstart = intval(substr($start,0,4)); $tstop = intval(substr($stop,0,4)); $hstart = intval(substr($start,0,2)); $hstop = intval(substr($stop,0,2)); $mstart = intval(substr($start,2,2)); $mstop = intval(substr($stop,2,2)); $day = 1; $Xstart = mktime ($hstart, $mstart, 0, 1, $day, 2010 ); if ($tstart > $tstop) $day = 2; $Xstop = mktime ($hstop, $mstop, 0, 1, $day, 2010 ); $diff = $Xstop - $Xstart; //Return decimal hours $flighthours = sprintf("%01.2f", $diff / 3600); if ($flighthours <= 0 || $flighthours >= 2400) $this->set_error("Block time is outside acceptable limits."); return $flighthours; } //------------------------------------------------------ // get $block_hhmm //------------------------------------------------------ function block_hhmm($start, $stop) { $tstart = intval(substr($start,0,4)); $tstop = intval(substr($stop,0,4)); $hstart = intval(substr($start,0,2)); $hstop = intval(substr($stop,0,2)); $mstart = intval(substr($start,2,2)); $mstop = intval(substr($stop,2,2)); $day = 1; $Xstart = mktime ($hstart, $mstart, 0, 1, $day, 2010 ); if ($tstart > $tstop) $day = 2; $Xstop = mktime ($hstop, $mstop, 0, 1, $day, 2010 ); $diff = $Xstop - $Xstart; $hours = intval($diff / 3600); $minutes = ($diff - ($hours * 3600)) / 60; //Return hh:mm return $hours.":".sprintf("%02d", $minutes); } function flight_time($dep, $des, $ac, $blocktime, $allowed) { if ($dep === $des) { $this->set_error("Departure and Destination are the same."); return; } $sth = $this->dbh->prepare("SELECT * FROM ast_airports WHERE icao = :orig or icao = :dest"); $sth->bindValue(":orig", $dep, PDO::PARAM_STR); $sth->bindValue(":dest", $des, PDO::PARAM_STR); $sth->execute(); if ($sth->rowCount() <> 2) { $this->set_error("Must provide two Airport ID's."); return; } $record = $sth->fetch(PDO::FETCH_OBJ); $orig_lat = $record->latitude; $orig_lon = $record->longitude; $record = $sth->fetch(PDO::FETCH_OBJ); $dest_lat = $record->latitude; $dest_lon = $record->longitude; $distance = $this->CalcDistance($orig_lat, $orig_lon, $dest_lat, $dest_lon); $sth = $this->dbh->prepare("SELECT * FROM ast_aircraft WHERE id = :aircraftid"); $sth->bindValue(":aircraftid", $ac, PDO::PARAM_INT); $sth->execute(); if (!$sth->rowCount()) { $this->set_error("Aircraft Cruise Speed is not available."); return; } $record = $sth->fetch(PDO::FETCH_OBJ); $cruise = $record->cruise; $range = $record->stdrange; // ete time for this flight // distance / cruise speed $ete = ($distance / $cruise); // maximum time for this flight // distance / cruise speed + additional timelimit $max_time = ($distance / $cruise) + $allowed; // minimum time for this flight // distance / 120% cruise speed $min_time = $distance / ($cruise * 1.2); if ($blocktime < $min_time or $blocktime > $max_time) $this->set_error("Block time is outside acceptable limits."); //$diff = abs($blocktime - $ete); //if ($diff > $allowed) // $this->set_error("Block time is outside acceptable limits."); //if ($distance > $range) // $this->set_error("Distance is outside this aircrafts range."); //echo "Distance ".$distance." Range ".$range." ETE ".$ETE."
"; } function compare($str1, $str2, $errstr) { if (!($str1 === $str2)) $this->set_error($errstr." do not match."); } // ------------------------------------------------------ // Calculate distance between orig and dest // ------------------------------------------------------ function CalcDistance($orig_lat, $orig_lon, $dest_lat, $dest_lon) { // convert degress to radians $radLAT1 = deg2rad($orig_lat); $radLAT2 = deg2rad($dest_lat); $radLONG1 = deg2rad($orig_lon); $radLONG2 = deg2rad($dest_lon); // calculate delta $deltaLAT = $radLAT2 - $radLAT1; $deltaLONG = $radLONG2 - $radLONG1; $sLAT = sin($deltaLAT / 2); $sLONG = sin($deltaLONG / 2); $s2LAT = $sLAT * $sLAT; $s2LONG = $sLONG * $sLONG; $a = $s2LAT + cos($radLAT1) * cos($radLAT2) * $s2LONG; $c = 2 * atan2(sqrt($a), sqrt(1 - $a)); $dKM = $c * 6371.00; $dMILES = $dKM * 0.539956803; return sprintf("%0.2f",$dMILES); } } ?> Constructor::".strtoupper('buttons').""; } public static function getInstance() { if (!self::$m_pInstance) { self::$m_pInstance = new buttons(); } return self::$m_pInstance; } function input($name, $button_name, $alt_text, $confirm = FALSE) { $dir = "../images/buttons/"; $normal_image = $dir.$button_name; if ($confirm) return " "; else return " "; } function rollover_input($name, $button_name, $alt_text) { $dir = "../images/buttons/"; $normal_image = $dir.$button_name."_f1.png"; $over_image = $dir.$button_name."_f2.png"; return " "; } function rollover_select($name, $button_name, $alt_text) { $dir = "../images/buttons/"; $normal_image = $dir.$button_name."_f1.png"; $over_image = $dir.$button_name."_f2.png"; return " "; } function image($button_name, $alt_text) { $dir = "../images/buttons/"; $normal_image = $dir.$button_name; return " ".$alt_text.""; } function image_link($button_name, $alt_text, $ref, $external=FALSE) { $dir = "../images/buttons/"; $normal_image = $dir.$button_name; $out = " "; return $out; } function rollover_image($button_name, $alt_text, $ref) { $dir = "../images/buttons/"; $normal_image = $dir.$button_name."_f1.png"; $over_image = $dir.$button_name."_f2.png"; return " ".$alt_text.""; } function window_aircraft($button_name, $alt_text, $ref) { $dir = "../images/buttons/"; $normal_image = $dir.$button_name; return " ".$alt_text.""; } function window_route($button_name, $alt_text, $ref) { $dir = "../images/buttons/"; $normal_image = $dir.$button_name; return " ".$alt_text.""; } function window_log($button_name, $alt_text, $ref) { $dir = "../images/buttons/"; $normal_image = $dir.$button_name; return " ".$alt_text.""; } function window_profile($button_name, $alt_text, $ref) { $dir = "../images/buttons/"; $normal_image = $dir.$button_name; return " ".$alt_text.""; } function window_resources($button_name, $alt_text, $ref) { $dir = "../images/buttons/"; $normal_image = $dir.$button_name; return " ".$alt_text.""; } function window_email($button_name, $alt_text, $ref) { $dir = "../images/buttons/"; $normal_image = $dir.$button_name; return " ".$alt_text.""; } function output($b) { echo "
"; echo "
"; foreach ($b as $key => $value) { switch ($b[$key]['type']) { case BTN_INPUT: echo $this->rollover_input($b[$key]['name'], $b[$key]['image'], $b[$key]['alt']); break; case BTN_SELECT: echo $this->rollover_select($b[$key]['name'], $b[$key]['image'], $b[$key]['alt']); break; case BTN_HREF: echo $this->rollover_image($b[$key]['image'], $b[$key]['alt'], $b[$key]['ref']); break; case BTN_WINDOW_PROFILE: echo $this->window_profile($b[$key]['image'], $b[$key]['alt'], $b[$key]['ref']); break; } } echo "
"; echo "
"; } } ?>