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
|
# Orario Scuola
|
||||||
Una piattaforma web per visualizzare gli orari scolastici delle classi, degli insegnanti e dei vari laboratori (se presenti)
|
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');
|
VALUES ('admin', '$2y$10$IS9v8CJNJnRXslV1NWDSquAjJ0GgU1sm6spBmGp6mjTLiNApfGcQi');
|
||||||
```
|
```
|
||||||
5. **Importa il file ``schema.sql`` nel tuo database MySQL**
|
5. **Importa il file ``schema.sql`` nel tuo database MySQL**
|
||||||
6. **Modifica il file ``config/config.php`` inserendo i valori richiesti**
|
6. **Modifica il file ``db.php`` cambiando l'host, il nome utente e la password (necessari per la connessione al database MySQL)**
|
||||||
- Esempio file ``config/config.php``:
|
- Esempio:
|
||||||
```php
|
```php
|
||||||
<?php
|
$host = "localhost";
|
||||||
// Impostazioni Database
|
$user = "utente";
|
||||||
if (!defined('DB_HOST')) {
|
$pass = "password123";
|
||||||
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','');
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
```
|
```
|
||||||
7. **Apri ``http://localhost`` e goditi il sito**
|
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):
|
||||||
## Installazione con Docker
|
```php
|
||||||
NOTA: L'installazione con Docker è in fase di sviluppo attivo, quindi potrebbe non funzionare.
|
$oidc = new OpenIDConnectClient(
|
||||||
1. Installa Docker
|
'https://keycloak.local/realms/master/',
|
||||||
```bash
|
'orario', // Client ID Keycloak
|
||||||
curl -fsSL https://get.docker.com | bash
|
'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:
|
- Esempio (``logout.php`` con keycloak):
|
||||||
```bash
|
```php
|
||||||
git clone https://git.vichingo455.freeddns.org/emmev-code/orario
|
header('Location: https://keycloak.local/realms/master/protocol/openid-connect/logout?post_logout_redirect_uri=https://orario.local&client_id=orario');
|
||||||
cd orario
|
|
||||||
git checkout dev # richiesto per passare alla versione di sviluppo
|
|
||||||
docker compose up -d --build
|
|
||||||
```
|
```
|
||||||
3. Il container dovrebbe diventare disponibile su ``http://localhost:8080``
|
8. **Apri ``http://localhost`` e goditi il sito**
|
||||||
|
|
||||||
### 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.
|
|
||||||
|
|
||||||
## Licenza
|
## Licenza
|
||||||
**Orario Scuola, Copyright (C) 2025 EmmeV.**
|
**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
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
if (!isset($_SESSION['admin'])) { header("Location: login.php"); exit; }
|
if (!isset($_SESSION['admin'])) { header("Location: login.php"); exit; }
|
||||||
include("../lib/db.php");
|
include("../db.php");
|
||||||
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['name'])) {
|
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['name'])) {
|
||||||
$name = $_POST['name'];
|
$name = $_POST['name'];
|
||||||
|
@@ -29,16 +29,7 @@ if (!isset($_SESSION['admin'])) {
|
|||||||
<a href="classes.php">Gestisci Classi</a>
|
<a href="classes.php">Gestisci Classi</a>
|
||||||
<a href="subjects.php">Gestisci Materie</a>
|
<a href="subjects.php">Gestisci Materie</a>
|
||||||
<a href="timetable.php">Gestisci Orario</a>
|
<a href="timetable.php">Gestisci Orario</a>
|
||||||
<?php
|
<!--<a href="logout.php">Logout</a>-->
|
||||||
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>';
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</p>
|
</p>
|
||||||
<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.
|
||||||
|
@@ -1,74 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
use Jumbojett\OpenIDConnectClient;
|
|
||||||
require 'vendor/autoload.php';
|
require 'vendor/autoload.php';
|
||||||
|
use Jumbojett\OpenIDConnectClient;
|
||||||
session_start();
|
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>
|
|
||||||
|
|
||||||
<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
|
// Configura il client Keycloak
|
||||||
$oidc = new OpenIDConnectClient(
|
$oidc = new OpenIDConnectClient(
|
||||||
'https://' + KEYCLOAK_DOMAIN + '/realms/' + KEYCLOAK_REALM + '/',
|
'https://<KEYCLOAK_URL>/realms/<REALM>/',
|
||||||
KEYCLOAK_CLIENT_ID,
|
'<CLIENT_ID>',
|
||||||
KEYCLOAK_CLIENT_SECRET
|
'<CLIENT_SECRET>'
|
||||||
);
|
);
|
||||||
// Redirect post-login
|
// Redirect post-login
|
||||||
$oidc->setRedirectURL('https://' + APP_DOMAIN + '/admin/login.php');
|
$oidc->setRedirectURL('https://<APP_DOMAIN>/admin/login.php');
|
||||||
|
|
||||||
$oidc->authenticate();
|
$oidc->authenticate();
|
||||||
$userinfo = $oidc->getVerifiedClaims();
|
$userinfo = $oidc->getVerifiedClaims();
|
||||||
$_SESSION['admin'] = $userinfo->preferred_username;
|
$_SESSION['admin'] = $userinfo->preferred_username;
|
||||||
$_SESSION['auth_type'] = 'keycloak';
|
|
||||||
header("Location: index.php");
|
header("Location: index.php");
|
||||||
exit;
|
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
|
<?php
|
||||||
include("../config/config.php");
|
|
||||||
session_start();
|
session_start();
|
||||||
session_destroy();
|
session_destroy();
|
||||||
if (AUTH_TYPE === 'local')
|
header('Location: https://<KEYCLOAK_URL>/realms/<REALM>/protocol/openid-connect/logout?post_logout_redirect_uri=https://<APP_DOMAIN>&client_id=<CLIENT_ID>');
|
||||||
header("Location: /index.php");
|
exit;
|
||||||
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);
|
|
||||||
?>
|
|
||||||
|
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;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-container input[type="text"],
|
.admin-container input[type="text"] {
|
||||||
.admin-container input[type="password"] {
|
|
||||||
padding: 8px 12px;
|
padding: 8px 12px;
|
||||||
border: 1px solid #ccc;
|
border: 1px solid #ccc;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
@@ -337,7 +336,6 @@ body {
|
|||||||
|
|
||||||
.admin-container form select,
|
.admin-container form select,
|
||||||
.admin-container form input[type="text"],
|
.admin-container form input[type="text"],
|
||||||
.admin-container input[type="password"],
|
|
||||||
.admin-container form button {
|
.admin-container form button {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin: 5px 0;
|
margin: 5px 0;
|
||||||
@@ -411,7 +409,6 @@ body {
|
|||||||
|
|
||||||
.admin-container form select,
|
.admin-container form select,
|
||||||
.admin-container form input[type="text"],
|
.admin-container form input[type="text"],
|
||||||
.admin-container input[type="password"],
|
|
||||||
.admin-container form button {
|
.admin-container form button {
|
||||||
font-size: 0.95em;
|
font-size: 0.95em;
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
if (!isset($_SESSION['admin'])) { header("Location: login.php"); exit; }
|
if (!isset($_SESSION['admin'])) { header("Location: login.php"); exit; }
|
||||||
include("../lib/db.php");
|
include("../db.php");
|
||||||
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['name'])) {
|
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['name'])) {
|
||||||
$name = $_POST['name'];
|
$name = $_POST['name'];
|
||||||
@@ -47,44 +47,7 @@ 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>
|
||||||
@@ -101,10 +64,7 @@ if(isset($_GET['edit'])){
|
|||||||
<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>
|
<td><a href='subjects.php?delete={$row['id']}' class='delete-link'>Elimina</a></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>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
if (!isset($_SESSION['admin'])) { header("Location: login.php"); exit; }
|
// if (!isset($_SESSION['admin'])) { header("Location: login.php"); exit; }
|
||||||
include("../lib/db.php");
|
include("../db.php");
|
||||||
|
|
||||||
// --- Recupera tutte le materie ---
|
// --- Recupera tutte le materie ---
|
||||||
$subjects = [];
|
$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%; }
|
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) {
|
@media (max-width: 768px) {
|
||||||
table {
|
table, thead, tbody, th, td, tr {
|
||||||
box-shadow: none;
|
display: block;
|
||||||
border-radius: 0;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
tr {
|
tr {
|
||||||
margin-bottom: 20px;
|
margin-bottom: 15px;
|
||||||
background: #fff;
|
padding: 0;
|
||||||
border-radius: 8px;
|
border-bottom: 2px solid #ddd;
|
||||||
box-shadow: 0 2px 6px rgba(0,0,0,0.08);
|
}
|
||||||
overflow: hidden;
|
|
||||||
padding: 10px;
|
th {
|
||||||
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
td {
|
td {
|
||||||
padding: 8px 8px 8px 50%;
|
position: relative;
|
||||||
|
padding-left: 50%;
|
||||||
|
text-align: left;
|
||||||
border: none;
|
border: none;
|
||||||
border-bottom: 1px solid #eee;
|
border-bottom: 1px solid #eee;
|
||||||
font-size: 0.9em;
|
min-height: 50px; /* ensures consistent vertical spacing */
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
td::before {
|
td::before {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 10px;
|
top: 10px;
|
||||||
left: 10px;
|
left: 10px;
|
||||||
color: #1f618d;
|
width: 40%;
|
||||||
font-size: 0.85em;
|
font-weight: bold;
|
||||||
text-transform: uppercase;
|
white-space: nowrap;
|
||||||
letter-spacing: 0.5px;
|
|
||||||
content: attr(data-label);
|
content: attr(data-label);
|
||||||
}
|
}
|
||||||
|
|
||||||
td > .subject {
|
/* make content stack nicely */
|
||||||
font-weight: 600;
|
td > .subject,
|
||||||
font-size: 1em;
|
td > .teacher,
|
||||||
margin-bottom: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
td > .teacher {
|
|
||||||
font-size: 0.85em;
|
|
||||||
color: #555;
|
|
||||||
}
|
|
||||||
|
|
||||||
td > .room {
|
td > .room {
|
||||||
font-size: 0.75em;
|
display: block;
|
||||||
color: #888;
|
margin: 2px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
td:last-child {
|
td:last-child {
|
||||||
border-bottom: none;
|
border-bottom: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Extra small screens */
|
||||||
@media (max-width: 480px) {
|
@media (max-width: 480px) {
|
||||||
td {
|
td {
|
||||||
padding-left: 45%;
|
padding-left: 55%;
|
||||||
}
|
}
|
||||||
td::before {
|
td::before {
|
||||||
width: 40%;
|
width: 45%;
|
||||||
font-size: 0.8em;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,9 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
include_once __DIR__ . '/../config/config.php';
|
$host = "<MYSQL_HOST>";
|
||||||
$host = DB_HOST;
|
$user = "<MYSQL_USER>";
|
||||||
$user = DB_USER;
|
$pass = "<MYSQL_PASSWORD>";
|
||||||
$pass = DB_PASS;
|
$dbname = "school_timetable";
|
||||||
$dbname = DB_NAME;
|
|
||||||
|
|
||||||
$conn = new mysqli($host, $user, $pass, $dbname);
|
$conn = new mysqli($host, $user, $pass, $dbname);
|
||||||
if ($conn->connect_error) {
|
if ($conn->connect_error) {
|
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
include("lib/db.php");
|
include("db.php");
|
||||||
$teacher = $_GET['teacher'];
|
$teacher = $_GET['teacher'];
|
||||||
$days = ["Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato"];
|
$days = ["Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato"];
|
||||||
$hours = [
|
$hours = [
|
||||||
@@ -23,6 +23,7 @@ $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;
|
||||||
}
|
}
|
||||||
@@ -37,7 +38,7 @@ if ($res->num_rows === 0) {
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="navbar">
|
<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">
|
<div class="links">
|
||||||
<a href="index.php">Home</a>
|
<a href="index.php">Home</a>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -1,24 +1,24 @@
|
|||||||
<?php
|
<?php
|
||||||
include("lib/db.php");
|
include("db.php");
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<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">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link rel="stylesheet" href="css/home.css">
|
<link rel="stylesheet" href="css/home.css">
|
||||||
<link rel="stylesheet" href="css/navbar.css">
|
<link rel="stylesheet" href="css/navbar.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="navbar">
|
<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">
|
<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>
|
<a href="https://git.vichingo455.freeddns.org/emmev-code/orario" target="_blank">Codice sorgente</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<h1><?php echo APP_NAME; ?> - A.S. <?php echo YEAR; ?></h1>
|
<h1>Orario - a.s. 2025/26</h1>
|
||||||
|
|
||||||
<!-- Sezione Classi -->
|
<!-- Sezione Classi -->
|
||||||
<h2>Classi</h2>
|
<h2>Classi</h2>
|
||||||
@@ -66,6 +66,6 @@ while($row = $res->fetch_assoc()){
|
|||||||
?>
|
?>
|
||||||
</div>
|
</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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
include("lib/db.php");
|
include("db.php");
|
||||||
$room = $_GET['room']; // aula selezionata
|
$room = $_GET['room']; // aula selezionata
|
||||||
$days = ["Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato"];
|
$days = ["Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato"];
|
||||||
$hours = [
|
$hours = [
|
||||||
@@ -34,7 +34,7 @@ if ($res->num_rows === 0) {
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="navbar">
|
<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">
|
<div class="links">
|
||||||
<a href="index.php">Home</a>
|
<a href="index.php">Home</a>
|
||||||
</div>
|
</div>
|
||||||
@@ -60,31 +60,11 @@ 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'>$subject</div>
|
<div class='subject'>{$row['subject_name']}</div>
|
||||||
<div class='room'>$entries_list</div>
|
<div class='teacher'>{$row['teacher']}</div>
|
||||||
|
<div class='room'>{$row['class_name']}</div>
|
||||||
</td>";
|
</td>";
|
||||||
} else {
|
} else {
|
||||||
echo "<td data-label='$d'></td>";
|
echo "<td data-label='$d'></td>";
|
||||||
@@ -94,6 +74,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>
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
include("lib/db.php");
|
include("db.php");
|
||||||
$class_id = intval($_GET['class_id']);
|
$class_id = intval($_GET['class_id']);
|
||||||
$class = $conn->query("SELECT * FROM classes WHERE id=$class_id")->fetch_assoc();
|
$class = $conn->query("SELECT * FROM classes WHERE id=$class_id")->fetch_assoc();
|
||||||
$days = ["Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato"];
|
$days = ["Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato"];
|
||||||
@@ -35,7 +35,7 @@ if ($res->num_rows === 0) {
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="navbar">
|
<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">
|
<div class="links">
|
||||||
<a href="index.php">Home</a>
|
<a href="index.php">Home</a>
|
||||||
</div>
|
</div>
|
||||||
@@ -54,33 +54,10 @@ 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()){
|
||||||
if($q->num_rows > 0){
|
echo "<td data-label='$d'><div class='subject'>{$row['name']}</div>
|
||||||
$row = $q->fetch_assoc();
|
<div class='teacher'>{$row['teacher']}</div>
|
||||||
$subject = $row['name'];
|
<div class='room'>{$row['room']}</div></td>";
|
||||||
$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>";
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user