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

Example Request

-

POST /api/postComment
+

POST /postComment
?comment=This is a nifty comment!
&username=colon
&accountID=106255
@@ -549,7 +550,7 @@

Profile Posting

-

POST: /api/postProfileComment

+

POST: /postProfileComment

Leaves a profile post. This one is a POST request!

@@ -568,7 +569,7 @@

Example

Example Requests

-

POST /api/postProfileComment
+

POST /postProfileComment
?comment=Update 2.0 is revolution!
&username=viprin
&accountID=2795
@@ -586,7 +587,7 @@

Liking

-

POST: /api/like

+

POST: /like

Likes/dislikes level, comment, or post. This one is a POST request!

@@ -607,7 +608,7 @@

Example Request

Drop a like on RobTop's popular "can you handle the kappa" comment:

-

POST /api/like
+

POST /like
?id=42602304 (ID of the comment)
&like=1 (thumbs up)
&type=2 (liking a comment)
@@ -683,7 +684,7 @@

Send "Hello!" to Tubular9:

-

POST /deleteMessage
+

POST /sendMessage
?accountID=106255
&password=KitsuneColon333
&subject=Message for you
diff --git a/html/comments.html b/html/comments.html index 6122355..103732f 100644 --- a/html/comments.html +++ b/html/comments.html @@ -200,6 +200,7 @@ fetch(`../api${!history ? window.location.pathname : "/comments/" + lvl.playerID let userName = !history ? x.username : lvl.username let userLink = encodeURI(userName) + let modNumber = x.moderator || lvl.moderator if (!compact) { ////// NORMAL MODE ////// @@ -210,11 +211,11 @@ fetch(`../api${!history ? window.location.pathname : "/comments/" + lvl.playerID

${userName}

- ${x.modColor || lvl.moderator == "2" ? `` : ""} + ${modNumber ? `` : ""}

${x.percent ? x.percent + "%" : ""}

-

${x.content}

+

${x.content}

${x.date}

@@ -236,11 +237,11 @@ fetch(`../api${!history ? window.location.pathname : "/comments/" + lvl.playerID

${userName}

- ${x.modColor || lvl.moderator == "2" ? `` : ""} + ${modNumber ? `` : ""}

${x.percent ? x.percent + "%" : ""}

-

${x.content}

+

${x.content}

${x.date}

diff --git a/html/level.html b/html/level.html index 6289d14..6ae9ccd 100644 --- a/html/level.html +++ b/html/level.html @@ -20,6 +20,7 @@ [[NAME]]
ID: [[ID]][[ORIGINALINFO]][[LOWDETAIL]][[PASS]][[UPLOAD]][[UPDATE]]
Version: [[VERSION]] +
GD Version: [[GAMEVERSION]] [[OBJECTINFO]][[REQUESTED]]

diff --git a/html/profile.html b/html/profile.html index 7c5d1ff..de1c803 100644 --- a/html/profile.html +++ b/html/profile.html @@ -108,12 +108,16 @@
- +
+ +
+

Account ID: [[ACCOUNTID]]
Player ID: [[PLAYERID]]

+
@@ -133,7 +137,7 @@
-
+
diff --git a/index.js b/index.js index e4e15ef..1f287ba 100644 --- a/index.js +++ b/index.js @@ -34,13 +34,13 @@ try { const secrets = require("./misc/secretStuff.json") app.id = secrets.id app.gjp = secrets.gjp - if (app.id == "account id goes here" || app.gjp == "account gjp goes here") console.log("Warning: No account ID and/or GJP has been provided in secretStuff.json! These are required for level leaderboards to work.") + if (app.id == "account id goes here" || app.gjp == "account gjp goes here") console.warn("Warning: No account ID and/or GJP has been provided in secretStuff.json! These are required for level leaderboards to work.") } catch(e) { app.id = 0 app.gjp = 0 - console.log("Warning: secretStuff.json has not been created! These are required for level leaderboards to work.") + console.warn("Warning: secretStuff.json has not been created! These are required for level leaderboards to work.") } app.parseResponse = function (responseBody, splitter) { diff --git a/misc/credits.json b/misc/credits.json index 185fe50..5a86267 100644 --- a/misc/credits.json +++ b/misc/credits.json @@ -21,7 +21,7 @@ "header": "Level Analyzing Help", "name": "Alten", "youtube": ["https://youtube.com/channel/UC9M8hLqh2yZIPSDvpyL7o8g", "youtube"], - "twitter": ["https://twitter.com/gd_alten", "twitter"], + "twitter": ["https://twitter.com/altenhh", "twitter"], "github": ["https://github.com/Altenhh", "github"] },