- Introduced `safe_id_segment`, `safe_centro_id`, and `safe_aulario_config_path` functions to sanitize input and construct file paths securely. - Updated `index.php`, `paneldiario.php`, `proyectos.php`, `aularios.php`, `centros.php`, `club_mkthumb.php`, `reset_password.php`, and `users.php` to utilize new sanitization functions. - Enhanced error handling for file existence checks and directory traversal prevention. - Ensured consistent use of safe path handling in user input across the application.
114 lines
4.0 KiB
PHP
114 lines
4.0 KiB
PHP
<?php
|
|
require_once "_incl/auth_redir.php";
|
|
require_once "_incl/pre-body.php";
|
|
require_once "_incl/tools.security.php";
|
|
|
|
function safe_id_segment($value)
|
|
{
|
|
$value = basename((string)$value);
|
|
return preg_replace('/[^A-Za-z0-9_-]/', '', $value);
|
|
}
|
|
|
|
function safe_centro_id($value)
|
|
{
|
|
return preg_replace('/[^0-9]/', '', (string)$value);
|
|
}
|
|
|
|
function safe_aulario_config_path($centro_id, $aulario_id)
|
|
{
|
|
$centro = safe_centro_id($centro_id);
|
|
$aulario = safe_id_segment($aulario_id);
|
|
if ($centro === '' || $aulario === '') {
|
|
return null;
|
|
}
|
|
return "/DATA/entreaulas/Centros/$centro/Aularios/$aulario.json";
|
|
}
|
|
|
|
$aulario_id = safe_id_segment(Sf($_GET["id"] ?? ""));
|
|
$centro_id = safe_centro_id($_SESSION["auth_data"]["entreaulas"]["centro"] ?? "");
|
|
$aulario_path = safe_aulario_config_path($centro_id, $aulario_id);
|
|
$aulario = ($aulario_path && file_exists($aulario_path)) ? json_decode(file_get_contents($aulario_path), true) : null;
|
|
|
|
if (!$aulario || !is_array($aulario)) {
|
|
?>
|
|
<div class="card pad">
|
|
<h1 class="card-title">Aulario no encontrado</h1>
|
|
<p>No se ha podido cargar la configuración del aulario.</p>
|
|
</div>
|
|
<?php require_once "_incl/post-body.php"; exit; }
|
|
?>
|
|
<div class="card pad">
|
|
<div>
|
|
<h1 class="card-title">Aulario: <?= htmlspecialchars($aulario["name"]) ?></h1>
|
|
<span>
|
|
Bienvenidx al aulario <?= htmlspecialchars($aulario["name"]) ?>. Aquí podrás gestionar las funcionalidades específicas de este aulario.
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="grid">
|
|
<a href="/entreaulas/paneldiario.php?aulario=<?= urlencode($aulario_id) ?>" class="btn btn-primary grid-item">
|
|
<img src="/static/arasaac/pdi.png" height="125" style="background: white; padding: 5px; border-radius: 10px;">
|
|
</br>
|
|
Panel Diario
|
|
</a>
|
|
<?php if (in_array("entreaulas:docente", $_SESSION["auth_data"]["permissions"] ?? [])): ?>
|
|
<a href="/entreaulas/alumnos.php?aulario=<?= urlencode($aulario_id) ?>" class="btn btn-info grid-item">
|
|
<img src="/static/arasaac/alumnos.png" height="125" style="background: white; padding: 5px; border-radius: 10px;" alt="Icono de gestión de alumnos">
|
|
<br>
|
|
Gestión de Alumnos
|
|
</a>
|
|
<?php endif; ?>
|
|
<?php if (in_array("sysadmin:access", $_SESSION["auth_data"]["permissions"] ?? [])): ?>
|
|
<a href="/sysadmin/aularios.php?action=edit&aulario=<?= urlencode($aulario_id) ?>" class="btn btn-secondary grid-item">
|
|
<img src="/static/iconexperience/gear_edit.png" height="125">
|
|
<br>
|
|
Cambiar Ajustes
|
|
</a>
|
|
<?php endif; ?>
|
|
<!-- Menú del comedor -->
|
|
<a href="/entreaulas/comedor.php?aulario=<?= urlencode($aulario_id) ?>" class="btn btn-success grid-item">
|
|
<img src="/static/arasaac/comedor.png" height="125" style="background: white; padding: 5px; border-radius: 10px;">
|
|
<br>
|
|
Menú del Comedor
|
|
</a>
|
|
<!-- Proyectos -->
|
|
<a href="/entreaulas/proyectos.php?aulario=<?= urlencode($aulario_id) ?>" class="btn btn-warning grid-item">
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" height="125" fill="currentColor">
|
|
<title>folder-multiple</title>
|
|
<path d="M22,4H14L12,2H6A2,2 0 0,0 4,4V16A2,2 0 0,0 6,18H22A2,2 0 0,0 24,16V6A2,2 0 0,0 22,4M2,6H0V11H0V20A2,2 0 0,0 2,22H20V20H2V6Z" />
|
|
</svg>
|
|
<br>
|
|
Proyectos
|
|
</a>
|
|
</div>
|
|
<style>
|
|
.grid-item {
|
|
margin-bottom: 10px !important;
|
|
padding: 15px;
|
|
width: 250px;
|
|
text-align: center;
|
|
}
|
|
|
|
.grid-item img {
|
|
margin: 0 auto;
|
|
height: 125px;
|
|
}
|
|
</style>
|
|
<script>
|
|
var msnry = new Masonry('#grid', {
|
|
"columnWidth": 250,
|
|
"itemSelector": ".grid-item",
|
|
"gutter": 10,
|
|
"transitionDuration": 0
|
|
});
|
|
setTimeout(() => {
|
|
msnry.layout()
|
|
}, 150)
|
|
// setInterval(() => {msnry.layout()}, 10000);
|
|
window.addEventListener('resize', function(event) {
|
|
msnry.layout()
|
|
}, true);
|
|
</script>
|
|
|
|
<?php require_once "_incl/post-body.php"; ?>
|