' . $lang['sql_tablesofdb'] . ' `' . $databases['Name'][$dbid] . '` ' . $lang['sql_edit'] . ''; //////////////////////// DH //Primaerschluessel loeschen if (isset($_GET['killPrimaryKey'])) { $keys=getPrimaryKeys($databases['Name'][$dbid],$_GET['tablename']); //Zu loeschenden Schluessel aus dem Array entfernen $keyPos=array_search($_GET['killPrimaryKey'],$keys); if (!( false === $keyPos )) { unset($keys[$keyPos]); $res=setNewPrimaryKeys($databases['Name'][$dbid],$_GET['tablename'],$keys); if ($res) { echo ''; } else { echo ''; } } else { echo ''; } } //Primärschlüssel löschen ende //Neue Primärschlüssel setzen if (isset($_POST['setNewPrimaryKeys'])) { $fields=getAllFields($databases['Name'][$dbid],$_GET['tablename']); $newKeysArray=Array(); foreach ($fields as $index=>$field) { if (( isset($_POST["setNewPrimKey" . $index]) ) && ( $_POST["setNewPrimKey" . $index] != "" )) { $newKeysArray[]=$_POST["setNewPrimKey" . $index]; } } //doppelte Elemente entfernen $newKeysArray=array_unique($newKeysArray); $res=setNewPrimaryKeys($databases['Name'][$dbid],$_GET['tablename'],$newKeysArray); if ($res) { echo ''; } else { echo ''; } } //Neue Primärschlüssel setzen ende //////////////////////// DH ende if (isset($_GET['kill'])) { if ($_GET['anz'] == 1) echo '

' . $lang['sql_nofielddelete'] . '

'; else { $sql_alter="ALTER TABLE `" . $databases['Name'][$dbid] . "`.`" . $_GET['tablename'] . "` DROP COLUMN `" . $_GET['kill'] . "`"; MSD_DoSQL($sql_alter); echo '
'; echo '

' . $lang['sql_fielddelete1'] . ' `' . $_GET['kill'] . '` ' . $lang['sql_deleted'] . '.

' . highlight_sql($out) . '
'; } } if (isset($_POST['tablecopysubmit'])) { $table_edit_name=$_GET['tablename']; if ($_POST['tablecopyname'] == "") { echo '

' . $lang['sql_nodest_copy'] . '

'; } elseif (Table_Exists($databases['Name'][$dbid],$_POST['tablecopyname'])) { echo '

' . $lang['sql_desttable_exists'] . '

'; } else { Table_Copy("`" . $databases['Name'][$dbid] . "`.`" . $table_edit_name . "`",$_POST['tablecopyname'],$_POST['copyatt']); echo '
'; echo ( $_POST['copyatt'] == 0 ) ? '

' . sprintf($lang['sql_scopy'],$table_edit_name,$_POST['tablecopyname']) . '.

' : sprintf($lang['sql_tcopy'],$table_edit_name,$_POST['tablecopyname']) . '

'; echo highlight_sql($out) . '
'; $tablename=$_POST['tablecopyname']; } } if (isset($_POST['newtablesubmit'])) { if ($_POST['newtablename'] == "") { echo '

' . $lang['sql_tablenoname'] . '

'; } else { $sql_alter="CREATE TABLE `" . $databases['Name'][$dbid] . "`.`" . $_POST['newtablename'] . "` (`id` int(11) unsigned not null AUTO_INCREMENT PRIMARY KEY ) " . ( ( MSD_NEW_VERSION ) ? "ENGINE" : "TYPE" ) . "=MyISAM;"; MSD_DoSQL($sql_alter); echo SQLOutput($out,$lang['table'] . ' `' . $_POST['newtablename'] . '` ' . $lang['sql_created']); } } if (isset($_POST['t_edit_submit'])) { $sql_alter="ALTER TABLE `" . $databases['Name'][$dbid] . "`.`" . $_POST['table_edit_name'] . "` "; if ($_POST['t_edit_name'] == "") echo '

