Hello,
I'm sending my changes for synchronization GUI.
Changelog:
*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
Remains:
*Add support for current PMA server - to be able to choose from
available databases
I still have to make some changes in backend, so it can work with
replication.
Tomas
Marc Delisle wrote:
>
zahranaeem@... a écrit :
>
>> Revision: 12877
>>
http://phpmyadmin.svn.sourceforge.net/phpmyadmin/?rev=12877&view=rev>> Author: zahranaeem
>> Date: 2009-08-24 17:23:14 +0000 (Mon, 24 Aug 2009)
>>
>> Log Message:
>> -----------
>> Removed spaces that were used to align text boxes in the form.
>>
>> Modified Paths:
>> --------------
>> trunk/phpMyAdmin/server_synchronize.php
>>
>> Modified: trunk/phpMyAdmin/server_synchronize.php
>> ===================================================================
>> --- trunk/phpMyAdmin/server_synchronize.php 2009-08-24 17:00:31 UTC (rev 12876)
>> +++ trunk/phpMyAdmin/server_synchronize.php 2009-08-24 17:23:14 UTC (rev 12877)
>> @@ -68,7 +68,7 @@
>> */
>> echo '<div class="error">' . "\n" ;
>> if(!$src_connection) {
>> - echo "Could not connect to the source</br>";
>> + echo "Could not connect to the source<br/>";
>> }
>> if(!$trg_connection){
>> echo "Could not connect to the target";
>>
>
> Hello Zahra,
> These messages are not extracted to message files?
>
>
Index: lang/english-utf-8.inc.php
===================================================================
--- lang/english-utf-8.inc.php (revision 12874)
+++ lang/english-utf-8.inc.php (working copy)
@@ -1560,4 +1560,10 @@
$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.';
?>
Index: themes/original/img/s_sync.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Index: server_synchronize.php
===================================================================
--- server_synchronize.php (revision 12874)
+++ server_synchronize.php (working copy)
@@ -47,31 +47,44 @@
*/
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"} = '';
+
+ 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);
- $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 (!($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,22 +94,22 @@
* 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_server);
+ $trg_connection = PMA_DBI_select_db($trg_db, $trg_link);
- $trg_link = PMA_DBI_connect($trg_username, $trg_password, $is_controluser = false);
- $trg_db_selected = PMA_DBI_select_db($trg_db, $trg_link);
-
if (($src_db_selected != 1) || ($trg_db_selected != 1)) {
/**
* Displays error string if the database(s) did not exist
*/
- echo '<div class="error">' . "\n" ;
+ 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 @@
$_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 @@
$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 @@
/**
* 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,56 +1194,76 @@
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
*/
echo '<table id="serverstatustraffic" class="data" >
<tr>
- <th>Source Database</th>
+ <th colspan="2">Source Database</th>
</tr>
<tr class="odd">
- <td>Host: <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: <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: <input type="password" name="src_pass" /> </td>
+ <td>'. $GLOBALS['strSocket']. '</td>
+ <td><input type="text" name="src_socket" /></td>
</tr>
<tr class="even">
- <td>Port: <input type="text" name="src_port" value="3306"></td>
+ <td>'. $GLOBALS['strUserName']. '</td>
+ <td><input type="text" name="src_username" /></td>
</tr>
<tr class="odd">
- <td>Database: <input type="text" name="src_db"></td>
+ <td>'. $GLOBALS['strPassword']. '</td>
+ <td><input type="password" name="src_pass" /> </td>
</tr>
+ <tr class="even">
+ <td>'. $GLOBALS['strDatabase']. '</td>
+ <td><input type="text" name="src_db" /></td>
+ </tr>
</table>';
/**
* Displays the form for target server
*/
- echo '<table id="serverstatusconnection" class="data">
+ echo '<table id="serverstatusconnection" class="data">
<tr>
- <th>Target Database</th>
+ <th colspan="2">Target Database</th>
</tr>
<tr class="odd">
- <td>Host: <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: <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: <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: <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: <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>
Index: libraries/dbi/mysqli.dbi.lib.php
===================================================================
--- libraries/dbi/mysqli.dbi.lib.php (revision 12874)
+++ libraries/dbi/mysqli.dbi.lib.php (working copy)
@@ -54,23 +54,38 @@
* @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)
{
- $server_port = (empty($GLOBALS['cfg']['Server']['port']))
- ? false
- : (int) $GLOBALS['cfg']['Server']['port'];
+ 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();
mysqli_options($link, MYSQLI_OPT_LOCAL_INFILE, true);
@@ -86,21 +101,25 @@
if ($GLOBALS['cfg']['Server']['ssl'] && defined('MYSQLI_CLIENT_SSL')) {
$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);
- $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);
+ // 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) {
- trigger_error($GLOBALS['strControluserFailed'], E_USER_WARNING);
- return false;
- }
- PMA_log_user($user, 'mysql-denied');
- PMA_auth_fails();
+ if ($is_controluser) {
+ trigger_error($GLOBALS['strControluserFailed'], E_USER_WARNING);
+ return false;
+ }
+ PMA_log_user($user, 'mysql-denied');
+ PMA_auth_fails();
} // end if
PMA_DBI_postConnect($link, $is_controluser);
Index: libraries/dbi/mysql.dbi.lib.php
===================================================================
--- libraries/dbi/mysql.dbi.lib.php (revision 12874)
+++ libraries/dbi/mysql.dbi.lib.php (working copy)
@@ -21,18 +21,18 @@
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 @@
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;
-
- $server_port = (empty($cfg['Server']['port']))
+
+ if ($server) {
+ $server_port = (empty($server['port']))
? ''
- : ':' . $cfg['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']))
+ ? ''
+ : ':' . (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
@@ -74,14 +91,20 @@
if (defined('MYSQL_CLIENT_SSL') && $cfg['Server']['ssl']) {
$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);
- $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);
+ // 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,9 +113,9 @@
PMA_log_user($user, 'mysql-denied');
PMA_auth_fails();
} // end if
+ if (!$server)
+ PMA_DBI_postConnect($link, $is_controluser);
- PMA_DBI_postConnect($link, $is_controluser);
-
return $link;
}
@@ -173,7 +196,6 @@
}
$_SESSION['debug']['queries'][$hash]['trace'][] = $trace;
}
-
if($r != FALSE and PMA_Tracker::isActive() == TRUE )
PMA_Tracker::handleQuery($query);
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.
http://p.sf.net/sfu/bobj-july_______________________________________________
Phpmyadmin-devel mailing list
Phpmyadmin-devel@...
https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel