mirror of
https://dev.s-ul.net/Galexion/MaiMaiDXNet.git
synced 2024-11-30 20:44:28 +01:00
124 lines
5.1 KiB
JavaScript
124 lines
5.1 KiB
JavaScript
var express = require('express');
|
|
var router = express.Router();
|
|
var fetch = require('cross-fetch');
|
|
const sqlite3 = require('sqlite3').verbose();
|
|
|
|
var config = require('../config.json');
|
|
let db = new sqlite3.Database(config.DXMemorialImageDirectory + '\\db.sqlite');
|
|
|
|
router.post('/getExtId/', function (req, res, next) {
|
|
db.all('SELECT * FROM sega_card', (err, rows) => {
|
|
if (err) {
|
|
console.error(err);
|
|
// Return a Failed Message.
|
|
res.status(500).json({ error: err.message, status: "Failed" });
|
|
} else {
|
|
// Make the Request easier to get to.
|
|
var request = req.body;
|
|
var mUser = undefined // Leave the Matched User undefined until the user is found.
|
|
for (user of rows) { // For Each User in Rows
|
|
if (request.input === user.luid) { // If the Access Code for the card is in the system,
|
|
mUser = user; // set the Matched User Variable to the User, and break the for Loop.
|
|
break
|
|
}
|
|
}
|
|
// Return a Response with the whole identifiable user data. the EXT_ID will be used later to identify images and other things and match them to the user's profile.
|
|
res.status(200).json({ data: mUser, status: "Complete" });
|
|
}
|
|
});
|
|
});
|
|
|
|
router.post('/getUserData/', function (req,res,next) {
|
|
db.all('SELECT * FROM maimai2_user_detail', (err, rows) => {
|
|
if (err) {
|
|
console.error(err);
|
|
// Return a Failed Message.
|
|
res.status(500).json({ error: err.message, status: "Failed" });
|
|
} else {
|
|
// Make the Request easier to get to.
|
|
var request = req.body;
|
|
var mUser = undefined // Leave the Matched User undefined until the user is found.
|
|
for (user of rows) { // For Each User in Rows
|
|
if (request.input === user.aime_card_id) { // If the Access Code for the card is in the system,
|
|
mUser = user; // set the Matched User Variable to the User, and break the for Loop.
|
|
break
|
|
}
|
|
}
|
|
// Return a Response with the whole identifiable user data. the EXT_ID will be used later to identify images and other things and match them to the user's profile.
|
|
res.status(200).json({ data: mUser, status: "Complete" });
|
|
}
|
|
});
|
|
})
|
|
|
|
router.post('/getUserScores/', function (req,res,next) {
|
|
db.all('SELECT * FROM maimai2_user_playlog', (err, rows) => {
|
|
if (err) {
|
|
console.error(err);
|
|
// Return a Failed Message.
|
|
res.status(500).json({ error: err.message, status: "Failed" });
|
|
} else {
|
|
// Make the Request easier to get to.
|
|
var request = req.body;
|
|
var mUser = new Array(); // Leave the Matched User's Scores undefined until the user is found.
|
|
for (score of rows) { // For Each Score in Rows
|
|
if (request.input == score.user_id) { // If the inputed User ID and Score's User ID Matches,
|
|
mUser.push(score) // add that score into the array.
|
|
}
|
|
}
|
|
// Return a Response with all the Scores listed under that user.
|
|
res.status(200).json({ data: mUser, status: "Complete" });
|
|
}
|
|
});
|
|
});
|
|
|
|
router.post('/getUserArea/', function (req,res,next) {
|
|
db.all('SELECT * FROM maimai2_user_map', (err, rows) => {
|
|
if (err) {
|
|
console.error(err);
|
|
// Return a Failed Message.
|
|
res.status(500).json({ error: err.message, status: "Failed" });
|
|
} else {
|
|
// Make the Request easier to get to.
|
|
var request = req.body;
|
|
var mUser = new Array(); // Leave the Matched User's Areas undefined until the user is found.
|
|
for (map of rows) { // For Each Area in Rows
|
|
if (request.input == map.user_id) { // If the inputed User ID and Score's User ID Matches,
|
|
mUser.push(map) // add that Area into the array.
|
|
}
|
|
}
|
|
// Return a Response with all the Areas listed under that user.
|
|
res.status(200).json({ data: mUser, status: "Complete" });
|
|
}
|
|
});
|
|
});
|
|
|
|
router.post('/getuserbanned/', function (req,res,next) {
|
|
var request = req.body;
|
|
if (request.input === undefined) {
|
|
return res.status(500).send('Failed to update user ban state, insufficent paramaters');
|
|
}
|
|
db.run('UPDATE maimai2_user_detail SET ban_state = ? WHERE id = ?', [2, request.input], function(err) {
|
|
if (err) {
|
|
console.error(err.message);
|
|
res.status(500).send('Failed to update user ban state');
|
|
} else {
|
|
res.send({"status": "Success", "message": `User ${request.input} banned.`});
|
|
}
|
|
});
|
|
});
|
|
|
|
router.post('/getuserunbanned/', function (req,res,next) {
|
|
var request = req.body;
|
|
if (request.input === undefined) {
|
|
return res.status(500).send('Failed to update user ban state, insufficent paramaters');
|
|
}
|
|
db.run('UPDATE maimai2_user_detail SET ban_state = ? WHERE id = ?', [0, request.input], function(err) {
|
|
if (err) {
|
|
console.error(err.message);
|
|
res.status(500).send('Failed to update user ban state');
|
|
} else {
|
|
res.send({"status": "Success", "message": `User ${request.input} unbanned.`});
|
|
}
|
|
});
|
|
});
|
|
module.exports = router; |