First commit of the new Insider version on docker

This commit is contained in:
2024-03-27 18:20:08 +01:00
parent 7637b068f9
commit be57c29e6e
61 changed files with 13693 additions and 1 deletions

149
views/AuthLogin.ejs Normal file
View File

@@ -0,0 +1,149 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
<link rel="stylesheet" href="/public/css/login.css">
<title>Connexion</title>
<link rel="icon" href="/public/assets/homelab_logo.png" />
</head>
<style>
.custom-btn {
transition: transform 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
color: #007BFF;
background-color: transparent;
padding: 10px 20px;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
border-radius: 50px;
cursor: pointer;
box-shadow: 0 2px 5px rgba(0,0,0,0.25);
border: 2px solid #007BFF;
}
.custom-btn:hover {
transform: scale(1.15);
background-color: #007BFF;
color: #fff;
}
.animate {
opacity: 0;
transform: translateY(-20px);
animation: slideIn 0.4s forwards;
animation-delay: 0.2s;
}
@keyframes slideIn {
100% {
opacity: 1;
transform: translateY(0);
}
}
</style>
<body class="light-mode animate">
<div class="container mt-4 animate">
<h1 class="title text-center animate">Connexion</h1>
<% if (currentUrl === '/auth/activedirectory' || setupData.hasOwnProperty('ldap')) { %>
<h3 class="text-center animate">Connexion avec Active Directory</h3>
<form action="/auth/activedirectory" method="post" class="mb-4 animate">
<% if (typeof errorMessage !== 'undefined' && errorMessage) { %>
<% } %>
<div class="form-group animate">
<label for="username" class="animate">Nom d'utilisateur :</label>
<input type="text" id="username" name="username" class="form-control animate" required>
</div>
<div class="form-group animate">
<label for="password" class="animate">Mot de passe :</label>
<input type="password" id="password" name="password" class="form-control animate" required>
</div>
<button type="submit" class="btn btn-primary d-flex align-items-center justify-content-center mx-auto d-block custom-btn">
<span class="ml-2 animate">Se connecter</span>
</button>
</form>
<% } %>
<% if (typeof setupData.discord !== 'undefined') { %>
<% if (typeof setupData.ldap !== 'undefined') { %>
<h3 class="text-center animate">Ou</h3>
<% } %>
<button onclick="location.href='/auth/discord'" class="btn btn-primary d-flex align-items-center justify-content-center mx-auto d-block custom-btn">
<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="#ffffff" width="24" height="24">
<title>Discord</title>
<path d="M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z"/>
</svg>
<span class="ml-2 animate">Se connecter avec Discord</span>
</button>
<% } %>
<br>
<div class="d-flex justify-content-center animate">
<button id="themeSwitcher" class="btn btn-warning mt-3 animate ">Changer de Thème</button>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script>
const body = document.body;
document.getElementById('themeSwitcher').addEventListener('click', function () {
body.classList.toggle('dark-mode');
});
document.addEventListener('DOMContentLoaded', function () {
const darkModeSwitch = document.getElementById('darkModeSwitch');
const darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
body.classList.toggle('dark-mode', darkModeMediaQuery.matches);
darkModeMediaQuery.addListener(function (e) {
body.classList.toggle('dark-mode', e.matches);
});
});
var isAuthenticated = "<%= isAuthenticated %>" === "true";
var errorMessage = '<%= errorMessage %>';
if (isAuthenticated) {
Swal.fire({
position: 'top',
icon: 'success',
title: 'Authentification réussie!',
text: 'Vous allez être redirigé vers le tableau de bord.',
showConfirmButton: false,
timer: 1800,
timerProgressBar: true,
toast: true,
willClose: () => {
window.location.replace('/dpanel/dashboard');
}
});
} else if (errorMessage) {
Swal.fire({
position: 'top',
icon: 'error',
title: 'Erreur lors de l\'authentification!',
text: 'Merci de reessayer.',
showConfirmButton: false,
timer: 2200,
timerProgressBar: true,
toast: true,
});
}
</script>
</body>
</html>

92
views/acces-denied.ejs Normal file
View File

@@ -0,0 +1,92 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="/public/assets/homelab_logo.png"/>
<title>Temporary Network Error</title>
<style>
body {
background-color: #313338;
color: #ffffff;
font-family: Arial, sans-serif;
text-align: center;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
height: 100vh;
}
.logo {
width : 150px;
height : 150px;
}
.error-message {
font-size: 24px;
margin-top: 50px;
}
.request-id {
font-size: 18px;
color: #ffffff;
margin-top: 45px;
}
.promotion {
margin-top: 30px;
font-size: 18px;
color: #ffffff;
}
.custom-btn {
transition: transform 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
color: #007BFF;
background-color: transparent;
padding: 10px 20px;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
border-radius: 50px;
cursor: pointer;
box-shadow: 0 2px 5px rgba(0,0,0,0.25);
border: 2px solid #007BFF;
}
.custom-btn:hover {
transform: scale(1.15);
background-color: #007BFF;
color: #fff;
}
</style>
</head>
<body>
<img class="logo" id="logo" src="../public/assets/homelab_logo.png">
<div class="error-message">
Temporary Network Error<br>
You do not have permission to access the requested resource, or there is an error. Please try again later.
</div>
<div class="request-id">
Request ID: <span id="request-id"></span>
</div>
<script>
document.getElementById('request-id').textContent = Math.random().toString(16).slice(2);
</script>
<br><a class="custom-btn" href="#" target="_blank">Check out the Uptime Page</a>
<div class="promotion">
<p>The modern CDN for secure file transfer</p>
<p>Power your project with our self-hosted CDN</p>
<p>Experience exceptional performance and ultra-fast content distribution.</p><br>
<a class="custom-btn" href="https://cdn-app.dinawo.fr" target="_blank">Learn more about our CDN</a><br>
<p>Created by SwiftLogic Labs.</p>
<a class="custom-btn" href="https://discord.gg/k6r96Tmtgx" target="_blank">Join our Discord Server</a>
</div>
</body>
</html>

251
views/dashboard.ejs Normal file
View File

