server_databases.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Server databases
  5. *
  6. * @package PhpMyAdmin
  7. */
  8. /**
  9. * Does the common work
  10. */
  11. require_once 'libraries/common.inc.php';
  12. require_once 'libraries/server_common.inc.php';
  13. require_once 'libraries/server_databases.lib.php';
  14. $response = PMA_Response::getInstance();
  15. $header = $response->getHeader();
  16. $scripts = $header->getScripts();
  17. $scripts->addFile('server_databases.js');
  18. if (! PMA_DRIZZLE) {
  19. include_once 'libraries/replication.inc.php';
  20. } else {
  21. $replication_types = array();
  22. $replication_info = null;
  23. }
  24. require 'libraries/build_html_for_db.lib.php';
  25. /**
  26. * Sets globals from $_POST
  27. */
  28. $post_params = array(
  29. 'mult_btn',
  30. 'query_type',
  31. 'selected'
  32. );
  33. foreach ($post_params as $one_post_param) {
  34. if (isset($_POST[$one_post_param])) {
  35. $GLOBALS[$one_post_param] = $_POST[$one_post_param];
  36. }
  37. }
  38. list($sort_by, $sort_order) = PMA_getListForSortDatabase();
  39. $dbstats = empty($_REQUEST['dbstats']) ? 0 : 1;
  40. $pos = empty($_REQUEST['pos']) ? 0 : (int) $_REQUEST['pos'];
  41. /**
  42. * Drops multiple databases
  43. */
  44. // workaround for IE behavior (it returns some coordinates based on where
  45. // the mouse was on the Drop image):
  46. if (isset($_REQUEST['drop_selected_dbs_x'])) {
  47. $_REQUEST['drop_selected_dbs'] = true;
  48. }
  49. if ((isset($_REQUEST['drop_selected_dbs']) || isset($_REQUEST['query_type']))
  50. && ($is_superuser || $cfg['AllowUserDropDatabase'])
  51. ) {
  52. PMA_dropMultiDatabases();
  53. }
  54. /**
  55. * Displays the sub-page heading
  56. */
  57. $header_type = $dbstats ? "database_statistics" : "databases";
  58. $response->addHTML(PMA_getHtmlForSubPageHeader($header_type));
  59. /**
  60. * Displays For Create database.
  61. */
  62. $html = '';
  63. if ($cfg['ShowCreateDb']) {
  64. $html .= '<ul><li id="li_create_database" class="no_bullets">' . "\n";
  65. include 'libraries/display_create_database.lib.php';
  66. $html .= ' </li>' . "\n";
  67. $html .= '</ul>' . "\n";
  68. }
  69. /**
  70. * Gets the databases list
  71. */
  72. if ($server > 0) {
  73. $databases = $GLOBALS['dbi']->getDatabasesFull(
  74. null, $dbstats, null, $sort_by, $sort_order, $pos, true
  75. );
  76. $databases_count = count($GLOBALS['pma']->databases);
  77. } else {
  78. $databases_count = 0;
  79. }
  80. /**
  81. * Displays the page
  82. */
  83. if ($databases_count > 0) {
  84. $html .= PMA_getHtmlForDatabase(
  85. $databases,
  86. $databases_count,
  87. $pos,
  88. $dbstats,
  89. $sort_by,
  90. $sort_order,
  91. $is_superuser,
  92. $cfg,
  93. $replication_types,
  94. $replication_info,
  95. $url_query
  96. );
  97. } else {
  98. $html .= __('No databases');
  99. }
  100. unset($databases_count);
  101. $response->addHTML($html);
  102. ?>