Created
February 7, 2019 08:54
-
-
Save 2nd-player/c5ae086f5f215b1c6d9819ab7fb3afef to your computer and use it in GitHub Desktop.
reCaptcha plugin for PyukiWiki
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
####################################################################### | |
# recaptcha.inc.pl - This is PyukiWiki, yet another Wiki clone. | |
# | |
# "PyukiWiki" ver 0.2.0-p3+ Modified by 2P@ポケモンWiki | |
# Author: Nanami http://nanakochi.daiba.cx/ | |
# Copyright (C) 2004-2012 Nekyo | |
# http://nekyo.qp.land.to/ | |
# Copyright (C) 2005-2012 PyukiWiki Developers Team | |
# http://pyukiwiki.sfjp.jp/ | |
# Based on YukiWiki http://www.hyuki.com/yukiwiki/ | |
# Powered by PukiWiki http://pukiwiki.sfjp.jp/ | |
# License: GPL3 and/or Artistic or each later version | |
# | |
# This program is free software; you can redistribute it and/or | |
# modify it under the same terms as Perl itself. | |
# Return:LF Code=UTF-8 1TAB=4Spaces | |
###################################################################### | |
use Net::SSLeay qw(get_https); | |
use strict; | |
$recaptcha::secret = "YOUR SECRET KEY"; | |
$recaptcha::public = "YOUR PUBLIC KEY"; | |
$recaptcha::check = undef; | |
sub plugin_recaptcha_init { | |
return; | |
} | |
sub plugin_recaptcha_edit { | |
$::IN_HEAD.=qq(<script src='https://www.google.com/recaptcha/api.js'></script>\n); | |
return '<div class="g-recaptcha" data-sitekey="' . $recaptcha::public . '"></div>'; | |
} | |
sub plugin_recaptcha_check { | |
my $recaptcha_res; | |
if ($recaptcha_res = $::form{'g-recaptcha-response'}){ | |
($recaptcha_res) = get_https('www.google.com', 443, "/recaptcha/api/siteverify?secret=${recaptcha::secret}&response=$recaptcha_res"); | |
} | |
unless($recaptcha_res =~ /success/){ | |
$recaptcha::check = 'ng'; | |
return "Captcha Failed"; | |
}else{ | |
$recaptcha::check = 'ok'; | |
} | |
return; | |
} | |
1; | |
__END__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment