update
[phpmyadmin/crack.git] / sql.php3
blob4ee010211b09edd56ab8b8b425be8ddc3a728dc0
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 . '?' . PMA_generate_common_url(isset($db) ? $db : '')
31 . ((strpos(' ' . $goto, 'db_details') != 1 && isset($table)) ? '&amp;table=' . urlencode($table) : '');
32 } // end if
34 // Coming from a bookmark dialog
35 if (isset($fields['query'])) {
36 $sql_query = $fields['query'];
39 /**
40 * Check rights in case of DROP DATABASE
42 * This test may be bypassed if $is_js_confirmed = 1 (already checked with js)
43 * but since a malicious user may pass this variable by url/form, we don't take
44 * into account this case.
46 if (!defined('PMA_CHK_DROP')
47 && !$cfg['AllowUserDropDatabase']
48 && eregi('DROP[[:space:]]+(IF EXISTS[[:space:]]+)?DATABASE[[:space:]]', $sql_query)) {
49 // Checks if the user is a Superuser
50 // TODO: set a global variable with this information
51 // loic1: optimized query
52 $result = @PMA_mysql_query('USE mysql');
53 if (PMA_mysql_error()) {
54 include('./header.inc.php3');
55 PMA_mysqlDie($strNoDropDatabases, '', '', $err_url);
56 } // end if
57 } // end if
60 /**
61 * Bookmark add
63 if (isset($store_bkm)) {
64 if (get_magic_quotes_gpc()) {
65 $fields['label'] = stripslashes($fields['label']);
67 include('./libraries/bookmark.lib.php3');
68 PMA_addBookmarks($fields, $cfg['Bookmark']);
69 header('Location: ' . $cfg['PmaAbsoluteUri'] . $goto);
70 } // end if
73 /**
74 * Gets the true sql query
76 // $sql_query has been urlencoded in the confirmation form for drop/delete
77 // queries or in the navigation bar for browsing among records
78 if (isset($btnDrop) || isset($navig)) {
79 $sql_query = urldecode($sql_query);
82 /**
83 * Reformat the query
86 $parsed_sql = PMA_SQP_parse((get_magic_quotes_gpc() ? stripslashes($sql_query) : $sql_query));
87 $analyzed_sql = PMA_SQP_analyze($parsed_sql);
88 // Bug #641765 - Robbat2 - 12 January 2003, 10:49PM
89 // Reverted - Robbat2 - 13 January 2003, 2:40PM
90 $sql_query = PMA_SQP_formatHtml($parsed_sql, 'query_only');
92 // old code did not work, for example, when there is a bracket
93 // before the SELECT
94 // so I guess it's ok to check for a real SELECT ... FROM
95 //$is_select = eregi('^SELECT[[:space:]]+', $sql_query);
96 $is_select = isset($analyzed_sql[0]['queryflags']['select_from']);
98 // If the query is a Select, extract the db and table names and modify
99 // $db and $table, to have correct page headers, links and left frame.
100 // db and table name may be enclosed with backquotes, db is optionnal,
101 // query may contain aliases.
103 // (TODO: if there are more than one table name in the Select:
104 // - do not extract the first table name
105 // - do not show a table name in the page header
106 // - do not display the sub-pages links)
108 if ($is_select) {
109 $prev_db = $db;
110 if (isset($analyzed_sql[0]['table_ref'][0]['table_true_name'])) {
111 $table = $analyzed_sql[0]['table_ref'][0]['table_true_name'];
113 if (isset($analyzed_sql[0]['table_ref'][0]['db'])
114 && !empty($analyzed_sql[0]['table_ref'][0]['db'])) {
115 $db = $analyzed_sql[0]['table_ref'][0]['db'];
117 else {
118 $db = $prev_db;
120 $reload = ($db == $prev_db) ? 0 : 1;
124 * Sets or modifies the $goto variable if required
126 if ($goto == 'sql.php3') {
127 $goto = 'sql.php3?'
128 . PMA_generate_common_url($db, $table)
129 . '&amp;pos=' . $pos
130 . '&amp;sql_query=' . urlencode($sql_query);
131 } // end if
135 * Go back to further page if table should not be dropped
137 if (isset($btnDrop) && $btnDrop == $strNo) {
138 if (!empty($back)) {
139 $goto = $back;
141 if ($is_gotofile) {
142 if (strpos(' ' . $goto, 'db_details') == 1 && !empty($table)) {
143 unset($table);
145 include('./' . ereg_replace('\.\.*', '.', $goto));
146 } else {
147 header('Location: ' . $cfg['PmaAbsoluteUri'] . str_replace('&amp;', '&', $goto));
149 exit();
150 } // end if
154 * Displays the confirm page if required
156 * This part of the script is bypassed if $is_js_confirmed = 1 (already checked
157 * with js) because possible security issue is not so important here: at most,
158 * the confirm message isn't displayed.
160 * Also bypassed if only showing php code.or validating a SQL query
162 if (!$cfg['Confirm']
163 || (isset($is_js_confirmed) && $is_js_confirmed)
164 || isset($btnDrop)
165 || !empty($GLOBALS['show_as_php'])
166 || !empty($GLOBALS['validatequery'])) {
167 $do_confirm = FALSE;
168 } else {
169 //$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));
171 $do_confirm = isset($analyzed_sql[0]['queryflags']['need_confirm']);
174 if ($do_confirm) {
175 // already stripped at beginning of script
176 //$stripped_sql_query = (get_magic_quotes_gpc() ? stripslashes($sql_query) : $sql_query);
177 $stripped_sql_query = $sql_query;
178 include('./header.inc.php3');
179 echo $strDoYouReally . '&nbsp;:<br />' . "\n";
180 echo '<tt>' . htmlspecialchars($stripped_sql_query) . '</tt>&nbsp;?<br/>' . "\n";
182 <form action="sql.php3" method="post">
183 <?php echo PMA_generate_common_hidden_inputs($db, (isset($table)?$table:'')); ?>
184 <input type="hidden" name="sql_query" value="<?php echo urlencode(addslashes($sql_query)); ?>" />
185 <input type="hidden" name="zero_rows" value="<?php echo isset($zero_rows) ? $zero_rows : ''; ?>" />
186 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
187 <input type="hidden" name="back" value="<?php echo isset($back) ? $back : ''; ?>" />
188 <input type="hidden" name="reload" value="<?php echo isset($reload) ? $reload : 0; ?>" />
189 <input type="hidden" name="show_query" value="<?php echo isset($show_query) ? $show_query : ''; ?>" />
190 <input type="submit" name="btnDrop" value="<?php echo $strYes; ?>" />
191 <input type="submit" name="btnDrop" value="<?php echo $strNo; ?>" />
192 </form>
193 <?php
194 echo "\n";
195 } // end if
199 * Executes the query and displays results
201 else {
202 if (!isset($sql_query)) {
203 $sql_query = '';
205 // already stripped at beginning of script
206 // else if (get_magic_quotes_gpc()) {
207 // $sql_query = stripslashes($sql_query);
209 // Defines some variables
210 // loic1: A table has to be created -> left frame should be reloaded
211 if ((!isset($reload) || $reload == 0)
212 && eregi('^CREATE TABLE[[:space:]]+(.*)', $sql_query)) {
213 $reload = 1;
215 // Gets the number of rows per page
216 if (!isset($session_max_rows)) {
217 $session_max_rows = $cfg['MaxRows'];
218 } else if ($session_max_rows != 'all') {
219 $cfg['MaxRows'] = $session_max_rows;
221 // Defines the display mode (horizontal/vertical) and header "frequency"
222 if (empty($disp_direction)) {
223 $disp_direction = $cfg['DefaultDisplay'];
225 if (empty($repeat_cells)) {
226 $repeat_cells = $cfg['RepeatCells'];
229 // SK -- Patch: $is_group added for use in calculation of total number of
230 // rows.
231 // $is_count is changed for more correct "LIMIT" clause
232 // appending in queries like
233 // "SELECT COUNT(...) FROM ... GROUP BY ..."
234 $is_explain = $is_count = $is_export = $is_delete = $is_insert = $is_affected = $is_show = $is_maint = $is_analyse = $is_group = $is_func = FALSE;
235 if ($is_select) { // see line 141
236 $is_group = eregi('[[:space:]]+(GROUP[[:space:]]+BY|HAVING|SELECT[[:space:]]+DISTINCT)[[:space:]]+', $sql_query);
238 $is_func = !$is_group && (eregi('[[:space:]]+(SUM|AVG|STD|STDDEV|MIN|MAX|BIT_OR|BIT_AND)\s*\(', $sql_query));
239 $is_count = !$is_group && (eregi('^SELECT[[:space:]]+COUNT\((.*\.+)?.*\)', $sql_query));
240 $is_export = (eregi('[[:space:]]+INTO[[:space:]]+OUTFILE[[:space:]]+', $sql_query));
241 $is_analyse = (eregi('[[:space:]]+PROCEDURE[[:space:]]+ANALYSE\(', $sql_query));
242 } else if (eregi('^EXPLAIN[[:space:]]+', $sql_query)) {
243 $is_explain = TRUE;
244 } else if (eregi('^DELETE[[:space:]]+', $sql_query)) {
245 $is_delete = TRUE;
246 $is_affected = TRUE;
247 } else if (eregi('^(INSERT|LOAD[[:space:]]+DATA|REPLACE)[[:space:]]+', $sql_query)) {
248 $is_insert = TRUE;
249 $is_affected = TRUE;
250 } else if (eregi('^UPDATE[[:space:]]+', $sql_query)) {
251 $is_affected = TRUE;
252 } else if (eregi('^SHOW[[:space:]]+', $sql_query)) {
253 $is_show = TRUE;
254 } else if (eregi('^(CHECK|ANALYZE|REPAIR|OPTIMIZE)[[:space:]]+TABLE[[:space:]]+', $sql_query)) {
255 $is_maint = TRUE;
258 // Do append a "LIMIT" clause?
259 if (isset($pos)
260 && (!$cfg['ShowAll'] || $session_max_rows != 'all')
261 && !($is_count || $is_export || $is_func || $is_analyse)
262 && isset($analyzed_sql[0]['queryflags']['select_from'])
263 && !eregi('[[:space:]]LIMIT[[:space:]0-9,-]+$', $sql_query)) {
264 $sql_limit_to_append = " LIMIT $pos, ".$cfg['MaxRows'];
265 if (eregi('(.*)([[:space:]](PROCEDURE[[:space:]](.*)|FOR[[:space:]]+UPDATE|LOCK[[:space:]]+IN[[:space:]]+SHARE[[:space:]]+MODE))$', $sql_query, $regs)) {
266 $full_sql_query = $regs[1] . $sql_limit_to_append . $regs[2];
267 } else {
268 $full_sql_query = $sql_query . $sql_limit_to_append;
270 } else {
271 $full_sql_query = $sql_query;
272 } // end if...else
274 PMA_mysql_select_db($db);
276 // If the query is a DELETE query with no WHERE clause, get the number of
277 // rows that will be deleted (mysql_affected_rows will always return 0 in
278 // this case)
279 if ($is_delete
280 && eregi('^DELETE([[:space:]].+)?([[:space:]]FROM[[:space:]](.+))$', $sql_query, $parts)
281 && !eregi('[[:space:]]WHERE[[:space:]]', $parts[3])) {
282 $cnt_all_result = @PMA_mysql_query('SELECT COUNT(*) as count' . $parts[2]);
283 if ($cnt_all_result) {
284 $num_rows = PMA_mysql_result($cnt_all_result, 0, 'count');
285 mysql_free_result($cnt_all_result);
286 } else {
287 $num_rows = 0;
291 // E x e c u t e t h e q u e r y
293 // Only if we didn't ask to see the php code (mikebeck)
294 if (!empty($GLOBALS['show_as_php']) || !empty($GLOBALS['validatequery'])) {
295 unset($result);
296 $num_rows = 0;
298 else {
299 $result = @PMA_mysql_query($full_sql_query);
301 // Displays an error message if required and stop parsing the script
302 if (PMA_mysql_error()) {
303 $error = PMA_mysql_error();
304 include('./header.inc.php3');
305 $full_err_url = (ereg('^(db_details|tbl_properties)', $err_url))
306 ? $err_url . '&amp;show_query=1&amp;sql_query=' . urlencode($sql_query)
307 : $err_url;
308 PMA_mysqlDie($error, $full_sql_query, '', $full_err_url);
311 // Gets the number of rows affected/returned
312 // (This must be done immediately after the query because
313 // mysql_affected_rows() reports about the last query done)
315 if (!$is_affected) {
316 $num_rows = ($result) ? @mysql_num_rows($result) : 0;
317 } else if (!isset($num_rows)) {
318 $num_rows = @mysql_affected_rows();
321 // Checks if the current database has changed
322 // This could happen if the user sends a query like "USE `database`;"
323 $res = PMA_mysql_query('SELECT DATABASE() AS "db";');
324 $row = PMA_mysql_fetch_array($res);
325 if ($db != $row['db']) {
326 $db = $row['db'];
327 $reload = 1;
329 @mysql_free_result($res);
330 unset($res);
331 unset($row);
333 // tmpfile remove after convert encoding appended by Y.Kawada
334 if (function_exists('PMA_kanji_file_conv')
335 && (isset($textfile) && file_exists($textfile))) {
336 unlink($textfile);
339 // Counts the total number of rows for the same 'SELECT' query without the
340 // '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) {
347 // c o u n t q u e r y
349 if (PMA_MYSQL_INT_VERSION < 40000) {
350 if (eregi('DISTINCT(.*)', $sql_query)) {
351 $count_what = 'DISTINCT ' . $analyzed_sql[0]['select_expr_clause'];
352 } else {
353 $count_what = '*';
356 $count_query = 'SELECT COUNT(' . $count_what . ') AS count';
358 else {
359 $count_query = 'SELECT SQL_CALC_FOUND_ROWS ';
362 // add the remaining of select expression if there is
363 // a GROUP BY or HAVING clause
364 if (PMA_MYSQL_INT_VERSION < 40000
365 && $count_what =='*'
366 && (!empty($analyzed_sql[0]['group_by_clause'])
367 || !empty($analyzed_sql[0]['having_clause']))) {
368 $count_query .= ' ,' . $analyzed_sql[0]['select_expr_clause'];
371 // add select expression after the SQL_CALC_FOUND_ROWS
372 if (PMA_MYSQL_INT_VERSION >= 40000) {
373 $count_query .= $analyzed_sql[0]['select_expr_clause'];
377 if (!empty($analyzed_sql[0]['from_clause'])) {
378 $count_query .= ' FROM ' . $analyzed_sql[0]['from_clause'];
381 if (!empty($analyzed_sql[0]['where_clause'])) {
382 $count_query .= ' WHERE ' . $analyzed_sql[0]['where_clause'];
384 if (!empty($analyzed_sql[0]['group_by_clause'])) {
385 $count_query .= ' GROUP BY ' . $analyzed_sql[0]['group_by_clause'];
388 if (!empty($analyzed_sql[0]['having_clause'])) {
389 $count_query .= ' HAVING ' . $analyzed_sql[0]['having_clause'];
392 // do not put the order_by_clause, it interferes
393 // run the count query
394 if (PMA_MYSQL_INT_VERSION < 40000) {
395 if ($cnt_all_result = mysql_query($count_query)) {
396 if ($is_group) {
397 $unlim_num_rows = @mysql_num_rows($cnt_all_result);
398 } else {
399 $unlim_num_rows = mysql_result($cnt_all_result, 0, 'count');
401 mysql_free_result($cnt_all_result);
402 } else {
403 if (mysql_error()) {
404 // there are some cases where the generated
405 // count_query (for MySQL 3) is wrong,
406 // so we get here.
407 //TODO: use a big unlimited query to get
408 // the correct number of rows (depending
409 // on a config variable?)
410 $unlim_num_rows = 0;
413 } else {
414 mysql_query($count_query);
415 if (mysql_error()) {
416 // void. I tried the case
417 // (SELECT `User`, `Host`, `Db`, `Select_priv` FROM `db`)
418 // UNION (SELECT `User`, `Host`, "%" AS "Db",
419 // `Select_priv`
420 // FROM `user`) ORDER BY `User`, `Host`, `Db`;
421 // and although the generated count_query is wrong
422 // the SELECT FOUND_ROWS() work!
424 $cnt_all_result = mysql_query('SELECT FOUND_ROWS() as count');
425 $unlim_num_rows = mysql_result($cnt_all_result,0,'count');
428 } else { // not $is_select
429 $unlim_num_rows = 0;
430 } // end rows total count
431 } // end else "didn't ask to see php code"
434 // No rows returned -> move back to the calling page
435 if ($num_rows < 1 || $is_affected) {
436 if ($is_delete) {
437 $message = $strDeletedRows . '&nbsp;' . $num_rows;
438 } else if ($is_insert) {
439 $message = $strInsertedRows . '&nbsp;' . $num_rows;
440 } else if ($is_affected) {
441 $message = $strAffectedRows . '&nbsp;' . $num_rows;
442 } else if (!empty($zero_rows)) {
443 $message = $zero_rows;
444 } else if (!empty($GLOBALS['show_as_php'])) {
445 $message = $strPhp;
446 } else if (!empty($GLOBALS['validatequery'])) {
447 $message = $strValidateSQL;
448 } else {
449 $message = $strEmptyResultSet;
452 if ($is_gotofile) {
453 $goto = ereg_replace('\.\.*', '.', $goto);
454 // Checks for a valid target script
455 if (isset($table) && $table == '') {
456 unset($table);
458 if (isset($db) && $db == '') {
459 unset($db);
461 $is_db = $is_table = FALSE;
462 if (strpos(' ' . $goto, 'tbl_properties') == 1) {
463 if (!isset($table)) {
464 $goto = 'db_details.php3';
465 } else {
466 $is_table = @PMA_mysql_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\'');
467 if (!($is_table && @mysql_numrows($is_table))) {
468 $goto = 'db_details.php3';
469 unset($table);
471 } // end if... else...
473 if (strpos(' ' . $goto, 'db_details') == 1) {
474 if (isset($table)) {
475 unset($table);
477 if (!isset($db)) {
478 $goto = 'main.php3';
479 } else {
480 $is_db = @PMA_mysql_select_db($db);
481 if (!$is_db) {
482 $goto = 'main.php3';
483 unset($db);
485 } // end if... else...
487 // Loads to target script
488 if (strpos(' ' . $goto, 'db_details') == 1
489 || strpos(' ' . $goto, 'tbl_properties') == 1) {
490 $js_to_run = 'functions.js';
492 if ($goto != 'main.php3') {
493 include('./header.inc.php3');
495 include('./' . $goto);
496 } // end if file_exist
497 else {
498 header('Location: ' . $cfg['PmaAbsoluteUri'] . str_replace('&amp;', '&', $goto) . '&message=' . urlencode($message));
499 } // end else
500 exit();
501 } // end no rows returned
503 // At least one row is returned -> displays a table with results
504 else {
505 // Displays the headers
506 if (isset($show_query)) {
507 unset($show_query);
509 if (isset($printview) && $printview == '1') {
510 include('./header_printview.inc.php3');
511 } else {
512 $js_to_run = 'functions.js';
513 unset($message);
514 if (!empty($table)) {
515 include('./tbl_properties_common.php3');
516 $url_query .= '&amp;goto=tbl_properties.php3&amp;back=tbl_properties.php3';
517 include('./tbl_properties_table_info.php3');
519 else {
520 include('./db_details_common.php3');
521 include('./db_details_db_info.php3');
523 include('./libraries/relation.lib.php3');
524 $cfgRelation = PMA_getRelationsParam();
527 // Gets the list of fields properties
528 if (isset($result) && $result) {
529 while ($field = PMA_mysql_fetch_field($result)) {
530 $fields_meta[] = $field;
532 $fields_cnt = count($fields_meta);
535 // Display previous update query (from tbl_replace)
536 if (isset($disp_query) && $cfg['ShowSQL'] == TRUE) {
537 $tmp_sql_query = $GLOBALS['sql_query'];
538 $tmp_sql_limit_to_append = (isset($GLOBALS['sql_limit_to_append'])?$GLOBALS['sql_limit_to_append']:'');
539 $GLOBALS['sql_query'] = stripslashes($disp_query);
540 $GLOBALS['sql_limit_to_append'] = '';
541 PMA_showMessage($disp_message);
542 $GLOBALS['sql_query'] = $tmp_sql_query;
543 $GLOBALS['sql_limit_to_append'] = $tmp_sql_limit_to_append;
546 // Displays the results in a table
547 include('./libraries/display_tbl.lib.php3');
548 if (empty($disp_mode)) {
549 // see the "PMA_setDisplayMode()" function in
550 // libraries/display_tbl.lib.php3
551 $disp_mode = 'urdr111101';
553 if (!isset($dontlimitchars)) {
554 $dontlimitchars = 0;
557 PMA_displayTable($result, $disp_mode, $analyzed_sql);
558 mysql_free_result($result);
560 if ($disp_mode[6] == '1' || $disp_mode[9] == '1') {
561 echo "\n";
562 echo '<p>' . "\n";
564 // Displays "Insert a new row" link if required
565 if ($disp_mode[6] == '1') {
566 $lnk_goto = 'sql.php3?'
567 . PMA_generate_common_url($db, $table)
568 . '&amp;pos=' . $pos
569 . '&amp;session_max_rows=' . $session_max_rows
570 . '&amp;disp_direction=' . $disp_direction
571 . '&amp;repeat_cells=' . $repeat_cells
572 . '&amp;dontlimitchars=' . $dontlimitchars
573 . '&amp;sql_query=' . urlencode($sql_query);
574 $url_query = '?'
575 . PMA_generate_common_url($db, $table)
576 . '&amp;pos=' . $pos
577 . '&amp;session_max_rows=' . $session_max_rows
578 . '&amp;disp_direction=' . $disp_direction
579 . '&amp;repeat_cells=' . $repeat_cells
580 . '&amp;dontlimitchars=' . $dontlimitchars
581 . '&amp;sql_query=' . urlencode($sql_query)
582 . '&amp;goto=' . urlencode($lnk_goto);
584 echo ' <!-- Insert a new row -->' . "\n"
585 . ' <a href="tbl_change.php3' . $url_query . '">' . $strInsertNewRow . '</a>';
586 if ($disp_mode[9] == '1') {
587 echo '<br />';
589 echo "\n";
590 } // end insert new row
592 // Displays "printable view" link if required
593 if ($disp_mode[9] == '1') {
594 $url_query = '?'
595 . PMA_generate_common_url($db, $table)
596 . '&amp;pos=' . $pos
597 . '&amp;session_max_rows=' . $session_max_rows
598 . '&amp;disp_direction=' . $disp_direction
599 . '&amp;repeat_cells=' . $repeat_cells
600 . '&amp;printview=1'
601 . ((isset($dontlimitchars) && $dontlimitchars == '1') ? '&amp;dontlimitchars=1' : '')
602 . '&amp;sql_query=' . urlencode($sql_query);
603 echo ' <!-- Print view -->' . "\n"
604 . ' <a href="sql.php3' . $url_query . '" target="print_view">' . $strPrintView . '</a>' . "\n";
605 } // end displays "printable view"
607 echo '</p>' . "\n";
610 // Export link, if only one table
611 // (the url_query has extra parameters that won't be used to export)
612 if (!isset($printview)
613 && isset($analyzed_sql[0]['table_ref'][0]['table_true_name'])
614 && !isset($analyzed_sql[0]['table_ref'][1]['table_true_name'])) {
615 echo ' <!-- Export -->' . "\n"
616 . ' <a href="tbl_properties_export.php3' . $url_query . '&amp;unlim_num_rows=' . $unlim_num_rows . '">' . $strExport . '</a>' . "\n";
619 // Bookmark Support if required
620 if ($disp_mode[7] == '1'
621 && ($cfg['Bookmark']['db'] && $cfg['Bookmark']['table'] && empty($id_bookmark))
622 && !empty($sql_query)) {
623 echo "\n";
625 $goto = 'sql.php3?'
626 . PMA_generate_common_url($db, $table)
627 . '&amp;pos=' . $pos
628 . '&amp;session_max_rows=' . $session_max_rows
629 . '&amp;disp_direction=' . $disp_direction
630 . '&amp;repeat_cells=' . $repeat_cells
631 . '&amp;dontlimitchars=' . $dontlimitchars
632 . '&amp;sql_query=' . urlencode($sql_query)
633 . '&amp;id_bookmark=1';
635 <!-- Bookmark the query -->
636 <form action="sql.php3" method="post" onsubmit="return emptyFormElements(this, 'fields[label]');">
637 <?php
638 echo "\n";
639 if ($disp_mode[3] == '1') {
640 echo ' <i>' . $strOr . '</i>' . "\n";
643 <br /><br />
644 <?php echo $strBookmarkLabel; ?>&nbsp;:
645 <?php echo PMA_generate_common_hidden_inputs(); ?>
646 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
647 <input type="hidden" name="fields[dbase]" value="<?php echo htmlspecialchars($db); ?>" />
648 <input type="hidden" name="fields[user]" value="<?php echo $cfg['Bookmark']['user']; ?>" />
649 <input type="hidden" name="fields[query]" value="<?php echo urlencode($sql_query); ?>" />
650 <input type="text" name="fields[label]" value="" />
651 <input type="submit" name="store_bkm" value="<?php echo $strBookmarkThis; ?>" />
652 </form>
653 <?php
654 } // end bookmark support
656 // Do print the page if required
657 if (isset($printview) && $printview == '1') {
658 echo "\n";
660 <script type="text/javascript" language="javascript1.2">
661 <!--
662 // Do print the page
663 if (typeof(window.print) != 'undefined') {
664 window.print();
666 //-->
667 </script>
668 <?php
669 } // end print case
670 } // end rows returned
672 } // end executes the query
673 echo "\n\n";
677 * Displays the footer
679 require('./footer.inc.php3');