-
Notifications
You must be signed in to change notification settings - Fork 263
/
Copy pathBase64Controller.php
56 lines (47 loc) · 1.58 KB
/
Base64Controller.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/*
* This file is part of the GenemuFormBundle package.
*
* (c) Olivier Chauvel <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Genemu\Bundle\FormBundle\Controller;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
/**
* Class Base64Controller
*
* @author Olivier Chauvel <[email protected]>
*/
class Base64Controller implements ContainerAwareInterface
{
/**
* @var ContainerInterface
*/
protected $container;
/**
* {@inheritdoc}
*/
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}
public function refreshCaptchaAction()
{
$captcha = $this->container->get('genemu.gd.captcha');
$options = $this->container->get('session')->get('genemu_form.captcha.options', array());
$captcha->setOptions($options);
$datas = preg_split('([;,]{1})', substr($captcha->getBase64(), 5));
return new Response(base64_decode($datas[2]), 200, array('Content-Type' => $datas[0]));
}
public function base64Action(Request $request)
{
$query = $request->server->get('QUERY_STRING');
$datas = preg_split('([;,]{1})', $query);
return new Response(base64_decode($datas[2]), 200, array('Content-Type' => $datas[0]));
}
}