@@ -0,0 +1,251 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css"
integrity="sha384-GLhlTQ8iRABdZLl6O5oVMWSktQOp6b7In1Zl3/JiR3eZB1+nHN/8u8UqXj2l1tji" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="https://cdn.jsdelivr.net/npm/toastify-js"></script>
<script src="/public/js/dashboard.js"></script>
<link rel="stylesheet" href="/public/css/styles.css" />
<title>Dashboard</title>
<link rel="icon" href="/public/assets/homelab_logo.png" />
<link rel="apple-touch-icon" sizes="57x57" href="/public/assets/homelab_logo@2x.png">
<link rel="apple-touch-icon" sizes="60x60" href="/public/assets/homelab_logo@3x.png">
</head>
<body class="light-mode">
<nav class="navbar navbar-expand-md navbar-light bg-light header">
<a class="navbar-brand">
Dashboard CDN
<span class="badge badge-info ml-1">Beta</span>
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<form action="/dpanel/upload" class="form-inline">
<button class="btn btn-primary btn-round mr-2">
<i class="fas fa-cloud-upload-alt"></i> Téléverser un fichier
</button>
</form>
</li>
<li class="nav-item">
<form id="newFolderModalForm" class="form-inline ml-2">
<button type="submit" class="btn btn-success btn-round ml-2" id="newFolderModalBtn" data-toggle="modal" data-target="#newFolderModal">
<i class="fas fa-folder-open"></i> Nouveau Dossier
</button>
</form>
</li>
<li class="nav-item">
<button id="styleSwitcher" class="btn btn-link btn-round">
<i id="themeIcon"></i>
</button>
</li>
<li class="nav-item dropdown">
<a class="btn dropdown-toggle" id="accountDropdownBtn" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<img src="https://api.dicebear.com/7.x/initials/svg?seed=<%= user.name %>" alt="User Icon" class="rounded-circle" style="width: 30px; height: 30px;" />
</a>
<div class="dropdown-menu dropdown-menu-right p-4 bg-dark text-white" id="accountDropdownMenu">
<div class="mb-3 text-center">
<h6 class="text-lg font-semibold"><%= user.name %></h6>
<p class="mb-0">ID: <%= user.id %></p>
<p class="mb-0">Role: <%= user.role %></p>
</div>
<div class="dropdown-divider mb-2"></div>
<% if (user.role === 'admin') { %>
<a class="dropdown-item text-center text-white no-hover custom-btn" href="/dpanel/dashboard/admin" id="adminLink">
<i class="fas fa-user-shield"></i> Administration du site
</a>
<% } %>
<a class="dropdown-item text-center text-white no-hover" href="/auth/logout" id="logoutLink">
<i class="fas fa-sign-out-alt text-white"></i> Déconnexion
</a>
</div>
</li>
</ul>
</div>
</nav>
<div class="container mt-4 table-container">
<div class="table-responsive">
<table class="table w-100 table table-hover">
<thead>
<tr>
<th>Nom du fichier</th>
<th>Taille</th>
<th class="text-right">Action</th>
</tr>
</thead>
<tbody>
<% files.forEach(file => { %>
<tr data-extension="<%= file.extension %>" data-type="<%= file.type %>">
<% if (fileInfoNames.includes(file.name)) { %>
<td><a href="#" onclick="showFileInfo('<%= file.name %>')"><%= file.name %></a></td>
<% } else { %>
<td><%= file.name %></td>
<% } %> <td>
<% if (file.type === 'folder') { %>
Dossier
<% } else { %>
<%
const fileSizeInBytes = file.size;
let fileSize;
if (fileSizeInBytes < 1024 * 1024) {
fileSize = `${(fileSizeInBytes / 1024).toFixed(2)} Ko`;
} else if (fileSizeInBytes < 1024 * 1024 * 1024) {
fileSize = `${(fileSizeInBytes / (1024 * 1024)).toFixed(2)} Mo`;
} else {
fileSize = `${(fileSizeInBytes / (1024 * 1024 * 1024)).toFixed(2)} Go`;
}
%>
<%= fileSize %>
<% } %>
</td>
<td class="d-flex justify-content-end align-items-center">
<% if (file.type === 'folder') { %>
<form class="file-actions mb-2">
<input type="hidden" name="folderName" value="<%= file.name %>">
<button class="delete-folder-button btn btn-danger btn-round" type="button">
<i class="fas fa-trash-alt"></i>
</button>
</form>
<a href="/dpanel/dashboard/folder/<%= file.name %>" class="btn btn-primary btn-round mb-2">
<i class="fas fa-folder-open"></i> Accéder
</a>
<% } else { %>
<button class="btn btn-primary btn-round" onclick="renameFile('<%= folderName %>', '<%= file.name %>')">
<i class="fas fa-edit"></i> Renommer
</button>
<form class="file-actions mb-2" id="deleteForm" action="/dpanel/dashboard/delete" method="post">
<input type="hidden" name="_method" value="DELETE">
<input type="hidden" name="filename" value="<%= file.name %>">
<button class="delete-button btn btn-danger btn-round" type="button" onclick="confirmDelete('<%= file.name %>')">
<i class="fas fa-trash-alt"></i>
</button>
</form>
<form class="file-actions mb-2">
<div class="copy-link-container d-flex align-items-center">
<input type="text" class="file-link form-control rounded mr-2" value="<%= file.url %>" readonly style="display: none;">
<button class="button copy-button btn btn-success btn-round" data-file="<%= file.name %>">
<i class="fas fa-copy"></i>
</button>
</div>
</form>
<form class="file-actions d-flex align-items-center mb-2" action="/dpanel/dashboard/movefile" method="post">
<input type="hidden" name="fileName" value="<%= file.name %>">
<select class="form-control rounded mr-2" name="folderName">
<option value="" disabled selected>Déplacer vers...</option>
<% allFolders.forEach(folder => { %>
<option value="<%= folder %>"><%= folder %></option>
<% }); %>
</select>
<button type="submit" class="btn btn-success btn-round">Déplacer</button>
</form>
<% } %>
</td>
</tr>
<% }); %>
</tbody>
</table>
</div>
</div>
<div class="modal fade" id="patchNoteModal" tabindex="-1" role="dialog" aria-labelledby="patchNoteModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg rounded-lg" role="document">
<div class="modal-content dark-mode">
<div class="modal-header">
<h5 class="modal-title" id="patchNoteModalLabel">Patch Note<span class="badge badge-info ml-1">v1.0.9-beta</span></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="patch-note-item">
<p><i class="fas fa-wrench"></i> Problèmes Résolus :</p>
<ul>
<li>Correction d'un Problème d'Authentification :</li>
<ul>
<li>Résolution d'un problème où l'authentification échouait pour les utilisateurs se connectant pour la première fois et n'étant pas présents dans user.json.<span class="badge badge-warning ml-1">PATCH</span></li>
<li>Correction du problème d'authentification avec Active Directory (AD) entraînant des échecs d'authentification.<span class="badge badge-warning ml-1">PATCH</span></li>
</ul>
<li>Correction du Problème de Compression des Journaux :</li>
<ul>
<li>Correction du problème des journaux compressés, assurant ainsi que les rapports et les affichages dans le panneau d'administration fonctionnent désormais comme prévu.<span class="badge badge-warning ml-1">PATCH</span></li>
</ul>
</ul>
</div>
<div class="patch-note-item">
<p><i class="fas fa-wrench"></i> Améliorations Générales :</p>
<ul>
<li>Corrections Mineures :</li>
<ul>
<li>Mise en place de diverses corrections mineures pour améliorer la stabilité générale et la fonctionnalité du système.<span class="badge badge-warning ml-1">PATCH</span></li>
<li>Résolution de petits problèmes signalés par la communauté des utilisateurs pour offrir une expérience plus fluide.<span class="badge badge-warning ml-1">PATCH</span></li>
</ul>
<li>Optimisation des Performances :</li>
<ul>
<li>Amélioration des performances du système, résultant en des temps de réponse plus rapides et une efficacité accrue à tous les niveaux.<span class="badge badge-success ml-1">AJOUT</span></li>
</ul>
</ul>
</div>
<div class="patch-note-item">
<p><i class="fas fa-shield-alt"></i> Sécurité :</p>
<ul>
<li>Correction Critique de Sécurité - Gérée par SwiftLogic CyberShield :</li>
<ul>
<li>Mise en place d'une correction critique de sécurité pour remédier aux vulnérabilités potentielles et assurer un environnement plus sûr pour les utilisateurs.<span class="badge badge-warning ml-1">PATCH</span></li>
</ul>
</ul>
</div>
<div class="patch-note-item">
<p>Remarque : Merci de continuer à fournir vos retours d'expérience et rapports de bugs pour nous aider à améliorer constamment notre plateforme. Nous sommes reconnaissants de votre engagement et de votre contribution.</p>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<footer class="py-3 my-4">
<ul class="nav justify-content-center border-bottom pb-3 mb-3">
<li class="nav-item">
<a class="nav-link px-2 text-muted" href="#" data-toggle="modal" data-target="#patchNoteModal">
Version: 1.0.9-beta
</a>
</li>
</ul>
<div class="d-flex justify-content-center align-items-center">
<p class="text-center text-muted mb-0">&copy; 2024 SwiftLogic Labs</p>
<div class="ml-3">
<% if (user.role === 'admin') { %>
<button id="checkUpdateButton" class="btn btn-icon btn-info btn-round" title="Vérifier les mises à jour" onclick="checkUpdates()">
<div class="d-flex align-items-center">
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" viewBox="0 0 512 512">
<path d="M370.7 133.3C339.5 104 298.9 88 255.8 88c-77.5 .1-144.3 53.2-162.8 126.9-1.3 5.4-6.1 9.2-11.7 9.2H24.1c-7.5 0-13.2-6.8-11.8-14.2C33.9 94.9 134.8 8 256 8c66.4 0 126.8 26.1 171.3 68.7L463 41C478.1 25.9 504 36.6 504 57.9V192c0 13.3-10.7 24-24 24H345.9c-21.4 0-32.1-25.9-17-41l41.8-41.7zM32 296h134.1c21.4 0 32.1 25.9 17 41l-41.8 41.8c31.3 29.3 71.8 45.3 114.9 45.3 77.4-.1 144.3-53.1 162.8-126.8 1.3-5.4 6.1-9.2 11.7-9.2h57.3c7.5 0 13.2 6.8 11.8 14.2C478.1 417.1 377.2 504 256 504c-66.4 0-126.8-26.1-171.3-68.7L49 471C33.9 486.1 8 475.4 8 454.1V320c0-13.3 10.7-24 24-24z"/>
</svg>
<span class="ml-2 d-none">Vérifier les mises à jours</span>
</div>
</button>
<% } %>
</div>
</div>
</footer>
</div>
</body>
</html>

