SQL
Search
Export
Import
";
if(!empty($_POST['table_sel']))echo "
Browse
Insert";
echo " \n".(isset($message)?$message:'');}
if(isset($_POST['push']) && !empty($_POST['querysql']))$_POST['go']=4;
if(isset($_POST['back']))$_POST['go']=2;
if(isset($_POST['brow']))$_POST['go']=4;
if(isset($_POST['editr']) && isset($_POST['edit']))$_POST['go']=6;// EDIT
if(isset($_POST['ed_save']))$_POST['go']=7;//INSERT
if(isset($_POST['search']))$_POST['go']=8;
if(isset($_POST['up']) && (!empty($_POST['load']) || !empty($_POST['upload'])))$_POST['go']=9;
elseif(isset($_POST['up']))$_POST['go']=3;
if((isset($_POST['dell']) && isset($_POST['edit']))|| isset($_POST['delp']))$_POST['go']=10;
if(!isset($_POST['go']) && !empty($_POST['table_sel']))$_POST['go']=4;
if(isset($_POST['go'])){
switch($_POST['go']){
case 0:
//SQL
echo "
\n";
break;
case 1:
echo "
";
break;
case 3:
//IMPORT
echo "Load file:
Local file:
Text".(function_exists('gzencode')?' Gzip':'').(function_exists('bzcompress')?' Bzip2':'')."
";
break;
case 4:
//BROWSE
if(!empty($_POST['table_sel']) || isset($_POST['querysql']))select();
//+++++++++++++++++++++++++++++++++++BROWSE _ END ++++++++++++++++++++++++++++++
break;
case 2:
//EXPORT
if(!isset($_POST['back'])){
echo '
';
if(isset($nt)){
echo '
';
}
echo ' ';
}
if(isset($_POST['back']) && $_POST['save']==0)echo "";
break;
case 5:
//INSERT IN TABLE
if(!empty($_POST['table_sel'])){
echo " ";
}
break;
case 6:
//EDIT
if($_POST['table_sel']===$_POST['table_sel2']){
$up_e=$_POST['edit'];
echo " ";
$up_e=urldecode($_POST['edit']);
echo " ";
}
else select();
break;
case 7:
//INSERT/UPDATE
$ted='';
reset($_POST);
while(list($key,$val)=each($_POST)){
if(preg_match('/^ed_key:(.+)/',$key,$m)){
$ted.="`".$m[1]."`= '".addslashes($val)."', ";
}}
$ted=substr($ted,0,-2);
$query=((isset($_POST['insert']))?"INSERT":"UPDATE")." `".$_POST['table_sel']."` SET $ted ".((isset($_POST['insert']))?'':"WHERE ".urldecode($_POST['edit'])." LIMIT 1 ");
echo "".htmlspecialchars($query,ENT_QUOTES)."
";
$result=mysql_query($query,$connect) or print("".mysql_error($connect)."
");
echo "".mysql_info($connect)."
";
break;
case 8:
//SEARCH;
print "";
$j=0;
function spdb($line){
global $connect,$j,$sql;
$fields=mysql_list_fields($_POST['db'], $line, $connect );
$columns=mysql_num_fields($fields);
for($i=0;$i<$columns;$i++){
$nomField=mysql_field_name($fields,$i);
$sql="SELECT ".$nomField." FROM ".$line." WHERE ".$nomField.' '.$_POST['opts'].(!preg_match('/NULL/',$_POST['opts'])?" ".(!preg_match('/[><]/',$_POST['opts'])?"'":'').addslashes($_POST['seart']).(!preg_match('/[><]/',$_POST['opts'])?"'":''):'').(!empty($_POST['limits'])?' LIMIT '.$_POST['limits']:'');
$query=mysql_query($sql) or print(mysql_error($connect));
if(mysql_num_rows($query)>0){
while($result=mysql_fetch_array($query)){
echo "Table:
".$line." Field:
".$nomField." SQL:
".htmlspecialchars($sql)." ".htmlspecialchars($result[0])."
";
echo "
";
$j++;
}}}}
if($_POST['locas']==0){
$tables=mysql_list_tables($_POST['db']);
while($line=mysql_fetch_row($tables)){
spdb($line[0]);
}}
else{
spdb($_POST['table_sel']);
}
echo "
Results: ".$j.'
';
break;
case 9:
if(is_uploaded_file($_FILES['upload']['tmp_name'])) {
$data=load($_FILES['upload']['tmp_name']);
}
elseif(!empty($_POST['load'])){
$data=load($_POST['load']);
}
if(isset($data)){
$arrup=explode(';',$data);
if(preg_match('/^[ \n\r]?$/',$arrup[count($arrup)-1]))array_splice($arrup,-1);
foreach($arrup as $aup){
mysql_query($aup,$connect) or $err=1;
}
print(isset($err)?mysql_error($connect):'Query susceful!');
}
break;
case 10:
//DELETE
if(!isset($_POST['table_sel2']) || $_POST['table_sel']===$_POST['table_sel2']){
$code='DELETE FROM `'.$_POST['table_sel'].'` WHERE '.urldecode($_POST['edit']).' LIMIT 1';
isset($_POST['delp'])?mysql_query($code):print("".htmlspecialchars($code).'
');
}
else select();
break;
}}
echo "