C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\webboard\admin\dynx_class.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
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
<?php
/* $Id: dynx_class.php,v 1.5 2003/01/02 15:17:08 dkreuer Exp $ */
/*
          ThWboard - PHP/MySQL Bulletin Board System
        ==============================================
            (c) 2000, 2001 by
               Paul Baecher         <paul@thewall.de>
               Felix Gonschorek   <funner@thewall.de>

          download the latest version:
            http://www.thwboard.de

          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,  or (at
          your option) any later version.

        ==============================================
*/

//Fehlermeldungen
$errorMessages = array(
/* 1 */    'Probleme beim Connecten zum MySQL Server:',
/* 2 */    'Fehler der MySQL Datenbank bei folgendem Query String:',
/* 3 */    'Die Styleimportierung wurde abgebrochen, da das Style eine inkompatible Version hat, n&auml;mlich die Version',
/* 4 */    'Die Style-Dateien Erstellung wurde abgebrochen, da der Zugriff auf den Ordner, bzw. der Datei verweigert wurde. Bitte &uuml;berpr&uuml;fen sie ihre CHMOD Einstellungen.',
/* 5 */    'Sie haben keine Styles ausgew&auml;hlt!',
/* 6 */    'Ein Fehler bei der Antwort des Servers ist aufgetreten, bitte versuchen Sie es sp&auml;ter nochmal.',
/* 7 */    'Der Server hat eine ung&uuml;ltige Anfrage bekommen, bitte vergiwissern Sie sich, dass Sie die aktuellste Version von DynX haben.',
/* 8 */    'Die Styleinformationen sind leider ung&uuml;ltig, bitte w&auml;hlen Sie ein anderes Style aus.',
/* 9 */ 'Die maximale Download Rate pro Tag wurde &uuml;berschritten, bitte versuchen sie es an einem anderen Tag wieder.'
);


///////////////////////
// Styles und Funktionen
// Top-Style + Bottom-Style
// Fehler-Handler, Style->SQL Konverter
///////////////////////

