diff --git a/calendar.html b/calendar.html index 7e0e172..b53541a 100644 --- a/calendar.html +++ b/calendar.html @@ -6,7 +6,7 @@ - + @@ -370,6 +370,8 @@ calSpacing.cellSpacing = 1; calSpacing.cellPadding = 1; } + + document.getElementById('calHeader').style.display = "block"; } @@ -389,42 +391,58 @@ //Get serverId const id = window.localStorage.getItem('Id').toString(); - var xhr2 = new XMLHttpRequest(); - xhr2.open('get', 'http://www.selmerbot.com/getCal/', true); - xhr2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); + //Check if the user has premium + var xhrverify = new XMLHttpRequest(); + xhrverify.open('post', 'http://www.selmerbot.com/verifypremium/', true); + xhrverify.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); //Use the guild Id as the userId - xhr2.setRequestHeader('userId', id); + xhrverify.setRequestHeader('userId', id); + xhrverify.onloadend = (e) => { + if (xhrverify.response == "Unauthorized") { + document.getElementById("unauth").style.display = "block"; + return; + } - xhr2.onloadend = (e) => { - const calList = new Map(); + var xhr2 = new XMLHttpRequest(); + xhr2.open('get', 'http://www.selmerbot.com/getCal/', true); + xhr2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); - const res = JSON.parse(xhr2.response); - const times = res[0]; - const monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; - document.getElementById('monthName').innerText = `Editing Reminders for the Month of ${monthNames[(new Date()).getMonth()]}`; + //Use the guild Id as the userId + xhr2.setRequestHeader('userId', id); - times.forEach((time, ind) => { - const fullDate = new Date(Number(time)); - const month = fullDate.getMonth(); - const day = fullDate.getDate(); + xhr2.onloadend = (e) => { + const calList = new Map(); - //Make sure it's the right month (old ones should be removed, this is just a catch) - if (month == (new Date()).getMonth()) { - if (calList.has(day)) { - var temp = calList.get(day); - temp.push(res[1][ind]); - calList.set(day, temp); - } else { - calList.set(day, [res[1][ind]]); + const res = JSON.parse(xhr2.response); + const times = res[0]; + const monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; + document.getElementById('monthName').innerText = `Editing Reminders for the Month of ${monthNames[(new Date()).getMonth()]}`; + + times.forEach((time, ind) => { + const fullDate = new Date(Number(time)); + const month = fullDate.getMonth(); + const day = fullDate.getDate(); + + //Make sure it's the right month (old ones should be removed, this is just a catch) + if (month == (new Date()).getMonth()) { + if (calList.has(day)) { + var temp = calList.get(day); + temp.push(res[1][ind]); + calList.set(day, temp); + } else { + calList.set(day, [res[1][ind]]); + } } - } - }); + }); - calSetup(calList); + calSetup(calList); + } + + xhr2.send(); } - xhr2.send(); + xhrverify.send(); } @@ -473,8 +491,14 @@ + + - + Sun diff --git a/dashboard.html b/dashboard.html index 9187c8e..9f5f8ff 100644 --- a/dashboard.html +++ b/dashboard.html @@ -6,7 +6,7 @@ Selmer Bot Web Dashboard - + @@ -385,102 +385,123 @@ } } - //Load the channels - var xhr = new XMLHttpRequest(); - xhr.open('get', `http://www.selmerbot.com/getChannels/`, true); - xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); - xhr.setRequestHeader('serverNumber', serverSettings.Id); - xhr.onloadend = (e) => { - //Channel Section - const channels = JSON.parse(xhr.response); - // console.log(channels.text); - // window.localStorage.setItem('channels', (xhr.response)); - - for (let i = 0; i < channels.text.length; i ++) { - var channel = channels.text[i]; - if (channel.name && channel.id) { - var optlog = document.createElement('option'); - optlog.value = channel.id; - optlog.innerHTML = channel.name; - - //I need two because if I try to append the same one, it only appends to one dorpdown - var optwelcome = document.createElement('option'); - optwelcome.value = channel.id; - optwelcome.innerHTML = channel.name; - - if (serverSettings.WELCOME.welcomechannel == optwelcome.value) { - optwelcome.setAttribute('selected', ''); - } - - if (serverSettings.LOG.logchannel == optlog.value) { - optlog.setAttribute('selected', ''); - // optlog.selected = serverSettings.LOG.logchannel; - } - - - document.getElementById('logchanneldropdown').appendChild(optlog); - document.getElementById('welcomechanneldropdown').appendChild(optwelcome); - } - } - - // document.getElementById('body').classList.replace('hide', 'show'); - - //Welcome section - let wc = serverSettings.WELCOME.welcomechannel || ''; - let wm = serverSettings.WELCOME.welcomemessage || ''; - // document.getElementById('wc').setAttribute('value', wc); - document.getElementById('wm').setAttribute('value', wm); - - //Logging section ,"LOG":{"_id":"LOG","keepLogs":false,"logchannel":null,"severity":0}} - let kl = serverSettings.LOG.keepLogs || false; - let lc = serverSettings.LOG.logchannel || ''; - let ls = serverSettings.LOG.severity || 0; - - document.getElementById('kl').checked = kl; - // document.getElementById('lc').setAttribute('value', lc); - - // document.getElementById('ls').children[ls].checked = true; //Doesn't work - } - xhr.send(); - //Get serverId instead of the userId const id = serverSettings.Id; - var xhr2 = new XMLHttpRequest(); - xhr2.open('get', 'http://www.selmerbot.com/getCal/', true); - xhr2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); + //Check if the user has premium + var xhrverify = new XMLHttpRequest(); + xhrverify.open('post', 'http://www.selmerbot.com/verifypremium/', true); + xhrverify.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); - xhr2.setRequestHeader('userId', id); + //Use the guild Id as the userId + xhrverify.setRequestHeader('userId', id); + xhrverify.onloadend = (e) => { + console.log(xhrverify.response); //WHAT + if (xhrverify.response == "Unauthorized") { + document.getElementById("calForm").style.display = "none"; + document.getElementById("unauth").style.display = "block"; + return; + } else if (xhrverify.response == 'Internal Server Error') { + alert("Uh oh, an Internal Server Error has occured!\nPlease try again!"); + return window.location.href = "index.html"; + } - xhr2.onloadend = (e) => { - const calList = new Map(); + //Load the channels + var xhr = new XMLHttpRequest(); + xhr.open('get', `http://www.selmerbot.com/getChannels/`, true); + xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); + xhr.setRequestHeader('serverNumber', id); + xhr.onloadend = (e) => { + //Channel Section + const channels = JSON.parse(xhr.response); + // console.log(channels.text); + // window.localStorage.setItem('channels', (xhr.response)); - const res = JSON.parse(xhr2.response); - const times = res[0]; - const monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; - document.getElementById('monthName').innerText = `Editing Reminders for the Month of ${monthNames[(new Date()).getMonth()]}`; + for (let i = 0; i < channels.text.length; i ++) { + var channel = channels.text[i]; + if (channel.name && channel.id) { + var optlog = document.createElement('option'); + optlog.value = channel.id; + optlog.innerHTML = channel.name; - times.forEach((time, ind) => { - const fullDate = new Date(Number(time)); - const month = fullDate.getMonth(); - const day = fullDate.getDate(); + //I need two because if I try to append the same one, it only appends to one dorpdown + var optwelcome = document.createElement('option'); + optwelcome.value = channel.id; + optwelcome.innerHTML = channel.name; - //Make sure it's the right month (old ones should be removed, this is just a catch) - if (month == (new Date()).getMonth()) { - if (calList.has(day)) { - var temp = calList.get(day); - temp.push(res[1][ind]); - calList.set(day, temp); - } else { - calList.set(day, [res[1][ind]]); + if (serverSettings.WELCOME.welcomechannel == optwelcome.value) { + optwelcome.setAttribute('selected', ''); + } + + if (serverSettings.LOG.logchannel == optlog.value) { + optlog.setAttribute('selected', ''); + // optlog.selected = serverSettings.LOG.logchannel; + } + + + document.getElementById('logchanneldropdown').appendChild(optlog); + document.getElementById('welcomechanneldropdown').appendChild(optwelcome); } } - }); + + // document.getElementById('body').classList.replace('hide', 'show'); + + //Welcome section + let wc = serverSettings.WELCOME.welcomechannel || ''; + let wm = serverSettings.WELCOME.welcomemessage || ''; + // document.getElementById('wc').setAttribute('value', wc); + document.getElementById('wm').setAttribute('value', wm); - calSetup(calList); + //Logging section ,"LOG":{"_id":"LOG","keepLogs":false,"logchannel":null,"severity":0}} + let kl = serverSettings.LOG.keepLogs || false; + let lc = serverSettings.LOG.logchannel || ''; + let ls = serverSettings.LOG.severity || 0; + + document.getElementById('kl').checked = kl; + // document.getElementById('lc').setAttribute('value', lc); + + // document.getElementById('ls').children[ls].checked = true; //Doesn't work + } + xhr.send(); + + var xhr2 = new XMLHttpRequest(); + xhr2.open('get', 'http://www.selmerbot.com/getCal/', true); + xhr2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); + + xhr2.setRequestHeader('userId', id); + + xhr2.onloadend = (e) => { + const calList = new Map(); + + const res = JSON.parse(xhr2.response); + const times = res[0]; + const monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; + document.getElementById('monthName').innerText = `Editing Reminders for the Month of ${monthNames[(new Date()).getMonth()]}`; + + times.forEach((time, ind) => { + const fullDate = new Date(Number(time)); + const month = fullDate.getMonth(); + const day = fullDate.getDate(); + + //Make sure it's the right month (old ones should be removed, this is just a catch) + if (month == (new Date()).getMonth()) { + if (calList.has(day)) { + var temp = calList.get(day); + temp.push(res[1][ind]); + calList.set(day, temp); + } else { + calList.set(day, [res[1][ind]]); + } + } + }); + + calSetup(calList); + } + + xhr2.send(); } - xhr2.send(); + xhrverify.send(); } @@ -670,6 +691,12 @@
+
+

