Created
May 14, 2015 04:32
-
-
Save basdog22/f20f0237093ed108567d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use \ReCaptcha\ReCaptcha; | |
class recaptchacheck{ | |
public function check(){ | |
$rec = requested('g-recaptcha-response'); | |
$secret = get_config_value('recaptcha_secret'); | |
if (isset($rec)){ | |
$recaptcha = new ReCaptcha($secret); | |
$resp = $recaptcha->verify($rec, $_SERVER['REMOTE_ADDR']); | |
if (!$resp->isSuccess()){ | |
return t('recaptcha::strings.captcha_wrong'); | |
} | |
} | |
} | |
} | |
register_plugin_route_filter('recaptchacheck@check'); | |
register_tpl_hook('form.closes.here','recaptcha::recaptcha'); | |
function recaptcha_install(){ | |
\Settings::create( | |
array( | |
'namespace' => 'cms', | |
'setting_name' => 'recapctha_sitekey', | |
'setting_value' => '0', | |
'autoload' => 1, | |
) | |
); | |
\Settings::create( | |
array( | |
'namespace' => 'cms', | |
'setting_name' => 'recaptcha_secret', | |
'setting_value' => '0', | |
'autoload' => 1, | |
) | |
); | |
} | |
function recaptcha_uninstall(){ | |
$setting = \Settings::whereNamespace('cms')->whereSettingName('recapctha_sitekey')->first(); | |
$setting->delete(); | |
$setting = \Settings::whereNamespace('cms')->whereSettingName('recaptcha_secret')->first(); | |
$setting->delete(); | |
} | |
register_plugin_install_handler('recaptcha','recaptcha_install'); | |
register_plugin_uninstall_handler('recaptcha','recaptcha_uninstall'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment