0
我正在使用本教程開展與我的項目的reCaptcha集成。但是,我應該在第四步做什麼,我無法完全理解,並寫在下面?reCaptcha集成:模型還是函數?
將下面的函數添加到您的MY_Validation類中,如下面的庫文件夾所示。 (如果您還沒有一個MY_Validation類,做一個。)
的代碼是這樣的教程第四步下。
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
類MY_Validation擴展CI_Validation {
function MY_Validation()
{
parent::CI_Validation();
}
function recaptcha_matches()
{
$CI =& get_instance();
$CI->config->load('recaptcha');
$public_key = $CI->config->item('recaptcha_public_key');
$private_key = $CI->config->item('recaptcha_private_key');
$response_field = $CI->input->post('recaptcha_response_field');
$challenge_field = $CI->input->post('recaptcha_challenge_field');
$response = recaptcha_check_answer($private_key,
$_SERVER['REMOTE_ADDR'],
$challenge_field,
$response_field);
if ($response->is_valid)
{
return TRUE;
}
else
{
$CI->validation->recaptcha_error = $response->error;
$CI->validation->set_message('recaptcha_matches', 'The %s is incorrect. Please try again.');
return FALSE;
}
}
}
你能幫我什麼問題呢?教程鏈接如下。
教程鏈接:https://ellislab.com/forums/viewthread/94299/
你之後告訴我鏈接被破壞了,我知道了。對於鏈接抱歉。順便謝謝你的建議。我會檢查那個圖書館。你看起來很簡單。 – Baris 2015-02-11 08:11:34