esteban72 | J'ai utilisé un script de news (celui de 1two). Le script fonctionne bien mais il fait faire des petits aux apostrophes du texte.
Je m'explique, j'ecris dans une news : t'es la. A la validation il va m'ecrire dans la news : t''es la. Si je fais modifier, il m'affiche : t''es la. Si je valide comme ca, il va m'afficher ensuite : t''''es la. A chaque modification il multiplie par 2 les apostrophes du texte.
Voici le code php du script sur la page qui affiche les news :
Code :
- <?php include ('intranews/_connexion.php'); ?>
- <table width="900" border="0" align="center" cellpadding="0" cellspacing="3">
- <tr>
- <td width="48" height="34"><a href="intranews/index.php" class="lien2"></a></td>
- <td width="66" valign="middle"><a href="http://192.168.10.249:8080/index.php" class="lien2">Accueil</a></td>
- <td width="425" valign="middle"><a href="intranews/admin/index.php" class="lien2">Administation</a></td>
- <td width="326" align="right" valign="middle">
- <form name="formrecherche" id="formrecherche" method="post" action="">
- <p align="right"><span class="textebig">Rechercher : </span>
- <input type="text" name="recherche" />
- <input type="submit" name="rechercher" value="OK" /></p>
- </form> </td>
- <td width="17"> </td>
- </tr>
- </table>
- <table width="900" border="0" align="center" cellpadding="0" cellspacing="3" class="texte">
- <tr valign="top">
- <td width="46" rowspan="4" align="center"><br> </td>
- <td width="400" align="center"><img src="intranews/design/sephaccueil.jpg" width="400" height="230"><BR><BR><a href="IntraSephira/index.php"><img src="intranews/design/lemans1.jpg" width="217" height="60" border="1" class="lien3"></a><BR><BR><a href="intracrip/index.html"><img src="intranews/design/marseille1.jpg" width="217" height="60" border="1"></a></td>
- <td width="398" rowspan="4">
- <?php if (($_POST['rechercher']=="OK" ) and ($_POST['recherche']!="" ))
- {
- $query="SELECT titre, texte, photo, DATE_FORMAT(date_ins, '%d-%m-%Y'), heure_ins, compteur FROM 1two_news_news WHERE titre LIKE '%$recherche%' or texte LIKE '%$recherche%' ORDER BY date_ins DESC , heure_ins DESC";
- $res_recherche = @mysql_query($query,$db);
- if (@mysql_num_rows($res_recherche)!=0)
- {
- $nbrecherche=mysql_num_rows($res_recherche);
- for ($i=0; $i<$nbrecherche; $i=$i+1)
- {
- $list_recherche=@mysql_fetch_row($res_recherche);
- echo "<table width='100%' border='0' cellspacing='2' cellpadding='0' bgcolor='#F7F7F7' class='cadrenews'>";
- echo "<tr>";
- echo "<td>";
- echo "<table width='100%' border='0' cellspacing='0' cellpadding='3'>";
- echo "<tr>";
- echo "<td width='60%' valign='top' class='textebig'>$list_recherche[0]</td>";
- echo "<td width='40%' align='right' valign='top' class='textedate'>Posté le $list_recherche[3]<br>à $list_recherche[4]</td>";
- echo "</tr>";
- echo "</table>";
- echo "<table width='100%'>";
- echo "<tr>";
- echo "<td width='100%' valign='top' class='texte'>"; if ($list_recherche[2]!="" ) {echo "<img src='$list_recherche[2]' width='150' align='left'>";} echo $list_recherche[1] . "</td>";
- echo "</tr>";
- echo "</table><br>";
- $query="SELECT newscompteur FROM 1two_news_commentaires WHERE newscompteur='$list_recherche[5]'";
- $res_nb_commentaires = @mysql_query($query,$db);
- $list_nb_commentaires=mysql_num_rows($res_nb_commentaires);
- echo "<span class='textesmall'><a href='?news=$list_recherche[5]&action=poster#com' class='lien1'>$list_nb_commentaires commentaire(s)</a> - <a href='?news=$list_recherche[5]&action=poster#postcom' class='lien1'>Poster un commentaire</a></span>";
- echo "</td></tr>";
- echo "</table>";
- }
- }
- }
- ?>
- <?php //------------------------------- Gestion des commentaires -------------------------------
- if ($_GET['action']=="poster" )
- {
- $query="SELECT titre, texte, photo, DATE_FORMAT(date_ins, '%d-%m-%Y'), heure_ins, compteur FROM 1two_news_news WHERE compteur='$news'";
- $res_news_commentaire = @mysql_query($query,$db);
- $list_news_commentaire=@mysql_fetch_row($res_news_commentaire);
- echo "<table width='100%' border='0' cellspacing='2' cellpadding='0' bgcolor='#F7F7F7' class='cadrenews'>";
- echo "<tr>";
- echo "<td>";
- echo "<table width='100%' border='0' cellspacing='0' cellpadding='3'>";
- echo "<tr>";
- echo "<td width='60%' valign='top' class='textebig'>$list_news_commentaire[0]</td>";
- echo "<td width='40%' align='right' valign='top' class='textedate'>Posté le $list_news_commentaire[3]<br>à $list_news_commentaire[4]</td>";
- echo "</tr>";
- echo "</table>";
- echo "<table width='100%'>";
- echo "<tr>";
- echo "<td width='100%' valign='top' class='texte'>"; if ($list_news_commentaire[2]!="" ) {echo "<img src='$list_news_commentaire[2]' width='150' align='left'>";} echo $list_news_commentaire[1] . "</td>";
- echo "</tr>";
- echo "</table>";
- echo "</td></tr>";
- echo "</table><br>";
- if (isset($_POST['soumettrecommentaire']))
- {
- if (($_POST['soumettrecommentaire']=="Envoyer" ) and ($_POST['nom']!="" ) and ($_POST['commentaire']!="" ))
- {
- $nom=strip_tags($nom);
- $commentaire=strip_tags($commentaire);
- $query="INSERT INTO 1two_news_commentaires (newscompteur, nom, commentaire, date_ins, heure_ins) VALUES ('$news', '$nom', '$commentaire', NOW(), NOW())";
- $result = mysql_query($query,$db);
- echo "<span class='textebig'><img src='design/ls-valid.gif'> <strong>Votre commentaire a été soumis.</strong></span><br><hr size='1'><br>";
- $nom=""; $email=""; $siteweb=""; $commentaire="";
- }
- else
- {
- if ($_POST['soumettrecommentaire']=="Envoyer" )
- {
- if ($_POST['nom']=="" ) {echo "<span class='textebig'><font color='#FF0000'><strong>- Le champs nom est requis</strong></font></span><br><br>";}
- if ($_POST['commentaire']=="" ) {echo "<span class='textebig'><font color='#FF0000'><strong>- Le champs commentaire est requis</strong></font></span><br><br>";}
- }
- }
- }
- ?>
- <?php echo "<span class='textebig'><a name='com'>Commentaires :</a></span><br><br>";
- $query="SELECT newscompteur, nom, email, siteweb, commentaire, DATE_FORMAT(date_ins, '%d-%m-%Y'), heure_ins, compteur FROM 1two_news_commentaires WHERE newscompteur='$news' ORDER BY date_ins DESC , heure_ins DESC";
- $res_get_commentaire = @mysql_query($query,$db);
- if (@mysql_num_rows($res_get_commentaire)!=0)
- {
- $nb=mysql_num_rows($res_get_commentaire);
- for ($i=0; $i<$nb; $i=$i+1)
- {
- $list_get_commentaire=@mysql_fetch_row($res_get_commentaire);
- ?>
- <?php echo "<table class='cadrecommentaires' width='100%'><tr><td><span class='texte'>Posté le $list_get_commentaire[5], par ";
- if ($list_get_commentaire[2]!="" ) {echo "<a href='mailto:$list_get_commentaire[2]' class='lien1'>$list_get_commentaire[1]</a>";}
- else {echo "$list_get_commentaire[1]";}
- if ($list_get_commentaire[3]!="" ) {echo " - <a href='$list_get_commentaire[3]' class='lien1' target='_blank'>Site</a>";}
- echo "<br><br></span>";
- echo "<span class='texte'>$list_get_commentaire[4]</span></td></tr></table>"; ?><br>
- <?php }
- }
- ?>
- <span class="textebig"><a name="postcom">Ajouter un commentaire</a></span>
- <form name="form1" id="form1" method="post" action="">
- <table width="100%" border="0" cellspacing="6" cellpadding="0" class="texte">
- <tr>
- <td>Nom et Prénom :<br /> <input name="nom" type="text" size="40" value="<?php echo $nom ?>" /></td>
- </tr>
- <tr>
- <td>Commentaire :<br /> <textarea name="commentaire" cols="50" rows="7"><?php echo $commentaire ?></textarea></td>
- </tr>
- <tr>
- <td><input type="submit" name="soumettrecommentaire" value="Envoyer" /></td>
- </tr>
- </table>
- </form>
- <?php }
- //------------------------------- Affichage des articles -------------------------------
- ?>
- <?php if (($_GET['action']!="poster" ) and ($_POST['rechercher']!="OK" ))
- {
- $query="SELECT ordre_news, nbr_news FROM 1two_news_preferences";
- $res_ordre_news = @mysql_query($query,$db);
- $list_ordre_news=mysql_fetch_row($res_ordre_news);
- if ($list_ordre_news[0]=="du plus ancien au plus récent" )
- {
- $query="SELECT titre, texte, photo, DATE_FORMAT(date_ins, '%d-%m-%Y'), heure_ins, compteur FROM 1two_news_news ORDER BY date_ins ASC , heure_ins ASC";
- $res_news = @mysql_query($query,$db);
- }
- else
- {
- $query="SELECT titre, texte, photo, DATE_FORMAT(date_ins, '%d-%m-%Y'), heure_ins, compteur FROM 1two_news_news ORDER BY date_ins DESC , heure_ins DESC";
- $res_news = @mysql_query($query,$db);
- }
- if (@mysql_num_rows($res_news)!=0)
- {
- $nb=mysql_num_rows($res_news);
- $nbpage=ceil($nb/$list_ordre_news[1]);
- if ($_GET['page']=="" ) {$page=1;}
- for ($i=0; $i<$nb; $i=$i+1)
- {
- $list_news=@mysql_fetch_row($res_news);
- if ( ($i>=$list_ordre_news[1]*$page-$list_ordre_news[1]) and ($i<$list_ordre_news[1]*$page) )
- {
- echo "<table width='100%' border='0' cellspacing='2' cellpadding='0' bgcolor='#F7F7F7' class='cadrenews'>";
- echo "<tr>";
- echo "<td>";
- echo "<table width='100%' border='0' cellspacing='0' cellpadding='3'>";
- echo "<tr>";
- echo "<td width='60%' valign='top' class='textebig'>$list_news[0]</td>";
- echo "<td width='40%' align='right' valign='top' class='textedate'>Posté le $list_news[3]<br>à $list_news[4]</td>";
- echo "</tr>";
- echo "</table>";
- echo "<table width='100%'>";
- echo "<tr>";
- echo "<td width='100%' valign='top' class='texte'>"; if ($list_news[2]!="" ) {echo "<img src='$list_news[2]' width='150' align='left'>";} echo $list_news[1] . "</td>";
- echo "</tr>";
- echo "</table><br>";
- $query="SELECT newscompteur FROM 1two_news_commentaires WHERE newscompteur='$list_news[5]'";
- $res_nb_commentaires = @mysql_query($query,$db);
- $list_nb_commentaires=mysql_num_rows($res_nb_commentaires);
- echo "<span class='textesmall'><a href='?news=$list_news[5]&action=poster#com' class='lien1'>$list_nb_commentaires commentaire(s)</a> - <a href='?news=$list_news[5]&action=poster#postcom' class='lien1'>Poster un commentaire</a></span>";
- echo "</td></tr>";
- echo "</table><br><br>";
- }
- else {}
- }
- }
- echo "<div align='right' class='texte'>Page ";
- for ($j=1; $j<=$nbpage; $j++) { echo " <a href='?page=$j' class='lien1'>$j</a> "; }
- echo "</div>";
- }
- ?>
|
Voici le code php du script sur la page administration qui permet d'ajouter des news :
Code :
- <?PHP
- if ($_GET['session']=="deconnexion" )
- {
- session_destroy();
- echo "<br><span class='texte'>Vous avez été déconnecté. <a href='index.php' class='lien1'>Cliquez ici</a> pour vous reconnecter.</span>";
- }
- else
- {
- $query="SELECT * FROM 1two_news_admin";
- $res_admin = @mysql_query($query,$db);
- $list_admin=@mysql_fetch_row($res_admin);
- if (($_SESSION["username"]==$list_admin[0]) and ($_SESSION["password"]==$list_admin[1]))
- {
- ?>
- <table width="100%" border="0" cellspacing="5" cellpadding="0">
- <tr>
-
- <td class="texte"><a href="?menu=liste" class="lien2">Liste des news</a> | <a href="?menu=ajouter" class="lien2">Ajouter
- une news</a> | <a href="?menu=preferences" class="lien2">Préférences</a>
- | <a href="?menu=commentaires" class="lien2">Gestion des commentaires</a></td>
- <td align="right"><a href="?session=deconnexion" class="lien2">Déconnexion</a></td>
- </tr>
- </table>
- <table width="100%" border="0" cellspacing="5" cellpadding="0">
- <tr>
- <td>
- <?PHP
- if (($_POST['SubmitNews']=="Valider" ) and ($titre!="" ) and ($texte!="" ))
- {
- $query="INSERT INTO 1two_news_news (titre, texte, date_ins, heure_ins) VALUES ('$titre', '$texte', NOW(), NOW())";
- $result=mysql_query($query,$db);
- echo "<span class='textebig'><img src='../design/ls-valid.gif'> Article soumis avec succès.</span><br><hr size='1'>";
- $titre=""; $texte="";
- }
- if ($_GET['menu']=="ajouter" )
- {
- ?>
- <form name="form1" method="post" action=""><br>
-
- <table width="100%" border="0" cellspacing="5" cellpadding="0" class="texte">
- <tr>
- <td width="20%" align="right" valign="top">Titre : </td>
- <td><input name="titre" type="text" size="40" value="<?PHP echo $titre ?>"></td>
- <td width="60%" valign="top"> </td>
- </tr>
- <tr>
- <td align="right" valign="top">Texte : </td>
- <td><textarea name="texte" cols="40" rows="8"><?PHP echo $texte ?></textarea>
- </td>
- <td valign="top" class="tips">Vous pouvez ajouter du code HTML.</td>
- </tr>
- <tr>
- <td align="right"> </td>
- <td><input type="submit" name="SubmitNews" value="Valider"></td>
- <td> </td>
- </tr>
- </table>
- </form>
- <?PHP
- }
- ?>
- </td>
- </tr>
- </table>
- <table width="100%" border="0" cellspacing="5" cellpadding="0">
- <tr>
- <td>
- <?PHP
- if ($_GET['action']=="suppnews" )
- {
- $query="DELETE FROM 1two_news_news WHERE compteur='$compteur'";
- $res_supp = @mysql_query($query,$db);
- echo "<span class='textebig'><img src='../design/ls-valid.gif'> Article supprimé avec succès.</span><br><hr size='1'>";
- }
- if ($_POST['SubmitEdit']=="Modifier" )
- {
- $query="UPDATE 1two_news_news SET titre='$titre', texte='$texte', date_ins='$date' WHERE compteur='$compteur'";
- $res_modif = @mysql_query($query,$db);
- echo "<span class='textebig'><img src='../design/ls-valid.gif'> Article modifié avec succès.</span><br><hr size='1'>";
- }
- if ($_GET['action']=="editnews" )
- {
- $query="SELECT * FROM 1two_news_news WHERE compteur='$compteur'";
- $res_edit=mysql_query($query,$db);
- $list_edit=@mysql_fetch_row($res_edit);
- echo "<span class='textebig'>Edition de la news $list_edit[0]</span>";
- ?>
- <form name="form1" method="post" action="">
- <table width="100%" border="0" cellspacing="5" cellpadding="0" class="texte">
- <tr>
- <td width="20%" align="right" valign="top">Titre : </td>
- <td><input name="titre" type="text" size="40" value="<?PHP echo $list_edit[0]; ?>"></td>
- </tr>
- <tr>
- <td align="right" valign="top">Texte : </td>
- <td><textarea name="texte" cols="40" rows="8"><?PHP echo $list_edit[1]; ?></textarea></td>
- </tr>
- <tr>
- <td align="right" valign="top">Date : </td>
- <td><input type="text" name="date" value="<?PHP echo $list_edit[3]; ?>"></td>
- </tr>
- <tr>
- <td align="right"> </td>
- <td><input type="submit" name="SubmitEdit" value="Modifier"></td>
- </tr>
- </table>
- </form>
- <?PHP
- }
- ?>
- </td>
- </tr>
- </table>
- <table width="100%" border="0" cellspacing="5" cellpadding="0">
- <tr>
- <td>
- <?PHP
- if (($_GET['menu']=="liste" ) OR ($_GET['menu']=="" ))
- {
- ?>
- <table width="100%" border="0" align="center" cellpadding="3" cellspacing="2" bordercolor="#000000" class="texte">
- <tr align="center" bgcolor="D9D9D9">
- <td width="30%"><strong>Titre</strong></td>
- <td width="100"><strong>Date insersion</strong></td>
- <td><strong>Upload photo</strong></td>
- <td width="70"><strong>Photo</strong></td>
- <td width="30"><strong>Modifier</strong></td>
- <td width="30"><strong>Supprimer</strong></td>
- </tr>
- <?PHP
- $query="SELECT * FROM 1two_news_news ORDER BY date_ins DESC , heure_ins DESC";
- $res_news = @mysql_query($query,$db);
- if (@mysql_num_rows($res_news)!=0)
- {
- $nb=mysql_num_rows($res_news);
- for ($i=0; $i<$nb; $i=$i+1)
- {
- $list_news=@mysql_fetch_row($res_news);
- if ($i % 2 == 0) { echo "<tr bgcolor=\"#EEEEEE\" align=\"center\">"; }
- else { echo "<tr bgcolor=\"#E6E6E6\" align=\"center\">"; }
- echo "<td>" . $list_news[0] . "</td>";
- echo "<td>" . $list_news[3] . "</td>";
- echo "<td>";
- ?>
- <FORM METHOD="POST" ENCTYPE="multipart/form-data" action="upload.php">
- <INPUT TYPE=FILE NAME="file"><input type="hidden" name="compteur" value="<?PHP echo $list_news[5]; ?>">
- <INPUT TYPE=SUBMIT NAME="upload_photo_news" value="<?PHP echo "Download"; ?>">
- </FORM>
- <?PHP
- echo "</td>";
- echo "<td>"; if ($list_news[2]!="" ) { echo "<img src='../" . $list_news[2] . "' width='70'><br>"; echo "<a href='delete.php?compteur=$list_news[5]'>supprimer</a>"; } echo "</td>";
- echo "<td><a href=\"?menu=liste&action=editnews&compteur=$list_news[5]\"><img src='../design/edit.gif' border='0' alt='Editer la news " . $list_news[0] . "'></a></td>";
- echo "<td><a href=\"?menu=liste&action=suppnews&compteur=$list_news[5]\"><img src='../design/icone-supprimer.gif' border='0' alt='Supprimer la news " . $list_news[0] . "'></a></td>";
- echo "</tr>";
- }
- }
- ?>
- </table>
- <?PHP
- }
- ?>
- </td>
- </tr>
- </table>
- <table width="100%" border="0" cellspacing="5" cellpadding="0">
- <tr>
- <td>
- <?PHP
- if ($_GET['menu']=="preferences" )
- {
- if ($_POST['SubmitPreferences']=="Valider les préférences" )
- {
- $query_update_preferences="UPDATE 1two_news_preferences SET ordre_news='$ordre_news'";
- $res_update_preferences=@mysql_query($query_update_preferences,$db);
- $query_update_preferences="UPDATE 1two_news_preferences SET nbr_news='$nbr_news'";
- $res_update_preferences=@mysql_query($query_update_preferences,$db);
- echo "<span class='textebig'><img src='../design/ls-valid.gif'> Vos préférences ont été sauvegardées avec succès.</span><br><hr size='1'>";
- }
- $query="SELECT ordre_news, nbr_news FROM 1two_news_preferences";
- $res_user_profile=@mysql_query($query,$db);
- $list_user_profile=mysql_fetch_row($res_user_profile);
- ?>
- <form name="form3" method="post" action="">
- <table width="100%" border="0" cellspacing="3" cellpadding="0" class="texte">
- <tr>
- <td width="20%" align="right">Affichage des articles : </td>
- <td><select name="ordre_news">
- <option <?PHP if ($list_user_profile[0]=="du plus récent au plus ancien" ) {echo "selected";} ?>>du plus récent au plus ancien</option>
- <option <?PHP if ($list_user_profile[0]=="du plus ancien au plus récent" ) {echo "selected";} ?>>du plus ancien au plus récent</option>
- </select></td>
- </tr>
- <tr>
- <td align="right">Nombre d'article par page : </td>
- <td><input type="text" name="nbr_news" value="<?PHP echo $list_user_profile[1]; ?>"></td>
- </tr>
- <tr>
- <td> </td>
- <td><input type="submit" name="SubmitPreferences" value="Valider les préférences"></td>
- </tr>
- </table>
- </form>
- <?PHP
- }
- ?>
- </td>
- </tr>
- </table>
- <table width="100%" border="0" cellspacing="5" cellpadding="0">
- <tr>
- <td>
- <?PHP
- if ($_GET['menu']=="commentaires" )
- {
- ?>
- <?PHP
- if ($_GET['action']=="delete" )
- {
- $query="DELETE FROM 1two_news_commentaires WHERE compteur='$compteur'";
- $res_modifier = @mysql_query($query,$db);
- echo "<span class='textebig'><img src='../design/ls-valid.gif'> Le commentaire a été supprimée avec succès.</span><br><hr size='1'><br>";
- }
- ?>
- <table width="100%" border="0" cellspacing="2" cellpadding="0" class="texte">
- <tr valign="top">
- <td class="texte">Liste des commentaires du plus récent au plus ancien :</td>
- </tr>
- </table>
- <table width="100%" border="0" align="center" cellpadding="3" cellspacing="2" bordercolor="#000000" class="texte">
- <tr align="center" bgcolor="D9D9D9">
- <td width="100"><strong>Ecrit par</strong></td>
- <td width="100"><strong>Date insersion</strong></td>
- <td width="150"><strong>Email</strong></td>
- <td width="150"><strong>Site web</strong></td>
- <td><strong>Commentaire</strong></td>
- <td width="30"><strong>Supprimer</strong></td>
- </tr>
- <?PHP
- $query="SELECT * FROM 1two_news_commentaires ORDER BY date_ins DESC , heure_ins DESC";
- $res_commentaires = @mysql_query($query,$db);
- if (@mysql_num_rows($res_commentaires)!=0)
- {
- $nb=mysql_num_rows($res_commentaires);
- for ($i=0; $i<$nb; $i=$i+1)
- {
- $list_commentaires=@mysql_fetch_row($res_commentaires);
- if ($i % 2 == 0) { echo "<tr bgcolor=\"#EEEEEE\" align=\"center\">"; }
- else { echo "<tr bgcolor=\"#E6E6E6\" align=\"center\">"; }
- echo "<td>" . $list_commentaires[1] . "</td>";
- echo "<td>" . $list_commentaires[5] . "</td>";
- echo "<td>" . $list_commentaires[2] . "</td>";
- echo "<td>" . $list_commentaires[3] . "</td>";
- echo "<td>" . $list_commentaires[4] . "</td>";
- echo "<td><a href=\"?menu=commentaires&action=delete&compteur=$list_commentaires[7]\"><img src='../design/icone-supprimer.gif' border='0' alt='Supprimer le commentaire'></a></td>";
- echo "</tr>";
- }
- }
- ?>
- </table>
- <?PHP
- }
- ?>
- </td>
- </tr>
- </table>
- <?PHP
- }
- else
- {
- session_destroy();
- ?>
- <form name="form2" method="post" action="">
- <table width="100%" border="0" cellspacing="3" cellpadding="0" class="texte">
- <tr>
- <td width="30%" align="right">Nom d'utilisateur : </td>
- <td><input type="text" name="username"></td>
- </tr>
- <tr>
- <td align="right">Mot de passe : </td>
- <td><input type="password" name="password"></td>
- </tr>
- <tr>
- <td> </td>
- <td><input type="submit" name="SubmitUser" value="Connexion"></td>
- </tr>
- </table>
- </form><br><br>
- <?PHP
- }
- }
- ?>
|
Je vous remercie de votre aide. Message édité par esteban72 le 01-08-2008 à 09:20:10
|