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'; } //Datensatz einfügen if(isset($_POST['insert'])) { GetPostParams(); $f=explode("|",$_POST['feldnamen']); $sqlu='Insert into `'.$tablename.'` Set '; for($i=0;$i'; } if(isset($_POST['cancel'])) GetPostParams(); //Tabellenansicht $showtables=(substr(strtoupper($sql['sql_statement']),0,5)=="SHOW ") ? 1 : 0; $tabellenansicht=(substr(strtoupper($sql['sql_statement']),0,10)=="SHOW TABLE") ? 1 : 0; if(strtolower(substr($sql['sql_statement'],0,6))=="select") $limit=' LIMIT '.$limitstart.', '.$limitende.';'; $params="sql.php?db=".$db."&tablename=".$tablename."&dbid=".$dbid.'&context='.$context.'&sql_statement='.urlencode($sql['sql_statement']).'&tdc='.$tdcompact.'&showtables='.$showtables; if($order!="") $params.="&order=".$order."&orderdir=".$orderdir.'&context='.$context; if($bb>-1) $params.="&bb=".$bb; $aus=headline($lang['sql_browser']); $aus.='

'.$lang['sql_backdboverview'].'  '; $aus.='['.$lang['tools'].']  '.$lang['db'].'  '; if($context<3) { $aus.='`'.$db.'` '.(($tablename!="") ? ''.$lang['table'].' `'.$tablename.'`' : '').''; } else $aus.="(".$lang['sql_selecdb'].")"; $aus.='

 

'; if($context==0) { //Start SQL-Box if(isset($_GET['readfile']) && $_GET['readfile']==1) { $aus.='
'; $aus.=''; $aus.='
'; $aus.='SQL-File öffnen (auch gz möglich):(max 2 MB)     
'; } 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.='
'; //Titelzeile $aus.='
'; $aus.='  '; $aus.='show less'; $aus.=' show more   '; $aus.=''.SQL_ComboBox().'  '.Table_ComboBox(); $aus.='   '; if(!isset($_GET['readfile'])) $aus.= '  read file '; $aus.=''; $aus.='
'; //Eingabebox $aus.='
'; $aus.='
'.$lang['sql_warning'].'
'; $aus.=''; $aus.='

'; } if(isset($_GET['mode']) && $context==0) { if(isset($_GET['recordkey'])) $rk=stripslashes(urldecode($_GET['recordkey'])); if(isset($_GET['tablename'])) $tablename=$_GET['tablename']; if($_GET['mode']=="kill") { if($showtables==0) { $sqlk= "DELETE FROM `$tablename` WHERE ".$rk; $res=MSD_query($sqlk) or die(SQLError($sqlk,mysql_error())); $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.='
'; $aus.=''; $row=mysql_fetch_row($res); $aus.=''; $feldnamen=""; for($x=0; $xname.'|'; $aus.=''; $aus.= ''; //'.$str->type.' } $aus.=''; $aus.='
'.$str->name.''; if($str->type=='blob') $aus.=''; else $aus.=''; $aus.=' 
      
'.FormHiddenParams().'
'; } if($_GET['mode']=="new") { $aus.='

'.$lang['sql_recordnew'].'

'; $sqledit="SHOW FIELDS FROM `$tablename`"; $res=MSD_query($sqledit) or die(SQLError($sqledit,mysql_error())); $num=mysql_numrows($res); $aus.='
'; $aus.=''; $aus.=''; $feldnamen=""; for($x=0; $x<$num; $x++) { $row=mysql_fetch_row($res); $feldnamen.=$row[0].'|'; $aus.=''; $aus.=''; //'.$str->type.' } $aus.=''; $aus.='
'.$row[0].''; $type=strtoupper($row[1]); if($type=='BLOB' || $type=='TEXT') $aus.=''; else $aus.=''; $aus.=' 
      
'.FormHiddenParams().'
'; } } if($context==0){ //Data-View echo $aus.'

'.(($showtables==1)?$lang['sql_tableview']:$lang['sql_dataview']).'

