Plugin Directory

Changeset 444954


Ignore:
Timestamp:
09/28/2011 08:03:57 PM (15 years ago)
Author:
picatcha
Message:

Added functionality to have users solve PICATCHA to retrieve a lost password or login on the site. Also added an additional screenshot

Location:
picatcha/trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • picatcha/trunk/picatcha-settings.php

    r429974 r444954  
    9494      </table>
    9595     
     96      <h3><?php _e('Lost Password', 'picatcha'); ?></h3>
     97        <table class="form-table">
     98           <tr valign="top">
     99              <th scope="row"><?php _e('Activation', 'picatcha'); ?></th>
     100              <td>
     101                 <input type="checkbox" id ="picatcha_options[show_in_lost_password]" name="picatcha_options[show_in_lost_password]" value="1" <?php checked('1', $this->options['show_in_lost_password']); ?> />
     102                 <label for="picatcha_options[show_in_lost_password]"><?php _e('Enable for Lost password form', 'picatcha'); ?></label>
     103              </td>
     104           </tr>
     105
     106           <!-- keeping this here just in case we decide to implement it -->
     107           <!-- <tr valign="top">
     108              <th scope="row"><?php //_e('Presentation', 'picatcha'); ?></th>
     109              <td>
     110                 <label for="picatcha_options[registration_theme]"><?php //_e('Theme:', 'picatcha'); ?></label>
     111                 <?php //$this->theme_dropdown('registration'); ?>
     112              </td>
     113           </tr>
     114
     115           <tr valign="top">
     116              <th scope="row"><?php //_e('Tab Index', 'picatcha'); ?></th>
     117              <td>
     118                 <input type="text" name="picatcha_options[registration_tab_index]" size="10" value="<?php //echo $this->options['registration_tab_index']; ?>" />
     119              </td>
     120           </tr>-->
     121        </table>
     122       
     123        <h3><?php _e('Login form', 'picatcha'); ?></h3>
     124            <table class="form-table">
     125               <tr valign="top">
     126                  <th scope="row"><?php _e('Activation', 'picatcha'); ?></th>
     127                  <td>
     128                     <input type="checkbox" id ="picatcha_options[show_in_login]" name="picatcha_options[show_in_login]" value="1" <?php checked('1', $this->options['show_in_login']); ?> />
     129                     <label for="picatcha_options[show_in_login]"><?php _e('Require for login', 'picatcha'); ?></label>
     130                  </td>
     131               </tr>
     132
     133               <!-- keeping this here just in case we decide to implement it -->
     134               <!-- <tr valign="top">
     135                  <th scope="row"><?php //_e('Presentation', 'picatcha'); ?></th>
     136                  <td>
     137                     <label for="picatcha_options[registration_theme]"><?php //_e('Theme:', 'picatcha'); ?></label>
     138                     <?php //$this->theme_dropdown('registration'); ?>
     139                  </td>
     140               </tr>
     141
     142               <tr valign="top">
     143                  <th scope="row"><?php //_e('Tab Index', 'picatcha'); ?></th>
     144                  <td>
     145                     <input type="text" name="picatcha_options[registration_tab_index]" size="10" value="<?php //echo $this->options['registration_tab_index']; ?>" />
     146                  </td>
     147               </tr>-->
     148            </table>
     149     
    96150      <h3><?php _e('General Options', 'picatcha'); ?></h3>
    97151      <table class="form-table">
  • picatcha/trunk/picatcha.php

    r431402 r444954  
    3838            if ($this->options['show_in_registration'])
    3939                add_action('login_head', array(&$this, 'registration_style')); // make unnecessary: instead use jQuery and add to the footer?
    40 
    41             if($this->options['display_powered_by'])
    42                 //WPPluginPicatcha::$displayPoweredBy=1;
    4340
    4441            // options
     
    5350                else
    5451                    add_action('register_form', array(&$this, 'show_picatcha_in_registration'));
     52            }
     53           
     54            if ($this->options['show_in_lost_password']){
     55                add_action('lostpassword_form', array(&$this, 'show_picatcha_in_registration'));
     56            }
     57           
     58            if($this->options['show_in_login']){ //$this->options['show_in_login']
     59                add_action('login_form', array(&$this, 'show_picatcha_in_registration'));
    5560            }
    5661
     
    8388                else
    8489                    add_filter('registration_errors', array(&$this, 'validate_picatcha_response'));
     90            }
     91           
     92            if($this->options['show_in_login']){
     93                if($this->is_multi_blog()){
     94                    add_filter('login_errors', array(&$this, 'validate_picatcha_response_wpmu'));
     95                }
     96                else{
     97                    add_filter('login_redirect', array(&$this, 'validate_picatcha_response_redirect'),10,3);
     98                    add_filter('login_errors', array(&$this, 'validate_picatcha_response'));
     99                   
     100                }
     101               
     102            }
     103           
     104            if($this->options['show_in_lost_password']){
     105                // picatcha validation
     106                if ($this->is_multi_blog())
     107                    add_filter('lostpassword_post', array(&$this, 'validate_picatcha_response_wpmu'));
     108                else
     109                    add_filter('lostpassword_post', array(&$this, 'check_picatcha_lost_password')); //validate_picatcha_response
     110                   
    85111            }
    86112        }
     
    106132               $option_defaults['show_in_comments'] = $old_options['re_comments']; // whether or not to show Picatcha on the comment post
    107133               $option_defaults['show_in_registration'] = $old_options['re_registration']; // whether or not to show Picatcha on the registration page
     134               $option_defaults['show_in_lost_password'] = $old_options['show_in_lost_password']; // whether or not to show when the user loses his/her password
     135               $option_defaults['show_in_login'] = $old_options['show_in_login']; // whether or not to require when the user is logging in
    108136               
    109137
     
    139167               $option_defaults['show_in_registration'] = 1; // whether or not to show Picatcha on the registration page
    140168               $option_defaults['display_powered_by'] = 1; //whether or not to show "Powered by Picatcha"
     169               $option_defaults['show_in_lost_password'] = 0; //defaults to not show in password recovery page
     170               $option_defaults['show_in_login'] = 0; //defaults to not show when the user logs in
    141171
    142172               // bypass levels
     
    197227                window.onload = function() {
    198228                    document.getElementById('login').style.width = '{$width}px';
    199                     document.getElementById('reg_passmail').style.marginTop = '10px';
    200                     document.getElementById('picatcha_widget_div').style.marginBottom = '10px';
     229                    if(document.getElementById('reg_passmail')){document.getElementById('reg_passmail').style.marginTop = '10px';}
     230                    if(document.getElementById('picatcha_widget_div')){document.getElementById('picatcha_widget_div').style.marginBottom = '10px';}
    201231                };
    202232                </script>
     
    243273            $validated['show_in_comments'] = ($input['show_in_comments'] == 1 ? 1 : 0);
    244274            $validated['bypass_for_registered_users'] = ($input['bypass_for_registered_users'] == 1 ? 1: 0);
     275            $validated['show_in_lost_password'] = ($input['show_in_lost_password'] == 1 ? 1: 0);
     276            $validated['show_in_login'] = ($input['show_in_login'] == 1 ? 1: 0);
    245277           
    246278            $capabilities = array ('read', 'edit_posts', 'publish_posts', 'moderate_comments', 'activate_plugins');
     
    302334            }
    303335
     336            //displays an error message in the captcha for the login screen
     337            if(isset($_REQUEST['picatcha'])){
     338                switch ($_REQUEST['picatcha']){
     339                    case 'empty':
     340                        echo "<b style='color: red;'>".$this->options['no_response_error']."</b>";
     341                        break;
     342                    case 'incorrect':
     343                        echo "<b style='color: red;'>".$this->options['incorrect_response_error']."</b>";
     344                        break;
     345                }
     346            }
     347           
    304348            // if it's for wordpress mu, show the errors
    305349            if ($this->is_multi_blog()) {
     
    312356            // for regular wordpress
    313357            else {
    314                 //echo out to see what the error is
    315                 //echo "error: ". $rerror;
    316358                echo $format . $this->get_picatcha_html($rerror, $use_ssl);
    317359            }
     
    319361       
    320362        function validate_picatcha_response($errors) {
    321             // empty so throw the empty response error
     363            // if the user does not fill out picatcha, throw the empty response error
     364           
    322365             if (empty($_POST['picatcha']['r']) || $_POST['picatcha']['r'] == '') {
    323                  $errors->add('blank_captcha', $this->options['no_response_error']);
     366                if(is_wp_error($errors)){
     367                    $errors->add('blank_captcha', $this->options['no_response_error']);
     368                }else{
     369                    $errors .= $this->options['no_response_error'];
     370                }
     371                 
    324372                 return $errors;
     373                 
    325374             }
    326375             $response = picatcha_check_answer($this->options['private_key'], $_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT'], $_POST['picatcha']['token'], $_POST['picatcha']['r']);
    327376 
    328377             // response is bad, add incorrect response error
     378             
    329379             if (!$response->is_valid)
     380                 if ($response->error == 'incorrect-answer'){
     381                     
     382                 
     383                    if (is_wp_error($errors))
     384                        $errors->add('captcha_wrong', $this->options['incorrect_response_error']);
     385                    if (!is_wp_error($errors)){
     386                       
     387                        // works for form errors
     388                        $errors .= $this->options['incorrect_response_error'];
     389                    }
     390                 }
     391            return $errors;
     392        }
     393
     394
     395        function check_picatcha_lost_password(){
     396            if (empty($_POST['picatcha']['r']) || $_POST['picatcha']['r'] == ''){
     397                wp_die(__($this->options['no_response_error']. "<br/> Please click your browser&apos;s back button to try again."));
     398            }
     399           
     400            //validate the captcha
     401            $response = picatcha_check_answer($this->options['private_key'], $_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT'], $_POST['picatcha']['token'], $_POST['picatcha']['r']);
     402           
     403            if (!$response->is_valid){
     404                if ($response->error == 'incorrect-answer')
     405                    wp_die(__($this->options['incorrect_response_error']. "<br/> Please click your browser&apos;s back button to try again."));
     406            }
     407         
     408        }
     409       
     410        function validate_picatcha_response_redirect($url) {
     411            //function to validate picatcha when the user is redirecting to a page.. ie if the username and password is correct
     412           
     413            //check to see if the picatcha is filled out to begin with...
     414             if (empty($_POST['picatcha']['r']) || $_POST['picatcha']['r'] == '') {
     415                 $_SESSION['rerror']= __('picatcha', 'The Picatcha is Empty!', 'picatcha');
     416                 // Log the user out immediately
     417                 wp_logout();
     418                 //return them to the login screen, passing along something to tell them the picatcha was wrong...
     419                 return $_SERVER['REQUEST_URI']."?picatcha=empty";
     420             }
     421             
     422             $response = picatcha_check_answer($this->options['private_key'], $_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT'], $_POST['picatcha']['token'], $_POST['picatcha']['r']);
     423 
     424             //if it is filled out, then validate it...
     425             
     426             if (!$response->is_valid){
     427                 //echo "response is not valid";
    330428                 if ($response->error == 'incorrect-answer')
    331                      $errors->add('captcha_wrong', $this->options['incorrect_response_error']);
    332  
    333             return $errors;
     429                    if (!is_wp_error($errors)){
     430                        // works for form errors
     431                        //$url = '?picatcha='.$this->options['no_response_error'];
     432                        //return $url;
     433                        $PicatchaError = new WP_Error('Picatcha',__('Picatcha is wrong'));
     434                        return $_SERVER['REQUEST_URI']."?picatcha=incorrect";
     435                       
     436                    }
     437                    //if the user did not pass picatcha, logs them out immediately
     438                    wp_logout();
     439             }else{
     440                //user completed the captcha correctly
     441               
     442                //return them to the main site
     443                return site_url()."/wp-admin/"; //maybe add in an option to the preferences to redirect it to another page? say the root page or something else?
     444            }
    334445        }
    335446       
  • picatcha/trunk/readme.txt

    r431402 r444954  
    55Requires at least: 2.7.1
    66Tested up to: 3.2.1
    7 Stable tag: 1.0
     7Stable tag: 1.1
    88
    9 Integrates Picatcha image-identification CAPTCHA - anti-spam solution with WordPress including comment and registration.
     9Integrates PICATCHA image-identification CAPTCHA - anti-spam solution with WordPress including comment and registration.
    1010
    1111== Description ==
    1212
    13 = What is Picatcha? =
     13= What is PICATCHA? =
    1414
    1515PICATCHA(TM) is a unique image-identification CAPTCHA that effectively protects your website from Internet abuse - spam and automated bots. It is a well known fact that websites lose approximately 3-18% of user interactions (comments, sign-up etc) due to the additional burden of re-typing the squiggly garbled text CAPTCHAs. Imagine if your website is visited from a tablet device or a smartphone - the end user is left to zoom/pan, decipher the text and typing with auto-correction makes the whole experience frustrating. It is also inevitable that mobile Internet will eclipse desktop Internet, and we believe that as a website administrator you make the right CAPTCHA choice and be ready for this shift.
     
    31311. Upload the `picatcha` folder to the `/wp-content/plugins/` directory
    32322. Activate the plugin through the `Plugins` menu in WordPress
    33 3. Get the Picatcha keys (Public and Private) [here](http://www.picatcha.com/signup)
     333. Get the PICATCHA keys (Public and Private) [here](http://www.picatcha.com/signup)
    34344. Add the Public/Private keys in Settings menu
    3535
     
    4343== ChangeLog ==
    4444
     45= Version 1.1 =
     46* Added Picatcha to the login and lost password screens.
     47
    4548= Version 1.01 =
    4649* Fixed a bug that prevented users from accessing the settings page
     
    5154== Upgrade Notice ==
    5255
    53 = Version 1.01 =
    54 If you are having trouble accessing the settings page for PICATCHA, this upgrade should fix the problem.
     56= Version 1.1 =
     57Version 1.1 allows Wordpress admins to have users solve PICATCHAs on the login screen and lost password screen, in addition to previous bug fixes.
    5558
    5659== Frequently Asked Questions ==
     
    6669== Screenshots ==
    6770
    68 1. The Picatcha Settings
     711. The PICATCHA Settings
    6972
    70 2. Picatcha in a comment form scaled down 50%
     732. PICATCHA in a comment form scaled down 50%
    7174
    72 3. Picatcha on the registration form of Wordpress
     753. PICATCHA on the registration form of Wordpress
    7376
     774. PICATCHA on the login form of Wordpress
Note: See TracChangeset for help on using the changeset viewer.