Plugin Directory

Changeset 1473575


Ignore:
Timestamp:
08/13/2016 05:59:28 AM (9 years ago)
Author:
haruncpi
Message:

2.0 version released.

Location:
wp-light-captcha
Files:
7 added
3 edited

Legend:

Unmodified
Added
Removed
  • wp-light-captcha/trunk/css/style.css

    r1356285 r1473575  
     1#wplc_user_answer {
     2    width: 100%;
     3    height: 28px !important;
     4    position: relative;
     5    top: 7px;
     6    font-size: 15px;
     7    border-radius: 4px;
     8    font-weight: 800;
     9    color: #666;
     10}
     11#wplc_comment_user_answer{
     12    width: 110px;
     13}
  • wp-light-captcha/trunk/readme.txt

    r1356285 r1473575  
    3333= 1.0.1 =
    3434* Style captcha answer input box
     35
     36= 2.0 =
     37* Captcha security is available in comment section.
     38* Style changes
  • wp-light-captcha/trunk/wp-light-captcha.php

    r1356285 r1473575  
    44 * Plugin URI: http://learn24bd.com/portfolio/wp-light-captcha
    55 * Description: WP Light Captcha is very simple and lightweight captcha plugins for your WordPress site.You can protect unwanted login request from hackers.
    6  * Version: 1.0.1
     6 * Version: 2.0
    77 * Author: Harun
    88 * Author URI: http://learn24bd.com
     
    1010 */
    1111require __DIR__ . "/lib/mc.class.php";
     12
     13function wplc_load_style()
     14{
     15    wp_register_style('wplc_style', plugins_url('css/style.css', __FILE__));
     16    wp_enqueue_style('wplc_style');
     17}
     18add_action('wp_enqueue_scripts', 'wplc_load_style');
     19
     20
    1221add_action('login_form', 'wplc_login_form');
    13 
    1422function wplc_login_form()
    1523{
    1624    Mc::putMcData();
    1725    ?>
    18     <style>
    19     #wplc_user_answer{
    20     width: 100%;
    21     height: 28px!important;
    22     position: relative;
    23     top: 7px;
    24     font-size: 15px;
    25     border-radius: 4px;
    26     font-weight: 800;
    27     color: #666;
    28     }
    29     </style>
    3026    <table>
    3127        <tr>
    32             <td width="45%"><strong>Captcha:</strong> <?=Mc::getMcQuestion();?></td>
     28            <td width="45%"><strong>Captcha:</strong> <?= Mc::getMcQuestion(); ?></td>
    3329            <td>
    34                 <input type="hidden" name="wplc_a" value="<?=md5(Mc::getMcAnswer())?>">
    35                 <input type="text" id="wplc_user_answer" name="wplc_user_answer" placeholder="Put Answer" required="required">
     30                <input type="hidden" name="wplc_a" value="<?= md5(Mc::getMcAnswer()) ?>">
     31                <input type="text" id="wplc_user_answer" name="wplc_user_answer" placeholder="Put Answer"
     32                       required="required">
    3633            </td>
    3734        </tr>
     
    4542{
    4643    if (isset($_POST['wplc_user_answer']) && isset($_POST['wplc_a'])) {
    47         $userAnswer   = md5($_POST['wplc_user_answer']);
     44        $userAnswer = md5($_POST['wplc_user_answer']);
    4845        $actualAnswer = $_POST['wplc_a'];
    4946        if ($userAnswer == $actualAnswer) {
     
    5956
    6057}
     58
     59add_action('comment_form', 'wplc_comment_captcha_display');
     60function wplc_comment_captcha_display()
     61{
     62    Mc::putMcData();
     63    ?>
     64
     65                <p><strong>Captcha:</strong> <?= Mc::getMcQuestion(); ?></p>
     66                <input type="hidden" name="wplc_a" value="<?= md5(Mc::getMcAnswer()) ?>">
     67                <input type="text" id="wplc_comment_user_answer" name="wplc_comment_user_answer"
     68                       placeholder="Put Answer" required="required">
     69
     70    <?php
     71}
     72
     73add_filter('preprocess_comment', 'wplc_comment_validate_captcha_field');
     74function wplc_comment_validate_captcha_field($commentdata)
     75{
     76    if (isset($_POST['wplc_comment_user_answer']) && isset($_POST['wplc_a'])) {
     77        $userAnswer = md5($_POST['wplc_user_answer']);
     78        $actualAnswer = $_POST['wplc_a'];
     79        if ($userAnswer == $actualAnswer) {
     80            return $commentdata;
     81        } else {
     82            wp_die(__('<strong>Sorry!</strong> incorrect captcha'));
     83        }
     84    } else {
     85        wp_die(__('<strong>Sorry!</strong> you must enter captcha'));
     86    }
     87}
Note: See TracChangeset for help on using the changeset viewer.