File size: 7.65Kb
<?php
////////////////////////////////////////////
//
// Скрипт Голосований на MySql
//
// Версия - 1.0 (wap1.1)
// Автор - CHEZZ
// гМыло :) - [email protected]
// wap-сайт - http://underwap.net
//
////////////////////////////////////////////
Error_Reporting(E_ALL & ~E_NOTICE); //// Нет ошибок
header("Pragma: no-cache");
header ("Content-type:text/vnd.wap.wml;charset=utf-8");///Выводим Хеадэр
include "config.php";/////Подключаем настройки
include "connect.php";////Подключаемся к БД
include "func.php";/////Подключаем функции
if(isset($id))///Если указан айди выводим страницу с голосованием
{
$id=filtr($id);
$r=mysql_query("SELECT * FROM vote_votes WHERE id="."$id"."");
/////////////////////////////////////Достаем из базы варианты ответов
$questions=mysql_query("SELECT question1, question2, question3, question4, question5, question6, question7, question8, question9, question10 FROM vote_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 '<p align="center"><strong>'.$name."</strong></p>\n";///Вопрос
echo "<select name=\"question\">\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";
echo "<anchor title=\"go\">Голосовать<go href=\"show.php\" method=\"post\">\n";
echo "<postfield name=\"vote\" value=\"$(question)\"/>\n";
echo "<postfield name=\"vote_id\" value=\"$id\"/>\n";
echo "</go></anchor><br/>\n";
echo "-<a href=\"rezult.php?id=$id\">Результаты</a><br/>\n";
echo "<br/><a href=\"http://$main_link\">$main_name</a>\n";
echo "$copy";
body_end();
exit();
}
elseif (isset($vote_id))///В другом случае выводим страницу с результатами
{
$r=mysql_query("SELECT * FROM vote_count WHERE id="."$vote_id"."");
$row = mysql_fetch_array($r);
$vote_id=filtr($vote_id);
if (isset($vote)) { $vote=filtr($vote);///////////Если указан вариант ответа
}
else {
header("Location: http://vote/index.php");///////////Если не указан вариант ответа
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,"underwap.net_vote_a2YdoIxE7".$vote_id."4ePD9skH50d")===false)//Проверяем наличие куки, если нет, то..
{
$countall = $row['countall']+1;
@mysql_query("UPDATE vote_count SET countall ="."$countall"." WHERE `id` ="."$vote_id"."");
@mysql_query("UPDATE vote_count SET count"."$vote"." ="."$count"." WHERE `id` ="."$vote_id"."");
SetCookie('underwap.net_vote_a2YdoIxE7'."$vote_id".'4ePD9skH50d',"vB7d6UIar53p6fyx98cREw",time()+$cookie_life);
body_begin();
echo '<p align="center">Спасибо за Ваш Голос!!</p>'."\n";
echo "<b>Результаты:</b><br/>\n";
/////////////////////////////////////Опять Достаем из базы вопрос и варианты ответов
$r2=mysql_query("SELECT * FROM vote_votes WHERE id="."$vote_id"."");
$questions=mysql_query("SELECT question1, question2, question3, question4, question5, question6, question7, question8, question9, question10 FROM vote_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 vote_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/>Всего проголосовало <u>$countall</u> человек<br/><br/>\n";
echo "<a href=\"index.php\">Голосования</a><br/>\n";
echo "<a href=\"http://$main_link\">$main_name</a>\n";
echo "$copy";
body_end();
exit();
}
else //Если есть куки
{
body_begin();
echo '<p align="center">Вы уже голосовали!!</p>'."\n";
echo "<br/><a href=\"index.php\">В Голосования</a>\n\r";
echo "<br/><a href=\"http://$main_link\">$main_name</a>\n\r";
echo "$copy";
body_end();
exit();
}
}
else ////////Если ничего не указано возвращаемся на главную страницу голосований
{
header("Location: http://$path");
exit();
}
//mysql_close($connect);
?>