<?
require '../sys/inc/start.php';
require '../sys/inc/compress.php';
require '../sys/inc/sess.php';
require '../sys/inc/home.php';
require '../sys/inc/settings.php';
require '../sys/inc/db_connect.php';
require '../sys/inc/ipua.php';
require '../sys/inc/fnc.php';
require '../sys/inc/user.php';

if(isset($_GET['s']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `soo` WHERE `id` = '".intval($_GET['s'])."' LIMIT 1"),0)==1)
{
$s=intval($_GET['s']);
$soo=mysql_fetch_assoc(mysql_query("SELECT * FROM `soo` WHERE `id` = '$s' LIMIT 1"));
require 'inc/ban.php';
$set['title']=$soo['name'].' - Опросы'; // заголовок страницы
require '../sys/inc/thead.php';
title();
if($soo['konf_soo']==0 || isset($user) && mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_users` WHERE `id_soo` = '$soo[id]' AND `id_user`='$user[id]' AND `invit`='0' AND `activate`='0' LIMIT 1"),0)==1 || isset($user) && $user['id']==$soo['admid']  || isset($user) && $user['level']>0)
{
if(isset($_GET['open']))
{
if(isset($user) && isset($_GET['id']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes` WHERE `id` = '".intval($_GET['id'])."' AND `id_soo`='$soo[id]' AND `time_close`>'$time' LIMIT 1"),0)==1)
{
$v=mysql_fetch_assoc(mysql_query("SELECT * FROM `soo_votes` WHERE `id` = '".intval($_GET['id'])."' AND `id_soo`='$soo[id]' LIMIT 1"));
if(isset($_POST['otvet']) && ($_POST['otvet']==1 || $_POST['otvet']==2 || $v['otvet_3']!=NULL && $_POST['otvet']==3 || $v['otvet_4']!=NULL && $_POST['otvet']==4 || $v['otvet_5']!=NULL && $_POST['otvet']==5 || $v['otvet_6']!=NULL && $_POST['otvet']==6 || $v['otvet_7']!=NULL && $_POST['otvet']==7 || $v['otvet_8']!=NULL && $_POST['otvet']==8 || $v['otvet_9']!=NULL && $_POST['otvet']==9 || $v['otvet_10']!=NULL && $_POST['otvet']==10) && mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes_otvet` WHERE `id_soo` = '$soo[id]' AND `id_user`='$user[id]' AND `id_vote`='$v[id]' LIMIT 1"),0)==0 && (mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_users` WHERE `id_soo` = '$soo[id]' AND `id_user`='$user[id]' AND `invit`='0' AND `activate`='0' LIMIT 1"),0)==1 || isset($user) && $user['id']==$soo['admid']))
{
$id_otvet=intval($_POST['otvet']);
mysql_query("INSERT INTO `soo_votes_otvet` (`id_soo`, `id_vote`, `id_otvet`, `id_user`) values ('$soo[id]', '$v[id]', '$id_otvet', '$user[id]')");
msg('Голос успешно принят');
}
}
if(isset($user) && $user['id']==$soo['admid'] && isset($_GET['close']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes` WHERE `id` = '".intval($_GET['close'])."' AND `id_soo`='$soo[id]' AND `time_close`>'$time' LIMIT 1"),0)==1)
{
mysql_query("UPDATE `soo_votes` SET `time_close`='$time' WHERE `id`='".intval($_GET['close'])."' AND `id_soo`='$soo[id]' LIMIT 1");
msg('Опрос успешно закрыт для голосования');
}
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes` WHERE `id_soo`='$soo[id]' AND `time_close`>'$time'"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];

if ($k_post==0)
{
?>
<div class='noy'>Открытых опросов нет</div>
<?
}
$q=mysql_query("SELECT * FROM `soo_votes` WHERE `id_soo`='$soo[id]' AND `time_close`>'$time' ORDER BY `time_create` DESC LIMIT $start, $set[p_str]");
while ($votes = mysql_fetch_assoc($q))
{
if($num==1){
echo "<div class='enk_div'>\n";
$num=0;
}else{
echo "<div class='enk2_div'>\n";
$num=1;}
echo '<img src="img/votes.png" alt="" /> ';
echo ''.$votes['vote'].' ('.vremja($votes['time_create']).')<br />';


if(isset($user) && mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes_otvet` WHERE `id_soo` = '$soo[id]' AND `id_user`='$user[id]' AND `id_vote`='$votes[id]' LIMIT 1"),0)==0 && (mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_users` WHERE `id_soo` = '$soo[id]' AND `id_user`='$user[id]' AND `invit`='0' AND `activate`='0' LIMIT 1"),0)==1 || isset($user) && $user['id']==$soo['admid']))
{
echo'<form method="post" action="?s='.$soo['id'].'&open&id='.$votes['id'].'">';
echo'<input type="radio" name="otvet" value="1"/> '.output_text($votes['otvet_1']).'<br/>';
echo'<input type="radio" name="otvet" value="2"/> '.output_text($votes['otvet_2']).'<br/>';
if($votes['otvet_3']!=NULL)echo'<input type="radio" name="otvet" value="3"/> '.output_text($votes['otvet_3']).'<br/>';
if($votes['otvet_4']!=NULL)echo'<input type="radio" name="otvet" value="4"/> '.output_text($votes['otvet_4']).'<br/>';
if($votes['otvet_5']!=NULL)echo'<input type="radio" name="otvet" value="5"/> '.output_text($votes['otvet_5']).'<br/>';
if($votes['otvet_6']!=NULL)echo'<input type="radio" name="otvet" value="6"/> '.output_text($votes['otvet_6']).'<br/>';
if($votes['otvet_7']!=NULL)echo'<input type="radio" name="otvet" value="7"/> '.output_text($votes['otvet_7']).'<br/>';
if($votes['otvet_8']!=NULL)echo'<input type="radio" name="otvet" value="8"/> '.output_text($votes['otvet_8']).'<br/>';
if($votes['otvet_9']!=NULL)echo'<input type="radio" name="otvet" value="9"/> '.output_text($votes['otvet_9']).'<br/>';
if($votes['otvet_10']!=NULL)echo'<input type="radio" name="otvet" value="10"/> '.output_text($votes['otvet_10']).'<br/>';
echo'<input type="submit" value="Голосовать">';
echo'</form>';
}else{
$all_otvets=mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes_otvet` WHERE `id_soo` = '$soo[id]' AND `id_vote`='$votes[id]'"),0);
$otvet_1=mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes_otvet` WHERE `id_soo` = '$soo[id]' AND `id_vote`='$votes[id]' AND `id_otvet`='1'"),0);
echo'1. '.output_text($votes['otvet_1']).': '.$otvet_1.' из '.$all_otvets.'<br/>';
$otvet_2=mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes_otvet` WHERE `id_soo` = '$soo[id]' AND `id_vote`='$votes[id]' AND `id_otvet`='2'"),0);
echo'2. '.output_text($votes['otvet_2']).': '.$otvet_2.' из '.$all_otvets.'<br/>';
if($votes['otvet_3']!=NULL){
$otvet_3=mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes_otvet` WHERE `id_soo` = '$soo[id]' AND `id_vote`='$votes[id]' AND `id_otvet`='3'"),0);
echo'3. '.output_text($votes['otvet_3']).': '.$otvet_3.' из '.$all_otvets.'<br/>';
}
if($votes['otvet_4']!=NULL){
$otvet_4=mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes_otvet` WHERE `id_soo` = '$soo[id]' AND `id_vote`='$votes[id]' AND `id_otvet`='4'"),0);
echo'4. '.output_text($votes['otvet_4']).': '.$otvet_4.' из '.$all_otvets.'<br/>';
}
if($votes['otvet_5']!=NULL){
$otvet_5=mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes_otvet` WHERE `id_soo` = '$soo[id]' AND `id_vote`='$votes[id]' AND `id_otvet`='5'"),0);
echo'5. '.output_text($votes['otvet_5']).': '.$otvet_5.' из '.$all_otvets.'<br/>';
}
if($votes['otvet_6']!=NULL){
$otvet_6=mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes_otvet` WHERE `id_soo` = '$soo[id]' AND `id_vote`='$votes[id]' AND `id_otvet`='6'"),0);
echo'6. '.output_text($votes['otvet_6']).': '.$otvet_6.' из '.$all_otvets.'<br/>';
}
if($votes['otvet_7']!=NULL){
$otvet_7=mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes_otvet` WHERE `id_soo` = '$soo[id]' AND `id_vote`='$votes[id]' AND `id_otvet`='7'"),0);
echo'7. '.output_text($votes['otvet_7']).': '.$otvet_7.' из '.$all_otvets.'<br/>';
}
if($votes['otvet_8']!=NULL){
$otvet_8=mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes_otvet` WHERE `id_soo` = '$soo[id]' AND `id_vote`='$votes[id]' AND `id_otvet`='8'"),0);
echo'8. '.output_text($votes['otvet_8']).': '.$otvet_8.' из '.$all_otvets.'<br/>';
}
if($votes['otvet_9']!=NULL){
$otvet_9=mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes_otvet` WHERE `id_soo` = '$soo[id]' AND `id_vote`='$votes[id]' AND `id_otvet`='9'"),0);
echo'9. '.output_text($votes['otvet_9']).': '.$otvet_9.' из '.$all_otvets.'<br/>';
}
if($votes['otvet_10']!=NULL){
$otvet_10=mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes_otvet` WHERE `id_soo` = '$soo[id]' AND `id_vote`='$votes[id]' AND `id_otvet`='10'"),0);
echo'10. '.output_text($votes['otvet_10']).': '.$otvet_10.' из '.$all_otvets.'<br/>';
}
}
if(isset($user) && $user['id']==$soo['admid'])echo'<a href="?s='.$soo['id'].'&open&close='.$votes['id'].'">Закончить опрос</a>';
echo '</div>';
}
if ($k_page>1)str("?s=$soo[id]&",$k_page,$page); // Вывод страниц
}
elseif(isset($_GET['results']))
{
if(isset($user) && $user['id']==$soo['admid'] && isset($_GET['del']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes` WHERE `id` = '".intval($_GET['del'])."' AND `id_soo`='$soo[id]' AND `time_close`<'$time' LIMIT 1"),0)==1)
{
mysql_query("DELETE FROM `soo_votes` WHERE `id`='".intval($_GET['del'])."' AND `id_soo`='$soo[id]' LIMIT 1");
msg('Опрос успешно удален');
}
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes` WHERE `id_soo`='$soo[id]' AND `time_close`<'$time'"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
if ($k_post==0)
{
?>
<div class='noy'>Закрытых опросов нет</div>
<?
}
$q=mysql_query("SELECT * FROM `soo_votes` WHERE `id_soo`='$soo[id]' AND `time_close`<'$time' ORDER BY `time_close` ASC LIMIT $start, $set[p_str]");
while ($votes = mysql_fetch_assoc($q))
{
if($num==1){
echo "<div class='enk_div'>\n";
$num=0;
}else{
echo "<div class='enk2_div'>\n";
$num=1;}
echo '<img src="img/votes.png" alt="e" /> ';
echo ''.$votes['vote'].' ('.vremja($votes['time_create']).')<br />';

$all_otvets=mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes_otvet` WHERE `id_soo` = '$soo[id]' AND `id_vote`='$votes[id]'"),0);
$otvet_1=mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes_otvet` WHERE `id_soo` = '$soo[id]' AND `id_vote`='$votes[id]' AND `id_otvet`='1'"),0);
echo'1. '.output_text($votes['otvet_1']).': '.$otvet_1.' из '.$all_otvets.'<br/>';
$otvet_2=mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes_otvet` WHERE `id_soo` = '$soo[id]' AND `id_vote`='$votes[id]' AND `id_otvet`='2'"),0);
echo'2. '.output_text($votes['otvet_2']).': '.$otvet_2.' из '.$all_otvets.'<br/>';
if($votes['otvet_3']!=NULL){
$otvet_3=mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes_otvet` WHERE `id_soo` = '$soo[id]' AND `id_vote`='$votes[id]' AND `id_otvet`='3'"),0);
echo'3. '.output_text($votes['otvet_3']).': '.$otvet_3.' из '.$all_otvets.'<br/>';
}
if($votes['otvet_4']!=NULL){
$otvet_4=mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes_otvet` WHERE `id_soo` = '$soo[id]' AND `id_vote`='$votes[id]' AND `id_otvet`='4'"),0);
echo'4. '.output_text($votes['otvet_4']).': '.$otvet_4.' из '.$all_otvets.'<br/>';
}
if($votes['otvet_5']!=NULL){
$otvet_5=mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes_otvet` WHERE `id_soo` = '$soo[id]' AND `id_vote`='$votes[id]' AND `id_otvet`='5'"),0);
echo'5. '.output_text($votes['otvet_5']).': '.$otvet_5.' из '.$all_otvets.'<br/>';
}
if($votes['otvet_6']!=NULL){
$otvet_6=mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes_otvet` WHERE `id_soo` = '$soo[id]' AND `id_vote`='$votes[id]' AND `id_otvet`='6'"),0);
echo'6. '.output_text($votes['otvet_6']).': '.$otvet_6.' из '.$all_otvets.'<br/>';
}
if($votes['otvet_7']!=NULL){
$otvet_7=mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes_otvet` WHERE `id_soo` = '$soo[id]' AND `id_vote`='$votes[id]' AND `id_otvet`='7'"),0);
echo'7. '.output_text($votes['otvet_7']).': '.$otvet_7.' из '.$all_otvets.'<br/>';
}
if($votes['otvet_8']!=NULL){
$otvet_8=mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes_otvet` WHERE `id_soo` = '$soo[id]' AND `id_vote`='$votes[id]' AND `id_otvet`='8'"),0);
echo'8. '.output_text($votes['otvet_8']).': '.$otvet_8.' из '.$all_otvets.'<br/>';
}
if($votes['otvet_9']!=NULL){
$otvet_9=mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes_otvet` WHERE `id_soo` = '$soo[id]' AND `id_vote`='$votes[id]' AND `id_otvet`='9'"),0);
echo'9. '.output_text($votes['otvet_9']).': '.$otvet_9.' из '.$all_otvets.'<br/>';
}
if($votes['otvet_10']!=NULL){
$otvet_10=mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes_otvet` WHERE `id_soo` = '$soo[id]' AND `id_vote`='$votes[id]' AND `id_otvet`='10'"),0);
echo'10. '.output_text($votes['otvet_10']).': '.$otvet_10.' из '.$all_otvets.'<br/>';
}
if(isset($user) && $user['id']==$soo['admid'])echo'<a href="?s='.$soo['id'].'&results&del='.$votes['id'].'">Удалить опрос</a>';
echo '</div>';
}
if ($k_page>1)str("?s=$soo[id]&",$k_page,$page); // Вывод страниц
}
elseif(isset($_GET['create']) && isset($user) && $user['id']==$soo['admid'])
{
if(isset($_POST['vote']) && isset($_POST['otvet_1']) && isset($_POST['otvet_2']) && isset($_POST['num']) && is_numeric($_POST['num']) && isset($_POST['type']) && ($_POST['type']=='1' || $_POST['type']=='2' || $_POST['type']=='3'))
{
$vote=htmlspecialchars($_POST['vote']);
$mat=antimat($vote);
if ($mat)$err[]='В вопросе обнаружен мат: '.$mat;
if (strlen2($vote)>1024){$err[]='Вопрос слишком длинный';}
elseif (strlen2($vote)<2){$err[]='Вопрос короткий';}

$otvet_1=htmlspecialchars($_POST['otvet_1']);
$mat=antimat($otvet_1);
if ($mat)$err[]='В ответе 1 обнаружен мат: '.$mat;
if (strlen2($otvet_1)>32){$err[]='Ответ 1 слишком длинный';}
elseif (strlen2($otvet_1)<1){$err[]='Ответ 1 короткий';}

$otvet_2=htmlspecialchars($_POST['otvet_2']);
$mat=antimat($otvet_2);
if ($mat)$err[]='В ответе 2 обнаружен мат: '.$mat;
if (strlen2($otvet_2)>32){$err[]='Ответ 2 слишком длинный';}
elseif (strlen2($otvet_2)<1){$err[]='Ответ 2 короткий';}

if(isset($_POST['otvet_3']) && $_POST['otvet_3']!=NULL)
{
$otvet_3=$_POST['otvet_3'];
$mat=antimat($otvet_3);
if ($mat)$err[]='В ответе 3 обнаружен мат: '.$mat;
if (strlen2($otvet_3)>32){$err[]='Ответ 3 слишком длинный';}
elseif (strlen2($otvet_3)<1){$err[]='Ответ 3 короткий';}
}
else
{
$otvet_3=NULL;
}

if(isset($_POST['otvet_4']) && $_POST['otvet_4']!=NULL)
{
$otvet_4=$_POST['otvet_4'];
$mat=antimat($otvet_4);
if ($mat)$err[]='В ответе 4 обнаружен мат: '.$mat;
if (strlen2($otvet_4)>32){$err[]='Ответ 4 слишком длинный';}
elseif (strlen2($otvet_4)<1){$err[]='Ответ 4 короткий';}
}
else
{
$otvet_4=NULL;
}

if(isset($_POST['otvet_5']) && $_POST['otvet_5']!=NULL)
{
$otvet_5=$_POST['otvet_5'];
$mat=antimat($otvet_5);
if ($mat)$err[]='В ответе 5 обнаружен мат: '.$mat;
if (strlen2($otvet_5)>32){$err[]='Ответ 5 слишком длинный';}
elseif (strlen2($otvet_5)<1){$err[]='Ответ 5 короткий';}
}
else
{
$otvet_5=NULL;
}

if(isset($_POST['otvet_6']) && $_POST['otvet_6']!=NULL)
{
$otvet_6=$_POST['otvet_6'];
$mat=antimat($otvet_6);
if ($mat)$err[]='В ответе 6 обнаружен мат: '.$mat;
if (strlen2($otvet_6)>32){$err[]='Ответ 6 слишком длинный';}
elseif (strlen2($otvet_6)<1){$err[]='Ответ 6 короткий';}
}
else
{
$otvet_6=NULL;
}

if(isset($_POST['otvet_7']) && $_POST['otvet_7']!=NULL)
{
$otvet_7=$_POST['otvet_7'];
$mat=antimat($otvet_7);
if ($mat)$err[]='В ответе 7 обнаружен мат: '.$mat;
if (strlen2($otvet_7)>32){$err[]='Ответ 7 слишком длинный';}
elseif (strlen2($otvet_7)<1){$err[]='Ответ 7 короткий';}
}
else
{
$otvet_7=NULL;
}

if(isset($_POST['otvet_8']) && $_POST['otvet_8']!=NULL)
{
$otvet_8=$_POST['otvet_8'];
$mat=antimat($otvet_8);
if ($mat)$err[]='В ответе 8 обнаружен мат: '.$mat;
if (strlen2($otvet_8)>32){$err[]='Ответ 8 слишком длинный';}
elseif (strlen2($otvet_8)<1){$err[]='Ответ 8 короткий';}
}
else
{
$otvet_8=NULL;
}

if(isset($_POST['otvet_9']) && $_POST['otvet_9']!=NULL)
{
$otvet_9=$_POST['otvet_9'];
$mat=antimat($otvet_9);
if ($mat)$err[]='В ответе 9 обнаружен мат: '.$mat;
if (strlen2($otvet_9)>32){$err[]='Ответ 9 слишком длинный';}
elseif (strlen2($otvet_9)<1){$err[]='Ответ 9 короткий';}
}
else
{
$otvet_9=NULL;
}

if(isset($_POST['otvet_10']) && $_POST['otvet_10']!=NULL)
{
$otvet_10=$_POST['otvet_10'];
$mat=antimat($otvet_10);
if ($mat)$err[]='В ответе 10 обнаружен мат: '.$mat;
if (strlen2($otvet_10)>32){$err[]='Ответ 10 слишком длинный';}
elseif (strlen2($otvet_10)<1){$err[]='Ответ 10 короткий';}
}
else
{
$otvet_10=NULL;
}

$num=intval($_POST['num']);
$type=intval($_POST['type']);
if($type=='1')$time_close=$time+60*60*24*$num; elseif($type=='2')$time_close=$time+60*60*24*7*$num; else $time_close=$time+60*60*24*30*$num;
if(!isset($err)){
mysql_query("INSERT INTO `soo_votes` (`id_soo`, `vote`, `otvet_1`, `otvet_2`, `otvet_3`, `otvet_4`, `otvet_5`, `otvet_6`, `otvet_7`, `otvet_8`, `otvet_9`, `otvet_10`, `time_create`, `time_close`) values ('$soo[id]', '".my_esc($vote)."', '".my_esc($otvet_1)."', '".my_esc($otvet_2)."', '".my_esc($otvet_3)."', '".my_esc($otvet_4)."', '".my_esc($otvet_5)."', '".my_esc($otvet_6)."', '".my_esc($otvet_7)."', '".my_esc($otvet_8)."', '".my_esc($otvet_9)."', '".my_esc($otvet_10)."', '$time', '$time_close')");
msg('Опрос успешно создан');
}
}
err();
echo "<div class='fyt'>\n";
echo "<b>Создание опроса</b>";
echo "</div>\n";
echo'<form method="post" action="?s='.$soo['id'].'&create">';
echo'Вопрос<br/>';
echo'<input type="text" name="vote"><br/>';
echo'Варианты ответа(необходимо указать минимум 2)<br/>';
echo'1. <input type="text" name="otvet_1"><br/>';
echo'2. <input type="text" name="otvet_2"><br/>';
echo'3. <input type="text" name="otvet_3"><br/>';
echo'4. <input type="text" name="otvet_4"><br/>';
echo'5. <input type="text" name="otvet_5"><br/>';
echo'6. <input type="text" name="otvet_6"><br/>';
echo'7. <input type="text" name="otvet_7"><br/>';
echo'8. <input type="text" name="otvet_8"><br/>';
echo'9. <input type="text" name="otvet_9"><br/>';
echo'10. <input type="text" name="otvet_10"><br/>';
echo'Длительность опроса<br/>';
echo'<input type="text" name="num" size="3">';
echo'<select name="type">';
echo'<option value="1">Дней</option>';
echo'<option value="2">Недель</option>';
echo'<option value="3">Месяцев</option>';
echo'</select><br/>';
echo'<input type="submit" value="Создать">';
echo'</form>';
echo "<div class='fyt'>\n";
echo'<a href="?s='.$soo['id'].'">Перейти к опросам</a>';
echo "</div>\n";
}else{
$open=mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes` WHERE `id_soo` = '$soo[id]' AND `time_close`>'$time'"),0);
$close=mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_votes` WHERE `id_soo` = '$soo[id]' AND `time_close`<'$time'"),0);
echo'<div class="enk_div">• <a href="?s='.$soo['id'].'&open">Открытые</a> ('.$open.')</div>';
echo'<div class="enk2_div">• <a href="?s='.$soo['id'].'&results">Результаты</a> ('.$close.')</div>';
}
if(isset($user) && $user['id']==$soo['admid'])echo '<div class="fyt"><a href="?s='.$soo['id'].'&create"><u>Создать опрос</u></a></div>';
echo "<div class='fyt'>\n";
echo '<img src="img/back.png" alt="" class="icon"/> <a href="index.php?s='.$soo['id'].'">В сообщество</a></div>';
}
else
{
?>
<div class='err'>Вам недоступен просмотр опросов данного сообщества</div>
<?
}
}
else
{
header("Location:index.php");
}
require '../sys/inc/tfoot.php';
?>