// print "Enter source database name (prefix added automatically): <input type='text' name='sourcedbname' />";
print "Choose source database: <select id='db' name='sourcedbname'>";
$list = mysql__getdatabases();
foreach ($list as $name) {
    print "<option value='{$name}' " . ($sourcedbname == $name ? "selected='selected'" : "") . ">{$name}</option>";
}
print "</select>";
print "<input type='checkbox' name='useoid' value='1' " . ($useOriginalID ? "checked='checked'" : "") . "/>Use Concept ID&nbsp;&nbsp;";
print "<input type='submit' value='Continue' />";
print "</form>";
if ($sourcedbname == null) {
    exit;
}
// ----FORM 2 - MAPPINGS FORM ----------------------------------------------------------------------------------------
$sourcedbname = $_REQUEST['sourcedbname'];
createMappingForm(null);
// ---- Create mapping form -----------------------------------------------------------------
function getPresetId($config, $id)
{
    if ($config && array_key_exists($id, $config)) {
        return $config[$id];
    } else {
        return null;
    }
}
/**
 * put your comment there...
 *
 *
 * @param mixed $config
 */
function saveSettings()
{
    global $sourcedbname;
    $config = array();
    $str = "";
    foreach ($_REQUEST as $name => $value) {
        $pos = strpos($name, "cb");
        if (is_numeric($pos) && $pos == 0) {
            $str = $str . $name . "=" . $value . ",";
            $config[$name] = $value;
        }
    }
    $folder = HEURIST_UPLOAD_DIR . "settings/";
    if (!file_exists($folder)) {
        if (!mkdir($folder, 0777, true)) {
            die('Failed to create folder for settings');
        }
    }
    $filename = $folder . "importfrom_" . $sourcedbname . ".cfg";
    file_put_contents($filename, $str);
    print "SETTINGS ARE SAVED!!!!";
    createMappingForm($config);
}