forked from leonardoxc/leonardoxc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCL_user.php
141 lines (117 loc) · 3.55 KB
/
CL_user.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
<?
//************************************************************************
// 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: CL_user.php,v 1.4 2010/11/21 14:26:01 manolis Exp $
//
//************************************************************************
class LeoUser {
var $userID;
var $valuesArray;
var $gotValues;
function LeoUser($userID="") {
if ( $userID) $this->userID=$userID+0;
$this->valuesArray=array("pilotID", "serverID", "countryCode",
"CIVL_ID", "NACid", "NACmemberID", "NACclubID"
);
$this->gotValues=0;
}
function changeEmail($userID,$newEmail) {
if ( function_exists('leoUser_changeEmail') ) {
return leoUser_changeEmail($userID,$newEmail);
} else return 0;
}
function changePassword($userID,$newPassword) {
if ( function_exists('leoUser_changePassword') ) {
return leoUser_changePassword($userID,$newPassword);
} else return 0;
}
function userExists() {
global $db,$pilotsTable;
$query="SELECT * FROM $pilotsTable WHERE pilotID=".$this->pilotID." AND serverID=".($this->serverID+0) ;
$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 getEmail($userID) {
global $db,$CONF;
$query="SELECT ".$CONF['userdb']['email_field']." as email FROM ".$CONF['userdb']['users_table']." WHERE ".$CONF['userdb']['user_id_field']."=$userID " ;
$res= $db->sql_query($query);
if($res <= 0){
echo "Error in getEmail() $query<BR>";
return;
}
if ( $row = $db->sql_fetchrow($res) ) return $row['email'];
else return '';
}
function deleteUser($deleteFlights=0,$deleteFiles=0) {
global $db,$pilotsTable;
$err=0;
$sql="DELETE FROM $pilotsTable WHERE pilotID=".$this->pilotID." AND serverID=".$this->serverID ;
$res= $db->sql_query($sql);
if($res <= 0){
echo "Error deleting pilot from DB $sql<BR>";
$err=1;
}
if ($deleteFiles) {
$pilotPath=$this->getAbsPath();
delDir($pilotPath);
}
return $err;
}
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;
}
}
?>