Файл: public_html/terrotory.php
Строк: 195
<?
include './system/common.php';
include './system/functions.php';
include './system/user.php';
if(!$user) {
header('location: /');
exit;
}
$title = "Обмен мифрилов";
include './system/h.php';
if($_GET['mod']=='taran' OR $_GET['mod']=='go' OR $_GET['mod']=='outtower' OR $_GET['mod']=='repair'){
$header=TRUE;
}else{
}
$timer=time()+300;
$log = $user[login];
switch($_GET['mod']){
default:
echo'<div class="main"><div class="block_zero center"><span style="color: #9bc;">Здесь вы сможете обменять <img src="https://od.barbars.ru/images/icons/mifrilbar.png"> на что нибудь драгоценное!!</span></div><div class="mini-line"></div><div class="block_zero center"><img src="http://btvar.ru/images/town/000005.jpg" width="240" height="120" alt="logo"></div><div class="mini-line"></div><div class="block_zero center">';echo'</div><div class="dot-line"></div>';
if($mestouser['towers']==0){
$req = mysql_query("SELECT * FROM `terrotory`");
$avto=mysql_num_rows($req);
if($avto>=1){
While($tower = mysql_fetch_array($req)){
if($tower['control']=='not'){
$tow="<img src='images/icon/race/bot.png'>";
}else{
$tow="<img src='images/icon/race/$tower[control].png'>";
}
if($user['level']>$tower['mlvl'] or $user['level']<$tower['lvl']){
$col="<span style='color: #c66;'>";
}else{
$col="<span style='color: #9c9;'>";
}
echo"<div class='list'>
<a href="terrotory.php?mod=go&id=$tower[id]"> $tow $col $tower[name]</a> <img width='16' height='16' src='images/icon/level.png'> <span style='color: #ffffff;'> $tower[lvl]-$tower[mlvl] ур.<br><small>Прочность: <img src='images/icon/health.png'> $tower[hp]/$tower[hpall] <br>Награда: <img src='images/icon/premium.png'> $tower[point] Героизма </small></span>";
}
}else{
echo'<div class="main"><div class="block_zero center"></div></div>';
}
}
echo'</div><div class="mini-line"></div>';
echo'<ul class="info"></a></li></ul>';
echo'</div></div>';
break;
case 'vhod':
echo'<div class="main"><div class="block_zero center"><span style="color: #9bc;">Тысячелетнее противостояние Бессмертных!</span></div><div class="mini-line"></div><div class="block_zero center"><img src="image/logo/newfight.jpg" alt="logo"></div><div class="mini-line"></div><div class="block_zero center">';
$tower = mysql_fetch_array(mysql_query("SELECT * FROM `terrotory` WHERE id='$mestouser[towers]'"));
if($tower['control']=='not'){
echo"<img src='image/icon/bot.png' alt='*'/>Контрольне установлен ";
}else{
echo"<img src='images/towers/$tower[control].png' alt='*'/>Под контролем у ";
}
echo" $tower[name] <br/><img src="/hptower.php" alt="*"/></div><div class='dot-line'></div><div class="block_zero center">";
if($tower['control']=='0'){
$strazh="Врата охраняют Титаны!";
}
elseif($tower['control']=='1'){
$strazh="Врата охраняют Боги!";
}
if($tower['control']!=$user['r']){
echo"$strazh<div class="separ"></div><a href="terrotory.php?mod=taran"><span class="btn"><span class="end"><input class="label" type="submit" value="Таранить Врата"></span></span></a>";
}else{
echo" $strazh<div class="separ"></div><a href="terrotory.php?mod=repair"><span class="btn"><span class="end"><input class="label" type="submit" value="Укрепить Врата"></span></span></a>";
}
echo'</div><div class="dot-line"></div><div class="block_zero">';
echo'Титаны:';
$odin=false;
$timeout=time()-300;//оффлайн
$req = mysql_query("SELECT * FROM online WHERE laikas > '$timeout' and `usr`!='$log'");
While($who = mysql_fetch_array($req)){
$reqs = mysql_query("SELECT * FROM `mesto` WHERE `usr` = '$who[usr]' LIMIT 1");
$mesto = mysql_fetch_array($reqs);//место
$reqs = mysql_query("SELECT id,city,r,health FROM `users` WHERE `id` = '$who[usr]' LIMIT 1");
$cit = mysql_fetch_array($reqs);//город
if($mesto['city']==0 && $mesto['towers']==$mestouser['towers']){
$idlog=$who['usr'];
if($cit['storona']==$user['r']){
echo'<font color="green"> Союзник: ';
echo''.$idlog.', ';
}else{
echo'<font color="red"> Враг: ';
echo''.$idlog.', ';
/*
echo" <a href="ok.php?k=pk&id=$cit[id]">Бить($cit[hp] хп)</a></font><br/>";
*/
}
$odin=true;
}
}
if($odin==false){
echo' никого нет';
}
echo'</div><div class="dot-line"></div><div class="block_zero center">';
echo"<a href="terrotory.php?mod=outtower"><span class="btn"><span class="end"><input class="label" type="submit" value="Выйти из боя"></span></span></a>";
echo'</div><div class="dot-line"></div><div class="block_zero">';
$data = mysql_query("SELECT * FROM `log`");
while($row = mysql_fetch_assoc($data))
{
echo "<center>$row[usr]:";
echo "$row[text] ";
echo "</center>";
}
echo'</font></div></div>';
break;
case 'go':
$req = mysql_query("SELECT * FROM `terrotory` WHERE `id` = '".mysql_real_escape_string($_GET['id'])."'");
$avto=mysql_num_rows($req);
$tower = mysql_fetch_array($req);
if($avto==0){header('Location: terrotory.php?');
exit();
}
if($user['level']>$tower['mlvl'] AND $log!='Admin'){
header('Location: terrotory.php?');
$_SESSION['err'] = 'У Вас высокий уровень!';
exit();
}
if($user['level']<$tower['lvl'] AND $log!='Admin'){
header('Location: terrotory.php?');
$_SESSION['err'] = 'У Вас низкий уровень!';
exit();
}
mysql_query("UPDATE `mesto` SET `towers` = '".mysql_real_escape_string($_GET['id'])."' WHERE `usr`='$log'");
mysql_query("INSERT INTO log SET usr='$log',text='Вы вошли во $tower[name]',kto='system',place='tower',timer='$timer'");
header('Location: terrotory.php?mod=vhod');
exit();
break;
case 'taran':
$req = mysql_query("SELECT * FROM `users` WHERE self='$user[self]'");
$avto=mysql_num_rows($req);
if($avto==0){
header('Location: terrotory.php?');
$_SESSION['err'] = 'Вы не находитесь возле Врат!';
exit();
}
$tower = mysql_fetch_array($req);
if($tower['control']==$user['r']){
header('Location: terrotory.php?mod=vhod');
$_SESSION['message'] = 'Врата уже Ваши!';
exit();
}
if($tower['hp']<=0){
header('Location: terrotory.php?mod=vhod');
$_SESSION['message'] = 'Врата уже Ваши!';
exit();
}else{
$uron=rand($user['str']-$user['str']/8,$user['str']+$user['str']/8);
$muron=2+rand(0,$user['health']/5);
$tower['hp']=$tower['hp']-$uron;
if($tower['hp']<=0){
$tow = mysql_query("SELECT * FROM `terrotory`");
$am=0;
While($sum = mysql_fetch_array($tow)){
$am=$am+$sum['point'];
}
$proc=$am/100;
$point=round($tower['point']/$proc);
$hpin=round($tower['hpall']/1.5);
mysql_query("UPDATE `terrotory` SET `control`='$user[r]',`hp`='$hpin' WHERE id='$mestouser[towers]'");
$req = mysql_query("SELECT * FROM `domination` WHERE `id` = '1' LIMIT 1");
$dom = mysql_fetch_array($req);
$m=explode(",",$tower['money']);
$m=rand($m['0'],$m['1']);
$user['g']=$user['g']+$m;
$user['s']=$user['s']+$tower['point'];
$user['exp']=$user['exp']+$tower['exp'];
if($user['r']=='0'){
$my=$dom['0'];
$enemy=$dom['1'];
}else{
$my=$dom['1'];
$enemy=$dom['0'];
}
$my=$my+$point;
if($tower['control']=='not'){
if($user['r']=='0'){
mysql_query("UPDATE `domination` SET `0` = '$my' WHERE `id` = '1'");
}else{
mysql_query("UPDATE `domination` SET `1` = '$my' WHERE `id` = '1'");
}
}else{
$enemy=$enemy-$point;
$ma = 10000;
if($user['r']=='0'){
mysql_query("UPDATE `domination` SET `0` = '$my',`1`='$enemy' WHERE `id` = '1'");
}else{
mysql_query("UPDATE `domination` SET `1` = '$my',`0`='$enemy' WHERE `id` = '1'");
}
}
$resd = mysql_query("SELECT `prodob` FROM `dost` WHERE `usr`='$log'") or die (mysql_error());
$res = mysql_fetch_array($resd);
$dob=$res['prodob']+1;
mysql_query("UPDATE `dost` SET `prodob` = '$dob' WHERE `usr` = '$log'");
$req = mysql_query("SELECT * FROM `clan` where `lider`='$user[clan]'");
$avto=mysql_num_rows($req);
$clan = mysql_fetch_array($req);
if($avto==1){
$clexp=$tower[exp]/10;
}
mysql_query("UPDATE `clan` SET `exp` = `exp`+'$clexp' WHERE `lider` = '$user[clan]'");
mysql_query("UPDATE `users` SET `s` = '$user[s]',`exp` = '$user[exp]',`g` = '$user[g]' WHERE `id` = '$log'");
mysql_query("INSERT INTO log SET usr='$log',text='Вы захватили $tower[name]! + $tower[exp] опыта, +$ma золота',kto='user',place='tower',timer='$timer'");
mysql_query("UPDATE `users` SET `g` = + '$ma',`exp` = '$tower[exp]',`g` = + '1' WHERE `id` = '$log'");
header ("Location: terrotory.php?mod=vhod");
exit;
}
if($user['health']>'0'){
//mysql_query("UPDATE `mesto` SET `place` = 'gorod',`city` = '0' WHERE usr='$log'");
header ("Location: index.php?");
exit;
}
mysql_query("UPDATE `terrotory` SET `hp` = '$tower[hp]' WHERE id='$mestouser[towers]'");
mysql_query("UPDATE `users` SET `hp` = '$user[health]'-'$muron' WHERE usr='$log'");
mysql_query("INSERT INTO log SET usr='$log',text='Атаковал башню на $uron',kto='user',place='tower',timer='$timer'");
mysql_query("INSERT INTO log SET usr='$log',text='Вас ранили стражнки на-$muron',kto='user',place='tower',timer='$timer'");
header ("Location: terrotory.php?mod=vhod");
exit;
}
break;
case 'repair':
$req = mysql_query("SELECT * FROM `terrotory` WHERE `id` = '$mestouser[towers]' AND `control` = '$user[r]'");
$avto=mysql_num_rows($req);
if($avto==0){
header('Location: terrotory.php?');
$_SESSION['err'] = 'Вы не находитесь возле Врат!';
exit();
}
$tower = mysql_fetch_array($req);
$req = mysql_query("SELECT * FROM `res` WHERE `lat_name` = 'kamen' AND `kol` >= '1' AND `usr` = '$log'");
$kamen=mysql_num_rows($req);
if($kamen==0){
mysql_query("INSERT INTO log SET usr='$log',text='Нет камня',kto='system',place='tower',timer='$timer'");
header ("Location: terrotory.php?mod=vhod");exit;}
$kam = mysql_fetch_array($req);
if($tower['hp']>=$tower['hpall']){
mysql_query("INSERT INTO log SET usr='$log',text='Врата целы',kto='system',place='tower',timer='$timer'");
header ("Location: terrotory.php?mod=vhod");exit;
}$tower['hp']=$tower['hp']+50;
if($tower['hp']>$tower['hpall']){$tower['hp']=$tower['hpall'];
}
$kam['kol']--;
$gogen = 100;
mysql_query("UPDATE `terrotory` SET `hp` = '$tower[hp]' WHERE id='$mestouser[towers]' and control='$user[r]'");
mysql_query("INSERT INTO log SET usr='$log',text='Вы отремонтировали Врата на 50 едениц, потратили 1 камень',kto='user',place='tower',timer='$timer'");
case 'outtower':
mysql_query("UPDATE `mesto` SET `terrotory` = '0' WHERE `usr`='$log'");
header ("Location: terrotory.php?");exit;
break;}
echo'</font>';
include './system/f.php';
?>