= 5.1.0 required by date functions if (file_exists(".config.php")) include(".config.php"); //SEF('DEBUG_S'); require_once dirname(__FILE__) . '/' . 'se-lib' . '/' . 'Lib.php'; Lib::loadClass('V'); Lib::loadClass('User'); Lib::loadClass('Config'); Lib::loadClass('App'); Lib::loadClass('DB'); Lib::loadClass('S'); echo ''."\n"; echo ""; echo ''; echo "\n".''."\n"; echo ''; echo ''; Lib::loadClass('DB_Dump'); if (!User::logged()) { die("Require login!"); } if (User::get('ADM_ADMIN_LEVEL') != 0) { die("Access denied!"); } $conf = Config::getZasobConf('Xdb_structupdater'); if (!$conf) { die("Error config for 'Xdb_structupdater' not exists!"); } $db_allowed = V::get('allowed_db', '', $conf); if (empty($db_allowed)) { die("Error in config - no allowe db set!"); } $db_allowed = explode(",", $db_allowed); $tbl_prefix_allowed = V::get('allowed_tbl_prefix', '', $conf); $tbl_prefix_allowed = (!empty($tbl_prefix_allowed))? explode(",", $tbl_prefix_allowed) : array('%'); $struct1_source = V::get('_s1', 'default', $_GET); $struct2_source = V::get('_s2', '', $_GET); $_tbl_prefix = V::get('_tbl_prefix', '', $_GET); if (!in_array($struct1_source, $db_allowed)) $struct1_source = ''; if (!in_array($struct2_source, $db_allowed)) $struct2_source = ''; echo '
'; echo "Source 1: "; echo ''; echo "Source 2: "; echo ''; echo "Tbl prefix: "; echo ''; echo " " . ''; echo '
'; if (empty($struct1_source) || empty($struct2_source) || empty($_tbl_prefix)) { die('

' . "Wybierz bazy danych i prefix tabel" . '

'); } $db = DB::getDB($struct1_source); if (!$db) { die("No db '" . $struct1_source . "'"); } else if ($db->has_errors()) { echo'
'."Errors db '" . $struct1_source . "':\n";print_r($db->get_errors());echo'
'; return; } $db2 = DB::getDB($struct2_source);// main db - sowa if (!$db2) { die("No db '" . $struct2_source . "'"); } else if ($db2->has_errors()) { echo'
'."Errors db '" . $struct2_source . "':\n";print_r($db2->get_errors());echo'
'; return; } Lib::loadClass('DB_Util'); $tbl_name = 'CRM_LISTA_ZASOBOW'; $ret = DB_Util::get_table_struct($db, $tbl_name); //echo'
ret: ';print_r($ret);echo'
'; $ret = DB_Util::get_table_struct($db2, $tbl_name); //echo'
ret2: ';print_r($ret);echo'
'; $ret = DB_Util::compare_db_table($db, $db2, $tbl_name); //echo'
ret3: ';print_r($ret);echo'
'; if ($ret === null || !is_array($ret)) { echo 'diff null'; } else if (empty($ret)) { echo 'diff empty'; } else { $sqls = DB_Util::compare_db_table_to_sql($tbl_name, $ret); //echo'
sqls: ';print_r($sqls);echo'
'; } echo '
'; $struct1 = DB_Dump::get_db_structure_by_table_prefix($db, $_tbl_prefix); //echo'
$struct1: ';print_r($struct1);echo'
'; if (!$struct1) { die("No struct for '" . $struct1_source . "'."); } $struct2 = DB_Dump::get_db_structure_by_table_prefix($db2, $_tbl_prefix); //echo'
$struct2: ';print_r($struct2);echo'
'; if (!$struct2) { die("No struct for '" . $struct2_source . "'."); } echo '

'."generating struct diff...".'

'; Lib::loadClass('DB_StructUpdater'); if (V::get('test', '', $_GET) == '123') { $file_struct1 = dirname(__FILE__) . '/../../sources/sowa.sql-bup-last/dump-diff-test.1.sql'; $file_struct2 = dirname(__FILE__) . '/../../sources/sowa.sql-bup-last/dump-diff-test.2.sql'; if (!file_exists($file_struct1)) { die("file struct1.sql not exists!"); } if (!file_exists($file_struct2)) { die("file struct2.sql not exists!"); } $struct1 = file_get_contents($file_struct1); $struct2 = file_get_contents($file_struct2); } echo ''; echo ''; echo ''; echo ''; echo ''; echo '
'; echo '

'."struct1.sql (" . $struct1_source . ")".'

'; echo ''; echo '
'; echo '

'."struct2.sql (" . $struct2_source . ")".'

'; echo ''; echo '
'; $updater = new DB_StructUpdater(); $res = $updater->getUpdates($struct2, $struct1); db_structupdater_print($res, "sync struct2 ($struct2_source) to struct1 ($struct1_source)"); $res = $updater->getUpdates($struct1, $struct2); db_structupdater_print($res, "sync struct1 ($struct1_source) to struct2 ($struct2_source)"); ?> ' . $title . " (" . $total . ")" . '

'; if ($total > 0) { $t = 0; foreach ($sql_arr as $line_nr => $line) { $sql_first_line = substr($line, 0, min(80, strpos($line . "\n", "\n"))); echo '
'; echo '
' . "-- " . $title . " (SQL " . ($line_nr + 1) . ")"; echo '' . " (- ukryj)" . ''; echo '' . " (+ pokaż) " . '' . $sql_first_line . " ..." . '' . ''; echo '
'; echo '
'; $out_rows = min(10, count(explode("\n", $line))); echo ''; echo '
'; echo '
';// .collapse } } }