Plugin Directory

Changeset 2866883


Ignore:
Timestamp:
02/17/2023 08:48:14 AM (3 years ago)
Author:
viaads
Message:

Order Hook Update

Location:
viaads
Files:
16 added
3 edited

Legend:

Unmodified
Added
Removed
  • viaads/trunk/js/viaads_handleEmailGuid.js

    r2866634 r2866883  
    22
    33if (window.location.search.includes("emailGuid=")) {
    4     let emailGuidInterval = setInterval(function () {
    5         let cookieAccept = getCookie("ViaAds");
    6         if (cookieAccept != undefined) {
     4    setInterval(function () {
     5        let cookieAaccept = getCookie("ViaAds");
     6        if (cookieAaccept != undefined) {
    77            setDefaultCookie();
    88            //guid//email//emailGuid
    9             var cookieValues = cookieAccept.split("//");
     9            var cookieValues = cookieAaccept.split("//");
    1010            var guid = cookieValues[0];
    11             if (guid == "") {
     11            if (guid == ""){
    1212                guid = uuidv4();
    1313            }
    14 
     14           
    1515            var mail = cookieValues[1];
    16             if (mail == "undefined") {
     16            if (mail == "undefined"){
    1717                mail = "";
    1818            }
    19 
     19           
    2020            document.cookie = "ViaAds=" + guid + "//" + mail + "//" + window.location.search.split("emailGuid=")[1] + "; max-age=34560000; path=/;";
    21             clearInterval(emailGuidInterval);
    2221        }
    2322    }, 2000);
     
    2524
    2625function setDefaultCookie() {
    27     let cookieAccept = getCookie("via_ads");
    28     if (cookieAccept != undefined) {
    29         let email = "";
    30         let eg = "";
    31 
    32         let oldCookie = getCookie("ViaAds");
    33         if (oldCookie != undefined) {
    34             let cookieValues = oldCookie.split("//");
    35             email = cookieValues[1];
    36             eg = cookieValues[2];
    37             document.cookie = 'ViaAds=; Max-Age=0; Path=/;';
    38         }
    39 
    40         //Basic cookie
    41         let cookie = {
    42             Consent: false,
    43             Session: uuidv4(),
    44             Email: email,
    45             EG: eg,
    46             FP: "",
    47             FPU: ""
    48         }
    49 
    50         fingerPrint(cookie);
    51     } else {
    52         let cookie = JSON.parse(atob(cookieAccept));
    53 
    54         //Check time for last fingerPrint update
    55         const date1Timestamp = cookie.FPU;
    56         const date2Timestamp = new Date().getTime() / 1000;
    57         const difference = date2Timestamp - date1Timestamp;
    58         const differenceInDays = Math.abs(difference / (60 * 60 * 24));
    59         if (differenceInDays >= 3) {
    60             fingerPrint(cookie);
    61             //hashFingerPrint(fingerPrint(cookie)).then(r => {});
     26    let cookieAaccept = getCookie("ViaAds");
     27    if (cookieAaccept != undefined) {
     28        if (cookieAaccept == "") {
     29            document.cookie = "ViaAds=" + uuidv4() + "////; max-age=34560000; path=/;";
    6230        }
    6331    }
     
    6735    const value = `; ${document.cookie}`;
    6836    const parts = value.split(`; ${name}=`);
    69     if (parts.length === 2) return decodeURIComponent(parts.pop().split(';').shift());
     37    if (parts.length === 2) return parts.pop().split(';').shift();
    7038}
    7139
     
    7543    );
    7644}
    77 
    78 function fingerPrint(cookie) {
    79     let userAgent = navigator.userAgent;
    80     let platForm = window.navigator.platform;
    81     let cookieEnabled = window.navigator.cookieEnabled;
    82     let timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
    83     let language = navigator.language;
    84     //Canvas
    85     let fonts = "";
    86     for (const font of document.fonts) {
    87         fonts += font.family;
    88     }
    89     let doNotTrack = window.navigator.doNotTrack;
    90     let vendor = window.navigator.vendor;
    91     let hardwareConcurrency = window.navigator.hardwareConcurrency;
    92 
    93     const audioContext = new (window.AudioContext || window.webkitAudioContext)();
    94     let audio = `${audioContext.destination.channelCount}|${audioContext.destination.channelCountMode}|${audioContext.destination.channelInterpretation}|${audioContext.destination.maxChannelCount}|
    95     ${audioContext.destination.numberOfInputs}|${audioContext.destination.numberOfOutputs}|${audioContext.sampleRate}|${audioContext.state}`;
    96 
    97     hashFingerPrint(`${userAgent}${platForm}${cookieEnabled}${timeZone}${language}${fonts}${doNotTrack}${vendor}${hardwareConcurrency}${audio}`).then(r => {
    98         cookie.FP = r;
    99         cookie.FPU = new Date().getTime() / 1000;
    100         console.log(cookie);
    101         document.cookie = "via_ads=" + btoa(JSON.stringify(cookie)) + "; max-age=34560000; path=/;";
    102     });
    103 
    104 }
    105 
    106 async function hashFingerPrint(message) {
    107     const msgUint8 = new TextEncoder().encode(message);                           // encode as (utf-8) Uint8Array
    108     const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8);           // hash the message
    109     const hashArray = Array.from(new Uint8Array(hashBuffer));                     // convert buffer to byte array
    110     const hashHex = hashArray.map((b) => b.toString(16).padStart(2, '0')).join(''); // convert bytes to hex string
    111     return hashHex;
    112 }
    113 
  • viaads/trunk/readme.txt

    r2866634 r2866883  
    44Requires at least: 5.4
    55Tested up to: 6.1
    6 Stable tag: 1.1.2
     6Stable tag: 1.1.3
    77Requires PHP: 7.0
    88License: GPLv3
  • viaads/trunk/viaads.php

    r2866634 r2866883  
    33 * Plugin Name: ViaAds
    44 * Description: Plugin der muliggør forbindelsen til ViaAds / Plug-in enabling the connection to ViaAds.
    5  * Version: 1.1.2
     5 * Version: 1.1.3
    66 * Author: ViaAds
    77 * Author URI: https://www.viaads.dk/
Note: See TracChangeset for help on using the changeset viewer.