1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
|
<?
session_start();
if (!isSet($_SESSION['site'])) {
$siteID = '';
$sitePrefixe = '';
$siteName = '';
} else {
$siteID = $_SESSION['site']['id'];
$sitePrefixe = $_SESSION['site']['prefixe'];
$siteName = $_SESSION['site']['nom'];
}
/***************************************************************************************************
********** CONTRÔL DES FICHIERS À INCLURE POUR L'AFFICHAGE DES PAGES
*********/
$include_files = array();
$include_files[] = array('pheader','includes/header.php');
$include_files[] = array('pfooter','includes/footer.php');
$include_files[] = array('variables','includes/variables.php');
$include_files[] = array('fonctions','includes/fonctions.php');
$fichiers_inclus = array();
if (count($include_files) > 0) {
for ($i = 0; $i < count($include_files); $i++) {
if (!file_exists($include_files[$i][1])) { header('Location: alerte.php?warning=500'); }
else { $files_includes[$include_files[$i][0]] = $include_files[$i][1]; }
}
}
include($files_includes['variables']);
include($files_includes['fonctions']);
/*
CREATE TABLE adm_sites (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
prefixe VARCHAR(200) NULL,
nom VARCHAR(200) NOT NULL,
infos TEXT NULL,
PRIMARY KEY (id),
UNIQUE (prefixe)
);
*/
// Initialisations des valiables
$id = 0;
$prefixe = '';
$nom = '';
$infos = '';
if ((isSet($_POST['gestion'])) || (isSet($_GET['gestion']))) {
if (($_GET['gestion'] == 'delete') && ($_GET['id'] > 0)) {
if (mySqli_query(db(),'DELETE FROM adm_sites WHERE id='.$_GET['id'])) {
header('Location: sites.php?alerte=valide');
} else { header('Location: sites.php?alerte=error'); }
}
else {
if ($_POST['prefixe'] == '') { $alerte[] = array('error','ATTENTION ! Vous n’avez pas spécifié le préfixe du site'); }
if ($_POST['nom'] == '') { $alerte[] = array('error','ATTENTION ! Vous n’avez pas spécifié le nom du site'); }
$prefixe = $_POST['prefixe'];
$nom = $_POST['nom'];
$nom = stripSlashes($nom);
$nom = trim($nom);
$nom = htmlEntities($nom);
$nom = str_replace('\'','’',$nom);
$infos = $_POST['infos'];
$infos = stripSlashes($infos);
$infos = trim($infos);
$infos = htmlEntities($infos);
$infos = str_replace('\'','’',$infos);
}
if (count($alerte) == 0) {
if (($_POST['gestion'] == $bt['update']) && ($_POST['id'] > 0)) {
if (mySqli_query(db(),'UPDATE adm_sites SET prefixe="'.$prefixe.'", nom="'.$nom.'", infos="'.$infos.'" WHERE id='.$_POST['id'])) {
header('Location: sites.php?alerte=valide');
} else { header('Location: sites.php?alerte=error'); }
}
if ($_POST['gestion'] == $bt['register']) {
if (mySqli_query(db(),'INSERT INTO adm_sites VALUES (NULL, "'.$prefixe.'", "'.$nom.'", "'.$infos.'")')) {
header('Location: sites.php?alerte=valide');
} else { header('Location: sites.php?alerte=error'); }
}
}
}
?>
<!DOCTYPE html>
<html lang="fr-CH">
<head>
<title>Administrations</title>
<link rel="stylesheet" href="images/designs/styles.css">
<script src="https://kit.fontawesome.com/2e9b34a81e.js"></script>
</head>
<body>
<? include($files_includes['pheader']); ?>
<h1>Gestion des Sites</h1>
<div align="justify" style="width: 600px;">
Concernant le nom du site ainsi que son préfixe, il serait important de ne pas mettre d’accents,
de caractères spéciaux ou d’espace. Il faudrait plutôt jouer entre les majuscules
et les minuscules pour différencier les mots. En revanche pour les infos, aucun soucis, tous les
caractères sont acceptés et présenteront aucun danger niveau codage.
</div>
<br />
<a href="sites.php?manage=insert" target="_parent" title="Ajouter une entrée"><i class="fas fa-folder-plus" style="font-size: 30px;"></i></a>
<br />
<?
if (isSet($_GET['alerte'])) {
if ($_GET['alerte'] == 'error') { $alerte[] = array('error','Opération impossible !'); }
if ($_GET['alerte'] == 'valide') { $alerte[] = array('valide','Opération réussi !'); }
}
if (count($alerte) > 0) { echo '<br />';
for($i = 0; $i < count($alerte); $i++) { echo '<div align="left" class="'.$alerte[$i][0].'">'.$alerte[$i][1].'</div>'; } echo '<br />';
}
?>
<br />
<?
if (isSet($_GET['manage']) && ($_GET['manage'] == 'insert')) {
?>
<br />
<table border="0" cellpadding="5" cellspacing="0">
<form method="POST">
<tr>
<td align="left" valign="top">Nom :</td>
<td align="left" valign="top"><input type="text" name="nom" value="<? if (isSet($_POST['nom'])) { echo $_POST['nom']; }?>" required style="width: 400px;"></td>
</tr>
<tr>
<td align="left" valign="top">Préfixe :</td>
<td align="left" valign="top"><input type="text" name="prefixe" value="<? if (isSet($_POST['prefixe'])) { echo $_POST['prefixe']; }?>" required style="width: 400px;"></td>
</tr>
<tr>
<td align="left" valign="top">Infos :</td>
<td align="left" valign="top"><textarea name="infos" cols="" rows="" style="width: 400px;"><? if (isSet($_POST['infos'])) { echo stripSlashes($_POST['infos']); }?></textarea></td>
</tr>
<tr>
<td align="left" valign="top"> </td>
<td align="left" valign="top"><input type="submit" name="gestion" value="<?=$bt['register'];?>" style="width: 405px;"></td>
</tr>
</form>
</table>
<?
}
?>
<br />
<br />
<br />
<?
$sql = $bdd1->query('SELECT * FROM adm_sites');
echo '<table border="0" cellpadding="2" cellspacing="0">';
while ($data = $sql->fetch()) {
?>
<form method="POST">
<input type="hidden" name="id" value="<?=$data['id'];?>">
<tr>
<td align="left" valign="top"><div style="font-weight: bold; font-size: 16px;"><?=$data['id'];?></div></td>
<td align="right" valign="top"><a href="sites.php?gestion=delete&id=<?=$data['id'];?>" target="_parent"><i class="fas fa-trash-alt"></i></a></td>
</tr>
<tr><td colspan="2" align="left" valign="top"><input type="text" name="nom" value="<?=$data['nom'];?>" maxlength="" style="width: 400px;"></td></tr>
<tr><td colspan="2" align="left" valign="top"><input type="text" name="prefixe" value="<?=$data['prefixe'];?>" maxlength="" style="width: 400px;"></td></tr>
<tr><td colspan="2" align="left" valign="top"><textarea name="infos" cols="" rows="3" style="width: 400px;"><?=$data['infos'];?></textarea></td></tr>
<tr><td colspan="2" align="left" valign="top"><input type="submit" name="gestion" value="<?=$bt['update'];?>"></td></tr>
<tr><td colspan="2" align="left" valign="top"> </td></tr>
</form>
<?
}
echo '</table>';
$sql->closeCursor();
?>
<? include($files_includes['pfooter']); ?>
</body>
</html> |
Partager