1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @name OpenImporter |
4
|
|
|
* @copyright OpenImporter contributors |
5
|
|
|
* @license BSD http://opensource.org/licenses/BSD-3-Clause |
6
|
|
|
* |
7
|
|
|
* @version 1.0 Alpha |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class mybb18 |
12
|
|
|
* Settings for the MyBB 1.8 system. |
13
|
|
|
*/ |
14
|
|
|
class mybb18 extends Importers\AbstractSourceImporter |
15
|
|
|
{ |
16
|
|
|
protected $setting_file = '/inc/config.php'; |
17
|
|
|
|
18
|
|
|
public function getName() |
19
|
|
|
{ |
20
|
|
|
return 'MyBB 1.8'; |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
public function getVersion() |
24
|
|
|
{ |
25
|
|
|
return 'ElkArte 1.0'; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function getPrefix() |
29
|
|
|
{ |
30
|
|
|
global $config; |
31
|
|
|
|
32
|
|
|
return '`' . $this->getDbName() . '`.' . $config['database']['table_prefix']; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function getDbName() |
36
|
|
|
{ |
37
|
|
|
global $config; |
38
|
|
|
|
39
|
|
|
return $config['database']['database']; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function getTableTest() |
43
|
|
|
{ |
44
|
|
|
return 'users'; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Copy attachment files |
49
|
|
|
* |
50
|
|
|
* @param string g$dir |
51
|
|
|
* @param array $row |
52
|
|
|
* @param int $id_attach |
53
|
|
|
* @param string $destination_path |
54
|
|
|
* @param bool $thumb |
55
|
|
|
* |
56
|
|
|
* @return array |
57
|
|
|
*/ |
58
|
|
|
public function mybb_copy_files($dir, $row, $id_attach, $destination_path, $thumb = false) |
59
|
|
|
{ |
60
|
|
|
// Some extra details |
61
|
|
|
list($ext, $basename, $mime_type) = attachment_type($row['filename']); |
62
|
|
|
|
63
|
|
|
// Prepare for the copy |
64
|
|
|
$file = $thumb ? $row['thumbnail'] : $row['attachname']; |
65
|
|
|
$source = $dir . '/' . $file; |
66
|
|
|
$file_hash = createAttachmentFileHash($file); |
67
|
|
|
$destination = $destination_path . '/' . $id_attach . '_' . $file_hash . '.elk'; |
68
|
|
|
$width = 0; |
69
|
|
|
$height = 0; |
70
|
|
|
$type = 0; |
71
|
|
|
|
72
|
|
|
// Copy it over |
73
|
|
|
copy_file($source, $destination); |
74
|
|
|
|
75
|
|
|
// If its an image, then make sure it has legit width/height |
76
|
|
|
if (!empty($ext)) |
77
|
|
|
{ |
78
|
|
|
list ($width, $height) = getimagesize($destination); |
79
|
|
|
if (empty($width)) |
80
|
|
|
{ |
81
|
|
|
$width = 0; |
82
|
|
|
$height = 0; |
83
|
|
|
} |
84
|
|
|
else |
85
|
|
|
{ |
86
|
|
|
$type = ($thumb) ? 3 : 0; |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
// Prepare our insert |
91
|
|
|
return array( |
92
|
|
|
'id_attach' => $id_attach, |
93
|
|
|
'id_thumb' => !$thumb && !empty($row['thumbnail']) ? ++$id_attach : 0, |
94
|
|
|
'size' => file_exists($destination) ? filesize($destination) : 0, |
95
|
|
|
'filename' => $basename . '.' . ($thumb ? $ext . '_thumb' : $ext), |
96
|
|
|
'file_hash' => $file_hash, |
97
|
|
|
'file_ext' => $ext, |
98
|
|
|
'mime_type' => $mime_type, |
99
|
|
|
'attachment_type' => $type, |
100
|
|
|
'id_msg' => $row['id_msg'], |
101
|
|
|
'downloads' => $row['downloads'], |
102
|
|
|
'width' => $width, |
103
|
|
|
'height' => $height, |
104
|
|
|
); |
105
|
|
|
} |
106
|
|
|
} |