forked from leonardoxc/leonardoxc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGUI_EXT_waypoint_add.php
207 lines (178 loc) · 8.07 KB
/
GUI_EXT_waypoint_add.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<?
/************************************************************************/
/* Leonardo: Gliding XC Server */
/* ============================================ */
/* */
/* Copyright (c) 2004-5 by Andreadakis Manolis */
/* http://sourceforge.net/projects/leonardoserver */
/* */
/* 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. */
/************************************************************************/
require_once dirname(__FILE__)."/EXT_config_pre.php";
require_once dirname(__FILE__)."/config.php";
require_once dirname(__FILE__)."/EXT_config.php";
require_once dirname(__FILE__)."/CL_flightData.php";
require_once dirname(__FILE__)."/FN_functions.php";
require_once dirname(__FILE__)."/FN_UTM.php";
require_once dirname(__FILE__)."/FN_waypoint.php";
require_once dirname(__FILE__)."/FN_output.php";
require_once dirname(__FILE__)."/FN_pilot.php";
require_once dirname(__FILE__)."/FN_flight.php";
require_once dirname(__FILE__)."/templates/".$PREFS->themeName."/theme.php";
setDEBUGfromGET();
require_once dirname(__FILE__)."/language/lang-".$currentlang.".php";
require_once dirname(__FILE__)."/language/countries-".$currentlang.".php";
if (! in_array($userID,$admin_users)) {
// return;
}
$waypointLat=$_REQUEST['lat']+0;
$waypointLon=$_REQUEST['lon']+0;
if ( $_POST['addWaypoint']==1 ) { // ADD waypoint
$waypt=new waypoint(0);
$waypt->name=$_POST['wname'];
$waypt->intName=$_POST['intName'];
$waypt->type=$_POST['type'];
$waypt->lat=$_POST['lat'];
$waypt->lon=$_POST['lon'];
$waypt->location=$_POST['location'];
$waypt->intLocation=$_POST['intLocation'];
$waypt->countryCode=$_POST['countryCode'];
$waypt->link=$_POST['link'];
$waypt->description=$_POST['description'];
if ( $waypt->putToDB(0) ) {
echo "<div align=center><BR><BR>"._WAYPOINT_ADDED."<BR><BR>";
//echo "<a href='?name=$module_name&op=list_flights'>RETURN to flights</a>";
echo "<br></div>";
} else echo("<H3> Error in inserting waypoint info query! </H3>\n");
return;
}
$query="SELECT countryCode from $waypointsTable WHERE ID=".($_REQUEST['takeoffID']+0);
$res= $db->sql_query($query);
if($res <= 0){
echo("<H3>"._NO_KNOWN_LOCATIONS."</H3>\n");
exit();
}
$row = mysql_fetch_assoc($res) ;
//if (!$row) { echo "##############" ;}
$nearestCountryCode=$row["countryCode"];
mysql_freeResult($res);
//echo $nearestCountryCode."^^";
?>
<style type="text/css">
body, p, table,tr,td {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;}
body {margin:0px}
</style>
<?
// open_inner_table(_ADD_WAYPOINT,450,"icon_pin.png");
// echo "<tr><td>";
// get info from leonardo server around the world !!!
// $leonardoServers=array("www.paraglidingforum.com","www.sky.gr","www.vololibero.net","xc.parapente.com.ar","www.ypforum.com","parablog.com.ar","www.heidel.com.ar");
$leonardoServers=array();
foreach ($leonardoServers as $leonardoServer) {
getWaypointInfo($leonardoServer,$waypointLat,$waypointLon);
}
function getWaypointInfo($leonardoServer,$lat,$lon) {
global $moduleRelPath;
echo "Trying server : $leonardoServer<br>";
$fp = @fsockopen ($leonardoServer,80, $errno, $errstr, 3);
if (!$fp) {
echo "SERVER $leonardoServer NOT ACTIVE";
return 0;
} else fclose ($fp);
$fl= "http://$leonardoServer/modules/leonardo/EXT_takeoff.php?op=find_wpt&lat=$lat&lon=$lon";
echo $fl."<br>";
$contents = implode("\n",file($fl));
require_once $moduleRelPath.'/miniXML/minixml.inc.php';
$xmlDoc = new MiniXMLDoc();
$xmlDoc->fromString($contents);
$xmlArray=$xmlDoc->toArray();
echo "Name: ".$xmlArray[search][waypoint][name]."#<BR>";
echo "Name: ".$xmlArray[search][waypoint][intName]."#<BR>";
echo "Name: ".$xmlArray[search][waypoint][location]."#<BR>";
echo "Name: ".$xmlArray[search][waypoint][intLocation]."#<BR>";
echo "Name: ".$xmlArray[search][waypoint][type]."#<BR>";
echo "Name: ".$xmlArray[search][waypoint][countryCode]."#<BR>";
echo "Name: ".$xmlArray[search][waypoint][lat]."#<BR>";
echo "Name: ".$xmlArray[search][waypoint][lon]."#<BR>";
echo "Name: ".$xmlArray[search][waypoint][link]."#<BR>";
echo "Name: ".$xmlArray[search][waypoint][description]."#<BR>";
echo "Name: ".$xmlArray[search][waypoint][modifyDate]."#<BR>";
echo "Name: ".$xmlArray[search][distance]."#<BR>";
echo "<hr>";
}
?>
<form name="form1" method="post" action="">
<table width=350 border="0" align="center" cellpadding="2" class="shadowBox main_text">
<tr>
<td width=100 bgcolor="#CFE2CF"><div align="right"><font color="#003366">Name</font></div></td>
<td width=150 bgcolor="#E3E7F2"><font color="#003366">
<input name="wname" type="text" id="wname" size="25">
<input name="type" type="hidden" id="type" value="1000">
</font></td>
<td colspan="2" bgcolor="#CFE2CF"><input type="submit" name="Submit" value="<? echo _ADD_WAYPOINT ?>" />
<input type="hidden" name="addWaypoint" value="1" /></td>
</tr>
<tr>
<td bgcolor="#CFE2CF"><div align="right"><font color="#003366">International
Name</font></div></td>
<td bgcolor="#E3E7F2"><font color="#003366">
<input name="intName" type="text" id="intName" size="25">
</font></td>
<td colspan="2" bgcolor="#E3E7F2"> </td>
</tr>
<tr>
<td bgcolor="#CFE2CF"><div align="right"><font color="#003366">Region</font></div></td>
<td bgcolor="#E3E7F2"><font color="#003366">
<input name="location" type="text" id="location" size="25">
</font></td>
<td bgcolor="#CFE2CF"><font color="#003366">lat</font></td>
<td bgcolor="#E3E7F2">
<input name="lat" type="text" id="lat" value='<? echo $waypointLat?>' size="10" />
</td>
</tr>
<tr>
<td bgcolor="#CFE2CF"><div align="right"><font color="#003366">International
Region</font></div></td>
<td bgcolor="#E3E7F2"><font color="#003366">
<input name="intLocation" type="text" id="intLocation" size="25">
</font></td>
<td bgcolor="#CFE2CF"><font color="#003366">lon</font></td>
<td bgcolor="#E3E7F2"><font color="#003366">
<input name="lon" type="text" id="lon" value='<? echo $waypointLon?>' size="10" />
</font></td>
</tr>
<tr>
<td bgcolor="#CFE2CF"><div align="right"><font color="#003366">Country
Code</font></div></td>
<td colspan="3" bgcolor="#E3E7F2"><font color="#003366">
<select name="countryCode">
<?
foreach ($countries as $key => $value) {
if ($nearestCountryCode==$key) $sel=" selected ";
else $sel="";
echo '<option value="'.$key.'" '.$sel.' >'.$key.' - '.$value.'</option>';
}
?>
</select>
</font></td>
</tr>
<tr>
<td bgcolor="#CFE2CF"><div align="right"><font color="#003366">Relevant URL</font></div></td>
<td colspan="3" bgcolor="#E3E7F2"><font color="#003366">
<input name="link" type="text" id="link" size="45" >
</font></td>
</tr>
<tr>
<td valign="top" bgcolor="#CFE2CF"><div align="right"><font color="#003366">Description</font></div></td>
<td colspan="3" bgcolor="#E3E7F2"><font color="#003366">
<textarea name="description" cols="35" rows="4" id="description"></textarea>
</font></td>
</tr>
</table>
</form>
<?
// echo "</td></tr>";
// close_inner_table();
?>