1
|
|
|
<?php |
2
|
|
|
namespace Tartana\Component\Decrypter; |
3
|
|
|
|
4
|
|
|
use GuzzleHttp\Client; |
5
|
|
|
use GuzzleHttp\ClientInterface; |
6
|
|
|
use Monolog\Logger; |
7
|
|
|
|
8
|
|
|
class Dlc extends BaseDecrypter |
9
|
|
|
{ |
10
|
|
|
|
11
|
|
|
private $client = null; |
12
|
|
|
|
13
|
6 |
|
public function __construct(ClientInterface $client = null) |
14
|
|
|
{ |
15
|
6 |
|
if (!$client) { |
16
|
1 |
|
$client = new Client( |
17
|
|
|
[ |
18
|
|
|
'headers' => [ |
19
|
|
|
'Accept' => 'application/json, text/javascript, */*', |
20
|
|
|
'Content-Type' => 'application/x-www-form-urlencoded', |
21
|
|
|
'Host' => 'dcrypt.it', |
22
|
|
|
'Origin' => 'http://dcrypt.it', |
23
|
|
|
'Referer' => 'http://dcrypt.it/', |
24
|
|
|
'X-Requested-With' => 'XMLHttpRequest', |
25
|
|
|
'Connection' => 'keep-alive', |
26
|
|
|
'User-Agent' => 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.39 Safari/537.36' |
27
|
|
|
] |
28
|
1 |
|
] |
29
|
|
|
); |
30
|
|
|
} |
31
|
6 |
|
$this->client = $client; |
32
|
6 |
|
} |
33
|
|
|
|
34
|
4 |
|
public function getLinks($content) |
35
|
|
|
{ |
36
|
4 |
|
$this->log('Calling http://dcrypt.it/decrypt/paste', Logger::INFO); |
37
|
4 |
|
$res = $this->client->request('post', 'http://dcrypt.it/decrypt/paste', [ |
38
|
|
|
'form_params' => [ |
39
|
4 |
|
'content' => $content |
40
|
|
|
] |
41
|
|
|
]); |
42
|
|
|
|
43
|
4 |
|
$decRes = json_decode($res->getBody()->getContents()); |
44
|
4 |
|
$this->log('Response from http://dcrypt.it/decrypt/paste was: ' . print_r($decRes, true)); |
45
|
|
|
|
46
|
4 |
|
if (is_object($decRes) && isset($decRes->success) && is_array($decRes->success->links)) { |
47
|
2 |
|
$links = $decRes->success->links; |
48
|
2 |
|
$links = array_filter($links, function ($link) { |
49
|
2 |
|
return strpos($link, 'http') === 0; |
50
|
2 |
|
}); |
51
|
|
|
|
52
|
2 |
|
$this->log('Found ' . count($links), Logger::INFO); |
53
|
|
|
|
54
|
2 |
|
return $links; |
55
|
|
|
} else { |
56
|
2 |
|
throw new \RuntimeException('Failed parsing response: ' . var_export($decRes, true)); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|