-ThX- Not here anymore | Allez...
tutoriel.php > fichier d'affichage pour les users
tutadmin.php > IHM d'administration
tutedit.php > a placer dans le meme rep que tutadmin.php
Code :
- <?
- // $_GET['action']
- // ---------------------
- // 0 editer
- // 1 monter d'un cran
- // 2 descendre d'un cran
- // 3 supprimer
- require_once ('functions.php');
- function displayEdition() {
- $cats= "<option value='0'>En attente</option>\n";
- connecter();
- if ($_GET['t'] != 0) {
- $rq = "SELECT * FROM tutoriels WHERE id_tutoriel={$_GET['t']}";
- $sql = mysql_query($rq);
- $ret = mysql_fetch_array($sql);
- $id = $_GET['t'];
- $cat = $ret['categorie'];
- $titre = $ret['titre'];
- $href = $ret['href'];
- $auteur = $ret['auteur'];
- $niveau = $ret['niveau'];
- $pdf = ($ret['format']=="1" ) ? "checked='checked'" : "" ;
-
- } else {
- $titre = "[ Titre du tutoriel ]";
- $href = "./.php";
- $auteur = "Anonyme";
- $id=0;
- }
- $rq = "SELECT * FROM categories";
- $sql = mysql_query($rq);
- while ( $ret = mysql_fetch_array($sql) ){
- $sel = ($ret['id_categorie']==$cat) ?"selected='selected'":"";
- $cats .= "<option value='{$ret['id_categorie']}' $sel >{$ret['titre']}</option>\n";
- }
- $niveaux="";
- for ($i=1; $i<=5 ; ++$i) {
- $sel = ($i==$niveau) ? "checked='checked'" : "";
- $niveaux .= " <input type='radio' name='niveau' value='$i' accesskey='niveau' $sel /><img src='images/niveau/$i.jpg' alt='$i'/>";
- }
- include ('displayedit.php');
- }
- switch($_GET['action']) {
- case 0:
- if (!isset($_POST['titre'])) {
- include ('overall_header.inc');
- displayEdition();
- include ('overall_footer.inc');
- } else {
- $t=$_GET['t'];
- connecter();
- if ($t=="0" ) {
- @mysql_query("INSERT INTO `tutoriels` ( `id_tutoriel` , `titre` , `auteur` , `niveau` , `href` , `categorie` , `format` , `ordre` )
- VALUES ( 'temp' , '', '', NULL , '', '', '', '".nextOrderInCategory($_POST['categorie'])."')" );
- $t = mysql_insert_id();
- }
- @mysql_query("UPDATE tutoriels SET titre='".$_POST['titre']."' WHERE id_tutoriel=".$t);
- @mysql_query("UPDATE tutoriels SET auteur='".$_POST['auteur']."' WHERE id_tutoriel=".$t);
- @mysql_query("UPDATE tutoriels SET niveau='".$_POST['niveau']."' WHERE id_tutoriel=".$t);
- @mysql_query("UPDATE tutoriels SET href='".$_POST['href']."' WHERE id_tutoriel=".$t);
- $pdf = ($_POST['pdf']=="ispdf" ) ?"1":"0";
- @mysql_query("UPDATE tutoriels SET format='$pdf' WHERE id_tutoriel=".$t);
- $sql=mysql_query("SELECT * FROM tutoriels WHERE id_tutoriel=".$t);
- $ret=@mysql_fetch_array($sql);
- if ($ret['categorie'] != $_POST['categorie']) {
- changeCat($t, $_POST['categorie']);
- }
- include_once('tutadmin.php');
- }
- break;
- case 1:
- connecter();
- $sql = mysql_query("SELECT * FROM tutoriels WHERE id_tutoriel={$_GET['t']}" );
- $ret = mysql_fetch_array($sql);
- mysql_free_result($sql);
- $cat = $ret['categorie'];
- monterTuto($_GET['t'],$cat);
- deconnecter();
- include_once ('tutadmin.php');
- break;
- case 2:
- connecter();
- $sql = mysql_query("SELECT * FROM tutoriels WHERE id_tutoriel={$_GET['t']}" );
- $ret = mysql_fetch_array($sql);
- mysql_free_result($sql);
- $cat = $ret['categorie'];
- descendreTuto($_GET['t'],$cat);
- deconnecter();
- include_once ('tutadmin.php');
- break;
- case 3:
- connecter();
- mysql_query("DELETE FROM tutoriels WHERE id_tutoriel={$_GET['t']} LIMIT 1" );
- deconnecter();
- include_once ('tutadmin.php');
- break;
- default:
- $message = "L´action demandée n´est pas impléementée";
- }
- ?>
|
catedit.php > meme chose
Code :
- <?
- // $_GET['action']
- // ---------------------
- // 0 editer
- // 1 monter
- // 2 descendre
- // 3 supprimer
- require_once ('functions.php');
- function displayEdition() {
- connecter();
- if ($_GET['c'] != 0) {
- $rq = "SELECT * FROM categories WHERE id_categorie={$_GET['c']}";
- $sql = mysql_query($rq);
- $ret = mysql_fetch_array($sql);
- $id = $_GET['c'];
- $titre = $ret['titre'];
- $icon = $ret['icon'];
- } else {
- $titre = "[ Titre de la catégorie ]";
- $icon = "./images/defcat.jpg";
- $id=0;
- }
- include ('displaycatedit.php');
- }
- switch($_GET['action']) {
- case 0:
- if (!isset($_POST['titre'])) {
- include ('overall_header.inc');
- displayEdition();
- include ('overall_footer.inc');
- } else {
- $c=$_GET['c'];
- connecter();
- if ($c=="0" ) {
- mysql_query("INSERT INTO `categories` ( `id_categorie` , `titre` , `icon` , `ordre` )
- VALUES (
- NULL , '', '', '".nextCatOrder()."'
- )" );
- $c = mysql_insert_id();
- }
- connecter();
- @mysql_query("UPDATE categories SET titre='{$_POST['titre']}' WHERE id_categorie=$c" );
- @mysql_query("UPDATE categories SET icon='{$_POST['icon']}' WHERE id_categorie=$c" );
- include_once('tutadmin.php');
- }
- break;
- case 1:
- connecter();
- monterCat($_GET['c']);
- deconnecter();
- include_once ('tutadmin.php');
- break;
- case 2:
- connecter();
- descendreCat($_GET['c']);
- deconnecter();
- include_once ('tutadmin.php');
- break;
- case 3:
- connecter();
- mysql_query("DELETE FROM categories WHERE id_categorie={$_GET['c']} LIMIT 1" );
- deconnecter();
- include_once ('tutadmin.php');
- break;
- default:
- $message = "L´action demandée n´est pas impléementée";
- }
- ?>
|
displaycatedit.php > fichier inclus IHM pour l'édition des catégories
Code :
- <?
- echo "<form id='editer' name='editer' method='post' action='catedit.php?action=0&c=$id'>";
- echo " <table align='center' width='80%' border='0' cellspacing='0' cellpadding='0'>";
- echo " <tr>";
- echo " <td> </td>";
- echo " <td>Titre</td>";
- echo " <td> </td>";
- echo " <td><input type='text' size='60' name='titre' accesskey='titre' value='$titre' /></td>";
- echo " <td> </td>";
- echo " </tr>";
- echo " <tr>";
- echo " <td> </td>";
- echo " <td>Icone</td>";
- echo " <td> </td>";
- echo " <td><input type='text' size='60' name='icon' accesskey='href' value='$icon' /></td>";
- echo " <td> </td>";
- echo " </tr>";
- echo " </table>";
- echo "<input type='submit' name='go' value='Modifier' />";
- echo "</form>";
- ?>
|
displayedit.php > pareil mais pour les cours/tutoriels
Code :
- <?
- echo "<form id='editer' name='editer' method='post' action='tutedit.php?action=0&t=$id'>";
- echo " <table align='center' width='80%' border='0' cellspacing='0' cellpadding='0'>";
- echo " <tr>";
- echo " <td> </td>";
- echo " <td>Titre</td>";
- echo " <td> </td>";
- echo " <td><input type='text' size='60' name='titre' accesskey='titre' value='$titre' /></td>";
- echo " <td> </td>";
- echo " </tr>";
- echo " <tr>";
- echo " <td> </td>";
- echo " <td>Auteur</td>";
- echo " <td> </td>";
- echo " <td><input type='text' size='60' name='auteur' accesskey='auteur' value='$auteur' /></td>";
- echo " <td> </td>";
- echo " </tr>";
- echo " <tr>";
- echo " <td> </td>";
- echo " <td>Lien</td>";
- echo " <td> </td>";
- echo " <td><input type='text' size='60' name='href' accesskey='href' value='$href' /></td>";
- echo " <td> </td>";
- echo " </tr>";
- echo " <tr>";
- echo " <td> </td>";
- echo " <td>Catégorie</td>";
- echo " <td> </td>";
- echo " <td><select name='categorie' accesskey='categorie'>";
- echo " $cats";
- echo " </select> </td>";
- echo " <td> </td>";
- echo " </tr>";
- echo " <tr>";
- echo " <td> </td>";
- echo " <td>Pdf</td>";
- echo " <td> </td>";
- echo " <td><input type='checkbox' name='pdf' value='ispdf' accesskey='pdf' $pdf /> </td>";
- echo " <td> </td>";
- echo " </tr>";
- echo " <tr>";
- echo " <td> </td>";
- echo " <td>Niveau</td>";
- echo " <td> </td>";
- echo " <td>";
- echo " $niveaux";
- echo " </td>";
- echo " <td> </td>";
- echo " </tr>";
- echo " </table>";
- echo "<input type='submit' name='go' value='Modifier' />";
- echo "</form>";
- ?>
|
functions.php donné quelques posts plus haut
Et ne pas oublier un "config.php" pour les infos de BDD. |