session_start();
include "conf.php";
if (ereg("[<>\\/-]",$act) or ereg("[<>\\/-]",$log) or ereg("[<>\\/-]",$boy) or ereg("[<>\\/-]",$timeout) or ereg("[<>\\/-]",$enemy_count)
or ereg("[<>\\/-]",$friend_count) or ereg("[<>\\/-]",$battle_type) or ereg("[<>\\/-]",$wait) or ereg("[<>\\/-]",$friend_minlevel) or ereg("[<>\\/-]",$friend_maxlevel)
or ereg("[<>\\/-]",$enemy_minlevel) or ereg("[<>\\/-]",$enemy_maxlevel) or ereg("[<>]",$comment)) {print "Недопустимые символы!!!"; exit();}
$act=htmlspecialchars($act);
$log=htmlspecialchars($log);
$boy=htmlspecialchars($boy);
$timeout=htmlspecialchars($timeout);
$enemy_count=htmlspecialchars($enemy_count);
$friend_count=htmlspecialchars($friend_count);
$battle_type=htmlspecialchars($battle_type);
$wait=htmlspecialchars($wait);
$friend_minlevel=htmlspecialchars($friend_minlevel);
$friend_maxlevel=htmlspecialchars($friend_maxlevel);
$enemy_minlevel=htmlspecialchars($enemy_minlevel);
$enemy_maxlevel=htmlspecialchars($enemy_maxlevel);
$comment=htmlspecialchars($comment);
function showHPMPg($who){
$result = mysql_query("SELECT * FROM characters WHERE login='$who'");
mysql_query("SET CHARSET cp1251");
$db = mysql_fetch_array($result);
$level=$db["level"];
$hp[0]=$db["hp"];
$hp[1]=$db["hp_all"];
$mp[0]=$db["mp"];
$mp[1]=$db["mp_all"];
$orden_d = $db["orden"];
$clan_s = $db["clan_short"];
$clan_f = $db["clan"];
$travm = $db["travm"];
$rang = $db["rang"];
$pl = str_replace(" ","%20",$who);
$cure_hp=$db["cure_hp"];
$cure_mp=$db["cure_mp"];
$time_to_cure=$cure_hp-time();
$hhh=$db["hp_all"];
if($db["battle"]==0){
if($time_to_cure>0){
$percent_hp=floor((100*$time_to_cure)/1200);
$percent=100-$percent_hp;
$percent=$percent;
$hp[0]=floor(($hhh*$percent)/100);
$sss="UPDATE characters SET hp='$hp[0]' WHERE login='$login'";
$q=mysql_query($sss);
}
else{
$hp[0]=$db["hp_all"];
$SS = mysql_query("UPDATE characters SET hp='$hp[0]',cure_hp='0' WHERE login='$login'");
mysql_query("SET CHARSET cp1251");
$time_to_cure_f=0;
}
}
if($travm!=0){
$travm_i = "";
}
else{$travm_i="";}
if($orden_d==1){$orden_dis="Белое братство";}
else if($orden_d==2){$orden_dis="Темное братство";}
else if($orden_d==3){$orden_dis="Нейтральное братство";}
else if($orden_d==4){$orden_dis="Алхимик";}
else if($orden_d==5){$orden_dis="Тюремный заключеный";}
if(empty($clan_s)){$clan="";}
else{$clan="";}
if(empty($orden_d)){$orden="";}
else{
if ($orden_d==2) {$orden="";}
else{$orden="";}
if ($orden_d==1) {$orden="";} }
print "
$orden$clan$who [$level]$travm_i |
";?>
}
$data = mysql_connect($base_name, $base_user, $base_pass);
mysql_select_db($db_name,$data);
mysql_query("SET CHARSET cp1251");
$S = mysql_query("SELECT * FROM characters WHERE login='$login'");
$db = mysql_fetch_array($S);
$orden = $db["orden"];
$orden_d = $db["orden"];
$clan_s = $db["clan_short"];
$clan_f = $db["clan"];
$travm = $db["travm"];
$level = $db["level"];
$room = $db["room"];
$rang = $db["rang"];
if($travm!=0){
$travm_i = "";
}
else{$travm_i="";}
if($orden_d==1){$orden_dis="Белое братство";}
else if($orden_d==2){$orden_dis="Темное братство";}
else if($orden_d==3){$orden_dis="Нейтральное братсво";}
else if($orden_d==4){$orden_dis="Алхимик";}
else if($orden_d==5){$orden_dis="Тюремный заключеный";}
if(empty($clan_s)){$clan="";}
else{$clan="";}
if(empty($orden_d)){$orden="";}
else{
if ($orden_d==2) {$orden="";}
else{$orden="";}
if ($orden_d==1) {$orden="";}}
?>
АнтиБК+
$data = mysql_connect($base_name, $base_user, $base_pass);
mysql_select_db($db_name,$data);
mysql_query("SET CHARSET cp1251");
$sql = "SELECT * FROM characters WHERE login='$login'";
$result = mysql_query($sql);
$db = mysql_fetch_array($result);
if(empty($act)){$act="";}
if($act=="get" && !empty($in)){
if(empty($ip))
{
if (getenv('HTTP_X_FORWARDED_FOR'))
{
$ip=getenv('HTTP_X_FORWARDED_FOR');
}
else
{
$ip=getenv('REMOTE_ADDR');
}
}
$Q2=mysql_query("SELECT * FROM team1 WHERE battle_id='$in'");
$t1_a=0;
while($DATAS=mysql_fetch_array($Q2)){
$t1_a++;
}
$Q3=mysql_query("SELECT * FROM team2 WHERE battle_id='$in'");
$t2_a=0;
while($DATAS=mysql_fetch_array($Q3)){
$t2_a++;
}
if($db["hp_all"]/3 > $db["hp"]){
print "Вы слишком ослаблены для поединка! Восстановитесь!
";
print "назад";
die();
}
$Q_TEAM1=mysql_query("SELECT * FROM team1 WHERE player='$login'");
$Q_TEAM2=mysql_query("SELECT * FROM team2 WHERE player='$login'");
while($D1=mysql_fetch_array($Q_TEAM1)){
if($D1["player"]==$login){
print "Вы не можете принять этот вызов! Сначала отзовите свою заявку.
";
print "Вернуться";
die();
}
}
while($D2=mysql_fetch_array($Q_TEAM2)){
if($D2["player"]==$login){
print "Вы не можете принять этот вызов! Сначала отзовите свою заявку.
";
print "Вернуться";
die();
}
}
$Q=mysql_query("SELECT * FROM zayavka WHERE creator='$in'");
while($D=mysql_fetch_array($Q)){
$status = $D["status"];
$type = $D["type"];
$timeout = $D["timeout"];
$minlev1 = $D["minlev1"];
$minlev2 = $D["minlev2"];
$maxlev1 = $D["maxlev1"];
$maxlev2 = $D["maxlev2"];
$limit1 = $D["limit1"];
$limit2 = $D["limit2"];
$wait = $D["wait"];
if($team==1){
$id=$D["id"];
if($t1_a>=$D["limit1"]){
print "В этой комманде нет места для Вас!
";
print "Вернуться";
die();
}
if($db["level"]<$D["minlev1"] || $db["level"]>$D["maxlev1"]){
print "Вы не подходите по уровню для этого поединка.!
";
print "Вернуться";
die();
}
$S=mysql_query("INSERT INTO team1(player,ip,battle_id,hitted,over) VALUES('$login','$ip','$in','0','0')");
}
else if($team==2){
$id=$D["id"];
if($t2_a>=$D["limit2"]){
print "В этой комманде нет места для Вас!
";
print "Вернуться";
die();
}
if($db["level"]<$D["minlev2"] || $db["level"]>$D["maxlev2"]){
print "Вы не подходите по уровню для этого поединка.!
";
print "Вернуться";
die();
}
$S=mysql_query("INSERT INTO team2(player,ip,battle_id,hitted,over) VALUES('$login','$ip','$in','0','0')");
}
}
}
if($act=="submit"){
/*=============================================================*/
$back_f='group_zayavka.php';
if($db["hp_all"]/3 > $db["hp"]){
print "Вы слишком ослаблены для поединка! Восстановитесь!
";
print "назад";
die();
}
if($friend_level==1){$friend_minlevel="0"; $friend_maxlevel=21;}
if($friend_level==2){$friend_minlevel=0; $friend_maxlevel=$db["level"];}
if($friend_level==3){$friend_minlevel=0; $friend_maxlevel=$db["level"]-1;}
if($friend_level==4){$friend_minlevel=$db["level"]; $friend_maxlevel=$db["level"];}
if($friend_level==5){$friend_minlevel=0; $friend_maxlevel=$db["level"]+1;}
if($friend_level==6){$friend_minlevel=$db["level"]-1; $friend_maxlevel=21;}
if($friend_level==7){$friend_minlevel=$db["level"]-1; $friend_maxlevel=$db["level"]+1;}
if($enemy_level==1){$enemy_minlevel="0"; $enemy_maxlevel=21;}
if($enemy_level==2){$enemy_minlevel=0; $enemy_maxlevel=$db["level"];}
if($enemy_level==3){$enemy_minlevel=0; $enemy_maxlevel=$db["level"]-1;}
if($enemy_level==4){$enemy_minlevel=$db["level"]; $enemy_maxlevel=$db["level"];}
if($enemy_level==5){$enemy_minlevel=0; $enemy_maxlevel=$db["level"]+1;}
if($enemy_level==6){$enemy_minlevel=$db["level"]-1; $enemy_maxlevel=21;}
if($enemy_level==7){$enemy_minlevel=$db["level"]-1; $enemy_maxlevel=$db["level"]+1;}
if(empty($friend_count) || empty($enemy_count)){
print "Вы заполнили не все поля.
";
print "Вернуться";
die();
}
if($friend_count>99 || $enemy_count>99){
print "Максимальное колличество бойцов в группе - 99.
";
print "Вернуться";
die();
}
if($friend_count<1 || $enemy_count<2){
print "Неверный ввод колличества бойцов. Минимальное количество противников - 2 человека.
";
print "Вернуться";
die();
}
if($friend_minlevel<0 || $friend_maxlevel>30 || $enemy_minlevel<0 || $enemy_maxlevel>30){
print "Неверный ввод ограничения уровня.
";
print "Вернуться";
die();
}
if(empty($ip))
{
if (getenv('HTTP_X_FORWARDED_FOR'))
{
$ip=getenv('HTTP_X_FORWARDED_FOR');
}
else
{
$ip=getenv('REMOTE_ADDR');
}
}
$Q_TEAM1=mysql_query("SELECT * FROM team1 WHERE player='$login'");
$Q_TEAM2=mysql_query("SELECT * FROM team2 WHERE player='$login'");
while($D1=mysql_fetch_array($Q_TEAM1)){
if($D1["player"]==$login){
print "Вы не можете подать заявку! Сначала отзовите свою.
";
print "Вернуться";
die();
}
}
while($D2=mysql_fetch_array($Q_TEAM2)){
if($D2["player"]==$login){
print "Вы не можете подать заявку!Сначала отзовите свою.
";
print "Вернуться";
die();
}
}
$time=date("H:i");
$mine_id=$db["id"];
$wait_to=$wait*60+time();
$comment=htmlspecialchars($comment);
$SQL="INSERT INTO zayavka(status,type,date,timeout,creator,minlev1,maxlev1,minlev2,maxlev2,limit1,limit2,wait,comment) VALUES('1','$battle_type','$time','10','$mine_id','$friend_minlevel','$friend_maxlevel','$enemy_minlevel','$enemy_maxlevel','$friend_count','$enemy_count','$wait_to','$comment')";
$QUERY=mysql_query($SQL);
$SQL_T="INSERT INTO team1(player,ip,battle_id,hitted,over) VALUES('$login','$ip','$mine_id','0','0')";
$QUERY2=mysql_query($SQL_T);
if(!$QUERY OR !$QUERY2){echo mysql_error();}
/*=============================================================*/
}
else
{
if(empty($act)){
?>
}
else if($act=="podat"){
$enemy_count=htmlspecialchars($enemy_count);
$friend_count=htmlspecialchars($friend_count);
$battle_type=htmlspecialchars($battle_type);
$wait=htmlspecialchars($wait);
$friend_minlevel=htmlspecialchars($friend_minlevel);
$friend_maxlevel=htmlspecialchars($friend_maxlevel);
$enemy_minlevel=htmlspecialchars($enemy_minlevel);
$enemy_maxlevel=htmlspecialchars($enemy_maxlevel);
$comment=htmlspecialchars($comment);
?>
}
}
if($act=="get" or $act=="submit"){
?>
}
$creator=array();
$team1_limit=array();
$team2_limit=array();
$t1_minlev=array();
$t1_maxlev=array();
$t2_minlev=array();
$t2_maxlev=array();
$t1_all=array();
$t2_all=array();
$btype=array();
$wait=array();
$comment=array();
$time=array();
$i=0;
$Q=mysql_query('SELECT * FROM zayavka WHERE type=3 OR type=4 ORDER BY creator');
$t1_ready=0;
$t2_ready=0;
while($DATA=mysql_fetch_array($Q)){
$cr=$DATA["creator"];
$mine_z[$i] = 0;
$Q2=mysql_query("SELECT * FROM team1 WHERE battle_id='$cr'");
$t1_all[$i]=0;
while($DATAS=mysql_fetch_array($Q2)){
$t1_all[$i]++;
}
$Q3=mysql_query("SELECT * FROM team2 WHERE battle_id='$cr'");
$t2_all[$i]=0;
while($DATAS=mysql_fetch_array($Q3)){
$t2_all[$i]++;
}
$creator[$i]=$DATA["creator"];
$team1_limit[$i]=$DATA["limit1"];
$team2_limit[$i]=$DATA["limit2"];
$t1_minlev[$i]=$DATA["minlev1"];
$t1_maxlev[$i]=$DATA["maxlev1"];
$t2_minlev[$i]=$DATA["minlev1"];
$t2_maxlev[$i]=$DATA["maxlev2"];
$btype[$i]=$DATA["type"];
$wait[$i]=$DATA["wait"];
$comment[$i]=$DATA["comment"];
$time[$i]=$DATA["date"];
$i++;
}
include "functions.php";
for($n=0;$n<$i;$n++){
if($t2_all[$n]==''){$t2_all[$n]=0;}
$wait_sec=$wait[$n];
$now=time();
$left_time=$wait_sec-$now;
$left_min=floor($left_time/60);
$left_sec=$left_time-$left_min*60;
$QUER=mysql_query("SELECT * FROM team2 WHERE battle_id='$creator[$n]'");
while($DATAS=mysql_fetch_array($QUER)){
$p2=$DATAS["player"];
if($p2!=''){
$QQ2=mysql_query("SELECT level,orden,clan,clan_short FROM characters WHERE login='$p2'");
$DD2=mysql_fetch_array($QQ2);
if($p2 == $login){$mine_z[$n] = 1;} // указывает, что н-ый массив относится к текущему перцу
}
}
$QUER=mysql_query("SELECT * FROM team1 WHERE battle_id='$creator[$n]'");
while($DATAS=mysql_fetch_array($QUER)){
$p1=$DATAS["player"];
if($p1!=''){
$QQ2=mysql_query("SELECT level,orden,clan,clan_short FROM characters WHERE login='$p1'");
$DD2=mysql_fetch_array($QQ2);
if($p1 == $login){$mine_z[$n] = 1;}
}
}
if($left_time>0){
print "
$time[$n] $team1_limit[$n] ($t1_minlev[$n]-$t1_maxlev[$n]) на $team2_limit[$n] ($t2_minlev[$n]-$t2_maxlev[$n])";
print " =>(";
$QUER=mysql_query("SELECT * FROM team1 WHERE battle_id='$creator[$n]' ORDER BY date ASC");
while($DATAS=mysql_fetch_array($QUER)){
$p1=$DATAS["player"];
$p = str_replace(" ","%20",$p1);
if($p1!=""){
$QQ=mysql_query("SELECT level,orden,clan,clan_short FROM characters WHERE login='$p1'");
$DD=mysql_fetch_array($QQ);
$lev=$DD["level"];
if($p1 == $login){$mine_z[$n] = 1;}
$p1="$p1 [$lev]";
if($t1_all[$n]==1){print "$p1";}else{
print "$p1, ";}
}
}
print ") ";
print "против =>(";
if($t2_all[$n]==0){print "группа не набрана";}
$QUER=mysql_query("SELECT * FROM team2 WHERE battle_id='$creator[$n]'");
while($DATAS=mysql_fetch_array($QUER)){
$p2=$DATAS["player"];
$p = str_replace(" ","%20",$p2);
if($p2!=''){
$QQ2=mysql_query("SELECT level,orden,clan,clan_short FROM characters WHERE login='$p2'");
$DD2=mysql_fetch_array($QQ2);
$lev2=$DD2["level"];
if($p2 == $login){$mine_z[$n] = 1;}
$p2="$p2 [$lev2]";
if($t2_all[$n]==1){print "$p2";}else{
print "$p2, ";}
}
}
print ")";
if($t2_all[$n]==$team2_limit[$n] AND $t1_all[$n]==$team1_limit[$n] AND $mine_z[$n] == 1){
goBattle($login);
}
$btype_n=$btype[$n]; //
if($btype[$n]==3){$btype[$n]="";}
if($btype[$n]==4){$btype[$n]="";}
print " тип боя: $btype[$n]";
if(!empty($comment[$n])){
print " (Комментарий: $comment[$n])";}
print " Начало через $left_min мин. $left_sec сек. ";
}
if($left_time<0){
$t2_a=0;
$Q_T2=mysql_query("SELECT player FROM team2 WHERE battle_id='$creator[$n]'");
while($QDAT=mysql_fetch_array($Q_T2)){
$t2_a++;
}
if($t2_a==0){
$Q_DZ=mysql_query("DELETE FROM zayavka WHERE creator=$creator[$n]");
$Q_T1=mysql_query("SELECT * FROM team1");
while($Q_T1DAT=mysql_fetch_array($Q_T1)){
if($Q_T1DAT["battle_id"]==$creator[$n]){
$cur_player=$Q_T1DAT["player"];
}
}
$Q_D2=mysql_query("DELETE FROM team1 WHERE battle_id=$creator[$n]");
}else if($mine_z[$n]==1){
goBattle($login);
}
}
}
?>