-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.xml
76 lines (71 loc) · 2.86 KB
/
install.xml
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
<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
<id>motokochan:recaptchaforsmf</id>
<name>Visual Verification Options</name>
<file name="$sourcedir/ManageSettings.php">
<operation>
<search position="before"><![CDATA[
array('desc', 'configure_verification_means_desc'),
]]></search>
<add><![CDATA[
array('check', 'recaptcha_enabled', 'subtext' => $txt['recaptcha_enable_desc']),
]]></add>
</operation>
<operation>
<search position="after"><![CDATA[
// Clever Thomas, who is looking sheepy now? Not I, the mighty sword swinger did say.
]]></search>
<add><![CDATA[
// reCAPTCHA
array('title', 'recaptcha_configure'),
array('desc', 'recaptcha_configure_desc', 'class' => 'windowbg'),
array('text', 'recaptcha_public_key'),
array('text', 'recaptcha_private_key'),
array('select', 'recaptcha_theme', array('light' => $txt['recaptcha_theme_light'],
'dark' => $txt['recaptcha_theme_dark'], )),
]]></add>
</operation>
</file>
<file name="$sourcedir/Subs-Editor.php">
<operation>
<search position="after"><![CDATA[
);
$thisVerification = &$context['controls']['verification'][$verificationOptions['id']];
]]></search>
<add><![CDATA[
'use_recaptcha' => !empty($modSettings['recaptcha_enabled']),
]]></add>
</operation>
<operation>
<search position="replace"><![CDATA[
if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']))
]]></search>
<add><![CDATA[
if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['use_recaptcha']))
]]></add>
</operation>
<operation>
<search position="before"><![CDATA[
if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'])))
fatal_lang_error('no_access', false);
]]></search>
<add><![CDATA[
//reCAPTCHA Verification
if(!empty($modSettings['recaptcha_enabled']) && ($modSettings['recaptcha_enabled'] == 1 && !empty($modSettings['recaptcha_public_key']) && !empty($modSettings['recaptcha_private_key'])))
{
$recaptcha = new \ReCaptcha\ReCaptcha($modSettings['recaptcha_private_key']);
// Was there a reCAPTCHA response?
if(isset($_REQUEST["g-recaptcha-response"]))
{
$resp = $recaptcha->verify($_REQUEST["g-recaptcha-response"], $_SERVER["REMOTE_ADDR"]);
if (!$resp->isSuccess())
$verification_errors[] = 'wrong_verification_code';
}
else
$verification_errors[] = 'need_verification_code';
}
]]></add>
</operation>
</file>
</modification>