Compare commits
9 Commits
a4b1e5bdea
...
4f7b1715f7
Author | SHA1 | Date | |
---|---|---|---|
4f7b1715f7 | |||
4aed96037d | |||
17f93a6846 | |||
d80bccf34d | |||
8be07a291c | |||
b499bb1be0 | |||
f82aa4c734 | |||
3383d1b614 | |||
1a9410c7b0 |
1
.gitignore
vendored
Executable file
1
.gitignore
vendored
Executable file
@ -0,0 +1 @@
|
||||
config_db.php
|
28
400.php
Executable file
28
400.php
Executable file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
header("HTTP/1.1 400 Bad Request");
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>TablIP - Erreur</title>
|
||||
<link rel="stylesheet" href="css/style.css"/>
|
||||
<link rel="stylesheet" href="css/icons.css"/>
|
||||
<link rel="stylesheet" href="css/materialize.css"/>
|
||||
<script type="text/javascript" src="js/script.js"></script>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript" src="js/materialize.js"></script>
|
||||
<header>
|
||||
<nav class="nav-wrapper navbar-fixed teal lighten-2">
|
||||
<div class="container">
|
||||
<a href="." class="breadcrumb">TablIP</a>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
<div class="container">
|
||||
<h4>Erreur</h4>
|
||||
<p>Données requises non reçues</p>
|
||||
<a class="waves-effect waves-light btn" href='javascript:history.back(1);'><i class="material-icons left">arrow_back</i>Retour</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
28
404.php
Executable file
28
404.php
Executable file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
header("HTTP/1.1 404 Not Found");
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>TablIP - Erreur</title>
|
||||
<link rel="stylesheet" href="css/style.css"/>
|
||||
<link rel="stylesheet" href="css/icons.css"/>
|
||||
<link rel="stylesheet" href="css/materialize.css"/>
|
||||
<script type="text/javascript" src="js/script.js"></script>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript" src="js/materialize.js"></script>
|
||||
<header>
|
||||
<nav class="nav-wrapper navbar-fixed teal lighten-2">
|
||||
<div class="container">
|
||||
<a href="." class="breadcrumb">TablIP</a>
|
||||
<div class="container">
|
||||
</nav>
|
||||
</header>
|
||||
<div class="container">
|
||||
<h4>Erreur</h4>
|
||||
<p>La ressource demandée n'a pas été trouvée</p>
|
||||
<a class="waves-effect waves-light btn" href='javascript:history.back(1);'><i class="material-icons left">arrow_back</i>Retour</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
28
500.php
Executable file
28
500.php
Executable file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
header("HTTP/1.1 500 Internal Server Error");
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>TablIP - Erreur</title>
|
||||
<link rel="stylesheet" href="css/style.css"/>
|
||||
<link rel="stylesheet" href="css/icons.css"/>
|
||||
<link rel="stylesheet" href="css/materialize.css"/>
|
||||
<script type="text/javascript" src="js/script.js"></script>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript" src="js/materialize.js"></script>
|
||||
<header>
|
||||
<nav class="nav-wrapper navbar-fixed teal lighten-2">
|
||||
<div class="container">
|
||||
<a href="." class="breadcrumb">TablIP</a>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
<div class="container">
|
||||
<h4>Erreur</h4>
|
||||
<p>Problème côté serveur</p>
|
||||
<a class="waves-effect waves-light btn" href='javascript:history.back(1);'><i class="material-icons left">arrow_back</i>Retour</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
156
TablIP.sql
Executable file
156
TablIP.sql
Executable file
@ -0,0 +1,156 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 5.1.1
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Hôte : localhost
|
||||
-- Généré le : lun. 27 sep. 2021 à 04:11
|
||||
-- Version du serveur : 10.3.29-MariaDB-0+deb10u1
|
||||
-- Version de PHP : 7.3.30-1+0~20210826.87+debian10~1.gbpe56a7b
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
START TRANSACTION;
|
||||
SET time_zone = "+00:00";
|
||||
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8mb4 */;
|
||||
|
||||
--
|
||||
-- Base de données : `TablIP`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `Hosts`
|
||||
--
|
||||
|
||||
CREATE TABLE `Hosts` (
|
||||
`IPAddress` bit(32) NOT NULL,
|
||||
`NetworkId` int(11) NOT NULL,
|
||||
`Hostname` varchar(255) NOT NULL DEFAULT '',
|
||||
`FQDN` varchar(255) NOT NULL DEFAULT '',
|
||||
`MacAddress` varchar(17) NOT NULL DEFAULT '',
|
||||
`Link` varchar(255) NOT NULL DEFAULT '',
|
||||
`Comments` varchar(255) NOT NULL DEFAULT ''
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `Networks`
|
||||
--
|
||||
|
||||
CREATE TABLE `Networks` (
|
||||
`id` int(11) NOT NULL,
|
||||
`Name` varchar(255) NOT NULL,
|
||||
`Address` bit(32) NOT NULL,
|
||||
`Mask` bit(32) NOT NULL,
|
||||
`SiteId` int(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `Sites`
|
||||
--
|
||||
|
||||
CREATE TABLE `Sites` (
|
||||
`id` int(11) NOT NULL,
|
||||
`Name` varchar(255) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `Users`
|
||||
--
|
||||
|
||||
CREATE TABLE `Users` (
|
||||
`id` int(11) NOT NULL,
|
||||
`login` varchar(255) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `UserSites`
|
||||
--
|
||||
|
||||
CREATE TABLE `UserSites` (
|
||||
`id` int(11) NOT NULL,
|
||||
`UserId` int(11) NOT NULL,
|
||||
`SiteId` int(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Index pour les tables déchargées
|
||||
--
|
||||
|
||||
--
|
||||
-- Index pour la table `Hosts`
|
||||
--
|
||||
ALTER TABLE `Hosts`
|
||||
ADD PRIMARY KEY (`IPAddress`),
|
||||
ADD UNIQUE KEY `IPAddress` (`IPAddress`);
|
||||
|
||||
--
|
||||
-- Index pour la table `Networks`
|
||||
--
|
||||
ALTER TABLE `Networks`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Index pour la table `Sites`
|
||||
--
|
||||
ALTER TABLE `Sites`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD UNIQUE KEY `Name` (`Name`),
|
||||
ADD UNIQUE KEY `Name_2` (`Name`);
|
||||
|
||||
--
|
||||
-- Index pour la table `Users`
|
||||
--
|
||||
ALTER TABLE `Users`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Index pour la table `UserSites`
|
||||
--
|
||||
ALTER TABLE `UserSites`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT pour les tables déchargées
|
||||
--
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `Networks`
|
||||
--
|
||||
ALTER TABLE `Networks`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `Sites`
|
||||
--
|
||||
ALTER TABLE `Sites`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `Users`
|
||||
--
|
||||
ALTER TABLE `Users`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `UserSites`
|
||||
--
|
||||
ALTER TABLE `UserSites`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
COMMIT;
|
||||
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
23
addNetwork.php
Executable file
23
addNetwork.php
Executable file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
$name = filter_input(INPUT_POST, "siteName", FILTER_SANITIZE_STRING);
|
||||
$gateway = ip2long(filter_input(INPUT_POST, "gateway", FILTER_VALIDATE_IP));
|
||||
$mask = ip2long(filter_input(INPUT_POST, "mask", FILTER_VALIDATE_IP));
|
||||
$siteId = filter_input(INPUT_POST, "siteId", FILTER_VALIDATE_INT);
|
||||
if (!($name && $gateway && $mask && $siteId)) {
|
||||
/*header("Location: 400.php");
|
||||
exit;*/
|
||||
include "400.php";
|
||||
die();
|
||||
}
|
||||
$networkAddress = $gateway & $mask;
|
||||
include "connect.php";
|
||||
try {
|
||||
$insert = $db->prepare("INSERT INTO Networks(Name, Address, Mask, SiteId) VALUES(:name, $networkAddress, $mask, $siteId)");
|
||||
$insert->execute(['name' => $_POST['name']]);
|
||||
$networkId = $db->lastInsertId();
|
||||
$insert = $db->exec("INSERT INTO Hosts(IPAddress, NetworkId, Comments) VALUES($gateway, $networkId, 'Passerelle')");
|
||||
header("Location: network.php?networkId=$networkId");
|
||||
} catch (Exception $e) {
|
||||
header("Location: 500.php");
|
||||
exit;
|
||||
}
|
19
addSite.php
Executable file
19
addSite.php
Executable file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
$siteName = filter_input(INPUT_POST, "siteName", FILTER_SANITIZE_STRING);
|
||||
if (!$siteName) {
|
||||
/*header("Location: 400.php");
|
||||
exit;*/
|
||||
include "400.php";
|
||||
die();
|
||||
}
|
||||
include "connect.php";
|
||||
try {
|
||||
$insert = $db->prepare("INSERT INTO Sites(Name) VALUES(:name)");
|
||||
$insert->execute(['name' => $siteName]);
|
||||
$siteId = $db->lastInsertId();
|
||||
header("Location: site.php?id=$siteId");
|
||||
} catch(Exception $e) {
|
||||
header("Location: 500.php");
|
||||
exit;
|
||||
}
|
||||
?>
|
7
config_db.php.inc
Executable file
7
config_db.php.inc
Executable file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
// Fill with your database connexion informations
|
||||
$DB_HOST = 'localhost';
|
||||
$DB_NAME = 'TablIP';
|
||||
$DB_USER = 'webapp_malingrey_fr_preprod';
|
||||
$DB_PASSWORD = 'B3JSRLmhB2PDAtPtiG8hvO2p';
|
||||
?>
|
10
connect.php
Executable file
10
connect.php
Executable file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
require_once("config_db.php");
|
||||
try {
|
||||
$db = new PDO("mysql:host=$DB_HOST;dbname=$DB_NAME", $DB_USER, $DB_PASSWORD);
|
||||
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
} catch (Exception $e) {
|
||||
//header("Location: 500.php");
|
||||
die($e);
|
||||
}
|
23
css/icons.css
Executable file
23
css/icons.css
Executable file
@ -0,0 +1,23 @@
|
||||
/* fallback */
|
||||
@font-face {
|
||||
font-family: 'Material Icons';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: url(../fonts/flUhRq6tzZclQEJ-Vdg-IuiaDsNc.woff2) format('woff2');
|
||||
}
|
||||
|
||||
.material-icons {
|
||||
font-family: 'Material Icons';
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
font-size: 24px;
|
||||
line-height: 1;
|
||||
letter-spacing: normal;
|
||||
text-transform: none;
|
||||
display: inline-block;
|
||||
white-space: nowrap;
|
||||
word-wrap: normal;
|
||||
direction: ltr;
|
||||
-moz-font-feature-settings: 'liga';
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
9085
css/materialize.css
vendored
Executable file
9085
css/materialize.css
vendored
Executable file
File diff suppressed because it is too large
Load Diff
32
css/style.css
Executable file
32
css/style.css
Executable file
@ -0,0 +1,32 @@
|
||||
|
||||
.td-input {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.td-input input:not(.browser-default) {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.pending::after {
|
||||
content: "sync";
|
||||
font-family: 'Material Icons';
|
||||
-moz-font-feature-settings: 'liga';
|
||||
color: grey;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.ok::after {
|
||||
content: "done";
|
||||
font-family: 'Material Icons';
|
||||
-moz-font-feature-settings: 'liga';
|
||||
color: green;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.nok::after {
|
||||
content: "sync_problem";
|
||||
font-family: 'Material Icons';
|
||||
-moz-font-feature-settings: 'liga';
|
||||
color: red;
|
||||
position: absolute;
|
||||
}
|
BIN
fonts/flUhRq6tzZclQEJ-Vdg-IuiaDsNc.woff2
Executable file
BIN
fonts/flUhRq6tzZclQEJ-Vdg-IuiaDsNc.woff2
Executable file
Binary file not shown.
48
index.php
Executable file
48
index.php
Executable file
@ -0,0 +1,48 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>TablIP - Sites</title>
|
||||
<link rel="stylesheet" href="css/style.css"/>
|
||||
<link rel="stylesheet" href="css/icons.css"/>
|
||||
<link rel="stylesheet" href="css/materialize.css"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript" src="js/script.js"></script>
|
||||
<script type="text/javascript" src="js/materialize.js"></script>
|
||||
<header>
|
||||
<nav class="nav-wrapper navbar-fixed teal lighten-2">
|
||||
<div class="container">
|
||||
<a class="breadcrumb">TablIP</a>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
<div class="container">
|
||||
<div id="linksCard" class="card">
|
||||
<div class="collection with-header">
|
||||
<div class="collection-header teal lighten-3 white-text"><h5>Sites</h5></div>
|
||||
<?php
|
||||
include "connect.php";
|
||||
foreach ($db->query("SELECT * FROM `Sites` ORDER BY `Name`") as $site) {
|
||||
print " <a href='site.php?id=${site['id']}' class='collection-item'>${site['Name']}</a>\n";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<button id="addButton" type="button" class="btn-floating halfway-fab waves-effect waves-light teal scale-transition" onclick="showCard(addCard, this)"><i class="material-icons">add</i></button>
|
||||
</div>
|
||||
<div id="addCard" class="card scale-transition scale-out">
|
||||
<form name="addSite" id="addSite" class="card-content" action="addSite.php" method="post">
|
||||
<span class="card-title">Nouveau site</span>
|
||||
<div class="input-field">
|
||||
<label for="siteName">Nom</label>
|
||||
<input type="text" class="validate" id="siteName" name="siteName" placeholder="Site" required/>
|
||||
</div>
|
||||
<div class="card-action right-align">
|
||||
<button class="btn waves-effect waves-light" type="submit" name="action">Ajouter
|
||||
<i class="material-icons right">add</i>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
12374
js/materialize.js
vendored
Executable file
12374
js/materialize.js
vendored
Executable file
File diff suppressed because it is too large
Load Diff
37
js/script.js
Executable file
37
js/script.js
Executable file
@ -0,0 +1,37 @@
|
||||
function showCard(card, button) {
|
||||
card.classList.remove('scale-out')
|
||||
card.classList.add('scale-in')
|
||||
button.classList.add('scale-out')
|
||||
}
|
||||
|
||||
function updateHost(input) {
|
||||
if (input.value) {
|
||||
input.required = true
|
||||
} else {
|
||||
input.required = false
|
||||
}
|
||||
if (input.form.checkValidity()) {
|
||||
var td = input.parentElement
|
||||
var tr = td.parentElement
|
||||
tr.classList.remove("ok")
|
||||
tr.classList.remove("nok")
|
||||
tr.classList.add("pending")
|
||||
fetch(new Request("updateHost.php", {
|
||||
method:"POST",
|
||||
body:new FormData(input.form),
|
||||
mode:"cors"
|
||||
})).then(response => {
|
||||
tr.classList.remove("pending")
|
||||
if (response.ok) {
|
||||
tr.classList.add("ok")
|
||||
var linkInput = tr.getElementsByTagName('input')[7]
|
||||
var linkA = tr.getElementsByTagName('a')[0]
|
||||
linkA.href = linkInput.value
|
||||
} else {
|
||||
tr.classList.add("nok")
|
||||
}
|
||||
})
|
||||
} else {
|
||||
input.form.reportValidity()
|
||||
}
|
||||
}
|
97
network.php
Executable file
97
network.php
Executable file
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
$networkId = filter_input(INPUT_GET, "id", FILTER_VALIDATE_INT);
|
||||
if (!$networkId) {
|
||||
header("Location: 400.php");
|
||||
exit;
|
||||
}
|
||||
include "connect.php";
|
||||
$network = $db->query("SELECT * from `Networks` WHERE id=$networkId")->fetch();
|
||||
$networkName = $network["Name"];
|
||||
if (!$networkName) {
|
||||
header("Location: 404.php");
|
||||
exit;
|
||||
}
|
||||
$networkAddress = $network["Address"];
|
||||
$networkAddressStr = long2ip($networkAddress);
|
||||
$networkMask = $network["Mask"];
|
||||
$networkMaskStr = long2ip($networkMask);
|
||||
$siteId = $network["SiteId"];
|
||||
$site = $db->query("SELECT Name from `Sites` WHERE id=$siteId")->fetch();
|
||||
$siteName = $site["Name"];
|
||||
if (!$siteName) {
|
||||
header("Location: 404.php");
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>TablIP - <?=$networkName?></title>
|
||||
<link rel="stylesheet" href="css/style.css"/>
|
||||
<link rel="stylesheet" href="css/icons.css"/>
|
||||
<link rel="stylesheet" href="css/materialize.css"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript" src="js/script.js"></script>
|
||||
<script type="text/javascript" src="js/materialize.js"></script>
|
||||
<header>
|
||||
<nav class="nav-wrapper navbar-fixed teal lighten-2">
|
||||
<div class="container">
|
||||
<a href="." class="breadcrumb">TablIP</a>
|
||||
<a href="site.php?id=<?=$siteId?>" class="breadcrumb"><?=$siteName?></a>
|
||||
<a class="breadcrumb"><?=$networkName?></a>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
<div class="container">
|
||||
<div class="card">
|
||||
<div class="card-content">
|
||||
<h5><?=$networkName?></h5>
|
||||
<p>@ <?=$networkAddressStr?> / <?=$networkMaskStr?></p>
|
||||
<table class="striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Adresse IP</th>
|
||||
<th>Nom d'hôte</th>
|
||||
<th>FQDN</th>
|
||||
<th>Adresse MAC</th>
|
||||
<th>Commentaires</th>
|
||||
<th>Lien</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="td-input"><input type="text" name='ip' value="<?=$networkAddressStr?>" disabled/></td>
|
||||
<td class="td-input" colspan="5"><input type="text" value="Adresse réseau" disabled/></td>
|
||||
</tr>
|
||||
<?php
|
||||
for ($ip = $networkAddress + 1; ($ip+1 & $networkMask) == $networkAddress; $ip++ ) {
|
||||
$host = $db->query("SELECT * from `Hosts` WHERE IPAddress=$ip AND NetworkId=$networkId")->fetch();
|
||||
?>
|
||||
<tr>
|
||||
<form>
|
||||
<input type="hidden" name="ip" value="<?=$ip?>"/>
|
||||
<input type="hidden" name="networkId" value="<?=$networkId?>"/>
|
||||
<td class="td-input"><input type="text" value="<?=long2ip($ip)?>" disabled/></td>
|
||||
<td class="td-input"><input type="text" onchange="updateHost(this)" name="hostname" pattern="^[A-Za-z0-9_-]*$" value="<?=$host["Hostname"]?>"/></td>
|
||||
<td class="td-input"><input type="text" onchange="updateHost(this)" name="fqdn" pattern="^[a-zA-Z0-9._-]*$" value="<?=$host["FQDN"]?>"/></td>
|
||||
<td class="td-input"><input type="text" onchange="updateHost(this)" name="macAddress" pattern="^([a-fA-F0-9]{2}[:-]{1}){5}[a-fA-F0-9]{2}$" title="XX:XX:XX:XX:XX:XX" value="<?=$host["MacAddress"]?>"/></td>
|
||||
<td class="td-input"><input type="text" onchange="updateHost(this)" name="comments" value="<?=$host["Comments"]?>"/></td>
|
||||
<td class="td-input"><input type="url" onchange="updateHost(this)" name="link" value="<?=$host["Link"]?>"/></td>
|
||||
<td><a href="<?=$host["Link"]?>" target="_blank"><i class="material-icons">launch</i></a></td>
|
||||
</form>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td class="td-input"><input type="text" name='ip' value="<?=long2ip($ip)?>" disabled/></td>
|
||||
<td class="td-input" colspan="5"><input type="text" value="Adresse de diffusion" disabled/></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
73
site.php
Executable file
73
site.php
Executable file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
$siteId = filter_input(INPUT_GET, "id", FILTER_VALIDATE_INT);
|
||||
if (!$siteId) {
|
||||
header("Location: 400.php");
|
||||
exit;
|
||||
}
|
||||
include "connect.php";
|
||||
$site = $db->query("SELECT Name from `Sites` WHERE `id`=$siteId")->fetch();
|
||||
$siteName = $site["Name"];
|
||||
if (!$siteName) {
|
||||
header("Location: 404.php");
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>TablIP - <?=$siteName?></title>
|
||||
<link rel="stylesheet" href="css/style.css"/>
|
||||
<link rel="stylesheet" href="css/icons.css"/>
|
||||
<link rel="stylesheet" href="css/materialize.css"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript" src="js/script.js"></script>
|
||||
<script type="text/javascript" src="js/materialize.js"></script>
|
||||
<header>
|
||||
<nav class="nav-wrapper navbar-fixed teal lighten-2">
|
||||
<div class="container">
|
||||
<a href="." class="breadcrumb">TablIP</a>
|
||||
<a class="breadcrumb"><?=$siteName?></a>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
<div class="container">
|
||||
<div id="linksCard" class="card">
|
||||
<div class="collection with-header">
|
||||
<div class="collection-header teal lighten-3 white-text"><h5><?=$siteName?></h5></div>
|
||||
<?php
|
||||
include "connect.php";
|
||||
foreach ($db->query("SELECT * FROM `Networks` WHERE `SiteId` = $siteId ORDER BY `Address`") as $network) {
|
||||
print " <a href='network.php?id=${network['id']}' class='collection-item'>".$network['Name']." @ ".long2ip($network['Address'])." / ".long2ip($network['Mask'])."</a>\n";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<button id="addButton" type="button" class="btn-floating halfway-fab waves-effect waves-light teal scale-transition" onclick="showCard(addCard, this)"><i class="material-icons">add</i></button>
|
||||
</div>
|
||||
<div id="addCard" class="card teal scale-transition scale-out">
|
||||
<form name="addNetwork" id="addNetwork" class="card-content" action="addNetwork.php" method="post">
|
||||
<span class="card-title">Nouveau réseau</span>
|
||||
<input type="hidden" name="siteId" value="<?=$siteId?>"/>
|
||||
<div class="input-field">
|
||||
<label for="nameInput">Nom</label>
|
||||
<input type="text" class="validate" id="nameInput" name="name" placeholder="LAN" required/>
|
||||
</div>
|
||||
<div class="input-field">
|
||||
<label for="gatewayInput">Passerelle</label>
|
||||
<input type="text" class="validate" id="gatewayInput" name="gateway" placeholder="192.168.0.1" pattern="^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$" title="XXX.XXX.XXX.XXX"/>
|
||||
</div>
|
||||
<div class="input-field">
|
||||
<label for="maskInput">Masque</label>
|
||||
<input type="text" class="validate" id="maskInput" name="mask" placeholder="255.255.255.0" pattern="^(255\.255\.(248|252|255)\.0|255\.255\.255\.(0|128|192|224|240|248|252|255))$" title="Plus grand masque autorisé : 255.255.248.0"/>
|
||||
</div>
|
||||
<div class="card-action right-align">
|
||||
<button class="btn waves-effect waves-light" type="submit" name="action">Ajouter
|
||||
<i class="material-icons right">add</i>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
39
updateHost.php
Executable file
39
updateHost.php
Executable file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
$ip = filter_input(INPUT_POST, "ip", FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE);
|
||||
$networkId = filter_input(INPUT_POST, "networkId", FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE);
|
||||
$hostname = filter_input(INPUT_POST, "hostname", FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME);
|
||||
$fqdn = filter_input(INPUT_POST, "fqdn", FILTER_VALIDATE_DOMAIN);
|
||||
$macAddress = filter_input(INPUT_POST, "macAddress", FILTER_VALIDATE_MAC);
|
||||
$comments = filter_input(INPUT_POST, "comments", FILTER_SANITIZE_STRING);
|
||||
$link = filter_input(INPUT_POST, "link", FILTER_VALIDATE_URL);
|
||||
|
||||
if (is_null($ip)
|
||||
|| is_null($networkId)) {
|
||||
header("Location: 400.php");
|
||||
exit;
|
||||
}
|
||||
include "connect.php";
|
||||
try {
|
||||
$update = $db->prepare(
|
||||
<<<SQL
|
||||
INSERT INTO Hosts(IpAddress, NetworkId, Hostname, FQDN, MacAddress, Link, Comments)
|
||||
VALUES($ip, $networkId, :i_hostname, :i_fqdn, :i_macAddress, :i_link, :i_comments)
|
||||
ON DUPLICATE KEY UPDATE Hostname = :u_hostname, FQDN = :u_fqdn, MacAddress = :u_macAddress, Comments = :u_comments, Link = :u_link
|
||||
SQL);
|
||||
$update->execute([
|
||||
'i_hostname' => $hostname,
|
||||
'i_fqdn' => $fqdn,
|
||||
'i_macAddress' => $macAddress,
|
||||
'i_link' => $link,
|
||||
'i_comments' => $comments,
|
||||
'u_hostname' => $hostname,
|
||||
'u_fqdn' => $fqdn,
|
||||
'u_macAddress' => $macAddress,
|
||||
'u_link' => $link,
|
||||
'u_comments' => $comments
|
||||
]);
|
||||
} catch(Exception $e) {
|
||||
header("Location: 500.php");
|
||||
exit;
|
||||
}
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user