0byt3m1n1
Path:
/
data
/
51
/
2
/
82
/
137
/
2408789.shuffle
/
user
/
2641263
/
htdocs
/
contest
/
uploads
/
[
Home
]
File: db-export.php
<?php require('../../wp-load.php'); if (is_user_logged_in() && current_user_can('publish_pages')) { function download_send_headers($filename) { header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header("Content-Disposition: attachment;filename={$filename}"); header("Content-Transfer-Encoding: binary"); } function array2csv(array &$array) { if (count($array) == 0) { return null; } ob_start(); $df = fopen("php://output", 'w'); fputcsv($df, array_keys(reset($array))); foreach ($array as $row) { fputcsv($df, $row); } fclose($df); return ob_get_clean(); } $db_dump = $wpdb->get_results(' SELECT * FROM ub_contest ', ARRAY_A); download_send_headers("contest_export_" . date('Y-m-d_His') . ".csv"); echo array2csv($db_dump); } else { get_header(); ?> <article> <p>This tool is available only to logged-in site administrators.</p> <?php wp_login_form(); ?> </article> <?php get_footer(); } ?>