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.
750 lines
28 KiB
750 lines
28 KiB
14 years ago
|
<?php
|
||
|
/*
|
||
|
*
|
||
|
* @copyright (c) 2009 animegame.eu
|
||
|
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public Licence
|
||
|
*
|
||
|
*/
|
||
|
/******
|
||
|
Funktionen fuer die Clanfights
|
||
|
Muss noch bearbeitet werden !!
|
||
|
|
||
|
******/
|
||
|
|
||
|
include_once($_SERVER['DOCUMENT_ROOT'].'/ag/include/config.inc.php');
|
||
|
|
||
|
function getClanMember($clanid) {
|
||
|
//$sql = 'SELECT * FROM user where clan = '.$clanid;
|
||
|
$qry = mysql_query('SELECT * FROM user where clan = '.$clanid);
|
||
|
$options = '';
|
||
|
while ($row = mysql_fetch_assoc($qry)) {
|
||
|
$options .= '<option value="'.$row['id'].'">'.$row['nickname'].'</option>';
|
||
|
}
|
||
|
return $options;
|
||
|
}
|
||
|
|
||
|
function getMemberCharacters($userid) {
|
||
|
$qry = mysql_query('SELECT * FROM chars where besitzer = '.$userid);
|
||
|
$options = '';
|
||
|
while ($row = mysql_fetch_assoc($qry)) {
|
||
|
$options .= '<option value="'.$row['id'].'">'.$row['name'].'</option>';
|
||
|
}
|
||
|
return $options;
|
||
|
}
|
||
|
|
||
|
function getClans($clanid) {
|
||
|
$qry= mysql_query('SELECT clanname, id FROM clan WHERE id != '.$clanid.' ORDER BY clanname ASC');
|
||
|
#$qry= mysql_query('SELECT clanname, id FROM clan ORDER BY clanname ASC');
|
||
|
$options = '';
|
||
|
while ($row = mysql_fetch_assoc($qry)) {
|
||
|
$options .= '<option value="'.$row['id'].'">'.$row['clanname'].'</option>';
|
||
|
}
|
||
|
return $options;
|
||
|
}
|
||
|
|
||
|
function displayClanFights($userid) {
|
||
|
$clanid = getClanOfUser($userid);
|
||
|
$claninfos= getClanInformation($clanid);
|
||
|
?>
|
||
|
<table width="548" cellspacing="0" cellpadding="0" border="0">
|
||
|
<tr>
|
||
|
<th height="29" valign="top" colspan="2">Clan Kämpfe</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td colspan="2">
|
||
|
<?php echo getActualClanChallengeInformation($clanid,$userid); ?>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<?php
|
||
|
if ($claninfos['leader'] == $userid OR $claninfos['co_leader'] == $userid) {
|
||
|
$anzahl_herausforderungen= mysql_num_rows(mysql_query('SELECT id FROM clan_fight_list WHERE clan='.$clanid.' AND status<2'));
|
||
|
if ($anzahl_herausforderungen == 3) {
|
||
|
?>
|
||
|
<tr>
|
||
|
<th height="29" valign="top" colspan="2">Dein Clan hat bereits 3 Herausforderungen. Mehr sind nicht möglich.</td>
|
||
|
</tr>
|
||
|
<?php
|
||
|
} else {
|
||
|
?>
|
||
|
<tr>
|
||
|
<th height="29" valign="top" colspan="2"><a href="index.php?as=clan/c_kampf&id=create">Clan herausfordern</a></td>
|
||
|
</tr>
|
||
|
<?php
|
||
|
}
|
||
|
}
|
||
|
?>
|
||
|
</table>
|
||
|
<?php
|
||
|
}
|
||
|
|
||
|
function displayClanFightType($userid) {
|
||
|
$clanid = getClanOfUser($userid);
|
||
|
?>
|
||
|
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?as=clan/c_kampf" method="POST">
|
||
|
<input type="hidden" name="id" value="1">
|
||
|
<table width="548" cellspacing="0" cellpadding="0" border="0">
|
||
|
<tr>
|
||
|
<th>Kampftyp: </th>
|
||
|
<td height="25">
|
||
|
<select class="input" name="clanfighttyp">
|
||
|
<option value="1">1 vs. 1</option>
|
||
|
<option value="2">Survival</option>
|
||
|
<!--<option value="4">2 vs. 2</option>
|
||
|
<option value="7">4 vs. 4</option>
|
||
|
<option value="12">7 vs. 7</option>-->
|
||
|
</select>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td height="25" align="center">
|
||
|
<input id="input" type="submit" value="weiter">
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</form>
|
||
|
<?php
|
||
|
}
|
||
|
|
||
|
function displaySelectNumberOfFighter($clanfighttyp) {
|
||
|
?>
|
||
|
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?as=clan/c_kampf" method="POST">
|
||
|
<input type="hidden" name="id" value="2">
|
||
|
<input type="hidden" name="clanfighttyp" value="<?php echo $clanfighttyp; ?>">
|
||
|
<table width="548" cellspacing="0" cellpadding="0" border="0">
|
||
|
<tr>
|
||
|
<th>Anzahl Kämpfer: </th>
|
||
|
<td height="25">
|
||
|
<select class="input" name="numberoffighter">
|
||
|
<?php
|
||
|
switch ($clanfighttyp) {
|
||
|
case "1":
|
||
|
?>
|
||
|
<option value="4">4 Kämpfer</option>
|
||
|
<option value="6">6 Kämpfer</option>
|
||
|
<?php
|
||
|
break;
|
||
|
case "2":
|
||
|
?>
|
||
|
<option value="4">4 Kämpfer</option>
|
||
|
<option value="6">6 Kämpfer</option>
|
||
|
<?php
|
||
|
break;
|
||
|
}
|
||
|
?>
|
||
|
</select>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td height="25" align="center">
|
||
|
<input id="input" type="submit" value="weiter">
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</form>
|
||
|
<?php
|
||
|
}
|
||
|
|
||
|
function displayClanUser($userid,$numberoffighter,$clanfighttyp,$type){
|
||
|
$clanid = getClanOfUser($userid);
|
||
|
$optionen = getCharacterOptions($clanid);
|
||
|
?>
|
||
|
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?as=clan/c_kampf" method="POST">
|
||
|
<?php
|
||
|
if ($type == 'create') {
|
||
|
echo '<input type="hidden" name="id" value="3">';
|
||
|
} elseif ($type == 'accept') {
|
||
|
echo '<input type="hidden" name="id" value="acc2">';
|
||
|
echo '<input type="hidden" name="kid" value="'.$_GET['kid'].'">';
|
||
|
}
|
||
|
?>
|
||
|
<input type="hidden" name="numberoffighter" value="<?php echo $numberoffighter;?>">
|
||
|
<?php
|
||
|
if (!empty($clanfighttyp)) {
|
||
|
?>
|
||
|
<input type="hidden" name="clanfighttyp" value="<?php echo $clanfighttyp; ?>">
|
||
|
<?php
|
||
|
}
|
||
|
?>
|
||
|
<table width="548" cellspacing="0" cellpadding="0" border="0">
|
||
|
<?php
|
||
|
for($i=1;$i<=$numberoffighter;$i++){
|
||
|
?>
|
||
|
<tr>
|
||
|
<th>User <?php echo $i; ?></th>
|
||
|
<td height="25">
|
||
|
<select class="input" name="user[<?php echo $i; ?>]">
|
||
|
<option value="-1">User wählen...
|
||
|
<?php echo getClanMember($clanid); ?>
|
||
|
</select>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<?php
|
||
|
}
|
||
|
?>
|
||
|
<tr>
|
||
|
<td height="25" align="center">
|
||
|
<input id="input" type="submit" value="weiter">
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</form>
|
||
|
<?php
|
||
|
}
|
||
|
|
||
|
function displayCharsOfClanUser($userid, $wahluser, $numberoffighter, $clanfighttyp='', $type){
|
||
|
$anzahl_gewaehlt= 0;
|
||
|
|
||
|
for($i=1;$i<count($wahluser)+1;$i++) {
|
||
|
if($wahluser[$i] != -1) {
|
||
|
$anzahl_gewaehlt++;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$count_member_array= array_count_values($wahluser);
|
||
|
|
||
|
for($i=1;$i<count($wahluser)+1;$i++) {
|
||
|
if($wahluser[$i] == -1) {
|
||
|
$errmsg .= '<p>Es sind nicht genug Clanmitglieder ausgewählt worden für einen Clankampf!</p>';
|
||
|
$errmsg .= '<p>Leider nur '.$anzahl_gewaehlt.' von '.count($wahluser).' Clanmitglieder ausgewählt!</p>';
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
foreach ($count_member_array as $key => $value) {
|
||
|
if ($value > 1 AND $key != -1) {
|
||
|
$errmsg .= '<p>Du hast leider ein Clanmitglied mehrfach ausgewählt!</p>';
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
$clanid = getClanOfUser($userid);
|
||
|
$optionen = getCharacterOptions($clanid);
|
||
|
|
||
|
if (empty($errmsg)) {
|
||
|
?>
|
||
|
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?as=clan/c_kampf" method="POST">
|
||
|
<?php
|
||
|
if ($type == 'create') {
|
||
|
echo '<input type="hidden" name="id" value="4">';
|
||
|
echo '<input type="hidden" name="numberoffighter" value="'.$numberoffighter.'">';
|
||
|
echo '<input type="hidden" name="clanfighttyp" value="'.$clanfighttyp.'">';
|
||
|
} elseif ($type == 'accept') {
|
||
|
echo '<input type="hidden" name="id" value="acc_fin">';
|
||
|
echo '<input type="hidden" name="kid" value="'.$_POST['kid'].'">';
|
||
|
}
|
||
|
?>
|
||
|
<table width="548" cellspacing="0" cellpadding="0" border="0">
|
||
|
<?php
|
||
|
for($i=1;$i<=$numberoffighter;$i++){
|
||
|
?>
|
||
|
<tr>
|
||
|
<th>User <?php echo $i; ?></th>
|
||
|
<td height="25">
|
||
|
<select class="input" name="char[<?php echo $i; ?>]">
|
||
|
<option value="0">Charakter wählen...
|
||
|
<?php echo getMemberCharacters($wahluser[$i]); ?>
|
||
|
</select>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<?php
|
||
|
}
|
||
|
?>
|
||
|
<tr>
|
||
|
<td height="25" align="center">
|
||
|
<input id="input" type="submit" value="weiter">
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</form>
|
||
|
<?php
|
||
|
} else {
|
||
|
$errmsg .= '<div style="text-align:center;"><input type="button" value="Zurück" onClick="history.back()"></div>';
|
||
|
echo $errmsg1;
|
||
|
echo $errmsg;
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function displaySelectClanToFight($userid,$numberoffighter,$clanfighttyp) {
|
||
|
$clanid = getClanOfUser($userid);
|
||
|
/*for ($i=1;$i<sizeof($_POST['char'])+1;$i++) {
|
||
|
if (getStatusOfChar($_POST['char'][$i]) != 'Frei') {
|
||
|
$fehlerhafter_status += 1;
|
||
|
$chars_mit_falschem_status[]= $_POST['char'][$i];
|
||
|
}
|
||
|
}
|
||
|
if (isset($fehlerhafter_status)) {
|
||
|
echo '<div style="text-align:center;"><input type="button" value="Zurück" onClick="history.back()"></div>';
|
||
|
echo '<p>Folgende Charaktere sind nicht verfügbar:</p>';
|
||
|
echo '<ul>';
|
||
|
for ($i=0;$i<count($chars_mit_falschem_status);$i++) {
|
||
|
echo '<li>'.getNameOfChar($chars_mit_falschem_status[$i]).'</li>';
|
||
|
}
|
||
|
echo '</ul>';
|
||
|
exit;
|
||
|
}*/
|
||
|
?>
|
||
|
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?as=clan/c_kampf" method="POST">
|
||
|
<input type="hidden" name="id" value="5">
|
||
|
<input type="hidden" name="chars" value=<?php echo serialize($_POST['char']);?>>
|
||
|
<input type="hidden" name="numberoffighter" value="<?php echo $numberoffighter;?>">
|
||
|
<input type="hidden" name="clanfighttyp" value="<?php echo $clanfighttyp;?>">
|
||
|
<table width="548" cellspacing="0" cellpadding="0" border="0">
|
||
|
<tr>
|
||
|
<th>Clan: </th>
|
||
|
<td height="25">
|
||
|
<select class="input" name="clan">
|
||
|
<option value="0">Clan wählen...
|
||
|
<?php echo getClans($clanid); ?>
|
||
|
</select>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th>Datum: </th>
|
||
|
<td height="25">
|
||
|
<select class="input" name="datum">
|
||
|
<?php
|
||
|
$timestamp= time();
|
||
|
for ($i=0;$i<14;$i++) {
|
||
|
$datum= date("d.m.Y",$timestamp+$i*60*60*24);
|
||
|
$timestamp_changed= strtotime(date("d.m.Y",$timestamp+$i*60*60*24));
|
||
|
echo '<option value="'.$timestam_changed.'">'.$datum.'</datum>';
|
||
|
}
|
||
|
?>
|
||
|
</select>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<th>Zeitpunkt: </th>
|
||
|
<td height="25">
|
||
|
<select class="input" name="zeitpunkt">
|
||
|
<option value="0">nachts (0 Uhr)</option>
|
||
|
<option value="8">morgens (8 Uhr)</option>
|
||
|
<option value="16">nachmittags (16 Uhr)</option>
|
||
|
</select>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<!--<tr>
|
||
|
<th>Ausrüstung: </th>
|
||
|
<td height="25">
|
||
|
<select class="input" name="ausruestung">
|
||
|
<option value="1">mit Ausrüstung</option>
|
||
|
<option value="0">ohne Ausrüstung</option>
|
||
|
</select>
|
||
|
</td>
|
||
|
</tr>-->
|
||
|
<tr>
|
||
|
<td height="25" align="center">
|
||
|
<input id="input" type="submit" value="weiter">
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</form>
|
||
|
<?php
|
||
|
}
|
||
|
|
||
|
function declineClanfight($clanfightid,$true='') {
|
||
|
if (empty($true)) {
|
||
|
echo '<p>Willst du den Clankamp wirklich ablehnen?</p>';
|
||
|
echo '<p><a href="index.php?as=clan/c_kampf&id=dec&kid='.$clanfightid.'&true=1">Ja</a> | <a href="index.php?as=clan/c_kampf">Nein</a></p>';
|
||
|
} else {
|
||
|
$clankampf_loeschen= mysql_query('DELETE FROM clan_fight_list WHERE id='.$clanfightid.' LIMIT 1');
|
||
|
echo '<p>Clankampf erfolgreich abgelehnt!</p>';
|
||
|
echo '<p><a href="index.php?as=clan/c_kampf">zurück zur Übersicht</a></p>';
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function checkIfChallengeTimedOut($userid) {
|
||
|
$clanid= getClanOfUser($userid);
|
||
|
$qry = mysql_query('SELECT id, zeitpunkt, status FROM clan_fight_list WHERE clan='.$clanid.' OR gclan='.$clanid);
|
||
|
while($row = mysql_fetch_assoc($qry)){
|
||
|
if ($row['zeitpunkt'] <= time() AND $row['status'] == 0) {
|
||
|
$status_updaten= mysql_query('UPDATE clan_fight_list SET status=3 WHERE id='.$row['id'].' LIMIT 1');
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function termineBereitsBelegt($clanid,$gclanid,$timestamp) {
|
||
|
global $errmsg;
|
||
|
$clan_qry= mysql_num_rows(mysql_query('SELECT id FROM clan_fight_list WHERE clan = '.$clanid.' AND status != 3 AND zeitpunkt = '.$timestamp));
|
||
|
$gclan_qry= mysql_num_rows(mysql_query('SELECT id FROM clan_fight_list WHERE gclan = '.$gclanid.' AND status != 3 AND zeitpunkt = '.$timestamp));
|
||
|
if ($clan_qry AND $gclan_qry) {
|
||
|
$errmsg= 'Dein Clan und der herausgeforderte Clan haben zu diesem Zeitpunkt bereits einen Clankampf!';
|
||
|
$err= 1;
|
||
|
} elseif ($clan_qry) {
|
||
|
$errmsg= 'Dein Clan hat zu diesem Zeitpunkt bereits einen Clankampf!';
|
||
|
$err= 1;
|
||
|
} elseif ($gclan_qry) {
|
||
|
$errmsg= 'Der herausgeforderte Clan hat zu diesem Zeitpunkt bereits einen Clankampf!';
|
||
|
$err= 1;
|
||
|
} else {
|
||
|
$err= 0;
|
||
|
}
|
||
|
return $err;
|
||
|
}
|
||
|
|
||
|
function clanfightFromOwnClan($clanfightid,$userid='') {
|
||
|
$clanid= getClanOfUser($userid);
|
||
|
$clanfightcheck= mysql_fetch_assoc(mysql_query('SELECT clan from clan_fight_list WHERE id='.$clanfightid.' LIMIT 1'));
|
||
|
if ($clanfightcheck['clan'] == $clanid) {
|
||
|
return 1;
|
||
|
} else {
|
||
|
global $errmsg;
|
||
|
$errmsg= '<p>Dieser Clankampf ist nicht von deinem Clan erstellt und kann somit nicht zurückgezogen werden!</p>';
|
||
|
return 0;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function clanfightToOwnClan($clanfightid,$userid='') {
|
||
|
$clanid= getClanOfUser($userid);
|
||
|
$clanfightcheck= mysql_fetch_assoc(mysql_query('SELECT gclan from clan_fight_list WHERE id='.$clanfightid.' LIMIT 1'));
|
||
|
if ($clanfightcheck['gclan'] == $clanid) {
|
||
|
return 1;
|
||
|
} else {
|
||
|
global $errmsg;
|
||
|
$errmsg= '<p>Die Herausforderung von diesem Clankampf ist nicht an deinem Clan gerichtet!</p>';
|
||
|
return 0;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function checkClanfight($clanfightid,$type='') {
|
||
|
if (is_numeric($clanfightid)) {
|
||
|
$clanfightcheck= mysql_fetch_assoc(mysql_query('SELECT status FROM clan_fight_list WHERE id='.$clanfightid.' LIMIT 1'));
|
||
|
if ($clanfightcheck) {
|
||
|
if ($clanfightcheck['status'] == 2 AND ($type == 'look' OR $type == 'look_survival')) {
|
||
|
return 1;
|
||
|
} elseif ($clanfightcheck['status'] != 0) {
|
||
|
global $errmsg;
|
||
|
$errmsg= '<p>Der Clankampf wurde bereits angenommen / abgelehnt!</p>';
|
||
|
return 0;
|
||
|
} else {
|
||
|
return 1;
|
||
|
}
|
||
|
} else {
|
||
|
global $errmsg;
|
||
|
$errmsg= '<p>Diesen Clankampf gibt es nicht!</p>';
|
||
|
return 0;
|
||
|
}
|
||
|
} else {
|
||
|
global $errmsg;
|
||
|
$errmsg= '<p>Die ID des Clankampfes ist kein numerischer Wert!</p>';
|
||
|
return 0;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function getNumberOfFightersByClanfightID($clanfightid) {
|
||
|
$clankampf_informationen= mysql_fetch_assoc(mysql_query('SELECT numberoffighter FROM clan_fight_list WHERE id='.$clanfightid.' LIMIT 1'));
|
||
|
return $clankampf_informationen['numberoffighter'];
|
||
|
}
|
||
|
|
||
|
function acceptClanfight($clanfightid,$chars) {
|
||
|
$chars= implode(",",$chars);
|
||
|
$status_pruefen= mysql_fetch_assoc(mysql_query('SELECT status FROM clan_fight_list WHERE id='.$clanfightid.' LIMIT 1'));
|
||
|
if ($status_pruefen['status'] == 0) {
|
||
|
$datensatz_updaten= mysql_query('UPDATE clan_fight_list SET gfighter="'.$chars.'", status=1 WHERE id='.$clanfightid) or die(mysql_error());
|
||
|
echo '<p>Der Clankampf wurde erfolgreich angenommen!</p>';
|
||
|
echo '<a href="index.php?as=clan/c_kampf">zurück zur Übersicht</a>';
|
||
|
} else {
|
||
|
echo '<p>Dieser Clankampf kann nichtmehr angenommen werden. Er wurde bereits angenommen!</p>';
|
||
|
echo '<a href="index.php?as=clan/c_kampf">zurück zur Übersicht</a>';
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function deleteClanFight($clanfightid) {
|
||
|
$clankampf_loeschen= mysql_query('DELETE FROM clan_fight_list WHERE id='.$clanfightid.' LIMIT 1');
|
||
|
echo '<p>Herausforderung erfolgreich zurückgezogen!</p>';
|
||
|
echo '<a href="index.php?as=clan/c_kampf">zurück zur Übersicht</a>';
|
||
|
}
|
||
|
|
||
|
function getClanOptions(){
|
||
|
$sql = 'SELECT clanname, id FROM clan order by clanname';
|
||
|
$qry = mysql_query($sql);
|
||
|
$options = '';
|
||
|
while($row = mysql_fetch_assoc($qry)){
|
||
|
$options .= '<option value="'.$row[id].'">'.$row[clanname].'</option>';
|
||
|
}
|
||
|
return $options;
|
||
|
}
|
||
|
|
||
|
|
||
|
// Diese Funktion liefert alle Karaktaere des Clans mit der id $clanid.
|
||
|
// Sortiert werden die Eintraege nach Trainer und Charname
|
||
|
function getCharacterOptions($clanid){
|
||
|
$sql = 'SELECT c.name, c.id, u.nickname FROM chars c LEFT JOIN user u ON (u.id=c.besitzer) WHERE u.clan='.$clanid.' ORDER BY u.nickname, c.name ASC';
|
||
|
$qry = mysql_query($sql);
|
||
|
$options = '';
|
||
|
while($row = mysql_fetch_assoc($qry)){
|
||
|
$options .= '<option value='.$row[id].'>'.$row[name].' ('.$row[nickname].')</option>';
|
||
|
}
|
||
|
return $options;
|
||
|
}
|
||
|
|
||
|
function getActualClanChallengeInformation($clanid,$userid){
|
||
|
$string = '<table>';
|
||
|
#$kaempfe = mysql_query('SELECT u.aktiv, u.besitzer, c.clanname, c2.clanname as clanname2, u.tick, u.id FROM clan_k_list u LEFT JOIN clan c ON(u.besitzer=c.id) LEFT JOIN clan c2 ON(u.an = c2.id )WHERE u.an='.$clanid.' OR u.besitzer='.$clanid.' ORDER BY tick ASC');
|
||
|
$kaempfe_query= mysql_query('SELECT * FROM clan_fight_list WHERE (clan='.$clanid.' OR gclan='.$clanid.') AND status=0 ORDER BY zeitpunkt DESC');
|
||
|
$informationen_eigener_clan= getClanInformation($clanid);
|
||
|
while($row = mysql_fetch_assoc($kaempfe_query)) {
|
||
|
if($row['clan'] == $clanid) {
|
||
|
$claninformationen= getClanInformation($row['gclan']);
|
||
|
if ($informationen_eigener_clan['leader'] == $userid OR $informationen_eigener_clan['co_leader'] == $userid) {
|
||
|
$string .= '<tr><th valign="top">Herausforderung an "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td> (<a href="index.php?as=clan/c_kampf&id=del&kid='.$row['id'].'">zurückziehen</a>) </td></tr>';
|
||
|
} else {
|
||
|
$string .= '<tr><th valign="top">Herausforderung an "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td> (zurückziehen) </td></tr>';
|
||
|
}
|
||
|
} else {
|
||
|
$claninformationen= getClanInformation($row['clan']);
|
||
|
if ($informationen_eigener_clan['leader'] == $userid OR $informationen_eigener_clan['co_leader'] == $userid) {
|
||
|
$string .= '<tr><th valign="top">Herausforderung von "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td>(<a href="index.php?as=clan/c_kampf&id=acc&kid='.$row['id'].'">annehmen</a> | <a href="index.php?as=clan/c_kampf&id=dec&kid='.$row['id'].'">ablehnen</a>)</td></tr>';
|
||
|
} else {
|
||
|
$string .= '<tr><th valign="top">Herausforderung von "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td>(annehmen | ablehnen)</td></tr>';
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
$string .= '</table>';
|
||
|
return $string;
|
||
|
}
|
||
|
|
||
|
function getActualClanFightInformation($clanid,$userid){
|
||
|
$string = '<table>';
|
||
|
#$kaempfe = mysql_query('SELECT u.aktiv, u.besitzer, c.clanname, c2.clanname as clanname2, u.tick, u.id FROM clan_k_list u LEFT JOIN clan c ON(u.besitzer=c.id) LEFT JOIN clan c2 ON(u.an = c2.id )WHERE u.an='.$clanid.' OR u.besitzer='.$clanid.' ORDER BY tick ASC');
|
||
|
$kaempfe_query= mysql_query('SELECT * FROM clan_fight_list WHERE clan='.$clanid.' OR gclan='.$clanid.' ORDER BY zeitpunkt DESC');
|
||
|
$informationen_eigener_clan= getClanInformation($clanid);
|
||
|
while($row = mysql_fetch_assoc($kaempfe_query)) {
|
||
|
if($row['clan'] == $clanid) {
|
||
|
$claninformationen= getClanInformation($row['gclan']);
|
||
|
if ($row['status'] == 1) {
|
||
|
$string .= '<tr><th valign="top">Clankampf gegen "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td>anschauen</td></tr>';
|
||
|
} elseif ($row['status'] == 2) {
|
||
|
$string .= '<tr><th valign="top">Clankampf gegen "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td><a href="index.php?as=clan/c_kampf&id=look&kid='.$row['id'].'">anschauen</a></td></tr>';
|
||
|
}
|
||
|
} else {
|
||
|
$claninformationen= getClanInformation($row['clan']);
|
||
|
if ($row['status'] == 1) {
|
||
|
$string .= '<tr><th valign="top">Clankampf gegen "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td>anschauen</td></tr>';
|
||
|
} elseif ($row['status'] == 2) {
|
||
|
$string .= '<tr><th valign="top">Clankampf gegen "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td><a href="index.php?as=clan/c_kampf&id=look&kid='.$row['id'].'">anschauen</a></td></tr>';
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
$string .= '</table>';
|
||
|
return $string;
|
||
|
}
|
||
|
|
||
|
function getClanInformation($clanid){
|
||
|
return mysql_fetch_array(mysql_query('SELECT clanname, leader, id, co_leader FROM clan WHERE id='.$clanid));
|
||
|
}
|
||
|
|
||
|
function getClanOfUser($userid){
|
||
|
$sql = 'SELECT clan FROM user WHERE id = '.$userid;
|
||
|
$row = mysql_fetch_assoc(mysql_query($sql));
|
||
|
return $row[clan];
|
||
|
}
|
||
|
|
||
|
function getStatusOfChar($charid) {
|
||
|
$sql= 'SELECT status FROM chars WHERE id='.$charid;
|
||
|
$row= mysql_fetch_assoc(mysql_query($sql));
|
||
|
return $row[status];
|
||
|
}
|
||
|
|
||
|
function getNameOfChar($charid) {
|
||
|
$sql= 'SELECT status, name FROM chars WHERE id='.$charid;
|
||
|
$row= mysql_fetch_assoc(mysql_query($sql));
|
||
|
return 'Char: '.$row[name].' - Status: '.$row[status];
|
||
|
}
|
||
|
|
||
|
function erstelleClanKampf($userid, $clanid, $time, $chars, $numberoffighter, $clanfighttyp) {
|
||
|
$chars= implode(",",$chars);
|
||
|
$own_clan = getClanOfUser($userid);
|
||
|
$claninfo = getClanInformation($own_clan);
|
||
|
$claninfo2 = getClanInformation($clanid);
|
||
|
|
||
|
$anfrage_an_clan_bereits_vorhanden= mysql_num_rows(mysql_query('SELECT * FROM clan_fight_list WHERE clan='.$claninfo['id'].' AND gclan='.$claninfo2['id'].' AND zeitpunkt='.$time.' AND status=0'));
|
||
|
if ($anfrage_an_clan_bereits_vorhanden == 1) {
|
||
|
echo '<div style="text-align:center;"><input type="button" value="Zurück" onClick="history.back()"></div>';
|
||
|
echo '<p>Eine Anfrage für den '.date("d.m.Y H:i:s",$time).' an den Clan "'.$claninfo2['clanname'].'" wurde bereits gestellt!</p>';
|
||
|
exit;
|
||
|
}
|
||
|
|
||
|
$anfrage_von_clan_bereits_vorhanden= mysql_num_rows(mysql_query('SELECT * FROM clan_fight_list WHERE clan='.$claninfo2['id'].' AND gclan='.$claninfo['id'].' AND zeitpunkt='.$time.' AND status=0'));
|
||
|
if ($anfrage_von_clan_bereits_vorhanden == 1) {
|
||
|
echo '<div style="text-align:center;"><input type="button" value="Zurück" onClick="history.back()"></div>';
|
||
|
echo '<p>Eine Herausforderung für den '.date("d.m.Y H:i:s",$time).' vom Clan "'.$claninfo2['clanname'].'" wurde bereits an deinen Clan gestellt!</p>';
|
||
|
exit;
|
||
|
}
|
||
|
|
||
|
if($claninfo2 == null){
|
||
|
return 'Der herauszufordernde Clan existiert nicht (mehr!';
|
||
|
}
|
||
|
if($userid != $claninfo[leader] && $userid != $claninfo[co_leader]){
|
||
|
return 'Nur der Leader, bzw. der Co-Leader kann Clan-kämpfe erstellen!';
|
||
|
}
|
||
|
|
||
|
$clankampfanfrage_eintragen = mysql_query("INSERT INTO clan_fight_list (id,clan,gclan,fighter,clanfighttyp,numberoffighter,zeitpunkt,status) VALUES ('','".$claninfo['id']."','".$claninfo2['id']."','".$chars."','".$clanfighttyp."','".$numberoffighter."','".$time."',0)");
|
||
|
if(!$foo){
|
||
|
return 'Error by sql: '.$sql.'<br>';
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
function loescheKampf($userid, $kampfid){
|
||
|
if(!is_numeric($userid) || !is_numeric($kampfid)){
|
||
|
return 'Fehler beim Übertragen der Daten aufgetreten!';
|
||
|
}
|
||
|
$clanid = getClanOfUser($userid);
|
||
|
$claninfo = getClanInformation($clanid);
|
||
|
if($userid != $claninfo[leader] && $userid != $claninfo[co_leader]){
|
||
|
return 'Nur der Leader, bzw. der Co-Leader kann das!';
|
||
|
}
|
||
|
$pruef = mysql_num_rows(mysql_query('SELECT id FROM clan_k_list WHERE (besitzer='.$clanid.' OR an='.$clanid.') AND id='.$kampfid));
|
||
|
if($pruef == 1){
|
||
|
if(mysql_query('DELETE FROM clan_k_list WHERE id = '.$kampfid)){
|
||
|
return '';
|
||
|
} else{
|
||
|
return 'Fehler beim löschen in der Datenbank';
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function nehmeKampfAn($userid, $kampfid, $chars){
|
||
|
if(!is_numeric($userid) || !is_numeric($kampfid) || !is_array($chars)){
|
||
|
return 'Fehler beim &Uml;bertragen der Daten augetreten!';
|
||
|
}
|
||
|
|
||
|
$clanid = getClanOfUser($userid);
|
||
|
$claninfo = getClanInformation($clanid);
|
||
|
if($userid != $claninfo[leader] && $userid != $claninfo[co_leader]){
|
||
|
return 'Nur der Leader, bzw. der Co-Leader kann das!';
|
||
|
}
|
||
|
|
||
|
$error = checkCharArray($clanid, $chars);
|
||
|
if($error != ''){
|
||
|
return $error;
|
||
|
}
|
||
|
$sql = 'Update clan_k_list SET aktiv = 1, gcharakter1 = '.$chars[1].', gcharakter2 = '.$chars[2].', gcharakter3 = '.$chars[3].', gcharakter4 = '.$chars[4].', gcharakter5 = '.$chars[5].', gcharakter6 = '.$chars[6].' WHERE aktiv = 0 and id = '.$kampfid.' and an='.$clanid;
|
||
|
if(mysql_query($sql)){
|
||
|
return '';
|
||
|
} else{
|
||
|
return 'Fehler beim einfuegen in der Datenbank';
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function checkIfClanFightsToExecute($userid) {
|
||
|
$clanid= getClanOfUser($userid);
|
||
|
$qry = mysql_query('SELECT id, zeitpunkt, status FROM clan_fight_list WHERE clan='.$clanid.' OR gclan='.$clanid);
|
||
|
while($row = mysql_fetch_assoc($qry)){
|
||
|
if ($row['zeitpunkt'] <= time() AND $row['status'] == 1) {
|
||
|
$status_updaten= mysql_query('UPDATE clan_fight_list SET status=2 WHERE id='.$row['id'].' LIMIT 1');
|
||
|
clanFightExecute($row['id']);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function starteClanFight($chara_1, $chara_2, $clanfight_id, $runde, $kampf){
|
||
|
global $sieger, $verlierer;
|
||
|
include 'kampf_clan.php';
|
||
|
}
|
||
|
|
||
|
function clanFightExecute($id) {
|
||
|
$pkt_a_satz= 0;
|
||
|
$pkt_b_satz= 0;
|
||
|
$pkt_runde_a= 0;
|
||
|
$pkt_runde_b= 0;
|
||
|
$rundenzaehler= 1;
|
||
|
$kampfzaehler= 1;
|
||
|
|
||
|
$clanfight_daten= mysql_fetch_assoc(mysql_query('SELECT fighter, gfighter, numberoffighter FROM clan_fight_list WHERE id='.$id.' LIMIT 1'));
|
||
|
$fighter_a_array= explode(",",$clanfight_daten['fighter']);
|
||
|
$fighter_b_array= explode(",",$clanfight_daten['gfighter']);
|
||
|
|
||
|
for ($x=1;;$x++) {
|
||
|
|
||
|
/*if ($rundenzaehler == 7) {
|
||
|
break;
|
||
|
}*/
|
||
|
|
||
|
$fighter_a= mt_rand(0, count($fighter_a_array)-1);
|
||
|
$fighter_b= mt_rand(0, count($fighter_b_array)-1);
|
||
|
|
||
|
$char_a= getChar2($fighter_a_array[$fighter_a]);
|
||
|
$char_b= getChar2($fighter_b_array[$fighter_b]);
|
||
|
|
||
|
starteClanFight($char_a, $char_b, $id, $rundenzaehler, $kampfzaehler);
|
||
|
|
||
|
$kampfzaehler++;
|
||
|
|
||
|
if ($fighter_a_array[$fighter_a] == $sieger) {
|
||
|
$pkt_a_satz++;
|
||
|
} else {
|
||
|
$pkt_b_satz++;
|
||
|
}
|
||
|
|
||
|
unset($fighter_a_array[$fighter_a]);
|
||
|
unset($fighter_b_array[$fighter_b]);
|
||
|
sort($fighter_a_array);
|
||
|
sort($fighter_b_array);
|
||
|
|
||
|
#if ($pkt_a_satz == 3 OR $pkt_b_satz == 3) {
|
||
|
if ($pkt_a_satz + $pkt_b_satz == $clanfight_daten['numberoffighter']) {
|
||
|
if ($pkt_a_satz > $pkt_b_satz) {
|
||
|
$pkt_runde_a++;
|
||
|
} elseif ($pkt_a_satz < $pkt_b_satz) {
|
||
|
$pkt_runde_b++;
|
||
|
}
|
||
|
|
||
|
$fighter_a_array= explode(",",$clanfight_daten['fighter']);
|
||
|
$fighter_b_array= explode(",",$clanfight_daten['gfighter']);
|
||
|
|
||
|
$rundenzaehler++;
|
||
|
$kampfzaehler= 1;
|
||
|
$pkt_a_satz= 0;
|
||
|
$pkt_b_satz= 0;
|
||
|
if ($pkt_runde_a + $pkt_runde_b == 6) {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
### old function ###
|
||
|
/*function getActualClanFightInformation($clanid,$userid){
|
||
|
$string = '<table>';
|
||
|
#$kaempfe = mysql_query('SELECT u.aktiv, u.besitzer, c.clanname, c2.clanname as clanname2, u.tick, u.id FROM clan_k_list u LEFT JOIN clan c ON(u.besitzer=c.id) LEFT JOIN clan c2 ON(u.an = c2.id )WHERE u.an='.$clanid.' OR u.besitzer='.$clanid.' ORDER BY tick ASC');
|
||
|
$kaempfe_query= mysql_query('SELECT * FROM clan_fight_list WHERE clan='.$clanid.' OR gclan='.$clanid.' ORDER BY zeitpunkt DESC');
|
||
|
$informationen_eigener_clan= getClanInformation($clanid);
|
||
|
while($row = mysql_fetch_assoc($kaempfe_query)){
|
||
|
if($row['clan'] == $clanid) {
|
||
|
$claninformationen= getClanInformation($row['gclan']);
|
||
|
if($row['status'] == 0){
|
||
|
if ($informationen_eigener_clan['leader'] == $userid OR $informationen_eigener_clan['co_leader'] == $userid) {
|
||
|
$string .= '<tr><th valign="top">Herausforderung an "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td> (<a href="index.php?as=clan/c_kampf&id=del&kid='.$row['id'].'">zurückziehen</a>) </td></tr>';
|
||
|
} else {
|
||
|
$string .= '<tr><th valign="top">Herausforderung an "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td> (zurückziehen) </td></tr>';
|
||
|
}
|
||
|
} elseif ($row['status'] == 1) {
|
||
|
$string .= '<tr><th valign="top">Clankampf gegen "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td>anschauen</td></tr>';
|
||
|
} elseif ($row['status'] == 2) {
|
||
|
$string .= '<tr><th valign="top">Clankampf gegen "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td><a href="index.php?as=clan/c_kampf&id=look&kid='.$row['id'].'">anschauen</a></td></tr>';
|
||
|
}
|
||
|
} else{
|
||
|
$claninformationen= getClanInformation($row['clan']);
|
||
|
if($row['status'] == 0){
|
||
|
if ($informationen_eigener_clan['leader'] == $userid OR $informationen_eigener_clan['co_leader'] == $userid) {
|
||
|
$string .= '<tr><th valign="top">Herausforderung von "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td>(<a href="index.php?as=clan/c_kampf&id=acc&kid='.$row['id'].'">annehmen</a> | <a href="index.php?as=clan/c_kampf&id=dec&kid='.$row['id'].'">ablehnen</a>)</td></tr>';
|
||
|
} else {
|
||
|
$string .= '<tr><th valign="top">Herausforderung von "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td>(annehmen | ablehnen)</td></tr>';
|
||
|
}
|
||
|
} elseif ($row['status'] == 1) {
|
||
|
$string .= '<tr><th valign="top">Clankampf gegen "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td>anschauen</td></tr>';
|
||
|
} elseif ($row['status'] == 2) {
|
||
|
$string .= '<tr><th valign="top">Clankampf gegen "'.$claninformationen['clanname'].'" am '.date("d.m.Y H:i:s",$row['zeitpunkt']).'</td><td><a href="index.php?as=clan/c_kampf&id=look&kid='.$row['id'].'">anschauen</a></td></tr>';
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
$string .= '</table>';
|
||
|
return $string;
|
||
|
}*/
|
||
|
|
||
|
?>
|