-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.php
150 lines (116 loc) · 3.13 KB
/
test.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
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php
// Initialize Session.
require_once("../../class2.php");
if(!e107::isInstalled('visualcaptcha'))
{
e107::redirect();
exit;
}
@include(__DIR__ . '/vendor/autoload.php');
$form = e107::getForm();
$msg = e107::getMessage();
define('e_IFRAME', true);
require_once(HEADERF);
if(!empty($_POST['namespace']))
{
$invalid = e107::getSecureImg()->invalidCode(); // validateCaptcha();
if($invalid)
{
$msg->addError('Validation failed.');
}
else
{
$msg->addSuccess('Validation success.');
}
echo $msg->render();
}
echo $form->open('captcha_test_form', 'POST', e_SELF);
echo e107::getSecureImg()->renderInput(); // toCaptcha();
echo $form->submit('submit', 'Submit');
echo $form->close();
echo $form->open('captcha_test_form_2', 'POST', e_SELF);
echo e107::getSecureImg()->renderInput(); // toCaptcha();
echo $form->submit('submit', 'Submit');
echo $form->close();
require_once(FOOTERF);
exit;
/**
* @return string
*/
/*
function toCaptcha()
{
$form = e107::getForm();
$tp = e107::getParser();
if(e_DEBUG)
{
e107::library('load', 'visualcaptcha.jquery');
}
else
{
e107::library('load', 'visualcaptcha.jquery', 'minified');
}
$library = e107::library('info', 'visualcaptcha.jquery');
$captchaSettings = array(
'imgPath' => $tp->replaceConstants($library['library_path']) . 'img/',
'url' => e_PLUGIN_ABS . 'visualcaptcha/app.php',
'imgCount' => 5,
'language' => array(
'accessibilityAlt' => 'Sound icon',
'accessibilityTitle' => 'Accessibility option: listen to a question and answer it!',
'accessibilityDescription' => 'Type below the <strong>answer</strong> to what you hear. Numbers or words:',
'explanation' => 'Click or touch the <strong>ANSWER</strong>',
'refreshAlt' => 'Refresh/reload icon',
'refreshTitle' => 'Refresh/reload: get new images and accessibility option!',
)
);
e107::js('settings', array('visualcaptcha' => $captchaSettings));
e107::css('visualcaptcha', 'css/styles.css');
e107::js('visualcaptcha', 'js/visualcaptcha.init.js');
$element = '<div class="visual-captcha"></div>';
$element .= $form->hidden('rand_num', 'x'); // BC compat.
return $element;
}*/
/**
* @return bool
*/
/*
function validateCaptcha()
{
$captchaValid = false;
if(!empty($_POST['namespace']))
{
$session = new \visualCaptcha\Session('visualcaptcha_' . $_POST['namespace']);
}
else
{
$session = new \visualCaptcha\Session();
}
$captcha = new \visualCaptcha\Captcha($session);
$frontendData = $captcha->getFrontendData();
// If captcha is present, try to validate it.
if($frontendData)
{
// If an image field name was submitted, try to validate it.
if(($imageAnswer = $_POST[$frontendData['imageFieldName']]) && !empty($imageAnswer))
{
if($captcha->validateImage($imageAnswer))
{
$captchaValid = true;
}
}
else
{
if(($audioAnswer = $_POST[$frontendData['audioFieldName']]) && !empty($audioAnswer))
{
if($captcha->validateAudio($audioAnswer))
{
$captchaValid = true;
}
}
}
// Clear current session after captcha has been validated.
$session->clear();
}
return $captchaValid;
}*/