~ubuntu-branches/ubuntu/dapper/phpmyadmin/dapper-updates

« back to all changes in this revision

Viewing changes to queryframe.php

  • Committer: Bazaar Package Importer
  • Author(s): Piotr Roszatycki
  • Date: 2004-12-13 19:23:57 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20041213192357-5jfwhvbnxaip4zbv
Tags: 2:2.6.1-rc1-1
* New upstream release.
* Security fix: Command execution and file disclosure was found.
  See http://www.phpmyadmin.net/home_page/security.php?issue=PMASA-2004-4
  Closes: #285488.
* Remove 003.non_standard_port_fix.diff applied to upstream.
* Add commented out options 'extension' and 'AllowRoot' to default config
  file.
* Support mysqli.so extension. Autodetect modules from 'extension' option.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
 
/* $Id: queryframe.php,v 2.2 2003/11/26 22:52:24 rabus Exp $ */
 
2
/* $Id: queryframe.php,v 2.20 2004/11/06 19:44:42 mkkeck Exp $ */
3
3
// vim: expandtab sw=4 ts=4 sts=4:
4
4
 
5
 
 
6
5
/**
7
6
 * Gets the variables sent to this script, retains the db name that may have
8
7
 * been defined as startup option and include a core library
17
16
 * Gets a core script and starts output buffering work
18
17
 */
19
18
require_once('./libraries/common.lib.php');
 
