Fixed verison number parsing
shoutouts to alex1304
This commit is contained in:
parent
6383e6fb65
commit
04aee60f8a
5 changed files with 9 additions and 9 deletions
|
@ -39,7 +39,7 @@ module.exports = async (app, req, res) => {
|
|||
if (!x[2]) return;
|
||||
|
||||
let comment = {}
|
||||
comment.content = app.clean(Buffer.from(x[2], 'base64').toString());
|
||||
comment.content = Buffer.from(x[2], 'base64').toString();
|
||||
comment.ID = x[6]
|
||||
comment.likes = x[4]
|
||||
comment.date = (x[9] || "?") + app.config.timestampSuffix
|
||||
|
|
|
@ -5,7 +5,7 @@ const crypto = require('crypto')
|
|||
function sha1(data) { return crypto.createHash("sha1").update(data, "binary").digest("hex"); }
|
||||
|
||||
let rateLimit = {};
|
||||
let cooldown = 10000
|
||||
let cooldown = 15000 // GD has a secret rate limit and doesn't alert you when a comment is rejected, so I'm doing the honors
|
||||
|
||||
function getTime(time) {
|
||||
let seconds = Math.ceil(time / 1000);
|
||||
|
@ -56,7 +56,5 @@ module.exports = async (app, req, res) => {
|
|||
return res.status(400).send(`You have been banned from commenting for ${(parseInt(banStuff[1]) / 86400).toFixed(0)} days. Reason: ${banStuff[2] || "None"}`)
|
||||
}
|
||||
res.status(200).send(`Comment posted to level ${params.levelID} with ID ${body}`)
|
||||
rateLimit[req.body.username] = Date.now();
|
||||
setTimeout(() => {delete rateLimit[req.body.username]; }, cooldown);
|
||||
})
|
||||
}
|
|
@ -24,7 +24,7 @@ class Level {
|
|||
this.diamonds = levelInfo[18] < 2 ? 0 : parseInt(levelInfo[18]) + 2
|
||||
this.featured = levelInfo[19] > 0
|
||||
this.epic = levelInfo[42] == 1
|
||||
this.gameVersion = levelInfo[13] > 17 ? (levelInfo[13] / 10).toFixed(1) : '1.' + (levelInfo[13]-1)
|
||||
this.gameVersion = levelInfo[13] > 17 ? (levelInfo[13] / 10).toFixed(1) : levelInfo[13] == 11 ? "1.8" : levelInfo[13] == 10 ? "1.7" : "Pre-1.7"
|
||||
if (levelInfo[28]) this.uploaded = levelInfo[28] + config.timestampSuffix
|
||||
if (levelInfo[29]) this.updated = levelInfo[29] + config.timestampSuffix
|
||||
this.version = levelInfo[5];
|
||||
|
|
|
@ -509,10 +509,10 @@
|
|||
<div id="commenting" class="anchor"></div>
|
||||
<div class="main-block">
|
||||
<h1>Commenting</h1>
|
||||
<p>POST: /api/postComment</p>
|
||||
<p>POST: /postComment</p>
|
||||
|
||||
<p>Leaves a comment on a level. This one is a POST request!</p>
|
||||
<p>*Commenting has a rate limit of 10 seconds</p>
|
||||
<p>*Commenting has a rate limit of 15 seconds</p>
|
||||
|
||||
<br>
|
||||
<p class="reveal" onclick="$('#params-commenting').slideToggle(100)"><b>Parameters (6)</b></p>
|
||||
|
|
|
@ -131,6 +131,8 @@ if (mode == "top") {
|
|||
$('#topSort').attr('src', "../assets/sort-likes-on.png")
|
||||
}
|
||||
|
||||
function clean(text) {if (!text || typeof text != "string") return text; else return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/=/g, "=").replace(/"/g, """).replace(/'/g, "'")}
|
||||
|
||||
$('#compactMode').attr('src', `../assets/compact-${compact ? "on" : "off"}.png`)
|
||||
|
||||
let target = `../api/level/${lvlID}`
|
||||
|
@ -215,7 +217,7 @@ fetch(`../api${!history ? window.location.pathname : "/comments/" + lvl.playerID
|
|||
<p class="commentPercent inline">${x.percent ? x.percent + "%" : ""}</p>
|
||||
|
||||
<div class="commentAlign">
|
||||
<p class="commentText" style="color: rgb(${!history && x.playerID == lvl.authorID ? "255, 255, 75" : x.playerID == "16" ? "50, 255, 255" : modNumber == 2 ? "75, 255, 75" : x.browserColor ? "255, 180, 255" : "255, 255, 255"})">${x.content}</p>
|
||||
<p class="commentText" style="color: rgb(${!history && x.playerID == lvl.authorID ? "255, 255, 75" : x.playerID == "16" ? "50, 255, 255" : modNumber == 2 ? "75, 255, 75" : x.browserColor ? "255, 180, 255" : "255, 255, 255"})">${clean(x.content)}</p>
|
||||
</div>
|
||||
</div>
|
||||
<p class="commentDate">${x.date}</p>
|
||||
|
@ -241,7 +243,7 @@ fetch(`../api${!history ? window.location.pathname : "/comments/" + lvl.playerID
|
|||
<p class="commentPercent inline">${x.percent ? x.percent + "%" : ""}</p>
|
||||
|
||||
<div class="commentAlign">
|
||||
<p class="commentText" style="color: rgb(${!history && x.playerID == lvl.authorID ? "255, 255, 75" : x.playerID == "16" ? "50, 255, 255" : modNumber == "2" ? "75, 255, 75" : x.browserColor ? "255, 180, 255" : "255, 255, 255"})">${x.content}</p>
|
||||
<p class="commentText" style="color: rgb(${!history && x.playerID == lvl.authorID ? "255, 255, 75" : x.playerID == "16" ? "50, 255, 255" : modNumber == "2" ? "75, 255, 75" : x.browserColor ? "255, 180, 255" : "255, 255, 255"})">${clean(x.content)}</p>
|
||||
</div>
|
||||
</div>
|
||||
<p class="commentDate compactDate">${x.date}</p>
|
||||
|
|
Loading…
Add table
Reference in a new issue