C:\$Recycle.Bin\S-1-5-21-3967099092-2644009230-141905953-500\$RTL8YJG\admin\mysql.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
<?php
/* $Id: mysql.php,v 1.1.1.1 2002/10/28 19:13:51 pbaecher 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.

        ==============================================

*/

include "common.inc.php";
tb_header();

if ( 
$action == '' )
{
    
$r_post query("SELECT count(postid) AS postcount FROM ".$pref."post");
    
$post mysql_fetch_array($r_post);
    
$r_thread query("SELECT count(threadid) AS threadcount FROM ".$pref."thread");
    
$thread mysql_fetch_array($r_thread);
    
    list(
$mysqlmajor,$mysqlminor,)=explode('.'mysql_get_server_info());
    if ( 
intval($mysqlmajor) >= && intval($mysqlminor) >= 23 )
    {
        
$r_table_details query("SHOW TABLE STATUS FROM $mysql_db");
        while ( 
$table_details mysql_fetch_array($r_table_details) )
        {
            if ( 
$showdbdetails )
            {
                if ( 
substr($table_details['Name'], 0strlen$pref ) ) == $pref )
                {
                    
$db_detail_row++;
                    
$db_detail_rows .= "<TR><TD bgcolor=" .  ( ( $db_detail_row ) == "#DDDDDD" "#EEEEEE" ) . ">" $table_details['Name'] . "</TD><TD bgcolor=" .  ( ( $db_detail_row ) == "#DDDDDD" "#EEEEEE" ) . ">" $table_details['Rows'] . "</TD><TD bgcolor=" .  ( ( $db_detail_row ) == "#DDDDDD" "#EEEEEE" ) . ">" round ( ( ( $table_details['Data_length'] + $table_details['index_length'] ) / 1024 ),). " kb</TD></TR>\n";
                }
                
$db_box '
              <TABLE border="0" cellspacing="1" cellpadding="1" bgcolor="black" width="300">
                <TR>
                  <TD bgcolor="#FCFCFC" colspan="2"><strong>Statistics: Mysql</strong></TD>
                </TR>
                <TR>
                  <TD bgcolor="#FCFCFC">
                    <Table border="0" cellspacing="0" cellpadding="0" width="100%">
                    <TR><TD bgcolor="#DDDDDD"><strong>Table</strong></TD><TD bgcolor="#DDDDDD"><strong>Records</strong></TD><TD bgcolor="#DDDDDD"><strong>Size</strong></TD></TR>
                    ' 
$db_detail_rows '
                        <TD colspan="3" align="center"><A HREF="mysql.php?session=' 
$session '">&laquo; Hide table details &raquo;</A></TD>
                    </TABLE>
                  </TD>
                </TR>
              </TABLE>'
;
            }
            else
            {
                if ( 
substr($table_details['Name'], 0strlen$pref ) ) == $pref )
                {
                    
$db_detail['size_content'] += $table_details['Data_length'];
                    
$db_detail['size_index'] += $table_details['Index_length'];            
                }
                
$db_box '
              <TABLE border="0" cellspacing="1" cellpadding="1" bgcolor="black" width="300">
                <TR>
                  <TD bgcolor="#FCFCFC" colspan="2"><strong>Statistics: Mysql</strong></TD>
                </TR>
                <TR>
                  <TD bgcolor="#FCFCFC">
                    <Table border="0" cellspacing="0" cellpadding="0" width="100%">
                      <TR>
                        <TD width="150">Content:</TD>
                        <TD width="150">' 
round( ( $db_detail['size_content'] / 1024 ), 1) . ' Kbytes</TD>
                      </TR>
                      <TR>
                        <TD width="150">Index:</TD>
                        <TD width="150">' 
round( ( $db_detail['size_index'] / 1024 ), ) . ' Kbytes</TD>
                      </TR>
                      <TR>
                        <TD width="150">Total:</TD>
                        <TD width="150">' 
round( ( ( $db_detail['size_index'] + $db_detail['size_content'] ) / 1024 ),) . ' Kbytes</TD>
                      </TR>
                      <TR>
                        <TD colspan="2" align="center"><A HREF="mysql.php?session=' 
$session '&showdbdetails=1">&laquo; Show table details &raquo;</A></TD>
                      </TR>
                    </TABLE>
                  </TD>
                </TR>
              </TABLE>
            '
;
            }
        }
    }
    else
    {
        
$db_box '<strong>You have to update your MySQL Version in order to see table stats</strong>';
    }
    
    print(
"<strong>MySQL-Statistics</strong>");
    print(
'<BR><BR>
        <TABLE border="0" cellspacing="0" cellpadding="0">
          <TR>
            <TD valign="top">
              <TABLE border="0" cellspacing="1" cellpadding="1" bgcolor="black" width="300">
                <TR>
                  <TD bgcolor="#FCFCFC" colspan="2"><strong>Statistics: Users</strong></TD>
                </TR>
                <TR>
                  <TD bgcolor="#FCFCFC">
                    <Table border="0" cellspacing="0" cellpadding="0" width="100%">
                      <TR>
                        <TD width="150">Registered users:</TD>
                        <TD width="150">' 
getusercount() . '</TD>
                      </TR>
                      <TR>
                        <TD width="150">Active users:</TD>
                        <TD width="150">' 
getactiveusers() . ' ( ' round( ( getactiveusers() / getusercount() ) * 100 ) . ' % )</TD>
                      </TR>
                    </TABLE>
                  </TD>
                </TR>
              </TABLE>
            </TD>
            <TD width="20">
            </TD>
            <TD valign="top">
              <TABLE border="0" cellspacing="1" cellpadding="1" bgcolor="black" width="300">
                <TR>
                  <TD bgcolor="#FCFCFC" colspan="2"><strong>Statistics: Threads & posts</strong></TD>
                </TR>
                <TR>
                  <TD bgcolor="#FCFCFC">
                    <Table border="0" cellspacing="0" cellpadding="0" width="100%">
                      <TR>
                        <TD>Threads:</TD>
                        <TD>' 
$thread['threadcount']  . '</TD>
                      </TR>
                      <TR>
                        <TD>Replys:</TD>
                        <TD>' 
. ( $post['postcount'] - $thread['threadcount'] ) . ' </TD>
                      </TR>
                      <TR>
                        <TD>&oslash; number of replys per thread:</TD>
                        <TD>' 
.
                        
/* fixed division durch null, wenn keine threads --dp */
                        
$thread['threadcount'] ? round( ( $post['postcount'] - $thread['threadcount'] ) / $thread['threadcount'] ) : '0' ). '</TD>
                      </TR>
                    </TABLE>
                  </TD>
                </TR>
              </TABLE>
            </TD>
          </TR>
          <TR>
            <TD>&nbsp;</TD>
          </TR>
          <TR>
            <TD colspan="1">
        ' 
