Пример #1
0
function rcl_get_captcha_field($fields)
{
    $rcl_captcha = new ReallySimpleCaptcha();
    $rcl_captcha->chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
    $rcl_captcha->char_length = '4';
    $rcl_captcha->img_size = array('72', '24');
    $rcl_captcha->fg = array('0', '0', '0');
    $rcl_captcha->bg = array('255', '255', '255');
    $rcl_captcha->font_size = '16';
    $rcl_captcha->font_char_width = '15';
    $rcl_captcha->img_type = 'png';
    $rcl_captcha->base = array('6', '18');
    $rcl_captcha_word = $rcl_captcha->generate_random_word();
    $rcl_captcha_prefix = mt_rand();
    $rcl_captcha_image_name = $rcl_captcha->generate_image($rcl_captcha_prefix, $rcl_captcha_word);
    $rcl_captcha_image_url = plugins_url('really-simple-captcha/tmp/');
    $rcl_captcha_image_src = $rcl_captcha_image_url . $rcl_captcha_image_name;
    $rcl_captcha_image_width = $rcl_captcha->img_size[0];
    $rcl_captcha_image_height = $rcl_captcha->img_size[1];
    $rcl_captcha_field_size = $rcl_captcha->char_length;
    $fields .= '
      <div class="form-block-rcl">
        <label>' . __('Enter characters', 'wp-recall') . ' <span class="required">*</span></label>
        <img src="' . $rcl_captcha_image_src . '" alt="captcha" width="' . $rcl_captcha_image_width . '" height="' . $rcl_captcha_image_height . '" />
        <input id="rcl_captcha_code" required name="rcl_captcha_code" style="width: 160px;" size="' . $rcl_captcha_field_size . '" type="text" />
        <input id="rcl_captcha_prefix" name="rcl_captcha_prefix" type="hidden" value="' . $rcl_captcha_prefix . '" />
     </div>';
    return $fields;
}
Пример #2
0
 public function reloadCaptcha()
 {
     $captcha_instance = new ReallySimpleCaptcha();
     $word = $captcha_instance->generate_random_word();
     $_SESSION['captcha_words'] = strtolower($word);
     $prefix = mt_rand();
     $image = $captcha_instance->generate_image($prefix, $word);
     echo json_encode(array('result' => true, 'imagePath' => $image));
     exit;
 }
Пример #3
0
function wpmtst_add_captcha($captcha)
{
    $html = '';
    switch ($captcha) {
        case 'akismet':
            break;
            // Captcha by BestWebSoft
        // Captcha by BestWebSoft
        case 'bwsmath':
            if (function_exists('cptch_display_captcha_custom')) {
                $html .= '<input type="hidden" name="cntctfrm_contact_action" value="true">';
                $html .= cptch_display_captcha_custom();
            }
            break;
            // Really Simple Captcha by Takayuki Miyoshi
        // Really Simple Captcha by Takayuki Miyoshi
        case 'miyoshi':
            if (class_exists('ReallySimpleCaptcha')) {
                $captcha_instance = new ReallySimpleCaptcha();
                $word = $captcha_instance->generate_random_word();
                $prefix = mt_rand();
                $image = $captcha_instance->generate_image($prefix, $word);
                $html .= '<span>' . _x('Input this code:', 'Captcha', 'strong-testimonials') . '&nbsp;<input type="hidden" name="captchac" value="' . $prefix . '"><img class="captcha" src="' . plugins_url('really-simple-captcha/tmp/') . $image . '"></span>';
                $html .= '<input type="text" class="captcha" name="captchar" maxlength="4" size="5">';
            }
            break;
            // Advanced noCaptcha reCaptcha by Shamim Hasan
        // Advanced noCaptcha reCaptcha by Shamim Hasan
        case 'advnore':
            if (function_exists('anr_captcha_form_field')) {
                $html .= anr_captcha_form_field(false);
            }
            break;
        default:
            // no captcha
    }
    return $html;
}
Пример #4
0
    function et_contact_form($atts)
    {
        extract(shortcode_atts(array('class' => ''), $atts));
        $captcha_instance = new ReallySimpleCaptcha();
        $captcha_instance->bg = array(244, 80, 80);
        $word = $captcha_instance->generate_random_word();
        $prefix = mt_rand();
        $img_name = $captcha_instance->generate_image($prefix, $word);
        $captcha_img = ETHEME_CODE_URL . '/inc/really-simple-captcha/tmp/' . $img_name;
        ob_start();
        ?>
        <div id="contactsMsgs"></div>
        <form action="<?php 
        the_permalink();
        ?>
" method="get" id="contact-form" class="contact-form <?php 
        echo $class;
        ?>
">
            
            <div class="form-group">
              <p class="form-name">
                <label for="name" class="control-label"><?php 
        _e('Name and Surname', ETHEME_DOMAIN);
        ?>
 <span class="required">*</span></label>
                <input type="text" name="contact-name" class="required-field form-control" id="contact-name">
              </p>
            </div>

            <div class="form-group">
                <p class="form-name">
                  <label for="contact-email" class="control-label"><?php 
        _e('Email', ETHEME_DOMAIN);
        ?>
 <span class="required">*</span></label>
                  <input type="text" name="contact-email" class="required-field form-control" id="contact-email">
                </p>
            </div>
            
            <div class="form-group">
              <p class="form-name">
                <label for="contact-website" class="control-label"><?php 
        _e('Website', ETHEME_DOMAIN);
        ?>
</label>
                <input type="text" name="contact-website" class="form-control" id="contact-website">
              </p>
            </div>
            

            <div class="form-group">
              <p class="form-textarea">
                <label for="contact_msg" class="control-label"><?php 
        _e('Message', ETHEME_DOMAIN);
        ?>
 <span class="required">*</span></label>
                <textarea name="contact-msg" id="contact-msg" class="required-field form-control" cols="30" rows="7"></textarea>
              </p>
            </div>
            
            <div class="captcha-block">
              <img src="<?php 
        echo $captcha_img;
        ?>
">
              <input type="text" name="captcha-word" class="captcha-input">
              <input type="hidden" name="captcha-prefix" value="<?php 
        echo $prefix;
        ?>
">
            </div>
            
            <p class="pull-right">
              <input type="hidden" name="contact-submit" id="contact-submit" value="true" >
              <span class="spinner"><?php 
        _e('Sending...', ETHEME_DOMAIN);
        ?>
</span>
              <button class="btn btn-black big" id="submit" type="submit"><?php 
        _e('Send message', ETHEME_DOMAIN);
        ?>
</button>
            </p>

            <div class="clearfix"></div>
        </form>
    <?php 
        $output = ob_get_contents();
        ob_end_clean();
        return $output;
    }
