var auswahl = "document.getElementsByName(\"f_export_tables[]\")[0]";
var msg1="'.$lang['sql_notablesselected'].'";
';
}
//Variabeln
$tdcompact=(isset($_GET['tdc'])) ? $_GET['tdc'] : $config['interface_table_compact'];
$mysql_help_ref='http://dev.mysql.com/doc/mysql/'.$config['language'].'/index.html';
$mysql_errorhelp_ref='http://dev.mysql.com/doc/mysql/'.$config['language'].'/error-handling.html';
$no_order=false;
$db=(!isset($_GET['db'])) ? $databases['db_actual'] : $_GET['db'];
$dbid=(!isset($_GET['dbid'])) ? $databases['db_selected_index'] : $_GET['dbid'];
$context=(!isset($_GET['context'])) ? 0 : $_GET['context'];
$context=(!isset($_POST['context'])) ? $context : $_POST['context'];
$tablename=(!isset($_GET['tablename'])) ? "" : $_GET['tablename'];
$limitstart=(!isset($_GET['limitstart'])) ? 0 : $_GET['limitstart'];
$orderdir=(!isset($_GET['orderdir'])) ? "" : $_GET['orderdir'];
$order=(!isset($_GET['order'])) ? "" : $_GET['order'];
$sqlconfig=(isset($_GET['sqlconfig'])) ? 1 : 0;
$editkey=(!isset($_GET['editkey'])) ? -1 : $_GET['editkey'];
$norder=($orderdir==" DESC") ? " ASC" : " DESC";
$sql['order_statement']=($order!="") ? " ORDER BY ".$order.$norder : "";
$sql['sql_statement']=(isset($_GET['sql_statement'])) ? stripslashes(urldecode($_GET['sql_statement'])) : "";
$showtables=(!isset($_GET['showtables'])) ? 0 : $_GET['showtables'];
$limit=$add_sql="";
$bb=(isset($_GET['bb'])) ? $_GET['bb'] : -1;
if(isset($_POST['tablename'])) $tablename=$_POST['tablename'];
//SQL-Statement geposted
if(isset($_POST['execsql']))
{
$sql['sql_statement']=(isset($_POST['sqltextarea'])) ? stripslashes($_POST['sqltextarea']) : "";
$db=$_POST['db'];
$dbid=$_POST['dbid'];
$tablename=$_POST['tablename'];
if($tablename=='') $tablename=ExtractTablename($sql['sql_statement']);
}
if($sql['sql_statement']==""){
if($tablename!="" && $showtables==0) {
$sql['sql_statement']="SELECT * FROM `$tablename`";
} else {
$sql['sql_statement']="SHOW TABLE STATUS FROM `$db`";
$showtables=1;
}
}
//sql-type
$sql_to_display_data=0;
$Anzahl_SQLs=substr_count(substr($sql['sql_statement'],0,strlen($sql['sql_statement'])-1),";");
if($Anzahl_SQLs==0 && (substr(strtoupper($sql['sql_statement']),0,6)=="SELECT" || substr(strtoupper($sql['sql_statement']),0,4)=="SHOW" ))
$sql_to_display_data=1;
//if($Anzahl_SQLs>0) $sql_to_display_data=0;
if($sql_to_display_data==1) {
//nur ein SQL-Statement
$limitende=($limitstart+$config['sql_limit']);
//Darf editiert werden?
$no_edit=(strtoupper(substr($sql['sql_statement'],0,6))!="SELECT" || $showtables==1
|| preg_match('@^((-- |#)[^\n]*\n|/\*.*?\*/)*(UNION|JOIN)@im', $sql['sql_statement']));
if($no_edit)$no_order=true;
//Darf sortiert werden?
$op=strpos(strtoupper($sql['sql_statement']),"ORDER");
if($op>0) {
$sql['order_statement']=substr($sql['sql_statement'],$op);
$sql['sql_statement']=substr($sql['sql_statement'],0,$op);
}
}
if(isset($_POST['tableselect']) && $_POST['tableselect']!="1") $tablename=$_POST['tableselect'];
//MySQL verbinden
MSD_mysql_connect();
mysql_select_db($db,$config['dbconnection']);
///*** EDIT / UPDATES / INSERTS ***///
///*** ***///
//Datensatz editieren
if(isset($_POST['update'])) {
GetPostParams();
$f=explode("|",$_POST['feldnamen']);
$sqlu='Update `'.$tablename.'` Set ';
for($i=0;$i
'; if($context==0) { //Start SQL-Box if(isset($_GET['readfile']) && $_GET['readfile']==1) { $aus.=''; } if(isset($_POST['submit_openfile'])) { //open file if (!isset($_FILES['upfile']['name']) || empty($_FILES['upfile']['name'])) $aus.=''.$lang['fm_uploadfilerequest'].''; else { $fn=$_FILES['upfile']['tmp_name']; if(strtolower(substr($_FILES['upfile']['name'],-3))==".gz") $read__user_sqlfile=gzfile($fn); else $read__user_sqlfile=file($fn); $aus.='geladenes File: '.$_FILES['upfile']['name'].' '.byte_output(filesize($_FILES['upfile']['tmp_name'])).''; $sql_loaded=implode("",$read__user_sqlfile); } } $aus.='
'.$lang['sql_recorddeleted'].'
'; } else { $sqlk= "Drop Table `$rk`"; $res=MSD_query($sqlk) or die(SQLError($sqlk,mysql_error())); $aus.=''.sprintf($lang['sql_recorddeleted'],$rk).'
'; } } if($_GET['mode']=="empty") { if($showtables==0) { } else { $sqlk= "TRUNCATE `$rk`"; $res=MSD_query($sqlk) or die(SQLError($sqlk,mysql_error())); $aus.=''.sprintf($lang['sql_tableemptied'],$rk).'
'; } } if($_GET['mode']=="emptyk") { if($showtables==0) { } else { $sqlk= "TRUNCATE `$rk`;"; $res=MSD_query($sqlk) or die(SQLError($sqlk,mysql_error())); $sqlk= "ALTER TABLE `$rk` AUTO_INCREMENT=1;"; $res=MSD_query($sqlk) or die(SQLError($sqlk,mysql_error())); $aus.=''.sprintf($lang['sql_tableemptiedkeys'],$rk).'
'; } } if($_GET['mode']=="edit") { $aus.=''.$lang['sql_recordedit'].' '.$rk.'
'; $sqledit="Select * from `$tablename` where $rk"; $res=MSD_query($sqledit) or die(SQLError($sqledit,mysql_error())); $aus.=''.$lang['sql_recordnew'].'
'; $sqledit="SHOW FIELDS FROM `$tablename`"; $res=MSD_query($sqledit) or die(SQLError($sqledit,mysql_error())); $num=mysql_numrows($res); $aus.=''; if($showtables==0){ $p='sql.php?sql_statement='.urlencode($sql['sql_statement']).'&db='.$db.'&tablename='.$tablename.'&dbid='.$dbid.'&limitstart='.$limitstart.'&order='.$order.'&orderdir='.$orderdir.'&tdc='.$tdcompact; echo ''.$lang['sql_recordnew'].' '; echo 'Tabellenstruktur bearbeiten'; } else { $p='sql.php?db='.$db.'&dbid='.$dbid.'&context=2'; echo ''.$lang['sql_tablenew'].''; } //Statuszeile echo '
Schau mal: '.ExtractTablenameFromSQL($sql['sql_statement']).'
'; if(isset($msg))echo $msg; //SQL ausführen if($sql_to_display_data==0) { //mehrere SQL-Statements $numrowsabs=$numrows=0; MSD_DoSQL($sql['sql_statement']); echo SQLOutput($out); } else { $numrowsabs=$numrows=0; $res=MSD_query($sql['sql_statement']) or die(SQLError($sql['sql_statement'],mysql_error())); $numrowsabs=mysql_num_rows($res); $res=MSD_query($sql['sql_statement'].$sql['order_statement'].$limit) or die(SQLError($sql['sql_statement'].$sql['order_statement'].$limit,mysql_error())); $numrows=mysql_num_rows($res); if($limitende>$numrowsabs)$limitende=$numrowsabs; } if($numrowsabs>0 && $Anzahl_SQLs<=1) { if($showtables==0) { $command_line=$lang['info_records']." ".($limitstart+1)." - $limitende ".$lang['sql_vonins']." $numrowsabs "; $command_line.=($limitstart>0) ? '<< ' : '<< '; $command_line.=($limitstart>0) ? '< ' : '< '; $command_line.=($limitende<$numrowsabs) ? '> ' : '> '; $command_line.=($limitende<($numrowsabs-$config['sql_limit'])) ? '>>' : '>>'; echo $command_line; } else { echo $numrowsabs." ".$lang['tables']; } echo '
'; //Datentabelle echo ''.(($tdcompact==0) ? 'Ansicht: normal' : 'Ansicht: kompakt').''; $t.=' '.$lang['sql_queryentry'].' '.count($row).' '.$lang['sql_columns']; $t.=' | |
'; for($x=0; $x | ';
$divstart=' ';
$divend=' ';
if($bb==$x){
$data=simple_bbcode_conversion($row[$x]);
} else
$data=(($fdesc[$x]['type']=='string' || $fdesc[$x]['type']=='blob') ? strip_tags($row[$x]) : $row[$x]);
$d.=($tabellenansicht==1 && $x==0) ? "$divstart$data$divend" : $divstart.$data.$divend;
$d.=' | ';
}
if($i==0) echo '
---|---|
'.$lang['sql_nodata'].'
'; } elseif ($context==1) { //SQL-Strings echo $aus.=''.$lang['sql_befehlsaved1'].' \''.$_POST['sqlname'.$ind].'\' '.$lang['sql_befehlsaved2'].'
'; } echo ''; } elseif ($context==2) { //Tabellen echo $aus.''.$lang['sql_nofielddelete'].'
'; else { $sql_alter="ALTER TABLE `".$databases['Name'][$dbid]."`.`".$_GET['tablename']."` DROP COLUMN `".$_GET['kill']."`"; MSD_DoSQL($sql_alter); echo ''.$lang['sql_fielddelete1'].' `'.$_GET['kill'].'` '.$lang['sql_deleted'].'.
'.highlight_sql($out).''.$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 ''.sprintf($lang['sql_scopy'],$table_edit_name,$_POST['tablecopyname']).'.
' : ''.sprintf($lang['sql_tcopy'],$table_edit_name,$_POST['tablecopyname']).'
'; echo highlight_sql($out).''.$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 '".$_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 '`'.$_POST['f_name'].'` '.((isset($_POST['editfield'])) ? $lang['sql_changed'] : $lang['sql_created']).'.
'; echo highlight_sql($out).''; if($table_edit_name!="") { $sqlf="SHOW FULL FIELDS FROM `".$databases['Name'][$dbid]."`.`$table_edit_name` ;"; $res=MSD_query($sqlf) or die(SQLError($sqlf,mysql_error())); $anz_fields=mysql_num_rows($res); //Array füllen $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 "
'; $field_fehler=0; echo '
'.((isset($_GET['editfield'])) ? $lang['sql_editfield']." `".$d_name."`" : $lang['sql_newfield']).' | |||||
---|---|---|---|---|---|
Name | ';
echo 'Type | ';
echo 'Size | ';
echo 'NULL | ';
echo 'Default | ';
echo 'Extra | ';
echo '
'.$lang['sql_indexes'].' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' | ';
echo ''.$lang['collation'].' | ';
echo ''.$lang['sql_attributes'].' | ';
echo ''.$lang['sql_atposition'].': |
'; } else echo ''.$lang['sql_insertnewfield'].'
Index-Name | '.((MSD_NEW_VERSION) ? 'Typ | ' : '').''.$lang['sql_allowdups'].' | '.$lang['sql_cardinality'].' | Spalten | |
---|---|---|---|---|---|
'.$lang['sql_tablenoindexes'].' | |||||
'; echo ' | '.$row['Key_name'].' | '; if(MSD_NEW_VERSION) echo ''.$row['Index_type'].' | '; echo ''.(($row['Non_unique']==1) ? $lang['yes']: $lang['no']).' | '; echo ''.(($row['Cardinality']>=0) ? $row['Cardinality'] : "keine").' | '; echo ''.$row['Column_name'].' | '; echo '
';print_r($fields_infos);echo '';*/ } } elseif ($context==3) { //Datenbanken if(isset($_GET['dbrefresh'])) SetDefault(); echo $aus."
'.$lang['db'].' `'.$databases['Name'][$db_index].'` wurde gelöscht.
'); $changed=true; break; case "empty": EmptyDB($databases['Name'][$db_index]); echo SQLOutput($out,''.$lang['db'].' `'.$databases['Name'][$db_index].'` '.$lang['sql_wasemptied'].'.
'); break; case "rename": $dbold=$databases['Name'][$db_index]; DB_Copy($dbold,$newname,1); echo SQLOutput($out,''.$lang['db'].' `'.$dbold.'` '.$lang['sql_renamedto'].' `'.$newname.'`.
'); $changed=true; break; case "copy": $dbold=$databases['Name'][$db_index]; DB_Copy($dbold,$newname); $changed=true; echo SQLOutput($out,''.sprintf($lang['sql_dbcopy'],$dbold,$newname).'
'); break; case "structure": DB_Copy($databases['Name'][$db_index],$newname,0,0); $changed=true; echo SQLOutput($out,''.sprintf($lang['sql_dbscopy'],$databases['Name'][$db_index],$newname).'
'); break; case "rights": break; } if($changed=true) { SetDefault(); include ($config['files']['parameter']); echo ''; } } if(isset($_POST['dbwantaction'])) { if(isset($_POST['db_createnew'])) { $newname=$_POST['db_create']; if(!empty($newname)) { $col=(MSD_NEW_VERSION) ? $_POST['db_collate'] : ""; if($col!="") { $r=explode("|",$col); $sqlc="CREATE DATABASE `$newname` DEFAULT CHARACTER SET $r[0] COLLATE $r[1]"; } else $sqlc="CREATE DATABASE `$newname`"; MSD_query($sqlc) or die(SQLError($sqlc,mysql_error())); echo $lang['db']." `$newname` ".$lang['sql_wascreated'].".'.print_r($_POST,true).'
'.$lang['export'].': | zeige in neuem Fenster |