<?php
define('ROOT','../');
define('GCMS',true);
require_once (ROOT.'system/power.php');
if ($aut) {
if ($id) {
$type = $db -> query("SELECT * FROM `news` WHERE `id` = '".$id."'");
if ($type -> num_rows > 0) $the = $type -> fetch_assoc(); else $the = false;
} else $the = false;
switch($mode) {
case 'minus':
$te = $db -> query("SELECT * FROM `reit` WHERE `where`='news' and `komy` = '".$id."' and `kto` = '".$ya['id']."'");
if ($te -> num_rows > 0) {
    $t=$te->fetch_assoc();
     $diz -> head('Ошибка');
     $diz -> title('Ошибка');
     $msg .= '<div class="fon">Вы уже голосовали за данную новость!</div>';
     header('refresh: 3; url=new'.$t['komy'].'');
     #####Копирайт#######
require_once (ROOT.'system/kopy.php');
     $diz -> out($msg);
}else{
$db -> multi_query("INSERT INTO `reit` SET `where`='news', `kto` = '".$ya['id']."', `komy` = '".$id."',`rei` = '0',`time` = '".time()."'");
header('location: new'.$the['id']);
}
break;

case 'plus':
$te = $db -> query("SELECT * FROM `reit` WHERE `where`='news' and `komy` = '".$id."' and `kto` = '".$ya['id']."'");
if ($te -> num_rows > 0) {
    $t=$te->fetch_assoc();
     $diz -> head('Ошибка');
     $diz -> title('Ошибка');
     $msg .= '<div class="fon">Вы уже голосовали за данную новость!</div>';
     header('refresh: 3; url=new'.$t['komy'].'');
     #####Копирайт#######
require_once (ROOT.'system/kopy.php');
     $diz -> out($msg);
}else{
$db -> multi_query("INSERT INTO `reit` SET `where`='news', `kto` = '".$ya['id']."', `komy` = '".$id."',`rei` = '1',`text` = '".$text."',`time` = '".time()."'");
header('location: new'.$the['id']);
}
break;

default:
header('location: ../index.php');
}
} else header('location: ../aut.php');
?>