You have to be a premium subscriber to use this feature!

+

vvv GET PREMIUM NOW vvv

+ +
+

- +
diff --git a/index.html b/index.html index 49312cc..11c21b0 100644 --- a/index.html +++ b/index.html @@ -6,7 +6,7 @@ Selmer Bot Web Dashboard - + diff --git a/main.js b/main.js index 019cc48..ad2566a 100644 --- a/main.js +++ b/main.js @@ -185,6 +185,24 @@ app.get('/.well-known/apple-developer-merchantid-domain-association', async (req return res.sendFile('apple-developer-merchantid-domain-association', { root: '.' }); }); +app.post('/verifypremium', async (req, res) => { + if (req.headers.userid) { + const id = req.headers.userid; + + connection.then((client) => { + const dbo = client.db('main').collection('authorized'); + dbo.findOne({id: id}).then((doc) => { + if (doc != undefined) { + res.sendStatus(200); + } else { + res.sendStatus(401); + } + }).catch((err) => { + console.error(err); return res.sendStatus(500); + }) + }); + } +}); app.post('/sendData', async (req, res) => { try { diff --git a/myGuilds.html b/myGuilds.html index 5d9f8d1..b9f9a06 100644 --- a/myGuilds.html +++ b/myGuilds.html @@ -4,7 +4,7 @@ Selmer Bot Web Dashboard - +