/
exporter-vanilla.php
101 lines (89 loc) · 2.52 KB
/
exporter-vanilla.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
/**
* Includes necessary files.
*/
function export_init ()
{
if (!class_exists ('BBXP'))
{
require_once ('exporter/bbxp.php');
require_once ('exporter/bbxp-vanilla.php');
require_once ('backpress/bpdb.php');
require_once ('backpress/functions.core.php');
}
}
/**
* Executes all necessary functions to make the exportation happen.
*/
function export_main ()
{
export_init ();
$user = $_POST['user'];
$password = $_POST['password'];
$database = $_POST['database'];
$host = $_POST['host'];
$prefix = $_POST['prefix'];
$bbxp = new BBXP_Vanilla;
$bbxp->db = new BPDB (array ('name' => $database, 'user' => $user, 'password' => $password, 'host' => $host));
$bbxp->initialize_db ($prefix);
$filename = 'phpbb' . date ('Y-m-d') . '.xml';
$bbxp->write_header ($filename);
$bbxp->write_users ();
$bbxp->write_forums ();
$bbxp->write_topics ();
$bbxp->write_footer ();
die ();
}
/**
* Displays the admin export page.
*
* Gives a simple explanation of how the export file works and gives
* users a nice shiny button to click.
*/
function export_page ()
{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 STRICT//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Vanilla BBXF Exporter</title>
</head>
<body>
<h2>Export</h2>
<p>When you submit the form below, Vanilla will generate a BBXF file for you to save to your computer.</p>
<p>This file will contain data about your users, forums, topics, and posts. You can use the Import function of another Vanilla installation or another compatible web forums software to import this data.</p>
<form action="" method="post">
<fieldset><legend>MySQL Hostname</legend>
<input type="text" name="host" />
</fieldset>
<fieldset><legend>MySQL Database</legend>
<input type="text" name="database" />
</fieldset>
<fieldset><legend>MySQL Username</legend>
<input type="text" name="user" />
</fieldset>
<fieldset><legend>MySQL Password</legend>
<input type="password" name="password" />
</fieldset>
<fieldset><legend>MySQL Table Prefix</legend>
<input type="text" name="prefix" />
</fieldset>
<p class="submit">
<input type="submit" name="submit" value="Download Export File" />
<input type="hidden" name="exporting" value="true" />
</p>
</form>
</body>
</html>
<?php
}
if ('true' == $_POST['exporting'] )
{
export_main ();
}
else
{
export_page ();
}
?>