at path:ROOT / clients / assets / js / whmcs / recaptcha.js
run:R W Run
2.97 KB
2026-04-08 19:29:25
R W Run
9 KB
2026-04-08 19:29:26
R W Run
1.49 KB
2026-04-08 19:29:25
R W Run
2.44 KB
2026-04-08 19:29:28
R W Run
5.28 KB
2026-04-08 19:29:28
R W Run
45 By
2026-04-08 19:29:27
R W Run
5.71 KB
2026-04-08 19:29:26
R W Run
4.91 KB
2026-04-08 19:29:25
R W Run
3.24 KB
2026-04-08 19:29:27
R W Run
24.58 KB
2026-04-08 19:29:26
R W Run
13.16 KB
2026-04-08 19:29:26
R W Run
5.46 KB
2026-04-08 19:29:27
R W Run
error_log
📄recaptcha.js
1/**
2 * reCaptcha module
3 *
4 * @copyright Copyright (c) WHMCS Limited 2005-2020
5 * @license http://www.whmcs.com/license/ WHMCS Eula
6 */
7var recaptchaLoadComplete = false,
8 recaptchaCount = 0,
9 recaptchaType = 'recaptcha',
10 recaptchaValidationComplete = false;
11
12(function(module) {
13 if (!WHMCS.hasModule('recaptcha')) {
14 WHMCS.loadModule('recaptcha', module);
15 }
16})(
17 function () {
18
19 this.register = function () {
20 if (recaptchaLoadComplete) {
21 return;
22 }
23 var postLoad = [],
24 recaptchaForms = jQuery(".btn-recaptcha").parents('form'),
25 isInvisible = false;
26 recaptchaForms.each(function (i, el){
27 if (typeof recaptchaSiteKey === 'undefined') {
28 console.log('Recaptcha site key not defined');
29 return;
30 }
31 recaptchaCount += 1;
32 var frm = jQuery(el),
33 btnRecaptcha = frm.find(".btn-recaptcha"),
34 required = (typeof requiredText !== 'undefined') ? requiredText : 'Required',
35 recaptchaId = 'divDynamicRecaptcha' + recaptchaCount;
36
37 isInvisible = btnRecaptcha.hasClass('btn-recaptcha-invisible')
38
39 // if no recaptcha element, make one
40 var recaptchaContent = frm.find('#' + recaptchaId + ' .g-recaptcha'),
41 recaptchaElement = frm.find('.recaptcha-container'),
42 appendElement = frm;
43
44 if (recaptchaElement.length) {
45 recaptchaElement.attr('id', recaptchaElement.attr('id') + recaptchaCount);
46 appendElement = recaptchaElement;
47 }
48 if (!recaptchaContent.length) {
49 appendElement.append('<div id="#' + recaptchaId + '" class="g-recaptcha"></div>');
50 recaptchaContent = appendElement.find('#' + recaptchaId);
51 }
52 // propagate invisible recaptcha if necessary
53 if (!isInvisible) {
54 recaptchaContent.data('toggle', 'tooltip')
55 .data('placement', 'bottom')
56 .data('trigger', 'manual')
57 .attr('title', required)
58 .hide();
59 }
60
61
62 // alter form to work around JS behavior on .submit() when there
63 // there is an input with the name 'submit'
64 var btnSubmit = frm.find("input[name='submit']");
65 if (btnSubmit.length) {
66 var action = frm.prop('action');
67 frm.prop('action', action + '&submit=1');
68 btnSubmit.remove();
69 }
70
71 // make callback for grecaptcha to invoke after
72 // injecting token & make it known via data-callback
73 var funcName = recaptchaId + 'Callback';
74 window[funcName] = function () {
75 if (isInvisible) {
76 frm.submit();
77 }
78 };
79
80 // setup an on form submit event to ensure that we
81 // are allowing required field validation to occur before
82 // we do the invisible recaptcha checking
83 if (isInvisible) {
84 recaptchaType = 'invisible';
85 frm.on('submit.recaptcha', function (event) {
86 var recaptchaId = frm.find('.g-recaptcha').data('recaptcha-id');
87 if (!grecaptcha.getResponse(recaptchaId).trim()) {
88 event.preventDefault();
89 grecaptcha.execute(recaptchaId);
90 recaptchaValidationComplete = false;
91 } else {
92 recaptchaValidationComplete = true;
93 }
94 });
95 } else {
96 postLoad.push(function () {
97 recaptchaContent.slideDown('fast', function() {
98 // just in case there's a delay in DOM; rare
99 recaptchaContent.find(':first').addClass('center-block');
100 });
101 });
102 postLoad.push(function() {
103 recaptchaContent.find(':first').addClass('center-block');
104 });
105 }
106 });
107
108 window.recaptchaLoadCallback = function() {
109 jQuery('.g-recaptcha').each(function(i, el) {
110 var element = jQuery(el),
111 frm = element.closest('form'),
112 btn = frm.find('.btn-recaptcha'),
113 idToUse = element.attr('id').substring(1);
114 var recaptchaId = grecaptcha.render(
115 el,
116 {
117 sitekey: recaptchaSiteKey,
118 size: (btn.hasClass('btn-recaptcha-invisible')) ? 'invisible' : 'normal',
119 callback: idToUse + 'Callback'
120 }
121 );
122 element.data('recaptcha-id', recaptchaId);
123 });
124 }
125
126 // fetch/invoke the grecaptcha lib
127 if (recaptchaForms.length) {
128 var gUrl = "https://www.google.com/recaptcha/api.js?onload=recaptchaLoadCallback&render=explicit";
129 jQuery.getScript(gUrl, function () {
130 for(var i = postLoad.length - 1; i >= 0 ; i--){
131 postLoad[i]();
132 }
133 });
134 }
135 recaptchaLoadComplete = true;
136 };
137
138 return this;
139 });
140