データベースにデータを挿入するためのフォームを作成し、データが人間から送信されたかどうかを確認するために、すでに CI に統合されている CAPTCHA を使用しました。
これは私のコントローラーです:
$checkrules = array(
'img_path' => realpath(APPPATH . '../upload/checking/img') . '/',
'img_url' => base_url() . 'upload/checking/img/',
'font_path' => realpath(APPPATH . '../upload/checking/font.ttf'),
'img_width' => 150,
'img_height' => 30,
'expiration' => 7200
);
$check = create_captcha($checkrules);
$data['checkimg'] = $check['image'];
$this->form_validation->set_rules('name', 'Name', 'required|max_length[40]|xss_clean');
$this->form_validation->set_rules('email', 'E-mail', 'required|valid_email|xss_clean');
$this->form_validation->set_rules('website', 'Website', 'max_length[80]|prep_url|xss_clean');
$this->form_validation->set_rules('comment', 'Comment', 'required|xss_clean');
$this->form_validation->set_rules('check', 'Check', 'required|xss_clean');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('cms/theme', $data);
}
else
{
echo "success";
$this->load->view('cms/theme', $data);
}
私の質問は、CAPTCHA を検証する最良の方法は何ですか?
1.) コールバックを作成しましたが、フォームを送信すると新しい CAPTCHA コードでエラーが発生するため、問題が発生しました。
2.) CAPTCHA のコードをデータベースに挿入し、そこからチェックします。問題は、データベースのロードが多くなり、非常にビジーになるためです。
そして2問目。この CAPTCHA はフォルダに .jpg 画像のみを保存していますか、それとも他の形式である可能性がありますか? (使用後にこのキャプチャを削除したいので、これを求めています。)