C:\$Recycle.Bin\S-1-5-21-3967099092-2644009230-141905953-500\$RTL8YJG\admin\query.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
<?php
/* $Id: query.php,v 1.1.1.1 2002/10/28 19:13:51 pbaecher Exp $ */
/*
          ThWboard - PHP/MySQL Bulletin Board System
        ==============================================
            (c) 2000-2002 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.

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

*/
require('./common.inc.php');
tb_header();


function 
unhtmlspecialchars($s)
{
    
$s str_replace('&gt;''>'$s);
    
$s str_replace('&lt;''<'$s);
    
$s str_replace('&#039;'"'"$s);
    
$s str_replace('&quot;''"'$s);
    
$s str_replace('&amp;''&'$s);
    
    return 
$s;
}

if( 
$action == '' )
{
    print 
'
<b>Execute MySQL Query</b><br>
<br>
MySQL Query<br>
<form name="form1" method="post" action="query.php">
  <textarea class="tbinput" name="query" rows="8" cols="50">SELECT * FROM '
.$pref.'board</textarea><br><br>
  <input type="hidden" name="session" value="'
.$session.'">
  <input type="hidden" name="action" value="exec_query">
  <input type="submit" name="btn" value="   Send Query   ">
</form>
<br>
<br>
<br>
<br>
<b>Note:</b> You may want to disable this feature. For security reasons, there 
is no appropriate option here, at the admin center. To disable this feature, connect 
with your ftp client and simply delete this file (&quot;query.php&quot;).'
;
}



elseif( 
$action == 'exec_query' )
{
    if( 
stristr($query'DROP') && !$confirm )
    {
        print 
'
<b>Confirm query</b><br>
<br>
You are attempting to drop a table/database. Are you sure?<br>
<br>
Query: <i>'
.$query.'</i><br>
<br>
<form method="POST" action="query.php">
  <input type="hidden" name="session" value="'
.$session.'">
  <input type="hidden" name="query" value="'
.htmlspecialchars($query).'">
  <input type="hidden" name="confirm" value="1">
  <input type="hidden" name="action" value="exec_query">
  <input type="submit" name="btn" value="   I know what Im doing   ">
</form>'
;
    }
    else
    {
        
$r mysql_query($query);
        if( 
mysql_error() )
        {
            print 
'
<b>Error</b><br>
<br>
<b>Query:</b> <i><font color="darkblue">'
.$query.'</font></i><br>
<br>
<b>MySQL:</b> <font color="darkred">'
.mysql_error().' ('.mysql_errno().')</font>';
        }
        else
        {
            if( 
stristr($query'SELECT') )
            {
                if( !
stristr($query'LIMIT') )
                {
                    
$query .= ' LIMIT 0, 30';
                }

                if( 
mysql_num_rows($r) < )
                {
                    print 
'Your query was OK, but no rows were selected. (mysql_num_rows() == 0)';
                }
                else
                {
                    
$fields mysql_num_fields($r);
                    
$r_field 

                    
$i 0;
                    print 
'<table width="100%" border="0" cellspacing="1" cellpadding="4">';

                    print 
'<tr><td></td><td></td>';
                    for( 
$j 0$j $fields$j++ )
                    {
                        print 
'<td bgcolor="#A8D3FF"><b>'.mysql_field_name($r$j).'</b></td>';
                    }
                    print 
'</tr>';

                    while( 
$table mysql_fetch_row($r) )
                    {
                        print 
'<tr>
                        <td'
.($i == ' bgcolor="#eeeeee"' ' bgcolor="#dfdfdf"').' valign="top"><a href="">edit</a></td>
                        <td'
.($i == ' bgcolor="#eeeeee"' ' bgcolor="#dfdfdf"').' valign="top"><a href="">delete</a></td>';
                        for( 
$j 0$j $fields$j++ )
                        {
                            print 
'<td'.($i == ' bgcolor="#eeeeee"' ' bgcolor="#dfdfdf"').' valign="top">'.htmlspecialchars($table[$j]).'</td>';
                        }
                        
$i++;
                        print 
'</tr>';
                    }
                    print 
'</table>';
                }
            }
            else
            {
                print 
'Query sucessfull.';
            }
        }
    } 
}


tb_footer();
?>