<?

$IP = $_SERVER['REMOTE_ADDR'];
include('concha.php');
mysql_connect ("$host", "$usuario", "$contra");
mysql_select_db ("$basedatos");

$sql = "SELECT * FROM encuestas";

$consulta = mysql_query ($sql);
while ($row = mysql_fetch_array($consulta))
{
$ID = $row["ID"];
$pregunta=$row["pregunta"];
$r1=$row["r1"];
$r10=$row["r10"];
$r2=$row["r2"];
$r3=$row["r3"];
$r4=$row["r4"];
$r5=$row["r5"];
$r6=$row["r6"];
$r7=$row["r7"];
$r8=$row["r8"];
$r9=$row["r9"];
$t1=$row["t1"];
$t10=$row["t10"];
$t2=$row["t2"];
$t3=$row["t3"];
$t4=$row["t4"];
$t5=$row["t5"];
$t6=$row["t6"];
$t7=$row["t7"];
$t8=$row["t8"];
$t9=$row["t9"];


?>
<table width="248" border="0" align="center" cellpadding="0" cellspacing="0">
  <tbody>
    <tr>
      <td colspan="3" background="https://www.radiosnet.com.ar/imag/<?php echo $estilo ?>/imag/arribaVENTANA.gif" width="248" height="50"><div align="center" class="e<?php echo $estilo ?>">
        <div align="left">
          <p align="center"><span style=";font-family:<?php echo $style_titulo ?>;font-size:13px;<?php if ($estilo >= 97) {?>color:#1D1D1D;
           <?php } else {?>color:#FFFFFF;<?php }?>">ENCUESTA</span></p>
        </div>
      </div></td>
    </tr>
    <tr>
      <td background="https://www.radiosnet.com.ar/imag/<?php echo $estilo ?>/imag/fdo-04.gif">&nbsp;</td>
      <td valign="top"  background="fondo.gif"><table class="texto" width="223" border="0" cellpadding="0" cellspacing="0">
        <tbody>
          <tr>
            <td width="209" height="118"><div align="center"><b><?php echo $pregunta ?></b></div>
                  <?


///calculo el cien por ciento
$cien = $t1 + $t2 + $t3 + $t4 + $t5 + $t6 + $t7 + $t8 + $t9 + $t10;
///calculo el porcentaje

if ($t1 == 0) {$ct1 = 0;} else {$ct1 = $t1 * 100 / $cien;};
if ($t2 == 0) {$ct2 = 0;} else {$ct2 = $t2 * 100 / $cien;};
if ($t3 == 0) {$ct3 = 0;} else {$ct3 = $t3 * 100 / $cien;};
if ($t4 == 0) {$ct4 = 0;} else {$ct4 = $t4 * 100 / $cien;};
if ($t5 == 0) {$ct5 = 0;} else {$ct5 = $t5 * 100 / $cien;};
if ($t6 == 0) {$ct6 = 0;} else {$ct6 = $t6 * 100 / $cien;};
if ($t7 == 0) {$ct7 = 0;} else {$ct7 = $t7 * 100 / $cien;};
if ($t8 == 0) {$ct8 = 0;} else {$ct8 = $t8 * 100 / $cien;};
if ($t9 == 0) {$ct9 = 0;} else {$ct9 = $t9 * 100 / $cien;};
if ($t10 == 0) {$ct10 = 0;} else {$ct10 = $t10 * 100 / $cien;};


?>
                  <style type="text/css">
<!--
.Estilo156 {
font-family:"Trebuchet MS";

font-size: 9px;}

.Estilo159 {
font-family:"Trebuchet MS";
font-size: 12px;
color:#333333;}

.Estilo157 {
font-family:"Arial";

font-size: 8px;}
-->
         </style>
                  <form action="<?php echo $dom ?>/votar.php" method="post" name="form1" id="form1">
                    <input name="ID" type="hidden" value="<?php echo $ID ?>" />
                    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="Estilo159">
                      <?php $var_r = $r1;

$var_ct = $ct1; 
$var_t = "t1"; 
include 'encuesta_inc.php';?>
                      <?php $var_r = $r2;

$var_ct = $ct2; 
$var_t = "t2"; 
include 'encuesta_inc.php';?>
                      <?php $var_r = $r3;

$var_ct = $ct3; 
$var_t = "t3"; 
include 'encuesta_inc.php';?>
                      <?php $var_r = $r4;

$var_ct = $ct4; 
$var_t = "t4"; 
include 'encuesta_inc.php';?>
                      <?php $var_r = $r5;

$var_ct = $ct5; 
$var_t = "t5"; 
include 'encuesta_inc.php';?>
                      <?php $var_r = $r6;

$var_ct = $ct6; 
$var_t = "t6"; 
include 'encuesta_inc.php';?>
                      <?php $var_r = $r7;

$var_ct = $ct7; 
$var_t = "t7"; 
include 'encuesta_inc.php';?>
                      <?php $var_r = $r8;

$var_ct = $ct8; 
$var_t = "t8"; 
include 'encuesta_inc.php';?>
                      <?php $var_r = $r9;

$var_ct = $ct9; 
$var_t = "t9"; 
include 'encuesta_inc.php';?>
                      <?php $var_r = $r10;

$var_ct = $ct10; 
$var_t = "t10"; 
include 'encuesta_inc.php';?>
                      <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                      </tr>
                      <tr>
                        <td height="24" colspan="4"><div align="center">
                            <?php   $encuesta = $_COOKIE["$ID"]; 
    ?>
                            <?php 




$sql3 = "SELECT * FROM ip_encuestas WHERE encuesta = '$ID';";



$consulta3 = mysql_query ($sql3);

while ($row3 = mysql_fetch_array($consulta3))

{

$IP_e = $row3["IP"];




}

mysql_free_result($consulta3);



?>
                            <?php    if ($encuesta == 1 or $IP_e == $IP) {echo "Gracias por votar";} else {?>
                            <input  class="Estilo159" type="submit" name="button" id="button" value="Votar &raquo;" />
                            <?php };?>
                        </div></td>
                      </tr>
                    </table>
                  </form></td>
          </tr>
        </tbody>
      </table></td>
      <td background="https://www.radiosnet.com.ar/imag/<?php echo $estilo ?>/imag/fdo-06.gif">&nbsp;</td>
    </tr>
    <tr>
      <td><img src="https://www.radiosnet.com.ar/imag/<?php echo $estilo ?>/imag/fdo-07.gif" width="14" height="15" /></td>
      <td><img src="https://www.radiosnet.com.ar/imag/<?php echo $estilo ?>/imag/fdo-08.gif" width="223" height="15" /></td>
      <td><img src="https://www.radiosnet.com.ar/imag/<?php echo $estilo ?>/imag/fdo-09.gif" width="11" height="15" /></td>
    </tr>
  </tbody>
</table>
<?

}
mysql_free_result($consulta);


?>
