Basic detection if mime-features are available, better check on error
[phpmyadmin/crack.git] / sql.php3
blobd2589c153c95a33edc9952fea1ff5c14d53ccabd
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 // garvin: Measure query time. TODO-Item http://sourceforge.net/tracker/index.php?func=detail&aid=571934&group_id=23067&atid=377411
300 list($usec, $sec) = explode(' ',microtime());
301 $querytime_before = ((float)$usec + (float)$sec);
303 $result = @PMA_mysql_query($full_sql_query);
305 list($usec, $sec) = explode(' ',microtime());
306 $querytime_after = ((float)$usec + (float)$sec);
308 $GLOBALS['querytime'] = $querytime_after - $querytime_before;
310 // Displays an error message if required and stop parsing the script
311 if (PMA_mysql_error()) {
312 $error = PMA_mysql_error();
313 include('./header.inc.php3');
314 $full_err_url = (ereg('^(db_details|tbl_properties)', $err_url))
315 ? $err_url . '&amp;show_query=1&amp;sql_query=' . urlencode($sql_query)
316 : $err_url;
317 PMA_mysqlDie($error, $full_sql_query, '', $full_err_url);
320 // Gets the number of rows affected/returned
321 // (This must be done immediately after the query because
322 // mysql_affected_rows() reports about the last query done)
324 if (!$is_affected) {
325 $num_rows = ($result) ? @mysql_num_rows($result) : 0;
326 } else if (!isset($num_rows)) {
327 $num_rows = @mysql_affected_rows();
330 // Checks if the current database has changed
331 // This could happen if the user sends a query like "USE `database`;"
332 $res = PMA_mysql_query('SELECT DATABASE() AS "db";');
333 $row = PMA_mysql_fetch_array($res);
334 if ($db != $row['db']) {
335 $db = $row['db'];
336 $reload = 1;
338 @mysql_free_result($res);
339 unset($res);
340 unset($row);
342 // tmpfile remove after convert encoding appended by Y.Kawada
343 if (function_exists('PMA_kanji_file_conv')
344 && (isset($textfile) && file_exists($textfile))) {
345 unlink($textfile);
348 // Counts the total number of rows for the same 'SELECT' query without the
349 // 'LIMIT' clause that may have been programatically added
351 if (empty($sql_limit_to_append)) {
352 $unlim_num_rows = $num_rows;
354 else if ($is_select) {
356 // c o u n t q u e r y
358 if (PMA_MYSQL_INT_VERSION < 40000) {
359 if (eregi('DISTINCT(.*)', $sql_query)) {
360 $count_what = 'DISTINCT ' . $analyzed_sql[0]['select_expr_clause'];
361 } else {
362 $count_what = '*';
365 $count_query = 'SELECT COUNT(' . $count_what . ') AS count';
367 else {
368 $count_query = 'SELECT SQL_CALC_FOUND_ROWS ';
371 // add the remaining of select expression if there is
372 // a GROUP BY or HAVING clause
373 if (PMA_MYSQL_INT_VERSION < 40000
374 && $count_what =='*'
375 && (!empty($analyzed_sql[0]['group_by_clause'])
376 || !empty($analyzed_sql[0]['having_clause']))) {
377 $count_query .= ' ,' . $analyzed_sql[0]['select_expr_clause'];
380 // add select expression after the SQL_CALC_FOUND_ROWS
381 if (PMA_MYSQL_INT_VERSION >= 40000) {
382 $count_query .= $analyzed_sql[0]['select_expr_clause'];
386 if (!empty($analyzed_sql[0]['from_clause'])) {
387 $count_query .= ' FROM ' . $analyzed_sql[0]['from_clause'];
390 if (!empty($analyzed_sql[0]['where_clause'])) {
391 $count_query .= ' WHERE ' . $analyzed_sql[0]['where_clause'];
393 if (!empty($analyzed_sql[0]['group_by_clause'])) {
394 $count_query .= ' GROUP BY ' . $analyzed_sql[0]['group_by_clause'];
397 if (!empty($analyzed_sql[0]['having_clause'])) {
398 $count_query .= ' HAVING ' . $analyzed_sql[0]['having_clause'];
401 // do not put the order_by_clause, it interferes
402 // run the count query
403 if (PMA_MYSQL_INT_VERSION < 40000) {
404 if ($cnt_all_result = mysql_query($count_query)) {
405 if ($is_group) {
406 $unlim_num_rows = @mysql_num_rows($cnt_all_result);
407 } else {
408 $unlim_num_rows = mysql_result($cnt_all_result, 0, 'count');
410 mysql_free_result($cnt_all_result);
411 } else {
412 if (mysql_error()) {
413 // there are some cases where the generated
414 // count_query (for MySQL 3) is wrong,
415 // so we get here.
416 //TODO: use a big unlimited query to get
417 // the correct number of rows (depending
418 // on a config variable?)
419 $unlim_num_rows = 0;
422 } else {
423 mysql_query($count_query);
424 if (mysql_error()) {
425 // void. I tried the case
426 // (SELECT `User`, `Host`, `Db`, `Select_priv` FROM `db`)
427 // UNION (SELECT `User`, `Host`, "%" AS "Db",
428 // `Select_priv`
429 // FROM `user`) ORDER BY `User`, `Host`, `Db`;
430 // and although the generated count_query is wrong
431 // the SELECT FOUND_ROWS() work!
433 $cnt_all_result = mysql_query('SELECT FOUND_ROWS() as count');
434 $unlim_num_rows = mysql_result($cnt_all_result,0,'count');
437 } else { // not $is_select
438 $unlim_num_rows = 0;
439 } // end rows total count
441 // garvin: if a table or database gets dropped, check column comments.
442 if (isset($purge)) {
443 include('./libraries/relation.lib.php3');
444 $cfgRelation = PMA_getRelationsParam();
446 if ($cfgRelation['commwork']) {
447 if (isset($table) && isset($db) && !empty($table) && !empty($db)) {
448 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['column_info'])
449 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
450 . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
451 $rmv_rs = PMA_query_as_cu($remove_query);
452 unset($rmv_query);
453 } elseif (isset($db) && !empty($db)) {
454 $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['column_info'])
455 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
456 $rmv_rs = PMA_query_as_cu($remove_query);
457 unset($rmv_query);
459 } // end if relation-stuff
460 } // end if ($purge)
461 } // end else "didn't ask to see php code"
464 // No rows returned -> move back to the calling page
465 if ($num_rows < 1 || $is_affected) {
466 if ($is_delete) {
467 $message = $strDeletedRows . '&nbsp;' . $num_rows;
468 } else if ($is_insert) {
469 $message = $strInsertedRows . '&nbsp;' . $num_rows;
470 } else if ($is_affected) {
471 $message = $strAffectedRows . '&nbsp;' . $num_rows;
472 } else if (!empty($zero_rows)) {
473 $message = $zero_rows;
474 } else if (!empty($GLOBALS['show_as_php'])) {
475 $message = $strPhp;
476 } else if (!empty($GLOBALS['validatequery'])) {
477 $message = $strValidateSQL;
478 } else {
479 $message = $strEmptyResultSet;
482 $message .= " (" . sprintf($strQueryTime, $GLOBALS['querytime']) . ")";
484 if ($is_gotofile) {
485 $goto = ereg_replace('\.\.*', '.', $goto);
486 // Checks for a valid target script
487 if (isset($table) && $table == '') {
488 unset($table);
490 if (isset($db) && $db == '') {
491 unset($db);
493 $is_db = $is_table = FALSE;
494 if (strpos(' ' . $goto, 'tbl_properties') == 1) {
495 if (!isset($table)) {
496 $goto = 'db_details.php3';
497 } else {
498 $is_table = @PMA_mysql_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\'');
499 if (!($is_table && @mysql_numrows($is_table))) {
500 $goto = 'db_details.php3';
501 unset($table);
503 } // end if... else...
505 if (strpos(' ' . $goto, 'db_details') == 1) {
506 if (isset($table)) {
507 unset($table);
509 if (!isset($db)) {
510 $goto = 'main.php3';
511 } else {
512 $is_db = @PMA_mysql_select_db($db);
513 if (!$is_db) {
514 $goto = 'main.php3';
515 unset($db);
517 } // end if... else...
519 // Loads to target script
520 if (strpos(' ' . $goto, 'db_details') == 1
521 || strpos(' ' . $goto, 'tbl_properties') == 1) {
522 $js_to_run = 'functions.js';
524 if ($goto != 'main.php3') {
525 include('./header.inc.php3');
527 include('./' . $goto);
528 } // end if file_exist
529 else {
530 header('Location: ' . $cfg['PmaAbsoluteUri'] . str_replace('&amp;', '&', $goto) . '&message=' . urlencode($message));
531 } // end else
532 exit();
533 } // end no rows returned
535 // At least one row is returned -> displays a table with results
536 else {
537 // Displays the headers
538 if (isset($show_query)) {
539 unset($show_query);
541 if (isset($printview) && $printview == '1') {
542 include('./header_printview.inc.php3');
543 } else {
544 $js_to_run = 'functions.js';
545 unset($message);
546 if (!empty($table)) {
547 include('./tbl_properties_common.php3');
548 $url_query .= '&amp;goto=tbl_properties.php3&amp;back=tbl_properties.php3';
549 include('./tbl_properties_table_info.php3');
551 else {
552 include('./db_details_common.php3');
553 include('./db_details_db_info.php3');
555 include('./libraries/relation.lib.php3');
556 $cfgRelation = PMA_getRelationsParam();
559 // Gets the list of fields properties
560 if (isset($result) && $result) {
561 while ($field = PMA_mysql_fetch_field($result)) {
562 $fields_meta[] = $field;
564 $fields_cnt = count($fields_meta);
567 // Display previous update query (from tbl_replace)
568 if (isset($disp_query) && $cfg['ShowSQL'] == TRUE) {
569 $tmp_sql_query = $GLOBALS['sql_query'];
570 $tmp_sql_limit_to_append = (isset($GLOBALS['sql_limit_to_append'])?$GLOBALS['sql_limit_to_append']:'');
571 $GLOBALS['sql_query'] = stripslashes($disp_query);
572 $GLOBALS['sql_limit_to_append'] = '';
573 PMA_showMessage($disp_message);
574 $GLOBALS['sql_query'] = $tmp_sql_query;
575 $GLOBALS['sql_limit_to_append'] = $tmp_sql_limit_to_append;
578 // Displays the results in a table
579 include('./libraries/display_tbl.lib.php3');
580 if (empty($disp_mode)) {
581 // see the "PMA_setDisplayMode()" function in
582 // libraries/display_tbl.lib.php3
583 $disp_mode = 'urdr111101';
585 if (!isset($dontlimitchars)) {
586 $dontlimitchars = 0;
589 PMA_displayTable($result, $disp_mode, $analyzed_sql);
590 mysql_free_result($result);
592 if ($disp_mode[6] == '1' || $disp_mode[9] == '1') {
593 echo "\n";
594 echo '<p>' . "\n";
596 // Displays "Insert a new row" link if required
597 if ($disp_mode[6] == '1') {
598 $lnk_goto = 'sql.php3?'
599 . PMA_generate_common_url($db, $table)
600 . '&amp;pos=' . $pos
601 . '&amp;session_max_rows=' . $session_max_rows
602 . '&amp;disp_direction=' . $disp_direction
603 . '&amp;repeat_cells=' . $repeat_cells
604 . '&amp;dontlimitchars=' . $dontlimitchars
605 . '&amp;sql_query=' . urlencode($sql_query);
606 $url_query = '?'
607 . PMA_generate_common_url($db, $table)
608 . '&amp;pos=' . $pos
609 . '&amp;session_max_rows=' . $session_max_rows
610 . '&amp;disp_direction=' . $disp_direction
611 . '&amp;repeat_cells=' . $repeat_cells
612 . '&amp;dontlimitchars=' . $dontlimitchars
613 . '&amp;sql_query=' . urlencode($sql_query)
614 . '&amp;goto=' . urlencode($lnk_goto);
616 echo ' <!-- Insert a new row -->' . "\n"
617 . ' <a href="tbl_change.php3' . $url_query . '">' . $strInsertNewRow . '</a>';
618 if ($disp_mode[9] == '1') {
619 echo '<br />';
621 echo "\n";
622 } // end insert new row
624 // Displays "printable view" link if required
625 if ($disp_mode[9] == '1') {
626 $url_query = '?'
627 . PMA_generate_common_url($db, $table)
628 . '&amp;pos=' . $pos
629 . '&amp;session_max_rows=' . $session_max_rows
630 . '&amp;disp_direction=' . $disp_direction
631 . '&amp;repeat_cells=' . $repeat_cells
632 . '&amp;printview=1'
633 . ((isset($dontlimitchars) && $dontlimitchars == '1') ? '&amp;dontlimitchars=1' : '')
634 . '&amp;sql_query=' . urlencode($sql_query);
635 echo ' <!-- Print view -->' . "\n"
636 . ' <a href="sql.php3' . $url_query . '" target="print_view">' . $strPrintView . '</a>' . "\n";
637 } // end displays "printable view"
639 echo '</p>' . "\n";
642 // Export link, if only one table
643 // (the url_query has extra parameters that won't be used to export)
644 if (!isset($printview)
645 && isset($analyzed_sql[0]['table_ref'][0]['table_true_name'])
646 && !isset($analyzed_sql[0]['table_ref'][1]['table_true_name'])) {
647 echo ' <!-- Export -->' . "\n"
648 . ' <a href="tbl_properties_export.php3' . $url_query . '&amp;unlim_num_rows=' . $unlim_num_rows . '">' . $strExport . '</a>' . "\n";
651 // Bookmark Support if required
652 if ($disp_mode[7] == '1'
653 && ($cfg['Bookmark']['db'] && $cfg['Bookmark']['table'] && empty($id_bookmark))
654 && !empty($sql_query)) {
655 echo "\n";
657 $goto = 'sql.php3?'
658 . PMA_generate_common_url($db, $table)
659 . '&amp;pos=' . $pos
660 . '&amp;session_max_rows=' . $session_max_rows
661 . '&amp;disp_direction=' . $disp_direction
662 . '&amp;repeat_cells=' . $repeat_cells
663 . '&amp;dontlimitchars=' . $dontlimitchars
664 . '&amp;sql_query=' . urlencode($sql_query)
665 . '&amp;id_bookmark=1';
667 <!-- Bookmark the query -->
668 <form action="sql.php3" method="post" onsubmit="return emptyFormElements(this, 'fields[label]');">
669 <?php
670 echo "\n";
671 if ($disp_mode[3] == '1') {
672 echo ' <i>' . $strOr . '</i>' . "\n";
675 <br /><br />
676 <?php echo $strBookmarkLabel; ?>&nbsp;:
677 <?php echo PMA_generate_common_hidden_inputs(); ?>
678 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
679 <input type="hidden" name="fields[dbase]" value="<?php echo htmlspecialchars($db); ?>" />
680 <input type="hidden" name="fields[user]" value="<?php echo $cfg['Bookmark']['user']; ?>" />
681 <input type="hidden" name="fields[query]" value="<?php echo urlencode($sql_query); ?>" />
682 <input type="text" name="fields[label]" value="" />
683 <input type="submit" name="store_bkm" value="<?php echo $strBookmarkThis; ?>" />
684 </form>
685 <?php
686 } // end bookmark support
688 // Do print the page if required
689 if (isset($printview) && $printview == '1') {
690 echo "\n";
692 <script type="text/javascript" language="javascript1.2">
693 <!--
694 // Do print the page
695 if (typeof(window.print) != 'undefined') {
696 window.print();
698 //-->
699 </script>
700 <?php
701 } // end print case
702 } // end rows returned
704 } // end executes the query
705 echo "\n\n";
709 * Displays the footer
711 require('./footer.inc.php3');