Файл: tankon.mobi/sys/inc/fnc.php
Строк: 1088
<?
// псевдонимы функций
function my_esc($str){return mysql_real_escape_string($str);}
// для php 4 (альтернатива file_put_contents)
if (!function_exists('file_put_contents')){
function file_put_contents($file,$data){
$f=@fopen($file, 'w');
return @fwrite($f, $data);
@fclose($f);}}
$time=time();
function atack($id){
$ank_atack=mysql_fetch_assoc(mysql_query("SELECT * FROM `tanks` WHERE `id` = '".$id."'"));
$ank_tanks_atack=mysql_fetch_assoc(mysql_query("SELECT * FROM `tanks_magazin` WHERE `id` = '".$ank_atack['tank']."'"));
$ank_mcu = mysql_fetch_array(mysql_query("SELECT * FROM `collective_user` WHERE `id_user` = '".$ank_atack['id']."'"));
$ank_mc = mysql_fetch_array(mysql_query("SELECT * FROM `collective` WHERE `id` = '".$ank_mcu['id_collective']."'"));
if($ank_mc['scholl_level']>=time()){
$s1=round($ank_atack['e1']+$ank_mc['scholl']);
}else{
$s1=round($ank_atack['e1']);
}
if($ank_tanks_atack['level']==1){$tanks_mosh=round($s1*0.1);$vet_mc=$ank_mc['vet']*1;}
elseif($ank_tanks_atack['level']==2){$tanks_mosh=round($s1*0.2);$vet_mc=$ank_mc['vet']*1;}
elseif($ank_tanks_atack['level']==3){$tanks_mosh=round($s1*0.3);$vet_mc=$ank_mc['vet']*1;}
elseif($ank_tanks_atack['level']==4){$tanks_mosh=round($s1*0.4);$vet_mc=$ank_mc['vet']*2;}
elseif($ank_tanks_atack['level']==5){$tanks_mosh=round($s1*0.5);$vet_mc=$ank_mc['vet']*2;}
elseif($ank_tanks_atack['level']==6){$tanks_mosh=round($s1*0.6);$vet_mc=$ank_mc['vet']*2;}
elseif($ank_tanks_atack['level']==7){$tanks_mosh=round($s1*0.7);$vet_mc=$ank_mc['vet']*4;}
elseif($ank_tanks_atack['level']==8){$tanks_mosh=round($s1*0.8);$vet_mc=$ank_mc['vet']*4;}
elseif($ank_tanks_atack['level']==9){$tanks_mosh=round($s1*0.9);$vet_mc=$ank_mc['vet']*5;}
elseif($ank_tanks_atack['level']==10){$tanks_mosh=round($s1*1.0);$vet_mc=$ank_mc['vet']*5;}
elseif($ank_tanks_atack['level']==11){$tanks_mosh=round($s1*1.1);$vet_mc=$ank_mc['vet']*7;}
elseif($ank_tanks_atack['level']==12){$tanks_mosh=round($s1*1.2);$vet_mc=$ank_mc['vet']*7;}
$ank_user_uid1 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '1' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid2 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '2' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid3 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '3' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid4 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '4' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid5 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '5' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid6 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '6' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid7 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '7' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid8 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '8' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid9 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '9' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid10 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '10' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$vsemoduli=$ank_user_uid1['ataka']+$ank_user_uid2['ataka']+$ank_user_uid3['ataka']+$ank_user_uid4['ataka']+$ank_user_uid5['ataka']+$ank_user_uid6['ataka']+$ank_user_uid7['ataka']+$ank_user_uid8['ataka']+$ank_user_uid9['ataka']+$ank_user_uid10['ataka'];
if($ank_mc['vet_level']>=time()){
$atackanew=$ank_tanks_atack['ataka']+$tanks_mosh+$vsemoduli+$vet_mc;
}else{
$atackanew=$ank_tanks_atack['ataka']+$tanks_mosh+$vsemoduli;
}
return $atackanew;
}
function bron($id){
$ank_atack=mysql_fetch_assoc(mysql_query("SELECT * FROM `tanks` WHERE `id` = '".$id."'"));
$ank_tanks_atack=mysql_fetch_assoc(mysql_query("SELECT * FROM `tanks_magazin` WHERE `id` = '".$ank_atack['tank']."'"));
if(mysql_result(mysql_query("SELECT COUNT(`id`) FROM `collective_user` WHERE `id_user` = '".$ank_atack['id']."'"),0)!=0){
$ank_mcu = mysql_fetch_array(mysql_query("SELECT * FROM `collective_user` WHERE `id_user` = '".$ank_atack['id']."'"));
$ank_mc = mysql_fetch_array(mysql_query("SELECT * FROM `collective` WHERE `id` = '".$ank_mcu['id_collective']."'"));
}
if($ank_mc['scholl_level']>=time()){
$s1=round($ank_atack['e2']+$ank_mc['scholl']);
}else{
$s1=round($ank_atack['e2']);
}
if($ank_tanks_atack['level']==1){$tanks_mosh=round($s1*0.1);$vet_mc=$ank_mc['vet']*1;}
elseif($ank_tanks_atack['level']==2){$tanks_mosh=round($s1*0.2);$vet_mc=$ank_mc['vet']*1;}
elseif($ank_tanks_atack['level']==3){$tanks_mosh=round($s1*0.3);$vet_mc=$ank_mc['vet']*1;}
elseif($ank_tanks_atack['level']==4){$tanks_mosh=round($s1*0.4);$vet_mc=$ank_mc['vet']*2;}
elseif($ank_tanks_atack['level']==5){$tanks_mosh=round($s1*0.5);$vet_mc=$ank_mc['vet']*2;}
elseif($ank_tanks_atack['level']==6){$tanks_mosh=round($s1*0.6);$vet_mc=$ank_mc['vet']*2;}
elseif($ank_tanks_atack['level']==7){$tanks_mosh=round($s1*0.7);$vet_mc=$ank_mc['vet']*4;}
elseif($ank_tanks_atack['level']==8){$tanks_mosh=round($s1*0.8);$vet_mc=$ank_mc['vet']*4;}
elseif($ank_tanks_atack['level']==9){$tanks_mosh=round($s1*0.9);$vet_mc=$ank_mc['vet']*5;}
elseif($ank_tanks_atack['level']==10){$tanks_mosh=round($s1*1.0);$vet_mc=$ank_mc['vet']*5;}
elseif($ank_tanks_atack['level']==11){$tanks_mosh=round($s1*1.1);$vet_mc=$ank_mc['vet']*7;}
elseif($ank_tanks_atack['level']==12){$tanks_mosh=round($s1*1.2);$vet_mc=$ank_mc['vet']*7;}
$ank_user_uid1 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '1' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid2 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '2' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid3 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '3' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid4 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '4' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid5 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '5' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid6 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '6' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid7 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '7' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid8 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '8' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid9 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '9' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid10 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '10' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$vsemoduli=$ank_user_uid1['bron']+$ank_user_uid2['bron']+$ank_user_uid3['bron']+$ank_user_uid4['bron']+$ank_user_uid5['bron']+$ank_user_uid6['bron']+$ank_user_uid7['bron']+$ank_user_uid8['bron']+$ank_user_uid9['bron']+$ank_user_uid10['bron'];
if($ank_mc['vet_level']>=time()){
$atackanew=$ank_tanks_atack['bron']+$tanks_mosh+$vsemoduli+$vet_mc;
}else{
$atackanew=$ank_tanks_atack['bron']+$tanks_mosh+$vsemoduli;
}
/*
$bron=$tanks_code['bron']+$s2+($mc['vet']*10);
$toch=$tanks_code['toch']+$s3+($mc['vet']*10);
$proch=$tanks_code['proch']+$s4+($mc['vet']*10);
*/
return $atackanew;
}
function toch($id){
$ank_atack=mysql_fetch_assoc(mysql_query("SELECT * FROM `tanks` WHERE `id` = '".$id."'"));
$ank_tanks_atack=mysql_fetch_assoc(mysql_query("SELECT * FROM `tanks_magazin` WHERE `id` = '".$ank_atack['tank']."'"));
$ank_mcu = mysql_fetch_array(mysql_query("SELECT * FROM `collective_user` WHERE `id_user` = '".$ank_atack['id']."'"));
$ank_mc = mysql_fetch_array(mysql_query("SELECT * FROM `collective` WHERE `id` = '".$ank_mcu['id_collective']."'"));
if($ank_mc['scholl_level']>=time()){
$s1=round($ank_atack['e3']+$ank_mc['scholl']);
}else{
$s1=round($ank_atack['e3']);
}
if($ank_tanks_atack['level']==1){$tanks_mosh=round($s1*0.1);$vet_mc=$ank_mc['vet']*1;}
elseif($ank_tanks_atack['level']==2){$tanks_mosh=round($s1*0.2);$vet_mc=$ank_mc['vet']*1;}
elseif($ank_tanks_atack['level']==3){$tanks_mosh=round($s1*0.3);$vet_mc=$ank_mc['vet']*1;}
elseif($ank_tanks_atack['level']==4){$tanks_mosh=round($s1*0.4);$vet_mc=$ank_mc['vet']*2;}
elseif($ank_tanks_atack['level']==5){$tanks_mosh=round($s1*0.5);$vet_mc=$ank_mc['vet']*2;}
elseif($ank_tanks_atack['level']==6){$tanks_mosh=round($s1*0.6);$vet_mc=$ank_mc['vet']*2;}
elseif($ank_tanks_atack['level']==7){$tanks_mosh=round($s1*0.7);$vet_mc=$ank_mc['vet']*4;}
elseif($ank_tanks_atack['level']==8){$tanks_mosh=round($s1*0.8);$vet_mc=$ank_mc['vet']*4;}
elseif($ank_tanks_atack['level']==9){$tanks_mosh=round($s1*0.9);$vet_mc=$ank_mc['vet']*5;}
elseif($ank_tanks_atack['level']==10){$tanks_mosh=round($s1*1.0);$vet_mc=$ank_mc['vet']*5;}
elseif($ank_tanks_atack['level']==11){$tanks_mosh=round($s1*1.1);$vet_mc=$ank_mc['vet']*7;}
elseif($ank_tanks_atack['level']==12){$tanks_mosh=round($s1*1.2);$vet_mc=$ank_mc['vet']*7;}
$ank_user_uid1 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '1' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid2 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '2' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid3 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '3' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid4 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '4' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid5 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '5' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid6 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '6' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid7 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '7' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid8 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '8' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid9 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '9' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid10 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '10' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$vsemoduli=$ank_user_uid1['toch']+$ank_user_uid2['toch']+$ank_user_uid3['toch']+$ank_user_uid4['toch']+$ank_user_uid5['toch']+$ank_user_uid6['toch']+$ank_user_uid7['toch']+$ank_user_uid8['toch']+$ank_user_uid9['toch']+$ank_user_uid10['toch'];
if($ank_mc['vet_level']>=time()){
$atackanew=$ank_tanks_atack['toch']+$tanks_mosh+$vsemoduli+$vet_mc;
}else{
$atackanew=$ank_tanks_atack['toch']+$tanks_mosh+$vsemoduli;
}
return $atackanew;
}
function proch($id){
$ank_atack=mysql_fetch_assoc(mysql_query("SELECT * FROM `tanks` WHERE `id` = '".$id."'"));
$ank_tanks_atack=mysql_fetch_assoc(mysql_query("SELECT * FROM `tanks_magazin` WHERE `id` = '".$ank_atack['tank']."'"));
$ank_mcu = mysql_fetch_array(mysql_query("SELECT * FROM `collective_user` WHERE `id_user` = '".$ank_atack['id']."'"));
$ank_mc = mysql_fetch_array(mysql_query("SELECT * FROM `collective` WHERE `id` = '".$ank_mcu['id_collective']."'"));
if($ank_mc['scholl_level']>=time()){
$s1=round($ank_atack['e4']+$ank_mc['scholl']);
}else{
$s1=round($ank_atack['e4']);
}
if($ank_tanks_atack['level']==1){$tanks_mosh=round($s1*0.1);$vet_mc=$ank_mc['vet']*1;}
elseif($ank_tanks_atack['level']==2){$tanks_mosh=round($s1*0.2);$vet_mc=$ank_mc['vet']*1;}
elseif($ank_tanks_atack['level']==3){$tanks_mosh=round($s1*0.3);$vet_mc=$ank_mc['vet']*1;}
elseif($ank_tanks_atack['level']==4){$tanks_mosh=round($s1*0.4);$vet_mc=$ank_mc['vet']*2;}
elseif($ank_tanks_atack['level']==5){$tanks_mosh=round($s1*0.5);$vet_mc=$ank_mc['vet']*2;}
elseif($ank_tanks_atack['level']==6){$tanks_mosh=round($s1*0.6);$vet_mc=$ank_mc['vet']*2;}
elseif($ank_tanks_atack['level']==7){$tanks_mosh=round($s1*0.7);$vet_mc=$ank_mc['vet']*4;}
elseif($ank_tanks_atack['level']==8){$tanks_mosh=round($s1*0.8);$vet_mc=$ank_mc['vet']*4;}
elseif($ank_tanks_atack['level']==9){$tanks_mosh=round($s1*0.9);$vet_mc=$ank_mc['vet']*5;}
elseif($ank_tanks_atack['level']==10){$tanks_mosh=round($s1*1.0);$vet_mc=$ank_mc['vet']*5;}
elseif($ank_tanks_atack['level']==11){$tanks_mosh=round($s1*1.1);$vet_mc=$ank_mc['vet']*7;}
elseif($ank_tanks_atack['level']==12){$tanks_mosh=round($s1*1.2);$vet_mc=$ank_mc['vet']*7;}
$ank_user_uid1 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '1' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid2 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '2' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid3 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '3' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid4 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '4' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid5 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '5' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid6 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '6' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid7 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '7' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid8 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '8' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid9 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '9' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$ank_user_uid10 = mysql_fetch_array(mysql_query("SELECT * FROM `tanks_sclad` WHERE `uids` = '10' AND `user` = '".$ank_atack['id']."' AND `tank` = '".$ank_atack['tank']."'"));
$vsemoduli=$ank_user_uid1['proch']+$ank_user_uid2['proch']+$ank_user_uid3['proch']+$ank_user_uid4['proch']+$ank_user_uid5['proch']+$ank_user_uid6['proch']+$ank_user_uid7['proch']+$ank_user_uid8['proch']+$ank_user_uid9['proch']+$ank_user_uid10['proch'];
if($ank_mc['vet_level']>=time()){
$atackanew=$ank_tanks_atack['proch']+$tanks_mosh+$vsemoduli+$vet_mc;
}else{
$atackanew=$ank_tanks_atack['proch']+$tanks_mosh+$vsemoduli;
}
return $atackanew;
}
function ansc($id) {
$ansc=mysql_fetch_assoc(mysql_query("SELECT * FROM `tanks` WHERE `id` = '".$id."'"));
$rres=mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = '".$ansc['id']."'"));
$mcu_ansc = mysql_fetch_array(mysql_query("SELECT * FROM `collective_user` WHERE `id_user` = '".$rres['id']."'"));
$mc_ansc = mysql_fetch_array(mysql_query("SELECT * FROM `collective` WHERE `id` = '".$mcu_ansc['id_collective']."'"));
echo'<a href="/profile?id='.$ansc['id'].'">';
if($ansc['status']==1){echo'<font color="#00CDCD">';}
elseif($ansc['status']==2){echo'<font color="green">';}
elseif($ansc['status']==0){echo'<font color="#BEBEBE">';}
echo'<b>'.$rres['nick'].'</b></a></font>'.online($rres['id']).' ';
if($ansc['clan']!=0){
echo'<a href="/clans?id='.$mc_ansc['id'].'"><font color="#4682B4">['.$mc_ansc['name'].']</font></a> ';
}
}
if($_SESSION['style']=='wap.css'){
function anscs($id) {
$ansc=mysql_fetch_assoc(mysql_query("SELECT * FROM `tanks` WHERE `id` = '".$id."'"));
$rres=mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = '".$ansc['id']."'"));
$mcu_ansc = mysql_fetch_array(mysql_query("SELECT * FROM `collective_user` WHERE `id_user` = '".$rres['id']."'"));
$mc_ansc = mysql_fetch_array(mysql_query("SELECT * FROM `collective` WHERE `id` = '".$mcu_ansc['id_collective']."'"));
if($mcu_ansc['status']==1){$mcu_ansc['status_name']='Ком.';}
elseif($mcu_ansc['status']==2){$mcu_ansc['status_name']='Зам. ком.';}
elseif($mcu_ansc['status']==3){$mcu_ansc['status_name']='Вер.';}
elseif($mcu_ansc['status']==4){$mcu_ansc['status_name']=($rres['pol']==1?'Сол.':'Мед.');}
else{$mcu_ansc['status_name']='Нов.';}
echo'<span class="small bold">';
echo'<a href="/profile?id='.$ansc['id'].'">';
if($ansc['status']==1){echo'<font color="#00CDCD">';}
elseif($ansc['status']==2){echo'<font color="green">';}
elseif($ansc['status']==0){echo'<font color="#BEBEBE">';}
echo'<b>'.$rres['nick'].'</b></a></font>'.online($rres['id']).'';
echo' <font color="#4682B4">['.$mcu_ansc['status_name'].']</font></span>';
}
}
else{
function anscs($id) {
$ansc=mysql_fetch_assoc(mysql_query("SELECT * FROM `tanks` WHERE `id` = '".$id."'"));
$rres=mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = '".$ansc['id']."'"));
$mcu_ansc = mysql_fetch_array(mysql_query("SELECT * FROM `collective_user` WHERE `id_user` = '".$rres['id']."'"));
$mc_ansc = mysql_fetch_array(mysql_query("SELECT * FROM `collective` WHERE `id` = '".$mcu_ansc['id_collective']."'"));
if($mcu_ansc['status']==1){$mcu_ansc['status_name']='Командир';}
elseif($mcu_ansc['status']==2){$mcu_ansc['status_name']='Зам. ком.';}
elseif($mcu_ansc['status']==3){$mcu_ansc['status_name']='Вербовщик';}
elseif($mcu_ansc['status']==4){$mcu_ansc['status_name']=($rres['pol']==1?'Солдат':'Медсестра');}
else{$mcu_ansc['status_name']='Новобранец';}
echo'<span class="medium bold">';
echo'<a href="/profile?id='.$ansc['id'].'">';
if($ansc['status']==1){echo'<font color="#00CDCD">';}
elseif($ansc['status']==2){echo'<font color="green">';}
elseif($ansc['status']==0){echo'<font color="#BEBEBE">';}
echo'<b>'.$rres['nick'].'</b></a></font>'.online($rres['id']).'';
echo' <font color="#4682B4">['.$mcu_ansc['status_name'].']</font></span>';
}
}
// Время считает
function time_left($tl){
$d=3600*24;
$day=floor($tl/$d);
$tl=$tl-($d*$day);
$hour=floor($tl/3600);
$tl=$tl-(3600*$hour);
$minute=floor($tl/60);
$tl=$tl-(60*$minute);
$second=floor($tl);
$dayt="".($day>0?"$day д. ":null)."";
$hourt="".($hour>0?"$hour ч. ":null)."";
$minutet="".($minute>0?"$minute м. ":null)."";
$secondt="".($second>0?"$second с. ":null)."";
if($day>0){
$minutet=NULL;
$secondt=NULL;
}
if($hour>0 && $day==0){
$secondt=NULL;
$dayt=NULL;
}
return "$dayt$hourt$minutet$secondt";
}
function normal_number($num){
return number_format($num,0,'','');
}
function rating($rating_qq){
$rating = normal_number($rating_qq);
$e=floor($rating/1000000000000000000);
$p=floor($rating/1000000000000000);
$t=floor($rating/1000000000000);
$g=floor($rating/1000000000);
$m=floor($rating/1000000);
$k=floor($rating/1000);
if($e!=0){
$e=$rating/1000000000000000000;
$rating=round($e,2);
$rating = $rating.'e';
}
elseif($p!=0){
$p=$rating/1000000000000000;
$rating=round($p,2);
$rating = $rating.'p';
}
elseif($t!=0){
$t=$rating/1000000000000;
$rating=round($t,2);
$rating = $rating.'t';
}
elseif($g!=0){
$g=$rating/1000000000;
$rating=round($g,2);
$rating = $rating.'g';
}
elseif($m!=0){
$m=$rating/1000000;
$rating=round($m,2);
$rating = $rating.'m';
}
elseif($k!=0){
$k=$rating/1000;
$rating=round($k,2);
$rating = $rating.'k';
}
else $rating=(int)$rating;
return $rating;
}
function mysql_querll($sql){
global $log_sql;
$_SESSION['sql_number']++;
$tim = microtime(true);
$rez = mysql_query($sql);
$time_sql = microtime(true) - $tim;
$_SESSION['sql_time'] += $time_sql;
if($_SESSION['id_user'] == $log_sql){array_push($_SESSION['sql_log'],((round($time_sql, 3)*1000).' ms - '.$sql));}
return $rez;
}
function no_rubles($rubles){
err_game('У Вас не хватает <img src="/images/rubles.png"> '.floor($rubles).' руб.');
}
function no_zolota($zolota){
err_game('У Вас не хватает <img src="/tanks/images/icons/gold.png"> '.floor($zolota).' золота');
}
function no_serebra($serebra){
err_game('У Вас не хватает <img src="/tanks/images/icons/silver.png"> '.floor($serebra).' серебра');
}
// бан по IP
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ban_ip` WHERE `min` <= '$iplong' AND `max` >= '$iplong'"), 0)!=0){
if (!isset($ban_ip_page)){header("Location: /ban_ip.php");exit;}}
if (isset($ip2['cl']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `ban_ip` WHERE `min` <= '".ip2long($ip2['cl'])."' AND `max` >= '".ip2long($ip2['cl'])."'"), 0)!=0){
if (!isset($ban_ip_page)){header("Location: /ban_ip.php");exit;}}
if (isset($ip2['xff']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `ban_ip` WHERE `min` <= '".ip2long($ip2['xff'])."' AND `max` >= '".ip2long($ip2['xff'])."'"), 0)!=0){
if (!isset($ban_ip_page)){header("Location: /ban_ip.php");exit;}}
function err_game($msg)
{
echo '<div class="trnt-block medium cntr white bold p5" style="margin-left:1px;border-radius: 3px 3px 3px 3px;border:2px solid #B22222;margin-top: 3px;margin-bottom: 3px;">'.$msg.'</div>';
}
function err_games($msg)
{
echo '<div class="trnt-block white bold small p5" style="margin-left:1px;border-radius: 3px 3px 3px 3px;border:2px solid #B22222;margin-top: 3px;margin-bottom: 3px;">'.$msg.'</div>';
}
function err_sms($msg)
{
echo '<div class="trnt-block white bold bold p5" style="margin-left:1px;border-radius: 3px 3px 3px 3px;border:2px solid #228B22;margin-top: 3px;margin-bottom: 3px;">'.$msg.'</div>';
}
// антимат сделает автоматическое предупреждение, а затем бан
function antimat($str)
{
global $user,$time,$set;
if ($set['antimat'])
{
$antimat=&$_SESSION['antimat'];
include_once H.'sys/inc/censure.php';
$censure=censure($str);
if ($censure)
{
$antimat[$censure]=$time;
if (count($antimat)>3 && isset($user) && $user['level']) // если сделано больше 3-х предупреждений
{
$prich="Обнаружен мат: $censure";
$timeban=$time+60*60; // бан на час
mysql_query("INSERT INTO `ban` (`id_user`, `id_ban`, `prich`, `time`) VALUES ('$user[id]', '0', '$prich', '$timeban')");
admin_log('Пользователи','Бан',"Бан пользователя '[url=/amd_panel/ban.php?id=$user[id]]$user[nick][/url]' (id#$user[id]) до ".vremja($timeban)." по причине '$prich'");
header('Location: /ban.php?'.SID);exit;
}
return $censure;
}
else return false;
}
else return false;
}
// рекурсивное удаление папки
function delete_dir($dir){
if (is_dir($dir)){$od=opendir($dir);
while ($rd=readdir($od)){
if ($rd == '.' || $rd == '..') continue;
if (is_dir("$dir/$rd")){
@chmod("$dir/$rd", 0777);
delete_dir("$dir/$rd");}
else{
@chmod("$dir/$rd", 0777);
@unlink("$dir/$rd");}}
closedir($od);
@chmod("$dir", 0777);
return @rmdir("$dir");}
else{
@chmod("$dir", 0777);
@unlink("$dir");}}
// запись о переходах на сайт
if (isset($_SERVER['HTTP_REFERER']) && !eregi( str_replace('.','.',$_SERVER['HTTP_HOST']), $_SERVER['HTTP_REFERER']) && $ref=@parse_url($_SERVER['HTTP_REFERER'])){
if (isset($ref['host']))$_SESSION['http_referer']=$ref['host'];}
function br($msg,$br='<br />'){return eregi_replace("((<br( ?/?)>)|n|r)+",$br, $msg);} // переносы строк
function esc($text,$br=NULL){ // Вырезает все нечитаемые символы
if ($br!=NULL)
for ($i=0;$i<=31;$i++)$text=str_replace(chr($i), NULL, $text);
else{
for ($i=0;$i<10;$i++)$text=str_replace(chr($i), NULL, $text);
for ($i=11;$i<20;$i++)$text=str_replace(chr($i), NULL, $text);
for ($i=21;$i<=31;$i++)$text=str_replace(chr($i), NULL, $text);}
return $text;}
// получаем данные пользователя и уровень прав (+ кеширование)
function get_user($user_id=0)
{
if ($user_id==0)
{
// бот
$ank2['id']=0;
$ank2['nick']='[Система wotmobi]';
$ank2['level']=999;
$ank2['pol']=1;
$ank2['group_name']='Системный робот';
$ank2['ank_o_sebe']='Создан для уведомлений';
return $ank2;
}
else
{
static $users; // переменная не удаляется после вызова функции
$user_id=intval($user_id);
$users[0]=false;
if (!isset($users[$user_id])){
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '$user_id'"),0)==1)
{
$users[$user_id]=mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = '$user_id' LIMIT 1"));
$tmp_us=mysql_fetch_assoc(mysql_query("SELECT `level`,`name` AS `group_name` FROM `user_group` WHERE `id` = '".$users[$user_id]['group_access']."' LIMIT 1"));
if ($tmp_us['group_name']==null) {
$users[$user_id]['level']=0;
$users[$user_id]['group_name']='Пользователь';
}
else
{
$users[$user_id]['level']=$tmp_us['level'];
$users[$user_id]['group_name']=$tmp_us['group_name'];
}
}
else $users[$user_id]=false;
}
return $users[$user_id];
}
}
// определение оператора
function opsos($ips=NULL){
global $ip;
if ($ips==NULL)$ips=$ip;
$ipl=ip2long($ips);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `opsos` WHERE `min` <= '$ipl' AND `max` >= '$ipl'"), 0)!=0){
$opsos=mysql_fetch_assoc(mysql_query("SELECT opsos FROM `opsos` WHERE `min` <= '$ipl' AND `max` >= '$ipl' LIMIT 1"));
return stripcslashes(htmlspecialchars($opsos['opsos']));}
else return false;}
// вывод времени
function vremja($time=NULL)
{
global $user;
if ($time==NULL)$time=time();
if (isset($user))$time=$time+$user['set_timesdvig']*60*60;
$timep="".date("j M в H:i", $time)."";
$time_p[0]=date("j n Y", $time);
$time_p[1]=date("H:i", $time);
if ($time_p[0]==date("j n Y"))$timep=date("H:i:s", $time);
if (isset($user)){
if ($time_p[0]==date("j n Y", time()+$user['set_timesdvig']*60*60))$timep=date("H:i:s", $time);
if ($time_p[0]==date("j n Y", time()-60*60*(24-$user['set_timesdvig'])))$timep="Вчера в $time_p[1]";}
else{
if ($time_p[0]==date("j n Y"))$timep=date("H:i:s", $time);
if ($time_p[0]==date("j n Y", time()-60*60*24))$timep="Вчера в $time_p[1]";}
$timep=str_replace("Jan","Янв",$timep);
$timep=str_replace("Feb","Фев",$timep);
$timep=str_replace("Mar","Марта",$timep);
$timep=str_replace("May","Мая",$timep);
$timep=str_replace("Apr","Апр",$timep);
$timep=str_replace("Jun","Июня",$timep);
$timep=str_replace("Jul","Июля",$timep);
$timep=str_replace("Aug","Авг",$timep);
$timep=str_replace("Sep","Сент",$timep);
$timep=str_replace("Oct","Окт",$timep);
$timep=str_replace("Nov","Ноября",$timep);
$timep=str_replace("Dec","Дек",$timep);
return $timep;
}
// только для зарегистрированых
function only_reg($link = NULL) {
global $user;
if (!isset($user))
{
if ($link==NULL)$link='/';
header("Location: $link");exit;}}
// только для незарегистрированых
function only_unreg($link = NULL) {
global $user;
if (isset($user)){
if ($link==NULL)$link='/';
header("Location: $link");exit;}}
// только для тех, у кого уровень доступа больше или равен $level
// вывод ошибок
function err(){
global $err;
if (isset($err)){
if (is_array($err)){
foreach ($err as $key=>$value) {
echo "<div class='err'>$value</div>n";}}
else echo "<div class='err'>$err</div>n";}}
function msg($msg){echo "<div class='msg'>$msg</div>n";} // вывод сообщений
// отправка запланированных писем
$q=mysql_query("SELECT * FROM `mail_to_send` LIMIT 1");
if (mysql_num_rows($q)!=0){
$mail = mysql_fetch_assoc($q);
$adds="From: "admin@$_SERVER[HTTP_HOST]" <admin@$_SERVER[HTTP_HOST]>n";
$adds .= "Content-Type: text/html; charset=utf-8n";
mail($mail['mail'],'=?utf-8?B?'.base64_encode($mail['them']).'?=',$mail['msg'],$adds);
mysql_query("DELETE FROM `mail_to_send` WHERE `id` = '$mail[id]'");}
// сохранение настроек системы
function save_settings($set){
unset($set['web']);
if ($fopen=@fopen(H.'sys/dat/settings_6.2.dat', 'w')){
@fputs($fopen, serialize($set));
@fclose($fopen);
@chmod(H.'sys/dat/settings_6.2.dat', 0777);
return true;}
else
return false;}
// запись действий администрации
function admin_log($mod,$act,$opis){
global $user;
$q=mysql_query("SELECT * FROM `admin_log_mod` WHERE `name` = '".my_esc($mod)."' LIMIT 1");
if (mysql_num_rows($q)==0)
{
mysql_query("INSERT INTO `admin_log_mod` (`name`) VALUES ('".my_esc($mod)."')");
$id_mod=mysql_insert_id();
}
else $id_mod=mysql_result($q, 0);
$q2=mysql_query("SELECT * FROM `admin_log_act` WHERE `name` = '".my_esc($act)."' AND `id_mod` = '$id_mod' LIMIT 1");
if (mysql_num_rows($q2)==0)
{
mysql_query("INSERT INTO `admin_log_act` (`name`, `id_mod`) VALUES ('".my_esc($act)."', '$id_mod')");
$id_act=mysql_insert_id();
}
else $id_act=mysql_result($q2, 0);
mysql_query("INSERT INTO `admin_log` (`time`, `id_user`, `mod`, `act`, `opis`) VALUES
('".time()."','$user[id]', '$id_mod', '$id_act', '".my_esc($opis)."')");
}
// Загрузка остальных функций из папки "sys/fnc"
$opdirbase=opendir(H.'sys/fnc');
while ($filebase=readdir($opdirbase))
{
if (eregi('.php$',$filebase))
{
include_once(H.'sys/fnc/'.$filebase);
}
}
// запись о посещении
?>