Compare commits

...

7 Commits

11 changed files with 189 additions and 53 deletions

View File

@@ -65,10 +65,10 @@ $pass = "password123";
```php ```php
$oidc = new OpenIDConnectClient( $oidc = new OpenIDConnectClient(
'https://keycloak.local/realms/master/', 'https://keycloak.local/realms/master/',
'orario', 'orario', // Client ID Keycloak
'abcdefghijklmnop' 'abcdefghijklmnop' // Client secret Keycloak
); );
$oidc->setRedirectURL('https://orario.local/admin/login.php'); $oidc->setRedirectURL('https://orario.local/admin/login.php'); // orario.local è il dominio base di questa piattaforma
``` ```
- Esempio (``logout.php`` con keycloak): - Esempio (``logout.php`` con keycloak):
```php ```php

View File

@@ -57,7 +57,7 @@ if (isset($_GET['delete'])) {
<p> <p>
Nota: Questa pagina si vede meglio da computer desktop. Se sei da computer, puoi ignorare questo messaggio. Nota: Questa pagina si vede meglio da computer desktop. Se sei da computer, puoi ignorare questo messaggio.
</p> </p>
<p style="text-align: center;">Copyright (C) 2025 EmmeV. All rights reserved.</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>
</div> </div>
</body> </body>
</html> </html>

View File

@@ -34,7 +34,7 @@ if (!isset($_SESSION['admin'])) {
<p> <p>
Nota: Questa pagina si vede meglio da computer desktop. Se sei da computer, puoi ignorare questo messaggio. Nota: Questa pagina si vede meglio da computer desktop. Se sei da computer, puoi ignorare questo messaggio.
</p> </p>
<p style="text-align: center;">Copyright (C) 2025 EmmeV. All rights reserved.</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>
</div> </div>
</body> </body>
</html> </html>

View File

@@ -45,6 +45,6 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
<button type="submit">Login</button> <button type="submit">Login</button>
</form> </form>
</div> </div>
<p style="text-align: center;">Copyright (C) 2025 EmmeV. All rights reserved.</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>
</body> </body>
</html> </html>

View File

@@ -47,7 +47,44 @@ if (isset($_GET['delete'])) {
<input type="text" name="room" placeholder="Laboratorio (opzionale)"> <input type="text" name="room" placeholder="Laboratorio (opzionale)">
<button type="submit">Aggiungi</button> <button type="submit">Aggiungi</button>
</form> </form>
<?php
// 1. Aggiornamento dati
if(isset($_POST['update'])){
$id = intval($_POST['id']);
$name = $conn->real_escape_string($_POST['name']);
$teacher = $conn->real_escape_string($_POST['teacher']);
$room = $conn->real_escape_string($_POST['room']);
$conn->query("UPDATE subjects
SET name='$name', teacher='$teacher', room='$room'
WHERE id=$id");
}
// 2. Mostrare il form se edit richiesto
if(isset($_GET['edit'])){
$id = intval($_GET['edit']);
$res = $conn->query("SELECT * FROM subjects WHERE id=$id");
if($res->num_rows > 0){
$subject = $res->fetch_assoc();
?>
<h3>Modifica materia</h3>
<form method="post" action="subjects.php">
<input type="hidden" name="id" value="<?php echo $subject['id']; ?>">
<label>Materia:</label>
<input type="text" name="name" value="<?php echo htmlspecialchars($subject['name']); ?>"><br>
<label>Docente:</label>
<input type="text" name="teacher" value="<?php echo htmlspecialchars($subject['teacher']); ?>"><br>
<label>Aula:</label>
<input type="text" name="room" value="<?php echo htmlspecialchars($subject['room']); ?>"><br>
<button type="submit" name="update">Salva modifiche</button>
</form>
<?php
}
}
?>
<table> <table>
<tr> <tr>
<th>ID</th> <th>ID</th>
@@ -64,7 +101,10 @@ if (isset($_GET['delete'])) {
<td>{$row['name']}</td> <td>{$row['name']}</td>
<td>{$row['teacher']}</td> <td>{$row['teacher']}</td>
<td>{$row['room']}</td> <td>{$row['room']}</td>
<td><a href='subjects.php?delete={$row['id']}' class='delete-link'>Elimina</a></td> <td>
<a href='subjects.php?edit={$row['id']}' class='edit-link'>Modifica</a> |
<a href='subjects.php?delete={$row['id']}' class='delete-link'>Elimina</a>
</td>
</tr>"; </tr>";
} }
?> ?>
@@ -72,7 +112,7 @@ if (isset($_GET['delete'])) {
<p> <p>
Nota: Questa pagina si vede meglio da computer desktop. Se sei da computer, puoi ignorare questo messaggio. Nota: Questa pagina si vede meglio da computer desktop. Se sei da computer, puoi ignorare questo messaggio.
</p> </p>
<p style="text-align: center;">Copyright (C) 2025 EmmeV. All rights reserved.</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>
</div> </div>
</body> </body>

View File

@@ -155,7 +155,7 @@ if ($class_id > 0) {
<p style="text-align: center;"> <p style="text-align: center;">
Nota: Questa pagina si vede meglio da computer desktop. Se sei da computer, puoi ignorare questo messaggio. Nota: Questa pagina si vede meglio da computer desktop. Se sei da computer, puoi ignorare questo messaggio.
</p> </p>
<p style="text-align: center;">Copyright (C) 2025 EmmeV. All rights reserved.</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>
</div> </div>
<script> <script>

View File

@@ -106,62 +106,115 @@ td:hover {
td { padding-left: 50%; } td { padding-left: 50%; }
} }
*/ */
@media (max-width: 768px) {
table, thead, tbody, th, td, tr { /* --- tuoi stili desktop (questi restano uguali) --- */
display: block; table {
border-collapse: collapse;
width: 100%; width: 100%;
max-width: 1000px;
margin: 0 auto;
background: #fff;
border-radius: 10px;
overflow: hidden;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
th, td {
border: 1px solid #ccc;
text-align: center;
padding: 10px;
vertical-align: top;
}
th {
background-color: #e0e0e0;
font-weight: bold;
}
td {
transition: background-color 0.2s;
}
td:hover {
background-color: #f7f7f7;
}
.subject {
font-weight: bold;
color: #1f618d;
}
.teacher {
font-size: 0.9em;
color: #2c3e50;
}
.room {
font-size: 0.8em;
color: #666;
}
/* --- qui sostituisci con la versione migliorata --- */
@media (max-width: 768px) {
table {
box-shadow: none;
border-radius: 0;
} }
tr { tr {
margin-bottom: 15px; margin-bottom: 20px;
padding: 0; background: #fff;
border-bottom: 2px solid #ddd; border-radius: 8px;
} box-shadow: 0 2px 6px rgba(0,0,0,0.08);
overflow: hidden;
th { padding: 10px;
display: none;
} }
td { td {
position: relative; padding: 8px 8px 8px 50%;
padding-left: 50%;
text-align: left;
border: none; border: none;
border-bottom: 1px solid #eee; border-bottom: 1px solid #eee;
min-height: 50px; /* ensures consistent vertical spacing */ font-size: 0.9em;
box-sizing: border-box;
} }
td::before { td::before {
position: absolute; position: absolute;
top: 10px; top: 10px;
left: 10px; left: 10px;
width: 40%; color: #1f618d;
font-weight: bold; font-size: 0.85em;
white-space: nowrap; text-transform: uppercase;
letter-spacing: 0.5px;
content: attr(data-label); content: attr(data-label);
} }
/* make content stack nicely */ td > .subject {
td > .subject, font-weight: 600;
td > .teacher, font-size: 1em;
margin-bottom: 2px;
}
td > .teacher {
font-size: 0.85em;
color: #555;
}
td > .room { td > .room {
display: block; font-size: 0.75em;
margin: 2px 0; color: #888;
} }
td:last-child { td:last-child {
border-bottom: 0; border-bottom: none;
} }
} }
/* Extra small screens */
@media (max-width: 480px) { @media (max-width: 480px) {
td { td {
padding-left: 55%; padding-left: 45%;
} }
td::before { td::before {
width: 45%; width: 40%;
font-size: 0.8em;
} }
} }

View File

@@ -10,7 +10,7 @@ $hours = [
5 => "Quinta ora<br>11:55 - 12:50", 5 => "Quinta ora<br>11:55 - 12:50",
6 => "Sesta ora<br>12:50 - 13:50" 6 => "Sesta ora<br>12:50 - 13:50"
]; ];
if ($teacher == "No Lezione") { if ($teacher == "No Lezione" || $teacher == "sconosciuto") {
header("Location: index.php"); header("Location: index.php");
exit; exit;
} }
@@ -23,7 +23,6 @@ $teacher = $conn->real_escape_string($_GET['teacher']);
$res = $conn->query("SELECT DISTINCT teacher FROM subjects WHERE teacher = '$teacher' LIMIT 1"); $res = $conn->query("SELECT DISTINCT teacher FROM subjects WHERE teacher = '$teacher' LIMIT 1");
if ($res->num_rows === 0) { if ($res->num_rows === 0) {
// Insegnante non trovato
header("Location: index.php"); header("Location: index.php");
exit; exit;
} }
@@ -72,6 +71,6 @@ if ($res->num_rows === 0) {
} }
?> ?>
</table> </table>
<p style="text-align: center;">Copyright (C) 2025 EmmeV. All rights reserved.</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>
</body> </body>
</html> </html>

View File

@@ -15,6 +15,7 @@ include("db.php");
<div class="links"> <div class="links">
<a href="index.php">Home</a> <a href="index.php">Home</a>
<a href="admin/index.php">Admin</a> <a href="admin/index.php">Admin</a>
<a href="https://git.vichingo455.freeddns.org/emmev-code/orario" target="_blank">Codice sorgente</a>
</div> </div>
</div> </div>
<h1>Orario - a.s. 2025/26</h1> <h1>Orario - a.s. 2025/26</h1>
@@ -41,7 +42,7 @@ include("db.php");
<?php <?php
$res = $conn->query("SELECT DISTINCT teacher FROM subjects ORDER BY teacher"); $res = $conn->query("SELECT DISTINCT teacher FROM subjects ORDER BY teacher");
while($row = $res->fetch_assoc()){ while($row = $res->fetch_assoc()){
if ($row['teacher'] != "No Lezione") { if ($row['teacher'] != "No Lezione" && $row['teacher'] != "sconosciuto") {
$teacher_name = htmlspecialchars($row['teacher']); $teacher_name = htmlspecialchars($row['teacher']);
echo "<ul><li><b>$teacher_name</b></li>"; echo "<ul><li><b>$teacher_name</b></li>";
echo "<li><a href='docenti.php?teacher=".urlencode($teacher_name)."'>Visualizza orario</a></li>"; echo "<li><a href='docenti.php?teacher=".urlencode($teacher_name)."'>Visualizza orario</a></li>";
@@ -65,6 +66,6 @@ while($row = $res->fetch_assoc()){
?> ?>
</div> </div>
<p style="text-align: center;">Copyright (C) 2025 EmmeV. All rights reserved.</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>
</body> </body>
</html> </html>

View File

@@ -60,11 +60,31 @@ if ($res->num_rows === 0) {
WHERE subjects.room='". $conn->real_escape_string($room) ."' WHERE subjects.room='". $conn->real_escape_string($room) ."'
AND timetable.day='$d' AND timetable.hour=$hnum AND timetable.day='$d' AND timetable.hour=$hnum
"); ");
if($row = $q->fetch_assoc()){
if($q->num_rows > 0){
$subject = null;
$entries = [];
while($row = $q->fetch_assoc()){
// salvo materia (prendo la prima, di solito è la stessa per tutti)
if($subject === null) {
$subject = $row['subject_name'];
}
// accumulo classi + docente
$entries[] = $row['class_name'] . " (" . $row['teacher'] . ")";
}
// unisci le classi con " e " se sono 2, altrimenti virgole + "e" finale
if(count($entries) > 1){
$last = array_pop($entries);
$entries_list = implode(", ", $entries) . " e " . $last;
} else {
$entries_list = $entries[0];
}
echo "<td data-label='$d'> echo "<td data-label='$d'>
<div class='subject'>{$row['subject_name']}</div> <div class='subject'>$subject</div>
<div class='teacher'>{$row['teacher']}</div> <div class='room'>$entries_list</div>
<div class='room'>{$row['class_name']}</div>
</td>"; </td>";
} else { } else {
echo "<td data-label='$d'></td>"; echo "<td data-label='$d'></td>";

View File

@@ -54,10 +54,33 @@ if ($res->num_rows === 0) {
FROM timetable FROM timetable
LEFT JOIN subjects ON timetable.subject_id = subjects.id LEFT JOIN subjects ON timetable.subject_id = subjects.id
WHERE class_id=$class_id AND day='$d' AND hour=$hnum"); WHERE class_id=$class_id AND day='$d' AND hour=$hnum");
if($row = $q->fetch_assoc()){
echo "<td data-label='$d'><div class='subject'>{$row['name']}</div> if($q->num_rows > 0){
<div class='teacher'>{$row['teacher']}</div> $row = $q->fetch_assoc();
<div class='room'>{$row['room']}</div></td>"; $subject = $row['name'];
$room = $row['room'];
// metto il primo docente
$teachers = [$row['teacher']];
// aggiungo eventuali altri docenti
while($row = $q->fetch_assoc()){
$teachers[] = $row['teacher'];
}
// se più docenti -> unisci con virgola e "e" finale
if(count($teachers) > 1){
$last = array_pop($teachers);
$teachers_list = implode(", ", $teachers) . " e " . $last;
} else {
$teachers_list = $teachers[0];
}
echo "<td data-label='$d'>
<div class='subject'>$subject</div>
<div class='teacher'>$teachers_list</div>
<div class='room'>$room</div>
</td>";
} else { } else {
echo "<td data-label='$d'></td>"; echo "<td data-label='$d'></td>";
} }
@@ -66,6 +89,6 @@ if ($res->num_rows === 0) {
} }
?> ?>
</table> </table>
<p style="text-align: center;">Copyright (C) 2025 EmmeV. All rights reserved.</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>
</body> </body>
</html> </html>