diff --git a/server_synchronize.php b/server_synchronize.php index 745ad1c1f..e3c60e820 100644 --- a/server_synchronize.php +++ b/server_synchronize.php @@ -51,43 +51,43 @@ $cons = array ("src", "trg"); if ((isset($_REQUEST['submit_connect']))) { 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}_type"} = $_REQUEST[$con.'_type']; + ${"{$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}_type"} = $_REQUEST[$con.'_type']; - if (${"{$con}_type"}=='cur') { - ${"{$con}_connection"} = null; - ${"{$con}_db"} = $_REQUEST[$con.'_db_sel']; - continue; - } + if (${"{$con}_type"} == 'cur') { + ${"{$con}_connection"} = null; + ${"{$con}_db"} = $_REQUEST[$con.'_db_sel']; + continue; + } - if (isset(${"{$con}_socket"}) && !empty(${"{$con}_socket"})) { - ${"{$con}_server"}['socket'] = ${"{$con}_socket"}; - } else { - ${"{$con}_server"}['host'] = ${"{$con}_host"}; - if (isset(${"{$con}_port"}) && !empty(${"{$con}_port"}) && ((int)${"{$con}_port"}*1)>0) { - ${"{$con}_server"}['port'] = ${"{$con}_port"}; - } - } + if (isset(${"{$con}_socket"}) && ! empty(${"{$con}_socket"})) { + ${"{$con}_server"}['socket'] = ${"{$con}_socket"}; + } else { + ${"{$con}_server"}['host'] = ${"{$con}_host"}; + if (isset(${"{$con}_port"}) && ! empty(${"{$con}_port"}) && ((int)${"{$con}_port"} * 1) > 0) { + ${"{$con}_server"}['port'] = ${"{$con}_port"}; + } + } - ${"{$con}_connection"} = PMA_DBI_connect(${"{$con}_username"}, ${"{$con}_password"}, $is_controluser = false, ${"{$con}_server"}); - } + ${"{$con}_connection"} = PMA_DBI_connect(${"{$con}_username"}, ${"{$con}_password"}, $is_controluser = false, ${"{$con}_server"}); + } // end foreach ($cons as $con) - if ((!$src_connection && $src_type=='rmt') || (!$trg_connection && $trg_type=='rmt')) { + if ((! $src_connection && $src_type=='rmt') || (! $trg_connection && $trg_type=='rmt')) { /** * Displays the connection error string if * connections are not established */ echo '
' . "\n" ; - if(!$src_connection) { + if(! $src_connection) { echo $GLOBALS['strCouldNotConnectSource'].'
'; } - if(!$trg_connection){ + if(! $trg_connection){ echo $GLOBALS['strCouldNotConnectTarget']; } echo '
'; @@ -98,13 +98,14 @@ 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 */ - foreach ($cons as $con) { - if (${"{$con}_connection"}!=null) - ${"{$con}_link"} = PMA_DBI_connect(${"{$con}_username"}, ${"{$con}_password"}, $is_controluser = false, ${"{$con}_server"}); - else - ${"{$con}_link"} = null; - ${"{$con}_db_selected"} = PMA_DBI_select_db(${"{$con}_db"}, ${"{$con}_link"}); - } + foreach ($cons as $con) { + if (${"{$con}_connection"} != null) { + ${"{$con}_link"} = PMA_DBI_connect(${"{$con}_username"}, ${"{$con}_password"}, $is_controluser = false, ${"{$con}_server"}); + } else { + ${"{$con}_link"} = null; + } + ${"{$con}_db_selected"} = PMA_DBI_select_db(${"{$con}_db"}, ${"{$con}_link"}); + } // end foreach ($cons as $con) if (($src_db_selected != 1) || ($trg_db_selected != 1)) { /** @@ -185,8 +186,7 @@ if ((isset($_REQUEST['submit_connect']))) { */ $criteria = array('Field', 'Type', 'Null', 'Collation', 'Key', 'Default', 'Comment'); - for($i=0; $i< sizeof($matching_tables); $i++) - { + for($i = 0; $i < sizeof($matching_tables); $i++) { /** * Finding out all the differences structure, data and index diff for all the matching tables only */ @@ -200,8 +200,7 @@ if ((isset($_REQUEST['submit_connect']))) { $add_indexes_array, $alter_indexes_array,$remove_indexes_array, $i); } - for($j=0; $j< sizeof($source_tables_uncommon); $j++) - { + for($j = 0; $j < sizeof($source_tables_uncommon); $j++) { /** * Finding out the number of rows to be added in tables that need to be added in target database */ @@ -285,8 +284,7 @@ if ((isset($_REQUEST['submit_connect']))) { /** * Display the matching tables' names and difference, first */ - for($i = 0; $i < count($matching_tables); $i++) - { + for($i = 0; $i < count($matching_tables); $i++) { $num_of_updates = 0; $num_of_insertions = 0; /** @@ -320,7 +318,7 @@ if ((isset($_REQUEST['submit_connect']))) { /** * Displays the name of the matching table */ - $odd_row = !$odd_row; + $odd_row = ! $odd_row; echo ' @@ -381,8 +379,7 @@ if ((isset($_REQUEST['submit_connect']))) { /** * Displays the tables' names present in source but missing from target */ - for ($j = 0; $j < count($source_tables_uncommon); $j++) - { + for ($j = 0; $j < count($source_tables_uncommon); $j++) { $odd_row = !$odd_row; echo ''. "\n" ; - if($row_count[$j]>0) + if ($row_count[$j] > 0) { echo 'Click to Select '; } - foreach ($target_tables_uncommon as $tbl_nc_name) - { - $odd_row = !$odd_row; + foreach ($target_tables_uncommon as $tbl_nc_name) { + $odd_row = ! $odd_row; echo ' @@ -422,27 +418,24 @@ if ((isset($_REQUEST['submit_connect']))) { Target Database: ' . $trg_db . ' '; $odd_row = false; - foreach ($matching_tables as $tbl_name) - { - $odd_row = !$odd_row; + foreach ($matching_tables as $tbl_name) { + $odd_row = ! $odd_row; echo ' ' .$tbl_name . ''; echo ''; } - foreach ($source_tables_uncommon as $tbl_nc_name) - { - $odd_row = !$odd_row; + foreach ($source_tables_uncommon as $tbl_nc_name) { + $odd_row = ! $odd_row; echo ' ' .$tbl_nc_name . "\n" . ' (Not present) '; } - foreach ($target_tables_uncommon as $tbl_nc_name) - { - $odd_row = !$odd_row; + foreach ($target_tables_uncommon as $tbl_nc_name) { + $odd_row = ! $odd_row; echo ' @@ -497,7 +490,7 @@ if ((isset($_REQUEST['submit_connect']))) { echo ''; } } -} +} // end if ((isset($_REQUEST['submit_connect']))) /** * Display the page when 'Apply Selected Changes' is pressed @@ -548,11 +541,12 @@ if (isset($_REQUEST['Table_ids'])) { * Creating link object for source and target databases */ foreach ($cons as $con) { - if (${"{$con}_type"}=="rmt") - ${"{$con}_link"} = PMA_DBI_connect(${"{$con}_username"}, ${"{$con}_password"}, $is_controluser = false, ${"{$con}_server"}); - else - ${"{$con}_link"} = null; - } + if (${"{$con}_type"}=="rmt") { + ${"{$con}_link"} = PMA_DBI_connect(${"{$con}_username"}, ${"{$con}_password"}, $is_controluser = false, ${"{$con}_server"}); + } else { + ${"{$con}_link"} = null; + } + } // end foreach ($cons as $con) /** * Initializing arrays to save the table ids whose data and structure difference is to be applied @@ -562,8 +556,7 @@ if (isset($_REQUEST['Table_ids'])) { $uncommon_table_structure_diff = array(); //stores id of uncommon tables having structure difference $uncommon_table_data_diff = array(); //stores id of uncommon tables having data difference - for ($i=0; isset($_REQUEST[$i]); $i++ ) - { + for ($i = 0; isset($_REQUEST[$i]); $i++ ) { if (isset($_REQUEST[$i])) { $table_id = split("US", $_REQUEST[$i]); if (isset($table_id[1])) { @@ -583,11 +576,11 @@ if (isset($_REQUEST['Table_ids'])) { $matching_table_data_diff[] = $table_id[1]; } } - } + } // end for /** * Applying the structure difference on selected matching tables */ - for($q=0 ; $q < sizeof($matching_table_structure_diff); $q++) + for($q = 0 ; $q < sizeof($matching_table_structure_diff); $q++) { if (isset($alter_str_array[$matching_table_structure_diff[$q]])) { @@ -633,7 +626,7 @@ if (isset($_REQUEST['Table_ids'])) { * Applying the data difference. First checks if structure diff is applied or not. * If not, then apply structure difference first then apply data difference. */ - for($p=0; $p < sizeof($matching_table_data_diff); $p++) + for($p = 0; $p < sizeof($matching_table_data_diff); $p++) { if ($_REQUEST['checked'] == 'true') { @@ -711,9 +704,9 @@ if (isset($_REQUEST['Table_ids'])) { /** * Applying structure difference to selected non-matching tables (present in Source but absent from Target). */ - for($s=0; $s < sizeof($uncommon_table_structure_diff); $s++) + for($s = 0; $s < sizeof($uncommon_table_structure_diff); $s++) { - PMA_createTargetTables ($src_db, $trg_db, $src_link, $trg_link, $uncommon_tables, $uncommon_table_structure_diff[$s], $uncommon_tables_fields, false); + PMA_createTargetTables($src_db, $trg_db, $src_link, $trg_link, $uncommon_tables, $uncommon_table_structure_diff[$s], $uncommon_tables_fields, false); $_SESSION['uncommon_tables_fields'] = $uncommon_tables_fields; unset($uncommon_tables[$uncommon_table_structure_diff[$s]]); @@ -722,7 +715,7 @@ if (isset($_REQUEST['Table_ids'])) { * Applying data difference to selected non-matching tables (present in Source but absent from Target). * Before data synchronization, structure synchronization is confirmed. */ - for($r=0; $r < sizeof($uncommon_table_data_diff); $r++) + for($r = 0; $r < sizeof($uncommon_table_data_diff); $r++) { if (!(in_array($uncommon_table_data_diff[$r], $uncommon_table_structure_diff))) { if (isset($uncommon_tables[$uncommon_table_data_diff[$r]])) { @@ -755,8 +748,7 @@ if (isset($_REQUEST['Table_ids'])) { Difference '; $odd_row = false; - for($i = 0; $i < count($matching_tables); $i++) - { + for($i = 0; $i < count($matching_tables); $i++) { $odd_row = !$odd_row; echo ' @@ -859,8 +850,7 @@ if (isset($_REQUEST['Table_ids'])) { * Display the difference only when it has not been applied */ if (!(in_array($j, $uncommon_table_data_diff))) { - if (isset($row_count[$j]) && ($row_count > 0)) - { + if (isset($row_count[$j]) && ($row_count > 0)) { echo 'Click to Select @@ -899,18 +888,16 @@ if (isset($_REQUEST['Table_ids'])) { Target Database: ' . $trg_db . ' '; $odd_row = false; - foreach ($matching_tables as $tbl_name) - { - $odd_row = !$odd_row; + foreach ($matching_tables as $tbl_name) { + $odd_row = ! $odd_row; echo ' ' .$tbl_name . ''; echo ''; } - foreach ($source_tables_uncommon as $tbl_nc_name) - { - $odd_row = !$odd_row; + foreach ($source_tables_uncommon as $tbl_nc_name) { + $odd_row = ! $odd_row; echo ''; @@ -922,9 +909,8 @@ if (isset($_REQUEST['Table_ids'])) { echo ' '; } - foreach ($target_tables_uncommon as $tbl_nc_name) - { - $odd_row = !$odd_row; + foreach ($target_tables_uncommon as $tbl_nc_name) { + $odd_row = ! $odd_row; echo ' @@ -982,7 +968,7 @@ if (isset($_REQUEST['Table_ids'])) { } /** -* Dispalys the page when 'Synchronize Databases' is pressed. +* Displays the page when 'Synchronize Databases' is pressed. */ if (isset($_REQUEST['synchronize_db'])) { @@ -1024,7 +1010,7 @@ if (isset($_REQUEST['synchronize_db'])) { */ echo '
Target database has been synchronized with source database.
'; /** - * Dispalying all the tables of source and target database and now no difference is there. + * Displaying all the tables of source and target database and now no difference is there. */ echo '
@@ -1056,9 +1041,8 @@ if (isset($_REQUEST['synchronize_db'])) { echo ' '; } - foreach ($target_tables_uncommon as $tbl_nc_name) - { - $odd_row = !$odd_row; + foreach ($target_tables_uncommon as $tbl_nc_name) { + $odd_row = ! $odd_row; echo ' @@ -1071,17 +1055,15 @@ if (isset($_REQUEST['synchronize_db'])) { Target Database: ' . $trg_db . ' '; $odd_row = false; - foreach ($matching_tables as $tbl_name) - { - $odd_row = !$odd_row; + foreach ($matching_tables as $tbl_name) { + $odd_row = ! $odd_row; echo ' ' .$tbl_name . ''; echo ''; } - foreach ($source_tables_uncommon as $tbl_nc_name) - { + foreach ($source_tables_uncommon as $tbl_nc_name) { $odd_row = !$odd_row; echo ' '; } - foreach ($target_tables_uncommon as $tbl_nc_name) - { - $odd_row = !$odd_row; + foreach ($target_tables_uncommon as $tbl_nc_name) { + $odd_row = ! $odd_row; echo ' @@ -1115,19 +1096,16 @@ if (isset($_REQUEST['synchronize_db'])) { /** * Applying all sorts of differences for each matching table */ - for($p=0; $p '; foreach ($databases as $db) { - if ($db['SCHEMA_NAME'] != 'mysql' - && $db['SCHEMA_NAME'] != 'information_schema') - echo ' '."\n"; + if ($db['SCHEMA_NAME'] != 'mysql' + && $db['SCHEMA_NAME'] != 'information_schema') { + echo ' '."\n"; + } } echo '