19
require_once('./libraries/bookmark.lib.php');
20
20
require_once('./libraries/ob.lib.php');
21
21
if ($cfg['OBGzip']) {
22
22
    $ob_mode = PMA_outBufferModeGet();
36
36
 */
37
37
// Gets the font sizes to use
38
38
PMA_setFontSizes();
 
39
 
 
40
/**
 
41
 * Relations
 
42
 */
 
43
require_once('./libraries/relation.lib.php');
 
44
$cfgRelation = PMA_getRelationsParam();
 
45
echo "<?xml version=\"1.0\" encoding=\"" . $GLOBALS['charset'] . "\"?".">"; // remove vertical scroll bar bug in ie
39
46
?>
40
47
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
41
48
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
42
49
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $available_languages[$lang][2]; ?>" lang="<?php echo $available_languages[$lang][2]; ?>" dir="<?php echo $text_dir; ?>">
43
50
 
44
51
<head>
45
 
    <title>phpMyAdmin</title>
46
 
    <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>" />
47
 
    <base<?php if (!empty($cfg['PmaAbsoluteUri'])) echo ' href="' . $cfg['PmaAbsoluteUri'] . '"'; ?> />
48
 
    <link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php?lang=<?php echo $lang; ?>&amp;js_frame=left&num_dbs=0" />
 
52
<title>phpMyAdmin</title>
 
53
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>" />
 
54
<base<?php if (!empty($cfg['PmaAbsoluteUri'])) echo ' href="' . $cfg['PmaAbsoluteUri'] . '"'; ?> />
 
55
<link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php?lang=<?php echo $lang; ?>&amp;js_frame=left&amp;num_dbs=0" />
49
56
<?php
50
57
if ($cfg['QueryFrame'] && $cfg['QueryFrameJS']) {
51
58
?>
52
59
<script type="text/javascript" language="javascript">
 
60
<!--
53
61
var querywindow = '';
54
62
 
55
63
function open_querywindow(url) {
61
69
    }
62
70
 
63
71
    if (!querywindow.opener) {
64
 
       querywindow.opener = self;
 
72
        querywindow.opener = self;
65
73
    }
66
74
 
67
75
    if (window.focus) {
70
78
 
71
79
    return false;
72
80
}
 
81
 
 
82
/**
 
83
  * function resizeRowsLeft()
 
84
  * added 2004-07-20 by Michael Keck <mail@michaelkeck.de>
 
85
  *                  - this function checks the complete frameset of
 
86
  *                    index.php (parent.frames)
 
87
  *                  - gets the offsetHeight of qfcontainer
 
88
  *                  - sets a new frameset.rows - definition for the
 
89
  *                    frameset 'leftFrameset' in 'index.php' dynamic.
 
90
  * this script was tested on
 
91
  *   IE 6, Opera 7.53, Netsacpe 7.1 and Firefox 0.9
 
92
  *   and should work on all other DOM-Browsers and old IE-Browsers.
 
93
  *   It will never work on Netscape smaller Version 6 and IE smaller Version 4.
 
94
  * Please give me feedback if any browser doesn't work with this script
 
95
  *   mailto:mail@michaelkeck.de?subject=resizeFrames - Browser: [the browser]
 
96
**/
 
97
 
 
98
function resizeRowsLeft() {
 
99
    if (document.getElementById('qfcontainer')) { // dom browsers
 
100
        // get the height of the div-element 'qfcontainer'
 
101
        // we must add 10 (px) for framespacing
 
102
        newHeight = document.getElementById('qfcontainer').offsetHeight+10;
 
103
        // check if the frameset exists
 
104
        // please see index.php and check the frameset-definitions
 
105
        if (parent.document.getElementById('mainFrameset') && parent.document.getElementById('leftFrameset')) {
 
106
            parent.document.getElementById('leftFrameset').rows=newHeight+',*';
 
107
        }
 
108
    } else {
 
109
        if (document.all) { // older ie-browsers
 
110
            // get the height of the div-element 'qfcontainer'
 
111
            // we must add 10 (px) for framespacing
 
112
            newHeight=document.all('qfcontainer').offsetHeight+10;
 
113
            // check if the frameset exists
 
114
            // please see index.php and check the frameset-definitions
 
115
            if (parent.leftFrameset) {
 
116
                parent.leftFrameset.rows=newHeight+',*';
 
117
            }
 
118
        }
 
119
    }
 
120
}
 
121
 
 
122
//-->
 
123
</script>
 
124
<?php
 
125
    // setup the onload handler for resizing frames
 
126
    $js_frame_onload=' onload="resizeRowsLeft();"';
 
127
}
 
128
if ($cfg['QueryFrame']) {
 
129
?>
 
130
<script type="text/javascript" language="javascript">
 
131
<!--
 
132
// added 2004-09-16 by Michael Keck (mkkeck)
 
133
//                  bug: #1027321
 
134
//                       drop-down databases list keep focus on database change
 
135
// modified 2004-11-06: bug #1046434 (Light mode does not work)
 
136
var focus_removed = false;
 
137
function remove_focus_select() {
 
138
    focus_removed = false;
 
139
    set_focus_to_nav();
 
140
}
 
141
function set_focus_to_nav() {
 
142
    if (typeof(parent.frames.nav)!='undefined' && focus_removed!=true) {
 
143
        parent.frames.nav.focus();
 
144
        focus_removed=true;
 
145
    } else {
 
146
        focus_removed=false;
 
147
        setTimeout("set_focus_to_nav();",500);
 
148
    }
 
149
}
 
150
//-->
73
151
</script>
74
152
<?php
75
153
}
76
154
?>
77
155
</head>
78
156
 
79
 
<body bgcolor="<?php echo $cfg['LeftBgColor']; ?>" style="margin-left: 0px; margin-top: 5px; margin-right: 0px; margin-bottom: 0px">
80
 
<form name="queryframeform" action="queryframe.php" method="get">
81
 
<input type="hidden" name="db" value="" />
82
 
<input type="hidden" name="table" value="" />
83
 
<input type="hidden" name="framename" value="queryframe" />
84
 
</form>
85
 
 
86
 
<?php
87
 
$anchor = 'querywindow.php?' . PMA_generate_common_url('', '');
88
 
if ($cfg['QueryFrameJS']) {
89
 
    $href = $anchor;
90
 
    $target = '';
91
 
    $onclick = 'onClick="javascript:open_querywindow(this.href); return false;"';
 
157
<body id="body_queryFrame" bgcolor="<?php echo $cfg['LeftBgColor']; ?>"<?php echo ((isset($js_frame_onload) && $js_frame_onload!='') ? $js_frame_onload : ''); ?>>
 
158
    <div id="qfcontainer">
 
159
<?php
 
160
if ($cfg['LeftDisplayLogo']) {
 
161
?>
 
162
<!-- phpMyAdmin logo -->
 
163
    <?php
 
164
    if (@file_exists($pmaThemeImage . 'logo_left.png')) {
 
165
    ?>
 
166
 
 
167
    <div align="center">
 
168
        <a href="http://www.phpmyadmin.net" target="_blank"><img src="<?php echo '' . $pmaThemeImage . 'logo_left.png'; ?>" alt="phpMyAdmin" vspace="3" border="0" /></a>
 
169
    </div>
 
170
    <?php
 
171
    } else {
 
172
        echo '    '
 
173
           . '<div align="center"><a href="http://www.phpmyadmin.net" target="_blank">'
 
174
           . '<img src="' . $GLOBALS['pmaThemeImage'] . 'pma_logo2.png'  .'" alt="phpMyAdmin" border="0" />'
 
175
           . '</a></div>' . "\n";
 
176
    }
 
177
    echo '<hr id="hr_first" />';
 
178
} // end of display logo
 
179
 
 
180
if ($cfg['MainPageIconic']) {
 
181
    $str_spacer_links='';
 
182
} else{
 
183
    $str_spacer_links=' - ';
 
184
}
 
185
    ?>
 
186
<!-- Link to the welcome page -->
 
187
    <div align="center">
 
188
<?php
 
189
    echo '<a class="item" href="main.php?' . PMA_generate_common_url() . '" target="phpmain' . $hash . '">'
 
190
       . ($cfg['MainPageIconic']
 
191
            ? '<img src="' . $pmaThemeImage . 'b_home.png" width="16" height="16" border="0" hspace="2" alt="' . $strHome . '" title="' . $strHome . '"'
 
192
                    .' onmouseover="this.style.backgroundColor=\'#ffffff\';" onmouseout="this.style.backgroundColor=\'\';" align="middle" />'
 
193
            : '<b>' . $strHome . '</b>')
 
194
        . '</a>';
 
195
    // if we have chosen server
 
196
    if ($server != 0) {
 
197
        // Logout for advanced authentication
 
198
        if ($cfg['Server']['auth_type'] != 'config') {
 
199
            echo $str_spacer_links;
 
200
            echo '<a class="item" href="index.php?' . PMA_generate_common_url() . '&amp;old_usr=' . urlencode($PHP_AUTH_USER) . '" target="_parent">'
 
201
               . ($cfg['MainPageIconic']
 
202
                    ? '<img src="' . $pmaThemeImage . 's_loggoff.png" width="16" height="16" border="0" hspace="2" alt="' . $strLogout . '" title="' . $strLogout . '"'
 
203
                            .' onmouseover="this.style.backgroundColor=\'#ffffff\';" onmouseout="this.style.backgroundColor=\'\';" align="middle" />'
 
204
                    : '<b>' . $strLogout . '</b>')
 
205
               . '</a>';
 
206
        } // end if
 
207
 
 
208
        $anchor = 'querywindow.php?' . PMA_generate_common_url('', '');
 
209
        if ($cfg['QueryFrameJS']) {
 
210
            $href = $anchor;
 
211
            $target = '';
 
212
            $onclick = 'onclick="javascript:open_querywindow(this.href); return false;"';
 
213
        } else {
 
214
            $href = $anchor;
 
215
            $target = 'target="phpmain' . $hash . '"';
 
216
            $onclick = '';
 
217
        }
 
218
        if ($cfg['MainPageIconic']) {
 
219
            $query_frame_link_text = '<img src="' . $pmaThemeImage . 'b_selboard.png" border="0" hspace="1" width="16" height="16" alt="' . $strQueryFrame . '" title="' . $strQueryFrame . '"'
 
220
                                   .' onmouseover="this.style.backgroundColor=\'#ffffff\';" onmouseout="this.style.backgroundColor=\'\';" align="middle" />';
 
221
        } else {
 
222
            echo ($str_spacer_links != '' ? '<br />' : '');
 
223
            $query_frame_link_text = '<b>' . $strQueryFrame . '</b>';
 
224
        }
 
225
    ?>
 
226
    <script type="text/javascript">
 
227
    <!--
 
228
    document.writeln('<a href="<?php echo $href; ?>" <?php echo $target . ' ' . $onclick; ?> class="item"><?php echo addslashes($query_frame_link_text); ?></a>');
 
229
    //-->
 
230
    </script>
 
231
    <noscript>
 
232
        <a href="<?php echo $href; ?>&amp;no_js=true" <?php echo $target . ' ' . $onclick; ?> target="phpmain<?php echo $hash; ?>" class="item"><?php echo $query_frame_link_text; ?></a>
 
233
    </noscript>
 
234
    <?php
 
235
    }
 
236
 
 
237
if ($cfg['MainPageIconic']) {
 
238
    echo '<img src="' .$GLOBALS['pmaThemeImage'] . 'spacer.png'  .'" width="2" height="1" border="0" alt="" />'
 
239
       . '<a href="Documentation.html" target="documentation" class="item">'
 
240
       . '<img src="' . $pmaThemeImage . 'b_docs.png" border="0" hspace="1" width="16" height="16" alt="' . $strPmaDocumentation . '" title="' . $strPmaDocumentation . '"'
 
241
       . ' onmouseover="this.style.backgroundColor=\'#ffffff\';" onmouseout="this.style.backgroundColor=\'\';" align="middle" />'
 
242
       . '</a>';
 
243
    echo ''
 
244
       . '<a href="' . $cfg['MySQLManualBase'] . '" target="documentation" class="item">'
 
245
       . '<img src="' . $pmaThemeImage . 'b_sqlhelp.png" border="0" hspace="1" width="16" height="16" alt="MySQL - ' . $strDocu . '" title="MySQL - ' . $strDocu . '"'
 
246
       .' onmouseover="this.style.backgroundColor=\'#ffffff\';" onmouseout="this.style.backgroundColor=\'\';" align="middle" />'
 
247
       . '</a>';
 
248
}
 
249
 
 
250
    ?>
 
251
    </div>
 
252
    <hr id="hr_second" />
 
253
 
 
254
    <?php
 
255
if ($cfg['LeftDisplayServers']){
 
256
    $show_server_left = TRUE;
 
257
    include('./libraries/select_server.lib.php');
 
258
} // end if LeftDisplayServers
 
259
    ?>
 
260
<!-- Databases list -->
 
261
    <?php
 
262
/**
 
263
 * Get the list and number of available databases.
 
264
 * Skipped if no server selected: in this case no database should be displayed
 
265
 * before the user choose among available ones at the welcome screen.
 
266
 */
 
267
if ($server > 0) {
 
268
    PMA_availableDatabases(); // this function is defined in "common.lib.php"
92
269
} else {
93
 
    $href = $anchor;
94
 
    $target = 'target="phpmain' . $hash . '"';
95
 
    $onclick = '';
 
270
    $num_dbs = 0;
96
271
}
97
 
?>
98
 
<center>
99
 
<script type="text/javascript">
100
 
document.writeln('<a href="<?php echo $href; ?>" <?php echo $target . ' ' . $onclick; ?>><?php echo addslashes($strQueryFrame); ?></a>');
101
 
</script>
102
 
<noscript>
103
 
<a href="<?php echo $href; ?>&amp;no_js=true" <?php echo $target . ' ' . $onclick; ?> target="phpmain<?php echo $hash; ?>"><?php echo $strQueryFrame; ?></a>
104
 
</noscript>
105
 
</center>
106
 
 
107
 
<form name="hashform" action="queryframe.php">
108
 
    <input type="hidden" name="hash" value="<?php echo $hash; ?>">
109
 
</form>
 
272
 
 
273
// Don't display expansible/collapsible database info if:
 
274
// 1. $server == 0 (no server selected)
 
275
//    This is the case when there are multiple servers and
 
276
//    '$cfg['ServerDefault'] = 0' is set. In that case, we want the welcome
 
277
//    screen to appear with no database info displayed.
 
278
// 2. there is only one database available (ie either only one database exists
 
279
//    or $cfg['Servers']['only_db'] is defined and is not an array)
 
280
//    In this case, the database should not be collapsible/expandable
 
281
if ($num_dbs > 1) {
 
282
    // Light mode -> beginning of the select combo for databases
 
283
    // Note: When javascript is active, the frameset will be changed from
 
284
    // within left.php. With no JS (<noscript>) the whole frameset will
 
285
    // be rebuilt with the new target frame.
 
286
    if ($cfg['LeftFrameLight']) {
 
287
    ?>
 
288
    <table border="0" cellpadding="1" cellspacing="0">
 
289
        <tr>
 
290
            <td align="left" class="heada"><?php echo $strDatabase; ?>:</td>
 
291
        </tr>
 
292
        <tr>
 
293
            <td nowrap="nowrap">
 
294
    <script type="text/javascript" language="javascript">
 
295
    <!--
 
296
        document.writeln('<form method="post" action="left.php" name="left" target="nav" style="margin: 0px; padding: 0px;">');
 
297
    //-->
 
298
    </script>
 
299
    <noscript>
 
300
        <form method="post" action="index.php" name="left" target="_parent" style="margin: 0px; padding: 0px;">
 
301
    </noscript>
 
302
    <?php
 
303
        echo PMA_generate_common_hidden_inputs();
 
304
        echo '        <input type="hidden" name="hash" value="' . $hash . '" />' . "\n";
 
305
        ?>
 
306
        <select name="lightm_db" onchange="remove_focus_select();this.form.submit();">
 
307
        <?php
 
308
        echo '            <option value="">(' . $strDatabases . ') ...</option>' . "\n";
 
309
        $table_list = '';
 
310
        $table_list_header = '';
 
311
        $db_name    = '';
 
312
        $selected_db = 0;
 
313
 
 
314
        // natural order for db list
 
315
        if ($cfg['NaturalOrder'] && $num_dbs > 0) {
 
316
            $dblist_temp = $dblist;
 
317
            natsort($dblist_temp);
 
318
            $i = 0;
 
319
            foreach ($dblist_temp as $each) {
 
320
                $dblist[$i] = $each;
 
321
                $i++;
 
322
            }
 
323
        }
 
324
 
 
325
        // Gets the tables list per database
 
326
        for ($i = 0; $i < $num_dbs; $i++) {
 
327
            $db = $dblist[$i];
 
328
            $j  = $i + 2;
 
329
            if (!empty($db_start) && $db == $db_start) {
 
330
                $selected_db = $j;
 
331
            }
 
332
            $tables              = PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE);
 
333
            $num_tables          = ($tables) ? @PMA_DBI_num_rows($tables) : 0;
 
334
            $common_url_query    = PMA_generate_common_url($db);
 
335
            if ($num_tables) {
 
336
                $num_tables_disp = $num_tables;
 
337
            } else {
 
338
                $num_tables_disp = '-';
 
339
            }
 
340
            // Get additional information about tables for tooltip
 
341
            if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
 
342
                && $num_tables
 
343
                && (!$cfg['LeftFrameLight'] || $selected_db == $j)) {
 
344
                $tooltip = array();
 
345
                $tooltip_name = array();
 
346
                $result  = PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
 
347
                while ($tmp = PMA_DBI_fetch_assoc($result)) {
 
348
                    $tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '');
 
349
                    $tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] && $cfg['ShowTooltipAliasTB'] !== 'nested' ? $tmp['Name'] : $tmp['Comment']);
 
350
                    $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
 
351
                                           . '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
 
352
                } // end while
 
353
            } // end if
 
