Файл: votes.php
Строк: 270
<?php
include_once("files/zagreg.php");
include_once("files/ini.php");
$polz=mysql_query("SELECT * FROM `users` WHERE `udata0`='$log' AND `udata1`='$pas' LIMIT 1");
if(mysql_num_rows($polz)==0){
header ("Location: index.php?error");
echo'<div class="p">Ошибка! Пользователь с таким логином и паролем не зарегистрирован, или пароль/логин неверен! <a href="index.php">На главную</a><br>';exit;
}else{
$ref=rand(100,100000);
echo "$div1<b>Голосования</b>$div9<br />n";
switch($mode) {
default:
$a = @mysql_query("select * from votes");
while($arr=mysql_fetch_array($a)){
$name=$arr['name'];
$date=$arr['date'];
$bid=$arr['id'];
$votes = mysql_fetch_array(@mysql_query("select count(klu4) as num from voting where vote='".$bid."'"));
echo "<a href="votes.php?mode=view&mid=$bid">$name</a> (<b>$votes[0]</b> | $date)";
if ($udata67=="200") {echo " [<a href="votes.php?mode=del&mid=$bid">Уд.</a> | <a href="votes.php?mode=edit&mid=$bid">Ред.</a>]";}
echo '<br/>';
}
if (mysql_affected_rows() == 0){
echo '<div class="d2">';
echo '<b>Голосований пока нет :)</b><br/>';
echo '</div>';
}
if ($udata67=="200") {
echo "<br />$div3<a href="votes.php?mode=add&ref=$ref">Добавить опрос</a>$div9n";
}
break;
case 'view':
$bid=intval($bid);
$q = mysql_query("select * from votes where id='".$mid."'");
if (mysql_affected_rows() == 0){
echo 'Нет такой записи :(<br/>';
} else {
$arr=mysql_fetch_array($q);
$mid=$arr['id'];
$name=$arr['name'];
$avtor=$arr['avtor'];
$vopros=$arr['vopros'];
$v1=$arr['v1'];
$v2=$arr['v2'];
$v3=$arr['v3'];
$v4=$arr['v4'];
$v5=$arr['v5'];
echo '<b>'.$name.'</b><br/>';
echo $vopros.' // Автор: <b><a href="search.php?&go=go&nick='.$avtor.'">'.$avtor.'</a></b><br/>';
if ($wap==1){echo $divide;}
$a = mysql_fetch_array(@mysql_query("select count(klu4) as num from voting where vote='".$mid."' and var='1'"));
echo "• <a href="votes.php?mode=vote&mid=$mid&v=1">$v1</a> (<a href="votes.php?mode=who&&mid=$mid&v=1">$a[0]</a>)<br/>";
$a = mysql_fetch_array(@mysql_query("select count(klu4) as num from voting where vote='".$mid."' and var='2'"));
echo "• <a href="votes.php?mode=vote&mid=$mid&v=2">$v2</a> (<a href="votes.php?mode=who&mid=$mid&v=2">$a[0]</a>)<br/>";
if ($v3) {$a = mysql_fetch_array(@mysql_query("select count(klu4) as num from voting where vote='".$mid."' and var='3'"));
echo "• <a href="votes.php?mode=vote&mid=$mid&v=3">$v3</a> (<a href="votes.php?mode=who&mid=$mid&v=3">$a[0]</a>)<br/>";}
if ($v4) {$a = mysql_fetch_array(@mysql_query("select count(klu4) as num from voting where vote='".$mid."' and var='4'"));
echo "• <a href="votes.php?mode=vote&mid=$mid&v=4">$v4</a> (<a href="votes.php?mode=who&mid=$mid&v=4">$a[0]</a>)<br/>";}
if ($v5) {$a = mysql_fetch_array(@mysql_query("select count(klu4) as num from voting where vote='".$mid."' and var='5'"));
echo "• <a href="votes.php?mode=vote&mid=$mid&v=5">$v5</a> (<a href="votes.php?mode=who&mid=$mid&v=5">$a[0]</a>)<br/>";}
if ($wap==1){echo $divide;}
$a = mysql_fetch_array(@mysql_query("select count(klu4) as num from voting where vote='".$mid."'"));
echo 'Голосов: '.$a[0].'<br/>';
}
break;
case 'add':
if ($udata67=="200"){
if (!$act){
echo '<b>Добавление Опроса:</b><br/>';
echo "<form method="POST" action="votes.php?mode=add&act=1" name="auth">n";
echo 'Тема:<br/>';
echo "<input name="name" maxlength="50" title="infa" emptyok="false"/><br/>n";
echo 'Вопрос:<br/>';
echo "<input name="vopros" maxlength="1000" title="infa" emptyok="false"/><br/>n";
echo 'Вариант 1:<br/>';
echo "<input name="v1" maxlength="50" title="infa" emptyok="false"/><br/>n";
echo 'Вариант 2:<br/>';
echo "<input name="v2" maxlength="50" title="infa" emptyok="false"/><br/>n";
echo 'Вариант 3:<br/>';
echo "<input name="v3" maxlength="50" title="infa" emptyok="false"/><br/>n";
echo 'Вариант 4:<br/>';
echo "<input name="v4" maxlength="50" title="infa" emptyok="false"/><br/>n";
echo 'Вариант 5:<br/>';
echo "<input name="v5" maxlength="50" title="infa" emptyok="false"/><br/>n";
if ($wap==1) {
echo "<anchor title="go">Добавить<go href="votes.php?mode=add&$ses&act=1" method="post">n";
echo "<postfield name="name" value="$(name)"/>n";
echo "<postfield name="vopros" value="$(vopros)"/>n";
echo "<postfield name="v1" value="$(v1)"/>n";
echo "<postfield name="v2" value="$(v2)"/>n";
echo "<postfield name="v3" value="$(v3)"/>n";
echo "<postfield name="v4" value="$(v4)"/>n";
echo "<postfield name="v5" value="$(v5)"/>n";
echo '</go></anchor><br/>';
} else {
echo "<input type="submit" value="Добавить" name="enter"><br/>n";
}
} else {
if (!$vopros or !$v1 or !$v2) {
echo 'Не введён вопрос, или опрос содержит менее двух вариантов ответов :)<br/>';
} else {
mysql_query("Insert into votes set name ='".$name."', avtor ='".$avtor."', date ='".$date."', vopros = '".$vopros."', v1 = '".$v1."', v2 = '".$v2."', v3 = '".$v3."', v4 = '".$v4."', v5 = '".$v5."'");
echo '<b>Опрос успешно добавлен :)</b><br/>';
// сообщение о добавлении Опроса, во все комнаты =)
$adm = @mysql_query ("Select user from users where id='1' LIMIT 1;");
$z = @mysql_fetch_array ($adm);
$administration = $z["user"];
$administration = check($administration);
$time = time();
$rnd = rand(0,99999999);
$today=date ("H:i");
$time = time();
$txt = "<b>ВНИМАНИЕ!!!</b> <u>Добавлен новый опрос</u> :) <u>Отдай свой голос, ведь он может быть очень важен для чата</u> ;)";
for ($num = 0; $num <= 22; $num++){
$room = "room".$num;
mysql_query ("Insert into $room set klu4= '".$rnd."', time='".$today."', who='".$administration."', message='".$txt."', id='".$time."', towhom='', hid='0', usid='1', komu=''");
}
//
}
}
}
break;
case 'golos_ok':
if(empty($_POST[text])){
echo '<form action="adms.php?go=rassilka" method="post">';
echo"OK:<br/>";
echo "<textarea name="text" rows=3 cols=17 wrap="off"></textarea><br/><br><input type="submit" value="Отправить" class="ibutton"></form><br/>";
}else{
$time = date("H:i d.m.y");
$req = mysql_query("SELECT * FROM `users` ");
while($avto = mysql_fetch_array($req)){
mysql_query("INSERT INTO `msg_r` SET `user_from` = 'Администрация', `user_to` = '$avto[udata0]', `time` = '$time', `read` = 1, `mail_msg` = '$_POST[text]'");
}
echo'Голос учтен!<br/>';}
break;
case 'edit':
if ($udata67=="200"){
if (!$act){
$q = mysql_query("select * from votes where id='".$mid."'");
if (mysql_affected_rows() == 0) die('<b>Нет такой категории :(</b>'.$fsize2.'</p></card></wml>');
$arr=mysql_fetch_array($q);
$vopros=$arr['vopros'];
$name=$arr['name'];
$v1=$arr['v1'];
$v2=$arr['v2'];
$v3=$arr['v3'];
$v4=$arr['v4'];
$v5=$arr['v5'];
echo '<b>Редактирование категории:</b><br/>';
echo "<form method="POST" action="votes.php?mode=edit&$ses&mid=$mid&act=1" name="auth">n";
echo 'Вопрос:<br/>';
echo "<input name="name" maxlength="50" value="$name" title="infa" emptyok="false"/><br/>n";
echo 'Описание:<br/>';
echo "<input name="vopros" maxlength="100" value="$vopros" title="infa" emptyok="false"/><br/>n";
echo 'Вариант 1:<br/>';
echo "<input name="v1" maxlength="50" value="$v1" title="infa" emptyok="false"/><br/>n";
echo 'Вариант 2:<br/>';
echo "<input name="v2" maxlength="50" value="$v2" title="infa" emptyok="false"/><br/>n";
echo 'Вариант 3:<br/>';
echo "<input name="v3" maxlength="50" value="$v3" title="infa" emptyok="false"/><br/>n";
echo 'Вариант 4:<br/>';
echo "<input name="v4" maxlength="50" value="$v4" title="infa" emptyok="false"/><br/>n";
echo 'Вариант 5:<br/>';
echo "<input name="v5" maxlength="50" value="$v5" title="infa" emptyok="false"/><br/>n";
if ($wap==1) {
echo "<anchor title="go">Изменить<go href="votes.php?mode=edit&$ses&mid=$mid&act=1&ref=$ref" method="post">n";
echo "<postfield name="name" value="$(name)"/>n";
echo "<postfield name="vopros" value="$(vopros)"/>n";
echo "<postfield name="v1" value="$(v1)"/>n";
echo "<postfield name="v2" value="$(v2)"/>n";
echo "<postfield name="v3" value="$(v3)"/>n";
echo "<postfield name="v4" value="$(v4)"/>n";
echo "<postfield name="v5" value="$(v5)"/>n";
echo '</go></anchor><br/>';
} else {
echo "<input type="submit" value="Добавить" name="enter"><br/>n";
}
} else {
if (!$vopros or !$v1 or !$v2) {
echo 'Не введён вопрос, или опрос содержит менее двух вариантов ответов :)<br/>';
} else {
mysql_query("update votes set name ='".$name."', avtor ='".$avtor."', vopros = '".$vopros."', v1 = '".$v1."', v2 = '".$v2."', v3 = '".$v3."', v4 = '".$v4."', v5 = '".$v5."' where id = '".$mid."'");
echo '<b>Вопрос изменен :)</b><br/>';
}
}
}
break;
case 'del':
if ($udata67=="200"){
if (!$act){
echo "<b>Удалить вопрос?</b><br/>
<a href="votes.php?mode=del&$ses&act=go&mid=$mid">Да</a> | <a href="votes.php?$ses&ref=$ref">Нет</a><br/>";
} else {
$zapros="delete from votes where id= '".$mid."'";
$zapros2="delete from voting where vote= '".$mid."'";
if (mysql_query($zapros) and mysql_query($zapros2)){
echo '<b>Вопрос успешно удален :)</b><br/>';
} else {
echo '<b>Ошибка при удалении :(</b><br/>';
}
}
}
break;
case'ok_vopros_del':
mysql_query("DROP TABLE `achieve`, `addhpmp`, `admin_log`, `akc`, `ali_chat`, `alliance`, `anketa`, `arena`, `armor`, `armor_item`, `aurs`, `baffs`, `ban`, `banchat`, `bank`, `battle`, `battle_log`, `blacklist`, `bonusstats`, `clan`, `clanitem`, `clanlog`, `clanwar`, `clan_alliance`, `clan_chat`, `clan_holl`, `clan_people`, `color`, `config`, `customer`, `dead`, `drops`, `drop_vesh`, `eventfish`, `fish`, `fishlov`, `forum`, `forums`, `forum_vote`, `forum_vote_us`, `gb`, `gb1`, `gb2`, `getekeeper`, `gorod`, `holl_stavka`, `hystory`, `item`, `kontakts`, `konts`, `mag`, `magic`, `mags`, `maxon`, `mdrop`, `msg_i`, `msg_r`, `msg_users`, `mshems`, `news`, `nextpay_sms`, `npcshop`, `odet`, `okrestnosti`, `olimpiada`, `paty`, `payments`, `peklo`, `peklowin`, `pit`, `pitmag`, `plans`, `posts`, `predl`, `proffession`, `questkristina`, `questkristina_mobs`, `questpet`, `quests`, `questsitem`, `rec`, `recommendations`, `refer`, `res`, `santa`, `sell`, `sellcoin`, `sell_pit`, `sell_res`, `sell_vesh`, `send_aden`, `send_coin`, `shems`, `shop`, `skil`, `skils`, `sklad`, `sms`, `spam_msg`, `spoil`, `spoilact`, `stan`, `stanmob`, `table_status`, `table_stena`, `table_vip`, `themes`, `tickets`, `tickets_msg`, `time`, `tmp_alliance`, `tmp_battle`, `tmp_clan`, `ufus`, `ukrasheniya`, `userquests`, `users`, `vigre_bonus`, `vigre_votes`, `vigre_votes_bot`, `viktorina`, `viktorina_chat`, `vilage`, `votes`, `voting`, `v_answer`, `v_question`, `weapon`, `weapon_item`, `xsolla_billing`, `yadusers`, `zamclan`, `zametki`, `zamok`");
break;
case 'vote':
$v=intval($v);
$date=date("j.m.Y");
if ($v<1 or $v>5) die();
mysql_query ("Select * from voting where vote='".$mid."' and who='".$log."'");
if (mysql_affected_rows() == 0) {
mysql_query("INSERT INTO voting SET vote = '".$mid."', date = '$date', who = '".$log."', var = '".$v."'");
//mysql_query("update blog set votes=votes+'1' where id = '".$mid."'");
//mysql_query("update users set blog=blog+'1' where id='".$usid."'");
echo '<b>Ваш голос принят :)</b><br/>';
} else {
echo '<b>Вы уже голосовали :)</b><br/>';
}
break;
case 'who':
$query = mysql_query("select who,date from voting where vote = '".$mid."' and var = '".$v."'");
if (mysql_affected_rows() == 0) {
echo '<b>Ещё не голосовали :)</b><br/>';
mysql_close ($link);
exit;
} else {
echo '<b>Кто отдал голос:</b><br/>';
$i = 1;
while($arr=mysql_fetch_array($query)){
$r = mysql_fetch_array(@mysql_query ("SELECT user from users where id='".$arr[0]."' LIMIT 1;"));
echo ($i++).') '.$r[0].' (ID: '.$arr[0].') - '.$arr[1].' <br/>';
}
}
break;
}
if($mode) {
print "<br/>$div1<a href="?$ses">Голосование</a>$div9";
}
include_once"files/down.php";
}
?>