oops
[phpmyadmin/crack.git] / sql.php3
blobfc649d16c493f2901cf44407f6e316a2d30a81fb
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;
298 // E x e c u t e t h e q u e r y
300 // Only if we didn't ask to see the php code (mikebeck)
301 if (!empty($GLOBALS['show_as_php']) || !empty($GLOBALS['validatequery'])) {
302 unset($result);
303 $num_rows = 0;
305 else {
306 $result = @PMA_mysql_query($full_sql_query);
308 // Displays an error message if required and stop parsing the script
309 if (PMA_mysql_error()) {
310 $error = PMA_mysql_error();
311 include('./header.inc.php3');
312 $full_err_url = (ereg('^(db_details|tbl_properties)', $err_url))
313 ? $err_url . '&amp;show_query=1&amp;sql_query=' . urlencode($sql_query)
314 : $err_url;
315 PMA_mysqlDie($error, $full_sql_query, '', $full_err_url);
318 // Gets the number of rows affected/returned
319 // (This must be done immediately after the query because
320 // mysql_affected_rows() reports about the last query done)
322 if (!$is_affected) {
323 $num_rows = ($result) ? @mysql_num_rows($result) : 0;
324 } else if (!isset($num_rows)) {
325 $num_rows = @mysql_affected_rows();
328 // Checks if the current database has changed
329 // This could happen if the user sends a query like "USE `database`;"
330 $res = PMA_mysql_query('SELECT DATABASE() AS "db";');
331 $row = PMA_mysql_fetch_array($res);
332 if ($db != $row['db']) {
333 $db = $row['db'];
334 $reload = 1;
336 @mysql_free_result($res);
337 unset($res);
338 unset($row);
340 // tmpfile remove after convert encoding appended by Y.Kawada
341 if (function_exists('PMA_kanji_file_conv')
342 && (isset($textfile) && file_exists($textfile))) {
343 unlink($textfile);
346 // Counts the total number of rows for the same 'SELECT' query without the
347 // 'LIMIT' clause that may have been programatically added
348 if (empty($sql_limit_to_append)) {
349 $unlim_num_rows = $num_rows;
351 else if ($is_select) {
352 // SK -- Patch : correct calculations for GROUP BY, HAVING, DISTINCT
354 // Reads only the from-part of the query...
355 // NOTE: here the presence of LIMIT is impossible, HAVING and GROUP BY
356 // are necessary for correct calculation, and extra spaces and
357 // lowercase reserved words are removed, so we have a simple split
358 // pattern:
360 $array = split('[[:space:]]+(FROM|ORDER BY)[[:space:]]+', $sql_query);
362 // if $array[1] is empty here, there is an error in the query:
363 // "... FROM [ORDER BY ...]", but the query is already executed with
364 // success so this check is redundant???
366 if (!empty($array[1])) {
367 // ... and makes a count(*) to count the entries
368 // Special case: SELECT DISTINCT ... FROM ...
369 // the count of resulting rows can be found as:
370 // SELECT COUNT(DISTINCT ...) FROM ...
371 if (eregi('^SELECT DISTINCT(.*)', $array[0], $array_dist)) {
372 $count_what = 'DISTINCT ' . $array_dist[1];
373 } else {
374 $count_what = '*';
376 $count_query = 'SELECT COUNT(' . $count_what . ') AS count FROM ' . $array[1];
377 if ($cnt_all_result = mysql_query($count_query)) {
378 if ($is_group) {
379 $unlim_num_rows = @mysql_num_rows($cnt_all_result);
380 } else {
381 $unlim_num_rows = mysql_result($cnt_all_result, 0, 'count');
383 mysql_free_result($cnt_all_result);
385 } else {
386 $unlim_num_rows = 0;
388 } // end rows total count
389 } // end else "didn't ask to see php code"
391 // No rows returned -> move back to the calling page
392 if ($num_rows < 1 || $is_affected) {
393 if ($is_delete) {
394 $message = $strDeletedRows . '&nbsp;' . $num_rows;
395 } else if ($is_insert) {
396 $message = $strInsertedRows . '&nbsp;' . $num_rows;
397 } else if ($is_affected) {
398 $message = $strAffectedRows . '&nbsp;' . $num_rows;
399 } else if (!empty($zero_rows)) {
400 $message = $zero_rows;
401 } else if (!empty($GLOBALS['show_as_php'])) {
402 $message = $strPhp;
403 } else if (!empty($GLOBALS['validatequery'])) {
404 $message = $strValidateSQL;
405 } else {
406 $message = $strEmptyResultSet;
409 if ($is_gotofile) {
410 $goto = ereg_replace('\.\.*', '.', $goto);
411 // Checks for a valid target script
412 if (isset($table) && $table == '') {
413 unset($table);
415 if (isset($db) && $db == '') {
416 unset($db);
418 $is_db = $is_table = FALSE;
419 if (strpos(' ' . $goto, 'tbl_properties') == 1) {
420 if (!isset($table)) {
421 $goto = 'db_details.php3';
422 } else {
423 $is_table = @PMA_mysql_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\'');
424 if (!($is_table && @mysql_numrows($is_table))) {
425 $goto = 'db_details.php3';
426 unset($table);
428 } // end if... else...
430 if (strpos(' ' . $goto, 'db_details') == 1) {
431 if (isset($table)) {
432 unset($table);
434 if (!isset($db)) {
435 $goto = 'main.php3';
436 } else {
437 $is_db = @PMA_mysql_select_db($db);
438 if (!$is_db) {
439 $goto = 'main.php3';
440 unset($db);
442 } // end if... else...
444 // Loads to target script
445 if (strpos(' ' . $goto, 'db_details') == 1
446 || strpos(' ' . $goto, 'tbl_properties') == 1) {
447 $js_to_run = 'functions.js';
449 if ($goto != 'main.php3') {
450 include('./header.inc.php3');
452 include('./' . $goto);
453 } // end if file_exist
454 else {
455 header('Location: ' . $cfg['PmaAbsoluteUri'] . str_replace('&amp;', '&', $goto) . '&message=' . urlencode($message));
456 } // end else
457 exit();
458 } // end no rows returned
460 // At least one row is returned -> displays a table with results
461 else {
462 // Displays the headers
463 if (isset($show_query)) {
464 unset($show_query);
466 if (isset($printview) && $printview == '1') {
467 include('./header_printview.inc.php3');
468 } else {
469 $js_to_run = 'functions.js';
470 unset($message);
471 if (!empty($table)) {
472 include('./tbl_properties_common.php3');
473 $url_query .= '&amp;goto=tbl_properties.php3&amp;back=tbl_properties.php3';
474 include('./tbl_properties_table_info.php3');
476 else {
477 include('./db_details_common.php3');
478 include('./db_details_db_info.php3');
480 include('./libraries/relation.lib.php3');
481 $cfgRelation = PMA_getRelationsParam();
484 // Gets the list of fields properties
485 if (isset($result) && $result) {
486 while ($field = PMA_mysql_fetch_field($result)) {
487 $fields_meta[] = $field;
489 $fields_cnt = count($fields_meta);
491 // Displays the results in a table
492 include('./libraries/display_tbl.lib.php3');
493 if (empty($disp_mode)) {
494 // see the "PMA_setDisplayMode()" function in
495 // libraries/display_tbl.lib.php3
496 $disp_mode = 'urdr111101';
498 if (!isset($dontlimitchars)) {
499 $dontlimitchars = 0;
502 PMA_displayTable($result, $disp_mode, $analyzed_sql);
503 mysql_free_result($result);
505 if ($disp_mode[6] == '1' || $disp_mode[9] == '1') {
506 echo "\n";
507 echo '<p>' . "\n";
509 // Displays "Insert a new row" link if required
510 if ($disp_mode[6] == '1') {
511 $lnk_goto = 'sql.php3'
512 . '?lang=' . $lang
513 . '&amp;convcharset=' . $convcharset
514 . '&amp;server=' . $server
515 . '&amp;db=' . urlencode($db)
516 . '&amp;table=' . urlencode($table)
517 . '&amp;pos=' . $pos
518 . '&amp;session_max_rows=' . $session_max_rows
519 . '&amp;disp_direction=' . $disp_direction
520 . '&amp;repeat_cells=' . $repeat_cells
521 . '&amp;dontlimitchars=' . $dontlimitchars
522 . '&amp;sql_query=' . urlencode($sql_query);
523 $url_query = '?lang=' . $lang
524 . '&amp;convcharset=' . $convcharset
525 . '&amp;server=' . $server
526 . '&amp;db=' . urlencode($db)
527 . '&amp;table=' . urlencode($table)
528 . '&amp;pos=' . $pos
529 . '&amp;session_max_rows=' . $session_max_rows
530 . '&amp;disp_direction=' . $disp_direction
531 . '&amp;repeat_cells=' . $repeat_cells
532 . '&amp;dontlimitchars=' . $dontlimitchars
533 . '&amp;sql_query=' . urlencode($sql_query)
534 . '&amp;goto=' . urlencode($lnk_goto);
536 echo ' <!-- Insert a new row -->' . "\n"
537 . ' <a href="tbl_change.php3' . $url_query . '">' . $strInsertNewRow . '</a>';
538 if ($disp_mode[9] == '1') {
539 echo '<br />';
541 echo "\n";
542 } // end insert new row
544 // Displays "printable view" link if required
545 if ($disp_mode[9] == '1') {
546 $url_query = '?lang=' . $lang
547 . '&amp;convcharset=' . $convcharset
548 . '&amp;server=' . $server
549 . '&amp;db=' . urlencode($db)
550 . '&amp;table=' . urlencode($table)
551 . '&amp;pos=' . $pos
552 . '&amp;session_max_rows=' . $session_max_rows
553 . '&amp;disp_direction=' . $disp_direction
554 . '&amp;repeat_cells=' . $repeat_cells
555 . '&amp;printview=1'
556 . ((isset($dontlimitchars) && $dontlimitchars == '1') ? '&amp;dontlimitchars=1' : '')
557 . '&amp;sql_query=' . urlencode($sql_query);
558 echo ' <!-- Print view -->' . "\n"
559 . ' <a href="sql.php3' . $url_query . '" target="print_view">' . $strPrintView . '</a>' . "\n";
560 } // end displays "printable view"
562 echo '</p>' . "\n";
565 // Bookmark Support if required
566 if ($disp_mode[7] == '1'
567 && ($cfg['Bookmark']['db'] && $cfg['Bookmark']['table'] && empty($id_bookmark))
568 && !empty($sql_query)) {
569 echo "\n";
571 $goto = 'sql.php3'
572 . '?lang=' . $lang
573 . '&amp;convcharset=' . $convcharset
574 . '&amp;server=' . $server
575 . '&amp;db=' . urlencode($db)
576 . '&amp;table=' . urlencode($table)
577 . '&amp;pos=' . $pos
578 . '&amp;session_max_rows=' . $session_max_rows
579 . '&amp;disp_direction=' . $disp_direction
580 . '&amp;repeat_cells=' . $repeat_cells
581 . '&amp;dontlimitchars=' . $dontlimitchars
582 . '&amp;sql_query=' . urlencode($sql_query)
583 . '&amp;id_bookmark=1';
585 <!-- Bookmark the query -->
586 <form action="sql.php3" method="post" onsubmit="return emptyFormElements(this, 'fields[label]');">
587 <?php
588 echo "\n";
589 if ($disp_mode[3] == '1') {
590 echo ' <i>' . $strOr . '</i>' . "\n";
593 <br /><br />
594 <?php echo $strBookmarkLabel; ?>&nbsp;:
595 <input type="hidden" name="server" value="<?php echo $server; ?>" />
596 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
597 <input type="hidden" name="fields[dbase]" value="<?php echo htmlspecialchars($db); ?>" />
598 <input type="hidden" name="fields[user]" value="<?php echo $cfg['Bookmark']['user']; ?>" />
599 <input type="hidden" name="fields[query]" value="<?php echo urlencode($sql_query); ?>" />
600 <input type="text" name="fields[label]" value="" />
601 <input type="submit" name="store_bkm" value="<?php echo $strBookmarkThis; ?>" />
602 </form>
603 <?php
604 } // end bookmark support
606 // Do print the page if required
607 if (isset($printview) && $printview == '1') {
608 echo "\n";
610 <script type="text/javascript" language="javascript1.2">
611 <!--
612 // Do print the page
613 if (typeof(window.print) != 'undefined') {
614 window.print();
616 //-->
617 </script>
618 <?php
619 } // end print case
620 } // end rows returned
622 } // end executes the query
623 echo "\n\n";
627 * Displays the footer
629 require('./footer.inc.php3');