<?

include '../../config.php';
include '../../func.php';
head();

$config = mysql_fetch_assoc(mysql_query("SELECT * FROM `config`"));

if ( $_GET['mod'] == 'vote_edit' AND $_GET['result'] == 'good' ) {
    
    echo link1 . 'Опрос изменен' . div;
    
}

if ( $_GET['mod'] == 'vote_edit' AND $_GET['result'] == 'error' ) {
    
    echo link1 . 'Ошибка при изменении опроса' . div;
    
}

if ( $_GET['mod'] == 'vote_delete' AND $_GET['result'] == 'good' ) {
    
    echo link1 . 'Опрос успешно удален' . div;
    
}

if ( $_GET['mod'] == 'vote_delete' AND $_GET['result'] == 'error' ) {
    
    echo link1 . 'Ошибка при удалении опроса' . div;
    
}
##################################

if ( $_GET['mod'] == 'status' ) {
    
    if ( $config['status_vote'] == 0 ) {
        mysql_query("UPDATE `config` SET `status_vote` = '1'");
        echo link2 . 'Опрос включен' . div;
    } else {
        mysql_query("UPDATE `config` SET `status_vote` = '0'");
        echo link2 . 'Опрос выключен' . div;        
    }
    
}

if ( $config['status_votes'] == 0 ) {
    echo link2 . 'Статус модуля: <b>Выключен</b><br/ > 
    [<a href="index.php?mod=status">ON</a>] <b>OFF</b><br/ >' . div;
} else {
    echo link2 . 'Статус модуля: <b>Включен</b><br/ > 
    [<a href="index.php?mod=status">OFF</a>] <b>ON</b><br/ >' . div;    
}

$result = mysql_query("SELECT * FROM votes");
while($vote = mysql_fetch_assoc($result)) {

    echo link1 . 'Опрос: '.$vote['nazv'].' - '.$vote['vopros'] . div;
    echo link2 . $blog['msg'] . '<br/ >';
       for($i=1; $i<6; $i++)
   {
    if($vote['v_'.$i.'']){
    
    echo "".$i.". " . $vote['v_'.$i.''] . "<br/>";
    }
   }
   
    echo '<br/ ><a href="vote_edit.php?id='.$vote['id'].'">Править</a> <a href="vote_delete.php?id='.$vote['id'].'">Удалить</a>' . div;
    
}