Merge pull request #435 from xmujay/0616_server_replication
refactor server_replication.php 1. render HTML at once 2. split long functions
This commit is contained in:
commit
c43991c390
@ -78,7 +78,7 @@ $slave_variables = array(
|
||||
* define important variables, which need to be watched for
|
||||
* correct running of replication in slave mode
|
||||
*
|
||||
* @usedby PMA_replication_print_status_table()
|
||||
* @usedby PMA_getHtmlForReplicationStatusTable()
|
||||
*/
|
||||
// TODO change to regexp or something, to allow for negative match.
|
||||
// To e.g. highlight 'Last_Error'
|
||||
|
||||
@ -9,14 +9,299 @@ if (! defined('PHPMYADMIN')) {
|
||||
}
|
||||
|
||||
/**
|
||||
* returns code for selecting databases
|
||||
* returns HTML for error message
|
||||
*
|
||||
* @return String HTML code
|
||||
*/
|
||||
function PMA_replication_db_multibox()
|
||||
function PMA_getHtmlForErrorMessage()
|
||||
{
|
||||
$html = '';
|
||||
if (isset($_SESSION['replication']['sr_action_status'])
|
||||
&& isset($_SESSION['replication']['sr_action_info'])
|
||||
) {
|
||||
if ($_SESSION['replication']['sr_action_status'] == 'error') {
|
||||
$error_message = $_SESSION['replication']['sr_action_info'];
|
||||
$html .= PMA_Message::error($error_message)->getDisplay();
|
||||
$_SESSION['replication']['sr_action_status'] = 'unknown';
|
||||
} elseif ($_SESSION['replication']['sr_action_status'] == 'success') {
|
||||
$success_message = $_SESSION['replication']['sr_action_info'];
|
||||
$html .= PMA_Message::success($success_message)->getDisplay();
|
||||
$_SESSION['replication']['sr_action_status'] = 'unknown';
|
||||
}
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns HTML for master replication
|
||||
*
|
||||
* @return String HTML code
|
||||
*/
|
||||
function PMA_getHtmlForMasterReplication()
|
||||
{
|
||||
$html = '';
|
||||
if (! isset($_REQUEST['repl_clear_scr'])) {
|
||||
$html .= '<fieldset>';
|
||||
$html .= '<legend>' . __('Master replication') . '</legend>';
|
||||
$html .= __('This server is configured as master in a replication process.');
|
||||
$html .= '<ul>';
|
||||
$html .= ' <li><a href="#" id="master_status_href">';
|
||||
$html .= __('Show master status') . '</a>';
|
||||
$html .= PMA_getHtmlForReplicationStatusTable('master', true, false);
|
||||
$html .= ' </li>';
|
||||
|
||||
$html .= ' <li><a href="#" id="master_slaves_href">';
|
||||
$html .= __('Show connected slaves') . '</a>';
|
||||
$html .= PMA_getHtmlForReplicationSlavesTable(true);
|
||||
$html .= ' </li>';
|
||||
|
||||
$_url_params = $GLOBALS['url_params'];
|
||||
$_url_params['mr_adduser'] = true;
|
||||
$_url_params['repl_clear_scr'] = true;
|
||||
|
||||
$html .= ' <li><a href="server_replication.php';
|
||||
$html .= PMA_generate_common_url($_url_params) . '" id="master_addslaveuser_href">';
|
||||
$html .= __('Add slave replication user') . '</a></li>';
|
||||
}
|
||||
|
||||
// Display 'Add replication slave user' form
|
||||
if (isset($_REQUEST['mr_adduser'])) {
|
||||
$html .= PMA_getHtmlForReplicationMasterAddSlaveuser();
|
||||
} elseif (! isset($_REQUEST['repl_clear_scr'])) {
|
||||
$html .= "</ul>";
|
||||
$html .= "</fieldset>";
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns HTML for master replication configuration
|
||||
*
|
||||
* @return String HTML code
|
||||
*/
|
||||
function PMA_getHtmlForMasterConfiguration()
|
||||
{
|
||||
$html = '<fieldset>';
|
||||
$html .= '<legend>' . __('Master configuration') . '</legend>';
|
||||
$html .= __('This server is not configured as master server in a replication process. '
|
||||
. 'You can choose from either replicating all databases and ignoring certain '
|
||||
. '(useful if you want to replicate majority of databases) or you can choose to ignore '
|
||||
. 'all databases by default and allow only certain databases to be replicated. Please select the mode:')
|
||||
. '<br /><br />';
|
||||
|
||||
$html .= '<select name="db_type" id="db_type">';
|
||||
$html .= '<option value="all">' . __('Replicate all databases; Ignore:');
|
||||
$html .= '</option>';
|
||||
$html .= '<option value="ign">' . __('Ignore all databases; Replicate:');
|
||||
$html .= '</option>';
|
||||
$html .= '</select>';
|
||||
$html .= '<br /><br />';
|
||||
$html .= __('Please select databases:') . '<br />';
|
||||
$html .= PMA_getHtmlForReplicationDbMultibox();
|
||||
$html .= '<br /><br />';
|
||||
$html .= __('Now, add the following lines at the end of [mysqld] section in your my.cnf and '
|
||||
. 'please restart the MySQL server afterwards.') . '<br />';
|
||||
$html .= '<pre id="rep"></pre>';
|
||||
$html .= __('Once you restarted MySQL server, please click on Go button. '
|
||||
. 'Afterwards, you should see a message informing you, that this server <b>is</b> configured as master.');
|
||||
$html .= '</fieldset>';
|
||||
$html .= '<fieldset class="tblFooters">';
|
||||
$html .= ' <form method="post" action="server_replication.php" >';
|
||||
$html .= PMA_generate_common_hidden_inputs('', '');
|
||||
$html .= ' <input type="submit" value="' . __('Go') . '" id="goButton" />';
|
||||
$html .= ' </form>';
|
||||
$html .= '</fieldset>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns HTML for slave replication configuration
|
||||
*
|
||||
* @param bool $server_slave_status Whether it is Master or Slave
|
||||
* @param Array $server_slave_replication Slave replication
|
||||
*
|
||||
* @return String HTML code
|
||||
*/
|
||||
function PMA_getHtmlForSlaveConfiguration($server_slave_status, $server_slave_replication)
|
||||
{
|
||||
$html = '<fieldset>';
|
||||
$html .= '<legend>' . __('Slave replication') . '</legend>';
|
||||
if ($server_slave_status) {
|
||||
$html .= '<div id="slave_configuration_gui">';
|
||||
|
||||
$_url_params = $GLOBALS['url_params'];
|
||||
$_url_params['sr_take_action'] = true;
|
||||
$_url_params['sr_slave_server_control'] = true;
|
||||
|
||||
if ($server_slave_replication[0]['Slave_IO_Running'] == 'No') {
|
||||
$_url_params['sr_slave_action'] = 'start';
|
||||
} else {
|
||||
$_url_params['sr_slave_action'] = 'stop';
|
||||
}
|
||||
|
||||
$_url_params['sr_slave_control_parm'] = 'IO_THREAD';
|
||||
$slave_control_io_link = 'server_replication.php'
|
||||
. PMA_generate_common_url($_url_params);
|
||||
|
||||
if ($server_slave_replication[0]['Slave_SQL_Running'] == 'No') {
|
||||
$_url_params['sr_slave_action'] = 'start';
|
||||
} else {
|
||||
$_url_params['sr_slave_action'] = 'stop';
|
||||
}
|
||||
|
||||
$_url_params['sr_slave_control_parm'] = 'SQL_THREAD';
|
||||
$slave_control_sql_link = 'server_replication.php'
|
||||
. PMA_generate_common_url($_url_params);
|
||||
|
||||
if ($server_slave_replication[0]['Slave_IO_Running'] == 'No'
|
||||
|| $server_slave_replication[0]['Slave_SQL_Running'] == 'No'
|
||||
) {
|
||||
$_url_params['sr_slave_action'] = 'start';
|
||||
} else {
|
||||
$_url_params['sr_slave_action'] = 'stop';
|
||||
}
|
||||
|
||||
$_url_params['sr_slave_control_parm'] = null;
|
||||
$slave_control_full_link = 'server_replication.php'
|
||||
. PMA_generate_common_url($_url_params);
|
||||
|
||||
$_url_params['sr_slave_action'] = 'reset';
|
||||
$slave_control_reset_link = 'server_replication.php'
|
||||
. PMA_generate_common_url($_url_params);
|
||||
|
||||
$_url_params = $GLOBALS['url_params'];
|
||||
$_url_params['sr_slave_skip_error'] = true;
|
||||
$slave_skip_error_link = 'server_replication.php'
|
||||
. PMA_generate_common_url($_url_params);
|
||||
|
||||
if ($server_slave_replication[0]['Slave_SQL_Running'] == 'No') {
|
||||
$html .= PMA_Message::error(__('Slave SQL Thread not running!'))->getDisplay();
|
||||
}
|
||||
if ($server_slave_replication[0]['Slave_IO_Running'] == 'No') {
|
||||
$html .= PMA_Message::error(__('Slave IO Thread not running!'))->getDisplay();
|
||||
}
|
||||
|
||||
$_url_params = $GLOBALS['url_params'];
|
||||
$_url_params['sl_configure'] = true;
|
||||
$_url_params['repl_clear_scr'] = true;
|
||||
|
||||
$reconfiguremaster_link = 'server_replication.php' . PMA_generate_common_url($_url_params);
|
||||
|
||||
$html .= __('Server is configured as slave in a replication process. Would you like to:');
|
||||
$html .= '<br />';
|
||||
$html .= '<ul>';
|
||||
$html .= ' <li><a href="#" id="slave_status_href">' . __('See slave status table') . '</a>';
|
||||
$html .= PMA_getHtmlForReplicationStatusTable('slave', true, false);
|
||||
$html .= ' </li>';
|
||||
|
||||
$html .= ' <li><a href="#" id="slave_control_href">' . __('Control slave:') . '</a>';
|
||||
$html .= ' <div id="slave_control_gui" style="display: none">';
|
||||
$html .= ' <ul>';
|
||||
$html .= ' <li><a href="'. $slave_control_full_link . '">';
|
||||
$html .= (($server_slave_replication[0]['Slave_IO_Running'] == 'No' ||
|
||||
$server_slave_replication[0]['Slave_SQL_Running'] == 'No')
|
||||
? __('Full start')
|
||||
: __('Full stop')) . ' </a></li>';
|
||||
$html .= ' <li><a href="'. $slave_control_reset_link . '">';
|
||||
$html .= __('Reset slave') . '</a></li>';
|
||||
if ($server_slave_replication[0]['Slave_SQL_Running'] == 'No') {
|
||||
$html .= ' <li><a href="' . $slave_control_sql_link . '">';
|
||||
$html .= __('Start SQL Thread only') . '</a></li>';
|
||||
} else {
|
||||
$html .= ' <li><a href="' . $slave_control_sql_link . '">';
|
||||
$html .= __('Stop SQL Thread only') . '</a></li>';
|
||||
}
|
||||
if ($server_slave_replication[0]['Slave_IO_Running'] == 'No') {
|
||||
$html .= ' <li><a href="' . $slave_control_io_link . '">';
|
||||
$html .= __('Start IO Thread only') . '</a></li>';
|
||||
} else {
|
||||
$html .= ' <li><a href="' . $slave_control_io_link . '">';
|
||||
$html .= __('Stop IO Thread only') . '</a></li>';
|
||||
}
|
||||
$html .= ' </ul>';
|
||||
$html .= ' </div>';
|
||||
$html .= ' </li>';
|
||||
$html .= ' <li>';
|
||||
$html .= PMA_getHtmlForSlaveErrorManagement($slave_skip_error_link);
|
||||
$html .= ' </li>';
|
||||
$html .= ' <li><a href="' . $reconfiguremaster_link . '">';
|
||||
$html .= __('Change or reconfigure master server') . '</a></li>';
|
||||
$html .= '</ul>';
|
||||
$html .= '</div>';
|
||||
|
||||
} elseif (! isset($_REQUEST['sl_configure'])) {
|
||||
$_url_params = $GLOBALS['url_params'];
|
||||
$_url_params['sl_configure'] = true;
|
||||
$_url_params['repl_clear_scr'] = true;
|
||||
|
||||
$html .= sprintf(__('This server is not configured as slave in a replication process. '
|
||||
. 'Would you like to <a href="%s">configure</a> it?'), 'server_replication.php'
|
||||
. PMA_generate_common_url($_url_params));
|
||||
}
|
||||
$html .= '</fieldset>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns HTML for Slave Error Management
|
||||
*
|
||||
* @param String $slave_skip_error_link error link
|
||||
*
|
||||
* @return String HTML code
|
||||
*/
|
||||
function PMA_getHtmlForSlaveErrorManagement($slave_skip_error_link)
|
||||
{
|
||||
$html = '<a href="#" id="slave_errormanagement_href">';
|
||||
$html .= __('Error management:') . '</a>';
|
||||
$html .= ' <div id="slave_errormanagement_gui" style="display: none">';
|
||||
$html .= PMA_Message::error(__('Skipping errors might lead into unsynchronized master and slave!'))->getDisplay();
|
||||
$html .= ' <ul>';
|
||||
$html .= ' <li><a href="' . $slave_skip_error_link . '">';
|
||||
$html .= __('Skip current error') . '</a></li>';
|
||||
$html .= ' <li>' . __('Skip next');
|
||||
$html .= ' <form method="post" action="server_replication.php">';
|
||||
$html .= PMA_generate_common_hidden_inputs('', '');
|
||||
$html .= ' <input type="text" name="sr_skip_errors_count" value="1" style="width: 30px" />' . __('errors.');
|
||||
$html .= ' <input type="submit" name="sr_slave_skip_error" value="' . __('Go') . '" />';
|
||||
$html .= ' <input type="hidden" name="sr_take_action" value="1" />';
|
||||
$html .= ' </form></li>';
|
||||
$html .= ' </ul>';
|
||||
$html .= ' </div>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns HTML for not configure for a server replication
|
||||
*
|
||||
* @return String HTML code
|
||||
*/
|
||||
function PMA_getHtmlForNotServerReplication()
|
||||
{
|
||||
$_url_params = $GLOBALS['url_params'];
|
||||
$_url_params['mr_configure'] = true;
|
||||
|
||||
$html = '<fieldset>';
|
||||
$html .= '<legend>' . __('Master replication') . '</legend>';
|
||||
$html .= sprintf(__('This server is not configured as master in a replication process. '
|
||||
. 'Would you like to <a href="%s">configure</a> it?'), 'server_replication.php'
|
||||
. PMA_generate_common_url($_url_params));
|
||||
$html .= '</fieldset>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns HTML code for selecting databases
|
||||
*
|
||||
* @return String HTML code
|
||||
*/
|
||||
function PMA_getHtmlForReplicationDbMultibox()
|
||||
{
|
||||
$multi_values = '';
|
||||
$multi_values .= '<select name="db_select[]" size="6" multiple="multiple" id="db_select">';
|
||||
$multi_values .= '<select name="db_select[]" '
|
||||
. 'size="6" multiple="multiple" id="db_select">';
|
||||
|
||||
foreach ($GLOBALS['pma']->databases as $current_db) {
|
||||
if ($GLOBALS['dbi']->isSystemSchema($current_db)) {
|
||||
@ -28,7 +313,8 @@ function PMA_replication_db_multibox()
|
||||
$is_selected = '';
|
||||
}
|
||||
$current_db = htmlspecialchars($current_db);
|
||||
$multi_values .= ' <option value="' . $current_db . '" ' . $is_selected . '>' . $current_db . '</option>';
|
||||
$multi_values .= ' <option value="' . $current_db . '" ' . $is_selected . '>';
|
||||
$multi_values .= $current_db . '</option>';
|
||||
} // end while
|
||||
|
||||
$multi_values .= '</select>';
|
||||
@ -38,65 +324,113 @@ function PMA_replication_db_multibox()
|
||||
}
|
||||
|
||||
/**
|
||||
* prints out code for changing master
|
||||
* returns HTML for changing master
|
||||
*
|
||||
* @param String $submitname - submit button name
|
||||
*
|
||||
* @return void
|
||||
* @return String HTML code
|
||||
*/
|
||||
|
||||
function PMA_replication_gui_changemaster($submitname)
|
||||
function PMA_getHtmlForReplicationChangeMaster($submitname)
|
||||
{
|
||||
|
||||
$html = '';
|
||||
list($username_length, $hostname_length) = PMA_replication_get_username_hostname_length();
|
||||
|
||||
echo '<form method="post" action="server_replication.php">';
|
||||
echo PMA_generate_common_hidden_inputs('', '');
|
||||
echo ' <fieldset id="fieldset_add_user_login">';
|
||||
echo ' <legend>' . __('Slave configuration') . ' - ' . __('Change or reconfigure master server') . '</legend>';
|
||||
echo __('Make sure, you have unique server-id in your configuration file (my.cnf). If not, please add the following line into [mysqld] section:') . '<br />';
|
||||
echo '<pre>server-id=' . time() . '</pre>';
|
||||
echo ' <div class="item">';
|
||||
echo ' <label for="text_username">' . __('User name:') . '</label>';
|
||||
echo ' <input type="text" name="username" id="text_username" maxlength="'. $username_length . '" title="' . __('User name') . '" />';
|
||||
echo ' </div>';
|
||||
echo ' <div class="item">';
|
||||
echo ' <label for="text_pma_pw">' . __('Password:') .'</label>';
|
||||
echo ' <input type="password" id="text_pma_pw" name="pma_pw" title="' . __('Password') . '" />';
|
||||
echo ' </div>';
|
||||
echo ' <div class="item">';
|
||||
echo ' <label for="text_hostname">' . __('Host:') . '</label>';
|
||||
echo ' <input type="text" id="text_hostname" name="hostname" maxlength="' . $hostname_length . '" value="" />';
|
||||
echo ' </div>';
|
||||
echo ' <div class="item">';
|
||||
echo ' <label for="text_port">' . __('Port:') . '</label>';
|
||||
echo ' <input type="text" id="text_port" name="port" maxlength="6" value="3306" />';
|
||||
echo ' </div>';
|
||||
echo ' </fieldset>';
|
||||
echo ' <fieldset id="fieldset_user_privtable_footer" class="tblFooters">';
|
||||
echo ' <input type="hidden" name="sr_take_action" value="true" />';
|
||||
echo ' <input type="hidden" name="' . $submitname . '" value="1" />';
|
||||
echo ' <input type="submit" id="confslave_submit" value="' . __('Go') . '" />';
|
||||
echo ' </fieldset>';
|
||||
echo '</form>';
|
||||
$html .= '<form method="post" action="server_replication.php">';
|
||||
$html .= PMA_generate_common_hidden_inputs('', '');
|
||||
$html .= ' <fieldset id="fieldset_add_user_login">';
|
||||
$html .= ' <legend>' . __('Slave configuration');
|
||||
$html .= ' - ' . __('Change or reconfigure master server') . '</legend>';
|
||||
$html .= __('Make sure, you have unique server-id in your configuration file (my.cnf). '
|
||||
. 'If not, please add the following line into [mysqld] section:') . '<br />';
|
||||
$html .= '<pre>server-id=' . time() . '</pre>';
|
||||
|
||||
$html .= PMA_getHtmlForAddUserInputDiv(array('text'=>__('User name:'), 'for'=>"text_username"),
|
||||
array('type'=>'text',
|
||||
'name'=>'username',
|
||||
'id'=>'text_username',
|
||||
'maxlength'=>$username_length,
|
||||
'title'=>__('User name')
|
||||
)
|
||||
);
|
||||
|
||||
$html .= PMA_getHtmlForAddUserInputDiv(array('text'=>__('Password:'), 'for'=>"text_pma_pw"),
|
||||
array('type'=>'password',
|
||||
'name'=>'pma_pw',
|
||||
'id'=>'text_pma_pw',
|
||||
'title'=>__('Password')
|
||||
)
|
||||
);
|
||||
|
||||
$html .= PMA_getHtmlForAddUserInputDiv(array('text'=>__('Host:'), 'for'=>"text_hostname"),
|
||||
array('type'=>'text',
|
||||
'name'=>'hostname',
|
||||
'id'=>'text_hostname',
|
||||
'maxlength'=>$hostname_length,
|
||||
'value'=>''
|
||||
)
|
||||
);
|
||||
|
||||
$html .= PMA_getHtmlForAddUserInputDiv(array('text'=>__('Port:'), 'for'=>"text_port"),
|
||||
array('type'=>'text',
|
||||
'name'=>'text_port',
|
||||
'id'=>'text_port',
|
||||
'maxlength'=>6,
|
||||
'value'=>'3306'
|
||||
)
|
||||
);
|
||||
|
||||
$html .= ' </fieldset>';
|
||||
$html .= ' <fieldset id="fieldset_user_privtable_footer" class="tblFooters">';
|
||||
$html .= ' <input type="hidden" name="sr_take_action" value="true" />';
|
||||
$html .= ' <input type="hidden" name="' . $submitname . '" value="1" />';
|
||||
$html .= ' <input type="submit" id="confslave_submit" value="' . __('Go') . '" />';
|
||||
$html .= ' </fieldset>';
|
||||
$html .= '</form>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns HTML code for Add user input div
|
||||
*
|
||||
* @param Array $label_array label tag elements
|
||||
* @param Array $input_array input tag elements
|
||||
*
|
||||
* @return String HTML code
|
||||
*/
|
||||
function PMA_getHtmlForAddUserInputDiv($label_array, $input_array)
|
||||
{
|
||||
$html = ' <div class="item">';
|
||||
$html .= ' <label for="' . $label_array['for'] . '">';
|
||||
$html .= $label_array['text'] . '</label>';
|
||||
|
||||
$html .= ' <input ';
|
||||
foreach($input_array as $key=>$value)
|
||||
$html .= ' ' . $key . '="' . $value. '" ';
|
||||
$html .= ' />';
|
||||
$html .= ' </div>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function prints out table with replication status.
|
||||
* This function returns html code for table with replication status.
|
||||
*
|
||||
* @param string $type either master or slave
|
||||
* @param boolean $hidden if true, then default style is set to hidden, default value false
|
||||
* @param boolen $title if true, then title is displayed, default true
|
||||
*
|
||||
* @return void
|
||||
* @return String HTML code
|
||||
*/
|
||||
function PMA_replication_print_status_table($type, $hidden = false, $title = true)
|
||||
function PMA_getHtmlForReplicationStatusTable($type, $hidden = false, $title = true)
|
||||
{
|
||||
global ${"{$type}_variables"};
|
||||
global ${"{$type}_variables_alerts"};
|
||||
global ${"{$type}_variables_oks"};
|
||||
global ${"server_{$type}_replication"};
|
||||
global ${"strReplicationStatus_{$type}"};
|
||||
|
||||
$html = '';
|
||||
|
||||
// TODO check the Masters server id?
|
||||
// seems to default to '1' when queried via SHOW VARIABLES , but resulted in error on the master when slave connects
|
||||
@ -105,48 +439,51 @@ function PMA_replication_print_status_table($type, $hidden = false, $title = tru
|
||||
//
|
||||
//$server_id = $GLOBALS['dbi']->fetchValue("SHOW VARIABLES LIKE 'server_id'", 0, 1);
|
||||
|
||||
echo '<div id="replication_' . $type . '_section" style="' . ($hidden ? 'display: none;' : '') . '"> ';
|
||||
$html .= '<div id="replication_' . $type . '_section" style="';
|
||||
$html .= ($hidden ? 'display: none;' : '') . '"> ';
|
||||
|
||||
if ($title) {
|
||||
if ($type == 'master') {
|
||||
echo '<h4><a name="replication_' . $type . '"></a>' . __('Master status') . '</h4>';
|
||||
$html .= '<h4><a name="replication_' . $type . '"></a>';
|
||||
$html .= __('Master status') . '</h4>';
|
||||
} else {
|
||||
echo '<h4><a name="replication_' . $type . '"></a>' . __('Slave status') . '</h4>';
|
||||
$html .= '<h4><a name="replication_' . $type . '"></a>';
|
||||
$html .= __('Slave status') . '</h4>';
|
||||
}
|
||||
} else {
|
||||
echo '<br />';
|
||||
$html .= '<br />';
|
||||
}
|
||||
|
||||
echo ' <table id="server' . $type . 'replicationsummary" class="data"> ';
|
||||
echo ' <thead>';
|
||||
echo ' <tr>';
|
||||
echo ' <th>' . __('Variable') . '</th>';
|
||||
echo ' <th>' . __('Value') . '</th>';
|
||||
echo ' </tr>';
|
||||
echo ' </thead>';
|
||||
echo ' <tbody>';
|
||||
$html .= ' <table id="server' . $type . 'replicationsummary" class="data"> ';
|
||||
$html .= ' <thead>';
|
||||
$html .= ' <tr>';
|
||||
$html .= ' <th>' . __('Variable') . '</th>';
|
||||
$html .= ' <th>' . __('Value') . '</th>';
|
||||
$html .= ' </tr>';
|
||||
$html .= ' </thead>';
|
||||
$html .= ' <tbody>';
|
||||
|
||||
$odd_row = true;
|
||||
foreach (${"{$type}_variables"} as $variable) {
|
||||
echo ' <tr class="' . ($odd_row ? 'odd' : 'even') . '">';
|
||||
echo ' <td class="name">';
|
||||
echo $variable;
|
||||
echo ' </td>';
|
||||
echo ' <td class="value">';
|
||||
$html .= ' <tr class="' . ($odd_row ? 'odd' : 'even') . '">';
|
||||
$html .= ' <td class="name">';
|
||||
$html .= $variable;
|
||||
$html .= ' </td>';
|
||||
$html .= ' <td class="value">';
|
||||
|
||||
|
||||
// TODO change to regexp or something, to allow for negative match
|
||||
if (isset(${"{$type}_variables_alerts"}[$variable])
|
||||
&& ${"{$type}_variables_alerts"}[$variable] == ${"server_{$type}_replication"}[0][$variable]
|
||||
) {
|
||||
echo '<span class="attention">';
|
||||
$html .= '<span class="attention">';
|
||||
|
||||
} elseif (isset(${"{$type}_variables_oks"}[$variable])
|
||||
&& ${"{$type}_variables_oks"}[$variable] == ${"server_{$type}_replication"}[0][$variable]
|
||||
) {
|
||||
echo '<span class="allfine">';
|
||||
$html .= '<span class="allfine">';
|
||||
} else {
|
||||
echo '<span>';
|
||||
$html .= '<span>';
|
||||
}
|
||||
// allow wrapping long table lists into multiple lines
|
||||
static $variables_wrap = array(
|
||||
@ -154,65 +491,70 @@ function PMA_replication_print_status_table($type, $hidden = false, $title = tru
|
||||
'Replicate_Do_Table', 'Replicate_Ignore_Table',
|
||||
'Replicate_Wild_Do_Table', 'Replicate_Wild_Ignore_Table');
|
||||
if (in_array($variable, $variables_wrap)) {
|
||||
echo str_replace(',', ', ', ${"server_{$type}_replication"}[0][$variable]);
|
||||
$html .= str_replace(',', ', ', ${"server_{$type}_replication"}[0][$variable]);
|
||||
} else {
|
||||
echo ${"server_{$type}_replication"}[0][$variable];
|
||||
$html .= ${"server_{$type}_replication"}[0][$variable];
|
||||
}
|
||||
echo '</span>';
|
||||
$html .= '</span>';
|
||||
|
||||
echo ' </td>';
|
||||
echo ' </tr>';
|
||||
$html .= ' </td>';
|
||||
$html .= ' </tr>';
|
||||
|
||||
$odd_row = ! $odd_row;
|
||||
}
|
||||
|
||||
echo ' </tbody>';
|
||||
echo ' </table>';
|
||||
echo ' <br />';
|
||||
echo '</div>';
|
||||
|
||||
$html .= ' </tbody>';
|
||||
$html .= ' </table>';
|
||||
$html .= ' <br />';
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints table with slave users connected to this master
|
||||
* returns html code for table with slave users connected to this master
|
||||
*
|
||||
* @param boolean $hidden - if true, then default style is set to hidden, default value false
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_replication_print_slaves_table($hidden = false)
|
||||
function PMA_getHtmlForReplicationSlavesTable($hidden = false)
|
||||
{
|
||||
|
||||
$html = '';
|
||||
// Fetch data
|
||||
$data = $GLOBALS['dbi']->fetchResult('SHOW SLAVE HOSTS', null, null);
|
||||
|
||||
echo ' <br />';
|
||||
echo ' <div id="replication_slaves_section" style="' . ($hidden ? 'display: none;' : '') . '"> ';
|
||||
echo ' <table class="data">';
|
||||
echo ' <thead>';
|
||||
echo ' <tr>';
|
||||
echo ' <th>' . __('Server ID') . '</th>';
|
||||
echo ' <th>' . __('Host') . '</th>';
|
||||
echo ' </tr>';
|
||||
echo ' </thead>';
|
||||
echo ' <tbody>';
|
||||
$html .= ' <br />';
|
||||
$html .= ' <div id="replication_slaves_section" style="';
|
||||
$html .= ($hidden ? 'display: none;' : '') . '"> ';
|
||||
$html .= ' <table class="data">';
|
||||
$html .= ' <thead>';
|
||||
$html .= ' <tr>';
|
||||
$html .= ' <th>' . __('Server ID') . '</th>';
|
||||
$html .= ' <th>' . __('Host') . '</th>';
|
||||
$html .= ' </tr>';
|
||||
$html .= ' </thead>';
|
||||
$html .= ' <tbody>';
|
||||
|
||||
$odd_row = true;
|
||||
foreach ($data as $slave) {
|
||||
echo ' <tr class="' . ($odd_row ? 'odd' : 'even') . '">';
|
||||
echo ' <td class="value">' . $slave['Server_id'] . '</td>';
|
||||
echo ' <td class="value">' . $slave['Host'] . '</td>';
|
||||
echo ' </tr>';
|
||||
$html .= ' <tr class="' . ($odd_row ? 'odd' : 'even') . '">';
|
||||
$html .= ' <td class="value">' . $slave['Server_id'] . '</td>';
|
||||
$html .= ' <td class="value">' . $slave['Host'] . '</td>';
|
||||
$html .= ' </tr>';
|
||||
|
||||
$odd_row = ! $odd_row;
|
||||
}
|
||||
|
||||
echo ' </tbody>';
|
||||
echo ' </table>';
|
||||
echo ' <br />';
|
||||
PMA_Message::notice(__('Only slaves started with the --report-host=host_name option are visible in this list.'))->display();
|
||||
echo ' <br />';
|
||||
echo ' </div>';
|
||||
$html .= ' </tbody>';
|
||||
$html .= ' </table>';
|
||||
$html .= ' <br />';
|
||||
$html .= PMA_Message::notice(__('Only slaves started with the '
|
||||
. '--report-host=host_name option are visible in this list.'))->getDisplay();
|
||||
$html .= ' <br />';
|
||||
$html .= ' </div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -245,70 +587,57 @@ function PMA_replication_get_username_hostname_length()
|
||||
}
|
||||
|
||||
/**
|
||||
* Print code to add a replication slave user to the master
|
||||
* returns html code to add a replication slave user to the master
|
||||
*
|
||||
* @return void
|
||||
* @return String HTML code
|
||||
*/
|
||||
function PMA_replication_gui_master_addslaveuser()
|
||||
function PMA_getHtmlForReplicationMasterAddSlaveuser()
|
||||
{
|
||||
|
||||
$html = '';
|
||||
list($username_length, $hostname_length) = PMA_replication_get_username_hostname_length();
|
||||
|
||||
if (isset($GLOBALS['username']) && strlen($GLOBALS['username']) === 0) {
|
||||
if (isset($_REQUEST['username']) && strlen($_REQUEST['username']) === 0) {
|
||||
$GLOBALS['pred_username'] = 'any';
|
||||
}
|
||||
echo '<div id="master_addslaveuser_gui">';
|
||||
echo '<form autocomplete="off" method="post" action="server_privileges.php" onsubmit="return checkAddUser(this);">';
|
||||
echo PMA_generate_common_hidden_inputs('', '');
|
||||
echo '<fieldset id="fieldset_add_user_login">'
|
||||
. '<legend>'.__('Add slave replication user').'</legend>'
|
||||
. '<input type="hidden" name="grant_count" value="25" />'
|
||||
. '<input type="hidden" name="createdb" id="createdb_0" value="0" />'
|
||||
. '<input id="checkbox_Repl_slave_priv" type="hidden" title="Needed for the replication slaves." value="Y" name="Repl_slave_priv"/>'
|
||||
. '<input id="checkbox_Repl_client_priv" type="hidden" title="Needed for the replication slaves." value="Y" name="Repl_client_priv"/>'
|
||||
. ''
|
||||
. '<input type="hidden" name="sr_take_action" value="true" />'
|
||||
. '<div class="item">'
|
||||
. '<label for="select_pred_username">'
|
||||
. ' ' . __('User name:')
|
||||
. '</label>'
|
||||
. '<span class="options">'
|
||||
. ' <select name="pred_username" id="select_pred_username" title="' . __('User name') . '"'
|
||||
. ' onchange="if (this.value == \'any\') { username.value = \'\'; } else if (this.value == \'userdefined\') { username.focus(); username.select(); }">'
|
||||
. ' <option value="any"' . ((isset($GLOBALS['pred_username']) && $GLOBALS['pred_username'] == 'any') ? ' selected="selected"' : '') . '>' . __('Any user') . '</option>'
|
||||
. ' <option value="userdefined"' . ((! isset($GLOBALS['pred_username']) || $GLOBALS['pred_username'] == 'userdefined') ? ' selected="selected"' : '') . '>' . __('Use text field:') . '</option>'
|
||||
. ' </select>'
|
||||
. '</span>'
|
||||
. '<input type="text" name="username" maxlength="'
|
||||
. $username_length . '" title="' . __('User name') . '"'
|
||||
. (empty($GLOBALS['username'])
|
||||
? ''
|
||||
: ' value="' . (isset($GLOBALS['new_username'])
|
||||
? $GLOBALS['new_username']
|
||||
: $GLOBALS['username']) . '"')
|
||||
. ' onchange="pred_username.value = \'userdefined\';" />'
|
||||
. '</div>'
|
||||
$html .= '<div id="master_addslaveuser_gui">';
|
||||
$html .= '<form autocomplete="off" method="post" action="server_privileges.php"';
|
||||
$html .= ' onsubmit="return checkAddUser(this);">';
|
||||
$html .= PMA_generate_common_hidden_inputs('', '');
|
||||
$html .= '<fieldset id="fieldset_add_user_login">'
|
||||
. '<legend>' . __('Add slave replication user') . '</legend>'
|
||||
. PMA_getHtmlForAddUserLoginForm($username_length)
|
||||
. '<div class="item">'
|
||||
. '<label for="select_pred_hostname">'
|
||||
. ' ' . __('Host:')
|
||||
. '</label>'
|
||||
. '<span class="options">'
|
||||
. ' <select name="pred_hostname" id="select_pred_hostname" title="' . __('Host') . '"';
|
||||
. ' <select name="pred_hostname" id="select_pred_hostname" title="'
|
||||
. __('Host') . '"';
|
||||
|
||||
$_current_user = $GLOBALS['dbi']->fetchValue('SELECT USER();');
|
||||
if (! empty($_current_user)) {
|
||||
$thishost = str_replace("'", '', substr($_current_user, (strrpos($_current_user, '@') + 1)));
|
||||
$thishost = str_replace("'",
|
||||
'',
|
||||
substr($_current_user, (strrpos($_current_user, '@') + 1))
|
||||
);
|
||||
if ($thishost == 'localhost' || $thishost == '127.0.0.1') {
|
||||
unset($thishost);
|
||||
}
|
||||
}
|
||||
echo ' onchange="if (this.value == \'any\') { hostname.value = \'%\'; } else if (this.value == \'localhost\') { hostname.value = \'localhost\'; } '
|
||||
. (empty($thishost) ? '' : 'else if (this.value == \'thishost\') { hostname.value = \'' . addslashes(htmlspecialchars($thishost)) . '\'; } ')
|
||||
. 'else if (this.value == \'hosttable\') { hostname.value = \'\'; } else if (this.value == \'userdefined\') { hostname.focus(); hostname.select(); }">' . "\n";
|
||||
$html .= ' onchange="if (this.value == \'any\') { hostname.value = \'%\'; } '
|
||||
. 'else if (this.value == \'localhost\') { hostname.value = \'localhost\'; } '
|
||||
. (empty($thishost)
|
||||
? ''
|
||||
: 'else if (this.value == \'thishost\') { hostname.value = \''
|
||||
. addslashes(htmlspecialchars($thishost)) . '\'; } ')
|
||||
. 'else if (this.value == \'hosttable\') { hostname.value = \'\'; } '
|
||||
. 'else if (this.value == \'userdefined\') { hostname.focus(); hostname.select(); }">'
|
||||
. "\n";
|
||||
unset($_current_user);
|
||||
|
||||
// when we start editing a user, $GLOBALS['pred_hostname'] is not defined
|
||||
if (! isset($GLOBALS['pred_hostname']) && isset($GLOBALS['hostname'])) {
|
||||
switch (strtolower($GLOBALS['hostname'])) {
|
||||
if (! isset($GLOBALS['pred_hostname']) && isset($_REQUEST['hostname'])) {
|
||||
switch (strtolower($_REQUEST['hostname'])) {
|
||||
case 'localhost':
|
||||
case '127.0.0.1':
|
||||
$GLOBALS['pred_hostname'] = 'localhost';
|
||||
@ -321,7 +650,7 @@ function PMA_replication_gui_master_addslaveuser()
|
||||
break;
|
||||
}
|
||||
}
|
||||
echo ' <option value="any"'
|
||||
$html .= ' <option value="any"'
|
||||
. ((isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'any')
|
||||
? ' selected="selected"' : '') . '>' . __('Any host')
|
||||
. '</option>'
|
||||
@ -331,13 +660,72 @@ function PMA_replication_gui_master_addslaveuser()
|
||||
. '</option>';
|
||||
|
||||
if (!empty($thishost)) {
|
||||
echo ' <option value="thishost"'
|
||||
$html .= ' <option value="thishost"'
|
||||
. ((isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'thishost')
|
||||
? ' selected="selected"' : '') . '>' . __('This Host')
|
||||
. '</option>';
|
||||
}
|
||||
unset($thishost);
|
||||
echo ' <option value="hosttable"'
|
||||
|
||||
$html .= PMA_getHtmlForTableInfoForm($hostname_length);
|
||||
$html .= '</form>';
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
/**
|
||||
* returns html code to add a replication slave user to the master
|
||||
*
|
||||
* @param int $username_length Username length
|
||||
*
|
||||
* @return String HTML code
|
||||
*/
|
||||
function PMA_getHtmlForAddUserLoginForm($username_length)
|
||||
{
|
||||
$html = '<input type="hidden" name="grant_count" value="25" />'
|
||||
. '<input type="hidden" name="createdb" id="createdb_0" value="0" />'
|
||||
. '<input id="checkbox_Repl_slave_priv" type="hidden"'
|
||||
. ' title="Needed for the replication slaves." value="Y" name="Repl_slave_priv"/>'
|
||||
. '<input id="checkbox_Repl_client_priv" type="hidden" title="Needed for the replication slaves."'
|
||||
. ' value="Y" name="Repl_client_priv"/> '
|
||||
. '<input type="hidden" name="sr_take_action" value="true" />'
|
||||
. '<div class="item">'
|
||||
. '<label for="select_pred_username">'
|
||||
. ' ' . __('User name:')
|
||||
. '</label>'
|
||||
. '<span class="options">'
|
||||
. ' <select name="pred_username" id="select_pred_username" title="' . __('User name') . '"'
|
||||
. ' onchange="if (this.value == \'any\') { username.value = \'\'; } '
|
||||
. 'else if (this.value == \'userdefined\') { '
|
||||
. ' username.focus(); username.select(); }">'
|
||||
. ' <option value="any"'
|
||||
. ((isset($GLOBALS['pred_username']) && $GLOBALS['pred_username'] == 'any') ? ' selected="selected"' : '')
|
||||
. '>' . __('Any user') . '</option>'
|
||||
. ' <option value="userdefined"'
|
||||
. ((! isset($GLOBALS['pred_username']) || $GLOBALS['pred_username'] == 'userdefined') ? ' selected="selected"' : '')
|
||||
. '>' . __('Use text field:') . '</option>'
|
||||
. ' </select>'
|
||||
. '</span>'
|
||||
. '<input type="text" name="username" maxlength="'
|
||||
. $username_length . '" title="' . __('User name') . '"'
|
||||
. (empty($_REQUEST['username']) ? '' : ' value="'
|
||||
. (isset($GLOBALS['new_username']) ? $GLOBALS['new_username'] : $_REQUEST['username']) . '"')
|
||||
. ' onchange="pred_username.value = \'userdefined\';" />'
|
||||
. '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns HTML for TableInfoForm
|
||||
*
|
||||
* @param int $hostname_length Selected hostname length
|
||||
*
|
||||
* @return String HTML code
|
||||
*/
|
||||
function PMA_getHtmlForTableInfoForm($hostname_length)
|
||||
{
|
||||
$html = ' <option value="hosttable"'
|
||||
. ((isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'hosttable')
|
||||
? ' selected="selected"' : '') . '>' . __('Use Host Table')
|
||||
. '</option>'
|
||||
@ -349,7 +737,7 @@ function PMA_replication_gui_master_addslaveuser()
|
||||
. '</span>'
|
||||
. '<input type="text" name="hostname" maxlength="'
|
||||
. $hostname_length . '" value="'
|
||||
. (isset($GLOBALS['hostname']) ? $GLOBALS['hostname'] : '')
|
||||
. (isset($_REQUEST['hostname']) ? $_REQUEST['hostname'] : '')
|
||||
. '" title="' . __('Host')
|
||||
. '" onchange="pred_hostname.value = \'userdefined\';" />'
|
||||
. PMA_Util::showHint(
|
||||
@ -363,39 +751,45 @@ function PMA_replication_gui_master_addslaveuser()
|
||||
. '<span class="options">'
|
||||
. ' <select name="pred_password" id="select_pred_password" title="'
|
||||
. __('Password') . '"'
|
||||
. ' onchange="if (this.value == \'none\') { pma_pw.value = \'\'; pma_pw2.value = \'\'; } else if (this.value == \'userdefined\') { pma_pw.focus(); pma_pw.select(); }">'
|
||||
. ' onchange="if (this.value == \'none\') { pma_pw.value = \'\'; pma_pw2.value = \'\'; } '
|
||||
. 'else if (this.value == \'userdefined\') { pma_pw.focus(); pma_pw.select(); }">'
|
||||
. ' <option value="none"';
|
||||
if (isset($GLOBALS['username'])) {
|
||||
echo ' selected="selected"';
|
||||
if (isset($_REQUEST['username'])) {
|
||||
$html .= ' selected="selected"';
|
||||
}
|
||||
echo '>' . __('No Password') . '</option>'
|
||||
. ' <option value="userdefined"' . (isset($GLOBALS['username']) ? '' : ' selected="selected"') . '>' . __('Use text field:') . '</option>'
|
||||
$html .= '>' . __('No Password') . '</option>'
|
||||
. ' <option value="userdefined"'
|
||||
. (isset($_REQUEST['username']) ? '' : ' selected="selected"')
|
||||
. '>' . __('Use text field:') . '</option>'
|
||||
. ' </select>'
|
||||
. '</span>'
|
||||
. '<input type="password" id="text_pma_pw" name="pma_pw" title="' . __('Password') . '" onchange="pred_password.value = \'userdefined\';" />'
|
||||
. '<input type="password" id="text_pma_pw" name="pma_pw" title="'
|
||||
. __('Password') . '" onchange="pred_password.value = \'userdefined\';" />'
|
||||
. '</div>'
|
||||
. '<div class="item">'
|
||||
. '<label for="text_pma_pw2">'
|
||||
. ' ' . __('Re-type:')
|
||||
. '</label>'
|
||||
. '<span class="options"> </span>'
|
||||
. '<input type="password" name="pma_pw2" id="text_pma_pw2" title="' . __('Re-type') . '" onchange="pred_password.value = \'userdefined\';" />'
|
||||
. '<input type="password" name="pma_pw2" id="text_pma_pw2" title="'
|
||||
. __('Re-type') . '" onchange="pred_password.value = \'userdefined\';" />'
|
||||
. '</div>'
|
||||
. '<div class="item">'
|
||||
. '<label for="button_generate_password">'
|
||||
. ' ' . __('Generate Password:')
|
||||
. '</label>'
|
||||
. '<span class="options">'
|
||||
. ' <input type="button" class="button" id="button_generate_password" value="' . __('Generate') . '" onclick="suggestPassword(this.form)" />'
|
||||
. ' <input type="button" class="button" id="button_generate_password" value="'
|
||||
. __('Generate') . '" onclick="suggestPassword(this.form)" />'
|
||||
. '</span>'
|
||||
. '<input type="text" name="generated_pw" id="generated_pw" />'
|
||||
. '</div>'
|
||||
. '</fieldset>';
|
||||
echo '<fieldset id="fieldset_user_privtable_footer" class="tblFooters">'
|
||||
$html .= '<fieldset id="fieldset_user_privtable_footer" class="tblFooters">'
|
||||
. ' <input type="hidden" name="adduser_submit" value="1" />'
|
||||
. ' <input type="submit" id="adduser_submit" value="' . __('Go') . '" />'
|
||||
. '</fieldset>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -29,6 +29,9 @@ function PMA_getSubPageHeader($type)
|
||||
$res['collations']['icon'] = 's_asci.png';
|
||||
$res['collations']['text'] = __('Character Sets and Collations');
|
||||
|
||||
$res['replication']['icon'] = 's_replication.png';
|
||||
$res['replication']['text'] = __('Replication');
|
||||
|
||||
$html = '<h2>' . "\n"
|
||||
. PMA_Util::getImage($res[$type]['icon'])
|
||||
. ' ' . $res[$type]['text'] . "\n"
|
||||
|
||||
@ -6,9 +6,13 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* include files
|
||||
*/
|
||||
require_once 'libraries/common.inc.php';
|
||||
require_once 'libraries/server_common.inc.php';
|
||||
|
||||
require_once 'libraries/replication.inc.php';
|
||||
require_once 'libraries/replication_gui.lib.php';
|
||||
|
||||
/**
|
||||
* Does the common work
|
||||
@ -19,61 +23,30 @@ $scripts = $header->getScripts();
|
||||
$scripts->addFile('server_privileges.js');
|
||||
$scripts->addFile('replication.js');
|
||||
|
||||
require 'libraries/server_common.inc.php';
|
||||
require 'libraries/replication.inc.php';
|
||||
require 'libraries/replication_gui.lib.php';
|
||||
|
||||
/**
|
||||
* Checks if the user is allowed to do what he tries to...
|
||||
*/
|
||||
if (! $is_superuser) {
|
||||
echo '<h2>' . "\n"
|
||||
. PMA_Util::getIcon('s_replication.png')
|
||||
. __('Replication') . "\n"
|
||||
. '</h2>' . "\n";
|
||||
PMA_Message::error(__('No Privileges'))->display();
|
||||
$html = PMA_getSubPageHeader('replication');
|
||||
$html .= PMA_Message::error(__('No Privileges'))->getDisplay();
|
||||
$response->addHTML($html);
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets globals from $_REQUEST
|
||||
*/
|
||||
$request_params = array(
|
||||
'hostname',
|
||||
'mr_adduser',
|
||||
'mr_configure',
|
||||
'pma_pw',
|
||||
'port',
|
||||
'repl_clear_scr',
|
||||
'repl_data',
|
||||
'sl_configure',
|
||||
'slave_changemaster',
|
||||
'sr_skip_errors_count',
|
||||
'sr_slave_action',
|
||||
'sr_slave_control_parm',
|
||||
'sr_slave_server_control',
|
||||
'sr_slave_skip_error',
|
||||
'sr_take_action',
|
||||
'url_params',
|
||||
'username'
|
||||
);
|
||||
|
||||
foreach ($request_params as $one_request_param) {
|
||||
if (isset($_REQUEST[$one_request_param])) {
|
||||
$GLOBALS[$one_request_param] = $_REQUEST[$one_request_param];
|
||||
}
|
||||
//change $GLOBALS['url_params'] with $_REQUEST['url_params']
|
||||
if (isset($_REQUEST['url_params'])) {
|
||||
$GLOBALS['url_params'] = $_REQUEST['url_params'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Handling control requests
|
||||
*/
|
||||
if (isset($GLOBALS['sr_take_action'])) {
|
||||
if (isset($_REQUEST['sr_take_action'])) {
|
||||
$refresh = false;
|
||||
if (isset($GLOBALS['slave_changemaster'])) {
|
||||
$_SESSION['replication']['m_username'] = $sr['username'] = PMA_Util::sqlAddSlashes($GLOBALS['username']);
|
||||
$_SESSION['replication']['m_password'] = $sr['pma_pw'] = PMA_Util::sqlAddSlashes($GLOBALS['pma_pw']);
|
||||
$_SESSION['replication']['m_hostname'] = $sr['hostname'] = PMA_Util::sqlAddSlashes($GLOBALS['hostname']);
|
||||
$_SESSION['replication']['m_port'] = $sr['port'] = PMA_Util::sqlAddSlashes($GLOBALS['port']);
|
||||
if (isset($_REQUEST['slave_changemaster'])) {
|
||||
$_SESSION['replication']['m_username'] = $sr['username'] = PMA_Util::sqlAddSlashes($_REQUEST['username']);
|
||||
$_SESSION['replication']['m_password'] = $sr['pma_pw'] = PMA_Util::sqlAddSlashes($_REQUEST['pma_pw']);
|
||||
$_SESSION['replication']['m_hostname'] = $sr['hostname'] = PMA_Util::sqlAddSlashes($_REQUEST['hostname']);
|
||||
$_SESSION['replication']['m_port'] = $sr['port'] = PMA_Util::sqlAddSlashes($_REQUEST['port']);
|
||||
$_SESSION['replication']['m_correct'] = '';
|
||||
$_SESSION['replication']['sr_action_status'] = 'error';
|
||||
$_SESSION['replication']['sr_action_info'] = __('Unknown error');
|
||||
@ -95,11 +68,19 @@ if (isset($GLOBALS['sr_take_action'])) {
|
||||
|
||||
if (empty($position)) {
|
||||
$_SESSION['replication']['sr_action_status'] = 'error';
|
||||
$_SESSION['replication']['sr_action_info'] = __('Unable to read master log position. Possible privilege problem on master.');
|
||||
$_SESSION['replication']['sr_action_info'] =
|
||||
__('Unable to read master log position. Possible privilege problem on master.');
|
||||
} else {
|
||||
$_SESSION['replication']['m_correct'] = true;
|
||||
|
||||
if (! PMA_Replication_Slave_changeMaster($sr['username'], $sr['pma_pw'], $sr['hostname'], $sr['port'], $position, true, false)) {
|
||||
if (! PMA_Replication_Slave_changeMaster(
|
||||
$sr['username'],
|
||||
$sr['pma_pw'],
|
||||
$sr['hostname'],
|
||||
$sr['port'],
|
||||
$position,
|
||||
true,
|
||||
false)) {
|
||||
$_SESSION['replication']['sr_action_status'] = 'error';
|
||||
$_SESSION['replication']['sr_action_info'] = __('Unable to change master');
|
||||
} else {
|
||||
@ -111,23 +92,23 @@ if (isset($GLOBALS['sr_take_action'])) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif (isset($GLOBALS['sr_slave_server_control'])) {
|
||||
if ($GLOBALS['sr_slave_action'] == 'reset') {
|
||||
} elseif (isset($_REQUEST['sr_slave_server_control'])) {
|
||||
if ($_REQUEST['sr_slave_action'] == 'reset') {
|
||||
PMA_Replication_Slave_control("STOP");
|
||||
$GLOBALS['dbi']->tryQuery("RESET SLAVE;");
|
||||
PMA_Replication_Slave_control("START");
|
||||
} else {
|
||||
PMA_Replication_Slave_control(
|
||||
$GLOBALS['sr_slave_action'],
|
||||
$GLOBALS['sr_slave_control_parm']
|
||||
$_REQUEST['sr_slave_action'],
|
||||
$_REQUEST['sr_slave_control_parm']
|
||||
);
|
||||
}
|
||||
$refresh = true;
|
||||
|
||||
} elseif (isset($GLOBALS['sr_slave_skip_error'])) {
|
||||
} elseif (isset($_REQUEST['sr_slave_skip_error'])) {
|
||||
$count = 1;
|
||||
if (isset($GLOBALS['sr_skip_errors_count'])) {
|
||||
$count = $GLOBALS['sr_skip_errors_count'] * 1;
|
||||
if (isset($_REQUEST['sr_skip_errors_count'])) {
|
||||
$count = $_REQUEST['sr_skip_errors_count'] * 1;
|
||||
}
|
||||
PMA_Replication_Slave_control("STOP");
|
||||
$GLOBALS['dbi']->tryQuery("SET GLOBAL SQL_SLAVE_SKIP_COUNTER = ".$count.";");
|
||||
@ -141,209 +122,34 @@ if (isset($GLOBALS['sr_take_action'])) {
|
||||
unset($refresh);
|
||||
}
|
||||
|
||||
|
||||
echo '<div id="replication">';
|
||||
echo ' <h2>';
|
||||
echo ' ' . PMA_Util::getImage('s_replication.png');
|
||||
echo __('Replication');
|
||||
echo ' </h2>';
|
||||
/**
|
||||
* start output
|
||||
*/
|
||||
$response->addHTML('<div id="replication">');
|
||||
$response->addHTML(PMA_getSubPageHeader('replication'));
|
||||
|
||||
// Display error messages
|
||||
if (isset($_SESSION['replication']['sr_action_status'])
|
||||
&& isset($_SESSION['replication']['sr_action_info'])
|
||||
) {
|
||||
if ($_SESSION['replication']['sr_action_status'] == 'error') {
|
||||
PMA_Message::error($_SESSION['replication']['sr_action_info'])->display();
|
||||
$_SESSION['replication']['sr_action_status'] = 'unknown';
|
||||
} elseif ($_SESSION['replication']['sr_action_status'] == 'success') {
|
||||
PMA_Message::success($_SESSION['replication']['sr_action_info'])->display();
|
||||
$_SESSION['replication']['sr_action_status'] = 'unknown';
|
||||
}
|
||||
}
|
||||
$response->addHTML(PMA_getHtmlForErrorMessage());
|
||||
|
||||
if ($server_master_status) {
|
||||
if (! isset($GLOBALS['repl_clear_scr'])) {
|
||||
echo '<fieldset>';
|
||||
echo '<legend>' . __('Master replication') . '</legend>';
|
||||
echo __('This server is configured as master in a replication process.');
|
||||
echo '<ul>';
|
||||
echo ' <li><a href="#" id="master_status_href">' . __('Show master status') . '</a>';
|
||||
PMA_replication_print_status_table('master', true, false);
|
||||
echo ' </li>';
|
||||
|
||||
echo ' <li><a href="#" id="master_slaves_href">' . __('Show connected slaves') . '</a>';
|
||||
PMA_replication_print_slaves_table(true);
|
||||
echo ' </li>';
|
||||
|
||||
$_url_params = $GLOBALS['url_params'];
|
||||
$_url_params['mr_adduser'] = true;
|
||||
$_url_params['repl_clear_scr'] = true;
|
||||
|
||||
echo ' <li><a href="server_replication.php' . PMA_generate_common_url($_url_params) . '" id="master_addslaveuser_href">';
|
||||
echo __('Add slave replication user') . '</a></li>';
|
||||
}
|
||||
|
||||
// Display 'Add replication slave user' form
|
||||
if (isset($GLOBALS['mr_adduser'])) {
|
||||
PMA_replication_gui_master_addslaveuser();
|
||||
} elseif (! isset($GLOBALS['repl_clear_scr'])) {
|
||||
echo "</ul>";
|
||||
echo "</fieldset>";
|
||||
}
|
||||
} elseif (! isset($GLOBALS['mr_configure']) && ! isset($GLOBALS['repl_clear_scr'])) {
|
||||
$_url_params = $GLOBALS['url_params'];
|
||||
$_url_params['mr_configure'] = true;
|
||||
|
||||
echo '<fieldset>';
|
||||
echo '<legend>' . __('Master replication') . '</legend>';
|
||||
echo sprintf(__('This server is not configured as master in a replication process. Would you like to <a href="%s">configure</a> it?'), 'server_replication.php' . PMA_generate_common_url($_url_params));
|
||||
echo '</fieldset>';
|
||||
$response->addHTML(PMA_getHtmlForMasterReplication());
|
||||
} elseif (! isset($_REQUEST['mr_configure']) && ! isset($_REQUEST['repl_clear_scr'])) {
|
||||
$response->addHTML(PMA_getHtmlForNotServerReplication());
|
||||
}
|
||||
|
||||
if (isset($GLOBALS['mr_configure'])) {
|
||||
if (isset($_REQUEST['mr_configure'])) {
|
||||
// Render the 'Master configuration' section
|
||||
echo '<fieldset>';
|
||||
echo '<legend>' . __('Master configuration') . '</legend>';
|
||||
echo __('This server is not configured as master server in a replication process. You can choose from either replicating all databases and ignoring certain (useful if you want to replicate majority of databases) or you can choose to ignore all databases by default and allow only certain databases to be replicated. Please select the mode:') . '<br /><br />';
|
||||
|
||||
echo '<select name="db_type" id="db_type">';
|
||||
echo '<option value="all">' . __('Replicate all databases; Ignore:') . '</option>';
|
||||
echo '<option value="ign">' . __('Ignore all databases; Replicate:') . '</option>';
|
||||
echo '</select>';
|
||||
echo '<br /><br />';
|
||||
echo __('Please select databases:') . '<br />';
|
||||
echo PMA_replication_db_multibox();
|
||||
echo '<br /><br />';
|
||||
echo __('Now, add the following lines at the end of [mysqld] section in your my.cnf and please restart the MySQL server afterwards.') . '<br />';
|
||||
echo '<pre id="rep"></pre>';
|
||||
echo __('Once you restarted MySQL server, please click on Go button. Afterwards, you should see a message informing you, that this server <b>is</b> configured as master.');
|
||||
echo '</fieldset>';
|
||||
echo '<fieldset class="tblFooters">';
|
||||
echo ' <form method="post" action="server_replication.php" >';
|
||||
echo PMA_generate_common_hidden_inputs('', '');
|
||||
echo ' <input type="submit" value="' . __('Go') . '" id="goButton" />';
|
||||
echo ' </form>';
|
||||
echo '</fieldset>';
|
||||
|
||||
$response->addHTML(PMA_getHtmlForMasterConfiguration());
|
||||
exit;
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
$response->addHTML('</div>');
|
||||
|
||||
if (! isset($GLOBALS['repl_clear_scr'])) {
|
||||
if (! isset($_REQUEST['repl_clear_scr'])) {
|
||||
// Render the 'Slave configuration' section
|
||||
echo '<fieldset>';
|
||||
echo '<legend>' . __('Slave replication') . '</legend>';
|
||||
if ($server_slave_status) {
|
||||
echo '<div id="slave_configuration_gui">';
|
||||
|
||||
$_url_params = $GLOBALS['url_params'];
|
||||
$_url_params['sr_take_action'] = true;
|
||||
$_url_params['sr_slave_server_control'] = true;
|
||||
|
||||
if ($server_slave_replication[0]['Slave_IO_Running'] == 'No') {
|
||||
$_url_params['sr_slave_action'] = 'start';
|
||||
} else {
|
||||
$_url_params['sr_slave_action'] = 'stop';
|
||||
}
|
||||
|
||||
$_url_params['sr_slave_control_parm'] = 'IO_THREAD';
|
||||
$slave_control_io_link = 'server_replication.php' . PMA_generate_common_url($_url_params);
|
||||
|
||||
if ($server_slave_replication[0]['Slave_SQL_Running'] == 'No') {
|
||||
$_url_params['sr_slave_action'] = 'start';
|
||||
} else {
|
||||
$_url_params['sr_slave_action'] = 'stop';
|
||||
}
|
||||
|
||||
$_url_params['sr_slave_control_parm'] = 'SQL_THREAD';
|
||||
$slave_control_sql_link = 'server_replication.php' . PMA_generate_common_url($_url_params);
|
||||
|
||||
if ($server_slave_replication[0]['Slave_IO_Running'] == 'No'
|
||||
|| $server_slave_replication[0]['Slave_SQL_Running'] == 'No'
|
||||
) {
|
||||
$_url_params['sr_slave_action'] = 'start';
|
||||
} else {
|
||||
$_url_params['sr_slave_action'] = 'stop';
|
||||
}
|
||||
|
||||
$_url_params['sr_slave_control_parm'] = null;
|
||||
$slave_control_full_link = 'server_replication.php' . PMA_generate_common_url($_url_params);
|
||||
|
||||
$_url_params['sr_slave_action'] = 'reset';
|
||||
$slave_control_reset_link = 'server_replication.php' . PMA_generate_common_url($_url_params);
|
||||
|
||||
$_url_params = $GLOBALS['url_params'];
|
||||
$_url_params['sr_slave_skip_error'] = true;
|
||||
$slave_skip_error_link = 'server_replication.php' . PMA_generate_common_url($_url_params);
|
||||
|
||||
if ($server_slave_replication[0]['Slave_SQL_Running'] == 'No') {
|
||||
PMA_Message::error(__('Slave SQL Thread not running!'))->display();
|
||||
}
|
||||
if ($server_slave_replication[0]['Slave_IO_Running'] == 'No') {
|
||||
PMA_Message::error(__('Slave IO Thread not running!'))->display();
|
||||
}
|
||||
|
||||
$_url_params = $GLOBALS['url_params'];
|
||||
$_url_params['sl_configure'] = true;
|
||||
$_url_params['repl_clear_scr'] = true;
|
||||
|
||||
$reconfiguremaster_link = 'server_replication.php' . PMA_generate_common_url($_url_params);
|
||||
|
||||
echo __('Server is configured as slave in a replication process. Would you like to:');
|
||||
echo '<br />';
|
||||
echo '<ul>';
|
||||
echo ' <li><a href="#" id="slave_status_href">' . __('See slave status table') . '</a>';
|
||||
PMA_replication_print_status_table('slave', true, false);
|
||||
echo ' </li>';
|
||||
|
||||
echo ' <li><a href="#" id="slave_control_href">' . __('Control slave:') . '</a>';
|
||||
echo ' <div id="slave_control_gui" style="display: none">';
|
||||
echo ' <ul>';
|
||||
echo ' <li><a href="'. $slave_control_full_link . '">' . (($server_slave_replication[0]['Slave_IO_Running'] == 'No' || $server_slave_replication[0]['Slave_SQL_Running'] == 'No') ? __('Full start') : __('Full stop')) . ' </a></li>';
|
||||
echo ' <li><a href="'. $slave_control_reset_link . '">' . __('Reset slave') . '</a></li>';
|
||||
if ($server_slave_replication[0]['Slave_SQL_Running'] == 'No') {
|
||||
echo ' <li><a href="' . $slave_control_sql_link . '">' . __('Start SQL Thread only') . '</a></li>';
|
||||
} else {
|
||||
echo ' <li><a href="' . $slave_control_sql_link . '">' . __('Stop SQL Thread only') . '</a></li>';
|
||||
}
|
||||
if ($server_slave_replication[0]['Slave_IO_Running'] == 'No') {
|
||||
echo ' <li><a href="' . $slave_control_io_link . '">' . __('Start IO Thread only') . '</a></li>';
|
||||
} else {
|
||||
echo ' <li><a href="' . $slave_control_io_link . '">' . __('Stop IO Thread only') . '</a></li>';
|
||||
}
|
||||
echo ' </ul>';
|
||||
echo ' </div>';
|
||||
echo ' </li>';
|
||||
echo ' <li><a href="#" id="slave_errormanagement_href">' . __('Error management:') . '</a>';
|
||||
echo ' <div id="slave_errormanagement_gui" style="display: none">';
|
||||
PMA_Message::error(__('Skipping errors might lead into unsynchronized master and slave!'))->display();
|
||||
echo ' <ul>';
|
||||
echo ' <li><a href="' . $slave_skip_error_link . '">' . __('Skip current error') . '</a></li>';
|
||||
echo ' <li>' . __('Skip next');
|
||||
echo ' <form method="post" action="server_replication.php">';
|
||||
echo PMA_generate_common_hidden_inputs('', '');
|
||||
echo ' <input type="text" name="sr_skip_errors_count" value="1" style="width: 30px" />' . __('errors.');
|
||||
echo ' <input type="submit" name="sr_slave_skip_error" value="' . __('Go') . '" />';
|
||||
echo ' <input type="hidden" name="sr_take_action" value="1" />';
|
||||
echo ' </form></li>';
|
||||
echo ' </ul>';
|
||||
echo ' </div>';
|
||||
echo ' </li>';
|
||||
echo ' <li><a href="' . $reconfiguremaster_link . '">' . __('Change or reconfigure master server') . '</a></li>';
|
||||
echo '</ul>';
|
||||
echo '</div>';
|
||||
|
||||
} elseif (! isset($GLOBALS['sl_configure'])) {
|
||||
$_url_params = $GLOBALS['url_params'];
|
||||
$_url_params['sl_configure'] = true;
|
||||
$_url_params['repl_clear_scr'] = true;
|
||||
|
||||
echo sprintf(__('This server is not configured as slave in a replication process. Would you like to <a href="%s">configure</a> it?'), 'server_replication.php' . PMA_generate_common_url($_url_params));
|
||||
}
|
||||
echo '</fieldset>';
|
||||
$response->addHTML(PMA_getHtmlForSlaveConfiguration($server_slave_status, $server_slave_replication));
|
||||
}
|
||||
if (isset($GLOBALS['sl_configure'])) {
|
||||
PMA_replication_gui_changemaster("slave_changemaster");
|
||||
if (isset($_REQUEST['sl_configure'])) {
|
||||
$response->addHTML(PMA_getHtmlForReplicationChangeMaster("slave_changemaster"));
|
||||
}
|
||||
?>
|
||||
|
||||
@ -141,7 +141,7 @@ function PMA_getServerStateGeneralInfoHtml($ServerStatusData)
|
||||
$retval .= '</a></h3>';
|
||||
foreach ($GLOBALS['replication_types'] as $type) {
|
||||
if (isset(${"server_{$type}_status"}) && ${"server_{$type}_status"}) {
|
||||
PMA_replication_print_status_table($type);
|
||||
$retval .= PMA_getHtmlForReplicationStatusTable($type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user