View File

@@ -0,0 +1,47 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fichier non trouvé</title>
<style>
body {
font-family: Arial, sans-serif;
background-image: linear-gradient(to right, #ff5a5e, #f93838);
color: #fff;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.container {
text-align: center;
}
h1 {
font-size: 2rem;
margin-bottom: 1rem;
}
p {
font-size: 1.2rem;
}
.error {
font-size: 1.5rem;
color: darkred;
margin-top: 2rem;
}
</style>
</head>
<body>
<div class="container">
<h1>Erreur lors de la récupération des fichiers</h1>
<p class="error">Code d'erreur: U5nV4l1dUs3r_FileRetrievalError</p>
</div>
</body>
</html>
</body>
</html>

49
views/file-expired.ejs Normal file
View File

@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fichier non trouvé</title>
<link rel="icon" href="/public/assets/homelab_logo.png" />
<style>
body {
font-family: Arial, sans-serif;
background-image: linear-gradient(to right, #66eaa8, #a2674b);
color: #fff;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.container {
text-align: center;
}
h1 {
font-size: 2rem;
margin-bottom: 1rem;
}
p {
font-size: 1.2rem;
}
.error {
font-size: 1.5rem;
color: darkred;
margin-top: 2rem;
}
</style>
</head>
<body>
<div class="container">
<h1>Désolé, ce fichier a expiré 😔</h1>
<p>Le fichier que vous essayez d'accéder a expiré et n'est plus disponible.</p>
<p class="error">Code d'erreur: Ysx457S_FileExpired</p>
</div>
</body>
</html>
</body>
</html>

48
views/file-not-found.ejs Normal file
View File

@@ -0,0 +1,48 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fichier non trouvé</title>
<style>
body {
font-family: Arial, sans-serif;
background-image: linear-gradient(to right, #667eea, #764ba2);
color: #fff;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.container {
text-align: center;
}
h1 {
font-size: 2rem;
margin-bottom: 1rem;
}
p {
font-size: 1.2rem;
}
.error {
font-size: 1.5rem;
color: darkred;
margin-top: 2rem;
}
</style>
</head>
<body>
<div class="container">
<h1>Fichier non trouvé</h1>
<p>Désolé, le fichier que vous recherchez est introuvable.</p>
<p class="error">Code d'erreur: XyZ789_FileNotFound</p>
</div>
</body>
</html>
</body>
</html>

181
views/folder.ejs Normal file
View File

@@ -0,0 +1,181 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css"
integrity="sha384-GLhlTQ8iRABdZLl6O5oVMWSktQOp6b7In1Zl3/JiR3eZB1+nHN/8u8UqXj2l1tji" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="https://cdn.jsdelivr.net/npm/toastify-js"></script>
<link rel="stylesheet" href="/public/css/styles.css" />
<script src="/public/js/folder.js"></script>
<title>Dashboard</title>
<link rel="icon" href="/public/assets/homelab_logo.png" />
</head>
<body class="light-mode">
<nav class="navbar navbar-expand-lg navbar-light bg-light header">
<a class="navbar-brand">
Dashboard CDN
<span class="badge badge-info ml-1">Beta</span>
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse ml-auto" id="navbarNav">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<button class="btn btn-warning btn-round mr-2" onclick="window.location.href='/dpanel/dashboard';">
<i class="fas fa-home"></i>Page principal</button>
</li>
<li class="nav-item">
<form action="/dpanel/upload" class="form-inline">
<button class="btn btn-primary btn-round mr-2">
<i class="fas fa-cloud-upload-alt"></i> Téléverser un fichier
</button>
</form>
</li>
<li class="nav-item">
<button id="styleSwitcher" class="btn btn-link btn-round">
<span id="themeIcon" class="fas theme-icon"></span>
</button>
</li>
</ul>
</div>
</nav>
<nav aria-label="breadcrumb">
<ol class="breadcrumb custom-breadcrumb">
<li class="breadcrumb-item"><a href="/dpanel/dashboard">Accueil</a></li>
<% let pathSegments = currentFolder.split('/'); %>
<% pathSegments.forEach((segment, index) => { %>
<% let pathSoFar = pathSegments.slice(0, index + 1).join('/'); %>
<li class="breadcrumb-item <%= (index === pathSegments.length - 1) ? 'active' : '' %>">
<% if (index === pathSegments.length - 1) { %>
<%= segment %>
<% } else { %>
<a href="/dpanel/dashboard/folder/<%= pathSoFar %>"><%= segment %></a>
<% } %>
</li>
<% }); %>
</ol>
</nav>
</body>
<% function formatSize(sizeInBytes) {
if (sizeInBytes < 1024) {
return `${sizeInBytes} octets`;
} else if (sizeInBytes < 1024 * 1024) {
return `${(sizeInBytes / 1024).toFixed(2)} Ko`;
} else if (sizeInBytes < 1024 * 1024 * 1024) {
return `${(sizeInBytes / (1024 * 1024)).toFixed(2)} Mo`;
} else {
return `${(sizeInBytes / (1024 * 1024 * 1024)).toFixed(2)} Go`;
}
}
%>
<div class="container mt-4 table-container">
<div class="table-responsive">
<table class="table w-100">
<thead>
<tr>
<th>Nom du fichier</th>
<th>Taille</th>
<th class="text-right">Action</th>
</tr>
</thead>
<tbody>
<% files.forEach(file => { %>
<tr data-extension="<%= file.extension %>" data-type="<%= file.type %>">
<% if (fileInfoNames.includes(file.name)) { %>
<td><a href="#" onclick="showFileInfo('<%= file.name %>')"><%= file.name %></a></td>
<% } else { %>
<td><%= file.name %></td>
<% } %>
<td>
<% if (file.type === 'folder') { %>
<% const folderSize = calculateFolderSize(file.contents); %>
<%= (folderSize !== undefined && !isNaN(folderSize)) ? formatSize(folderSize) : 'Taille inconnue' %>
<% } else { %>
<%
const fileSizeInBytes = file.size;
let fileSize;
if (fileSizeInBytes !== undefined && !isNaN(fileSizeInBytes) && fileSizeInBytes >= 0) {
fileSize = formatSize(fileSizeInBytes);
} else {
console.error('Invalid file size:', fileSizeInBytes);
fileSize = 'Taille inconnue';
}
%>
<%= fileSize %>
<% } %>
</td>
<td class="d-flex justify-content-end align-items-center">
<% if (file.type === 'folder') { %>
<a href="/dpanel/dashboard/folder/<%= file.name %>" class="btn btn-primary btn-round mb-2">
<i class="fas fa-folder-open fa-xs btn-icon"></i> Accéder
</a>
<% } else { %>
<button class="btn btn-primary btn-round" onclick="renameFile('<%= folderName %>', '<%= file.name %>')">
<i class="fas fa-edit fa-xs btn-icon"></i> Renommer
</button>
<form class="file-actions mb-2" id="deleteForm" action="/dpanel/dashboard/delete" method="post">
<input type="hidden" name="_method" value="DELETE">
<input type="hidden" name="filename" value="<%= file.name %>">
<button class="delete-button btn btn-danger btn-round" type="button" onclick="confirmDeleteFile('<%= currentFolder %>', '<%= file.name %>')">
<i class="fas fa-trash-alt fa-xs btn-icon"></i>
</button>
</form>
<form class="file-actions mb-2">
<div class="copy-link-container d-flex align-items-center">
<input type="text" class="file-link form-control rounded mr-2" value="<%= file.url %>" readonly style="display: none;">
<button class="button copy-button btn btn-success btn-round" data-file="<%= file.name %>">
<i class="fas fa-copy fa-xs btn-icon"></i>
</button>
</div>
</form>
<form class="file-actions d-flex align-items-center mb-2" action="/dpanel/dashboard/movefile/<%= folderName %>" method="post">
<input type="hidden" name="fileName" value="<%= file.name %>">
<select class="form-control rounded mr-2" name="folderName">
<option value="" disabled selected>Déplacer vers...</option>
<% allFolders.forEach(folder => { %>
<option value="<%= folder %>"><%= folder %></option>
<% }); %>
</select>
<button type="submit" class="btn btn-success btn-round">Déplacer</button>
</form>
<% } %>
</td>
</tr>
<% }); %>
</tbody>
</table>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script>
</script>
<div class="container">
<footer class="py-3 my-4">
<ul class="nav justify-content-center border-bottom pb-3 mb-3">
<li class="nav-item"><a class="nav-link px-2 text-muted">Version: 1.0.9-beta</a></li>
</ul>
<p class="text-center text-muted">&copy; 2024 SwiftLogic Labs</p>
</footer>
</div>
</body>
</html>

107
views/paramAdmin.ejs Normal file
View File

@@ -0,0 +1,107 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
<link rel="stylesheet" href="/public/css/login.css">
<title>Parameter Admin</title>
<link rel="icon" href="/public/assets/homelab_logo.png" />
</head>
<style>
.custom-btn {
transition: transform 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
color: #007BFF;
background-color: transparent;
padding: 10px 20px;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
border-radius: 50px;
cursor: pointer;
box-shadow: 0 2px 5px rgba(0,0,0,0.25);
border: 2px solid #007BFF;
width: 50%;
margin: 0 auto;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.custom-btn:hover {
transform: scale(1.15);
background-color: #007BFF;
color: #fff;
}
.animate {
opacity: 0;
transform: translateY(-20px);
animation: slideIn 0.4s forwards;
animation-delay: 0.2s;
}
@keyframes slideIn {
100% {
opacity: 1;
transform: translateY(0);
}
}</style>
<body class="light-mode animate">
<div class="container mt-4 animate">
<h1 class="title text-center animate">Bienvenue dans les parametres admin</h1>
<h4 class="title text-center animate">Que souhaitez vous faire ?</h4><br>
<a class="dropdown-item text-center text-white no-hover custom-btn" href="/dpanel/dashboard/admin/users?page=1&limit=10" id="adminLink1">
<i class="fas fa-users"></i> Gérer les utilisateurs
</a><br>
<a class="dropdown-item text-center text-white no-hover custom-btn" href="/dpanel/dashboard/admin/settingsetup" id="adminLink2">
<i class="fas fa-cogs"></i> Modifier les parametres de configuration
</a><br>
<a class="dropdown-item text-center text-white no-hover custom-btn" href="/dpanel/dashboard/admin/stats&logs" id="adminLink3">
<i class="fas fa-chart-bar"></i> Afficher les statistiques & les logs
</a><br>
<a class="dropdown-item text-center text-white no-hover custom-btn" href="/dpanel/dashboard/admin/Privacy&Security" id="adminLink4">
<i class="fas fa-shield-alt"></i> Confidentialité & Sécurité
</a><br><br>
<a class="dropdown-item text-center text-white no-hover custom-btn" href="/dpanel/dashboard/" id="adminLink5">
<i class="fas fa-home"></i> Retourner au dashboard
</a>
<div class="d-flex justify-content-center animate">
<button id="themeSwitcher" class="btn btn-warning mt-3 animate ">Changer de Thème</button>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script>
const body = document.body;
document.getElementById('themeSwitcher').addEventListener('click', function () {
body.classList.toggle('dark-mode');
});
document.addEventListener('DOMContentLoaded', function () {
const darkModeSwitch = document.getElementById('darkModeSwitch');
const darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
body.classList.toggle('dark-mode', darkModeMediaQuery.matches);
darkModeMediaQuery.addListener(function (e) {
body.classList.toggle('dark-mode', e.matches);
});
});
</script>
</body>
</html>

View File

@@ -0,0 +1,200 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<link rel="stylesheet" href="/public/css/login.css">
<title>Confidentialité et Sécurité</title>
<link rel="icon" href="/public/assets/homelab_logo.png" />
<style>
.modal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
padding-top: 100px; /* Location of the box */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}
/* Modal Content */
.modal-content {
background-color: #fefefe;
margin: auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
}
/* The Close Button */
.close {
color: #aaaaaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
}
.custom-btn {
transition: transform 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
color: #007BFF;
background-color: transparent;
padding: 5px 10px;
text-decoration: none;
display: inline-block;
font-size: 14px;
margin: 4px 2px;
border-radius: 50px;
cursor: pointer;
box-shadow: 0 2px 5px rgba(0,0,0,0.25);
border: 2px solid #007BFF;
}
.custom-btn:hover {
transform: scale(1.15);
background-color: #007BFF;
color: #fff;
}
</style>
</head>
<body class="light-mode animate">
<div class="container mt-4 table-container animate">
<h2 class="text-center">Confidentialité et Sécurité</h2><br>
<h2>Données d'analyse</h2>
<div class="row">
<% reports && reports.forEach((report, index) => { %>
<% if (report) { %>
<div class="col-md-4 text-center">
<button class="btn btn-primary custom-btn reportName" data-index="<%= index %>"><%= report.name %></button>
</div>
<% if ((index + 1) % 3 === 0) { %>
</div><div class="row">
<% } %>
<div id="myReportModal<%= index %>" class="modal">
<div class="modal-content">
<span class="close" data-index="<%= index %>">&times;</span>
<pre><%= report.content %></pre>
</div>
</div>
<% } %>
<% }); %>
</div>
<br><div class="d-flex justify-content-center align-items-center">
<a class="dropdown-item text-center text-white no-hover custom-btn" href="/dpanel/dashboard/admin/" style="max-width: 250px; padding: 10px;">
<i class="fas fa-sign-out-alt text-white "></i> Retourner au dashboard admin
</a>
</div>
<div class="d-flex justify-content-center animate">
<button id="themeSwitcher" class="btn btn-warning mt-3 animate ">Changer de Thème</button>
</div>
<script>
var logNames = document.getElementsByClassName("logName");
var closeButtons = document.getElementsByClassName("close");
// Add event listeners to all log names
for (var i = 0; i < logNames.length; i++) {
logNames[i].addEventListener("click", function(event) {
var index = event.target.getAttribute("data-index");
var modal = document.getElementById("myModal" + index);
modal.style.display = "block";
});
}
// Add event listeners to all close buttons
for (var i = 0; i < closeButtons.length; i++) {
closeButtons[i].addEventListener("click", function(event) {
var index = event.target.getAttribute("data-index");
var modal = document.getElementById("myModal" + index);
modal.style.display = "none";
});
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target.className === "modal") {
event.target.style.display = "none";
}
}
var reportNames = document.getElementsByClassName("reportName");
var reportCloseButtons = document.getElementsByClassName("close");
// Add event listeners to all report names
for (var i = 0; i < reportNames.length; i++) {
reportNames[i].addEventListener("click", function(event) {
var index = event.target.getAttribute("data-index");
var modal = document.getElementById("myReportModal" + index);
modal.style.display = "block";
});
}
// Add event listeners to all close buttons
for (var i = 0; i < reportCloseButtons.length; i++) {
reportCloseButtons[i].addEventListener("click", function(event) {
var index = event.target.getAttribute("data-index");
var modal = document.getElementById("myReportModal" + index);
modal.style.display = "none";
});
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target.className === "modal") {
event.target.style.display = "none";
}
}
const body = document.body;
document.getElementById('themeSwitcher').addEventListener('click', function () {
if (body.classList.contains('dark-mode')) {
body.classList.remove('dark-mode');
body.classList.add('light-mode');
} else {
body.classList.remove('light-mode');
body.classList.add('dark-mode');
}
});
document.addEventListener('DOMContentLoaded', function () {
const darkModeSwitch = document.getElementById('darkModeSwitch');
const darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
body.classList.toggle('dark-mode', darkModeMediaQuery.matches);
darkModeMediaQuery.addListener(function (e) {
body.classList.toggle('dark-mode', e.matches);
});
});
</script>
</body>
</script>
</div>
</body>
</html>

View File

@@ -0,0 +1,254 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
<link rel="stylesheet" href="/public/css/login.css">
<title>Parameter Admin</title>
<link rel="icon" href="/public/assets/homelab_logo.png" />
<style>
.custom-btn {
transition: transform 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
color: #007BFF;
background-color: transparent;
padding: 5px 10px;
text-decoration: none;
display: inline-block;
font-size: 14px;
margin: 4px 2px;
border-radius: 50px;
cursor: pointer;
box-shadow: 0 2px 5px rgba(0,0,0,0.25);
border: 2px solid #007BFF;
}
.custom-btn:hover {
transform: scale(1.15);
background-color: #007BFF;
color: #fff;
}
input[type="text"] {
width: 100%;
padding: 5px 15px;
margin: 8px 0;
box-sizing: border-box;
border: none;
border-bottom: 2px solid #007BFF;
border-radius: 4px;
}
input[type="text"]:focus {
border-bottom: 2px solid #555;
}
.switch {
position: relative;
display: inline-block;
width: 60px;
height: 34px;
}
.switch input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color: #2196F3;
}
input:focus + .slider {
box-shadow: 0 0 1px #2196F3;
}
input:checked + .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}
/* Rounded sliders */
.slider.round {
border-radius: 34px;
}
.slider.round:before {
border-radius: 50%;
}
</style>
</head>
<body class="light-mode animate">
<div class="container mt-4 table-container animate">
<h2 class="text-center">Gestion de la configuration</h2><br>
<div class="table-responsive">
<form action="/dpanel/dashboard/update-setup" method="POST">
<table class="table w-100">
<thead>
<tr>
<th>Paramètre</th>
<th>Valeur</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="2"><h2>LDAP Settings</h2></td>
</tr>
<tr>
<td>Activer LDAP:</td>
<td>
<label class="switch">
<input type="checkbox" name="ldap[enabled]" <%= setup.ldap ? 'checked' : '' %>
onchange="toggleForm('ldapForm', this)">
<span class="slider round"></span>
</label>
</td>
</tr>
<tbody id="ldapForm" style="display: block">
<tr>
<td>URL:</td>
<td><input type="text" name="ldap[url]" value="<%= setup.ldap ? setup.ldap.url : '' %>"></td>
</tr>
<tr>
<td>Base DN:</td>
<td><input type="text" name="ldap[baseDN]" value="<%= setup.ldap ? setup.ldap.baseDN : '' %>"></td>
</tr>
<tr>
<td>Username:</td>
<td><input type="text" name="ldap[username]" value="<%= setup.ldap ? setup.ldap.username : '' %>"></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="text" name="ldap[password]" value="<%= setup.ldap ? setup.ldap.password : '' %>"></td>
</tr>
</tbody>
<tr>
<td colspan="2"><h2>Discord Settings</h2></td>
</tr>
<tr>
<td>Activer Discord:</td>
<td>
<label class="switch">
<input type="checkbox" name="discord[enabled]" <%= setup.discord ? 'checked' : '' %>
onchange="toggleForm('discordForm', this)">
<span class="slider round"></span>
</label>
</td>
</tr>
<tbody id="discordForm" style="display: block">
<tr>
<td>Client ID:</td>
<td><input type="text" name="discord[clientID]" value="<%= setup.discord ? setup.discord.clientID : '' %>"></td>
</tr>
<tr>
<td>Client Secret:</td>
<td><input type="text" name="discord[clientSecret]" value="<%= setup.discord ? setup.discord.clientSecret : '' %>"></td>
</tr>
<tr>
<td>Identify URL:</td>
<td><input type="text" name="discord[identifyURL]" value="<%= setup.discord ? setup.discord.identifyURL : '' %>"></td>
</tr>
<tr>
<td>Authorized IDs:</td>
<td><input type="text" name="discord[authorizedIDs]" value="<%= setup.discord ? setup.discord.authorizedIDs : '' %>">
</td>
</tr>
</tbody>
<tr>
<td colspan="2"><h2>Other Settings</h2></td>
</tr>
<tr>
<td>Domain:</td>
<td><input type="text" name="domain" value="<%= setup.domain %>"></td>
</tr>
<tr>
<td>Uptime:</td>
<td><input type="text" name="uptime" value="<%= setup.uptime %>"></td>
</tr>
</tbody>
</table>
<div class="text-center">
<button type="submit" class="btn btn-primary custom-btn">Mettre à jour</button>
</div>
</form>
</div>
<div class="d-flex justify-content-center align-items-center">
<a class="dropdown-item text-center text-white no-hover custom-btn" href="/dpanel/dashboard/admin/" style="max-width: 250px; padding: 10px;">
<i class="fas fa-sign-out-alt text-white "></i> Retourner au dashboard admin
</a>
</div>
<div class="d-flex justify-content-center animate">
<button id="themeSwitcher" class="btn btn-warning mt-3 animate ">Changer de Thème</button>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script>
const body = document.body;
document.getElementById('themeSwitcher').addEventListener('click', function () {
if (body.classList.contains('dark-mode')) {
body.classList.remove('dark-mode');
body.classList.add('light-mode');
} else {
body.classList.remove('light-mode');
body.classList.add('dark-mode');
}
});
document.addEventListener('DOMContentLoaded', function () {
const darkModeSwitch = document.getElementById('darkModeSwitch');
const darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
body.classList.toggle('dark-mode', darkModeMediaQuery.matches);
darkModeMediaQuery.addListener(function (e) {
body.classList.toggle('dark-mode', e.matches);
});
});
function toggleForm(formId, checkbox) {
const form = document.getElementById(formId);
form.style.display = checkbox.checked ? 'block' : 'none';
}
</script>
</body>
</html>

