Fix security issues in ¿Quién soy? flow
Co-authored-by: naielv <109038805+naielv@users.noreply.github.com>
This commit is contained in:
@@ -7,9 +7,14 @@ header("Access-Control-Allow-Origin: *");
|
|||||||
|
|
||||||
switch ($_GET["type"]) {
|
switch ($_GET["type"]) {
|
||||||
case "alumno_photo":
|
case "alumno_photo":
|
||||||
$centro = str_replace('..', '_', $_GET["centro"] ?? '');
|
$centro = basename($_GET["centro"] ?? '');
|
||||||
$aulario = str_replace('..', '_', $_GET["aulario"] ?? '');
|
$aulario = basename($_GET["aulario"] ?? '');
|
||||||
$alumno = str_replace('..', '_', $_GET["alumno"] ?? '');
|
$alumno = basename($_GET["alumno"] ?? '');
|
||||||
|
// Additional validation to prevent empty names
|
||||||
|
if (empty($centro) || empty($aulario) || empty($alumno)) {
|
||||||
|
header("HTTP/1.1 400 Bad Request");
|
||||||
|
die("Invalid parameters");
|
||||||
|
}
|
||||||
$relpath = "entreaulas/Centros/$centro/Aularios/$aulario/Alumnos/$alumno/photo.jpg";
|
$relpath = "entreaulas/Centros/$centro/Aularios/$aulario/Alumnos/$alumno/photo.jpg";
|
||||||
break;
|
break;
|
||||||
case "panel_actividades":
|
case "panel_actividades":
|
||||||
|
|||||||
@@ -152,8 +152,14 @@ switch ($_GET["action"]) {
|
|||||||
break;
|
break;
|
||||||
case "quien_soy":
|
case "quien_soy":
|
||||||
// ¿Quién soy? - Identificación del alumno
|
// ¿Quién soy? - Identificación del alumno
|
||||||
$aulario_id = $_GET["aulario"] ?? "";
|
$aulario_id = basename($_GET["aulario"] ?? '');
|
||||||
$centro_id = $_SESSION["auth_data"]["entreaulas"]["centro"] ?? "";
|
$centro_id = basename($_SESSION["auth_data"]["entreaulas"]["centro"] ?? '');
|
||||||
|
|
||||||
|
// Validate parameters
|
||||||
|
if (empty($aulario_id) || empty($centro_id)) {
|
||||||
|
echo '<div class="card pad"><p>Error: Parámetros inválidos.</p></div>';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$alumnos_path = "/DATA/entreaulas/Centros/$centro_id/Aularios/$aulario_id/Alumnos";
|
$alumnos_path = "/DATA/entreaulas/Centros/$centro_id/Aularios/$aulario_id/Alumnos";
|
||||||
$alumnos = [];
|
$alumnos = [];
|
||||||
@@ -166,7 +172,7 @@ switch ($_GET["action"]) {
|
|||||||
function seleccionarAlumno(element, nombre) {
|
function seleccionarAlumno(element, nombre) {
|
||||||
element.style.backgroundColor = "#9cff9f"; // Verde
|
element.style.backgroundColor = "#9cff9f"; // Verde
|
||||||
announceAndMaybeRedirect(
|
announceAndMaybeRedirect(
|
||||||
nombre + ", ¡Hola " + nombre + "!",
|
"¡Hola " + nombre + "!",
|
||||||
"/entreaulas/paneldiario.php?aulario=<?php echo urlencode($_GET['aulario'] ?? ''); ?>",
|
"/entreaulas/paneldiario.php?aulario=<?php echo urlencode($_GET['aulario'] ?? ''); ?>",
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
@@ -193,7 +199,7 @@ switch ($_GET["action"]) {
|
|||||||
$photo_path = $alumno_path . "/photo.jpg";
|
$photo_path = $alumno_path . "/photo.jpg";
|
||||||
$photo_exists = file_exists($photo_path);
|
$photo_exists = file_exists($photo_path);
|
||||||
?>
|
?>
|
||||||
<a class="card grid-item" style="color: black;" onclick="seleccionarAlumno(this, '<?php echo htmlspecialchars($alumno_name); ?>');">
|
<a class="card grid-item" style="color: black;" onclick="seleccionarAlumno(this, <?php echo json_encode($alumno_name, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT); ?>);">
|
||||||
<?php if ($photo_exists): ?>
|
<?php if ($photo_exists): ?>
|
||||||
<img src="_filefetch.php?type=alumno_photo&alumno=<?php echo urlencode($alumno_name); ?>¢ro=<?php echo urlencode($centro_id); ?>&aulario=<?php echo urlencode($aulario_id); ?>" height="150" class="bg-white">
|
<img src="_filefetch.php?type=alumno_photo&alumno=<?php echo urlencode($alumno_name); ?>¢ro=<?php echo urlencode($centro_id); ?>&aulario=<?php echo urlencode($aulario_id); ?>" height="150" class="bg-white">
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
|
|||||||
Reference in New Issue
Block a user