diff --git a/app.js b/app.js
index 731b6af..fc6ba27 100644
--- a/app.js
+++ b/app.js
@@ -19,7 +19,7 @@ var setRouter = require('./routes/set');
var uploadRouter = require('./routes/upload');
var userManagerRouter = require('./routes/usermanager');
var linkRouter = require('./routes/link');
-
+var fileRouter = require("./routes/filemanager")
var app = express();
@@ -46,6 +46,7 @@ app.use('/set', setRouter)
app.use('/upload', uploadRouter)
app.use('/usermanager', userManagerRouter)
app.use('/link', linkRouter)
+app.use("/filemanager", fileRouter)
// catch 404 and forward to error handler
diff --git a/links.json b/links.json
index f7bf650..e8ff510 100644
--- a/links.json
+++ b/links.json
@@ -1,10 +1,10 @@
{
- "Git GeekSchool": {
- "src": "https://git.geekschool.fr",
- "dest": "gitschool"
- },
"Gmail": {
"src": "https://mail.google.com/mail/",
"dest": "gmail"
+ },
+ "Git GeekSchool": {
+ "src": "https://git.geekschool.fr",
+ "dest": "gitschool"
}
}
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index 6b1f3f3..e59d2c2 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "neutral",
- "version": "DEV_2.0",
+ "version": "DEV_3.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "neutral",
- "version": "DEV_2.0",
+ "version": "DEV_3.0",
"dependencies": {
"@popperjs/core": "^2.11.6",
"bootstrap": "^5.2.2",
@@ -21,6 +21,7 @@
"http-errors": "~1.6.3",
"jimp": "^0.22.4",
"jquery": "^3.6.3",
+ "mime-types": "^2.1.35",
"morgan": "~1.9.1",
"nodemon": "^2.0.20",
"serve-favicon": "^2.5.0",
diff --git a/package.json b/package.json
index 933c480..95e13d2 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "neutral",
- "version": "DEV_3.0",
+ "version": "DEV_5.0",
"private": true,
"nodemonConfig": {
"ext": "js",
@@ -26,6 +26,7 @@
"http-errors": "~1.6.3",
"jimp": "^0.22.4",
"jquery": "^3.6.3",
+ "mime-types": "^2.1.35",
"morgan": "~1.9.1",
"nodemon": "^2.0.20",
"serve-favicon": "^2.5.0",
diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css
index 4cf8663..c7a95c6 100644
--- a/public/stylesheets/style.css
+++ b/public/stylesheets/style.css
@@ -156,28 +156,6 @@ body {
-.edropdown {
- display: inline-block;
- position: relative;
- --bs-gutter-x: 0rem;
-
-}
-.edropdown-content {
- text-align: center;
- display: none;
- background-color: rgb(80, 80, 80);
- position: absolute;
- width: 90%;
- right: 5%;
- padding: 0%;
- bottom: 15%;
- overflow: auto;
- border-radius: 1vw;
- box-shadow: 5px 5px 5px rgba(0,0,0,0.4);
- transition: all 0.1s ease 0s;
- margin-left: 1%;
-
-}
.viewbar {
@@ -229,6 +207,30 @@ body {
@media (min-width: 992px) {
+
+
+ .edropdown {
+ display: inline-block;
+ position: relative;
+ --bs-gutter-x: 0rem;
+
+ }
+ .edropdown-content {
+ text-align: center;
+ display: none;
+ background-color: rgb(80, 80, 80);
+ position: absolute;
+ width: 90%;
+ right: 5%;
+ padding: 0%;
+ bottom: 15%;
+ overflow: auto;
+ border-radius: 1vw;
+ box-shadow: 5px 5px 5px rgba(0,0,0,0.4);
+ transition: all 0.1s ease 0s;
+ margin-left: 1%;
+
+}
.logo {
@@ -408,6 +410,29 @@ body {
@media (max-width: 992px) {
+
+ .edropdown {
+ display: inline-block;
+ position: relative;
+ --bs-gutter-x: 0rem;
+
+ }
+ .edropdown-content {
+ text-align: center;
+ display: none;
+ background-color: rgb(80, 80, 80);
+ position: absolute;
+ width: 90%;
+ right: 5%;
+ padding: 0%;
+ overflow: auto;
+ border-radius: 1vw;
+ box-shadow: 5px 5px 5px rgba(0,0,0,0.4);
+ transition: all 0.1s ease 0s;
+ margin-left: 1%;
+
+ }
+
.sidebar {
font-size: 7vw;
@@ -450,17 +475,11 @@ body {
}
- .sidebar:hover .sidebar-image {
-
- display: unset;
-
- }
.sidebar-text {
- display: none;
-moz-user-select: none; /* Firefox */
-webkit-user-select: none; /* Chrome, Safari, Opéra depuis la version 15 */
-ms-user-select: none; /* Internet explorer depuis la version 10 et Edge */
@@ -468,11 +487,6 @@ body {
}
- .sidebar:hover .sidebar-text {
-
- display: unset;
- }
-
.sidebar-item {
diff --git a/public/templates/files.html b/public/templates/files.html
new file mode 100644
index 0000000..c769207
--- /dev/null
+++ b/public/templates/files.html
@@ -0,0 +1,554 @@
+
+
Gestionnnaire de fichiers
+
+
+
+
+
+
Fichiers
+
+
+
+
+
+
+
+
+
+
Le répertoire n'existe pas ou est vide.
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/public/templates/link.html b/public/templates/link.html
index b338a27..edbd221 100644
--- a/public/templates/link.html
+++ b/public/templates/link.html
@@ -70,29 +70,35 @@
var links = response.content
- for(var link of links) {
-
- linksContent.push('')
- dialogContent.push('')
+ if(response.result == "failed") {
+ content.innerHTML = ' Erreur de chargement des données - Erreur : ' + response.content + '
'
+ console.log("FAILED")
- lkcontent.innerHTML = linksContent.join("")
- lkdialogs.innerHTML = dialogContent.join("")
+ } else if(response.result == "success") {
+ for(var link of links) {
+
+ linksContent.push('')
+ dialogContent.push('')
+
+ lkcontent.innerHTML = linksContent.join("")
+ lkdialogs.innerHTML = dialogContent.join("")
+
+ }
+
+ for(var link of links) {
+
+ makeAction(link)
+ }
+
+
+ if(links.length == 0) {
+
+ lkcontent.innerHTML = 'Aucun lien raccourci n\'a été crée.' // lkcontent.innerHTML = linksContent.join("")
+
+ }
}
- for(var link of links) {
-
- makeAction(link)
- }
-
-
- if(links.length == 0) {
-
- lkcontent.innerHTML = 'Aucun lien raccourci n\'a été crée.' // lkcontent.innerHTML = linksContent.join("")
-
- }
-
-
}
diff --git a/public/templates/users.html b/public/templates/users.html
index fdc4692..0b43d63 100644
--- a/public/templates/users.html
+++ b/public/templates/users.html
@@ -187,7 +187,7 @@
fullname.innerHTML = response.content.fullname
permLevel.innerHTML = response.content.permLevel
- lastco.innerHTML = currentDate
+ lastco.innerHTML = currentDate;
const editBtn = document.getElementById(response.content.username + "_edit")
const decoBtn = document.getElementById(response.content.username +"_deco")
diff --git a/routes/filemanager.js b/routes/filemanager.js
new file mode 100644
index 0000000..83efa2e
--- /dev/null
+++ b/routes/filemanager.js
@@ -0,0 +1,105 @@
+var express = require('express');
+var router = express.Router();
+var ntr = require("../neutral-functions.js")
+var fs = require("fs")
+var path = require("path")
+var mime = require('mime-types')
+
+/* GET home page. */
+router.get('/', function(req, res, next) {
+
+
+ var check = ntr.checkToken(req, res)
+
+ if(check.name != false) {
+
+ res.redirect(302, "/")
+
+ } else {
+
+ res.render('login', {error: ""});
+ }
+
+});
+
+router.post("/", function(req, res, next) {
+
+ var check = ntr.checkToken(req, res)
+
+ if(check.name == false) {
+
+ res.send({"result":"failed", "content":"ERROR_TOKEN_NOT_VALID"})
+
+
+ } else {
+
+ if(check.permLevel >= 3) {
+
+ const bod = req.body
+
+ if(bod.request == "add") {
+
+ res.send({"result":"failed", "content":"ERROR_NOT_MAKE"})
+
+ } else if(bod.request == "get") {
+
+ var files = new Array()
+ const directory = req.body.value
+ fs.readdir(directory.replace("/", path.sep.replace("\\", path.sep)), (err, data) => {
+
+ if(err) {
+ res.send({"result":"success", "content": "ERROR_NOT_EXIST"})
+
+ } else {
+
+ try {
+
+ for(var file of data) {
+
+
+ const stat = fs.statSync(directory.replace("/", path.sep.replace("\\", path.sep)) + path.sep + file)
+
+ files.push({"name":file, "type":mime.lookup(file), "size":stat.size, "lastedition":stat.mtimeMs, "directory":stat.isDirectory()})
+
+
+ }
+
+ res.send({"result":"success", "content": files})
+
+
+ } catch(err) {
+
+ res.send({"result":"success", "content": "ERROR_NOT_PERMITTED"})
+
+ }
+
+
+ }
+
+ })
+
+
+
+
+ } else if(bod.request == "del") {
+
+ res.send({"result":"failed", "content":"ERROR_NOT_MAKE"})
+
+ } else if(bod.request == "rename") {
+
+ res.send({"result":"failed", "content":"ERROR_NOT_MAKE"})
+
+ } else {
+ res.send({"result":"failed", "content":"ERROR_REQUEST_MISSING_FIELDS", "additional": "REQUEST_MISSING"})
+ }
+
+ } else {
+
+ res.send({"result":"failed", "content":"ERROR_USER_PERMISSION_TOO_LOW"})
+ }
+
+ }
+
+})
+
+module.exports = router;
diff --git a/routes/link.js b/routes/link.js
index 83302fc..f7f9646 100644
--- a/routes/link.js
+++ b/routes/link.js
@@ -33,7 +33,7 @@ router.post("/", function (req, res, next) {
} else {
- if(check.permLevel >= 3) {
+ if(check.permLevel >= 1) {
if(req.body.request == "add") {
diff --git a/users/0cee5da6-6812-49d8-97f5-2df5c1d78191.json b/users/0cee5da6-6812-49d8-97f5-2df5c1d78191.json
index ca5acd2..c810756 100644
--- a/users/0cee5da6-6812-49d8-97f5-2df5c1d78191.json
+++ b/users/0cee5da6-6812-49d8-97f5-2df5c1d78191.json
@@ -5,9 +5,9 @@
"fullname": "Raphael PICOT",
"permissionLevel": 4,
"token": {
- "tokenID": "1c80ca40-60e9-4e48-b986-753678de41ca",
+ "tokenID": "0c2ac628-848e-42dd-9def-aaccac08b058",
"livableToken": true,
- "createdAt": 1677159656255
+ "createdAt": 1677339339934
},
- "lastconnexion": 1677159976281
+ "lastconnexion": 1677421147948
}
\ No newline at end of file
diff --git a/users/c8f353a4-d0df-4c10-bccc-d4f47daf0f51.json b/users/c8f353a4-d0df-4c10-bccc-d4f47daf0f51.json
index 69f6e5a..37fa7b5 100644
--- a/users/c8f353a4-d0df-4c10-bccc-d4f47daf0f51.json
+++ b/users/c8f353a4-d0df-4c10-bccc-d4f47daf0f51.json
@@ -1,13 +1,13 @@
{
"username": "root",
- "password": "U2FsdGVkX1/ICaOrZjiK+VFckzaSu/AcyQrpIPg2KuY=",
+ "password": "U2FsdGVkX19uiFCajX45dwmAqo3GpmAQho5U9g5RSww=",
"uuid": "c8f353a4-d0df-4c10-bccc-d4f47daf0f51",
"fullname": "Administrateur",
"permissionLevel": 4,
"token": {
- "tokenID": "00e7bb54-cd31-4c60-92a5-5c45164ea6ed",
+ "tokenID": "c750c10a-f69d-4dd2-8a35-65d8a74897bb",
"livableToken": false,
- "createdAt": 1677159640804
+ "createdAt": 1677339320398
},
- "lastconnexion": 1677159652801
+ "lastconnexion": 1677339336836
}
\ No newline at end of file