Page 1 of 11 123 ... LastLast
Results 1 to 10 of 104
Like Tree1Likes

Thread: reCaptcha on the contact form of single-page ads.

  1. #1
    Thread Starter
    Veteran barukar's Avatar
    Join Date
    Sep 2010
    Location
    Brasil, São Paulo, SP
    Posts
    6,784
    Thanks
    186
    Thanked 742 Times in 623 Posts

    reCaptcha on the contact form of single-page ads.

    To prevent issues with SPAM on contact form page ad only made a few changes in the files "sidebar-contact.php" and "style.css" to replace the captcha fully employed by reCAPTCHA.

    Please Wordpress Admin and click Edit Appearance:
    Select the "sidebar-contact.php"and replace the code by origimal modified code below. Before you save you should put the keys "reCaptcha Public Key - $ publickey =" key and "Private Key reCaptcha - $ privatekey =" You can business users the same key business users in the admin ClassiPress "Security"

    $ publickey = xxxxxxxxxxxxxxxxxxxxxxxxxx (substitute your key)
    $ privatekey = xxxxxxxxxxxxxxxxxxxxxxxxxx (substitute your key)


    sidebar-contact.php
    PHP Code:
    <?php
     
    // call the lib..
        
    require_once (TEMPLATEPATH '/includes/lib/recaptchalib.php');
        
    $resp null;
        
    $error null;
     
    // Get a key from http://recaptcha.net/api/getkey
    $publickey "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
    $privatekey "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
     
     
    # was there a reCAPTCHA response?
    if ($_POST["submit"]) {
     
        
    $response recaptcha_check_answer($privatekey,
            
    $_SERVER["REMOTE_ADDR"],
            
    $_POST["recaptcha_challenge_field"],
            
    $_POST["recaptcha_response_field"]);
     
            if (
    $response->is_valid) {
                    
    cp_contact_ad_owner_email($post->ID);
            
    $msg '<p class="green center"><strong>' __('Your message has been sent!''appthemes') . '</p>';
            } else {
     
                    
    # set the error code so that we can display it
            
    $msg '<p class="red center"><strong>' __('The anti-spam reCaptcha answer was incorrect!' 'appthemes') . '</p>';
     
             }
    }
     
    ?>
     
       <form name="mainform" id="mainform" class="form_contact" action="#priceblock2" method="post" enctype="multipart/form-data">
           <?php echo $msg?>
           <p class="contact_msg"><?php _e('To inquire about this ad listing, complete the form below to send a message to the ad poster.''appthemes'?></p>
     
            <ol>
                <li>
     
                    <label><?php _e('Name:''appthemes'?></label>
                    <input name="from_name" id="from_name" type="text" minlength="2" value="<?php if(isset($_POST['from_name'])) echo stripslashes($_POST['from_name']); ?>" class="text required" />
                    <div class="clr"></div>
     
                </li>
     
                <li>
                    <label><?php _e('Email:''appthemes'?></label>
                    <input name="from_email" id="from_email" type="text" minlength="5" value="<?php if(isset($_POST['from_email'])) echo stripslashes($_POST['from_email']); ?>" class="text required email" />
                    <div class="clr"></div>
     
                </li>
     
                <li>
     
                    <label><?php _e('Subject:''appthemes'?></label>
                    <input name="subject" id="subject" type="text" minlength="2" value="<?php the_title();?>" class="text required" />
                    <div class="clr"></div>
     
                </li>
     
                <li>
     
                    <label><?php _e('Message:''appthemes'?></label>
                    <textarea name="message" id="message" rows="" cols="" class="text required"><?php if(isset($_POST['message'])) echo stripslashes($_POST['message']); ?></textarea>
                     <div class="clr"></div>
     
               </li>
     
                <li>
     
              <?php 
        
    // include the spam checker if enabled
              
    appthemes_recaptcha();
         
    ?>
     
     
              <input name="submit" type="submit" id="submit_inquiry" class="btn_orange" value="<?php _e('Send Inquiry','appthemes'); ?>" />
     
     
              </li>
     
       </form>
    Now we will align the reCAPTCHA box

    Please Wordpress Admin and click Edit Appearance:
    Select the file "style.css" and locate the line within the code seuinte "/* reCaptcha styles */" and replace with the code below:

    style.css
    PHP Code:
    /* reCaptcha styles */
    #recaptcha_area, #recaptcha_table {
    float:center;
    width:318px;


    This will result in the form:
    Attached Images Attached Images
    Last edited by pepsi; February 24th, 2011 at 03:22 AM.
    -------------------------------------------------------------------------------------------
    Projects: ClassiNoiva - Classimóveis - vocênoenem - i50 - Clube DETRAN

  2. The Following 12 Users Say Thank You to barukar For This Useful Post:

    almightyeric (August 19th, 2012), appouser (April 20th, 2012), benja (July 13th, 2011), itsme (June 30th, 2011), jeffagogo (January 19th, 2012), levt (April 22nd, 2012), matt9250 (March 2nd, 2011), megasale (March 21st, 2012), ndlindquist (December 19th, 2011), nikthompson (October 9th, 2012), omar (July 24th, 2012), theecotrader (March 1st, 2011)

  3. #2
    quim's Avatar
    Join Date
    Jan 2011
    Location
    Spain
    Posts
    463
    Thanks
    29
    Thanked 2 Times in 2 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!
    Attached Images Attached Images

  4. #3
    Thread Starter
    Veteran barukar's Avatar
    Join Date
    Sep 2010
    Location
    Brasil, São Paulo, SP
    Posts
    6,784
    Thanks
    186
    Thanked 742 Times in 623 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!
    -------------------------------------------------------------------------------------------
    Projects: ClassiNoiva - Classimóveis - vocênoenem - i50 - Clube DETRAN

  5. The Following User Says Thank You to barukar For This Useful Post:

    theecotrader (March 1st, 2011)

  6. #4
    quim's Avatar
    Join Date
    Jan 2011
    Location
    Spain
    Posts
    463
    Thanks
    29
    Thanked 2 Times in 2 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!
    Attached Images Attached Images

  7. #5
    lucasstarbuck's Avatar
    Join Date
    Oct 2010
    Posts
    86
    Thanks
    10
    Thanked 12 Times in 6 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  8. #6
    lucasstarbuck's Avatar
    Join Date
    Oct 2010
    Posts
    86
    Thanks
    10
    Thanked 12 Times in 6 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  9. #7
    Thread Starter
    Veteran barukar's Avatar
    Join Date
    Sep 2010
    Location
    Brasil, São Paulo, SP
    Posts
    6,784
    Thanks
    186
    Thanked 742 Times in 623 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!
    -------------------------------------------------------------------------------------------
    Projects: ClassiNoiva - Classimóveis - vocênoenem - i50 - Clube DETRAN

  10. The Following 2 Users Say Thank You to barukar For This Useful Post:

    lucasstarbuck (February 24th, 2011), omar (July 24th, 2012)

  11. #8
    lucasstarbuck's Avatar
    Join Date
    Oct 2010
    Posts
    86
    Thanks
    10
    Thanked 12 Times in 6 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  12. #9
    Junior Member igorsandee's Avatar
    Join Date
    Jan 2011
    Posts
    32
    Thanks
    4
    Thanked 1 Time in 1 Post
    You must be an AppThemes customer and logged in to view this response. Join today!

  13. #10
    Thread Starter
    Veteran barukar's Avatar
    Join Date
    Sep 2010
    Location
    Brasil, São Paulo, SP
    Posts
    6,784
    Thanks
    186
    Thanked 742 Times in 623 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!
    -------------------------------------------------------------------------------------------
    Projects: ClassiNoiva - Classimóveis - vocênoenem - i50 - Clube DETRAN

  14. The Following 5 Users Say Thank You to barukar For This Useful Post:

    igorsandee (February 24th, 2011), khouloud (November 22nd, 2011), levt (April 22nd, 2012), luizz (October 10th, 2011), storehound (June 17th, 2013)

Page 1 of 11 123 ... LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Is it possible to show ad posting form on single page ?
    By postfreeads in forum Report ClassiPress Bugs
    Replies: 9
    Last Post: August 28th, 2017, 01:33 PM
  2. Using recaptcha on Job Roller contact form
    By acsepic in forum Report JobRoller Bugs
    Replies: 10
    Last Post: February 6th, 2013, 03:06 PM
  3. How to add the reCaptcha also to the contact form?
    By jerome281 in forum JobRoller General Discussion
    Replies: 1
    Last Post: December 29th, 2010, 12:10 AM