You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

255 lines
8.5 KiB

13 years ago
<html>
<body bgcolor="#008080">
<?php
/*
*
* @copyright (c) 2010 animegame.eu
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public Licence
*
*/
include_once('../path.inc.php'); // get the path ;)
include_once(ROOT_PATH.'/include/config.inc.php');
include_once(ROOT_PATH.'/include/clan.inc.php');
include_once(ROOT_PATH.'/include/char.inc.php');
include_once(ROOT_PATH.'/include/designfunctions.inc.php');
include_once(ROOT_PATH.'/include/parse.inc.php');
include_once(ROOT_PATH.'/include/fehlerausgabe.inc.php');
// GET-Section
// Kritisch (SQL-Injections)
$challenge_id = validateInteger($_GET['challenge'], null);
// Unkritisch
$action = $_GET['action'];
function getEventChars($challenge_id, $event_id) {
$sql = 'SELECT * FROM clan_challenge_participants ccp INNER JOIN event_chars ec ON ccp.char_id=ec.event_char_id
INNER JOIN event_fights ef ON ccp.slot=ef.event_fight_id
WHERE ccp.clan_challenge_id = '.$challenge_id.' AND ec.event_id= '.$event_id.' AND ef.event_id= '.$event_id.';';
$qry = mysql_query($sql);
$chars = array();
while($row = mysql_fetch_array($qry)) {
$chars[] = $row;
}
return $chars;
}
function getChallengeClans($challenge_id) {
$sql = 'SELECT ccc.id, c.clanname, c.id as clan_id FROM clan_challenge_clans ccc INNER JOIN clan c ON ccc.clan_id=c.id WHERE clan_challenge_id='.$challenge_id.';';
$qry = mysql_query($sql);
$clans = array();
while($row = mysql_fetch_array($qry)) {
$clans[$row['id']] = array('name' => $row['clanname'], 'id' => $row['clan_id']);
}
return $clans;
}
function displayChar($char) {
if($char['visible'] < time()) {
echo '<div style "position:relative; top:0px; left:0px">';
echo '<div style "position:relative; top:0px; left:0px">';
echo '<img src="../'.$char['char_bild'].'" width="75" height="75" border="0">';
echo '</div>';
if($char['event_char_id'] != $char['winner']) {
echo '<div style="position:absolute; top:0px; left:0px; z-index:1">';
echo '<img src="../design/bilder/avatare/Char.gif" width="75" height="75" border="0">';
echo '</div>';
}
echo '</div>';
echo $char['char_name'];
} else {
echo '<img src="../design/bilder/avatare/Char.gif" width="75" height="75" border="0"><br>???';
}
}
function displayHeader($top, $bottom, $challenge) {
$border = 0;
$challenge_id = $challenge['clan_challenge_id'];
$event_id = $challenge['event_id'];
$chars = getEventChars($challenge_id, $event_id);
$clans = getChallengeClans($challenge_id);
echo '<table cellpadding="0" cellspacing="0" width="913" height="0" border="'.$border.'">';
echo '<tr><th valign="top" height="32" colspan="9" align="center">Clankampf am ...</th></tr>';
echo '<tr>';
//erste spalte
echo '<th width="45%" height="32" valign="middle" align="center">'.$clans[0]['name'].'</th>';
//zweite spalte
echo '<td width="5%" valign="middle" align="center" rowspan="3"><b>VS.</b></td>';
//dritte spalte
echo '<th width="45%" height="32" valign="middle" align="center">'.$clans[1]['name'].'</th>';
echo '</tr>';
//obere Teil
echo '<tr height = "150">';
//Darstellen der Bilder auf der linken Seite
echo '<td><table width="100%" height="100%" cellpadding="0" cellspacing="0" border="'.$border.'"><tr>';
$width = 100 / $top;
for ($i = 0; $i < $top; $i++) {
echo '<td width="'.$width.'%" valign="middle" align="center">';
if($clans[0]['id'] == $chars[$i]['clan_id']) {
displayChar($chars[$i]);
}
echo '</td>';
}
echo '</tr></table></td>';
//Darstellen der Bilder auf der linken Seite
echo '<td><table width="100%" height="100%" cellpadding="0" cellspacing="0" border="'.$border.'"><tr>';
$max = (count($chars)/2)+$top;
$min = (count($chars)/2);
for ($i = $min; $i < $max; $i++) {
echo '<td width="'.$width.'%" valign="middle" align="center">';
if($clans[1]['id'] == $chars[$i]['clan_id']) {
displayChar($chars[$i]);
}
echo '</td>';
}
echo '</tr></table></td>';
echo '</tr>';
//untere Teil
echo '<tr height = "150">';
//Darstellen der Bilder auf der linken Seite
echo '<td><table width="100%" height="100%" cellpadding="0" cellspacing="0" border="'.$border.'"><tr>';
$min = $top;
$max = count($chars) / 2;
$width = 100 / $bottom;
for ($i = $min; $i < $max; $i++) {
echo '<td width="'.$width.'%" valign="middle" align="center">';
if($clans[0]['id'] == $chars[$i]['clan_id']) {
displayChar($chars[$i]);
}
echo '</td>';
}
echo '</tr></table></td>';
//Darstellen der Bilder auf der linken Seite
echo '<td><table width="100%" height="100%" cellpadding="0" cellspacing="0" border="'.$border.'"><tr>';
$min = (count($chars)/2)+$top;
$max = count($chars);
for ($i = $min; $i < $max; $i++) {
echo '<td width="'.$width.'%" valign="middle" align="center">';
if($clans[1]['id'] == $chars[$i]['clan_id']) {
displayChar($chars[$i]);
}
echo '</td>';
}
echo '</tr></table></td>';
echo '</tr>';
echo '</table>';
}
function getColor($row) {
if($row % 2 == 0) {
$color = '#018B8B';
//$color = '#FFFFFF';
} else {
$color = '#029393';
//$color = '#FF00FF';
}
return $color;
}
function displayBody($event_id) {
$fight_ids = getEventFightIds($event_id);
$row = 0;
echo '<table cellpadding="0" cellspacing="0" width="913" height="83" border="0">';
foreach($fight_ids as $fight_id) {
$event_fight = getEventFight($event_id, $fight_id);
$round_data = getEventFightRoundData($event_id, $event_fight['event_fight_id'], 0); // get participants of fight
$host_char_id = NULL;
$guest_char_id = NULL;
foreach($round_data as $key => $value) {
if($event_fight['host'] == $key) {
$host_char_id = $key;
} else {
$guest_char_id = $key;
}
}
// Key now lets read out the event_chars ...
$host_char = getEventChar($event_id, $host_char_id);
$guest_char = getEventChar($event_id, $guest_char_id);
// TODO: Check if the fight is already "visible"
echo '<tr><td width="45%" height="15" valign="middle" bgcolor="'.getColor($row).'" align="right">';
echo '<a href="../event_kampf_anzeige.php?event_id='.$event_id.'&event_fight_id='.$event_fight['event_fight_id'].'">';
echo $host_char['char_name'].'</a>';
echo '</td>';
echo '<td width="5%" valign="middle" bgcolor="'.getColor($row).'" align="center">vs</td>';
echo '<td width="45%" valign="middle" bgcolor="'.getColor($row).'" align="left">';
echo '<a href="../event_kampf_anzeige.php?event_id='.$event_id.'&event_fight_id='.$event_fight['event_fight_id'].'">';
echo $guest_char['char_name'].'</a>';
echo '</td></tr>';
$row++;
}
echo '<tr><td height="15" bgcolor="'.getColor($row++).'" colspan="3"> </td></tr>';
echo '<tr><td width="45%" height="15" valign="middle" align="right" bgcolor="'.getColor($row).'">Clan-EXP:</td>';
echo '<td width="5%" valign="middle" align="left" bgcolor="'.getColor($row).'"></td>';
echo '<td width="45%" valign="middle" align="left" bgcolor="'.getColor($row++).'"> 1337</td></tr>';
echo '<tr><td width="45%" height="15" valign="middle" align="right" bgcolor="'.getColor($row).'">Clan-Geld: </td>';
echo '<td width="5%" valign="middle" align="left" bgcolor="'.getColor($row).'"></td>';
echo '<td width="45%" valign="middle" align="left" bgcolor="'.getColor($row++).'"> 1337</td></tr>';
echo '<tr><td width="45%" height="15" valign="middle" align="right" bgcolor="'.getColor($row).'">ELO-Punkte: </td>';
echo '<td width="5%" valign="middle" align="left" bgcolor="'.getColor($row).'"> </td>';
echo '<td width="45%" valign="middle" align="left" bgcolor="'.getColor($row).'"> 1337</td></tr>';
echo '</table>';
}
function displayOverview($challenge_id, $user) {
$user_clan = getClan($user['clan']);
$challenge = getChallenge($challenge_id);
$clans = getParticipatingClanIDs($challenge_id);
if(!in_array($user['clan'] , $clans)) {
displayErrorMessage(NULL, 'Wollte da jemand schummeln? ;)', displayHistoryBackLink());
return;
}
if($challenge['calculated'] == FALSE) {
displayErrorMessage(NULL, 'Der Clankampf ist noch nicht soweit!!', displayHistoryBackLink());
return;
}
$event_id = $challenge['event_id'];
$event = getEvent($event_id);
if($event['event_type'] != EVENT_CLAN_FIGHT) {
displayErrorMessage(NULL, 'Das Event is garkein Clan-Kampf!!', displayHistoryBackLink());
return;
}
//TODO: Kampfbeteiligte ermitteln
//$participating_chars = getEventChars($event_id);
$number_participants = count($participating_chars) / 2;
switch ($challenge['anzahl_chars']) {
case 3:
//not implemented yet!!
break;
case 4:
//not implemented yet!!
break;
case 5:
displayHeader(2, 3, $challenge);
break;
}
displayBody($event_id);
}
switch ($action) {
case 'showsomething':
break;
default:
displayOverview($challenge_id, $user_ida);
break;
}
?>
</body>
</html>