■掲示板に戻る■ 全部 1- 101- 201- 301- 401- 501- 601- 701- 801- 最新50 [PR]ぜろちゃんねるプラス[PR]  

ぜろちゃんねるプラス質問スレ 2

733 :名無しさん@ぜろちゃんねるプラス:2021/11/16(火) 12:40:51.83 ID:CeE2lGh80
>>728です
reCaptchaを実装しようとbbs.cgiを弄ってみてどうしても不具合が出るのでここに記載します
質問の仕方が悪いかもしれませんが、何か分かれば教えていただけると幸いです


以下bbs.cgiのスクリプト


#以下追加分

use CGI;
use LWP::UserAgent;
use JSON::Parse 'parse_json';

# CGIの実行結果を終了コードとする
exit(captcha());


sub captcha
{

my $secret_key = 'Googleキャプチャのシークレットキー';
my $url = 'https://www.google.com/recaptcha/api/siteverify';

my $cgi = CGI->new();
my $ua = LWP::UserAgent->new();
my $recaptcha_response = $cgi->param('g-recaptcha-response');
my $remote_ip = $ENV{REMOTE_ADDR};
my $response = $ua->post(
$url,
{
remoteip => $remote_ip,
response => $recaptcha_response,
secret => $secret_key,
},
);
if ( $response->is_success() ) {
my $json = $response->decoded_content();
my $out = parse_json($json);
if ( $out->{success} ) {

&BBSCGI;

#確認用
print "Content-Type: text/html; charset=Shift_JIS\n\n";
print "認証ができています\n"

}else{
print "Content-Type: text/html; charset=Shift_JIS\n\n";
print("認証ができていません!");
}
}

}

#以上で追加分終わり

277KB
続きを読む

名前: E-mail(省略可)
READ.CGI - 0ch+ BBS 0.7.5 20220323
ぜろちゃんねるプラス