bug 643236
[phpmyadmin/crack.git] / sql.php3
blobb7f11acefde6ae513544e82ad9ae15af37bad165
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
5 /**
6 * Gets some core libraries
7 */
8 require('./libraries/grab_globals.lib.php3');
9 require('./libraries/common.lib.php3');
11 /**
12 * Defines the url to return to in case of error in a sql statement
14 // Security checkings
15 if (!empty($goto)) {
16 $is_gotofile = ereg_replace('^([^?]+).*$', '\\1', $goto);
17 if (!@file_exists('./' . $is_gotofile)) {
18 unset($goto);
19 } else {
20 $is_gotofile = ($is_gotofile == $goto);
22 } // end if (security checkings)
24 if (empty($goto)) {
25 $goto = (empty($table)) ? $cfg['DefaultTabDatabase'] : $cfg['DefaultTabTable'];
26 $is_gotofile = TRUE;
27 } // end if
28 if (!isset($err_url)) {
29 $err_url = (!empty($back) ? $back : $goto)
30 . '?lang=' . $lang
31 . '&amp;convcharset=' . $convcharset
32 . '&amp;server=' . $server
33 . (isset($db) ? '&amp;db=' . urlencode($db) : '')
34 . ((strpos(' ' . $goto, 'db_details') != 1 && isset($table)) ? '&amp;table=' . urlencode($table) : '');
35 } // end if
37 // Coming from a bookmark dialog
38 if (isset($fields['query'])) {
39 $sql_query = $fields['query'];
42 /**
43 * Check rights in case of DROP DATABASE
45 * This test may be bypassed if $is_js_confirmed = 1 (already checked with js)
46 * but since a malicious user may pass this variable by url/form, we don't take
47 * into account this case.
49 if (!defined('PMA_CHK_DROP')
50 && !$cfg['AllowUserDropDatabase']
51 && eregi('DROP[[:space:]]+(IF EXISTS[[:space:]]+)?DATABASE[[:space:]]', $sql_query)) {
52 // Checks if the user is a Superuser
53 // TODO: set a global variable with this information
54 // loic1: optimized query
55 $result = @PMA_mysql_query('USE mysql');
56 if (PMA_mysql_error()) {
57 include('./header.inc.php3');
58 PMA_mysqlDie($strNoDropDatabases, '', '', $err_url);
59 } // end if
60 } // end if
63 /**
64 * Bookmark add
66 if (isset($store_bkm)) {
67 if (get_magic_quotes_gpc()) {
68 $fields['label'] = stripslashes($fields['label']);
70 include('./libraries/bookmark.lib.php3');
71 PMA_addBookmarks($fields, $cfg['Bookmark']);
72 header('Location: ' . $cfg['PmaAbsoluteUri'] . $goto);
73 } // end if
76 /**
77 * Gets the true sql query
79 // $sql_query has been urlencoded in the confirmation form for drop/delete
80 // queries or in the navigation bar for browsing among records
81 if (isset($btnDrop) || isset($navig)) {
82 $sql_query = urldecode($sql_query);
85 /**
86 * Reformat the query
89 $parsed_sql = PMA_SQP_parse((get_magic_quotes_gpc() ? stripslashes($sql_query) : $sql_query));
90 $analyzed_sql = PMA_SQP_analyze($parsed_sql);
91 $sql_query = PMA_SQP_formatHtml($parsed_sql, 'query_only');
93 // here we are sure that SELECT is uppercase
94 $is_select = eregi('^SELECT[[:space:]]+', $sql_query);
96 // If the query is a Select, extract the db and table names and modify
97 // $db and $table, to have correct page headers, links and left frame.
98 // db and table name may be enclosed with backquotes, db is optionnal,
99 // query may contain aliases.
100 // (todo: check for embedded comments...)
102 // (todo: if there are more than one table name in the Select:
103 // - do not extract the first table name
104 // - do not show a table name in the page header
105 // - do not display the sub-pages links)
107 if ($is_select) {
108 eregi('^SELECT[[:space:]]+(.*)[[:space:]]+FROM[[:space:]]+(`[^`]+`|[A-Za-z0-9_$]+)([\.]*)(`[^`]*`|[A-Za-z0-9_$]*)', $sql_query, $tmp);
110 if ($tmp[3] == '.') {
111 $prev_db = $db;
112 $db = str_replace('`', '', $tmp[2]);
113 $reload = ($db == $prev_db) ? 0 : 1;
114 $table = str_replace('`', '', $tmp[4]);
116 else {
117 $table = str_replace('`', '', $tmp[2]);
119 } // end if
123 * Sets or modifies the $goto variable if required
125 if ($goto == 'sql.php3') {
126 $goto = 'sql.php3'
127 . '?lang=' . $lang
128 . '&amp;convcharset=' . $convcharset
129 . '&amp;server=' . $server
130 . '&amp;db=' . urlencode($db)
131 . '&amp;table=' . urlencode($table)
132 . '&amp;pos=' . $pos
133 . '&amp;sql_query=' . urlencode($sql_query);
134 } // end if
138 * Go back to further page if table should not be dropped
140 if (isset($btnDrop) && $btnDrop == $strNo) {
141 if (!empty($back)) {
142 $goto = $back;
144 if ($is_gotofile) {
145 if (strpos(' ' . $goto, 'db_details') == 1 && !empty($table)) {
146 unset($table);
148 include('./' . ereg_replace('\.\.*', '.', $goto));
149 } else {
150 header('Location: ' . $cfg['PmaAbsoluteUri'] . str_replace('&amp;', '&', $goto));
152 exit();
153 } // end if
157 * Displays the confirm page if required
159 * This part of the script is bypassed if $is_js_confirmed = 1 (already checked
160 * with js) because possible security issue is not so important here: at most,
161 * the confirm message isn't displayed.
163 * Also bypassed if only showing php code.or validating a SQL query
165 if (!$cfg['Confirm']
166 || (isset($is_js_confirmed) && $is_js_confirmed)
167 || isset($btnDrop)
168 || !empty($GLOBALS['show_as_php'])
169 || !empty($GLOBALS['validatequery'])) {
170 $do_confirm = FALSE;
171 } else {
172 /* SQL-Parser-Analyzer */
173 $do_confirm = (eregi('DROP[[:space:]]+(IF[[:space:]]+EXISTS[[:space:]]+)?(TABLE|DATABASE[[:space:]])|ALTER[[:space:]]+TABLE[[:space:]]+((`[^`]+`)|([A-Za-z0-9_$]+))[[:space:]]+DROP[[:space:]]|DELETE[[:space:]]+FROM[[:space:]]', $sql_query));
176 if ($do_confirm) {
177 // already stripped at beginning of script
178 //$stripped_sql_query = (get_magic_quotes_gpc() ? stripslashes($sql_query) : $sql_query);
179 $stripped_sql_query = $sql_query;
180 include('./header.inc.php3');
181 echo $strDoYouReally . '&nbsp;:<br />' . "\n";
182 echo '<tt>' . htmlspecialchars($stripped_sql_query) . '</tt>&nbsp;?<br/>' . "\n";
184 <form action="sql.php3" method="post">
185 <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
186 <input type="hidden" name="convcharset" value="<?php echo $convcharset; ?>" />
187 <input type="hidden" name="server" value="<?php echo $server; ?>" />
188 <input type="hidden" name="db" value="<?php echo htmlspecialchars($db); ?>" />
189 <input type="hidden" name="table" value="<?php echo isset($table) ? htmlspecialchars($table) : ''; ?>" />
190 <input type="hidden" name="sql_query" value="<?php echo urlencode(addslashes($sql_query)); ?>" />
191 <input type="hidden" name="zero_rows" value="<?php echo isset($zero_rows) ? $zero_rows : ''; ?>" />
192 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
193 <input type="hidden" name="back" value="<?php echo isset($back) ? $back : ''; ?>" />
194 <input type="hidden" name="reload" value="<?php echo isset($reload) ? $reload : 0; ?>" />
195 <input type="hidden" name="show_query" value="<?php echo isset($show_query) ? $show_query : ''; ?>" />
196 <input type="submit" name="btnDrop" value="<?php echo $strYes; ?>" />
197 <input type="submit" name="btnDrop" value="<?php echo $strNo; ?>" />
198 </form>
199 <?php
200 echo "\n";
201 } // end if
205 * Executes the query and displays results
207 else {
208 if (!isset($sql_query)) {
209 $sql_query = '';
211 // already stripped at beginning of script
212 // else if (get_magic_quotes_gpc()) {
213 // $sql_query = stripslashes($sql_query);
215 // Defines some variables
216 // loic1: A table has to be created -> left frame should be reloaded
217 if ((!isset($reload) || $reload == 0)
218 && eregi('^CREATE TABLE[[:space:]]+(.*)', $sql_query)) {
219 $reload = 1;
221 // Gets the number of rows per page
222 if (!isset($session_max_rows)) {
223 $session_max_rows = $cfg['MaxRows'];
224 } else if ($session_max_rows != 'all') {
225 $cfg['MaxRows'] = $session_max_rows;
227 // Defines the display mode (horizontal/vertical) and header "frequency"
228 if (empty($disp_direction)) {
229 $disp_direction = $cfg['DefaultDisplay'];
231 if (empty($repeat_cells)) {
232 $repeat_cells = $cfg['RepeatCells'];
235 // SK -- Patch: $is_group added for use in calculation of total number of
236 // rows.
237 // $is_count is changed for more correct "LIMIT" clause
238 // appending in queries like
239 // "SELECT COUNT(...) FROM ... GROUP BY ..."
240 $is_explain = $is_count = $is_export = $is_delete = $is_insert = $is_affected = $is_show = $is_maint = $is_analyse = $is_group = $is_func = FALSE;
241 if ($is_select) { // see line 141
242 $is_group = eregi('[[:space:]]+(GROUP[[:space:]]+BY|HAVING|SELECT[[:space:]]+DISTINCT)[[:space:]]+', $sql_query);
244 $is_func = !$is_group && (eregi('[[:space:]]+(SUM|AVG|STD|STDDEV|MIN|MAX|BIT_OR|BIT_AND)\s*\(', $sql_query));
245 $is_count = !$is_group && (eregi('^SELECT[[:space:]]+COUNT\((.*\.+)?.*\)', $sql_query));
246 $is_export = (eregi('[[:space:]]+INTO[[:space:]]+OUTFILE[[:space:]]+', $sql_query));
247 $is_analyse = (eregi('[[:space:]]+PROCEDURE[[:space:]]+ANALYSE\(', $sql_query));
248 } else if (eregi('^EXPLAIN[[:space:]]+', $sql_query)) {
249 $is_explain = TRUE;
250 } else if (eregi('^DELETE[[:space:]]+', $sql_query)) {
251 $is_delete = TRUE;
252 $is_affected = TRUE;
253 } else if (eregi('^(INSERT|LOAD[[:space:]]+DATA|REPLACE)[[:space:]]+', $sql_query)) {
254 $is_insert = TRUE;
255 $is_affected = TRUE;
256 } else if (eregi('^UPDATE[[:space:]]+', $sql_query)) {
257 $is_affected = TRUE;
258 } else if (eregi('^SHOW[[:space:]]+', $sql_query)) {
259 $is_show = TRUE;
260 } else if (eregi('^(CHECK|ANALYZE|REPAIR|OPTIMIZE)[[:space:]]+TABLE[[:space:]]+', $sql_query)) {
261 $is_maint = TRUE;
264 // Do append a "LIMIT" clause?
265 if (isset($pos)
266 && (!$cfg['ShowAll'] || $session_max_rows != 'all')
267 && $is_select
268 && !($is_count || $is_export || $is_func || $is_analyse)
269 && eregi('[[:space:]]FROM[[:space:]]', $sql_query)
270 && !eregi('[[:space:]]LIMIT[[:space:]0-9,-]+$', $sql_query)) {
271 $sql_limit_to_append = " LIMIT $pos, ".$cfg['MaxRows'];
272 if (eregi('(.*)([[:space:]](PROCEDURE[[:space:]](.*)|FOR[[:space:]]+UPDATE|LOCK[[:space:]]+IN[[:space:]]+SHARE[[:space:]]+MODE))$', $sql_query, $regs)) {
273 $full_sql_query = $regs[1] . $sql_limit_to_append . $regs[2];
274 } else {
275 $full_sql_query = $sql_query . $sql_limit_to_append;
277 } else {
278 $full_sql_query = $sql_query;
279 } // end if...else
281 PMA_mysql_select_db($db);
283 // If the query is a DELETE query with no WHERE clause, get the number of
284 // rows that will be deleted (mysql_affected_rows will always return 0 in
285 // this case)
286 if ($is_delete
287 && eregi('^DELETE([[:space:]].+)?([[:space:]]FROM[[:space:]](.+))$', $sql_query, $parts)
288 && !eregi('[[:space:]]WHERE[[:space:]]', $parts[3])) {
289 $cnt_all_result = @PMA_mysql_query('SELECT COUNT(*) as count' . $parts[2]);
290 if ($cnt_all_result) {
291 $num_rows = PMA_mysql_result($cnt_all_result, 0, 'count');
292 mysql_free_result($cnt_all_result);
293 } else {
294 $num_rows = 0;
297 // Executes the query
298 // Only if we didn't ask to see the php code (mikebeck)
299 if (!empty($GLOBALS['show_as_php']) || !empty($GLOBALS['validatequery'])) {
300 unset($result);
301 $num_rows = 0;
303 else {
304 $result = @PMA_mysql_query($full_sql_query);
305 // Displays an error message if required and stop parsing the script
306 if (PMA_mysql_error()) {
307 $error = PMA_mysql_error();
308 include('./header.inc.php3');
309 $full_err_url = (ereg('^(db_details|tbl_properties)', $err_url))
310 ? $err_url . '&amp;show_query=1&amp;sql_query=' . urlencode($sql_query)
311 : $err_url;
312 PMA_mysqlDie($error, $full_sql_query, '', $full_err_url);
315 // Checks if the current database has changed
316 // This could happen if the user sends a query like "USE `database`;"
317 $res = PMA_mysql_query('SELECT DATABASE() AS "db";');
318 $row = PMA_mysql_fetch_array($res);
319 if ($db != $row['db']) {
320 $db = $row['db'];
321 $reload = 1;
323 @mysql_free_result($res);
324 unset($res);
325 unset($row);
327 // tmpfile remove after convert encoding appended by Y.Kawada
328 if (function_exists('PMA_kanji_file_conv')
329 && (isset($textfile) && file_exists($textfile))) {
330 unlink($textfile);
333 // Gets the number of rows affected/returned
334 if (!$is_affected) {
335 $num_rows = ($result) ? @mysql_num_rows($result) : 0;
336 } else if (!isset($num_rows)) {
337 $num_rows = @mysql_affected_rows();
340 // Counts the total number of rows for the same 'SELECT' query without the
341 // 'LIMIT' clause that may have been programatically added
342 if (empty($sql_limit_to_append)) {
343 $unlim_num_rows = $num_rows;
345 else if ($is_select) {
346 // SK -- Patch : correct calculations for GROUP BY, HAVING, DISTINCT
348 // Reads only the from-part of the query...
349 // NOTE: here the presence of LIMIT is impossible, HAVING and GROUP BY
350 // are necessary for correct calculation, and extra spaces and
351 // lowercase reserved words are removed, so we have a simple split
352 // pattern:
354 $array = split('[[:space:]]+(FROM|ORDER BY)[[:space:]]+', $sql_query);
356 // if $array[1] is empty here, there is an error in the query:
357 // "... FROM [ORDER BY ...]", but the query is already executed with
358 // success so this check is redundant???
360 if (!empty($array[1])) {
361 // ... and makes a count(*) to count the entries
362 // Special case: SELECT DISTINCT ... FROM ...
363 // the count of resulting rows can be found as:
364 // SELECT COUNT(DISTINCT ...) FROM ...
365 if (eregi('^SELECT DISTINCT(.*)', $array[0], $array_dist)) {
366 $count_what = 'DISTINCT ' . $array_dist[1];
367 } else {
368 $count_what = '*';
370 $count_query = 'SELECT COUNT(' . $count_what . ') AS count FROM ' . $array[1];
371 if ($cnt_all_result = mysql_query($count_query)) {
372 if ($is_group) {
373 $unlim_num_rows = @mysql_num_rows($cnt_all_result);
374 } else {
375 $unlim_num_rows = mysql_result($cnt_all_result, 0, 'count');
377 mysql_free_result($cnt_all_result);
379 } else {
380 $unlim_num_rows = 0;
382 } // end rows total count
383 } // end else "didn't ask to see php code"
385 // No rows returned -> move back to the calling page
386 if ($num_rows < 1 || $is_affected) {
387 if ($is_delete) {
388 $message = $strDeletedRows . '&nbsp;' . $num_rows;
389 } else if ($is_insert) {
390 $message = $strInsertedRows . '&nbsp;' . $num_rows;
391 } else if ($is_affected) {
392 $message = $strAffectedRows . '&nbsp;' . $num_rows;
393 } else if (!empty($zero_rows)) {
394 $message = $zero_rows;
395 } else if (!empty($GLOBALS['show_as_php'])) {
396 $message = $strPhp;
397 } else if (!empty($GLOBALS['validatequery'])) {
398 $message = $strValidateSQL;
399 } else {
400 $message = $strEmptyResultSet;
403 if ($is_gotofile) {
404 $goto = ereg_replace('\.\.*', '.', $goto);
405 // Checks for a valid target script
406 if (isset($table) && $table == '') {
407 unset($table);
409 if (isset($db) && $db == '') {
410 unset($db);
412 $is_db = $is_table = FALSE;
413 if (strpos(' ' . $goto, 'tbl_properties') == 1) {
414 if (!isset($table)) {
415 $goto = 'db_details.php3';
416 } else {
417 $is_table = @PMA_mysql_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\'');
418 if (!($is_table && @mysql_numrows($is_table))) {
419 $goto = 'db_details.php3';
420 unset($table);
422 } // end if... else...
424 if (strpos(' ' . $goto, 'db_details') == 1) {
425 if (isset($table)) {
426 unset($table);
428 if (!isset($db)) {
429 $goto = 'main.php3';
430 } else {
431 $is_db = @PMA_mysql_select_db($db);
432 if (!$is_db) {
433 $goto = 'main.php3';
434 unset($db);
436 } // end if... else...
438 // Loads to target script
439 if (strpos(' ' . $goto, 'db_details') == 1
440 || strpos(' ' . $goto, 'tbl_properties') == 1) {
441 $js_to_run = 'functions.js';
443 if ($goto != 'main.php3') {
444 include('./header.inc.php3');
446 include('./' . $goto);
447 } // end if file_exist
448 else {
449 header('Location: ' . $cfg['PmaAbsoluteUri'] . str_replace('&amp;', '&', $goto) . '&message=' . urlencode($message));
450 } // end else
451 exit();
452 } // end no rows returned
454 // At least one row is returned -> displays a table with results
455 else {
456 // Displays the headers
457 if (isset($show_query)) {
458 unset($show_query);
460 if (isset($printview) && $printview == '1') {
461 include('./header_printview.inc.php3');
462 } else {
463 $js_to_run = 'functions.js';
464 unset($message);
465 if (!empty($table)) {
466 include('./tbl_properties_common.php3');
467 $url_query .= '&amp;goto=tbl_properties.php3&amp;back=tbl_properties.php3';
468 include('./tbl_properties_table_info.php3');
470 else {
471 include('./db_details_common.php3');
472 include('./db_details_db_info.php3');
474 include('./libraries/relation.lib.php3');
475 $cfgRelation = PMA_getRelationsParam();
478 // Gets the list of fields properties
479 if (isset($result) && $result) {
480 while ($field = PMA_mysql_fetch_field($result)) {
481 $fields_meta[] = $field;
483 $fields_cnt = count($fields_meta);
485 // Displays the results in a table
486 include('./libraries/display_tbl.lib.php3');
487 if (empty($disp_mode)) {
488 // see the "PMA_setDisplayMode()" function in
489 // libraries/display_tbl.lib.php3
490 $disp_mode = 'urdr111101';
492 if (!isset($dontlimitchars)) {
493 $dontlimitchars = 0;
496 PMA_displayTable($result, $disp_mode, $analyzed_sql);
497 mysql_free_result($result);
499 if ($disp_mode[6] == '1' || $disp_mode[9] == '1') {
500 echo "\n";
501 echo '<p>' . "\n";
503 // Displays "Insert a new row" link if required
504 if ($disp_mode[6] == '1') {
505 $lnk_goto = 'sql.php3'
506 . '?lang=' . $lang
507 . '&amp;convcharset=' . $convcharset
508 . '&amp;server=' . $server
509 . '&amp;db=' . urlencode($db)
510 . '&amp;table=' . urlencode($table)
511 . '&amp;pos=' . $pos
512 . '&amp;session_max_rows=' . $session_max_rows
513 . '&amp;disp_direction=' . $disp_direction
514 . '&amp;repeat_cells=' . $repeat_cells
515 . '&amp;dontlimitchars=' . $dontlimitchars
516 . '&amp;sql_query=' . urlencode($sql_query);
517 $url_query = '?lang=' . $lang
518 . '&amp;convcharset=' . $convcharset
519 . '&amp;server=' . $server
520 . '&amp;db=' . urlencode($db)
521 . '&amp;table=' . urlencode($table)
522 . '&amp;pos=' . $pos
523 . '&amp;session_max_rows=' . $session_max_rows
524 . '&amp;disp_direction=' . $disp_direction
525 . '&amp;repeat_cells=' . $repeat_cells
526 . '&amp;dontlimitchars=' . $dontlimitchars
527 . '&amp;sql_query=' . urlencode($sql_query)
528 . '&amp;goto=' . urlencode($lnk_goto);
530 echo ' <!-- Insert a new row -->' . "\n"
531 . ' <a href="tbl_change.php3' . $url_query . '">' . $strInsertNewRow . '</a>';
532 if ($disp_mode[9] == '1') {
533 echo '<br />';
535 echo "\n";
536 } // end insert new row
538 // Displays "printable view" link if required
539 if ($disp_mode[9] == '1') {
540 $url_query = '?lang=' . $lang
541 . '&amp;convcharset=' . $convcharset
542 . '&amp;server=' . $server
543 . '&amp;db=' . urlencode($db)
544 . '&amp;table=' . urlencode($table)
545 . '&amp;pos=' . $pos
546 . '&amp;session_max_rows=' . $session_max_rows
547 . '&amp;disp_direction=' . $disp_direction
548 . '&amp;repeat_cells=' . $repeat_cells
549 . '&amp;printview=1'
550 . ((isset($dontlimitchars) && $dontlimitchars == '1') ? '&amp;dontlimitchars=1' : '')
551 . '&amp;sql_query=' . urlencode($sql_query);
552 echo ' <!-- Print view -->' . "\n"
553 . ' <a href="sql.php3' . $url_query . '" target="print_view">' . $strPrintView . '</a>' . "\n";
554 } // end displays "printable view"
556 echo '</p>' . "\n";
559 // Bookmark Support if required
560 if ($disp_mode[7] == '1'
561 && ($cfg['Bookmark']['db'] && $cfg['Bookmark']['table'] && empty($id_bookmark))
562 && !empty($sql_query)) {
563 echo "\n";
565 $goto = 'sql.php3'
566 . '?lang=' . $lang
567 . '&amp;convcharset=' . $convcharset
568 . '&amp;server=' . $server
569 . '&amp;db=' . urlencode($db)
570 . '&amp;table=' . urlencode($table)
571 . '&amp;pos=' . $pos
572 . '&amp;session_max_rows=' . $session_max_rows
573 . '&amp;disp_direction=' . $disp_direction
574 . '&amp;repeat_cells=' . $repeat_cells
575 . '&amp;dontlimitchars=' . $dontlimitchars
576 . '&amp;sql_query=' . urlencode($sql_query)
577 . '&amp;id_bookmark=1';
579 <!-- Bookmark the query -->
580 <form action="sql.php3" method="post" onsubmit="return emptyFormElements(this, 'fields[label]');">
581 <?php
582 echo "\n";
583 if ($disp_mode[3] == '1') {
584 echo ' <i>' . $strOr . '</i>' . "\n";
587 <br /><br />
588 <?php echo $strBookmarkLabel; ?>&nbsp;:
589 <input type="hidden" name="server" value="<?php echo $server; ?>" />
590 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
591 <input type="hidden" name="fields[dbase]" value="<?php echo htmlspecialchars($db); ?>" />
592 <input type="hidden" name="fields[user]" value="<?php echo $cfg['Bookmark']['user']; ?>" />
593 <input type="hidden" name="fields[query]" value="<?php echo urlencode($sql_query); ?>" />
594 <input type="text" name="fields[label]" value="" />
595 <input type="submit" name="store_bkm" value="<?php echo $strBookmarkThis; ?>" />
596 </form>
597 <?php
598 } // end bookmark support
600 // Do print the page if required
601 if (isset($printview) && $printview == '1') {
602 echo "\n";
604 <script type="text/javascript" language="javascript1.2">
605 <!--
606 // Do print the page
607 if (typeof(window.print) != 'undefined') {
608 window.print();
610 //-->
611 </script>
612 <?php
613 } // end print case
614 } // end rows returned
616 } // end executes the query
617 echo "\n\n";
621 * Displays the footer
623 require('./footer.inc.php3');