$db_box '
            </TD>
            <TD width="20">
            </TD>            
            <TD valign="top">
              <TABLE border="0" cellspacing="1" cellpadding="1" bgcolor="black" width="300">
                <TR>
                  <TD bgcolor="#FCFCFC" colspan="2"><strong>Clean: Set correct postcount</strong></TD>
                </TR>
                <TR>
                  <TD bgcolor="#FCFCFC">
                    <Table border="0" cellspacing="0" cellpadding="0" width="100%">
                      <TR>
                        <TD valign="top">
                            <form action="mysql.php?session=' 
$session '&action=postcount" method="post" target="_self">    
                        <input type="submit" value="Set correct postcount">
                        </form>
                        </TD>
                      </TR>
                    </TABLE>
                  </TD>
                </TR>
              </TABLE>
            </TD>
          </TR>
          <TR>
            <TD>&nbsp;</TD>
          </TR>
          <TR>
            <TD colspan="3">
              <TABLE border="0" cellspacing="1" cellpadding="1" bgcolor="black" width="100%">
                <TR>
                  <TD bgcolor="#FCFCFC" colspan="2"><strong>Mysql-Cleaner</strong></TD>
                </TR>
                <TR>
                  <TD bgcolor="#FCFCFC">
                    <Table border="0" cellspacing="0" cellpadding="0" width="600">
                      <TR>
                        <TD><font color="red"><strong>Warning:</strong><BR></font>
                        <hr noshade>
                        <font color="red" size="1"><B>This utility is only suitable for advanced admins. You could delete active users and the content of your forum!</B></font>
                        <hr noshade><form action="mysql.php?session=' 
