Esempio n. 1
0
function captcha_process()
{
    global $messages;
    if (captcha_go()) {
        $post_code = trim(optional_param('security_code'));
        if (empty($post_code)) {
            $messages[] = gettext('Please enter the verification code.');
            return true;
        } else {
            if (!is_human($post_code)) {
                $messages[] = gettext('Verification code incorrect. Please try again.');
                return true;
            }
        }
    }
    //$messages[] = gettext('Verification code passed.');
    return false;
}
 function spamfilter($comment = null)
 {
     global $vars, $defaultpage;
     // Through if GET (Check only POST)
     if ($_SERVER['REQUEST_METHOD'] === 'GET') {
         return;
     }
     // Through if POST is from akismet plugin (submitHam)
     if (isset($vars['cmd']) && $vars['cmd'] == 'akismet') {
         return;
     }
     // Through if in IGNORE list
     $cmd = isset($vars['cmd']) ? $vars['cmd'] : (isset($vars['plugin']) ? $vars['plugin'] : 'read');
     if (defined('PLUGIN_AKISMET_IGNORE_PLUGINS')) {
         if (in_array($cmd, explode(',', PLUGIN_AKISMET_IGNORE_PLUGINS))) {
             return;
         }
     }
     // Through if already known he is a human
     $use_authlevel = PLUGIN_AKISMET_THROUGH_IF_ENROLLEE ? ROLE_AUTH : (PLUGIN_AKISMET_THROUGH_IF_ADMIN ? ROLE_ADM_CONTENTS : 0);
     if (is_human(NULL, PLUGIN_AKISMET_USE_SESSION, $use_authlevel)) {
         return;
     }
     // Initialize $comment
     if (!isset($comment)) {
         // special case (now only supports edit plugin)
         if ($vars['cmd'] === 'edit' || $vars['plugin'] === 'edit') {
             $body = $vars['msg'];
         } else {
             $body = implode("\n", $vars);
         }
         $comment = array('author' => '', 'email' => '', 'website' => '', 'body' => $body, 'permalink' => '', 'user_ip' => $_SERVER['REMOTE_ADDR'], 'user_agent' => $_SERVER['HTTP_USER_AGENT']);
     }
     $is_spam = TRUE;
     if (PLUGIN_AKISMET_USE_AKISMET) {
         // Through if no body (Akismet recognizes as a spam if no body)
         if ($comment['body'] == '') {
             return;
         }
         // instantiate an instance of the class
         $akismet = new Akismet(get_script_uri(), PLUGIN_AKISMET_API_KEY, $comment);
         // test for errors
         if ($akismet->errorsExist()) {
             // returns TRUE if any errors exist
             if ($akismet->isError('AKISMET_INVALID_KEY')) {
                 die_message('akismet : APIキーが不正です.');
             } elseif ($akismet->isError('AKISMET_RESPONSE_FAILED')) {
                 //die_message('akismet : レスポンスの取得に失敗しました');
             } elseif ($akismet->isError('AKISMET_SERVER_NOT_FOUND')) {
                 //die_message('akismet : サーバへの接続に失敗しました.');
             }
             $is_spam = FALSE;
             // through if akismet.com is not available.
         } else {
             $is_spam = $akismet->isSpam();
         }
         if ($is_spam) {
             $detail = PLUGIN_AKISMET_SPAMLOG_DETAIL ? $comment : array();
             PluginAkismet::spamlog_write($vars, $detail, PLUGIN_AKISMET_SPAMLOG_FILENAME);
         }
     }
     if ($is_spam) {
         if (PLUGIN_AKISMET_RECAPTCHA_LOG) {
             PluginAkismet::spamlog_write($vars, array('body' => 'hit'), LOG_DIR . 'captchalog.txt');
         }
         $form = PluginAkismet::get_captcha_form($vars, $comment);
         // die_message('</strong>' . $form . '<strong>');
         $title = $page = 'キャプチャ認証';
         pkwk_common_headers();
         catbody($title, $page, $form);
         exit;
     }
 }