354
 
 
355
            // garvin: Get comments from PMA comments table
 
356
            $db_tooltip = '';
 
357
            if ($cfg['ShowTooltip'] && $cfgRelation['commwork']) {
 
358
                $tmp_db_tooltip = PMA_getComments($db);
 
359
                if (is_array($tmp_db_tooltip)) {
 
360
                    $db_tooltip = implode(' ', $tmp_db_tooltip);
 
361
                }
 
362
            }
 
363
 
 
364
            // Builds the databases' names list
 
365
            if (!empty($db_start) && $db == $db_start) {
 
366
                $table_title = array();
 
367
                $table_array = array();
 
368
                // Gets the list of tables from the current database
 
369
                while (list($table) = PMA_DBI_fetch_row($tables)) {
 
370
                    $table_array[$table] = '';
 
371
                    $url_title  = (!empty($tooltip) && isset($tooltip[$table]))
 
372
                                ? htmlspecialchars($tooltip[$table])
 
373
                                : '';
 
374
                    $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
 
375
                                ? htmlspecialchars($tooltip_name[$table])
 
376
                                : '';
 
377
                    $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
 
378
                } // end while (tables list)
 
379
                $selected = ' selected="selected"';
 
380
            } else {
 
381
                $selected = '';
 
382
            } // end if... else...
 