$session '&action=delusers&save=1" method="post">
                        Delete all <strong>users</strong>, who <BR>
                        &raquo;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;are <strong>longer</strong> registered than <input type="text" name="reg_days" size="4" maxlength="3" value="0"> day(s),<BR>
                        &raquo;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;haven\'t been online for <strong>at least</strong> <input type="text" name="laston_days" size="4" maxlength="3" value="0"> day(s) and<BR>
                        &raquo;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;have <strong>less</strong> then <input type="text" name="posts" size="5" maxlength="4" value="0"> posts.<BR><BR>
                        <input type="submit" value="Delete users"></form>
                        <form action="mysql.php?session=' 
$session '&action=delthreads&save=1" method="post">
                        Delete all threads, which<BR>
                        &raquo;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; are <strong>older</strong> than <input type="text" name="age_days" size="4" maxlength="3" value="0"> day(s) and<BR>
                        &raquo;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; have <strong>less</strong> then <strong><input type="text" name="replys" size="4" maxlength="3" value="1"></strong> posts.<BR><BR>
                        <input type="submit" value="Delete threads">
                        </form>
                        </TD>
                      </TR>
                    </TABLE>
                  </TD>
                </TR>
              </TABLE>
            </TD>
          </TR>
        </TABLE>
    '
);
}
elseif ( 
$action == "delusers" )
{
    if ( 
$save != )
    {
        
$r_user query("SELECT * FROM " $pref "user WHERE userjoin < '" . ( time() - ( $reg_days 86400 ) ) . "' AND userlastonline < '" . ( time() - ( $laston_days 86400 ) ) . "' AND userposts < '" $posts "'");
        print(
'You are sure to delete following users ? (' mysql_num_rows$r_user ) . ')<BR>
        <form action="mysql.php?session=' 
$session '&action=delusers" method="post">
        <input type="hidden" name="reg_days" value="' 
$reg_days '">
        <input type="hidden" name="laston_days" value="' 
$laston_days '">
        <input type="hidden" name="posts" value="' 
$posts '">
        <input type=submit value="Delete this ' 
mysql_num_rows$r_user ) . ' user(s) ?"></form><BR>
        <table border="0" cellspacing="0" cellpadding="0">
        <TD width="30" bgcolor="EEEEEE">&nbsp;</TD><TD width="130" bgcolor="EEEEEE"><strong>Username</strong></TD><TD width="200" bgcolor="EEEEEE"><strong>E-Mail</strong> </TD><TD width="170" bgcolor="EEEEEE"><strong>Last online</strong></TD><TD width="170" bgcolor="EEEEEE"><strong>Registration</strong></TD><TD width="50" bgcolor="EEEEEE"><strong>Posts</strong></TD>
        '
);
        while ( 
$user mysql_fetch_array$r_user ) )
        {
            
$i++;
            if ( 
$i == "0" )
            {
                
$t_bgcolor "EEEEEE";
            }
            else
            {
                
$t_bgcolor "";
            }
            print(
'
          <TR>
             <TD width="30" bgcolor="' 
$t_bgcolor '"> ' $i '.) </TD><TD width="130" bgcolor="' .$t_bgcolor '">' $user['username'] . '</TD><TD width="200" bgcolor="' .$t_bgcolor '"> ' $user['useremail'] . ' </TD><TD width="170" bgcolor="' .$t_bgcolor '">' date("d.m.Y @ H:i:s",$user['userlastonline']) . '</TD><TD width="170" bgcolor="' .$t_bgcolor '">' date("d.m.Y @ H:i:s",$user['userjoin']) . '</TD><TD width="50" bgcolor="' .$t_bgcolor '">' $user['userposts'] . '</TD>
          </TR>'
);
        }
        print(
'</table>');
    }
    else
    {
        
query("DELETE FROM " $pref "user WHERE userjoin < '" . ( time() - ( $reg_days 86400 ) ) . "' AND userlastonline < '" . ( time() - ( $laston_days 86400 ) ) . "' AND userposts < '" $posts "' ");
        print(
"Deleting ... successful");
    }
}
elseif ( 
$action == "delthreads" )
{
    if ( 
$save != )
    {
        
$r_threads query("SELECT * FROM " $pref "thread WHERE threadtime < '" . ( time() - ( $age_days 86400 ) ) . "' AND threadreplies < '" $replys "'");
        print(
'You are sure to delete following thread(s) ? (' mysql_num_rows$r_threads ) . ')<BR>
        <form action="mysql.php?session=' 
$session '&action=delthreads" method="post">
        <input type="hidden" name="age_days" value="' 
$age_days '">
        <input type="hidden" name="replys" value="' 
$replys '">
        <input type=submit value="Delete this ' 
mysql_num_rows$r_threads ) . ' threads(s) ?"></form><BR>
        <table border="0" cellspacing="0" cellpadding="0">
        <TD width="30" bgcolor="EEEEEE">&nbsp;</TD><TD width="130" bgcolor="EEEEEE"><strong>Threadtopic</strong></TD><TD width="200" bgcolor="EEEEEE"><strong>Lastreply</strong> </TD><TD width="60" bgcolor="EEEEEE"><strong>Posts</strong></TD><TD width="120" bgcolor="EEEEEE"><strong>Author</strong></TD>
        '
);
        while ( 
$threads mysql_fetch_array$r_threads ) )
        {
            
$i++;
            if ( 
$i == "0" )
            {
                
$t_bgcolor "EEEEEE";
            }
            else
            {
                
$t_bgcolor "";
            }
            print(
'
          <TR>
             <TD width="30" bgcolor="' 
$t_bgcolor '"> ' $i '.) </TD><TD width="130" bgcolor="' .$t_bgcolor '">' $threads['threadtopic'] . '</TD><TD width="200" bgcolor="' .$t_bgcolor '"> ' date("d.m.Y @ H:i:s",$threads['threadtime']) . ' </TD><TD width="60" bgcolor="' .$t_bgcolor '"> ' $threads['threadreplies'] . ' </TD><TD width="120" bgcolor="' .$t_bgcolor '"> ' $threads['threadauthor'] . ' </TD>
          </TR>'
);
        }
        print(
'</table>');
    }
    else
    {
        
query("DELETE FROM " $pref "thread WHERE threadtime < '" . ( time() - ( $age_days 86400 ) ) . "' AND threadreplies < '" $replys "'");
        print(
"Deleting ... successful");
    }
}
elseif ( 
$action == "postcount" )
{
    if( !isset( 
$do ) || !$do )
    {
        print(
'    Do you want to continue correcting the postcount of ' getusercount() . ' Users?<BR>
            <a href="mysql.php?session=' 
$session '&action=postcount&do=1">Yes</a> || <a href="mysql.php?session=' $session '">No</a>'
            
);
        exit();
    }
    print(
"Postcount is being checked ... please wait ...<BR><BR>");
    
$r_user query("    SELECT user.userid, user.userposts, count(post.userid) AS postcount
                FROM " 
$pref "user AS user
                INNER JOIN " 
$pref "post AS post
                ON post.userid = user.userid
                WHERE user.userposts > '0'
                GROUP BY user.userid"
);
    
$a_user = array();
    
$corrected 0;
    
$checked 0;
    
$wrong 0;
    while( 
$a_user mysql_fetch_array$r_user ) )
    {
        if( 
$a_user['userposts'] != $a_user['postcount'] )
        {
            
query("UPDATE " $pref "user SET userposts = '" $a_user['postcount'] . "' WHERE userid = '" $a_user['userid'] . "'");
            
$corrected++;
            if( 
$a_user['userposts'] > $a_user['postcount'] )
            {
                
$wrong += $a_user['userposts'] - $a_user['postcount'];
            }
            else
            {
                
$wrong += $a_user['postcount'] - $a_user['userposts'];
            }
        }
        
$checked++;
    }
    print(
'    Postcount of <strong>' $checked '</strong> Users was checked.<br>
        It was corrected <strong>' 
$corrected '</strong> Times.<br>
        Totally <strong>' 
$wrong '</strong> Posts were wrong counted.<br>
        <br><a href="mysql.php?session=' 
$session '">back to mysql-clean</a>');
}
tb_footer();
?>