mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 17:21:39 +09:00
Remove reCAPTCHA addon
This commit is contained in:
parent
f2f6018b5f
commit
ced97f4f4d
6 changed files with 0 additions and 310 deletions
|
|
@ -1,131 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<addon version="0.2">
|
||||
<title xml:lang="ko">reCAPTCHA</title>
|
||||
<title xml:lang="en">reCAPTCHA</title>
|
||||
<description xml:lang="ko">구글 reCAPTCHA 서비스를 사용하여 자동 가입 스팸을 방지합니다.</description>
|
||||
<description xml:lang="en">Prevent automated signups and spam with Google's reCAPTCHA service.</description>
|
||||
<version>1.0.0</version>
|
||||
<date>2016-05-27</date>
|
||||
<author email_address="kijin@kijinsung.com" link="https://github.com/kijin">
|
||||
<name xml:lang="ko">Kijin Sung</name>
|
||||
<name xml:lang="en">Kijin Sung</name>
|
||||
</author>
|
||||
<extra_vars>
|
||||
<var name="site_key" type="text">
|
||||
<title xml:lang="ko">Site Key</title>
|
||||
<title xml:lang="en">Site Key</title>
|
||||
</var>
|
||||
<var name="secret_key" type="text">
|
||||
<title xml:lang="ko">Secret Key</title>
|
||||
<title xml:lang="en">Secret Key</title>
|
||||
</var>
|
||||
<var name="use_signup" type="select">
|
||||
<title xml:lang="ko">회원가입에 사용</title>
|
||||
<title xml:lang="en">Use on Signup Form</title>
|
||||
<options value="Y">
|
||||
<title xml:lang="ko">예</title>
|
||||
<title xml:lang="en">Yes</title>
|
||||
</options>
|
||||
<options value="N">
|
||||
<title xml:lang="ko">아니오</title>
|
||||
<title xml:lang="en">No</title>
|
||||
</options>
|
||||
</var>
|
||||
<var name="use_login" type="select">
|
||||
<title xml:lang="ko">로그인에 사용</title>
|
||||
<title xml:lang="en">Use on Login Form</title>
|
||||
<options value="Y">
|
||||
<title xml:lang="ko">예</title>
|
||||
<title xml:lang="en">Yes</title>
|
||||
</options>
|
||||
<options value="N">
|
||||
<title xml:lang="ko">아니오</title>
|
||||
<title xml:lang="en">No</title>
|
||||
</options>
|
||||
</var>
|
||||
<var name="use_recovery" type="select">
|
||||
<title xml:lang="ko">ID/PW찾기에 사용</title>
|
||||
<title xml:lang="en">Use on Account Recovery Form</title>
|
||||
<options value="Y">
|
||||
<title xml:lang="ko">예</title>
|
||||
<title xml:lang="en">Yes</title>
|
||||
</options>
|
||||
<options value="N">
|
||||
<title xml:lang="ko">아니오</title>
|
||||
<title xml:lang="en">No</title>
|
||||
</options>
|
||||
</var>
|
||||
<var name="use_document" type="select">
|
||||
<title xml:lang="ko">글쓰기에 사용</title>
|
||||
<title xml:lang="en">Use on New Document</title>
|
||||
<options value="N">
|
||||
<title xml:lang="ko">아니오</title>
|
||||
<title xml:lang="en">No</title>
|
||||
</options>
|
||||
<options value="Y">
|
||||
<title xml:lang="ko">예</title>
|
||||
<title xml:lang="en">Yes</title>
|
||||
</options>
|
||||
</var>
|
||||
<var name="use_comment" type="select">
|
||||
<title xml:lang="ko">댓글쓰기에 사용</title>
|
||||
<title xml:lang="en">Use on New Comment</title>
|
||||
<options value="N">
|
||||
<title xml:lang="ko">아니오</title>
|
||||
<title xml:lang="en">No</title>
|
||||
</options>
|
||||
<options value="Y">
|
||||
<title xml:lang="ko">예</title>
|
||||
<title xml:lang="en">Yes</title>
|
||||
</options>
|
||||
</var>
|
||||
<var name="target_users" type="select">
|
||||
<title xml:lang="ko">사용 대상</title>
|
||||
<title xml:lang="en">Target Users</title>
|
||||
<options value="non_members">
|
||||
<title xml:lang="ko">비회원만 사용</title>
|
||||
<title xml:lang="en">Non-members Only</title>
|
||||
</options>
|
||||
<options value="everyone">
|
||||
<title xml:lang="ko">모든 방문자에게 사용</title>
|
||||
<title xml:lang="en">Everyone</title>
|
||||
</options>
|
||||
</var>
|
||||
<var name="target_frequency" type="select">
|
||||
<title xml:lang="ko">사용 빈도</title>
|
||||
<title xml:lang="en">Target Frequency</title>
|
||||
<options value="every_time">
|
||||
<title xml:lang="ko">매번 사용</title>
|
||||
<title xml:lang="en">Every Time</title>
|
||||
</options>
|
||||
<options value="first_time_only">
|
||||
<title xml:lang="ko">방문자당 최초 1회만 사용</title>
|
||||
<title xml:lang="en">First Time Only</title>
|
||||
</options>
|
||||
</var>
|
||||
<var name="theme" type="select">
|
||||
<title xml:lang="ko">테마</title>
|
||||
<title xml:lang="en">Theme</title>
|
||||
<options value="light">
|
||||
<title xml:lang="ko">밝은 테마</title>
|
||||
<title xml:lang="en">Light</title>
|
||||
</options>
|
||||
<options value="dark">
|
||||
<title xml:lang="ko">어두운 테마</title>
|
||||
<title xml:lang="en">Dark</title>
|
||||
</options>
|
||||
</var>
|
||||
<var name="size" type="select">
|
||||
<title xml:lang="ko">크기</title>
|
||||
<title xml:lang="en">Size</title>
|
||||
<options value="normal">
|
||||
<title xml:lang="ko">보통</title>
|
||||
<title xml:lang="en">Normal</title>
|
||||
</options>
|
||||
<options value="compact">
|
||||
<title xml:lang="ko">작게</title>
|
||||
<title xml:lang="en">Compact</title>
|
||||
</options>
|
||||
</var>
|
||||
</extra_vars>
|
||||
</addon>
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
<?php
|
||||
$lang->msg_recaptcha_connection_error = 'An error occurred while connecting to the reCAPTCHA verification server.';
|
||||
$lang->msg_recaptcha_server_error = 'An error occurred while verifying your reCAPTCHA response.';
|
||||
$lang->msg_recaptcha_invalid_response = 'Please check reCAPTCHA.';
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
<?php
|
||||
$lang->msg_recaptcha_connection_error = 'reCAPTCHA 스팸방지 서버에 접속하는 도중 오류가 발생했습니다.';
|
||||
$lang->msg_recaptcha_server_error = 'reCAPTCHA 스팸방지 서버와 통신하는 도중 오류가 발생했습니다.';
|
||||
$lang->msg_recaptcha_invalid_response = 'reCAPTCHA 스팸방지 기능을 체크해 주십시오.';
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
<?php
|
||||
|
||||
if (!defined('RX_BASEDIR') || !$addon_info->site_key || !$addon_info->secret_key || $called_position !== 'before_module_init')
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$current_action = Context::get('act');
|
||||
$current_member = Context::get('logged_info');
|
||||
|
||||
if ($current_member->is_admin === 'Y')
|
||||
{
|
||||
$enable_captcha = false;
|
||||
}
|
||||
elseif ($addon_info->target_users !== 'everyone' && $current_member->member_srl)
|
||||
{
|
||||
$enable_captcha = false;
|
||||
}
|
||||
elseif ($addon_info->target_frequency !== 'every_time' && isset($_SESSION['recaptcha_authenticated']) && $_SESSION['recaptcha_authenticated'])
|
||||
{
|
||||
$enable_captcha = false;
|
||||
}
|
||||
elseif ($addon_info->use_signup === 'Y' && preg_match('/^(?:disp|proc)Member(?:SignUp|Insert)/i', $current_action))
|
||||
{
|
||||
$enable_captcha = true;
|
||||
}
|
||||
elseif ($addon_info->use_login === 'Y' && preg_match('/^(?:disp|proc)MemberLogin(?:Form)?/i', $current_action))
|
||||
{
|
||||
$enable_captcha = true;
|
||||
}
|
||||
elseif ($addon_info->use_recovery === 'Y' && preg_match('/^(?:disp|proc)Member(?:FindAccount|ResendAuthMail)/i', $current_action))
|
||||
{
|
||||
$enable_captcha = true;
|
||||
}
|
||||
elseif ($addon_info->use_document === 'Y' && preg_match('/^(?:disp|proc)Board(Write|InsertDocument)/i', $current_action))
|
||||
{
|
||||
$enable_captcha = true;
|
||||
}
|
||||
elseif ($addon_info->use_comment === 'Y' && (preg_match('/^(?:disp|proc)Board(Content|InsertComment)/i', $current_action) || (!$current_action && Context::get('document_srl'))))
|
||||
{
|
||||
$enable_captcha = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$enable_captcha = false;
|
||||
}
|
||||
|
||||
if ($enable_captcha)
|
||||
{
|
||||
include_once __DIR__ . '/recaptcha.class.php';
|
||||
reCAPTCHA::init($addon_info);
|
||||
|
||||
if (strncasecmp('proc', $current_action, 4) === 0)
|
||||
{
|
||||
getController('module')->addTriggerFunction('moduleObject.proc', 'before', 'reCAPTCHA::check');
|
||||
}
|
||||
else
|
||||
{
|
||||
Context::set('captcha', new reCAPTCHA());
|
||||
}
|
||||
}
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
<?php
|
||||
|
||||
class reCAPTCHA
|
||||
{
|
||||
protected static $verify = 'https://www.google.com/recaptcha/api/siteverify';
|
||||
protected static $config = null;
|
||||
protected static $scripts_added = false;
|
||||
protected static $instances_inserted = 0;
|
||||
protected static $sequence = 1;
|
||||
|
||||
public static function init($config)
|
||||
{
|
||||
self::$config = $config;
|
||||
}
|
||||
|
||||
public static function check()
|
||||
{
|
||||
$response = Context::get('g-recaptcha-response');
|
||||
if (!$response)
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('recaptcha.msg_recaptcha_invalid_response');
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$verify_request = \Requests::post(self::$verify, array(), array(
|
||||
'secret' => self::$config->secret_key,
|
||||
'response' => $response,
|
||||
'remoteip' => \RX_CLIENT_IP,
|
||||
));
|
||||
}
|
||||
catch (\Requests_Exception $e)
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('recaptcha.msg_recaptcha_connection_error');
|
||||
}
|
||||
|
||||
$verify = @json_decode($verify_request->body, true);
|
||||
if ($verify && isset($verify['error-codes']) && in_array('invalid-input-response', $verify['error-codes']))
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('recaptcha.msg_recaptcha_invalid_response');
|
||||
}
|
||||
elseif (!$verify || !$verify['success'] || (isset($verify['error-codes']) && $verify['error-codes']))
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('recaptcha.msg_recaptcha_server_error');
|
||||
}
|
||||
else
|
||||
{
|
||||
$_SESSION['recaptcha_authenticated'] = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
if (!self::$scripts_added)
|
||||
{
|
||||
self::$scripts_added = true;
|
||||
Context::loadFile(array('./addons/recaptcha/recaptcha.js', 'body'));
|
||||
Context::addHtmlFooter('<script src="https://www.google.com/recaptcha/api.js?render=explicit&onload=reCaptchaCallback" async defer></script>');
|
||||
$html = '<div id="recaptcha-config" data-sitekey="%s" data-theme="%s" data-size="%s"></div>';
|
||||
$html = sprintf($html, escape(self::$config->site_key), self::$config->theme ?: 'light', self::$config->size ?: 'normal');
|
||||
Context::addHtmlFooter($html);
|
||||
}
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return sprintf('<div id="recaptcha-instance-%d" class="g-recaptcha"></div>', self::$instances_inserted++);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
|
||||
function reCaptchaCallback() {
|
||||
var recaptcha_config = $("#recaptcha-config");
|
||||
var recaptcha_instances = $(".g-recaptcha");
|
||||
var recaptcha_instance_id = 1;
|
||||
|
||||
if (recaptcha_instances.size() === 0) {
|
||||
var autoinsert_candidates = $("form").filter(function() {
|
||||
var actinput = $("input[name='act']", this);
|
||||
if (actinput.size() && actinput.val() && actinput.val().match(/^proc.+(Insert(Document|Comment|)|Login|FindAccount|ResendAuthMail)/i)) {
|
||||
return true;
|
||||
}
|
||||
var procfilter = $(this).attr("onsubmit");
|
||||
if (procfilter && procfilter.match(/procFilter\b.+\binsert/i)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
autoinsert_candidates.each(function() {
|
||||
var new_instance = $('<div class="g-recaptcha"></div>');
|
||||
new_instance.attr("id", "recaptcha-instance-" + recaptcha_instance_id++);
|
||||
var autoinsert_point = $(this).find("button[type='submit'],input[type='submit']").parent();
|
||||
if (autoinsert_point.size()) {
|
||||
new_instance.insertBefore(autoinsert_point);
|
||||
} else {
|
||||
new_instance.appendTo($(this));
|
||||
}
|
||||
});
|
||||
var recaptcha_instances = $(".g-recaptcha");
|
||||
}
|
||||
|
||||
recaptcha_instances.each(function() {
|
||||
var instance = $(this);
|
||||
grecaptcha.render(instance.attr("id"), {
|
||||
sitekey: recaptcha_config.data("sitekey"),
|
||||
size: recaptcha_config.data("size"),
|
||||
theme: recaptcha_config.data("theme")
|
||||
});
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue