back to previous version
[phpmyadmin/crack.git] / sql.php3
blob07d8fc8579845ce1eea0d1e1b95cbb09a5681b7f
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 include('./libraries/bookmark.lib.php3');
65 PMA_addBookmarks($fields, $cfg['Bookmark']);
66 header('Location: ' . $cfg['PmaAbsoluteUri'] . $goto);
67 } // end if
70 /**
71 * Gets the true sql query
73 // $sql_query has been urlencoded in the confirmation form for drop/delete
74 // queries or in the navigation bar for browsing among records
75 if (isset($btnDrop) || isset($navig)) {
76 $sql_query = urldecode($sql_query);
79 /**
80 * Reformat the query
83 $parsed_sql = PMA_SQP_parse($sql_query);
84 $analyzed_sql = PMA_SQP_analyze($parsed_sql);
85 // Bug #641765 - Robbat2 - 12 January 2003, 10:49PM
86 // Reverted - Robbat2 - 13 January 2003, 2:40PM
87 $sql_query = PMA_SQP_formatHtml($parsed_sql, 'query_only');
89 // old code did not work, for example, when there is a bracket
90 // before the SELECT
91 // so I guess it's ok to check for a real SELECT ... FROM
92 //$is_select = eregi('^SELECT[[:space:]]+', $sql_query);
93 $is_select = isset($analyzed_sql[0]['queryflags']['select_from']);
95 // If the query is a Select, extract the db and table names and modify
96 // $db and $table, to have correct page headers, links and left frame.
97 // db and table name may be enclosed with backquotes, db is optionnal,
98 // query may contain aliases.
100 // (TODO: if there are more than one table name in the Select:
101 // - do not extract the first table name
102 // - do not show a table name in the page header
103 // - do not display the sub-pages links)
105 if ($is_select) {
106 $prev_db = $db;
107 if (isset($analyzed_sql[0]['table_ref'][0]['table_true_name'])) {
108 $table = $analyzed_sql[0]['table_ref'][0]['table_true_name'];
110 if (isset($analyzed_sql[0]['table_ref'][0]['db'])
111 && !empty($analyzed_sql[0]['table_ref'][0]['db'])) {
112 $db = $analyzed_sql[0]['table_ref'][0]['db'];
114 else {
115 $db = $prev_db;
117 $reload = ($db == $prev_db) ? 0 : 1;
121 * Sets or modifies the $goto variable if required
123 if ($goto == 'sql.php3') {
124 $goto = 'sql.php3?'
125 . PMA_generate_common_url($db, $table)
126 . '&amp;pos=' . $pos
127 . '&amp;sql_query=' . urlencode($sql_query);
128 } // end if
132 * Go back to further page if table should not be dropped
134 if (isset($btnDrop) && $btnDrop == $strNo) {
135 if (!empty($back)) {
136 $goto = $back;
138 if ($is_gotofile) {
139 if (strpos(' ' . $goto, 'db_details') == 1 && !empty($table)) {
140 unset($table);
142 include('./' . ereg_replace('\.\.*', '.', $goto));
143 } else {
144 header('Location: ' . $cfg['PmaAbsoluteUri'] . str_replace('&amp;', '&', $goto));
146 exit();
147 } // end if
151 * Displays the confirm page if required
153 * This part of the script is bypassed if $is_js_confirmed = 1 (already checked
154 * with js) because possible security issue is not so important here: at most,
155 * the confirm message isn't displayed.
157 * Also bypassed if only showing php code.or validating a SQL query
159 if (!$cfg['Confirm']
160 || (isset($is_js_confirmed) && $is_js_confirmed)
161 || isset($btnDrop)
162 || !empty($GLOBALS['show_as_php'])
163 || !empty($GLOBALS['validatequery'])) {
164 $do_confirm = FALSE;
165 } else {
166 //$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));
168 $do_confirm = isset($analyzed_sql[0]['queryflags']['need_confirm']);
171 if ($do_confirm) {
172 $stripped_sql_query = $sql_query;
173 include('./header.inc.php3');
174 echo $strDoYouReally . '&nbsp;:<br />' . "\n";
175 echo '<tt>' . htmlspecialchars($stripped_sql_query) . '</tt>&nbsp;?<br/>' . "\n";
177 <form action="sql.php3" method="post">
178 <?php echo PMA_generate_common_hidden_inputs($db, (isset($table)?$table:'')); ?>
179 <input type="hidden" name="sql_query" value="<?php echo urlencode(addslashes($sql_query)); ?>" />
180 <input type="hidden" name="zero_rows" value="<?php echo isset($zero_rows) ? $zero_rows : ''; ?>" />
181 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
182 <input type="hidden" name="back" value="<?php echo isset($back) ? $back : ''; ?>" />
183 <input type="hidden" name="reload" value="<?php echo isset($reload) ? $reload : 0; ?>" />
184 <input type="hidden" name="show_query" value="<?php echo isset($show_query) ? $show_query : ''; ?>" />
185 <input type="submit" name="btnDrop" value="<?php echo $strYes; ?>" />
186 <input type="submit" name="btnDrop" value="<?php echo $strNo; ?>" />
187 </form>
188 <?php
189 echo "\n";
190 } // end if
194 * Executes the query and displays results
196 else {
197 if (!isset($sql_query)) {
198 $sql_query = '';
200 // Defines some variables
201 // loic1: A table has to be created -> left frame should be reloaded
202 if ((!isset($reload) || $reload == 0)
203 && eregi('^CREATE TABLE[[:space:]]+(.*)', $sql_query)) {
204 $reload = 1;
206 // Gets the number of rows per page
207 if (!isset($session_max_rows)) {
208 $session_max_rows = $cfg['MaxRows'];
209 } else if ($session_max_rows != 'all') {
210 $cfg['MaxRows'] = $session_max_rows;
212 // Defines the display mode (horizontal/vertical) and header "frequency"
213 if (empty($disp_direction)) {
214 $disp_direction = $cfg['DefaultDisplay'];
216 if (empty($repeat_cells)) {
217 $repeat_cells = $cfg['RepeatCells'];
220 // SK -- Patch: $is_group added for use in calculation of total number of
221 // rows.
222 // $is_count is changed for more correct "LIMIT" clause
223 // appending in queries like
224 // "SELECT COUNT(...) FROM ... GROUP BY ..."
225 $is_explain = $is_count = $is_export = $is_delete = $is_insert = $is_affected = $is_show = $is_maint = $is_analyse = $is_group = $is_func = FALSE;
226 if ($is_select) { // see line 141
227 $is_group = eregi('[[:space:]]+(GROUP[[:space:]]+BY|HAVING|SELECT[[:space:]]+DISTINCT)[[:space:]]+', $sql_query);
229 $is_func = !$is_group && (eregi('[[:space:]]+(SUM|AVG|STD|STDDEV|MIN|MAX|BIT_OR|BIT_AND)\s*\(', $sql_query));
230 $is_count = !$is_group && (eregi('^SELECT[[:space:]]+COUNT\((.*\.+)?.*\)', $sql_query));
231 $is_export = (eregi('[[:space:]]+INTO[[:space:]]+OUTFILE[[:space:]]+', $sql_query));
232 $is_analyse = (eregi('[[:space:]]+PROCEDURE[[:space:]]+ANALYSE\(', $sql_query));
233 } else if (eregi('^EXPLAIN[[:space:]]+', $sql_query)) {
234 $is_explain = TRUE;
235 } else if (eregi('^DELETE[[:space:]]+', $sql_query)) {
236 $is_delete = TRUE;
237 $is_affected = TRUE;
238 } else if (eregi('^(INSERT|LOAD[[:space:]]+DATA|REPLACE)[[:space:]]+', $sql_query)) {
239 $is_insert = TRUE;
240 $is_affected = TRUE;
241 } else if (eregi('^UPDATE[[:space:]]+', $sql_query)) {
242 $is_affected = TRUE;
243 } else if (eregi('^SHOW[[:space:]]+', $sql_query)) {
244 $is_show = TRUE;
245 } else if (eregi('^(CHECK|ANALYZE|REPAIR|OPTIMIZE)[[:space:]]+TABLE[[:space:]]+', $sql_query)) {
246 $is_maint = TRUE;
249 // Do append a "LIMIT" clause?
250 if (isset($pos)
251 && (!$cfg['ShowAll'] || $session_max_rows != 'all')
252 && !($is_count || $is_export || $is_func || $is_analyse)
253 && isset($analyzed_sql[0]['queryflags']['select_from'])
254 && !eregi('[[:space:]]LIMIT[[:space:]0-9,-]+$', $sql_query)) {
255 $sql_limit_to_append = " LIMIT $pos, ".$cfg['MaxRows'];
256 if (eregi('(.*)([[:space:]](PROCEDURE[[:space:]](.*)|FOR[[:space:]]+UPDATE|LOCK[[:space:]]+IN[[:space:]]+SHARE[[:space:]]+MODE))$', $sql_query, $regs)) {
257 $full_sql_query = $regs[1] . $sql_limit_to_append . $regs[2];
258 } else {
259 $full_sql_query = $sql_query . $sql_limit_to_append;
261 } else {
262 $full_sql_query = $sql_query;
263 } // end if...else
265 PMA_mysql_select_db($db);
267 // If the query is a DELETE query with no WHERE clause, get the number of
268 // rows that will be deleted (mysql_affected_rows will always return 0 in
269 // this case)
270 if ($is_delete
271 && eregi('^DELETE([[:space:]].+)?([[:space:]]FROM[[:space:]](.+))$', $sql_query, $parts)
272 && !eregi('[[:space:]]WHERE[[:space:]]', $parts[3])) {
273 $cnt_all_result = @PMA_mysql_query('SELECT COUNT(*) as count' . $parts[2]);
274 if ($cnt_all_result) {
275 $num_rows = PMA_mysql_result($cnt_all_result, 0, 'count');
276 mysql_free_result($cnt_all_result);
277 } else {
278 $num_rows = 0;
282 // E x e c u t e t h e q u e r y
284 // Only if we didn't ask to see the php code (mikebeck)
285 if (!empty($GLOBALS['show_as_php']) || !empty($GLOBALS['validatequery'])) {
286 unset($result);
287 $num_rows = 0;
289 else {
290 // garvin: Measure query time. TODO-Item http://sourceforge.net/tracker/index.php?func=detail&aid=571934&group_id=23067&atid=377411
291 list($usec, $sec) = explode(' ',microtime());
292 $querytime_before = ((float)$usec + (float)$sec);
294 $result = @PMA_mysql_query($full_sql_query);
296 list($usec, $sec) = explode(' ',microtime());
297 $querytime_after = ((float)$usec + (float)$sec);
299 $GLOBALS['querytime'] = $querytime_after - $querytime_before;
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
432 // garvin: if a table or database gets dropped, check column comments.
433 if (isset($purge)) {
434 include('./libraries/relation.lib.php3');
435 $cfgRelation = PMA_getRelationsParam();
437 if ($cfgRelation['commwork']) {
438 if (isset($table) && isset($db) && !empty($table) && !empty($db)) {
439 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['column_info'])
440 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
441 . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
442 $rmv_rs = PMA_query_as_cu($remove_query);
443 unset($rmv_query);
444 } elseif (isset($db) && !empty($db)) {
445 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['column_info'])
446 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
447 $rmv_rs = PMA_query_as_cu($remove_query);
448 unset($rmv_query);
450 } // end if relation-stuff
451 } // end if ($purge)
452 } // end else "didn't ask to see php code"
455 // No rows returned -> move back to the calling page
456 if ($num_rows < 1 || $is_affected) {
457 if ($is_delete) {
458 $message = $strDeletedRows . '&nbsp;' . $num_rows;
459 } else if ($is_insert) {
460 $message = $strInsertedRows . '&nbsp;' . $num_rows;
461 } else if ($is_affected) {
462 $message = $strAffectedRows . '&nbsp;' . $num_rows;
463 } else if (!empty($zero_rows)) {
464 $message = $zero_rows;
465 } else if (!empty($GLOBALS['show_as_php'])) {
466 $message = $strPhp;
467 } else if (!empty($GLOBALS['validatequery'])) {
468 $message = $strValidateSQL;
469 } else {
470 $message = $strEmptyResultSet;
473 $message .= " (" . sprintf($strQueryTime, $GLOBALS['querytime']) . ")";
475 if ($is_gotofile) {
476 $goto = ereg_replace('\.\.*', '.', $goto);
477 // Checks for a valid target script
478 if (isset($table) && $table == '') {
479 unset($table);
481 if (isset($db) && $db == '') {
482 unset($db);
484 $is_db = $is_table = FALSE;
485 if (strpos(' ' . $goto, 'tbl_properties') == 1) {
486 if (!isset($table)) {
487 $goto = 'db_details.php3';
488 } else {
489 $is_table = @PMA_mysql_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\'');
490 if (!($is_table && @mysql_numrows($is_table))) {
491 $goto = 'db_details.php3';
492 unset($table);
494 } // end if... else...
496 if (strpos(' ' . $goto, 'db_details') == 1) {
497 if (isset($table)) {
498 unset($table);
500 if (!isset($db)) {
501 $goto = 'main.php3';
502 } else {
503 $is_db = @PMA_mysql_select_db($db);
504 if (!$is_db) {
505 $goto = 'main.php3';
506 unset($db);
508 } // end if... else...
510 // Loads to target script
511 if (strpos(' ' . $goto, 'db_details') == 1
512 || strpos(' ' . $goto, 'tbl_properties') == 1) {
513 $js_to_run = 'functions.js';
515 if ($goto != 'main.php3') {
516 include('./header.inc.php3');
518 include('./' . $goto);
519 } // end if file_exist
520 else {
521 header('Location: ' . $cfg['PmaAbsoluteUri'] . str_replace('&amp;', '&', $goto) . '&message=' . urlencode($message));
522 } // end else
523 exit();
524 } // end no rows returned
526 // At least one row is returned -> displays a table with results
527 else {
528 // Displays the headers
529 if (isset($show_query)) {
530 unset($show_query);
532 if (isset($printview) && $printview == '1') {
533 include('./header_printview.inc.php3');
534 } else {
535 $js_to_run = 'functions.js';
536 unset($message);
537 if (!empty($table)) {
538 include('./tbl_properties_common.php3');
539 $url_query .= '&amp;goto=tbl_properties.php3&amp;back=tbl_properties.php3';
540 include('./tbl_properties_table_info.php3');
542 else {
543 include('./db_details_common.php3');
544 include('./db_details_db_info.php3');
546 include('./libraries/relation.lib.php3');
547 $cfgRelation = PMA_getRelationsParam();
550 // Gets the list of fields properties
551 if (isset($result) && $result) {
552 while ($field = PMA_mysql_fetch_field($result)) {
553 $fields_meta[] = $field;
555 $fields_cnt = count($fields_meta);
558 // Display previous update query (from tbl_replace)
559 if (isset($disp_query) && $cfg['ShowSQL'] == TRUE) {
560 $tmp_sql_query = $GLOBALS['sql_query'];
561 $tmp_sql_limit_to_append = (isset($GLOBALS['sql_limit_to_append'])?$GLOBALS['sql_limit_to_append']:'');
562 $GLOBALS['sql_query'] = stripslashes($disp_query);
563 $GLOBALS['sql_limit_to_append'] = '';
564 PMA_showMessage($disp_message);
565 $GLOBALS['sql_query'] = $tmp_sql_query;
566 $GLOBALS['sql_limit_to_append'] = $tmp_sql_limit_to_append;
569 // Displays the results in a table
570 include('./libraries/display_tbl.lib.php3');
571 if (empty($disp_mode)) {
572 // see the "PMA_setDisplayMode()" function in
573 // libraries/display_tbl.lib.php3
574 $disp_mode = 'urdr111101';
576 if (!isset($dontlimitchars)) {
577 $dontlimitchars = 0;
580 PMA_displayTable($result, $disp_mode, $analyzed_sql);
581 mysql_free_result($result);
583 if ($disp_mode[6] == '1' || $disp_mode[9] == '1') {
584 echo "\n";
585 echo '<p>' . "\n";
587 // Displays "Insert a new row" link if required
588 if ($disp_mode[6] == '1') {
589 $lnk_goto = 'sql.php3?'
590 . PMA_generate_common_url($db, $table)
591 . '&amp;pos=' . $pos
592 . '&amp;session_max_rows=' . $session_max_rows
593 . '&amp;disp_direction=' . $disp_direction
594 . '&amp;repeat_cells=' . $repeat_cells
595 . '&amp;dontlimitchars=' . $dontlimitchars
596 . '&amp;sql_query=' . urlencode($sql_query);
597 $url_query = '?'
598 . PMA_generate_common_url($db, $table)
599 . '&amp;pos=' . $pos
600 . '&amp;session_max_rows=' . $session_max_rows
601 . '&amp;disp_direction=' . $disp_direction
602 . '&amp;repeat_cells=' . $repeat_cells
603 . '&amp;dontlimitchars=' . $dontlimitchars
604 . '&amp;sql_query=' . urlencode($sql_query)
605 . '&amp;goto=' . urlencode($lnk_goto);
607 echo ' <!-- Insert a new row -->' . "\n"
608 . ' <a href="tbl_change.php3' . $url_query . '">' . $strInsertNewRow . '</a>';
609 if ($disp_mode[9] == '1') {
610 echo '<br />';
612 echo "\n";
613 } // end insert new row
615 // Displays "printable view" link if required
616 if ($disp_mode[9] == '1') {
617 $url_query = '?'
618 . PMA_generate_common_url($db, $table)
619 . '&amp;pos=' . $pos
620 . '&amp;session_max_rows=' . $session_max_rows
621 . '&amp;disp_direction=' . $disp_direction
622 . '&amp;repeat_cells=' . $repeat_cells
623 . '&amp;printview=1'
624 . ((isset($dontlimitchars) && $dontlimitchars == '1') ? '&amp;dontlimitchars=1' : '')
625 . '&amp;sql_query=' . urlencode($sql_query);
626 echo ' <!-- Print view -->' . "\n"
627 . ' <a href="sql.php3' . $url_query . '" target="print_view">' . $strPrintView . '</a>' . "\n";
628 } // end displays "printable view"
630 echo '</p>' . "\n";
633 // Export link, if only one table
634 // (the url_query has extra parameters that won't be used to export)
635 if (!isset($printview)
636 && isset($analyzed_sql[0]['table_ref'][0]['table_true_name'])
637 && !isset($analyzed_sql[0]['table_ref'][1]['table_true_name'])) {
638 echo ' <!-- Export -->' . "\n"
639 . ' <a href="tbl_properties_export.php3' . $url_query . '&amp;unlim_num_rows=' . $unlim_num_rows . '">' . $strExport . '</a>' . "\n";
642 // Bookmark Support if required
643 if ($disp_mode[7] == '1'
644 && ($cfg['Bookmark']['db'] && $cfg['Bookmark']['table'] && empty($id_bookmark))
645 && !empty($sql_query)) {
646 echo "\n";
648 $goto = 'sql.php3?'
649 . PMA_generate_common_url($db, $table)
650 . '&amp;pos=' . $pos
651 . '&amp;session_max_rows=' . $session_max_rows
652 . '&amp;disp_direction=' . $disp_direction
653 . '&amp;repeat_cells=' . $repeat_cells
654 . '&amp;dontlimitchars=' . $dontlimitchars
655 . '&amp;sql_query=' . urlencode($sql_query)
656 . '&amp;id_bookmark=1';
658 <!-- Bookmark the query -->
659 <form action="sql.php3" method="post" onsubmit="return emptyFormElements(this, 'fields[label]');">
660 <?php
661 echo "\n";
662 if ($disp_mode[3] == '1') {
663 echo ' <i>' . $strOr . '</i>' . "\n";
666 <br /><br />
667 <?php echo $strBookmarkLabel; ?>&nbsp;:
668 <?php echo PMA_generate_common_hidden_inputs(); ?>
669 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
670 <input type="hidden" name="fields[dbase]" value="<?php echo htmlspecialchars($db); ?>" />
671 <input type="hidden" name="fields[user]" value="<?php echo $cfg['Bookmark']['user']; ?>" />
672 <input type="hidden" name="fields[query]" value="<?php echo urlencode($sql_query); ?>" />
673 <input type="text" name="fields[label]" value="" />
674 <input type="submit" name="store_bkm" value="<?php echo $strBookmarkThis; ?>" />
675 </form>
676 <?php
677 } // end bookmark support
679 // Do print the page if required
680 if (isset($printview) && $printview == '1') {
681 echo "\n";
683 <script type="text/javascript" language="javascript1.2">
684 <!--
685 // Do print the page
686 if (typeof(window.print) != 'undefined') {
687 window.print();
689 //-->
690 </script>
691 <?php
692 } // end print case
693 } // end rows returned
695 } // end executes the query
696 echo "\n\n";
700 * Displays the footer
702 require('./footer.inc.php3');