Файл: votes/inc/setting.php
Строк: 49
<?
$set['title']='Параметры голосований';
include_once '../sys/inc/thead.php';
title();
aut();
################################################################################
switch($_GET['do'])
{
case 'priority':
$id=abs(intval($_GET['id']));
$vote=mysql_fetch_array(mysql_query("SELECT * FROM `votes` WHERE `id`='$id'"));
if(isset($_GET['ok']))
{
mysql_query("UPDATE `votes` SET `priority` = '0'");
mysql_query("UPDATE `votes` SET `priority` = '1' WHERE id='$id'");
if($vote['close']==1)
{
mysql_query("UPDATE `votes` SET `close` = '0' WHERE id='$id'");
}
header("Location: ?act=setting&priok");
exit;
}else{
echo"Вы действительно хотите сделать это голосование главным? <br />
[<a href='?act=setting&do=priority&id=".$id."&ok'>Да</a>][<a href='?act=setting'>Нет</a>]n";
}
break;
case 'close':
$id=abs(intval($_GET['id']));
$vote=mysql_fetch_array(mysql_query("SELECT * FROM `votes` WHERE `id`='$id'"));
if($vote['close']==0)
{
$cl= "закрыть";
$clos=1;
if($vote['priority']==1)
{
$pr=mysql_fetch_array(mysql_query("SELECT * FROM `votes` WHERE `close`!='1' AND id!='$id' ORDER BY `create_date` DESC"));
mysql_query("UPDATE `votes` SET `priority` = '1' WHERE id='".$pr['id']."'");
mysql_query("UPDATE `votes` SET `priority` = '0' WHERE id='".$id."'");
}
}else{
$cl= "открыть";
$clos=0;
$cpr=mysql_result(mysql_query("SELECT COUNT(*) FROM `votes` WHERE `priority`='1'"),0);
if($cpr==0)
{
mysql_query("UPDATE `votes` SET `priority` = '1' WHERE id='".$id."'");
}
}
if(isset($_GET['ok']))
{
mysql_query("UPDATE `votes` SET `close` = '$clos' WHERE id='$id'");
header("Location: ?act=setting&close$clos");
exit;
}else{
echo"Вы действительно хотите $cl это голосование? <br />
[<a href='?act=setting&do=close&id=".$id."&ok'>Да</a>][<a href='?act=setting'>Нет</a>]n";
}
break;
case 'delete':
$id=abs(intval($_GET['id']));
$vote=mysql_fetch_array(mysql_query("SELECT * FROM `votes` WHERE `id`='$id'"));
if(isset($_GET['ok']))
{
mysql_query("DELETE FROM `votes` WHERE `id` = '$id'");
mysql_query("DELETE FROM `votes_dilem` WHERE `v_id` = '$id'");
mysql_query("DELETE FROM `votes_user` WHERE `v_id` = '$id'");
if($vote['priority']==1)
{
$pr=mysql_fetch_array(mysql_query("SELECT * FROM `votes` WHERE `close`!='1' ORDER BY `create_date` DESC"));
mysql_query("UPDATE `votes` SET `priority` = '1' WHERE id='".$pr['id']."'");
}
header("Location: ?act=setting&delok");
exit;
}else{
echo"Вы действительно хотите удалить это голосование? <br />
[<a href='?act=setting&do=delete&id=".$id."&ok'>Да</a>][<a href='?act=setting'>Нет</a>]n";
}
break;
default:
if(isset($_GET['priok']))
{
msg('Голосование назначено главным');
}
if(isset($_GET['close1']))
{
msg('Голосование закрыто');
}
if(isset($_GET['close0']))
{
msg('Голосование открыто');
}
if(isset($_GET['delok']))
{
msg('Голосование удалено');
}
$votes=mysql_query("SELECT * FROM `votes` ORDER BY `priority` DESC,`create_date` DESC");
echo "<table class='post'>n";
while($vote=mysql_fetch_array($votes))
{
echo " <tr>n";
echo " <td class='icon' rowspan='2'>n";
echo " <img src='/style/themes/$set[set_them]/votes/vote.png' alt='' />n";
echo " </td>n";
echo " <td class='p_t'>n";
echo " <a href="?v_id=".$vote['id'].""><b>".esc(trim(br(bbcode(smiles(links(stripcslashes(htmlspecialchars($vote['text']))))))))."</b></a>";
echo " </td>n";
echo " </tr>n";
echo " <tr>n";
echo " <td class='p_m'>n";
if($vote['priority']==1)
{
echo "Главное голосование<br />n";
}else{
echo "<a href='?act=setting&do=priority&id=".$vote['id']."'>Сделать главным</a><br />n";
}
if($vote['close']==1)
{
echo "<a href='?act=setting&do=close&id=".$vote['id']."'>Открыть </a>n";
}else{
echo "<a href='?act=setting&do=close&id=".$vote['id']."'>Закрыть </a>n";
}
echo "<a href='?act=setting&do=delete&id=".$vote['id']."'>Удалить</a><br />n";
echo " </td>n";
echo " </tr>n";
}
echo "</table>n";
echo "<a href='?'>Вернуться к голосованиям</a><br />n";
break;
}
?>