bon g trouver ce script sur le net car moi et les long script pour le moment c'est pas sa!mais le serveur me dit qu'il y a une erreur à la ligne 5
<?
if($sondage != 1)
{
$temps = 86400;//temps défini 24 heures, vous pouvez le modifier (60 secondes=1 minutes, donc 3600 secondes=1 heures donc 3600*24=86400
setcookie("sondage", $vot, time()+ $temps);
}
?>
<?
$vote = "";//ne pas toucher!!
$fichier = "donnees.txt";//nom du fichier où seront sauvegardés les votes
/***************************************************************/
/* Partie que vous pouvez modifier selon vos choix */
/***************************************************************/
$jour = "12";//jour d'arret du sondage
$mois = "09";//mois d'arret du sondage
$annee = "2007";//année d'arret du sondage
$secondes = "00";//vous pouvez laisser à 00 ou définir des secondes
$minutes = "05";//vous pouvez laisser à 00 ou définir des minutes
$heures = "11"; //vous pouvez laisser à 00 ou définir des heures
$appel = "Sondage terminé"; //l'expression qui s'affiche quand le sondage est terminé, mettre celle de votre choix
$image1 = "images/sond2.gif";//adresse de l'image affichant la barre des pourcentages de votes
$largtab = "140"; //largeur du tableau pricipal
$coulbor = "#000000"; //couleur des bordures du tableaux principal
$titr= "Sondage"; //titre du sondage
$coultitr = "#6666CC"; //couleur de la cellule du titre du sondage
$coulint = "#FFFFFF"; //couleur du tableaux interne
$coulchoi ="#FFFFFF"; //couleur de la cellule des différents choix
$coulpolictitr ="#F0B500"; //couleur de la police du titre du sondage
$coulpolicques ="#F0B500"; //couleur de la police de la question et du nombre de vote
$taillefont1= "+1"; //taille de la police du titre du sondage
$taillefont2= "0"; //taille de la police de la question et du nombre de votes
$taillefont3= "-1"; //taille de la police des choix
/********************************************************************/
function creerSondage()//ne pas toucher!!
{
global $fichier, $vote;//ne pas toucher!!
/*******************************************************************************************************************************
* Pour créer un nouveau sondage: *
* remplissez les champs suivants et effacez le fichier "donnees.txt" (s'il existe) et remettre un vierge à la place. *
* Vous pouvez en ajouter autant que vous le souhaitez, en suivant le même schéma et en ayant autant de 'reponse' que de 'vote'.*
* il y a déjà deux autres 'reponses' et 'votes' disponibles, vous pouvez les decommenter pour les utiliser *
*(pour cela enlever les barres obliques devant $vote['reponse'][] = "choix4"; et $vote['vote'][] = "0";) *
********************************************************************************************************************************/
$vote['question'] = "Que pensez vous de ce site ?";//Question du sondage
$vote['reponse'][] = "Site très satisfaisant, tout est parfait!";//Choix 1
$vote['reponse'][] = "Site bofff pas super! Quelque chose a changer!";//Choix 2
$vote['reponse'][] = "Site merdique ";//Choix 3
//$vote['reponse'][] = "choix4";//Choix 4
//$vote['reponse'][] = "choix5";Choix 5
$vote['vote'][] = "0";//réponse 1
$vote['vote'][] = "0";//réponse 2
$vote['vote'][] = "0";//réponse 3
//$vote['vote'][] = "0";//réponse 4
//$vote['vote'][] = "0"; //réponse 5
//ne plus toucher à partit d'ici
if ( count($vote['reponse']) != count($vote['vote']) )
{
?>Problème : le sondage a été mal conçu.<?
}
else
{
$vote_chaine = serialize($vote);
sauverDonnees($vote_chaine);
}
}
function sauverDonnees($vote_chaine)
{
global $fichier;
if (!is_writable($fichier))
{
?>Ecriture impossible!<?
}
elseif (!$f = fopen($fichier,'w'))
{
?>Problème fichier!<?
}
elseif (!fwrite($f, $vote_chaine))
{
?>Problème lors de l'écriture.<?
}
else
{
fclose($f);
}
}
function afficherSondage()
{
global $fichier, $vote,$action;
clearstatcache();
if ( (!file_exists($fichier)) || (filesize($fichier) < 1) )
{
creerSondage();
}
else
{
$vote = unserialize(file_get_contents($fichier));
}
if ($action!=1) {
afficherOptions();
}
else
{
if ($action==1) { afficherResultats(); }
}
}
function afficherOptions()
{
global $heures, $minutes, $secondes, $mois, $jour, $annee;
if (isset($_COOKIE['sondage'])) {
if(checkdate($mois,$jour,$annee)){
$maintenant = time();
$compte_rebours_fin = mktime($heures, $minutes, $secondes, $mois, $jour, $annee);
$reste = $compte_rebours_fin - $maintenant;
if($compte_rebours_fin <= $maintenant){
fin ();
}
}
if($compte_rebours_fin > $maintenant){
afficherResultats();
}
}
else
{
global $vote,$coulbor,$coultitr,$coulint,$coulchoi,$coulpolictitr,$taillefont1,$taillefont2,$taillefont3,$coulpolicques,$largtab,$titr;
$nbrElements = count($vote['reponse']);
if ( (!isset($_GET['vote-fait'])) || ($_GET['vote-fait'] != "ok" ) )
{
if ($nbrElements != count($vote['vote']) )
{
?>Problème : le sondage a été mal conçu.<?
}
else
{
global $heures, $minutes, $secondes, $mois, $jour, $annee;
if(checkdate($mois,$jour,$annee)){
$maintenant = time();
$compte_rebours_fin = mktime($heures, $minutes, $secondes, $mois, $jour, $annee);
$reste = $compte_rebours_fin - $maintenant;
if($compte_rebours_fin <= $maintenant){
fin ();
}
}
if($compte_rebours_fin > $maintenant){
?>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<form name="formulaire" method="get" action="<?=$_SERVER['PHP_SELF'];?>">
<input type="hidden" name="vote-fait" value="ok">
<input type="hidden" name="fait" value="1">
<input type="hidden" name="vot" value="1">
<table BORDER="0" CELLPADDING="1" CELLSPACING="0" align="center" bgcolor="<?=$coulbor;?>" width="<?=$largtab;?>"><tr><td ><table BORDER="0" CELLPADDING="0" CELLSPACING="0" align="center" bgcolor="<?=$coulint;?>" width="100%"><tr><td bgcolor="<?=$coultitr;?>" valign="middle" align="center" height="25" colspan="3"><font size="<?=$taillefont1;?>"><font color="<?=$coulpolictitr;?>"> <b><?=$titr;?></b> </font></font><br>
</td></tr><tr><td bgcolor="<?=$coulchoi;?>"> </td><td align="left" bgcolor="<?=$coulchoi;?>" valign="middle" nowrap><br>
<?
echo "<div align=\"center\"><font color=\"$coulpolicques\"><font size=\"$taillefont2\"><b>" .$vote['question']. "</b></font></font></div>";
for ($i=0; $i < $nbrElements; $i++)
{
?><br> <font color="<?=$coulpolicques;?>"><font size="<?=$taillefont3;?>"><input type="radio" name="choix" value="<?=$i;?>" onClick="document.formulaire.submit();"> <?
echo $vote['reponse'][$i]."</font></font></font><br>";
}
$nbrVotes = array_sum($vote['vote']);
echo "<br><div align=\"center\"><font color=\"$coulpolicques\"><font size=\"$taillefont2\"><b>Nombre de votes : </b>$nbrVotes</font></font><br></div>";
echo"<div align=\"center\"><a href=\""; echo $PHP_SELF; echo "?action=1\"><font color=\"$coulpolicques\" size=\"$taillefont2\" face=\"$pol\">Résultats</font></a></div>";
}
?>
<br>
</td><td bgcolor="<?=$coulchoi;?>"> </td></tr></table></td></tr></table>
</form>
<?
}
}
else
{
if(checkdate($mois,$jour,$annee)){
$maintenant = time();
$compte_rebours_fin = mktime($heures, $minutes, $secondes, $mois, $jour, $annee);
$reste = $compte_rebours_fin - $maintenant;
if($compte_rebours_fin <= $maintenant){
fin ();
}
}
if($compte_rebours_fin > $maintenant){
ajouterVote($_GET['choix']);
afficherResultats();
}
}
}
}
function ajouterVote($choix)
{
global $vote;
$vote['vote'][$choix] += 1;
$vote_chaine = serialize($vote);
sauverDonnees($vote_chaine);
}
function afficherResultats()
{
global $vote,$coulbor,$coultitr,$coulint,$coulchoi,$coulpolictitr,$taillefont1,$taillefont2,$taillefont3,$coulpolicques,$largtab,$titr,$image1,$image2;
$nbrElements = count($vote['reponse']);
$nbrVotes = array_sum($vote['vote']);
echo "<table BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"0\" align=\"center\" bgcolor=\"$coulbor\" width=\"$largtab\"><tr><td><table BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\" align=\"center\" bgcolor=\"$coulint\" width=\"100%\"><tr><td bgcolor=\"$coultitr\" colspan=\"3\" valign=\"middle\" align=\"center\" height=\"25\" nowrap><font size=\"$taillefont1\"><font color=\"$coulpolictitr\"><b>$titr</b></font></b></font></font></td></tr><tr><td bgcolor=\"$coulchoi\"> </td><td align=left valign=middle nowrap bgcolor=\"$coulchoi\"><br>";
echo "<div align=\"center\"><font color=\"$coulpolicques\"><font size=\"$taillefont2\"><b>" .$vote['question']. "</b></font></font></div><br>";
for ($i=0; $i < $nbrElements; $i++)
{
?>
<div align="center"><font color="<?=$coulpolicques;?>"><font size="<?=$taillefont3;?>"> <?=$vote['reponse'][$i];?></font></font></div> <img src="<?=$image1;?>" border="0" width="<?=round($vote['vote'][$i]*100/$nbrVotes, 2);?>" height="10" align="middle"><img src="<?=$image2;?>" border="0" width="<?=100-(round($vote['vote'][$i]*100/$nbrVotes, 2));?>" height="10" align="middle"><font color="<?=$coulpolicques;?>"> <font size="<?=$taillefont3;?>"><?=@round($vote['vote'][$i]*100/$nbrVotes, 0);?>%</font></font> <br>
<?
}
echo "<br><div align=\"center\"><font color=\"$coulpolicques\"><font size=\"$taillefont2\"><b>Nombre de votes :</b> $nbrVotes</font> </font></div>";
echo"<br></td><td bgcolor=\"$coulchoi\"> </td></tr>";
echo"</table></td></tr></table>";
}
function fin ()
{
global $vote,$coulbor,$coultitr,$coulint,$coulchoi,$coulpolictitr,$taillefont1,$taillefont2,$taillefont3,$coulpolicques,$largtab,$titr,$image1,$image2,$appel;
$nbrElements = count($vote['reponse']);
$nbrVotes = array_sum($vote['vote']);
echo "<table BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"0\" align=\"center\" bgcolor=\"$coulbor\" width=\"$largtab\"><tr><td><table BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\" bgcolor=\"$coulint\" width=\"100%\"><tr><td bgcolor=\"$coultitr\" colspan=\"2\" valign=\"middle\" align=\"center\" height=\"25\" nowrap><font size=\"$taillefont1\"><font color=\"$coulpolictitr\"><b>$titr</b></font></b></font></font></td></tr><tr><td colspan=\"2\" align=\"center\" valign=\"middle\" nowrap bgcolor=\"$coulchoi\"><br>";
echo "<font color=\"$coulpolicques\"><font size=\"$taillefont2\"><b>" .$vote['question']. "</b></font></font></td></tr>";
for ($i=0; $i < $nbrElements; $i++)
{
?>
<tr><td> </td><td align="center" valign="top" nowrap><font color="<?=$coulpolicques;?>"><font size="<?=$taillefont3;?>"> <?=$vote['reponse'][$i];?></font></font><br> <img src="<?=$image1;?>" border="0" width="<?=round($vote['vote'][$i]*100/$nbrVotes, 2);?>" height="10" align="middle"><img src="<?=$image2;?>" border="0" width="<?=100-(round($vote['vote'][$i]*100/$nbrVotes, 2));?>" height="10" align="middle"><font color="<?=$coulpolicques;?>"> <font size="<?=$taillefont3;?>"><?=@round($vote['vote'][$i]*100/$nbrVotes, 0);?>%</font></font> </td></tr>
<?
}
echo "<tr><td colspan=\"2\" align=\"center\"><font color=\"$coulpolicques\"><font size=\"$taillefont2\"><b>Nombre de votes :</b> $nbrVotes </font></font><br><font size=\"$taillefont2\"><font color=\"#ff0000\">$appel</font></font><br><br>";
echo"</td></tr></table></td></tr></table>";
}
?>