-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVisualCaptchaController.php
More file actions
95 lines (87 loc) · 1.97 KB
/
VisualCaptchaController.php
File metadata and controls
95 lines (87 loc) · 1.97 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
/**
* VisualCaptcha Controller
*
* @author Noriko Arai <arai@nii.ac.jp>
* @author Allcreator <info@allcreator.net>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
* @copyright Copyright 2014, NetCommons Project
*/
App::uses('AppController', 'Controller');
/**
* VisualCaptchaController
*
* @author Allcreator <info@allcreator.net>
* @package NetCommons\VisualCaptcha\Controller
*/
class VisualCaptchaController extends VisualCaptchaAppController {
/**
* use components
*
* @var array
*/
public $components = array(
'Pages.PageLayout',
'VisualCaptcha.VisualCaptcha' => array(
'operationType' => 'none',
),
);
/**
* beforeFilter
*
* @return void
*/
public function beforeFilter() {
parent::beforeFilter();
$this->Auth->allow('captcha', 'captcha_image', 'captcha_audio');
}
/**
* view method
* Display the VisualCaptcha auto redirect screen
*
* @return void
*/
public function view() {
if ($this->request->is('post')) {
if ($this->VisualCaptcha->check()) {
// リダイレクト先はセッションクリアか
return $this->redirect($this->VisualCaptcha->getReturnUrl());
}
}
$this->request->data['Frame'] = Current::read('Frame');
$this->request->data['Block'] = Current::read('Block');
}
/**
* captcha
* return to Client captcha data
*
* @return string
*/
public function captcha() {
$this->autoRender = false;
// もしも表示数を変えたいときは引数に数値を設定
echo $this->VisualCaptcha->generate();
}
/**
* captcha_image
* return to Client captcha data
*
* @param int $index captcha image number
* @return string
*/
public function captcha_image($index) {
$this->autoRender = false;
return $this->VisualCaptcha->image($index);
}
/**
* captcha_audio
* return to Client captcha audio data
*
* @return string
*/
public function captcha_audio() {
$this->autoRender = false;
echo $this->VisualCaptcha->audio();
}
}