Esempio n. 1
0
    function gglcptch_display($content = false)
    {
        global $gglcptch_options, $gglcptch_count, $gglcptch_plugin_info;
        if (empty($gglcptch_options)) {
            $gglcptch_options = get_option('gglcptch_options');
        }
        if (!$gglcptch_count) {
            $gglcptch_count = 1;
        }
        if (!gglcptch_get_allow_url_fopen() && isset($gglcptch_options['recaptcha_version']) && $gglcptch_options['recaptcha_version'] == 'v2') {
            $content .= '<div class="gglcptch allow_url_fopen_off"></div>';
            $gglcptch_count++;
            return $content;
        }
        $publickey = $gglcptch_options['public_key'];
        $privatekey = $gglcptch_options['private_key'];
        $content .= '<div class="gglcptch gglcptch_' . $gglcptch_options['recaptcha_version'] . '">';
        if (!$privatekey || !$publickey) {
            if (current_user_can('manage_options')) {
                $content .= sprintf('<strong>%s <a target="_blank" href="https://www.google.com/recaptcha/admin#list">%s</a> %s <a target="_blank" href="%s">%s</a>.</strong>', __('To use Google Captcha you must get the keys from', 'google-captcha'), __('here', 'google-captcha'), __('and enter them on the', 'google-captcha'), admin_url('/admin.php?page=google-captcha.php'), __('plugin setting page', 'google-captcha'));
            }
            $content .= '</div>';
            $gglcptch_count++;
            return $content;
        }
        if (isset($gglcptch_options['recaptcha_version']) && 'v2' == $gglcptch_options['recaptcha_version']) {
            $content .= '<div id="gglcptch_recaptcha_' . $gglcptch_count . '" class="gglcptch_recaptcha"></div>
			<noscript>
				<div style="width: 302px;">
					<div style="width: 302px; height: 422px; position: relative;">
						<div style="width: 302px; height: 422px; position: absolute;">
							<iframe src="https://www.google.com/recaptcha/api/fallback?k=' . $publickey . '" frameborder="0" scrolling="no" style="width: 302px; height:422px; border-style: none;"></iframe>
						</div>
					</div>
					<div style="border-style: none; bottom: 12px; left: 25px; margin: 0px; padding: 0px; right: 25px; background: #f9f9f9; border: 1px solid #c1c1c1; border-radius: 3px; height: 60px; width: 300px;">
						<textarea id="g-recaptcha-response" name="g-recaptcha-response" class="g-recaptcha-response" style="width: 250px !important; height: 40px !important; border: 1px solid #c1c1c1 !important; margin: 10px 25px !important; padding: 0px !important; resize: none !important;"></textarea>
					</div>
				</div>
			</noscript>';
            $api_url = "https://www.google.com/recaptcha/api.js";
        } else {
            require_once 'lib/recaptchalib.php';
            $content .= '<div id="gglcptch_recaptcha_' . $gglcptch_count . '" class="gglcptch_recaptcha"></div>';
            $content .= gglcptch_recaptcha_get_html($publickey, null, is_ssl());
            $api_url = "//www.google.com/recaptcha/api/js/recaptcha_ajax.js";
        }
        $content .= '</div>';
        $gglcptch_count++;
        /* register reCAPTCHA script */
        if (!wp_script_is('gglcptch_api', 'registered')) {
            wp_register_script('gglcptch_api', $api_url, false, $gglcptch_plugin_info["Version"], true);
            add_action('wp_footer', 'gglcptch_add_scripts');
            if ('1' == $gglcptch_options['login_form'] || '1' == $gglcptch_options['reset_pwd_form'] || '1' == $gglcptch_options['registration_form']) {
                add_action('login_footer', 'gglcptch_add_scripts');
            }
        }
        return $content;
    }
