Viewing file: Modification chapitres.php (7.62 KB) -rw----r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
if (isset($_SESSION['identifiant']))
{
$user = $_SESSION['identifiant'];
if ($user)
{
if (isset($_GET['creation']))
{
}
else
{ echo "<table width='540' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td valign='bottom'>
<br><span class='Style6'>Modification des chapitres</span>
</td>
<td valign='bottom'><div align='right'>
<form action='index.php?page=Modification chapitres&creation=1' method='POST' enctype='multipart/form-data'>
<input type='submit' name='sup' value='Ajouter un Chapitre'>
</form>
</div></td>
</tr>
</table><p>";
}
if (isset($_GET['creation']))
{
$creation = $_GET['creation'];
if ($creation==2)
{
if (isset($_POST['crea']))
{
//récuperer le fichier envoyé
$chap = $_POST['nomchap'];
$name = $_FILES['myfile']['name'];
$size = $_FILES['myfile']['size']; //voir le tutorial upload pour vérifier que c'est une image
$tmp_name = $_FILES['myfile']['tmp_name'];
$cat = $chap;
if ($name)
{
//Chargement en cours (on commence par configurer la photo (3 lignes)
$chap2 = $chap;
$chap2 = strtr($chap2, 'ÁÀÂÄÃÅÇÉÈÊËÍÏÎÌÑÓÒÔÖÕÚÙÛÜÝ', 'AAAAAACEEEEEIIIINOOOOOUUUUY');
$chap2 = strtr($chap2, 'áàâäãåçéèêëíìîïñóòôöõúùûüýÿ/', 'aaaaaaceeeeiiiinooooouuuuyy_');
$cat2 = $chap2;
$location ="photo_chapitre/".$chap2.".png";
$emplacement ="photo_chapitre/";
include ("Enregistrement.php");
$location ="photo_chapitre/$chap2.png";
move_uploaded_file($tmp_name,$location); //regarder le tutorial pour que personne ne puisse y installer des fichier!!!
$query = mysql_query("INSERT INTO articles_chapitre VALUES ('','$chap','$location')");
echo("<br><span class='Style5'>Le nouveau chapitre est maintenant enregistré <a href='index.php?page=member'>Retour</a></span><br>");
}
else
echo("Sélectionner un fichier!");
}
}
else
{
//formulaire de creation de chapitre
echo"<form action='index.php?page=Modification chapitres&creation=2' method='POST' enctype='multipart/form-data'>
<br><span class='Style5'>
<span class='Style6'>Création d'un chapitre</span><p>
<table width='400' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td>Nom du chapitre: </td>
<td><input type='text' name='nomchap'><br>
<img src='image/transparent.png' width='30' height='4' /></td>
</tr>
<tr>
<td>Image: </td>
<td><input type='file' name='myfile'><br>
<img src='image/transparent.png' width='30' height='4' /></td>
</tr>
<tr>
<td></td>
<td><input type='submit' name='crea' value='Confirmer la création'></td>
</tr>
</table>
</span><p>
</form>
";
}
}
else
{}
if (isset($_GET['choix']))
{
$choix = $_GET['choix'];
if (isset($_GET['supprimer']))
{
$supprimer = $_GET['supprimer'];
if ($supprimer==2)
{
$query = mysql_query("DELETE FROM articles_chapitre WHERE CHAPITRE='$choix'");
echo ("Le chapitre ".$choix." n'existe maintenant plus. <a href='index.php?page=Modification chapitres'><strong>Retour</strong></a><br>");
}
else
{
echo "<form action='index.php?page=Modification chapitres&choix=".$choix."&supprimer=2' method='POST' enctype='multipart/form-data'>
Confirmer la suppression de \"".$choix."\"
<input type='submit' name='sup' value='Supprimer'>
</form>";
}
}
else
{
if (isset($_POST['submit']))
{
//récuperer le fichier envoyé
$name = $_FILES['myfile']['name'];
$size = $_FILES['myfile']['size']; //voir le tutorial upload pour vérifier que c'est une image
$tmp_name = $_FILES['myfile']['tmp_name'];
if ($name)
{
//Chargement en cours
$choix2 = $choix;
$choix2 = strtr($choix2, 'ÁÀÂÄÃÅÇÉÈÊËÍÏÎÌÑÓÒÔÖÕÚÙÛÜÝ', 'AAAAAACEEEEEIIIINOOOOOUUUUY');
$choix2 = strtr($choix2, 'áàâäãåçéèêëíìîïñóòôöõúùûüýÿ/', 'aaaaaaceeeeiiiinooooouuuuyy_');
$location ="photo_chapitre/".$choix2.".png";
$emplacement ="photo_chapitre/";
$cat = $choix;
$cat2 = $choix2;
include ("Enregistrement.php");
$location ="photo_chapitre/$choix2.png";
move_uploaded_file($tmp_name,$location); //regarder le tutorial pour que personne ne puisse y installer des fichier!!!
$query = mysql_query("UPDATE articles_chapitre SET PHOTO='$location' WHERE CHAPITRE='$choix'");
echo("L'image est maintenant enregistré <a href='index.php?page=member'>Retour</a><br>");
}
else
echo("Sélectionner un fichier!");
}
else
{
echo "Mettre à jour la photo: \"".$choix."\"<br>
<img src='image/transparent.png' width='30' height='4' /><br>
<form action='index.php?page=Modification chapitres&choix=".$choix."' method='POST' enctype='multipart/form-data'>
Fichier: <input type='file' name='myfile'> <input type='submit' name='submit' value='Charger'>
</form>";
}
}
echo '</span>';
}
else
{}
//apparition des données
$get = mysql_query("SELECT * FROM articles_chapitre");
while ($row = mysql_fetch_assoc($get))
{
// obtenir données
$picture = $row['PHOTO'];
$name = $row['CHAPITRE'];
echo "
<table width='562' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td> </td>
</tr>
<tr>
<td background='image/article.png'><table width='540' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='120' height='90'><div align='center'><img src='$picture' width='100' height='70' /></div></td>
<td width='407' valign='middle'><div align='left'>
<p align='left' class='Style5'>";
echo"<strong>".$name."</strong>";
// mettre dans l'echo si dessous les options possibles supprimer ou modifier
echo"<br /><br />
<table width='400' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td><div align='right' class='Style5'><a href='index.php?page=Modification chapitres&choix=".$name."'>Modifier l'image</a> | <a href='index.php?page=Modification chapitres&supprimer=1&choix=".$name."'>Supprimer</a></div></td>
</tr>
</table>
</p>
</p>
</div></td>
</tr>
</table></td>
</tr>
</table>";
}
}
else
echo("Vous devez être connecté.");
}
else
echo("Vous devez être connecté.");
?>
|