<?php
#[-------------------------------------------]
#[=] [=]
#[=] Wap - Голосования [=]
#[=] [=]
#[=] Версия - 2.0 [=]
#[=] Автор - chezz [=]
#[=] Мыло - [email protected] [=]
#[=] ICQ - 29-48-48 [=]
#[=] [=]
#[-------------------------------------------]
Error_Reporting(E_ALL & ~E_NOTICE);
Error_Reporting (ERROR | WARNING);
define('VOTES','1');
require_once ("config.php");/////Подключаем настройки
require_once ("connect.php");////Подключаемся к БД
require_once ("func.php");/////Подключаем функции
require_once ("lang.ini.php");/////Подключаем lang-файл
if($_GET['id'])///Если указан айди выводим страницу с голосованием
{
$id=filtr($_GET['id']);
$r=@mysql_query("SELECT * FROM ".$prefix."votes WHERE id=".$id);
/////////////////////////////////////Достаем из базы варианты ответов
$questions=@mysql_query("SELECT question1, question2, question3, question4, question5, question6, question7, question8, question9, question10 FROM ".$prefix."votes WHERE id=".$id);
$que = mysql_fetch_array($questions);
if ($que['question1']) $question[1]=$que['question1'];
if ($que['question2']) $question[2]=$que['question2'];
if ($que['question3']) $question[3]=$que['question3'];
if ($que['question4']) $question[4]=$que['question4'];
if ($que['question5']) $question[5]=$que['question5'];
if ($que['question6']) $question[6]=$que['question6'];
if ($que['question7']) $question[7]=$que['question7'];
if ($que['question8']) $question[8]=$que['question8'];
if ($que['question9']) $question[9]=$que['question9'];
if ($que['question10']) $question[10]=$que['question10'];
$question_count=count($question);
////////////////////////////////////Конец
body_begin();
$row = mysql_fetch_array($r);
$id = $row['id'];
$count = $row['count'];
$name = $row['name'];
echo "\n<p align=\"center\"><strong>".$name."</strong></p>\n";///Вопрос
if (!$wml) { echo "<form method=\"post\" action=\"show.php?$m\">\n"; }
echo "<select name=\"vote\">\n";
for($i = 0;$i < $question_count;$i++)
{
if(!isset($num)) $num=1;
else $num++;
echo "<option value=\"$num\">$question[$num]</option>\n";///Варианты Ответов
}
echo "</select><br />\n";
if (!$wml) {
echo "<input type=\"hidden\" name=\"vote_id\" value=\"$id\"/>\n";
echo "<input value=\"$lang[tovote]\" name=\"do\" type=\"submit\"/>\n";
echo "</form><br />\n";
} else {
echo "<anchor title=\"go\">$lang[tovote]<go href=\"show.php?$m\" method=\"post\">\n";
echo "<postfield name=\"vote\" value=\"$(vote)\"/>\n";
echo "<postfield name=\"vote_id\" value=\"$id\"/>\n";
echo "</go></anchor><br />\n"; }
echo "-<a href=\"rezult.php?id=$id&$m\">$lang[rezult]</a><br />\n";
echo "<br /><a href=\"index.php?$m\">$lang[invotes]</a>\n";
echo "<br /><a href=\"http://$main_link\">$lang[main_name]</a>\n";
xmllink();//Ссылка на xhtml или на wml
echo "$copy";
body_end();
exit();
}
elseif (isset($_POST['vote_id']))///В другом случае выводим страницу с результатами
{
$vote_id=filtr($_POST['vote_id']);
$r=@mysql_query("SELECT * FROM ".$prefix."count WHERE id=".$vote_id);
$row = mysql_fetch_array($r);
if (isset($_POST['vote'])) { $vote=filtr($_POST['vote']);///////////Если указан вариант ответа
} else {
header("Location: index.php?$m");///////////Если не указан вариант ответа
exit(); }
if($vote==1) $count=$row['count1']+1;
if($vote==2) $count=$row['count2']+1;
if($vote==3) $count=$row['count3']+1;
if($vote==4) $count=$row['count4']+1;
if($vote==5) $count=$row['count5']+1;
if($vote==6) $count=$row['count6']+1;
if($vote==7) $count=$row['count7']+1;
if($vote==8) $count=$row['count8']+1;
if($vote==9) $count=$row['count9']+1;
if($vote==10) $count=$row['count10']+1;
if (strpos($HTTP_COOKIE,"$cook[1]".$vote_id."$cook[2]")===false)//Проверяем наличие куки, если нет, то..
{
$countall = $row['countall']+1;
@mysql_query("UPDATE ".$prefix."count SET countall =".$countall." WHERE `id` =".$vote_id);
@mysql_query("UPDATE ".$prefix."count SET count".$vote."=".$count." WHERE `id` =".$vote_id);
if($setcookie=="1") SetCookie("$cook[1]"."$vote_id"."$cook[2]",md5($mainlink),time()+$cookie_life);
body_begin();
echo "<p align=\"center\">$lang[senks]</p>\n";
echo "<b>$lang[rezult]</b><br />\n";
/////////////////////////////////////Опять Достаем из базы вопрос и варианты ответов
$r2=@mysql_query("SELECT * FROM ".$prefix."votes WHERE id="."$vote_id"."");
$questions=@mysql_query("SELECT question1, question2, question3, question4, question5, question6, question7, question8, question9, question10 FROM ".$prefix."votes WHERE id="."$vote_id"."");
$que = mysql_fetch_array($questions);
if ($que['question1']) $question[1]=$que['question1'];
if ($que['question2']) $question[2]=$que['question2'];
if ($que['question3']) $question[3]=$que['question3'];
if ($que['question4']) $question[4]=$que['question4'];
if ($que['question5']) $question[5]=$que['question5'];
if ($que['question6']) $question[6]=$que['question6'];
if ($que['question7']) $question[7]=$que['question7'];
if ($que['question8']) $question[8]=$que['question8'];
if ($que['question9']) $question[9]=$que['question9'];
if ($que['question10']) $question[10]=$que['question10'];
$question_count=count($question);
$rr=@mysql_query("SELECT count1, count2, count3, count4, count5, count6, count7, count8, count9, count10 FROM ".$prefix."count WHERE id="."$vote_id"."");
$rowz = mysql_fetch_array($rr);
if ($rowz['count1']) $countt[1]=$rowz['count1'];
if ($rowz['count2']) $countt[2]=$rowz['count2'];
if ($rowz['count3']) $countt[3]=$rowz['count3'];
if ($rowz['count4']) $countt[4]=$rowz['count4'];
if ($rowz['count5']) $countt[5]=$rowz['count5'];
if ($rowz['count6']) $countt[6]=$rowz['count6'];
if ($rowz['count7']) $countt[7]=$rowz['count7'];
if ($rowz['count8']) $countt[8]=$rowz['count8'];
if ($rowz['count9']) $countt[9]=$rowz['count9'];
if ($rowz['count10']) $countt[10]=$rowz['count10'];
////////////////////////////////////Конец
$row2 = mysql_fetch_array($r2);
$id = $row2['id'];
$name = $row2['name'];
echo "<p>$name</p>\n";///Вопрос
for($i = 0;$i < $question_count;$i++)
{
if(!isset($num)) $num=1;
else $num++;
$percent=$countt[$num]/$countall*100;
//$percent=round($percent, 2);
$percent=ceil($percent);
if(!$countt[$num]) $countt[$num]=0;
echo "> $question[$num] - $countt[$num] ($percent%)<br />\n";///Варианты Ответов
//$p=ceil($percent);
$p=$percent;
if ($p) echo "<img src=\"img.php?p=$p\" alt=\"$p%\"/><br />";
else echo"<br />";
}
echo "<br />$lang[allcount] <u>$countall</u> $lang[allcount2]<br /><br />\n";
echo "<a href=\"index.php\">$lang[votes]</a><br />\n";
echo "<a href=\"http://$main_link\">$lang[main_name]</a>\n";
echo "$copy";
}
else //Если есть куки
{
body_begin();
echo "<p align=\"center\">$lang[voted]</p>\n";
echo "<br /><a href=\"index.php?$m\">$lang[invotes]</a>\n";
echo "<br /><a href=\"http://$main_link\">$lang[main_name]</a>\n";
echo "$copy";
}
body_end();
}
else ////////Если ничего не указано возвращаемся на главную страницу голосований
{
header("Location: index.php?$m");
exit();
}
?>