Advertisement
supportnwl

Captcha alternative

Nov 14th, 2012
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.42 KB | None | 0 0
  1. Download and Install -> http://wordpress.org/extend/plugins/really-simple-captcha/
  2.  
  3. Copy and Modify Template File at wp-content/plugins/events-manager/templates/placeholders/bookingform.php
  4. 1. copy php file at wp-content/plugins/events-manager/templates/placeholders/bookingform.php
  5. 2. paste in your current theme directory e.g. wp-content/themes/YOUR THEME NAME/plugins/events-manager/bookingform.php (create folders if not existing)
  6. 3. open and modify
  7.  
  8. PASTE THIS SNIPPET
  9. ==================================
  10. <?php
  11. $captcha_instance = new ReallySimpleCaptcha();
  12. $captcha_instance->chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
  13. $captcha_instance->char_length = '4';
  14. // Width/Height dimensions of CAPTCHA image.
  15. $captcha_instance->img_size = array( '72', '24' );
  16. // Font color of CAPTCHA characters, in RGB (0 - 255).
  17. $captcha_instance->fg = array( '0', '0', '0' );
  18. // Background color of CAPTCHA image, in RGB (0 - 255).
  19. $captcha_instance->bg = array( '255', '255', '255' );
  20. // Font Size of CAPTCHA characters.
  21. $captcha_instance->font_size = '16';
  22. // Width between CAPTCHA characters.
  23. $captcha_instance->font_char_width = '15';
  24. // CAPTCHA image type. Can be 'png', 'jpeg', or 'gif'
  25. $captcha_instance->img_type = 'png';
  26. $captcha_instance_word = $captcha_instance->generate_random_word();
  27. $captcha_instance_prefix = mt_rand();
  28. $captcha_instance_image_name = $captcha_instance->generate_image($captcha_instance_prefix, $captcha_instance_word);
  29. $captcha_instance_image_url = get_bloginfo('wpurl') . '/wp-content/plugins/really-simple-captcha/tmp/';
  30. $captcha_instance_image_src = $captcha_instance_image_url.$captcha_instance_image_name;
  31. $captcha_instance_image_width = $captcha_instance->img_size[0];
  32. $captcha_instance_image_height = $captcha_instance->img_size[1];
  33. $captcha_instance_field_size = $captcha_instance->char_length;
  34. $captcha_instance_form_label = 'Anti-Spam:';
  35. ?>
  36. <p class="comment-form-captcha">
  37. <img src="<?php echo $captcha_instance_image_src; ?>" alt="captcha" width="<?php echo $captcha_instance_image_width; ?>" height="<?php echo $captcha_instance_image_height; ?>" />
  38. <label for="captcha_code"><?php echo $captcha_instance_form_label; ?></label>
  39. <input id="captcha_instance_code" name="captcha_instance_code" size="<?php echo $captcha_instance_field_size; ?>" type="text" />
  40. <input id="captcha_instance_prefix" name="captcha_instance_prefix" type="hidden" value="<?php echo $captcha_instance_prefix; ?>" />
  41. </p>
  42. ==================================
  43.  
  44. ABOVE
  45. ==================================
  46. <div class="em-booking-buttons">
  47. <?php if( preg_match('/https?:\/\//',get_option('dbem_bookings_submit_button')) ): //Settings have an image url (we assume). Use it here as the button.?>
  48. ==================================
  49.  
  50. PASTE THIS SNIPPET IN YOUR THEME FUNCTIONS.PHP
  51. ==================================
  52. function em_validate(){
  53. global $EM_Event,$EM_Notices;
  54. $captcha_instance = new ReallySimpleCaptcha();
  55. $captcha_instance_correct = false;
  56. $captcha_instance_prefix = $_POST['captcha_instance_prefix'];
  57. $captcha_instance_code = $_POST['captcha_instance_code'];
  58. $captcha_instance_check = $captcha_instance->check( $captcha_instance_prefix, $captcha_instance_code );
  59. $captcha_instance_correct = $captcha_instance_check;
  60. if ( !$captcha_instance_correct ){
  61. $EM_Notices->add_error('Invalid security code');
  62. return false;
  63. }
  64. return true;
  65. }
  66. add_filter('em_event_validate','em_validate');
  67. ==================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement