Translation update done using Pootle.
[phpmyadmin/madhuracj.git] / server_synchronize.php
blob9ba41b7b3e092d6b5a00c30367d03375317183d8
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"})
77 && ! empty(${"{$con}_port"})
78 && ((int)${"{$con}_port"} * 1) > 0
79 ) {
80 ${"{$con}_server"}['port'] = (int)${"{$con}_port"};
84 ${"{$con}_connection"} = PMA_DBI_connect(${"{$con}_username"},
85 ${"{$con}_password"}, $is_controluser = false,
86 ${"{$con}_server"}, $auxiliary_connection = true);
87 } // end foreach ($cons as $con)
89 if ((! $src_connection && $src_type != 'cur')
90 || (! $trg_connection && $trg_type != 'cur')
91 ) {
92 /**
93 * Displays the connection error string if
94 * connections are not established
97 echo '<div class="error">';
98 if (! $src_connection && $src_type != 'cur') {
99 echo __('Could not connect to the source') . '<br />';
101 if (! $trg_connection && $trg_type != 'cur') {
102 echo __('Could not connect to the target');
104 echo '</div>';
105 unset($_REQUEST['submit_connect']);
107 } else {
109 * Creating the link object for both source and target databases and
110 * selecting the source and target databases using these links
112 foreach ($cons as $con) {
113 if (${"{$con}_connection"} != null) {
114 ${"{$con}_link"} = PMA_DBI_connect(${"{$con}_username"},
115 ${"{$con}_password"}, $is_controluser = false, ${"{$con}_server"});
116 } else {
117 ${"{$con}_link"} = null;
119 ${"{$con}_db_selected"} = PMA_DBI_select_db(${"{$con}_db"}, ${"{$con}_link"});
120 } // end foreach ($cons as $con)
122 if (($src_db_selected != 1) || ($trg_db_selected != 1)) {
124 * Displays error string if the database(s) did not exist
126 echo '<div class="error">';
127 if ($src_db_selected != 1) {
128 echo sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($src_db));
130 if ($trg_db_selected != 1) {
131 echo sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($trg_db));
133 echo '</div>';
134 unset($_REQUEST['submit_connect']);
136 } else if (($src_db_selected == 1) && ($trg_db_selected == 1)) {
139 * Using PMA_DBI_get_tables() to get all the tables
140 * from target and source databases.
142 $src_tables = PMA_DBI_get_tables($src_db, $src_link);
143 $source_tables_num = sizeof($src_tables);
145 $trg_tables = PMA_DBI_get_tables($trg_db, $trg_link);
146 $target_tables_num = sizeof($trg_tables);
149 * initializing arrays to save matching and non-matching
150 * table names from target and source databases.
152 $unmatched_num_src = 0;
153 $source_tables_uncommon = array();
154 $unmatched_num_trg = 0;
155 $target_tables_uncommon = array();
156 $matching_tables = array();
157 $matching_tables_num = 0;
160 * Using PMA_getMatchingTables to find which of the tables' names match
161 * in target and source database.
163 PMA_getMatchingTables($trg_tables, $src_tables, $matching_tables, $source_tables_uncommon);
165 * Finding the uncommon tables for the target database
166 * using function PMA_getNonMatchingTargetTables()
168 PMA_getNonMatchingTargetTables($trg_tables, $matching_tables, $target_tables_uncommon);
171 * Initializing several arrays to save the data and structure
172 * difference between the source and target databases.
174 $row_count = array(); //number of rows in source table that needs to be created in target database
175 $fields_num = array(); //number of fields in each matching table
176 $delete_array = array(); //stores the primary key values for target tables that have excessive rows than corresponding source tables.
177 $insert_array = array(array(array()));// stores the primary key values for the rows in each source table that are not present in target tables.
178 $update_array = array(array(array())); //stores the primary key values, name of field to be updated, value of the field to be updated for
179 // each row of matching table.
180 $matching_tables_fields = array(); //contains the fields' names for each matching table
181 $matching_tables_keys = array(); //contains the primary keys' names for each matching table
182 $uncommon_tables_fields = array(); //coantains the fields for all the source tables that are not present in target
183 $matching_tables_num = sizeof($matching_tables);
185 $source_columns = array(); //contains the full columns' information for all the source tables' columns
186 $target_columns = array(); //contains the full columns' information for all the target tables' columns
187 $uncommon_columns = array(); //contains names of columns present in source table but absent from the corresponding target table
188 $source_indexes = array(); //contains indexes on all the source tables
189 $target_indexes = array(); //contains indexes on all the target tables
190 $add_indexes_array = array(); //contains the indexes name present in source but absent from target tables
191 $target_tables_keys = array(); //contains the keys of all the target tables
192 $alter_indexes_array = array(); //contains the names of all the indexes for each table that need to be altered in target database
193 $remove_indexes_array = array(); //contains the names of indexes that are excessive in target tables
194 $alter_str_array = array(array()); //contains the criteria for each column that needs to be altered in target tables
195 $add_column_array = array(array()); //contains the name of columns that need to be added in target tables
197 * The criteria array contains all the criteria against which columns are compared for differences.
199 $criteria = array('Field', 'Type', 'Null', 'Collation', 'Key', 'Default', 'Comment');
201 for ($i = 0; $i < sizeof($matching_tables); $i++) {
203 * Finding out all the differences structure, data and index diff
204 * for all the matching tables only
206 PMA_dataDiffInTables($src_db, $trg_db, $src_link, $trg_link,
207 $matching_tables, $matching_tables_fields, $update_array,
208 $insert_array, $delete_array, $fields_num, $i,
209 $matching_tables_keys);
211 PMA_structureDiffInTables($src_db, $trg_db, $src_link, $trg_link,
212 $matching_tables, $source_columns, $target_columns,
213 $alter_str_array, $add_column_array, $uncommon_columns,
214 $criteria, $target_tables_keys, $i);
216 PMA_indexesDiffInTables($src_db, $trg_db, $src_link, $trg_link,
217 $matching_tables, $source_indexes, $target_indexes,
218 $add_indexes_array, $alter_indexes_array, $remove_indexes_array, $i);
221 for ($j = 0; $j < sizeof($source_tables_uncommon); $j++) {
223 * Finding out the number of rows to be added in tables
224 * that need to be added in target database
226 PMA_dataDiffInUncommonTables($source_tables_uncommon, $src_db,
227 $src_link, $j, $row_count);
231 * Storing all arrays in session for use when page is reloaded
232 * for each button press
234 $_SESSION['matching_tables'] = $matching_tables;
235 $_SESSION['update_array'] = $update_array;
236 $_SESSION['insert_array'] = $insert_array;
237 $_SESSION['src_db'] = $src_db;
238 $_SESSION['trg_db'] = $trg_db;
239 $_SESSION['matching_fields'] = $matching_tables_fields;
240 $_SESSION['src_uncommon_tables'] = $source_tables_uncommon;
241 $_SESSION['src_username'] = $src_username ;
242 $_SESSION['trg_username'] = $trg_username;
243 $_SESSION['src_password'] = $src_password;
244 $_SESSION['trg_password'] = $trg_password;
245 $_SESSION['trg_password'] = $trg_password;
246 $_SESSION['src_server'] = $src_server;
247 $_SESSION['trg_server'] = $trg_server;
248 $_SESSION['src_type'] = $src_type;
249 $_SESSION['trg_type'] = $trg_type;
250 $_SESSION['matching_tables_keys'] = $matching_tables_keys;
251 $_SESSION['uncommon_tables_fields'] = $uncommon_tables_fields;
252 $_SESSION['uncommon_tables_row_count'] = $row_count;
253 $_SESSION['target_tables_uncommon'] = $target_tables_uncommon;
254 $_SESSION['uncommon_tables'] = $source_tables_uncommon;
255 $_SESSION['delete_array'] = $delete_array;
256 $_SESSION['uncommon_columns'] = $uncommon_columns;
257 $_SESSION['source_columns'] = $source_columns;
258 $_SESSION['alter_str_array'] = $alter_str_array;
259 $_SESSION['target_tables_keys'] = $target_tables_keys;
260 $_SESSION['add_column_array'] = $add_column_array;
261 $_SESSION['criteria'] = $criteria;
262 $_SESSION['target_tables'] = $trg_tables;
263 $_SESSION['add_indexes_array'] = $add_indexes_array;
264 $_SESSION['alter_indexes_array'] = $alter_indexes_array;
265 $_SESSION['remove_indexes_array'] = $remove_indexes_array;
266 $_SESSION['source_indexes'] = $source_indexes;
267 $_SESSION['target_indexes'] = $target_indexes;
270 * Displays the sub-heading and icons showing Structure Synchronization
271 * and Data Synchronization
274 <form name="synchronize_form" id="synchronize_form" method="post" action="server_synchronize.php">
275 <?php echo PMA_generate_common_hidden_inputs('', ''); ?>
276 <table width="40%">
277 <tr>
278 <td>
279 <img class="icon" src="<?php echo $pmaThemeImage; ?>new_struct.png" width="16" height="16" alt="" />
280 <?php echo __('Structure Synchronization'); ?>
281 </td>
282 <td>
283 <img class="icon" src="<?php echo $pmaThemeImage; ?>new_data.png" width="16" height="16" alt="" />
284 <?php echo __('Data Synchronization'); ?>
285 </td>
286 </tr>
287 </table>
288 <?php
290 * Displays the tables containing the source tables names,
291 * their difference with the target tables and target tables names.
293 PMA_syncDisplayHeaderCompare($src_db, $trg_db);
294 $rows = array();
297 * Display the matching tables' names and difference, first
299 for ($i = 0; $i < count($matching_tables); $i++) {
301 * Calculating the number of updates for each matching table
303 if (isset($update_array[$i]) && isset($update_array[$i][0])
304 && !empty($matching_tables_keys[$i][0])
305 && isset($update_array[$i][0][$matching_tables_keys[$i][0]])) {
306 $num_of_updates = sizeof($update_array[$i]);
307 } else {
308 $num_of_updates = 0;
311 * Calculating the number of insertions for each matching table
313 if (isset($insert_array[$i]) && isset($insert_array[$i][0])
314 && !empty($matching_tables_keys[$i])
315 && isset($insert_array[$i][0][$matching_tables_keys[$i][0]])) {
316 $num_of_insertions = sizeof($insert_array[$i]);
317 } else {
318 $num_of_insertions = 0;
322 * Calculating the number of alter columns, number of columns to be
323 * added, number of columns to be removed,
324 * number of index to be added and removed.
326 $num_alter_cols = 0;
327 $num_insert_cols = 0;
328 $num_remove_cols = 0;
329 $num_add_index = 0;
330 $num_remove_index = 0;
332 if (isset($alter_str_array[$i])) {
333 $num_alter_cols = sizeof($alter_str_array[$i]);
335 if (isset($add_column_array[$i])) {
336 $num_insert_cols = sizeof($add_column_array[$i]);
338 if (isset($uncommon_columns[$i])) {
339 $num_remove_cols = sizeof($uncommon_columns[$i]);
341 if (isset($add_indexes_array[$i])) {
342 $num_add_index = sizeof($add_indexes_array[$i]);
344 if (isset($remove_indexes_array[$i])) {
345 $num_remove_index = sizeof($remove_indexes_array[$i]);
347 if (isset($alter_indexes_array[$i])) {
348 $num_add_index += sizeof($alter_indexes_array[$i]);
349 $num_remove_index += sizeof($alter_indexes_array[$i]);
352 $btn_structure_params = null;
353 $btn_data_params = null;
356 * Display the red button of structure synchronization if there
357 * exists any structure difference or index difference.
359 if (($num_alter_cols > 0)
360 || ($num_insert_cols > 0)
361 || ($num_remove_cols > 0)
362 || ($num_add_index > 0)
363 || ($num_remove_index > 0)
365 $btn_structure_params = array($i, $num_alter_cols, $num_insert_cols,
366 $num_remove_cols, $num_add_index, $num_remove_index);
370 * Display the green button of data synchronization if there exists
371 * any data difference.
373 if ((isset($update_array[$i])
374 || isset($insert_array[$i]))
375 && !empty($matching_tables_keys[$i])
377 if (isset($update_array[$i][0][$matching_tables_keys[$i][0]])
378 || isset($insert_array[$i][0][$matching_tables_keys[$i][0]])
380 $btn_data_params = array($i, $num_of_updates,
381 $num_of_insertions, null, null, null);
385 $rows[] = array(
386 'src_table_name' => $matching_tables[$i],
387 'dst_table_name' => $matching_tables[$i],
388 'btn_type' => 'M',
389 'btn_structure' => $btn_structure_params,
390 'btn_data' => $btn_data_params
394 * Displays the tables' names present in source but missing from target
396 for ($j = 0; $j < count($source_tables_uncommon); $j++) {
397 $row = array(
398 'src_table_name' => '+ ' . $source_tables_uncommon[$j],
399 'dst_table_name' => $source_tables_uncommon[$j] . ' (' . __('not present') . ')',
400 'btn_type' => 'U',
401 'btn_structure' => array($j, null, null, null, null, null),
402 'btn_data' => null
404 if ($row_count[$j] > 0) {
405 $row['btn_data'] = array($j, null, $row_count[$j], null, null, null);
407 $rows[] = $row;
409 foreach ($target_tables_uncommon as $tbl_nc_name) {
410 $rows[] = array(
411 'src_table_name' => '',
412 'dst_table_name' => $tbl_nc_name);
415 * Displays the target tables names
417 PMA_syncDisplayDataCompare($rows);
418 echo '</table>
419 </div>
420 </fieldset>';
423 * This "list" div will contain a table and each row will depict
424 * information about structure/data difference in tables.
425 * Rows will be generated dynamically as soon as the colored
426 * buttons "D" or "S" are clicked.
429 echo '<fieldset style="padding:0"><div id="list" style="overflow:auto; height:140px; padding:1em">
431 <table>
432 <thead>
433 <tr style="width: 100%;">
434 <th id="table_name" style="width: 10%;" colspan="1">' . __('Table') . ' </th>
435 <th id="str_diff" style="width: 65%;" colspan="6">' . __('Structure Difference') . ' </th>
436 <th id="data_diff" style="width: 20%;" colspan="2">' . __('Data Difference') . '</th>
437 </tr>
438 <tr style="width: 100%;">
439 <th style="width: 10%;">' . __('Table name') . '</th>
440 <th style="width: 10%;">' . __('Create table'). '</th>
441 <th style="width: 11%;">' . __('Add column(s)') . '</th>
442 <th style="width: 13%;">' . __('Remove column(s)') . '</th>
443 <th style="width: 11%;">' . __('Alter column(s)') . '</th>
444 <th style="width: 12%;">' . __('Remove index(s)') . '</th>
445 <th style="width: 11%;">' . __('Apply index(s)') . '</th>
446 <th style="width: 10%;">'. __('Update row(s)') . '</th>
447 <th style="width: 10%;">' . __('Insert row(s)') . '</th>
448 </tr>
449 </thead>
450 <tbody></tbody>
451 </table>
452 </div></fieldset>';
454 * This fieldset displays the checkbox to confirm deletion of previous rows from target tables
456 echo '<fieldset>
457 <p><input type= "checkbox" name="delete_rows" id ="delete_rows" /><label for="delete_rows">'
458 . __('Would you like to delete all the previous rows from target tables?')
459 . '</label> </p>
460 </fieldset>
461 <fieldset class="tblFooters">';
462 echo '<input type="button" name="apply_changes" value="'
463 . __('Apply Selected Changes')
464 . '" onclick ="ApplySelectedChanges('
465 . "'" . htmlspecialchars($_SESSION['token']) . "'" . ')" />';
466 echo '<input type="submit" name="synchronize_db" value="'
467 . __('Synchronize Databases') . '" />' . '</fieldset>';
468 echo '</form>';
471 } // end if ((isset($_REQUEST['submit_connect'])))
474 * Display the page when 'Apply Selected Changes' is pressed
476 if (isset($_REQUEST['Table_ids'])) {
478 * Displays success message
480 echo '<div class="success">'
481 . __('Selected target tables have been synchronized with source tables.')
482 . '</div>';
484 $src_db = $_SESSION['src_db'];
485 $trg_db = $_SESSION['trg_db'];
486 $update_array = $_SESSION['update_array'];
487 $insert_array = $_SESSION['insert_array'];
488 $src_username = $_SESSION['src_username'];
489 $trg_username = $_SESSION['trg_username'];
490 $src_password = $_SESSION['src_password'];
491 $trg_password = $_SESSION['trg_password'];
492 $src_server = $_SESSION['src_server'];
493 $trg_server = $_SESSION['trg_server'];
494 $src_type = $_SESSION['src_type'];
495 $trg_type = $_SESSION['trg_type'];
496 $uncommon_tables = $_SESSION['uncommon_tables'];
497 $matching_tables = $_SESSION['matching_tables'];
498 $matching_tables_keys = $_SESSION['matching_tables_keys'];
499 $matching_tables_fields = $_SESSION['matching_fields'];
500 $source_tables_uncommon = $_SESSION['src_uncommon_tables'];
501 $uncommon_tables_fields = $_SESSION['uncommon_tables_fields'];
502 $target_tables_uncommon = $_SESSION['target_tables_uncommon'];
503 $row_count = $_SESSION['uncommon_tables_row_count'];
504 $target_tables = $_SESSION['target_tables'];
506 $delete_array = $_SESSION['delete_array'];
507 $uncommon_columns = $_SESSION['uncommon_columns'];
508 $source_columns = $_SESSION['source_columns'];
509 $alter_str_array = $_SESSION['alter_str_array'];
510 $criteria = $_SESSION['criteria'];
511 $target_tables_keys = $_SESSION['target_tables_keys'];
512 $add_column_array = $_SESSION['add_column_array'];
513 $add_indexes_array = $_SESSION['add_indexes_array'];
514 $alter_indexes_array = $_SESSION['alter_indexes_array'];
515 $remove_indexes_array = $_SESSION['remove_indexes_array'];
516 $source_indexes = $_SESSION['source_indexes'];
517 $target_indexes = $_SESSION['target_indexes'];
518 $uncommon_cols = $uncommon_columns;
521 * Creating link object for source and target databases
523 foreach ($cons as $con) {
524 if (${"{$con}_type"} != "cur") {
525 ${"{$con}_link"} = PMA_DBI_connect(${"{$con}_username"},
526 ${"{$con}_password"}, $is_controluser = false, ${"{$con}_server"});
527 } else {
528 ${"{$con}_link"} = null;
529 // working on current server, so initialize this for tracking
530 // (does not work if user defined current server as a remote one)
531 $GLOBALS['db'] = ${"{$con}_db"};
533 } // end foreach ($cons as $con)
536 * Initializing arrays to save the table ids whose data and structure difference is to be applied
538 $matching_table_data_diff = array(); //stores id of matching table having data difference
539 $matching_table_structure_diff = array(); //stores id of matching tables having structure difference
540 $uncommon_table_structure_diff = array(); //stores id of uncommon tables having structure difference
541 $uncommon_table_data_diff = array(); //stores id of uncommon tables having data difference
543 for ($i = 0; isset($_REQUEST[$i]); $i++ ) {
544 if (isset($_REQUEST[$i])) {
545 $table_id = explode("US", $_REQUEST[$i]);
546 if (isset($table_id[1])) {
547 $uncommon_table_structure_diff[] = $table_id[1];
549 $table_id = explode("UD", $_REQUEST[$i]);
550 if (isset($table_id[1])) {
551 $uncommon_table_data_diff[] = $table_id[1];
553 $table_id = explode("MS", $_REQUEST[$i]);
554 if (isset($table_id[1])) {
555 $matching_table_structure_diff[] = $table_id[1];
558 $table_id = explode("MD", $_REQUEST[$i]);
559 if (isset($table_id[1])) {
560 $matching_table_data_diff[] = $table_id[1];
563 } // end for
565 * Applying the structure difference on selected matching tables
567 for ($q = 0; $q < sizeof($matching_table_structure_diff); $q++) {
568 if (isset($alter_str_array[$matching_table_structure_diff[$q]])) {
569 PMA_alterTargetTableStructure($trg_db, $trg_link, $matching_tables,
570 $source_columns, $alter_str_array, $matching_tables_fields,
571 $criteria, $matching_tables_keys, $target_tables_keys,
572 $matching_table_structure_diff[$q], false);
574 unset($alter_str_array[$matching_table_structure_diff[$q]]);
576 if (isset($add_column_array[$matching_table_structure_diff[$q]])) {
577 PMA_findDeleteRowsFromTargetTables($delete_array, $matching_tables,
578 $matching_table_structure_diff[$q], $target_tables_keys,
579 $matching_tables_keys, $trg_db, $trg_link, $src_db, $src_link);
581 if (isset($delete_array[$matching_table_structure_diff[$q]])) {
582 PMA_deleteFromTargetTable($trg_db, $trg_link, $matching_tables,
583 $matching_table_structure_diff[$q], $target_tables_keys,
584 $delete_array, false);
586 unset($delete_array[$matching_table_structure_diff[$q]]);
588 PMA_addColumnsInTargetTable($src_db, $trg_db,$src_link, $trg_link,
589 $matching_tables, $source_columns, $add_column_array,
590 $matching_tables_fields, $criteria, $matching_tables_keys,
591 $target_tables_keys, $uncommon_tables,$uncommon_tables_fields,
592 $matching_table_structure_diff[$q], $uncommon_cols, false);
594 unset($add_column_array[$matching_table_structure_diff[$q]]);
596 if (isset($uncommon_columns[$matching_table_structure_diff[$q]])) {
597 PMA_removeColumnsFromTargetTable($trg_db, $trg_link, $matching_tables,
598 $uncommon_columns, $matching_table_structure_diff[$q], false);
600 unset($uncommon_columns[$matching_table_structure_diff[$q]]);
602 if (isset($add_indexes_array[$matching_table_structure_diff[$q]])
603 || isset($remove_indexes_array[$matching_table_structure_diff[$q]])
604 || isset($alter_indexes_array[$matching_table_structure_diff[$q]])
606 PMA_applyIndexesDiff ($trg_db, $trg_link, $matching_tables,
607 $source_indexes, $target_indexes, $add_indexes_array,
608 $alter_indexes_array, $remove_indexes_array,
609 $matching_table_structure_diff[$q], false);
611 unset($add_indexes_array[$matching_table_structure_diff[$q]]);
612 unset($alter_indexes_array[$matching_table_structure_diff[$q]]);
613 unset($remove_indexes_array[$matching_table_structure_diff[$q]]);
617 * Applying the data difference. First checks if structure diff is applied or not.
618 * If not, then apply structure difference first then apply data difference.
620 for ($p = 0; $p < sizeof($matching_table_data_diff); $p++) {
621 if ($_REQUEST['checked'] == 'true') {
622 PMA_findDeleteRowsFromTargetTables($delete_array, $matching_tables,
623 $matching_table_data_diff[$p], $target_tables_keys,
624 $matching_tables_keys, $trg_db, $trg_link, $src_db, $src_link);
626 if (isset($delete_array[$matching_table_data_diff[$p]])) {
627 PMA_deleteFromTargetTable($trg_db, $trg_link, $matching_tables,
628 $matching_table_data_diff[$p], $target_tables_keys,
629 $delete_array, false);
631 unset($delete_array[$matching_table_data_diff[$p]]);
634 if (isset($alter_str_array[$matching_table_data_diff[$p]])) {
635 PMA_alterTargetTableStructure($trg_db, $trg_link, $matching_tables,
636 $source_columns, $alter_str_array, $matching_tables_fields,
637 $criteria, $matching_tables_keys, $target_tables_keys,
638 $matching_table_data_diff[$p], false);
640 unset($alter_str_array[$matching_table_data_diff[$p]]);
642 if (isset($add_column_array[$matching_table_data_diff[$p]])) {
643 PMA_findDeleteRowsFromTargetTables($delete_array, $matching_tables,
644 $matching_table_data_diff[$p], $target_tables_keys,
645 $matching_tables_keys, $trg_db, $trg_link, $src_db, $src_link);
647 if (isset($delete_array[$matching_table_data_diff[$p]])) {
648 PMA_deleteFromTargetTable($trg_db, $trg_link, $matching_tables,
649 $matching_table_data_diff[$p], $target_tables_keys,
650 $delete_array, false);
652 unset($delete_array[$matching_table_data_diff[$p]]);
654 PMA_addColumnsInTargetTable($src_db, $trg_db,$src_link, $trg_link,
655 $matching_tables, $source_columns, $add_column_array,
656 $matching_tables_fields, $criteria, $matching_tables_keys,
657 $target_tables_keys, $uncommon_tables, $uncommon_tables_fields,
658 $matching_table_data_diff[$p], $uncommon_cols, false);
660 unset($add_column_array[$matching_table_data_diff[$p]]);
662 if (isset($uncommon_columns[$matching_table_data_diff[$p]])) {
663 PMA_removeColumnsFromTargetTable($trg_db, $trg_link, $matching_tables,
664 $uncommon_columns, $matching_table_data_diff[$p], false);
666 unset($uncommon_columns[$matching_table_data_diff[$p]]);
668 if ((isset($matching_table_structure_diff[$q])
669 && isset($add_indexes_array[$matching_table_structure_diff[$q]]))
670 || (isset($matching_table_structure_diff[$q])
671 && isset($remove_indexes_array[$matching_table_structure_diff[$q]]))
672 || (isset($matching_table_structure_diff[$q])
673 && isset($alter_indexes_array[$matching_table_structure_diff[$q]]))
675 PMA_applyIndexesDiff ($trg_db, $trg_link, $matching_tables,
676 $source_indexes, $target_indexes, $add_indexes_array,
677 $alter_indexes_array, $remove_indexes_array,
678 $matching_table_structure_diff[$q], false);
680 unset($add_indexes_array[$matching_table_structure_diff[$q]]);
681 unset($alter_indexes_array[$matching_table_structure_diff[$q]]);
682 unset($remove_indexes_array[$matching_table_structure_diff[$q]]);
685 * Applying the data difference.
687 PMA_updateTargetTables($matching_tables, $update_array, $src_db, $trg_db,
688 $trg_link, $matching_table_data_diff[$p], $matching_tables_keys, false);
690 PMA_insertIntoTargetTable($matching_tables, $src_db, $trg_db, $src_link,
691 $trg_link, $matching_tables_fields, $insert_array,
692 $matching_table_data_diff[$p], $matching_tables_keys, $source_columns,
693 $add_column_array, $criteria, $target_tables_keys, $uncommon_tables,
694 $uncommon_tables_fields, $uncommon_cols, $alter_str_array,
695 $source_indexes, $target_indexes, $add_indexes_array,
696 $alter_indexes_array, $delete_array, $update_array, false);
699 * Updating the session variables to the latest values of the arrays.
701 $_SESSION['delete_array'] = $delete_array;
702 $_SESSION['uncommon_columns'] = $uncommon_columns;
703 $_SESSION['alter_str_array'] = $alter_str_array;
704 $_SESSION['add_column_array'] = $add_column_array;
705 $_SESSION['add_indexes_array'] = $add_indexes_array;
706 $_SESSION['remove_indexes_array'] = $remove_indexes_array;
707 $_SESSION['insert_array'] = $insert_array;
708 $_SESSION['update_array'] = $update_array;
711 * Applying structure difference to selected non-matching tables
712 * (present in Source but absent from Target).
714 for ($s = 0; $s < sizeof($uncommon_table_structure_diff); $s++) {
715 PMA_createTargetTables($src_db, $trg_db, $src_link, $trg_link,
716 $uncommon_tables, $uncommon_table_structure_diff[$s],
717 $uncommon_tables_fields, false);
718 $_SESSION['uncommon_tables_fields'] = $uncommon_tables_fields;
720 unset($uncommon_tables[$uncommon_table_structure_diff[$s]]);
723 * Applying data difference to selected non-matching tables
724 * (present in Source but absent from Target).
725 * Before data synchronization, structure synchronization is confirmed.
727 for ($r = 0; $r < sizeof($uncommon_table_data_diff); $r++) {
728 if (!(in_array($uncommon_table_data_diff[$r], $uncommon_table_structure_diff))) {
729 if (isset($uncommon_tables[$uncommon_table_data_diff[$r]])) {
730 PMA_createTargetTables($src_db, $trg_db, $src_link, $trg_link,
731 $uncommon_tables, $uncommon_table_data_diff[$r],
732 $uncommon_tables_fields, false);
733 $_SESSION['uncommon_tables_fields'] = $uncommon_tables_fields;
735 unset($uncommon_tables[$uncommon_table_data_diff[$r]]);
738 PMA_populateTargetTables($src_db, $trg_db, $src_link, $trg_link,
739 $source_tables_uncommon, $uncommon_table_data_diff[$r],
740 $_SESSION['uncommon_tables_fields'], false);
742 unset($row_count[$uncommon_table_data_diff[$r]]);
745 * Again all the tables from source and target database are displayed with their differences.
746 * The differences have been removed from tables that have been synchronized
748 echo '<form name="applied_difference" id="synchronize_form" method="post" action="server_synchronize.php">'
749 . PMA_generate_common_hidden_inputs('', '');
751 PMA_syncDisplayHeaderCompare($src_db, $trg_db);
752 $rows = array();
753 for ($i = 0; $i < count($matching_tables); $i++) {
754 $num_alter_cols = 0;
755 $num_insert_cols = 0;
756 $num_remove_cols = 0;
757 $num_add_index = 0;
758 $num_remove_index = 0;
760 if (isset($alter_str_array[$i])) {
761 $num_alter_cols = sizeof($alter_str_array[$i]);
763 if (isset($add_column_array[$i])) {
764 $num_insert_cols = sizeof($add_column_array[$i]);
766 if (isset($uncommon_columns[$i])) {
767 $num_remove_cols = sizeof($uncommon_columns[$i]);
769 if (isset($add_indexes_array[$i])) {
770 $num_add_index = sizeof($add_indexes_array[$i]);
772 if (isset($remove_indexes_array[$i])) {
773 $num_remove_index = sizeof($remove_indexes_array[$i]);
776 $btn_structure_params = null;
777 $btn_data_params = null;
779 if (($num_alter_cols > 0)
780 || ($num_insert_cols > 0)
781 || ($num_remove_cols > 0)
782 || ($num_add_index > 0)
783 || ($num_remove_index > 0)
785 $btn_structure_params = array($i, $num_alter_cols, $num_insert_cols,
786 $num_remove_cols, $num_add_index, $num_remove_index);
788 if (!(in_array($i, $matching_table_data_diff))) {
789 if (isset($matching_tables_keys[$i][0])
790 && isset($update_array[$i][0][$matching_tables_keys[$i][0]])
792 if (isset($update_array[$i])) {
793 $num_of_updates = sizeof($update_array[$i]);
794 } else {
795 $num_of_updates = 0;
797 } else {
798 $num_of_updates = 0;
800 if (isset($matching_tables_keys[$i][0])
801 && isset($insert_array[$i][0][$matching_tables_keys[$i][0]])
803 if (isset($insert_array[$i])) {
804 $num_of_insertions = sizeof($insert_array[$i]);
805 } else {
806 $num_of_insertions = 0;
808 } else {
809 $num_of_insertions = 0;
812 if ((isset($matching_tables_keys[$i][0])
813 && isset($update_array[$i][0][$matching_tables_keys[$i][0]]))
814 || (isset($matching_tables_keys[$i][0])
815 && isset($insert_array[$i][0][$matching_tables_keys[$i][0]]))
817 $btn_data_params = array($i, $num_of_updates, $num_of_insertions,
818 null, null, null);
820 } else {
821 unset($update_array[$i]);
822 unset($insert_array[$i]);
824 $rows[] = array(
825 'src_table_name' => $matching_tables[$i],
826 'dst_table_name' => $matching_tables[$i],
827 'btn_type' => 'M',
828 'btn_structure' => $btn_structure_params,
829 'btn_data' => $btn_data_params
833 * placing updated value of arrays in session
836 $_SESSION['update_array'] = $update_array;
837 $_SESSION['insert_array'] = $insert_array;
839 for ($j = 0; $j < count($source_tables_uncommon); $j++) {
840 $btn_structure_params = null;
841 $btn_data_params = null;
844 * Display the difference only when it has not been applied
846 if (!(in_array($j, $uncommon_table_structure_diff))) {
847 if (isset($uncommon_tables[$j])) {
848 $btn_structure_params = array($j, null, null, null, null, null);
850 $dst_table_name = $source_tables_uncommon[$j] . ' (' . __('not present') . ')';
851 } else {
852 unset($uncommon_tables[$j]);
853 $dst_table_name = $source_tables_uncommon[$j];
856 * Display the difference only when it has not been applied
858 if (!(in_array($j, $uncommon_table_data_diff))) {
859 if (isset($row_count[$j]) && ($row_count[$j] > 0)) {
860 $btn_data_params = array($j, null, $row_count[$j], null, null, null);
862 } else {
863 unset($row_count[$j]);
866 $rows[] = array(
867 'src_table_name' => $source_tables_uncommon[$j],
868 'dst_table_name' => $dst_table_name,
869 'btn_type' => 'U',
870 'btn_structure' => $btn_structure_params,
871 'btn_data' => $btn_data_params
875 * placing the latest values of arrays in session
878 $_SESSION['uncommon_tables'] = $uncommon_tables;
879 $_SESSION['uncommon_tables_row_count'] = $row_count;
883 * Displaying the target database tables
885 foreach ($target_tables_uncommon as $tbl_nc_name) {
886 $rows[] = array(
887 'src_table_name' => '',
888 'dst_table_name' => $tbl_nc_name);
890 PMA_syncDisplayDataCompare($rows);
891 echo '</table>
892 </div>
893 </fieldset>';
896 * This "list" div will contain a table and each row will depict information about
897 * structure/data difference in tables.
898 * Rows will be generated dynamically as soon as the colored buttons "D" or "S"
899 * are clicked.
902 echo '<fieldset style="padding:0"><div id="list" style = "overflow:auto; height:140px; padding:1em">';
903 echo '<table>
904 <thead>
905 <tr style="width: 100%;">
906 <th id="table_name" style="width: 10%;" colspan="1">' . __('Table') . ' </th>
907 <th id="str_diff" style="width: 65%;" colspan="6">' . __('Structure Difference') . ' </th>
908 <th id="data_diff" style="width: 20%;" colspan="2">' . __('Data Difference') . '</th>
909 </tr>
910 <tr style="width: 100%;">
911 <th style="width: 10%;">' . __('Table name') . '</th>
912 <th style="width: 10%;">' . __('Create table'). '</th>
913 <th style="width: 11%;">' . __('Add column(s)') . '</th>
914 <th style="width: 13%;">' . __('Remove column(s)') . '</th>
915 <th style="width: 11%;">' . __('Alter column(s)') . '</th>
916 <th style="width: 12%;">' . __('Remove index(s)') . '</th>
917 <th style="width: 11%;">' . __('Apply index(s)') . '</th>
918 <th style="width: 10%;">' . __('Update row(s)') . '</th>
919 <th style="width: 10%;">' . __('Insert row(s)') . '</th>
920 </tr>
921 </thead>
922 <tbody></tbody>
923 </table>
924 </div></fieldset>';
927 * This fieldset displays the checkbox to confirm deletion of previous rows from target tables
929 echo '<fieldset>
930 <p><input type="checkbox" name="delete_rows" id ="delete_rows" /><label for="delete_rows">'
931 . __('Would you like to delete all the previous rows from target tables?') . '</label> </p>
932 </fieldset>';
934 echo '<fieldset class="tblFooters">';
935 echo '<input type="button" name="apply_changes" value="'
936 . __('Apply Selected Changes') . '" onclick ="ApplySelectedChanges('
937 . "'" . htmlspecialchars($_SESSION['token']) . "'" .')" />';
938 echo '<input type="submit" name="synchronize_db" value="'
939 . __('Synchronize Databases') . '" />'
940 . '</fieldset>';
941 echo '</form>';
945 * Displays the page when 'Synchronize Databases' is pressed.
948 if (isset($_REQUEST['synchronize_db'])) {
950 $src_db = $_SESSION['src_db'];
951 $trg_db = $_SESSION['trg_db'];
952 $update_array = $_SESSION['update_array'];
953 $insert_array = $_SESSION['insert_array'];
954 $src_username = $_SESSION['src_username'];
955 $trg_username = $_SESSION['trg_username'];
956 $src_password = $_SESSION['src_password'];
957 $trg_password = $_SESSION['trg_password'];
958 $matching_tables = $_SESSION['matching_tables'];
959 $matching_tables_keys = $_SESSION['matching_tables_keys'];
960 $matching_tables_fields = $_SESSION['matching_fields'];
961 $source_tables_uncommon = $_SESSION['src_uncommon_tables'];
962 $uncommon_tables_fields = $_SESSION['uncommon_tables_fields'];
963 $target_tables_uncommon = $_SESSION['target_tables_uncommon'];
964 $row_count = $_SESSION['uncommon_tables_row_count'];
965 $uncommon_tables = $_SESSION['uncommon_tables'];
966 $target_tables = $_SESSION['target_tables'];
968 $delete_array = $_SESSION['delete_array'];
969 $uncommon_columns = $_SESSION['uncommon_columns'];
970 $source_columns = $_SESSION['source_columns'];
971 $alter_str_array = $_SESSION['alter_str_array'];
972 $criteria = $_SESSION['criteria'];
973 $target_tables_keys = $_SESSION['target_tables_keys'];
974 $add_column_array = $_SESSION['add_column_array'];
975 $add_indexes_array = $_SESSION['add_indexes_array'];
976 $alter_indexes_array = $_SESSION['alter_indexes_array'];
977 $remove_indexes_array = $_SESSION['remove_indexes_array'];
978 $source_indexes = $_SESSION['source_indexes'];
979 $target_indexes = $_SESSION['target_indexes'];
980 $uncommon_cols = $uncommon_columns;
983 * Display success message.
985 echo '<div class="success">'
986 . __('Target database has been synchronized with source database')
987 . '</div>';
989 * Displaying all the tables of source and target database
990 * and now no difference is there.
992 PMA_syncDisplayHeaderCompare($src_db, $trg_db);
993 $rows = array();
994 for ($i = 0; $i < count($matching_tables); $i++) {
995 $rows[] = array(
996 'src_table_name' => $matching_tables[$i],
997 'dst_table_name' => $matching_tables[$i]);
999 foreach ($source_tables_uncommon as $tbl_nc_name) {
1000 $rows[] = array(
1001 'src_table_name' => '+ ' . $tbl_nc_name,
1002 'dst_table_name' => $tbl_nc_name);
1004 foreach ($target_tables_uncommon as $tbl_nc_name) {
1005 $rows[] = array(
1006 'src_table_name' => '',
1007 'dst_table_name' => $tbl_nc_name);
1009 PMA_syncDisplayDataCompare($rows);
1010 echo '</table>
1011 </div>
1012 </fieldset>';
1015 * connecting the source and target servers
1017 if ('cur' != $_SESSION['src_type']) {
1018 $src_link = PMA_DBI_connect($src_username, $src_password,
1019 $is_controluser = false, $_SESSION['src_server']);
1020 } else {
1021 $src_link = $GLOBALS['userlink'];
1022 // working on current server, so initialize this for tracking
1023 // (does not work if user defined current server as a remote one)
1024 $GLOBALS['db'] = $_SESSION['src_db'];
1026 if ('cur' != $_SESSION['trg_type']) {
1027 $trg_link = PMA_DBI_connect($trg_username, $trg_password,
1028 $is_controluser = false, $_SESSION['trg_server']);
1029 } else {
1030 $trg_link = $GLOBALS['userlink'];
1031 // working on current server, so initialize this for tracking
1032 $GLOBALS['db'] = $_SESSION['trg_db'];
1036 * Displaying the queries.
1038 echo '<fieldset><legend>' . __('Executed queries') . '</legend>';
1040 * Applying all sorts of differences for each matching table
1042 for ($p = 0; $p < sizeof($matching_tables); $p++) {
1044 * If the check box is checked for deleting previous rows from the target database tables then
1045 * first find out rows to be deleted and then delete the rows.
1047 if (isset($_REQUEST['delete_rows'])) {
1048 PMA_findDeleteRowsFromTargetTables($delete_array, $matching_tables, $p,
1049 $target_tables_keys, $matching_tables_keys,
1050 $trg_db, $trg_link, $src_db, $src_link);
1052 if (isset($delete_array[$p])) {
1053 PMA_deleteFromTargetTable($trg_db, $trg_link, $matching_tables, $p,
1054 $target_tables_keys, $delete_array, true);
1055 unset($delete_array[$p]);
1058 if (isset($alter_str_array[$p])) {
1059 PMA_alterTargetTableStructure($trg_db, $trg_link, $matching_tables,
1060 $source_columns, $alter_str_array, $matching_tables_fields,
1061 $criteria, $matching_tables_keys, $target_tables_keys, $p, true);
1062 unset($alter_str_array[$p]);
1064 if (! empty($add_column_array[$p])) {
1065 PMA_findDeleteRowsFromTargetTables($delete_array, $matching_tables, $p,
1066 $target_tables_keys, $matching_tables_keys,
1067 $trg_db, $trg_link, $src_db, $src_link);
1069 if (isset($delete_array[$p])) {
1070 PMA_deleteFromTargetTable($trg_db, $trg_link, $matching_tables, $p,
1071 $target_tables_keys, $delete_array, true);
1072 unset($delete_array[$p]);
1074 PMA_addColumnsInTargetTable($src_db, $trg_db, $src_link, $trg_link,
1075 $matching_tables, $source_columns, $add_column_array,
1076 $matching_tables_fields, $criteria, $matching_tables_keys,
1077 $target_tables_keys, $uncommon_tables, $uncommon_tables_fields,
1078 $p, $uncommon_cols, true);
1079 unset($add_column_array[$p]);
1081 if (isset($uncommon_columns[$p])) {
1082 PMA_removeColumnsFromTargetTable($trg_db, $trg_link, $matching_tables,
1083 $uncommon_columns, $p, true);
1084 unset($uncommon_columns[$p]);
1086 if (isset($matching_table_structure_diff)
1087 && (isset($add_indexes_array[$matching_table_structure_diff[$p]])
1088 || isset($remove_indexes_array[$matching_table_structure_diff[$p]])
1089 || isset($alter_indexes_array[$matching_table_structure_diff[$p]]))
1091 PMA_applyIndexesDiff ($trg_db, $trg_link, $matching_tables,
1092 $source_indexes, $target_indexes, $add_indexes_array,
1093 $alter_indexes_array, $remove_indexes_array,
1094 $matching_table_structure_diff[$p], true);
1096 unset($add_indexes_array[$matching_table_structure_diff[$p]]);
1097 unset($alter_indexes_array[$matching_table_structure_diff[$p]]);
1098 unset($remove_indexes_array[$matching_table_structure_diff[$p]]);
1101 PMA_updateTargetTables($matching_tables, $update_array, $src_db, $trg_db,
1102 $trg_link, $p, $matching_tables_keys, true);
1104 PMA_insertIntoTargetTable($matching_tables, $src_db, $trg_db, $src_link,
1105 $trg_link , $matching_tables_fields, $insert_array, $p,
1106 $matching_tables_keys, $matching_tables_keys, $source_columns,
1107 $add_column_array, $criteria, $target_tables_keys, $uncommon_tables,
1108 $uncommon_tables_fields,$uncommon_cols, $alter_str_array,$source_indexes,
1109 $target_indexes, $add_indexes_array,
1110 $alter_indexes_array, $delete_array, $update_array, true);
1114 * Creating and populating tables present in source but absent
1115 * from target database.
1117 for ($q = 0; $q < sizeof($source_tables_uncommon); $q++) {
1118 if (isset($uncommon_tables[$q])) {
1119 PMA_createTargetTables($src_db, $trg_db, $src_link, $trg_link,
1120 $source_tables_uncommon, $q, $uncommon_tables_fields, true);
1122 if (isset($row_count[$q])) {
1123 PMA_populateTargetTables($src_db, $trg_db, $src_link, $trg_link,
1124 $source_tables_uncommon, $q, $uncommon_tables_fields, true);
1127 echo "</fieldset>";
1131 * Displays the main page when none of the following buttons is pressed
1134 if (! isset($_REQUEST['submit_connect'])
1135 && ! isset($_REQUEST['synchronize_db'])
1136 && ! isset($_REQUEST['Table_ids'])
1139 * Displays the sub-page heading
1141 echo '<h2>' . ($GLOBALS['cfg']['MainPageIconic']
1142 ? '<img class="icon ic_s_sync" src="themes/dot.gif" alt="" />'
1143 : '')
1144 . __('Synchronize')
1145 .'</h2>';
1147 echo '<div id="serverstatus">
1148 <form name="connection_form" id="connection_form" method="post" action="server_synchronize.php"
1149 >' // TODO: add check if all var. are filled in
1150 . PMA_generate_common_hidden_inputs('', '');
1151 echo '<fieldset>';
1152 echo '<legend>' . __('Synchronize') . '</legend>';
1154 * Displays the forms
1157 $databases = PMA_DBI_get_databases_full(null, false, null, 'SCHEMA_NAME',
1158 'ASC', 0, true);
1160 if ($GLOBALS['cfg']['AllowArbitraryServer'] === false) {
1161 $possibly_readonly = ' readonly="readonly"';
1162 } else {
1163 $possibly_readonly = '';
1166 foreach ($cons as $type) {
1167 if ('src' == $type) {
1168 $database_header = __('Source database');
1169 } else {
1170 $database_header = __('Target database');
1173 $database_header .= PMA_showHint(PMA_sanitize(sprintf('%sAllowArbitraryServer%s',
1174 '[a@./Documentation.html#AllowArbitraryServer@_blank]', '[/a]')));
1176 <table id="serverconnection_<?php echo $type; ?>_remote" class="data noclick">
1177 <caption class="tblHeaders"><?php echo $database_header; ?></caption>
1178 <tr class="odd">
1179 <td colspan="2" style="text-align: center">
1180 <select name="<?php echo $type; ?>_type" id="<?php echo $type; ?>_type" class="server_selector">
1181 <?php
1182 if ($GLOBALS['cfg']['AllowArbitraryServer']) {
1183 $preselected_option = 'rmt';
1184 echo '<option value="rmt" selected="selected">' . __('Enter manually') . '</option>';
1185 } else {
1186 $preselected_option = 'cur';
1188 echo '<option value="cur"';
1189 if ('cur' == $preselected_option) {
1190 echo ' selected="selected"';
1192 echo '>' . __('Current connection') . '</option>';
1194 foreach ($GLOBALS['cfg']['Servers'] as $key => $tmp_server) {
1195 if (empty($tmp_server['host']) && empty($tmp_server['socket'])) {
1196 continue;
1199 if (!empty($tmp_server['verbose'])) {
1200 $label = $tmp_server['verbose'];
1201 } else {
1202 $label = $tmp_server['host'];
1203 if (!empty($tmp_server['port'])) {
1204 $label .= ':' . $tmp_server['port'];
1207 $value = $tmp_server['host'];
1208 $value .= '||||';
1209 if (empty($tmp_server['port']) && empty($tmp_server['socket'])) {
1210 $value .= '3306';
1211 } else {
1212 $value .= $tmp_server['port'];
1214 $value .= '||||';
1215 $value .= $tmp_server['socket'];
1216 $value .= '||||';
1217 $value .= $tmp_server['user'];
1218 $value .= '||||';
1219 $value .= $tmp_server['only_db'];
1220 echo '<option value="' . $value . '" >'
1221 . sprintf(__('Configuration: %s'), htmlspecialchars($label)) . '</option>';
1222 } // end foreach
1224 </select>
1225 </td>
1226 </tr>
1227 <tr class="even toggler remote-server">
1228 <td><?php echo __('Server'); ?></td>
1229 <td><input type="text" name="<?php echo $type; ?>_host" class="server-host" <?php echo $possibly_readonly; ?>/></td>
1230 </tr>
1231 <tr class="odd toggler remote-server">
1232 <td><?php echo __('Port'); ?></td>
1233 <td><input type="text" name="<?php echo $type; ?>_port" class="server-port" <?php echo $possibly_readonly; ?> value="3306" maxlength="5" size="5" /></td>
1234 </tr>
1235 <tr class="even toggler remote-server">
1236 <td><?php echo __('Socket'); ?></td>
1237 <td><input type="text" name="<?php echo $type; ?>_socket" class="server-socket" <?php echo $possibly_readonly; ?>/></td>
1238 </tr>
1239 <tr class="odd toggler remote-server">
1240 <td><?php echo __('User name'); ?></td>
1241 <td><input type="text" name="<?php echo $type; ?>_username" class="server-user" /></td>
1242 </tr>
1243 <tr class="even toggler remote-server">
1244 <td><?php echo __('Password'); ?></td>
1245 <td><input type="password" name="<?php echo $type; ?>_pass" class="server-pass" /> </td>
1246 </tr>
1247 <tr class="odd toggler remote-server">
1248 <td><?php echo __('Database'); ?></td>
1249 <td><input type="text" name="<?php echo $type; ?>_db" class="server-db" /></td>
1250 </tr>
1251 <tr class="even toggler current-server" style="display: none;">
1252 <td><?php echo __('Database'); ?></td>
1253 <td>
1254 <?php
1255 // these unset() do not complain if the elements do not exist
1256 unset($databases['mysql']);
1257 unset($databases['information_schema']);
1259 if (count($databases) == 0) {
1260 echo __('No databases');
1261 } else {
1262 echo '
1263 <select name="' . $type . '_db_sel">
1265 foreach ($databases as $db) {
1266 echo ' <option>' . htmlspecialchars($db['SCHEMA_NAME']) . '</option>';
1268 echo '</select>';
1270 echo '</td> </tr>
1271 </table>';
1273 unset ($types, $type);
1275 echo '
1276 </fieldset>
1277 <fieldset class="tblFooters">
1278 <input type="submit" name="submit_connect" value="' . __('Go') .'" id="buttonGo" />
1279 </fieldset>
1280 </form>
1281 </div>
1282 <div class="notice">' . __('Target database will be completely synchronized with source database. Source database will remain unchanged.') . '</div>';
1286 * Displays the footer
1288 require './libraries/footer.inc.php';