function style_top($title 'Installer')
{
    print (
'<html>
<head>
<title>ThWboard DynX Client - ' 
$title '</title>
<style type="text/css">
body { background-color: #FFFFFF; text-align: center; }
table.main { background-color: #909090; }

td.main { background-color: #EFEFEF; color: #7F7F7F; }
td { font-family: "Verdana"; font-size: 10pt; color: #7F7F7F; }

div.title1 { font-size: 14pt; font-family: "Verdana", "Arial", "sans-serif"; }
div.copy { font-size: 8pt; font-family: "Verdana"; color: #7F7F7F; }

.dynxbutton { font-family: Verdana; font-size: 8pt; background-color: #EFEFEF; border:2px solid #C0C0C0; }

a:link { color: #7E7E7E; text-decoration: none; font-weight: bold; }
a:visited { color: #7E7E7E; text-decoration: none; font-weight: bold; }
a:active { color: #7E7E7E; text-decoration: none; font-weight: bold; }
a:hover { color: #7E7E7E; text-decoration: none; font-weight: bold; }
</style>
</head>
<body>
<script language="JavaScript">
<!--
function SelectAll(a)
{
    var boolValue;
    if (a == 1)
    {
        boolValue = document.theform.selell.checked;
    }
    else
    {
        boolValue = document.theform.selectall.checked;
    }
    for (var i=a;i<document.theform.elements.length;i=i+2)
    {
        var e = document.theform.elements[i];
        if (e.name != "disable")
        {
            e.checked = boolValue;
        }
    }
}

--></script>
<center><table class="main" width="60%" cellpadding="2" cellspacing="1">
  <tr>
    <td class="main">
      <table width="100%" cellspacing="1" cellpadding="0">
        <tr><td width="15%"><img src="./images/dynx_logo.gif"></td><td class="main" width="85%"><div class="title1">&nbsp;ThWBoard Dyn<i>X</i></div></td></tr>
        <tr><td colspan="2" bgcolor="#909090"> </td></tr>
        <tr><td colspan="2" height="6"> </td></tr>
        <tr><td colspan="2" class="main">
          <form name="theform" method="post" action="dynx.php">
'
);
}

// ===================================================

function style_bottom($action$buttontitle$hiddeninput 0)
{
    global 
$l_username$l_userpassword;
    
    if( !
$hiddeninput )
    {
        print (
'
      <input type="hidden" name="l_username" value="' 
$l_username '">
          <input type="hidden" name="l_userpassword" value="' 
$l_userpassword '">');
        }
    
    print (
'      <input type="hidden" name="action" value="' $action '"><br>
          <br><input type="submit" name="next" value="' 
$buttontitle '" class="dynxbutton">
      </form>
        </td></tr>
      </table>
    </td>
  </tr>
</table></center>
<br>
<br>
<!-- Dieser Copyright-Vermerk darf weder ver&auml;ndert noch entfernt werden! -->
<div class="copy">
&copy; 2002 the <a href="http://thwboard.de">ThWboard</a> developer team
</div>
</body>
</html>'
);
}

// ===================================================

function ERROR_Handler $erorrno$errormsg '' )
{
    global 
$errorMessages;
    
    print 
'
<b>Ein Fehler ist aufgetreten:</b><br>
<br>
'
.$errorMessages[$erorrno 1].'<br>
<br>
<pre>'
.$errormsg.'</pre><br>
<br>
<a href="JavaScript:history.back(0)">Zur&uuml;ck</a>
'
;
exit();
}

// ===================================================

function style2sql$style_file$pref )
{
    
$style_file_version '1.0';
    
$styledata explode("\n"$style_file);
    
$a_name = array();
    
$a_value = array();
    while( list(
$nline$line) = each($styledata) )
    {
        if( 
trim($line) )
        {
            
$pos strpos($line'=');
        
            
$name substr($line0$pos);
            
$value substr($line$pos 1);
            
            if( 
$name == 'styleversion' )
            {
                
$ver trim($value);
            }
            else
            {
                
$a_name[] = $name;
                
$a_value[] = "'".addslashes(trim($value))."'";
            }
        }
    }
    if( 
$ver != $style_file_version )
    {
        
ERROR_Handler(3$ver);
    }
    else
    {
        
$query "INSERT INTO $pref"."style
            ("
.implode(','$a_name).")
            VALUES
            ("
.implode(','$a_value).")";
    return( 
$query );
    }
}

///////////////////////
// Klassen
// Dateisystem, Datenbanksystem, Zeit und Server-System
///////////////////////
class FILEFUNC
{
    var 
$F_Stream '';
    
    function 
writefile($path$filecontext)
    {
        if( !
FILEFUNC::WriteAccess($path) )
        {
            
ERROR_Handler(4);
            return 
FALSE;
        }
        else
        {
            
$this->F_Stream = @fopen($path'w');
            
fwrite($this->F_Stream$filecontext);
            
fclose($this->F_Stream);
            return 
TRUE;
        }
    }
    
    function 
writeaccess($file)
    {
        
$this->F_Stream = @fopen($file'w');
        if( !
$this->F_Stream )
        {
            return 
FALSE;
        }
        else
        {
            
fclose($this->F_Stream);
            return 
TRUE;
        }
    }
    
    function 
has_access$file$access_rights )
    {
        return 
1;
    }
      
}

// ===================================================

class DB_Connection
{
    var 
$_errorno 0;
    var 
$_errormsg '';

    function 
DB_Connection$dbconnstring )
    {
        
$dbconnval explode","$dbconnstring );
        
$db mysql_connect$dbconnval['0'], $dbconnval['1'], $dbconnval['2'] );
        
$db2 mysql_select_db$dbconnval['3'], $db );
        if( 
mysql_error() )
        {
            
$this->_errormsg mysql_error();
            
$this->_errorno 1;
            
ERROR_Handler($this->_errorno$this->_errormsg);
        }
    }
    
    function 
query$querystring )
    {
        
$test 2;
        
$r_result mysql_query$querystring );
        
        if( 
mysql_error() )
        {
            
$this->_errormsg mysql_error();
            
$this->_errorno 2;
            
ERROR_Handler($this->_errorno$this->_errormsg);
        }
        
        return 
$r_result;
    }
}

// ===================================================

class timer
{
    var 
$starttime '';
    var 
$endtime '';
    
    function 
timer()
    {
        
$this->start();
    }
    
    function 
start()
    {
        
$this->starttime $this->_getmicrotime();
    }
    
    function 
stop()
    {
        
$this->endtime $this->_getmicrotime();
        return 
$this->gettime();
        
$this null;
    }
    
    function 
_getmicrotime()
    {
        list( 
$usec$sec ) = explode" "microtime() );
        return( (float)
$usec + (float)$sec );
    }
    
    function 
gettime$multi 100000 )
    {
        return 
round( ($this->endtime $this->starttime) * $multi0);
    }
    
    function 
pause()
    {
        
$this->endtime _getmicrotime();
        return 
$this->gettime();
    }
}

// ===================================================

class server
{
    var 
$connection '';
    var 
$serveruri '';
    var 
$thwboardver '2.8'// Fuer 2.8 bisher...
    
    
function server$uri$retries )
    {
        
$this->serveruri $uri;
        
$this->pingserver();
    }
    
    
// Noch dummy, bekommt in der naechsten Version einen richtigen Zweck
    
function pingserver()
    {
        
$fp fsockopen'udp://' $this->serveruri);
        
$timer = new timer();
        
fwrite$fp"ping" );
        
$time $timer->stop();
        
fclose$fp );
        return 
$time;
    }

    function 
getAnswer$question )
    {
        
$this->connection fopen('http://'.$this->serveruri.'/xtrasrv/srv.php?quest='.$question.'&tbver='.$this->thwboardver'r');
        
$answere '';
        while( !
feof$this->connection ) )
        {
            
$answere .= fread($this->connection1024);
        }
        
fclose$this->connection );
        
        
// fuer den fall das Server-Headers mitgeschickt werden
        
if( substr($answere07) == 'X-Power' )
        {
            
$pos strpos($answere"html");
            
$answere substr($answere$pos 8);
        }
        
        
$answere trim($answere);
        
        if( 
substr$answere09) == 'srv_error' )
        {
            
// Identifiziere Fehlermeldung des Servers und gebe entsprechende Erklaerungen aus
            
switch( substr$answere10) )
            {
                case 
"false_command":
                    
ERROR_Handler(7);
                    break;
                case 
"no_styledata":
                    
ERROR_Handler(8);
                    break;
                case 
"no_quest":
                    
ERROR_Handler(6);
                    break;
                case 
"no_styleid":
                    
ERROR_Handler(5);
                    break;
                case 
"error_style_limit":
                    
ERROR_Handler(9);
                    break;
                default:
                    
ERROR_Handler(6$answere);
            }
        }
        
        return( 
$answere );
    }
    
    
//ttt: Wird dies noch gebraucht? Hat Probleme gemacht in Verbindung mit fopen()...
    
function getReadBytes()
    {
        
$bytes socket_get_status($this->connection);
        return 
$bytes;
    }
}
?>