<?php
if ($votee =="true"){
if ($vote) echo "<b><font color=red> Спасибо за Ваше мнение! </font></b><p>";
if ($vote) {
$data = File("vote/base.txt");
$f = fopen("vote/base.txt","w");
fputs($f, "$data[0]");
for ($i=1;$i<count($data);$i++)
{
$votes = split("~", $data[$i]);
if ($i==$vote) $votes[0]++;
fputs($f,"$votes[0]~$votes[1]");
}
fclose($f);
$bun = "vote/ban.txt";
$ip = getenv("REMOTE_ADDR")."\r\n";
$fp = fopen($bun,"a");
fputs($fp, $ip);
fclose($fp);
}
echo '
<center>Считывание результатов...</center>
<SCRIPT LANGUAGE="JavaScript">
<!--
if (self.parent.frames.length == 0)
self.parent.location="?votee=see";
// -->
</SCRIPT>';
}
$found = 0;
$f=file("vote/ban.txt");
for($i=0; $i<count($f);$i++) {
if(trim($f[$i])==getenv("REMOTE_ADDR")) {
$found = 1 ;
break;
}
}
if ($found & !$votee =="see") {
echo '
<center>Считывание результатов...</center>
<SCRIPT LANGUAGE="JavaScript">
<!--
if (self.parent.frames.length == 0)
self.parent.location="?votee=see";
// -->
</SCRIPT>';
}
if (!$votee =="true" or !$votee =="see" & !$found)
{
$data = File("vote/base.txt");
echo '<form action="?votee=true" method="POST">
<input type="Hidden" name=id value=1>
<b>'.$data[0].'</b><br>';
for ($i=1; $i<count($data); $i++) {
$vopros = explode("~", $data[$i]);
echo '<input type="Radio" name=vote value='.$i.' checked>'.$vopros[1].'<br>';
}
echo '<br><input type="Submit" value=" Голосовать! "></form>';
}
if ($votee =="see") {
$arr=File("vote/base.txt");
for($i=0;$i<count($arr);$i++)
{
$arr2=explode("~",$arr[$i]);
$sum+=$arr2[0];
}
$data = File("vote/base.txt");
echo "<b>$data[0]</b><p>";
echo '<body>
<table cellSpacing="0" cellPadding="0" align="center" border="0" height="47">
<tbody>';
for ($i=1;$i<count($data);$i++)
{
$votes = split("~", $data[$i]);
$text = ($votes[0]/$sum)*100;
$weight = ($votes[0]/$sum)*200;
$text=(int)$text;
echo "<tr><td>$i. $votes[1]: </td><td><img src=\"vote/img/$i.gif\" width=\"$weight\" height=\"10\"> <b> $text % ($votes[0])</b><br></td></tr>";
}
echo "<b>Всего голосов: $sum</b><br>";
echo " </tbody>
</table>
</body>";
}
?>