function do_export() { global $DB, $VERSION, $D, $BOM, $ex_isgz; $rt = str_replace('`', '', $_REQUEST['t']); $t = explode(",", $rt); $th = array_flip($t); $ct = count($t); $z = db_row("show variables like 'max_allowed_packet'"); $MAXI = floor($z['Value'] * 0.8); if (!$MAXI) { $MAXI = 838860; } $aext = ''; $ctp = ''; $ex_isgz = $_REQUEST['gz'] ? 1 : 0; if ($ex_isgz) { $aext = '.gz'; $ctp = 'application/x-gzip'; } ex_start(); if ($ct == 1 && $_REQUEST['et'] == 'csv') { ex_hdr($ctp ? $ctp : 'text/csv', "{$t['0']}.csv{$aext}"); if ($DB['chset'] == 'utf8') { ex_w($BOM); } $sth = db_query("select * from `{$t['0']}`"); $fn = mysql_num_fields($sth); for ($i = 0; $i < $fn; $i++) { $m = mysql_fetch_field($sth, $i); ex_w(qstr($m->name) . ($i < $fn - 1 ? "," : "")); } ex_w($D); while ($row = mysql_fetch_row($sth)) { ex_w(to_csv_row($row)); } ex_end(); exit; } ex_hdr($ctp ? $ctp : 'text/plain', "{$DB['db']}" . ($ct == 1 && $t[0] ? ".{$t['0']}" : ($ct > 1 ? '.' . $ct . 'tables' : '')) . ".sql{$aext}"); ex_w("-- phpMiniAdmin dump {$VERSION}{$D}-- Datetime: " . date('Y-m-d H:i:s') . "{$D}-- Host: {$DB['host']}{$D}-- Database: {$DB['db']}{$D}{$D}"); ex_w("/*!40030 SET NAMES {$DB['chset']} */;{$D}/*!40030 SET GLOBAL max_allowed_packet=16777216 */;{$D}{$D}"); $sth = db_query("show tables from `{$DB['db']}`"); while ($row = mysql_fetch_row($sth)) { if (!$rt || array_key_exists($row[0], $th)) { do_export_table($row[0], 1, $MAXI); } } ex_w("{$D}-- phpMiniAdmin dump end{$D}"); ex_end(); exit; }
function do_export() { global $DB, $VERSION; $rt = $_REQUEST['t']; $t = split(",", $rt); $th = array_flip($t); $ct = count($t); $z = db_array("show variables like 'max_allowed_packet'"); $MAXI = floor($z[0]['Value'] * 0.8); if (!$MAXI) { $MAXI = 838860; } if ($ct == 1 && $_REQUEST['et'] == 'csv') { header('Content-type: text/csv'); header("Content-Disposition: attachment; filename=\"{$t['0']}.csv\""); $csv_data = "First Name,Last Name,Email,ClickBank ID,Registered\n"; $sth = db_query("select * from `{$t['0']}`"); $fn = mysql_num_fields($sth); for ($i = 0; $i < $fn; $i++) { $m = mysql_fetch_field($sth, $i); echo qstr($m->name) . ($i < $fn - 1 ? "," : ""); } echo "\n"; while ($row = mysql_fetch_row($sth)) { echo to_csv_row($row); } exit; } header('Content-type: text/plain'); header("Content-Disposition: attachment; filename=\"{$DB['db']}" . ($ct == 1 && $t[0] ? ".{$t['0']}" : ($ct > 1 ? '.' . $ct . 'tables' : '')) . ".sql\""); echo "-- phpMiniAdmin dump {$VERSION}\n-- Datetime: " . date('Y-m-d H:i:s') . "\n-- Host: {$DB['host']}\n-- Database: {$DB['db']}\n\n/*!40030 SET max_allowed_packet={$MAXI} */;\n\n"; $sth = db_query("show tables from {$DB['db']}"); while ($row = mysql_fetch_row($sth)) { if (!$rt || array_key_exists($row[0], $th)) { do_export_table($row[0], 1, $MAXI); } } exit; }
function do_export(){ global $DB,$VERSION,$D,$BOM,$ex_isgz; $rt=str_replace('`','',$_REQUEST['t']); $t=explode(",",$rt); $th=array_flip($t); $ct=count($t); $z=db_row("show variables like 'max_allowed_packet'"); $MAXI=floor($z['Value']*0.8); if(!$MAXI)$MAXI=838860; $aext='';$ctp=''; $ex_super=($_REQUEST['sp'])?1:0; $ex_isgz=($_REQUEST['gz'])?1:0; if ($ex_isgz) { $aext='.gz';$ctp='application/x-gzip'; } ex_start(); if ($ct==1&&$_REQUEST['et']=='csv'){ ex_hdr($ctp?$ctp:'text/csv',"$t[0].csv$aext"); if ($DB['chset']=='utf8') ex_w($BOM); $sth=db_query("select * from `$t[0]`"); $fn=mysql_num_fields($sth); for($i=0;$i<$fn;$i++){ $m=mysql_fetch_field($sth,$i); ex_w(qstr($m->name).(($i<$fn-1)?",":"")); } ex_w($D); while($row=mysql_fetch_row($sth)) ex_w(to_csv_row($row)); ex_end(); exit; } ex_hdr($ctp?$ctp:'text/plain',"$DB[db]".(($ct==1&&$t[0])?".$t[0]":(($ct>1)?'.'.$ct.'tables':'')).".sql$aext"); ex_w("-- phpMiniAdmin dump $VERSION$D-- Datetime: ".date('Y-m-d H:i:s')."$D-- Host: $DB[host]$D-- Database: $DB[db]$D$D"); ex_w("/*!40030 SET NAMES $DB[chset] */;$D"); $ex_super && ex_w("/*!40030 SET GLOBAL max_allowed_packet=16777216 */;$D$D"); ex_w("/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;$D$D"); $sth=db_query("show tables from `$DB[db]`"); while($row=mysql_fetch_row($sth)){ if (!$rt||array_key_exists($row[0],$th)) do_export_table($row[0],1,$MAXI); } ex_w("/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;$D$D"); ex_w("$D-- phpMiniAdmin dump end$D"); ex_end(); exit; }