1
|
|
|
<?php |
2
|
|
|
namespace Tartana\Controller; |
3
|
|
|
|
4
|
|
|
use League\Flysystem\Adapter\Local; |
5
|
|
|
use League\Flysystem\Config; |
6
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
7
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
8
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
9
|
|
|
use Symfony\Component\HttpFoundation\Request; |
10
|
|
|
use Tartana\Util; |
11
|
|
|
|
12
|
|
|
class ClicknLoadController extends Controller |
13
|
|
|
{ |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @Route("/flash/addcrypted2", name="clicknload") |
17
|
|
|
*/ |
18
|
2 |
|
public function addcrypted2Action(Request $request) |
19
|
|
|
{ |
20
|
|
|
$data = array( |
21
|
2 |
|
'success' => false, |
22
|
2 |
|
'message' => $this->get('Translator')->trans('TARTANA_CLICKNLOAD_ERROR_ADDING_TO_QUEUE') |
23
|
|
|
); |
24
|
|
|
|
25
|
2 |
|
preg_match('/\'(.*?)\'/', $request->get('jk'), $matches); |
26
|
|
|
|
27
|
2 |
|
if (count($matches) < 1) { |
28
|
|
|
return; |
29
|
|
|
} |
30
|
|
|
|
31
|
2 |
|
$key = hex2bin($matches[1]); |
32
|
|
|
|
33
|
2 |
|
$cp = @mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', 'cbc', ''); |
34
|
2 |
|
@mcrypt_generic_init($cp, $key, $key); |
|
|
|
|
35
|
2 |
|
$dec = @mdecrypt_generic($cp, base64_decode($request->get('crypted'))); |
36
|
2 |
|
@mcrypt_generic_deinit($cp); |
|
|
|
|
37
|
2 |
|
@mcrypt_module_close($cp); |
|
|
|
|
38
|
|
|
|
39
|
2 |
|
$folder = $this->container->getParameter('tartana.config')['links']['folder']; |
40
|
2 |
|
$folder = Util::realPath($folder); |
41
|
|
|
|
42
|
2 |
|
if (!empty($folder)) { |
43
|
2 |
|
$fs = new Local($folder); |
44
|
|
|
|
45
|
2 |
|
$name = $request->get('package', rand(0, 1000)) . '.txt'; |
46
|
|
|
|
47
|
|
|
// Sanitize content |
48
|
2 |
|
$content = ''; |
49
|
2 |
|
foreach (preg_split('/\r\n|\r|\n/', $dec) as $file) { |
50
|
2 |
|
if (strpos($file, 'http://') !== 0) { |
51
|
1 |
|
continue; |
52
|
|
|
} |
53
|
|
|
|
54
|
1 |
|
$content .= $file . PHP_EOL; |
55
|
|
|
} |
56
|
|
|
|
57
|
2 |
|
$content = trim($content); |
58
|
|
|
|
59
|
2 |
|
if ($content) { |
60
|
1 |
|
$fs->write($name, $content, new Config()); |
61
|
|
|
|
62
|
|
|
$data = array( |
63
|
1 |
|
'success' => true, |
64
|
1 |
|
'message' => $this->get('Translator')->trans('TARTANA_CLICKNLOAD_CONTENT_ADDED_TO_QUEUE') |
65
|
|
|
); |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
69
|
2 |
|
return new JsonResponse($data); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
If you suppress an error, we recommend checking for the error condition explicitly: