Файл: conf/top.php
Строк: 248
<?php
$time_beg=microtime();
$user_top = $_SESSION['id'];
$query_hp = "Select hp, max_hp, last_active, radiation, bronya, antirad_time, regen, gruppa, read_ad, mentor_time, mentor_type, clan, location, sost_cl,sost_p, sost_w, time_p, speed_p, time_w, speed_w, message, m_fight from users where id = '$user_top'";
$result_hp = mysqli_query($dbc, $query_hp) or die ('Ошибка передачи запроса к БД');
$row_hp = mysqli_fetch_array($result_hp);
$hp = $row_hp['hp'];
$read_ad = $row_hp['read_ad'];
$gruppa_inv = $row_hp['gruppa'];
$location = $row_hp['location'];
$antirad_time = $row_hp['antirad_time'];
$radiation = $row_hp['radiation'];
$regen = $row_hp['regen'];
$mentor_time = $row_hp['mentor_time'];
$mentor_type = $row_hp['mentor_type'];
$max_hp = $row_hp['max_hp'];
$last_active = $row_hp['last_active'];
$clan_ad = $row_hp['clan'];
$now = (date("Y-m-d H:i:s"));
$last_active = strtotime("$last_active");
$now=strtotime("$now");
/////////////////////////////////////////////////Атака всякой нечести:)
    $m_fight=$row_hp['m_fight'];
    if ($m_fight<> 0) { 
    $query_at = "Select id_monster, hp, start, last_active, time_start, clan_id from m_fight where id_fight= '$m_fight' limit 1";
    $result_at = mysqli_query($dbc, $query_at) or die ('Ошибка передачи запроса к БД2');
    $row_at = mysqli_fetch_array($result_at);
    if (!empty($row_at)) {
      if ($row_at['start'] == 1 and $row_at['hp'] > 0) {
       $m_at = $row_at['id_monster'];
       $query_m = "Select name, screen, clan, max_people, max_hp, bronya, yron, speed, bonus_type, bonus, location, time_angry, location_name, respawn_time, max_aptechki from monsters where id_monster = '$m_at' limit 1";
$result_m = mysqli_query($dbc, $query_m) or die ('Ошибка передачи запроса к БД2');
$row_m = mysqli_fetch_array($result_m);
$max_people=$row_m['max_people'];
$max_hp_m=$row_m['max_hp'];
$loca=$row_m['location'];
       
       
       
        ///////////////////////РАНДОМНАЯ Атака Монстра
  $now = (date("Y-m-d H:i:s"));
  $now = strtotime("$now");
  $last_active = $row_at['last_active'];
  $last_active = strtotime("$last_active");
  $time = ($now - $last_active);
  $speed = $row_m['speed'];
  $count = ($time/$speed);
  $s=0;
  $count = round($count);
  while ($s <> $count) {
    
    $s=$s+1;
    $query_att = "Select id, hp, bronya, sost_cl, razriv_cl, sost_cl from users where location='$loca' and hp > 0 and last_active > NOW() - (60*5) and ban != 1 and m_fight = '$m_fight'";
    $result_att = mysqli_query($dbc, $query_att) or die ('Ошибка передачи запроса к БД7'); 
    $count_att = mysqli_num_rows($result_att);
    $row_att = mysqli_fetch_array($result_att);
    $t=1;
    $rand_number = rand(1,$count_att);
    while ($t<>$rand_number) {
      $t=$t+1;
      $row_att = mysqli_fetch_array($result_att);
    }
    ///////////Жертва выбраnа
    if ($row_att['sost_cl'] > 0) {
      $bron = $row_att['razriv_cl'];
    }
    else {
      $bron = 0;
    }
    $p = rand(245,275);
    $p = ($p/1000);
    if ($bron <> 0) {
      $attack = (($row_m['yron'] / $bron) * $p);
    }
    else {
      $attack = ($row_m['yron'] * $p);
    }
    $hp_att = ($row_att['hp'] - $attack);
    if ($hp_att <= 0) {
      if ($count_att <= 1) {
        if ($row_m['clan'] <> 0) {
          $query = "update m_fight set start = 0, hp='$max_hp_m' where id_fight='$m_fight' limit 1";
          $result = mysqli_query($dbc, $query) or die ('Ошибка передачи запроса к БД4g');
         }
         $query = "update users set m_fight = 0 where m_fight='$m_fight' limit $max_people";
         $result = mysqli_query($dbc, $query) or die ('Ошибка передачи запроса к БД4gt');
      }
    }
    $id_att = $row_att['id'];
    if ($id_att == $user_top) {
      $hp=($hp_att);
      $hp=round($hp);
    }
    $query_log = "insert into log (`time`, `user_id`, `sboitie`, `thing` , `yron`) values (NOW(), '$m_at', 10 , '$id_att', '$attack')";
    $result_log = mysqli_query($dbc, $query_log) or die ('Ошибка передачи запроса к БД18');
    if ($hp_att < 0) { 
      $query_log = "insert into log (`time`, `user_id`, `sboitie`, `thing` , `yron`) values (NOW(), '$m_at', 11 , '$id_att', '0')";
      $result_log = mysqli_query($dbc, $query_log) or die ('Ошибка передачи запроса к БД18');
    }
    $query_reb = "update users set hp = '$hp_att' where  id = '$id_att' limit 1";
    $result_reb= mysqli_query($dbc, $query_reb) or die ('Ошибка передачи запроса к БД10');
    if ($id_att == $user_id) {
    $hphp=$hp_att;
    }
    $query_reb = "update m_fight set last_active=NOW() where  id_fight = '$m_fight' limit 1";
    $result_reb= mysqli_query($dbc, $query_reb) or die ('Ошибка передачи запроса к БД10');    
  }
  ////////////////////////////////////////////
  ////////////////////////////////////////////
      }
    }
   }
///////////////////////////////////////////////////////////////////////// Конец нечести.
$last_active = $row_hp['last_active'];
$last_active = strtotime("$last_active");
///////////////////////////////Наставник
if (!empty($clan_ad)) {
  $mentor_time = strtotime("$mentor_time");
  $razn_mentor = ($now - $mentor_time);
  if ($razn_mentor_user < 3600) {
    $query_ment = "Select mentor from clans where clan_id = '$clan_ad'";
    $result_ment = mysqli_query($dbc, $query_ment) or die ('Ошибка передачи запроса к БД');
    $row_ment = mysqli_fetch_array($result_ment);
    $mentor = $row_ment['mentor'];
    if ($mentor_type == 1) { 
      $mentor = ($mentor/2);
    }
  $max_hp = ($max_hp+$max_hp/100*$mentor);
  }
}
/////////////////////////////////////////
$hp_time = ($now - $last_active);
if ($hp > 0 ) {
    $antirad_time = strtotime("$antirad_time");
    $time = (date("Y-m-d H:i:s"));
    $time = strtotime("$time");
    $antirad_time = ($time - $antirad_time);
  if ($location <> 'index' and $antirad_time > 7200) {
    $query_loc = "select radiation from location where location_name = '$location'  limit 1";
    $result_loc = mysqli_query($dbc, $query_loc) or die ('Ошибка передачи запроса к БД2');
    $row_loc = mysqli_fetch_array($result_loc);
    $radiation_loc = $row_loc['radiation'];
    $hp_down_rad = ($radiation - $radiation_loc);
    if ($hp_down_rad < 0) { 
      $regen = ($regen + $hp_down_rad);
    }
    $showregen = abs($regen);
  }
if ($hp_time !=0) {
  $hp_up = ($hp_time * $regen);
  $hp_up = ($hp + $hp_up);
      if ($hp_up <= 0) {
        $query_time_hp = "update users set hp = 0, last_active = NOW() where id = '$user_top' limit 1";
        $result_time_hp = mysqli_query($dbc, $query_time_hp) or die ('Ошибка передачи запроса к БД');
        $hp = 0;    
      }
      if (($max_hp > $hp_up) and ($hp_up > 0)) {
        $query_time_hp = "update users set hp = '$hp_up', last_active = NOW() where id = '$user_top' limit 1";
        $result_time_hp = mysqli_query($dbc, $query_time_hp) or die ('Ошибка передачи запроса к БД');    
      }
      if ($hp_up > $max_hp) {
        $query_time_hp = "update users set hp = '$max_hp', last_active = NOW() where id = '$user_top' limit 1";
        $result_time_hp = mysqli_query($dbc, $query_time_hp) or die ('Ошибка передачи запроса к БД');
      }
}
else {
  if ($hp<0) {
  $hp=0;
  }
}
}
else {
  if ($hp<0) {
  $hp=0;
  }
}
$time_p = '--';
$speed_p = $row_hp['speed_p'];
$last_using_p = $row_hp['time_p'];
if ($speed_p <> 0) {
  $last_using_p=strtotime("$last_using_p");
  $timer_p = ($now - $last_using_p);
  $time_p = ($speed_p - $timer_p);
  if ($time_p <0) {
    $time_p = 0;
  }
}
////    
$query_up_act = "update users set last_active = NOW() where id = '$user_top'";
$result_up_act = mysqli_query($dbc, $query_up_act) or die ('Ошибка передачи запроса к БД');
//////
$time_w = '--';
$speed_w = $row_hp['speed_w'];
$last_using_w = $row_hp['time_w'];
if ($speed_w <> 0) {
  $last_using_w=strtotime("$last_using_w");
  $timer_w = ($now - $last_using_w);
  $time_w = ($speed_w - $timer_w);
  if ($time_w <0) {
    $time_w = 0;
  }
}                            
?>
<div id="top">
  <img src="img/ico/life.png" alt="h" width="12" height="12"/><?php echo "$hp";?>
  <img src="img/ico/pistol.png" alt="p" width="12" height="12"/><?php echo "$time_p";?>
  <img src="img/ico/weapon.png" alt="w" width="36" height="12"/><?php echo "$time_w";?>
