Tfe

Ongi etorri tfe-ren webgunera...

Old stuff/old_sites/www/include/sondages.php

(Deskargatu)
<div class="full">
<h3>Le sondage du moment</h3>
<?
if (empty($axx)) { echo "<p>Vous devez &ecirc;tre identifi&eacute;s pour acc&eacute;der aux sondages</p>"; }
else
{






$ip = $REMOTE_ADDR;
$var = ip_read("sondages");


	if (empty($_POST['vote']) and empty($var[$ip]))
	{
	    $query = "SELECT * FROM mp_sondages ORDER BY id DESC LIMIT 1";
	    $result = mysql_query($query) or die(mysql_error());
	    $row = mysql_fetch_assoc($result);
	    echo "<form action=\"index.php?page=sondages&amp;id=".$row{'id'}."\" method=\"post\">
	    ";
	    echo "<dl>
	    <dt>Question</dt><dd>".$row{'question'}."</dd>
	    <dt>R&eacute;ponses</dt><dd><select name=\"vote\">";
	    foreach(array("a","b","c","d","e","f") as $key)
		{ if (!empty($row{$key})) { echo  "<option value=\"".$key."\">".$row{$key}."</option>\n"; } }
	    echo "</select></dd>
	    <dt>Validation</dt><dd><input type=\"submit\" value=\"Ok\" /></dd>
	    </dl>
	    </form>";
	
	}
	elseif(empty($var["$ip"]))
	{
	    $vote = preg_replace("[^abcdef]","",$_POST['vote']);
	    $id = preg_replace("/\D/","",$_GET['id']);
	    $query = "UPDATE mp_sondages_rep set $vote = $vote+1";
	    mysql_query($query) or die(mysql_error());
	    $var["$ip"]["pseudo"]= $nick;
	    ip_write("sondages",$var);
	    echo "<p>Votre vote a bien &eacute;t&eacute; pris en compte !</p>";
	}
	else 
	{
	    echo "<p>Vous avez d&eacute;j&agrave; vot&eacute;</p>";
	}
?>    

<h3>Les r&eacute;sultats</h3>
<?
	    $query = "SELECT * FROM mp_sondages ORDER BY id DESC LIMIT 1";
	    $result = mysql_query($query) or die(mysql_error());
	    $row = mysql_fetch_assoc($result);
	    $query = "SELECT * FROM mp_sondages_rep WHERE ref='".$row{'id'}."'";
	    $result = mysql_query($query) or die(mysql_error());
	    $rep = mysql_fetch_assoc($result);
	    
	    
	    echo "<dl>
	    <dt>Question</dt><dd>".$row{'question'}."</dd>
	    </dl>
	    <ul>";
	    
	    foreach(array("a","b","c","d","e","f") as $key)
		{ 
		if (!empty($row{$key})) 
		    { 
			echo  "<li>".$row{$key}." : ".$rep{$key}." vote(s)</li>\n"; 
		    } 
		}
	    echo "</ul>";
	    
}
?>



</div>