db_search.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * searches the entire database
  5. *
  6. * @todo make use of UNION when searching multiple tables
  7. * @todo display executed query, optional?
  8. * @package PhpMyAdmin
  9. */
  10. use PhpMyAdmin\Database\Search;
  11. use PhpMyAdmin\Response;
  12. use PhpMyAdmin\Util;
  13. /**
  14. * Gets some core libraries
  15. */
  16. require_once 'libraries/common.inc.php';
  17. $response = Response::getInstance();
  18. $header = $response->getHeader();
  19. $scripts = $header->getScripts();
  20. $scripts->addFile('db_search.js');
  21. $scripts->addFile('sql.js');
  22. $scripts->addFile('makegrid.js');
  23. require 'libraries/db_common.inc.php';
  24. // If config variable $GLOBALS['cfg']['UseDbSearch'] is on false : exit.
  25. if (! $GLOBALS['cfg']['UseDbSearch']) {
  26. Util::mysqlDie(
  27. __('Access denied!'), '', false, $err_url
  28. );
  29. } // end if
  30. $url_query .= '&amp;goto=db_search.php';
  31. $url_params['goto'] = 'db_search.php';
  32. // Create a database search instance
  33. $db_search = new Search($GLOBALS['db']);
  34. // Display top links if we are not in an Ajax request
  35. if (! $response->isAjax()) {
  36. list(
  37. $tables,
  38. $num_tables,
  39. $total_num_tables,
  40. $sub_part,
  41. $is_show_stats,
  42. $db_is_system_schema,
  43. $tooltip_truename,
  44. $tooltip_aliasname,
  45. $pos
  46. ) = Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
  47. }
  48. // Main search form has been submitted, get results
  49. if (isset($_POST['submit_search'])) {
  50. $response->addHTML($db_search->getSearchResults());
  51. }
  52. // If we are in an Ajax request, we need to exit after displaying all the HTML
  53. if ($response->isAjax() && empty($_REQUEST['ajax_page_request'])) {
  54. exit;
  55. }
  56. // Display the search form
  57. $response->addHTML($db_search->getSelectionForm());
  58. $response->addHTML('<div id="searchresults"></div>');
  59. $response->addHTML(
  60. '<div id="togglesearchresultsdiv"><a id="togglesearchresultlink"></a></div>'
  61. );
  62. $response->addHTML('<br class="clearfloat" />');
  63. $response->addHTML($db_search->getResultDivs());