forked from robrotheram/phpbb_to_flarum
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathxenforo_connection.php
89 lines (74 loc) · 2.96 KB
/
xenforo_connection.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
<?php
// Autoload from Flarum
// Really should take more advantage of this
require '../vendor/autoload.php';
// include_once('formatter.php');
include_once 'xfscripts/XenForoBundle.php';
set_time_limit(0);
ini_set('memory_limit', -1);
ini_set('display_errors', 'On');
ini_set('error_reporting', 'E_ALL');
ini_set('log_errors', 1);
ini_set('error_log', 'php-error.log');
error_reporting(E_ALL & ~E_NOTICE);
class Database
{
//***********************************************/
// ✨ Change these variables ✨
//***********************************************/
protected $servername = 'localhost';
protected $username = '';
protected $password = '';
// Table migrating from (XenForo)
public $exportDBName = 'xenforo';
public $exportDBPrefix = 'xf_';
// Table migrating to (Flarum)
public $importDBName = 'flarum';
public $importDBPrefix = '';
public $adminUserID = 1;
//***********************************************/
public function __contruct($servername, $username, $password, $exportDBName, $exportDBPrefix, $importDBName, $importDBPrefix, $adminUserID)
{
$this->servername = $servername;
$this->username = $username;
$this->password = $password;
$this->exportDBName = $exportDBName;
$this->exportDBPrefix = $exportDBPrefix;
$this->importDBName = $importDBName;
$this->importDBPrefix = $importDBPrefix;
$this->adminUserID = $adminUserID;
}
public function connectExport()
{
$exportDbConnection = new mysqli($this->servername, $this->username, $this->password, $this->exportDBName);
if ($exportDbConnection->connect_error) {
die('Export - Connection failed: '.$exportDbConnection->connect_error);
} else {
echo "Export - Connected successfully<br>\n";
if (! $exportDbConnection->set_charset('utf8')) {
printf("Error loading character set utf8: %s<br>\n", $exportDbConnection->error);
exit();
} else {
printf("Current character set: %s<br>\n", $exportDbConnection->character_set_name());
}
}
return $exportDbConnection;
}
public function connectImport()
{
$importDbConnection = new mysqli($this->servername, $this->username, $this->password, $this->importDBName);
if ($importDbConnection->connect_error) {
die('Export - Connection failed: '.$importDbConnection->connect_error);
} else {
echo "Import - Connected successfully<br>\n";
if (! $importDbConnection->set_charset('utf8')) {
printf("Error loading character set utf8: %s<br>\n", $importDbConnection->error);
exit();
} else {
printf("Current character set: %s<br>\n", $importDbConnection->character_set_name());
}
}
$importDbConnection->query('SET FOREIGN_KEY_CHECKS=0');
return $importDbConnection;
}
}