●主機作業系統:Linux
●快速架站程式:
●免費空間連結:
●您的上網方式:
●您安裝的程式:Apache + php + MySql
●您的 phpBB 版本:phpBB 3.05
●您的 domain (網域名稱) : intranet
●您的 phpBB 連結網址:
##### 以上為 '基本的發問格式' #####
●安裝外掛:以問答方式防止廣告機器人侵入
我在下面網址看到有人寫出一個 php 的網頁, 來做"以問答方式防止廣告機器人侵入"
http://www.ezdiy.org/forum/viewtopic.php?id=384
因為很單純, 也很有效, 比起圖形與在使用者的欄位內自設"如果你不是機器人, 請輸入一個介於 ?? 到 ?? 的數目字" 的問答有效.
代碼: 選擇全部
<?php
/*
作者: coolhd @ http://www.ezdiy.org
功能: 以問答的方式來防止 SpamBot 訊息侵入
版本: v1.1
*/
$question = array();
/*****問題與答案編輯區*********************************************************************/
/* $question[N][0] = '題目'; */
/* $question[N][1] = '答案1'; */
/* $question[N][2] = '答案2'; */
$question[0][0] = '請問 5 加 3 等於多少 ?';
$question[0][1] = '8';
$question[0][2] = 'eight';
$question[1][0] = '請問在英文單字 Free 裡面有幾個英文字母 e ?';
$question[1][1] = '2';
$question[1][2] = 'two';
$question[2][0] = 'x 加上 6 等於 9, 那麼請問 x 應該是多少 ?';
$question[2][1] = '3';
$question[2][2] = 'three';
$question[3][0] = '請問 25 減去 10 等於多少 ?';
$question[3][1] = '15';
$question[4][0] = '請問本站的網址是什麼(不包含 http://) ?';
$question[4][1] = 'www';
$question[5][0] = '請寫出 BLUE 這個英文單字的小寫。';
$question[5][1] = 'blue';
/*************************************************************************************/
session_start();
//顯示驗證欄位
function human_check_field() {
global $pun_user, $question;
$human_check_field = '';
if ($pun_user['is_guest']) {
$_SESSION['human_id'] = session_id();
$question_index = rand(0,count($question)-1);
$ask_question = $question[$question_index][0];
$answer_counts = count($question[$question_index]);
$question_answers = array();
for($i=1; $i < $answer_counts; $i++) {
$question_answers[] = $question[$question_index][$i];
}
$_SESSION['question_answers'] = $question_answers;
$human_check_field = '
<div class="inform">
<fieldset>
<legend>驗證</legend>
<div class="infldset">
請您回答底下問題。<br /><br />
問題: <strong>'.$ask_question.'</strong><br />
答案: <input type="text" size="30" maxlength="100" name="human_check_answer" value="" />
</div>
</fieldset>
</div>';
}
echo $human_check_field;
}
//執行驗證檢查
function human_check() {
global $question;
if (!isset($_SESSION['human_id'])) {
message('請正確地完成欄位填寫 !');
}
if (isset($_POST['human_check_answer'])) {
$human_check_answer = strip_tags(trim($_POST['human_check_answer']));
} else {
$human_check_answer = null;
}
$human_check_pass = (in_array($human_check_answer, $_SESSION['question_answers'])) ? true : false;
if ($human_check_pass == false) {
message('您輸入的驗證答案錯誤 !');
}
unset($_SESSION['human_id']);
unset($_SESSION['question_answers']);
}
?>


