forked from leonardoxc/leonardoxc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCL_pilot.php
119 lines (102 loc) · 3.78 KB
/
CL_pilot.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
<?
/************************************************************************/
/* 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. */
/************************************************************************/
class pilot{
var $pilotID,$serverID;
var $valuesArray;
var $gotValues;
function pilot($serverID="",$pilotID="") {
if ($pilotID!="") $this->pilotID=$pilotID;
if ($serverID!="") $this->serverID=$serverID;
$this->valuesArray=array("pilotID", "serverID", "countryCode", "CIVL_ID", "NACid", "NACmemberID", "NACclubID",
"olcBirthDate", "olcFirstName", "olcLastName", "olcCallSign", "olcFilenameSuffix", "olcAutoSubmit",
"FirstName", "LastName", "clubID", "sponsor", "Sex", "Birthdate", "Occupation", "MartialStatus", "OtherInterests",
"PersonalWebPage", "PilotLicence", "BestMemory", "WorstMemory", "Training", "personalDistance", "personalHeight",
"glider", "FlyingSince", "HoursFlown", "HoursPerYear", "FavoriteLocation", "UsualLocation", "FavoriteBooks",
"FavoriteActors", "FavoriteSingers", "FavoriteMovies", "FavoriteSite", "Sign",
"Spiral", "Bline", "FullStall", "Sat", "AsymmetricSpiral", "Spin", "OtherAcro",
"camera", "camcorder", "Vario", "GPS", "Harness", "Reserve", "Helmet", "PilotPhoto"
);
$this->gotValues=0;
}
function pilotExists() {
global $db,$pilotsTable;
$query="SELECT * FROM $pilotsTable WHERE pilotID=".$this->pilotID." AND serverID=".$this->serverID ;
$res= $db->sql_query($query);
if($res <= 0){
echo "Error in pilotExists() $query<BR>";
return;
}
if ($db->sql_numrows($res) ) return 1;
else return 0;
}
function isPilotLocal() {
global $CONF_server_id;
if (! $this->serverID || $this->serverID==$CONF_server_id) return 1;
else return 0;
}
function createDirs() {
global $flightsAbsPath,$CONF_server_id;
if ( $this->isPilotLocal() ) $sPrefix='';
else $sPrefix=$this->serverID.'_';
$pilotPath=$flightsAbsPath.'/'.$sPrefix.$this->pilotID;
@mkdir($pilotPath."/flights");
@mkdir($pilotPath."/charts");
@mkdir($pilotPath."/maps");
@mkdir($pilotPath."/photos");
}
function getFromDB() {
global $db,$pilotsTable;
$res= $db->sql_query("SELECT * FROM $pilotsTable WHERE pilotID=".$this->pilotID." AND serverID=".$this->serverID );
if($res <= 0){
echo "Error getting club from DB<BR>";
return;
}
$row = $db->sql_fetchrow($res);
foreach ($this->valuesArray as $valStr) {
$this->$valStr=$row["$valStr"];
}
$this->gotValues=1;
}
function putToDB($update=0) {
global $db,$pilotsTable;
if ($update) {
$query="REPLACE INTO ";
$fl_id_1="pilotID,serverID, ";
$fl_id_2=$this->pilotID.", ".$this->serverID.",";
}else {
$query="INSERT INTO ";
$fl_id_1="";
$fl_id_2="";
}
$query.=" $pilotsTable ( ";
foreach ($this->valuesArray as $valStr) {
$query.= $valStr.",";
}
$query=substr($query,0,-1);
$query.= " ) VALUES ( ";
foreach ($this->valuesArray as $valStr) {
$query.= "'".prep_for_DB($this->$valStr)."',";
}
$query=substr($query,0,-1);
$query.= " ) ";
// echo $query;
$res= $db->sql_query($query);
if($res <= 0){
echo "Error putting pilot to DB : $query<BR>";
return 0;
}
$this->gotValues=1;
return 1;
}
}
?>