Synchronize: add missing arguments to a function, document possibly broken function
[phpmyadmin.git] / server_synchronize.php
blob3e57f441a095eca36e20f22dad13b3a2ee3eb9cf
1 <?php
3 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 /**
6 * @package phpMyAdmin
7 */
9 /**
12 require_once './libraries/common.inc.php';
14 /**
15 * Does the common work
17 $GLOBALS['js_include'][] = 'server_synchronize.js';
18 require_once './libraries/server_common.inc.php';
20 /**
21 * Contains all the functions specific to synchronization
23 require './libraries/server_synchronize.lib.php';
25 /**
26 * Increases the time limit up to the configured maximum
28 @set_time_limit($cfg['ExecTimeLimit']);
30 /**
31 * Displays the links
33 require './libraries/server_links.inc.php';
35 /**
36 * Enables warnings on the page
38 //$cfg['Error_Handler']['display'] = true;
39 //$cfg['Error_Handler']['gather'] = true;
41 /**
42 * Save the value of token generated for this page
44 if (isset($_REQUEST['token'])) {
45 $_SESSION['token'] = $_REQUEST['token'];
48 // variable for code saving
49 $cons = array ("src", "trg");
51 /**
52 * Displays the page when 'Go' is pressed
55 if ((isset($_REQUEST['submit_connect']))) {
56 foreach ($cons as $con) {
57 ${"{$con}_host"} = $_REQUEST[$con . '_host'];
58 ${"{$con}_username"} = $_REQUEST[$con . '_username'];
59 ${"{$con}_password"} = $_REQUEST[$con . '_pass'];
60 ${"{$con}_port"} = $_REQUEST[$con . '_port'];
61 ${"{$con}_socket"} = $_REQUEST[$con . '_socket'];
62 ${"{$con}_db"} = $_REQUEST[$con . '_db'];
63 ${"{$con}_type"} = $_REQUEST[$con . '_type'];
65 if (${"{$con}_type"} == 'cur') {
66 ${"{$con}_connection"} = null;
67 ${"{$con}_server"} = null;
68 ${"{$con}_db"} = $_REQUEST[$con . '_db_sel'];
69 continue;
72 if (isset(${"{$con}_socket"}) && ! empty(${"{$con}_socket"})) {
73 ${"{$con}_server"}['socket'] = ${"{$con}_socket"};
74 } else {
75 ${"{$con}_server"}['host'] = ${"{$con}_host"};
76 if (isset(${"{$con}_port"}) && ! empty(${"{$con}_port"}) && ((int)${"{$con}_port"} * 1) > 0) {
77 ${"{$con}_server"}['port'] = (int)${"{$con}_port"};
81 ${"{$con}_connection"} = PMA_DBI_connect(${"{$con}_username"}, ${"{$con}_password"}, $is_controluser = false, ${"{$con}_server"}, $auxiliary_connection = true);
82 } // end foreach ($cons as $con)
84 if ((! $src_connection && $src_type != 'cur') || (! $trg_connection && $trg_type != 'cur')) {
85 /**
86 * Displays the connection error string if
87 * connections are not established
90 echo '<div class="error">';
91 if (! $src_connection && $src_type != 'cur') {
92 echo __('Could not connect to the source') . '<br />';
94 if (! $trg_connection && $trg_type != 'cur') {
95 echo __('Could not connect to the target');
97 echo '</div>';
98 unset($_REQUEST['submit_connect']);
100 } else {
102 * Creating the link object for both source and target databases and
103 * selecting the source and target databases using these links
105 foreach ($cons as $con) {
106 if (${"{$con}_connection"} != null) {
107 ${"{$con}_link"} = PMA_DBI_connect(${"{$con}_username"}, ${"{$con}_password"}, $is_controluser = false, ${"{$con}_server"});
108 } else {
109 ${"{$con}_link"} = null;
111 ${"{$con}_db_selected"} = PMA_DBI_select_db(${"{$con}_db"}, ${"{$con}_link"});
112 } // end foreach ($cons as $con)
114 if (($src_db_selected != 1) || ($trg_db_selected != 1)) {
116 * Displays error string if the database(s) did not exist
118 echo '<div class="error">';
119 if ($src_db_selected != 1) {
120 echo sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($src_db));
122 if ($trg_db_selected != 1) {
123 echo sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($trg_db));
125 echo '</div>';
126 unset($_REQUEST['submit_connect']);
128 } else if (($src_db_selected == 1) && ($trg_db_selected == 1)) {
131 * Using PMA_DBI_get_tables() to get all the tables
132 * from target and source databases.
134 $src_tables = PMA_DBI_get_tables($src_db, $src_link);
135 $source_tables_num = sizeof($src_tables);
137 $trg_tables = PMA_DBI_get_tables($trg_db, $trg_link);
138 $target_tables_num = sizeof($trg_tables);
141 * initializing arrays to save matching and non-matching
142 * table names from target and source databases.
144 $unmatched_num_src = 0;
145 $source_tables_uncommon = array();
146 $unmatched_num_trg = 0;
147 $target_tables_uncommon = array();
148 $matching_tables = array();
149 $matching_tables_num = 0;
152 * Using PMA_getMatchingTables to find which of the tables' names match
153 * in target and source database.
155 PMA_getMatchingTables($trg_tables, $src_tables, $matching_tables, $source_tables_uncommon);
157 * Finding the uncommon tables for the target database
158 * using function PMA_getNonMatchingTargetTables()
160 PMA_getNonMatchingTargetTables($trg_tables, $matching_tables, $target_tables_uncommon);
163 * Initializing several arrays to save the data and structure
164 * difference between the source and target databases.
166 $row_count = array(); //number of rows in source table that needs to be created in target database
167 $fields_num = array(); //number of fields in each matching table
168 $delete_array = array(); //stores the primary key values for target tables that have excessive rows than corresponding source tables.
169 $insert_array = array(array(array()));// stores the primary key values for the rows in each source table that are not present in target tables.
170 $update_array = array(array(array())); //stores the primary key values, name of field to be updated, value of the field to be updated for
171 // each row of matching table.
172 $matching_tables_fields = array(); //contains the fields' names for each matching table
173 $matching_tables_keys = array(); //contains the primary keys' names for each matching table
174 $uncommon_tables_fields = array(); //coantains the fields for all the source tables that are not present in target
175 $matching_tables_num = sizeof($matching_tables);
177 $source_columns = array(); //contains the full columns' information for all the source tables' columns
178 $target_columns = array(); //contains the full columns' information for all the target tables' columns
179 $uncommon_columns = array(); //contains names of columns present in source table but absent from the corresponding target table
180 $source_indexes = array(); //contains indexes on all the source tables
181 $target_indexes = array(); //contains indexes on all the target tables
182 $add_indexes_array = array(); //contains the indexes name present in source but absent from target tables
183 $target_tables_keys = array(); //contains the keys of all the target tables
184 $alter_indexes_array = array(); //contains the names of all the indexes for each table that need to be altered in target database
185 $remove_indexes_array = array(); //contains the names of indexes that are excessive in target tables
186 $alter_str_array = array(array()); //contains the criteria for each column that needs to be altered in target tables
187 $add_column_array = array(array()); //contains the name of columns that need to be added in target tables
189 * The criteria array contains all the criteria against which columns are compared for differences.
191 $criteria = array('Field', 'Type', 'Null', 'Collation', 'Key', 'Default', 'Comment');
193 for ($i = 0; $i < sizeof($matching_tables); $i++) {
195 * Finding out all the differences structure, data and index diff for all the matching tables only
197 PMA_dataDiffInTables($src_db, $trg_db, $src_link, $trg_link, $matching_tables, $matching_tables_fields, $update_array, $insert_array,
198 $delete_array, $fields_num, $i, $matching_tables_keys);
200 PMA_structureDiffInTables($src_db, $trg_db, $src_link, $trg_link, $matching_tables, $source_columns,
201 $target_columns, $alter_str_array, $add_column_array, $uncommon_columns, $criteria, $target_tables_keys, $i);
203 PMA_indexesDiffInTables($src_db, $trg_db, $src_link, $trg_link, $matching_tables, $source_indexes, $target_indexes,
204 $add_indexes_array, $alter_indexes_array, $remove_indexes_array, $i);
207 for ($j = 0; $j < sizeof($source_tables_uncommon); $j++) {
209 * Finding out the number of rows to be added in tables that need to be added in target database
211 PMA_dataDiffInUncommonTables($source_tables_uncommon, $src_db, $src_link, $j, $row_count);
215 * Storing all arrays in session for use when page is reloaded for each button press
217 $_SESSION['matching_tables'] = $matching_tables;
218 $_SESSION['update_array'] = $update_array;
219 $_SESSION['insert_array'] = $insert_array;
220 $_SESSION['src_db'] = $src_db;
221 $_SESSION['trg_db'] = $trg_db;
222 $_SESSION['matching_fields'] = $matching_tables_fields;
223 $_SESSION['src_uncommon_tables'] = $source_tables_uncommon;
224 $_SESSION['src_username'] = $src_username ;
225 $_SESSION['trg_username'] = $trg_username;
226 $_SESSION['src_password'] = $src_password;
227 $_SESSION['trg_password'] = $trg_password;
228 $_SESSION['trg_password'] = $trg_password;
229 $_SESSION['src_server'] = $src_server;
230 $_SESSION['trg_server'] = $trg_server;
231 $_SESSION['src_type'] = $src_type;
232 $_SESSION['trg_type'] = $trg_type;
233 $_SESSION['matching_tables_keys'] = $matching_tables_keys;
234 $_SESSION['uncommon_tables_fields'] = $uncommon_tables_fields;
235 $_SESSION['uncommon_tables_row_count'] = $row_count;
236 $_SESSION['target_tables_uncommon'] = $target_tables_uncommon;
237 $_SESSION['uncommon_tables'] = $source_tables_uncommon;
238 $_SESSION['delete_array'] = $delete_array;
239 $_SESSION['uncommon_columns'] = $uncommon_columns;
240 $_SESSION['source_columns'] = $source_columns;
241 $_SESSION['alter_str_array'] = $alter_str_array;
242 $_SESSION['target_tables_keys'] = $target_tables_keys;
243 $_SESSION['add_column_array'] = $add_column_array;
244 $_SESSION['criteria'] = $criteria;
245 $_SESSION['target_tables'] = $trg_tables;
246 $_SESSION['add_indexes_array'] = $add_indexes_array;
247 $_SESSION['alter_indexes_array'] = $alter_indexes_array;
248 $_SESSION['remove_indexes_array'] = $remove_indexes_array;
249 $_SESSION['source_indexes'] = $source_indexes;
250 $_SESSION['target_indexes'] = $target_indexes;
253 * Displays the sub-heading and icons showing Structure Synchronization and Data Synchronization
256 <form name="synchronize_form" id="synchronize_form" method="post" action="server_synchronize.php">
257 <?php PMA_generate_common_hidden_inputs('', ''); ?>
258 <table width="40%">
259 <tr>
260 <td>
261 <img class="icon" src="<?php echo $pmaThemeImage; ?>new_struct.png" width="16" height="16" alt="" />
262 <?php echo __('Structure Synchronization'); ?>
263 </td>
264 <td>
265 <img class="icon" src="<?php echo $pmaThemeImage; ?>new_data.png" width="16" height="16" alt="" />
266 <?php echo __('Data Synchronization'); ?>
267 </td>
268 </tr>
269 </table>
270 <?php
272 * Displays the tables containing the source tables names, their difference with the target tables and target tables names
274 PMA_syncDisplayHeaderCompare($src_db, $trg_db);
275 $rows = array();
278 * Display the matching tables' names and difference, first
280 for ($i = 0; $i < count($matching_tables); $i++) {
282 * Calculating the number of updates for each matching table
284 if (isset($update_array[$i]) && isset($update_array[$i][0]) &&
285 isset($update_array[$i][0][$matching_tables_keys[$i][0]])) {
286 $num_of_updates = sizeof($update_array[$i]);
287 } else {
288 $num_of_updates = 0;
291 * Calculating the number of insertions for each matching table
293 if (isset($insert_array[$i]) && isset($insert_array[$i][0]) &&
294 isset($insert_array[$i][0][$matching_tables_keys[$i][0]])) {
295 $num_of_insertions = sizeof($insert_array[$i]);
296 } else {
297 $num_of_insertions = 0;
301 * Calculating the number of alter columns, number of columns to be added, number of columns to be removed,
302 * number of index to be added and removed.
304 $num_alter_cols = 0;
305 $num_insert_cols = 0;
306 $num_remove_cols = 0;
307 $num_add_index = 0;
308 $num_remove_index = 0;
310 if (isset($alter_str_array[$i])) {
311 $num_alter_cols = sizeof($alter_str_array[$i]);
313 if (isset($add_column_array[$i])) {
314 $num_insert_cols = sizeof($add_column_array[$i]);
316 if (isset($uncommon_columns[$i])) {
317 $num_remove_cols = sizeof($uncommon_columns[$i]);
319 if (isset($add_indexes_array[$i])) {
320 $num_add_index = sizeof($add_indexes_array[$i]);
322 if (isset($remove_indexes_array[$i])) {
323 $num_remove_index = sizeof($remove_indexes_array[$i]);
325 if (isset($alter_indexes_array[$i])) {
326 $num_add_index += sizeof($alter_indexes_array[$i]);
327 $num_remove_index += sizeof($alter_indexes_array[$i]);
330 $btn_structure_params = null;
331 $btn_data_params = null;
334 * Display the red button of structure synchronization if there exists any structure difference or index difference.
336 if (($num_alter_cols > 0) || ($num_insert_cols > 0) || ($num_remove_cols > 0) || ($num_add_index > 0) || ($num_remove_index > 0)) {
337 $btn_structure_params = array($i, $num_alter_cols, $num_insert_cols,
338 $num_remove_cols, $num_add_index, $num_remove_index);
342 * Display the green button of data synchronization if there exists any data difference.
344 if (isset($update_array[$i]) || isset($insert_array[$i])) {
345 if (isset($update_array[$i][0][$matching_tables_keys[$i][0]]) || isset($insert_array[$i][0][$matching_tables_keys[$i][0]])) {
346 $btn_data_params = array($i, $num_of_updates, $num_of_insertions, null, null, null);
350 $rows[] = array(
351 'src_table_name' => $matching_tables[$i],
352 'dst_table_name' => $matching_tables[$i],
353 'btn_type' => 'M',
354 'btn_structure' => $btn_structure_params,
355 'btn_data' => $btn_data_params
359 * Displays the tables' names present in source but missing from target
361 for ($j = 0; $j < count($source_tables_uncommon); $j++) {
362 $row = array(
363 'src_table_name' => '+ ' . $source_tables_uncommon[$j],
364 'dst_table_name' => $source_tables_uncommon[$j] . ' (' . __('not present') . ')',
365 'btn_type' => 'U',
366 'btn_structure' => array($j, null, null, null, null, null),
367 'btn_data' => null
369 if ($row_count[$j] > 0) {
370 $row['btn_data'] = array($j, null, $row_count[$j], null, null, null);
372 $rows[] = $row;
374 foreach ($target_tables_uncommon as $tbl_nc_name) {
375 $rows[] = array(
376 'src_table_name' => '',
377 'dst_table_name' => $tbl_nc_name);
380 * Displays the target tables names
382 PMA_syncDisplayDataCompare($rows);
383 echo '</table>
384 </div>
385 </fieldset>';
388 * This "list" div will contain a table and each row will depict information about structure/data diffrence in tables.
389 * Rows will be generated dynamically as soon as the colored buttons "D" or "S" are clicked.
392 echo '<fieldset style="padding:0"><div id="list" style="overflow:auto; height:140px; padding:1em">
394 <table>
395 <thead>
396 <tr style="width: 100%;">
397 <th id="table_name" style="width: 10%;" colspan="1">' . __('Table') . ' </th>
398 <th id="str_diff" style="width: 65%;" colspan="6">' . __('Structure Difference') . ' </th>
399 <th id="data_diff" style="width: 20%;" colspan="2">' . __('Data Difference') . '</th>
400 </tr>
401 <tr style="width: 100%;">
402 <th style="width: 10%;">' . __('Table name') . '</th>
403 <th style="width: 10%;">' . __('Create table'). '</th>
404 <th style="width: 11%;">' . __('Add column(s)') . '</th>
405 <th style="width: 13%;">' . __('Remove column(s)') . '</th>
406 <th style="width: 11%;">' . __('Alter column(s)') . '</th>
407 <th style="width: 12%;">' . __('Remove index(s)') . '</th>
408 <th style="width: 11%;">' . __('Apply index(s)') . '</th>
409 <th style="width: 10%;">'. __('Update row(s)') . '</th>
410 <th style="width: 10%;">' . __('Insert row(s)') . '</th>
411 </tr>
412 </thead>
413 <tbody></tbody>
414 </table>
415 </div></fieldset>';
417 * This fieldset displays the checkbox to confirm deletion of previous rows from target tables
419 echo '<fieldset>
420 <p><input type= "checkbox" name="delete_rows" id ="delete_rows" /><label for="delete_rows">' . __('Would you like to delete all the previous rows from target tables?') . '</label> </p>
421 </fieldset>
422 <fieldset class="tblFooters">';
423 echo '<input type="button" name="apply_changes" value="' . __('Apply Selected Changes')
424 . '" onclick ="ApplySelectedChanges(' . "'" . htmlspecialchars($_SESSION['token']) . "'" . ')" />';
425 echo '<input type="submit" name="synchronize_db" value="' . __('Synchronize Databases') . '" />' . '</fieldset>';
426 echo '</form>';
429 } // end if ((isset($_REQUEST['submit_connect'])))
432 * Display the page when 'Apply Selected Changes' is pressed
434 if (isset($_REQUEST['Table_ids'])) {
436 * Displays success message
438 echo '<div class="success">' . __('Selected target tables have been synchronized with source tables.') . '</div>';
440 $src_db = $_SESSION['src_db'];
441 $trg_db = $_SESSION['trg_db'];
442 $update_array = $_SESSION['update_array'];
443 $insert_array = $_SESSION['insert_array'];
444 $src_username = $_SESSION['src_username'];
445 $trg_username = $_SESSION['trg_username'];
446 $src_password = $_SESSION['src_password'];
447 $trg_password = $_SESSION['trg_password'];
448 $src_server = $_SESSION['src_server'];
449 $trg_server = $_SESSION['trg_server'];
450 $src_type = $_SESSION['src_type'];
451 $trg_type = $_SESSION['trg_type'];
452 $uncommon_tables = $_SESSION['uncommon_tables'];
453 $matching_tables = $_SESSION['matching_tables'];
454 $matching_tables_keys = $_SESSION['matching_tables_keys'];
455 $matching_tables_fields = $_SESSION['matching_fields'];
456 $source_tables_uncommon = $_SESSION['src_uncommon_tables'];
457 $uncommon_tables_fields = $_SESSION['uncommon_tables_fields'];
458 $target_tables_uncommon = $_SESSION['target_tables_uncommon'];
459 $row_count = $_SESSION['uncommon_tables_row_count'];
460 $target_tables = $_SESSION['target_tables'];
462 $delete_array = $_SESSION['delete_array'];
463 $uncommon_columns = $_SESSION['uncommon_columns'];
464 $source_columns = $_SESSION['source_columns'];
465 $alter_str_array = $_SESSION['alter_str_array'];
466 $criteria = $_SESSION['criteria'];
467 $target_tables_keys = $_SESSION['target_tables_keys'];
468 $add_column_array = $_SESSION['add_column_array'];
469 $add_indexes_array = $_SESSION['add_indexes_array'];
470 $alter_indexes_array = $_SESSION['alter_indexes_array'];
471 $remove_indexes_array = $_SESSION['remove_indexes_array'];
472 $source_indexes = $_SESSION['source_indexes'];
473 $target_indexes = $_SESSION['target_indexes'];
474 $uncommon_cols = $uncommon_columns;
477 * Creating link object for source and target databases
479 foreach ($cons as $con) {
480 if (${"{$con}_type"} != "cur") {
481 ${"{$con}_link"} = PMA_DBI_connect(${"{$con}_username"}, ${"{$con}_password"}, $is_controluser = false, ${"{$con}_server"});
482 } else {
483 ${"{$con}_link"} = null;
484 // working on current server, so initialize this for tracking
485 // (does not work if user defined current server as a remote one)
486 $GLOBALS['db'] = ${"{$con}_db"};
488 } // end foreach ($cons as $con)
491 * Initializing arrays to save the table ids whose data and structure difference is to be applied
493 $matching_table_data_diff = array(); //stores id of matching table having data difference
494 $matching_table_structure_diff = array(); //stores id of matching tables having structure difference
495 $uncommon_table_structure_diff = array(); //stores id of uncommon tables having structure difference
496 $uncommon_table_data_diff = array(); //stores id of uncommon tables having data difference
498 for ($i = 0; isset($_REQUEST[$i]); $i++ ) {
499 if (isset($_REQUEST[$i])) {
500 $table_id = explode("US", $_REQUEST[$i]);
501 if (isset($table_id[1])) {
502 $uncommon_table_structure_diff[] = $table_id[1];
504 $table_id = explode("UD", $_REQUEST[$i]);
505 if (isset($table_id[1])) {
506 $uncommon_table_data_diff[] = $table_id[1];
508 $table_id = explode("MS", $_REQUEST[$i]);
509 if (isset($table_id[1])) {
510 $matching_table_structure_diff[] = $table_id[1];
513 $table_id = explode("MD", $_REQUEST[$i]);
514 if (isset($table_id[1])) {
515 $matching_table_data_diff[] = $table_id[1];
518 } // end for
520 * Applying the structure difference on selected matching tables
522 for ($q = 0; $q < sizeof($matching_table_structure_diff); $q++)
524 if (isset($alter_str_array[$matching_table_structure_diff[$q]])) {
526 PMA_alterTargetTableStructure($trg_db, $trg_link, $matching_tables, $source_columns, $alter_str_array, $matching_tables_fields,
527 $criteria, $matching_tables_keys, $target_tables_keys, $matching_table_structure_diff[$q], false);
529 unset($alter_str_array[$matching_table_structure_diff[$q]]);
531 if (isset($add_column_array[$matching_table_structure_diff[$q]])) {
533 PMA_findDeleteRowsFromTargetTables($delete_array, $matching_tables, $matching_table_structure_diff[$q], $target_tables_keys,
534 $matching_tables_keys, $trg_db, $trg_link, $src_db, $src_link);
536 if (isset($delete_array[$matching_table_structure_diff[$q]])) {
538 PMA_deleteFromTargetTable($trg_db, $trg_link, $matching_tables, $matching_table_structure_diff[$q], $target_tables_keys, $delete_array, false);
540 unset($delete_array[$matching_table_structure_diff[$q]]);
542 PMA_addColumnsInTargetTable($src_db, $trg_db,$src_link, $trg_link, $matching_tables, $source_columns, $add_column_array, $matching_tables_fields,
543 $criteria, $matching_tables_keys, $target_tables_keys, $uncommon_tables,$uncommon_tables_fields, $matching_table_structure_diff[$q], $uncommon_cols, false);
545 unset($add_column_array[$matching_table_structure_diff[$q]]);
547 if (isset($uncommon_columns[$matching_table_structure_diff[$q]])) {
549 PMA_removeColumnsFromTargetTable($trg_db, $trg_link, $matching_tables, $uncommon_columns, $matching_table_structure_diff[$q], false);
551 unset($uncommon_columns[$matching_table_structure_diff[$q]]);
553 if (isset($add_indexes_array[$matching_table_structure_diff[$q]]) || isset($remove_indexes_array[$matching_table_structure_diff[$q]])
554 || isset($alter_indexes_array[$matching_table_structure_diff[$q]])) {
556 PMA_applyIndexesDiff ($trg_db, $trg_link, $matching_tables, $source_indexes, $target_indexes, $add_indexes_array, $alter_indexes_array,
557 $remove_indexes_array, $matching_table_structure_diff[$q], false);
559 unset($add_indexes_array[$matching_table_structure_diff[$q]]);
560 unset($alter_indexes_array[$matching_table_structure_diff[$q]]);
561 unset($remove_indexes_array[$matching_table_structure_diff[$q]]);
565 * Applying the data difference. First checks if structure diff is applied or not.
566 * If not, then apply structure difference first then apply data difference.
568 for ($p = 0; $p < sizeof($matching_table_data_diff); $p++)
570 if ($_REQUEST['checked'] == 'true') {
572 PMA_findDeleteRowsFromTargetTables($delete_array, $matching_tables, $matching_table_data_diff[$p], $target_tables_keys,
573 $matching_tables_keys, $trg_db, $trg_link, $src_db, $src_link);
575 if (isset($delete_array[$matching_table_data_diff[$p]])) {
577 PMA_deleteFromTargetTable($trg_db, $trg_link, $matching_tables, $matching_table_data_diff[$p], $target_tables_keys, $delete_array, false);
579 unset($delete_array[$matching_table_data_diff[$p]]);
582 if (isset($alter_str_array[$matching_table_data_diff[$p]])) {
584 PMA_alterTargetTableStructure($trg_db, $trg_link, $matching_tables, $source_columns, $alter_str_array, $matching_tables_fields,
585 $criteria, $matching_tables_keys, $target_tables_keys, $matching_table_data_diff[$p], false);
587 unset($alter_str_array[$matching_table_data_diff[$p]]);
589 if (isset($add_column_array[$matching_table_data_diff[$p]])) {
591 PMA_findDeleteRowsFromTargetTables($delete_array, $matching_tables, $matching_table_data_diff[$p], $target_tables_keys,
592 $matching_tables_keys, $trg_db, $trg_link, $src_db, $src_link);
594 if (isset($delete_array[$matching_table_data_diff[$p]])) {
596 PMA_deleteFromTargetTable($trg_db, $trg_link, $matching_tables, $matching_table_data_diff[$p], $target_tables_keys, $delete_array, false);
598 unset($delete_array[$matching_table_data_diff[$p]]);
600 PMA_addColumnsInTargetTable($src_db, $trg_db,$src_link, $trg_link, $matching_tables, $source_columns, $add_column_array, $matching_tables_fields,
601 $criteria, $matching_tables_keys, $target_tables_keys, $uncommon_tables, $uncommon_tables_fields, $matching_table_data_diff[$p], $uncommon_cols, false);
603 unset($add_column_array[$matching_table_data_diff[$p]]);
605 if (isset($uncommon_columns[$matching_table_data_diff[$p]])) {
607 PMA_removeColumnsFromTargetTable($trg_db, $trg_link, $matching_tables, $uncommon_columns, $matching_table_data_diff[$p], false);
609 unset($uncommon_columns[$matching_table_data_diff[$p]]);
611 if ((isset($matching_table_structure_diff[$q]) && isset($add_indexes_array[$matching_table_structure_diff[$q]]))
612 || (isset($matching_table_structure_diff[$q]) && isset($remove_indexes_array[$matching_table_structure_diff[$q]]))
613 || (isset($matching_table_structure_diff[$q]) && isset($alter_indexes_array[$matching_table_structure_diff[$q]]))) {
615 PMA_applyIndexesDiff ($trg_db, $trg_link, $matching_tables, $source_indexes, $target_indexes, $add_indexes_array, $alter_indexes_array,
616 $remove_indexes_array, $matching_table_structure_diff[$q], false);
618 unset($add_indexes_array[$matching_table_structure_diff[$q]]);
619 unset($alter_indexes_array[$matching_table_structure_diff[$q]]);
620 unset($remove_indexes_array[$matching_table_structure_diff[$q]]);
623 * Applying the data difference.
625 PMA_updateTargetTables($matching_tables, $update_array, $src_db, $trg_db, $trg_link, $matching_table_data_diff[$p], $matching_tables_keys, false);
627 PMA_insertIntoTargetTable($matching_tables, $src_db, $trg_db, $src_link, $trg_link , $matching_tables_fields, $insert_array,
628 $matching_table_data_diff[$p], $matching_tables_keys, $source_columns, $add_column_array, $criteria, $target_tables_keys,
629 $uncommon_tables, $uncommon_tables_fields, $uncommon_cols, $alter_str_array, $source_indexes, $target_indexes, $add_indexes_array,
630 $alter_indexes_array, $delete_array, $update_array, false);
633 * Updating the session variables to the latest values of the arrays.
635 $_SESSION['delete_array'] = $delete_array;
636 $_SESSION['uncommon_columns'] = $uncommon_columns;
637 $_SESSION['alter_str_array'] = $alter_str_array;
638 $_SESSION['add_column_array'] = $add_column_array;
639 $_SESSION['add_indexes_array'] = $add_indexes_array;
640 $_SESSION['remove_indexes_array'] = $remove_indexes_array;
641 $_SESSION['insert_array'] = $insert_array;
642 $_SESSION['update_array'] = $update_array;
645 * Applying structure difference to selected non-matching tables (present in Source but absent from Target).
647 for ($s = 0; $s < sizeof($uncommon_table_structure_diff); $s++)
649 PMA_createTargetTables($src_db, $trg_db, $src_link, $trg_link, $uncommon_tables, $uncommon_table_structure_diff[$s], $uncommon_tables_fields, false);
650 $_SESSION['uncommon_tables_fields'] = $uncommon_tables_fields;
652 unset($uncommon_tables[$uncommon_table_structure_diff[$s]]);
655 * Applying data difference to selected non-matching tables (present in Source but absent from Target).
656 * Before data synchronization, structure synchronization is confirmed.
658 for ($r = 0; $r < sizeof($uncommon_table_data_diff); $r++)
660 if (!(in_array($uncommon_table_data_diff[$r], $uncommon_table_structure_diff))) {
661 if (isset($uncommon_tables[$uncommon_table_data_diff[$r]])) {
663 PMA_createTargetTables($src_db, $trg_db, $src_link, $trg_link, $uncommon_tables, $uncommon_table_data_diff[$r],
664 $uncommon_tables_fields, false);
665 $_SESSION['uncommon_tables_fields'] = $uncommon_tables_fields;
667 unset($uncommon_tables[$uncommon_table_data_diff[$r]]);
670 PMA_populateTargetTables($src_db, $trg_db, $src_link, $trg_link, $source_tables_uncommon, $uncommon_table_data_diff[$r],
671 $_SESSION['uncommon_tables_fields'], false);
673 unset($row_count[$uncommon_table_data_diff[$r]]);
676 * Again all the tables from source and target database are displayed with their differences.
677 * The differences have been removed from tables that have been synchronized
679 echo '<form name="applied_difference" id="synchronize_form" method="post" action="server_synchronize.php">'
680 . PMA_generate_common_hidden_inputs('', '');
682 PMA_syncDisplayHeaderCompare($src_db, $trg_db);
683 $rows = array();
684 for ($i = 0; $i < count($matching_tables); $i++) {
685 $num_alter_cols = 0;
686 $num_insert_cols = 0;
687 $num_remove_cols = 0;
688 $num_add_index = 0;
689 $num_remove_index = 0;
691 if (isset($alter_str_array[$i])) {
692 $num_alter_cols = sizeof($alter_str_array[$i]);
694 if (isset($add_column_array[$i])) {
695 $num_insert_cols = sizeof($add_column_array[$i]);
697 if (isset($uncommon_columns[$i])) {
698 $num_remove_cols = sizeof($uncommon_columns[$i]);
700 if (isset($add_indexes_array[$i])) {
701 $num_add_index = sizeof($add_indexes_array[$i]);
703 if (isset($remove_indexes_array[$i])) {
704 $num_remove_index = sizeof($remove_indexes_array[$i]);
707 $btn_structure_params = null;
708 $btn_data_params = null;
710 if (($num_alter_cols > 0) || ($num_insert_cols > 0) || ($num_remove_cols > 0) || ($num_add_index > 0) || ($num_remove_index > 0)) {
711 $btn_structure_params = array($i, $num_alter_cols, $num_insert_cols,
712 $num_remove_cols, $num_add_index, $num_remove_index);
714 if (!(in_array($i, $matching_table_data_diff))) {
716 if (isset($matching_tables_keys[$i][0]) && isset($update_array[$i][0][$matching_tables_keys[$i][0]])) {
717 if (isset($update_array[$i])) {
718 $num_of_updates = sizeof($update_array[$i]);
719 } else {
720 $num_of_updates = 0;
722 } else {
723 $num_of_updates = 0;
725 if (isset($matching_tables_keys[$i][0]) && isset($insert_array[$i][0][$matching_tables_keys[$i][0]])) {
726 if (isset($insert_array[$i])) {
727 $num_of_insertions = sizeof($insert_array[$i]);
728 } else {
729 $num_of_insertions = 0;
731 } else {
732 $num_of_insertions = 0;
735 if ((isset($matching_tables_keys[$i][0]) && isset($update_array[$i][0][$matching_tables_keys[$i][0]]))
736 || (isset($matching_tables_keys[$i][0]) && isset($insert_array[$i][0][$matching_tables_keys[$i][0]]))) {
737 $btn_data_params = array($i, $num_of_updates, $num_of_insertions,
738 null, null, null);
740 } else {
741 unset($update_array[$i]);
742 unset($insert_array[$i]);
744 $rows[] = array(
745 'src_table_name' => $matching_tables[$i],
746 'btn_type' => 'M',
747 'btn_structure' => $btn_structure_params,
748 'btn_data' => $btn_data_params
752 * placing updated value of arrays in session
755 $_SESSION['update_array'] = $update_array;
756 $_SESSION['insert_array'] = $insert_array;
758 for ($j = 0; $j < count($source_tables_uncommon); $j++) {
759 $btn_structure_params = null;
760 $btn_data_params = null;
763 * Display the difference only when it has not been applied
765 if (!(in_array($j, $uncommon_table_structure_diff))) {
766 if (isset($uncommon_tables[$j])) {
767 $btn_structure_params = array($j, null, null, null, null, null);
769 $dst_table_name = $source_tables_uncommon[$j] . ' (' . __('not present') . ')';
770 } else {
771 unset($uncommon_tables[$j]);
772 $dst_table_name = $source_tables_uncommon[$j];
775 * Display the difference only when it has not been applied
777 if (!(in_array($j, $uncommon_table_data_diff))) {
778 if (isset($row_count[$j]) && ($row_count[$j] > 0)) {
779 $btn_data_params = array($j, null, $row_count[$j], null, null, null);
781 } else {
782 unset($row_count[$j]);
785 $rows[] = array(
786 'src_table_name' => $source_tables_uncommon[$j],
787 'dst_table_name' => $dst_table_name,
788 'btn_type' => 'U',
789 'btn_structure' => $btn_structure_params,
790 'btn_data' => $btn_data_params
794 * placing the latest values of arrays in session
797 $_SESSION['uncommon_tables'] = $uncommon_tables;
798 $_SESSION['uncommon_tables_row_count'] = $row_count;
802 * Displaying the target database tables
804 foreach ($target_tables_uncommon as $tbl_nc_name) {
805 $rows[] = array(
806 'src_table_name' => '',
807 'dst_table_name' => $tbl_nc_name);
809 PMA_syncDisplayDataCompare($rows);
810 echo '</table>
811 </div>
812 </fieldset>';
815 * This "list" div will contain a table and each row will depict information about structure/data diffrence in tables.
816 * Rows will be generated dynamically as soon as the colored buttons "D" or "S" are clicked.
819 echo '<fieldset style="padding:0"><div id="list" style = "overflow:auto; height:140px; padding:1em">';
820 echo '<table>
821 <thead>
822 <tr style="width: 100%;">
823 <th id="table_name" style="width: 10%;" colspan="1">' . __('Table') . ' </th>
824 <th id="str_diff" style="width: 65%;" colspan="6">' . __('Structure Difference') . ' </th>
825 <th id="data_diff" style="width: 20%;" colspan="2">' . __('Data Difference') . '</th>
826 </tr>
827 <tr style="width: 100%;">
828 <th style="width: 10%;">' . __('Table name') . '</th>
829 <th style="width: 10%;">' . __('Create table'). '</th>
830 <th style="width: 11%;">' . __('Add column(s)') . '</th>
831 <th style="width: 13%;">' . __('Remove column(s)') . '</th>
832 <th style="width: 11%;">' . __('Alter column(s)') . '</th>
833 <th style="width: 12%;">' . __('Remove index(s)') . '</th>
834 <th style="width: 11%;">' . __('Apply index(s)') . '</th>
835 <th style="width: 10%;">' . __('Update row(s)') . '</th>
836 <th style="width: 10%;">' . __('Insert row(s)') . '</th>
837 </tr>
838 </thead>
839 <tbody></tbody>
840 </table>
841 </div></fieldset>';
844 * This fieldset displays the checkbox to confirm deletion of previous rows from target tables
846 echo '<fieldset>
847 <p><input type="checkbox" name="delete_rows" id ="delete_rows" /><label for="delete_rows">' . __('Would you like to delete all the previous rows from target tables?') . '</label> </p>
848 </fieldset>';
850 echo '<fieldset class="tblFooters">';
851 echo '<input type="button" name="apply_changes" value="' . __('Apply Selected Changes') . '"
852 onclick ="ApplySelectedChanges(' . "'" . htmlspecialchars($_SESSION['token']) . "'" .')" />';
853 echo '<input type="submit" name="synchronize_db" value="' . __('Synchronize Databases') . '" />'
854 . '</fieldset>';
855 echo '</form>';
859 * Displays the page when 'Synchronize Databases' is pressed.
862 if (isset($_REQUEST['synchronize_db'])) {
864 $src_db = $_SESSION['src_db'];
865 $trg_db = $_SESSION['trg_db'];
866 $update_array = $_SESSION['update_array'];
867 $insert_array = $_SESSION['insert_array'];
868 $src_username = $_SESSION['src_username'];
869 $trg_username = $_SESSION['trg_username'];
870 $src_password = $_SESSION['src_password'];
871 $trg_password = $_SESSION['trg_password'];
872 $matching_tables = $_SESSION['matching_tables'];
873 $matching_tables_keys = $_SESSION['matching_tables_keys'];
874 $matching_tables_fields = $_SESSION['matching_fields'];
875 $source_tables_uncommon = $_SESSION['src_uncommon_tables'];
876 $uncommon_tables_fields = $_SESSION['uncommon_tables_fields'];
877 $target_tables_uncommon = $_SESSION['target_tables_uncommon'];
878 $row_count = $_SESSION['uncommon_tables_row_count'];
879 $uncommon_tables = $_SESSION['uncommon_tables'];
880 $target_tables = $_SESSION['target_tables'];
882 $delete_array = $_SESSION['delete_array'];
883 $uncommon_columns = $_SESSION['uncommon_columns'];
884 $source_columns = $_SESSION['source_columns'];
885 $alter_str_array = $_SESSION['alter_str_array'];
886 $criteria = $_SESSION['criteria'];
887 $target_tables_keys = $_SESSION['target_tables_keys'];
888 $add_column_array = $_SESSION['add_column_array'];
889 $add_indexes_array = $_SESSION['add_indexes_array'];
890 $alter_indexes_array = $_SESSION['alter_indexes_array'];
891 $remove_indexes_array = $_SESSION['remove_indexes_array'];
892 $source_indexes = $_SESSION['source_indexes'];
893 $target_indexes = $_SESSION['target_indexes'];
894 $uncommon_cols = $uncommon_columns;
897 * Display success message.
899 echo '<div class="success">' . __('Target database has been synchronized with source database') . '</div>';
901 * Displaying all the tables of source and target database and now no difference is there.
903 PMA_syncDisplayHeaderCompare($src_db, $trg_db);
904 $rows = array();
905 for ($i = 0; $i < count($matching_tables); $i++)
907 $rows[] = array(
908 'src_table_name' => $matching_tables[$i],
909 'dst_table_name' => $matching_tables[$i]);
911 foreach ($source_tables_uncommon as $tbl_nc_name) {
912 $rows[] = array(
913 'src_table_name' => '+ ' + $tbl_nc_name,
914 'dst_table_name' => $tbl_nc_name);
916 foreach ($target_tables_uncommon as $tbl_nc_name) {
917 $rows[] = array(
918 'src_table_name' => '',
919 'dst_table_name' => $tbl_nc_name);
921 PMA_syncDisplayDataCompare($rows);
922 echo '</table>
923 </div>
924 </fieldset>';
927 * connecting the source and target servers
929 if ('cur' != $_SESSION['src_type']) {
930 $src_link = PMA_DBI_connect($src_username, $src_password, $is_controluser = false, $_SESSION['src_server']);
931 } else {
932 $src_link = $GLOBALS['userlink'];
933 // working on current server, so initialize this for tracking
934 // (does not work if user defined current server as a remote one)
935 $GLOBALS['db'] = $_SESSION['src_db'];
937 if ('cur' != $_SESSION['trg_type']) {
938 $trg_link = PMA_DBI_connect($trg_username, $trg_password, $is_controluser = false, $_SESSION['trg_server']);
939 } else {
940 $trg_link = $GLOBALS['userlink'];
941 // working on current server, so initialize this for tracking
942 $GLOBALS['db'] = $_SESSION['trg_db'];
946 * Displaying the queries.
948 echo '<h5>' . __('The following queries have been executed:') . '</h5>';
949 echo '<div id="serverstatus" style = "overflow: auto; width: 1050px; height: 180px;
950 border-left: 1px gray solid; border-bottom: 1px gray solid; padding: 0px; margin: 0px"> ';
952 * Applying all sorts of differences for each matching table
954 for ($p = 0; $p < sizeof($matching_tables); $p++) {
956 * If the check box is checked for deleting previous rows from the target database tables then
957 * first find out rows to be deleted and then delete the rows.
959 if (isset($_REQUEST['delete_rows'])) {
960 PMA_findDeleteRowsFromTargetTables($delete_array, $matching_tables, $p, $target_tables_keys, $matching_tables_keys,
961 $trg_db, $trg_link, $src_db, $src_link);
963 if (isset($delete_array[$p])) {
964 PMA_deleteFromTargetTable($trg_db, $trg_link, $matching_tables, $p, $target_tables_keys, $delete_array, true);
965 unset($delete_array[$p]);
968 if (isset($alter_str_array[$p])) {
969 PMA_alterTargetTableStructure($trg_db, $trg_link, $matching_tables, $source_columns, $alter_str_array, $matching_tables_fields,
970 $criteria, $matching_tables_keys, $target_tables_keys, $p, true);
971 unset($alter_str_array[$p]);
973 if (! empty($add_column_array[$p])) {
974 PMA_findDeleteRowsFromTargetTables($delete_array, $matching_tables, $p, $target_tables_keys, $matching_tables_keys,
975 $trg_db, $trg_link, $src_db, $src_link);
977 if (isset($delete_array[$p])) {
978 PMA_deleteFromTargetTable($trg_db, $trg_link, $matching_tables, $p, $target_tables_keys, $delete_array, true);
979 unset($delete_array[$p]);
981 PMA_addColumnsInTargetTable($src_db, $trg_db, $src_link, $trg_link, $matching_tables, $source_columns, $add_column_array,
982 $matching_tables_fields, $criteria, $matching_tables_keys, $target_tables_keys, $uncommon_tables, $uncommon_tables_fields,
983 $p, $uncommon_cols, true);
984 unset($add_column_array[$p]);
986 if (isset($uncommon_columns[$p])) {
987 PMA_removeColumnsFromTargetTable($trg_db, $trg_link, $matching_tables, $uncommon_columns, $p, true);
988 unset($uncommon_columns[$p]);
990 if (isset($matching_table_structure_diff) &&
991 (isset($add_indexes_array[$matching_table_structure_diff[$p]])
992 || isset($remove_indexes_array[$matching_table_structure_diff[$p]])
993 || isset($alter_indexes_array[$matching_table_structure_diff[$p]]))) {
994 PMA_applyIndexesDiff ($trg_db, $trg_link, $matching_tables, $source_indexes, $target_indexes, $add_indexes_array, $alter_indexes_array,
995 $remove_indexes_array, $matching_table_structure_diff[$p], true);
997 unset($add_indexes_array[$matching_table_structure_diff[$p]]);
998 unset($alter_indexes_array[$matching_table_structure_diff[$p]]);
999 unset($remove_indexes_array[$matching_table_structure_diff[$p]]);
1002 PMA_updateTargetTables($matching_tables, $update_array, $src_db, $trg_db, $trg_link, $p, $matching_tables_keys, true);
1004 PMA_insertIntoTargetTable($matching_tables, $src_db, $trg_db, $src_link, $trg_link , $matching_tables_fields, $insert_array, $p,
1005 $matching_tables_keys, $matching_tables_keys, $source_columns, $add_column_array, $criteria, $target_tables_keys, $uncommon_tables,
1006 $uncommon_tables_fields,$uncommon_cols, $alter_str_array,$source_indexes, $target_indexes, $add_indexes_array,
1007 $alter_indexes_array, $delete_array, $update_array, true);
1011 * Creating and populating tables present in source but absent from target database.
1013 for ($q = 0; $q < sizeof($source_tables_uncommon); $q++) {
1014 if (isset($uncommon_tables[$q])) {
1015 PMA_createTargetTables($src_db, $trg_db, $src_link, $trg_link, $source_tables_uncommon, $q, $uncommon_tables_fields, true);
1017 if (isset($row_count[$q])) {
1018 PMA_populateTargetTables($src_db, $trg_db, $src_link, $trg_link, $source_tables_uncommon, $q, $uncommon_tables_fields, true);
1021 echo "</div>";
1025 * Displays the main page when none of the following buttons is pressed
1028 if (! isset($_REQUEST['submit_connect']) && ! isset($_REQUEST['synchronize_db']) && ! isset($_REQUEST['Table_ids']) )
1031 * Displays the sub-page heading
1033 echo '<h2>' . ($GLOBALS['cfg']['MainPageIconic']
1034 ? '<img class="icon ic_s_sync" src="themes/dot.gif" alt="" />'
1035 : '')
1036 . __('Synchronize')
1037 .'</h2>';
1039 echo '<div id="serverstatus">
1040 <form name="connection_form" id="connection_form" method="post" action="server_synchronize.php"
1041 >' // TODO: add check if all var. are filled in
1042 . PMA_generate_common_hidden_inputs('', '');
1043 echo '<fieldset>';
1044 echo '<legend>' . __('Synchronize') . '</legend>';
1046 * Displays the forms
1049 $databases = PMA_DBI_get_databases_full(null, false, null, 'SCHEMA_NAME',
1050 'ASC', 0, true);
1052 if ($GLOBALS['cfg']['AllowArbitraryServer'] === false) {
1053 $possibly_readonly = ' readonly="readonly"';
1054 } else {
1055 $possibly_readonly = '';
1058 foreach ($cons as $type) {
1059 if ('src' == $type) {
1060 $database_header = __('Source database');
1061 } else {
1062 $database_header = __('Target database');
1065 $database_header .= PMA_showHint(PMA_sanitize(sprintf('%sAllowArbitraryServer%s', '[a@./Documentation.html#AllowArbitraryServer@_blank]', '[/a]')));
1067 <table id="serverconnection_<?php echo $type; ?>_remote" class="data noclick">
1068 <caption class="tblHeaders"><?php echo $database_header; ?></caption>
1069 <tr class="odd">
1070 <td colspan="2" style="text-align: center">
1071 <select name="<?php echo $type; ?>_type" id="<?php echo $type; ?>_type" class="server_selector">
1072 <?php
1073 if ($GLOBALS['cfg']['AllowArbitraryServer']) {
1074 $preselected_option = 'rmt';
1075 echo '<option value="rmt" selected="selected">' . __('Enter manually') . '</option>';
1076 } else {
1077 $preselected_option = 'cur';
1079 echo '<option value="cur"';
1080 if ('cur' == $preselected_option) {
1081 echo ' selected="selected"';
1083 echo '>' . __('Current connection') . '</option>';
1085 foreach ($GLOBALS['cfg']['Servers'] as $key => $tmp_server) {
1086 if (empty($tmp_server['host'])) {
1087 continue;
1090 if (!empty($tmp_server['verbose'])) {
1091 $label = $tmp_server['verbose'];
1092 } else {
1093 $label = $tmp_server['host'];
1094 if (!empty($tmp_server['port'])) {
1095 $label .= ':' . $tmp_server['port'];
1098 $value = $tmp_server['host'];
1099 $value .= '||||';
1100 if (empty($tmp_server['port']) && empty($tmp_server['socket'])) {
1101 $value .= '3306';
1102 } else {
1103 $value .= $tmp_server['port'];
1105 $value .= '||||';
1106 $value .= $tmp_server['socket'];
1107 $value .= '||||';
1108 $value .= $tmp_server['user'];
1109 $value .= '||||';
1110 $value .= $tmp_server['only_db'];
1111 echo '<option value="' . $value . '" >'
1112 . sprintf(__('Configuration: %s'), htmlspecialchars($label)) . '</option>';
1113 } // end foreach
1115 </select>
1116 </td>
1117 </tr>
1118 <tr class="even toggler remote-server">
1119 <td><?php echo __('Server'); ?></td>
1120 <td><input type="text" name="<?php echo $type; ?>_host" class="server-host" <?php echo $possibly_readonly; ?>/></td>
1121 </tr>
1122 <tr class="odd toggler remote-server">
1123 <td><?php echo __('Port'); ?></td>
1124 <td><input type="text" name="<?php echo $type; ?>_port" class="server-port" <?php echo $possibly_readonly; ?> value="3306" maxlength="5" size="5" /></td>
1125 </tr>
1126 <tr class="even toggler remote-server">
1127 <td><?php echo __('Socket'); ?></td>
1128 <td><input type="text" name="<?php echo $type; ?>_socket" class="server-socket" <?php echo $possibly_readonly; ?>/></td>
1129 </tr>
1130 <tr class="odd toggler remote-server">
1131 <td><?php echo __('User name'); ?></td>
1132 <td><input type="text" name="<?php echo $type; ?>_username" class="server-user" /></td>
1133 </tr>
1134 <tr class="even toggler remote-server">
1135 <td><?php echo __('Password'); ?></td>
1136 <td><input type="password" name="<?php echo $type; ?>_pass" class="server-pass" /> </td>
1137 </tr>
1138 <tr class="odd toggler remote-server">
1139 <td><?php echo __('Database'); ?></td>
1140 <td><input type="text" name="<?php echo $type; ?>_db" class="server-db" /></td>
1141 </tr>
1142 <tr class="even toggler current-server" style="display: none;">
1143 <td><?php echo __('Database'); ?></td>
1144 <td>
1145 <?php
1146 // these unset() do not complain if the elements do not exist
1147 unset($databases['mysql']);
1148 unset($databases['information_schema']);
1150 if (count($databases) == 0) {
1151 echo __('No databases');
1152 } else {
1153 echo '
1154 <select name="' . $type . '_db_sel">
1156 foreach ($databases as $db) {
1157 echo ' <option>' . htmlspecialchars($db['SCHEMA_NAME']) . '</option>';
1159 echo '</select>';
1161 echo '</td> </tr>
1162 </table>';
1164 unset ($types, $type);
1166 echo '
1167 </fieldset>
1168 <fieldset class="tblFooters">
1169 <input type="submit" name="submit_connect" value="' . __('Go') .'" id="buttonGo" />
1170 </fieldset>
1171 </form>
1172 </div>
1173 <div class="notice">' . __('Target database will be completely synchronized with source database. Source database will remain unchanged.') . '</div>';
1177 * Displays the footer
1179 require './libraries/footer.inc.php';