diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 3f016d548..a43e39772 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -2733,11 +2733,13 @@ function PMA_getTitleForTarget($target) { function PMA_js_mootools_domready($code, $print=true) { $out = ''; - $out .= ''."\n"; + $out .= '});'; + $out .= '// ]]>'; + $out .= ''; if ($print) echo $out; diff --git a/libraries/replication_gui.lib.php b/libraries/replication_gui.lib.php index 0e2f722ef..e52235a50 100644 --- a/libraries/replication_gui.lib.php +++ b/libraries/replication_gui.lib.php @@ -14,52 +14,52 @@ $jscode['master_replication'] = 'divShowHideFunc(\'master_status_href\', \'repli // Add JS events to generate example my.cnf config lines $jscode['configure_master'] = - 'var c_output = "";'."\n". - 'var c_text = "server-id='.$serverid.'
log-bin=mysql-bin
log-error=mysql-bin.err
";'."\n". - 'var c_ignore = "binlog_ignore_db=";'."\n". - 'var c_do = "binlog_do_db=";'."\n". + 'var c_output = "";' . "\n" . + 'var c_text = "server-id=' . $serverid . '
log-bin=mysql-bin
log-error=mysql-bin.err
";' . "\n" . + 'var c_ignore = "binlog_ignore_db=";' . "\n" . + 'var c_do = "binlog_do_db=";' . "\n" . - '$(\'db_reset_href\').addEvent(\'click\', function() {'."\n". - ' $(\'db_select\').getSelected().each(function(el) {'."\n". - ' el.selected = false;'."\n". - ' });'."\n". - ' $(\'rep\').set(\'html\', c_text);'."\n". - '});'."\n". - '$(\'db_type\').addEvent(\'change\',function() {'."\n". - ' if ($(\'db_type\').getSelected().get(\'value\')=="all")'."\n". - ' $(\'rep\').set(\'html\', c_text+c_ignore+c_output);'."\n". - ' else'."\n". - ' $(\'rep\').set(\'html\', c_text+c_do+c_output);'."\n". - '});'."\n". + '$(\'db_reset_href\').addEvent(\'click\', function() {' . "\n" . + ' $(\'db_select\').getSelected().each(function(el) {' . "\n" . + ' el.selected = false;' . "\n" . + ' });' . "\n" . + ' $(\'rep\').set(\'html\', c_text);' . "\n" . + '});' . "\n" . + '$(\'db_type\').addEvent(\'change\',function() {' . "\n" . + ' if ($(\'db_type\').getSelected().get(\'value\')=="all")' . "\n" . + ' $(\'rep\').set(\'html\', c_text+c_ignore+c_output);' . "\n" . + ' else' . "\n" . + ' $(\'rep\').set(\'html\', c_text+c_do+c_output);' . "\n" . + '});' . "\n" . - '$(\'db_select\').addEvent(\'change\',function() {'."\n". - ' var count = 0;'."\n". + '$(\'db_select\').addEvent(\'change\',function() {' . "\n" . + ' var count = 0;' . "\n" . - ' $(\'db_select\').getSelected().each(function(el) { '."\n". - ' if (count==0)'."\n". - ' c_output = el.get(\'value\');'."\n". - ' else'."\n". - ' c_output = c_output + \',\' +el.get(\'value\');'."\n". + ' $(\'db_select\').getSelected().each(function(el) { ' . "\n" . + ' if (count==0)' . "\n" . + ' c_output = el.get(\'value\');' . "\n" . + ' else' . "\n" . + ' c_output = c_output + \',\' +el.get(\'value\');' . "\n" . - ' count=count+1;'."\n". + ' count=count+1;' . "\n" . - ' if ($(\'db_select\').getSelected().length==count) {'."\n". - ' if ($(\'db_type\').getSelected().get(\'value\')=="all")'."\n". - ' $(\'rep\').set(\'html\', c_text+c_ignore+c_output);'."\n". - ' else'."\n". - ' $(\'rep\').set(\'html\', c_text+c_do+c_output);'."\n". - ' count = 0;'."\n". - ' }'."\n". - ' });'."\n". - '});'."\n"; + ' if ($(\'db_select\').getSelected().length==count) {' . "\n" . + ' if ($(\'db_type\').getSelected().get(\'value\')=="all")' . "\n" . + ' $(\'rep\').set(\'html\', c_text+c_ignore+c_output);' . "\n" . + ' else' . "\n" . + ' $(\'rep\').set(\'html\', c_text+c_do+c_output);' . "\n" . + ' count = 0;' . "\n" . + ' }' . "\n" . + ' });' . "\n" . + '});' . "\n"; $jscode['slave_control'] = - 'divShowHideFunc(\'slave_status_href\', \'replication_slave_section\');'."\n". - 'divShowHideFunc(\'slave_control_href\', \'slave_control_gui\');'."\n". - 'divShowHideFunc(\'slave_errormanagement_href\',\'slave_errormanagement_gui\'); '."\n"; + 'divShowHideFunc(\'slave_status_href\', \'replication_slave_section\');' . "\n" . + 'divShowHideFunc(\'slave_control_href\', \'slave_control_gui\');' . "\n" . + 'divShowHideFunc(\'slave_errormanagement_href\',\'slave_errormanagement_gui\'); ' . "\n"; $jscode['slave_control_sync'] = - 'divShowHideFunc(\'slave_synchronization_href\', \'slave_synchronization_gui\');'."\n"; + 'divShowHideFunc(\'slave_synchronization_href\', \'slave_synchronization_gui\');' . "\n"; /** * returns code for selecting databases @@ -70,19 +70,17 @@ function PMA_replication_db_multibox() { $multi_values = ''; $multi_values .= ''; $multi_values .= '
' . $GLOBALS['strUncheckAll'] . ''; @@ -96,38 +94,37 @@ function PMA_replication_db_multibox() */ function PMA_replication_gui_changemaster($submitname) { - global $username_length; - global $hostname_length; - echo '
'."\n"; + list($username_length, $hostname_length) = PMA_replication_get_username_hostname_length(); + + echo ''; echo PMA_generate_common_hidden_inputs('', ''); - echo '
'."\n"; - echo ' ' . $GLOBALS['strReplicationSlaveConfiguration']. ' - ' . $GLOBALS['strReplicationSlaveChangeMaster'] . ''."\n"; - echo $GLOBALS['strSlaveConfigure'].'
'."\n"; - echo '
server-id='.time().'
'."\n"; - echo '
'."\n"; - echo ' '."\n"; - echo ' '."\n"; - echo '
'."\n"; - echo '
'."\n"; - echo ' '."\n"; - echo ' '."\n"; - echo '
'."\n"; - echo '
'."\n"; - echo ' '."\n"; - echo ' '."\n"; - echo '
'."\n"; - echo '
'."\n"; - echo ' '."\n"; - echo ' '."\n"; - echo '
'."\n"; - echo '
'."\n"; - echo ' '."\n"; - echo '
'."\n"; - + echo '
'; + echo ' ' . $GLOBALS['strReplicationSlaveConfiguration'] . ' - ' . $GLOBALS['strReplicationSlaveChangeMaster'] . ''; + echo $GLOBALS['strSlaveConfigure'] . '
'; + echo '
server-id=' . time() . '
'; + echo '
'; + echo ' '; + echo ' '; + echo '
'; + echo '
'; + echo ' '; + echo ' '; + echo '
'; + echo '
'; + echo ' '; + echo ' '; + echo '
'; + echo '
'; + echo ' '; + echo ' '; + echo '
'; + echo '
'; + echo ' '; + echo ''; } /** @@ -151,58 +148,58 @@ function PMA_replication_print_status_table($type, $hidden = false, $title = tru // //$server_id = PMA_DBI_fetch_value("SHOW VARIABLES LIKE 'server_id'", 0, 1); - echo '
'."\n"; + echo '
'; if ($title) { - echo '

'.${"strReplicationStatus_{$type}"} .'

'."\n"; + echo '

' . ${"strReplicationStatus_{$type}"} . '

'; } else { - echo '
'."\n"; + echo '
'; } - echo ' '."\n"; - echo ' '."\n"; - echo ' '."\n"; - echo ' '."\n"; - echo ' '."\n"; - echo ' '."\n"; - echo ' '."\n"; - echo ' '."\n"; + echo '
'. $GLOBALS['strVar'] .''. $GLOBALS['strValue'] .'
'; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; $odd_row = true; foreach (${"{$type}_variables"} as $variable) { - echo ' '."\n"; - echo ' '."\n"; - echo ' '; + echo ' '; + echo ' '."\n"; - echo ' '."\n"; + echo ' '; + echo ' '; - $odd_row = !$odd_row; + $odd_row = ! $odd_row; } - echo ' '."\n"; - echo '
' . $GLOBALS['strVar'] . '' . $GLOBALS['strValue'] . '
'."\n"; - echo $variable."\n"; - echo ' '."\n"; + echo '
'; + echo $variable; + 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 ''."\n"; + echo ''; } elseif (isset(${"{$type}_variables_oks"}[$variable]) && ${"{$type}_variables_oks"}[$variable] == ${"server_{$type}_replication"}[0][$variable] ) { - echo ''."\n"; + echo ''; } else { - echo ''."\n"; + echo ''; } echo ${"server_{$type}_replication"}[0][$variable]; - echo ''."\n"; + echo ''; - echo '
'."\n"; - echo '
'."\n"; - echo '
'."\n"; + echo ' '; + echo ' '; + echo '
'; + echo '
'; } @@ -216,41 +213,43 @@ function PMA_replication_print_slaves_table($hidden = false) { // Fetch data $data = PMA_DBI_fetch_result('SHOW SLAVE HOSTS', null, null); - echo '
' . "\n"; - echo '
' . "\n"; - echo ' ' . "\n"; - echo ' ' . "\n"; - echo ' '."\n"; - echo ' ' . "\n"; - echo ' ' . "\n"; - echo ' '."\n"; - echo ' '."\n"; - echo ' '."\n"; + echo '
'; + echo '
'; + echo '
' . $GLOBALS['strBinLogServerId'] . '' . $GLOBALS['strHost'] . '
'; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; $odd_row = true; foreach ($data as $slave) { - echo ' ' . "\n"; - echo ' ' . "\n"; - echo ' ' . "\n"; - echo ' ' . "\n"; + echo ' '; + echo ' '; + echo ' '; + echo ' '; - $odd_row = !$odd_row; + $odd_row = ! $odd_row; } - echo ' '."\n"; - echo '
' . $GLOBALS['strBinLogServerId'] . '' . $GLOBALS['strHost'] . '
' . $slave['Server_id'] . '' . $slave['Host'] . '
' . $slave['Server_id'] . '' . $slave['Host'] . '
'."\n"; - echo '
'."\n"; + echo ' '; + echo ' '; + echo '
'; PMA_Message::notice('strReplicationShowConnectedSlavesNote')->display(); - echo '
'."\n"; - echo '
'."\n"; - + echo '
'; + echo ' '; } - /** - * Print code to add a replication slave user to the master + * get the correct username and hostname lengths for this MySQL server + * + * @uses strtok() + * @return array username length, hostname length */ -function PMA_replication_gui_master_addslaveuser() { + +function PMA_replication_get_username_hostname_length() { $fields_info = PMA_DBI_get_fields('mysql', 'user'); $username_length = 16; $hostname_length = 41; @@ -269,33 +268,41 @@ function PMA_replication_gui_master_addslaveuser() { } } } - unset($fields_info); + return array($username_length, $hostname_length); +} + +/** + * Print code to add a replication slave user to the master + */ +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 '
'."\n"; - echo '
'."\n"; + echo '
'; + echo ''; echo PMA_generate_common_hidden_inputs('', ''); - echo '
' . "\n" - . ''.$GLOBALS['strReplicationAddSlaveUser'].'' . "\n" - . '' . "\n" - . '' . "\n" - . ''. "\n" - . ''. "\n" - . '' . "\n" - . ''. "\n" - . '
' . "\n" - . '' . "\n" - . '' . "\n" - . ' ' . "\n" - . '' . "\n" + echo '
' + . ''.$GLOBALS['strReplicationAddSlaveUser'].'' + . '' + . '' + . '' + . '' + . '' + . '' + . '
' + . '' + . '' + . ' ' + . '' . '' . "\n" - . '
' . "\n" - . '
' . "\n" - . '' . "\n" - . '' . "\n" - . ' ' . $GLOBALS['strAnyHost'] - . '' . "\n" + . '' . ' ' . "\n"; + . ''; if (!empty($thishost)) { echo ' ' . "\n"; + . ''; } unset($thishost); echo ' ' . "\n" + . '' . ' ' . "\n" - . ' ' . "\n" - . '' . "\n" + . '>' . $GLOBALS['strUseTextField'] . ':' + . ' ' + . '' . '' . "\n" + . '" onchange="pred_hostname.value = \'userdefined\';" />' . PMA_showHint($GLOBALS['strHostTableExplanation']) - . '
' . "\n" - . '
' . "\n" - . '' . "\n" - . '' . "\n" + . '
' + . '
' + . '' + . '' . ' ' . "\n" - . '' . "\n" - . '' . "\n" - . '
' . "\n" - . '
' . "\n" - . '' . "\n" - . ' ' . "\n" - . '' . "\n" - . '
' . "\n" - . '
' . "\n" - . '' . "\n" - . '' . "\n" - . ' ' . "\n" - . '' . "\n" - . '' . "\n" - . '
' . "\n" - . '
' . "\n"; - echo '' . "\n"; - echo ''."\n"; - echo '
'."\n"; + echo '>' . $GLOBALS['strNoPassword'] . '' + . ' ' + . ' ' + . '' + . '' + . '
' + . '
' + . '' + . ' ' + . '' + . '
' + . '
' + . '' + . '' + . ' ' + . '' + . '' + . '
' + . ''; + echo ''; + echo ''; + echo '
'"; } ?> - diff --git a/server_replication.php b/server_replication.php index 13124bac0..8a7a92218 100644 --- a/server_replication.php +++ b/server_replication.php @@ -229,7 +229,7 @@ if (isset($GLOBALS['mr_configure'])) { echo PMA_replication_db_multibox(); echo '

'; echo $GLOBALS['strReplicationAddLines'] . '
'; - echo '
server-id='. $serverid . '
log-bin=mysql-bin
log-error=mysql-bin.err
'; + echo '
server-id='. $serverid . '
log-bin=mysql-bin
log-error=mysql-bin.err
'; echo $GLOBALS['strReplicationRestartServer']; echo ''; echo '
';