Update Recaptcha-related JavaScript
authorMatthias Schmidt <gravatronics@live.com>
Thu, 14 Aug 2014 19:51:19 +0000 (21:51 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Thu, 14 Aug 2014 19:51:19 +0000 (21:51 +0200)
com.woltlab.wcf/templates/__commentJavaScript.tpl
com.woltlab.wcf/templates/recaptcha.tpl
wcfsetup/install/files/acp/templates/recaptcha.tpl
wcfsetup/install/files/lib/system/WCF.class.php
wcfsetup/install/files/lib/system/recaptcha/RecaptchaHandler.class.php

index 2a070de5d8c407a5ff887334e5c9244fced6fecc..9c4e728b3e93b0dd984368c36e2aba589c51cf9b 100644 (file)
@@ -1,6 +1,3 @@
-{if !$__wcf->user->userID}
-       <script data-relocate="true" src="http{if $__wcf->secureConnection()}s{/if}://www.google.com/recaptcha/api/js/recaptcha_ajax.js"></script>
-{/if}
 <script data-relocate="true">
        //<![CDATA[
        $(function() {
index c538a1157fe5ebb546c8a0659f5c42f6edb8dbde..e215b27fe17a6644df48f76d51037cc8c99137c3 100644 (file)
                        </dd>
                        
                        {if !$ajaxCaptcha|isset || !$ajaxCaptcha}
-                               <script data-relocate="true" src="http{if $recaptchaUseSSL}s{/if}://www.google.com/recaptcha/api/challenge?k={$recaptchaPublicKey}"></script>
+                               <script data-relocate="true" src="//www.google.com/recaptcha/api/challenge?k={$recaptchaPublicKey}"></script>
                                <noscript>
                                        <dd>
-                                               <iframe src="http{if $recaptchaUseSSL}s{/if}://www.google.com/recaptcha/api/noscript?k={$recaptchaPublicKey}" height="300" width="500" seamless="seamless"></iframe><br />
+                                               <iframe src="//www.google.com/recaptcha/api/noscript?k={$recaptchaPublicKey}" height="300" width="500" seamless="seamless"></iframe><br />
                                                <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
                                                <input type="hidden" name="recaptcha_response_field" value="manual_challenge" />
                                        </dd>
                        {else}
                                <script data-relocate="true">
                                        //<![CDATA[
-                                       Recaptcha.create("{$recaptchaPublicKey}", "recaptcha_image", {
-                                               lang: '{@$recaptchaLanguageCode}',
-                                               theme : 'custom'
-                                       });
-                                       
-                                       WCF.System.Captcha.addCallback('{$captchaID}', function() {
-                                               return {
-                                                       recaptcha_challenge_field: Recaptcha.get_challenge(),
-                                                       recaptcha_response_field: Recaptcha.get_response()
-                                               };
+                                       $.getScript('//www.google.com/recaptcha/api/js/recaptcha_ajax.js', function() {
+                                               Recaptcha.create("{$recaptchaPublicKey}", "recaptcha_image", {
+                                                       lang: '{@$recaptchaLanguageCode}',
+                                                       theme : 'custom'
+                                               });
+                                               
+                                               WCF.System.Captcha.addCallback('{$captchaID}', function() {
+                                                       return {
+                                                               recaptcha_challenge_field: Recaptcha.get_challenge(),
+                                                               recaptcha_response_field: Recaptcha.get_response()
+                                                       };
+                                               });
                                        });
                                        //]]>
                                </script>
index c538a1157fe5ebb546c8a0659f5c42f6edb8dbde..e215b27fe17a6644df48f76d51037cc8c99137c3 100644 (file)
                        </dd>
                        
                        {if !$ajaxCaptcha|isset || !$ajaxCaptcha}
-                               <script data-relocate="true" src="http{if $recaptchaUseSSL}s{/if}://www.google.com/recaptcha/api/challenge?k={$recaptchaPublicKey}"></script>
+                               <script data-relocate="true" src="//www.google.com/recaptcha/api/challenge?k={$recaptchaPublicKey}"></script>
                                <noscript>
                                        <dd>
-                                               <iframe src="http{if $recaptchaUseSSL}s{/if}://www.google.com/recaptcha/api/noscript?k={$recaptchaPublicKey}" height="300" width="500" seamless="seamless"></iframe><br />
+                                               <iframe src="//www.google.com/recaptcha/api/noscript?k={$recaptchaPublicKey}" height="300" width="500" seamless="seamless"></iframe><br />
                                                <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
                                                <input type="hidden" name="recaptcha_response_field" value="manual_challenge" />
                                        </dd>
                        {else}
                                <script data-relocate="true">
                                        //<![CDATA[
-                                       Recaptcha.create("{$recaptchaPublicKey}", "recaptcha_image", {
-                                               lang: '{@$recaptchaLanguageCode}',
-                                               theme : 'custom'
-                                       });
-                                       
-                                       WCF.System.Captcha.addCallback('{$captchaID}', function() {
-                                               return {
-                                                       recaptcha_challenge_field: Recaptcha.get_challenge(),
-                                                       recaptcha_response_field: Recaptcha.get_response()
-                                               };
+                                       $.getScript('//www.google.com/recaptcha/api/js/recaptcha_ajax.js', function() {
+                                               Recaptcha.create("{$recaptchaPublicKey}", "recaptcha_image", {
+                                                       lang: '{@$recaptchaLanguageCode}',
+                                                       theme : 'custom'
+                                               });
+                                               
+                                               WCF.System.Captcha.addCallback('{$captchaID}', function() {
+                                                       return {
+                                                               recaptcha_challenge_field: Recaptcha.get_challenge(),
+                                                               recaptcha_response_field: Recaptcha.get_response()
+                                                       };
+                                               });
                                        });
                                        //]]>
                                </script>
index 4cb4c81c4a97763594b329e02adf924c88568af0..48f29b1d7a9a3acd9dc7ae97e1d7a8283094446d 100644 (file)
@@ -813,13 +813,6 @@ class WCF {
                return $data['updates'];
        }
        
-       /**
-        * @see \wcf\system\request\RouteHandler::secureConnection()
-        */
-       public function secureConnection() {
-               return RouteHandler::secureConnection();
-       }
-       
        /**
         * Returns a 8 character prefix for editor autosave.
         * 
index 5439a1b7819dd4a32a3450517f700468d1c248bc..33f5ed4e5087dc9ef9e460a232725334eb96f64b 100644 (file)
@@ -181,7 +181,7 @@ class RecaptchaHandler extends SingletonFactory {
                WCF::getTPL()->assign(array(
                        'recaptchaLanguageCode' => $this->languageCode,
                        'recaptchaPublicKey' => $this->publicKey,
-                       'recaptchaUseSSL' => RouteHandler::secureConnection(),
+                       'recaptchaUseSSL' => RouteHandler::secureConnection(), // @deprecated since 2.1
                        'recaptchaLegacyMode' => true
                ));
        }