<?php
define('_IN_JOHNCMS', 1);
require_once ('../incfiles/core.php');
require_once ('../incfiles/head.php');
$user = intval($_GET['user']);
$cid = intval($_GET['cid']);
$req = mysql_query("SELECT * FROM `fanclub_vote` WHERE `user_id` = '$user_id' AND `cid`='$id'");
$res = mysql_fetch_array($req);

switch ($act) {
    case 'yes':
        if ($res) {
            /*если уже голосовал останавливаем*/
            echo functions::display_error('Siz ovoz bergansiz!<br/><a href="titul_club.php?id=' . $id .
                '">Orqaga</a>');
            require_once ("../incfiles/end.php");
            exit;
        }

        /*тут добавляем голос*/
        /*если фан то count=1*/
        $sql = mysql_query("INSERT INTO `fanclub_vote` SET
`cid`='" . $id . "',
`user_id`='" . $user_id . "',
`count`='1'
");
        $req = mysql_query("SELECT * FROM `fanclub` WHERE `id`='$id'");
        $res = mysql_fetch_array($req);

        $plus = $res['plus'] + 1;
        $sql1 = mysql_query("UPDATE `fanclub` SET
        `plus` = '" . $plus . "'
        WHERE `id` = '" . $id . "' LIMIT 1");


        header('Location: titul_club.php?id=' . $id . '');
        break;

    case 'no':
        if ($res) {
            /*если уже голосовал останавливаем*/
            echo functions::display_error('Siz ovoz bergansiz!<br/><a href="titul_club.php?id=' . $id .
                '">Orqaga</a>');
            require_once ("../incfiles/end.php");
            exit;
        }
        /*тут добавляем голос*/
        /*если анти-фан то count=0*/
        $sql = mysql_query("INSERT INTO `fanclub_vote` SET
`cid`='" . $id . "',
`user_id`='" . $user_id . "',
`count`='0'
");
        $req = mysql_query("SELECT * FROM `fanclub` WHERE `id`='$id'");
        $res = mysql_fetch_array($req);

        $minus = $res['minus'] + 1;
        $sql1 = mysql_query("UPDATE `fanclub` SET
        `minus` = '" . $minus . "'
        WHERE `id` = '" . $id . "' LIMIT 1");


        header('Location: titul_club.php?id=' . $id . '');

        break;

    case 'delkomm':
        mysql_query("DELETE FROM `fanclub_komm` 
 WHERE `id`='" . $id . "'
");
        header('Location: titul_club.php?id=' . $cid . '');
        break;
    case 'lider':


        $sql1 = mysql_query("UPDATE `fanclub` SET
        `user` = '" . $user . "'
        WHERE `id` = '" . $id . "' LIMIT 1");
        header('Location: users_club.php?id=' . $id . '&sort=1');

        break;

    default:
        header('Location: index.php');
}
require_once ('../incfiles/end.php');