var auswahl = "document.getElementsByName(\"f_export_tables[]\")[0]"; var msg1="' . $lang['sql_notablesselected'] . '"; '; } //Variabeln $mysql_help_ref='http://dev.mysql.com/doc/'; $mysql_errorhelp_ref='http://dev.mysql.com/doc/mysql/en/error-handling.html'; $no_order=false; $tdcompact=( isset($_GET['tdc']) ) ? $_GET['tdc'] : $config['interface_table_compact']; $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($_POST['limitstart']) ) ? intval($_POST['limitstart']) : 0; if (isset($_GET['limitstart'])) $limitstart=intval($_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'])) : ''; if (isset($_POST['sql_statement'])) $sql['sql_statement']=$_POST['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']; $search=( isset($_GET['search']) ) ? $_GET['search'] : 0; //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=ExtractTablenameFromSQL($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=getCountSQLStatements($sql['sql_statement']); $sql_to_display_data=sqlReturnsRecords($sql['sql_statement']); if ($Anzahl_SQLs > 1) $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) { //is order by last ? $sql['order_statement']=substr($sql['sql_statement'],$op); if (strpos($sql['order_statement'],')') > 0) $sql['order_statement']=''; else $sql['sql_statement']=substr($sql['sql_statement'],0,$op); } } if (isset($_POST['tableselect']) && $_POST['tableselect'] != "1") $tablename=$_POST['tableselect']; MSD_mysql_connect(); mysql_select_db($db,$config['dbconnection']); ///*** EDIT / UPDATES / INSERTS ***/// ///*** ***/// //Datensatz editieren if (isset($_POST['update']) || isset($_GET['update'])) { GetPostParams(); $f=explode('|',$_POST['feldnamen']); $sqlu='UPDATE `' . $tablename . '` SET '; for ($i=0; $i < count($f); $i++) { $fkey=str_replace('.','_',$f[$i]); $sqlu.='`' . $f["$i"] . '`=\'' . convert_to_latin1($_POST[$fkey]) . '\', '; } $sqlu=substr($sqlu,0,strlen($sqlu) - 2) . ' WHERE ' . $recordkey; $res=MSD_query($sqlu); $msg='

' . $lang['sql_recordupdated'] . '

'; if (isset($mode) && $mode == 'searchedit') $search=1; $sql_to_display_data=1; } //Datensatz einfuegen if (isset($_POST['insert'])) { GetPostParams(); $f=explode('|',$_POST['feldnamen']); $sqlu='INSERT INTO `' . $tablename . '` SET '; for ($i=0; $i < count($f); $i++) { $sqlu.='`' . $f[$i] . '`=\'' . convert_to_latin1($_POST[$f[$i]]) . '\', '; } $sqlu=substr($sqlu,0,strlen($sqlu) - 2); $res=MSD_query($sqlu); $msg='

' . $lang['sql_recordinserted'] . '

'; $sql_to_display_data=1; } if (isset($_POST['cancel'])) GetPostParams(); //Tabellenansicht $showtables=( substr(strtoupper($sql['sql_statement']),0,10) == "SHOW TABLE" ) ? 1 : 0; $tabellenansicht=( substr(strtoupper($sql['sql_statement']),0,5) == "SHOW " ) ? 1 : 0; if (!isset($limitstart)) $limitstart=0; $limitende=$config['sql_limit']; 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']); // Kopfzeile -- Tools... $aus.='

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

'; if ($search == 0 && !$download) { echo $aus; $aus=''; include ( './sqlbrowser/sqlbox.php' ); if ($mode > '' && $context == 0) { if (isset($recordkey) && $recordkey > '') $rk=urldecode($recordkey); if (isset($_GET['tablename'])) $tablename=$_GET['tablename']; if ($mode == 'kill' || $mode == 'kill_view') { if ($showtables == 0) { if (strpos($rk,"|") != false) { $rk=str_replace('|',' AND ',$rk); } $sqlk="DELETE FROM `$tablename` WHERE " . $rk . " LIMIT 1"; $res=MSD_query($sqlk); //echo "
".$sqlk; $aus.='

' . $lang['sql_recorddeleted'] . '

'; } else { $sqlk="DROP TABLE `$rk`"; if ($mode == 'kill_view') $sqlk='DROP VIEW `' . $rk . '`'; $res=MSD_query($sqlk); $aus.='

' . sprintf($lang['sql_recorddeleted'],$rk) . '

'; } } if ($mode == "empty") { if ($showtables == 0) { } else { $sqlk="TRUNCATE `$rk`"; $res=MSD_query($sqlk); $aus.='

' . sprintf($lang['sql_tableemptied'],$rk) . '

'; } } if ($mode == "emptyk") { if ($showtables == 0) { } else { $sqlk="TRUNCATE `$rk`;"; $res=MSD_query($sqlk); $sqlk="ALTER TABLE `$rk` AUTO_INCREMENT=1;"; $res=MSD_query($sqlk); $aus.='

' . sprintf($lang['sql_tableemptiedkeys'],$rk) . '

'; } } if ($mode == "edit" || $mode == "searchedit") { $rk=str_replace('|',' AND ',$recordkey); $aus.='

' . $lang['sql_recordedit'] . '

'; $sqledit="SELECT * FROM `$tablename` WHERE " . $rk; $res=MSD_query($sqledit); $aus.='
'; $row=mysql_fetch_row($res); $aus.=''; $feldnamen=""; for ($x=0; $x < count($row); $x++) { $str=mysql_fetch_field($res,$x); $feldnamen.=$str->name . '|'; $aus.=''; $aus.=''; //'.$str->type.' } $aus.=''; $aus.='
' . convert_to_utf8($str->name) . ''; if ($str->type == 'blob') $aus.=''; else $aus.=''; $aus.=' 
       
' . FormHiddenParams() . '
'; } if ($mode == "new") { $aus.='

' . $lang['sql_recordnew'] . '

'; $sqledit="SHOW FIELDS FROM `$tablename`"; $res=MSD_query($sqledit); $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) include_once ( './sqlbrowser/sql_dataview.php' ); if ($context == 1) include ( './sqlbrowser/sql_commands.php' ); if ($context == 2) include ( './sqlbrowser/sql_tables.php' ); if ($context == 3) include ( './inc/sql_tools.php' ); } if ($context == 4) include ( './inc/sql_importexport.php' ); if ($search == 1) include ( './sqlbrowser/mysql_search.php' ); if (!$download) { ?>

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