-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathe_module.php
More file actions
114 lines (90 loc) · 2.64 KB
/
e_module.php
File metadata and controls
114 lines (90 loc) · 2.64 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2012 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* User signup
*
* $URL: https://e107.svn.sourceforge.net/svnroot/e107/trunk/e107_0.8/signup.php $
* $Id: signup.php 12780 2012-06-02 14:36:22Z secretr $
*
*/
$recaptchaActive = e107::pref('recaptcha', 'active');
$recaptchaSiteKey = e107::pref('recaptcha', 'sitekey');
$recaptchaSecretKey = e107::pref('recaptcha', 'secretkey');
if($recaptchaActive)
{
class e107recaptcha
{
public function __construct()
{
e107::lan('recaptcha', false, true);
}
static function blank()
{
return ;
}
static function input()
{
//$text = '<div class="g-recaptcha" data-sitekey="'.e107::pref('recaptcha', 'sitekey').'" ></div> ';
$text = '<div class="g-recaptcha" ></div> ';
return $text;
}
static function hiddeninput()
{
$frm = e107::getForm();
$element = '<div class="g-recaptcha" ></div> ';
$element .= $frm->hidden("rand_num", 'google' );
return $element;
}
static function verify($code, $other)
{
if ( ! function_exists( 'recaptcha_get_html' ) )
require_once e_PLUGIN.'recaptcha/inc/recaptchalib.php';
// your secret key
$secret = e107::pref('recaptcha', 'secretkey');
// empty response
$response = null;
// check secret key
$reCaptcha = new ReCaptcha($secret);
// if submitted check response
if ($_POST["g-recaptcha-response"]) {
$response = $reCaptcha->verifyResponse(
$_SERVER["REMOTE_ADDR"],
$_POST["g-recaptcha-response"]
);
}
if ($response != null && $response->success) {
return true;
} else {
return false;
}
}
// Return an Error message (true) if check fails, otherwise return false.
/**
* @param $rec_num
* @param $checkstr
* @return bool|mixed|string
*/
function invalidinvalid($code, $other)
{
if(self::verify($rec_num,$checkstr))
{
return false;
}
else
{
return 'You did not pass robot test';
}
}
}
/* remove original captcha */
e107::getOverride()->replace('secure_image::r_image', 'e107recaptcha::blank');
e107::getOverride()->replace('secure_image::renderInput', 'e107recaptcha::hiddeninput');
e107::getOverride()->replace('secure_image::invalidCode', 'e107recaptcha::invalid');
e107::getOverride()->replace('secure_image::renderLabel', 'e107recaptcha::blank');
e107::getOverride()->replace('secure_image::verify_code', 'e107recaptcha::verify');
}