1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @name OpenImporter |
4
|
|
|
* @copyright OpenImporter contributors |
5
|
|
|
* @license BSD https://opensource.org/licenses/BSD-3-Clause |
6
|
|
|
* |
7
|
|
|
* @version 2.0 Alpha |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
class SeoBoards1_1 extends Importers\AbstractSourceImporter |
11
|
|
|
{ |
12
|
|
|
protected $setting_file = '/seo-board_options.php'; |
13
|
|
|
protected $child_level = 0; |
14
|
|
|
|
15
|
|
|
public function getName() |
16
|
|
|
{ |
17
|
|
|
return 'SEO-Boards 1.1'; |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
public function getVersion() |
21
|
|
|
{ |
22
|
|
|
return '1.0'; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function dbConnectionData() |
26
|
|
|
{ |
27
|
|
|
if ($this->path === null) |
28
|
|
|
return false; |
29
|
|
|
|
30
|
|
|
return array( |
31
|
|
|
'dbname' => $this->fetchSetting('dbname'), |
32
|
|
|
'user' => $this->fetchSetting('dbuser'), |
33
|
|
|
'password' => $this->fetchSetting('dbpass'), |
34
|
|
|
'host' => $this->fetchSetting('dbhost'), |
35
|
|
|
'driver' => 'pdo_mysql', // As far as I can tell IPB is MySQL only |
36
|
|
|
'test_table' => $this->getTableTest(), |
37
|
|
|
'system_name' => $this->getname(), |
38
|
|
|
); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function getDbPrefix() |
42
|
|
|
{ |
43
|
|
|
return $this->fetchSetting('dbpref'); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function getDbName() |
47
|
|
|
{ |
48
|
|
|
return $this->fetchSetting('dbname'); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
protected function getTableTest() |
52
|
|
|
{ |
53
|
|
|
return '{dbPrefix}users'; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function fetchSetting($name) |
57
|
|
|
{ |
58
|
|
|
$content = $this->readSettingsFile(); |
|
|
|
|
59
|
|
|
|
60
|
|
|
$match = array(); |
61
|
|
|
preg_match('~\$' . $name . '\s*=\s*\'(.*?)\';~', $content, $match); |
62
|
|
|
|
63
|
|
|
return isset($match[1]) ? $match[1] : ''; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* $shaprefix is necessary in order to perform the login. |
68
|
|
|
* Because passwords are stored in the db as: |
69
|
|
|
* sha1($shaprefix . $pass) |
70
|
|
|
*/ |
71
|
|
|
public function codeSettings() |
72
|
|
|
{ |
73
|
|
|
$rows = array(array( |
74
|
|
|
'variable' => 'shaprefix', |
75
|
|
|
'value' => $this->fetchSetting('shaprefix'), |
76
|
|
|
)); |
77
|
|
|
|
78
|
|
|
return $rows; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* From here on, all the methods are needed helper for the conversion |
83
|
|
|
*/ |
84
|
|
|
public function preparseMembers($originalRows) |
85
|
|
|
{ |
86
|
|
|
$rows = array(); |
87
|
|
|
|
88
|
|
|
foreach ($originalRows as $row) |
89
|
|
|
{ |
90
|
|
|
if (!empty($row['user_banned'])) |
91
|
|
|
$row['is_activated'] = 11; |
92
|
|
|
$row['date_registered'] = date('Y-m-d G:i:s', $row['date_registered']); |
93
|
|
|
|
94
|
|
|
unset($row['user_banned']); |
95
|
|
|
|
96
|
|
|
$rows[] = $row; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
return $rows; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
public function preparseBoards($originalRows) |
103
|
|
|
{ |
104
|
|
|
$rows = array(); |
105
|
|
|
|
106
|
|
|
foreach ($originalRows as $row) |
107
|
|
|
{ |
108
|
|
|
$row['id_cat'] = $this->getRootForum($row['id_board']); |
109
|
|
|
$row['child_level'] = $this->child_level; |
110
|
|
|
|
111
|
|
|
$this->child_level = 0; |
112
|
|
|
$rows[] = $row; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
return $rows; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
protected function getRootForum($id) |
119
|
|
|
{ |
120
|
|
|
$request = $this->db->query(" |
121
|
|
|
SELECT forum_parent |
122
|
|
|
FROM {$this->config->from_prefix}forums |
123
|
|
|
WHERE forum_id = $id"); |
124
|
|
|
list ($parent) = $this->db->fetch_row($request); |
125
|
|
|
$this->db->free_result($request); |
126
|
|
|
|
127
|
|
|
if ($parent == 0) |
128
|
|
|
{ |
129
|
|
|
$this->child_level--; |
130
|
|
|
return $id; |
131
|
|
|
} |
132
|
|
|
else |
133
|
|
|
{ |
134
|
|
|
$this->child_level++; |
135
|
|
|
return $this->getRootForum($parent); |
136
|
|
|
} |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
public function preparseMessages($originalRows) |
140
|
|
|
{ |
141
|
|
|
$rows = array(); |
142
|
|
|
|
143
|
|
|
foreach ($originalRows as $row) |
144
|
|
|
{ |
145
|
|
|
$row['smileys_enabled'] = (((int) $row['post_text_status']) & 4) != 0 ? 1 : 0; |
146
|
|
|
unset($row['post_text_status']); |
147
|
|
|
|
148
|
|
|
$rows[] = $row; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
return $rows; |
152
|
|
|
} |
153
|
|
|
} |
154
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.