Файл: GeroyHaosa/files/func.php
Строк: 222
<?php
defined('PROTECTOR') or die('Error: restricted access');
function zasad(){
global $inzasada;
if ($inzasada=='1'){
header ('Location: zasada.php?');exit;
}
}
function ryd(){
global $inryd;
if ($inryd=='1'){
header ('Location: rydnik.php?');exit;
}
}
//////////БОИ
function going(){
global $in_battle,$inpk,$inar,$inzasada;
///////////////////////////////БОЙ/////////////////////
if ($in_battle=='1'){
header ('Location: battle.php?');exit;
}
/////////////////////////////////////////////////////////////////
elseif ($inpk=='1'){
header ('Location: pk.php?');exit;
}
///////////////////////////////////////////////////////////////////
elseif ($inar=='1'){
header ('Location: combat.php?');exit;
}
}
##############################################################################################
function auto_clean(){
global $log;
$req=mysql_query("SELECT * FROM log WHERE usr = '$log' LIMIT 20");
$avto = mysql_num_rows($req);
if($avto>='20'){
$lim=round($avto/2);
mysql_query("DELETE FROM `log` WHERE `usr` = '$log' LIMIT $lim");
}
}
function del_log($lpl){
global $log;
mysql_query("DELETE FROM `log` WHERE `usr` = '$log' and `place` = '$lpl'");
}
function log_msg($tlog){
global $log;
$req=mysql_query("SELECT * FROM log WHERE usr = '$log' and place='$tlog' and timer>='".time()."' ORDER BY id DESC LIMIT 6");
$avto = mysql_num_rows($req);
if($avto>=1){
echo'<div class="logtext">';
While($ilok = mysql_fetch_assoc($req))
{
if($ilok['kto']=='system'){$color='grey';}
if($ilok['kto']=='user'){$color='green';}
if($ilok['kto']=='enemy'){$color='red';}
echo '<small><font color="'.$color.'">'.$ilok[text].'</font></small><br/>';
}
echo'</div>';
}
}
function idlog($idlog){
$reqi = mysql_query("SELECT lvl,storona FROM `users` WHERE `usr` = '$idlog' LIMIT 1");
// //////////////////////////
$avto = mysql_num_rows($reqi);
if($avto>=1){
$ref = mysql_fetch_assoc($reqi);
echo'<img src="pic/main/'.$ref['storona'].'.png" alt="#"/><a href="search.php?nick='.$idlog.'&go=go">'.$idlog.'</a> <img src="pic/main/up.png" alt="lvl"/> '.$ref['lvl'];
}
}
///РЕФЕРАЛЫ
function ref(){
global $log,$udata;
if(!empty($udata['ref'])){
if($udata['lvl']>='5' and $udata['ref']!='not'){
$req = mysql_query("SELECT `exp`,`money` FROM `users` WHERE `id` = '$udata[ref]' LIMIT 1");
// //////////////////////////
$avto = mysql_num_rows($req);
if ($avto == 1) {
$refer = mysql_fetch_assoc($req);
$refer[money]=$refer[money]+250;
$refer[exp]=$refer[exp]+250;
mysql_query("UPDATE users SET money = '$refer[money]',exp='$refer[exp]' WHERE id = '$udata[ref]' LIMIT 1");
mysql_query("UPDATE users SET ref = 'not' WHERE usr = '$log' LIMIT 1");
}
}
}
}
/////////////////////
function asasins(){
global $log;
$timeout=time()-86400;
$req = mysql_query("SELECT * FROM `asasins_active` WHERE `usr` = '$log' LIMIT 1");
$avto=mysql_num_rows($req);
if($avto=='1'){
$a = mysql_fetch_array($req);
mysql_query("UPDATE `asasins_active` SET `ltime` = '".time()."' WHERE `usr`='$log' LIMIT 1");
}
$req = mysql_query("SELECT * FROM `asasins_active` WHERE `ltime`<'$timeout'");
$avto=mysql_num_rows($req);
if($avto>='1'){
While($ak = mysql_fetch_assoc($req))
{
$req = mysql_query("SELECT hpall FROM `asasins` WHERE `id`='$ak[asasin]' LIMIT 1");
$ass = mysql_fetch_array($req);
mysql_query("UPDATE asasins SET status = 'on',`hp`='$ass[hpall]' WHERE `id`='$ak[asasin]' LIMIT 1");
}
mysql_query("DELETE FROM `asasins_active` WHERE `ltime`<'$timeout'");
}
}
function domin(){
global $udata;
$req=mysql_query("SELECT * FROM domination WHERE id = '1'");
$dom = mysql_fetch_assoc($req);
if($udata['storona']=='white'){
$my=$dom['white'];
$enemy=$dom['black'];
}else{
$my=$dom['black'];
$enemy=$dom['white'];
}
$all=$my+$enemy;
$domin=round($my/$all * 100);
if($domin<='15'){
echo' <img src="pic/main/towerscontrol1.png" alt="d">'.$domin.'%';
}elseif($domin<='30'){
echo' <img src="pic/main/towerscontrol2.png" alt="d">'.$domin.'%';
}elseif($domin<='45'){
echo' <img src="pic/main/towerscontrol3.png" alt="d">'.$domin.'%';
}elseif($domin<='55'){
echo' <img src="pic/main/towerscontrol4.png" alt="d">'.$domin.'%';
}elseif($domin<='70'){
echo' <img src="pic/main/towerscontrol5.png" alt="d">'.$domin.'%';
}elseif($domin<='85'){
echo' <img src="pic/main/towerscontrol6.png" alt="d">'.$domin.'%';
}elseif($domin<='100'){
echo' <img src="pic/main/towerscontrol7.png" alt="d">'.$domin.'%';
}
}
//////////////////ОТДЫХ
function out(){
global $log;
$time=time();
///////
$req = mysql_query("SELECT * FROM `out` WHERE `timeout`<'$time' and `usr`='$log'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>='1'){
mysql_query("DELETE FROM `out` WHERE `usr` = '$log'");
}
}
function clanwarn(){
global $log,$udata;
$time=time();
///////
$req = mysql_query("SELECT * FROM `clanwar` WHERE `timeout`<'$time' and `clan`='$udata[clan]'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
mysql_query("DELETE FROM `clanwar` WHERE `usr` = '$log'");
}
}
//////////////////////
/////АУРЫ//////////////
function aura(){
global $log,$udata;
$time=time();
///////
$req = mysql_query("SELECT * FROM `aurs` WHERE `actimer`<'$time' and `usr`='$log'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto=='1'){
$req = mysql_query("SELECT * FROM `item_aura` WHERE `usr` = '$log' and `status`='1' LIMIT 1");
$avto=mysql_num_rows($req);
if($avto=='1'){
$mag = mysql_fetch_assoc($req);
$numin=$udata['umin']-$mag['umin'];
$numax=$udata['umax']-$mag['umax'];
$nprotect=$udata['prot']-$mag['protect'];
$nhp=$udata['hpall']-$mag['hp'];
$nmp=$udata['mpall']-$mag['mp'];
$nkrit=$udata['krit']-$mag['krit'];
$nukrit=$udata['ukrit']-$mag['ukrit'];
$nanti=$udata['antikrit']-$mag['antikrit'];
mysql_query("UPDATE `users` SET
`umin` = '$numin',
`umax` = '$numax',
`hpall` = '$nhp',
`mpall` = '$nmp',
`krit` = '$nkrit',
`ukrit` = '$nukrit',
`antikrit` = '$nanti',
`prot` = '$nprotect' WHERE usr = '$log'");
if($mag['kol']=='1'){
mysql_query("DELETE FROM `item_aura` WHERE `id` = '$mag[id]' LIMIT 1");
}else{
$mag[kol]--;
mysql_query("UPDATE item_aura SET kol = '$mag[kol]',status='0' WHERE `id` = '$mag[id]' LIMIT 1");
}
mysql_query("DELETE FROM `aurs` WHERE `usr` = '$log' LIMIT 1");
}
}
}
////////////////////////
//////////////ЧИСТИМ АРЕНУ
function clear_arena(){
$time=time();
///////
$req = mysql_query("SELECT * FROM `arena_wait` WHERE `wait`<'$time'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>='1'){
While($inv = mysql_fetch_assoc($req))
{
if(empty($inv['enemy'])){
mysql_query("DELETE FROM `arena_wait` WHERE id='$inv[id]'");//чистим заявки
}else{
mysql_query("INSERT INTO
`arena` SET `usr` = '$inv[usr]',
`enemy` = '$inv[enemy]',
`xod` = 'not',
`ltime`='$time'");
mysql_query("INSERT INTO
`arena` SET `usr` = '$inv[enemy]',
`enemy` = '$inv[usr]',
`xod` = 'not',
`ltime`='$time'");
del_log($lpl='combat');
$timer=time()+300;
mysql_query("INSERT INTO log SET usr='$log',text='$inv[usr] против $inv[enemy]!Бой начался!',kto='system',place='combat',timer='$timer'");
mysql_query("DELETE FROM `arena_wait` WHERE usr='$inv[usr]' LIMIT 1");//чистим заявки
mysql_query("DELETE FROM `arena_wait` WHERE usr='$inv[enemy]' LIMIT 1");//чистим заявки
}
}
}
}
//////////////////////
///////КОРМИМ ПИТОВ
function pit_eda(){
global $log;
$time=time();
$req = mysql_query("SELECT `dies`,`lasteda`,`name` FROM `pit` WHERE `usr` = '$log' and `status`='on' LIMIT 1");
$avto=mysql_num_rows($req);
if($avto>='1'){
$pit = mysql_fetch_assoc($req);
if($pit['lasteda']<=$time){
$pit['dies']=$pit['dies']+1;
mysql_query("UPDATE `pit` SET `hp` = '0',`dies`='$pit[dies]',`status`='die' WHERE `usr` = '$log' and `status`='on' LIMIT 1");
///пишем письмо
$time = date("H:i d.m.y");
$text = $pit[name].' погиб от голода! Вы можете его воскресить в питомнике!';
mysql_query("INSERT INTO `msg_r` SET `user_from` = 'Зверовод', `user_to` = '$log', `time` = '$time', `read` = 1, `mail_msg` = '$text'");
}
}
}
////////////////
//навигация
function place_okr(){
global $log;
$req = mysql_query("SELECT `city` FROM `mesto` WHERE `usr` = '$log' LIMIT 1");
////////////////////////////
$mestouser = mysql_fetch_assoc($req);
if($mestouser['city']=='1'){
header ('Location: okrestnosti.php?');exit;
}
}
//навигация
function place_zamok(){
global $log;
$req = mysql_query("SELECT `city` FROM `mesto` WHERE `usr` = '$log' LIMIT 1");
////////////////////////////
$mestouser = mysql_fetch_assoc($req);
if($mestouser['city']=='2'){
header ('Location: zamok.php?');exit;
}
}
//навигация
function place_tower(){
global $log;
$req = mysql_query("SELECT `city` FROM `mesto` WHERE `usr` = '$log' LIMIT 1");
////////////////////////////
$mestouser = mysql_fetch_assoc($req);
if($mestouser['city']=='3'){
header ('Location: towers.php?');exit;
}
}
//навигация
function place_city(){
global $log;
$req = mysql_query("SELECT `city` FROM `mesto` WHERE `usr` = '$log' LIMIT 1");
////////////////////////////
$mestouser = mysql_fetch_assoc($req);
if($mestouser['city']=='0'){
header ('Location: gorod.php?');exit;
}
}
?>