Dump WordPress MySQL Database and Download

<?php // HACKY MYSQL DUMP UTILITY FOR WORDPRESS BY @ijasonwhite
unlink(__FILE__); //STIL MANUALLY CHECK M'KAY include_once('wp-config.php'); 
$file = sys_get_temp_dir() . ("/".uniqid().".mysql_dump_file"); //outside of public_html in tmp
$exec = "mysqldump --user=".DB_USER." --password=".DB_PASSWORD." --host=".DB_HOST." ".DB_NAME." > ".$file;
exec($exec);
if (file_exists($file)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename="'.basename($file).'"');
    header('Expires: 0');
    header('Cache-Control: must-revalidate');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    readfile($file);
	unlink($file);
    exit;
} else { 
	
	echo 'error 0x000000001';
	exit;
}


© Jason White 2019 | Privacy Policy | CV | Life Hacks

made with