';
foreach ($GLOBALS['pma']->databases as $current_db) {
if ($GLOBALS['dbi']->isSystemSchema($current_db)) {
continue;
}
if (! empty($selectall) || (isset($tmp_select) && strpos(' ' . $tmp_select, '|' . $current_db . '|'))) {
$is_selected = ' selected="selected"';
} else {
$is_selected = '';
}
$current_db = htmlspecialchars($current_db);
$multi_values .= ' ';
} // end while
$multi_values .= '';
$multi_values .= ' ' . __('Uncheck All') . '';
return $multi_values;
}
/**
* prints out code for changing master
*
* @param String $submitname - submit button name
*
* @return void
*/
function PMA_replication_gui_changemaster($submitname)
{
list($username_length, $hostname_length) = PMA_replication_get_username_hostname_length();
echo '
';
}
/**
* This function prints out 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
*/
function PMA_replication_print_status_table($type, $hidden = false, $title = true)
{
global ${"{$type}_variables"};
global ${"{$type}_variables_alerts"};
global ${"{$type}_variables_oks"};
global ${"server_{$type}_replication"};
global ${"strReplicationStatus_{$type}"};
// 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
// [ERROR] Error reading packet from server: Misconfigured master - server id was not set ( server_errno=1236)
// [ERROR] Got fatal error 1236: 'Misconfigured master - server id was not set' from master when reading data from binary log
//
//$server_id = $GLOBALS['dbi']->fetchValue("SHOW VARIABLES LIKE 'server_id'", 0, 1);
echo '
';
// 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 '';
} elseif (isset(${"{$type}_variables_oks"}[$variable])
&& ${"{$type}_variables_oks"}[$variable] == ${"server_{$type}_replication"}[0][$variable]
) {
echo '';
} else {
echo '';
}
// allow wrapping long table lists into multiple lines
static $variables_wrap = array(
'Replicate_Do_DB', 'Replicate_Ignore_DB',
'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]);
} else {
echo ${"server_{$type}_replication"}[0][$variable];
}
echo '';
echo '
';
echo '
';
$odd_row = ! $odd_row;
}
echo ' ';
echo '
';
echo ' ';
echo '
';
}
/**
* Prints 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)
{
// Fetch data
$data = $GLOBALS['dbi']->fetchResult('SHOW SLAVE HOSTS', null, null);
echo ' ';
echo '
';
echo ' ';
PMA_Message::notice(__('Only slaves started with the --report-host=host_name option are visible in this list.'))->display();
echo ' ';
echo '
';
}
/**
* get the correct username and hostname lengths for this MySQL server
*
* @return array username length, hostname length
*/
function PMA_replication_get_username_hostname_length()
{
$fields_info = $GLOBALS['dbi']->getColumns('mysql', 'user');
$username_length = 16;
$hostname_length = 41;
foreach ($fields_info as $val) {
if ($val['Field'] == 'User') {
strtok($val['Type'], '()');
$v = strtok('()');
if (is_int($v)) {
$username_length = $v;
}
} elseif ($val['Field'] == 'Host') {
strtok($val['Type'], '()');
$v = strtok('()');
if (is_int($v)) {
$hostname_length = $v;
}
}
}
return array($username_length, $hostname_length);
}
/**
* Print code to add a replication slave user to the master
*
* @return void
*/
function PMA_replication_gui_master_addslaveuser()
{
list($username_length, $hostname_length) = PMA_replication_get_username_hostname_length();
if (isset($GLOBALS['username']) && strlen($GLOBALS['username']) === 0) {
$GLOBALS['pred_username'] = 'any';
}
echo '