Completed
Push — master ( 48abf8...8f7739 )
by C
13:50
created

Rsdf::getLinks()   C

Complexity

Conditions 8
Paths 24

Size

Total Lines 43
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 22
CRAP Score 8

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 43
ccs 22
cts 22
cp 1
rs 5.3846
cc 8
eloc 22
nc 24
nop 1
crap 8
1
<?php
2
namespace Tartana\Component\Decrypter;
3
4
class Rsdf extends BaseDecrypter
5
{
6
7 5
	public function getLinks ($content)
8
	{
9 5
		$key = pack('H*', "8C35192D964DC3182C6F84F3252239EB4A320D2500000000");
10 5
		$iv = pack('H*', "a3d5a33cb95ac1f5cbdb1ad25cb0a7aa");
11 5
		$cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CFB, '');
12 5
		mcrypt_generic_init($cipher, $key, $iv);
13
14 5
		$content = @pack('H*', $content);
15
16 5
		$links = [];
17 5
		if (stripos($content, "\xDA") !== false)
18
		{
19 1
			$links = explode("\xDA", $content);
20
		}
21 4
		else if (stripos($content, "\n") !== false)
22
		{
23 3
			$links = explode("\n", $content);
24
		}
25
26 5
		$urls = [];
27 5
		foreach ($links as $link)
28
		{
29 4
			if (empty($link))
30
			{
31 4
				continue;
32
			}
33
34 4
			$text = @mdecrypt_generic($cipher, base64_decode($link));
35 4
			if (empty($text))
36
			{
37 1
				continue;
38
			}
39
40 3
			$urls[] = $text;
41
		}
42
43 5
		if (empty($urls) && error_get_last())
44
		{
45 2
			throw new \RuntimeException(error_get_last()['message']);
46
		}
47
48 3
		return $urls;
49
	}
50
}