<?php
require_once('conf/dbc.php');
require_once('conf/session_start.php');
require_once('conf/ban.php');
$page_title = 'Напасть';
require_once('conf/head.php');
require_once('conf/top.php');
$usid = abs(intval($_SESSION['id']));
$user = $pdo->query("SELECT * FROM users WHERE id='".$usid."'")->fetch();
$clanid = $user['clan'];
$clanpr= abs(intval($_GET['pr_id']));
$clan = $pdo->query("SELECT * FROM clans WHERE clan_id='".$clanid."'")->fetch();
if($user[clan]<=0){header('location: index.php');
exit();}
if($clan[bitva]>0){header('location: bitva.php');
exit();}
if($clanpr<=0){header('location: index.php');
exit();}
if($user[clan_rang]<8){header('location: clan.php?id='.$clanid.'');
exit();}
$query = "Select * from bitva  WHERE `clan_id` = '$clanid' or `clan_id` = '$clanid' LIMIT 1";
$for= mysqli_query($dbc, $query) or die ('Ошибка передачи запроса к БД');
$avto = mysqli_num_rows($for);
if($avto==0){
$pdo->exec("INSERT INTO `bitva` SET  `clan_id` = '$clanid', `clan_pr_id` = '$clanpr',time_start='".time()."'");
header('location: bitva.php');}
else{header('location: bitva.php');
exit();}
require_once('conf/navig.php');
require_once('conf/foot.php');
?>
</div>
</body>
</html>