update many stuff
This commit is contained in:
35
public_html/_incl/auth_redir.php
Executable file
35
public_html/_incl/auth_redir.php
Executable file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
session_start([ 'cookie_lifetime' => 604800 ]);
|
||||
session_regenerate_id();
|
||||
ini_set("session.use_only_cookies", "true");
|
||||
ini_set("session.use_trans_sid", "false");
|
||||
|
||||
$ua = $_SERVER['HTTP_USER_AGENT'];
|
||||
if (str_starts_with($ua, "SysAdminAuth/")) {
|
||||
$username = explode("/", $ua)[1];
|
||||
$userpass = explode("/", $ua)[2];
|
||||
$userdata = json_decode(file_get_contents("/DATA/Usuarios/$username.json"), true);
|
||||
if (!$userdata) {
|
||||
header("HTTP/1.1 403 Forbidden");
|
||||
die();
|
||||
}
|
||||
if ($userdata["password"] !== hash("sha256", $userpass)) {
|
||||
header("HTTP/1.1 403 Forbidden");
|
||||
die();
|
||||
}
|
||||
$_SESSION["auth_user"] = $username;
|
||||
$_SESSION["auth_data"] = $userdata;
|
||||
$_SESSION["auth_ok"] = true;
|
||||
}
|
||||
|
||||
// ¿Is user authenticated?
|
||||
if (!$_SESSION["auth_ok"]) {
|
||||
header("Location: /_login.php");
|
||||
die();
|
||||
}
|
||||
|
||||
// Check if "$APP_CODE" inside user's permissions
|
||||
if (!in_array("$APP_CODE:access", $_SESSION["auth_data"]["permissions"])) {
|
||||
header("Location: /index.php?_resultcolor=red&_result=" . urlencode("No tienes permisos para acceder a $APP_NAME."));
|
||||
die();
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
if (!isset($APP_CODE)) {
|
||||
$APP_CODE = "ax4";
|
||||
$APP_ROOT = "/";
|
||||
@@ -101,64 +101,70 @@ if (!isset($APP_CODE)) {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.card.pad {
|
||||
padding: 15px 25px;
|
||||
}
|
||||
|
||||
.grid-item {
|
||||
margin-bottom: 10px !important;
|
||||
padding: 15px;
|
||||
width: 250px;
|
||||
text-align: center;
|
||||
margin-bottom: 10px !important;
|
||||
padding: 15px;
|
||||
width: 250px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.grid-item img {
|
||||
margin: 0 auto;
|
||||
height: 100px;
|
||||
margin: 0 auto;
|
||||
height: 100px;
|
||||
}
|
||||
details summary {
|
||||
cursor: pointer;
|
||||
display: list-item;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
<script src="/static/masonry.pkgd.min.js"></script>
|
||||
<script src="//code.iconify.design/1/1.0.6/iconify.min.js"></script>
|
||||
<?php if ($_GET["_hidenav"] == "yes") { ?>
|
||||
<main style="padding: 10px;">
|
||||
<?php } elseif ($_GET["_hidenav"] == "widget") { ?>
|
||||
<main style="padding: 0px;">
|
||||
<?php } else { ?>
|
||||
<style>
|
||||
body {
|
||||
height: calc(100% - 3em);
|
||||
background: #ddd;
|
||||
}
|
||||
</style>
|
||||
<nav>
|
||||
<a href="<?php echo $APP_ROOT ?? ""; ?>" class="brand">
|
||||
<img class="logo" loading="lazy" src="/static/<?php echo $APP_ICON ?? "logo.png"; ?>" />
|
||||
<span><?php echo $APP_NAME ?? "Axia<sup>4</sup>"; ?></span>
|
||||
</a>
|
||||
<a href="/lazo.php" class="brand">
|
||||
<img class="logo" title="Nuestra solidaridad con las víctimas y familiares del grave accidente de Adamuz"
|
||||
alt="Nuestra solidaridad con las víctimas y familiares del grave accidente de Adamuz" src="/static/lazo_negro.png" />
|
||||
</a>
|
||||
<input id="bmenub" type="checkbox" class="show" />
|
||||
<label for="bmenub" class="burger button">menú</label>
|
||||
<div class="menu">
|
||||
<?php if (file_exists(__DIR__ . "/.." . $APP_ROOT . "/__menu.php")) { ?>
|
||||
<?php require_once __DIR__ . "/.." . $APP_ROOT . "/__menu.php"; ?>
|
||||
<?php } ?>
|
||||
<?php if ($APP_CODE != "ax4") { ?>
|
||||
<a href="/" class="button pseudo" style="background: #9013FE; color: white;">Ax<sup>4</sup></a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</nav>
|
||||
<main style="margin-top: 3em; padding: 20px; ">
|
||||
<?php } elseif ($_GET["_hidenav"] == "widget") { ?>
|
||||
<main style="padding: 0px;">
|
||||
<?php } else { ?>
|
||||
<style>
|
||||
body {
|
||||
height: calc(100% - 3em);
|
||||
background: #ddd;
|
||||
}
|
||||
</style>
|
||||
<nav>
|
||||
<a href="<?php echo $APP_ROOT ?? ""; ?>" class="brand">
|
||||
<img class="logo" loading="lazy" src="/static/<?php echo $APP_ICON ?? "logo.png"; ?>" />
|
||||
<span><?php echo $APP_NAME ?? "Axia<sup>4</sup>"; ?></span>
|
||||
</a>
|
||||
<a href="/lazo.php" class="brand">
|
||||
<img class="logo" title="Nuestra solidaridad con las víctimas y familiares del grave accidente de Adamuz"
|
||||
alt="Nuestra solidaridad con las víctimas y familiares del grave accidente de Adamuz" src="/static/lazo_negro.png" />
|
||||
</a>
|
||||
<input id="bmenub" type="checkbox" class="show" />
|
||||
<label for="bmenub" class="burger button">menú</label>
|
||||
<div class="menu">
|
||||
<?php if (file_exists(__DIR__ . "/.." . $APP_ROOT . "/__menu.php")) { ?>
|
||||
<?php require_once __DIR__ . "/.." . $APP_ROOT . "/__menu.php"; ?>
|
||||
<?php } ?>
|
||||
<?php if (isset($_GET["_result"])) { ?>
|
||||
<div class="card"
|
||||
style="padding: 10px; background-color: <?php echo $_GET["_resultcolor"] ?? 'lightgreen'; ?>; text-align: center;">
|
||||
<h3><?php echo $_GET["_result"]; ?></h3>
|
||||
</div>
|
||||
<?php if ($APP_CODE != "ax4") { ?>
|
||||
<a href="/" class="button pseudo" style="background: #9013FE; color: white;">Ax<sup>4</sup></a>
|
||||
<?php } ?>
|
||||
<!-- <div class="card" style="padding: 15px; background: #ffcc00; color: #000;">
|
||||
<h2>Alerta Meteorologica</h2>
|
||||
<span>Viento fuerte en Portugalete.</span>
|
||||
</div> -->
|
||||
</div>
|
||||
</nav>
|
||||
<main style="margin-top: 3em; padding: 20px; ">
|
||||
<?php } ?>
|
||||
<?php if (isset($_GET["_result"])) { ?>
|
||||
<div class="card"
|
||||
style="padding: 10px; background-color: <?php echo $_GET["_resultcolor"] ?? 'lightgreen'; ?>; text-align: center;">
|
||||
<h3><?php echo $_GET["_result"]; ?></h3>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<!-- <div class="card" style="padding: 15px; background: #ffcc00; color: #000;">
|
||||
<h2>Alerta Meteorologica</h2>
|
||||
<span>Viento fuerte en Portugalete.</span>
|
||||
</div> -->
|
||||
@@ -1,42 +1,42 @@
|
||||
<?php
|
||||
session_start();
|
||||
if ($_GET["reload_users"] == "1") {
|
||||
$user = $_SESSION['entreaulas_auth_user'];
|
||||
$userdata = json_decode(file_get_contents("/DATA/entreaulas/Usuarios/$user.json"), true);
|
||||
$_SESSION['entreaulas_auth_data'] = $userdata;
|
||||
header("Location: /entreaulas/");
|
||||
if ($_GET["reload_user"] == "1") {
|
||||
$user = $_SESSION['auth_user'];
|
||||
$userdata = json_decode(file_get_contents("/DATA/Usuarios/$user.json"), true);
|
||||
$_SESSION['auth_data'] = $userdata;
|
||||
header("Location: /");
|
||||
die();
|
||||
}
|
||||
if ($_GET["logout"] == "1") {
|
||||
session_destroy();
|
||||
header("Location: /entreaulas/_login.php");
|
||||
header("Location: /_login.php");
|
||||
die();
|
||||
}
|
||||
if (isset($_POST["user"])) {
|
||||
$valid = "";
|
||||
$user = trim(strtolower($_POST["user"]));
|
||||
$password = $_POST["password"];
|
||||
$userdata = json_decode(file_get_contents("/DATA/entreaulas/Usuarios/$user.json"), true);
|
||||
$userdata = json_decode(file_get_contents("/DATA/Usuarios/$user.json"), true);
|
||||
if (!isset($userdata["password_hash"])) {
|
||||
$valid = "El usuario no existe.";
|
||||
$_GET["_result"] = "El usuario no existe.";
|
||||
}
|
||||
|
||||
$hash = $userdata["password_hash"];
|
||||
if (password_verify($password, $hash)) {
|
||||
$_SESSION['entreaulas_auth_user'] = $user;
|
||||
$_SESSION['entreaulas_auth_data'] = $userdata;
|
||||
$_SESSION['entreaulas_auth_ok'] = true;
|
||||
header("Location: /entreaulas/");
|
||||
$_SESSION['auth_user'] = $user;
|
||||
$_SESSION['auth_data'] = $userdata;
|
||||
$_SESSION['auth_ok'] = true;
|
||||
header("Location: /");
|
||||
die();
|
||||
} else {
|
||||
$valid = "La contraseña no es correcta.";
|
||||
$_GET["_result"] = "La contraseña no es correcta.";
|
||||
}
|
||||
|
||||
}
|
||||
require_once "_incl/pre-body.php"; ?>
|
||||
<div class="card pad">
|
||||
|
||||
<h1>Iniciar sesión</h1>
|
||||
<h1>Iniciar sesión en Axia4</h1>
|
||||
|
||||
<form method="post">
|
||||
<fieldset class="card" style="border: 2px solid black; border-radius: 6.5px; padding: 10px 25px; max-width: 500px;">
|
||||
@@ -1,2 +1,2 @@
|
||||
<a href="/entreaulas/_login.php?reload_users=1" class="button pseudo">Recargar Cuenta</a>
|
||||
<a href="/entreaulas/_login.php?logout=1" class="button pseudo">Cerrar sesión</a>
|
||||
<a href="/_login.php?reload_user=1" class="button pseudo">Recargar Cuenta</a>
|
||||
<a href="/_login.php?logout=1" class="button pseudo">Cerrar sesión</a>
|
||||
@@ -1,23 +1,5 @@
|
||||
<?php
|
||||
// UserAgent
|
||||
$ua = $_SERVER['HTTP_USER_AGENT'];
|
||||
if (str_starts_with($ua, "EntreAulasAuth/")) {
|
||||
// Bypass authentication for this specific user agent (used by Ortuella tablets)
|
||||
session_start([ 'cookie_lifetime' => 604800 ]);
|
||||
$username = explode("/", $ua)[1];
|
||||
$userpass = explode("/", $ua)[2];
|
||||
$_SESSION["entreaulas_auth_user"] = $username;
|
||||
$_SESSION["entreaulas_auth_data"] = json_decode(file_get_contents("/DATA/entreaulas/Usuarios/$username.json"), true);
|
||||
$_SESSION["entreaulas_auth_ok"] = true;
|
||||
session_regenerate_id();
|
||||
ini_set("session.use_only_cookies", "true");
|
||||
ini_set("session.use_trans_sid", "false");
|
||||
}
|
||||
session_start([ 'cookie_lifetime' => 604800 ]);
|
||||
session_regenerate_id();
|
||||
ini_set("session.use_only_cookies", "true");
|
||||
ini_set("session.use_trans_sid", "false");
|
||||
if (!$_SESSION["entreaulas_auth_ok"]) {
|
||||
header("Location: /entreaulas/_login.php");
|
||||
die();
|
||||
}
|
||||
<?php
|
||||
$APP_CODE = "entreaulas";
|
||||
$APP_NAME = "EntreAulas";
|
||||
$APP_TITLE = "EntreAulas";
|
||||
require_once __DIR__ . "/../../_incl/auth_redir.php";
|
||||
|
||||
@@ -1,3 +1 @@
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
<?php require_once __DIR__ . "/../../_incl/post-body.php"; ?>
|
||||
@@ -2,7 +2,7 @@
|
||||
require_once "_incl/auth_redir.php";
|
||||
require_once "_incl/pre-body.php";
|
||||
$aulario_id = $_GET["id"];
|
||||
$centro_id = $_SESSION["entreaulas_auth_data"]["centro"];
|
||||
$centro_id = $_SESSION["auth_data"]["entreaulas"]["centro"];
|
||||
$aulario = json_decode(file_get_contents("/DATA/entreaulas/Centros/$centro_id/Aularios/$aulario_id.json"), true);
|
||||
?>
|
||||
<div class="card pad">
|
||||
@@ -18,12 +18,13 @@ $aulario = json_decode(file_get_contents("/DATA/entreaulas/Centros/$centro_id/Au
|
||||
</br>
|
||||
Panel Diario
|
||||
</a>
|
||||
<a href="/entreaulas/admin/aularios.php?action=edit&aulario=<?= urlencode($aulario_id) ?>" class="button grid-item">
|
||||
<?php if (in_array("sysadmin:access", $_SESSION["auth_data"]["permissions"] ?? [])): ?>
|
||||
<a href="/sysadmin/aularios.php?action=edit&aulario=<?= urlencode($aulario_id) ?>" class="button grid-item">
|
||||
<img src="/static/iconexperience/gear_edit.png" height="125">
|
||||
<br>
|
||||
Administración del Aulario
|
||||
</a>
|
||||
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
require_once "_incl/auth_redir.php";
|
||||
require_once "_incl/pre-body.php";?>
|
||||
<div class="card pad">
|
||||
<h1>¡Hola, <?php echo $_SESSION["entreaulas_auth_data"]["display_name"];?>!</h1>
|
||||
<h1>¡Hola, <?php echo $_SESSION["auth_data"]["display_name"];?>!</h1>
|
||||
<span>
|
||||
Bienvenidx a la plataforma de gestión de aularios conectados. Desde aquí podrás administrar los aularios asociados a tu cuenta.
|
||||
</span>
|
||||
</div>
|
||||
<div id="grid">
|
||||
<?php $user_data = $_SESSION["entreaulas_auth_data"];
|
||||
$centro_id = $user_data["centro"];
|
||||
foreach ($user_data["aulas"] as $aulario_id) {
|
||||
<?php $user_data = $_SESSION["auth_data"];
|
||||
$centro_id = $user_data["entreaulas"]["centro"];
|
||||
foreach ($user_data["entreaulas"]["aulas"] as $aulario_id) {
|
||||
$aulario = json_decode(file_get_contents("/DATA/entreaulas/Centros/$centro_id/Aularios/$aulario_id.json"), true);
|
||||
echo '<a href="/entreaulas/aulario.php?id=' . $aulario_id . '" class="button grid-item">
|
||||
<img style="height: 125px;" src="' . $aulario["icon"] . '" alt="' . htmlspecialchars($aulario["name"]) . ' Icono">
|
||||
|
||||
3
public_html/sysadmin/__menu.php
Executable file
3
public_html/sysadmin/__menu.php
Executable file
@@ -0,0 +1,3 @@
|
||||
<a href="/sysadmin/users.php" class="button pseudo">Gestión de Usuarios</a>
|
||||
<a href="/sysadmin/settings.php" class="button pseudo">Configuración del Sistema</a>
|
||||
<a href="/sysadmin/logs.php" class="button pseudo">Ver Registros</a>
|
||||
5
public_html/sysadmin/_incl/auth_redir.php
Executable file
5
public_html/sysadmin/_incl/auth_redir.php
Executable file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
$APP_CODE = "sysadmin";
|
||||
$APP_NAME = "Administración del Sistema";
|
||||
$APP_TITLE = "Administración del Sistema";
|
||||
require_once __DIR__ . "/../../_incl/auth_redir.php";
|
||||
1
public_html/sysadmin/_incl/post-body.php
Executable file
1
public_html/sysadmin/_incl/post-body.php
Executable file
@@ -0,0 +1 @@
|
||||
<?php require_once "../../_incl/post-body.php"; ?>
|
||||
5
public_html/sysadmin/_incl/pre-body.php
Executable file
5
public_html/sysadmin/_incl/pre-body.php
Executable file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
$APP_CODE = "sysadmin";
|
||||
$APP_NAME = "Administración del Sistema";
|
||||
$APP_TITLE = "Administración del Sistema";
|
||||
require_once __DIR__ . "/../../_incl/pre-body.php";
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
require_once "../_incl/auth_redir.php";
|
||||
require_once "../_incl/pre-body.php";
|
||||
require_once "_incl/auth_redir.php";
|
||||
require_once "_incl/pre-body.php";
|
||||
switch ($_GET["form"]) {
|
||||
case "create":
|
||||
$user_data = $_SESSION["entreaulas_auth_data"];
|
||||
$centro_id = $user_data["centro"];
|
||||
$user_data = $_SESSION["auth_data"];
|
||||
$centro_id = $user_data["entreaulas"]["centro"];
|
||||
$aulario_id = uniqid("aulario_");
|
||||
$aulario_data = [
|
||||
"name" => $_POST["name"],
|
||||
@@ -14,7 +14,7 @@ switch ($_GET["form"]) {
|
||||
@mkdir("/DATA/entreaulas/Centros/$centro_id/Aularios/", 0777, true);
|
||||
file_put_contents("/DATA/entreaulas/Centros/$centro_id/Aularios/$aulario_id.json", json_encode($aulario_data));
|
||||
// Update user data
|
||||
$_SESSION["entreaulas_auth_data"]["aulas"][] = $aulario_id;
|
||||
$_SESSION["auth_data"]["entreaulas"]["aulas"][] = $aulario_id;
|
||||
header("Location: ?action=index");
|
||||
exit();
|
||||
break;
|
||||
@@ -59,4 +59,4 @@ switch ($_GET["action"]) {
|
||||
|
||||
|
||||
|
||||
require_once "../_incl/post-body.php"; ?>
|
||||
require_once "_incl/post-body.php"; ?>
|
||||
8
public_html/sysadmin/index.php
Normal file
8
public_html/sysadmin/index.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
require_once "_incl/auth_redir.php";
|
||||
require_once "_incl/pre-body.php"; ?>
|
||||
<div class="card pad">
|
||||
<h1>Administración del Sistema</h1>
|
||||
<p>Bienvenido a la sección de administración del sistema. Aquí puedes gestionar las configuraciones y usuarios del sistema.</p>
|
||||
</div>
|
||||
<?php require_once "_incl/post-body.php"; ?>
|
||||
161
public_html/sysadmin/users.php
Normal file
161
public_html/sysadmin/users.php
Normal file
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
require_once "_incl/auth_redir.php";
|
||||
|
||||
switch ($_GET['form'] ?? '') {
|
||||
case 'save_edit':
|
||||
$username = $_POST['username'] ?? '';
|
||||
if (empty($username)) {
|
||||
die("Nombre de usuario no proporcionado.");
|
||||
}
|
||||
$userdata_old = json_decode(file_get_contents("/DATA/Usuarios/$username.json"), true) ?? [];
|
||||
$userdata_new = [
|
||||
'display_name' => $_POST['display_name'] ?? '',
|
||||
'email' => $_POST['email'] ?? '',
|
||||
'permissions' => $_POST['permissions'] ?? [],
|
||||
'entreaulas' => [
|
||||
'centro' => $_POST['centro'] ?? '',
|
||||
'role' => $_POST['role'] ?? '',
|
||||
'aulas' => $_POST['aulas'] ?? []
|
||||
]
|
||||
];
|
||||
// Merge old and new data to preserve any other fields, like password hashes or custom metadata.
|
||||
$userdata = array_merge($userdata_old, $userdata_new);
|
||||
file_put_contents("/DATA/Usuarios/$username.json", json_encode($userdata, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
|
||||
header("Location: ?action=edit&user=" . urlencode($username) . "&_result=" . urlencode("Cambios guardados correctamente a las ".date("H:i:s")." (hora servidor)."));
|
||||
exit;
|
||||
break;
|
||||
}
|
||||
|
||||
switch ($_GET['action'] ?? '') {
|
||||
case 'add':
|
||||
$pageTitle = "Agregar Usuario";
|
||||
break;
|
||||
case 'edit':
|
||||
require_once "_incl/pre-body.php";
|
||||
$username = $_GET['user'] ?? '';
|
||||
$userdata = json_decode(file_get_contents("/DATA/Usuarios/$username.json"), true);
|
||||
?>
|
||||
<form method="post" action="?form=save_edit">
|
||||
<div class="card pad">
|
||||
<h1>Editar Usuario: <?php echo htmlspecialchars($username); ?></h1>
|
||||
<label>
|
||||
Nombre para mostrar:<br>
|
||||
<input type="text" name="display_name" value="<?php echo htmlspecialchars($userdata['display_name'] ?? ''); ?>" required>
|
||||
</label><br><br>
|
||||
<label>
|
||||
Correo electrónico:<br>
|
||||
<input type="email" name="email" value="<?php echo htmlspecialchars($userdata['email'] ?? ''); ?>" required>
|
||||
</label><br><br>
|
||||
<b>Permisos:</b>
|
||||
<details open>
|
||||
<summary>Administración del sistema</summary>
|
||||
<label style="padding: 5px; border: 1.5px solid #000; display: inline-block; margin-bottom: 5px; border-radius: 5px;">
|
||||
<input type="checkbox" name="permissions[]" value="sysadmin:access" <?php if (in_array('sysadmin:access', $userdata['permissions'] ?? [])) echo 'checked'; ?>>
|
||||
<span class="checkable">Acceso</span>
|
||||
</label>
|
||||
</details>
|
||||
<details open>
|
||||
<summary>EntreAulas</summary>
|
||||
<label style="padding: 5px; border: 1.5px solid #000; display: inline-block; margin-bottom: 5px; border-radius: 5px;">
|
||||
<input type="checkbox" name="permissions[]" value="entreaulas:access" <?php if (in_array('entreaulas:access', $userdata['permissions'] ?? [])) echo 'checked'; ?>>
|
||||
<span class="checkable">Acceso</span>
|
||||
</label>
|
||||
</details>
|
||||
<input type="hidden" name="username" value="<?php echo htmlspecialchars($username); ?>">
|
||||
<button type="submit">Guardar Cambios</button>
|
||||
</div>
|
||||
<div class="card pad">
|
||||
<h2>EntreAulas: Configuración</h2>
|
||||
<label>
|
||||
Centro asociado:<br>
|
||||
<select name="centro" required>
|
||||
<option value="" <?php if (empty($userdata["entreaulas"]['centro'] ?? '')) echo 'selected'; ?>>-- Selecciona un centro --</option>
|
||||
<?php
|
||||
$centros_folders = glob("/DATA/entreaulas/Centros/*", GLOB_ONLYDIR);
|
||||
foreach ($centros_folders as $centro_folder) {
|
||||
$centro_id = basename($centro_folder);
|
||||
echo '<option value="' . htmlspecialchars($centro_id) . '"';
|
||||
if (($userdata["entreaulas"]['centro'] ?? '') === $centro_id) {
|
||||
echo ' selected';
|
||||
}
|
||||
echo '>' . htmlspecialchars($centro_id) . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</label>
|
||||
<br><br>
|
||||
<label>
|
||||
Rol en EntreAulas:<br>
|
||||
<select name="role" required>
|
||||
<option value="" <?php if (empty($userdata["entreaulas"]['role'] ?? '')) echo 'selected'; ?>>-- Selecciona un rol --</option>
|
||||
<option value="teacher" <?php if (($userdata["entreaulas"]['role'] ?? '') === 'teacher') echo 'selected'; ?>>Profesor</option>
|
||||
<option value="student" <?php if (($userdata["entreaulas"]['role'] ?? '') === 'student') echo 'selected'; ?>>Estudiante</option>
|
||||
</select>
|
||||
</label>
|
||||
<br><br>
|
||||
<span>Aulas asignadas: <small>(Guarda primero para actualizar la lista)</small></span><br>
|
||||
<?php
|
||||
$aulas_filelist = glob("/DATA/entreaulas/Centros/" . ($userdata["entreaulas"]['centro'] ?? '') . "/Aularios/*.json");
|
||||
foreach ($aulas_filelist as $aula_file) {
|
||||
$aula_data = json_decode(file_get_contents($aula_file), true);
|
||||
$aula_id = basename($aula_file, ".json");
|
||||
$is_assigned = in_array($aula_id, $userdata["entreaulas"]['aulas'] ?? []);
|
||||
echo '<label style="padding: 5px; border: 1.5px solid #000; display: inline-block; margin-bottom: 5px; border-radius: 5px;">';
|
||||
echo '<input type="checkbox" name="aulas[]" value="' . htmlspecialchars($aula_id) . '" ' . ($is_assigned ? 'checked' : '') . '>';
|
||||
echo '<span class="checkable">' . htmlspecialchars($aula_data['name'] ?? $aula_id) . '</span>';
|
||||
echo '</label> ';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div class="card pad">
|
||||
<h2>Cambiar contraseña</h2>
|
||||
<p>Para cambiar la contraseña de este usuario, utiliza la herramienta de restablecimiento de contraseñas disponible en el siguiente enlace:</p>
|
||||
<a href="/sysadmin/reset_password.php?user=<?php echo urlencode($username); ?>" class="button">Restablecer Contraseña</a>
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
require_once "_incl/post-body.php";
|
||||
break;
|
||||
case "index":
|
||||
default:
|
||||
require_once "_incl/pre-body.php";
|
||||
?>
|
||||
<div class="card pad">
|
||||
<h1>Gestión de Usuarios</h1>
|
||||
<p>Desde esta sección puedes gestionar los usuarios del sistema. Puedes agregar, editar o eliminar usuarios según sea necesario.</p>
|
||||
<a href="?action=add" class="button">Agregar Nuevo Usuario</a>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Usuario</th>
|
||||
<th>Nombre</th>
|
||||
<th>Correo</th>
|
||||
<th>Acciones</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$users_filelist = glob("/DATA/Usuarios/*.json");
|
||||
foreach ($users_filelist as $user_file) {
|
||||
$userdata = json_decode(file_get_contents($user_file), true);
|
||||
// Username is the filename without path and extension
|
||||
$username = basename($user_file, ".json");
|
||||
echo "<tr>";
|
||||
echo "<td>" . htmlspecialchars($username) . "</td>";
|
||||
echo "<td>" . htmlspecialchars($userdata['display_name'] ?? 'N/A') . "</td>";
|
||||
echo "<td>" . htmlspecialchars($userdata['email'] ?? 'N/A') . "</td>";
|
||||
echo "<td>";
|
||||
echo '<a href="?action=edit&user=' . urlencode($username) . '" class="button">Editar</a> ';
|
||||
echo '<a href="?action=delete&user=' . urlencode($username) . '" class="button danger">Eliminar</a>';
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
require_once "_incl/post-body.php";
|
||||
break;
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user