'; 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 ''; $t=$d=""; $fdesc=Array(); $key=-1; if ($numrows>0){ //Infos und Header holen //1.Datensatz für Feldinfos $row= mysql_fetch_row($res); //Kompaktmodus-Switcher $t=''; $t.=''; for($x=0; $xname; $fdesc[$x]['table']=$str->table; $fdesc[$x]['max_length']=$str->max_length; $fdesc[$x]['not_null']=$str->not_null; $fdesc[$x]['primary_key']=$str->primary_key; $fdesc[$x]['unique_key']=$str->unique_key; $fdesc[$x]['multiple_key']=$str->multiple_key; $fdesc[$x]['numeric']=$str->numeric; $fdesc[$x]['blob']=$str->blob; $fdesc[$x]['type']=$str->type; $fdesc[$x]['unsigned']=$str->unsigned; $fdesc[$x]['zerofill']=$str->zerofill; $tt="Name: ".$fdesc[$x]['name']."\nType: ".$fdesc[$x]['type']."\nMax Length: ".$fdesc[$x]['max_length']."\nUnsigned: ".$fdesc[$x]['unsigned']."\nzerofill: ".$fdesc[$x]['zerofill']; $pic=''; if($str->primary_key==1 || $str->unique_key==1) { if($key==-1) $key=$x; if($str->primary_key==1) $pic='primary key'; elseif($str->unique_key==1) $pic='unique key'; } if($bb==-1) $bb_link=($str->type=="blob") ? '   [BB]' : ''; else $bb_link=($str->type=="blob") ? '   [no BB]' : ''; if($no_order==false && $showtables==0) $t.=$pic.' '.$str->name.''.$bb_link; else $t.=$pic.' '.$str->name.''.$bb_link; $arname=($orderdir==" ASC") ? "arup.gif" : "ardown.gif"; if($str->name==$order)$t.='  '; $t.=''; //echo "
DOING HEADERS
$t"; } //und jetzt Daten holen mysql_data_seek ($res, 0); for ($i=0;$i<$numrows;$i++) { $row= mysql_fetch_row($res); $cl= ($i % 2) ? "dbrow" : "dbrow1"; for($x=0; $x '.$nl; $p='sql.php?sql_statement='.urlencode($sql['sql_statement']).'&db='.$db.'&tablename='.$tablename.'&dbid='.$dbid.'&limitstart='.$limitstart.'&order='.$order.'&orderdir='.$orderdir.'&editkey='.$key.'&tdc='.$tdcompact; if($key==-1) { $rk=""; for($il=0;$iledit '; } } if($showtables==0) { $d.='delete'; } else { if($tabellenansicht==1) { $d.=''.$lang['edit'].' '.$nl.$nl; $d.=''.$lang['empty'].' '.$nl.$nl; $d.=''.$lang['emptykeys'].' '.$nl.$nl; $d.=''.$lang['delete'].' '.$nl.$nl; } } $d.=''; } $d.='
'; } if($i==0) echo ''.$t.''; echo "\n\n".''.$d.''."\n\n"; $d=""; } } echo '
'.(($tdcompact==0) ? 'Ansicht: normal' : 'Ansicht: kompakt').''; $t.='   '.$lang['sql_queryentry'].' '.count($row).' '.$lang['sql_columns']; $t.='
 '; $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($showtables==0) echo '
'.$command_line; } else echo '

'.$lang['sql_nodata'].'

'; } elseif ($context==1) { //SQL-Strings echo $aus.='

'.$lang['sql_befehle'].' ('.count($SQL_ARRAY).')

'; echo ''.$lang['sql_befehlneu'].'

'; if(isset($_POST['sqlnewupdate'])) { $ind=count($SQL_ARRAY); if(count($SQL_ARRAY)>0) array_push($SQL_ARRAY,$_POST['sqlname'.$ind]."|".$_POST['sqlstring'.$ind]); else $SQL_ARRAY[0]=$_POST['sqlname0']."|".$_POST['sqlstring0']; WriteSQL(); echo '

'.$lang['sql_befehlsaved1'].' \''.$_POST['sqlname'.$ind].'\' '.$lang['sql_befehlsaved2'].'

'; } echo '
'; echo ''; $i=0; if(count($SQL_ARRAY)>0) { for($i=0;$i'.$lang['sql_befehlsaved1'].' \''.$_POST['sqlname'.$i].'\' '.$lang['sql_befehlsaved3'].'

'; $SQL_ARRAY[$i]=$_POST['sqlname'.$i]."|".$_POST['sqlstring'.$i]; WriteSQL(); } if(isset($_POST['sqlmove'.$i])) { echo '

