View file forum/forum/vote.php

File size: 3.83Kb
<?php
require_once"../template/start.php";
require_once"../template/regglobals.php";
require_once"../template/config.php";
require_once"../template/functions.php";
require_once"../template/antidos.php";
require_once"../template/cookies.php";
require_once"../template/gzip.php";
require_once"../template/header.php";
require_once"../template/referer.php";
include_once"../themes/$config_themes/index.php";
include_once"../template/isset.php";
include_once"../template/db.php";

$themes = mysql_query("SELECT * FROM `theme` WHERE `author` = '$log' ORDER BY `id` DESC");
$theme = mysql_fetch_array($themes);

$act = isset($_GET['act']) ? $_GET['act'] : '';
switch($act){
default:
echo '<div class="b"> '.$theme['name'].'</div><div>';
echo '<form action="?act=2" method="post">';
echo 'Кол-во вариантов ответа(Max-10):<br> <input type="text" name="count_otv" size"=3" maxlength="2"><br>';
echo '<input type="submit" value="Далее" name="go1">';
echo '</form></div><hr>';

break;

case('2'):
if (intval($count_otv) <= '10'){
if (intval($count_otv) >= '2'){
if ($isset=="vopros"){echo "<div align=center><font color=red><b>Вы не ввели вопрос!</b></font></div><br>\n";}

echo '<div class="b"> '.$theme['name'].'</div><div>';
echo "<form action='?act=3&ns=".intval($count_otv)."' method='post'>\n";
echo "<input type='hidden' name='count_otv' value='".intval($count_otv)."'>\n";
echo "Вопрос: <br><input type='text' name='vote_question'><br>\n";

while ($n < intval($count_otv)) {
$n++;
echo "Вариант ответа $n:<br><input type='text' name='question$n'><br>\n";}
echo "<input type='submit' value='Далее' name='go1'>\n";
echo '</form></div><hr>';
}else{ $v = '1'; echo "<br> <img src='".$config_home."/images/img/close.gif' alt=''> Минимальное колличество ответов 2 <br><br>\n";}	
}else{ $v = '1';  echo "<br> <img src='".$config_home."/images/img/close.gif' alt=''> Максимально колличество ответов 10 <br><br>\n";}
break;

case('3'):
if((int)$ns){
if ($_POST['vote_question'] == NULL){ header ("Location: vote.php?act=2&count_otv=$ns&isset=vopros"); exit;}	
if ($_POST['question1']==NULL){header ("Location: vote.php?act=2&count_otv=$ns&isset=otv1"); exit;}	
if ($_POST['question2']==NULL){header ("Location: vote.php?act=2&count_otv=$ns&isset=otv2"); exit;}
if ($theme['vote'] != '0'){header ("Location: ".$config_home."/forum/posts/".$theme['id'].""); exit;}


$vote_question = check($_POST['vote_question']);
while ($n < (int)$ns) {$n++;
if ($_POST['question'.$n]!=NULL){
$question = check($_POST['question'.$n]);
mysql_query ("INSERT INTO `vote` (forum,under,theme,quesn) VALUES ('".$theme['forums']."','".$theme['under']."','".$theme['id']."','".$question."')");
echo "$question <br>";}
}
mysql_query ("INSERT INTO `itemvote` (forum,under,theme,item,user) VALUES ('".$theme['forums']."','".$theme['under']."','".$theme['id']."','".$vote_question."','".$log."')");


$votes = mysql_query("SELECT * FROM `itemvote` WHERE `user` = '".$log."' ORDER BY `id` DESC");
$vote = mysql_fetch_array($votes);

mysql_query("UPDATE `theme` SET `vote`='".$vote['id']."' WHERE `id` = '".$theme['id']."'");
mysql_query("UPDATE `theme` SET `itemvote`='".$vote_question."' WHERE `id` = '".$theme['id']."'");
header ("Location: ".$config_home."/forum/posts/".$theme['id'].""); exit;

}else{ $v = '1'; echo "<br> <img src='".$config_home."/images/img/close.gif' alt=''> Не выбранно колличество ответов!<br><br>\n";}	
break;}

echo '<div>';
if ($v == '1'){echo ": <a href='vote.php'>Назад</a><br>\n";}
echo ":: <a href='".$config_home."/forum/posts/".$theme['id']."'>В тему</a><br>\n";
echo "::: <a href='index.php'>На главную</a></div>\n";

include_once"../themes/$config_themes/foot.php";
?>