Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
4614cd330c | |||
7d8760febb | |||
940426e45c | |||
78eb485ef7 | |||
060f05247a | |||
e5fb838445 | |||
72ca358139 | |||
0a3de8a846 |
16
Dockerfile
16
Dockerfile
@@ -1,16 +0,0 @@
|
||||
FROM php:8.2-apache
|
||||
RUN docker-php-ext-install mysqli pdo pdo_mysql
|
||||
COPY htdocs/ /var/www/html/
|
||||
COPY docker/php/config.php /var/www/html/config/config.php
|
||||
RUN apt-get update && apt-get install -y \
|
||||
unzip \
|
||||
curl \
|
||||
git \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||
RUN composer --version
|
||||
WORKDIR /var/www/html/admin
|
||||
RUN composer install --no-interaction
|
||||
RUN chown -R www-data:www-data /var/www/html
|
||||
RUN a2enmod rewrite
|
||||
EXPOSE 80
|
82
README.md
82
README.md
@@ -1,6 +1,3 @@
|
||||
## AVVISO IMPORTANTE
|
||||
Questo è il ramo di SVILUPPO. È inteso per testare le ultime funzionalità e aiutarmi nello sviluppo. La stabilità e il funzionamento del codice non sono garantiti. Usare a proprio rischio e pericolo.
|
||||
|
||||
# Orario Scuola
|
||||
Una piattaforma web per visualizzare gli orari scolastici delle classi, degli insegnanti e dei vari laboratori (se presenti)
|
||||
|
||||
@@ -53,71 +50,28 @@ C:\xampp\php\php.exe generate_hash.php <password>
|
||||
VALUES ('admin', '$2y$10$IS9v8CJNJnRXslV1NWDSquAjJ0GgU1sm6spBmGp6mjTLiNApfGcQi');
|
||||
```
|
||||
5. **Importa il file ``schema.sql`` nel tuo database MySQL**
|
||||
6. **Modifica il file ``config/config.php`` inserendo i valori richiesti**
|
||||
- Esempio file ``config/config.php``:
|
||||
6. **Modifica il file ``db.php`` cambiando l'host, il nome utente e la password (necessari per la connessione al database MySQL)**
|
||||
- Esempio:
|
||||
```php
|
||||
<?php
|
||||
// Impostazioni Database
|
||||
if (!defined('DB_HOST')) {
|
||||
define('DB_HOST', 'db');
|
||||
}
|
||||
if (!defined('DB_USER')) {
|
||||
define('DB_USER', 'orario');
|
||||
}
|
||||
if (!defined('DB_PASS')) {
|
||||
define('DB_PASS', 'orario');
|
||||
}
|
||||
if (!defined('DB_NAME')) {
|
||||
define('DB_NAME', 'school_timetable');
|
||||
}
|
||||
// Impostazioni sito generali
|
||||
if (!defined('APP_NAME')) {
|
||||
define('APP_NAME', 'Orario Scuola');
|
||||
}
|
||||
if (!defined('YEAR')) {
|
||||
define('YEAR', '2025/26');
|
||||
}
|
||||
// Impostazioni autenticazione dashboard amministrativa
|
||||
if (!defined('AUTH_TYPE')) {
|
||||
define('AUTH_TYPE','local'); // Può essere keycloak o local (integrata)
|
||||
}
|
||||
if (!defined('KEYCLOAK_DOMAIN')) {
|
||||
define('KEYCLOAK_DOMAIN','');
|
||||
}
|
||||
if (!defined('KEYCLOAK_REALM')) {
|
||||
define('KEYCLOAK_REALM','');
|
||||
}
|
||||
if (!defined('KEYCLOAK_CLIENT_ID')) {
|
||||
define('KEYCLOAK_CLIENT_ID','');
|
||||
}
|
||||
if (!defined('KEYCLOAK_CLIENT_SECRET')) {
|
||||
define('KEYCLOAK_CLIENT_SECRET','');
|
||||
}
|
||||
if (!defined('APP_DOMAIN')) {
|
||||
define('APP_DOMAIN','');
|
||||
}
|
||||
?>
|
||||
$host = "localhost";
|
||||
$user = "utente";
|
||||
$pass = "password123";
|
||||
```
|
||||
7. **Apri ``http://localhost`` e goditi il sito**
|
||||
|
||||
## Installazione con Docker
|
||||
NOTA: L'installazione con Docker è in fase di sviluppo attivo, quindi potrebbe non funzionare.
|
||||
1. Installa Docker
|
||||
```bash
|
||||
curl -fsSL https://get.docker.com | bash
|
||||
7. **Modifica ``admin/login.php`` e ``admin/logout.php`` con i dati di un'istanza keycloak. In caso tu voglia usare l'autenticazione via nome utente e password (e non keycloak), cancella quei due file e rinomina ``admin/login.php.backup`` in ``login.php`` e ``admin/logout.php.backup`` in ``logout.php``**
|
||||
- Esempio (``login.php`` con keycloak):
|
||||
```php
|
||||
$oidc = new OpenIDConnectClient(
|
||||
'https://keycloak.local/realms/master/',
|
||||
'orario', // Client ID Keycloak
|
||||
'abcdefghijklmnop' // Client secret Keycloak
|
||||
);
|
||||
$oidc->setRedirectURL('https://orario.local/admin/login.php'); // orario.local è il dominio base di questa piattaforma
|
||||
```
|
||||
2. Compila e crea il container:
|
||||
```bash
|
||||
git clone https://git.vichingo455.freeddns.org/emmev-code/orario
|
||||
cd orario
|
||||
git checkout dev # richiesto per passare alla versione di sviluppo
|
||||
docker compose up -d --build
|
||||
- Esempio (``logout.php`` con keycloak):
|
||||
```php
|
||||
header('Location: https://keycloak.local/realms/master/protocol/openid-connect/logout?post_logout_redirect_uri=https://orario.local&client_id=orario');
|
||||
```
|
||||
3. Il container dovrebbe diventare disponibile su ``http://localhost:8080``
|
||||
|
||||
### Per utenti Docker avanzati
|
||||
Se sei un utente Docker avanzato e vuoi personalizzare puoi modificare la configurazione di docker nei file ``docker/php/config.php``, ``docker-compose.yml`` e ``Dockerfile`` per adattare tutto al tuo ambiente.
|
||||
Per la maggior parte degli utenti consigliamo di usare la configurazione per Docker predefinita.
|
||||
8. **Apri ``http://localhost`` e goditi il sito**
|
||||
|
||||
## Licenza
|
||||
**Orario Scuola, Copyright (C) 2025 EmmeV.**
|
||||
|
@@ -1,23 +0,0 @@
|
||||
services:
|
||||
web:
|
||||
build: .
|
||||
container_name: orario-web
|
||||
ports:
|
||||
- "8080:80"
|
||||
depends_on:
|
||||
- db
|
||||
restart: unless-stopped
|
||||
db:
|
||||
image: mariadb:11
|
||||
container_name: orario-db
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: P@ssw0rd
|
||||
MYSQL_DATABASE: school_timetable
|
||||
MYSQL_USER: orario
|
||||
MYSQL_PASSWORD: orario
|
||||
volumes:
|
||||
- db_data:/var/lib/mysql
|
||||
- ./schema.sql:/docker-entrypoint-initdb.d/init.sql:ro
|
||||
volumes:
|
||||
db_data:
|
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
// Impostazioni Database
|
||||
if (!defined('DB_HOST')) {
|
||||
define('DB_HOST', 'db');
|
||||
}
|
||||
if (!defined('DB_USER')) {
|
||||
define('DB_USER', 'orario');
|
||||
}
|
||||
if (!defined('DB_PASS')) {
|
||||
define('DB_PASS', 'orario');
|
||||
}
|
||||
if (!defined('DB_NAME')) {
|
||||
define('DB_NAME', 'school_timetable');
|
||||
}
|
||||
// Impostazioni sito generali
|
||||
if (!defined('APP_NAME')) {
|
||||
define('APP_NAME', 'Orario Scuola');
|
||||
}
|
||||
if (!defined('YEAR')) {
|
||||
define('YEAR', '2025/26');
|
||||
}
|
||||
// Impostazioni autenticazione dashboard amministrativa
|
||||
if (!defined('AUTH_TYPE')) {
|
||||
define('AUTH_TYPE','local'); // Può essere keycloak o local (integrata)
|
||||
}
|
||||
if (!defined('KEYCLOAK_DOMAIN')) {
|
||||
define('KEYCLOAK_DOMAIN','');
|
||||
}
|
||||
if (!defined('KEYCLOAK_REALM')) {
|
||||
define('KEYCLOAK_REALM','');
|
||||
}
|
||||
if (!defined('KEYCLOAK_CLIENT_ID')) {
|
||||
define('KEYCLOAK_CLIENT_ID','');
|
||||
}
|
||||
if (!defined('KEYCLOAK_CLIENT_SECRET')) {
|
||||
define('KEYCLOAK_CLIENT_SECRET','');
|
||||
}
|
||||
if (!defined('APP_DOMAIN')) {
|
||||
define('APP_DOMAIN','');
|
||||
}
|
||||
?>
|
@@ -1 +0,0 @@
|
||||
These files are used by docker compose builder to create a working image in one command.
|
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
session_start();
|
||||
if (!isset($_SESSION['admin'])) { header("Location: login.php"); exit; }
|
||||
include("../lib/db.php");
|
||||
include("../db.php");
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['name'])) {
|
||||
$name = $_POST['name'];
|
||||
|
@@ -29,16 +29,7 @@ if (!isset($_SESSION['admin'])) {
|
||||
<a href="classes.php">Gestisci Classi</a>
|
||||
<a href="subjects.php">Gestisci Materie</a>
|
||||
<a href="timetable.php">Gestisci Orario</a>
|
||||
<?php
|
||||
if ($_SESSION['auth_type'] === 'local') {
|
||||
echo '<a href="password.php">Cambia Password</a>';
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
if ($_SESSION['auth_type'] === 'local' && $_SESSION['admin'] === 'admin') {
|
||||
echo '<a href="users.php">Gestisci Amministratori</a>';
|
||||
}
|
||||
?>
|
||||
<!--<a href="logout.php">Logout</a>-->
|
||||
</p>
|
||||
<p>
|
||||
Nota: Questa pagina si vede meglio da computer desktop. Se sei da computer, puoi ignorare questo messaggio.
|
||||
|
@@ -1,74 +1,18 @@
|
||||
<?php
|
||||
use Jumbojett\OpenIDConnectClient;
|
||||
require 'vendor/autoload.php';
|
||||
use Jumbojett\OpenIDConnectClient;
|
||||
session_start();
|
||||
include("../lib/db.php");
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST" && AUTH_TYPE == 'local') {
|
||||
$username = $_POST['username'];
|
||||
$password = $_POST['password'];
|
||||
$stmt = $conn->prepare("SELECT * FROM admin WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt->execute();
|
||||
$res = $stmt->get_result();
|
||||
if ($row = $res->fetch_assoc()) {
|
||||
if (password_verify($password, $row['password'])) {
|
||||
$_SESSION['admin'] = $row['username'];
|
||||
$_SESSION['auth_type'] = 'local';
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$error = "Credenziali non valide";
|
||||
}
|
||||
if (AUTH_TYPE == 'local') {
|
||||
echo <<<HTML
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Login Admin</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
// Configura il client Keycloak
|
||||
$oidc = new OpenIDConnectClient(
|
||||
'https://<KEYCLOAK_URL>/realms/<REALM>/',
|
||||
'<CLIENT_ID>',
|
||||
'<CLIENT_SECRET>'
|
||||
);
|
||||
// Redirect post-login
|
||||
$oidc->setRedirectURL('https://<APP_DOMAIN>/admin/login.php');
|
||||
|
||||
<div class="navbar">
|
||||
<div class="logo">Admin Dashboard</div>
|
||||
<div class="links">
|
||||
<a href="/">Torna al sito</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Container login -->
|
||||
<div class="login-container">
|
||||
<h1>Login Admin</h1>
|
||||
<form method="post">
|
||||
<input type="text" name="username" placeholder="Username" required><br>
|
||||
<input type="password" name="password" placeholder="Password" required><br>
|
||||
<button type="submit">Login</button>
|
||||
</form>
|
||||
HTML;
|
||||
if(isset($error)) echo "<br><div class='error'>$error</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>
|
||||
</body>
|
||||
</html>
|
||||
HTML;
|
||||
}
|
||||
else if (AUTH_TYPE === 'keycloak') {
|
||||
// Configura il client Keycloak
|
||||
$oidc = new OpenIDConnectClient(
|
||||
'https://' + KEYCLOAK_DOMAIN + '/realms/' + KEYCLOAK_REALM + '/',
|
||||
KEYCLOAK_CLIENT_ID,
|
||||
KEYCLOAK_CLIENT_SECRET
|
||||
);
|
||||
// Redirect post-login
|
||||
$oidc->setRedirectURL('https://' + APP_DOMAIN + '/admin/login.php');
|
||||
$oidc->authenticate();
|
||||
$userinfo = $oidc->getVerifiedClaims();
|
||||
$_SESSION['admin'] = $userinfo->preferred_username;
|
||||
$_SESSION['auth_type'] = 'keycloak';
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
$oidc->authenticate();
|
||||
$userinfo = $oidc->getVerifiedClaims();
|
||||
$_SESSION['admin'] = $userinfo->preferred_username;
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
|
50
htdocs/admin/login.php.backup
Normal file
50
htdocs/admin/login.php.backup
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
session_start();
|
||||
include("../db.php");
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
$username = $_POST['username'];
|
||||
$password = $_POST['password'];
|
||||
$stmt = $conn->prepare("SELECT * FROM admin WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt->execute();
|
||||
$res = $stmt->get_result();
|
||||
if ($row = $res->fetch_assoc()) {
|
||||
if (password_verify($password, $row['password'])) {
|
||||
$_SESSION['admin'] = $row['username'];
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$error = "Credenziali non valide";
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Login Admin</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="navbar">
|
||||
<div class="logo">Admin Dashboard</div>
|
||||
<div class="links">
|
||||
<a href="/">Torna al sito</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Container login -->
|
||||
<div class="login-container">
|
||||
<h1>Login Admin</h1>
|
||||
<?php if(isset($error)) echo "<div class='error'>$error</div>"; ?>
|
||||
<form method="post">
|
||||
<input type="text" name="username" placeholder="Username" required><br>
|
||||
<input type="password" name="password" placeholder="Password" required><br>
|
||||
<button type="submit">Login</button>
|
||||
</form>
|
||||
</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>
|
||||
</body>
|
||||
</html>
|
@@ -1,9 +1,5 @@
|
||||
<?php
|
||||
include("../config/config.php");
|
||||
session_start();
|
||||
session_destroy();
|
||||
if (AUTH_TYPE === 'local')
|
||||
header("Location: /index.php");
|
||||
else if (AUTH_TYPE === 'keycloak')
|
||||
header('Location: https://' + KEYCLOAK_DOMAIN + '/realms/' + KEYCLOAK_REALM + '/protocol/openid-connect/logout?post_logout_redirect_uri=https://' + APP_DOMAIN + '&client_id=' + KEYCLOAK_CLIENT_ID);
|
||||
?>
|
||||
header('Location: https://<KEYCLOAK_URL>/realms/<REALM>/protocol/openid-connect/logout?post_logout_redirect_uri=https://<APP_DOMAIN>&client_id=<CLIENT_ID>');
|
||||
exit;
|
||||
|
5
htdocs/admin/logout.php.backup
Normal file
5
htdocs/admin/logout.php.backup
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
session_start();
|
||||
session_destroy();
|
||||
header("Location: /index.php");
|
||||
?>
|
@@ -1,82 +0,0 @@
|
||||
<?php
|
||||
session_start();
|
||||
include("../lib/db.php");
|
||||
|
||||
if (!isset($_SESSION['admin']) || $_SESSION['auth_type'] != 'local') {
|
||||
header("Location: login.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$message = '';
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
$old = $_POST['old_password'];
|
||||
$new = $_POST['new_password'];
|
||||
$confirm = $_POST['confirm_password'];
|
||||
$user = $_SESSION['admin'];
|
||||
|
||||
if ($new !== $confirm) {
|
||||
$message = "Le nuove password non coincidono.";
|
||||
} else {
|
||||
// Recupera hash password attuale
|
||||
$stmt = $conn->prepare("SELECT password FROM admin WHERE username = ?");
|
||||
$stmt->bind_param("s", $user);
|
||||
$stmt->execute();
|
||||
$res = $stmt->get_result();
|
||||
$row = $res->fetch_assoc();
|
||||
|
||||
if ($row && password_verify($old, $row['password'])) {
|
||||
$newHash = password_hash($new, PASSWORD_DEFAULT);
|
||||
$stmt = $conn->prepare("UPDATE admin SET password = ? WHERE username = ?");
|
||||
$stmt->bind_param("ss", $newHash, $user);
|
||||
$stmt->execute();
|
||||
$message = "Password cambiata con successo.";
|
||||
} else {
|
||||
$message = "Password attuale errata.";
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Cambia Password</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="navbar">
|
||||
<div class="logo">Admin Dashboard</div>
|
||||
<div class="links">
|
||||
<a href="index.php">Dashboard</a>
|
||||
<a href="logout.php">Logout</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin-container">
|
||||
<h1>Cambia Password</h1>
|
||||
<a href="index.php" class="back-link">⬅ Torna al Dashboard</a>
|
||||
|
||||
<form method="POST">
|
||||
<label>Password attuale:<br>
|
||||
<input type="password" name="old_password" required>
|
||||
</label><br><br>
|
||||
|
||||
<label>Nuova password:<br>
|
||||
<input type="password" name="new_password" required>
|
||||
</label><br><br>
|
||||
|
||||
<label>Conferma nuova password:<br>
|
||||
<input type="password" name="confirm_password" required>
|
||||
</label><br><br>
|
||||
|
||||
<button type="submit">Cambia password</button>
|
||||
</form>
|
||||
<?php if ($message): ?>
|
||||
<p style="color:<?php echo strpos($message,'successo')!==false ? 'green':'red'; ?>;"><?php echo $message; ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
@@ -104,8 +104,7 @@ body {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.admin-container input[type="text"],
|
||||
.admin-container input[type="password"] {
|
||||
.admin-container input[type="text"] {
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 6px;
|
||||
@@ -337,7 +336,6 @@ body {
|
||||
|
||||
.admin-container form select,
|
||||
.admin-container form input[type="text"],
|
||||
.admin-container input[type="password"],
|
||||
.admin-container form button {
|
||||
width: 100%;
|
||||
margin: 5px 0;
|
||||
@@ -411,7 +409,6 @@ body {
|
||||
|
||||
.admin-container form select,
|
||||
.admin-container form input[type="text"],
|
||||
.admin-container input[type="password"],
|
||||
.admin-container form button {
|
||||
font-size: 0.95em;
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
session_start();
|
||||
if (!isset($_SESSION['admin'])) { header("Location: login.php"); exit; }
|
||||
include("../lib/db.php");
|
||||
include("../db.php");
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['name'])) {
|
||||
$name = $_POST['name'];
|
||||
@@ -47,44 +47,7 @@ if (isset($_GET['delete'])) {
|
||||
<input type="text" name="room" placeholder="Laboratorio (opzionale)">
|
||||
<button type="submit">Aggiungi</button>
|
||||
</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>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
@@ -101,10 +64,7 @@ if(isset($_GET['edit'])){
|
||||
<td>{$row['name']}</td>
|
||||
<td>{$row['teacher']}</td>
|
||||
<td>{$row['room']}</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>
|
||||
<td><a href='subjects.php?delete={$row['id']}' class='delete-link'>Elimina</a></td>
|
||||
</tr>";
|
||||
}
|
||||
?>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
session_start();
|
||||
if (!isset($_SESSION['admin'])) { header("Location: login.php"); exit; }
|
||||
include("../lib/db.php");
|
||||
// if (!isset($_SESSION['admin'])) { header("Location: login.php"); exit; }
|
||||
include("../db.php");
|
||||
|
||||
// --- Recupera tutte le materie ---
|
||||
$subjects = [];
|
||||
|
@@ -1,115 +0,0 @@
|
||||
<?php
|
||||
session_start();
|
||||
include("../lib/db.php");
|
||||
|
||||
if (!isset($_SESSION['admin']) || $_SESSION['auth_type'] != 'local' || $_SESSION['admin'] != 'admin') {
|
||||
header("Location: login.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$message = "";
|
||||
|
||||
// Add admin
|
||||
if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST['add_user'])) {
|
||||
$username = trim($_POST['username']);
|
||||
$password = $_POST['password'];
|
||||
|
||||
if (!empty($username) && !empty($password)) {
|
||||
$hash = password_hash($password, PASSWORD_DEFAULT);
|
||||
$stmt = $conn->prepare("INSERT INTO admin (username, password) VALUES (?, ?)");
|
||||
$stmt->bind_param("ss", $username, $hash);
|
||||
if ($stmt->execute()) {
|
||||
$message = "Utente admin aggiunto con successo.";
|
||||
} else {
|
||||
$message = "Errore durante l'aggiunta: " . $conn->error;
|
||||
}
|
||||
} else {
|
||||
$message = "Compila tutti i campi.";
|
||||
}
|
||||
}
|
||||
|
||||
// Delete admin
|
||||
if (isset($_GET['delete'])) {
|
||||
$id = intval($_GET['delete']);
|
||||
if ($id != 1) { // proteggi super admin
|
||||
$stmt = $conn->prepare("DELETE FROM admin WHERE id = ?");
|
||||
$stmt->bind_param("i", $id);
|
||||
$stmt->execute();
|
||||
$message = "Utente admin rimosso.";
|
||||
} else {
|
||||
$message = "Non puoi eliminare il super admin.";
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch admins
|
||||
$result = $conn->query("SELECT id, username FROM admin ORDER BY id ASC");
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Gestione Admin</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="navbar">
|
||||
<div class="logo">Admin Dashboard</div>
|
||||
<div class="links">
|
||||
<a href="index.php">Dashboard</a>
|
||||
<a href="logout.php">Logout</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin-container">
|
||||
<h1>Gestione Amministratori</h1>
|
||||
<a href="index.php" class="back-link">⬅ Torna al Dashboard</a>
|
||||
|
||||
<?php if ($message): ?>
|
||||
<p style="color:<?php echo strpos($message,'successo')!==false ? 'green':'red'; ?>;">
|
||||
<?php echo htmlspecialchars($message); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<h2>Utenti Attivi</h2>
|
||||
<table border="1" cellspacing="0" cellpadding="6" width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Username</th>
|
||||
<th>Azione</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php while ($row = $result->fetch_assoc()): ?>
|
||||
<tr>
|
||||
<td><?php echo $row['id']; ?></td>
|
||||
<td><?php echo htmlspecialchars($row['username']); ?></td>
|
||||
<td>
|
||||
<?php if ($row['id'] != 1): ?>
|
||||
<a href="?delete=<?php echo $row['id']; ?>"
|
||||
onclick="return confirm('Vuoi davvero eliminare questo amministratore?')"
|
||||
style="color:red;">Elimina</a>
|
||||
<?php else: ?>
|
||||
<em>Super Admin</em>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endwhile; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h2>Aggiungi Nuovo Admin</h2>
|
||||
<form method="POST">
|
||||
<label>Username:<br>
|
||||
<input type="text" name="username" required>
|
||||
</label><br><br>
|
||||
<label>Password:<br>
|
||||
<input type="password" name="password" required>
|
||||
</label><br><br>
|
||||
<button type="submit" name="add_user">Aggiungi</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
// Impostazioni Database
|
||||
if (!defined('DB_HOST')) {
|
||||
define('DB_HOST', '<MYSQL_HOST>'); // Host del database (ad esempio localhost)
|
||||
}
|
||||
if (!defined('DB_USER')) {
|
||||
define('DB_USER', '<MYSQL_USER>'); // Utente del database (ad esempio orario)
|
||||
}
|
||||
if (!defined('DB_PASS')) {
|
||||
define('DB_PASS', '<MYSQL_PASSWORD>'); // Password dell'utente specificato prima (ad esempio password123)
|
||||
}
|
||||
if (!defined('DB_NAME')) {
|
||||
define('DB_NAME', 'school_timetable'); // Nome del database, non modificare se non sai cosa stai facendo.
|
||||
}
|
||||
// Impostazioni sito generali
|
||||
if (!defined('APP_NAME')) {
|
||||
define('APP_NAME', 'Orario Scuola'); // Nome del sito
|
||||
}
|
||||
if (!defined('YEAR')) {
|
||||
define('YEAR', '2025/26'); // Anno Scolastico Corrente
|
||||
}
|
||||
// Impostazioni autenticazione dashboard amministrativa
|
||||
if (!defined('AUTH_TYPE')) {
|
||||
define('AUTH_TYPE','local'); // Può essere keycloak o local (integrata)
|
||||
}
|
||||
// Impostazioni autenticazione via Keycloak (facoltative se AUTH_TYPE sta impostato su local)
|
||||
if (!defined('KEYCLOAK_DOMAIN')) {
|
||||
define('KEYCLOAK_DOMAIN',''); // Dominio di Keycloak (ad esempio auth.yourdomain.com)
|
||||
}
|
||||
if (!defined('KEYCLOAK_REALM')) {
|
||||
define('KEYCLOAK_REALM',''); // Realm di Keycloak (ad esempio master)
|
||||
}
|
||||
if (!defined('KEYCLOAK_CLIENT_ID')) {
|
||||
define('KEYCLOAK_CLIENT_ID',''); // Client ID per Keycloak (ad esempio orario)
|
||||
}
|
||||
if (!defined('KEYCLOAK_CLIENT_SECRET')) {
|
||||
define('KEYCLOAK_CLIENT_SECRET',''); // Client Secret per Keycloak (ad esempio abcdefghijklm)
|
||||
}
|
||||
if (!defined('APP_DOMAIN')) {
|
||||
define('APP_DOMAIN',''); // Dominio del sito (ad esempio orario.yourdomain.com)
|
||||
}
|
||||
?>
|
@@ -106,115 +106,62 @@ td:hover {
|
||||
td { padding-left: 50%; }
|
||||
}
|
||||
*/
|
||||
|
||||
/* --- tuoi stili desktop (questi restano uguali) --- */
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
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;
|
||||
table, thead, tbody, th, td, tr {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
tr {
|
||||
margin-bottom: 20px;
|
||||
background: #fff;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 6px rgba(0,0,0,0.08);
|
||||
overflow: hidden;
|
||||
padding: 10px;
|
||||
margin-bottom: 15px;
|
||||
padding: 0;
|
||||
border-bottom: 2px solid #ddd;
|
||||
}
|
||||
|
||||
th {
|
||||
display: none;
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 8px 8px 8px 50%;
|
||||
position: relative;
|
||||
padding-left: 50%;
|
||||
text-align: left;
|
||||
border: none;
|
||||
border-bottom: 1px solid #eee;
|
||||
font-size: 0.9em;
|
||||
min-height: 50px; /* ensures consistent vertical spacing */
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
td::before {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
left: 10px;
|
||||
color: #1f618d;
|
||||
font-size: 0.85em;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
width: 40%;
|
||||
font-weight: bold;
|
||||
white-space: nowrap;
|
||||
content: attr(data-label);
|
||||
}
|
||||
|
||||
td > .subject {
|
||||
font-weight: 600;
|
||||
font-size: 1em;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
td > .teacher {
|
||||
font-size: 0.85em;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
/* make content stack nicely */
|
||||
td > .subject,
|
||||
td > .teacher,
|
||||
td > .room {
|
||||
font-size: 0.75em;
|
||||
color: #888;
|
||||
display: block;
|
||||
margin: 2px 0;
|
||||
}
|
||||
|
||||
td:last-child {
|
||||
border-bottom: none;
|
||||
border-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Extra small screens */
|
||||
@media (max-width: 480px) {
|
||||
td {
|
||||
padding-left: 45%;
|
||||
padding-left: 55%;
|
||||
}
|
||||
td::before {
|
||||
width: 40%;
|
||||
font-size: 0.8em;
|
||||
width: 45%;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,9 +1,8 @@
|
||||
<?php
|
||||
include_once __DIR__ . '/../config/config.php';
|
||||
$host = DB_HOST;
|
||||
$user = DB_USER;
|
||||
$pass = DB_PASS;
|
||||
$dbname = DB_NAME;
|
||||
$host = "<MYSQL_HOST>";
|
||||
$user = "<MYSQL_USER>";
|
||||
$pass = "<MYSQL_PASSWORD>";
|
||||
$dbname = "school_timetable";
|
||||
|
||||
$conn = new mysqli($host, $user, $pass, $dbname);
|
||||
if ($conn->connect_error) {
|
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
include("lib/db.php");
|
||||
include("db.php");
|
||||
$teacher = $_GET['teacher'];
|
||||
$days = ["Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato"];
|
||||
$hours = [
|
||||
@@ -11,8 +11,8 @@ $hours = [
|
||||
6 => "Sesta ora<br>12:50 - 13:50"
|
||||
];
|
||||
if ($teacher == "No Lezione" || $teacher == "sconosciuto") {
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
else if (!isset($_GET['teacher'])) {
|
||||
header("Location: index.php");
|
||||
@@ -23,6 +23,7 @@ $teacher = $conn->real_escape_string($_GET['teacher']);
|
||||
$res = $conn->query("SELECT DISTINCT teacher FROM subjects WHERE teacher = '$teacher' LIMIT 1");
|
||||
|
||||
if ($res->num_rows === 0) {
|
||||
// Insegnante non trovato
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
@@ -37,7 +38,7 @@ if ($res->num_rows === 0) {
|
||||
</head>
|
||||
<body>
|
||||
<div class="navbar">
|
||||
<div class="logo"><?php echo APP_NAME; ?> <?php echo YEAR; ?></div>
|
||||
<div class="logo">Orario Scuola 2025/26</div>
|
||||
<div class="links">
|
||||
<a href="index.php">Home</a>
|
||||
</div>
|
||||
|
@@ -1,24 +1,24 @@
|
||||
<?php
|
||||
include("lib/db.php");
|
||||
include("db.php");
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title><?php echo APP_NAME; ?> - A.S. <?php echo YEAR; ?></title>
|
||||
<title>Orario - A.S. 2025/26</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="css/home.css">
|
||||
<link rel="stylesheet" href="css/navbar.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="navbar">
|
||||
<div class="logo"><?php echo APP_NAME; ?> <?php echo YEAR; ?></div>
|
||||
<div class="logo">Orario Scuola 2025/26</div>
|
||||
<div class="links">
|
||||
<a href="index.php">Home</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>
|
||||
<h1><?php echo APP_NAME; ?> - A.S. <?php echo YEAR; ?></h1>
|
||||
<h1>Orario - a.s. 2025/26</h1>
|
||||
|
||||
<!-- Sezione Classi -->
|
||||
<h2>Classi</h2>
|
||||
@@ -66,6 +66,6 @@ while($row = $res->fetch_assoc()){
|
||||
?>
|
||||
</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>
|
||||
<p style="text-align: center;">Copyright (C) 2025 EmmeV. - Released under GNU AGPL 3.0 License.</p>
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
include("lib/db.php");
|
||||
include("db.php");
|
||||
$room = $_GET['room']; // aula selezionata
|
||||
$days = ["Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato"];
|
||||
$hours = [
|
||||
@@ -34,7 +34,7 @@ if ($res->num_rows === 0) {
|
||||
</head>
|
||||
<body>
|
||||
<div class="navbar">
|
||||
<div class="logo"><?php echo APP_NAME; ?> <?php echo YEAR; ?></div>
|
||||
<div class="logo">Orario Scuola 2025/26</div>
|
||||
<div class="links">
|
||||
<a href="index.php">Home</a>
|
||||
</div>
|
||||
@@ -60,31 +60,11 @@ if ($res->num_rows === 0) {
|
||||
WHERE subjects.room='". $conn->real_escape_string($room) ."'
|
||||
AND timetable.day='$d' AND timetable.hour=$hnum
|
||||
");
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
if($row = $q->fetch_assoc()){
|
||||
echo "<td data-label='$d'>
|
||||
<div class='subject'>$subject</div>
|
||||
<div class='room'>$entries_list</div>
|
||||
<div class='subject'>{$row['subject_name']}</div>
|
||||
<div class='teacher'>{$row['teacher']}</div>
|
||||
<div class='room'>{$row['class_name']}</div>
|
||||
</td>";
|
||||
} else {
|
||||
echo "<td data-label='$d'></td>";
|
||||
@@ -94,6 +74,6 @@ if ($res->num_rows === 0) {
|
||||
}
|
||||
?>
|
||||
</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>
|
||||
</html>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
include("lib/db.php");
|
||||
include("db.php");
|
||||
$class_id = intval($_GET['class_id']);
|
||||
$class = $conn->query("SELECT * FROM classes WHERE id=$class_id")->fetch_assoc();
|
||||
$days = ["Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato"];
|
||||
@@ -35,7 +35,7 @@ if ($res->num_rows === 0) {
|
||||
</head>
|
||||
<body>
|
||||
<div class="navbar">
|
||||
<div class="logo"><?php echo APP_NAME; ?> <?php echo YEAR; ?></div>
|
||||
<div class="logo">Orario Scuola 2025/26</div>
|
||||
<div class="links">
|
||||
<a href="index.php">Home</a>
|
||||
</div>
|
||||
@@ -54,33 +54,10 @@ if ($res->num_rows === 0) {
|
||||
FROM timetable
|
||||
LEFT JOIN subjects ON timetable.subject_id = subjects.id
|
||||
WHERE class_id=$class_id AND day='$d' AND hour=$hnum");
|
||||
|
||||
if($q->num_rows > 0){
|
||||
$row = $q->fetch_assoc();
|
||||
$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>";
|
||||
if($row = $q->fetch_assoc()){
|
||||
echo "<td data-label='$d'><div class='subject'>{$row['name']}</div>
|
||||
<div class='teacher'>{$row['teacher']}</div>
|
||||
<div class='room'>{$row['room']}</div></td>";
|
||||
} else {
|
||||
echo "<td data-label='$d'></td>";
|
||||
}
|
||||
|
Reference in New Issue
Block a user