-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdb.php
executable file
·221 lines (208 loc) · 4.75 KB
/
db.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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<?php
$basepath = dirname(dirname($_SERVER['SCRIPT_FILENAME'])).DIRECTORY_SEPARATOR;
require_once($basepath . 'adm_program/system/common.php');
require_once($basepath . 'adm_program/system/classes/list_configuration.php');
require_once($basepath . 'adm_program/system/classes/table_roles.php');
global $mailqueue;
global $gDb;
$sql = 'SELECT 1
FROM '. TBL_MEMBERS. ', '. TBL_ROLES. '
WHERE mem_rol_id = rol_id
AND mem_end >= \''.DATE_NOW.'\'
AND mem_usr_id = '.$gCurrentUser->getValue('usr_id').'
AND rol_valid = 1
AND rol_id = 127';
$result_role = $gDb->query($sql);
$agnewsletter = false;
if($gDb->num_rows($result_role) > 0)
{
$agnewsletter = true;
}
if (!isset($mailqueue) || !$mailqueue)
{
// prueft, ob der User die notwendigen Rechte hat, neue User anzulegen
if($gCurrentUser && $gCurrentUser->editUsers() == false)
{
$roles = array(2,37,38,39,40,41,42,43,44,45);
$access = array();
foreach ($roles as $getRoleId)
{
// Rollenobjekt erzeugen
$role = new TableRoles($gDb, $getRoleId);
//Testen ob Recht zur Listeneinsicht besteht
if($role->viewRole() == false && !$agnewsletter)
{
}
else
{
$access[] = $getRoleId;
if ($getRoleId == 2)
{
$access = array(2);
break;
}
}
}
if (count($access) == 0)
{
if(!$gCurrentUser || !$gValidLogin)
{
$gMessage->show($gL10n->get('SYS_NO_RIGHTS'));
}
}
}
else
{
$access = array(2);
}
//Verwaltung der Session
$_SESSION['navigation']->clear();
$_SESSION['navigation']->addUrl(CURRENT_URL);
}
function checklogin($access)
{
if (in_array(2,$access))
return 1;
if (in_array(38,$access))
return 2;
if (in_array(40,$access))
return 4;
if (in_array(39,$access))
return 8;
if (in_array(41,$access))
return 16;
if (in_array(42,$access))
return 32;
if (in_array(43,$access))
return 64;
if (in_array(45,$access))
return 128;
if (in_array(37,$access))
return 256;
if (in_array(44,$access))
return 512;
return 0;
}
class db {
private $dbConn_ = null;
public $dbType_ = null;
public function __construct($dbType, $name, $host = null)
{
$this->dbType_ = $dbType;
switch ($this->dbType_)
{
case 'mysql':
global $dbUser;
global $dbPass;
$this->dbConn_ = mysql_connect($host, $dbUser, $dbPass);
if (!$this->dbConn_)
{
exit('Could not connect: ' . mysql_error());
}
mysql_select_db($name, $this->dbConn_);
break;
case 'pgsql':
$this->dbConn_ = pg_connect("dbname=$name")
or exit('Could not connect: ' . pg_last_error());
break;
default:
exit("invalid dbtype!");
}
}
public function query($query)
{
$result_array = array();
switch ($this->dbType_)
{
case 'mysql':
$result = mysql_query($query);
if (!$result)
return $false;
if ($result === true)
return true;
while ($line = mysql_fetch_assoc($result)) {
$result_array[] = $line;
}
break;
case 'pgsql':
$result = pg_query($query) or exit('Abfrage fehlgeschlagen: ' . pg_last_error() . '<br><br>' . $query);
if (!$result)
return $false;
while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) {
$result_array[] = $line;
}
pg_free_result($result);
break;
}
return $result_array;
}
public function close()
{
switch ($this->dbType_)
{
case 'mysql':
mysql_close($this->dbConn_);
break;
case 'pgsql':
pg_close($this->dbConn_);
break;
default:
exit("invalid dbtype!");
}
}
public function escape($text)
{
switch ($this->dbType_)
{
case 'mysql':
return "'".mysql_escape_string($text)."'";
case 'pgsql':
return pg_escape_literal($text);
default:
exit("invalid dbtype!");
}
}
}
function decodePrefs($prefs)
{
$prefs = intval($prefs);
if ($prefs & 1)
$pa[] = "Bundesweite Informationen";
if ($prefs & 2)
$pa[] = "Burgenland";
if ($prefs & 4)
$pa[] = "Kärnten";
if ($prefs & 8)
$pa[] = "Niederösterreich";
if ($prefs & 16)
$pa[] = "Oberösterreich";
if ($prefs & 32)
$pa[] = "Salzburg";
if ($prefs & 512)
$pa[] = "Tirol";
if ($prefs & 64)
$pa[] = "Steiermark";
if ($prefs & 128)
$pa[] = "Vorarlberg";
if ($prefs & 256)
$pa[] = "Wien";
return $pa;
}
function getAdminNames($admins)
{
global $dbLang, $dbName;
$db = new db($dbLang, $dbName);
foreach ($admins as $admin)
{
if (preg_match('/^\d+$/', $admin) != 1)
continue;
$result = $db->query("SELECT usd_value FROM ppoe_mitglieder.adm_user_data WHERE usd_usf_id = 37 AND usd_usr_id = $admin");
if (count($result) != 1)
$admin_names[] = $admin;
else
$admin_names[] = $result[0]['usd_value'];
}
$db->close();
return $admin_names;
}
?>