forked from leonardoxc/leonardoxc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EXT_takeoff_functions.php
129 lines (101 loc) · 3.73 KB
/
EXT_takeoff_functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?
//************************************************************************
// Leonardo XC Server, https://github.com/leonardoxc/leonardoxc
//
// Copyright (c) 2004-2010 by Andreadakis Manolis
//
// This program is free software. You can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License.
//
// $Id: EXT_takeoff_functions.php,v 1.10 2010/07/13 11:06:46 manolis Exp $
//
//************************************************************************
require_once dirname(__FILE__)."/EXT_config_pre.php";
require_once "config.php";
require_once "EXT_config.php";
require_once "CL_flightData.php";
require_once "FN_functions.php";
require_once "FN_UTM.php";
require_once "FN_waypoint.php";
require_once "FN_output.php";
require_once "FN_pilot.php";
require_once "FN_flight.php";
require_once dirname(__FILE__)."/templates/".$PREFS->themeName."/theme.php";
setDEBUGfromGET();
if ( !L_auth::isAdmin($userID) ) { echo "go away"; return; }
$op=makeSane($_GET['op']);
if ($op=='addToArea'){
$tID=makeSane($_GET['tID']);
$aID=makeSane($_GET['aID']);
$query="INSERT INTO $areasTakeoffsTable (areaID,takeoffID) VALUES ($aID,$tID)" ;
// echo $query;
$res= $db->sql_query($query);
if($res <= 0){
echo "Problem in inserting takeoff to area";
} else {
echo "Takeoff added to area<br>";
}
} else if ($op=='removeFromArea'){
$tID=makeSane($_GET['tID']);
$aID=makeSane($_GET['aID']);
$query="DELETE FROM $areasTakeoffsTable WHERE areaID=$aID AND takeoffID=$tID" ;
// echo $query;
$res= $db->sql_query($query);
if($res <= 0){
echo "Problem in removing takeoff from area QUERY";
} else {
if ($db->sql_affectedrows() )
echo "Takeoff removed from area<br>";
else
echo "Problem in removing takeoff from area";
}
}else if ($op=='deleteTakeoffs'){
$toDeleteStr=$_GET['takeoffs'];
$toDeleteList=split('_',$toDeleteStr);
//echo "list is :";
//print_r($toDeleteList);
$flightsNum=waypoint::deleteBulk($toDeleteList);
echo "$flightsNum flights relocated<BR>";
foreach($toDeleteList as $waypointIDdelete) {
echo "Takeoff #$waypointIDdelete deleted<BR>";
}
} if ($op=='getTakeoffInfo'){
$wpID=$_GET['wpID']+0;
echo "<b>$wpID</b><BR>";
$query="SELECT intName , countryCode from $waypointsTable WHERE ID=$wpID ";
$res= $db->sql_query($query);
if($res > 0){
if ($row = mysql_fetch_assoc($res)) {
$description=$row['intName'];
} else {
echo "no results inquery :$query";
}
} else {
echo "error in query :$query";
}
echo "<a target='_blank' href='".
getLeonardoLink(array('op'=>'show_waypoint','waypointIDview'=>$wpID))
."'>$description</a><br>";
$query="SELECT MAX(MAX_LINEAR_DISTANCE) as record_km, ID FROM $flightsTable WHERE takeoffID =".$wpID." GROUP BY ID ORDER BY record_km DESC ";
$flightNum=0;
$res= $db->sql_query($query);
if($res > 0){
$flightNum=mysql_num_rows($res);
if ($flightNum>0) {
echo "<b><a href='".
getLeonardoLink(array('op'=>'list_flights','takeoffID'=>$wpID,
'year'=>0,'month'=>'0','season'=>'0','pilotID'=>'0_0','country'=>'0','cat'=>'0'
))."' target='_blank'> Flights[ ".$flightNum." ]</a></b><br>";
echo "<b>"._SITE_RECORD."</b>:";
$row = mysql_fetch_assoc($res);
echo '<a target=\'_top\' href=\'http://'.$_SERVER['SERVER_NAME'].
getLeonardoLink(array('op'=>'show_flight','flightID'=>$row['ID'])).'\'>'.
formatDistance($row['record_km'],1).'</a>';
} else {
echo " No flights from this location";
}
}
// echo ' " } ';
}
?>