'.$lang['sql_befehlsaved1'].' \''.$_POST['sqlname'.$i].'\' '.$lang['sql_befehlsaved4'].'

'; $a[]=$SQL_ARRAY[$i]; array_splice($SQL_ARRAY,$i,1); $SQL_ARRAY=array_merge($a,$SQL_ARRAY); WriteSQL(); } if(isset($_POST['sqldelete'.$i])) { echo '

'.$lang['sql_befehlsaved1'].' \''.$_POST['sqlname'.$i].'\' '.$lang['sql_befehlsaved5'].'

'; array_splice($SQL_ARRAY,$i,1); WriteSQL(); } } for($i=0;$i
'; echo ''; echo ''; } } if(isset($_GET['new'])) { $cl= ($i % 2) ? "dbrow" : "dbrow1"; echo ''; } echo '
PositionNameSQL'.$lang['command'].'
'.($i+1).''; echo '

'.($i+1).''; echo '
'.$lang['sql_library'].'
'; echo '
'; } elseif ($context==2) { //Tabellen echo $aus.'
'.$lang['sql_tablesofdb'].' `'.$databases['Name'][$dbid].'` '.$lang['sql_edit'].'
'; 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 '".$_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) or die(SQLError($sqlt,mysql_error())); $anz_tabellen=mysql_numrows($res); $p="sql.php?db=".$databases['Name'][$dbid]."&dbid=$dbid&tablename=$table_edit_name&context=2"; echo '
'; echo ''; echo '
'.$lang['new'].' '.$lang['sql_createtable'].':
'.$lang['sql_copytable'].':
'; echo ''; if($anz_tabellen==0) { echo ''; } else { echo ''; echo ''; echo ''; } echo '
'.$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) 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 "
Tabelle `$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 '
Felder der Tabelle `'.$table_edit_name.'`
'; 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=(isset($_GET['editfield'])) ? 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; $d_collate=(isset($_GET['editfield'])) ? $fields_infos[$id]['collate'] : ""; $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'; 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 '.$lang['sql_enumsethelp'].'
NULL
Default
Extra
'.$lang['sql_indexes'].'
'; echo 'No Index '; echo 'Primary Key '; echo 'Unique Index '; echo 'Index '; echo 'Fulltext Index 
'.$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 ''.$td.$fields_infos[$i]['extra'].''; echo ''; } echo '
 FieldTypeSizeNULLKeyAttributeDefaultExtraSortierung
'; echo 'edit field  '; echo 'delete field  '; echo ''.$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 'Primary Key'; if(isset($fields_infos['_fulltextkey_'])) { for($ii=0;$ii'; break; } } } if(isset($fields_infos['_uniquekey_'])) { for($ii=0;$ii'; break; } } } if(isset($fields_infos['_key_'])) { for($ii=0;$ii".$fields_infos['_key_'][$ii]['columns'].""; if($fields_infos['_key_'][$ii]['name']==$fields_infos[$i]['name']) { echo '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) or die(SQLError($sqlk,mysql_error())); $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 ''; if(MSD_NEW_VERSION) echo ''; echo ''; echo ''; echo ''; echo ''; } } echo '
 Index-NameTyp'.$lang['sql_allowdups'].''.$lang['sql_cardinality'].'Spalten
'.$lang['sql_tablenoindexes'].'
  '.$row['Key_name'].''.$row['Index_type'].''.(($row['Non_unique']==1) ? $lang['yes']: $lang['no']).''.(($row['Cardinality']>=0) ? $row['Cardinality'] : "keine").''.$row['Column_name'].'

'; /*echo "
"; echo '
';print_r($fields_infos);echo '
';*/ } } elseif ($context==3) { //Datenbanken if(isset($_GET['dbrefresh'])) SetDefault(); echo $aus."

Tools

"; if(isset($_POST['dbdosubmit'])) { $newname=$_POST['newname']; $db_index=$_POST['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,'

'.$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'].".
"; SetDefault(); include ($config['files']['parameter']); echo ''; } } $db_action=$newname="";$db_index=-1; for($i=0;$i
'; echo '
'; switch($db_action) { case "drop": echo ''.sprintf($lang['askdbdelete'],$databases['Name'][$i]).'

'; echo ''; break; case "empty": echo ''.sprintf($lang['askdbempty'],$databases['Name'][$i]).'

'; echo ''; break; case "rename": echo ''.$lang['sql_renamedb'].' `'.$databases['Name'][$db_index].'` '.$lang['in'].' `'.$newname.'`

'; echo ''; break; case "copy": echo ''.sprintf($lang['askdbcopy'],$databases['Name'][$db_index],$newname).'

'; if($newname=="") echo '

'.$lang['sql_namedest_missing'].'

'; else { echo ''; } break; case "structure": echo ''.$lang['fm_askdbcopy1'].'`'.$databases['Name'][$db_index].'`'.$lang['fm_askdbcopy2'].'`'.$newname.'`'.$lang['fm_askdbcopy3'].'

'; if($newname=="") echo '

'.$lang['sql_namedest_missing'].'

'; else { echo ''; } break; case "rights": break; } echo "

"; } } echo '
'; echo '
'; echo ''; echo '
'.$lang['create_database'].'
Name: '; echo '  '.$lang['collation'].':   '; echo '
'; echo '

 

'; echo ''; for($i=0;$i' : ''; echo ''; echo ''; } echo '
'.$lang['dbs'].''.$lang['sql_actions'].'
'.$databases['Name'][$i].''; echo '  '; echo "\n\n".'  '; echo '  
'; } elseif ($context==4) { //Im-/Export $import=(isset($_GET['import'])) ? 1 : 0; if($import==1) { //IMPORT CheckcsvOptions(); if(isset($_POST['f_import_csvtrenn'])) $sql['import']['trenn']=($config['magic_quotes_gpc']) ? stripslashes($_POST['f_import_csvtrenn']) : $_POST['f_import_csvtrenn']; if(isset($_POST['f_import_csvenc'])) $sql['import']['enc']=($config['magic_quotes_gpc']) ? stripslashes($_POST['f_import_csvenc']) : $_POST['f_import_csvenc']; if(isset($_POST['f_import_csvesc'])) $sql['import']['esc']=($config['magic_quotes_gpc']) ? stripslashes($_POST['f_import_csvesc']) : $_POST['f_import_csvesc']; if (empty($sql['import']['endline'])) { $sql['import']['endline']=$nl; } else { $sql['import']['endline']= str_replace('\\r', "\015",$sql['import']['endline']); $sql['import']['endline'] = str_replace('\\n', "\012",$sql['import']['endline']); $sql['import']['endline']= str_replace('\\t', "\011",$sql['import']['endline']); } $sql['import']['endline']= str_replace('\\t', "\011",$sql['import']['endline']); if(isset($_POST['f_import_csvnull'])) $sql['import']['null']=($config['magic_quotes_gpc']) ? stripslashes($_POST['f_import_csvnull']) : $_POST['f_import_csvnull']; $sql['import']['namefirstline']=(isset($_POST['f_import_namefirstline'])) ? $_POST['f_import_namefirstline'] : 0; $sql['import']['emptydb']=(isset($_POST['import_emptydb'])) ? 1:0; $sql['import']['createindex']=(isset($_POST['import_createindex'])) ? 1:0; $sql['import']['table']=(isset($_POST['import_table'])) ? $_POST['import_table'] : ""; $sql['import']['import_source']=isset($_POST['import_source']) ? $_POST['import_source'] : 0; $sql['import']['text']=isset($_POST['import_text']) ? (($config['magic_quotes_gpc']) ? stripslashes($_POST['import_text']) : $_POST['import_text']) : ""; $sql['import']['csv']=""; if(isset($_POST['do_import'])) { $sql['import']['tablecreate']=0; if($sql['import']['table']=="new") { $sql['import']['table']="import_"; $sql['import']['tablecreate']=1; } if($sql['import']['table']=="") { $aus.=''.$lang['import_notable'].''; } else { if($_POST['import_source']==0) { //Import aus textbox $sql['import']['csv']=explode($sql['import']['endline'],$sql['import']['text']); } else { if (!isset($_FILES['upfile']['name']) || empty($_FILES['upfile']['name'])) { $aus.=''.$lang['fm_uploadfilerequest'].''; } else { $fn=$_FILES['upfile']['tmp_name']; $sql['import']['csv']=(substr($_FILES['upfile']['name'],-3)==".gz") ? gzfile($fn) : file($fn); $sql['import']['text']=implode("",$sql['import']['csv']); $aus.=''.$lang['sql_uploadedfile'].''.$_FILES['upfile']['name'].'   '.byte_output(filesize($_FILES['upfile']['tmp_name'])).''; } } if(is_array($sql['import']['csv'])) $aus.=DoImport(); else $aus.='
'.$lang['csv_nodata'].''; } } $impaus=$aus; $impaus.='
'.$nl; $impaus.= ''; $impaus.= ''.$lang['export'].''; $impaus.= '
'.sprintf($lang['sql_import'],$databases['Name'][$dbid]).'
'; $impaus.= ''.$nl; $impaus.= ''; $impaus.=''; $impaus.=''; $impaus.= '
'.$nl; $impaus.= $lang['importoptions'].''.$lang['csvoptions'].'
'.$nl; $impaus.= ''.$nl; $impaus.= ''.$nl; $impaus.= ''.$nl; $impaus.= ''.$nl; $impaus.= ''.$nl; $impaus.= ''.$nl; $impaus.= '
'.$lang['importtable'].'
'.$lang['importsource'].''.$lang['fromtextbox'].'
'.$nl; $impaus.= ''.$lang['fromfile'].'
'.$lang['emptytablebefore'].'
'.$lang['createautoindex'].'
'.$nl; $impaus.= '
'.$nl; $impaus.= ''.$nl; $impaus.= ''.$nl; $impaus.= ''.$nl; $impaus.= ''.$nl; $impaus.= ''.$nl; $impaus.= ''.$nl; $impaus.= ''.$nl; $impaus.= '
'.$lang['csv_namefirstline'].'
'.$lang['csv_fieldseperate'].'
'.$lang['csv_fieldsenclosed'].'
'.$lang['csv_fieldsescape'].'
'.$lang['csv_eol'].'
'.$lang['csv_null'].'
'.$nl; $impaus.= '
'.$lang['csv_fileopen'].':   '; $impaus.='
'.$nl; $impaus.= '

 

'.$lang['import'].':
'.$nl; $impaus.= ''.$nl; echo $impaus.$nl; } else { //EXPORT $tables=0;$tblstr=""; $sql['export']['db']=$db; if(isset($_POST['f_export_submit'])) { //echo '
'.print_r($_POST,true).'

'; $sql['export']['header_sent']=""; $sql['export']['lines']=0; $sql['export']['format']=$_POST['f_export_format']; $sql['export']['ztrenn']=($config['magic_quotes_gpc']) ? stripslashes($_POST['f_export_csvztrenn']) : $_POST['f_export_csvztrenn']; $sql['endline']['ztrenn']=$sql['export']['ztrenn']; if($sql['export']['format']==0) { //CSV $format=0; $sql['export']['trenn']=($config['magic_quotes_gpc']) ? stripslashes($_POST['f_export_csvtrenn']) : $_POST['f_export_csvtrenn']; $sql['export']['enc']=($config['magic_quotes_gpc']) ? stripslashes($_POST['f_export_csvenc']) : $_POST['f_export_csvenc']; $sql['export']['esc']=($config['magic_quotes_gpc']) ? stripslashes($_POST['f_export_csvesc']) : $_POST['f_export_csvesc']; if (empty($sql['export']['endline'])) { $sql['export']['endline']=$nl; } else { $sql['export']['endline']= str_replace('\\r', "\015",$sql['export']['endline']); $sql['export']['endline'] = str_replace('\\n', "\012",$sql['export']['endline']); $sql['export']['endline']= str_replace('\\t', "\011",$sql['export']['endline']); } $sql['export']['endline']= str_replace('\\t', "\011",$sql['export']['endline']); } elseif($sql['export']['format']==1) { //EXCEL $format=1; $sql['export']['trenn']=","; $sql['export']['enc']='"'; $sql['export']['esc']='"'; $sql['export']['endline']="\015\012"; } elseif($sql['export']['format']==3) { //EXCEL 2003 $format=1; $sql['export']['trenn']=";"; $sql['export']['enc']='"'; $sql['export']['esc']='"'; $sql['export']['endline']="\015\012"; } elseif($sql['export']['format']==4) { //XML $format=4; CheckcsvOptions(); } elseif($sql['export']['format']==5) { //HTML $format=5; CheckcsvOptions(); } if($format<3) $sql['export']['null']=($config['magic_quotes_gpc']) ? stripslashes($_POST['f_export_csvnull'.$format]) : $_POST['f_export_csvnull'.$format]; $sql['export']['namefirstline']=(isset($_POST['f_export_namefirstline'.$format])) ? $_POST['f_export_namefirstline'.$format] : 0; $sql['export']['sendfile']=$_POST['f_export_sendresult']; $sql['export']['compressed']=(isset($_POST['f_export_compressed'])) ? $_POST['f_export_compressed'] : 0; $sql['export']['exportfile']=""; $sql['export']['xmlstructure']=(isset($_POST['f_export_xmlstructure'])) ? $_POST['f_export_xmlstructure'] : 0; $sql['export']['htmlstructure']=(isset($_POST['f_export_htmlstructure'])) ? $_POST['f_export_htmlstructure'] : 0; //ausgewählte Tabellen if(isset($_POST['f_export_tables'])) $sql['export']['tables']=$_POST['f_export_tables']; } else CheckcsvOptions(); //Tabellenliste $sqlt="SHOW TABLE STATUS FROM `$db`"; $res=MSD_query($sqlt) or die(SQLError($sqlt,mysql_error())); if($res) { $sql['export']['tablecount']=mysql_numrows($res); $sql['export']['recordcount']=0; for($i=0;$i<$sql['export']['tablecount'];$i++) { $row = mysql_fetch_array($res); $tblstr.=''."\n"; $sql['export']['recordcount']+=$row['Rows']; } } $exaus=$aus.'

'.sprintf($lang['sql_export'],$databases['Name'][$dbid]).'

'; $exaus.='
'.$nl; $exaus.= ''.$lang['import'].''; $exaus.= '
'.sprintf($lang['sql_export'],$databases['Name'][$dbid]).'
'; $exaus.= ''.$nl; $exaus.= ''; $exaus.= ''; $exaus.= ''; $exaus.= '
'.$lang['tables'].''.$lang['exportoptions'].''.$lang['export'].'
'.$sql['export']['tablecount'].' '.$lang['tables'].', '.$sql['export']['recordcount'].' '.$lang['records'].''; $exaus.= '   '.$lang['all'].'  '.$lang['none'].''.$nl; $exaus.= '

'.$nl; $exaus.= '
'.$nl; $exaus.= ''.$nl; $exaus.= ''."CSV".'   '.$nl; $exaus.= ''."Excel".'   '.$nl; $exaus.= ''.$lang['excel2003'].'
'.$nl; $exaus.= ''."XML".'   '.$nl; $exaus.= ''."HTML".'

'.$nl; $exaus.= '
CSV-Optionen'.$nl; $exaus.= ''.$nl; $exaus.= ''.$nl; $exaus.= ''.$nl; $exaus.= ''.$nl; $exaus.= ''.$nl; $exaus.= '
'.$nl; $exaus.= ''.$lang['csv_namefirstline'].'
'.$lang['csv_fieldseperate'].'
'.$lang['csv_fieldsenclosed'].'
'.$lang['csv_fieldsescape'].'
'.$lang['csv_eol'].'
'.$lang['csv_null'].'
'.$nl; $exaus.= '
Excel-Optionen'.$nl; $exaus.= ''.$nl; $exaus.= '
'; $exaus.= ''.$lang['csv_namefirstline'].'
'.$lang['csv_null'].'
'.$nl; $exaus.= '
XML-Optionen'; $exaus.= ''; $exaus.= '
mit Struktur
'.$nl; $exaus.= '
HTML-Optionen'; $exaus.= ''; $exaus.= '
mit Struktur
'.$nl; $exaus.= '
'.$nl; $exaus.= ''.$lang['showresult'].'
'.$nl; $exaus.= ''.$lang['sendresultasfile'].'
'.$nl; $exaus.= '
'.$lang['compressed'].'

'.$nl; $exaus.= '
'.$nl; $exaus.= '
'.$nl; $exaus.= ''.$nl; if(!$download) echo $exaus.$nl; if(isset($_POST['f_export_submit']) && isset($sql['export']['tables'])) { if(!$download) echo '

'.$lang['export'].':zeige in neuem Fenster

'.$nl; echo ''.$lang['exportfinished'].'  '.sprintf($lang['exportlines'],$sql['export']['lines']).$nl; } else exit(); } } } ?>

'; echo MSDFooter(); function FormHiddenParams() { global $db,$dbid,$tablename,$context,$limitstart,$order,$orderdir; $s=''; $s.=''; $s.=''; $s.=''; $s.=''; $s.=''; $s.=''; return $s; } ?>