' . $lang['sql_tblnameempty'] . '

'; elseif (MSD_NEW_VERSION && $_POST['t_edit_collate'] != "" && substr($_POST['t_edit_collate'],0,strlen($_POST['t_edit_charset'])) != $_POST['t_edit_charset']) echo '

' . $lang['sql_collatenotmatch'] . '

'; else { if ($_POST['table_edit_name'] != $_POST['t_edit_name']) { $sql_alter.="RENAME TO `" . $_POST['t_edit_name'] . "`, "; $table_edit_name=$_POST['t_edit_name']; } else $table_edit_name=$_POST['table_edit_name']; if ($_POST['t_edit_engine'] != "") $sql_alter.=( ( MSD_NEW_VERSION ) ? "ENGINE=" : "TYPE=" ) . $_POST['t_edit_engine'] . ", "; if ($_POST['t_edit_rowformat'] != "") $sql_alter.="ROW_FORMAT=" . $_POST['t_edit_rowformat'] . ", "; if (MSD_NEW_VERSION && $_POST['t_edit_charset'] != "") $sql_alter.="DEFAULT CHARSET=" . $_POST['t_edit_charset'] . ", "; if (MSD_NEW_VERSION && $_POST['t_edit_collate'] != "") $sql_alter.="COLLATE " . $_POST['t_edit_collate'] . ", "; $sql_alter.="COMMENT='" . $_POST['t_edit_comment'] . "' "; MSD_DoSQL($sql_alter); echo SQLOutput($out,$lang['table'] . ' `' . $_POST['table_edit_name'] . '` ' . $lang['sql_changed']); } } else { if (!isset($table_edit_name) || $table_edit_name == "") { $table_edit_name=( isset($_GET['tablename']) ) ? $_GET['tablename'] : ""; if (isset($_POST['tableselect'])) $table_edit_name=$_POST['tableselect']; if (isset($_POST['newtablesubmit'])) $table_edit_name=$_POST['newtablename']; } } if (isset($_POST['newfield_posted'])) { //build sql for alter if ($_POST['f_name'] == '') { echo '

' . $lang['sql_fieldnamenotvalid'] . ' (' . $_POST['f_name'] . ')

'; $field_fehler=1; } else { //alter Key $oldkeys[0]=$_POST['f_primary']; $oldkeys[1]=$_POST['f_unique']; $oldkeys[2]=$_POST['f_index']; $oldkeys[3]=$_POST['f_fulltext']; //neuer Key $newkeys[0]=( $_POST['f_index_new'] == "primary" ) ? 1 : 0; $newkeys[1]=( $_POST['f_index_new'] == "unique" ) ? 1 : 0; $newkeys[2]=( $_POST['f_index_new'] == "index" ) ? 1 : 0; $newkeys[3]=( isset($_POST['f_indexfull']) ) ? 1 : 0; $add_sql.=ChangeKeys($oldkeys,$newkeys,$_POST['f_name'],$_POST['f_size'],"drop_only"); $sql_stamm="ALTER TABLE `" . $databases['Name'][$dbid] . "`.`$table_edit_name` "; $sql_alter=$sql_stamm . ( ( isset($_POST['editfield']) ) ? "CHANGE COLUMN `" . $_POST['fieldname'] . "` `" . $_POST['f_name'] . "` " : "ADD COLUMN `" . $_POST['f_name'] . "` " ); $sql_alter.=$_POST['f_type']; $wl=stripslashes($_POST['f_size']); if ($wl != "" && !preg_match('@^(DATE|DATETIME|TIME|TINYBLOB|TINYTEXT|BLOB|TEXT|MEDIUMBLOB|MEDIUMTEXT|LONGBLOB|LONGTEXT)$@i',$_POST['f_type'])) { $sql_alter.="($wl) "; } elseif ($_POST['f_size'] == "" && preg_match('@^(VARCHAR)$@i',$_POST['f_type'])) { $sql_alter.="(" . "255" . ") "; } else $sql_alter.=" "; $sql_alter.=$_POST['f_attribut'] . " "; $sql_alter.=$_POST['f_null'] . " "; $sql_alter.=( $_POST['f_default'] != "" ) ? "DEFAULT '" . addslashes($_POST['f_default']) . "' " : ""; if (MSD_NEW_VERSION && $_POST['f_collate'] != "") $sql_alter.="COLLATE " . $_POST['f_collate'] . " "; if ($_POST['f_extra'] == "AUTO_INCREMENT") { $sql_alter.=" AUTO_INCREMENT "; } if ($newkeys[0] == 1) $sql_alter.=" PRIMARY KEY "; 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 '
'; echo '

