// exit;
// }
+ function dumpDatabase()
+ {
+ $roo = HTML_FlexyFramework::get()->page;
+
+ $dsn = HTML_FlexyFramework::get()->database;
+ print_r($dsn);exit;
+ $database = explode('@', $dsn);
+
+ $ui = str_replace('mysql://', '', $database[0]);
+
+ $user = array_shift(explode(':', $ui));
+ $pw = array_pop(explode(':', $ui));
+
+ $host = array_shift(explode('/', $database[1]));
+ $dn = array_pop(explode('/', $database[1]));
+
+ $cmd = "mysqldump -u{$user} ";
+ if(!empty($pw)){
+ $cmd .= "-p{$pw} ";
+ }
+
+ $cmd .= "--no-create-info summit {$tn}";
+
+ require_once 'System.php';
+
+ $tmpdir = System::mktemp("-d dump");
+
+ $path = $tmpdir . '/' . $tn . '.sql';
+
+ ob_start();
+
+ passthru($cmd);
+
+ $data = ob_get_contents();
+
+ ob_end_clean();
+
+ file_put_contents($path, $data);
+
+ header('Content-Description: File Transfer');
+ header ('Content-Type: application/octet-stream');
+ header("Content-Disposition: attachment; filename=\"".basename($path)."\";" );
+ header("Expires: 0");
+ header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
+ header("Pragma: public");
+ header('Content-Length: ' . filesize($path));
+
+ @ob_clean();
+ flush();
+ readfile($path);
+
+ exit;
+ }
+
}