From 07e66fec2612459563b116fb276312621fce9f6c Mon Sep 17 00:00:00 2001
From: GDColon
Date: Thu, 20 Feb 2020 20:09:40 -0500
Subject: [PATCH] Profile improvements, level versions, mod badges, oh my!
I'M ALIVE!!!!!
- Added account and player ID to profile page
- You can now search players by account ID. (It should figure it out automatically)
- Moved profile post button to the bottom left of profile page and put the uploaded levels button back where it belongs
- Added GD version to level info
- Added support for regular mod badge in comments ("modColor" is now "moderator" in API)
- IP address is now randomized when posting a comment, because it seems to be the best method
---
api/comments.js | 3 ++-
api/post/postComment.js | 2 +-
api/profile.js | 9 ++-------
classes/Level.js | 1 +
html/api.html | 21 +++++++++++----------
html/comments.html | 9 +++++----
html/level.html | 1 +
html/profile.html | 8 ++++++--
index.js | 4 ++--
misc/credits.json | 2 +-
10 files changed, 32 insertions(+), 28 deletions(-)
diff --git a/api/comments.js b/api/comments.js
index d30d909..f5f3a57 100644
--- a/api/comments.js
+++ b/api/comments.js
@@ -55,7 +55,8 @@ module.exports = async (app, req, res) => {
comment.accountID = y[16]
comment.form = ['icon', 'ship', 'ball', 'ufo', 'wave', 'robot', 'spider'][Number(y[14])]
if (x[10] > 0) comment.percent = x[10]
- if (x[12] && x[12].includes(',')) comment.modColor = true
+ if (x[12] && x[12].includes(',')) comment.moderator = 1 + (x[12] != "255,255,255")
+ else comment.moderator = 0
}
commentArray.push(comment)
diff --git a/api/post/postComment.js b/api/post/postComment.js
index eb19e1f..3b816bc 100644
--- a/api/post/postComment.js
+++ b/api/post/postComment.js
@@ -47,7 +47,7 @@ module.exports = async (app, req, res) => {
request.post(app.endpoint + 'uploadGJComment21.php', {
form: params,
- headers: {'x-forwarded-for': req.headers['x-forwarded-for'] || req.connection.remoteAddress } // prevent pesky ip bans
+ headers: {'x-forwarded-for': (Math.floor(Math.random() * 255) + 1)+"."+(Math.floor(Math.random() * 255) + 0)+"."+(Math.floor(Math.random() * 255) + 0)+"."+(Math.floor(Math.random() * 255) + 0) } // prevent pesky ip bans using a random ip
}, function (err, resp, body) {
if (err) return res.status(400).send("The Geometry Dash servers returned an error! Perhaps they're down for maintenance")
if (!body || body == "-1") return res.status(400).send("The Geometry Dash servers rejected your comment! Try again later, or make sure your username and password are entered correctly.")
diff --git a/api/profile.js b/api/profile.js
index 098e9d3..ab513fc 100644
--- a/api/profile.js
+++ b/api/profile.js
@@ -10,16 +10,11 @@ module.exports = async (app, req, res, api, getLevels) => {
}
}, function (err1, res1, b1) {
- if (err1 || b1 == '-1' || !b1) {
- if (!api) return res.redirect('/search/' + req.params.id)
- else return res.send("-1")
- }
-
- let gdSearchResult = app.parseResponse(b1)
+ let searchResult = (err1 || b1 == '-1' || !b1) ? req.params.id : app.parseResponse(b1)[16]
request.post(app.endpoint + 'getGJUserInfo20.php', {
form: {
- targetAccountID: gdSearchResult[16],
+ targetAccountID: searchResult,
secret: app.secret
}
}, function (err2, res2, body) {
diff --git a/classes/Level.js b/classes/Level.js
index 6094bf4..95bf2d0 100644
--- a/classes/Level.js
+++ b/classes/Level.js
@@ -24,6 +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 : Number('1.' + (levelInfo[13]-1))
if (levelInfo[28]) this.uploaded = levelInfo[28] + config.timestampSuffix
if (levelInfo[29]) this.updated = levelInfo[29] + config.timestampSuffix
this.version = levelInfo[5];
diff --git a/html/api.html b/html/api.html
index df0c8c4..64b433f 100644
--- a/html/api.html
+++ b/html/api.html
@@ -80,10 +80,10 @@
Level Leaderboards /api/leaderboardLevel/levelID
Comments & Posts /api/comments/level-or-user-ID
Level Analysis /api/analyze/levelID
- Commenting /api/postComment (POST)
- Profile Posting /api/postProfileComment (POST)
+ Commenting /postComment (POST)
+ Profile Posting /postProfileComment (POST)
Messages /messages (4 different POSTs)
- Liking /api/like (POST)
+ Liking /like (POST)
Icons /icon/username
@@ -132,6 +132,7 @@
diamonds: Amount of diamonds received for beating the level (stars + 2)
featured: Whether the level is featured or not
epic: Whether the level has an "epic" rating or not
+ gameVersion: The version of GD the level was released on (1.9, 2.1, etc)
version: Number of times the level was updated
copiedID: The original level ID, if the level was copied. Otherwise returns 0
officialSong: The level number of the song, if no custom song is used. Otherwise returns 0
@@ -442,7 +443,7 @@
accountID: The commenter's account ID
form: The form of the commenter's icon
percent: The commenter's percent on the level, if provided
- modColor: If the commenter is an elder mod and gets fancy green text
+ moderator: If type of moderator the commenter is. Returns 0 (none), 1 (mod) or 2 (elder, green text)
@@ -530,7 +531,7 @@
Example
${x.content}
+${x.content}