`' . $_POST['f_name'] . '` ' . ( ( isset($_POST['editfield']) ) ? $lang['sql_changed'] : $lang['sql_created'] ) . '.

'; echo highlight_sql($out) . '
'; $fields_infos=FillFieldinfos($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 '
'; echo ''; echo ''; if ($anz_tabellen == 0) { echo ''; } else { echo ''; echo ''; echo ''; } echo '
' . $lang['new'] . ' ' . $lang['sql_createtable'] . ':
' . $lang['sql_copytable'] . ':
' . $lang['sql_notablesindb'] . ' `' . $databases['Name'][$dbid] . '`
' . $lang['sql_selecttable'] . ':     

 

'; if ($table_edit_name != "") { $sqlf="SHOW FULL FIELDS FROM `" . $databases['Name'][$dbid] . "`.`$table_edit_name` ;"; $res=MSD_query($sqlf); $anz_fields=mysql_num_rows($res); $fields_infos=FillFieldinfos($databases['Name'][$dbid],$table_edit_name); if (MSD_NEW_VERSION) $t_engine=( isset($fields_infos['_tableinfo_']['ENGINE']) ) ? $fields_infos['_tableinfo_']['ENGINE'] : "MyISAM"; else $t_engine=( isset($fields_infos['_tableinfo_']['TYPE']) ) ? $fields_infos['_tableinfo_']['TYPE'] : "MyISAM"; $t_charset=( isset($fields_infos['_tableinfo_']['DEFAULT CHARSET']) ) ? $fields_infos['_tableinfo_']['DEFAULT CHARSET'] : ""; $t_collation=isset($row['Collation']) ? $row['Collation'] : ""; //(isset($fields_infos['_tableinfo_']['COLLATE'])) ? $fields_infos['_tableinfo_']['COLLATE'] : ""; $t_comment=( isset($fields_infos['_tableinfo_']['COMMENT']) ) ? substr($fields_infos['_tableinfo_']['COMMENT'],1,strlen($fields_infos['_tableinfo_']['COMMENT']) - 2) : ""; $t_rowformat=( isset($fields_infos['_tableinfo_']['ROW_FORMAT']) ) ? $fields_infos['_tableinfo_']['ROW_FORMAT'] : ""; echo "
" . $lang['table'] . " `$table_edit_name`
"; $td=''; //Tabelleneigenschaften echo '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
' . $lang['sql_tblpropsof'] . ' `' . $table_edit_name . '` (' . $anz_fields . ' ' . $lang['fields'] . ')Name
Engine
Row Format
' . $lang['charset'] . '
' . $lang['collation'] . '
' . $lang['comment'] . '
 

 

