|
|
@ -13,6 +13,9 @@ var jsonParser = bodyParser.json();
|
|
|
|
var urlencodedParser = bodyParser.urlencoded({
|
|
|
|
var urlencodedParser = bodyParser.urlencoded({
|
|
|
|
extended: false
|
|
|
|
extended: false
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const moment = require('moment'); // 使用 moment.js 来方便地处理时间格式
|
|
|
|
//桌面latest版
|
|
|
|
//桌面latest版
|
|
|
|
function execute(cmd){
|
|
|
|
function execute(cmd){
|
|
|
|
execSync(cmd,{cwd:'C:\\Users\\17217\\Desktop\\english\\python'},function(error, stdout, stderr){
|
|
|
|
execSync(cmd,{cwd:'C:\\Users\\17217\\Desktop\\english\\python'},function(error, stdout, stderr){
|
|
|
@ -158,6 +161,28 @@ router.get('/download', function (req, res, next) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
router.post('/login', urlencodedParser, function (req, res, next) {
|
|
|
|
router.post('/login', urlencodedParser, function (req, res, next) {
|
|
|
|
var name = req.body.name;
|
|
|
|
var name = req.body.name;
|
|
|
|
|
|
|
|
// 获取当前时间并格式化
|
|
|
|
|
|
|
|
const now = new Date();
|
|
|
|
|
|
|
|
const loginTime = now.toISOString(); // 使用 ISO 格式的时间字符串
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 在 name 获取后,添加文件操作代码
|
|
|
|
|
|
|
|
//const fs = require('fs');
|
|
|
|
|
|
|
|
const path = 'C:/Users/17217/Desktop/teamwk123/log.txt'; // 文件路径
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 将 name 和 loginTime 写入文件,追加模式
|
|
|
|
|
|
|
|
fs.appendFile(path, `${name} - ${loginTime}\n`, function (err) {
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
|
|
|
|
console.error('写入文件时发生错误:', err);
|
|
|
|
|
|
|
|
// 你可以选择返回错误响应或者继续执行
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log('用户名和登录时间已写入文件:', name, loginTime);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var pwd = req.body.pwd;
|
|
|
|
var pwd = req.body.pwd;
|
|
|
|
var sqlite3 = require('sqlite3').verbose()
|
|
|
|
var sqlite3 = require('sqlite3').verbose()
|
|
|
|
var sql = "SELECT * FROM users where username='" + name + "' and password='" + pwd+"'"
|
|
|
|
var sql = "SELECT * FROM users where username='" + name + "' and password='" + pwd+"'"
|
|
|
@ -168,7 +193,11 @@ router.post('/login', urlencodedParser, function (req, res, next) {
|
|
|
|
req.session.error = "用户名或密码错误,请重新输入!";
|
|
|
|
req.session.error = "用户名或密码错误,请重新输入!";
|
|
|
|
res.redirect('login');
|
|
|
|
res.redirect('login');
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
username = name
|
|
|
|
username = name; // 使用 const 来定义变量
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// var exec = require('child_process').exec;
|
|
|
|
// var exec = require('child_process').exec;
|
|
|
|
// exec(`python C:/Users/17217/Desktop/english/users/admin/log.py `+username)
|
|
|
|
// exec(`python C:/Users/17217/Desktop/english/users/admin/log.py `+username)
|
|
|
|
// db.run("delete from "+name,function(){ //每次先将表信息清空再重新读取文件夹里面的文件信息
|
|
|
|
// db.run("delete from "+name,function(){ //每次先将表信息清空再重新读取文件夹里面的文件信息
|
|
|
@ -315,7 +344,7 @@ router.post('/upload', multer({dest:'./users/'}).any(),function(req, res){
|
|
|
|
})
|
|
|
|
})
|
|
|
|
// execute("python D:/99/ui_ref/users/admin/a.py")
|
|
|
|
// execute("python D:/99/ui_ref/users/admin/a.py")
|
|
|
|
var exec = require('child_process').exec;
|
|
|
|
var exec = require('child_process').exec;
|
|
|
|
exec(`python C:/Users/17217/Desktop/english/users/admin/decode.py`)
|
|
|
|
exec(`python C:/Users/17217/Desktop/teamwk123/users/admin/decode.py`)
|
|
|
|
res.send('上传成功,点击←返回上一页');
|
|
|
|
res.send('上传成功,点击←返回上一页');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
@ -329,7 +358,7 @@ router.post('/execution',function(req, res){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
router.post("/getit", function (data, res) {
|
|
|
|
router.post("/getit", function (data, res) {
|
|
|
|
fs.readFile("C:\\Users\\17217\\Desktop\\english\\result.txt", 'utf-8', (err, data) => {
|
|
|
|
fs.readFile("C:\\Users\\17217\\Desktop\\teamwk123\\result.txt", 'utf-8', (err, data) => {
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
|
console.error(err);
|
|
|
|
console.error(err);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -341,7 +370,7 @@ router.post("/getit", function (data, res) {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
router.post("/histroy", function (data, res) {
|
|
|
|
router.post("/histroy", function (data, res) {
|
|
|
|
fs.readFile("C:\\Users\\17217\\Desktop\\english\\log.txt", 'utf-8', (err, data) => {
|
|
|
|
fs.readFile("C:\\Users\\17217\\Desktop\\teamwk123\\log.txt", 'utf-8', (err, data) => {
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
|
console.error(err);
|
|
|
|
console.error(err);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -353,7 +382,7 @@ router.post("/histroy", function (data, res) {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
router.post("/log", function (data, res) {
|
|
|
|
router.post("/log", function (data, res) {
|
|
|
|
fs.readFile("C:\\Users\\17217\\Desktop\\english\\rizhi.txt", 'utf-8', (err, data) => {
|
|
|
|
fs.readFile("C:\\Users\\17217\\Desktop\\teamwk123\\rizhi.txt", 'utf-8', (err, data) => {
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
|
console.error(err);
|
|
|
|
console.error(err);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|