00001 <?php
00002
00003
00004
00008 require_once('./libraries/grab_globals.lib.php');
00009 require_once('./libraries/common.lib.php');
00010 require_once('./libraries/tbl_indexes.lib.php');
00011
00015
00016 if (!empty($goto)) {
00017 $is_gotofile = preg_replace('@^([^?]+).*$@s', '\\1', $goto);
00018 if (!@file_exists('./' . $is_gotofile)) {
00019 unset($goto);
00020 } else {
00021 $is_gotofile = ($is_gotofile == $goto);
00022 }
00023 }
00024
00025 if (empty($goto)) {
00026 $goto = (empty($table)) ? $cfg['DefaultTabDatabase'] : $cfg['DefaultTabTable'];
00027 $is_gotofile = TRUE;
00028 }
00029 if (!isset($err_url)) {
00030 $err_url = (!empty($back) ? $back : $goto)
00031 . '?' . PMA_generate_common_url(isset($db) ? $db : '')
00032 . ((strpos(' ' . $goto, 'db_details') != 1 && isset($table)) ? '&table=' . urlencode($table) : '');
00033 }
00034
00035
00036 if (isset($fields['query'])) {
00037 $sql_query = $fields['query'];
00038 }
00039
00040
00041 if (isset($fields['dbase'])) {
00042 $db = $fields['dbase'];
00043 }
00044
00045
00046 PMA_checkParameters(array('sql_query', 'db'));
00047
00048
00049 $is_drop_database = preg_match('@DROP[[:space:]]+DATABASE[[:space:]]+@i', $sql_query);
00050
00058 if (!defined('PMA_CHK_DROP')
00059 && !$cfg['AllowUserDropDatabase']
00060 && $is_drop_database) {
00061
00062
00063
00064 if (!($result = PMA_DBI_select_db('mysql'))) {
00065 require_once('./header.inc.php');
00066 PMA_mysqlDie($strNoDropDatabases, '', '', $err_url);
00067 }
00068 }
00069
00070
00075 if (isset($find_real_end) && $find_real_end) {
00076 $unlim_num_rows = PMA_countRecords($db, $table, TRUE, TRUE);
00077 $pos = @((ceil($unlim_num_rows / $session_max_rows) - 1) * $session_max_rows);
00078 }
00079
00083 if (isset($store_bkm)) {
00084 require_once('./libraries/bookmark.lib.php');
00085 PMA_addBookmarks($fields, $cfg['Bookmark'], (isset($bkm_all_users) && $bkm_all_users == 'true' ? true : false));
00086 PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . $goto);
00087 }
00088
00089
00093
00094
00095 if (isset($btnDrop) || isset($navig)) {
00096 $sql_query = urldecode($sql_query);
00097 }
00098
00103 $GLOBALS['unparsed_sql'] = $sql_query;
00104 $parsed_sql = PMA_SQP_parse($sql_query);
00105 $analyzed_sql = PMA_SQP_analyze($parsed_sql);
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 $is_select = isset($analyzed_sql[0]['queryflags']['select_from']);
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139 if ($is_select) {
00140 $prev_db = $db;
00141 if (isset($analyzed_sql[0]['table_ref'][0]['table_true_name'])) {
00142 $table = $analyzed_sql[0]['table_ref'][0]['table_true_name'];
00143 }
00144 if (isset($analyzed_sql[0]['table_ref'][0]['db'])
00145 && !empty($analyzed_sql[0]['table_ref'][0]['db'])) {
00146 $db = $analyzed_sql[0]['table_ref'][0]['db'];
00147 }
00148 else {
00149 $db = $prev_db;
00150 }
00151
00152 if (!isset($reload) || $reload == 0) {
00153 $reload = ($db == $prev_db) ? 0 : 1;
00154 }
00155 }
00156
00160 if ($goto == 'sql.php') {
00161 $is_gotofile = FALSE;
00162 $goto = 'sql.php?'
00163 . PMA_generate_common_url($db, $table)
00164 . '&pos=' . $pos
00165 . '&sql_query=' . urlencode($sql_query);
00166 }
00167
00168
00172 if (isset($btnDrop) && $btnDrop == $strNo) {
00173 if (!empty($back)) {
00174 $goto = $back;
00175 }
00176 if ($is_gotofile) {
00177 if (strpos(' ' . $goto, 'db_details') == 1 && !empty($table)) {
00178 unset($table);
00179 }
00180 $active_page = $goto;
00181 require('./' . PMA_securePath($goto));
00182 } else {
00183 PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . str_replace('&', '&', $goto));
00184 }
00185 exit();
00186 }
00187
00188
00198 if (!$cfg['Confirm']
00199 || (isset($is_js_confirmed) && $is_js_confirmed)
00200 || isset($btnDrop)
00201
00202
00203
00204
00205 || isset($GLOBALS['show_as_php'])
00206
00207 || !empty($GLOBALS['validatequery'])) {
00208 $do_confirm = FALSE;
00209 } else {
00210 $do_confirm = isset($analyzed_sql[0]['queryflags']['need_confirm']);
00211 }
00212
00213 if ($do_confirm) {
00214 $stripped_sql_query = $sql_query;
00215 require_once('./header.inc.php');
00216 echo '<table border="0" cellpadding="3" cellspacing="0">' . "\n";
00217 if ($is_drop_database) {
00218 echo ' <tr>' . "\n"
00219 . ' <td class="tblHeadError">' . "\n";
00220 if($cfg['ErrorIconic']){
00221 echo ' <img src="' .$pmaThemeImage .'s_warn.png" border="0" hspace="2" vspace="2" align="left" />';
00222 }
00223 echo $strDropDatabaseStrongWarning . ' <br />' . "\n";
00224 } else {
00225 echo ' <tr>' . "\n"
00226 . ' <td class="tblHeadError">' . "\n";
00227 if($cfg['ErrorIconic']){
00228 echo ' <img src="' .$pmaThemeImage .'s_really.png" border="0" hspace="2" align="middle" />';
00229 }
00230 }
00231 echo $strDoYouReally . "\n"
00232 . ' </td>' . "\n"
00233 . ' </tr>' . "\n"
00234 . ' <tr>' . "\n"
00235 . ' <td class="tblError">' . "\n"
00236 . ' <tt>' . htmlspecialchars($stripped_sql_query) . '</tt> ?<br/>' . "\n"
00237 . ' </td>' . "\n"
00238 . ' </tr>' . "\n"
00239 . ' <form action="sql.php" method="post">' . "\n"
00240 . ' <tr>' . "\n"
00241 . ' <td align="right">' . "\n"
00242 ?>
00243 <?php echo PMA_generate_common_hidden_inputs($db, (isset($table)?$table:'')); ?>
00244 <input type="hidden" name="sql_query" value="<?php echo urlencode($sql_query); ?>" />
00245 <input type="hidden" name="zero_rows" value="<?php echo isset($zero_rows) ? PMA_sanitize($zero_rows) : ''; ?>" />
00246 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
00247 <input type="hidden" name="back" value="<?php echo isset($back) ? PMA_sanitize($back) : ''; ?>" />
00248 <input type="hidden" name="reload" value="<?php echo isset($reload) ? PMA_sanitize($reload) : 0; ?>" />
00249 <input type="hidden" name="purge" value="<?php echo isset($purge) ? PMA_sanitize($purge) : ''; ?>" />
00250 <input type="hidden" name="cpurge" value="<?php echo isset($cpurge) ? PMA_sanitize($cpurge) : ''; ?>" />
00251 <input type="hidden" name="purgekey" value="<?php echo isset($purgekey) ? PMA_sanitize($purgekey) : ''; ?>" />
00252 <input type="hidden" name="show_query" value="<?php echo isset($show_query) ? PMA_sanitize($show_query) : ''; ?>" />
00253 <input type="submit" name="btnDrop" value="<?php echo $strYes; ?>" id="buttonYes" />
00254 <input type="submit" name="btnDrop" value="<?php echo $strNo; ?>" id="buttonNo" />
00255 <?php
00256 echo ' </td>' . "\n"
00257 . ' </tr>' . "\n"
00258 . ' </form>' . "\n"
00259 . '</table>';
00260 echo "\n";
00261 }
00262
00263
00267 else {
00268 if (!isset($sql_query)) {
00269 $sql_query = '';
00270 }
00271
00272
00273
00274
00275 if ((!isset($reload) || $reload == 0)
00276 && (preg_match('@^CREATE TABLE[[:space:]]+(.*)@i', $sql_query)
00277 || preg_match('@^ALTER TABLE[[:space:]]+(.*)RENAME@i', $sql_query)
00278 || preg_match('@^TRUNCATE@i', $sql_query))) {
00279 $reload = 1;
00280 }
00281
00282 if (empty($session_max_rows)) {
00283 $session_max_rows = $cfg['MaxRows'];
00284 } else if ($session_max_rows != 'all') {
00285 $cfg['MaxRows'] = $session_max_rows;
00286 }
00287
00288 if (empty($disp_direction)) {
00289 $disp_direction = $cfg['DefaultDisplay'];
00290 }
00291 if (empty($repeat_cells)) {
00292 $repeat_cells = $cfg['RepeatCells'];
00293 }
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304 $is_explain = $is_count = $is_export = $is_delete = $is_insert = $is_affected = $is_show = $is_maint = $is_analyse = $is_group = $is_func = FALSE;
00305 if ($is_select) {
00306 $is_group = preg_match('@(GROUP[[:space:]]+BY|HAVING|SELECT[[:space:]]+DISTINCT)[[:space:]]+@i', $sql_query);
00307 $is_func = !$is_group && (preg_match('@[[:space:]]+(SUM|AVG|STD|STDDEV|MIN|MAX|BIT_OR|BIT_AND)\s*\(@i', $sql_query));
00308 $is_count = !$is_group && (preg_match('@^SELECT[[:space:]]+COUNT\((.*\.+)?.*\)@i', $sql_query));
00309 $is_export = (preg_match('@[[:space:]]+INTO[[:space:]]+OUTFILE[[:space:]]+@i', $sql_query));
00310 $is_analyse = (preg_match('@[[:space:]]+PROCEDURE[[:space:]]+ANALYSE@i', $sql_query));
00311 } else if (preg_match('@^EXPLAIN[[:space:]]+@i', $sql_query)) {
00312 $is_explain = TRUE;
00313 } else if (preg_match('@^DELETE[[:space:]]+@i', $sql_query)) {
00314 $is_delete = TRUE;
00315 $is_affected = TRUE;
00316 } else if (preg_match('@^(INSERT|LOAD[[:space:]]+DATA|REPLACE)[[:space:]]+@i', $sql_query)) {
00317 $is_insert = TRUE;
00318 $is_affected = TRUE;
00319 } else if (preg_match('@^UPDATE[[:space:]]+@i', $sql_query)) {
00320 $is_affected = TRUE;
00321 } else if (preg_match('@^SHOW[[:space:]]+@i', $sql_query)) {
00322 $is_show = TRUE;
00323 } else if (preg_match('@^(CHECK|ANALYZE|REPAIR|OPTIMIZE)[[:space:]]+TABLE[[:space:]]+@i', $sql_query)) {
00324 $is_maint = TRUE;
00325 }
00326
00327
00328 if (isset($pos)
00329 && (!$cfg['ShowAll'] || $session_max_rows != 'all')
00330 && !($is_count || $is_export || $is_func || $is_analyse)
00331 && isset($analyzed_sql[0]['queryflags']['select_from'])
00332 && !isset($analyzed_sql[0]['queryflags']['offset'])
00333 && !preg_match('@[[:space:]]LIMIT[[:space:]0-9,-]+$@i', $sql_query)) {
00334 $sql_limit_to_append = " LIMIT $pos, ".$cfg['MaxRows'] . " ";
00335
00336
00337
00338
00339
00340
00341
00342 $full_sql_query = $analyzed_sql[0]['section_before_limit'] . $sql_limit_to_append . $analyzed_sql[0]['section_after_limit'];
00343
00344
00345 if (isset($display_query)) {
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356 if (!empty($analyzed_sql[0]['section_after_limit'])) {
00357 $analyzed_display_query = PMA_SQP_analyze(PMA_SQP_parse($display_query));
00358 $display_query = $analyzed_display_query[0]['section_before_limit'] . $sql_limit_to_append . $analyzed_display_query[0]['section_after_limit'];
00359 }
00360 }
00361
00362 } else {
00363 $full_sql_query = $sql_query;
00364 }
00365
00366 PMA_DBI_select_db($db);
00367
00368
00369
00370
00371
00372 if ($is_delete
00373 && preg_match('@^DELETE([[:space:]].+)?(FROM[[:space:]](.+))$@i', $sql_query, $parts)
00374 && !preg_match('@[[:space:]]WHERE[[:space:]]@i', $parts[3])) {
00375 $cnt_all_result = @PMA_DBI_try_query('SELECT COUNT(*) as count ' . $parts[2]);
00376 if ($cnt_all_result) {
00377 list($num_rows) = PMA_DBI_fetch_row($cnt_all_result);
00378 PMA_DBI_free_result($cnt_all_result);
00379 } else {
00380 $num_rows = 0;
00381 }
00382 }
00383
00384
00385
00386
00387 if (isset($GLOBALS['show_as_php']) || !empty($GLOBALS['validatequery'])) {
00388 unset($result);
00389 $num_rows = 0;
00390 }
00391 else {
00392
00393 list($usec, $sec) = explode(' ',microtime());
00394 $querytime_before = ((float)$usec + (float)$sec);
00395
00396 $result = @PMA_DBI_try_query($full_sql_query, NULL, PMA_DBI_QUERY_STORE);
00397
00398 list($usec, $sec) = explode(' ',microtime());
00399 $querytime_after = ((float)$usec + (float)$sec);
00400
00401 $GLOBALS['querytime'] = $querytime_after - $querytime_before;
00402
00403
00404 if ($error = PMA_DBI_getError()) {
00405 require_once('./header.inc.php');
00406 $full_err_url = (preg_match('@^(db_details|tbl_properties)@', $err_url))
00407 ? $err_url . '&show_query=1&sql_query=' . urlencode($sql_query)
00408 : $err_url;
00409 PMA_mysqlDie($error, $full_sql_query, '', $full_err_url);
00410 }
00411 unset($error);
00412
00413
00414
00415
00416
00417 if (!$is_affected) {
00418 $num_rows = ($result) ? @PMA_DBI_num_rows($result) : 0;
00419 } else if (!isset($num_rows)) {
00420 $num_rows = @PMA_DBI_affected_rows();
00421 }
00422
00423
00424
00425 $res = PMA_DBI_query('SELECT DATABASE() AS \'db\';');
00426 $row = PMA_DBI_fetch_row($res);
00427 if (is_array($row) && isset($row[0]) && (strcasecmp($db,$row[0]) != 0)) {
00428 $db = $row[0];
00429 $reload = 1;
00430 }
00431 @PMA_DBI_free_result($res);
00432 unset($res, $row);
00433
00434
00435 if (function_exists('PMA_kanji_file_conv')
00436 && (isset($textfile) && file_exists($textfile))) {
00437 unlink($textfile);
00438 }
00439
00440
00441
00442
00443 if (empty($sql_limit_to_append)) {
00444 $unlim_num_rows = $num_rows;
00445
00446
00447 $GLOBALS['session_max_rows'] = 'all';
00448 }
00449 else if ($is_select) {
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462 if (!$is_group
00463 && !isset($analyzed_sql[0]['queryflags']['union'])
00464 && !isset($analyzed_sql[0]['table_ref'][1]['table_name'])
00465 && (empty($analyzed_sql[0]['where_clause'])
00466 || $analyzed_sql[0]['where_clause'] == '1 ')
00467 && !isset($find_real_end)
00468 ) {
00469
00470
00471 $unlim_num_rows = PMA_countRecords($db, $table, TRUE);
00472
00473 } else {
00474
00475 if (PMA_MYSQL_INT_VERSION < 40000) {
00476
00477
00478
00479
00480 if (isset($analyzed_sql[0]['queryflags']['distinct'])) {
00481 $count_what = 'DISTINCT ';
00482 $first_expr = TRUE;
00483 foreach($analyzed_sql[0]['select_expr'] as $part) {
00484 $count_what .= (!$first_expr ? ', ' : '') . $part['expr'];
00485 $first_expr = FALSE;
00486 }
00487 } else {
00488 $count_what = '*';
00489 }
00490 $count_query = 'SELECT COUNT(' . $count_what . ') AS count';
00491 }
00492
00493
00494
00495 if (PMA_MYSQL_INT_VERSION < 40000
00496 && $count_what =='*'
00497 && (!empty($analyzed_sql[0]['group_by_clause'])
00498 || !empty($analyzed_sql[0]['having_clause']))) {
00499 $count_query .= ' ,' . $analyzed_sql[0]['select_expr_clause'];
00500 }
00501
00502 if (PMA_MYSQL_INT_VERSION >= 40000) {
00503
00504
00505
00506
00507
00508
00509
00510
00511 $count_query = PMA_SQP_formatHtml($parsed_sql, 'query_only', 0, $analyzed_sql[0]['position_of_first_select'] + 1);
00512 $count_query .= ' SQL_CALC_FOUND_ROWS ';
00513
00514 $count_query .= PMA_SQP_formatHtml($parsed_sql, 'query_only', $analyzed_sql[0]['position_of_first_select']+1);
00515 } else {
00516
00517 if (!empty($analyzed_sql[0]['from_clause'])) {
00518 $count_query .= ' FROM ' . $analyzed_sql[0]['from_clause'];
00519 }
00520 if (!empty($analyzed_sql[0]['where_clause'])) {
00521 $count_query .= ' WHERE ' . $analyzed_sql[0]['where_clause'];
00522 }
00523 if (!empty($analyzed_sql[0]['group_by_clause'])) {
00524 $count_query .= ' GROUP BY ' . $analyzed_sql[0]['group_by_clause'];
00525 }
00526 if (!empty($analyzed_sql[0]['having_clause'])) {
00527 $count_query .= ' HAVING ' . $analyzed_sql[0]['having_clause'];
00528 }
00529 }
00530
00531
00532
00533
00534
00535 if (PMA_MYSQL_INT_VERSION >= 40000
00536 && !isset($analyzed_sql[0]['queryflags']['union'])) {
00537 $count_query .= ' LIMIT 1';
00538 }
00539
00540
00541
00542 if (PMA_MYSQL_INT_VERSION < 40000) {
00543 if ($cnt_all_result = PMA_DBI_try_query($count_query)) {
00544 if ($is_group && $count_what == '*') {
00545 $unlim_num_rows = @PMA_DBI_num_rows($cnt_all_result);
00546 } else {
00547 $unlim_num_rows = PMA_DBI_fetch_assoc($cnt_all_result);
00548 $unlim_num_rows = $unlim_num_rows['count'];
00549 }
00550 PMA_DBI_free_result($cnt_all_result);
00551 } else {
00552 if (PMA_DBI_getError()) {
00553
00554
00555
00556
00557
00558
00559
00560 $unlim_num_rows = 0;
00561 }
00562 }
00563 } else {
00564 PMA_DBI_try_query($count_query);
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580 $cnt_all_result = PMA_DBI_query('SELECT FOUND_ROWS() as count;');
00581 list($unlim_num_rows) = PMA_DBI_fetch_row($cnt_all_result);
00582 @PMA_DBI_free_result($cnt_all_result);
00583 }
00584 }
00585
00586 } else {
00587 $unlim_num_rows = 0;
00588 }
00589
00590
00591 if (isset($purge) && $purge == '1') {
00592 require_once('./libraries/relation_cleanup.lib.php');
00593
00594 if (isset($table) && isset($db) && !empty($table) && !empty($db)) {
00595 PMA_relationsCleanupTable($db, $table);
00596 } elseif (isset($db) && !empty($db)) {
00597 PMA_relationsCleanupDatabase($db);
00598 } else {
00599
00600 }
00601 }
00602
00603
00604 if (isset($cpurge) && $cpurge == '1' && isset($purgekey)
00605 && isset($db) && isset($table)
00606 && !empty($db) && !empty($table) && !empty($purgekey)) {
00607 require_once('./libraries/relation_cleanup.lib.php');
00608 PMA_relationsCleanupColumn($db, $table, $purgekey);
00609
00610 }
00611 }
00612
00613
00614 if ($num_rows < 1 || $is_affected) {
00615 if ($is_delete) {
00616 $message = $strDeletedRows . ' ' . $num_rows;
00617 } else if ($is_insert) {
00618 $message = $strInsertedRows . ' ' . $num_rows;
00619 $insert_id = PMA_DBI_insert_id();
00620 if ($insert_id != 0) {
00621
00622 $message .= '[br]'.$strInsertedRowId . ' ' . ($insert_id + $num_rows - 1);
00623 }
00624 } else if ($is_affected) {
00625 $message = $strAffectedRows . ' ' . $num_rows;
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635 } else if (!empty($zero_rows) && !$is_select) {
00636 $message = $zero_rows;
00637 } else if (!empty($GLOBALS['show_as_php'])) {
00638 $message = $strPhp;
00639 } else if (!empty($GLOBALS['validatequery'])) {
00640 $message = $strValidateSQL;
00641 } else {
00642 $message = $strEmptyResultSet;
00643 }
00644
00645 $message .= ' ' . (isset($GLOBALS['querytime']) ? '(' . sprintf($strQueryTime, $GLOBALS['querytime']) . ')' : '');
00646
00647 if ($is_gotofile) {
00648 $goto = PMA_securePath($goto);
00649
00650 if (isset($table) && $table == '') {
00651 unset($table);
00652 }
00653 if (isset($db) && $db == '') {
00654 unset($db);
00655 }
00656 $is_db = $is_table = FALSE;
00657 if (strpos(' ' . $goto, 'tbl_properties') == 1) {
00658 if (!isset($table)) {
00659 $goto = 'db_details.php';
00660 } else {
00661 $is_table = @PMA_DBI_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\';', NULL, PMA_DBI_QUERY_STORE);
00662 if (!($is_table && @PMA_DBI_num_rows($is_table))) {
00663 $goto = 'db_details.php';
00664 unset($table);
00665 }
00666 @PMA_DBI_free_result($is_table);
00667 }
00668 }
00669 if (strpos(' ' . $goto, 'db_details') == 1) {
00670 if (isset($table)) {
00671 unset($table);
00672 }
00673 if (!isset($db)) {
00674 $goto = 'main.php';
00675 } else {
00676 $is_db = @PMA_DBI_select_db($db);
00677 if (!$is_db) {
00678 $goto = 'main.php';
00679 unset($db);
00680 }
00681 }
00682 }
00683
00684 if (strpos(' ' . $goto, 'db_details') == 1
00685 || strpos(' ' . $goto, 'tbl_properties') == 1) {
00686 $js_to_run = 'functions.js';
00687 }
00688 if ($goto != 'main.php') {
00689 require_once('./header.inc.php');
00690 }
00691 $active_page = $goto;
00692 require('./' . $goto);
00693 }
00694 else {
00695 PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . str_replace('&', '&', $goto) . '&message=' . urlencode($message));
00696 }
00697 exit();
00698 }
00699
00700
00701 else {
00702
00703 if (isset($show_query)) {
00704 unset($show_query);
00705 }
00706 if (isset($printview) && $printview == '1') {
00707 require_once('./header_printview.inc.php');
00708 } else {
00709 $js_to_run = 'functions.js';
00710 unset($message);
00711 if (!empty($table)) {
00712 require('./tbl_properties_common.php');
00713 $url_query .= '&goto=tbl_properties.php&back=tbl_properties.php';
00714 require('./tbl_properties_table_info.php');
00715 require('./tbl_properties_links.php');
00716 }
00717 else {
00718 require('./db_details_common.php');
00719 require('./db_details_db_info.php');
00720 }
00721 }
00722
00723 require_once('./libraries/relation.lib.php');
00724 $cfgRelation = PMA_getRelationsParam();
00725
00726
00727 if (isset($result) && $result) {
00728 $fields_meta = PMA_DBI_get_fields_meta($result);
00729 $fields_cnt = count($fields_meta);
00730 }
00731
00732
00733 if (isset($disp_query) && $cfg['ShowSQL'] == TRUE) {
00734 $tmp_sql_query = $GLOBALS['sql_query'];
00735 $GLOBALS['sql_query'] = $disp_query;
00736 PMA_showMessage($disp_message);
00737 $GLOBALS['sql_query'] = $tmp_sql_query;
00738 }
00739
00740
00741 require_once('./libraries/display_tbl.lib.php');
00742 if (empty($disp_mode)) {
00743
00744
00745 $disp_mode = 'urdr111101';
00746 }
00747 if (!isset($dontlimitchars)) {
00748 $dontlimitchars = 0;
00749 }
00750
00751 PMA_displayTable($result, $disp_mode, $analyzed_sql);
00752 PMA_DBI_free_result($result);
00753
00754
00755 if (isset($query_type) && $query_type == 'check_tbl' && isset($selected) && is_array($selected)) {
00756 foreach($selected AS $idx => $tbl_name) {
00757 $indexes = $indexes_info = $indexes_data = array();
00758 $tbl_ret_keys = PMA_get_indexes(urldecode($tbl_name), $err_url_0);
00759
00760 PMA_extract_indexes($tbl_ret_keys, $indexes, $indexes_info, $indexes_data);
00761
00762 $idx_collection = PMA_show_indexes(urldecode($tbl_name), $indexes, $indexes_info, $indexes_data, false);
00763 $check = PMA_check_indexes($idx_collection);
00764 if (!empty($check)) {
00765 ?>
00766 <table border="0" cellpadding="2" cellspacing="0">
00767 <tr>
00768 <td class="tblHeaders" colspan="7"><?php printf($strIndexWarningTable, urldecode($tbl_name)); ?></td>
00769 </tr>
00770 <?php echo $check; ?>
00771 </table>
00772 <?php
00773 }
00774 }
00775 }
00776
00777 if ($disp_mode[6] == '1' || $disp_mode[9] == '1') {
00778 echo "\n";
00779 echo '<hr />' . "\n";
00780
00781
00782 if ($disp_mode[6] == '1') {
00783 $lnk_goto = 'sql.php?'
00784 . PMA_generate_common_url($db, $table)
00785 . '&pos=' . $pos
00786 . '&session_max_rows=' . $session_max_rows
00787 . '&disp_direction=' . $disp_direction
00788 . '&repeat_cells=' . $repeat_cells
00789 . '&dontlimitchars=' . $dontlimitchars
00790 . '&sql_query=' . urlencode($sql_query);
00791 $url_query = '?'
00792 . PMA_generate_common_url($db, $table)
00793 . '&pos=' . $pos
00794 . '&session_max_rows=' . $session_max_rows
00795 . '&disp_direction=' . $disp_direction
00796 . '&repeat_cells=' . $repeat_cells
00797 . '&dontlimitchars=' . $dontlimitchars
00798 . '&sql_query=' . urlencode($sql_query)
00799 . '&goto=' . urlencode($lnk_goto);
00800
00801 echo ' <!-- Insert a new row -->' . "\n";
00802 echo PMA_linkOrButton(
00803 'tbl_change.php' . $url_query,
00804 ($cfg['PropertiesIconic'] ? '<img src="' . $pmaThemeImage . 'b_insrow.png" border="0" height="16" width="16" align="middle" hspace="2" alt="' . $strInsertNewRow . '"/>' : '') . $strInsertNewRow,
00805 '', TRUE, TRUE, '') . "\n";
00806
00807 if ($disp_mode[9] == '1') {
00808 echo ' ';
00809 }
00810 echo "\n";
00811 }
00812
00813
00814 if ($disp_mode[9] == '1') {
00815 $url_query = '?'
00816 . PMA_generate_common_url($db, $table)
00817 . '&pos=' . $pos
00818 . '&session_max_rows=' . $session_max_rows
00819 . '&disp_direction=' . $disp_direction
00820 . '&repeat_cells=' . $repeat_cells
00821 . '&printview=1'
00822 . '&sql_query=' . urlencode($sql_query);
00823 echo ' <!-- Print view -->' . "\n";
00824 echo PMA_linkOrButton(
00825 'sql.php' . $url_query . ((isset($dontlimitchars) && $dontlimitchars == '1') ? '&dontlimitchars=1' : ''),
00826 ($cfg['PropertiesIconic'] ? '<img src="' . $pmaThemeImage . 'b_print.png" border="0" height="16" width="16" align="middle" hspace="2" alt="' . $strPrintView . '"/>' : '') . $strPrintView,
00827 '', TRUE, TRUE, 'print_view') . "\n";
00828
00829 if (!$dontlimitchars) {
00830 echo ' ' . "\n";
00831 echo PMA_linkOrButton(
00832 'sql.php' . $url_query . '&dontlimitchars=1',
00833 ($cfg['PropertiesIconic'] ? '<img src="' . $pmaThemeImage . 'b_print.png" border="0" height="16" width="16" align="middle" hspace="2" alt="' . $strPrintViewFull . '"/>' : '') . $strPrintViewFull,
00834 '', TRUE, TRUE, 'print_view') . "\n";
00835 }
00836 }
00837
00838 echo "\n";
00839 }
00840
00841
00842
00843
00844
00845 if (isset($analyzed_sql[0]) && $analyzed_sql[0]['querytype'] == 'SELECT' && !isset($printview)) {
00846 if (isset($analyzed_sql[0]['table_ref'][0]['table_true_name']) && !isset($analyzed_sql[0]['table_ref'][1]['table_true_name'])) {
00847 $single_table = '&single_table=true';
00848 } else {
00849 $single_table = '';
00850 }
00851 echo ' <!-- Export -->' . "\n";
00852 echo ' ' . "\n";
00853 echo PMA_linkOrButton(
00854 'tbl_properties_export.php' . $url_query . '&unlim_num_rows=' . $unlim_num_rows . $single_table,
00855 ($cfg['PropertiesIconic'] ? '<img src="' . $pmaThemeImage . 'b_tblexport.png" border="0" height="16" width="16" align="middle" hspace="2" alt="' . $strExport . '" />' : '') . $strExport,
00856 '', TRUE, TRUE, '') . "\n";
00857 }
00858
00859
00860 if ($disp_mode[7] == '1'
00861 && ($cfg['Bookmark']['db'] && $cfg['Bookmark']['table'] && empty($id_bookmark))
00862 && !empty($sql_query)) {
00863 echo "\n";
00864
00865 $goto = 'sql.php?'
00866 . PMA_generate_common_url($db, $table)
00867 . '&pos=' . $pos
00868 . '&session_max_rows=' . $session_max_rows
00869 . '&disp_direction=' . $disp_direction
00870 . '&repeat_cells=' . $repeat_cells
00871 . '&dontlimitchars=' . $dontlimitchars
00872 . '&sql_query=' . urlencode($sql_query)
00873 . '&id_bookmark=1';
00874 ?>
00875 <!-- Bookmark the query -->
00876 <?php
00877 echo "\n";
00878 if ($disp_mode[3] == '1') {
00879 echo ' <i>' . $strOr . '</i>' . "\n";
00880 }else echo '<br /><br />';
00881 ?>
00882 <form action="sql.php" method="post" onsubmit="return emptyFormElements(this, 'fields[label]');">
00883 <table border="0" cellpadding="2" cellspacing="0">
00884 <tr><td class="tblHeaders" colspan="2"><?php
00885 echo ($cfg['PropertiesIconic'] ? '<img src="' . $pmaThemeImage . 'b_bookmark.png" border="0" width="16" height="16" hspace="2" align="middle" alt="' . $strBookmarkThis . '" />' : '')
00886 . $strBookmarkThis;
00887 ?></td></tr>
00888 <tr bgcolor="<?php echo $cfg['BgcolorOne']; ?>"><td>
00889 <?php echo $strBookmarkLabel; ?>:
00890 <?php echo PMA_generate_common_hidden_inputs(); ?>
00891 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
00892 <input type="hidden" name="fields[dbase]" value="<?php echo htmlspecialchars($db); ?>" />
00893 <input type="hidden" name="fields[user]" value="<?php echo $cfg['Bookmark']['user']; ?>" />
00894 <input type="hidden" name="fields[query]" value="<?php echo urlencode(isset($complete_query) ? $complete_query : $sql_query); ?>" />
00895 </td><td>
00896 <input type="text" name="fields[label]" value="" />
00897 </td></tr>
00898 <tr bgcolor="<?php echo $cfg['BgcolorOne']; ?>"><td align="right" valign="top">
00899 <input type="checkbox" name="bkm_all_users" id="bkm_all_users" value="true" /></td>
00900 <td><label for="bkm_all_users"><?php echo $strBookmarkAllUsers; ?></label></td>
00901 </tr>
00902 <tr>
00903 <td class="tblFooters" colspan="2" align="right">
00904 <input type="submit" name="store_bkm" value="<?php echo $strBookmarkThis; ?>" />
00905 </td></tr>
00906 </table></form>
00907 <?php
00908 }
00909
00910
00911 if (isset($printview) && $printview == '1') {
00912 echo "\n";
00913 ?>
00914 <script type="text/javascript" language="javascript1.2">
00915 <!--
00916
00917 if (typeof(window.print) != 'undefined') {
00918 window.print();
00919 }
00920
00921 </script>
00922 <?php
00923 }
00924 }
00925
00926 }
00927 echo "\n\n";
00928
00932 require_once('./footer.inc.php');
00933 ?>