$antispam_send_spam_comment_to_admin, 'allow_trackbacks' => $antispam_allow_trackbacks, 'admin_email' => get_option('admin_email'), 'log_spam_comment' => $antispam_log_spam_comment ); include('anti-spam-functions.php'); include('anti-spam-info.php'); function antispam_enqueue_script() { if (is_singular() && comments_open()) { // load script only for pages with comments form wp_enqueue_script('anti-spam-script', plugins_url('/js/anti-spam-4.3.js', __FILE__), null, null, true); } } add_action('wp_enqueue_scripts', 'antispam_enqueue_script'); function antispam_form_part() { global $antispam_settings; $rn = "\r\n"; // .chr(13).chr(10) if ( ! is_user_logged_in()) { // add anti-spam fields only for not logged in users echo '
'.$rn; // question (hidden with js) echo ' '.$rn; // empty field (hidden with css); trap for spammers because many bots will try to put email or url here } } add_action('comment_form', 'antispam_form_part'); // add anti-spam inputs to the comment form function antispam_check_comment($commentdata) { global $antispam_settings; $rn = "\r\n"; // .chr(13).chr(10) extract($commentdata); $antispam_pre_error_message = '
Go back and try again.
'; $antispam_error_message = ''; if (($antispam_settings['send_spam_comment_to_admin']) || ($antispam_settings['log_spam_comment'])) { // if sending email to admin is enabled or loging $post = get_post($comment->comment_post_ID); $antispam_message_spam_info = 'Spam for post: "'.$post->post_title.'"' . $rn; $antispam_message_spam_info .= get_permalink($comment->comment_post_ID) . $rn.$rn; $antispam_message_spam_info .= 'IP: ' . $_SERVER['REMOTE_ADDR'] . $rn; $antispam_message_spam_info .= 'User agent: ' . $_SERVER['HTTP_USER_AGENT'] . $rn; $antispam_message_spam_info .= 'Referer: ' . $_SERVER['HTTP_REFERER'] . $rn.$rn; $antispam_message_spam_info .= 'Comment data:'.$rn; // lets see what comment data spammers try to submit foreach ($commentdata as $key => $value) { $antispam_message_spam_info .= '$commentdata['.$key. '] = '.$value.$rn; } $antispam_message_spam_info .= $rn.$rn; $antispam_message_spam_info .= 'Post vars:'.$rn; // lets see what post vars spammers try to submit foreach ($_POST as $key => $value) { $antispam_message_spam_info .= '$_POST['.$key. '] = '.$value.$rn; } $antispam_message_spam_info .= $rn.$rn; $antispam_message_spam_info .= 'Cookie vars:'.$rn; // lets see what cookie vars spammers try to submit foreach ($_COOKIE as $key => $value) { $antispam_message_spam_info .= '$_COOKIE['.$key. '] = '.$value.$rn; } $antispam_message_spam_info .= $rn.$rn; $antispam_message_append = '-----------------------------'.$rn; $antispam_message_append .= 'This is spam comment rejected by Anti-spam plugin - wordpress.org/plugins/anti-spam/' . $rn; $antispam_message_append .= 'You may edit "anti-spam.php" file and disable this notification.' . $rn; $antispam_message_append .= 'You should find "$antispam_send_spam_comment_to_admin" and make it equal to "false".' . $rn; } if ( ! is_user_logged_in() && $comment_type != 'pingback' && $comment_type != 'trackback') { // logged in user is not a spammer $spam_flag = false; $antspm_q = ''; if (isset($_POST['antspm-q'])) { $antspm_q = trim($_POST['antspm-q']); } $antspm_d = ''; if (isset($_POST['antspm-d'])) { $antspm_d = trim($_POST['antspm-d']); } $antspm_e = ''; if (isset($_POST['antspm-e-email-url-website'])) { $antspm_e = trim($_POST['antspm-e-email-url-website']); } if ( $antspm_q != date('Y') ) { // year-answer is wrong - it is spam if ( $antspm_d != date('Y') ) { // extra js-only check: there is no js added input - it is spam $spam_flag = true; if (empty($antspm_q)) { // empty answer - it is spam $antispam_error_message .= 'Error: empty answer. ['.esc_attr( $antspm_q ).']