function DoImport() { global $sql, $lang; $r = '<span class="swarnung">'; $zeilen = count($sql['import']['csv']) - $sql['import']['namefirstline']; $sql['import']['first_zeile'] = explode($sql['import']['trenn'], $sql['import']['csv'][0]); $importfelder = count($sql['import']['first_zeile']); if ($sql['import']['tablecreate'] == 0) { $res = MSD_query("show fields FROM " . $sql['import']['table']); $tabellenfelder = mysql_num_rows($res); if ($importfelder != $tabellenfelder) { $r .= '<br>' . sprintf($lang['csv_fieldcount_nomatch'], $tabellenfelder, $importfelder); } else { $ok = 1; } } else { $ok = ImportCreateTable(); if ($ok == 0) { $r .= '<br>' . sprintf($lang['csv_errorcreatetable'], $sql['import']['table']); } } if ($ok == 1) { $insert = ""; if ($sql['import']['emptydb'] == 1 && $sql['import']['tablecreate'] == 0) { MSD_DoSQL("TRUNCATE " . $sql['import']['table'] . ";"); } $sql['import']['lines_imported'] = 0; $enc = $sql['import']['enc'] == "" ? "'" : ""; $zc = ""; for ($i = $sql['import']['namefirstline']; $i < $zeilen + $sql['import']['namefirstline']; $i++) { //Importieren $insert = "INSERT INTO " . $sql['import']['table'] . " VALUES("; if ($sql['import']['createindex'] == 1) { $insert .= "'', "; } $zc .= trim(rtrim($sql['import']['csv'][$i])); echo "Zeile {$i}: {$zc}<br>"; if ($zc != "" && substr($zc, -1) == $enc) { $zeile = explode($sql['import']['trenn'], $zc); for ($j = 0; $j < $importfelder; $j++) { $a = $zeile[$j] == "" && $enc == "" ? "''" : $zeile[$j]; $insert .= $enc . $a . $enc . ($j == $importfelder - 1 ? ");\n" : ","); } //MSD_DoSQL($insert); $sql['import']['lines_imported']++; $zc = ""; } } $r .= sprintf($lang['csv_fieldslines'], $importfelder, $sql['import']['lines_imported']); } $r .= '</span>'; return $r; }
} if ($newkeys[1] == 1) { $sql_alter .= " UNIQUE INDEX "; } if ($newkeys[2] == 1) { $sql_alter .= " INDEX "; } if ($newkeys[3] == 1) { $sql_alter .= " FULLTEXT INDEX "; } $sql_alter .= $_POST['f_position'] . " ;"; if ($add_sql != "") { $add_sql = $sql_stamm . $add_sql; $sql_alter = "{$sql_alter};\n{$add_sql};\n"; } MSD_DoSQL($sql_alter); echo '<div align="left" id="sqleditbox" style="font-size: 11px;width:90%;padding=6px;">'; echo '<p class="success"> `' . $_POST['f_name'] . '` ' . (isset($_POST['editfield']) ? $lang['L_SQL_CHANGED'] : $lang['L_SQL_CREATED']) . '.</p>'; echo highlight_sql($out) . '</div>'; $fields_infos = getFieldinfos($databases['Name'][$dbid], $table_edit_name); } } mysql_select_db($databases['Name'][$dbid]); $sqlt = "SHOW TABLE STATUS FROM `" . $databases['Name'][$dbid] . "` ;"; $res = MSD_query($sqlt); $anz_tabellen = mysql_numrows($res); $p = "sql.php?db=" . $databases['Name'][$dbid] . "&dbid={$dbid}&tablename={$table_edit_name}&context=2"; echo '<form action="sql.php?db=' . $databases['Name'][$dbid] . '&dbid=' . $dbid . '&tablename=' . $table_edit_name . '&context=2" method="post">'; echo '<table class="bdr"><tr class="dbrow"><td>' . $lang['L_SQL_CREATETABLE'] . ': </td><td colspan="2"><input type="text" class="text" name="newtablename" size="30" maxlength="150"></td><td><input type="submit" name="newtablesubmit" value="' . $lang['L_SQL_CREATETABLE'] . '" class="Formbutton"></td></tr>'; echo '<tr class="dbrow1"><td>' . $lang['L_SQL_COPYTABLE'] . ': </td><td><input type="text" class="text" name="tablecopyname" size="20" maxlength="150"></td><td><select name="copyatt"><option value="0">' . $lang['L_SQL_STRUCTUREONLY'] . '</option>' . (MSD_NEW_VERSION ? '<option value="1">' . $lang['L_SQL_STRUCTUREDATA'] . '</option>' : '') . '</select></td><td><input type="submit" class="Formbutton" name="tablecopysubmit" value="' . $lang['L_SQL_COPYTABLE'] . '" ' . ($table_edit_name == "" ? "disabled=\"disabled\"" : "") . '></td></tr>'; if ($anz_tabellen == 0) {
function Table_Copy($source, $destination, $insert_data, $destinationdb = "") { global $config; if (!isset($config['dbconnection'])) { MSD_mysql_connect(); } $SQL_Array = $t = ""; $sqlc = "SHOW CREATE TABLE {$source}"; $res = MSD_query($sqlc); $row = mysql_fetch_row($res); $c = $row[1]; $a1 = strpos($c, "`"); $a2 = strpos($c, "`", $a1 + 1); $c = substr($c, 0, $a1 + 1) . $destination . substr($c, $a2); if (substr($c, -1) == ";") { $c = substr($c, 0, strlen($c) - 1); } $SQL_Array .= $insert_data == 1 ? "{$c} SELECT * FROM {$source} ;\n" : "{$c} ;\n"; //echo "<h5>$SQL_Array</h5>"; MSD_DoSQL($SQL_Array); }
echo '<script type="text/javascript" language="javascript">' . 'parent.MySQL_Dumper_menu.location.href=\'menu.php?dbindex=' . $dbid . '\';</script>'; } echo '</p><p class="tablename">' . ($tn != '' ? $lang['L_TABLE'] . ' <strong>`' . $databases['db_actual'] . '`.`' . $tn . '`</strong><br>' : ''); if (isset($msg)) { echo $msg; } $numrowsabs = -1; $numrows = 0; // vorgehensweise - zwischen SELECT und FROM alles rausschneiden und durch count(*) ersetzen // es soll die Summe der Datensaetze ermittelt werden, wenn es kein LIMIT geben wuerde, um die // Blaettern-Links korrekt anzuzeigen $skip_mysql_execution = false; if ($sql_to_display_data == 0) { //mehrere SQL-Statements $numrowsabs = $numrows = 0; MSD_DoSQL($sql['sql_statement']); echo SQLOutput($out); $skip_mysql_execution = true; } else { $sql_temp = strtolower($sql['sql_statement']); if (substr($sql_temp, 0, 7) == 'select ') { if (false !== strpos($sql_temp, ' limit ')) { // es wurde ein eigenes Lmit im Query angegeben - eigene Berechnung abbrechen $numrowsabs = -1; } else { $pos = strpos($sql_temp, 'from '); $sql_temp = 'SELECT count(*) as anzahl ' . substr($sql['sql_statement'], $pos, strlen($sql['sql_statement']) - $pos); $res = @MSD_query($sql_temp, false); if ($res) { if ($row = mysql_fetch_object($res)) { $numrowsabs = $row->anzahl;
get_sql_encodings(); //Datenbanken if (isset($_GET['dbrefresh'])) { SetDefault(); } echo $aus . '<h4>' . $lang['L_TOOLS'] . '</h4>'; if (isset($_POST['dbdosubmit'])) { $newname = $_POST['newname']; $db_index = $_POST['db_index']; echo "<br>Db-Index:" . $_GET['db_index']; $db_action = $_POST['db_action']; $changed = false; $ausgabe = $out = ""; switch ($db_action) { case "drop": MSD_DoSQL("DROP DATABASE `" . $databases['Name'][$db_index] . "`"); echo SQLOutput($out, '<p class="success">' . $lang['L_DB'] . ' `' . $databases['Name'][$db_index] . '` wurde gelöscht.</p>'); $changed = true; break; case "empty": EmptyDB($databases['Name'][$db_index]); echo SQLOutput($out, '<p class="success">' . $lang['L_DB'] . ' `' . $databases['Name'][$db_index] . '` ' . $lang['L_SQL_WASEMPTIED'] . '.</p>'); break; case "rename": $dbold = $databases['Name'][$db_index]; DB_Copy($dbold, $newname, 1); echo SQLOutput($out, '<p class="success">' . $lang['L_DB'] . ' `' . $dbold . '` ' . $lang['L_SQL_RENAMEDTO'] . ' `' . $newname . '`.</p>'); $changed = true; break; case "copy": $dbold = $databases['Name'][$db_index];