Esempio n. 2
0
    function gglcptch_display($content = false)
    {
        if (gglcptch_check_role()) {
            return;
        }
        global $gglcptch_options, $gglcptch_count, $gglcptch_allow_url_fopen;
        if (empty($gglcptch_count)) {
            $gglcptch_count = 1;
        }
        if ($gglcptch_count > 1) {
            return $content;
        }
        if (!$gglcptch_allow_url_fopen && isset($gglcptch_options['recaptcha_version']) && $gglcptch_options['recaptcha_version'] == 'v2') {
            $content .= '<div class="gglcptch allow_url_fopen_off"></div>';
            $gglcptch_count++;
            return $content;
        }
        $publickey = $gglcptch_options['public_key'];
        $privatekey = $gglcptch_options['private_key'];
        $content .= '<div class="gglcptch">';
        if (!$privatekey || !$publickey) {
            if (current_user_can('manage_options')) {
                $content .= sprintf('<strong>%s <a target="_blank" href="https://www.google.com/recaptcha/admin#list">%s</a> %s <a target="_blank" href="%s">%s</a>.</strong>', __('To use Google Captcha you must get the keys from', 'google-captcha'), __('here', 'google-captcha'), __('and enter them on the', 'google-captcha'), admin_url('/admin.php?page=google-captcha.php'), __('plugin setting page', 'google-captcha'));
            }
            $content .= '</div>';
            $gglcptch_count++;
            return $content;
        }
        if (isset($gglcptch_options['recaptcha_version']) && 'v2' == $gglcptch_options['recaptcha_version']) {
            $content .= '<style type="text/css" media="screen">
					#gglcptch_error {
						color: #F00;
					}
				</style>
				<script type="text/javascript">
					var ajaxurl = "' . admin_url('admin-ajax.php') . '",
					gglcptch_error_msg = "' . __('Error: You have entered an incorrect CAPTCHA value.', 'google-captcha') . '";
				</script>';
            $content .= '<div class="g-recaptcha" data-sitekey="' . $publickey . '" data-theme="' . $gglcptch_options['theme_v2'] . '"></div>
			<script type="text/javascript" src="https://www.google.com/recaptcha/api.js"></script>
			<noscript>
				<div style="width: 302px;">
					<div style="width: 302px; height: 422px; position: relative;">
						<div style="width: 302px; height: 422px; position: absolute;">
							<iframe src="https://www.google.com/recaptcha/api/fallback?k=' . $publickey . '" frameborder="0" scrolling="no" style="width: 302px; height:422px; border-style: none;"></iframe>
						</div>
					</div>
					<div style="border-style: none; bottom: 12px; left: 25px; margin: 0px; padding: 0px; right: 25px; background: #f9f9f9; border: 1px solid #c1c1c1; border-radius: 3px; height: 60px; width: 300px;">
						<textarea id="g-recaptcha-response" name="g-recaptcha-response" class="g-recaptcha-response" style="width: 250px; height: 40px; border: 1px solid #c1c1c1; margin: 10px 25px !important; padding: 0px; resize: none; "></textarea>
					</div>
				</div>
			</noscript>';
        } else {
            require_once 'lib/recaptchalib.php';
            $content .= sprintf('<style type="text/css" media="screen">
					#recaptcha_response_field {
						max-height: 35px;
					}
					#gglcptch_error {
						color: #F00;
					}
					.gglcptch table#recaptcha_table {
					    table-layout: auto;
					}
				</style>
				<script type="text/javascript">
					var RecaptchaOptions = { theme : "%s" },
					ajaxurl = "%s",
					gglcptch_error_msg = "%s";
				</script>', $gglcptch_options['theme'], admin_url('admin-ajax.php'), __('Error: You have entered an incorrect CAPTCHA value.', 'google-captcha'));
            if (is_ssl()) {
                $content .= gglcptch_recaptcha_get_html($publickey, '', true);
            } else {
                $content .= gglcptch_recaptcha_get_html($publickey);
            }
        }
        $content .= '</div>';
        $gglcptch_count++;
        return $content;
    }