'; $field_fehler=0; echo '
'.$lang['fields_of_table'].' `' . $table_edit_name . '`
'; $d_collate=''; $d_comment=''; if (isset($_GET['newfield']) || isset($_GET['editfield']) || $field_fehler > 0 || isset($_POST['newfield_posted'])) { if (isset($_GET['editfield'])) $id=$_GET['editfield']; $d_name=( isset($_GET['editfield']) ) ? $fields_infos[$id]['name'] : ""; $d_type=( isset($_GET['editfield']) ) ? $fields_infos[$id]['type'] : ""; $d_size=( isset($_GET['editfield']) ) ? $fields_infos[$id]['size'] : ""; $d_null=( isset($_GET['editfield']) ) ? $fields_infos[$id]['null'] : ""; $d_attribute=( isset($_GET['editfield']) ) ? $fields_infos[$id]['attribut'] : ""; $d_default=''; if (isset($id) && isset($fields_infos[$id]) && isset($fields_infos[$id]['default'])) { if ($fields_infos[$id]['default']=='NULL') $d_default='NULL'; else $d_default=substr($fields_infos[$id]['default'],1,strlen($fields_infos[$id]['default']) - 2); } $d_extra=( isset($_GET['editfield']) ) ? $fields_infos[$id]['extra'] : ""; $d_primary=$d_unique=$d_index=$d_fulltext=0; if (isset($id)) { if (isset($fields_infos[$id]['collate'])) $d_collate=( isset($_GET['editfield']) ) ? $fields_infos[$id]['collate'] : ""; if (isset($fields_infos[$id]['comment'])) $d_comment=( isset($_GET['editfield']) ) ? $fields_infos[$id]['comment'] : ""; } $d_privileges=( isset($_GET['editfield']) ) ? $fields_infos[$id]['privileges'] : ""; if (isset($_GET['editfield'])) { $d_primary=( isset($fields_infos['_primarykey_']) && $fields_infos['_primarykey_'] == $fields_infos[$id]['name'] ) ? 1 : 0; if (isset($fields_infos['_key_'])) { for ($i=0; $i < count($fields_infos['_key_']); $i++) { if ($fields_infos['_key_'][$i]['name'] == $fields_infos[$id]['name']) { $d_index=1; break; } } } if (isset($fields_infos['_fulltextkey_'])) { for ($i=0; $i < count($fields_infos['_fulltextkey_']); $i++) { if ($fields_infos['_fulltextkey_'][$i]['name'] == $fields_infos[$id]['name']) { $d_fulltext=1; break; } } } if (isset($fields_infos['_uniquekey_'])) { for ($i=0; $i < count($fields_infos['_uniquekey_']); $i++) { if ($fields_infos['_uniquekey_'][$i]['name'] == $fields_infos[$id]['name']) { $d_unique=1; break; } } } } echo '
'; if (isset($_GET['editfield'])) echo ''; if (isset($_POST['newtablesubmit'])) echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
' . ( ( isset($_GET['editfield']) ) ? $lang['sql_editfield'] . " `" . $d_name . "`" : $lang['sql_newfield'] ) . '
Name
Type
Size 
NULL
Default
Extra
' . $lang['sql_indexes'] . '
'; echo ''; echo '  '; echo ''; echo '  '; echo ''; echo '  '; echo ' '; echo '  '; echo ''; echo '  
' . $lang['collation'] . '
' . $lang['sql_attributes'] . '
' . $lang['sql_atposition'] . ':

 

'; } else echo '' . $lang['sql_insertnewfield'] . '

'; //Felder ausgeben echo ''; for ($i=0; $i < $anz_fields; $i++) { $cl=( $i % 2 ) ? "dbrow" : "dbrow1"; if ($i == 0) echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '' . $td . $fields_infos[$i]['extra'] . ''; echo ''; } echo '
 FieldTypeSizeNULLKeyAttributeDefaultExtraSortierung
