mirror of
https://dev.s-ul.net/Galexion/MaiMaiDXNet.git
synced 2024-11-28 00:20:50 +01:00
Hotfix #2: thanks for waiting
This commit is contained in:
parent
769317c0d7
commit
39fb90e14b
28
dbhandler.js
28
dbhandler.js
@ -7,12 +7,27 @@ if (serverType === 0) {
|
|||||||
const mysql = require('mysql');
|
const mysql = require('mysql');
|
||||||
//var con = mysql.createConnection(ArtConnSettings);
|
//var con = mysql.createConnection(ArtConnSettings);
|
||||||
var pool = mysql.createPool(ArtConnSettings);
|
var pool = mysql.createPool(ArtConnSettings);
|
||||||
var con = undefined
|
|
||||||
if (serverType === 1) {
|
if (serverType === 1) {
|
||||||
pool.getConnection(function(err, connection) {
|
function establishConnection() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
pool.getConnection(function(err, con) {
|
||||||
if (err) throw err; // not connected!
|
if (err) throw err; // not connected!
|
||||||
con = connection;
|
resolve(con);
|
||||||
|
con.on('error', function(err) {
|
||||||
|
console.log('MySQL error', err);
|
||||||
|
if (err.code === 'PROTOCOL_CONNECTION_LOST') {
|
||||||
|
console.log('Reconnecting MySQL connection...');
|
||||||
|
con = mysql.createConnection(connection.config);
|
||||||
|
pool.getConnection(function(err, connection) {
|
||||||
|
if (err) throw err; // not connected!
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// index.js route '/'
|
// index.js route '/'
|
||||||
@ -30,6 +45,7 @@ async function getUserCount() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
var con = await establishConnection();
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
con.query("SELECT * FROM aime.mai2_profile_detail", function (err, result, fields) {
|
con.query("SELECT * FROM aime.mai2_profile_detail", function (err, result, fields) {
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -71,6 +87,7 @@ async function getUserData(req) {
|
|||||||
});
|
});
|
||||||
}); // function is required to obtain the User Data, and create the user profile. I'm going to bed.
|
}); // function is required to obtain the User Data, and create the user profile. I'm going to bed.
|
||||||
} else { // 07-23 oh god im going to have to recreate this function again aren't i
|
} else { // 07-23 oh god im going to have to recreate this function again aren't i
|
||||||
|
var con = await establishConnection();
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
con.query("SELECT * FROM aime.mai2_profile_detail", function (err, result, fields) {
|
con.query("SELECT * FROM aime.mai2_profile_detail", function (err, result, fields) {
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -82,7 +99,6 @@ async function getUserData(req) {
|
|||||||
const cookies = req.cookies
|
const cookies = req.cookies
|
||||||
var mUser = undefined // Leave the Matched User undefined until the user is found.
|
var mUser = undefined // Leave the Matched User undefined until the user is found.
|
||||||
for (user of result) { // For Each User in Rows
|
for (user of result) { // For Each User in Rows
|
||||||
console.log(user.user)
|
|
||||||
if (cookies.aime_card_id === user.user.toString()) { // If the Access Code for the card is in the system,
|
if (cookies.aime_card_id === user.user.toString()) { // 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.
|
mUser = user; // set the Matched User Variable to the User, and break the for Loop.
|
||||||
break;
|
break;
|
||||||
@ -126,6 +142,7 @@ async function getExtId(req) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
var con = await establishConnection();
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
con.query("SELECT * FROM aime.aime_card", function (err, result, fields) {
|
con.query("SELECT * FROM aime.aime_card", function (err, result, fields) {
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -177,6 +194,7 @@ async function getUserScores(req) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
var con = await establishConnection();
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
con.query("SELECT * FROM aime.mai2_playlog", function (err, result, fields) {
|
con.query("SELECT * FROM aime.mai2_playlog", function (err, result, fields) {
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -191,7 +209,6 @@ async function getUserScores(req) {
|
|||||||
var request = req.body;
|
var request = req.body;
|
||||||
var mUser = new Array(); // Leave the Matched User's Scores undefined until the user is found.
|
var mUser = new Array(); // Leave the Matched User's Scores undefined until the user is found.
|
||||||
for (score of result) { // For Each Score in Rows
|
for (score of result) { // For Each Score in Rows
|
||||||
console.log(request.input)
|
|
||||||
if (request.input == score.user) { // If the inputed User ID and Score's User ID Matches,
|
if (request.input == score.user) { // If the inputed User ID and Score's User ID Matches,
|
||||||
mUser.push(score) // add that score into the array.
|
mUser.push(score) // add that score into the array.
|
||||||
}
|
}
|
||||||
@ -228,6 +245,7 @@ async function getUserArea(req) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
var con = await establishConnection();
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
con.query("SELECT * FROM aime.mai2_item_map", function (err, result, fields) {
|
con.query("SELECT * FROM aime.mai2_item_map", function (err, result, fields) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
Loading…
Reference in New Issue
Block a user