/
userinfo.php
350 lines (311 loc) · 14.5 KB
/
userinfo.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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
<?php
// Anzahl der User, die gerade Online sind, als Grafik ausgeben
// time limit auf 3 sekunden - falls z.B. ein DB-Server hängt, wird
// hiermit hoffentlich verhindert, daß dieser Prozess zu lange hängt
// und den Apache blockiert...
set_time_limit(3);
$userinfo_hilfe = "<B>Es wird eine transparente Grafik als JPG erzeugt, welche die aktuelle Zahl\nder User im Chat enthält. "
. "Falls kein User im Chat ist, wird ein leeres JPG ausgegeben.\n\n"
. "Übergabeparameter:</B>\n" . " text - Text nach der Zahl\n"
. " size - Größe in Punkt für die Schrift\n"
. " hrot - Hintergrundfarbe Rotanteil\n"
. " hgruen - Hintergrundfarbe Grünanteil\n"
. " hblau - Hintergrundfarbe Blauanteil\n"
. " vrot - Hintergrundfarbe Rotanteil\n"
. " vgruen - Hintergrundfarbe Grünanteil\n"
. " vblau - Hintergrundfarbe Blauanteil\n"
. " registriert=j - zeige User-registriert statt User-online\n"
. " art=user - Zeige Anzahl der User als Grafik oder Text (Voreinstellung)\n"
. " art=raumliste - Zeige Textliste der Räume, in denen ein Login möglich ist\n"
. " art=alles - Zeige Textliste mit den wichtigen Informationen\n"
. " null=j - Falls j, erfolgt bei \"0 User online\" eine Ausgabe. Ansonsten wird nur ein transparentes leeres JPG ausgegeben.\n"
. " text=j - es wird statt einer Grafik die Anzahl der User als Text ausgegeben.\n\n"
. " jscript=j - es wird statt einer Grafik die Anzahl der User als Text ausgegeben.\n\n"
. "<B>Beispiel 1:</B>\n<IMG SRC=\"http://chat.main.de/userinfo.php?size=24&text=User+gerade+online+im+Testchat\">\n"
. "ergibt folgende Grafik:\n\n"
. "<IMG SRC=\"http://chat.main.de/userinfo.php?size=24&text=User+gerade+online+im+Testchat\">\n\n"
. "<B>Beispiel 2:</B>\n<IMG SRC=\"http://chat.main.de/userinfo.php?size=24&hrot=0&hgruen=0&hblau=0&vrot=255&vgruen=255&vblau=0\">\n"
. "ergibt folgende Grafik in Gelb für einen blauen Hintergrund:\n\n"
. "<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 BGCOLOR=\"#0000FF\"><TR><TD><IMG SRC=\"http://chat.main.de/userinfo.php?size=24&hrot=0&hgruen=0&hblau=255&vrot=255&vgruen=255&vblau=0\"></TD></TR></TABLE>\n";
// Falls ?hilfe übergeben wurde, Hilfe anzeigen
// voreingestellter Zeichensatz
$fontname = "arialbd.ttf";
require("functions-init.php");
require("functions.php");
function get_maximum_height($fontname, $fontsize)
{
$str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890!\"ß%&/()=?ß*+";
$oldheight = 0;
for ($i = 0; $i < strlen($str); $i++) {
unset($b);
$b = ImageTTFBBox($fontsize, 0, $fontname, $str[$i]);
$height = abs($b[7]) + abs($b[1]);
$height = $height - round($height / 4);
if ($height > $oldheight) {
$oldheight = $height;
}
}
return array("0" => $oldheight, "1" => abs($b[7]));
}
function JPGText($str, $fontname, $fontsize, $backcol, $txtcol)
{
global $layout;
Header("Last-Modified: " . gmDate("D, d M Y H:i:s", Time()) . " GMT");
Header("Expires: " . gmDate("D, d M Y H:i:s", Time() - 3601) . " GMT");
Header("Pragma: no-cache");
Header("Cache-control: no-cache");
Header("Content-Type: image/jpeg");
$a = ImageTTFBBox($fontsize, 0, $fontname, $str);
$width = $a[2] + 4;
$bla = get_maximum_height($fontname, $fontsize);
$height = $bla[0] + 3;
$bl = $bla[1];
$im = ImageCreate($width, $height);
$bgcol = ImageColorAllocate($im, $backcol['red'], $backcol['green'],
$backcol['blue']);
$fgcol = ImageColorAllocate($im, $txtcol['red'], $txtcol['green'],
$txtcol['blue']);
if (!function_exists(imagegif)) {
imageTTFText($im, $fontsize, 0, 2, $bl + ($fontsize / 6) + 2, $fgcol,
$fontname, $str);
imagejpeg($im, "", 80);
} else {
ImageColorTransparent($im, $bgcol);
imageTTFText($im, $fontsize, 0, 2, $bl + ($fontsize / 6) + 2, $fgcol,
$fontname, $str);
imagegif($im);
}
ImageDestroy($im);
}
if ($_SERVER['QUERY_STRING'] == "hilfe") {
// Hilfe anzeigen
echo "<HTML><BODY BGCOLOR=\"#FFFFFF\"><PRE>userinfo.php - (C) by fidion GmbH 1999-2012\n\n"
. $userinfo_hilfe . "\n</PRE></HTML></BODY>\n";
} else {
if (!isset($art))
$art = "";
// Art der Aktion
switch ($art) {
case "raumliste":
if ($raum_auswahl && !$beichtstuhl) {
// Falls eintrittsraum nicht gesetzt ist, mit Lobby überschreiben
if (strlen($eintrittsraum) == 0) {
$eintrittsraum = $lobby;
}
// Raumauswahlliste erstellen
$query = "SELECT r_name,r_id FROM raum "
. "WHERE (r_status1='O' OR r_status1 LIKE BINARY 'm') AND r_status2='P'"
. "ORDER BY r_name";
$result = mysql_query($query, $conn);
$raeume = "<SELECT NAME=\"eintritt\">";
$i = 0;
if ($communityfeatures && $forumfeatures)
$raeume = $raeume
. "<OPTION VALUE=\"forum\">>>Forum<<\n";
if ($result && mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_object($result)) {
if ((!isset($eintritt)
AND $row->r_name == $eintrittsraum)
|| (isset($eintritt) AND $row->r_id == $eintritt)) {
$raeume = $raeume
. "<OPTION SELECTED VALUE=\"$row->r_id\">$row->r_name\n";
} else {
$raeume = $raeume
. "<OPTION VALUE=\"$row->r_id\">$row->r_name\n";
}
$i++;
}
}
if ($communityfeatures && $forumfeatures)
$raeume = $raeume
. "<OPTION VALUE=\"forum\">>>Forum<<\n";
$raeume = $raeume . "</SELECT>\n";
@mysql_free_result($result);
} else {
if (strlen($eintrittsraum) == 0) {
$eintrittsraum = $lobby;
}
$query = "SELECT r_id FROM raum WHERE r_name = '" . mysql_real_escape_string($eintrittsraum) . "'";
$result = mysql_query($query, $conn);
if ($result && mysql_num_rows($result) == 1) {
$lobby_id = mysql_result($result, 0, "r_id");
}
@mysql_free_result($result);
$raeume = "<INPUT TYPE=HIDDEN NAME=\"eintritt\" VALUE=$lobby_id>\n";
}
echo $raeume;
break;
case "alles":
if (!$beichtstuhl) {
$ergebnis = array();
// Wie viele User sind in der DB?
$query = "SELECT count(u_id) FROM user WHERE u_level in ('A','C','G','M','S','U')";
$result = mysql_query($query, $conn);
$rows = mysql_num_rows($result);
if ($result) {
$ergebnis['registriert'] = mysql_result($result, 0, 0);
mysql_free_result($result);
} else {
$ergebnis['registriert'] = 0;
}
// User online und Räume bestimmen -> merken
$query = "SELECT o_who,o_name,o_level,r_name,r_status1,r_status2, "
. "r_name='" . mysql_real_escape_string($lobby) . "' as lobby "
. "FROM online left join raum on o_raum=r_id "
. "WHERE (UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(o_aktiv)) <= $timeout "
. "ORDER BY lobby desc,r_name,o_who,o_name ";
$result2 = mysql_query($query, $conn);
if ($result2) {
$ergebnis['online'] = mysql_num_rows($result2);
} else {
$ergebnis['online'] = 0;
}
if ($abweisen == false and !$beichtstuhl
and $ergebnis['online'] > 0) {
$text = '';
$i = 0;
$r_name_alt = '';
$zeigen_alt = TRUE;
while ($row = mysql_fetch_object($result2)) {
if (($row->o_level == 'S') or ($row->o_level == 'C')) {
$nick = str_replace(';', '',
'<b class="admin">' . $row->o_name . '</b>');
} else {
$nick = str_replace(';', '', $row->o_name);
}
// Unterscheidung Raum oder Community-Modul
if (!$row->r_name or $row->r_name == 'NULL') {
$r_name = $whotext[$row->o_who];
$zeigen = TRUE;
} else {
// Nur offene, permanente Räume zeigen
if (($row->r_status1 == 'O'
|| $row->r_status1 == 'm')
&& $row->r_status2 == 'P') {
$zeigen = TRUE;
} else {
$zeigen = FALSE;
}
$r_name = $row->r_name;
}
// Textwechsel
if ($r_name_alt != $r_name) {
if (strlen($text) == 0) {
$text = $nick . ';';
} else {
// Nur offene, permanente Räume zeigen
if ($zeigen_alt) {
$ergebnis[$r_name_alt] = $text;
}
$text = $nick . ';';
}
$r_name_alt = $r_name;
$zeigen_alt = $zeigen;
} else {
$text .= $nick . ';';
}
$i++;
}
if ($zeigen_alt) {
$ergebnis[$r_name_alt] = $text;
}
mysql_free_result($result2);
} else {
@mysql_free_result($result2);
}
foreach ($ergebnis as $key => $val) {
echo $key . ";" . $val . "\n";
}
}
break;
default:
// Anzahl der User abfragen
if (isset($registriert) && $registriert == "j") {
$query = "SELECT count(u_id) as anzahl FROM user WHERE u_level IN ('A','C','G','M','S','U')";
$result = @mysql_query($query, $conn);
if ($result && @mysql_Num_Rows($result) > 0) {
$anzahl = @mysql_result($result, 0, "anzahl");
mysql_free_result($result);
}
} else {
$query = "SELECT count(o_id) as anzahl FROM online "
. "WHERE (UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(o_aktiv)) <= $timeout";
$result = @mysql_query($query);
if ($result && @mysql_Num_Rows($result) > 0) {
$anzahl = @mysql_result($result, 0, "anzahl");
mysql_free_result($result);
}
}
if (isset($anzahl)) {
if (!isset($text))
$text = "";
if (!isset($jscript))
$jscript = "";
if (!isset($registriert))
$registriert = "";
if (!isset($null))
$null = "";
if ($text != "j" && $jscript != "j") {
// Voreinstellungen
if (!isset($hrot)) {
$hrot = 255;
}
if (!isset($hgruen)) {
$hgruen = 255;
}
if (!isset($hblau)) {
$hblau = 255;
}
if (!isset($vrot)) {
$vrot = 0;
}
if (!isset($vgruen)) {
$vgruen = 0;
}
if (!isset($vblau)) {
$vblau = 0;
}
if (!isset($size)) {
$size = 12;
}
if (!$text) {
if ($registriert == "j") {
$text = "User im $chat registriert!";
$text0 = "Kein";
} else {
$text = "User im $chat online!";
$text0 = "Kein";
}
} else {
$text0 = "0";
}
if ($size > 64) {
$size = 64;
}
// Nur bei mindestens einem User Anzahl ausgeben
if ($anzahl == 0 && $null != "j") {
$text = "";
} elseif ($anzahl == 0) {
$text = $text0 . " " . $text;
} else {
$text = $anzahl . " " . $text;
}
// Aufgabe JPG
JPGText(urldecode($text), $fontname, $size,
array("red" => $hrot, "green" => $hgruen,
"blue" => $hblau),
array("red" => $vrot, "green" => $vgruen,
"blue" => $vblau));
} else {
if ($text == "j") {
// Textausgabe
echo $anzahl . "\n";
}
if ($jscript == "j") {
echo "document.write('$anzahl $text');\n";
}
}
}
}
}
?>