var auswahl = "document.getElementsByName(\"f_export_tables[]\")[0]"; var msg1="'.$lang['L_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; $norder=($orderdir=="DESC") ? 'ASC' : 'DESC'; $sql['order_statement']=($order!='') ? ' ORDER BY `'.$order.'` '.$norder : ''; $sql['sql_statement']=(isset($_GET['sql_statement'])) ? 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'])) ? $_POST['sqltextarea'] : ''; $db=$_POST['db']; $dbid=$_POST['dbid']; $tablename=$_POST['tablename']; if (isset($_POST['tablecombo'])&&$_POST['tablecombo']>'') { $sql['sql_statement']=$_POST['tablecombo']; $tablename=ExtractTablenameFromSQL($sql['sql_statement']); } if (isset($_POST['sqltextarea'])&&$_POST['sqltextarea']>'') $tablename=ExtractTablenameFromSQL($_POST['sqltextarea']); 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(); mysqli_select_db($config['dbconnection'], $db); ///*** EDIT / UPDATES / INSERTS ***/// ///*** ***/// // handle update action after submitting it if (isset($_POST['update'])||isset($_GET['update'])) { GetPostParams(); $f=explode('|',$_POST['feldnamen']); $sqlu='UPDATE `'.$_POST['db'].'`.`'.$tablename.'` SET '; for ($i=0; $i'; if (isset($mode)&&$mode=='searchedit') $search=1; $sql_to_display_data=1; } // handle insert action after submitting it if (isset($_POST['insert'])) { GetPostParams(); $f=explode('|',$_POST['feldnamen']); $sqlu='INSERT INTO `'.$tablename.'` SET '; for ($i=0; $i'; $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['L_SQL_BROWSER']); if ($search==0&&!$download) { echo $aus; $aus=''; include ('./inc/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) { $sqlk="DELETE FROM `$tablename` WHERE ".$rk." LIMIT 1"; $res=MSD_query($sqlk); //echo "
".$sqlk; $aus.='

'.$lang['L_SQL_RECORDDELETED'].'

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

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

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

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

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

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

'; } } $javascript_switch=''; if ($mode=='edit'||$mode=='searchedit') include ('./inc/sqlbrowser/sql_record_update_inputmask.php'); if ($mode=='new') include ('./inc/sqlbrowser/sql_record_insert_inputmask.php'); } if ($context==0) include_once ('./inc/sqlbrowser/sql_dataview.php'); if ($context==1) include ('./inc/sqlbrowser/sql_commands.php'); if ($context==2) include ('./inc/sqlbrowser/sql_tables.php'); if ($context==3) include ('./inc/sql_tools.php'); } if ($context==4) include ('./inc/sql_importexport.php'); if ($search==1) include ('./inc/sqlbrowser/mysql_search.php'); if (!$download) { ?>

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