phpBB3::getVersion()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
/**
3
 * @name      OpenImporter
4
 * @copyright OpenImporter contributors
5
 * @license   BSD https://opensource.org/licenses/BSD-3-Clause
6
 *
7
 * @version 1.0
8
 */
9
10
/**
11
 * Class phpBB3
12
 */
13
class phpBB3 extends Importers\AbstractSourceImporter
14
{
15
	protected $setting_file = '/config.php';
16
17
	public function getName()
18
	{
19
		return 'phpBB3';
20
	}
21
22
	public function getVersion()
23
	{
24
		return 'Wedge 0.1';
25
	}
26
27
	public function setDefines()
28
	{
29
		if (!defined('IN_PHPBB'))
30
		{
31
			define('IN_PHPBB', 1);
32
		}
33
	}
34
35
	public function getPrefix()
36
	{
37
		global $table_prefix;
38
39
		return '`' . $this->getDbName() . '`.' . $table_prefix;
40
	}
41
42
	public function getDbName()
43
	{
44
		global $dbname;
45
46
		return $dbname;
47
	}
48
49
	public function getTableTest()
50
	{
51
		return 'users';
52
	}
53
}
54
55
// Utility functions specific to phpbb
56
57
/**
58
 * @param int $percent
59
 *
60
 * @return int
61
 */
62
function percent_to_px($percent)
63
{
64
	return intval(11 * (intval($percent) / 100.0));
65
}
66
67
/**
68
 * Normalize BBC
69
 *
70
 * @param string $message
71
 *
72
 * @return mixed|string
73
 */
74
function phpbb_replace_bbc($message)
75
{
76
	$message = preg_replace(
77
		array(
78
			'~\[quote=&quot;(.+?)&quot;\:(.+?)\]~is',
79
			'~\[quote\:(.+?)\]~is',
80
			'~\[/quote\:(.+?)\]~is',
81
			'~\[b\:(.+?)\]~is',
82
			'~\[/b\:(.+?)\]~is',
83
			'~\[i\:(.+?)\]~is',
84
			'~\[/i\:(.+?)\]~is',
85
			'~\[u\:(.+?)\]~is',
86
			'~\[/u\:(.+?)\]~is',
87
			'~\[url\:(.+?)\]~is',
88
			'~\[/url\:(.+?)\]~is',
89
			'~\[url=(.+?)\:(.+?)\]~is',
90
			'~\[/url\:(.+?)\]~is',
91
			'~\<a(.+?) href="(.+?)">(.+?)</a>~is',
92
			'~\[img\:(.+?)\]~is',
93
			'~\[/img\:(.+?)\]~is',
94
			'~\[size=(.+?)\:(.+?)\]~is',
95
			'~\[/size\:(.+?)?\]~is',
96
			'~\[color=(.+?)\:(.+?)\]~is',
97
			'~\[/color\:(.+?)\]~is',
98
			'~\[code=(.+?)\:(.+?)\]~is',
99
			'~\[code\:(.+?)\]~is',
100
			'~\[/code\:(.+?)\]~is',
101
			'~\[list=(.+?)\:(.+?)\]~is',
102
			'~\[list\:(.+?)\]~is',
103
			'~\[/list\:(.+?)\]~is',
104
			'~\[\*\:(.+?)\]~is',
105
			'~\[/\*\:(.+?)\]~is',
106
			'~\<img src=\"{SMILIES_PATH}/(.+?)\" alt=\"(.+?)\" title=\"(.+?)\" /\>~is',
107
		),
108
		array(
109
			'[quote author="$1"]',
110
			'[quote]',
111
			'[/quote]',
112
			'[b]',
113
			'[/b]',
114
			'[i]',
115
			'[/i]',
116
			'[u]',
117
			'[/u]',
118
			'[url]',
119
			'[/url]',
120
			'[url=$1]',
121
			'[/url]',
122
			'[url=$2]$3[/url]',
123
			'[img]',
124
			'[/img]',
125
			'[size=' . percent_to_px("\1") . 'px]',
0 ignored issues
show
Bug introduced by
'' of type string is incompatible with the type integer expected by parameter $percent of percent_to_px(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

125
			'[size=' . percent_to_px(/** @scrutinizer ignore-type */ "\1") . 'px]',
Loading history...
126
			'[/size]',
127
			'[color=$1]',
128
			'[/color]',
129
			'[code=$1]',
130
			'[code]',
131
			'[/code]',
132
			'[list type=$1]',
133
			'[list]',
134
			'[/list]',
135
			'[li]',
136
			'[/li]',
137
			'$2',
138
		), $message);
139
140
	$message = preg_replace('~\[size=(.+?)px\]~is', "[size=" . ('\1' > '99' ? 99 : '"\1"') . "px]", $message);
141
142
	$message = strtr($message, array(
143
		'[list type=1]' => '[list type=decimal]',
144
		'[list type=a]' => '[list type=lower-alpha]',
145
	));
146
147
	return stripslashes($message);
148
}