デフォルトでインストールされているConfirmEdit の QuestyCaptchaを利用して設定。
require_once( "$IP/extensions/ConfirmEdit/ConfirmEdit.php" ); require_once( "$IP/extensions/ConfirmEdit/QuestyCaptcha.php"); $wgCaptchaClass = 'QuestyCaptcha'; $rand = array(rand(1,9),rand(1,9),rand(1,9),rand(1,9)); $cnt = 0; foreach($rand as $i){ if($i == 1 ){ $rand_[$cnt] = "一"; }elseif($i == 2 ){ $rand_[$cnt] = "二"; }elseif($i == 3 ){ $rand_[$cnt] = "三"; }elseif($i == 4 ){ $rand_[$cnt] = "四"; }elseif($i == 5 ){ $rand_[$cnt] = "五"; }elseif($i == 6 ){ $rand_[$cnt] = "六"; }elseif($i == 7 ){ $rand_[$cnt] = "七"; }elseif($i == 8 ){ $rand_[$cnt] = "八"; }elseif($i == 9 ){ $rand_[$cnt] = "九"; } $cnt = $cnt+1; } $wordarr = array ( "四ケタの数字を半角英数字で入力してください→" . $rand_[0] . $rand_[1] . $rand_[2] . $rand_[3] => $rand[0] . $rand[1] . $rand[2] . $rand[3] , ); foreach ( $wordarr as $key => $value ) { $wgCaptchaQuestions[] = array( 'question' => $key, 'answer' => $value ); } $wgCaptchaTriggers['edit'] = true; $wgCaptchaTriggers['create'] = true; $wgCaptchaTriggers['addurl'] = true; $wgCaptchaTriggers['createaccount'] = true; $wgCaptchaTriggers['badlogin'] = true;
参考にしたページ
https://pasero.net/~mako/blog/s/623