<?php
  if ($row_hp['sost_cl']<=0 and $row_hp['bronya'] <> 0) {
  $show=1;
  }
  if ($row_hp['sost_p']<=0 and $row_hp['speed_p'] <> 0) {
  $show=1;
  }
  if ($row_hp['sost_w']<=0 and $row_hp['speed_w'] <> 0) {
  $show=1;
  }
  if ($show==1) {
  ?> <a href="clothes.php?id=<?php echo "$user_top"; ?>"><img src="img/ico/redshield.png" alt="w" width="12" height="12" border="0"/></a> <?php 
  }
////////////////////////////////////////////////Излучение
if ($location <> 'index') {
  if ($regen > 0) {
    ?> <img src="img/ico/goodrad.png" alt="r" width="12" height="12"/>0<?php
  }
  if ($regen <= 0 and $regen > -10) {
    ?> <img src="img/ico/smrad.png" alt="r" width="12" height="12"/><?php echo "$showregen";
  }
  
  if ($regen < -10) {
    ?> <img src="img/ico/bigrad.png" alt="r" width="12" height="12"/><?php echo "$showregen";
  }
}
///////////////////////////////////////////////////////////////////////
if ($row_hp['message'] <> 0) {?> <a href="mail.php"><img src="img/ico/letter.png"  alt="п"width="12" height="12"/></a><?php }
if ($speed_p == 0) {?><div class="zx"><p class="red"><img src="img/ico/redshield.png" alt="w" width="12" height="12" border="0"/> Оденьте пистолет. [<a class="red" href="bag.php">в рюкзаке</a>]</p></div>
<?php }?><?php
if ($row_hp['bronya'] == 0) {?><div class="zx"><p class="red"><img src="img/ico/redshield.png" alt="w" width="12" height="12" border="0"/> Оденьте костюм. [<a class="red" href="bag.php">в рюкзаке</a>]</p></div>
<?php }?><?php
$query_inv = "select user_id_in, clan_name, clan_id, id_in from in_clan where user_id = '$user_top'";
$result_inv = mysqli_query($dbc, $query_inv) or die ('Ошибка передачи запроса к БД');
$row_inv = mysqli_fetch_array($result_inv);
$user_id_in = $row_inv['user_id_in'];
$clan_name = $row_inv['clan_name'];
$clan_id = $row_inv['clan_id'];
$id_in = $row_inv['id_in'];
$count_inv = mysqli_num_rows($result_inv);
if ($count_inv <> 0) {
?>
  <p class="zx"><span class="bonus"><img src="img/ico/point.png" width="12" height="12"/> <a href="profile.php?id=<?php echo "$id_in";?>"><?php echo "$user_id_in";?></a> приглашает вас вступить в 
  <?php
  if ($gruppa_inv == 'svoboda') {?> <img src="img/ico/svobodaon.png" width="12" height="12"/><?php }
  if ($gruppa_inv == 'dolg') {?> <img src="img/ico/dolgon.png" width="12" height="12"/><?php }
  if ($gruppa_inv == 'naemniki') {?> <img src="img/ico/odinochkion.png" width="12" height="12"/><?php }
  ?><a href="company.php?company_id=<?php echo "$clan_id";?>"><?php echo "$clan_name";?></a></span></p>
  <p>[<a href="acceptinv.php?acc=1">Принять</a>][<a href="acceptinv.php?acc=2">Отклонить</a>]</p>
<?php
}
if (!empty($read_ad)) {
  $query_ad = "select ad_nick, ad from clans where clan_id = '$clan_ad'";
  $result_ad = mysqli_query($dbc, $query_ad) or die ('Ошибка передачи запроса к БД');
  $row_ad = mysqli_fetch_array($result_ad);
  $ad = $row_ad['ad'];
  $ad_nick = $row_ad['ad_nick'];
  ?>
  <p class="zx"><span class="white">Объявление отряда: </span><span class="bonus"><?php echo "$ad // $ad_nick"; ?></span> <span class="white">[<a class="white" href="hidead.php">скрыть</a>]</span></p>
  <?php
}
?>
</div>