|
@ -335,11 +335,13 @@ app.post('/set-skin', function (req, res){ |
|
|
//(OldCoder, 2019)
|
|
|
//(OldCoder, 2019)
|
|
|
var directPath = ""; |
|
|
var directPath = ""; |
|
|
var indirectPath = ""; |
|
|
var indirectPath = ""; |
|
|
|
|
|
var destName = ""; |
|
|
var msg = "Uploading..."; |
|
|
var msg = "Uploading..."; |
|
|
form.parse(req, function(err, fields, files) { |
|
|
form.parse(req, function(err, fields, files) { |
|
|
if (err) next(err); |
|
|
if (err) next(err); |
|
|
directPath = skinDir + "/player_" + fields.userName + ".png"; |
|
|
destName = destName = "player_" + fields.userName; |
|
|
indirectPath = skinDir + "/player_" + fields.userName + ".skin"; |
|
|
directPath = skinDir + "/" + destName + ".png"; |
|
|
|
|
|
indirectPath = skinDir + "/" + destName + ".skin"; |
|
|
// TODO: make sure my_file and project_id values are present
|
|
|
// TODO: make sure my_file and project_id values are present
|
|
|
if (files.userFile != undefined) { |
|
|
if (files.userFile != undefined) { |
|
|
var originalPath = files.userFile.path; |
|
|
var originalPath = files.userFile.path; |
|
@ -348,10 +350,17 @@ app.post('/set-skin', function (req, res){ |
|
|
fs.rename(files.userFile.path, directPath, function(err) { |
|
|
fs.rename(files.userFile.path, directPath, function(err) { |
|
|
if (err) { |
|
|
if (err) { |
|
|
msg = "Failed to rename " + originalPath |
|
|
msg = "Failed to rename " + originalPath |
|
|
+ " to " + directPath + "<br/>\n"; |
|
|
+ " to " + directPath + "<br/>\n"; |
|
|
console.log(msg); |
|
|
console.log(msg); |
|
|
next(err); |
|
|
next(err); |
|
|
} |
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
fs.writeFile(indirectPath, destName, function(err, data) { |
|
|
|
|
|
if (err) console.log(err); |
|
|
|
|
|
console.log("Successfully wrote " + destName |
|
|
|
|
|
+ " to "+indirectPath+"."); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
res.end(); |
|
|
res.end(); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
@ -387,7 +396,6 @@ app.get('/', function (req, res) { |
|
|
if (req.query.date) selected_date_s = req.query.date |
|
|
if (req.query.date) selected_date_s = req.query.date |
|
|
if (req.query.msg != undefined) { |
|
|
if (req.query.msg != undefined) { |
|
|
ret += "<br/>\n"; |
|
|
ret += "<br/>\n"; |
|
|
|
|
|
|
|
|
//ret += "<b>" + querystring.parse(req.query.msg) + "</b><br>\n";
|
|
|
//ret += "<b>" + querystring.parse(req.query.msg) + "</b><br>\n";
|
|
|
// line above causes:
|
|
|
// line above causes:
|
|
|
//TypeError: Cannot convert object to primitive value
|
|
|
//TypeError: Cannot convert object to primitive value
|
|
|