0,
'Rows' => 1,
'Data_length' => 2,
'Auto_increment' => 3,
'Avg_row_length' => 4,
'Max_data_length' => 5,
'Comment' => 6,
'Row_format' => 7,
'Index_length' => 8,
'Data_free' => 9,
'Collation' => 10,
'Create_time' => 11,
'Update_time' => 12,
'Check_time' => 13,
'Create_options' => 14,
'Version' => 15,
'Engine' => 16,
'Checksum' => 17
);
$byte_output=array(
'Data_length',
'Avg_row_length',
'Max_data_length',
'Index_length',
'Data_free'
);
function add_sortkey($name)
{
global $keysort;
//echo "
Uebergeben: ".$name;
if (array_key_exists($name,$keysort)) $ret=$keysort[$name];
else $ret=0;
return $ret;
}
//Data-View
echo $aus . '
'; if ($showtables == 0) { $p='sql.php?sql_statement=' . urlencode($sql['sql_statement']) . '&db=' . $db . '&tablename=' . $tablename . '&dbid=' . $dbid . '&limitstart=' . $limitstart . '&order=' . urlencode($order) . '&orderdir=' . $orderdir . '&tdc=' . $tdcompact; echo '' . $lang['L_SQL_RECORDNEW'] . ' '; echo '' . $lang['L_SQL_EDIT_TABLESTRUCTURE'] . ''; } else { $p='sql.php?db=' . $db . '&dbid=' . $dbid . '&context=2'; echo '' . $lang['L_SQL_TABLENEW'] . ''; } //Statuszeile $tn=ExtractTablenameFromSQL($sql['sql_statement']); if ($databases['Name'][$dbid]!=$databases['db_actual']) { // Table is located in a different databasse // switch the actual database $databases['db_actual']=$databases['Name'][$dbid]; // refresh menu to switch to actual database echo ''; } echo '
' . ( $tn != '' ? $lang['L_TABLE'] . ' `' . $databases['db_actual'] . '`.`' . $tn . '`
' : '' );
if (isset($msg)) echo $msg;
$numrowsabs=-1;
$numrows=0;
// vorgehensweise - zwischen SELECT und FROM alles rausschneiden und durch count(*) ersetzen
// es soll die Summe der Datensaetze ermittelt werden, wenn es kein LIMIT geben wuerde, um die
// Blaettern-Links korrekt anzuzeigen
$skip_mysql_execution=false;
if ($sql_to_display_data == 0)
{
//mehrere SQL-Statements
$numrowsabs=$numrows=0;
MSD_DoSQL($sql['sql_statement']);
echo SQLOutput($out);
$skip_mysql_execution=true;
}
else
{
$sql_temp=strtolower($sql['sql_statement']);
if (substr($sql_temp,0,7) == 'select ')
{
if (false !== strpos($sql_temp,' limit '))
{
// es wurde ein eigenes Lmit im Query angegeben - eigene Berechnung abbrechen
$numrowsabs=-1;
}
else
{
$pos=strpos($sql_temp,'from ');
$sql_temp='SELECT count(*) as anzahl ' . substr($sql['sql_statement'],$pos,strlen($sql['sql_statement']) - $pos);
$res=@MSD_query($sql_temp,false);
if ($res)
{
if ($row=mysql_fetch_object($res))
{
$numrowsabs=$row->anzahl;
}
}
else
{
// Query ergab Fehler - Anzahl unbekannt; -1 übernimmt dann die Groesse des Resultsets
$numrowsabs=-1;
}
}
}
}
$sqltmp=$sql['sql_statement'] . $sql['order_statement'] . ( strpos(strtolower($sql['sql_statement'] . $sql['order_statement']),' limit ') ? '' : $limit );
if (!$skip_mysql_execution) $res=MSD_query($sqltmp);
$numrows=@mysql_num_rows($res);
if ($numrowsabs == -1) $numrowsabs=$numrows;
if ($limitende > $numrowsabs) $limitende=$numrowsabs;
if ($numrowsabs > 0 && $Anzahl_SQLs <= 1)
{
if ($showtables == 0)
{
$command_line=$lang['L_INFO_RECORDS'] . " " . ( $limitstart + 1 ) . " - ";
if ($limitstart + $limitende > $numrowsabs) $command_line.=$numrowsabs;
else $command_line.=$limitstart + $limitende;
$command_line.=" " . $lang['L_SQL_VONINS'] . " $numrowsabs ";
$command_line.=( $limitstart > 0 ) ? '<< ' : '<< ';
$command_line.=( $limitstart > 0 ) ? '< ' : '< ';
$command_line.=( $limitstart + $limitende < $numrowsabs ) ? '> ' : '> ';
$command_line.=( $limitstart + $limitende < ( $numrowsabs - $config['sql_limit'] ) ) ? '>>' : '>>';
echo $command_line;
}
else
{
echo $numrowsabs.' '.($numrowsabs>1 ? $lang['L_TABLES']:$lang['L_TABLE']);
}
echo '
' . ( ( $tdcompact == 1 ) ? $lang['L_SQL_VIEW_STANDARD'] : $lang['L_SQL_VIEW_COMPACT'] ) . ''; $t.=' ' . $lang['L_SQL_QUERYENTRY'] . ' ' . count($row) . ' ' . $lang['L_SQL_COLUMNS']; $t.=' | |||||
# | '; $temp=array(); for ($x=0; $x < count($row); $x++) { $temp[$x]['data']=mysql_fetch_field($res,$x); $temp[$x]['sort']=add_sortkey($temp[$x]['data']->name); } //v($temp); if ($showtables == 1) $temp=mu_sort($temp,'sort'); for ($x=0; $x < count($temp); $x++) { $str=$temp[$x]['data']; $t.=''; $pic=""; $fdesc[$temp[$x]['data']->name]['name']=isset($str->name) ? $str->name : ''; $fdesc[$temp[$x]['data']->name]['table']=isset($str->table) ? $str->table : ''; $fdesc[$temp[$x]['data']->name]['max_length']=isset($str->max_length) ? $str->max_length : ''; $fdesc[$temp[$x]['data']->name]['not_null']=isset($str->not_null) ? $str->not_null : ''; $fdesc[$temp[$x]['data']->name]['primary_key']=isset($str->primary_key) ? $str->primary_key : ''; $fdesc[$temp[$x]['data']->name]['unique_key']=isset($str->unique_key) ? $str->unique_key : ''; $fdesc[$temp[$x]['data']->name]['multiple_key']=isset($str->multiple_key) ? $str->multiple_key : ''; $fdesc[$temp[$x]['data']->name]['numeric']=isset($str->numeric) ? $str->numeric : ''; $fdesc[$temp[$x]['data']->name]['blob']=isset($str->blob) ? $str->blob : ''; $fdesc[$temp[$x]['data']->name]['type']=isset($str->type) ? $str->type : ''; $fdesc[$temp[$x]['data']->name]['unsigned']=$str->unsigned; $fdesc[$temp[$x]['data']->name]['zerofill']=$str->zerofill; $fdesc[$temp[$x]['data']->name]['Check_time']=isset($str->Check_time) ? $str->Check_time : ''; $fdesc[$temp[$x]['data']->name]['Checksum']=isset($str->Checksum) ? $str->Checksum : ''; $fdesc[$temp[$x]['data']->name]['Engine']=isset($str->Engine) ? $str->Engine : ''; if (isset($str->Comment) && substr($str->Comment,0,4) == 'VIEW') $fdesc[$temp[$x]['data']->name]['Engine']='View'; $fdesc[$temp[$x]['data']->name]['Version']=isset($str->Version) ? $str->Version : ''; $tt=$lang['L_NAME'] . ': ' . $fdesc[$temp[$x]['data']->name]['name'] . ' Type: ' . $fdesc[$temp[$x]['data']->name]['type'] . " Max Length: " . $fdesc[$temp[$x]['data']->name]['max_length'] . " Unsigned: " . $fdesc[$temp[$x]['data']->name]['unsigned'] . " zerofill: " . $fdesc[$temp[$x]['data']->name]['zerofill']; $pic=''; if ($str->primary_key == 1 || $str->unique_key == 1) { if ($key == -1) $key=$temp[$x]['data']->name; else $key.='|' . $temp[$x]['data']->name; if ($str->primary_key == 1) $pic=$icon['key_primary']; elseif ($str->unique_key == 1) $pic=$icon['index']; } // show sorting icon $arname=( $orderdir == "ASC" ) ? $icon['arrow_down'] : $icon['arrow_up']; if ($str->name == $order) $t.=$arname; 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; $t.=' | '; } unset($temp); $temp=array(); //und jetzt Daten holen mysql_data_seek($res,0); $s=$keysort; $s=array_flip($keysort); ksort($s); for ($i=0; $i < $numrows; $i++) { $data[0]=mysql_fetch_array($res,MYSQL_ASSOC); if ($showtables == 1 && $tabellenansicht == 1) { // Spalten sortieren, wenn wir uns in einer Tabellenuebersicht befinden $xx=mu_sort($data,"$s[0],$s[1],$s[2],$s[3],$s[4],$s[5],$s[6],$s[7],$s[8],$s[9],$s[10],$s[11],$s[12],$s[13],$s[14],$s[15],$s[16]"); $temp[$i]=$xx[0]; } else $temp[$i]=$data[0]; } $rownr=$limitstart + 1; for ($i=0; $i < $numrows; $i++) { $row=$temp[$i]; // mysql_fetch_row($res); $cl=( $i % 2 ) ? 'dbrow' : 'dbrow1'; $erste_spalte=1; // bei Tabellenuebersicht soll nach vorgefertigter Reihenfolge sortiert werden, ansonsten einfach Daten anzeigen if ($showtables == 1) $sortkey=$keysort; else $sortkey=$row; $spalte=0; // get primary key link for editing if ($key > -1) { $primary_key=''; $keys=explode('|',$key); foreach ($sortkey as $rowkey=>$rowval) { if (in_array($rowkey,$keys)) { if (strlen($primary_key) > 0) $primary_key.='|'; $primary_key.='`' . urlencode($rowkey) . '`=\'' . urlencode($rowval) . '\''; } } //echo "' . $nl; $p='sql.php?sql_statement=' . urlencode($sql['sql_statement']) . '&db=' . $databases['db_actual'] . '&tablename=' . $tablename . '&dbid=' . $dbid . '&limitstart=' . $limitstart . '&order=' . urlencode($order) . '&orderdir=' . $orderdir . '&tdc=' . $tdcompact; if ($key == -1) { $rk=build_where_from_record($temp[$i]); $p.='&recordkey=' . urlencode($rk); } else { //Key vorhanden $p.='&recordkey=' . urlencode($primary_key); //urlencode("`".$fdesc[$key]['name']."`='".$rowval."'"); } if ($showtables == 1) $p.='&recordkey=' . urlencode($tablename); if (!isset($no_edit) || !$no_edit) { if ($showtables == 0) { $d.='' . $icon['edit'] . ' '; } } if ($showtables == 0 && $tabellenansicht == 0) { $d.='' . $icon['delete'] . ''; } else { if ($tabellenansicht == 1 && $showtables == 1) { $d.='' . $icon['edit'] . ' ' . $nl . $nl; if (!( isset($row['Comment']) && ( substr(strtoupper($row['Comment']),0,4) == 'VIEW' ) )) { $d.='' . $icon['table_truncate'] . ' ' . $nl . $nl; $d.='' . $icon['table_truncate_reset'] . ' ' . $nl . $nl; $d.='' . $icon['delete'] . ' ' . $nl . $nl; } else { $d.='' . $icon['delete'] . ' ' . $nl . $nl; } } } $d.=' | ' . $rownr . '. | '; $rownr++; $erste_spalte=0; } $d.='';
$divstart=' ';
$divend=' ';
if ($bb == $spalte)
{
$data=convert_to_utf8(simple_bbcode_conversion($rowval));
}
else
{
if ($showtables == 0)
{
if (isset($fdesc[$rowkey]['type'])) $data=( $fdesc[$rowkey]['type'] == 'string' || $fdesc[$rowkey]['type'] == 'blob' ) ? convert_to_utf8($rowval) : $rowval;
}
else
{
if (isset($temp[$i][$rowkey])) $data=( $fdesc[$rowkey]['type'] == 'string' || $fdesc[$rowkey]['type'] == 'blob' ) ? convert_to_utf8($temp[$i][$rowkey]) : $temp[$i][$rowkey];
else $data='';
if (in_array($rowkey,$byte_output)) $data=byte_output($data);
}
}
//v($fdesc[$rowkey]);
if ($showtables==0)
{
if (is_null($rowval)) $data='NULL';
else $data=htmlspecialchars($data,ENT_COMPAT,'UTF-8');
}
$spalte++;
$browse_link='';
$d.=( $tabellenansicht == 1 && $rowkey == 'Name' ) ? $divstart . $browse_link . $icon['browse'] . " " . $browse_link . $data . "$divend" : $divstart . $data . $divend;
$d.=' | ';
}
// Tabellenueberschrift en ausgeben
if ($i == 0) echo '|
---|---|---|---|---|---|
' . $lang['L_SQL_NODATA'] . '
';