File size: 2.84Kb
<?
//echo "<div class=\"title\">оставь свой голос</div>\n";
if (isset($_GET['msg']) && $_GET['msg']=='addv')
echo "<span style=\"color:$color[msg]\"><hr />\n<b>Голос успешно принят</b></span><br />\n";
if (isset($_GET['msg']) && $_GET['msg']=='add')
echo "<span style=\"color:$color[msg]\"><b>Голосование добавлено</b></span><br />\n";
$voice_ok='0';
$q = mysql_query("SELECT COUNT(*) FROM `$mysql[pref]voice`");
$k_voice=mysql_result($q, 0);
if ($k_voice==0)
{
}
$page=1;
if (isset($_GET['page']) && $_GET['page']!='')
{
if ($_GET['page']=='end')
{
$page=$k_voice;
}
else
{
$page=intval($_GET['page']);
}
}
$page=intval($page);
if ($k_voice<$page){$page=$k_voice;}
if (0>$page){$page=1;}
$i=$page-1;
$q56 = mysql_query("SELECT * FROM `$mysql[pref]voice` ORDER BY id DESC LIMIT $i, 1;");
$voice56 = mysql_fetch_array($q56);
if(isset($user))
{
$q_v3 = mysql_query("SELECT COUNT(*) FROM `$mysql[pref]voices` WHERE `id_v` = '$voice56[id]' AND `id_user` = '$user[id]';");
if (mysql_result($q_v3, 0)==0)
{
$voice_ok=0;
}
else $voice_ok=1;
}
else $voice_ok=0;
if($_GET['msg']=='addv') $voice_ok=1;
echo "<div class=\"mess\">";
if ($voice_ok==0)
{
echo "<hr />\n<form method=\"post\" action=\"index.php?act=voice\">\n";
$q = mysql_query("SELECT * FROM `$mysql[pref]voice` ORDER BY id DESC LIMIT $i, 1;");
while ($voice = mysql_fetch_array($q))
{
echo "<b>$voice[name]</b>";
echo "<br />\n";
for ($i_v=1;$i_v<=8;$i_v++)
{
if ($voice[$i_v]!='')
{
if ($voice_ok==0 && isset($_GET['act']) && $_GET['act']=='voice' && isset($_POST['voice_'.$voice['id']]) && $_POST['voice_'.$voice['id']]==$i_v)
{
mysql_query("INSERT INTO `$mysql[pref]voices` (`id_v`, `voice`, `id_user`, `time`)
values('$voice[id]', '$i_v', '$user[id]', '$time');");
header("Location: index.php?".SID."msg=addv");
exit;
}
$q_v1 = mysql_query("SELECT COUNT(*) FROM `$mysql[pref]voices` WHERE `id_v` = '$voice[id]';");
$q_v2 = mysql_query("SELECT COUNT(*) FROM `$mysql[pref]voices` WHERE `id_v` = '$voice[id]' AND `voice` = '$i_v';");
$k_p_voice1=mysql_result($q_v1, 0);
if ($k_p_voice1==0){$k_p_voice1=1;}
$k_p_voice2=mysql_result($q_v2, 0);
if ($voice_ok==0)
echo "<input name=\"voice_$voice[id]\" type=\"radio\" value=\"$i_v\" /> ";
echo "$voice[$i_v] [$k_p_voice2]<br />\n";
$proc=round($k_p_voice2/$k_p_voice1*100, 0);
echo "<img src=\"voice/rat.php?r=$proc\" act=\"\" /><br />\n";
}
}
}
echo "<input value=\"Проголосовать\" class=\"form\" type=\"submit\" />\n";
echo "</form>\n";
echo "</div>\n";
/*
echo "<hr />\n<div class=\"str\">";
str("voice/index.php?",$k_voice,$page);
echo "</div>\n";
*/
echo "<div class=\"str\">\n";
echo "<b>Ждём Ваших отзывов в гостевой книге</b><br />";
}
echo "</div>\n";
?>