Introduzione modalita' sviluppatore e vari change

This commit is contained in:
2025-10-03 10:15:25 +02:00
parent f91019b884
commit 35ff83d1d0
8 changed files with 53 additions and 8 deletions

View File

@@ -58,6 +58,11 @@ if (isset($_GET['delete'])) {
Nota: Questa pagina si vede meglio da computer desktop. Se sei da computer, puoi ignorare questo messaggio.
</p>
<p style="text-align: center;">Copyright (C) 2025 EmmeV. - Released under <a href="https://git.vichingo455.freeddns.org/emmev-code/orario/src/branch/stable/LICENSE.txt" target="_blank">GNU AGPL 3.0 License</a>.</p>
<?php
if (DEV_MODE) {
echo "<p>[DEBUG] Tipo di autenticazione: " . $_SESSION['auth_type'] . "</p>";
}
?>
</div>
</body>
</html>

View File

@@ -1,4 +1,5 @@
<?php
include_once __DIR__ . '/../config/config.php';
session_start();
if (!isset($_SESSION['admin'])) {
header("Location: login.php");
@@ -44,6 +45,11 @@ if (!isset($_SESSION['admin'])) {
Nota: Questa pagina si vede meglio da computer desktop. Se sei da computer, puoi ignorare questo messaggio.
</p>
<p style="text-align: center;">Copyright (C) 2025 EmmeV. - Released under <a href="https://git.vichingo455.freeddns.org/emmev-code/orario/src/branch/stable/LICENSE.txt" target="_blank">GNU AGPL 3.0 License</a>.</p>
<?php
if (DEV_MODE) {
echo "<p>[DEBUG] Tipo di autenticazione: " . $_SESSION['auth_type'] . "</p>";
}
?>
</div>
</body>
</html>

View File

@@ -16,13 +16,20 @@ if ($_SERVER["REQUEST_METHOD"] == "POST" && AUTH_TYPE == 'local') {
if (password_verify($password, $row['password'])) {
$_SESSION['admin'] = $row['username'];
$_SESSION['auth_type'] = 'local';
header("Location: index.php");
if (DEV_MODE) {
echo "[DEBUG] Password " . $password . " trovata con l'hash " . $row['password'] . '. <a href="index.php">Vai al panello amministrativo</a>';
}
else {
header("Location: index.php");
}
exit;
} else if (DEV_MODE) {
echo "[DEBUG] Password " . $password . " non trovata nel database.";
}
}
$error = "Credenziali non valide";
} catch {
$error = "Errore durante l'autenticazione. Potrebbe essere un problema con PHP oppure col database.";
} catch (Exception $e) {
$error = "Errore durante l'autenticazione. Potrebbe essere un problema con PHP oppure col database. Ulteriori dettagli: " . $e;
}
}
if (AUTH_TYPE == 'local') {
@@ -76,7 +83,7 @@ else if (AUTH_TYPE === 'keycloak') {
$_SESSION['auth_type'] = 'keycloak';
header("Location: index.php");
exit;
} catch {
} catch (Exception $e) {
http_response_code(500);
echo <<<HTML
<!DOCTYPE html>
@@ -99,7 +106,11 @@ else if (AUTH_TYPE === 'keycloak') {
<div class="login-container">
<h1>Login Admin</h1>
HTML;
echo "<br><div class='error'>Errore durante l'autenticazione con Keycloak. Assicurati di avere impostato i vari parametri correttamente.</div>";
if (DEV_MODE) {
echo "<br><div class='error'>Errore durante l'autenticazione con Keycloak. Assicurati di avere impostato i vari parametri correttamente. Ulteriori dettagli: " . $e . "</div>";
} else {
echo "<br><div class='error'>Errore durante l'autenticazione con Keycloak. Contatta l'amministratore del sito.</div>";
}
echo <<<HTML
</div>
<p style="text-align: center;">Copyright (C) 2025 EmmeV. - Released under <a href="https://git.vichingo455.freeddns.org/emmev-code/orario/src/branch/stable/LICENSE.txt" target="_blank">GNU AGPL 3.0 License</a>.</p>
@@ -165,7 +176,7 @@ HTML;
exit;
}
}
} catch {
} catch (Exception $e) {
http_response_code(500);
echo <<<HTML
<!DOCTYPE html>
@@ -188,7 +199,11 @@ HTML;
<div class="login-container">
<h1>Login Admin</h1>
HTML;
echo "<br><div class='error'>Errore durante l'autenticazione con Google. Assicurati di avere impostato i vari parametri correttamente.</div>";
if (DEV_MODE) {
echo "<br><div class='error'>Errore durante l'autenticazione con Google. Assicurati di avere impostato i vari parametri correttamente. Ulteriori dettagli: " . $e . "</div>";
} else {
echo "<br><div class='error'>Errore durante l'autenticazione con Google. Contatta l'amministratore del sito.</div>";
}
echo <<<HTML
</div>
<p style="text-align: center;">Copyright (C) 2025 EmmeV. - Released under <a href="https://git.vichingo455.freeddns.org/emmev-code/orario/src/branch/stable/LICENSE.txt" target="_blank">GNU AGPL 3.0 License</a>.</p>

View File

@@ -113,6 +113,11 @@ if(isset($_GET['edit'])){
Nota: Questa pagina si vede meglio da computer desktop. Se sei da computer, puoi ignorare questo messaggio.
</p>
<p style="text-align: center;">Copyright (C) 2025 EmmeV. - Released under <a href="https://git.vichingo455.freeddns.org/emmev-code/orario/src/branch/stable/LICENSE.txt" target="_blank">GNU AGPL 3.0 License</a>.</p>
<?php
if (DEV_MODE) {
echo "<p>[DEBUG] Tipo di autenticazione: " . $_SESSION['auth_type'] . "</p>";
}
?>
</div>
</body>

View File

@@ -156,6 +156,11 @@ if ($class_id > 0) {
Nota: Questa pagina si vede meglio da computer desktop. Se sei da computer, puoi ignorare questo messaggio.
</p>
<p style="text-align: center;">Copyright (C) 2025 EmmeV. - Released under <a href="https://git.vichingo455.freeddns.org/emmev-code/orario/src/branch/stable/LICENSE.txt" target="_blank">GNU AGPL 3.0 License</a>.</p>
<?php
if (DEV_MODE) {
echo "<p>[DEBUG] Tipo di autenticazione: " . $_SESSION['auth_type'] . "</p>";
}
?>
</div>
<script>

View File

@@ -19,6 +19,9 @@ if (!defined('APP_NAME')) {
if (!defined('YEAR')) {
define('YEAR', '2025/26'); // Anno Scolastico Corrente
}
if (!defined('DEV_MODE')) {
define('DEV_MODE', false); // Modalita' di sviluppo: abilita messaggi di debug aggiuntivi. Imposta su false se sei in produzione
}
// Impostazioni autenticazione dashboard amministrativa
if (!defined('AUTH_TYPE')) {
define('AUTH_TYPE','local'); // Può essere local (integrata), keycloak, google

View File

@@ -7,6 +7,9 @@ $dbname = DB_NAME;
$conn = new mysqli($host, $user, $pass, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
if (DEV_MODE)
die("[DEBUG] Connessione al database fallita: " . $conn->connect_error);
else
die("Connessione al database fallita!");
}
?>