View File

@@ -0,0 +1,192 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<link rel="stylesheet" href="/public/css/login.css">
<title>Statistiques du serveur</title>
<link rel="icon" href="/public/assets/homelab_logo.png" />
<style>
.modal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
padding-top: 100px; /* Location of the box */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}
/* Modal Content */
.modal-content {
background-color: #fefefe;
margin: auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
}
/* The Close Button */
.close {
color: #aaaaaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
}
.custom-btn {
transition: transform 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
color: #007BFF;
background-color: transparent;
padding: 5px 10px;
text-decoration: none;
display: inline-block;
font-size: 14px;
margin: 4px 2px;
border-radius: 50px;
cursor: pointer;
box-shadow: 0 2px 5px rgba(0,0,0,0.25);
border: 2px solid #007BFF;
}
.custom-btn:hover {
transform: scale(1.15);
background-color: #007BFF;
color: #fff;
}
</style>
</head>
<body class="light-mode animate">
<div class="container mt-4 table-container animate">
<h2 class="text-center">Statistiques du serveur</h2><br>
<div class="table-responsive">
<table class="table w-100">
<thead>
<tr>
<th>Paramètre</th>
<th>Valeur</th>
</tr>
</thead>
<tbody>
<tr>
<td>Temps de fonctionnement</td>
<td><%= Math.floor(uptime / 86400) %> jours, <%= Math.floor(uptime % 86400 / 3600) %> heures, <%= Math.floor(uptime % 3600 / 60) %> minutes, <%= uptime % 60 %> secondes</td>
</tr>
<tr>
<td>Utilisation de la mémoire</td>
<td><%= memoryUsage.toFixed(2) %> Mo</td>
</tr>
<tr>
<td>Utilisation du processeur</td>
<td><%= (cpuUsage * 100).toFixed(2) %> %</td>
</tr>
</tbody>
</table>
</div>
<h2>Journaux</h2>
<div class="row">
<% logs && logs.forEach((log, index) => { %>
<% if (log) { %>
<div class="col-md-4 text-center">
<button class="btn btn-primary custom-btn logName" data-index="<%= index %>"><%= log.name %></button>
</div>
<% if ((index + 1) % 3 === 0) { %>
</div><div class="row">
<% } %>
<div id="myModal<%= index %>" class="modal">
<div class="modal-content">
<span class="close" data-index="<%= index %>">&times;</span>
<pre><%= log.content %></pre>
</div>
</div>
<% } %>
<% }); %>
</div>
<div class="d-flex justify-content-center animate">
<button id="themeSwitcher" class="btn btn-warning mt-3 animate ">Changer de Thème</button>
</div>
<br><div class="d-flex justify-content-center align-items-center">
<a class="dropdown-item text-center text-white no-hover custom-btn" href="/dpanel/dashboard/admin/" style="max-width: 250px; padding: 10px;">
<i class="fas fa-sign-out-alt text-white "></i> Retourner au dashboard admin
</a>
</div>
<script>
var logNames = document.getElementsByClassName("logName");
var closeButtons = document.getElementsByClassName("close");
// Add event listeners to all log names
for (var i = 0; i < logNames.length; i++) {
logNames[i].addEventListener("click", function(event) {
var index = event.target.getAttribute("data-index");
var modal = document.getElementById("myModal" + index);
modal.style.display = "block";
});
}
// Add event listeners to all close buttons
for (var i = 0; i < closeButtons.length; i++) {
closeButtons[i].addEventListener("click", function(event) {
var index = event.target.getAttribute("data-index");
var modal = document.getElementById("myModal" + index);
modal.style.display = "none";
});
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target.className === "modal") {
event.target.style.display = "none";
}
}
const body = document.body;
document.getElementById('themeSwitcher').addEventListener('click', function () {
if (body.classList.contains('dark-mode')) {
body.classList.remove('dark-mode');
body.classList.add('light-mode');
} else {
body.classList.remove('light-mode');
body.classList.add('dark-mode');
}
});
document.addEventListener('DOMContentLoaded', function () {
const darkModeSwitch = document.getElementById('darkModeSwitch');
const darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
body.classList.toggle('dark-mode', darkModeMediaQuery.matches);
darkModeMediaQuery.addListener(function (e) {
body.classList.toggle('dark-mode', e.matches);
});
});
</script>
</body>
</script>
</div>
</body>
</html>