383
 
 
384
            if (!empty($num_tables)) {
 
385
                echo '            '
 
386
                   . '<option value="' . htmlspecialchars($db) . '"' . $selected . '>'
 
387
                   . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (' . $num_tables . ')</option>' . "\n";
 
388
            } else {
 
389
                echo '            '
 
390
                   . '<option value="' . htmlspecialchars($db) . '"' . $selected . '>'
 
391
                   . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (-)</option>' . "\n";
 
392
            } // end if... else...
 
393
 
 
394
        } // end for $i (db list)
 
395
        ?>
 
396
        </select>
 
397
        <noscript><input type="submit" name="Go" value="<?php echo $strGo; ?>" /></noscript>
 
398
    </form>
 
399
            </td>
 
400
        </tr>
 
401
    </table>
 
402
    <hr id="hr_third" />
 
403
    <?php
 
404
    } // end if LeftFrameLight
 
405
} // end if num_db > 1
 
406
    ?>
 
407
    <form name="queryframeform" action="queryframe.php" method="get" style="margin:0px; padding:0px; display:none;">
 
408
        <input type="hidden" name="db" value="" />
 
409
        <input type="hidden" name="table" value="" />
 
410
        <input type="hidden" name="framename" value="queryframe" />
 
411
    </form>
 
412
    <form name="hashform" action="queryframe.php" style="margin:0px; padding:0px; display:none;">
 
413
        <input type="hidden" name="hash" value="<?php echo $hash; ?>" />
 
414
    </form>
 
415
    </div>
110
416
</body>
111
417
</html>
112
418
 
115
421
 * Close MySql connections
116
422
 */
117
423
if (isset($dbh) && $dbh) {
118
 
    @mysql_close($dbh);
 
424
    @PMA_DBI_close($dbh);
119
425
}
120
426
if (isset($userlink) && $userlink) {
121
 
    @mysql_close($userlink);
 
427
    @PMA_DBI_close($userlink);
122
428
}
123
429
 
124
430