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
| <?php
session_start();
include("../../connect.php");
//on verifie que l'utilisateur est bien connecté
if ( isset($_SESSION) && (empty($_SESSION['utilisateur'])) && (empty($_SESSION['motdepasse'])) ) {
// si l'utilisateur n'est pas connecté alors on le renvoi vers la page de connexion
header("Location: ../connexion.php");
}
else {
?>
<html>
<HEAD>
<BASE HREF="http://127.0.0.1/GP/">
<TITLE>Administration des tables</TITLE>
</HEAD>
<!--appel du menu-->
<?
include("../../menu.html");
?>
<body BGCOLOR="#FFFFFF" topmargin="0" leftmargin="50" marginwidth="50" marginheight="0" background="images/index/arbres_gris.gif">
<table width="696" border="0" align="center">
<tr>
<td width="100">
</td>
<td height="19">
<div align="center"><font face="Comic Sans MS" size="4"><b>LE CERCLE GÉNÉALOGIQUE
DE PICARDIE</b></font></div>
</td>
<td width="100">
<font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<a href="admin/deconnexion.php" onclick="return confirm('Voulez vous réellement vous déconnecté ?')">Déconnexion</a></font>
</td>
</tr>
</table>
<br>
<p align="center"><img src="images/index/familleok.gif" width="693" height="70"></p>
<table width="696" border="0" align="center">
<tr>
<td>
<div align="center">
<p><b><font face="Verdana, Arial, Helvetica, sans-serif" size="4">Administration des tables</font></b></p>
</div>
</td>
</tr>
</table>
<form method="POST" action="admin/page/admintable.php">
<table width="696" align="center">
<tr>
<td align="center">
<font face="Verdana, Arial, Helvetica, sans-serif" size="2">Choississez une table à administrer : </font>
<select name="table">
<?
$droit=$_SESSION['droit'];
switch($droit)
{
//Cas quand c'est l'administrateur droit=0
case '0':
$tables = mysql_query("SHOW TABLES;");
while($tables_array = mysql_fetch_row($tables)) {
echo '<option>'.$tables_array[0].'</option><br />';
}
break;
//Cas quand c'est un utilisateur quelconque droit=1
case '1':
$tables = mysql_query("SHOW TABLES;");
//Boucle permettant de ne pas afficher la table identification pour les utilisateurs quelconques
while($tables_array = mysql_fetch_row($tables)) {
if ($tables_array[0] != 'identification') {
echo '<option>'.$tables_array[0].'</option><br />';
}
}
break;
}
?>
</select>
</td>
</tr>
<tr>
<td align="center">
<br><br>
<input type="submit" value="Administrer la table">
</td>
</tr>
</table>
</form>
<?
if(array_key_exists('table', $_POST)){
$table=$_POST['table'];
$reqsql = 'SELECT * FROM '.$table;
$result = mysql_query($reqsql);
//commpte le nombre de champ, cela servira pour l'affichage de la table sélectionnée
$nb_champ = mysql_num_fields($result);
//Pour le nombre total de colonne avec modifier et supprimer inclus
$nb_champtot = $nb_champ + 2;
?>
<table width="696" align="center">
<tr>
<td align="center">
<br><br>
<font face="Verdana, Arial, Helvetica, sans-serif" size="4">
<b>
Table sélectionnée : <? echo $table;?>
<br><br>
</b>
</font>
</td>
</tr>
</table>
<table width="696" border="0" cellpadding="0" cellspacing="0" bgcolor="#EEFFBB" align="center"><tr><td>
<table width="100%" align="center" border=0 cellspacing="1" cellpadding="2">
<tr bgcolor="#CCCCCC">
<td colspan="<? echo $nb_champtot?>" align="center"><a href="admin/page/ajout.php?table=<? echo $table;?>"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b>Ajouter une entrée dans cette table</b></font></a></td>
</tr>
<tr bgcolor="#666666">
<?
//affichage des noms de champs de la table choisie
$sql = 'DESCRIBE '.$table;
$champs = mysql_query($sql);
while($table_champs = mysql_fetch_array($champs))
{
?>
<th><font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<? echo $table_champs[0]; ?>
</font></th>
<? } ?>
<th> </th><th> </th>
</tr>
<?php
//affichage de la table sélectionnée
for ($i=0; $i < mysql_num_rows($result); ++$i)
{
echo '<tr bgcolor="#CCCCCC">';
mysql_data_seek($result, $i);
$champs = mysql_fetch_array($result);
for ($col=0; $col<$nb_champ; ++$col)
echo '<td align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">'.$champs[$col].'</font></td>';
//demande de confirmation de suppression
$vars= 'ID='.$champs[0];
echo '<td align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><a href="admin/page/modif.php?'.$vars.'&table='.$table.'">Modifier</a></font></td>';
echo '<td align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><a href="admin/page/suppr.php?ID='.$champs[0].'&table='.$table.'" onclick="return confirm(\'Voulez vous réellement supprimer cette entrée ?\')">Supprimer</a></font></td></tr>';
}
//Affichage d'une indication concernant l'utilisation de la colonne "nouv"
echo '<tr bgcolor="#666666">';
echo '<td colspan="'.$nb_champtot.'" align="center"><P align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b>S´il y a une colonne NOUV, vous pouvez indiqué si c\'est nouveau ou non. Si vous mettez "o", l\'entrée sera considérée comme nouvelle et inversement si vous mettez "n".</b></font></P></a></td>';
}
mysql_close();
?>
</table>
</table>
<!-- Message de confirmation d'ajout, de modification ou de suppression -->
<table width="696" align="center" border=0>
<tr>
<td align="center">
<font face="Verdana, Arial, Helvetica, sans-serif" size="4">
<b>
<?
if(array_key_exists('afficherConfirm', $_GET)){
$confirmation=$_GET['afficherConfirm'];
switch($confirmation)
{
case '1':
echo 'Ajout dans la table effectuée.';
break;
case '2':
echo 'Modification de la table effectuée.';
break;
case '3':
echo 'Suppression dans la table effectuée.';
break;
}
}
?>
</b>
</font>
</td>
</tr>
</table>
</body>
</html>
<? } ?> |
Partager