1apbctLocalStorage = { 2 get : function(key, property) { 3 if ( typeof property === 'undefined' ) { 4 property = 'value'; 5 } 6 const storageValue = localStorage.getItem(key); 7 if ( storageValue !== null ) { 8 try { 9 const json = JSON.parse(storageValue); 10 return json.hasOwnProperty(property) ? JSON.parse(json[property]) : json; 11 } catch (e) { 12 return storageValue; 13 } 14 } 15 return false; 16 }, 17 set : function(key, value, is_json = true) { 18 if (is_json){ 19 let objToSave = {'value': JSON.stringify(value), 'timestamp': Math.floor(new Date().getTime() / 1000)}; 20 localStorage.setItem(key, JSON.stringify(objToSave)); 21 } else { 22 localStorage.setItem(key, value); 23 } 24 }, 25 isAlive : function(key, maxLifetime) { 26 if ( typeof maxLifetime === 'undefined' ) { 27 maxLifetime = 86400; 28 } 29 const keyTimestamp = this.get(key, 'timestamp'); 30 return keyTimestamp + maxLifetime > Math.floor(new Date().getTime() / 1000); 31 }, 32 isSet : function(key) { 33 return localStorage.getItem(key) !== null; 34 }, 35 delete : function (key) { 36 localStorage.removeItem(key); 37 }, 38 getCleanTalkData : function () { 39 let data = {} 40 for(let i=0; i<localStorage.length; i++) { 41 let key = localStorage.key(i); 42 if (key.indexOf('ct_') !==-1 || key.indexOf('apbct_') !==-1){ 43 data[key.toString()] = apbctLocalStorage.get(key) 44 } 45 } 46 return data 47 }, 48 49} 50 51function ctSetCookie(c_name, value) { 52 if (typeof ct_setcookie !== "undefined" && ct_setcookie) { 53 document.cookie = c_name + "=" + encodeURIComponent(value) + "; path=/"; 54 } 55} 56 57/** 58 * Set some cookies from object 59 * @param cookies 60 */ 61function ctSetCookies(cookies) 62{ 63 if (typeof ctPublicData !== 'undefined' && ctPublicData.typeOfCookie && ctPublicData.typeOfCookie === 'alt_cookies') { 64 ctSetAltCookies(cookies); 65 } else { 66 for (const [cookie, value] of Object.entries(cookies)) { 67 ctSetCookie(cookie, value); 68 } 69 } 70} 71 72ct_attach_event_handler(window, "DOMContentLoaded", ct_ready); 73 74//Stop observing function 75function ctMouseStopData(){ 76 if(typeof window.addEventListener == "function") 77 window.removeEventListener("mousemove", ctFunctionMouseMove); 78 else 79 window.detachEvent("onmousemove", ctFunctionMouseMove); 80 clearInterval(ctMouseReadInterval); 81 clearInterval(ctMouseWriteDataInterval); 82} 83 84//Stop key listening function 85function ctKeyStopStopListening(){ 86 if(typeof window.addEventListener == "function"){ 87 window.removeEventListener("mousedown", ctFunctionFirstKey); 88 window.removeEventListener("keydown", ctFunctionFirstKey); 89 }else{ 90 window.detachEvent("mousedown", ctFunctionFirstKey); 91 window.detachEvent("keydown", ctFunctionFirstKey); 92 } 93} 94 95var d = new Date(), 96 ctTimeMs = new Date().getTime(), 97 ctMouseEventTimerFlag = true, //Reading interval flag 98 ctMouseData = "[", 99 ctMouseDataCounter = 0; 100 101//Reading interval 102var ctMouseReadInterval = setInterval(function(){ 103 ctMouseEventTimerFlag = true; 104}, 150); 105 106//Writting interval 107var ctMouseWriteDataInterval = setInterval(function(){ 108 var ctMouseDataToSend = ctMouseData.slice(0,-1).concat("]"); 109 if (typeof ctPublicData !== 'undefined' && ctPublicData.typeOfCookie && ctPublicData.typeOfCookie === 'alt_cookies') { 110 apbctLocalStorage.set('ct_pointer_data', ctMouseDataToSend); 111 } else { 112 ctSetCookie('ct_pointer_data', ctMouseDataToSend); 113 } 114}, 1200); 115 116//Logging mouse position each 300 ms 117var ctFunctionMouseMove = function output(event){ 118 if(ctMouseEventTimerFlag == true){ 119 var mouseDate = new Date(); 120 ctMouseData += "[" + event.pageY + "," + event.pageX + "," + (mouseDate.getTime() - ctTimeMs) + "],"; 121 ctMouseDataCounter++; 122 ctMouseEventTimerFlag = false; 123 if(ctMouseDataCounter >= 100) 124 ctMouseStopData(); 125 } 126} 127//Writing first key press timestamp 128var ctFunctionFirstKey = function output(event){ 129 var KeyTimestamp = Math.floor(new Date().getTime()/1000); 130 if (typeof ctPublicData !== 'undefined' && ctPublicData.typeOfCookie && ctPublicData.typeOfCookie === 'alt_cookies') { 131 ctSetAltCookies({'ct_fkp_timestamp': KeyTimestamp}); 132 } else {
133 ctSetCookie('ct_fkp_timestamp', KeyTimestamp); 134 } 135 ctKeyStopStopListening(); 136} 137 138if(typeof window.addEventListener == "function"){ 139 window.addEventListener("mousemove", ctFunctionMouseMove); 140 window.addEventListener("mousedown", ctFunctionFirstKey); 141 window.addEventListener("keydown", ctFunctionFirstKey); 142}else{ 143 window.attachEvent("onmousemove", ctFunctionMouseMove); 144 window.attachEvent("mousedown", ctFunctionFirstKey); 145 window.attachEvent("keydown", ctFunctionFirstKey); 146} 147// Ready function 148function ct_ready(){ 149 const cookies = { 150 ct_ps_timestamp: Math.floor(new Date().getTime()/1000), 151 ct_fkp_timestamp: 0, 152 ct_pointer_data: 0, 153 ct_timezone: new Date().getTimezoneOffset()/60*(-1), 154 ct_visible_fields: 0, 155 ct_visible_fields_count: 0 156 } 157 158 ctSetCookies(cookies); 159 160 setTimeout(function(){ 161 for(var i = 0; i < document.forms.length; i++){ 162 var form = document.forms[i]; 163 164 checkEasySocial(form); 165 166 if (!form.name && !form.id) { 167 continue; 168 } 169 170 // Get only fields 171 var elements = []; 172 for(var key in this.elements){ 173 if(!isNaN(+key)) 174 elements[key] = this.elements[key]; 175 } 176 177 // Filter fields 178 elements = elements.filter(function(elem){ 179 180 var pass = true; 181 182 // Filter fields 183 if( getComputedStyle(elem).display === "none" || // hidden 184 getComputedStyle(elem).visibility === "hidden" || // hidden 185 getComputedStyle(elem).opacity === "0" || // hidden 186 elem.getAttribute("type") === "hidden" || // type == hidden 187 elem.getAttribute("type") === "submit" || // type == submit 188 elem.value === "" || // empty value 189 elem.getAttribute('name') === null 190 ){ 191 return false; 192 } 193 194 // Filter elements with same names for type == radio 195 if(elem.getAttribute("type") === "radio"){ 196 elements.forEach(function(el, j, els){ 197 if(elem.getAttribute('name') === el.getAttribute('name')){ 198 pass = false; 199 return; 200 } 201 }); 202 } 203 204 return true; 205 }); 206 207 // Visible fields count 208 var visible_fields_count = elements.length; 209 210 // Visible fields 211 var visible_fields = ''; 212 elements.forEach(function(elem, i, elements){ 213 visible_fields += " " + elem.getAttribute("name"); 214 }); 215 visible_fields = visible_fields.trim(); 216 217 form.onsubmit_prev = form.onsubmit; 218 219 form.onsubmit = function(event, visible_fields, visible_fields_count) { 220 if (typeof ctPublicData !== 'undefined' && ctPublicData.typeOfCookie && ctPublicData.typeOfCookie === 'alt_cookies') { 221 const cookies = { 222 ct_pointer_data: apbctLocalStorage.get('ct_pointer_data'), 223 ct_visible_fields: visible_fields, 224 ct_visible_fields_count: visible_fields_count 225 } 226 ctSetAltCookies(cookies); 227 } else { 228 ctSetCookie("ct_visible_fields", visible_fields); 229 ctSetCookie("ct_visible_fields_count", visible_fields_count); 230 } 231 232 // Call previous submit action 233 if (event.target.onsubmit_prev instanceof Function && !ct_is_excluded_forms(event.target)) { 234 setTimeout(function() { 235 event.target.onsubmit_prev.call(event.target, event); 236 }, 500); 237 } 238 } 239 } 240 }, 1000); 241} 242 243function checkEasySocial(form) { 244 if (form.classList.contains('es-form-login')) { 245 form.querySelectorAll('a.btn').forEach(function (el) { 246 if (el.hasAttribute('data-oauth-login-button')) { 247 el.removeAttribute('data-oauth-login-button'); 248 el.setAttribute('data-oauth-login-button-blocked', ''); 249 } 250 el.onclick = function(e) { 251 e.preventDefault(); 252 let allow = function(target) { 253 if (target.hasAttribute('data-oauth-login-button-blocked')) { 254 target.removeAttribute('data-oauth-login-button-blocked'); 255 target.setAttribute('data-oauth-login-button', ''); 256 } 257 target.onclick = null; 258 target.click(); 259 }; 260 let forbidden = function(target, msg) { 261 let el = document.createElement('div'); 262 el.style.background = 'red'; 263 el.style.color = 'white'; 264 el.style.padding = '1em'; 265 el.style.margin = '1em'; 266 el.innerHTML = msg; 267 target.insertAdjacentElement('afterend', el); 268 }; 269 270 ctCheckAjax(e.target, allow, forbidden); 271 272 return false;
273 } 274 }) 275 } 276} 277 278function ct_is_excluded_forms(form) { 279 if (form.onsubmit_prev && form.onsubmit_prev.toString().includes('validateRegistrationForm')) { 280 return true; 281 } 282 283 let value; 284 for (let key in form.elements){ 285 if (isNaN(+key)) { 286 continue; 287 } 288 289 value = form.elements[key]; 290 if (value.classList.contains('cf-input')) { 291 return true; 292 } 293 if (value.classList.contains('ff_elem bfCalendarInput')) { 294 return true; 295 } 296 } 297 298 return false; 299} 300 301function ct_attach_event_handler(elem, event, callback){ 302 if(typeof window.addEventListener === "function") elem.addEventListener(event, callback); 303 else elem.attachEvent(event, callback); 304} 305 306function ct_remove_event_handler(elem, event, callback){ 307 if(typeof window.removeEventListener === "function") elem.removeEventListener(event, callback); 308 else elem.detachEvent(event, callback); 309} 310 311function ct_attach_event_token(){ 312 if (typeof apbctLocalStorage !== "undefined"){ 313 const ct_event_token_string = apbctLocalStorage.get('bot_detector_event_token') 314 const ct_event_token_obj = JSON.parse(ct_event_token_string.toString()) 315 if (typeof ctSetCookie == "function" && typeof ct_event_token_obj.value != "undefined"){ 316 const value = ct_event_token_obj.value; 317 if (typeof value === "string" && value.length === 64){ 318 if (typeof ctPublicData !== 'undefined' && ctPublicData.typeOfCookie && ctPublicData.typeOfCookie === 'alt_cookies') { 319 ctSetAltCookies({'ct_event_token': ct_event_token_obj.value}); 320 } else { 321 ctSetCookie("ct_event_token", ct_event_token_obj.value); 322 } 323 324 return true; 325 } 326 } 327 } 328 return false; 329} 330 331// Setting alt-cookies from array 332function ctSetAltCookies(altCookies) 333{ 334 altCookies.action = 'set_alt_cookies'; 335 336 Joomla.request({ 337 url: 'index.php?option=com_ajax&plugin=cleantalkantispam&format=raw', 338 method: 'POST', 339 data: JSON.stringify(altCookies), 340 headers: { 341 'Cache-Control' : 'no-cache', 342 'Content-Type': 'application/json' 343 }, 344 onSuccess: function (response){ 345 console.log(response); 346 }, 347 onError: function (error){ 348 console.log(error); 349 } 350 }); 351} 352 353function ctCheckAjax(target, allow, forbidden) 354{ 355 let data = apbctLocalStorage.getCleanTalkData(); 356 data.action = 'check_ajax'; 357 358 Joomla.request({ 359 url: 'index.php?option=com_ajax&plugin=cleantalkantispam&format=raw', 360 method: 'POST', 361 data: JSON.stringify(data), 362 headers: { 363 'Cache-Control' : 'no-cache', 364 'Content-Type': 'application/json' 365 }, 366 onSuccess: function (response){ 367 let result = JSON.parse(response); 368 369 if (result && result.allow == 1) { 370 allow(target); 371 } 372 373 if (result && result.allow == 0) { 374 forbidden(target, result.msg); 375 } 376 }, 377 onError: function (error){ 378 console.log('error', error); 379 } 380 }); 381}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.