php — header.php<?php
echo "<h1>Tableau de bord du réseau</h1>";
echo "<hr>";
?>
php — footer.php<?php
echo "<hr>";
echo "<p>Administration réseau © 2026</p>";
?>
php — fonctions_reseau.php<?php
function estPortSecurise($port) {
return ($port == 22 || $port == 443);
}
function nomDuService($port) {
$services = [
21 => "FTP",
22 => "SSH",
23 => "Telnet",
25 => "SMTP",
80 => "HTTP",
443 => "HTTPS"
];
return $services[$port] ?? "Inconnu";
}
?>
php — index.php<?php
require 'fonctions_reseau.php'; // ← require : le site n'a aucun sens sans
include 'header.php';
$serveurs = [
["nom" => "SRV-WEB", "ip" => "192.168.0.10", "port" => 443],
["nom" => "SRV-FILE", "ip" => "192.168.0.11", "port" => 21],
["nom" => "SRV-ADM", "ip" => "192.168.0.12", "port" => 22],
["nom" => "SRV-OLD", "ip" => "192.168.0.13", "port" => 23]
];
echo "<table border='1'>";
echo "<tr><th>Serveur</th><th>IP</th><th>Port</th>"
. "<th>Service</th><th>Sécurisé</th></tr>";
foreach ($serveurs as $s) {
$securise = estPortSecurise($s["port"]) ? "Oui" : "Non";
echo "<tr>";
echo "<td>" . htmlspecialchars($s["nom"]) . "</td>";
echo "<td>" . htmlspecialchars($s["ip"]) . "</td>";
echo "<td>" . $s["port"] . "</td>";
echo "<td>" . nomDuService($s["port"]) . "</td>";
echo "<td>" . $securise . "</td>";
echo "</tr>";
}
echo "</table>";
include 'footer.php';
?>
résultatServeur IP Port Service Sécurisé
SRV-WEB 192.168.0.10 443 HTTPS Oui
SRV-FILE 192.168.0.11 21 FTP Non
SRV-ADM 192.168.0.12 22 SSH Oui
SRV-OLD 192.168.0.13 23 Telnet Non
🧰 Les trois choix qui font la note
require pour les fonctions, include pour le
header : sans les fonctions, la page n'a aucun sens — il faut qu'elle
s'arrête. Sans le header, elle reste lisible.
- L'opérateur
?? dans nomDuService : il
évite un avertissement « clé indéfinie » pour un port inconnu.
- L'écriture ternaire
condition ? "Oui" : "Non" :
un if…else en une ligne, très courant en PHP.
🌍 Ce que raconte ce tableau de bord
Deux serveurs sur quatre ne sont pas sécurisés : SRV-FILE en FTP et
SRV-OLD en Telnet. Ce sont exactement les protocoles qui font
circuler les identifiants en clair. Un vrai tableau de bord
d'administrateur sert précisément à faire ressortir cela d'un coup d'œil — et à
déclencher la migration vers SFTP et SSH.