/**
 * 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>';
    /**
     * check for multi-master replication functionality
     */
    $server_slave_multi_replication = $GLOBALS['dbi']->fetchResult('SHOW ALL SLAVES STATUS');
    if ($server_slave_multi_replication) {
        $html .= __('Master connection:');
        $html .= '<form method="get" action="server_replication.php">';
        $html .= PMA_URL_getHiddenInputs($GLOBALS['url_params']);
        $html .= ' <select name="master_connection">';
        $html .= '<option value="">' . __('Default') . '</option>';
        foreach ($server_slave_multi_replication as $server) {
            $html .= '<option' . (isset($_REQUEST['master_connection']) && $_REQUEST['master_connection'] == $server['Connection_name'] ? ' selected="selected"' : '') . '>' . $server['Connection_name'] . '</option>';
        }
        $html .= '</select>';
        $html .= ' <input type="submit" value="' . __('Go') . '" id="goButton" />';
        $html .= '</form>';
        $html .= '<br /><br />';
    }
    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_URL_getCommon($_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_URL_getCommon($_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_URL_getCommon($_url_params);
        $_url_params['sr_slave_action'] = 'reset';
        $slave_control_reset_link = 'server_replication.php' . PMA_URL_getCommon($_url_params);
        $_url_params = $GLOBALS['url_params'];
        $_url_params['sr_take_action'] = true;
        $_url_params['sr_slave_skip_error'] = true;
        $slave_skip_error_link = 'server_replication.php' . PMA_URL_getCommon($_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_URL_getCommon($_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">';
        $html .= __('See slave status table') . '</a>';
        $html .= PMA_getHtmlForReplicationStatusTable('slave', true, false);
        $html .= ' </li>';
        $html .= ' <li><a href="#" id="slave_control_href">';
        $html .= __('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_URL_getCommon($_url_params));
    }
    $html .= '</fieldset>';
    return $html;
}
Example #2
0
/**
 * 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_URL_getCommon($_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_URL_getCommon($_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_URL_getCommon($_url_params);
        $_url_params['sr_slave_action'] = 'reset';
        $slave_control_reset_link = 'server_replication.php' . PMA_URL_getCommon($_url_params);
        $_url_params = $GLOBALS['url_params'];
        $_url_params['sr_slave_skip_error'] = true;
        $slave_skip_error_link = 'server_replication.php' . PMA_URL_getCommon($_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_URL_getCommon($_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">';
        $html .= __('See slave status table') . '</a>';
        $html .= PMA_getHtmlForReplicationStatusTable('slave', true, false);
        $html .= ' </li>';
        $html .= ' <li><a href="#" id="slave_control_href">';
        $html .= __('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_URL_getCommon($_url_params));
    }
    $html .= '</fieldset>';
    return $html;
}