function easy_t_outputCaptcha()
{
    if (easy_testimonials_use_recaptcha()) {
        ?>
			<div class="g-recaptcha" data-sitekey="<?php 
        echo htmlentities(get_option('easy_t_recaptcha_api_key', ''));
        ?>
"></div>
			<br />		
		<?php 
    } else {
        if (class_exists('ReallySimpleCaptcha')) {
            // Instantiate the ReallySimpleCaptcha class, which will handle all of the heavy lifting
            $captcha = new ReallySimpleCaptcha();
            // ReallySimpleCaptcha class option defaults.
            // Changing these values will hav no impact. For now, these are here merely for reference.
            // If you want to configure these options, see "Set Really Simple CAPTCHA Options", below
            $captcha_defaults = array('chars' => 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789', 'char_length' => '4', 'img_size' => array('72', '24'), 'fg' => array('0', '0', '0'), 'bg' => array('255', '255', '255'), 'font_size' => '16', 'font_char_width' => '15', 'img_type' => 'png', 'base' => array('6', '18'));
            /**************************************
             * All configurable options are below  *
             ***************************************/
            //Set Really Simple CAPTCHA Options
            $captcha->chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
            $captcha->char_length = '4';
            $captcha->img_size = array('100', '50');
            $captcha->fg = array('0', '0', '0');
            $captcha->bg = array('255', '255', '255');
            $captcha->font_size = '16';
            $captcha->font_char_width = '15';
            $captcha->img_type = 'png';
            $captcha->base = array('6', '18');
            /********************************************************************
             * Nothing else to edit.  No configurable options below this point.  *
             *********************************************************************/
            // Generate random word and image prefix
            $captcha_word = $captcha->generate_random_word();
            $captcha_prefix = mt_rand();
            // Generate CAPTCHA image
            $captcha_image_name = $captcha->generate_image($captcha_prefix, $captcha_word);
            // Define values for CAPTCHA fields
            $captcha_image_url = get_bloginfo('wpurl') . '/wp-content/plugins/really-simple-captcha/tmp/';
            $captcha_image_src = $captcha_image_url . $captcha_image_name;
            $captcha_image_width = $captcha->img_size[0];
            $captcha_image_height = $captcha->img_size[1];
            $captcha_field_size = $captcha->char_length;
            // Output the CAPTCHA fields
            ?>
		<div class="easy_t_field_wrap">
			<img src="<?php 
            echo $captcha_image_src;
            ?>
"
			 alt="captcha"
			 width="<?php 
            echo $captcha_image_width;
            ?>
"
			 height="<?php 
            echo $captcha_image_height;
            ?>
" /><br/>
			<label for="captcha_code"><?php 
            echo get_option('easy_t_captcha_field_label', 'Captcha');
            ?>
</label><br/>
			<input id="captcha_code" name="captcha_code"
			 size="<?php 
            echo $captcha_field_size;
            ?>
" type="text" />
			<p class="easy_t_description"><?php 
            echo get_option('easy_t_captcha_field_description', 'Enter the value in the image above into this field.');
            ?>
</p>
			<input id="captcha_prefix" name="captcha_prefix" type="hidden"
			 value="<?php 
            echo $captcha_prefix;
            ?>
" />
		</div>
		<?php 
        }
    }
}
Пример #6
0
    function et_register_form($args = array())
    {
        $rand = rand(100, 1000);
        $captcha_instance = new ReallySimpleCaptcha();
        $captcha_instance->bg = et_get_captcha_color();
        $word = $captcha_instance->generate_random_word();
        $prefix = mt_rand();
        $img_name = $captcha_instance->generate_image($prefix, $word);
        $captcha_img = ETHEME_CODE_URL . '/inc/really-simple-captcha/tmp/' . $img_name;
        ?>
	        <form class="et-register-form form-<?php 
        echo $rand;
        ?>
" action="" method="get">
            	<div id="register-popup-result"></div> 
	            <div class="login-fields">
	                <p class="form-row">
	                    <label class=""><?php 
        _e("Enter your username", ETHEME_DOMAIN);
        ?>
 <span class="required">*</span></label>
	                    <input type="text" name="username" class="text input-text" />
	                </p>
	                <p class="form-row">
	                    <label class=""><?php 
        _e("Enter your E-mail address", ETHEME_DOMAIN);
        ?>
 <span class="required">*</span></label>
	                    <input type="text" name="email" class="text input-text" />
	                </p>
	                <p class="form-row">
	                    <label class=""><?php 
        _e("Enter your password", ETHEME_DOMAIN);
        ?>
 <span class="required">*</span></label>
	                    <input type="password" name="et_pass" class="text input-text" />
	                </p>
	                <p class="form-row">
	                    <label class=""><?php 
        _e("Re-enter your password", ETHEME_DOMAIN);
        ?>
 <span class="required">*</span></label>
	                    <input type="password" name="et_pass2" class="text input-text" />
	                </p>
	            </div>
				<div class="captcha-block">
					<img src="<?php 
        echo $captcha_img;
        ?>
">
					<input type="text" name="captcha-word" class="captcha-input">
					<input type="hidden" name="captcha-prefix" value="<?php 
        echo $prefix;
        ?>
">
				</div>
	            <p class="form-row right">
	                <input type="hidden" name="et_register" value="1">
	                <button class="btn btn-black big text-center submitbtn" type="submit"><span><?php 
        _e("Register", ETHEME_DOMAIN);
        ?>
</span></button>
	            </p>
	        </form>
	        <script type="text/javascript">
	        	jQuery(function($){
		        	$('.form-<?php 
        echo $rand;
        ?>
').submit(function(e) {
			        	e.preventDefault();
			        	$('.form-<?php 
        echo $rand;
        ?>
 div#register-popup-result').html('<img src="<?php 
        echo get_template_directory_uri();
        ?>
/images/loading.gif" class="loader" />').fadeIn();
		                var input_data = $(this).serialize();
		                input_data += '&action=et_register_action';
		                $.ajax({
		                    type: "GET",
		                    dataType: "JSON",
		                    url: "<?php 
        echo admin_url('admin-ajax.php');
        ?>
",
		                    data: input_data,
		                    success: function(response){
		                        $('.loader').remove();
		                        if(response.status == 'error') {
		                        	var msgHtml = '<span class="error">' + response.msg + '</span>';
		                            $('<div>').html(msgHtml).appendTo('.form-<?php 
        echo $rand;
        ?>
 div#register-popup-result').hide().fadeIn('slow');
		                            
		                        } else {
		                        	var msgHtml = '<span class="success">' + response.msg + '</span>';
		                            $('<div>').html(msgHtml).appendTo('.form-<?php 
        echo $rand;
        ?>
 div#register-popup-result').hide().fadeIn('slow');
		                            $(this).find("input[type=text], input[type=password], textarea").val("");
		                        }
		                    }
		                });
			        	
		        	});
	        	}, jQuery);
	        </script>
		<?php 
    }
Пример #7
0
                    <div class="sam_field">
                        <textarea class="big_area" name="comment" cols="" rows=""></textarea>
                    </div>
                    <!-- END .sam_field -->
                </div>
                <!-- END .field_b -->
                <!-- END .pos_boxObz-->
                <div class="title_verif_b">
                    <span class="formBlack12"><?php 
        echo get_translation('contact_form_feedback_symbols');
        ?>
:</span>
                </div>
                <?php 
        $captcha_instance = new ReallySimpleCaptcha();
        $word = $captcha_instance->generate_random_word();
        $_SESSION['captcha_words'] = strtolower($word);
        $prefix = mt_rand();
        $image = $captcha_instance->generate_image($prefix, $word);
        ?>
                <!-- END .title_verif_b -->
                <div class="box_verif">
                    <img id="captchaImg" src="<?php 
        echo $image;
        ?>
" width="78" height="24">
                </div>
                <!-- end .box_verif -->
                <a class="chImg" href="javascript:;" onclick="contactObj.reloadCaptcha();"><?php 
        echo get_translation('contact_form_feedback_change_image');
        ?>
/**
 * Add Really Simple CAPTCHA to the comment form, using the comment_form_after_fields hook.
 * http://wordpress.org/extend/plugins/really-simple-captcha/
 */
function cbnet_rscc_captcha()
{
    if (!is_user_logged_in() && class_exists('ReallySimpleCaptcha')) {
        // Instantiate the ReallySimpleCaptcha class, which will handle all of the heavy lifting
        $cbnet_rscc_captcha = new ReallySimpleCaptcha();
        // Get Plugin options
        global $cbnet_rscc_options;
        /************************************************************
         * All configurable options are below  *
         ************************************************************/
        // Set Really Simple CAPTCHA Options
        $cbnet_rscc_captcha->chars = $cbnet_rscc_options['chars'];
        //'ABCDEFGHJKLMNPQRSTUVWXYZ23456789'
        $cbnet_rscc_captcha->char_length = $cbnet_rscc_options['char_length'];
        //'4'
        $cbnet_rscc_captcha->img_size = array($cbnet_rscc_options['img_size_x'], $cbnet_rscc_options['img_size_y']);
        //array( '72', '24' )
        $cbnet_rscc_captcha->fg = array($cbnet_rscc_options['fg_r'], $cbnet_rscc_options['fg_g'], $cbnet_rscc_options['fg_b']);
        //array( '0', '0', '0' )
        $cbnet_rscc_captcha->bg = array($cbnet_rscc_options['bg_r'], $cbnet_rscc_options['bg_g'], $cbnet_rscc_options['bg_b']);
        //array( '255', '255', '255' )
        $cbnet_rscc_captcha->font_size = $cbnet_rscc_options['font_size'];
        //'16'
        $cbnet_rscc_captcha->font_char_width = $cbnet_rscc_options['font_char_width'];
        //'15'
        $cbnet_rscc_captcha->img_type = $cbnet_rscc_options['img_type'];
        //'png'
        $cbnet_rscc_captcha->base = $cbnet_rscc_options['base'];
        //array( '6', '18' )
        // Set Comment Form Options
        $cbnet_rscc_captcha_form_label = $cbnet_rscc_options['comment_form_label'];
        //'Anti-Spam:'
        /************************************************************
         * Nothing else to edit.  No configurable options below this point.  *
         ************************************************************/
        // Generate random word and image prefix
        $cbnet_rscc_captcha_word = $cbnet_rscc_captcha->generate_random_word();
        $cbnet_rscc_captcha_prefix = mt_rand();
        // Generate CAPTCHA image
        $cbnet_rscc_captcha_image_name = $cbnet_rscc_captcha->generate_image($cbnet_rscc_captcha_prefix, $cbnet_rscc_captcha_word);
        // Define values for comment form CAPTCHA fields
        $cbnet_rscc_captcha_image_url = get_bloginfo('wpurl') . '/wp-content/plugins/really-simple-captcha/tmp/';
        $cbnet_rscc_captcha_image_src = $cbnet_rscc_captcha_image_url . $cbnet_rscc_captcha_image_name;
        $cbnet_rscc_captcha_image_width = $cbnet_rscc_captcha->img_size[0];
        $cbnet_rscc_captcha_image_height = $cbnet_rscc_captcha->img_size[1];
        $cbnet_rscc_captcha_field_size = $cbnet_rscc_captcha->char_length;
        // AJAX url
        $cbnet_rscc_captcha_ajax_url = plugin_dir_url(__FILE__) . 'ajaxresponse.php';
        // ABSPATH
        $cbnet_rscc_abspath = urlencode(ABSPATH);
        // Output the comment form CAPTCHA fields
        ?>
		<script>
		function cbnetRsccInlineCaptchaCheck( code, prefix, url, abspath ) {
			// Setup variables
			var code_string = '?code=' + code;
			var prefix_string = '&prefix=' + prefix;
			var abspath_string = '&abspath=' + abspath;
			var request_url_base = url;
			var request_url = request_url_base + code_string + prefix_string + abspath_string;
			
			// Instantiate request
			var xmlhttp = new XMLHttpRequest();
			
			// Parse resonse
			xmlhttp.onreadystatechange=function() { 
				if ( 4 == xmlhttp.readyState && 200 ==xmlhttp.status ) {
					var ajax_response = xmlhttp.responseText;
					
					// Update form verification feedback
					if ( 'true' == ajax_response ) {
						document.getElementById( 'cbnet-rscc-captcha-verify' ).innerHTML = '<span style="color:green">Correcto!</span>';
						document.getElementById( 'comment_captcha_code' ).style.background = '#ccffcc';
					} else if ( 'false' == ajax_response ) {
						document.getElementById( 'cbnet-rscc-captcha-verify' ).innerHTML = '<span style="color:red">Incorrecto! intente nuevamente</span>';
						document.getElementById( 'comment_captcha_code' ).style.background = '#ffccff';
					}				
				}
			}
			// Send request
			xmlhttp.open( 'GET', request_url, true );
			xmlhttp.send();
		}
		</script>
		<p class="comment-form-captcha"><img src="<?php 
        echo $cbnet_rscc_captcha_image_src;
        ?>
" alt="captcha" width="<?php 
        echo $cbnet_rscc_captcha_image_width;
        ?>
" height="<?php 
        echo $cbnet_rscc_captcha_image_height;
        ?>
" />
			<label for="captcha_code"><?php 
        echo $cbnet_rscc_captcha_form_label;
        ?>
</label>
			<?php 
        echo "<input type='text' name='comment_captcha_code' id='comment_captcha_code' value='' size='{$cbnet_rscc_captcha_field_size}' onblur='cbnetRsccInlineCaptchaCheck( this.value, \"{$cbnet_rscc_captcha_prefix}\", \"{$cbnet_rscc_captcha_ajax_url}\", \"{$cbnet_rscc_abspath}\" )' />";
        ?>
			<input type="hidden" name="comment_captcha_prefix" id="comment_captcha_prefix" value="<?php 
        echo $cbnet_rscc_captcha_prefix;
        ?>
" />
			<p id="cbnet-rscc-captcha-verify">Por favor introduce el texto que aparece en la imagen</p>
		</p>
	<?php 
    }
}
 private function load_si_captcha()
 {
     if (class_exists('ReallySimpleCaptcha')) {
         $captcha_instance = new ReallySimpleCaptcha();
         $captcha_instance->bg = array(0, 0, 0);
         $word = $captcha_instance->generate_random_word();
         $prefix = mt_rand();
         return $captcha_instance->generate_image($prefix, $word);
     } else {
         return '';
     }
 }
Пример #10
0
function gwolle_gb_frontend_write()
{
    global $gwolle_gb_errors, $gwolle_gb_error_fields, $gwolle_gb_messages, $gwolle_gb_data;
    $output = '';
    // Set data up for refilling an already submitted form that had errors
    $name = '';
    $origin = '';
    $email = '';
    $website = '';
    $antispam = '';
    $content = '';
    // Auto-fill the form if the user is already logged in
    $user_id = get_current_user_id();
    // returns 0 if no current user
    if ($user_id > 0) {
        $userdata = get_userdata($user_id);
        if (is_object($userdata)) {
            if (isset($userdata->display_name)) {
                $name = $userdata->display_name;
            } else {
                $name = $userdata->user_login;
            }
            $email = $userdata->user_email;
            $website = $userdata->user_url;
        }
    }
    // Only show old data when there are errors
    if ($gwolle_gb_errors) {
        if (is_array($gwolle_gb_data) && !empty($gwolle_gb_data)) {
            if (isset($gwolle_gb_data['author_name'])) {
                $name = stripslashes($gwolle_gb_data['author_name']);
            }
            if (isset($gwolle_gb_data['author_origin'])) {
                $origin = stripslashes($gwolle_gb_data['author_origin']);
            }
            if (isset($gwolle_gb_data['author_email'])) {
                $email = stripslashes($gwolle_gb_data['author_email']);
            }
            if (isset($gwolle_gb_data['author_website'])) {
                $website = stripslashes($gwolle_gb_data['author_website']);
            }
            if (isset($gwolle_gb_data['antispam'])) {
                $antispam = stripslashes($gwolle_gb_data['antispam']);
            }
            if (isset($gwolle_gb_data['content'])) {
                $content = stripslashes($gwolle_gb_data['content']);
            }
        }
    }
    // Initialize errors, if not set
    if (empty($gwolle_gb_error_fields)) {
        $gwolle_gb_error_fields = array();
    }
    /*
     * Handle Messaging to the user
     */
    $class = "";
    if ($gwolle_gb_errors) {
        $class = "error";
    }
    if (isset($gwolle_gb_messages) && $gwolle_gb_messages != '') {
        $output .= "<div id='gwolle_gb_messages' class='{$class}'>";
        $output .= $gwolle_gb_messages;
        $output .= "</div>";
    }
    /*
     * Button 'write a new entry.'
     */
    $output .= '
		<div id="gwolle_gb_write_button">
			<input type="button" value="&raquo; ' . esc_attr__('Write a new entry.', GWOLLE_GB_TEXTDOMAIN) . '" />
		</div>';
    // Option to allow only logged-in users to post. Don't show the form if not logged-in. We still see the messages above.
    if (!is_user_logged_in() && get_option('gwolle_gb-require_login', 'false') == 'true') {
        $output .= '
			<div id="gwolle_gb_new_entry">
				<h3>' . __('Log in to post an entry', GWOLLE_GB_TEXTDOMAIN) . '</h3>';
        $args = array('echo' => false, 'redirect' => (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
        $output .= wp_login_form($args);
        $output .= wp_register('', '', false);
        $output .= '</div>';
        return $output;
    }
    /*
     * Build up Form including possible error_fields
     */
    $form_setting = gwolle_gb_get_setting('form');
    $autofocus = 'autofocus="autofocus"';
    // Form for submitting new entries
    $header = gwolle_gb_sanitize_output(get_option('gwolle_gb-header', false));
    if ($header == false) {
        $header = __('Write a new entry for the Guestbook', GWOLLE_GB_TEXTDOMAIN);
    }
    $output .= '
		<form id="gwolle_gb_new_entry" action="#" method="POST">
			<h3>' . $header . '</h3>
			<input type="hidden" name="gwolle_gb_function" value="add_entry" />';
    /* Name */
    if (isset($form_setting['form_name_enabled']) && $form_setting['form_name_enabled'] === 'true') {
        $output .= '<div class="gwolle_gb_author_name">
				<div class="label"><label for="gwolle_gb_author_name">' . __('Name', GWOLLE_GB_TEXTDOMAIN) . ':';
        if (isset($form_setting['form_name_mandatory']) && $form_setting['form_name_mandatory'] === 'true') {
            $output .= ' *';
        }
        $output .= '</label></div>
				<div class="input"><input class="';
        if (in_array('name', $gwolle_gb_error_fields)) {
            $output .= ' error';
        }
        $output .= '" value="' . $name . '" type="text" name="gwolle_gb_author_name" id="gwolle_gb_author_name" placeholder="' . __('Name', GWOLLE_GB_TEXTDOMAIN) . '" ';
        if (in_array('name', $gwolle_gb_error_fields) && isset($autofocus)) {
            $output .= $autofocus;
            $autofocus = false;
            // disable it for the next error.
        }
        $output .= ' /></div>
			</div>
			<div class="clearBoth">&nbsp;</div>';
    }
    /* City / Origin */
    if (isset($form_setting['form_city_enabled']) && $form_setting['form_city_enabled'] === 'true') {
        $output .= '<div class="gwolle_gb_author_origin">
					<div class="label"><label for="gwolle_gb_author_origin">' . __('City', GWOLLE_GB_TEXTDOMAIN) . ':';
        if (isset($form_setting['form_city_mandatory']) && $form_setting['form_city_mandatory'] === 'true') {
            $output .= ' *';
        }
        $output .= '</label></div>
					<div class="input"><input class="';
        if (in_array('author_origin', $gwolle_gb_error_fields)) {
            $output .= ' error';
        }
        $output .= '" value="' . $origin . '" type="text" name="gwolle_gb_author_origin" id="gwolle_gb_author_origin" placeholder="' . __('City', GWOLLE_GB_TEXTDOMAIN) . '" ';
        if (in_array('author_origin', $gwolle_gb_error_fields) && isset($autofocus)) {
            $output .= $autofocus;
            $autofocus = false;
            // disable it for the next error.
        }
        $output .= ' /></div>
				</div>
				<div class="clearBoth">&nbsp;</div>';
    }
    /* Email */
    if (isset($form_setting['form_email_enabled']) && $form_setting['form_email_enabled'] === 'true') {
        $output .= '<div class="gwolle_gb_author_email">
				<div class="label"><label for="gwolle_gb_author_email">' . __('Email', GWOLLE_GB_TEXTDOMAIN) . ':';
        if (isset($form_setting['form_email_mandatory']) && $form_setting['form_email_mandatory'] === 'true') {
            $output .= ' *';
        }
        $output .= '</label></div>
				<div class="input"><input class="';
        if (in_array('author_email', $gwolle_gb_error_fields)) {
            $output .= ' error';
        }
        $output .= '" value="' . $email . '" type="text" name="gwolle_gb_author_email" id="gwolle_gb_author_email" placeholder="' . __('Email', GWOLLE_GB_TEXTDOMAIN) . '" ';
        if (in_array('author_email', $gwolle_gb_error_fields) && isset($autofocus)) {
            $output .= $autofocus;
            $autofocus = false;
            // disable it for the next error.
        }
        $output .= ' /></div>
			</div>
			<div class="clearBoth">&nbsp;</div>';
    }
    /* Website / Homepage */
    if (isset($form_setting['form_homepage_enabled']) && $form_setting['form_homepage_enabled'] === 'true') {
        $output .= '<div class="gwolle_gb_author_website">
				<div class="label"><label for="gwolle_gb_author_website">' . __('Website', GWOLLE_GB_TEXTDOMAIN) . ':';
        if (isset($form_setting['form_homepage_mandatory']) && $form_setting['form_homepage_mandatory'] === 'true') {
            $output .= ' *';
        }
        $output .= '</label></div>
				<div class="input"><input class="';
        if (in_array('author_website', $gwolle_gb_error_fields)) {
            $output .= ' error';
        }
        $output .= '" value="' . $website . '" type="text" name="gwolle_gb_author_website" id="gwolle_gb_author_website" placeholder="' . __('Website', GWOLLE_GB_TEXTDOMAIN) . '" ';
        if (in_array('author_website', $gwolle_gb_error_fields) && isset($autofocus)) {
            $output .= $autofocus;
            $autofocus = false;
            // disable it for the next error.
        }
        $output .= ' /></div>
			</div>
			<div class="clearBoth">&nbsp;</div>';
    }
    /* Content */
    if (isset($form_setting['form_message_enabled']) && $form_setting['form_message_enabled'] === 'true') {
        $output .= '<div class="gwolle_gb_content">
				<div class="label"><label for="gwolle_gb_content">' . __('Guestbook entry', GWOLLE_GB_TEXTDOMAIN) . ':';
        if (isset($form_setting['form_message_mandatory']) && $form_setting['form_message_mandatory'] === 'true') {
            $output .= ' *';
        }
        $output .= '</label></div>
				<div class="input"><textarea name="gwolle_gb_content" id="gwolle_gb_content" class="';
        if (in_array('content', $gwolle_gb_error_fields)) {
            $output .= ' error';
        }
        $output .= '" placeholder="' . __('Message', GWOLLE_GB_TEXTDOMAIN) . '" ';
        if (in_array('content', $gwolle_gb_error_fields) && isset($autofocus)) {
            $output .= $autofocus;
            $autofocus = false;
            // disable it for the next error.
        }
        $output .= ' >' . $content . '</textarea>';
        if (isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true') {
            // BBcode and MarkItUp
            wp_enqueue_script('markitup', plugins_url('markitup/jquery.markitup.js', __FILE__), 'jquery', GWOLLE_GB_VER, false);
            wp_enqueue_script('markitup_set', plugins_url('markitup/set.js', __FILE__), 'jquery', GWOLLE_GB_VER, false);
            wp_enqueue_style('gwolle_gb_markitup_css', plugins_url('markitup/style.css', __FILE__), false, GWOLLE_GB_VER, 'screen');
            // Emoji symbols
            $output .= '<div class="gwolle_gb_emoji" style="display:none;">';
            $output .= gwolle_gb_get_emoji();
            $output .= '</div>';
        }
        $output .= '</div>';
        // .input
        $output .= '
				</div>
			<div class="clearBoth">&nbsp;</div>';
    }
    /* Custom Anti-Spam */
    if (isset($form_setting['form_antispam_enabled']) && $form_setting['form_antispam_enabled'] === 'true') {
        $antispam_question = gwolle_gb_sanitize_output(get_option('gwolle_gb-antispam-question'));
        $antispam_answer = gwolle_gb_sanitize_output(get_option('gwolle_gb-antispam-answer'));
        if (isset($antispam_question) && strlen($antispam_question) > 0 && isset($antispam_answer) && strlen($antispam_answer) > 0) {
            $output .= '
				<div class="gwolle_gb_antispam">
					<div class="label">
						<label for="gwolle_gb_antispam_answer">' . __('Anti-spam', GWOLLE_GB_TEXTDOMAIN) . ': *<br />
						' . __('Question:', GWOLLE_GB_TEXTDOMAIN) . " " . $antispam_question . '</label>
					</div>
					<div class="input"><input class="';
            if (in_array('antispam', $gwolle_gb_error_fields)) {
                $output .= ' error';
            }
            $output .= '" value="' . $antispam . '" type="text" name="gwolle_gb_antispam_answer" id="gwolle_gb_antispam_answer" placeholder="' . __('Answer', GWOLLE_GB_TEXTDOMAIN) . '" ';
            if (in_array('antispam', $gwolle_gb_error_fields) && isset($autofocus)) {
                $output .= $autofocus;
                $autofocus = false;
                // disable it for the next error.
            }
            $output .= ' />
						</div>
					</div>
					<div class="clearBoth">&nbsp;</div>';
        }
    }
    /* CAPTCHA */
    if (isset($form_setting['form_recaptcha_enabled']) && $form_setting['form_recaptcha_enabled'] === 'true') {
        if (class_exists('ReallySimpleCaptcha')) {
            // Instantiate the ReallySimpleCaptcha class, which will handle all of the heavy lifting
            $gwolle_gb_captcha = new ReallySimpleCaptcha();
            // Set Really Simple CAPTCHA Options
            $gwolle_gb_captcha->chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
            $gwolle_gb_captcha->char_length = '4';
            $gwolle_gb_captcha->img_size = array('72', '24');
            $gwolle_gb_captcha->fg = array('0', '0', '0');
            $gwolle_gb_captcha->bg = array('255', '255', '255');
            $gwolle_gb_captcha->font_size = '16';
            $gwolle_gb_captcha->font_char_width = '15';
            $gwolle_gb_captcha->img_type = 'png';
            $gwolle_gb_captcha->base = array('6', '18');
            // Generate random word and image prefix
            $gwolle_gb_captcha_word = $gwolle_gb_captcha->generate_random_word();
            $gwolle_gb_captcha_prefix = mt_rand();
            // Generate CAPTCHA image
            $gwolle_gb_captcha_image_name = $gwolle_gb_captcha->generate_image($gwolle_gb_captcha_prefix, $gwolle_gb_captcha_word);
            // Define values for CAPTCHA fields
            $gwolle_gb_captcha_image_url = get_bloginfo('wpurl') . '/wp-content/plugins/really-simple-captcha/tmp/';
            $gwolle_gb_captcha_image_src = $gwolle_gb_captcha_image_url . $gwolle_gb_captcha_image_name;
            $gwolle_gb_captcha_image_width = $gwolle_gb_captcha->img_size[0];
            $gwolle_gb_captcha_image_height = $gwolle_gb_captcha->img_size[1];
            $gwolle_gb_captcha_field_size = $gwolle_gb_captcha->char_length;
            // AJAX url
            $gwolle_gb_captcha_ajax_url = GWOLLE_GB_URL . '/frontend/captcha/ajaxresponse.php';
            // ABSPATH
            $gwolle_gb_abspath = urlencode(ABSPATH);
            // Output the CAPTCHA fields
            ?>
			<script>
			function gwolle_gb_captcha_check( code, prefix, url, abspath ) {
				// Setup variables
				var code_string = '?code=' + code;
				var prefix_string = '&prefix=' + prefix;
				var abspath_string = '&abspath=' + abspath;
				var request_url_base = url;
				var request_url = request_url_base + code_string + prefix_string + abspath_string;

				// Instantiate request
				var xmlhttp = new XMLHttpRequest();

				// Parse resonse
				xmlhttp.onreadystatechange = function() {
					if ( 4 == xmlhttp.readyState && 200 == xmlhttp.status ) {
						var ajax_response = xmlhttp.responseText;

						// Update form verification feedback
						if ( 'true' == ajax_response ) {
							document.getElementById( 'gwolle_gb_captcha_verify' ).innerHTML = '<span style="color:green"><?php 
            _e('Correct CAPTCHA value.', GWOLLE_GB_TEXTDOMAIN);
            ?>
</span>';
							jQuery( '#gwolle_gb_captcha_code' ).removeClass('error');
						} else if ( 'false' == ajax_response ) {
							document.getElementById( 'gwolle_gb_captcha_verify' ).innerHTML = '<span style="color:red"><?php 
            _e('Incorrect CAPTCHA value.', GWOLLE_GB_TEXTDOMAIN);
            ?>
</span>';
							jQuery( '#gwolle_gb_captcha_code' ).addClass('error');
						}
					}
				}
				// Send request
				xmlhttp.open( 'GET', request_url, true );
				xmlhttp.send();
			}
			</script>

			<?php 
            $output .= '
				<div class="gwolle_gb_captcha">
					<div class="label">
						<label for="gwolle_gb_captcha_code">' . __('Anti-spam', GWOLLE_GB_TEXTDOMAIN) . ': *<br />
						<img src="' . $gwolle_gb_captcha_image_src . '" alt="captcha" width="' . $gwolle_gb_captcha_image_width . '" height="' . $gwolle_gb_captcha_image_height . '" />
						</label>
					</div>
					<div class="input">
					<input class="';
            if (in_array('captcha', $gwolle_gb_error_fields)) {
                $output .= 'error';
            }
            $output .= '" value="" type="text" name="gwolle_gb_captcha_code" id="gwolle_gb_captcha_code" placeholder="' . __('CAPTCHA', GWOLLE_GB_TEXTDOMAIN) . '" onblur="gwolle_gb_captcha_check( this.value, \'' . $gwolle_gb_captcha_prefix . '\', \'' . $gwolle_gb_captcha_ajax_url . '\', \'' . $gwolle_gb_abspath . '\' )" ';
            if (in_array('captcha', $gwolle_gb_error_fields) && isset($autofocus)) {
                $output .= $autofocus;
                $autofocus = false;
                // disable it for the next error.
            }
            $output .= ' />
							<input type="hidden" name="gwolle_gb_captcha_prefix" id="gwolle_gb_captcha_prefix" value="' . $gwolle_gb_captcha_prefix . '" />
							<span id="gwolle_gb_captcha_verify"></span>
						</div>
					</div>
					<div class="clearBoth">&nbsp;</div>';
        }
    }
    $output .= '
			<div class="gwolle_gb_submit">
				<div class="label">&nbsp;</div>
				<div class="input"><input type="submit" name="gwolle_gb_submit" value="' . esc_attr__('Submit', GWOLLE_GB_TEXTDOMAIN) . '" /></div>
			</div>
			<div class="clearBoth">&nbsp;</div>

			<div class="gwolle_gb_notice">
				';
    $notice = gwolle_gb_sanitize_output(get_option('gwolle_gb-notice', false));
    if ($notice == false) {
        // No text set by the user. Use the default text.
        $notice = __('
Fields marked with * are obligatory.
Your E-mail address wil not be published.
For security reasons we save the ip address %ip%.
It might be that your entry will only be visible in the guestbook after we reviewed it.
We reserve our right to edit, delete, or not publish entries.
', GWOLLE_GB_TEXTDOMAIN);
    }
    $notice = nl2br($notice);
    $output .= str_replace('%ip%', $_SERVER['REMOTE_ADDR'], $notice);
    $output .= '
			</div>
		</form>';
    if (get_option('gwolle_gb-labels_float', 'true') === 'true') {
        $output .= '
		<style type="text/css" scoped>
			#gwolle_gb .label,
			#gwolle_gb .input {
				float: left;
			}
		</style>
		';
    }
    // Add filter for the form, so devs can manipulate it.
    $output = apply_filters('gwolle_gb_write', $output);
    return $output;
}
Пример #11
0
    /**
     * Prints really simple captcha
     *
     * @param array $attr
     * @param int|null $post_id
     */
    function really_simple_captcha($attr, $post_id, $form_id)
    {
        if ($post_id) {
            return;
        }
        if (!class_exists('ReallySimpleCaptcha')) {
            ?>
            <div class="wpuf-fields <?php 
            echo ' wpuf_' . $attr['name'] . '_' . $form_id;
            ?>
">
            <?php 
            _e('Error: Really Simple Captcha plugin not found!', 'wpuf');
            ?>
            </div>
            <?php 
            return;
        }
        $captcha_instance = new ReallySimpleCaptcha();
        $word = $captcha_instance->generate_random_word();
        $prefix = mt_rand();
        $image_num = $captcha_instance->generate_image($prefix, $word);
        ?>
        <div class="wpuf-fields <?php 
        echo ' wpuf_' . $attr['name'] . '_' . $form_id;
        ?>
">
            <img src="<?php 
        echo plugins_url('really-simple-captcha/tmp/' . $image_num);
        ?>
" alt="Captcha" />
            <input type="text" name="rs_captcha" value="" />
            <input type="hidden" name="rs_captcha_val" value="<?php 
        echo $prefix;
        ?>
" />
        </div>
        <?php 
    }
Пример #12
0
function mytheme_comment_captcha()
{
    $comment_captcha = new ReallySimpleCaptcha();
    // Characters to use in CAPTCHA image.
    $comment_captcha->chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
    // Number of characters in CAPTCHA image.
    $comment_captcha->char_length = '4';
    // Width/Height dimensions of CAPTCHA image.
    $comment_captcha->img_size = array('85', '24');
    // Font color of CAPTCHA characters, in RGB (0 - 255).
    $comment_captcha->fg = array('0', '0', '0');
    // Background color of CAPTCHA image, in RGB (0 - 255).
    $comment_captcha->bg = array('255', '255', '255');
    // Font Size of CAPTCHA characters.
    $comment_captcha->font_size = '20';
    // Width between CAPTCHA characters.
    $comment_captcha->font_char_width = '18';
    // CAPTCHA image type. Can be 'png', 'jpeg', or 'gif'
    $comment_captcha->img_type = 'png';
    // Generate random word and image prefix
    $comment_captcha_word = $comment_captcha->generate_random_word();
    $comment_captcha_prefix = mt_rand();
    // Generate CAPTCHA image
    $comment_captcha_image_name = $comment_captcha->generate_image($comment_captcha_prefix, $comment_captcha_word);
    $comment_captcha_image_url = get_bloginfo('wpurl') . '/wp-content/plugins/really-simple-captcha/tmp/';
    $comment_captcha_image_src = $comment_captcha_image_url . $comment_captcha_image_name;
    $comment_captcha_image_width = $comment_captcha->img_size[0];
    $comment_captcha_image_height = $comment_captcha->img_size[1];
    $comment_captcha_field_size = $comment_captcha->char_length;
    $comment_captcha_form_label = 'Anti-Spam* (lowercase):';
    ?>
<p class="comment-form-captcha">

<img src="<?php 
    echo $comment_captcha_image_src;
    ?>
" alt="captcha" width="<?php 
    echo $comment_captcha_image_width;
    ?>
" height="<?php 
    echo $comment_captcha_image_height;
    ?>
" />

<label for="captcha_code"><?php 
    echo $comment_captcha_form_label;
    ?>
</label>

<input id="comment_captcha_code" class = "required" remote = "" name="comment_captcha_code" size="<?php 
    echo $comment_captcha_field_size;
    ?>
" type="text" />

<input id="comment_captcha_prefix" name="comment_captcha_prefix" type="hidden" value="<?php 
    echo $comment_captcha_prefix;
    ?>
" /></p>

<?php 
}
Пример #13
0
function gwolle_gb_frontend_write($shortcode_atts)
{
    global $gwolle_gb_errors, $gwolle_gb_error_fields, $gwolle_gb_messages, $gwolle_gb_data;
    $html5 = current_theme_supports('html5');
    $output = '';
    // Set data up for refilling an already submitted form that had errors
    $name = '';
    $origin = '';
    $email = '';
    $website = '';
    $antispam = '';
    $content = '';
    // Auto-fill the form if the user is already logged in
    $user_id = get_current_user_id();
    // returns 0 if no current user
    if ($user_id > 0) {
        $userdata = get_userdata($user_id);
        if (is_object($userdata)) {
            if (isset($userdata->display_name)) {
                $name = $userdata->display_name;
            } else {
                $name = $userdata->user_login;
            }
            $email = $userdata->user_email;
            $website = $userdata->user_url;
        }
    }
    // Only show old data when there are errors
    if ($gwolle_gb_errors) {
        if (is_array($gwolle_gb_data) && !empty($gwolle_gb_data)) {
            if (isset($gwolle_gb_data['author_name'])) {
                $name = stripslashes($gwolle_gb_data['author_name']);
            }
            if (isset($gwolle_gb_data['author_origin'])) {
                $origin = stripslashes($gwolle_gb_data['author_origin']);
            }
            if (isset($gwolle_gb_data['author_email'])) {
                $email = stripslashes($gwolle_gb_data['author_email']);
            }
            if (isset($gwolle_gb_data['author_website'])) {
                $website = stripslashes($gwolle_gb_data['author_website']);
            }
            if (isset($gwolle_gb_data['antispam'])) {
                $antispam = stripslashes($gwolle_gb_data['antispam']);
            }
            if (isset($gwolle_gb_data['content'])) {
                $content = stripslashes($gwolle_gb_data['content']);
            }
        }
    }
    // Initialize errors, if not set
    if (empty($gwolle_gb_error_fields)) {
        $gwolle_gb_error_fields = array();
    }
    /*
     * Handle Messaging to the user
     */
    $class = "";
    if ($gwolle_gb_errors) {
        $class = "error";
    }
    if (isset($gwolle_gb_messages) && $gwolle_gb_messages != '') {
        $output .= "<div id='gwolle_gb_messages' class='{$class}'>";
        $output .= $gwolle_gb_messages;
        $output .= "</div>";
    }
    /*
     * Button 'write a new entry.'
     */
    $output .= '
		<div id="gwolle_gb_write_button">
			<input type="button" value="&raquo; ' . esc_attr__('Write a new entry.', 'gwolle-gb') . '" />
		</div>';
    // Option to allow only logged-in users to post. Don't show the form if not logged-in. We still see the messages above.
    if (!is_user_logged_in() && get_option('gwolle_gb-require_login', 'false') == 'true') {
        $output .= '
			<div id="gwolle_gb_new_entry">
				<h3>' . __('Log in to post an entry', 'gwolle-gb') . '</h3>';
        $args = array('echo' => false, 'redirect' => (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
        $output .= wp_login_form($args);
        $output .= wp_register('', '', false);
        $output .= '</div>';
        return $output;
    }
    /*
     * Build up Form including possible error_fields
     */
    $form_setting = gwolle_gb_get_setting('form');
    $autofocus = 'autofocus="autofocus"';
    // Form for submitting new entries
    $header = gwolle_gb_sanitize_output(get_option('gwolle_gb-header', false));
    if ($header == false) {
        $header = __('Write a new entry for the Guestbook', 'gwolle-gb');
    }
    $output .= '
		<form id="gwolle_gb_new_entry" action="#" method="POST">
			<h3>' . $header . '</h3>
			<input type="hidden" name="gwolle_gb_function" id="gwolle_gb_function" value="add_entry" />';
    // The book_id from the shortcode, to be used by the posthandling function again.
    $output .= '<input type="hidden" name="gwolle_gb_book_id" id="gwolle_gb_book_id" value="' . $shortcode_atts['book_id'] . '" />';
    // Use this filter to just add something
    $output .= apply_filters('gwolle_gb_write_add_before', '');
    /* Name */
    if (isset($form_setting['form_name_enabled']) && $form_setting['form_name_enabled'] === 'true') {
        $output .= '<div class="gwolle_gb_author_name">
				<div class="label"><label for="gwolle_gb_author_name">' . __('Name', 'gwolle-gb') . ':';
        if (isset($form_setting['form_name_mandatory']) && $form_setting['form_name_mandatory'] === 'true') {
            $output .= ' *';
        }
        $output .= '</label></div>
				<div class="input"><input class="';
        if (in_array('name', $gwolle_gb_error_fields)) {
            $output .= ' error';
        }
        $output .= '" value="' . $name . '" type="text" name="gwolle_gb_author_name" id="gwolle_gb_author_name" placeholder="' . __('Name', 'gwolle-gb') . '" ';
        if (in_array('name', $gwolle_gb_error_fields) && isset($autofocus)) {
            $output .= $autofocus;
            $autofocus = false;
            // disable it for the next error.
        }
        $output .= ' /></div>
			</div>
			<div class="clearBoth">&nbsp;</div>';
    }
    /* City / Origin */
    if (isset($form_setting['form_city_enabled']) && $form_setting['form_city_enabled'] === 'true') {
        $output .= '<div class="gwolle_gb_author_origin">
					<div class="label"><label for="gwolle_gb_author_origin">' . __('City', 'gwolle-gb') . ':';
        if (isset($form_setting['form_city_mandatory']) && $form_setting['form_city_mandatory'] === 'true') {
            $output .= ' *';
        }
        $output .= '</label></div>
					<div class="input"><input class="';
        if (in_array('author_origin', $gwolle_gb_error_fields)) {
            $output .= ' error';
        }
        $output .= '" value="' . $origin . '" type="text" name="gwolle_gb_author_origin" id="gwolle_gb_author_origin" placeholder="' . __('City', 'gwolle-gb') . '" ';
        if (in_array('author_origin', $gwolle_gb_error_fields) && isset($autofocus)) {
            $output .= $autofocus;
            $autofocus = false;
            // disable it for the next error.
        }
        $output .= ' /></div>
				</div>
				<div class="clearBoth">&nbsp;</div>';
    }
    /* Email */
    if (isset($form_setting['form_email_enabled']) && $form_setting['form_email_enabled'] === 'true') {
        $output .= '<div class="gwolle_gb_author_email">
				<div class="label"><label for="gwolle_gb_author_email">' . __('Email', 'gwolle-gb') . ':';
        if (isset($form_setting['form_email_mandatory']) && $form_setting['form_email_mandatory'] === 'true') {
            $output .= ' *';
        }
        $output .= '</label></div>
				<div class="input"><input class="';
        if (in_array('author_email', $gwolle_gb_error_fields)) {
            $output .= ' error';
        }
        $output .= '" value="' . $email . '" ' . ($html5 ? 'type="email"' : 'type="text"') . ' name="gwolle_gb_author_email" id="gwolle_gb_author_email" placeholder="' . __('Email', 'gwolle-gb') . '" ';
        if (in_array('author_email', $gwolle_gb_error_fields) && isset($autofocus)) {
            $output .= $autofocus;
            $autofocus = false;
            // disable it for the next error.
        }
        $output .= ' /></div>
			</div>
			<div class="clearBoth">&nbsp;</div>';
    } else {
        if (isset($email) && strlen($email) > 0) {
            // For logged in users, just save the email anyway.
            $output .= '<input class="" value="' . $email . '" type="hidden" name="gwolle_gb_author_email" id="gwolle_gb_author_email" />';
        }
    }
    /* Website / Homepage */
    if (isset($form_setting['form_homepage_enabled']) && $form_setting['form_homepage_enabled'] === 'true') {
        $output .= '<div class="gwolle_gb_author_website">
				<div class="label"><label for="gwolle_gb_author_website">' . __('Website', 'gwolle-gb') . ':';
        if (isset($form_setting['form_homepage_mandatory']) && $form_setting['form_homepage_mandatory'] === 'true') {
            $output .= ' *';
        }
        $output .= '</label></div>
				<div class="input"><input class="';
        if (in_array('author_website', $gwolle_gb_error_fields)) {
            $output .= ' error';
        }
        $output .= '" value="' . $website . '" ' . ($html5 ? 'type="url"' : 'type="text"') . ' name="gwolle_gb_author_website" id="gwolle_gb_author_website" placeholder="' . __('Website', 'gwolle-gb') . '" ';
        if (in_array('author_website', $gwolle_gb_error_fields) && isset($autofocus)) {
            $output .= $autofocus;
            $autofocus = false;
            // disable it for the next error.
        }
        $output .= ' /></div>
			</div>
			<div class="clearBoth">&nbsp;</div>';
    }
    /* Content */
    if (isset($form_setting['form_message_enabled']) && $form_setting['form_message_enabled'] === 'true') {
        $output .= '<div class="gwolle_gb_content">
				<div class="label"><label for="gwolle_gb_content">' . __('Guestbook entry', 'gwolle-gb') . ':';
        if (isset($form_setting['form_message_mandatory']) && $form_setting['form_message_mandatory'] === 'true') {
            $output .= ' *';
        }
        $output .= '</label></div>
				<div class="input"><textarea name="gwolle_gb_content" id="gwolle_gb_content" class="';
        if (in_array('content', $gwolle_gb_error_fields)) {
            $output .= ' error';
        }
        $output .= '" placeholder="' . __('Message', 'gwolle-gb') . '" ';
        if (in_array('content', $gwolle_gb_error_fields) && isset($autofocus)) {
            $output .= $autofocus;
            $autofocus = false;
            // disable it for the next error.
        }
        $output .= ' >' . $content . '</textarea>';
        if (isset($form_setting['form_bbcode_enabled']) && $form_setting['form_bbcode_enabled'] === 'true') {
            // BBcode and MarkItUp
            wp_enqueue_script('markitup', plugins_url('markitup/jquery.markitup.js', __FILE__), 'jquery', GWOLLE_GB_VER, false);
            wp_enqueue_script('markitup_set', plugins_url('markitup/set.js', __FILE__), 'jquery', GWOLLE_GB_VER, false);
            wp_enqueue_style('gwolle_gb_markitup_css', plugins_url('markitup/style.css', __FILE__), false, GWOLLE_GB_VER, 'screen');
            $dataToBePassed = array('bold' => __('Bold', 'gwolle-gb'), 'italic' => __('Italic', 'gwolle-gb'), 'bullet' => __('Bulleted List', 'gwolle-gb'), 'numeric' => __('Numeric List', 'gwolle-gb'), 'picture' => __('Picture', 'gwolle-gb'), 'source' => __('Source', 'gwolle-gb'), 'link' => __('Link', 'gwolle-gb'), 'linktext' => __('Your text to link...', 'gwolle-gb'), 'clean' => __('Clean', 'gwolle-gb'), 'emoji' => __('Emoji', 'gwolle-gb'));
            wp_localize_script('markitup_set', 'gwolle_gb_localize', $dataToBePassed);
            // Emoji symbols
            $output .= '<div class="gwolle_gb_emoji" style="display:none;">';
            $output .= gwolle_gb_get_emoji();
            $output .= '</div>';
        }
        $output .= '</div>';
        // .input
        $output .= '
				</div>
			<div class="clearBoth">&nbsp;</div>';
    }
    /* Custom Anti-Spam */
    if (isset($form_setting['form_antispam_enabled']) && $form_setting['form_antispam_enabled'] === 'true') {
        $antispam_question = gwolle_gb_sanitize_output(get_option('gwolle_gb-antispam-question'));
        $antispam_answer = gwolle_gb_sanitize_output(get_option('gwolle_gb-antispam-answer'));
        if (isset($antispam_question) && strlen($antispam_question) > 0 && isset($antispam_answer) && strlen($antispam_answer) > 0) {
            $output .= '
				<div class="gwolle_gb_antispam">
					<div class="label">
						<label for="gwolle_gb_antispam_answer">' . __('Anti-spam', 'gwolle-gb') . ': *<br />
						' . __('Question:', 'gwolle-gb') . " " . $antispam_question . '</label>
					</div>
					<div class="input"><input class="';
            if (in_array('antispam', $gwolle_gb_error_fields)) {
                $output .= ' error';
            }
            $output .= '" value="' . $antispam . '" type="text" name="gwolle_gb_antispam_answer" id="gwolle_gb_antispam_answer" placeholder="' . __('Answer', 'gwolle-gb') . '" ';
            if (in_array('antispam', $gwolle_gb_error_fields) && isset($autofocus)) {
                $output .= $autofocus;
                $autofocus = false;
                // disable it for the next error.
            }
            $output .= ' />
						</div>
					</div>
					<div class="clearBoth">&nbsp;</div>';
        }
    }
    /* CAPTCHA */
    if (isset($form_setting['form_recaptcha_enabled']) && $form_setting['form_recaptcha_enabled'] === 'true') {
        if (class_exists('ReallySimpleCaptcha')) {
            // Disable page caching, we want a new CAPTCHA image each time.
            if (!defined('DONOTCACHEPAGE')) {
                define("DONOTCACHEPAGE", "true");
            }
            // Instantiate the ReallySimpleCaptcha class, which will handle all of the heavy lifting
            $gwolle_gb_captcha = new ReallySimpleCaptcha();
            // Set Really Simple CAPTCHA Options
            $gwolle_gb_captcha->chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
            $gwolle_gb_captcha->char_length = '4';
            $gwolle_gb_captcha->img_size = array('72', '24');
            $gwolle_gb_captcha->fg = array('0', '0', '0');
            $gwolle_gb_captcha->bg = array('255', '255', '255');
            $gwolle_gb_captcha->font_size = '16';
            $gwolle_gb_captcha->font_char_width = '15';
            $gwolle_gb_captcha->img_type = 'png';
            $gwolle_gb_captcha->base = array('6', '18');
            // Generate random word and image prefix
            $gwolle_gb_captcha_word = $gwolle_gb_captcha->generate_random_word();
            $gwolle_gb_captcha_prefix = mt_rand();
            // Generate CAPTCHA image
            $gwolle_gb_captcha_image_name = $gwolle_gb_captcha->generate_image($gwolle_gb_captcha_prefix, $gwolle_gb_captcha_word);
            // Define values for CAPTCHA fields
            $gwolle_gb_captcha_image_url = content_url('plugins/really-simple-captcha/tmp/');
            $gwolle_gb_captcha_image_src = $gwolle_gb_captcha_image_url . $gwolle_gb_captcha_image_name;
            $gwolle_gb_captcha_image_width = $gwolle_gb_captcha->img_size[0];
            $gwolle_gb_captcha_image_height = $gwolle_gb_captcha->img_size[1];
            $gwolle_gb_captcha_field_size = $gwolle_gb_captcha->char_length;
            // Enqueue and localize the frontend script for CAPTCHA.
            wp_enqueue_script('gwolle_gb_captcha_js', plugins_url('js/captcha.js', __FILE__), 'jquery', GWOLLE_GB_VER, true);
            $dataToBePassed = array('ajaxurl' => admin_url('admin-ajax.php'), 'security' => wp_create_nonce('gwolle_gb_captcha_ajax'), 'correct' => __('Correct CAPTCHA value.', 'gwolle-gb'), 'incorrect' => __('Incorrect CAPTCHA value.', 'gwolle-gb'), 'gwolle_gb_captcha_prefix' => $gwolle_gb_captcha_prefix);
            wp_localize_script('gwolle_gb_captcha_js', 'gwolle_gb_captcha', $dataToBePassed);
            // Output the CAPTCHA fields
            $output .= '
				<div class="gwolle_gb_captcha">
					<div class="label">
						<label for="gwolle_gb_captcha_code">' . __('Anti-spam', 'gwolle-gb') . ': *<br />
						<img src="' . $gwolle_gb_captcha_image_src . '" alt="captcha" width="' . $gwolle_gb_captcha_image_width . '" height="' . $gwolle_gb_captcha_image_height . '" />
						</label>
					</div>
					<div class="input">
					<input class="';
            if (in_array('captcha', $gwolle_gb_error_fields)) {
                $output .= 'error';
            }
            $output .= '" value="" type="text" name="gwolle_gb_captcha_code" id="gwolle_gb_captcha_code" placeholder="' . __('CAPTCHA', 'gwolle-gb') . '" ';
            if (in_array('captcha', $gwolle_gb_error_fields) && isset($autofocus)) {
                $output .= $autofocus;
                $autofocus = false;
                // disable it for the next error.
            }
            $output .= ' />
							<input type="hidden" name="gwolle_gb_captcha_prefix" id="gwolle_gb_captcha_prefix" value="' . $gwolle_gb_captcha_prefix . '" />
							<span id="gwolle_gb_captcha_verify"></span>
						</div>
					</div>
					<div class="clearBoth">&nbsp;</div>';
        }
    }
    // Use this filter to just add something
    $output .= apply_filters('gwolle_gb_write_add_form', '');
    $output .= '
			<div class="gwolle_gb_submit">
				<div class="label">&nbsp;</div>
				<div class="input"><input type="submit" name="gwolle_gb_submit" value="' . esc_attr__('Submit', 'gwolle-gb') . '" /></div>
			</div>
			<div class="clearBoth">&nbsp;</div>

			<div class="gwolle_gb_notice">
				';
    $notice = gwolle_gb_sanitize_output(get_option('gwolle_gb-notice', false));
    if ($notice == false) {
        // No text set by the user. Use the default text.
        $notice = __('
Fields marked with * are obligatory.
Your E-mail address wil not be published.
For security reasons we save the ip address %ip%.
It might be that your entry will only be visible in the guestbook after we reviewed it.
We reserve our right to edit, delete, or not publish entries.
', 'gwolle-gb');
    }
    $notice = nl2br($notice);
    $output .= str_replace('%ip%', $_SERVER['REMOTE_ADDR'], $notice);
    $output .= '
			</div>';
    // Use this filter to just add something
    $output .= apply_filters('gwolle_gb_write_add_after', '');
    $output .= '</form>';
    if (get_option('gwolle_gb-labels_float', 'true') === 'true') {
        $output .= '
		<style type="text/css" scoped>
			#gwolle_gb .label,
			#gwolle_gb .input {
				float: left;
			}
		</style>
		';
    }
    // Add filter for the form, so devs can manipulate it.
    $output = apply_filters('gwolle_gb_write', $output);
    return $output;
}
Пример #14
0
function reload_captcha_really()
{
    require_once ABSPATH . 'wp-admin/admin-functions.php';
    if (class_exists('ReallySimpleCaptcha')) {
        //check if the Really Simple Captcha class is available
        $captcha = new ReallySimpleCaptcha();
        $captcha->char_length = 6;
        $captcha->img_size = array(95, 28);
        $captcha_word = $captcha->generate_random_word();
        //generate a random string with letters
        $captcha_prefix = mt_rand();
        //random number
        $captcha_image = $captcha->generate_image($captcha_prefix, $captcha_word);
        //generate the image file. it returns the file name
        echo json_encode(array(rtrim(get_bloginfo('wpurl'), '/') . '/wp-content/plugins/really-simple-captcha/tmp/' . $captcha_image, $captcha_prefix));
        //construct the absolute URL of the captcha image
    } else {
        echo '';
    }
    exit;
}
function cbnet_comment_captcha()
{
    if (!is_user_logged_in() && class_exists('ReallySimpleCaptcha')) {
        // Instantiate the ReallySimpleCaptcha class, which will handle all of the heavy lifting
        $cbnet_comment_captcha = new ReallySimpleCaptcha();
        // ReallySimpleCaptcha class option defaults.
        // For now, these are here merely for reference.
        // Changing these values will hav no impact.
        // If you want to configure these options, see "Set Really Simple CAPTCHA Options", below
        // TODO: Add admin page to allow configuration of options.
        $cbnet_comment_captcha_defaults = array('chars' => 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789', 'char_length' => '4', 'img_size' => array('72', '24'), 'fg' => array('0', '0', '0'), 'bg' => array('255', '255', '255'), 'font_size' => '16', 'font_char_width' => '15', 'img_type' => 'png', 'base' => array('6', '18'));
        /************************************************************
         * All configurable options are below  *
         ************************************************************/
        // Set Really Simple CAPTCHA Options
        $cbnet_comment_captcha->chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
        $cbnet_comment_captcha->char_length = '5';
        $cbnet_comment_captcha->img_size = array('95', '40');
        $cbnet_comment_captcha->fg = array('0', '0', '0');
        $cbnet_comment_captcha->bg = array('255', '255', '255');
        $cbnet_comment_captcha->font_size = '20';
        $cbnet_comment_captcha->font_char_width = '15';
        $cbnet_comment_captcha->img_type = 'png';
        $cbnet_comment_captcha->base = array('13', '25');
        // Set Comment Form Options
        $cbnet_comment_captcha_form_label = __('Anti-Spam', 'gdl_front_end');
        /************************************************************
         * Nothing else to edit.  No configurable options below this point.  *
         ************************************************************/
        // Generate random word and image prefix
        $cbnet_comment_captcha_word = $cbnet_comment_captcha->generate_random_word();
        $cbnet_comment_captcha_prefix = mt_rand();
        // Generate CAPTCHA image
        $cbnet_comment_captcha_image_name = $cbnet_comment_captcha->generate_image($cbnet_comment_captcha_prefix, $cbnet_comment_captcha_word);
        // Define values for comment form CAPTCHA fields
        $cbnet_comment_captcha_image_url = GOODLAYERS_PATH . '/include/plugin/really-simple-captcha/tmp/';
        $cbnet_comment_captcha_image_src = $cbnet_comment_captcha_image_url . $cbnet_comment_captcha_image_name;
        $cbnet_comment_captcha_image_width = $cbnet_comment_captcha->img_size[0];
        $cbnet_comment_captcha_image_height = $cbnet_comment_captcha->img_size[1];
        $cbnet_comment_captcha_field_size = $cbnet_comment_captcha->char_length;
        // Output the comment form CAPTCHA fields
        ?>
	<p class="comment-form-captcha">
		<img src="<?php 
        echo $cbnet_comment_captcha_image_src;
        ?>
" alt="captcha" width="<?php 
        echo $cbnet_comment_captcha_image_width;
        ?>
" height="<?php 
        echo $cbnet_comment_captcha_image_height;
        ?>
" />
		<input type="text" name="comment_captcha_code" id="comment_captcha_code" value="" size="<?php 
        echo $cbnet_comment_captcha_field_size;
        ?>
" />
		<input type="hidden" name="comment_captcha_prefix" id="comment_captcha_prefix" value="<?php 
        echo $cbnet_comment_captcha_prefix;
        ?>
" />
		<label for="captcha_code"><?php 
        echo $cbnet_comment_captcha_form_label;
        ?>
</label>
		<span class="required">*</span>
		<div class="clear"></div>
	</p>
<?php 
    }
}
Пример #16
0
/**
 * Create Really Simple CAPTCHA.
 *
 * @since 2.9.5
 *
 * @return array Form elements for Really Simple CAPTCHA.
 */
function wpmem_build_rs_captcha()
{
    if (defined('REALLYSIMPLECAPTCHA_VERSION')) {
        // setup defaults
        $defaults = array('characters' => 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789', 'num_char' => '4', 'dim_w' => '72', 'dim_h' => '30', 'font_color' => '0,0,0', 'bg_color' => '255,255,255', 'font_size' => '12', 'kerning' => '14', 'img_type' => 'png');
        $wpmem_captcha = get_option('wpmembers_captcha');
        $args = isset($wpmem_captcha['really_simple']) && is_array($wpmem_captcha['really_simple']) ? $wpmem_captcha['really_simple'] : array();
        $args = wp_parse_args($args, $defaults);
        $img_size = array($args['dim_w'], $args['dim_h']);
        $fg = explode(",", $args['font_color']);
        $bg = explode(",", $args['bg_color']);
        $wpmem_captcha = new ReallySimpleCaptcha();
        $wpmem_captcha->chars = $args['characters'];
        $wpmem_captcha->char_length = $args['num_char'];
        $wpmem_captcha->img_size = $img_size;
        $wpmem_captcha->fg = $fg;
        $wpmem_captcha->bg = $bg;
        $wpmem_captcha->font_size = $args['font_size'];
        $wpmem_captcha->font_char_width = $args['kerning'];
        $wpmem_captcha->img_type = $args['img_type'];
        $wpmem_captcha_word = $wpmem_captcha->generate_random_word();
        $wpmem_captcha_prefix = mt_rand();
        $wpmem_captcha_image_name = $wpmem_captcha->generate_image($wpmem_captcha_prefix, $wpmem_captcha_word);
        /**
         * Filters the default Really Simple Captcha folder location.
         *
         * @since 3.0
         *
         * @param string The default location of RS Captcha.
         */
        $wpmem_captcha_image_url = apply_filters('wpmem_rs_captcha_folder', get_bloginfo('wpurl') . '/wp-content/plugins/really-simple-captcha/tmp/');
        $img_w = $wpmem_captcha->img_size[0];
        $img_h = $wpmem_captcha->img_size[1];
        $src = $wpmem_captcha_image_url . $wpmem_captcha_image_name;
        $size = $wpmem_captcha->char_length;
        $pre = $wpmem_captcha_prefix;
        return array('label' => '<label class="text" for="captcha">' . __('Input the code:', 'wp-members') . '</label>', 'field' => '<input id="captcha_code" name="captcha_code" size="' . $size . '" type="text" />
					<input id="captcha_prefix" name="captcha_prefix" type="hidden" value="' . $pre . '" />
					<img src="' . $src . '" alt="captcha" width="' . $img_w . '" height="' . $img_h . '" />');
    } else {
        return;
    }
}
Пример #17
0
?>
"><?php 
echo stripslashes($_REQUEST[$number]['question']);
?>
</textarea>
            </label>
        </p>
        
        <?php 
if ($this->use_captcha()) {
    ?>
        	<?php 
    $captcha = new ReallySimpleCaptcha();
    ?>
            <?php 
    $captcha_word = $captcha->generate_random_word();
    ?>
        	<?php 
    $captcha_prefix = mt_rand();
    ?>
        	<p class="<?php 
    echo $this->pre;
    ?>
captcha">
            	<input type="hidden" name="<?php 
    echo $number;
    ?>
[captcha_prefix]" value="<?php 
    echo $captcha_prefix;
    ?>
" />