<?

  include_once '../config.inc.php';
  if (!($result1 = mysql_query ('select * from properties')))
  {
    exit ('<b>Error:</b>' . mysql_error ());
    ;
  }

  $row1 = mysql_fetch_row ($result1);
  for ($i = 0; $i < sizeof ($row1); ++$i)
  {
    define (mysql_field_name ($result1, $i), $row1[$i]);
  }

  include '../lang/' . language;
  echo '
';
  if (txt_direction == 'LTR')
  {
    echo '<html>';
  }
  else
  {
    echo '<html dir="rtl">';
  }

  echo '<head>
<title>';
  echo title;
  echo '</title>
	<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=';
  echo encoding;
  echo '">
	<META NAME="keywords" CONTENT="';
  echo keywords;
  echo '">
	<META NAME="description" CONTENT="';
  echo description;
  echo '">
</head>
';
  echo bodytagset;
  echo '
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="10" CELLPADDING="0" ALIGN="center"><TR><TD ALIGN="right">';
  if ($_GET['action'] == 'Vote')
  {
    mysql_query ('' . 'DELETE FROM poll_ip WHERE pollID=\'' . $_GET['id'] . '\' AND timeout<\'' . ($curtime[0] - 3600) . '\'');
    $result = mysql_query ('' . 'SELECT * FROM poll_ip WHERE pollID=\'' . $_GET['id'] . '\' AND votersIP=\'' . $_SERVER['REMOTE_ADDR'] . '\'');
    echo '
	';
    if ($row = mysql_fetch_array ($result))
    {
      echo '		<DIV ALIGN="center"><FONT color=navy style="font-family:tahoma; font-size:12px;"><B>';
      echo $text__vote_accepted;
      echo ' IP: ';
      echo $row['votersIP'];
      echo '</B><BR>';
      echo $text__vote_again;
      echo ': <B><FONT COLOR="Red">';
      echo round ((3600 - ($curtime[0] - $row['timeout'])) / 60, 0);
      echo '</FONT></B> min</FONT></DIV><BR>
	';
    }
    else
    {
      if ($_SERVER['REMOTE_ADDR'])
      {
        if (!(mysql_query ('' . 'INSERT INTO poll_ip VALUES(\'' . $_GET['id'] . '\',\'' . $_SERVER['REMOTE_ADDR'] . '\',\'' . $curtime['0'] . '\')')))
        {
          exit ('Invalid query');
          ;
        }
      }

      if (0 <= $_GET['answer'])
      {
        if (!($result = mysql_query ('' . 'SELECT * FROM poll_result WHERE id=\'' . $_GET['id'] . '\'')))
        {
          exit ('Invalid query');
          ;
        }

        $row = mysql_fetch_array ($result);
        $split = split ('
', $row['result']);
        $split[$_GET['answer']] = $split[$_GET['answer']] + 1;
        $new_value = join ('
', $split);
        $SQL = '' . 'UPDATE poll_result SET result = \'' . $new_value . '\' WHERE id=\'' . $_GET['id'] . '\'';
        if (!(mysql_query ($SQL)))
        {
          exit ('Invalid query');
          ;
        }
      }
    }
  }

  if (!($result = mysql_query ('' . 'SELECT * FROM poll_result WHERE id=\'' . $_GET['id'] . '\'')))
  {
    exit ('Invalid query');
    ;
  }

  $row = mysql_fetch_array ($result);
  $split = split ('
', $row['result']);
  $total = array_sum ($split);
  if (!($result1 = mysql_query ('' . 'SELECT * FROM poll WHERE id=\'' . $_GET['id'] . '\'')))
  {
    exit ('Invalid query');
    ;
  }

  $row1 = mysql_fetch_array ($result1);
  $split1 = split ('
', $row1['answer']);
  echo '
<DIV ALIGN="center"><font color="#800000" style="color: Maroon; font-family: Verdana; font-size: 12px;">';
  echo $row1['question'];
  echo '</font></DIV><BR>
<TABLE BORDER="0" CELLSPACING="5" CELLPADDING="0" ALIGN="center">
';
  for ($i = 0; $i < sizeof ($split1); ++$i)
  {
    echo '<TR>
				<TD ALIGN="right">
					<font style="color: Navy; font-family: Tahoma; font-size: 11px;">';
    echo stripslashes ($split1[$i]);
    echo '</font>
				</TD>
				<TD>
					';
    if ((0 < $split[$i] AND 0 < $total))
    {
      $procent = round ($split[$i] * 100 / $total, 0);
      $procent1 = round ($split[$i] * 100 / $total, 1);
    }
    else
    {
      $procent = 0;
      $procent1 = 0;
    }

    echo '					<img src="images/line_bar.gif" height=12 width=1>';
    if (0 < $procent)
    {
      echo '<img src="images/bar.gif" height=12 width=';
      echo $procent;
      echo '>';
    }

    if ($procent < 100)
    {
      echo '<img src="images/empty_bar.gif" height=12 width=';
      echo 100 - $procent;
      echo '>';
    }

    echo '<img src="images/line_bar.gif" height=12 width=1>
					<font style="font-family: Tahoma; font-size: 11px;">';
    echo $split[$i];
    echo ' (';
    echo $procent1 . '%';
    echo ')</font>
				</TD>
			</TR>';
  }

  echo '</TABLE>

<DIV ALIGN="center">
<BR><font color="#800000" style="color: navy; font-family: Tahoma; font-size: 12px; font-weight: bold;"><B>';
  echo $text__Total_votes;
  echo ' ';
  echo $total;
  echo '</B></font><br>
</TD></TR></TABLE>
<br><div align="center"><input type="button" value="';
  echo $text__Close_this_window;
  echo '" onClick="window.self.close()"></div>


</BODY></HTML>';
?>
