*Fixed bug with different port than 3306
*Fixed support for other server than localhost *Added support for sockets *Fixed GUI bugs - strings (localization), table, fieldset... *new PNG transparent icon.16x16
This commit is contained in:
@@ -568,18 +568,42 @@ function ApplySelectedChanges(token)
|
||||
*/
|
||||
function validateConnection(form_name, form_obj)
|
||||
{
|
||||
var check = true;
|
||||
var src_hostfilled = true;
|
||||
var trg_hostfilled = true;
|
||||
|
||||
for (var i=1; i<form_name.elements.length; i++)
|
||||
{
|
||||
// All the text fields are checked excluding the port field because the default port can be used.
|
||||
if ((form_name.elements[i].type == 'text') && (form_name.elements[i].name != 'src_port') && (form_name.elements[i].name != 'trg_port')) {
|
||||
var check = emptyFormElements(form_obj, form_name.elements[i].name);
|
||||
check = true;
|
||||
check = emptyFormElements(form_obj, form_name.elements[i].name);
|
||||
|
||||
if (check==false) {
|
||||
element = form_name.elements[i].name;
|
||||
if (form_name.elements[i].name == 'src_host') {
|
||||
src_hostfilled = false;
|
||||
continue;
|
||||
}
|
||||
if (check === false) {
|
||||
// alert('Password field can be empty.');
|
||||
return false;
|
||||
if (form_name.elements[i].name == 'trg_host') {
|
||||
trg_hostfilled = false;
|
||||
continue;
|
||||
}
|
||||
if ((form_name.elements[i].name == 'src_socket' && src_hostfilled==false) || (form_name.elements[i].name == 'trg_socket' && trg_hostfilled==false))
|
||||
break;
|
||||
else
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (!check) {
|
||||
form_obj.reset();
|
||||
element.select();
|
||||
alert(PMA_messages['strFormEmpty']);
|
||||
element.focus();
|
||||
}
|
||||
return check;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -610,8 +634,6 @@ function emptyCheckTheField(theForm, theFieldName)
|
||||
|
||||
|
||||
/**
|
||||
* Displays an error message if an element of a form hasn't been completed and
|
||||
* should be
|
||||
*
|
||||
* @param object the form
|
||||
* @param string the name of the form field to put the focus on
|
||||
@@ -623,15 +645,8 @@ function emptyFormElements(theForm, theFieldName)
|
||||
var theField = theForm.elements[theFieldName];
|
||||
var isEmpty = emptyCheckTheField(theForm, theFieldName);
|
||||
|
||||
if (isEmpty) {
|
||||
theForm.reset();
|
||||
theField.select();
|
||||
alert(PMA_messages['strFormEmpty']);
|
||||
theField.focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return isEmpty;
|
||||
} // end of the 'emptyFormElements()' function
|
||||
|
||||
|
||||
|
@@ -1560,4 +1560,10 @@ $strYes = 'Yes';
|
||||
$strZeroRemovesTheLimit = 'Note: Setting these options to 0 (zero) removes the limit.';
|
||||
$strZip = '"zipped"';
|
||||
|
||||
// TOMS - sync
|
||||
$strPort = 'Port';
|
||||
$strSocket = 'Socket';
|
||||
$strCouldNotConnectSource = 'Could not connect to the source';
|
||||
$strCouldNotConnectTarget = 'Could not connect to the target';
|
||||
$strDatabaseNotExisting = '\'%s\' database does not exist.';
|
||||
?>
|
||||
|
@@ -21,18 +21,18 @@ if (! defined('PMA_MYSQL_CLIENT_API')) {
|
||||
unset($client_api);
|
||||
}
|
||||
|
||||
function PMA_DBI_real_connect($server, $user, $password, $client_flags)
|
||||
function PMA_DBI_real_connect($server, $user, $password, $client_flags, $persistant=false)
|
||||
{
|
||||
global $cfg;
|
||||
|
||||
if (empty($client_flags)) {
|
||||
if ($cfg['PersistentConnections']) {
|
||||
if ($cfg['PersistentConnections'] || $persistant) {
|
||||
$link = @mysql_pconnect($server, $user, $password);
|
||||
} else {
|
||||
$link = @mysql_connect($server, $user, $password);
|
||||
}
|
||||
} else {
|
||||
if ($cfg['PersistentConnections']) {
|
||||
if ($cfg['PersistentConnections'] || $persistant) {
|
||||
$link = @mysql_pconnect($server, $user, $password, $client_flags);
|
||||
} else {
|
||||
$link = @mysql_connect($server, $user, $password, false, $client_flags);
|
||||
@@ -41,23 +41,40 @@ function PMA_DBI_real_connect($server, $user, $password, $client_flags)
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
function PMA_DBI_connect($user, $password, $is_controluser = false)
|
||||
/**
|
||||
* @param string $user mysql user name
|
||||
* @param string $password mysql user password
|
||||
* @param boolean $is_controluser
|
||||
* @param array $server host/port/socket/persistant
|
||||
* @return mixed false on error or a mysqli object on success
|
||||
*/
|
||||
function PMA_DBI_connect($user, $password, $is_controluser = false, $server = null)
|
||||
{
|
||||
global $cfg, $php_errormsg;
|
||||
|
||||
if ($server) {
|
||||
$server_port = (empty($server['port']))
|
||||
? ''
|
||||
: ':' . (int)$server['port'];
|
||||
$server_socket = (empty($server['socket']))
|
||||
? ''
|
||||
: ':' . $server['socket'];
|
||||
$server_persistant = (empty($server['persistant']))
|
||||
? false
|
||||
: true;
|
||||
} else {
|
||||
$server_port = (empty($cfg['Server']['port']))
|
||||
? ''
|
||||
: ':' . $cfg['Server']['port'];
|
||||
: ':' . (int)$cfg['Server']['port'];
|
||||
$server_socket = (empty($cfg['Server']['socket']))
|
||||
? ''
|
||||
: ':' . $cfg['Server']['socket'];
|
||||
}
|
||||
|
||||
if (strtolower($cfg['Server']['connect_type']) == 'tcp') {
|
||||
$cfg['Server']['socket'] = '';
|
||||
}
|
||||
|
||||
$server_socket = (empty($cfg['Server']['socket']))
|
||||
? ''
|
||||
: ':' . $cfg['Server']['socket'];
|
||||
|
||||
$client_flags = 0;
|
||||
|
||||
// always use CLIENT_LOCAL_FILES as defined in mysql_com.h
|
||||
@@ -75,13 +92,19 @@ function PMA_DBI_connect($user, $password, $is_controluser = false)
|
||||
$client_flags |= MYSQL_CLIENT_SSL;
|
||||
}
|
||||
|
||||
if (!$server) {
|
||||
$link = PMA_DBI_real_connect($cfg['Server']['host'] . $server_port . $server_socket, $user, $password, empty($client_flags) ? NULL : $client_flags);
|
||||
|
||||
// Retry with empty password if we're allowed to
|
||||
if (empty($link) && $cfg['Server']['nopassword'] && !$is_controluser) {
|
||||
$link = PMA_DBI_real_connect($cfg['Server']['host'] . $server_port . $server_socket, $user, '', empty($client_flags) ? NULL : $client_flags);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!isset($server['host']))
|
||||
$link = PMA_DBI_real_connect($server_socket, $user, $password, NULL, $server_persistant);
|
||||
else
|
||||
$link = PMA_DBI_real_connect($server['host'] . $server_port . $server_socket, $user, $password, NULL, $server_persistant);
|
||||
}
|
||||
if (empty($link)) {
|
||||
if ($is_controluser) {
|
||||
trigger_error($GLOBALS['strControluserFailed'], E_USER_WARNING);
|
||||
@@ -90,7 +113,7 @@ function PMA_DBI_connect($user, $password, $is_controluser = false)
|
||||
PMA_log_user($user, 'mysql-denied');
|
||||
PMA_auth_fails();
|
||||
} // end if
|
||||
|
||||
if (!$server)
|
||||
PMA_DBI_postConnect($link, $is_controluser);
|
||||
|
||||
return $link;
|
||||
@@ -173,7 +196,6 @@ function PMA_DBI_try_query($query, $link = null, $options = 0)
|
||||
}
|
||||
$_SESSION['debug']['queries'][$hash]['trace'][] = $trace;
|
||||
}
|
||||
|
||||
if($r != FALSE and PMA_Tracker::isActive() == TRUE )
|
||||
PMA_Tracker::handleQuery($query);
|
||||
|
||||
|
@@ -54,22 +54,37 @@ if (! defined('MYSQLI_TYPE_BIT')) {
|
||||
* @param string $user mysql user name
|
||||
* @param string $password mysql user password
|
||||
* @param boolean $is_controluser
|
||||
* @param array $server host/port/socket
|
||||
* @return mixed false on error or a mysqli object on success
|
||||
*/
|
||||
function PMA_DBI_connect($user, $password, $is_controluser = false)
|
||||
function PMA_DBI_connect($user, $password, $is_controluser = false, $server = null)
|
||||
{
|
||||
if ($server) {
|
||||
$server_port = (empty($server['port']))
|
||||
? ''
|
||||
: (int)$server['port'];
|
||||
$server_socket = (empty($server['socket']))
|
||||
? ''
|
||||
: $server['socket'];
|
||||
$server['host'] = (empty($server['host']))
|
||||
? 'localhost'
|
||||
: $server['host'];
|
||||
} else {
|
||||
$server_port = (empty($GLOBALS['cfg']['Server']['port']))
|
||||
? false
|
||||
: (int) $GLOBALS['cfg']['Server']['port'];
|
||||
$server_socket = (empty($GLOBALS['cfg']['Server']['socket']))
|
||||
? null
|
||||
: $GLOBALS['cfg']['Server']['socket'];
|
||||
}
|
||||
|
||||
|
||||
if (strtolower($GLOBALS['cfg']['Server']['connect_type']) == 'tcp') {
|
||||
$GLOBALS['cfg']['Server']['socket'] = '';
|
||||
}
|
||||
|
||||
// NULL enables connection to the default socket
|
||||
$server_socket = (empty($GLOBALS['cfg']['Server']['socket']))
|
||||
? null
|
||||
: $GLOBALS['cfg']['Server']['socket'];
|
||||
|
||||
|
||||
$link = mysqli_init();
|
||||
|
||||
@@ -87,12 +102,16 @@ function PMA_DBI_connect($user, $password, $is_controluser = false)
|
||||
$client_flags |= MYSQLI_CLIENT_SSL;
|
||||
}
|
||||
|
||||
if (!$server) {
|
||||
$return_value = @mysqli_real_connect($link, $GLOBALS['cfg']['Server']['host'], $user, $password, false, $server_port, $server_socket, $client_flags);
|
||||
|
||||
// Retry with empty password if we're allowed to
|
||||
if ($return_value == false && isset($cfg['Server']['nopassword']) && $cfg['Server']['nopassword'] && !$is_controluser) {
|
||||
$return_value = @mysqli_real_connect($link, $GLOBALS['cfg']['Server']['host'], $user, '', false, $server_port, $server_socket, $client_flags);
|
||||
}
|
||||
} else {
|
||||
$return_value = @mysqli_real_connect($link, $server['host'], $user, $password, false, $server_port, $server_socket);
|
||||
}
|
||||
|
||||
if ($return_value == false) {
|
||||
if ($is_controluser) {
|
||||
|
@@ -47,31 +47,44 @@ if (isset($_REQUEST['token'])) {
|
||||
*/
|
||||
|
||||
if ((isset($_REQUEST['submit_connect']))) {
|
||||
$src_host = $_REQUEST['src_host'];
|
||||
$src_username = $_REQUEST['src_username'];
|
||||
$src_password = $_REQUEST['src_pass'];
|
||||
$src_port = $_REQUEST['src_port'];
|
||||
$src_db = $_REQUEST['src_db'];
|
||||
$src_connection = @mysql_connect($src_host, $src_username, $src_password);
|
||||
$cons = array ("src", "trg");
|
||||
foreach ($cons as $con) {
|
||||
${"{$con}_host"} = $_REQUEST[$con.'_host'];
|
||||
${"{$con}_username"} = $_REQUEST[$con.'_username'];
|
||||
${"{$con}_password"} = $_REQUEST[$con.'_pass'];
|
||||
${"{$con}_port"} = $_REQUEST[$con.'_port'];
|
||||
${"{$con}_socket"} = $_REQUEST[$con.'_socket'];
|
||||
${"{$con}_db"} = $_REQUEST[$con.'_db'];
|
||||
${"{$con}_url"} = '';
|
||||
|
||||
$trg_host = $_REQUEST['trg_host'];
|
||||
$trg_username = $_REQUEST['trg_username'];
|
||||
$trg_password = $_REQUEST['trg_pass'];
|
||||
$trg_port = $_REQUEST['trg_port'];
|
||||
$trg_db = $_REQUEST['trg_db'];
|
||||
$trg_connection = @mysql_connect($trg_host, $trg_username, $trg_password);
|
||||
if (isset(${"{$con}_socket"}) && !empty(${"{$con}_socket"})) {
|
||||
${"{$con}_url"} = ':'.${"{$con}_socket"};
|
||||
${"{$con}_server"}['socket'] = ${"{$con}_socket"};
|
||||
} else {
|
||||
${"{$con}_url"} = ${"{$con}_host"};
|
||||
${"{$con}_server"}['host'] = ${"{$con}_host"};
|
||||
if (isset(${"{$con}_port"}) && !empty(${"{$con}_port"}) && ((int)${"{$con}_port"}*1)>0) {
|
||||
${"{$con}_url"} .= ':' . ${"{$con}_port"};
|
||||
${"{$con}_server"}['port'] = ${"{$con}_port"};
|
||||
}
|
||||
}
|
||||
|
||||
${"{$con}_connection"} = @mysql_connect(${"{$con}_url"}, ${"{$con}_username"}, ${"{$con}_password"});
|
||||
}
|
||||
unset ($con, $cons);
|
||||
|
||||
if (!($src_connection) || !($trg_connection)) {
|
||||
/**
|
||||
* Displays the connection error string if
|
||||
* connections are not established
|
||||
*/
|
||||
|
||||
echo '<div class="error">' . "\n" ;
|
||||
if(!$src_connection) {
|
||||
echo "Could not connect to the source<br/>";
|
||||
echo $GLOBALS['strCouldNotConnectSource'].'<br />';
|
||||
}
|
||||
if(!$trg_connection){
|
||||
echo "Could not connect to the target";
|
||||
echo $GLOBALS['strCouldNotConnectTarget'];
|
||||
}
|
||||
echo '</div>';
|
||||
unset($_REQUEST['submit_connect']);
|
||||
@@ -81,11 +94,11 @@ if ((isset($_REQUEST['submit_connect']))) {
|
||||
* Creating the link object for both source and target databases and
|
||||
* selecting the source and target databases using these links
|
||||
*/
|
||||
$src_link = PMA_DBI_connect($src_username, $src_password, $is_controluser = false);
|
||||
$src_db_selected = PMA_DBI_select_db($src_db, $src_link);
|
||||
$src_link = PMA_DBI_connect($src_username, $src_password, $is_controluser = false, $src_server);
|
||||
$src_connection = PMA_DBI_select_db($src_db, $src_link);
|
||||
|
||||
$trg_link = PMA_DBI_connect($trg_username, $trg_password, $is_controluser = false);
|
||||
$trg_db_selected = PMA_DBI_select_db($trg_db, $trg_link);
|
||||
$trg_link = PMA_DBI_connect($trg_username, $trg_password, $is_controluser = false, $trg_server);
|
||||
$trg_connection = PMA_DBI_select_db($trg_db, $trg_link);
|
||||
|
||||
if (($src_db_selected != 1) || ($trg_db_selected != 1)) {
|
||||
/**
|
||||
@@ -93,10 +106,10 @@ if ((isset($_REQUEST['submit_connect']))) {
|
||||
*/
|
||||
echo '<div class="error">' . "\n" ;
|
||||
if ($src_db_selected != 1) {
|
||||
echo "'".$src_db."' database does not exists<br/>";
|
||||
echo sprintf($GLOBALS['strDatabaseNotExisting'], $src_db);
|
||||
}
|
||||
if ($trg_db_selected != 1) {
|
||||
echo "'".$trg_db."' database does not exists<br/>";
|
||||
echo sprintf($GLOBALS['strDatabaseNotExisting'], $trg_db);
|
||||
}
|
||||
echo '</div>';
|
||||
unset($_REQUEST['submit_connect']);
|
||||
@@ -203,6 +216,8 @@ if ((isset($_REQUEST['submit_connect']))) {
|
||||
$_SESSION['src_password'] = $src_password;
|
||||
$_SESSION['trg_password'] = $trg_password;
|
||||
$_SESSION['trg_password'] = $trg_password;
|
||||
$_SESSION['src_server'] = $src_server;
|
||||
$_SESSION['trg_server'] = $trg_server;
|
||||
$_SESSION['matching_tables_keys'] = $matching_tables_keys;
|
||||
$_SESSION['uncommon_tables_fields'] = $uncommon_tables_fields;
|
||||
$_SESSION['uncommon_tables_row_count'] = $row_count;
|
||||
@@ -493,6 +508,8 @@ if (isset($_REQUEST['Table_ids'])) {
|
||||
$trg_username = $_SESSION['trg_username'];
|
||||
$src_password = $_SESSION['src_password'];
|
||||
$trg_password = $_SESSION['trg_password'];
|
||||
$src_server = $_SESSION['src_server'];
|
||||
$trg_server = $_SESSION['trg_server'];
|
||||
$uncommon_tables = $_SESSION['uncommon_tables'];
|
||||
$matching_tables = $_SESSION['matching_tables'];
|
||||
$matching_tables_keys = $_SESSION['matching_tables_keys'];
|
||||
@@ -520,8 +537,8 @@ if (isset($_REQUEST['Table_ids'])) {
|
||||
/**
|
||||
* Creating link object for source and target databases
|
||||
*/
|
||||
$src_link = PMA_DBI_connect($src_username, $src_password, $is_controluser = false);
|
||||
$trg_link = PMA_DBI_connect($trg_username, $trg_password, $is_controluser = false);
|
||||
$src_link = PMA_DBI_connect($src_username, $src_password, $is_controluser = false, $src_server);
|
||||
$trg_link = PMA_DBI_connect($trg_username, $trg_password, $is_controluser = false, $trg_server);
|
||||
|
||||
/**
|
||||
* Initializing arrays to save the table ids whose data and structure difference is to be applied
|
||||
@@ -1177,8 +1194,10 @@ if (isset($_REQUEST['synchronize_db'])) {
|
||||
|
||||
echo '<div id="serverstatus">
|
||||
<form name="connection_form" id="connection_form" method="POST" action="server_synchronize.php"
|
||||
onsubmit="return validateConnection(connection_form,this)">'
|
||||
>' // TODO: add check if all var. are filled in
|
||||
. PMA_generate_common_hidden_inputs('', '');
|
||||
echo '<fieldset>'."\n";
|
||||
echo '<legend>Synchronization</legend>'."\n";
|
||||
/**
|
||||
* Displays the form for source server
|
||||
*/
|
||||
@@ -1187,24 +1206,28 @@ if (isset($_REQUEST['synchronize_db'])) {
|
||||
<th colspan="2">Source Database</th>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td>Host: </td>
|
||||
<td><input type="text" name="src_host"></td>
|
||||
<td>'. $GLOBALS['strHost']. '</td>
|
||||
<td><input type="text" name="src_host" /></td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td>Username: </td>
|
||||
<td><input type="text" name="src_username"/></td>
|
||||
<td>'. $GLOBALS['strPort']. '</td>
|
||||
<td><input type="text" name="src_port" value="3306" maxlength="5" size="5" /></td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td>Password: </td>
|
||||
<td>'. $GLOBALS['strSocket']. '</td>
|
||||
<td><input type="text" name="src_socket" /></td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td>'. $GLOBALS['strUserName']. '</td>
|
||||
<td><input type="text" name="src_username" /></td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td>'. $GLOBALS['strPassword']. '</td>
|
||||
<td><input type="password" name="src_pass" /> </td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td>Port: </td>
|
||||
<td><input type="text" name="src_port" value="3306"></td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td>Database: </td>
|
||||
<td><input type="text" name="src_db"></td>
|
||||
<td>'. $GLOBALS['strDatabase']. '</td>
|
||||
<td><input type="text" name="src_db" /></td>
|
||||
</tr>
|
||||
</table>';
|
||||
|
||||
@@ -1216,27 +1239,31 @@ if (isset($_REQUEST['synchronize_db'])) {
|
||||
<th colspan="2">Target Database</th>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td>Host: </td>
|
||||
<td><input type="text" name="trg_host"></td>
|
||||
<td>'. $GLOBALS['strHost']. '</td>
|
||||
<td><input type="text" name="trg_host" /></td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td>Username: </td>
|
||||
<td><input type="text" name="trg_username"></td>
|
||||
<td>'. $GLOBALS['strPort']. '</td>
|
||||
<td><input type="text" name="trg_port" value="3306" maxlength="5" size="5" /></td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td>Password: </td>
|
||||
<td><input type="password" name="trg_pass"></td>
|
||||
<td>'. $GLOBALS['strSocket']. '</td>
|
||||
<td><input type="text" name="trg_socket" /></td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td>Port: </td>
|
||||
<td><input type="text" name="trg_port" value="3306"></td>
|
||||
<td>'. $GLOBALS['strUserName']. '</td>
|
||||
<td><input type="text" name="trg_username" /></td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td>Database: </td>
|
||||
<td><input type="text" name="trg_db"></td>
|
||||
<td>'. $GLOBALS['strPassword']. '</td>
|
||||
<td><input type="password" name="trg_pass" /></td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td>'. $GLOBALS['strDatabase']. '</td>
|
||||
<td><input type="text" name="trg_db" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</fieldset>
|
||||
<fieldset class="tblFooters">
|
||||
<input type="submit" name="submit_connect" value="' .$GLOBALS['strGo'] .'" id="buttonGo" />
|
||||
</fieldset>
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 551 B |
Reference in New Issue
Block a user