<?php
/**
 * limpiarVotosController.php — Sprint 4: CSRF
 */
namespace app\controller\administradores;

use app\models\user;
use app\models\votos;

require_once '../../../app/models/user.php';
require_once '../../../app/models/votos.php';
require_once '../../../app/helpers/csrf.php';

session_save_path("/home/evolucionamos/public_html/mejora/sessions");
session_start();

if (empty($_SESSION['adm'])) {
    header("Location: ../../../index.php");
    exit;
}

if ($_SESSION['role'] != 1) {
    header("Location: ../../../index.php");
    exit;
}

// Sprint 4: Validar CSRF
validarCSRF();

$user = new user();
$user->limpiarVotos();

$votos = new votos();
$votos->limpiarVotos();

header("Location: ../../../administradores/admin.php?success=Votos+vacíos");
exit;
