Dieser Commit ist enthalten in:
Commit
35b80040c0
337 geänderte Dateien mit 31341 neuen und 0 gelöschten Zeilen
411
sqlbrowser/mysql_search.php
Normale Datei
411
sqlbrowser/mysql_search.php
Normale Datei
|
|
@ -0,0 +1,411 @@
|
|||
<?php
|
||||
if (!defined('MSD_VERSION')) die('No direct access.');
|
||||
//alle Tabellen der aktuellen Datenbank ermitteln und Zugriffs-Array aufbauen
|
||||
$sql='SHOW TABLES FROM `' . $db . '`';
|
||||
$tables=ARRAY();
|
||||
$link=MSD_mysql_connect();
|
||||
$res=mysql_query($sql,$link);
|
||||
if (!$res === false)
|
||||
{
|
||||
WHILE ($row=mysql_fetch_array($res,MYSQL_NUM))
|
||||
{
|
||||
$tables[]=$row[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
die("No Tables in Database!");
|
||||
|
||||
// Suchkriterien aus Session holen oder aus POST-Umgebung
|
||||
// so bleiben die Suchkriterien auch erhalten wenn man zwischendurch woanders klickt
|
||||
if (isset($_POST['suchbegriffe'])) $_SESSION['mysql_search']['suchbegriffe']=$_POST['suchbegriffe'];
|
||||
if (!isset($_SESSION['mysql_search']['suchbegriffe'])) $_SESSION['mysql_search']['suchbegriffe']='';
|
||||
$suchbegriffe=$_SESSION['mysql_search']['suchbegriffe'];
|
||||
|
||||
if (isset($_POST['suchart'])) $_SESSION['mysql_search']['suchart']=$_POST['suchart'];
|
||||
if (!isset($_SESSION['mysql_search']['suchart']) || strlen($_SESSION['mysql_search']['suchart']) < 2) $_SESSION['mysql_search']['suchart']='AND';
|
||||
$suchart=$_SESSION['mysql_search']['suchart'];
|
||||
|
||||
if (isset($_POST['table_selected'])) $_SESSION['mysql_search']['table_selected']=$_POST['table_selected'];
|
||||
if (!isset($_SESSION['mysql_search']['table_selected'])) $_SESSION['mysql_search']['table_selected']=0;
|
||||
$table_selected=$_SESSION['mysql_search']['table_selected'];
|
||||
// Falls zwischendurch Tabellen geloescht wurden und der Index nicht mehr existiert, zuruecksetzen
|
||||
if ($table_selected > count($tables) - 1) $table_selected=0;
|
||||
|
||||
$offset=( isset($_POST['offset']) ) ? intval($_POST['offset']):0;
|
||||
|
||||
$tablename=isset($_GET['tablename']) ? urldecode($_GET['tablename']):'';
|
||||
|
||||
// Delete
|
||||
if (isset($_GET['mode']) && $_GET['mode'] == "kill" && $rk > '')
|
||||
{
|
||||
//echo "<br> RK ist: ".$rk."<br><br>";
|
||||
if (strpos($rk,"|") != false) $rk=str_replace('|',' AND ',$rk);
|
||||
$sqlk="DELETE FROM `$tablename` WHERE " . $rk . " LIMIT 1";
|
||||
//echo $sqlk;
|
||||
$res=MSD_query($sqlk);
|
||||
// echo "<br>".$res;
|
||||
$aus.='<p class="success">' . $lang['sql_recorddeleted'] . '</p>';
|
||||
}
|
||||
|
||||
function mysql_search($db, $tabelle, $suchbegriffe, $suchart, $offset=0, $anzahl_ergebnisse=20, $auszuschliessende_tabellen='')
|
||||
{
|
||||
global $tables,$config;
|
||||
$ret=false;
|
||||
$link=MSD_mysql_connect();
|
||||
if (sizeof($tables) > 0)
|
||||
{
|
||||
$suchbegriffe=trim(str_replace('*','',$suchbegriffe));
|
||||
$suchworte=explode(' ',$suchbegriffe);
|
||||
if (( $suchbegriffe > '' ) && ( is_array($suchworte) ))
|
||||
{
|
||||
// Leere Einträge (durch doppelte Leerzeichen) entfernen
|
||||
$anzahl_suchworte=sizeof($suchworte);
|
||||
for ($i=0; $i < $anzahl_suchworte; $i++)
|
||||
{
|
||||
if (trim($suchworte[$i]) == '') unset($suchworte[$i]);
|
||||
}
|
||||
|
||||
$bedingung='';
|
||||
$where='';
|
||||
$felder='';
|
||||
|
||||
// Felder ermitteln
|
||||
$sql='SHOW COLUMNS FROM `' . $db . '`.`' . $tables[$tabelle] . '`';
|
||||
$res=mysql_query($sql,$link);
|
||||
unset($felder);
|
||||
if (!$res === false)
|
||||
{
|
||||
// Felder der Tabelle ermitteln
|
||||
WHILE ($row=mysql_fetch_object($res))
|
||||
{
|
||||
$felder[]=$row->Field;
|
||||
}
|
||||
}
|
||||
|
||||
$feldbedingung='';
|
||||
if ($suchart == 'CONCAT')
|
||||
{
|
||||
if (is_array($felder))
|
||||
{
|
||||
//Concat-String bildem
|
||||
$concat=implode('`),LOWER(`',$felder);
|
||||
$concat='CONCAT_WS(\'\',LOWER(`' . $concat . '`))';
|
||||
$where='';
|
||||
foreach ($suchworte as $suchbegriff)
|
||||
{
|
||||
$where.=$concat . ' LIKE \'%' . strtolower($suchbegriff) . '%\' AND ';
|
||||
}
|
||||
$where=substr($where,0,-4); // letztes AND entfernen
|
||||
$sql='SELECT * FROM `' . $db . '`.`' . $tables[$tabelle] . '` WHERE ' . $where . ' LIMIT ' . $offset . ',' . $anzahl_ergebnisse;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$pattern='`{FELD}` LIKE \'%{SUCHBEGRIFF}%\'';
|
||||
if (is_array($felder))
|
||||
{
|
||||
foreach ($felder as $feld)
|
||||
{
|
||||
unset($feldbedingung);
|
||||
foreach ($suchworte as $suchbegriff)
|
||||
{
|
||||
$suchen=ARRAY(
|
||||
|
||||
'{FELD}',
|
||||
'{SUCHBEGRIFF}'
|
||||
);
|
||||
$ersetzen=ARRAY(
|
||||
|
||||
$feld,
|
||||
$suchbegriff
|
||||
);
|
||||
$feldbedingung[]=str_replace($suchen,$ersetzen,$pattern);
|
||||
}
|
||||
$bedingung[]='(' . implode(' ' . $suchart . ' ',$feldbedingung) . ') ';
|
||||
}
|
||||
}
|
||||
else
|
||||
die('<br>Fehler bei Suche: ich konnte nicht ermitteln welche Felder die Tabelle "' . $tabelle . '" hat!');
|
||||
$where=implode(' OR ',$bedingung);
|
||||
$sql='SELECT * FROM `' . $db . '`.`' . $tables[$tabelle] . '` WHERE (' . $where . ') LIMIT ' . $offset . ',' . $anzahl_ergebnisse;
|
||||
}
|
||||
}
|
||||
else
|
||||
$sql='SELECT * FROM `' . $db . '`.`' . $tables[$tabelle] . '` LIMIT ' . $offset . ',' . $anzahl_ergebnisse;
|
||||
|
||||
$res=@mysql_query($sql,$link);
|
||||
if ($res)
|
||||
{
|
||||
WHILE ($row=mysql_fetch_array($res,MYSQL_ASSOC))
|
||||
{
|
||||
//Treffer markieren
|
||||
foreach ($row as $key=>$val)
|
||||
{
|
||||
foreach ($suchworte as $suchbegriff)
|
||||
{
|
||||
$row[$key]=markiere_suchtreffer($suchbegriff,$row[$key]);
|
||||
}
|
||||
$row[$key]=ersetze_suchtreffer($row[$key]);
|
||||
}
|
||||
$ret[]=$row;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// Markiert den Suchbegriff mit einem Code (ASCII 01/02)
|
||||
// - falls nicht gefunden : Rückgabe des Originalstrings
|
||||
//
|
||||
function markiere_suchtreffer($suchbegriff, $suchstring)
|
||||
{
|
||||
$str=strtolower($suchstring);
|
||||
$suchbegriff=strtolower($suchbegriff);
|
||||
if (( strlen($str) > 0 ) && ( strlen($suchbegriff) > 0 ))
|
||||
{
|
||||
// Treffer Position bestimmen
|
||||
$offset=0;
|
||||
$trefferpos=0;
|
||||
while (( $offset <= strlen($str) ))
|
||||
//Wenn nur der erste Treffer markiert werden soll, so muss die Zeile so lauten
|
||||
// while ( ($offset<=strlen($str)) || ($in_html==false) )
|
||||
{
|
||||
for ($offset=$trefferpos; $offset <= strlen($str); $offset++)
|
||||
{
|
||||
$start=strpos($str,$suchbegriff,$offset);
|
||||
if ($start === false) $offset=strlen($str) + 1;
|
||||
else
|
||||
{
|
||||
if ($offset <= strlen($str))
|
||||
{
|
||||
//Treffer überprüfen
|
||||
$in_html=false;
|
||||
// Steht die Fundstelle zwischen < und > (also im HTML-Tag) ?
|
||||
for ($position=$start; $position >= 0; $position--)
|
||||
{
|
||||
if (substr($str,$position,1) == ">")
|
||||
{
|
||||
$in_html=false;
|
||||
$position=-1; // Schleife verlassen
|
||||
}
|
||||
if (substr($str,$position,1) == "<")
|
||||
{
|
||||
$in_html=true;
|
||||
$position=-1; // Schleife verlassen
|
||||
}
|
||||
}
|
||||
if ($in_html)
|
||||
{
|
||||
for ($position2=$start; $position2 < strlen($str); $position2++)
|
||||
{
|
||||
if (substr($str,$position2,1) == "<")
|
||||
{
|
||||
$position2=strlen($str) + 1;
|
||||
}
|
||||
if (substr($str,$position2,1) == ">")
|
||||
{
|
||||
$in_html=true;
|
||||
$position2=strlen($str) + 1;
|
||||
$offset=strlen($str) + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$in_html)
|
||||
{
|
||||
$ersetzen=substr($suchstring,$start,strlen($suchbegriff));
|
||||
$str=substr($suchstring,0,$start);
|
||||
$str.=chr(1) . $ersetzen . chr(2);
|
||||
$str.=substr($suchstring,( $start + strlen($ersetzen) ),( strlen($suchstring) - strlen($ersetzen) ));
|
||||
$suchstring=$str;
|
||||
}
|
||||
if ($in_html)
|
||||
{
|
||||
$trefferpos=$start + 1;
|
||||
$offset=$trefferpos;
|
||||
}
|
||||
}
|
||||
$offset=$start + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $suchstring;
|
||||
}
|
||||
|
||||
// Ersetzt die Codes letztlich durch die Fontangabe
|
||||
function ersetze_suchtreffer($text)
|
||||
{
|
||||
$such=ARRAY(
|
||||
|
||||
chr(1),
|
||||
chr(2)
|
||||
);
|
||||
$ersetzen=ARRAY(
|
||||
|
||||
'<span class="treffer">',
|
||||
'</span>'
|
||||
);
|
||||
return str_replace($such,$ersetzen,htmlspecialchars($text));
|
||||
}
|
||||
|
||||
$suchbegriffe=trim($suchbegriffe); // Leerzeichen vorne und hinten wegschneiden
|
||||
if (isset($_POST['reset']))
|
||||
{
|
||||
$suchbegriffe='';
|
||||
$_SESSION['mysql_search']['suchbegriffe']='';
|
||||
$suchart='AND';
|
||||
$_SESSION['mysql_search']['suchart']='AND';
|
||||
$table_selected=0;
|
||||
$_SESSION['mysql_search']['table_selected']=0;
|
||||
}
|
||||
$showtables=0; // Anzeige der Tabellendaten im restlichen SQL-Browser ausschalten
|
||||
|
||||
|
||||
// Fix bis zur kompletten Umstellung auf Templates
|
||||
echo $aus;
|
||||
$aus='';
|
||||
|
||||
$anzahl_tabellen=sizeof($tables);
|
||||
$table_options='';
|
||||
if ($anzahl_tabellen > 0)
|
||||
{
|
||||
for ($i=0; $i < $anzahl_tabellen; $i++)
|
||||
{
|
||||
if (isset($tables[$i]))
|
||||
{
|
||||
$table_options.='<option value="' . $i . '"';
|
||||
if (( $i == $table_selected ) || ( $tables[$i] == $tablename ))
|
||||
{
|
||||
$table_options.=' selected';
|
||||
$table_selected=$i;
|
||||
}
|
||||
$table_options.='>' . $tables[$i] . '</option>' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$tpl=new MSDTemplate();
|
||||
$tpl->set_filenames(array(
|
||||
|
||||
'show' => './sqlbrowser/templates/mysql_search.tpl'
|
||||
));
|
||||
|
||||
$tpl->assign_vars(array(
|
||||
|
||||
'LANG_SQLSEARCH' => $lang['sql_search'],
|
||||
'LANG_SQL_SEARCHWORDS' => $lang['sql_searchwords'],
|
||||
'SUCHBEGRIFFE' => $suchbegriffe,
|
||||
'LANG_START_SQLSEARCH' => $lang['start_sql_search'],
|
||||
'LANG_RESET_SEARCHWORDS' => $lang['reset_searchwords'],
|
||||
'LANG_SEARCH_OPTIONS' => $lang['search_options'],
|
||||
'AND_SEARCH' => $suchart == 'AND' ? ' checked':'',
|
||||
'OR_SEARCH' => $suchart == 'OR' ? ' checked':'',
|
||||
'CONCAT_SEARCH' => $suchart == 'CONCAT' ? ' checked':'',
|
||||
'TABLE_OPTIONS' => $table_options,
|
||||
'LANG_SEARCH_OPTIONS_AND' => $lang['search_options_and'],
|
||||
'LANG_SEARCH_OPTIONS_OR' => $lang['search_options_or'],
|
||||
'LANG_SEARCH_OPTIONS_CONCAT' => $lang['search_options_concat'],
|
||||
'LANG_SEARCH_IN_TABLE' => $lang['search_in_table']
|
||||
));
|
||||
|
||||
$max_treffer=20;
|
||||
$treffer=mysql_search($db,$table_selected,$suchbegriffe,$suchart,$offset,$max_treffer + 1);
|
||||
if (is_array($treffer) && isset($treffer[0]))
|
||||
{
|
||||
$search_message=sprintf($lang['search_results'],$suchbegriffe,$tables[$table_selected]);
|
||||
$anzahl_treffer=count($treffer);
|
||||
// Blaettern-Buttons
|
||||
$tpl->assign_block_vars('HITS',array(
|
||||
|
||||
'LANG_SEARCH_RESULTS' => $search_message,
|
||||
'LAST_OFFSET' => $offset - $max_treffer,
|
||||
'BACK_BUTTON_DISABLED' => $offset > 0 ? '':' disabled',
|
||||
'NEXT_OFFSET' => $offset + $max_treffer,
|
||||
'NEXT_BUTTON_DISABLED' => ( $anzahl_treffer != $max_treffer + 1 ) ? ' disabled':'',
|
||||
'LANG_ACCESS_KEYS' => $lang['search_access_keys']
|
||||
));
|
||||
|
||||
// Ausgabe der Treffertabelle
|
||||
$anzahl_felder=sizeof($treffer[0]);
|
||||
|
||||
// Ausgabe der Tabellenueberschrift/ Feldnamen
|
||||
foreach ($treffer[0] as $key=>$val)
|
||||
{
|
||||
$tpl->assign_block_vars('HITS.TABLEHEAD',array(
|
||||
|
||||
'KEY' => $key
|
||||
));
|
||||
}
|
||||
|
||||
// Ausgabe der Daten
|
||||
$zeige_treffer=sizeof($treffer);
|
||||
if ($zeige_treffer == $max_treffer + 1) $zeige_treffer=$max_treffer;
|
||||
|
||||
// built key - does a primary key exist?
|
||||
$fieldinfos=FillFieldinfos($db,$tables[$table_selected]);
|
||||
// auf zusammengesetzte Schlüssel untersuchen
|
||||
$keys=0;
|
||||
if (isset($fieldinfos['_primarykey_']))
|
||||
{
|
||||
$keys=explode(',',$fieldinfos['_primarykey_']);
|
||||
}
|
||||
|
||||
for ($a=0; $a < $zeige_treffer; $a++)
|
||||
{
|
||||
$tablename=array_keys($treffer[$a]);
|
||||
if (is_array($keys) && $keys[0] > '')
|
||||
{
|
||||
$keystring='';
|
||||
foreach ($keys as $k)
|
||||
{
|
||||
// Treffermarkierung aus Wert wieder entfernen
|
||||
$x=str_replace('<span class="treffer">','',$treffer[$a][$k]);
|
||||
$x=str_replace('</span>','',$x);
|
||||
$keystring.='`' . $k . '`="' . addslashes($x) . '"|';
|
||||
}
|
||||
$keystring=substr($keystring,0,-1);
|
||||
$rk=build_recordkey($keystring);
|
||||
}
|
||||
else
|
||||
{
|
||||
$rk=urlencode(build_where_from_record($treffer[$a])); // no keys
|
||||
}
|
||||
|
||||
$delete_link='sql.php?search=1&mode=kill&tablename=' . urlencode($tables[$table_selected]) . '&rk=' . $rk;
|
||||
$edit_link='sql.php?mode=searchedit&tablename=' . urlencode($tables[$table_selected]) . '&recordkey=' . $rk;
|
||||
|
||||
$tpl->assign_block_vars('HITS.TABLEROW',array(
|
||||
|
||||
'CLASS' => ( $a % 2 ) ? 'dbrow':'dbrow1',
|
||||
'NR' => $a + $offset + 1,
|
||||
'TABLENAME' => $tables[$table_selected],
|
||||
'LINK_EDIT' => $edit_link,
|
||||
'ICON_EDIT' => $icon['edit'],
|
||||
'LINK_DELETE' => $delete_link,
|
||||
'ICON_DELETE' => $icon['delete']
|
||||
));
|
||||
|
||||
foreach ($treffer[$a] as $key=>$val)
|
||||
{
|
||||
if ($val == '') $val=" ";
|
||||
$tpl->assign_block_vars('HITS.TABLEROW.TABLEDATA',array(
|
||||
|
||||
'VAL' => $val
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isset($tables[$table_selected])) $tables[$table_selected]='';
|
||||
if ($suchbegriffe == '') $tpl->assign_block_vars('NO_ENTRIES',array(
|
||||
|
||||
'LANG_NO_ENTRIES' => sprintf($lang['no_entries'],$tables[$table_selected])
|
||||
));
|
||||
else $tpl->assign_block_vars('NO_RESULTS',array(
|
||||
|
||||
'LANG_SEARCH_NO_RESULTS' => sprintf($lang['search_no_results'],$suchbegriffe,$tables[$table_selected])
|
||||
));
|
||||
}
|
||||
|
||||
$tpl->pparse('show');
|
||||
84
sqlbrowser/sql_commands.php
Normale Datei
84
sqlbrowser/sql_commands.php
Normale Datei
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
if (!defined('MSD_VERSION')) die('No direct access.');
|
||||
//SQL-Strings
|
||||
echo $aus.='<h4>' . $lang['sql_befehle'] . ' (' . count($SQL_ARRAY) . ')</h4>';
|
||||
echo '<a href="' . $params . '&sqlconfig=1&new=1">' . $lang['sql_befehlneu'] . '</a><br><br>';
|
||||
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 '<p>' . $lang['sql_befehlsaved1'] . ' \'' . $_POST['sqlname' . $ind] . '\' ' . $lang['sql_befehlsaved2'] . '</p>';
|
||||
}
|
||||
echo '<form name="sqlform" action="sql.php" method="post">
|
||||
<input type="hidden" name="context" value="1">
|
||||
<input type="hidden" name="sqlconfig" value="1">
|
||||
<input type="hidden" name="tablename" value="' . $tablename . '">
|
||||
<input type="hidden" name="dbid" value="' . $dbid . '">';
|
||||
echo '<table class="bdr"><tr class="thead"><th>#</th><th>' . $lang['name'] . '</th><th>SQL</th><th>' . $lang['command'] . '</th></tr>';
|
||||
$i=0;
|
||||
if (count($SQL_ARRAY) > 0)
|
||||
{
|
||||
for ($i=0; $i < count($SQL_ARRAY); $i++)
|
||||
{
|
||||
if (isset($_POST['sqlupdate' . $i]))
|
||||
{
|
||||
|
||||
echo '<p class="success">' . $lang['sql_befehlsaved1'] . ' \'' . $_POST['sqlname' . $i] . '\' ' . $lang['sql_befehlsaved3'] . '</p>';
|
||||
$SQL_ARRAY[$i]=$_POST['sqlname' . $i] . "|" . $_POST['sqlstring' . $i];
|
||||
WriteSQL();
|
||||
}
|
||||
if (isset($_POST['sqlmove' . $i]))
|
||||
{
|
||||
echo '<p class="success">' . $lang['sql_befehlsaved1'] . ' \'' . $_POST['sqlname' . $i] . '\' ' . $lang['sql_befehlsaved4'] . '</p>';
|
||||
$a[]=$SQL_ARRAY[$i];
|
||||
array_splice($SQL_ARRAY,$i,1);
|
||||
$SQL_ARRAY=array_merge($a,$SQL_ARRAY);
|
||||
WriteSQL();
|
||||
}
|
||||
if (isset($_POST['sqldelete' . $i]))
|
||||
{
|
||||
echo '<p class="success">' . $lang['sql_befehlsaved1'] . ' \'' . $_POST['sqlname' . $i] . '\' ' . $lang['sql_befehlsaved5'] . '</p>';
|
||||
array_splice($SQL_ARRAY,$i,1);
|
||||
WriteSQL();
|
||||
}
|
||||
}
|
||||
for ($i=0; $i < count($SQL_ARRAY); $i++)
|
||||
{
|
||||
$cl=( $i % 2 ) ? "dbrow" : "dbrow1";
|
||||
echo '<tr class="' . $cl . '"><td>' . ( $i + 1 ) . '</td><td>';
|
||||
echo '<input type="text" class="text" name="sqlname' . $i . '" value="' . SQL_Name($i) . '"></td>';
|
||||
echo '<td><textarea rows="3" cols="40" name="sqlstring' . $i . '">' . stripslashes(SQL_String($i)) . '</textarea></td>';
|
||||
echo '<td><input class="Formbutton" style="width:80px;" type="submit" name="sqlupdate' . $i . '" value="save"><br>
|
||||
<input class="Formbutton" style="width:80px;" type="submit" name="sqlmove' . $i . '" value="move up"><br>
|
||||
<input class="Formbutton" style="width:80px;" type="submit" name="sqldelete' . $i . '" value="delete"></td></tr>';
|
||||
}
|
||||
}
|
||||
if (isset($_GET['new']))
|
||||
{
|
||||
$cl=( $i % 2 ) ? "dbrow" : "dbrow1";
|
||||
echo '<tr class="' . $cl . '"><td>' . ( $i + 1 ) . '</td><td>';
|
||||
echo '<input type="text" class="text" name="sqlname' . $i . '" id="sqlname' . $i . '" value="SQL ' . ( $i + 1 ) . '"><br><div class="small" align="center">' . $lang['sql_library'] . '<br>';
|
||||
echo '<select id="sqllib" name="sqllib" onChange="InsertLib(' . $i . ');" class="small">';
|
||||
echo '<option value=""></option>';
|
||||
$og=false;
|
||||
for ($j=0; $j < count($sqllib); $j++)
|
||||
{
|
||||
if ($sqllib[$j]['sql'] == "trenn")
|
||||
{
|
||||
if ($og) echo '</optgroup>';
|
||||
echo '<optgroup label="' . $sqllib[$j]['name'] . '">';
|
||||
$og=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<option value="' . $sqllib[$j]['sql'] . '">' . $sqllib[$j]['name'] . '</option>';
|
||||
}
|
||||
}
|
||||
if ($og) echo '</optgroup>';
|
||||
echo '</select></div></td>
|
||||
<td><textarea rows="3" cols="40" name="sqlstring' . $i . '" id="sqlstring' . $i . '">SELECT * FROM</textarea></td>
|
||||
<td><input class="Formbutton" style="width:80px;" type="submit" name="sqlnewupdate" value="save"></td></tr>';
|
||||
}
|
||||
echo '</table></form>';
|
||||
347
sqlbrowser/sql_dataview.php
Normale Datei
347
sqlbrowser/sql_dataview.php
Normale Datei
|
|
@ -0,0 +1,347 @@
|
|||
<?php
|
||||
if (!defined('MSD_VERSION')) die('No direct access.');
|
||||
|
||||
// fuegt eine Sortierungsnummer hinzu, um die Ausgabereihenfolge der Daten steuern zu koennen
|
||||
// (das Feld ENGINE interessiert mich nicht so sehr und muss nicht vorne stehen)
|
||||
$keysort=array(
|
||||
|
||||
'Name' => 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 "<br>Uebergeben: ".$name;
|
||||
if (array_key_exists($name,$keysort)) $ret=$keysort[$name];
|
||||
else $ret=0;
|
||||
return $ret;
|
||||
}
|
||||
|
||||
//Data-View
|
||||
echo $aus . '<h4>' . ( ( $showtables == 1 ) ? $lang['sql_tableview'] : $lang['sql_dataview'] ) . '</h4><p>';
|
||||
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 '<a href="' . $p . '&mode=new">' . $lang['sql_recordnew'] . '</a> ';
|
||||
echo '<a href="sql.php?db=' . $db . '&dbid=' . $dbid . '&tablename=' . $tablename . '&context=2">' . $lang['sql_edit_tablestructure'] . '</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$p='sql.php?db=' . $db . '&dbid=' . $dbid . '&context=2';
|
||||
echo '<a href="' . $p . '">' . $lang['sql_tablenew'] . '</a>';
|
||||
}
|
||||
|
||||
//Statuszeile
|
||||
$tn=ExtractTablenameFromSQL($sql['sql_statement']);
|
||||
echo '</p><p class="tablename">' . ( $tn != '' ? $lang['table'] . ' ' . $tn . '<br>' : '' );
|
||||
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);
|
||||
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['info_records'] . " " . ( $limitstart + 1 ) . " - ";
|
||||
if ($limitstart + $limitende > $numrowsabs) $command_line.=$numrowsabs;
|
||||
else $command_line.=$limitstart + $limitende;
|
||||
$command_line.=" " . $lang['sql_vonins'] . " $numrowsabs ";
|
||||
$command_line.=( $limitstart > 0 ) ? '<a href="' . $params . '&limitstart=0"><<</a> ' : '<< ';
|
||||
$command_line.=( $limitstart > 0 ) ? '<a href="' . $params . '&limitstart=' . ( ( $limitstart - $config['sql_limit'] < 0 ) ? 0 : $limitstart - $config['sql_limit'] ) . '"><</a> ' : '< ';
|
||||
$command_line.=( $limitstart + $limitende < $numrowsabs ) ? '<a href="' . $params . '&limitstart=' . ( $limitstart + $config['sql_limit'] ) . '">></a> ' : '> ';
|
||||
$command_line.=( $limitstart + $limitende < ( $numrowsabs - $config['sql_limit'] ) ) ? '<a href="' . $params . '&limitstart=' . ( $numrowsabs - $config['sql_limit'] ) . '">>></a>' : '>>';
|
||||
echo $command_line;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo $numrowsabs . " " . $lang['tables'];
|
||||
}
|
||||
echo '</p>';
|
||||
//Datentabelle
|
||||
echo '<table class="bdr" id="dataTable">';
|
||||
|
||||
$t=$d="";
|
||||
$fdesc=Array();
|
||||
$key=-1;
|
||||
if ($numrows > 0)
|
||||
{
|
||||
//Infos und Header holen
|
||||
//1.Datensatz fuer Feldinfos
|
||||
$row=mysql_fetch_row($res);
|
||||
|
||||
//Kompaktmodus-Switcher
|
||||
$t='<td colspan="' . ( count($row) + 1 ) . '" align="left"><a href="sql.php?db=' . $db . '&tablename=' . $tablename . '&dbid=' . $dbid . '&order=' . $order . '&orderdir=' . $orderdir . '&limitstart=' . $limitstart . '&sql_statement=' . urlencode($sql['sql_statement']) . '&tdc=' . ( ( $tdcompact == 0 ) ? '1' : '0' ) . '">' . ( ( $tdcompact == 1 ) ? $lang['sql_view_standard'] : $lang['sql_view_compact'] ) . '</a>';
|
||||
$t.=' ' . $lang['sql_queryentry'] . ' ' . count($row) . ' ' . $lang['sql_columns'];
|
||||
$t.='</td></tr><tr class="thead">';
|
||||
$t.='<th> </th><th>#</th>';
|
||||
$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.='<th align="left" nowrap="nowrap">';
|
||||
$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['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='<img src="' . $icon['blank'] . '" alt="" width="1" height="1" border="0">';
|
||||
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" ) ? ' <a style="font-size:10px;color:blue;" title="use BB-Code for this field" href="sql.php?db=' . $db . '&bb=' . $x . '&tablename=' . $tablename . '&dbid=' . $dbid . '&order=' . $order . '&orderdir=' . $orderdir . '&limitstart=' . $limitstart . '&sql_statement=' . urlencode($sql['sql_statement']) . '&tdc=' . $tdcompact . '">[BB]</a>' : '';
|
||||
else $bb_link=( $str->type == "blob" ) ? ' <a title="use BB-Code for this field" href="sql.php?db=' . $db . '&bb=-1&tablename=' . $tablename . '&dbid=' . $dbid . '&order=' . $order . '&orderdir=' . $orderdir . '&limitstart=' . $limitstart . '&sql_statement=' . urlencode($sql['sql_statement']) . '&tdc=' . $tdcompact . '">[no BB]</a>' : '';
|
||||
if ($no_order == false && $showtables == 0) $t.=$pic . ' <a title="' . $tt . '" href="sql.php?db=' . $db . '&tablename=' . $tablename . '&dbid=' . $dbid . '&order=' . $str->name . '&orderdir=' . $norder . '&sql_statement=' . urlencode($sql['sql_statement']) . '&tdc=' . $tdcompact . '">' . $str->name . '</a>' . $bb_link;
|
||||
else $t.=$pic . ' <span title="' . $tt . '" >' . $str->name . '</span>' . $bb_link;
|
||||
$t.='</th>';
|
||||
}
|
||||
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 "<br><br>Primaerschluessel erkannt: ".$primary_key;
|
||||
}
|
||||
|
||||
foreach ($sortkey as $rowkey=>$rowval)
|
||||
{
|
||||
if (( $rowkey == 'Name' ) && $tabellenansicht == 1 && isset($row['Name'])) $tablename=$row['Name'];
|
||||
|
||||
if ($erste_spalte == 1)
|
||||
{
|
||||
//edit-pics
|
||||
$d.=$nl . '<td valign="top" nowrap="nowrap" class="small"> ' . $nl;
|
||||
$p='sql.php?sql_statement=' . urlencode($sql['sql_statement']) . '&db=' . $db . '&tablename=' . $tablename . '&dbid=' . $dbid . '&limitstart=' . $limitstart . '&order=' . $order . '&orderdir=' . $orderdir . '&editkey=' . $rowkey . '&tdc=' . $tdcompact;
|
||||
if ($key == -1)
|
||||
{
|
||||
$rk=build_where_from_record($temp[$i]);
|
||||
$p.='&recordkey=' . urlencode($rk);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Key vorhanden
|
||||
$p.='&recordkey=' . $primary_key; //urlencode("`".$fdesc[$key]['name']."`='".$rowval."'");
|
||||
}
|
||||
if ($showtables == 1) $p.='&recordkey=' . $tablename;
|
||||
if (!isset($no_edit) || !$no_edit)
|
||||
{
|
||||
if ($showtables == 0)
|
||||
{
|
||||
$d.='<a href="' . $p . '&mode=edit">' . $icon['edit'] . '</a> ';
|
||||
}
|
||||
}
|
||||
|
||||
if ($showtables == 0 && $tabellenansicht == 0)
|
||||
{
|
||||
$d.='<a href="' . $p . '&mode=kill" onclick="if(!confirm(\'' . $lang['askdeleterecord'] . '\')) return false;">' . $icon['delete'] . '</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($tabellenansicht == 1 && $showtables == 1)
|
||||
{
|
||||
$d.='<a href="sql.php?db=' . $db . '&dbid=' . $dbid . '&tablename=' . $tablename . '&context=2">' . $icon['edit'] . '</a> ' . $nl . $nl;
|
||||
if (!( isset($row['Comment']) && ( substr(strtoupper($row['Comment']),0,4) == 'VIEW' ) ))
|
||||
{
|
||||
$d.='<a href="' . $p . '&mode=empty" onclick="if(!confirm(\'' . sprintf($lang['asktableempty'],$tablename) . '\')) return false;">' . $icon['table_truncate'] . '</a> ' . $nl . $nl;
|
||||
$d.='<a href="' . $p . '&mode=emptyk" onclick="if(!confirm(\'' . sprintf($lang['asktableemptykeys'],$tablename) . '\')) return false;">' . $icon['table_truncate_reset'] . '</a> ' . $nl . $nl;
|
||||
$d.='<a href="' . $p . '&mode=kill" onclick="if(!confirm(\'' . sprintf($lang['askdeletetable'],$tablename) . '\')) return false;">' . $icon['delete'] . '</a> ' . $nl . $nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
$d.='<a href="' . $p . '&mode=kill_view" onclick="if(!confirm(\'' . sprintf($lang['askdeletetable'],$tablename) . '\')) return false;">' . $icon['delete'] . '</a> ' . $nl . $nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
$d.='</td><td valign="top" class="small" style="text-align:right">' . $rownr . '. </td>';
|
||||
$rownr++;
|
||||
$erste_spalte=0;
|
||||
}
|
||||
$d.='<td valign="top" class="small" nowrap="nowrap">';
|
||||
$divstart='<div' . ( ( $tdcompact == 1 ) ? ' class="tdcompact" ' : ' class="tdnormal"' ) . '>';
|
||||
$divend='</div>';
|
||||
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(strip_tags($rowval)) : $rowval;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isset($temp[$i][$rowkey])) $data=( $fdesc[$rowkey]['type'] == 'string' || $fdesc[$rowkey]['type'] == 'blob' ) ? convert_to_utf8(strip_tags($temp[$i][$rowkey])) : $temp[$i][$rowkey];
|
||||
else $data='';
|
||||
if (in_array($rowkey,$byte_output)) $data=byte_output($data);
|
||||
|
||||
}
|
||||
}
|
||||
$spalte++;
|
||||
$browse_link='<a href="sql.php?db=' . $db . '&tablename=' . $tablename . '&dbid=' . $dbid . '" title="' . $data . '">';
|
||||
$d.=( $tabellenansicht == 1 && $rowkey == 'Name' ) ? $divstart . $browse_link . $icon['browse'] . "</a> " . $browse_link . $data . "</a>$divend" : $divstart . $data . $divend;
|
||||
$d.='</td>';
|
||||
}
|
||||
// Tabellenueberschrift en ausgeben
|
||||
if ($i == 0) echo '<tr>' . $t . '</tr>';
|
||||
// Daten anzeigen
|
||||
echo "\n\n" . '<tr class="' . $cl . '">' . $d . '</tr>' . "\n\n";
|
||||
$d="";
|
||||
}
|
||||
}
|
||||
echo '</table>';
|
||||
|
||||
if ($showtables == 0) echo '<br>' . $command_line;
|
||||
}
|
||||
else
|
||||
echo '<p class="success">' . $lang['sql_nodata'] . '</p>';
|
||||
533
sqlbrowser/sql_tables.php
Normale Datei
533
sqlbrowser/sql_tables.php
Normale Datei
|
|
@ -0,0 +1,533 @@
|
|||
<?php
|
||||
if (!defined('MSD_VERSION')) die('No direct access.');
|
||||
//Tabellen
|
||||
echo $aus . '<h6>' . $lang['sql_tablesofdb'] . ' `' . $databases['Name'][$dbid] . '` ' . $lang['sql_edit'] . '</h6>';
|
||||
|
||||
//////////////////////// DH
|
||||
//Primaerschluessel loeschen
|
||||
if (isset($_GET['killPrimaryKey']))
|
||||
{
|
||||
$keys=getPrimaryKeys($databases['Name'][$dbid],$_GET['tablename']);
|
||||
//Zu loeschenden Schluessel aus dem Array entfernen
|
||||
$keyPos=array_search($_GET['killPrimaryKey'],$keys);
|
||||
if (!( false === $keyPos ))
|
||||
{
|
||||
unset($keys[$keyPos]);
|
||||
$res=setNewPrimaryKeys($databases['Name'][$dbid],$_GET['tablename'],$keys);
|
||||
if ($res)
|
||||
{
|
||||
echo '<script language="JavaScript">
|
||||
alert("' . $lang['primaryKey_deleted'] . ': ' . $_GET['killPrimaryKey'] . '");
|
||||
</script>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<script language="JavaScript">
|
||||
alert("' . $lang['primaryKey_notFound'] . ': ' . $_GET['killPrimaryKey'] . '");
|
||||
</script>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<script language="JavaScript">
|
||||
alert("' . $lang['primaryKey_notFound'] . ': ' . $_GET['killPrimaryKey'] . '");
|
||||
</script>';
|
||||
}
|
||||
}
|
||||
//Primärschlüssel löschen ende
|
||||
|
||||
|
||||
//Neue Primärschlüssel setzen
|
||||
if (isset($_POST['setNewPrimaryKeys']))
|
||||
{
|
||||
$fields=getAllFields($databases['Name'][$dbid],$_GET['tablename']);
|
||||
$newKeysArray=Array();
|
||||
foreach ($fields as $index=>$field)
|
||||
{
|
||||
if (( isset($_POST["setNewPrimKey" . $index]) ) && ( $_POST["setNewPrimKey" . $index] != "" ))
|
||||
{
|
||||
$newKeysArray[]=$_POST["setNewPrimKey" . $index];
|
||||
}
|
||||
}
|
||||
//doppelte Elemente entfernen
|
||||
$newKeysArray=array_unique($newKeysArray);
|
||||
|
||||
$res=setNewPrimaryKeys($databases['Name'][$dbid],$_GET['tablename'],$newKeysArray);
|
||||
if ($res)
|
||||
{
|
||||
echo '<script language="JavaScript">
|
||||
alert("' . $lang['primaryKeys_changed'] . '");
|
||||
</script>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<script language="JavaScript">
|
||||
alert("' . $lang['primaryKeys_changingError'] . '");
|
||||
</script>';
|
||||
}
|
||||
}
|
||||
//Neue Primärschlüssel setzen ende
|
||||
//////////////////////// DH ende
|
||||
|
||||
|
||||
if (isset($_GET['kill']))
|
||||
{
|
||||
if ($_GET['anz'] == 1) echo '<p class="error">' . $lang['sql_nofielddelete'] . '</p>';
|
||||
else
|
||||
{
|
||||
$sql_alter="ALTER TABLE `" . $databases['Name'][$dbid] . "`.`" . $_GET['tablename'] . "` DROP COLUMN `" . $_GET['kill'] . "`";
|
||||
MSD_DoSQL($sql_alter);
|
||||
echo '<div align="left" id="sqleditbox" style="font-size: 11px;width:90%;padding=6px;">';
|
||||
echo '<p class="success">' . $lang['sql_fielddelete1'] . ' `' . $_GET['kill'] . '` ' . $lang['sql_deleted'] . '.</p>' . highlight_sql($out) . '</div>';
|
||||
}
|
||||
}
|
||||
if (isset($_POST['tablecopysubmit']))
|
||||
{
|
||||
$table_edit_name=$_GET['tablename'];
|
||||
if ($_POST['tablecopyname'] == "")
|
||||
{
|
||||
echo '<p class="error">' . $lang['sql_nodest_copy'] . '</p>';
|
||||
}
|
||||
elseif (Table_Exists($databases['Name'][$dbid],$_POST['tablecopyname']))
|
||||
{
|
||||
echo '<p class="error">' . $lang['sql_desttable_exists'] . '</p>';
|
||||
}
|
||||
else
|
||||
{
|
||||
Table_Copy("`" . $databases['Name'][$dbid] . "`.`" . $table_edit_name . "`",$_POST['tablecopyname'],$_POST['copyatt']);
|
||||
echo '<div align="left" id="sqleditbox">';
|
||||
echo ( $_POST['copyatt'] == 0 ) ? '<p class="success">' . sprintf($lang['sql_scopy'],$table_edit_name,$_POST['tablecopyname']) . '.</p>' : sprintf($lang['sql_tcopy'],$table_edit_name,$_POST['tablecopyname']) . '</p>';
|
||||
echo highlight_sql($out) . '</div>';
|
||||
$tablename=$_POST['tablecopyname'];
|
||||
}
|
||||
}
|
||||
if (isset($_POST['newtablesubmit']))
|
||||
{
|
||||
if ($_POST['newtablename'] == "")
|
||||
{
|
||||
echo '<p class="error">' . $lang['sql_tablenoname'] . '</p>';
|
||||
}
|
||||
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 '<p class="error">' . $lang['sql_tblnameempty'] . '</p>';
|
||||
elseif (MSD_NEW_VERSION && $_POST['t_edit_collate'] != "" && substr($_POST['t_edit_collate'],0,strlen($_POST['t_edit_charset'])) != $_POST['t_edit_charset']) echo '<p class="error">' . $lang['sql_collatenotmatch'] . '</p>';
|
||||
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 '<p class="error">' . $lang['sql_fieldnamenotvalid'] . ' (' . $_POST['f_name'] . ')</p>';
|
||||
$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 '" . addslashes($_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 '<div align="left" id="sqleditbox" style="font-size: 11px;width:90%;padding=6px;">';
|
||||
echo '<p class="success"> `' . $_POST['f_name'] . '` ' . ( ( isset($_POST['editfield']) ) ? $lang['sql_changed'] : $lang['sql_created'] ) . '.</p>';
|
||||
echo highlight_sql($out) . '</div>';
|
||||
$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);
|
||||
$anz_tabellen=mysql_numrows($res);
|
||||
$p="sql.php?db=" . $databases['Name'][$dbid] . "&dbid=$dbid&tablename=$table_edit_name&context=2";
|
||||
|
||||
echo '<form action="sql.php?db=' . $databases['Name'][$dbid] . '&dbid=' . $dbid . '&tablename=' . $table_edit_name . '&context=2" method="post">';
|
||||
echo '<table class="bdr"><tr class="dbrow"><td>' . $lang['new'] . ' ' . $lang['sql_createtable'] . ': </td><td colspan="2"><input type="text" class="text" name="newtablename" size="30" maxlength="150"></td><td><input type="submit" name="newtablesubmit" value="' . $lang['sql_createtable'] . '" class="Formbutton"></td></tr>';
|
||||
echo '<tr class="dbrow1"><td>' . $lang['sql_copytable'] . ': </td><td><input type="text" class="text" name="tablecopyname" size="20" maxlength="150"></td><td><select name="copyatt"><option value="0">' . $lang['sql_structureonly'] . '</option>' . ( ( MSD_NEW_VERSION ) ? '<option value="1">' . $lang['sql_structuredata'] . '</option>' : '' ) . '</select></td><td><input type="submit" class="Formbutton" name="tablecopysubmit" value="' . $lang['sql_copytable'] . '" ' . ( ( $table_edit_name == "" ) ? "disabled=\"disabled\"" : "" ) . '></td></tr>';
|
||||
|
||||
if ($anz_tabellen == 0)
|
||||
{
|
||||
echo '<tr><td>' . $lang['sql_notablesindb'] . ' `' . $databases['Name'][$dbid] . '`</td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
echo '<tr><td>' . $lang['sql_selecttable'] . ': </td>';
|
||||
echo '<td colspan="2"><select name="tableselect" onchange="this.form.submit()"><option value="1" SELECTED></option>';
|
||||
for ($i=0; $i < $anz_tabellen; $i++)
|
||||
{
|
||||
$row=mysql_fetch_array($res);
|
||||
echo '<option value="' . $row['Name'] . '">' . $row['Name'] . '</option>';
|
||||
}
|
||||
echo '</select> </td>';
|
||||
echo '<td><input type="button" class="Formbutton" value="' . $lang['sql_showdatatable'] . '" onclick="location.href=\'sql.php?db=' . $databases['Name'][$dbid] . '&dbid=' . $dbid . '&tablename=' . $tablename . '\'"></td></tr>';
|
||||
}
|
||||
echo '</table></form><p> </p>';
|
||||
if ($table_edit_name != "")
|
||||
{
|
||||
|
||||
$sqlf="SHOW FULL FIELDS FROM `" . $databases['Name'][$dbid] . "`.`$table_edit_name` ;";
|
||||
$res=MSD_query($sqlf);
|
||||
$anz_fields=mysql_num_rows($res);
|
||||
$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 "<h6>" . $lang['table'] . " `$table_edit_name`</h6>";
|
||||
$td='<td valign="top" nowrap="nowrap" class="small">';
|
||||
|
||||
//Tabelleneigenschaften
|
||||
echo '<form action="' . $p . '" method="post"><input type="hidden" name="table_edit_name" value="' . $table_edit_name . '"><table class="bdr">';
|
||||
echo '<tr class="sqlNew"><td colspan="4" style="font-size:10pt;font-weight:bold;">' . $lang['sql_tblpropsof'] . ' `' . $table_edit_name . '` (' . $anz_fields . ' ' . $lang['fields'] . ')</td>';
|
||||
echo '<td class="small" colspan="2" align="center">Name<br><input type="text" class="text" name="t_edit_name" value="' . $table_edit_name . '" size="30" maxlength="150" style="font-size:11px;"></td></tr>';
|
||||
echo '<tr class="sqlNew">';
|
||||
echo '<td class="small" align="center">Engine<br><select name="t_edit_engine" style="font-size:11px;">' . EngineCombo($t_engine) . '</select></td>';
|
||||
echo '<td class="small" align="center">Row Format<br><select name="t_edit_rowformat" style="font-size:11px;">' . GetOptionsCombo($feldrowformat,$t_rowformat) . '</select></td>';
|
||||
echo '<td class="small" align="center">' . $lang['charset'] . '<br><select name="t_edit_charset" style="font-size:11px;">' . CharsetCombo($t_charset) . '</select></td>';
|
||||
echo '<td class="small" align="center">' . $lang['collation'] . '<br><select name="t_edit_collate" style="font-size:11px;">' . CollationCombo($t_collation) . '</select></td>';
|
||||
echo '<td class="small" align="center">' . $lang['comment'] . '<br><input type="text" class="text" name="t_edit_comment" value="' . $t_comment . '" size="30" maxlength="100" style="font-size:11px;"></td>';
|
||||
echo '<td class="small" align="center"> <br><input type="submit" name="t_edit_submit" value="' . $lang['change'] . '" class="Formbutton"></td></tr>';
|
||||
echo '</table></form><p> </p>';
|
||||
|
||||
$field_fehler=0;
|
||||
echo '<h6>'.$lang['fields_of_table'].' `' . $table_edit_name . '`</h6>';
|
||||
|
||||
$d_collate='';
|
||||
$d_comment='';
|
||||
|
||||
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='';
|
||||
if (isset($id) && isset($fields_infos[$id]) && isset($fields_infos[$id]['default']))
|
||||
{
|
||||
if ($fields_infos[$id]['default']=='NULL') $d_default='NULL';
|
||||
else $d_default=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;
|
||||
if (isset($id))
|
||||
{
|
||||
if (isset($fields_infos[$id]['collate'])) $d_collate=( isset($_GET['editfield']) ) ? $fields_infos[$id]['collate'] : "";
|
||||
if (isset($fields_infos[$id]['comment'])) $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 < count($fields_infos['_key_']); $i++)
|
||||
{
|
||||
if ($fields_infos['_key_'][$i]['name'] == $fields_infos[$id]['name'])
|
||||
{
|
||||
$d_index=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($fields_infos['_fulltextkey_']))
|
||||
{
|
||||
for ($i=0; $i < count($fields_infos['_fulltextkey_']); $i++)
|
||||
{
|
||||
if ($fields_infos['_fulltextkey_'][$i]['name'] == $fields_infos[$id]['name'])
|
||||
{
|
||||
$d_fulltext=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($fields_infos['_uniquekey_']))
|
||||
{
|
||||
for ($i=0; $i < count($fields_infos['_uniquekey_']); $i++)
|
||||
{
|
||||
if ($fields_infos['_uniquekey_'][$i]['name'] == $fields_infos[$id]['name'])
|
||||
{
|
||||
$d_unique=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
echo '<form action="' . $p . '" method="post" id="smallform"><input type="hidden" name="newfield_posted" value="1">';
|
||||
if (isset($_GET['editfield'])) echo '<input type="hidden" name="editfield" value="' . $id . '"><input type="hidden" name="fieldname" value="' . $d_name . '">';
|
||||
if (isset($_POST['newtablesubmit'])) echo '<input type="hidden" name="newtablename" value="' . $_POST['newtablename'] . '">';
|
||||
echo '<input type="hidden" name="f_primary" value="' . $d_primary . '"><input type="hidden" name="f_unique" value="' . $d_unique . '">';
|
||||
echo '<input type="hidden" name="f_index" value="' . $d_index . '"><input type="hidden" name="f_fulltext" value="' . $d_fulltext . '">';
|
||||
echo '<table class="bdr"><tr class="thead"><th colspan="6" align="center">' . ( ( isset($_GET['editfield']) ) ? $lang['sql_editfield'] . " `" . $d_name . "`" : $lang['sql_newfield'] ) . '</th></tr>';
|
||||
echo '<tr><td class="small">Name<br><input type="text" class="text" value="' . $d_name . '" name="f_name" size="30"></td>';
|
||||
echo '<td>Type<br><select name="f_type">' . GetOptionsCombo($feldtypen,$d_type) . '</select></td>';
|
||||
echo '<td>Size <br><input type="text" class="text" value="' . $d_size . '" name="f_size" size="3" maxlength="80"></td>';
|
||||
echo '<td>NULL<br><select name="f_null">' . GetOptionsCombo($feldnulls,$d_null) . '</select></td>';
|
||||
echo '<td align="center">Default<br><input type="text" class="text" name="f_default" value="' . $d_default . '" size="10"></td>';
|
||||
echo '<td align="center">Extra<br><select name="f_extra">' . GetOptionsCombo($feldextras,$d_extra) . '</select></td>';
|
||||
|
||||
echo '</tr><tr><td align="center">' . $lang['sql_indexes'] . '<br>';
|
||||
echo '<input type="radio" class="radio" name="f_index_new" id="k_no_index" value="no" ' . ( ( $d_primary + $d_unique + $d_index + $d_fulltext == 0 ) ? 'checked="checked"' : '' ) . '>';
|
||||
echo '<label for="k_no_index">' . $icon['key_nokey'] . '</label> ';
|
||||
|
||||
echo '<input type="radio" class="radio" name="f_index_new" id="k_primary" value="primary" ' . ( ( $d_primary == 1 ) ? "checked" : "" ) . '>';
|
||||
echo '<label for="k_primary">' . $icon['key_primary'] . '</label> ';
|
||||
|
||||
echo '<input type="radio" class="radio" name="f_index_new" id="k_unique" value="unique" ' . ( ( $d_unique == 1 ) ? "checked" : "" ) . '>';
|
||||
echo '<label for="k_unique">' . $icon['key_unique'] . '</label> ';
|
||||
|
||||
echo '<input type="radio" class="radio" name="f_index_new" id="k_index" value="index" ' . ( ( $d_index == 1 ) ? "checked" : "" ) . '> ';
|
||||
echo '<label for="k_index">' . $icon['index'] . '</label> ';
|
||||
|
||||
echo '<input type="checkbox" class="checkbox" name="f_indexfull" id="k_fulltext" value="1" ' . ( ( $d_fulltext == 1 ) ? "checked" : "" ) . '>';
|
||||
echo '<label for="k_fulltext">' . $icon['key_fulltext'] . '</label> </td>';
|
||||
|
||||
echo '<td align="center" colspan="2" >' . $lang['collation'] . '<br><select name="f_collate">' . CollationCombo($d_collate) . '</select></td>';
|
||||
echo '<td align="center">' . $lang['sql_attributes'] . '<br><select name="f_attribut">' . AttributeCombo($d_attribute) . '</select></td>';
|
||||
echo '<td align="center">' . $lang['sql_atposition'] . ':<br><select name="f_position"><option value=""></option><option value="FIRST">' . $lang['sql_first'] . '</option>';
|
||||
if ($anz_fields > 0)
|
||||
{
|
||||
for ($i=0; $i < $anz_fields; $i++)
|
||||
{
|
||||
echo '<option value="AFTER `' . $fields_infos[$i]['name'] . '`">' . $lang['sql_after'] . ' `' . $fields_infos[$i]['name'] . '`</option>';
|
||||
}
|
||||
}
|
||||
echo '</select></td><td align="center"><input type="submit" name="newfieldsubmit" value="' . ( ( isset($_GET['editfield']) ) ? $lang['sql_changefield'] : $lang['sql_insertfield'] ) . '" class="Formbutton"></td></tr></table></form><p> </p>';
|
||||
}
|
||||
else
|
||||
echo '<a style="font-size:8pt;padding-bottom:8px;" href="' . $p . '&newfield=1">' . $lang['sql_insertnewfield'] . '</a><br><br>';
|
||||
|
||||
//Felder ausgeben
|
||||
echo '<table class="bdr">';
|
||||
for ($i=0; $i < $anz_fields; $i++)
|
||||
{
|
||||
$cl=( $i % 2 ) ? "dbrow" : "dbrow1";
|
||||
if ($i == 0) echo '<tr class="thead"><th colspan="2"> </th><th>Field</th><th>Type</th><th>Size</th><th>NULL</th><th>Key</th><th>Attribute</th><th>Default</th><th>Extra</th><th>Sortierung</th></tr>';
|
||||
echo '<tr class="' . $cl . '">';
|
||||
echo '<td nowrap="nowrap">';
|
||||
echo '<a href="' . $p . '&editfield=' . $i . '"><img src="' . $config['files']['iconpath'] . 'edit.gif" title="edit field" alt="edit field" border="0"></a> ';
|
||||
echo '<a href="' . $p . '&kill=' . $fields_infos[$i]['name'] . '&anz=' . $anz_fields . '" onclick="if(!confirm(\'' . $lang['askdeletefield'] . '\')) return false;"><img src="' . $config['files']['iconpath'] . 'delete.gif" alt="delete field" border="0"></a> ';
|
||||
|
||||
echo '</td>';
|
||||
echo '<td style="text-align:right">' . ( $i + 1 ) . '.</td>';
|
||||
|
||||
echo '<td><strong>' . $fields_infos[$i]['name'] . '</strong></td><td>' . $fields_infos[$i]['type'] . '</td><td>' . $fields_infos[$i]['size'] . '</td>';
|
||||
echo '<td>' . $fields_infos[$i]['null'] . '</td><td>';
|
||||
//key
|
||||
if ($fields_infos['_primarykey_'] == $fields_infos[$i]['name']) echo $icon['key_primary'];
|
||||
if (isset($fields_infos['_fulltextkey_']))
|
||||
{
|
||||
for ($ii=0; $ii < count($fields_infos['_fulltextkey_']); $ii++)
|
||||
{
|
||||
if ($fields_infos['_fulltextkey_'][$ii]['name'] == $fields_infos[$i]['name'])
|
||||
{
|
||||
echo $icon['key_fulltext'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($fields_infos['_uniquekey_']))
|
||||
{
|
||||
for ($ii=0; $ii < count($fields_infos['_uniquekey_']); $ii++)
|
||||
{
|
||||
if ($fields_infos['_uniquekey_'][$ii]['name'] == $fields_infos[$i]['name'])
|
||||
{
|
||||
echo $icon['key_unique'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($fields_infos['_key_']))
|
||||
{
|
||||
for ($ii=0; $ii < count($fields_infos['_key_']); $ii++)
|
||||
{
|
||||
//echo "<h5>".$fields_infos['_key_'][$ii]['columns']."</h5>";
|
||||
if ($fields_infos['_key_'][$ii]['name'] == $fields_infos[$i]['name'])
|
||||
{
|
||||
echo $icon['index'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
echo '</td><td>' . $fields_infos[$i]['attribut'] . '</td>';
|
||||
echo '<td>' . $fields_infos[$i]['default'] . '</td>' . $td . $fields_infos[$i]['extra'] . '</td>';
|
||||
echo '<td>' . ( ( MSD_NEW_VERSION ) ? $fields_infos[$i]['collate'] : " " ) . '</td></tr>';
|
||||
}
|
||||
echo '</table><br>';
|
||||
|
||||
echo '<h6>' . $lang['sql_tableindexes'] . ' `' . $table_edit_name . '`</h6>';
|
||||
echo '<table class="bdr"><tr class="thead"><th colspan="2"> </th><th>Index-Name</th>' . ( ( MSD_NEW_VERSION ) ? '<th>Typ</th>' : '' ) . '<th>' . $lang['sql_allowdups'] . '</th><th>' . $lang['sql_cardinality'] . '</th><th>Spalten</th></tr>';
|
||||
$sqlk="SHOW KEYS FROM `" . $databases['Name'][$dbid] . "`.`$table_edit_name`;";
|
||||
$res=MSD_query($sqlk);
|
||||
$num=mysql_numrows($res);
|
||||
if ($num == 0)
|
||||
{
|
||||
echo '<tr><td colspan="6">' . $lang['sql_tablenoindexes'] . '</td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
for ($i=0; $i < $num; $i++)
|
||||
{
|
||||
$row=mysql_fetch_array($res);
|
||||
$cl=( $i % 2 ) ? "dbrow" : "dbrow1";
|
||||
//Images
|
||||
echo '<tr class="' . $cl . '">';
|
||||
echo '<td>';
|
||||
echo '<img src="' . $config['files']['iconpath'] . 'edit.gif" alt="" border="0"> ';
|
||||
///// DH
|
||||
//erstmal nur fuer Primaerschluessel
|
||||
if ($row['Key_name'] == "PRIMARY") echo '<a href="' . $p . '&killPrimaryKey=' . $row['Column_name'] . '" onclick="if(!confirm(\'' . $lang['primaryKey_confirmDelete'] . '\')) return false;">';
|
||||
echo '<img src="' . $config['files']['iconpath'] . 'delete.gif" alt="" border="0">';
|
||||
if ($row['Key_name'] == "PRIMARY") echo '</a>';
|
||||
///// DH ende
|
||||
echo '</td>';
|
||||
echo '<td style="text-align:right">' . ( $i + 1 ) . '.</td>';
|
||||
echo '<td>' . $row['Key_name'] . '</td>';
|
||||
if (MSD_NEW_VERSION) echo '<td>' . $row['Index_type'] . '</td>';
|
||||
echo '<td align="center">' . ( ( $row['Non_unique'] == 1 ) ? $lang['yes'] : $lang['no'] ) . '</td>';
|
||||
echo '<td>' . ( ( $row['Cardinality'] >= 0 ) ? $row['Cardinality'] : "keine" ) . '</td>';
|
||||
echo '<td>' . $row['Column_name'] . '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
}
|
||||
echo '</table><br><input type="Button" value="' . $lang['sql_createindex'] . '" onclick="location.href=\'' . $p . '&sql_createindex=1\'" class="Formbutton">';
|
||||
|
||||
///// DH
|
||||
if (( isset($_GET['sql_createindex']) ) && ( $_GET['sql_createindex'] == "1" ))
|
||||
{
|
||||
echo '<form action="' . $p . '" method="POST">';
|
||||
echo '<h6>' . $lang['setPrimaryKeysFor'] . ' `' . $table_edit_name . '`</h6>';
|
||||
//kopf
|
||||
echo '<table class="bdr"><tr class="thead"><th>' . $lang['primaryKey_field'] . '</th></tr>';
|
||||
//body
|
||||
$sqlFelder="DESCRIBE `" . $databases['Name'][$dbid] . "`.`" . $_GET['tablename'] . "`;";
|
||||
$res=MSD_query($sqlFelder);
|
||||
$num=mysql_numrows($res);
|
||||
if ($num == 0)
|
||||
{
|
||||
echo '<tr><td>' . $lang['sql_tablenoindexes'] . '</td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
//alle Felder holen
|
||||
$feldArray=Array();
|
||||
while ($row=mysql_fetch_array($res))
|
||||
{
|
||||
$feldArray[$row['Field']]=$row['Type'];
|
||||
}
|
||||
//Primaerschluessel holen, um automatisch vorzuselektieren
|
||||
$primaryKeys=getPrimaryKeys($databases['Name'][$dbid],$_GET['tablename']);
|
||||
//eine Select-Box pro Feld anzeigen
|
||||
for ($i=0; $i < $num; $i++)
|
||||
{
|
||||
$cl=( $i % 2 ) ? "dbrow" : "dbrow1";
|
||||
echo '<tr class="' . $cl . '">';
|
||||
echo '<td>';
|
||||
echo '<select name="setNewPrimKey' . $i . '">';
|
||||
echo '<option value="">---</option>';
|
||||
foreach ($feldArray as $feldName=>$feldTyp)
|
||||
{
|
||||
echo '<option value="' . $feldName . '"';
|
||||
//alle Primaerschluessel vorselektieren
|
||||
if (( isset($primaryKeys[$i]) ) && ( $primaryKeys[$i] == $feldName )) echo ' selected="selected"';
|
||||
echo '>' . $feldName . ' [' . $feldTyp . ']</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
}
|
||||
echo '</table>';
|
||||
//Speichern Knopf
|
||||
echo '<br /><input name="setNewPrimaryKeys" type="submit" value="' . $lang['primaryKeys_save'] . '" class="Formbutton">';
|
||||
echo '</form>';
|
||||
}
|
||||
///// DH ende
|
||||
}
|
||||
63
sqlbrowser/sqlbox.php
Normale Datei
63
sqlbrowser/sqlbox.php
Normale Datei
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
if (!defined('MSD_VERSION')) die('No direct access.');
|
||||
//Start SQL-Box
|
||||
$tpl=new MSDTemplate();
|
||||
$tpl->set_filenames(array(
|
||||
|
||||
'show' => $config['paths']['root'] . 'sqlbrowser/templates/sqlbox.tpl'
|
||||
));
|
||||
|
||||
if (isset($_GET['readfile']) && $_GET['readfile'] == 1)
|
||||
{
|
||||
$tpl->assign_block_vars('SQLUPLOAD',array(
|
||||
|
||||
'POSTTARGET' => $params,
|
||||
'LANG_OPENSQLFILE' => $lang['sql_openfile'],
|
||||
'LANG_OPENSQLFILE_BUTTON' => $lang['sql_openfile_button'],
|
||||
'LANG_SQL_MAXSIZE' => $lang['max_upload_size'],
|
||||
'MAX_FILESIZE' => $config['upload_max_filesize']
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
if (isset($_POST['submit_openfile']))
|
||||
{
|
||||
//open file
|
||||
if (!isset($_FILES['upfile']['name']) || empty($_FILES['upfile']['name'])) $aus.='<span class="error">' . $lang['fm_uploadfilerequest'] . '</span>';
|
||||
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.='<span>geladenes File: <strong>' . $_FILES['upfile']['name'] . '</strong> ' . byte_output(filesize($_FILES['upfile']['tmp_name'])) . '</span>';
|
||||
$sql_loaded=implode("",$read__user_sqlfile);
|
||||
}
|
||||
}
|
||||
|
||||
// Sind SQL-Befehle in der SQLLib vorhanden?
|
||||
$sqlcombo=SQL_ComboBox();
|
||||
if ($sqlcombo > '') $tpl->assign_block_vars('SQLCOMBO',array(
|
||||
|
||||
'SQL_COMBOBOX' => $sqlcombo
|
||||
));
|
||||
|
||||
$tpl->assign_vars(array(
|
||||
|
||||
'LANG_SQL_WARNING' => $lang['sql_warning'],
|
||||
'ICONPATH' => $config['files']['iconpath'],
|
||||
'MYSQL_REF' => $mysql_help_ref,
|
||||
'BOXSIZE' => $config['interface_sqlboxsize'],
|
||||
'BOXCONTENT' => ( ( isset($sql_loaded) ) ? $sql_loaded : $sql['sql_statement'] . $sql['order_statement'] ),
|
||||
'LANG_SQL_BEFEHLE' => $lang['sql_befehle'],
|
||||
'TABLE_COMBOBOX' => Table_ComboBox(),
|
||||
'LANG_SQL_EXEC' => $lang['sql_exec'],
|
||||
'PARAMS' => $params,
|
||||
'DB' => $db,
|
||||
'DBID' => $dbid,
|
||||
'TABLENAME' => $tablename,
|
||||
'ICON_SEARCH' => $icon['search'],
|
||||
'ICON_UPLOAD' => $icon['upload'],
|
||||
'ICON_MYSQL_HELP' => $icon['mysql_help'],
|
||||
'MYSQL_HELP' => $lang['title_mysql_help']
|
||||
));
|
||||
$tpl->pparse('show');
|
||||
72
sqlbrowser/templates/mysql_search.tpl
Normale Datei
72
sqlbrowser/templates/mysql_search.tpl
Normale Datei
|
|
@ -0,0 +1,72 @@
|
|||
<div id="sqlsearch">
|
||||
<form action="sql.php?search=1" method="POST" name="suche">
|
||||
<fieldset>
|
||||
<legend><b>{LANG_SQLSEARCH}</b></legend>
|
||||
<b>{LANG_SQL_SEARCHWORDS}:</b> <input type="text" style="width:300px;" name="suchbegriffe" value="{SUCHBEGRIFFE}">
|
||||
<input type="submit" name="suche" value="{LANG_START_SQLSEARCH}" class="Formbutton">
|
||||
<input type="submit" name="reset" value="{LANG_RESET_SEARCHWORDS}" class="Formbutton" onclick="document.suche.suchbegriffe.value='';">
|
||||
<span style="font-size:10px;">{LANG_SEARCH_EXPLAIN}<br></span>
|
||||
<fieldset>
|
||||
<legend><b>{LANG_SEARCH_OPTIONS}</b></legend>
|
||||
<input type="radio" id="and" name="suchart" value="AND"{AND_SEARCH}>
|
||||
<label for="and" onmouseover="this.style.cursor='pointer'">{LANG_SEARCH_OPTIONS_AND}</label>
|
||||
<br>
|
||||
<input type="radio" id="or" name="suchart" value="OR"{OR_SEARCH}>
|
||||
<label for="or" onmouseover="this.style.cursor='pointer'">{LANG_SEARCH_OPTIONS_OR}</label>
|
||||
<br>
|
||||
<input type="radio" id="concat" name="suchart" value="CONCAT"{CONCAT_SEARCH}>
|
||||
<label for="concat" onmouseover="this.style.cursor='pointer'">{LANG_SEARCH_OPTIONS_CONCAT}</label>
|
||||
<br>
|
||||
{LANG_SEARCH_IN_TABLE}:
|
||||
<select name="table_selected" size="1" onchange="document.suche.submit();">
|
||||
{TABLE_OPTIONS}
|
||||
</select>
|
||||
<input type="hidden" name="offset" value="0">
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
</form>
|
||||
<!-- BEGIN HITS -->
|
||||
{HITS.LANG_SEARCH_RESULTS}:<br>
|
||||
|
||||
<input type="button" value=" << " class="Formbutton"
|
||||
onclick="document.suche.offset.value='{HITS.LAST_OFFSET}';document.suche.submit();"
|
||||
{HITS.BACK_BUTTON_DISABLED} accesskey="c">
|
||||
|
||||
<input type="button" value=" >> " class="Formbutton"
|
||||
onclick="document.suche.offset.value='{HITS.NEXT_OFFSET}';document.suche.submit();"
|
||||
{HITS.NEXT_BUTTON_DISABLED} accesskey="v">
|
||||
{HITS.LANG_ACCESS_KEYS}
|
||||
|
||||
<br><br>
|
||||
<table cellpadding="0" cellspacing="0" class="bdr">
|
||||
<tr class="thead">
|
||||
<th class="thead"> </th>
|
||||
<th class="thead" style="text-align:left">#</th>
|
||||
<!-- BEGIN TABLEHEAD -->
|
||||
<th class="thead" style="text-align:left">{HITS.TABLEHEAD.KEY}</th>
|
||||
<!-- END TABLEHEAD -->
|
||||
</tr>
|
||||
<!-- BEGIN TABLEROW -->
|
||||
<tr class="{HITS.TABLEROW.CLASS}">
|
||||
<td nowrap="nowrap">
|
||||
<a href="{HITS.TABLEROW.LINK_EDIT}">{HITS.TABLEROW.ICON_EDIT}</a><a href="{HITS.TABLEROW.LINK_DELETE}">{HITS.TABLEROW.ICON_DELETE}</a>
|
||||
</td>
|
||||
<td style="text-align:right;">{HITS.TABLEROW.NR}. </td>
|
||||
<!-- BEGIN TABLEDATA -->
|
||||
<td>{HITS.TABLEROW.TABLEDATA.VAL}</td>
|
||||
<!-- END TABLEDATA -->
|
||||
</tr>
|
||||
<!-- END TABLEROW -->
|
||||
</table>
|
||||
<!-- END HITS -->
|
||||
|
||||
<!-- BEGIN NO_RESULTS -->
|
||||
{NO_RESULTS.LANG_SEARCH_NO_RESULTS}
|
||||
<!-- END NO_RESULTS -->
|
||||
|
||||
<!-- BEGIN NO_ENTRIES -->
|
||||
{NO_ENTRIES.LANG_NO_ENTRIES}
|
||||
<!-- END NO_ENTRIES -->
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">document.suche.suchbegriffe.focus();</script>
|
||||
45
sqlbrowser/templates/sqlbox.tpl
Normale Datei
45
sqlbrowser/templates/sqlbox.tpl
Normale Datei
|
|
@ -0,0 +1,45 @@
|
|||
<!-- BEGIN SQLUPLOAD -->
|
||||
<form action="{SQLUPLOAD.POSTTARGET}" method="post" enctype="multipart/form-data">
|
||||
<table class="bordersmall">
|
||||
<tr>
|
||||
<td>{SQLUPLOAD.LANG_OPENSQLFILE}</td>
|
||||
<td><input type="file" name="upfile" class="Formbutton"></td>
|
||||
<td><input type="submit" class="Formbutton" name="submit_openfile" value="{SQLUPLOAD.LANG_OPENSQLFILE_BUTTON}"></td>
|
||||
<td>{SQLUPLOAD.LANG_SQL_MAXSIZE}: <b>{SQLUPLOAD.MAX_FILESIZE}</b></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<!-- END SQLUPLOAD -->
|
||||
|
||||
<div id="ymysqlbox">
|
||||
<form action="sql.php" method="post">
|
||||
<div id="sqlheaderbox">
|
||||
<a href="#" onclick="resizeSQL(0);">
|
||||
<img src="{ICONPATH}close.gif" width="16" height="16" alt="" border="0" vspace="0" hspace="0" align="bottom"></a>
|
||||
<a href="#" onclick="resizeSQL(1);">
|
||||
<img src="{ICONPATH}arrowup.gif" width="16" height="16" alt="show less" border="0" vspace="0" hspace="0" align="bottom"></a>
|
||||
<a href="#" onclick="resizeSQL(2);"><img src="{ICONPATH}arrowdown.gif" width="16" height="16" alt="show more" border="0" vspace="0" hspace="0" align="bottom"></a>
|
||||
|
||||
<input class="Formbutton" type="button" onclick="document.location.href='{PARAMS}&context=1'" value="{LANG_SQL_BEFEHLE}">
|
||||
<!-- BEGIN SQLCOMBO -->
|
||||
{SQLCOMBO.SQL_COMBOBOX}
|
||||
<!-- END SQLCOMBO -->
|
||||
{TABLE_COMBOBOX}
|
||||
<input class="Formbutton" type="reset" name="reset" value="reset">
|
||||
<input class="Formbutton" type="submit" name="execsql" value="{LANG_SQL_EXEC}">
|
||||
|
||||
<a href="{PARAMS}&readfile=1">{ICON_UPLOAD}</a>
|
||||
<a href="{PARAMS}&search=1">{ICON_SEARCH}</a>
|
||||
<a href="{MYSQL_REF}" title="{MYSQL_HELP}" target="_blank">{ICON_MYSQL_HELP}</a>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<textarea style="height:{BOXSIZE}px;" name="sqltextarea" id="sqltextarea" rows="4" cols="10">{BOXCONTENT}</textarea>
|
||||
<div class="sqlbox-warning" align="center">{LANG_SQL_WARNING}</div>
|
||||
<input type="hidden" name="db" value="{DB}">
|
||||
<input type="hidden" name="tablename" value="{TABLENAME}">
|
||||
<input type="hidden" name="dbid" value="{DBID}">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<br>
|
||||
Laden …
Tabelle hinzufügen
Einen Link hinzufügen
In neuem Issue referenzieren