Файл: tankon.mobi/tanks/function.php
Строк: 432
<?
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/next_level_clan.php';
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `tanks` WHERE `id`='".$user['id']."'"),0)==0){
mysql_query("INSERT INTO `tanks`(`id`,`id_u`) VALUES('".$user['id']."','".$user['id']."')");
$id_ava=mysql_insert_id();
if($user['pol']!=1){$rand_ava=rand(5,8);mysql_query("UPDATE `tanks` SET `ava` = '".$rand_ava."' WHERE `id` = '".$id_ava."' LIMIT 1");}
else{$rand_ava=rand(1,4);mysql_query("UPDATE `tanks` SET `ava` = '".$rand_ava."' WHERE `id` = '".$id_ava."' LIMIT 1");}
}
$tankss_code = mysql_fetch_array(mysql_query("SELECT * FROM `tanks` WHERE `id_u`='".$ank['id']."'"));
$tanks_code = mysql_fetch_array(mysql_query("SELECT * FROM `tanks` WHERE `id_u`='".$user['id']."'"));
$us_code = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id`='".$tanks_code['id']."'"));
$tank_lin = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_magazin` WHERE `id`='".$tanks_code['tank']."'"));
$all_tankist = mysql_result(mysql_query("SELECT COUNT(*) FROM `tanks` WHERE `id_u`!='".$user['id']."'"),0);
$tank_lins = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_magazin` WHERE `id`='".$tankss_code['tank']."'"));
$angar_result=mysql_result(mysql_query("SELECT COUNT(*) FROM `tanks_angar` WHERE `user` = '".$tanks_code['id']."'"), 0);
if(mysql_result(mysql_query("SELECT COUNT(`id`) FROM `collective_invite` WHERE `id_user` = '$user[id]'"),0)!=0){
$invite = mysql_fetch_array(mysql_query("SELECT * FROM `collective_invite` WHERE `id_user` = '$user[id]'"));
$cti = mysql_fetch_array(mysql_query("SELECT * FROM `collective` WHERE `id` = '$invite[id_collective]'"));
$who = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$invite[id_who]'"));
$whos = mysql_fetch_array(mysql_query("SELECT * FROM `collective_user` WHERE `id` = '$tanks_code[id]'"));
$cti['users'] = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `collective_user` WHERE `id_collective` = '$cti[id]'"),0);
$cti['users_max']=($cti['soil']*3) + 10;
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `collective_user` WHERE `id_user` = '".$tanks_code['id_u']."'"), 0)==0){
if(isset($_GET['invite_collective']) && $_GET['invite_collective']=='yes'){
if ($cti['users']<$cti['users_max']){
mysql_query("UPDATE `tanks` SET `clan` = '1' WHERE `id` = '$user[id]'");
mysql_query("DELETE FROM `collective_invite` WHERE `id` = '$invite[id]'");
mysql_query("INSERT INTO `collective_user` SET `id_user` = '$user[id]', `id_collective` = '$cti[id]', `time` = '$time', `status` = '7'");
mysql_query("INSERT INTO `collective_journal` (`zadan`,`id_collective`) VALUES ('В клан вступил(а) ".$us_code['nick']."','".$cti['id']."')");
header("Location:/myclan");}else{
err_game('В клане уже нет мест нажмите "Отказатся"');}
}
elseif(isset($_GET['invite_collective']) && $_GET['invite_collective']=='no'){
mysql_query("DELETE FROM `collective_invite` WHERE `id` = '$invite[id]'");
header("Location:/");
}
echo '<div class="trnt-block mb6">
<div class="wrap1">
<div class="wrap2">
<div class="wrap3">
<div class="wrap4">
<div class="wrap5">
<div class="wrap6">
<div class="wrap7">
<div class="wrap8">
<div class="wrap-content-mini">
<div class="mt5 mb5 green1 small cntr">';
echo " <a href='profile?id=$who[id]'>".$who['nick']."</a> приглашает Вас в свой клан <a href='?clan=$cti[id]'>".$cti['name']."</a>";
echo'<div class="bot">
<table>
<tbody>
<tr>
<td class="w50 pr1">
<a class="simple-but border" href="?invite_collective=yes">
<span>
<span>Принять</span>
</span>
</a>
</td>
<td class="w50 pl1">
<a class="simple-but border" href="?invite_collective=no">
<span>
<span>Отказаться</span>
</span>
</a>
</td>
</tr>
</tbody>
</table>
</div>';
echo'</div></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>';
}
}
if(mysql_result(mysql_query("SELECT COUNT(`id`) FROM `collective_user` WHERE `id_user` = '$user[id]'"),0)!=0){
$mcu = mysql_fetch_array(mysql_query("SELECT * FROM `collective_user` WHERE `id_user` = '$user[id]'"));
$mc = mysql_fetch_array(mysql_query("SELECT * FROM `collective` WHERE `id` = '$mcu[id_collective]'"));
$mc['users_max'] = ($mc['soil']*3) + 10;
$mc['users'] = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `collective_user` WHERE `id_collective` = '$mc[id]'"),0);
$mc['next_level'] = $mc['level'] + 1;
$ss['fues'] = ($mc['irrigate']*15) + 300;
mysql_query("UPDATE `tanks` SET `fuels` = '".$ss['fues']."' WHERE `id_u` = '$user[id]'");;
}
/*if($tanks_code['status']!=2){header("Location: /path");}*/
$ss['fues'] = ($mc['irrigate']*15) + 300;
if ($tanks_code['skidka_prem']<=time() && $tanks_code['skidka_prem']!=0){
mysql_query("UPDATE `tanks` SET `skidka_prem` = '0' WHERE `id_u` = '$user[id]'");
}
if ($tanks_code['skidka']<=time() && $tanks_code['skidka']!=0){
mysql_query("UPDATE `tanks` SET `skidka` = '0' WHERE `id_u` = '$user[id]'");
}
if ($tanks_code['prem']<=time() && $tanks_code['prem']!=0){
mysql_query("UPDATE `tanks` SET `prem` = '0' WHERE `id_u` = '$user[id]'");
}
if ($tanks_code['bans']<=time() && $tanks_code['bans']!=0 && $tanks_code['bans']!=1){
mysql_query("UPDATE `tanks` SET `bans` = '0' WHERE `id_u` = '$user[id]'");
}
if ($tanks_code['forum_time']<=time() && $tanks_code['forum_time']!=0){
mysql_query("UPDATE `tanks` SET `forum_time` = '0' WHERE `id_u` = '$user[id]'");
}
if ($tanks_code['chaty_time']<=time() && $tanks_code['chaty_time']!=0){
mysql_query("UPDATE `tanks` SET `chaty_time` = '0' WHERE `id_u` = '$user[id]'");
}
if ($tanks_code['pocht_time']<=time() && $tanks_code['pocht_time']!=0){
mysql_query("UPDATE `tanks` SET `pocht_time` = '0' WHERE `id_u` = '$user[id]'");
}
if ($tanks_code['forum_times']<=time() && $tanks_code['forum_times']!=0){
mysql_query("UPDATE `tanks` SET `forum_times` = '0' WHERE `id_u` = '$user[id]'");
}
mysql_query("UPDATE `tanks` SET `ip` = '".$_SERVER['REMOTE_ADDR']."' WHERE `id` = '$user[id]' LIMIT 1");
if ($tanks_code['level']>=1){
include_once '../sys/inc/level.php';
include_once 'sys/inc/level.php';
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `tanks_angar` WHERE `user` = '".$tanks_code['id']."'"), 0)==0){
if($_SERVER['PHP_SELF']!='/tanks/obuch.php'){
header("Location: /obuch");
}
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `tanks_angar` WHERE `user` = '".$tanks_code['id']."'"), 0)!=0){
if($tanks_code['tank']==0 && $_SERVER['PHP_SELF']!='/tanks/tanki.php'){
header("Location: /tanki");
}
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `tanks_angar` WHERE `user` = '".$tanks_code['id']."'"), 0)!=0){
if ($tanks_code['news']==0 && $_SERVER['PHP_SELF']!='/tanks/news.php'){
$q=mysql_query("SELECT * FROM `tanks_news` ORDER BY id DESC LIMIT 3");
err_sms('<a href="/news"><center><img src="/images/icons/exp.png"><img src="/images/icons/exp.png"><img src="/images/icons/exp.png"> Свежие новости <img src="/images/icons/exp.png"><img src="/images/icons/exp.png"><img src="/images/icons/exp.png"></center></a>');
}
}
if ($tanks_code['bans']>=time()){
$times=time();
$keys=time_left($tanks_code['bans']-$times);
err_game('<center>У вас бан на '.$keys.'<br>причина: '.$tanks_code['prich_ban'].'</center>');
}
if ($tanks_code['prem']>=time()){
$time=time();
$keyss=time_left($tanks_code['prem']-$time);
err_sms('<center>Премиум на '.$keyss.'</center>');}
if ($user['ank_mail']==NULL){
err_sms('Пожалуйста заполните свой E-mail в настройках');
}
if ($tanks_code['bans']==1 && $_SERVER['PHP_SELF']!='/tanks/index.php'){
header("Location: /");}
elseif($tanks_code['bans']==1 && $_SERVER['PHP_SELF']=='/tanks/index.php') {
include_once 'ban_nav.php';
echo'<div class="trnt-block p5 white bold" style="margin-bottom:3px;">Вы в бане навсегда, причина:<br><font color="red">'.$tanks_code['prich_ban'].'</font></div>';
include_once 'foots.php';
exit;
}
$avatr = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_ava` WHERE `id`='".$tanks_code['ava']."'"));
echo'<div class="trnt-block " style="padding:3px;margin-top: 3px;border-radius:1px;margin-bottom: 0px;">';
if($_SESSION['style']!='wap.css'){
echo' <div class="mb0 inbl"><div class="thumb fl"><img src="/images/avatar/'.$avatr['screen'].'" alt="" title=""><span class="mask2"> </span></div><div class="ml58 medium white sh_b bold">';
}
echo'<table class="white medium cntr bold"><tr>';
if($_SERVER['PHP_SELF']=='/tanks/wartour.php' || $_SERVER['PHP_SELF']=='/tanks/warclan.php'){
echo'
<td style="width:120px;" class="block_m"><div сlass="white small"><img src="/tanks/images/icons/gold.png"> '.$tanks_code['zolota'].'</div></td>
<td style="width:120px;" class="block_m"><div сlass="white small"><img title="Серебро" alt="Серебро" src="/tanks/images/icons/silver.png"> '.rating($tanks_code['serebro']).'</div>
</td></tr></table>';
}else{
echo'<td style="width:70px;" class="block_m"><div сlass="white small bold"><img src="/tanks/images/fuel.png"> '.$tanks_code['fuel'].'</div></td>
<td style="width:90px;" class="block_m"><div сlass="white small"><img src="/tanks/images/icons/gold.png"> '.$tanks_code['zolota'].'</div></td>
<td style="width:80px;" class="block_m"><div сlass="white small"><img title="Серебро" alt="Серебро" src="/tanks/images/icons/silver.png"> '.rating($tanks_code['serebro']).'</div>
</td></tr></table>';
}
$max = $level['rating'];
$tek = $kr;
$forl = ($tek/$max)*100;
echo '<table style="width:98%;margin-left:0.8%;border-collapse:collapse;border-spacing:0;" class="rblock blue esmall"><tr><td><div class="value-block lh1" style="border-radius:8px;"><span><span><img height="12" width="12" src="/images/levels.png"/> '.$tanks_code["level"].'</span></span></div></td>
<td class="progr"><div class="scale-block">
<div class="expline" style="width:'.number_format($forl,10,'.','').'%;"></div></div></td>
<td><div class="value-block lh1" style="border-radius:8px;"><span><span><img height="14" width="14" src="/images/icons/exp.png"/> ';echo"".($tanks_code['level']<$bigl?"".rating($kr)." / ".rating($level['rating'])."":"".rating($tanks_code['rating'])."")."";
echo'</span></span></div></td></tr></table></div></div>';
echo '</div>';
$new_mes_sql = mysql_result(mysql_query('SELECT COUNT(`id`) FROM `kolhoz_mail` WHERE `id_user`="'.$user['id'].'" AND `read`="0"'), 0);
if($tanks_code['tank']>0){
echo'<table style="width:100%;margin-bottom:3px;border-collapse:collapse;border-spacing:0;"><tbody><tr><td style="width:30%;padding-right:4px;"><div style="position:relative;"><a class="simple-but border gray mb1" href="/">
<span><span>Ангар</span></span></a></div></td><td style="width:40%;padding:0 4px;"><div style="position:relative;">';
if($tanks_code['fuel']<15){echo'<a class="simple-but border mb1 red" href="/boyuser">';}else{echo'<a class="simple-but border mb1 green" href="/boyuser">';}
echo'<span><span>В бой!</span></span></a></div></td><td style="width:30%;padding-left:4px;"><div style="position:relative;">';
if($new_mes_sql>=1){echo'<span class="digit esmall"><span class="l"> </span><span class="m">'.$new_mes_sql.'</span><span class="r"> </span></span>';}
echo'<a class="simple-but gray border mb1" href="/mail"><span><span>Почта</span></span></a></div></td></tr></tbody></table>';}
if(isset($_SESSION['no_rubles'])){
no_rubles($_SESSION['no_rubles']);
unset($_SESSION['no_rubles']);
}
if(isset($_SESSION['no_zolota'])){
no_zolota($_SESSION['no_zolota']);
unset($_SESSION['no_zolota']);
}
if(isset($_SESSION['no_serebra'])){
no_serebra($_SESSION['no_serebra']);
unset($_SESSION['no_serebra']);
}
if ($tanks_code['win']>=250){
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `tanks_medal` WHERE `id_user` = '".$user['id']."' AND `name` = 'Медаль Абрамса (IV)'"), 0)==0){
mysql_query("INSERT INTO `tanks_medal` (`id_user`,`name`,`screen`,`tank`,`zadan`) VALUES ('$tanks_code[id]','Медаль Абрамса (IV)','MedalAbrams1.png','$tanks_code[tank]','уничтожение 250 танков')");
err_games('Вы награждены медалью Абрамса IV степени');
}
}
if ($tanks_code['win']>=500){
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `tanks_medal` WHERE `id_user` = '".$user['id']."' AND `name` = 'Медаль Абрамса (III)'"), 0)==0){
mysql_query("INSERT INTO `tanks_medal` (`id_user`,`name`,`screen`,`tank`,`zadan`) VALUES ('$tanks_code[id]','Медаль Абрамса (III)','MedalAbrams2.png','$tanks_code[tank]','уничтожение 500 танков')");
err_games('Вы награждены медалью Абрамса III степени');
}
}
if ($tanks_code['win']>=750){
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `tanks_medal` WHERE `id_user` = '".$user['id']."' AND `name` = 'Медаль Абрамса (II)'"), 0)==0){
mysql_query("INSERT INTO `tanks_medal` (`id_user`,`name`,`screen`,`tank`,`zadan`) VALUES ('$tanks_code[id]','Медаль Абрамса (II)','MedalAbrams3.png','$tanks_code[tank]','уничтожение 750 танков')");
err_games('Вы награждены медалью Абрамса II степени');
}}
if ($tanks_code['win']>=1000){
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `tanks_medal` WHERE `id_user` = '".$user['id']."' AND `name` = 'Медаль Абрамса (I)'"), 0)==0){
mysql_query("INSERT INTO `tanks_medal` (`id_user`,`name`,`screen`,`tank`,`zadan`) VALUES ('$tanks_code[id]','Медаль Абрамса (I)','MedalAbrams4.png','$tanks_code[tank]','уничтожение 1000 танков')");
err_games('Вы награждены медалью Абрамса I степени');
}}
/*Лавриненко*/
$stats_pobs=$tanks_code['win']+$tanks_code['lose']+$tanks_code['nich'];
if ($stats_pobs>=1000){
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `tanks_medal` WHERE `id_user` = '".$user['id']."' AND `name` = 'Медаль Лавриненко (IV)'"), 0)==0){
mysql_query("UPDATE `tanks` SET `zolota`=`zolota`+'50' WHERE `id`='".$user['id']."'");
mysql_query("INSERT INTO `tanks_medal` (`id_user`,`name`,`screen`,`tank`,`zadan`) VALUES ('$tanks_code[id]','Медаль Лавриненко (IV)','medlavr1.png','$tanks_code[tank]','1000 боёв')");
err_games('Вы награждены медалью Лавриненко IV степени и 50 золотыми');
}
}
if ($stats_pobs>=2500){
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `tanks_medal` WHERE `id_user` = '".$user['id']."' AND `name` = 'Медаль Лавриненко (III)'"), 0)==0){
mysql_query("UPDATE `tanks` SET `zolota`=`zolota`+'100' WHERE `id`='".$user['id']."'");
mysql_query("INSERT INTO `tanks_medal` (`id_user`,`name`,`screen`,`tank`,`zadan`) VALUES ('$tanks_code[id]','Медаль Лавриненко (III)','medlavr2.png','$tanks_code[tank]','2500 боёв')");
err_games('Вы награждены медалью Лавриненко III степени и 100 золотыми');
}
}
if ($stats_pobs>=5000){
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `tanks_medal` WHERE `id_user` = '".$user['id']."' AND `name` = 'Медаль Лавриненко (II)'"), 0)==0){
mysql_query("UPDATE `tanks` SET `zolota`=`zolota`+'250' WHERE `id`='".$user['id']."'");
mysql_query("INSERT INTO `tanks_medal` (`id_user`,`name`,`screen`,`tank`,`zadan`) VALUES ('$tanks_code[id]','Медаль Лавриненко (II)','medlavr3.png','$tanks_code[tank]','5000 боёв')");
err_games('Вы награждены медалью Лавриненко II степени и 250 золотыми');
}}
if ($stats_pobs>=10000){
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `tanks_medal` WHERE `id_user` = '".$user['id']."' AND `name` = 'Медаль Лавриненко (I)'"), 0)==0){
mysql_query("UPDATE `tanks` SET `zolota`=`zolota`+'500' WHERE `id`='".$user['id']."'");
mysql_query("INSERT INTO `tanks_medal` (`id_user`,`name`,`screen`,`tank`,`zadan`) VALUES ('$tanks_code[id]','Медаль Лавриненко (I)','medlavr4.png','$tanks_code[tank]','10000 боёв')");
err_games('Вы награждены медалью Лавриненко I степени и 500 золотыми');
}}
if ($tanks_code['skidka']>=time() && ($_SERVER['PHP_SELF']=='/tanks/store.php' || $_SERVER['PHP_SELF']=='/tanks/ame.php' || $_SERVER['PHP_SELF']=='/tanks/fra.php' || $_SERVER['PHP_SELF']=='/tanks/ssr.php')){
$keysr=time_left($tanks_code['skidka']-time());
err_sms('<center>У вас скидка 50% на '.$keysr.'</center>');}
if ($tanks_code['skidka_prem']>=time() && $_SERVER['PHP_SELF']=='/tanks/premtank.php'){
$keysrs=time_left($tanks_code['skidka_prem']-time());
err_sms('<center>У вас скидка 15% на '.$keysrs.'</center>');}
?>