'; echo 'edit field  '; echo 'delete field  '; echo '' . ( $i + 1 ) . '.' . $fields_infos[$i]['name'] . '' . $fields_infos[$i]['type'] . '' . $fields_infos[$i]['size'] . '' . $fields_infos[$i]['null'] . ''; //key if ($fields_infos['_primarykey_'] == $fields_infos[$i]['name']) echo $icon['key_primary']; if (isset($fields_infos['_fulltextkey_'])) { for ($ii=0; $ii < count($fields_infos['_fulltextkey_']); $ii++) { if ($fields_infos['_fulltextkey_'][$ii]['name'] == $fields_infos[$i]['name']) { echo $icon['key_fulltext']; break; } } } if (isset($fields_infos['_uniquekey_'])) { for ($ii=0; $ii < count($fields_infos['_uniquekey_']); $ii++) { if ($fields_infos['_uniquekey_'][$ii]['name'] == $fields_infos[$i]['name']) { echo $icon['key_unique']; break; } } } if (isset($fields_infos['_key_'])) { for ($ii=0; $ii < count($fields_infos['_key_']); $ii++) { //echo "
".$fields_infos['_key_'][$ii]['columns']."
"; if ($fields_infos['_key_'][$ii]['name'] == $fields_infos[$i]['name']) { echo $icon['index']; break; } } } echo '
' . $fields_infos[$i]['attribut'] . '' . $fields_infos[$i]['default'] . '' . ( ( MSD_NEW_VERSION ) ? $fields_infos[$i]['collate'] : " " ) . '

'; echo '
' . $lang['sql_tableindexes'] . ' `' . $table_edit_name . '`
'; echo '' . ( ( MSD_NEW_VERSION ) ? '' : '' ) . ''; $sqlk="SHOW KEYS FROM `" . $databases['Name'][$dbid] . "`.`$table_edit_name`;"; $res=MSD_query($sqlk); $num=mysql_numrows($res); if ($num == 0) { echo ''; } else { for ($i=0; $i < $num; $i++) { $row=mysql_fetch_array($res); $cl=( $i % 2 ) ? "dbrow" : "dbrow1"; //Images echo ''; echo ''; echo ''; echo ''; if (MSD_NEW_VERSION) echo ''; echo ''; echo ''; echo ''; echo ''; } } echo '
 Index-NameTyp' . $lang['sql_allowdups'] . '' . $lang['sql_cardinality'] . 'Spalten
' . $lang['sql_tablenoindexes'] . '
'; echo '  '; ///// DH //erstmal nur fuer Primaerschluessel if ($row['Key_name'] == "PRIMARY") echo ''; echo ''; if ($row['Key_name'] == "PRIMARY") echo ''; ///// DH ende echo '' . ( $i + 1 ) . '.' . $row['Key_name'] . '' . $row['Index_type'] . '' . ( ( $row['Non_unique'] == 1 ) ? $lang['yes'] : $lang['no'] ) . '' . ( ( $row['Cardinality'] >= 0 ) ? $row['Cardinality'] : "keine" ) . '' . $row['Column_name'] . '

'; ///// DH if (( isset($_GET['sql_createindex']) ) && ( $_GET['sql_createindex'] == "1" )) { echo '
'; echo '
' . $lang['setPrimaryKeysFor'] . ' `' . $table_edit_name . '`
'; //kopf echo ''; //body $sqlFelder="DESCRIBE `" . $databases['Name'][$dbid] . "`.`" . $_GET['tablename'] . "`;"; $res=MSD_query($sqlFelder); $num=mysql_numrows($res); if ($num == 0) { echo ''; } else { //alle Felder holen $feldArray=Array(); while ($row=mysql_fetch_array($res)) { $feldArray[$row['Field']]=$row['Type']; } //Primaerschluessel holen, um automatisch vorzuselektieren $primaryKeys=getPrimaryKeys($databases['Name'][$dbid],$_GET['tablename']); //eine Select-Box pro Feld anzeigen for ($i=0; $i < $num; $i++) { $cl=( $i % 2 ) ? "dbrow" : "dbrow1"; echo ''; echo ''; echo ''; } } echo '
' . $lang['primaryKey_field'] . '
' . $lang['sql_tablenoindexes'] . '
'; echo ''; echo '
'; //Speichern Knopf echo '
'; echo '
'; } ///// DH ende }