forked from genemu/GenemuFormBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBase64Controller.php
41 lines (34 loc) · 1.24 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
<?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\ContainerAware;
use Symfony\Component\HttpFoundation\Response;
/**
* Class Base64Controller
*
* @author Olivier Chauvel <[email protected]>
*/
class Base64Controller extends ContainerAware
{
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()
{
$query = $this->container->get('request')->server->get('QUERY_STRING');
$datas = preg_split('([;,]{1})', $query);
return new Response(base64_decode($datas[2]), 200, array('Content-Type' => $datas[0]));
}
}