source: trunk/www.guidonia.net/wp/wp-content/themes/atahualpa/options/export.php@ 44

Last change on this file since 44 was 44, checked in by luciano, 14 years ago
File size: 1.3 KB
Line 
1<?php
2// Find wp-load.php so we can access the database from within our non-standard, external file here
3$d = 0; // search depth;
4while (!file_exists(str_repeat('../', $d) . 'wp-load.php')) if (++$d > 99) exit;
5$wp_load = str_repeat('../', $d) . 'wp-load.php';
6require_once($wp_load);
7
8global $wpdb;
9
10// get all option names and options values from the WP Options table where the option name starts with "bfa_ata_"
11$atahualpa_options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options WHERE option_name REGEXP '^bfa_ata_'");
12
13// output the header
14$filename = 'atahualpa.options.' . str_replace("http://","",get_option('siteurl')) . "." . date('Y-m-d') . '.xml';
15header('Content-Description: File Transfer');
16header("Content-Disposition: attachment; filename=$filename");
17header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
18
19// output the file
20echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?' . ">\n";
21
22echo "<atahualpa_options>\n";
23// Loop through the database query that we got earlier
24foreach ($atahualpa_options as $atahualpa_option) {
25 echo "<" . $atahualpa_option->option_name . ">\n";
26 echo htmlspecialchars($atahualpa_option->option_value);
27 echo "\n</" . $atahualpa_option->option_name . ">\n";
28 }
29echo"</atahualpa_options>\n";
30?>
Note: See TracBrowser for help on using the repository browser.