server_replication.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Server replications
  5. *
  6. * @package PhpMyAdmin
  7. */
  8. use PhpMyAdmin\ReplicationGui;
  9. use PhpMyAdmin\Response;
  10. use PhpMyAdmin\Server\Common;
  11. use PhpMyAdmin\Template;
  12. /**
  13. * include files
  14. */
  15. require_once 'libraries/common.inc.php';
  16. require_once 'libraries/server_common.inc.php';
  17. require_once 'libraries/replication.inc.php';
  18. /**
  19. * Does the common work
  20. */
  21. $response = Response::getInstance();
  22. $header = $response->getHeader();
  23. $scripts = $header->getScripts();
  24. $scripts->addFile('server_privileges.js');
  25. $scripts->addFile('replication.js');
  26. $scripts->addFile('vendor/zxcvbn.js');
  27. /**
  28. * Checks if the user is allowed to do what he tries to...
  29. */
  30. if (! $GLOBALS['dbi']->isSuperuser()) {
  31. $html = Template::get('server/sub_page_header')->render([
  32. 'type' => 'replication',
  33. ]);
  34. $html .= PhpMyAdmin\Message::error(__('No Privileges'))->getDisplay();
  35. $response->addHTML($html);
  36. exit;
  37. }
  38. // change $GLOBALS['url_params'] with $_POST['url_params']
  39. // only if it is an array
  40. if (isset($_POST['url_params']) && is_array($_POST['url_params'])) {
  41. $GLOBALS['url_params'] = $_POST['url_params'];
  42. }
  43. /**
  44. * Handling control requests
  45. */
  46. ReplicationGui::handleControlRequest();
  47. /**
  48. * start output
  49. */
  50. $response->addHTML('<div id="replication">');
  51. $response->addHTML(Template::get('server/sub_page_header')->render([
  52. 'type' => 'replication',
  53. ]));
  54. // Display error messages
  55. $response->addHTML(ReplicationGui::getHtmlForErrorMessage());
  56. if ($GLOBALS['replication_info']['master']['status']) {
  57. $response->addHTML(ReplicationGui::getHtmlForMasterReplication());
  58. } elseif (! isset($_POST['mr_configure'])
  59. && ! isset($_POST['repl_clear_scr'])
  60. ) {
  61. $response->addHTML(ReplicationGui::getHtmlForNotServerReplication());
  62. }
  63. if (isset($_POST['mr_configure'])) {
  64. // Render the 'Master configuration' section
  65. $response->addHTML(ReplicationGui::getHtmlForMasterConfiguration());
  66. exit;
  67. }
  68. $response->addHTML('</div>');
  69. if (! isset($_POST['repl_clear_scr'])) {
  70. // Render the 'Slave configuration' section
  71. $response->addHTML(
  72. ReplicationGui::getHtmlForSlaveConfiguration(
  73. $GLOBALS['replication_info']['slave']['status'],
  74. $server_slave_replication
  75. )
  76. );
  77. }
  78. if (isset($_POST['sl_configure'])) {
  79. $response->addHTML(ReplicationGui::getHtmlForReplicationChangeMaster("slave_changemaster"));
  80. }