<?php
/*
*
* @copyright (c) 2009 animegame.eu
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public Licence
*
*/
?>
< SCRIPT language = "JavaScript" >
function clankampf(clan_fight_id){
window.open("./last_fight3.php?kampf_id="+clan_fight_id+"&spleoic=clan_fights","","status=no,hotkeys=no,Height=600,Width=929,scrollbars=yes");
}
< / SCRIPT >
<?php
include_once(ROOT_PATH.'//include/clanfights.inc.php');
include_once(ROOT_PATH.'//include/char.inc.php');
if (!empty($_POST['id'])) {
$id= $_POST['id'];
} elseif (!empty($_GET['id'])) {
$id= $_GET['id'];
}
switch ($id) {
case "1":
displaySelectNumberOfFighter($_POST['clanfighttyp']);
break;
case "2":
displayClanUser($user_ida[id],$_POST['numberoffighter'],$_POST['clanfighttyp'],'create');
break;
case "3":
displayCharsOfClanUser($user_ida[id], $_POST['user'], $_POST['numberoffighter'],$_POST['clanfighttyp'],'create');
break;
case "4":
displaySelectClanToFight($user_ida[id],$_POST['numberoffighter'],$_POST['clanfighttyp']);
break;
case "5":
$char_unserialized= unserialize(stripslashes($_POST['chars']));
if (isset($_POST['clan']) AND isset($char_unserialized) AND isset($_POST['zeitpunkt']) AND isset($_POST['datum']) /*AND isset($_POST['ausruestung']) */AND !empty($_POST['clan']) AND !empty($char_unserialized) AND (!empty($_POST['zeitpunkt']) OR $_POST['zeitpunkt'] == 0) AND !empty($_POST['datum'])/* AND !empty($_POST['ausruestung'])*/) {
if ($_POST['clan'] == 0) {
echo '< div style = "text-align:center;" > < input type = "button" value = "Zurück" onClick = "history.back()" > < / div > ';
echo '< p > Bitte wä hle einen Clan aus< / p > ';
} else {
if (date("d.m.Y") == date("d.m.Y", $_POST['datum']) AND date("G") >= $_POST['zeitpunkt']) {
echo '< div style = "text-align:center;" > < input type = "button" value = "Zurück" onClick = "history.back()" > < / div > ';
echo '< p > Dieser Zeitpunkt ist bereits verstrichen. Bitte wä hle einen Zeitpunkt der noch nicht verstrichen ist.< / p > ';
} else {
$clanid = getClanOfUser($user_ida[id]);
$timestamp= strtotime(date("d.m.Y", $_POST['datum']))+$_POST['zeitpunkt']*3600;
if (termineBereitsBelegt($clanid,$_POST['clan'],$timestamp) == 1) {
echo '< div style = "text-align:center;" > < input type = "button" value = "Zurück" onClick = "history.back()" > < / div > ';
echo '< p > '.$errmsg.'< / p > ';
echo '< p > Bitte wä hle einen anderen Zeitpunkt!< / p > ';
} else {
erstelleClanKampf($user_ida[id],$_POST['clan'],$timestamp,unserialize(stripslashes($_POST['chars'])),$_POST['numberoffighter'],$_POST['clanfighttyp']);
$clandaten= getClanInformation($_POST['clan']);
echo '< p > Anfrage, zwecks einen Clankampfes, an Clan "< span style = "font-weight:bold;" > '.$clandaten['clanname'].'< / span > " erfolgreich gesendet!< / p > ';
echo '< a href = "index.php?as=clan/c_kampf" > zurü ck zur Ü bersicht< / a > ';
}
}
}
} else {
echo '< p > Bitte fü hre das Skript zur Herausforderung an einen anderen Clan korrekt aus und versuche nicht es irgendwie zu umgehen!< / p > ';
}
break;
case "del":
if (checkClanfight($_GET['kid']) == 1) {
if (clanfightFromOwnClan($_GET['kid'],$user_ida[id]) == 1) {
deleteClanFight($_GET['kid']);
} else {
echo $errmsg;
}
} else {
echo $errmsg;
}
break;
case "acc":
if (checkClanfight($_GET['kid']) == 1) {
if (clanfightToOwnClan($_GET['kid'],$user_ida[id]) == 1) {
displayClanUser($user_ida[id],getNumberOfFightersByClanfightID($_GET['kid']),'','accept');
} else {
echo $errmsg;
}
} else {
echo $errmsg;
}
break;
case "acc2":
displayCharsOfClanUser($user_ida[id], $_POST['user'], $_POST['numberoffighter'],'','accept');
break;
case "acc_fin":
acceptClanfight($_POST['kid'],$_POST['char']);
break;
case "dec":
if (checkClanfight($_GET['kid']) == 1) {
if (clanfightToOwnClan($_GET['kid'],$user_ida[id]) == 1) {
if (isset($_GET['true'])) {
declineClanfight($_GET['kid'],$_GET['true']);
} else {
declineClanfight($_GET['kid']);
}
} else {
echo $errmsg;
}
} else {
echo $errmsg;
}
break;
case "look":
if (checkClanfight($_GET['kid'],$_GET['id']) == 1) {
?>
< a href = "index.php?as=clan/c_kampf&id=fights" > zurü ck zur Ü bersicht< / a >
< table cellpadding = "0" cellspacing = "0" width = "600" height = "83" >
< tr width = "100%" >
< th valign = "middle" height = "21" align = "center" > Clankampf< / th >
< / tr >
<?php
$anzahl_runden= mysql_fetch_assoc(mysql_query('SELECT runde FROM clan_fights WHERE clanfight_id='.$_GET['kid'].' ORDER BY id DESC LIMIT 1'));
$kampf_daten= mysql_fetch_assoc(mysql_query('SELECT clan, gclan, zeitpunkt, score_set FROM clan_fight_list WHERE id='.$_GET['kid'].' LIMIT 1'));
$pkt_satz_a= 0;
$pkt_satz_b= 0;
$pkt_runde_a= 0;
$pkt_runde_b= 0;
$x= 0;
$duration_of_one_fight= 60; // Anzahl der Sekunden wie lange es Fight dauern soll bis das Ergebnis angezeigt wird.
for ($y=1;$y< $anzahl_runden['runde']+1;$y++) {
$anzahl_kaempfe_bisherige_runden+= mysql_num_rows(mysql_query('SELECT * FROM clan_fights WHERE clanfight_id='.$_GET['kid'].' AND runde='.($y-1)));
$anzahl_kaempfe_inklusive_runden+= mysql_num_rows(mysql_query('SELECT * FROM clan_fights WHERE clanfight_id='.$_GET['kid'].' AND runde='.$y));
$anzahl_kaempfe_runde= mysql_num_rows(mysql_query('SELECT * FROM clan_fights WHERE clanfight_id='.$_GET['kid'].' AND runde='.$y));
if ($kampf_daten['zeitpunkt']+$anzahl_kaempfe_bisherige_runden*$duration_of_one_fight < = time()) {
echo '< tr > < td colspan = "2" height = "15" valign = "bottom" bgcolor = "#cccccc" align = "center" > ';
echo '< h3 > Runde: '.$y.' ';
echo '< / h3 > < / td > < / tr > ';
}
$o=0;
$kaempfe_query= mysql_query('SELECT * FROM clan_fights WHERE clanfight_id='.$_GET['kid'].' AND runde='.$y.' ORDER BY id ASC');
while ($kaempfe_array= mysql_fetch_assoc($kaempfe_query)) {
if($o == 0) {
$mul = '#018B8B';
$o++;
} else {
$mul = '#029393';
$o--;
}
$char_a= getChar2($kaempfe_array['char1']);
$char_b= getChar2($kaempfe_array['char2']);
if ($kaempfe_array['win'] == $kaempfe_array['char1']) {
$pkt_satz_a++;
} else {
$pkt_satz_b++;
}
if ($kampf_daten['zeitpunkt']+$x*$duration_of_one_fight < = time()) {
echo '< tr > < td height = "15" valign = "middle" bgcolor = "'.$mul.'" align = "center" > ';
if (time()-$duration_of_one_fight < $kampf_daten['zeitpunkt']+$x*$duration_of_one_fight) {
echo $char_a['name'].' vs. '.$char_b['name'].'< / td > < td bgcolor = "'.$mul.'" > - : -';
} else {
if ($kaempfe_array['char1'] == $kaempfe_array['win']) {
echo '< a href = "javascript:clankampf('.$kaempfe_array['id'].');" > < b > '.$char_a['name'].'< / b > vs. '.$char_b['name'].'< / a > < / td > < td bgcolor = "'.$mul.'" > '.$pkt_satz_a.' : '.$pkt_satz_b;
} else {
echo '< a href = "javascript:clankampf('.$kaempfe_array['id'].');" > '.$char_a['name'].' vs. < b > '.$char_b['name'].'< / b > < / a > < / td > < td bgcolor = "'.$mul.'" > '.$pkt_satz_a.' : '.$pkt_satz_b;
}
}
echo '< / td > < / tr > ';
}
$x++;
}
if ($pkt_satz_a > $pkt_satz_b) {
$pkt_runde_a++;
} elseif ($pkt_satz_b > $pkt_satz_a) {
$pkt_runde_b++;
}
$pkt_array[$y][pkt_satz_a]= $pkt_satz_a;
$pkt_array[$y][pkt_satz_b]= $pkt_satz_b;
$pkt_array[$y][pkt_runde_a]= $pkt_runde_a;
$pkt_array[$y][pkt_runde_b]= $pkt_runde_b;
$pkt_satz_a= 0;
$pkt_satz_b= 0;
}
?>
< / table >
< p / >
<?php
if ($kampf_daten['zeitpunkt']+$anzahl_kaempfe_inklusive_runden*$duration_of_one_fight < = time()) {
$clan_a= getClanInformation($kampf_daten['clan']);
$clan_b= getClanInformation($kampf_daten['gclan']);
?>
< table align = "center" style = "background-color:#ccc;" >
< tr >
< td style = "font-weight:bold;" > Runde:< / td >
<?php
for ($y=1;$y< $anzahl_runden['runde']+1;$y++) {
echo '< td style = "text-align:center;width:20px;font-weight:bold;" > '.$y.'< / td > ';
}
?>
< / tr >
< tr >
< td style = "font-weight:bold;" > Punkte <?php echo $clan_a [ clanname ]; ?> :</ td >
<?php
for ($y=1;$y< $anzahl_runden['runde']+1;$y++) {
if ($pkt_array[$y][pkt_satz_a] > $pkt_array[$y][pkt_satz_b]) {
echo '< td style = "text-align:center;width:20px;font-weight:bold;color:#f00;" > '.$pkt_array[$y][pkt_satz_a].'< / td > ';
} else {
echo '< td style = "text-align:center;width:20px;" > '.$pkt_array[$y][pkt_satz_a].'< / td > ';
}
}
?>
< / tr >
< tr >
< td style = "font-weight:bold;" > Punkte <?php echo $clan_b [ clanname ]; ?> :</ td >
<?php
for ($y=1;$y< $anzahl_runden['runde']+1;$y++) {
if ($pkt_array[$y][pkt_satz_b] > $pkt_array[$y][pkt_satz_a]) {
echo '< td style = "text-align:center;width:20px;font-weight:bold;color:#f00;" > '.$pkt_array[$y][pkt_satz_b].'< / td > ';
} else {
echo '< td style = "text-align:center;width:20px;" > '.$pkt_array[$y][pkt_satz_b].'< / td > ';
}
}
?>
< / tr >
< / table >
<?php
echo '< p style = "text-align:center;" > '.$clan_a[clanname].' '.$pkt_array[count($pkt_array)][pkt_runde_a].' : '.$pkt_array[count($pkt_array)][pkt_runde_b].' '.$clan_b[clanname].'< / p > ';
if ($pkt_array[count($pkt_array)][pkt_runde_a] > $pkt_array[count($pkt_array)][pkt_runde_b]) {
echo '< p style = "text-align:center;" > < span style = "font-weight:bold;" > Gewinner< / span > : '.$clan_a[clanname].' - < span style = "font-weight:bold;" > Verlierer< / span > : '.$clan_b[clanname].'< / p > ';
} elseif ($pkt_array[count($pkt_array)][pkt_runde_b] > $pkt_array[count($pkt_array)][pkt_runde_a]) {
echo '< p style = "text-align:center;" > < span style = "font-weight:bold;" > Gewinner< / span > : '.$clan_b[clanname].' - < span style = "font-weight:bold;" > Verlierer< / span > : '.$clan_a[clanname].'< / p > ';
} else {
echo '< p style = "text-align:center;" > Der Clankampf zwischen '.$clan_b[clanname].' und '.$clan_a[clanname].' endet Unentschieden.< / p > ';
}
if ($kampf_daten['score_set'] == 0) {
if ($pkt_array[count($pkt_array)][pkt_runde_a] > $pkt_array[count($pkt_array)][pkt_runde_b]) {
$clan_a_updaten= mysql_query('UPDATE clan SET siege=siege+1 WHERE id='.$kampf_daten['clan'].' LIMIT 1');
$clan_b_updaten= mysql_query('UPDATE clan SET niederlagen=niederlagen+1 WHERE id='.$kampf_daten['gclan'].' LIMIT 1');
} elseif ($pkt_array[count($pkt_array)][pkt_runde_b] > $pkt_array[count($pkt_array)][pkt_runde_a]) {
$clan_a_updaten= mysql_query('UPDATE clan SET niederlagen=niederlagen+1 WHERE id='.$kampf_daten['clan'].' LIMIT 1');
$clan_b_updaten= mysql_query('UPDATE clan SET siege=siege+1 WHERE id='.$kampf_daten['gclan'].' LIMIT 1');
} else {
$clan_a_updaten= mysql_query('UPDATE clan SET unentschieden=unentschieden+1 WHERE id='.$kampf_daten['clan'].' LIMIT 1');
$clan_b_updaten= mysql_query('UPDATE clan SET unentschieden=unentschieden+1 WHERE id='.$kampf_daten['gclan'].' LIMIT 1');
}
$score_set_updaten= mysql_query('UPDATE clan_fight_list SET score_set=1 WHERE id='.$_GET['kid'].' LIMIT 1');
}
}
} else {
echo $errmsg;
}
break;
case "create":
displayClanFightType($user_ida[id]);
break;
case "fights":
$clanid= getClanOfUser($user_ida[id]);
echo getActualClanFightInformation($clanid,$user_ida[id]);
break;
case "look_survival":
if (checkClanfight($_GET['kid'],$_GET['id']) == 1) {
?>
< a href = "index.php?as=clan/c_kampf&id=fights" > zurü ck zur Ü bersicht< / a >
< table cellpadding = "0" cellspacing = "0" width = "600" height = "83" >
< tr width = "100%" >
< th valign = "middle" height = "21" align = "center" > Clankampf< / th >
< / tr >
<?php
$anzahl_kaempfe= mysql_num_rows(mysql_query('SELECT id FROM clan_fights WHERE clanfight_id='.$_GET['kid']));
$kampf_daten= mysql_fetch_assoc(mysql_query('SELECT clan, gclan, zeitpunkt, score_set FROM clan_fight_list WHERE id='.$_GET['kid'].' LIMIT 1'));
$pkt_satz_a= 0;
$pkt_satz_b= 0;
$pkt_runde_a= 0;
$pkt_runde_b= 0;
$x= 0;
$duration_of_one_fight= 180; // Anzahl der Sekunden wie lange es Fight dauern soll bis das Ergebnis angezeigt wird.
$o=0;
$kaempfe_query= mysql_query('SELECT * FROM clan_fights WHERE clanfight_id='.$_GET['kid'].' ORDER BY id ASC');
while ($kaempfe_array= mysql_fetch_assoc($kaempfe_query)) {
if($o == 0) {
$mul = '#018B8B';
$o++;
} else {
$mul = '#029393';
$o--;
}
$char_a= getChar2($kaempfe_array['char1']);
$char_b= getChar2($kaempfe_array['char2']);
if ($kaempfe_array['win'] == $kaempfe_array['char1']) {
$pkt_satz_a++;
} else {
$pkt_satz_b++;
}
if ($kampf_daten['zeitpunkt']+$x*$duration_of_one_fight < = time()) {
echo '< tr > < td height = "15" valign = "middle" bgcolor = "'.$mul.'" align = "center" > ';
if (time()-$duration_of_one_fight < $kampf_daten['zeitpunkt']+$x*$duration_of_one_fight) {
echo $char_a['name'].' vs. '.$char_b['name'].'< / td > < td bgcolor = "'.$mul.'" > - : -';
} else {
if ($kaempfe_array['char1'] == $kaempfe_array['win']) {
echo '< a href = "javascript:clankampf('.$kaempfe_array['id'].');" > < b > '.$char_a['name'].'< / b > vs. '.$char_b['name'].'< / a > < / td > < td bgcolor = "'.$mul.'" > '.$pkt_satz_a.' : '.$pkt_satz_b;
} else {
echo '< a href = "javascript:clankampf('.$kaempfe_array['id'].');" > '.$char_a['name'].' vs. < b > '.$char_b['name'].'< / b > < / a > < / td > < td bgcolor = "'.$mul.'" > '.$pkt_satz_a.' : '.$pkt_satz_b;
}
}
echo '< / td > < / tr > ';
}
$x++;
}
?>
< / table >
< p / >
<?php
if ($kampf_daten['zeitpunkt']+$anzahl_kaempfe*$duration_of_one_fight < = time()) {
$clan_a= getClanInformation($kampf_daten['clan']);
$clan_b= getClanInformation($kampf_daten['gclan']);
echo '< p style = "text-align:center;" > '.$clan_a[clanname].' < span style = "font-weight:bold;" > '.$pkt_satz_a.' : '.$pkt_satz_b.'< / span > '.$clan_b[clanname].'< / p > ';
if ($pkt_satz_a > $pkt_satz_b) {
echo '< p style = "text-align:center;" > < span style = "font-weight:bold;" > Gewinner< / span > : '.$clan_a[clanname].' - < span style = "font-weight:bold;" > Verlierer< / span > : '.$clan_b[clanname].'< / p > ';
} elseif ($pkt_satz_b > $pkt_satz_a) {
echo '< p style = "text-align:center;" > < span style = "font-weight:bold;" > Gewinner< / span > : '.$clan_b[clanname].' - < span style = "font-weight:bold;" > Verlierer< / span > : '.$clan_a[clanname].'< / p > ';
}
if ($kampf_daten['score_set'] == 0) {
if ($pkt_satz_a > $pkt_satz_b) {
$clan_a_updaten= mysql_query('UPDATE clan SET siege=siege+1 WHERE id='.$kampf_daten['clan'].' LIMIT 1');
$clan_b_updaten= mysql_query('UPDATE clan SET niederlagen=niederlagen+1 WHERE id='.$kampf_daten['gclan'].' LIMIT 1');
} elseif ($pkt_satz_b > $pkt_satz_a) {
$clan_a_updaten= mysql_query('UPDATE clan SET niederlagen=niederlagen+1 WHERE id='.$kampf_daten['clan'].' LIMIT 1');
$clan_b_updaten= mysql_query('UPDATE clan SET siege=siege+1 WHERE id='.$kampf_daten['gclan'].' LIMIT 1');
}
$score_set_updaten= mysql_query('UPDATE clan_fight_list SET score_set=1 WHERE id='.$_GET['kid'].' LIMIT 1');
}
}
} else {
echo $errmsg;
}
break;
default:
checkIfChallengeTimedOut($user_ida[id]);
#checkIfClanFightsToExecute($user_ida[id]);
displayClanFights($user_ida[id]);
break;
}
?>