Advertisement
MikeInMass

contact form plugin antispam diff

Apr 15th, 2013
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 21.69 KB | None | 0 0
  1. *** contact_form.php-orig   2013-04-09 02:22:38.000000000 -0500
  2. --- contact_form.php    2013-04-15 22:51:38.000000000 -0500
  3. ***************
  4. *** 142,152 ****
  5. --- 142,155 ----
  6.             'cntctfrm_mail_method' => 'wp-mail',
  7.             'cntctfrm_display_coming_from' => 1,
  8.             'cntctfrm_display_user_agent' => 1,
  9. +           'cntctfrm_display_honeypot_field' => 0,
  10. +           'cntctfrm_use_akismet' => 1,
  11.             'cntctfrm_language' => array(),
  12.             'cntctfrm_change_label' => 0,
  13.             'cntctfrm_name_label' => array( 'en' => __( "Name:", 'contact_form' ) ),
  14.             'cntctfrm_email_label' => array( 'en' => __( "Email Address:", 'contact_form' ) ),
  15.             'cntctfrm_phone_label' => array( 'en' => __( "Phone number:", 'contact_form' ) ),
  16. +           'cntctfrm_honeypot_label' => array( 'en' => __( "Please leave this field blank.", 'contact_form' ) ),
  17.             'cntctfrm_subject_label' => array( 'en' => __( "Subject:", 'contact_form' ) ),
  18.             'cntctfrm_message_label' => array( 'en' => __( "Message:", 'contact_form' ) ),
  19.             'cntctfrm_attachment_label' => array( 'en' => __( "Attachment:", 'contact_form' ) ),
  20. ***************
  21. *** 172,177 ****
  22. --- 175,181 ----
  23.             $cntctfrm_options['cntctfrm_name_label']                = array( 'en' => $cntctfrm_options['cntctfrm_name_label'] );
  24.             $cntctfrm_options['cntctfrm_email_label']               = array( 'en' => $cntctfrm_options['cntctfrm_email_label'] );
  25.             $cntctfrm_options['cntctfrm_phone_label']               = array( 'en' => $cntctfrm_options['cntctfrm_phone_label'] );
  26. +           $cntctfrm_options['cntctfrm_honeypot_label']                = array( 'en' => $cntctfrm_options['cntctfrm_honeypot_label'] );
  27.             $cntctfrm_options['cntctfrm_subject_label']         = array( 'en' => $cntctfrm_options['cntctfrm_subject_label'] );
  28.             $cntctfrm_options['cntctfrm_message_label']         = array( 'en' => $cntctfrm_options['cntctfrm_message_label'] );
  29.             $cntctfrm_options['cntctfrm_attachment_label']  = array( 'en' => $cntctfrm_options['cntctfrm_attachment_label'] );
  30. ***************
  31. *** 223,228 ****
  32. --- 227,234 ----
  33.                 $cntctfrm_options_submit['cntctfrm_attachment_explanations']                    = 1;
  34.                 $cntctfrm_options_submit['cntctfrm_send_copy']                  = 0;
  35.                 $cntctfrm_options_submit['cntctfrm_from_field']                 = get_bloginfo( 'name' );
  36. +               $cntctfrm_options_submit['cntctfrm_use_akismet']            = 0;
  37. +               $cntctfrm_options_submit['cntctfrm_display_honeypot_field'] = 0;
  38.                 $cntctfrm_options_submit['cntctfrm_display_phone_field']    = 0;
  39.                 $cntctfrm_options_submit['cntctfrm_required_name_field']    = 1;
  40.                 $cntctfrm_options_submit['cntctfrm_required_email_field']   = 1;
  41. ***************
  42. *** 286,291 ****
  43. --- 292,299 ----
  44.                 $cntctfrm_options_submit['cntctfrm_display_add_info']                   = isset( $_POST['cntctfrm_display_add_info']) ? 1 : 0;
  45.                 $cntctfrm_options_submit['cntctfrm_change_label']                           = isset( $_POST['cntctfrm_change_label']) ? 1 : 0;
  46.                 $cntctfrm_options_submit['cntctfrm_display_phone_field']            = isset( $_POST['cntctfrm_display_phone_field']) ? 1 : 0;
  47. +               $cntctfrm_options_submit['cntctfrm_display_honeypot_field']         = isset( $_POST['cntctfrm_display_honeypot_field']) ? 1 : 0;
  48. +               $cntctfrm_options_submit['cntctfrm_use_akismet']                    = isset( $_POST['cntctfrm_use_akismet']) ? 1 : 0;
  49.                 $cntctfrm_options_submit['cntctfrm_required_name_field']            = isset( $_POST['cntctfrm_required_name_field']) ? 1 : 0;
  50.                 $cntctfrm_options_submit['cntctfrm_required_email_field']           = isset( $_POST['cntctfrm_required_email_field']) ? 1 : 0;
  51.             //  $cntctfrm_options_submit['cntctfrm_required_phone_field']           = isset( $_POST['cntctfrm_required_phone_field']) ? 1 : 0;
  52. ***************
  53. *** 314,319 ****
  54. --- 322,328 ----
  55.                         $cntctfrm_options_submit['cntctfrm_name_label'][$key]                   = $_POST['cntctfrm_name_label'][$key];
  56.                         $cntctfrm_options_submit['cntctfrm_email_label'][$key]              = $_POST['cntctfrm_email_label'][$key];
  57.                         $cntctfrm_options_submit['cntctfrm_phone_label'][$key]              = $_POST['cntctfrm_phone_label'][$key];
  58. +                       $cntctfrm_options_submit['cntctfrm_honeypot_label'][$key]               = $_POST['cntctfrm_honeypot_label'][$key];
  59.                         $cntctfrm_options_submit['cntctfrm_subject_label'][$key]            = $_POST['cntctfrm_subject_label'][$key];
  60.                         $cntctfrm_options_submit['cntctfrm_message_label'][$key]            = $_POST['cntctfrm_message_label'][$key];
  61.                         $cntctfrm_options_submit['cntctfrm_attachment_label'][$key]     = $_POST['cntctfrm_attachment_label'][$key];
  62. ***************
  63. *** 335,340 ****
  64. --- 344,350 ----
  65.                         $cntctfrm_options_submit['cntctfrm_name_label']                 = $cntctfrm_option_defaults['cntctfrm_name_label'];
  66.                         $cntctfrm_options_submit['cntctfrm_email_label']                = $cntctfrm_option_defaults['cntctfrm_email_label'];
  67.                         $cntctfrm_options_submit['cntctfrm_phone_label']                = $cntctfrm_option_defaults['cntctfrm_phone_label'];
  68. +                       $cntctfrm_options_submit['cntctfrm_honeypot_label']             = $cntctfrm_option_defaults['cntctfrm_honeypot_label'];
  69.                         $cntctfrm_options_submit['cntctfrm_subject_label']          = $cntctfrm_option_defaults['cntctfrm_subject_label'];
  70.                         $cntctfrm_options_submit['cntctfrm_message_label']          = $cntctfrm_option_defaults['cntctfrm_message_label'];
  71.                         $cntctfrm_options_submit['cntctfrm_attachment_label']       = $cntctfrm_option_defaults['cntctfrm_attachment_label'];
  72. ***************
  73. *** 355,360 ****
  74. --- 365,371 ----
  75.                         $cntctfrm_options_submit['cntctfrm_name_label']['en']                   = $cntctfrm_option_defaults['cntctfrm_name_label']['en'];
  76.                         $cntctfrm_options_submit['cntctfrm_email_label']['en']              = $cntctfrm_option_defaults['cntctfrm_email_label']['en'];
  77.                         $cntctfrm_options_submit['cntctfrm_phone_label']['en']              = $cntctfrm_option_defaults['cntctfrm_phone_label']['en'];
  78. +                       $cntctfrm_options_submit['cntctfrm_honeypot_label']['en']               = $cntctfrm_option_defaults['cntctfrm_honeypot_label']['en'];
  79.                         $cntctfrm_options_submit['cntctfrm_subject_label']['en']            = $cntctfrm_option_defaults['cntctfrm_subject_label']['en'];
  80.                         $cntctfrm_options_submit['cntctfrm_message_label']['en']            = $cntctfrm_option_defaults['cntctfrm_message_label']['en'];
  81.                         $cntctfrm_options_submit['cntctfrm_attachment_label']['en']     = $cntctfrm_option_defaults['cntctfrm_attachment_label']['en'];
  82. ***************
  83. *** 513,518 ****
  84. --- 524,541 ----
  85.                     </td>
  86.                 </tr>
  87.                 <tr valign="top" class="cntctfrm_additions_block <?php if($cntctfrm_options['cntctfrm_additions_options'] == '0') echo "cntctfrm_hidden"; ?>">
  88. +                   <th scope="row" style="width:200px;"><?php _e( "Include a hidden honeypot field to identify spambots", 'contact_form' ); ?></th>
  89. +                   <td colspan="2">
  90. +                       <input type="checkbox" id="cntctfrm_display_honeypot_field" name="cntctfrm_display_honeypot_field" value="1" <?php if($cntctfrm_options['cntctfrm_display_honeypot_field'] == '1') echo "checked=\"checked\" "; ?>/>
  91. +                   </td>
  92. +               </tr>
  93. +               <tr valign="top" class="cntctfrm_additions_block <?php if($cntctfrm_options['cntctfrm_additions_options'] == '0') echo "cntctfrm_hidden"; ?>">
  94. +                   <th scope="row" style="width:200px;"><?php _e( "Use Akismet to silently discard spam", 'contact_form' ); ?></th>
  95. +                   <td colspan="2">
  96. +                       <input type="checkbox" id="cntctfrm_use_akismet" name="cntctfrm_use_akismet" value="1" <?php if($cntctfrm_options['cntctfrm_use_akismet'] == '1') echo "checked=\"checked\" "; ?>/>
  97. +                   </td>
  98. +               </tr>
  99. +               <tr valign="top" class="cntctfrm_additions_block <?php if($cntctfrm_options['cntctfrm_additions_options'] == '0') echo "cntctfrm_hidden"; ?>">
  100.                     <th scope="row" style="width:200px;"><?php _e( "Required fields", 'contact_form' ); ?></th>
  101.                     <td colspan="2">
  102.                         <input type="checkbox" id="cntctfrm_required_name_field" name="cntctfrm_required_name_field" value="1" <?php if($cntctfrm_options['cntctfrm_required_name_field'] == '1') echo "checked=\"checked\" "; ?>/> <?php _e( "Name", 'contact_form' ); ?><br />
  103. ***************
  104. *** 564,569 ****
  105. --- 587,593 ----
  106.                             <input type="text" name="cntctfrm_name_label[en]" value="<?php echo $cntctfrm_options['cntctfrm_name_label']['en']; ?>" /> <span class="cntctfrm_info"><?php _e( "Name:", 'contact_form' ); ?></span><br />
  107.                             <input type="text" name="cntctfrm_email_label[en]" value="<?php echo $cntctfrm_options['cntctfrm_email_label']['en']; ?>" /> <span class="cntctfrm_info"><?php _e( "Email Address:", 'contact_form' ); ?></span><br />
  108.                             <input type="text" name="cntctfrm_phone_label[en]" value="<?php echo $cntctfrm_options['cntctfrm_phone_label']['en']; ?>" /> <span class="cntctfrm_info"><?php _e( "Phone number:", 'contact_form' ); ?></span><br />
  109. +                           <input type="text" name="cntctfrm_honeypot_label[en]" value="<?php echo $cntctfrm_options['cntctfrm_honeypot_label']['en']; ?>" /> <span class="cntctfrm_info"><?php _e( "Leave this line blank!", 'contact_form' ); ?></span><br />
  110.                             <input type="text" name="cntctfrm_subject_label[en]" value="<?php echo $cntctfrm_options['cntctfrm_subject_label']['en']; ?>" /> <span class="cntctfrm_info"><?php _e( "Subject:", 'contact_form' ); ?></span><br />
  111.                             <input type="text" name="cntctfrm_message_label[en]" value="<?php echo $cntctfrm_options['cntctfrm_message_label']['en']; ?>" /> <span class="cntctfrm_info"><?php _e( "Message:", 'contact_form' ); ?></span><br />
  112.                             <input type="text" name="cntctfrm_attachment_label[en]" value="<?php echo $cntctfrm_options['cntctfrm_attachment_label']['en']; ?>" /> <span class="cntctfrm_info"><?php _e( "Attachment:", 'contact_form' ); ?></span><br />
  113. ***************
  114. *** 585,590 ****
  115. --- 609,615 ----
  116.                                     <input type="text" name="cntctfrm_name_label[<?php echo $val; ?>]" value="<?php if( isset( $cntctfrm_options['cntctfrm_name_label'][$val] ) ) echo $cntctfrm_options['cntctfrm_name_label'][$val]; ?>" /> <span class="cntctfrm_info"><?php _e( "Name:", 'contact_form' ); ?></span><br />
  117.                                     <input type="text" name="cntctfrm_email_label[<?php echo $val; ?>]" value="<?php if( isset( $cntctfrm_options['cntctfrm_email_label'][$val] ) ) echo $cntctfrm_options['cntctfrm_email_label'][$val]; ?>" /> <span class="cntctfrm_info"><?php _e( "Email Address:", 'contact_form' ); ?></span><br />
  118.                                     <input type="text" name="cntctfrm_phone_label[<?php echo $val; ?>]" value="<?php if( isset( $cntctfrm_options['cntctfrm_phone_label'][$val] ) ) echo $cntctfrm_options['cntctfrm_phone_label'][$val]; ?>" /> <span class="cntctfrm_info"><?php _e( "Phone number:", 'contact_form' ); ?></span><br />
  119. +                                   <input type="text" name="cntctfrm_honeypot_label[<?php echo $val; ?>]" value="<?php if( isset( $cntctfrm_options['cntctfrm_honeypot_label'][$val] ) ) echo $cntctfrm_options['cntctfrm_honeypot_label'][$val]; ?>" /> <span class="cntctfrm_info"><?php _e( "Leave this blank!", 'contact_form' ); ?></span><br />
  120.                                     <input type="text" name="cntctfrm_subject_label[<?php echo $val; ?>]" value="<?php if( isset( $cntctfrm_options['cntctfrm_subject_label'][$val] ) ) echo $cntctfrm_options['cntctfrm_subject_label'][$val]; ?>" /> <span class="cntctfrm_info"><?php _e( "Subject:", 'contact_form' ); ?></span><br />
  121.                                     <input type="text" name="cntctfrm_message_label[<?php echo $val; ?>]" value="<?php if( isset( $cntctfrm_options['cntctfrm_message_label'][$val] ) ) echo $cntctfrm_options['cntctfrm_message_label'][$val]; ?>" /> <span class="cntctfrm_info"><?php _e( "Message:", 'contact_form' ); ?></span><br />
  122.                                     <input type="text" name="cntctfrm_attachment_label[<?php echo $val; ?>]" value="<?php if( isset( $cntctfrm_options['cntctfrm_attachment_label'][$val] ) ) echo $cntctfrm_options['cntctfrm_attachment_label'][$val]; ?>" /> <span class="cntctfrm_info"><?php _e( "Attachment:", 'contact_form' ); ?></span><br />
  123. ***************
  124. *** 663,668 ****
  125. --- 688,694 ----
  126.         $subject = isset( $_POST['cntctfrm_contact_subject'] ) ? $_POST['cntctfrm_contact_subject'] : "";
  127.         $message = isset( $_POST['cntctfrm_contact_message'] ) ? $_POST['cntctfrm_contact_message'] : "";
  128.         $phone = isset( $_POST['cntctfrm_contact_phone'] ) ? $_POST['cntctfrm_contact_phone'] : "";
  129. +       $honeypot = isset( $_POST['cntctfrm_contact_referral'] ) ? $_POST['cntctfrm_contact_referral'] : "";
  130.  
  131.         $name = strip_tags( preg_replace ( '/<[^>]*>/', '', preg_replace ( '/<script.*<\/[^>]*>/', '', $name ) ) );
  132.         $email = strip_tags( preg_replace ( '/<[^>]*>/', '', preg_replace ( '/<script.*<\/[^>]*>/', '', $email ) ) );  
  133. ***************
  134. *** 670,675 ****
  135. --- 696,703 ----
  136.         $message = strip_tags( preg_replace ( '/<[^>]*>/', '', preg_replace ( '/<script.*<\/[^>]*>/', '', $message ) ) );
  137.         $phone = strip_tags( preg_replace ( '/<[^>]*>/', '', preg_replace ( '/<script.*<\/[^>]*>/', '', $phone ) ) );  
  138.  
  139. +       $honeypot = strip_tags( preg_replace ( '/<[^>]*>/', 'SPAM', preg_replace ( '/<script.*<\/[^>]*>/', 'SPAM', $honeypot ) ) );  
  140. +
  141.         $send_copy = isset( $_POST['cntctfrm_contact_send_copy'] ) ? $_POST['cntctfrm_contact_send_copy'] : "";
  142.         // If it is good
  143.         if( true === $cntctfrm_result ) {
  144. ***************
  145. *** 742,747 ****
  146. --- 770,784 ----
  147.             $content .= '<div style="text-align: left;">
  148.                     <textarea rows="5" cols="30" name="cntctfrm_contact_message" id="cntctfrm_contact_message">'.$message.'</textarea>
  149.                 </div>';
  150. +           if( $cntctfrm_options['cntctfrm_display_honeypot_field'] == 1 ) {
  151. +               $content .= '<div class="cntctfrm_referral">
  152. +                       <label for="cntctfrm_contact_referral">'. $cntctfrm_options['cntctfrm_honeypot_label'][$lang] . '
  153. +                   </label></div>';
  154. +               $content .= '<div style="text-align: left;">
  155. +                       <input class="text" type="text" size="40" value="" name="cntctfrm_contact_referral" id="cntctfrm_contact_referral" style="text-align: left; margin: 0;" />
  156. +                   </div>
  157. +                   ';
  158. +           }
  159.             if($cntctfrm_options['cntctfrm_attachment'] == 1 ) {
  160.                 $content .= '<div style="text-align: left;">
  161.                         <label for="cntctfrm_contact_attachment">'. $cntctfrm_options['cntctfrm_attachment_label'][$lang] . '</label>
  162. ***************
  163. *** 817,828 ****
  164. --- 854,867 ----
  165.         $subject = isset( $_POST['cntctfrm_contact_subject'] ) ? $_POST['cntctfrm_contact_subject'] : "";
  166.         $message = isset( $_POST['cntctfrm_contact_message'] ) ? $_POST['cntctfrm_contact_message'] : "";
  167.         $phone = isset( $_POST['cntctfrm_contact_phone'] ) ? $_POST['cntctfrm_contact_phone'] : "";
  168. +       $honeypot = isset( $_POST['cntctfrm_contact_referral'] ) ? $_POST['cntctfrm_contact_referral'] : "";
  169.  
  170.         $name = strip_tags( preg_replace ( '/<[^>]*>/', '', preg_replace ( '/<script.*<\/[^>]*>/', '', $name ) ) );
  171.         $email = strip_tags( preg_replace ( '/<[^>]*>/', '', preg_replace ( '/<script.*<\/[^>]*>/', '', $email ) ) );  
  172.         $subject = strip_tags( preg_replace ( '/<[^>]*>/', '', preg_replace ( '/<script.*<\/[^>]*>/', '', $subject ) ) );  
  173.         $message = strip_tags( preg_replace ( '/<[^>]*>/', '', preg_replace ( '/<script.*<\/[^>]*>/', '', $message ) ) );
  174.         $phone = strip_tags( preg_replace ( '/<[^>]*>/', '', preg_replace ( '/<script.*<\/[^>]*>/', '', $phone ) ) );  
  175. +       $honeypot = strip_tags( preg_replace ( '/<[^>]*>/', 'SPAM', preg_replace ( '/<script.*<\/[^>]*>/', 'SPAM', $honeypot ) ) );  
  176.  
  177.         if( $cntctfrm_options['cntctfrm_required_name_field'] == 1 )
  178.             $error_message['error_name'] = $cntctfrm_options['cntctfrm_name_error'][$language];
  179. ***************
  180. *** 919,927 ****
  181. --- 958,978 ----
  182.         }
  183.         if( 1 == count( $error_message ) ) {
  184.             unset( $error_message['error_form'] );
  185. +
  186. +         if (strlen(trim(preg_replace('/\xc2\xa0/',' ',$honeypot))) != 0) {
  187. +               // With the following line un-commented,
  188. +               // don't send mail if the honeypot contains something.
  189. +               // Just silently report success to the bot.
  190. +           // $cntctfrm_result = true;
  191. +
  192. +               // With the following line un-commented,
  193. +               // send mail, but flag it as spam.
  194. +           $cntctfrm_result = cntctfrm_send_mail();
  195. +         } else {
  196.             // If all is good - send mail
  197.             $cntctfrm_result = cntctfrm_send_mail();
  198.           }
  199. +       }
  200.         return $cntctfrm_result;
  201.     }
  202.   }
  203. ***************
  204. *** 937,951 ****
  205. --- 988,1094 ----
  206.         $subject = isset( $_POST['cntctfrm_contact_subject'] ) ? $_POST['cntctfrm_contact_subject'] : "";
  207.         $message = isset( $_POST['cntctfrm_contact_message'] ) ? $_POST['cntctfrm_contact_message'] : "";
  208.         $phone = isset( $_POST['cntctfrm_contact_phone'] ) ? $_POST['cntctfrm_contact_phone'] : "";
  209. +       $honeypot = isset( $_POST['cntctfrm_contact_referral'] ) ? $_POST['cntctfrm_contact_referral'] : "";
  210.  
  211.         $name = stripslashes( strip_tags( preg_replace ( '/<[^>]*>/', '', preg_replace ( '/<script.*<\/[^>]*>/', '', $name ) ) ) );
  212.         $email = stripslashes( strip_tags( preg_replace ( '/<[^>]*>/', '', preg_replace ( '/<script.*<\/[^>]*>/', '', $email ) ) ) );  
  213.         $subject = stripslashes( strip_tags( preg_replace ( '/<[^>]*>/', '', preg_replace ( '/<script.*<\/[^>]*>/', '', $subject ) ) ) );  
  214.         $message = stripslashes( strip_tags( preg_replace ( '/<[^>]*>/', '', preg_replace ( '/<script.*<\/[^>]*>/', '', $message ) ) ) );
  215.         $phone = stripslashes( strip_tags( preg_replace ( '/<[^>]*>/', '', preg_replace ( '/<script.*<\/[^>]*>/', '', $phone ) ) ) );  
  216. +       $honeypot = stripslashes( strip_tags( preg_replace ( '/<[^>]*>/', 'SPAM', preg_replace ( '/<script.*<\/[^>]*>/', 'SPAM', $honeypot ) ) ) );  
  217.  
  218.         if( isset( $_SESSION['cntctfrm_send_mail'] ) && $_SESSION['cntctfrm_send_mail'] == true )
  219.             return true;
  220. +
  221. +       // Un-comment these for debugging
  222. +       /*
  223. +       if ( ! ( $cntctfrm_options['cntctfrm_use_akismet'] == 1 ) ) {
  224. +         $name = "<b> Akismet not configured! </b><p/>" . $name;
  225. +       }
  226. +
  227. +       if ( ! function_exists( 'akismet_http_post' ) ) {
  228. +         $name = "<b> Warning: no akismet_http_post() </b><p/>" . $name;
  229. +       }
  230. +
  231. +
  232. +       if ( ! get_option( 'wordpress_api_key' ) ) {
  233. +         $name = "<b> Warning: no wordpress_api_key option </b><p/>" . $name;
  234. +       }
  235. +       */
  236. +
  237. +       if( ( $cntctfrm_options['cntctfrm_use_akismet'] == 1) &&
  238. +           function_exists( 'akismet_http_post' ) &&
  239. +           (get_option( 'wordpress_api_key' ) || $wpcom_api_key ) )  {
  240. +
  241. +         global $akismet_api_host, $akismet_api_port;
  242. +        
  243. +         $akismet_data_array = array();
  244. +         $akismet_data_array['blog']           = get_option( 'home' );
  245. +         $akismet_data_array['user_ip']        = $_SERVER['REMOTE_ADDR'];
  246. +         $akismet_data_array['user_agent']     = $_SERVER['HTTP_USER_AGENT'];
  247. +         $akismet_data_array['referrer']       = $_SERVER['HTTP_REFERER'];
  248. +         $akismet_data_array['comment_type']   = 'contactformplugin';
  249. +
  250. +         if ( $permalink = get_permalink() )
  251. +           $akismet_data_array['permalink'] = $permalink;
  252. +        
  253. +         if ( isset( $_POST['cntctfrm_contact_name'] ) )
  254. +           $akismet_data_array['comment_author'] = $_POST['cntctfrm_contact_name'];
  255. +
  256. +         if ( isset( $_POST['cntctfrm_contact_email'] ) )
  257. +           $akismet_data_array['comment_author_email'] = $_POST['cntctfrm_contact_email'];
  258. +
  259. +         $comment_content = "";
  260. +         if ( isset( $_POST['cntctfrm_contact_subject'] ) ) {
  261. +           $comment_content .= $_POST['cntctfrm_contact_subject'];
  262. +           $comment_content .= "\n";
  263. +         }
  264. +
  265. +         if ( isset( $_POST['cntctfrm_contact_message'] ) )  {
  266. +           $comment_content .= $_POST['cntctfrm_contact_message'];
  267. +           $comment_content .= "\n";
  268. +         }
  269. +
  270. +         if ( isset( $_POST['cntctfrm_contact_phone'] ) )  {
  271. +           $comment_content .= $_POST['cntctfrm_contact_phone'];
  272. +           $comment_content .= "\n";
  273. +         }
  274. +
  275. +         if ( isset( $_POST['cntctfrm_contact_referral'] ) )  {
  276. +           $comment_content .= $_POST['cntctfrm_contact_referral'];
  277. +           $comment_content .= "\n";
  278. +         }
  279. +
  280. +         $akismet_data_array['comment_content'] = $comment_content;
  281. +
  282. +         $ignore = array( 'HTTP_COOKIE' );
  283. +
  284. +         foreach ( $_SERVER as $key => $value )
  285. +           if ( ! in_array( $key, (array) $ignore ) )
  286. +             $akismet_data_array["$key"] = $value;
  287. +
  288. +         $query_string = '';
  289. +         foreach ( $akismet_data_array as $key => $value )
  290. +           $query_string .= $key . '=' . urlencode( stripslashes( (string) $value ) ) . '&';
  291. +
  292. +         $response = akismet_http_post( $query_string, $akismet_api_host,
  293. +                                                        '/1.1/comment-check', $akismet_api_port );
  294. +
  295. +
  296. +         if ( 'true' == $response[1] ) {
  297. +           // To just add a spam banner here, use the following line:
  298. +                      $name = "<b>*** Akismet verified this as spam ***</b><p/>" . $name;
  299. +            // To silently discard the message, use the following line:
  300. +            return true;
  301. +                   }
  302. +
  303. +
  304. +       }
  305. +
  306. +
  307. +       if (strlen(trim(preg_replace('/\xc2\xa0/',' ',$honeypot))) != 0) {
  308. +         $name = "<b>***SPAM***</b><p/>" . $name;
  309. +       }
  310.         if( $cntctfrm_options['cntctfrm_select_email'] == 'user' ) {
  311.                 if( function_exists('get_userdatabylogin') && false !== $user = get_userdatabylogin( $cntctfrm_options['cntctfrm_user_email'] ) ){
  312.                     $to = $user->user_email;
  313. ***************
  314. *** 1030,1035 ****
  315. --- 1173,1181 ----
  316.                         <td>'. __( "Message", 'contact_form' ) . '</td><td>'. $message .'</td>
  317.                     </tr>
  318.                     <tr>
  319. +                       <td>'. __( "Spam detection contents", 'contact_form' ) . '</td><td>'. $honeypot .'</td>
  320. +                   </tr>
  321. +                   <tr>
  322.                         <td>'. __( "Site", 'contact_form' ) . '</td><td>'.get_bloginfo("url").'</td>
  323.                     </tr>
  324.                     <tr>
  325. ***************
  326. *** 1216,1221 ****
  327. --- 1362,1369 ----
  328.         unset( $cntctfrm_options['cntctfrm_email_label'][$_REQUEST['lang']]);
  329.     if( isset( $cntctfrm_options['cntctfrm_phone_label'][$_REQUEST['lang']] ) )
  330.         unset( $cntctfrm_options['cntctfrm_phone_label'][$_REQUEST['lang']]);
  331. +   if( isset( $cntctfrm_options['cntctfrm_honeypot_label'][$_REQUEST['lang']] ) )
  332. +       unset( $cntctfrm_options['cntctfrm_honeypot_label'][$_REQUEST['lang']]);
  333.     if( isset( $cntctfrm_options['cntctfrm_subject_label'][$_REQUEST['lang']] ) )
  334.         unset( $cntctfrm_options['cntctfrm_subject_label'][$_REQUEST['lang']]);
  335.     if( isset( $cntctfrm_options['cntctfrm_message_label'][$_REQUEST['lang']] ) )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement