PDF rausgenommen
This commit is contained in:
397
msd2/msd/inc/sqlbrowser/mysql_search.php
Normal file
397
msd2/msd/inc/sqlbrowser/mysql_search.php
Normal file
@ -0,0 +1,397 @@
|
||||
<?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=mysqli_query($link, $sql);
|
||||
if (!$res===false)
|
||||
{
|
||||
while ($row=mysqli_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>";
|
||||
$sqlk="DELETE FROM `$tablename` WHERE ".$rk." LIMIT 1";
|
||||
//echo $sqlk;
|
||||
$res=MSD_query($sqlk);
|
||||
// echo "<br>".$res;
|
||||
$aus.='<p class="success">'.$lang['L_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=mysqli_query($link,$sql);
|
||||
unset($felder);
|
||||
if (!$res===false)
|
||||
{
|
||||
// Felder der Tabelle ermitteln
|
||||
while ($row=mysqli_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=@mysqli_query($link, $sql);
|
||||
if ($res)
|
||||
{
|
||||
while ($row=mysqli_fetch_array($res,MYSQLI_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' => './tpl/sqlbrowser/mysql_search.tpl'));
|
||||
|
||||
$tpl->assign_vars(array(
|
||||
'DB_NAME_URLENCODED' => urlencode($db),
|
||||
'LANG_SQLSEARCH' => $lang['L_SQL_SEARCH'],
|
||||
'LANG_SQL_SEARCHWORDS' => $lang['L_SQL_SEARCHWORDS'],
|
||||
'SUCHBEGRIFFE' => $suchbegriffe,
|
||||
'LANG_START_SQLSEARCH' => $lang['L_START_SQL_SEARCH'],
|
||||
'LANG_RESET_SEARCHWORDS' => $lang['L_RESET_SEARCHWORDS'],
|
||||
'LANG_SEARCH_OPTIONS' => $lang['L_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['L_SEARCH_OPTIONS_AND'],
|
||||
'LANG_SEARCH_OPTIONS_OR' => $lang['L_SEARCH_OPTIONS_OR'],
|
||||
'LANG_SEARCH_OPTIONS_CONCAT' => $lang['L_SEARCH_OPTIONS_CONCAT'],
|
||||
'LANG_SEARCH_IN_TABLE' => $lang['L_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['L_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['L_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=getExtendedFieldinfo($db,$tables[$table_selected]);
|
||||
//v($fieldinfos);
|
||||
// auf zusammengesetzte Schlüssel untersuchen
|
||||
$table_keys=isset($fieldinfos['primary_keys']) ? $fieldinfos['primary_keys'] : '';
|
||||
|
||||
for ($a=0; $a<$zeige_treffer; $a++)
|
||||
{
|
||||
$tablename=array_keys($treffer[$a]);
|
||||
if (is_array($table_keys)&&sizeof($table_keys)>0)
|
||||
{
|
||||
// a primary key exitst
|
||||
$keystring='';
|
||||
foreach ($table_keys as $k)
|
||||
{
|
||||
// remove hit marker from value
|
||||
$x=str_replace('<span class="treffer">','',$treffer[$a][$k]);
|
||||
$x=str_replace('</span>','',$x);
|
||||
$keystring.='`'.$k.'`="'.addslashes($x).'" AND ';
|
||||
}
|
||||
$keystring=substr($keystring,0,-5);
|
||||
$rk=build_recordkey($keystring);
|
||||
}
|
||||
else
|
||||
{
|
||||
$rk=urlencode(build_where_from_record($treffer[$a])); // no keys
|
||||
}
|
||||
|
||||
$delete_link='sql.php?search=1&mode=kill&db='.urlencode($db).'&tablename='.urlencode($tables[$table_selected]).'&rk='.$rk;
|
||||
$edit_link='sql.php?mode=searchedit&db='.urlencode($db).'&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['L_NO_ENTRIES'],$tables[$table_selected])));
|
||||
else
|
||||
$tpl->assign_block_vars('NO_RESULTS',array(
|
||||
|
||||
'LANG_SEARCH_NO_RESULTS' => sprintf($lang['L_SEARCH_NO_RESULTS'],$suchbegriffe,$tables[$table_selected])));
|
||||
}
|
||||
|
||||
$tpl->pparse('show');
|
108
msd2/msd/inc/sqlbrowser/sql_commands.php
Normal file
108
msd2/msd/inc/sqlbrowser/sql_commands.php
Normal file
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
MyOOS [Dumper]
|
||||
http://www.oos-shop.de/
|
||||
|
||||
Copyright (c) 2016 by the MyOOS Development Team.
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
|
||||
MySqlDumper
|
||||
http://www.mysqldumper.de
|
||||
|
||||
Copyright (C)2004-2011 Daniel Schlichtholz (admin@mysqldumper.de)
|
||||
----------------------------------------------------------------------
|
||||
Released under the GNU General Public License
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
if (!defined('MSD_VERSION')) die('No direct access.');
|
||||
function nl2null($string)
|
||||
{
|
||||
$search=array("\r","\n");
|
||||
$replace=array('','');
|
||||
return trim(str_replace($search,$replace,$string));
|
||||
}
|
||||
//SQL-Strings
|
||||
echo $aus.='<h4>' . $lang['L_SQL_BEFEHLE'] . ' (' . count($SQL_ARRAY) . ')</h4>';
|
||||
echo '<a href="' . $params . '&sqlconfig=1&new=1">' . $lang['L_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]=htmlspecialchars($_POST['sqlname0'],ENT_COMPAT ,'UTF-8') . '|' . $_POST['sqlstring0'];
|
||||
WriteSQL();
|
||||
echo '<p>' . $lang['L_SQL_BEFEHLSAVED1'] . ' \'' . $_POST['sqlname' . $ind] . '\' ' . $lang['L_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" style="width:100%"><tr class="thead"><th>#</th><th>' . $lang['L_NAME'] . '</th><th>SQL</th><th>' . $lang['L_COMMAND'] . '</th></tr>';
|
||||
$i=0;
|
||||
if (count($SQL_ARRAY) > 0)
|
||||
{
|
||||
for ($i=0; $i < count($SQL_ARRAY); $i++)
|
||||
{
|
||||
if (isset($_POST['sqlupdate' . $i]))
|
||||
{
|
||||
|
||||
echo '<tr><td colspan="4"><p class="success">' . $lang['L_SQL_BEFEHLSAVED1']
|
||||
. ' \'' . htmlspecialchars($_POST['sqlname' . $i],ENT_COMPAT ,'UTF-8') . '\' ' . $lang['L_SQL_BEFEHLSAVED3'] . '</p></td></tr>';
|
||||
$SQL_ARRAY[$i]=$_POST['sqlname' . $i] . "|" . nl2null($_POST['sqlstring' . $i]);
|
||||
WriteSQL();
|
||||
}
|
||||
if (isset($_POST['sqlmove' . $i]))
|
||||
{
|
||||
echo '<tr><td colspan="4"><p class="success">' . $lang['L_SQL_BEFEHLSAVED1'] . ' \'' . $_POST['sqlname' . $i] . '\' ' . $lang['L_SQL_BEFEHLSAVED4'] . '</p></td></tr>';
|
||||
$a[]=$SQL_ARRAY[$i];
|
||||
array_splice($SQL_ARRAY,$i,1);
|
||||
$SQL_ARRAY=array_merge($a,$SQL_ARRAY);
|
||||
WriteSQL();
|
||||
}
|
||||
if (isset($_POST['sqldelete' . $i]))
|
||||
{
|
||||
echo '<tr><td colspan="4"><p class="success">' . $lang['L_SQL_BEFEHLSAVED1'] . ' \'' . $_POST['sqlname' . $i] . '\' ' . $lang['L_SQL_BEFEHLSAVED5'] . '</p></td></tr>';
|
||||
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="' . htmlspecialchars(SQL_Name($i),ENT_COMPAT,'UTF-8') . '"></td>';
|
||||
echo '<td><textarea rows="4" cols="80" style="width:100%;" 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['L_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>';
|
410
msd2/msd/inc/sqlbrowser/sql_dataview.php
Normal file
410
msd2/msd/inc/sqlbrowser/sql_dataview.php
Normal file
@ -0,0 +1,410 @@
|
||||
<?php
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
MyOOS [Dumper]
|
||||
http://www.oos-shop.de/
|
||||
|
||||
Copyright (c) 2016 by the MyOOS Development Team.
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
|
||||
MySqlDumper
|
||||
http://www.mysqldumper.de
|
||||
|
||||
Copyright (C)2004-2011 Daniel Schlichtholz (admin@mysqldumper.de)
|
||||
----------------------------------------------------------------------
|
||||
Released under the GNU General Public License
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
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['L_SQL_TABLEVIEW'] : $lang['L_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=' . urlencode($order) . '&orderdir=' . $orderdir . '&tdc=' . $tdcompact;
|
||||
echo '<a href="' . $p . '&mode=new">' . $lang['L_SQL_RECORDNEW'] . '</a> ';
|
||||
echo '<a href="sql.php?db=' . $databases['db_actual'] . '&dbid=' . $dbid . '&tablename=' . $tablename . '&context=2">' . $lang['L_SQL_EDIT_TABLESTRUCTURE'] . '</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$p='sql.php?db=' . $db . '&dbid=' . $dbid . '&context=2';
|
||||
echo '<a href="' . $p . '">' . $lang['L_SQL_TABLENEW'] . '</a>';
|
||||
}
|
||||
|
||||
//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 '<script type="text/javascript" language="javascript">'
|
||||
.'parent.MyOOS_Dumper_menu.location.href=\'menu.php?dbindex='.$dbid.'\';</script>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
echo '</p><p class="tablename">' . ( $tn != '' ? $lang['L_TABLE'] . ' <strong>`' . $databases['db_actual'] . '`.`' . $tn . '`</strong><br>' : '' );
|
||||
if (isset($msg)) echo $msg;
|
||||
|
||||
$numrowsabs=-1;
|
||||
$numrows=0;
|
||||
// Vorgehensweise - es soll die Summe der Datensaetze ermittelt werden, wenn es kein LIMIT gibt,
|
||||
// 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
|
||||
{
|
||||
$sql_temp="SELECT count(*) as anzahl FROM (".$sql_temp.") as query;";
|
||||
$res=@MSD_query($sql_temp,false);
|
||||
if ($res)
|
||||
{
|
||||
if ($row=mysqli_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=@mysqli_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 ) ? '<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.' '.($numrowsabs>1 ? $lang['L_TABLES']:$lang['L_TABLE']);
|
||||
}
|
||||
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=mysqli_fetch_row($res);
|
||||
//Kompaktmodus-Switcher
|
||||
$t='<td colspan="' . ( count($row) + 1 ) . '" align="left"><a href="sql.php?db=' . $db . '&tablename=' . $tablename . '&dbid=' . $dbid . '&order=' . urlencode($order) . '&orderdir=' . $orderdir . '&limitstart=' . $limitstart . '&sql_statement=' . urlencode($sql['sql_statement']) . '&tdc=' . ( ( $tdcompact == 0 ) ? '1' : '0' ) . '">' . ( ( $tdcompact == 1 ) ? $lang['L_SQL_VIEW_STANDARD'] : $lang['L_SQL_VIEW_COMPACT'] ) . '</a>';
|
||||
$t.=' ' . $lang['L_SQL_QUERYENTRY'] . ' ' . count($row) . ' ' . $lang['L_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']=mysqli_fetch_field($res,$x);
|
||||
$temp[$x]['data']=mysqli_fetch_field($res);
|
||||
$temp[$x]['sort']=add_sortkey($temp[$x]['data']->name);
|
||||
}
|
||||
|
||||
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']=isset($str->unsigned) ? $str->unsigned : '';
|
||||
$fdesc[$temp[$x]['data']->name]['zerofill']=isset($str->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='<img src="' . $icon['blank'] . '" alt="" width="1" height="1" border="0">';
|
||||
if ( (isset($str->primary_key) && ($str->primary_key == 1)) || (isset($str->unique_key) && ($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=' . urlencode($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=' . urlencode($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
|
||||
mysqli_data_seek($res,0);
|
||||
|
||||
$s=$keysort;
|
||||
$s=array_flip($keysort);
|
||||
ksort($s);
|
||||
for ($i=0; $i < $numrows; $i++)
|
||||
{
|
||||
$data[0]=mysqli_fetch_array($res,MYSQLI_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];
|
||||
|
||||
/***********************
|
||||
Ergänzung www.betanet-web.ch - 30.04.2019
|
||||
Anz. Einträge in der Tabelle wird in Ausgabe Array überschrieben, damit alle Daten exportiert werden.
|
||||
************************/
|
||||
|
||||
$tabellenname = $data[0]['Name'];
|
||||
$numrows12 = 0;
|
||||
$select12 = "select * from $tabellenname";
|
||||
$res12 = MSD_query($select12);
|
||||
$numrows12 = @mysqli_num_rows($res12);
|
||||
|
||||
// Überschreiben mit neuem Wert
|
||||
$temp[$i]['Rows'] = $numrows12;
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
$temp[$i]=$data[0];
|
||||
}
|
||||
|
||||
$rownr=$limitstart + 1;
|
||||
for ($i=0; $i < $numrows; $i++)
|
||||
{
|
||||
$row=$temp[$i]; // mysqli_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.=' AND ';
|
||||
$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=' . $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.='<a href="' . $p . '&mode=edit">' . $icon['edit'] . '</a> ';
|
||||
}
|
||||
}
|
||||
|
||||
if ($showtables == 0 && $tabellenansicht == 0)
|
||||
{
|
||||
$d.='<a href="' . $p . '&mode=kill" onclick="if(!confirm(\'' . $lang['L_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['L_ASKTABLEEMPTY'],$tablename) . '\')) return false;">' . $icon['table_truncate'] . '</a> ' . $nl . $nl;
|
||||
$d.='<a href="' . $p . '&mode=emptyk" onclick="if(!confirm(\'' . sprintf($lang['L_ASKTABLEEMPTYKEYS'],$tablename) . '\')) return false;">' . $icon['table_truncate_reset'] . '</a> ' . $nl . $nl;
|
||||
$d.='<a href="' . $p . '&mode=kill" onclick="if(!confirm(\'' . sprintf($lang['L_ASKDELETETABLE'],$tablename) . '\')) return false;">' . $icon['delete'] . '</a> ' . $nl . $nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
$d.='<a href="' . $p . '&mode=kill_view" onclick="if(!confirm(\'' . sprintf($lang['L_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($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='<i>NULL</i>';
|
||||
|
||||
else $data=htmlspecialchars($data,ENT_COMPAT,'UTF-8');
|
||||
}
|
||||
$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['L_SQL_NODATA'] . '</p>';
|
58
msd2/msd/inc/sqlbrowser/sql_record_insert_inputmask.php
Normal file
58
msd2/msd/inc/sqlbrowser/sql_record_insert_inputmask.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
MyOOS [Dumper]
|
||||
http://www.oos-shop.de/
|
||||
|
||||
Copyright (c) 2016 by the MyOOS Development Team.
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
|
||||
MySqlDumper
|
||||
http://www.mysqldumper.de
|
||||
|
||||
Copyright (C)2004-2011 Daniel Schlichtholz (admin@mysqldumper.de)
|
||||
----------------------------------------------------------------------
|
||||
Released under the GNU General Public License
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
// insert a new record
|
||||
$tpl=new MSDTemplate();
|
||||
$tpl->set_filenames(array(
|
||||
'show' => './tpl/sqlbrowser/sql_record_insert_inputmask.tpl'));
|
||||
|
||||
$sqledit="SHOW FIELDS FROM `$tablename`";
|
||||
$res=MSD_query($sqledit);
|
||||
$num=mysqli_num_rows($res);
|
||||
|
||||
$feldnamen="";
|
||||
for ($x=0; $x<$num; $x++)
|
||||
{
|
||||
$row=mysqli_fetch_object($res);
|
||||
$feldnamen.=$row->Field.'|';
|
||||
$tpl->assign_block_vars('ROW',array(
|
||||
'CLASS' => ($x%2) ? 1 : 2,
|
||||
'FIELD_NAME' => $row->Field,
|
||||
'FIELD_ID' => correct_post_index($row->Field)));
|
||||
|
||||
$type=strtoupper($row->Type);
|
||||
|
||||
if (strtoupper($row->Null)=='YES')
|
||||
{
|
||||
//field is nullable
|
||||
$tpl->assign_block_vars('ROW.IS_NULLABLE',array());
|
||||
}
|
||||
|
||||
if (in_array($type,array(
|
||||
'BLOB',
|
||||
'TEXT'))) $tpl->assign_block_vars('ROW.IS_TEXTAREA',array());
|
||||
else
|
||||
$tpl->assign_block_vars('ROW.IS_TEXTINPUT',array());
|
||||
}
|
||||
|
||||
$tpl->assign_vars(array(
|
||||
'HIDDEN_FIELDS' => FormHiddenParams(),
|
||||
'FIELDNAMES' => substr($feldnamen,0,strlen($feldnamen)-1),
|
||||
'SQL_STATEMENT' => my_quotes($sql['sql_statement'])));
|
||||
|
||||
$tpl->pparse('show');
|
68
msd2/msd/inc/sqlbrowser/sql_record_update_inputmask.php
Normal file
68
msd2/msd/inc/sqlbrowser/sql_record_update_inputmask.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
MyOOS [Dumper]
|
||||
http://www.oos-shop.de/
|
||||
|
||||
Copyright (c) 2016 by the MyOOS Development Team.
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
|
||||
MySqlDumper
|
||||
http://www.mysqldumper.de
|
||||
|
||||
Copyright (C)2004-2011 Daniel Schlichtholz (admin@mysqldumper.de)
|
||||
----------------------------------------------------------------------
|
||||
Released under the GNU General Public License
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
|
||||
// Edit record -> built Edit-Form
|
||||
$tpl=new MSDTemplate();
|
||||
$tpl->set_filenames(array(
|
||||
'show' => './tpl/sqlbrowser/sql_record_update_inputmask.tpl'));
|
||||
|
||||
$target=($mode=="searchedit") ? '?mode=searchedit' : '?mode=update'; // jump back to search hit list after saving
|
||||
$fields=getExtendedFieldInfo($db,$tablename);
|
||||
|
||||
$sqledit="SELECT * FROM `$tablename` WHERE ".$recordkey;
|
||||
$res=MSD_query($sqledit);
|
||||
$record=mysqli_fetch_array($res,MYSQLI_ASSOC); // get the record
|
||||
$num=sizeof($record); // get the nr of fields of the record
|
||||
|
||||
|
||||
// iterate fields
|
||||
$x=0;
|
||||
$fieldnames='';
|
||||
foreach ($record as $field=>$fieldvalue)
|
||||
{
|
||||
$fieldnames.=$field.'|';
|
||||
$tpl->assign_block_vars('ROW',array(
|
||||
'CLASS' => ($x%2) ? 1 : 2,
|
||||
'FIELD_NAME' => $field,
|
||||
'FIELD_VALUE' => my_quotes($fieldvalue),
|
||||
'FIELD_ID' => correct_post_index($field)));
|
||||
|
||||
if ('YES'==$fields[$field]['null'])
|
||||
{
|
||||
//field is nullable - precheck checkbox if value is null
|
||||
$tpl->assign_block_vars('ROW.IS_NULLABLE',array(
|
||||
'NULL_CHECKED' => is_null($fieldvalue) ? ' checked="checked"' : ''));
|
||||
}
|
||||
|
||||
$type=strtoupper($fields[$field]['type']);
|
||||
if (in_array($type,array(
|
||||
'BLOB',
|
||||
'TEXT'))) $tpl->assign_block_vars('ROW.IS_TEXTAREA',array());
|
||||
else
|
||||
$tpl->assign_block_vars('ROW.IS_TEXTINPUT',array());
|
||||
$x++;
|
||||
}
|
||||
$tpl->assign_vars(array(
|
||||
'HIDDEN_FIELDS' => FormHiddenParams(),
|
||||
'FIELDNAMES' => substr($fieldnames,0,strlen($fieldnames)-1),
|
||||
'SQL_STATEMENT' => my_quotes($sql['sql_statement']),
|
||||
'RECORDKEY' => my_quotes($recordkey),
|
||||
'TARGET' => $target));
|
||||
|
||||
$tpl->pparse('show');
|
612
msd2/msd/inc/sqlbrowser/sql_tables.php
Normal file
612
msd2/msd/inc/sqlbrowser/sql_tables.php
Normal file
@ -0,0 +1,612 @@
|
||||
<?php
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
MyOOS [Dumper]
|
||||
http://www.oos-shop.de/
|
||||
|
||||
Copyright (c) 2016 by the MyOOS Development Team.
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
|
||||
MySqlDumper
|
||||
http://www.mysqldumper.de
|
||||
|
||||
Copyright (C)2004-2011 Daniel Schlichtholz (admin@mysqldumper.de)
|
||||
----------------------------------------------------------------------
|
||||
Released under the GNU General Public License
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
if (!defined('MSD_VERSION')) die('No direct access.');
|
||||
//Tabellen
|
||||
echo $aus.'<h6>'.$lang['L_SQL_TABLESOFDB'].' `'.$databases['Name'][$dbid].'` '.$lang['L_SQL_EDIT'].'</h6>';
|
||||
|
||||
//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['name']);
|
||||
if (!(false===$keyPos))
|
||||
{
|
||||
unset($keys['name'][$keyPos]);
|
||||
unset($keys['size'][$keyPos]);
|
||||
$keys['name']=array_values($keys['name']);
|
||||
$keys['size']=array_values($keys['size']);
|
||||
$res=setNewPrimaryKeys($databases['Name'][$dbid], $_GET['tablename'], $keys['name'], $keys['size']);
|
||||
if ($res)
|
||||
{
|
||||
echo '<script language="JavaScript">
|
||||
alert("'.$lang['L_PRIMARYKEY_DELETED'].': '.$_GET['killPrimaryKey'].'");
|
||||
</script>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<script language="JavaScript">
|
||||
alert("'.$lang['L_PRIMARYKEYS_CHANGINGERROR'].': '.$_GET['killPrimaryKey'].'");
|
||||
</script>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<script language="JavaScript">
|
||||
alert("'.$lang['L_PRIMARYKEY_NOTFOUND'].': '.$_GET['killPrimaryKey'].'");
|
||||
</script>';
|
||||
}
|
||||
}
|
||||
//Primärschlüssel löschen ende
|
||||
|
||||
|
||||
//Neue Schlüssel setzen
|
||||
if (isset($_POST['setNewKeys']))
|
||||
{
|
||||
$fields=getAllFields($databases['Name'][$dbid],$_GET['tablename']);
|
||||
$newKeysArray=Array();
|
||||
$newKeySizesArray=Array();
|
||||
foreach ($fields as $index=>$field)
|
||||
{
|
||||
if ((isset($_POST["setNewKey".$index]))&&($_POST["setNewKey".$index]!=""))
|
||||
{
|
||||
$newKeysArray[]=$_POST["setNewKey".$index];
|
||||
$newKeySizesArray[]=isset($_POST["indexSize".$index]) ? (int) $_POST["indexSize".$index]:'';
|
||||
}
|
||||
}
|
||||
//doppelte Elemente entfernen
|
||||
$newKeysArray=array_unique($newKeysArray);
|
||||
$newKeySizesArray=array_intersect_key($newKeySizesArray, $newKeysArray);
|
||||
|
||||
if ($_POST["indexType"]=="primary")
|
||||
{
|
||||
$res=setNewPrimaryKeys($databases['Name'][$dbid], $_GET['tablename'], $newKeysArray, $newKeySizesArray);
|
||||
if ($res)
|
||||
{
|
||||
echo '<script language="JavaScript">
|
||||
alert("'.$lang['L_PRIMARYKEYS_CHANGED'].'");
|
||||
</script>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<script language="JavaScript">
|
||||
alert("'.$lang['L_PRIMARYKEYS_CHANGINGERROR'].'");
|
||||
</script>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($_POST["indexType"]=="unique")
|
||||
{
|
||||
$newIndexType="UNIQUE";
|
||||
}
|
||||
elseif ($_POST["indexType"]=="fulltext")
|
||||
{
|
||||
$newIndexType="FULLTEXT";
|
||||
}
|
||||
else
|
||||
{
|
||||
$newIndexType="INDEX";
|
||||
}
|
||||
|
||||
$res=setNewKeys($databases['Name'][$dbid], $_GET['tablename'], $newKeysArray, $newIndexType, $_POST['indexName'], $newKeySizesArray);
|
||||
if ($res)
|
||||
{
|
||||
echo '<script language="JavaScript">
|
||||
alert("'.$lang['L_KEY_ADDED'].'");
|
||||
</script>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<script language="JavaScript">
|
||||
alert("'.$lang['L_KEY_ADDERROR'].'");
|
||||
</script>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Andere Indizes löschen
|
||||
if (isset($_GET['killIndex']))
|
||||
{
|
||||
$res = killKey($databases['Name'][$dbid], $_GET['tablename'], $_GET['killIndex']);
|
||||
if ($res)
|
||||
{
|
||||
echo '<script language="JavaScript">
|
||||
alert("'.$lang['L_KEY_DELETED'].': '.$_GET['killIndex'].'");
|
||||
</script>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<script language="JavaScript">
|
||||
alert("'.$lang['L_KEY_DELETEERROR'].': '.$_GET['killIndex'].'");
|
||||
</script>';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['kill']))
|
||||
{
|
||||
if ($_GET['anz']==1) echo '<p class="error">'.$lang['L_SQL_NOFIELDDELETE'].'</p>';
|
||||
else
|
||||
{
|
||||
$sql_alter="ALTER TABLE `".$databases['Name'][$dbid]."`.`".$_GET['tablename']."` DROP COLUMN `".$_GET['kill']."`";
|
||||
$res = MSD_DoSQL($sql_alter);
|
||||
if ($res)
|
||||
{
|
||||
echo '<div align="left" id="sqleditbox" style="font-size: 11px;width:90%;padding=6px;">';
|
||||
echo '<p class="success">'.$lang['L_SQL_FIELDDELETE1'].' `'.$_GET['kill'].'` '.$lang['L_SQL_DELETED'].'.</p>'.highlight_sql($out).'</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($_POST['tablecopysubmit']))
|
||||
{
|
||||
$table_edit_name=$_GET['tablename'];
|
||||
if ($_POST['tablecopyname']=="")
|
||||
{
|
||||
echo '<p class="error">'.$lang['L_SQL_NODEST_COPY'].'</p>';
|
||||
}
|
||||
elseif (Table_Exists($databases['Name'][$dbid],$_POST['tablecopyname']))
|
||||
{
|
||||
echo '<p class="error">'.$lang['L_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['L_SQL_SCOPY'],$table_edit_name,$_POST['tablecopyname']).'</p>' : sprintf($lang['L_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['L_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;";
|
||||
$res = MSD_DoSQL($sql_alter);
|
||||
if ($res)
|
||||
{
|
||||
echo SQLOutput($out,$lang['L_TABLE'].' `'.$_POST['newtablename'].'` '.$lang['L_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['L_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['L_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']."' ";
|
||||
|
||||
$res = MSD_DoSQL($sql_alter);
|
||||
if ($res)
|
||||
{
|
||||
echo SQLOutput($out,$lang['L_TABLE'].' `'.$_POST['table_edit_name'].'` '.$lang['L_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['L_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 ";
|
||||
}
|
||||
$sql_alter.=$_POST['f_position'];
|
||||
|
||||
if ($newkeys[0]==1) $sql_alter.=", ADD PRIMARY KEY (`".$_POST['f_name']."`)";
|
||||
if ($newkeys[1]==1) $sql_alter.=", ADD UNIQUE (`".$_POST['f_name']."`)";
|
||||
if ($newkeys[2]==1) $sql_alter.=", ADD INDEX (`".$_POST['f_name']."`)";
|
||||
if ($newkeys[3]==1) $sql_alter.=", ADD FULLTEXT INDEX (`".$_POST['f_name']."`)";
|
||||
|
||||
$sql_alter.=";";
|
||||
|
||||
if ($add_sql!="")
|
||||
{
|
||||
$add_sql=$sql_stamm.$add_sql;
|
||||
$sql_alter="$sql_alter\n$add_sql;";
|
||||
}
|
||||
$res = MSD_DoSQL($sql_alter);
|
||||
if ($res)
|
||||
{
|
||||
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['L_SQL_CHANGED'] : $lang['L_SQL_CREATED']).'</p>';
|
||||
echo highlight_sql($out).'</div>';
|
||||
}
|
||||
$fields_infos=getFieldinfos($databases['Name'][$dbid],$table_edit_name);
|
||||
}
|
||||
}
|
||||
mysqli_select_db($config['dbconnection'], $databases['Name'][$dbid]);
|
||||
$sqlt="SHOW TABLE STATUS FROM `".$databases['Name'][$dbid]."` ;";
|
||||
$res=MSD_query($sqlt);
|
||||
$anz_tabellen=mysqli_num_rows($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['L_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['L_SQL_CREATETABLE'].'" class="Formbutton"></td></tr>';
|
||||
echo '<tr class="dbrow1"><td>'.$lang['L_SQL_COPYTABLE'].': </td><td><input type="text" class="text" name="tablecopyname" size="20" maxlength="150"></td><td><select name="copyatt"><option value="0">'.$lang['L_SQL_STRUCTUREONLY'].'</option>'.((MSD_NEW_VERSION) ? '<option value="1">'.$lang['L_SQL_STRUCTUREDATA'].'</option>' : '').'</select></td><td><input type="submit" class="Formbutton" name="tablecopysubmit" value="'.$lang['L_SQL_COPYTABLE'].'" '.(($table_edit_name=="") ? "disabled=\"disabled\"" : "").'></td></tr>';
|
||||
|
||||
if ($anz_tabellen==0)
|
||||
{
|
||||
echo '<tr><td>'.$lang['L_SQL_NOTABLESINDB'].' `'.$databases['Name'][$dbid].'`</td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
echo '<tr><td>'.$lang['L_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=mysqli_fetch_array($res);
|
||||
echo '<option value="'.$row['Name'].'">'.$row['Name'].'</option>';
|
||||
}
|
||||
echo '</select> </td>';
|
||||
echo '<td><input type="button" class="Formbutton" value="'.$lang['L_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=mysqli_num_rows($res);
|
||||
$fields_infos=getFieldinfos($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['L_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['L_SQL_TBLPROPSOF'].' `'.$table_edit_name.'` ('.$anz_fields.' '.$lang['L_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['L_CHARSET'].'<br><select name="t_edit_charset" style="font-size:11px;">'.CharsetCombo($t_charset).'</select></td>';
|
||||
echo '<td class="small" align="center">'.$lang['L_COLLATION'].'<br><select name="t_edit_collate" style="font-size:11px;">'.CollationCombo($t_collation).'</select></td>';
|
||||
echo '<td class="small" align="center">'.$lang['L_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['L_CHANGE'].'" class="Formbutton"></td></tr>';
|
||||
echo '</table></form><p> </p>';
|
||||
|
||||
$field_fehler=0;
|
||||
echo '<h6>'.$lang['L_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]['attributes'] : "";
|
||||
|
||||
$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=(in_array($fields_infos[$id]['name'],$fields_infos['_primarykeys_'])) ? 1 : 0;
|
||||
$d_index=(in_array($fields_infos[$id]['name'],$fields_infos['_key_'])) ? 1 : 0;
|
||||
$d_fulltext=(in_array($fields_infos[$id]['name'],$fields_infos['_fulltextkey_'])) ? 1 : 0;
|
||||
$d_unique=(in_array($fields_infos[$id]['name'],$fields_infos['_uniquekey_'])) ? 1 : 0;
|
||||
}
|
||||
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['L_SQL_EDITFIELD']." `".$d_name."`" : $lang['L_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['L_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['L_COLLATION'].'<br><select name="f_collate">'.CollationCombo($d_collate).'</select></td>';
|
||||
echo '<td align="center">'.$lang['L_SQL_ATTRIBUTES'].'<br><select name="f_attribut">'.AttributeCombo($d_attribute).'</select></td>';
|
||||
echo '<td align="center">'.$lang['L_SQL_ATPOSITION'].':<br><select name="f_position"><option value=""></option><option value="FIRST">'.$lang['L_SQL_FIRST'].'</option>';
|
||||
if ($anz_fields>0)
|
||||
{
|
||||
for ($i=0; $i<$anz_fields; $i++)
|
||||
{
|
||||
echo '<option value="AFTER `'.$fields_infos[$i]['name'].'`">'.$lang['L_SQL_AFTER'].' `'.$fields_infos[$i]['name'].'`</option>';
|
||||
}
|
||||
}
|
||||
echo '</select></td><td align="center"><br><input type="submit" name="newfieldsubmit" value="'.((isset($_GET['editfield'])) ? $lang['L_SQL_CHANGEFIELD'] : $lang['L_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['L_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>'.
|
||||
$lang['L_COLLATION'].'</th><th>'.$lang['L_COMMENT'].'</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['L_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>'.get_output_attribut_null($fields_infos[$i]['null']).'</td><td>';
|
||||
//key
|
||||
if (in_array($fields_infos[$i]['name'],$fields_infos['_primarykeys_'])) echo $icon['key_primary'];
|
||||
if (in_array($fields_infos[$i]['name'],$fields_infos['_fulltextkey_'])) echo $icon['key_fulltext'];
|
||||
if (in_array($fields_infos[$i]['name'],$fields_infos['_uniquekey_'])) echo $icon['key_unique'];
|
||||
if (in_array($fields_infos[$i]['name'],$fields_infos['_key_'])) echo $icon['index'];
|
||||
echo '</td><td>'.$fields_infos[$i]['attributes'].'</td>';
|
||||
echo '<td>'.$fields_infos[$i]['default'].'</td>'.$td.$fields_infos[$i]['extra'].'</td>';
|
||||
echo '<td>'.((MSD_NEW_VERSION) ? $fields_infos[$i]['collate'] : " ").'</td>';
|
||||
echo '<td>'.((isset($fields_infos[$i]['comment'])) ? $fields_infos[$i]['comment'] : " ").'</td>';
|
||||
echo "</tr>";
|
||||
}
|
||||
echo '</table><br>';
|
||||
|
||||
echo '<h6>'.$lang['L_SQL_TABLEINDEXES'].' `'.$table_edit_name.'`</h6>';
|
||||
echo '<table class="bdr">
|
||||
<tr class="thead">
|
||||
<th colspan="2"> </th>
|
||||
<th>'.$lang['L_NAME'].'</th>
|
||||
<th>'.$lang['L_SQL_COLUMNS'].'</th>
|
||||
<th>'.$lang['L_INFO_SIZE'].'</th>
|
||||
'.((MSD_NEW_VERSION) ? '<th>'.$lang['L_TABLE_TYPE'].'</th>' : '').'
|
||||
<th>'.$lang['L_SQL_ALLOWDUPS'].'</th>
|
||||
<th>'.$lang['L_SQL_CARDINALITY'].'</th>
|
||||
<th>'.$lang['L_COMMENT'].'</th>
|
||||
</tr>';
|
||||
$sqlk="SHOW KEYS FROM `".$databases['Name'][$dbid]."`.`$table_edit_name`;";
|
||||
$res=MSD_query($sqlk);
|
||||
$num=mysqli_num_rows($res);
|
||||
if ($num==0)
|
||||
{
|
||||
echo '<tr><td colspan="6">'.$lang['L_SQL_TABLENOINDEXES'].'</td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
for ($i=0; $i<$num; $i++)
|
||||
{
|
||||
$row=mysqli_fetch_array($res,MYSQLI_ASSOC);
|
||||
if (!isset($row['Comment'])) {
|
||||
$row['Comment'] = '';
|
||||
}
|
||||
$cl=($i%2) ? "dbrow" : "dbrow1";
|
||||
//Images
|
||||
echo '<tr class="'.$cl.'">';
|
||||
echo '<td>';
|
||||
if ($row['Key_name']=="PRIMARY")
|
||||
{
|
||||
echo '<a href="'.$p.'&killPrimaryKey='.$row['Column_name'].'" onclick="if(!confirm(\''.$lang['L_PRIMARYKEY_CONFIRMDELETE'].'\')) return false;">';
|
||||
echo '<img src="'.$config['files']['iconpath'].'delete.gif" alt="" border="0">';
|
||||
echo '</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<a href="'.$p.'&killIndex='.$row['Key_name'].'" onclick="if(!confirm(\''.$lang['L_KEY_CONFIRMDELETE'].'\')) return false;">';
|
||||
echo '<img src="'.$config['files']['iconpath'].'delete.gif" alt="" border="0">';
|
||||
echo '</a>';
|
||||
}
|
||||
echo '</td>';
|
||||
echo '<td style="text-align:right">'.($i+1).'.</td>';
|
||||
echo '<td>'.$row['Key_name'].'</td>';
|
||||
echo '<td>'.$row['Column_name'].'</td>';
|
||||
echo '<td class="right">';
|
||||
if (isset($row['Sub_part']) && $row['Sub_part']>0) echo $row['Sub_part'];
|
||||
echo '</td>';
|
||||
if (MSD_NEW_VERSION) echo '<td>'.$row['Index_type'].'</td>';
|
||||
echo '<td align="center">'.(($row['Non_unique']==1) ? $lang['L_YES'] : $lang['L_NO']).'</td>';
|
||||
echo '<td>'.(($row['Cardinality']>=0) ? $row['Cardinality'] : $lang['L_NO']).'</td>';
|
||||
echo '<td>'.$row['Comment'].'</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
}
|
||||
echo '</table><br><input type="Button" value="'.$lang['L_SQL_CREATEINDEX'].'" onclick="location.href=\''.$p.'&sql_createindex=1#setnewkeys\'" class="Formbutton">';
|
||||
|
||||
if ((isset($_GET['sql_createindex']))&&($_GET['sql_createindex']=="1"))
|
||||
{ ?>
|
||||
<script type="text/javascript">
|
||||
function toggleIndexLength(id)
|
||||
{
|
||||
var mysqlStrings = ['<?php echo implode("','", $mysql_string_types);?>'];
|
||||
var field = 'setNewKey'+id;
|
||||
var sel = document.getElementById(field).selectedIndex;
|
||||
var val = document.getElementById(field).options[sel].innerHTML;
|
||||
document.getElementById('indexSize'+id).disabled = true;
|
||||
for (i=0;i<mysqlStrings.length;i++)
|
||||
{
|
||||
if (val.indexOf("["+mysqlStrings[i]) != -1)
|
||||
{
|
||||
document.getElementById('indexSize'+id).disabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
echo '<br><a name="setnewkeys"></a>';
|
||||
echo '<form action="'.$p.'" method="POST">';
|
||||
echo '<h6>'.$lang['L_SETKEYSFOR'].' `'.$table_edit_name.'`</h6>';
|
||||
//kopf
|
||||
echo '<table class="bdr">';
|
||||
//body
|
||||
$sqlFelder="DESCRIBE `".$databases['Name'][$dbid]."`.`".$_GET['tablename']."`;";
|
||||
$res=MSD_query($sqlFelder);
|
||||
$num=mysqli_num_rows($res);
|
||||
if ($num==0)
|
||||
{
|
||||
echo '<tr><td>'.$lang['L_SQL_TABLENOINDEXES'].'</td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<tr class="thead"><th>'.$lang['L_NAME'].'</th><th>'.$lang['L_TABLE_TYPE'].'</th></tr>';
|
||||
echo '<tr>';
|
||||
echo '<td><input type="text" name="indexName" value="" class="text">';
|
||||
echo '<td><select name="indexType"><option value="primary">'.$lang['L_TITLE_KEY_PRIMARY'].'</option><option value="unique">'.$lang['L_TITLE_KEY_UNIQUE'].'</option><option value="index" selected="selected">'.$lang['L_TITLE_INDEX'].'</option><option value="fulltext">'.$lang['L_TITLE_KEY_FULLTEXT'].'</option></select></td>';
|
||||
echo '</tr>';
|
||||
echo '</table><br>';
|
||||
|
||||
//alle Felder holen
|
||||
$feldArray=Array();
|
||||
echo '<table class="bdr">';
|
||||
echo '<tr class="thead"><th>#</th><th>'.$lang['L_PRIMARYKEY_FIELD'].'</th><th>'.$lang['L_INFO_SIZE'].'</th>';
|
||||
|
||||
while ($row=mysqli_fetch_array($res, MYSQLI_ASSOC))
|
||||
{
|
||||
$feldArray[$row['Field']]=$row['Type'];
|
||||
}
|
||||
//Primaerschluessel holen, um automatisch vorzuselektieren
|
||||
$primaryKeys=getPrimaryKeys($databases['Name'][$dbid],$_GET['tablename']);
|
||||
//eine Select-Box pro Feld anzeigen, Felder für Name und Typ nur in der ersten Zeile
|
||||
for ($i=0; $i<$num; $i++)
|
||||
{
|
||||
echo '<tr><td class="right">'.($i+1).'.</td><td>';
|
||||
$options ="\n\n".'<option value="">---</option>';
|
||||
$selectedFeldTyp = false;
|
||||
foreach ($feldArray as $feldName=>$feldTyp)
|
||||
{
|
||||
$options.="\n".'<option value="'.$feldName.'"';
|
||||
//alle Primaerschluessel vorselektieren
|
||||
if (isset($primaryKeys['name'][$i]) && $primaryKeys['name'][$i]==$feldName) {
|
||||
$options.=' selected="selected"';
|
||||
$selectedFeldTyp = $feldTyp;
|
||||
}
|
||||
$options.='>'.$feldName.' ['.$feldTyp.']</option>';
|
||||
}
|
||||
echo '<select id="setNewKey'.$i.'" name="setNewKey'.$i.'" onchange="toggleIndexLength('.$i.');">';
|
||||
echo $options."\n".'</select></td>';
|
||||
echo '<td>';
|
||||
$type =explode('(', $selectedFeldTyp);
|
||||
echo '<input type="text" id="indexSize'.$i.'" name="indexSize'.$i.'" value="" size="10" class="text"';
|
||||
if (!isset($type[0]) || !in_array($type[0], $mysql_string_types)) echo ' disabled="disabled"';
|
||||
echo '></td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
$i ++;
|
||||
}
|
||||
echo '</table>';
|
||||
//Speichern Knopf
|
||||
echo '<br><input name="setNewKeys" type="submit" value="'.$lang['L_SAVE'].'" class="Formbutton">';
|
||||
echo '</form>';
|
||||
}
|
||||
}
|
84
msd2/msd/inc/sqlbrowser/sqlbox.php
Normal file
84
msd2/msd/inc/sqlbrowser/sqlbox.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
MyOOS [Dumper]
|
||||
http://www.oos-shop.de/
|
||||
|
||||
Copyright (c) 2016 by the MyOOS Development Team.
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
|
||||
MySqlDumper
|
||||
http://www.mysqldumper.de
|
||||
|
||||
Copyright (C)2004-2011 Daniel Schlichtholz (admin@mysqldumper.de)
|
||||
----------------------------------------------------------------------
|
||||
Released under the GNU General Public License
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
if (!defined('MSD_VERSION')) die('No direct access.');
|
||||
//Start SQL-Box
|
||||
$tpl=new MSDTemplate();
|
||||
$tpl->set_filenames(array(
|
||||
'show' => $config['paths']['root'].'./tpl/sqlbrowser/sqlbox.tpl'));
|
||||
|
||||
if (isset($_GET['readfile'])&&$_GET['readfile']==1)
|
||||
{
|
||||
$tpl->assign_block_vars('SQLUPLOAD',array(
|
||||
|
||||
'POSTTARGET' => $params,
|
||||
'LANG_OPENSQLFILE' => $lang['L_SQL_OPENFILE'],
|
||||
'LANG_OPENSQLFILE_BUTTON' => $lang['L_SQL_OPENFILE_BUTTON'],
|
||||
'LANG_SQL_MAXSIZE' => $lang['L_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['L_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['L_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['L_SQL_BEFEHLE'],
|
||||
'TABLE_COMBOBOX' => Table_ComboBox(),
|
||||
'LANG_SQL_EXEC' => $lang['L_SQL_EXEC'],
|
||||
'LANG_RESET' => $lang['L_RESET'],
|
||||
'PARAMS' => $params,
|
||||
'DB' => $databases['Name'][$dbid],
|
||||
'DBID' => $dbid,
|
||||
'TABLENAME' => $tablename,
|
||||
'ICON_SEARCH' => $icon['search'],
|
||||
'ICON_UPLOAD' => $icon['upload'],
|
||||
'ICON_MYSQL_HELP' => $icon['mysql_help'],
|
||||
'MYSQL_HELP' => $lang['L_TITLE_MYSQL_HELP'],
|
||||
'DBID' => $databases['db_selected_index'],
|
||||
'LANG_TOOLBOX' => $lang['L_TOOLS_TOOLBOX'],
|
||||
'LANG_TOOLS' => $lang['L_TOOLS'],
|
||||
'LANG_DB' => $lang['L_DB'],
|
||||
'LANG_TABLE' => $lang['L_TABLE'],
|
||||
'LANG_SQL_TABLEVIEW' => $lang['L_SQL_TABLEVIEW'],
|
||||
'LANG_BACK_TO_DB_OVERVIEW' => $lang['L_SQL_BACKDBOVERVIEW']));
|
||||
if ($tablename>'') $tpl->assign_block_vars('TABLE_SELECTED',array());
|
||||
|
||||
$tpl->pparse('show');
|
Reference in New Issue
Block a user