193
views/paramAdminUser.ejs Normal file
View File

@@ -0,0 +1,193 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
<link rel="stylesheet" href="/public/css/login.css">
<title>Parameter Admin</title>
<link rel="icon" href="/public/assets/homelab_logo.png" />
</head>
<style>
.pagination .active .page-link {
background-color: #007bff !important;
color: white !important;
}
.table-container {
max-width: 90%;
}
#searchInput {
flex-grow: 1;
}
#searchButton {
margin-left: 10px;
}
.custom-btn {
transition: transform 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
color: #007BFF;
background-color: transparent;
padding: 5px 10px;
text-decoration: none;
display: inline-block;
font-size: 14px;
margin: 4px 2px;
border-radius: 50px;
cursor: pointer;
box-shadow: 0 2px 5px rgba(0,0,0,0.25);
border: 2px solid #007BFF;
}
.custom-btn:hover {
transform: scale(1.15);
background-color: #007BFF;
color: #fff;
}
</style>
<body class="light-mode animate">
<div class="container mt-4 table-container animate">
<h2 class="text-center">Gestion des utilisateurs</h2><br>
<div class="d-flex justify-content-between align-items-center">
<input type="text" id="searchInput" class="form-control rounded mr-2" placeholder="Rechercher par nom ou ID">
<span id="shortcutHint" class="mr-2 align-self-center"></span>
<button id="searchButton" class="btn btn-primary custom-btn">Rechercher</button>
<select id="usersPerPage" class="form-control rounded ml-2" style="width: auto;">
<option value="10">10</option>
<option value="50">50</option>
<option value="100">100</option>
<option value="500">500</option>
</select>
</div>
<div class="table-responsive mt-2">
<table class="table w-100 table table-hover">
<thead>
<tr>
<th>ID</th>
<th>Nom</th>
<th>Rôle</th>
<th class="text-right">Action</th>
</tr>
</thead>
<tbody>
<% users.forEach(user => { %>
<tr>
<td><%= user.id %></td>
<td><%= user.name %></td>
<td><%= user.role %></td>
<td>
<form action="/dpanel/dashboard/update-role" method="POST" class="d-flex align-items-center">
<input type="hidden" name="id" value="<%= user.id %>">
<input type="hidden" name="name" value="<%= user.name %>">
<select class="form-control rounded mr-2" name="role">
<option value="user" <%= user.role === 'user' ? 'selected' : '' %>>User</option>
<option value="admin" <%= user.role === 'admin' ? 'selected' : '' %>>Admin</option>
</select>
<button type="submit" class="btn btn-primary btn-round custom-btn">Mettre à jour</button>
</form>
</td>
</tr>
<% }) %>
</tbody>
</table>
</div>
<nav aria-label="Page navigation example">
<ul class="pagination justify-content-center">
<% for(let i = 1; i <= pages; i++) { %>
<li class="page-item <%= i === currentPage ? 'active' : '' %>">
<a class="page-link" href="/dpanel/dashboard/admin/users?page=<%= i %>&limit=<%= limit %>"><%= i %></a>
</li>
<% } %>
</ul>
</nav>
<div class="d-flex justify-content-center align-items-center">
<a class="dropdown-item text-center text-white no-hover custom-btn" href="/dpanel/dashboard/admin/" style="max-width: 250px; padding: 10px;">
<i class="fas fa-sign-out-alt text-white "></i> Retourner au dashboard admin
</a>
</div>
</div>
<div class="d-flex justify-content-center animate">
<button id="themeSwitcher" class="btn btn-warning mt-3 animate ">Changer de Thème</button>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script>
const body = document.body;
document.getElementById('themeSwitcher').addEventListener('click', function () {
body.classList.toggle('dark-mode');
});
document.getElementById('usersPerPage').addEventListener('change', function () {
window.location.href = "/dpanel/dashboard/admin/users?page=1&limit=" + this.value;
});
window.onload = function() {
var urlParams = new URLSearchParams(window.location.search);
var limit = urlParams.get('limit');
document.getElementById('usersPerPage').value = limit;
}
document.addEventListener('DOMContentLoaded', function () {
const darkModeSwitch = document.getElementById('darkModeSwitch');
const darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
body.classList.toggle('dark-mode', darkModeMediaQuery.matches);
darkModeMediaQuery.addListener(function (e) {
body.classList.toggle('dark-mode', e.matches);
});
});
function searchUsers() {
var input = document.getElementById('searchInput');
var filter = input.value.toUpperCase();
var table = document.querySelector('.table');
var tr = table.getElementsByTagName('tr');
for (var i = 0; i < tr.length; i++) {
var tdName = tr[i].getElementsByTagName('td')[1];
var tdId = tr[i].getElementsByTagName('td')[0];
if (tdName || tdId) {
var txtValueName = tdName.textContent || tdName.innerText;
var txtValueId = tdId.textContent || tdId.innerText;
if (txtValueName.toUpperCase().indexOf(filter) > -1 || txtValueId.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
document.getElementById('searchButton').addEventListener('click', function (e) {
e.preventDefault();
searchUsers();
});
document.addEventListener('keydown', function (e) {
if (e.ctrlKey && e.key === 'k') {
e.preventDefault();
document.getElementById('searchInput').focus();
}
});
var isMac = navigator.platform.toUpperCase().indexOf('MAC') >= 0;
var searchInput = document.getElementById('searchInput');
searchInput.placeholder = isMac ? 'Rechercher par nom ou ID (Cmd + K)' : 'Rechercher par nom ou ID (Ctrl + K)';
</script>
</body>
</html>

31
views/parametres.ejs Normal file
View File

@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<title>En maintenance...</title>
<link rel="icon" href="/public/assets/homelab_logo.png"/>
<style>
body {
background-color: #000;
text-align: center;
padding: 150px; }
h1 {
font-size: 50px; }
body {
font: 20px Helvetica, sans-serif; color: #fff;
}
img{
width : 300px;
height : 300px;
}
a{
color: #FFF
}
</style>
</head>
<body>
<img id="img" src="/client/assets/img/homelab_logo.png">
<h1>Désolé, nous sommes en maintenance.</h1>
<h2>Nous serons bientôt de retour..</h2>
</body>
</html>

123
views/password-check.ejs Normal file
View File

@@ -0,0 +1,123 @@
<!DOCTYPE html>
<html>
<head>
<title>Fichier sécurisé</title>
<link rel="icon" href="/public/assets/homelab_logo.png" />
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
</head>
<style>
.custom-btn {
transition: transform 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
color: #007BFF;
background-color: transparent;
padding: 10px 20px;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
border-radius: 50px;
cursor: pointer;
box-shadow: 0 2px 5px rgba(0,0,0,0.25);
border: 2px solid #007BFF;
}
.custom-btn:hover {
transform: scale(1.15);
background-color: #007BFF;
color: #fff;
}
.animate {
opacity: 0;
transform: translateY(-20px);
animation: slideIn 0.4s forwards;
animation-delay: 0.2s;
}
@keyframes slideIn {
100% {
opacity: 1;
transform: translateY(0);
}
}
</style>
<body class="bg-gray-900 text-white">
<div class="flex justify-center items-center h-screen animate">
<div class="max-w-md mx-auto bg-gray-800 p-8 rounded shadow-md">
<h1 class="text-3xl font-bold text-center mb-8">Entrer le mot de passe pour <%= filename %></h1>
<p class="text-center text-red-500 mb-4">Le fichier <span class="text-blue-500"><%= filename %></span> est protégé. Veuillez entrer le mot de passe pour y accéder.</p>
<form id="password-form" action="/attachments/<%= userId %>/<%= filename %>" method="post">
<div class="mb-4">
<label for="password" class="block text-gray-200 font-bold mb-2">Mot de passe :</label>
<input type="password" id="password" name="password" required class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-200 bg-gray-700 leading-tight focus:outline-none focus:shadow-outline">
</div>
<div class="flex justify-center">
<input type="submit" value="Soumettre" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline custom-btn">
</div>
</form>
</div>
</div>
<script>
$('#password-form').on('submit', function(e) {
e.preventDefault();
const userId = '<%= userId %>';
const filename = '<%= filename %>';
const enteredPassword = $('#password').val();
if (!enteredPassword) {
Swal.fire({
position: 'top',
icon: 'error',
title: 'Password is required',
showConfirmButton: false,
timer: 1800,
toast: true
});
return;
}
$.post('/attachments/' + userId + '/' + filename, { password: enteredPassword })
.done(function(data) {
if (data.success) {
Swal.fire({
position: 'top',
icon: 'success',
title: 'Mot de passe correct',
text: 'Vous allez être redirigé vers le fichier !',
showConfirmButton: false,
timer: 1800,
toast: true
}).then(() => {
window.location.href = '/attachments/' + userId + '/' + filename;
});
} else {
Swal.fire({
position: 'top',
icon: 'error',
title: 'Mot de passe incorrect',
showConfirmButton: false,
timer: 1800,
toast: true
});
}
})
.fail(function() {
Swal.fire({
position: 'top',
icon: 'error',
title: 'Erreur lors de la vérification du mot de passe',
showConfirmButton: false,
timer: 1800,
toast: true
});
});
});
</script>
</body>
</html>

53
views/unauthorized.ejs Normal file
View File

@@ -0,0 +1,53 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Accès non autorisé</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
text-align: center;
}
.container {
background-color: #fff;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
padding: 20px;
margin: 50px auto;
max-width: 400px;
}
h1 {
color: #e74c3c;
}
p {
color: #333;
}
.button {
display: inline-block;
padding: 10px 20px;
margin-top: 20px;
background-color: #3498db;
color: #fff;
text-decoration: none;
border-radius: 5px;
}
.button:hover {
background-color: #2980b9;
}
</style>
</head>
<body>
<div class="container">
<h1>Accès non autorisé</h1>
<p>Vous n'êtes pas autorisé à accéder à cette ressource.</p>
<a class="button" href="/">Retour à la page d'accueil</a>
</div>
</body>
</html>

147
views/upload.ejs Normal file
View File

@@ -0,0 +1,147 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<link rel="stylesheet" href="/public/css/upload.css">
<link rel="stylesheet" href="/public/css/styles.css">
<title>Upload</title>
<link rel="icon" href="/public/assets/homelab_logo.png" />
</head>
<body class="light-mode">
<div class="container mt-4 flex-column">
<h1 class="mb-4">Upload de Fichiers</h1>
<form id="uploadForm" enctype="multipart/form-data">
<div class="form-group">
<label for="file">Sélectionnez un fichier :</label>
<input class="form-control" type="file" name="file" id="fileInput"
accept=".zip, .pdf, .txt, .jpg, .jpeg, .png, .gif, .iso, .mp4">
</div>
<div class="form-group">
<label for="expiryDate">Date d'expiration :</label>
<input class="form-control" type="date" name="expiryDate" id="expiryDate">
</div>
<div class="form-group">
<label for="password">Mot de passe :</label>
<input class="form-control" type="password" name="password" id="password">
</div>
</form>
<div class="progress mt-4 bg-white shadow-sm form-control">
<div class="progress-bar" id="progressBar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<div class="mt-2 progress-info">
<small class="text-muted" id="progressText">0%</small>
<small class="text-muted ml-3" id="estimatedTime">Temps estimé : Calcul en cours...</small>
</div>
<div class="d-flex justify-content-between mt-4">
<button onclick="window.location.href='/dpanel/dashboard';" class="btn btn-primary mt-3 custom-btn">Retourner au Dashboard</button>
<div class="mx-auto">
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="darkModeSwitch">
<button id="themeSwitcher" class="btn btn-warning mt-3 ml-2">Changer de Thème</button>
</div>
</div>
<button type="submit" form="uploadForm" class="btn btn-primary mt-3 custom-btn">Envoyer</button>
</div>
</div>
<script>
const progressBar = document.getElementById('progressBar');
const progressText = document.getElementById('progressText');
const estimatedTime = document.getElementById('estimatedTime');
const uploadForm = document.getElementById('uploadForm');
const body = document.body;
document.getElementById('themeSwitcher').addEventListener('click', function () {
body.classList.toggle('dark-mode');
});
uploadForm.addEventListener('submit', (event) => {
event.preventDefault();
const fileInput = document.getElementById('fileInput');
const file = fileInput.files[0];
const expiryDate = document.getElementById('expiryDate').value;
const password = document.getElementById('password').value;
const formData = new FormData();
formData.append('file', file);
formData.append('expiryDate', expiryDate);
formData.append('password', password);
const xhr = new XMLHttpRequest();
xhr.open('POST', '/dpanel/upload', true);
xhr.upload.onprogress = (event) => {
if (event.lengthComputable) {
const percentage = Math.round((event.loaded / event.total) * 100);
const remainingTime = calculateRemainingTime(event.loaded, event.total, event.timeStamp);
updateProgress(percentage, remainingTime);
}
};
xhr.onload = () => {
if (xhr.status === 200) {
const response = JSON.parse(xhr.responseText);
const fileLink = response.fileLink;
window.location.href = '/dpanel/upload-success';
} else {
console.error('Erreur lors du téléchargement du fichier.', xhr.status);
}
};
xhr.send(formData);
});
function calculateRemainingTime(loaded, total, timeStamp) {
const bytesPerSecond = loaded / (timeStamp / 1000);
const remainingBytes = total - loaded;
const remainingSeconds = Math.round(remainingBytes / bytesPerSecond);
if (remainingSeconds < 60) {
return remainingSeconds + ' seconde' + (remainingSeconds !== 1 ? 's' : '');
} else if (remainingSeconds < 3600) {
const remainingMinutes = Math.floor(remainingSeconds / 60);
const remainingSecondsPart = remainingSeconds % 60;
return remainingMinutes + ' minute' + (remainingMinutes !== 1 ? 's' : '') + ' et ' + remainingSecondsPart + ' seconde' + (remainingSecondsPart !== 1 ? 's' : '');
} else {
const remainingHours = Math.floor(remainingSeconds / 3600);
const remainingMinutes = Math.floor((remainingSeconds % 3600) / 60);
const remainingSecondsPart = remainingSeconds % 60;
return remainingHours + ' heure' + (remainingHours !== 1 ? 's' : '') + ' ' + remainingMinutes + ' minute' + (remainingMinutes !== 1 ? 's' : '') + ' et ' + remainingSecondsPart + ' seconde' + (remainingSecondsPart !== 1 ? 's' : '');
}
}
function updateProgress(percentage, timeRemaining) {
progressBar.style.width = percentage + '%';
progressBar.setAttribute('aria-valuenow', percentage);
progressText.textContent = percentage + '%';
estimatedTime.textContent = 'Temps estimé : ' + timeRemaining;
}
document.addEventListener('DOMContentLoaded', function () {
const darkModeSwitch = document.getElementById('darkModeSwitch');
const body = document.body;
const darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
body.classList.toggle('dark-mode', darkModeMediaQuery.matches);
darkModeMediaQuery.addListener(function (e) {
body.classList.toggle('dark-mode', e.matches);
});
});
</script>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
</body>
</html>