added missing sign up stuffz and made tournaments manageable

main
hecht 7 years ago
parent 2c5f3f8e8e
commit 0189ccc302

@ -11,97 +11,107 @@ defineIfNotDefined('TURNIER_ANFAENGER_GEBUEHR', 10000);
defineIfNotDefined('TURNIER_WOCHEN_GEBUEHR', 50000); defineIfNotDefined('TURNIER_WOCHEN_GEBUEHR', 50000);
defineIfNotDefined('TURNIER_WOCHENST_GEBUEHR', 50000); defineIfNotDefined('TURNIER_WOCHENST_GEBUEHR', 50000);
function displayTournamentOptions() { include_once(ROOT_PATH.'/include/tournament.inc.php');
function persistTournamentChanges($request) {
$data = getTournamentType($request['id']);
$changes = array();
foreach ($data as $key => $value) {
if (isset($request[$key])) {
if ($request[$key] == 'on') {
$value = 1;
} else {
$value = $request[$key];
}
}
if ($key == 'id') {
continue;
} else if ($key == 'name') {
$changes[] = $key.'=\''.$value.'\'';
} else {
$changes[] = $key.'='.$value;
}
}
$sql = 'UPDATE tournament_types SET '.join(',', $changes).' WHERE id = '.$request['id'];
// echo $sql;
silent_query($sql);
return db_affected_rows();
}
function displayTournamentForm($request, $data) {
$form_data = array();
foreach ($data as $key => $value) {
$form_data[$key] = isset($request[$key]) ? $request[$key] : $value;
}
?> ?>
<form method="POST"> <form method="POST" action="">
<input type="hidden" name="choose" value="tournament"> <input <table>
type="hidden" name="action" value="checktnmt">
<table width="80%">
<tr> <tr>
<th colspan="2"><h1 style="text-align: center">Übersicht</h1></th> <th colspan="2">Turnier editieren</th>
</tr> </tr>
<tr> <tr>
<td>Art</td> <td colspan="2" align="center"><hr /></td>
<td style="text-align: center"><select id="input" name="art">
<option value="klein">Anf&auml;ngerturnier</option>
<option value="wochen">Wochenturnier</option>
<option value="wochenst">Wochenturnier non-Fusion</option>
<option value="gross">Weltturnier</option>
<option value="grossst">Weltturnier non-Fusion</option>
</select>
</td>
</tr> </tr>
<tr> <tr>
<td>Anzahl</td> <td align="left">Name:</td>
<td style="text-align: center"><select id="input" name="anzahl"> <td>
<option value="2">2</option> <input type="text" name="name" value=<?php echo $form_data['name']; ?> />
<option value="4">4</option>
<option value="8">8</option>
<option value="16">16</option>
<option value="32">32</option>
<option value="64">64</option>
<option value="128">128</option>
<option value="256">256</option>
<option value="512">512</option>
</select>
</tr>
<tr>
<td>Fusion erlaubt?</td>
<td style="text-align: center"><select id="input" name="fusion">
<option value="1">ja</option>
<option value="0">nein</option>
</select>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Spezialcharaktere erlaubt? (Kaio/Shichi)</td> <td align="left">Teilnehmer:</td>
<td style="text-align: center"><select id="input" name="special"> <td>
<option value="1">ja</option> <select name="competitors">
<option value="0">nein</option> <?php
for ($i = 2; $i <= 512; $i *= 2 ) {
$selected = '';
if ( $form_data['competitors'] == $i ) {
$selected = ' selected';
}
?>
<option value="<?php echo $i; ?>" <?php echo $selected; ?>><?php echo $i; ?></option>
<?php
}
?>
</select> </select>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Min. Level</td> <td>Fusion ausschließen?</td>
<td style="text-align: center"><input name="minlevel" value="1"></td> <td>
</tr> <input type="checkbox" name="excl_fusions" <?php echo $form_data['excl_fusions']?'checked="checked"':''; ?> />
<tr>
<td>Max. Level</td>
<td style="text-align: center"><input name="maxlevel" value="150"></td>
</tr>
<tr>
<td>Teilnehmer</td>
<td style="text-align: center"><select id="input" name="gain">
<option value="Anmeldung">Anmeldung</option>
<option value="PL">Powerlevel</option>
<option value="Level">Level</option>
</select>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Zufällige Reihenfolge?</td> <td>Gewinner ausschließen?</td>
<td style="text-align: center"><select id="input" name="randomize"> <td>
<option value="1">ja</option> <input type="checkbox" name="excl_winners" <?php echo $form_data['excl_winners']?'checked="checked"':''; ?> />
<option value="0">nein</option>
</select>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Ausrüstung ignorieren?</td> <td>Spezialchars ausschließen?</td>
<td style="text-align: center"><select id="input" name="itemless"> <td>
<option value="1">ja</option> <input type="checkbox" name="excl_special_chars" <?php echo $form_data['excl_special_chars']?'checked="checked"':''; ?> />
<option value="0">nein</option>
</select>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Chance auf eine Frucht</td> <td>Maximale Teilnahme von Fusionen</td>
<td style="text-align: center"><select id="input" name="fruit"> <td>
<select name="excl_fusion_particip_count">
<?php <?php
for ($i = 0; $i <= 100; ++$i) { for ($i = 0; $i < 4; ++$i ) {
$selected = '';
if ( $form_data['excl_fusion_particip_count'] == $i ) {
$selected = ' selected';
}
?> ?>
<option value="<?php echo $i; ?>"><?php echo $i; ?>%</option> <option value="<?php echo $i; ?>" <?php echo $selected; ?>><?php echo $i; ?></option>
<?php <?php
} }
?> ?>
@ -109,13 +119,17 @@ for ($i = 0; $i <= 100; ++$i) {
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Fruchttyp</td> <td>Mindest Level</td>
<td style="text-align: center"><select id="input" name="fruit_type"> <td>
<select name="min_level">
<?php <?php
$types = array('natur', 'Logia', 'Paramecia', 'Zoan'); for ($i = 1; $i < CHAR_MAX_LEVEL; ++$i ) {
foreach ($types as $type) { $selected = '';
if ( $form_data['min_level'] == $i ) {
$selected = ' selected';
}
?> ?>
<option value="<?php echo $type; ?>"><?php echo $type; ?></option> <option value="<?php echo $i; ?>" <?php echo $selected; ?>><?php echo $i; ?></option>
<?php <?php
} }
?> ?>
@ -123,167 +137,161 @@ foreach ($types as $type) {
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Turniergewinner ausschliessen?</td> <td>Maximales Level</td>
<td style="text-align: center"><select id="input" name="exclude_winners"> <td>
<option value="1">ja</option> <select name="max_level">
<option value="0">nein</option> <option value="0">-</option>
<?php
for ($i = 1; $i < CHAR_MAX_LEVEL; ++$i ) {
$selected = '';
if ( $form_data['max_level'] == $i ) {
$selected = ' selected';
}
?>
<option value="<?php echo $i; ?>" <?php echo $selected; ?>><?php echo $i; ?></option>
<?php
}
?>
</select> </select>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Anzahl Teilnahmen nach der Fusionen ausgeschlossen werden?</td> <td>Reihenfolge jede Runde neu?</td>
<td style="text-align: center"><select id="input" name="exclude_fusi_count"> <td>
<option value="0">deaktiviert</option> <input type="checkbox" name="randomize" <?php echo $form_data['randomize']?'checked="checked"':''; ?> />
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</td> </td>
</tr> </tr>
<!-- <tr>
<td>Gruppenphase?</td>
<td style="text-align: center"><select id="input" name="gruppenphase">
<option value="0">nein</option>
<option value="1">ja</option>
</select>
</td>
</tr>
<tr>
<td>Gruppengr&ouml;sse</td>
<td style="text-align: center"><input name="grp_size" value="0"></td>
</tr>
<tr> <tr>
<td>Anzahl der Sieger die eine Gruppe verlassen</td> <td>Ausrüstung ignorieren?</td>
<td style="text-align: center"><input name="grp_proceed" value="0"></td> <td>
</tr>--> <input type="checkbox" name="without_equip" <?php echo $form_data['without_equip']?'checked="checked"':''; ?> />
<tr>
<td align="center" colspan="2"><input type="submit" value="starten">
</td> </td>
</tr> </tr>
<tr> <tr>
<td align="center" colspan="2"><a <td>Frucht Droprate?</td>
href="<?php echo $_SERVER['PHP_SELF'].'?choose=tournament'; ?>">Zur&uuml;ck</a> <td>
<select id="input" name="fruit_chance">
<?php
for ($i = 0; $i <= 100; ++$i) {
$selected = '';
if ( $form_data['fruit_chance'] == $i ) {
$selected = ' selected';
}
?>
<option value="<?php echo $i; ?>" <?php echo $selected; ?>><?php echo $i; ?>%</option>
<?php
}
?>
</select>
</td> </td>
</tr> </tr>
<tr> <tr>
<td align="center" colspan="2"><a <td>Fruchttyp</td>
href="<?php echo $_SERVER['PHP_SELF']; ?>">Zum Hauptmenu</a> <td>
</td> <select id="input" name="fruit_type">
</tr> <option value="0">-</option>
</table>
</form>
<?php <?php
$types = array('Logia', 'Paramecia', 'Zoan', 'natur');
foreach ($types as $type) {
$selected = '';
if ( $form_data['fruit_type'] == $type) {
$selected = ' selected';
} }
?>
function displayCheckTournament($request) { <option value="<?php echo $type; ?>" <?php echo $selected; ?>><?php echo $type; ?></option>
$name = $request['art']; <?php
$anzahl = $request['anzahl']; }
$fusion = $request['fusion']; ?>
$special = $request['special']; </select>
$minlvl = $request['minlevel'];
$maxlvl = $request['maxlevel'];
$gain = $request['gain'];
$random = $request['randomize'];
$itemless = $request['itemless'];
$fruit_chance = $request['fruit'];
$fruit_type = $request['fruit_type'];
$exclude_winners = $request['exclude_winners'];
$exclude_fusi_count = $request['exclude_fusi_count'];
if(is_numeric($minlvl) && is_numeric($maxlvl)) {?>
<table width="80%">
<tr>
<th colspan="2" style="text-align: center">Turnier wirklich starten?</th>
</tr>
<tr>
<td style="text-align: center"><a
href="<?php echo $GLOBALS['URL_TO_TURNIER'].'?fusion='.$fusion.'&special='.
$special.'&minlevel='.$minlvl.'&maxlevel='.$maxlvl.'&gain='.$gain.'&randomize='.
$random.'&name='.$name.'&anzahl='.$anzahl.'&itemless='.$itemless.'&fruit='.
$fruit_chance.'&fruit_type='.$fruit_type.'&exclude_winners='.$exclude_winners.
'&exclude_fusi_count='.$exclude_fusi_count;?>"
target="_blank">Turnier starten!</a>
</td>
<td style="text-align: center"><a
href="<?php echo $_SERVER['PHP_SELF'].'?choose=tournament&action=tnmt'; ?>">Doch
nicht</a>
</td> </td>
</tr> </tr>
</table> <tr>
<td>Teilnameart</td>
<td>
<select id="input" name="gain">
<?php <?php
} else { $types = array( TOURNAMENT_GAIN_ANMELDUNG => 'Anmeldung', TOURNAMENT_GAIN_PL => 'Powerlevel', TOURNAMENT_GAIN_LEVEL => 'Level' );
echo 'Keine gültige Eingabe von Min. oder Max. Level<br>'; foreach ($types as $key => $value) {
echo '<a href="'.$_SERVER['PHP_SELF'].'?choose=tournament&action=tnmt">Zur&uuml;ck</a>'; $selected = '';
} if ( $form_data['gain'] == $key) {
} $selected = ' selected';
function displayEditFee($request) {
$klein = $request['klein'];
$wochen = $request['wochen'];
$wochenst = $request['wochenst'];
$change = FALSE;
if($klein !== NULL || $wochen !== null) {
if($klein !== NULL && $klein != TURNIER_ANFAENGER_GEBUEHR) {
$change = TRUE;
setDefine('TURNIER_ANFAENGER_GEBUEHR', $klein);
} }
if($wochen !== NULL && $wochen != TURNIER_WOCHEN_GEBUEHR) { ?>
$change = TRUE; <option value="<?php echo $key; ?>" <?php echo $selected; ?>><?php echo $value; ?></option>
setDefine('TURNIER_WOCHEN_GEBUEHR', $wochen); <?php
}
if($wochenst !== NULL && $wochenst != TURNIER_WOCHENST_GEBUEHR) {
$change = TRUE;
setDefine('TURNIER_WOCHENST_GEBUEHR', $wochenst);
}
} else {
} }
?> ?>
<form method="get"> </select>
<input type="hidden" name="choose" value="tournament"> <input
type="hidden" name="action" value="fee">
<table width="80%">
<tr>
<th colspan="2"><h1 style="text-align: center">Übersicht</h1></th>
</tr>
<?php if($change === TRUE) {?>
<tr>
<td colspan="2" align="center">&Auml;nderungen &uuml;bernommen!</td>
</tr>
<?php }?>
<tr>
<td colspan="2" align="center"><b>Anf&auml;ngerturnier</b>
</td> </td>
</tr> </tr>
<tr> <tr>
<td align="left">Anmeldegeb&uuml;hr:</td> <td>Eventuelle Anmeldegebühr</td>
<td><input type="text" name="klein" <td>
value=<?php echo ($klein == null)?TURNIER_ANFAENGER_GEBUEHR:$klein;?>> <input type="number" name="entrance_fee" value="<?php echo $form_data['entrance_fee']; ?>" />
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2" align="center"><b>Wochenturnier</b> <td>Wochentag</td>
<td>
<select id="input" name="day_of_week">
<option value="0">-</option>
<?php
$translation = array('', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonntag');
for ($i = 1; $i < count($translation); ++$i) {
$selected = '';
if ( $form_data['day_of_week'] == $i ) {
$selected = ' selected';
}
?>
<option value="<?php echo $i; ?>" <?php echo $selected; ?>><?php echo $translation[$i]; ?></option>
<?php
}
?>
</select>
</td> </td>
</tr> </tr>
<tr> <tr>
<td align="left">Anmeldegeb&uuml;hr:</td> <td>Tag des Monats</td>
<td><input type="text" name="wochen" <td>
value=<?php echo ($wochen == null)?TURNIER_WOCHEN_GEBUEHR:$wochen;?>> <select id="input" name="day_of_month">
<option value="0">-</option>
<?php
for ($i = 1; $i <= 28; ++$i) {
$selected = '';
if ( $form_data['day_of_month'] == $i ) {
$selected = ' selected';
}
?>
<option value="<?php echo $i; ?>" <?php echo $selected; ?>><?php echo $i; ?></option>
<?php
}
?>
</select>
</td> </td>
</tr> </tr>
<td colspan="2" align="center"><b>Wochenturnier non-Fusion</b> <tr>
<td>Tageszeit</td>
<td>
<select id="input" name="hour_of_day">
<?php
for ($i = 0; $i < 24; ++$i) {
$selected = '';
if ( $form_data['hour_of_day'] == $i ) {
$selected = ' selected';
}
?>
<option value="<?php echo $i; ?>" <?php echo $selected; ?>><?php echo $i; ?> Uhr</option>
<?php
}
?>
</select>
</td> </td>
</tr> </tr>
<tr> <tr>
<td align="left">Anmeldegeb&uuml;hr:</td> <td colspan="2" align="center"><hr /></td>
<td><input type="text" name="wochenst"
value=<?php echo ($wochenst == null)?TURNIER_WOCHENST_GEBUEHR:$wochenst;?>>
</td>
</tr> </tr>
<td align="center" colspan="2"><input type="submit" <tr>
value="&auml;ndern"> <td colspan="2" align="center"><input type="submit" value="speichern" /></td>
</td>
</tr> </tr>
<tr> <tr>
<td align="center" colspan="2"><a <td align="center" colspan="2"><a
@ -300,36 +308,77 @@ function displayEditFee($request) {
<?php <?php
} }
function displayStartTournament($id) {
runTournament($id);
}
function displayEditTournament($request) {
$persisted = false;
if(isset($request['name'])) {
$persisted = persistTournamentChanges($request);
if (!$persisted) {
echo '<p>Speichern nicht erfolgreich.</p>';
}
}
if ( !$persisted ) {
displayTournamentForm($request, getTournamentType($request['id']));
} else {
echo 'Editieren erfolgreich. <a href="'.$_SERVER['PHP_SELF'].'?choose=tournament">Weiter</a>';
}
}
function displayTournamentMenu($request) { function displayTournamentMenu($request) {
switch ($request['action']) { switch ($request['action']) {
case 'checktnmt': case 'start':
displayCheckTournament($request); displayStartTournament($request['id']);
break;
case 'tnmt':
displayTournamentOptions();
break; break;
case 'fee': case 'edit':
displayEditFee($request); displayEditTournament($request);
break; break;
default: default:
?> ?>
<table> <table>
<?php if($GLOBALS['URL_TO_TURNIER'] !== null) { ?>
<tr> <tr>
<td><a <th colspan="3">Turniere</th>
href="<?php $_SERVER['PHP_SELF'] ?>?choose=tournament&action=tnmt">Turnier
starten</a>
</td>
</tr> </tr>
<?php }?> <?php
$tournaments = getTournamentTypes();
foreach ($tournaments as $tournament) {
?>
<tr> <tr>
<td><a <td><?php echo $tournament['name']?>:</td>
href="<?php $_SERVER['PHP_SELF'] ?>?choose=tournament&action=fee"> <?php
Anmeldegebühren bearbeiten</a> if (canStartTournament($tournament)) {
?>
<td><a href="<?php $_SERVER['PHP_SELF'] ?>?choose=tournament&action=start&id=<?php echo $tournament['id']; ?>">starten</a></td>
<?php
} else {
?>
<td>starten</td>
<?php
}
?>
</td> </td>
<?php
if (canEditTournament($tournament)) {
?>
<td><a href="<?php $_SERVER['PHP_SELF'] ?>?choose=tournament&action=edit&id=<?php echo $tournament['id']; ?>">edit</a></td>
<?php
} else {
?>
<td>edit</td>
<?php
}
?>
</tr> </tr>
<?php
}
?>
<tr> <tr>
<td><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Zum Hauptmenu</a> <td colspan="3">
<a href="<?php echo $_SERVER['PHP_SELF']; ?>">Zum Hauptmenu</a>
</td> </td>
</tr> </tr>
</table> </table>

@ -11,6 +11,7 @@ include_once(ROOT_PATH.'//include/designfunctions.inc.php');
include_once (ROOT_PATH . '/include/clan.inc.php'); include_once (ROOT_PATH . '/include/clan.inc.php');
include_once (ROOT_PATH . '/include/clan_chat.inc.php'); include_once (ROOT_PATH . '/include/clan_chat.inc.php');
$itemsx1 = mysqli_num_rows(db_query("SELECT id FROM sp_ware WHERE item='1' AND user='$user_ida[id]'")); $itemsx1 = mysqli_num_rows(db_query("SELECT id FROM sp_ware WHERE item='1' AND user='$user_ida[id]'"));
$itemsz1 = mysqli_fetch_array(db_query("SELECT id FROM sp_ware WHERE item='1' AND user='$user_ida[id]' LIMIT 1")); $itemsz1 = mysqli_fetch_array(db_query("SELECT id FROM sp_ware WHERE item='1' AND user='$user_ida[id]' LIMIT 1"));
@ -55,10 +56,14 @@ if ($name AND $passwort) {
$training_009 = ""; $training_009 = "";
$turnier_009 = '<a href="index.php?as=turnier&art=wochen">Wochen Turnier Anmeldung</a><br>' . $turnier_009 = '';
'<a href="index.php?as=turnier&art=wochenst">Non-Fusi Turnier Anmeldung</a><br>'.
'<a href="index.php?as=turnier&art=klein">Anf&auml;nger Turnier Anmeldung</a><br>' . $tournaments = db_query('SELECT id, abbrevation FROM tournament_types WHERE gain = 0');
'<a href="index.php?as=turnier_auswahl">Turnier Angucken</a><br>'; foreach ($tournaments as $tournament) {
$turnier_009 = $turnier_009 . '<a href="index.php?as=turnier&type_id='.$tournament['id'].'">'.$tournament['abbrevation'].' Anmeldung</a><br>';
}
$turnier_009 = $turnier_009 . '<a href="index.php?as=turnier_auswahl">Turnier Angucken</a><br>';
if ($user_ida['clan'] == 0) { if ($user_ida['clan'] == 0) {
$clan_009 = " $clan_009 = "

@ -38,12 +38,6 @@ function getStatus($charid, $buffer_enabled = true) {
return $GLOBALS['char_buffered_statuses'][$charid]; return $GLOBALS['char_buffered_statuses'][$charid];
} }
$sql = 'SELECT count(*) as anzahl FROM turnier_kampf t where art != \'gross\' and (win = ' . $charid . ' or lose = ' . $charid . ') and dauer > now()';
$row = mysqli_fetch_assoc(db_query($sql));
if ($row['anzahl'] > 0) {
$GLOBALS['char_buffered_statuses'][$charid] = 'Turnier';
return 'Turnier';
}
$sql = 'SELECT count(*) as anzahl from quests where charid = ' . $charid; $sql = 'SELECT count(*) as anzahl from quests where charid = ' . $charid;
$row = mysqli_fetch_assoc(db_query($sql)); $row = mysqli_fetch_assoc(db_query($sql));
if ($row['anzahl'] > 0) { if ($row['anzahl'] > 0) {
@ -63,7 +57,7 @@ function getStatus($charid, $buffer_enabled = true) {
$GLOBALS['char_buffered_statuses'][$charid] = 'Kampf erstellt'; $GLOBALS['char_buffered_statuses'][$charid] = 'Kampf erstellt';
return 'Kampf erstellt'; return 'Kampf erstellt';
} }
$sql = 'SELECT count(*) as anzahl FROM turnier1 where charakter = ' . $charid; $sql = 'SELECT count(*) as anzahl FROM tournament_registration where charakter = ' . $charid;
$row = mysqli_fetch_assoc(db_query($sql)); $row = mysqli_fetch_assoc(db_query($sql));
if ($row['anzahl'] > 0) { if ($row['anzahl'] > 0) {
$GLOBALS['char_buffered_statuses'][$charid] = 'Angemeldet'; $GLOBALS['char_buffered_statuses'][$charid] = 'Angemeldet';

@ -177,10 +177,6 @@ function addExpToChar($char_id, $n_exp){
db_query($sql); db_query($sql);
$char = getChar($char_id, false); // We really want the actual char!! $char = getChar($char_id, false); // We really want the actual char!!
if($char['level'] > 25) {
// remove this char out of the registration of the beginners tournament
db_query('Delete from turnier1 where art = \'klein\' and charakter = \''.$char_id.'\'');
}
} }
function addExpToArena($user_id, $n_exp){ function addExpToArena($user_id, $n_exp){

@ -14,123 +14,82 @@ include_once(ROOT_PATH.'/include/designfunctions.inc.php');
include_once(ROOT_PATH.'/include/char.inc.php'); include_once(ROOT_PATH.'/include/char.inc.php');
include_once(ROOT_PATH.'/include/halloffame.inc.php'); include_once(ROOT_PATH.'/include/halloffame.inc.php');
include_once(ROOT_PATH.'/include/auktion_functions.inc.php'); include_once(ROOT_PATH.'/include/auktion_functions.inc.php');
include_once(ROOT_PATH.'/include/tournament.inc.php');
// GET-Section // GET-Section
// Kritisch (SQL-Injections) // Kritisch (SQL-Injections)
$char_id = validateUnsignedInteger($_GET['char_id'], null); $char_id = validateUnsignedInteger($_GET['char_id'], null);
$art = validateString($_GET['art']); $type_id = validateUnsignedInteger($_GET['type_id']);
// Unkritisch // Unkritisch
$charm = $_GET['charm']; $charm = $_GET['charm'];
function anmelden($user, $charid, $art){ function anmelden($user, $charid, $type_id){
// Security $tournament_type = getTournamentType($type_id);
if($art != 'klein' && $art != 'wochen' && $art != 'wochenst'){ $filter_sql = getTournamentCharExclusionSQL($tournament_type, 'c');
$anzahl = $tournament_type['competitors'];
if ($tournament_type['gain'] != TOURNAMENT_GAIN_ANMELDUNG) {
displayErrorMessage(NULL,'Es ist ein Fehler beim Anmelden aufgetreten!!','<a href="index.php">weiter...</a>'); displayErrorMessage(NULL,'Es ist ein Fehler beim Anmelden aufgetreten!!','<a href="index.php">weiter...</a>');
return;
} }
if(!is_numeric($charid)){ // Ist Charid wirklich eine Zahl???? if(!is_numeric($charid)){ // Ist Charid wirklich eine Zahl????
displayErrorMessage(NULL,'Charid ist nicht numerisch!!','<a href="index.php">weiter...</a>'); displayErrorMessage(NULL,'Charid ist nicht numerisch!!','<a href="index.php">weiter...</a>');
return; return;
} }
// Es wird angenommen, dass $user schon sicher ist, weil das in der config.inc.php ausgelesen wird // Es wird angenommen, dass $user schon sicher ist, weil das in der config.inc.php ausgelesen wird
if($art == 'wochen') { $fee = $tournament_type['entrance_fee'];
$fee = (TURNIER_WOCHEN_GEBUEHR=='TURNIER_WOCHEN_GEBUEHR')?0:TURNIER_WOCHEN_GEBUEHR;
} else if($art == 'klein') {
$fee = (TURNIER_ANFAENGER_GEBUEHR=='TURNIER_ANFAENGER_GEBUEHR')?0:TURNIER_ANFAENGER_GEBUEHR;
} else if($art == 'wochenst') {
$fee = (TURNIER_WOCHENST_GEBUEHR=='TURNIER_WOCHENST_GEBUEHR')?0:TURNIER_WOCHENST_GEBUEHR;
}
if(getUserAvailableMoney($user['id']) < $fee) { if(getUserAvailableMoney($user['id']) < $fee) {
displayErrorMessage(NULL,'Nicht genug Geld um am Turnier teilzunehmen!','<a href="index.php">weiter...</a>'); displayErrorMessage(NULL,'Nicht genug Geld um am Turnier teilzunehmen!','<a href="index.php">weiter...</a>');
return; return;
} }
if($art == 'klein' && getHallOfFameEntryCount('Anf&auml;ngerturnier', $user['id']) >= 2) { $sear_a = mysqli_num_rows(db_query('SELECT tr.id FROM tournament_registration tr inner join chars as c ON tr.charakter = c.id WHERE tr.type='.$type_id.' AND '.$filter_sql));
displayErrorMessage(NULL,'Du hast das Anf&auml;ngerturnier schon zu oft gewonnen!!!','<a href="index.php">weiter...</a>'); echo $sear_a.'<br>'; // Print the amount of registrations!
if($sear_a >= $anzahl) {
displayErrorMessage(NULL,'Turnier voll! Es k&uuml;nnen maximal nur '.$anzahl.' Chars am Turnier teilnehmen','<a href="index.php?as=turnier&type_id='.$type_id.'">weiter...</a>');
return;
} }
if($art == 'klein'){
$races = getSpecialRaceIds();
$special_race_ids = array();
foreach($races as $race) {
$special_race_ids[] = '\''.$race['id'].'\'';
}
// Char darf max lvl 25 haben und keine Fusion sein und auch keine Teufelsfrucht gegessen haben
$special_clue = 'AND level<=25 AND fusion_rasse = \'0\' AND rasse NOT IN ('.implode(',',$special_race_ids).') AND frucht is null';
$anzahl = 32;
} else if($art == 'wochenst') {
$special_clue = 'AND fusion_rasse = \'0\'';
$anzahl = 64;
} else{
$anzahl = 64;
}
// sehr speziell und deswegen nicht getChar(); // sehr speziell und deswegen nicht getChar();
$PRUEF = mysqli_num_rows(db_query('SELECT id FROM chars WHERE id=\''.$charid.'\' '.$special_clue.' AND besitzer=\''.$user['id'].'\' LIMIT 1')); $PRUEF = mysqli_num_rows(db_query('SELECT id FROM chars c WHERE id=\''.$charid.'\' AND '.$filter_sql.' AND besitzer=\''.$user['id'].'\' LIMIT 1'));
if(!$PRUEF) { if(!$PRUEF) {
displayErrorMessage(NULL,'Charakter erf&uuml;llt die Bestimungen nicht!','<a href="index.php?as=turnier&art='.$art.'">weiter...</a>'); displayErrorMessage(NULL,'Charakter erf&uuml;llt die Bestimungen nicht!','<a href="index.php?as=turnier&type_id='.$type_id.'">weiter...</a>');
return; return;
} }
$sear_a = mysqli_num_rows(db_query('SELECT id FROM turnier1 WHERE art=\''.$art.'\'')); $sear = mysqli_fetch_assoc(db_query('SELECT id FROM tournament_registration WHERE besitzer=\''.$user['id'].'\' and type = \''.$type_id.'\' LIMIT 1'));
if($sear_a >= $anzahl) {
displayErrorMessage(NULL,'Turnier voll! Es k&uuml;nnen maximal nur '.$anzahl.' Chars am Turnier teilnehmen','<a href="index.php?as=turnier&art='.$art.'">weiter...</a>');
return;
}
$sear = mysqli_fetch_assoc(db_query('SELECT id FROM turnier1 WHERE besitzer=\''.$user['id'].'\' and art = \''.$art.'\' LIMIT 1'));
if($sear['id']) { if($sear['id']) {
displayErrorMessage(NULL,'Es darf nur einer deiner Chars am Turnier teilnehmen','<a href="index.php?as=turnier&art='.$art.'">weiter...</a>'); displayErrorMessage(NULL,'Es darf nur einer deiner Chars am Turnier teilnehmen','<a href="index.php?as=turnier&type_id='.$type_id.'">weiter...</a>');
return; return;
} }
$sql = 'INSERT turnier1 SET charakter='.$charid.', besitzer='.$user['id'].', art = \''.$art.'\''; $sql = 'INSERT tournament_registration SET charakter='.$charid.', besitzer='.$user['id'].', type = '.$type_id;
// echo $sql; // echo $sql;
db_query($sql); db_query($sql);
db_query('UPDATE chars SET status=\'Turnier\' WHERE id='.$charid); db_query('UPDATE chars SET status=\'Turnier\' WHERE id='.$charid);
db_query('UPDATE user SET geld= '.($user['geld']-$fee).' WHERE id='.$user['id']); db_query('UPDATE user SET geld= '.($user['geld']-$fee).' WHERE id='.$user['id']);
displayErrorMessage('&Auml;nderungen &uuml;bernommen','Charakter erfolgreich beim Turnier angemeldet','<a href="index.php?as=turnier&art='.$art.'">weiter...</a>'); displayErrorMessage('&Auml;nderungen &uuml;bernommen','Charakter erfolgreich beim Turnier angemeldet','<a href="index.php?as=turnier&type_id='.$type_id.'">weiter...</a>');
return; return;
} }
function abmelden($user_ida, $char_id, $art){ function abmelden($user_ida, $char_id, $type_id){
db_query('DELETE FROM turnier1 WHERE charakter=\''.$char_id.'\' AND besitzer=\''.$user_ida['id'].'\''); db_query('DELETE FROM tournament_registration WHERE charakter=\''.$char_id.'\' AND besitzer=\''.$user_ida['id'].'\'');
db_query('UPDATE chars SET status=\'Frei\' WHERE id=\''.$char_id.'\' AND besitzer=\''.$user_ida['id'].'\' AND status=\'Turnier\' LIMIT 1'); db_query('UPDATE chars SET status=\'Frei\' WHERE id=\''.$char_id.'\' AND besitzer=\''.$user_ida['id'].'\' AND status=\'Turnier\' LIMIT 1');
displayErrorMessage('&Auml;nderungen &uuml;bernommen','Charakter erfolgreich beim Turnier abgemeldet','<a href="index.php?as=turnier&art='.$art.'">weiter...</a>'); displayErrorMessage('&Auml;nderungen &uuml;bernommen','Charakter erfolgreich beim Turnier abgemeldet','<a href="index.php?as=turnier&type_id='.$type_id.'">weiter...</a>');
return; return;
} }
function displayDefault($user, $art){ function displayDefault($user, $type_id){
$tournament_type = getTournamentType($type_id);
$filter_sql = getTournamentCharExclusionSQL($tournament_type);
if($art == 'klein'){
$turniername = 'Anf&auml;nger';
$races = getSpecialRaceIds();
$special_race_ids = array();
foreach($races as $race) {
$special_race_ids[] = '\''.$race['id'].'\'';
}
// Char darf max lvl 25 haben und keine Fusion sein und auch keine Teufelsfrucht gegessen haben
$special_clue = ' AND level<=25 AND fusion_rasse = \'0\' AND rasse NOT IN ('.implode(',',$special_race_ids).') AND frucht is null';
$fee = (TURNIER_ANFAENGER_GEBUEHR=='TURNIER_ANFAENGER_GEBUEHR')?0:TURNIER_ANFAENGER_GEBUEHR;
} else if($art == 'wochen'){
$turniername = 'Wochen';
$fee = (TURNIER_WOCHEN_GEBUEHR=='TURNIER_WOCHEN_GEBUEHR')?0:TURNIER_WOCHEN_GEBUEHR;
} else if($art == 'wochenst') {
$turniername = 'Wochen non-fusion';
$fee = (TURNIER_WOCHENST_GEBUEHR=='TURNIER_WOCHENST_GEBUEHR')?0:TURNIER_WOCHENST_GEBUEHR;
} else {
displayErrorMessage(NULL,'Anzeigefehler!!','<a href="index.php">weiter...</a>');
return;
}
// sehr speziell und deswegen nicht getChar(); // sehr speziell und deswegen nicht getChar();
$sql = 'SELECT id, name FROM chars WHERE besitzer='.$user['id'].$special_clue; $sql = 'SELECT id, name FROM chars WHERE besitzer='.$user['id'].' AND '.$filter_sql;
$char = db_query($sql); $char = db_query($sql);
if(!$char) if(!$char)
echo $sql; echo $sql;
@ -148,16 +107,16 @@ else document.forms[0].elements['submit'].disabled=true;
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get"> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
<input type="hidden" name="as" value="turnier"> <input type="hidden" name="as" value="turnier">
<input type="hidden" name="charm" value="1"> <input type="hidden" name="charm" value="1">
<input type="hidden" name="art" value="<?php echo $art; ?>"> <input type="hidden" name="type_id" value="<?php echo $type_id; ?>">
<table cellpadding="0" cellspacing="0" width="100%" height="25"> <table cellpadding="0" cellspacing="0" width="100%" height="25">
<!-- MSTableType="layout" --> <!-- MSTableType="layout" -->
<tr> <tr>
<th colspan="2" align="center"><?php echo $turniername; ?>-Turnier Anmeldung</th> <th colspan="2" align="center"><?php echo $tournament_type['name']; ?> Anmeldung</th>
</tr> </tr>
<tr> <tr>
<th align="center">Anmeldegeb&uuml;hr</th> <th align="center">Anmeldegeb&uuml;hr</th>
<td valign="top"> <td valign="top">
<?php echo $fee;?> <?php echo $tournament_type['entrance_fee'];?>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -182,7 +141,7 @@ while($row = mysqli_fetch_assoc($char)) {
</tr> </tr>
</table><hr id="hrc"> </table><hr id="hrc">
<?php <?php
$char_ag = db_query('SELECT c.id as charid, c.name, t.charakter, u.nickname, u.id as userid FROM turnier1 t LEFT JOIN chars c ON(t.charakter=c.id) LEFT JOIN user u ON(t.besitzer=u.id) WHERE t.art=\''.$art.'\''); $char_ag = db_query('SELECT c.id as charid, c.name, t.charakter, u.nickname, u.id as userid FROM tournament_registration t LEFT JOIN chars c ON(t.charakter=c.id) LEFT JOIN user u ON(t.besitzer=u.id) WHERE t.type='.$type_id);
?> ?>
<table cellpadding="0" cellspacing="0" width="388" height="0"> <table cellpadding="0" cellspacing="0" width="388" height="0">
<!-- MSTableType="layout" --> <!-- MSTableType="layout" -->
@ -198,7 +157,7 @@ $char_ag = db_query('SELECT c.id as charid, c.name, t.charakter, u.nickname, u.i
<?php <?php
while($row2 = mysqli_fetch_assoc($char_ag)) { while($row2 = mysqli_fetch_assoc($char_ag)) {
if($row2['userid'] == $user['id']) { if($row2['userid'] == $user['id']) {
$alo = '<a href="index.php?as=turnier&charm=2&char_id='.$row2['charakter'].'&art='.$art.'">Abmelden</a>'; $alo = '<a href="index.php?as=turnier&charm=2&char_id='.$row2['charakter'].'&type_id='.$type_id.'">Abmelden</a>';
} else { } else {
$alo = '&nbsp;'; $alo = '&nbsp;';
} }
@ -216,11 +175,11 @@ while($row2 = mysqli_fetch_assoc($char_ag)) {
} }
if($charm == 1){ if($charm == 1){
anmelden($user_ida,$char_id,$art); anmelden($user_ida,$char_id,$type_id);
} else if($charm == 2){ } else if($charm == 2){
abmelden($user_ida, $char_id,$art); abmelden($user_ida, $char_id,$type_id);
} else{ } else{
displayDefault($user_ida, $art); displayDefault($user_ida, $type_id);
} }

@ -31,7 +31,7 @@ function displaySomething($event_id, $id, $new_max_turnier, $char_nic1, $char_ni
// GET-Section // GET-Section
// Kritisch (SQL-Injections) // Kritisch (SQL-Injections)
$art = validateStringCritical($_GET['art']); $type_id = validateUnsignedInteger($_GET['type_id']);
$id = validateUnsignedInteger($_GET['id']); $id = validateUnsignedInteger($_GET['id']);
// Unkritisch // Unkritisch
@ -40,9 +40,9 @@ $charm = $_GET['charm'];
$turnier_daten = NULL; $turnier_daten = NULL;
if (is_numeric($id)) { if (is_numeric($id)) {
$turnier_daten = mysqli_fetch_assoc(db_query('SELECT * from turniere WHERE id = "'.$id.'"')); $turnier_daten = mysqli_fetch_assoc(db_query('SELECT * from tournament WHERE id = "'.$id.'"'));
} else { } else {
$turnier_daten = mysqli_fetch_assoc(db_query('SELECT * from turniere WHERE art = "'.$art.'" ORDER BY datum DESC LIMIT 1')); $turnier_daten = mysqli_fetch_assoc(db_query('SELECT * from tournament WHERE type = "'.$type_id.'" ORDER BY datum DESC LIMIT 1'));
} }
if(!$turnier_daten) { if(!$turnier_daten) {
@ -56,15 +56,13 @@ else if($charm == 1) {
echo '<link rel="stylesheet" type="text/css" href="design/style3.css">'; echo '<link rel="stylesheet" type="text/css" href="design/style3.css">';
$turnier_date = $turnier_daten['datum']; $turnier_date = $turnier_daten['datum'];
$turnier_info = db_query('SELECT win, char1, char2, id, round, dauer FROM turnier_kampf WHERE art=\''.$art.'\' ORDER BY id ASC');
$u=0; $u=0;
$pl = 300;
$eventChars = array(); $eventChars = array();
$char_nick1 = array(); $char_nick1 = array();
$char_nick2 = array(); $char_nick2 = array();
$char_nic1[] = array(); $char_nic1 = array();
$char_nic2[] = array(); $char_nic2 = array();
$char1 = array(); $char1 = array();
$char2 = array(); $char2 = array();
$win = array(); $win = array();
@ -105,7 +103,7 @@ else if($charm == 1) {
$char_nick1[]=$char_info1['char_name']; $char_nick1[]=$char_info1['char_name'];
$char_nick2[]=$char_info2['char_name']; $char_nick2[]=$char_info2['char_name'];
$char1[]=$char_info1['event_char_id']; $char1[]=$char_info1['event_char_id'];
$char2[]=$char_info1['event_char_id']; $char2[]=$char_info2['event_char_id'];
$win[]=$event_fight['winner']; $win[]=$event_fight['winner'];
$round[]=getEventFightMetaData($event_id, $event_fight_id)['round']; $round[]=getEventFightMetaData($event_id, $event_fight_id)['round'];

@ -5,11 +5,16 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public Licence * @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/tournament.inc.php');
?> ?>
<SCRIPT language="JavaScript"> <SCRIPT language="JavaScript">
function kampf(art){ function kampf(type_id){
window.open("./turnier2.php?charm=1&art="+art,"","status=no,hotkeys=no,Height=600,Width=929,scrollbars=yes"); window.open("./turnier2.php?charm=1&type_id="+type_id,"","status=no,hotkeys=no,Height=600,Width=929,scrollbars=yes");
} }
</SCRIPT> </SCRIPT>
@ -18,38 +23,21 @@
<tr> <tr>
<th valign="top" colspan="3" align="center">Turnier Auswahl</th> <th valign="top" colspan="3" align="center">Turnier Auswahl</th>
</tr> </tr>
<?php
$tournament_types = getTournamentTypes();
foreach ($tournament_types as $tournament_type) {
?>
<tr> <tr>
<td valign="top" align="center"> <td valign="top" align="center">
<a href='javascript:kampf("woche");'> <a href='javascript:kampf("<?php echo $tournament_type['id']; ?>");'>
<img border="0" src="design/bilder/buttons/wt-turnier.jpg" title="Das Turnier ist einmal die Woche, Sonntags um 15 Uhr. (64 Spieler)" width="150" height="150" /> <img border="0" src="<?php echo $tournament_type['icon']; ?>" title="Das Turnier ist einmal die Woche, Sonntags um 15 Uhr. (64 Spieler)" width="150" height="150" />
</a>
</td>
<td>&nbsp;</td>
<td valign="top" align="center">
<a href='javascript:kampf("wochenst");'>
<img border="0" src="design/bilder/buttons/wts-turnier.jpg" title="Das Turnier ist einmal die Woche, Samstags um 15 Uhr. (64 Spieler ohne Fusionen)" width="150" height="150" />
</a>
</td>
</tr>
<tr>
<td colspan="3" valign="top" align="center">
<a href='javascript:kampf("klein");'>
<img border="0" src="design/bilder/buttons/af-turnier.jpg" title="Das Anf&auml;nger Turnier ist einmal die Woche, Freitags um 15 Uhr. (32 Spieler)" width="150" height="150" />
</a>
</td>
</tr>
<tr>
<td align="center">
<a href='javascript:kampf("gross");'>
<img border="0" src="design/bilder/buttons/WT-turnier.jpg" title="Das Welt Turnier ist immer am ersten Tag des Monats um 21 Uhr (Maximal 512 Spieler)" width="150" height="150" />
</a>
</td>
<td>&nbsp;</td>
<td valign="top" align="center">
<a href='javascript:kampf("grossst");'>
<img border="0" src="design/bilder/buttons/WTs-turnier.jpg" title="Das Turnier ist immer am 15. Tag des Monats um 21 Uhr, (Maximal 512 Spieler ohne Fusionen)" width="150" height="150" />
</a> </a>
</td> </td>
<td align="center">Hier kommt noch info hin (to be programmed)</td>
</tr> </tr>
<?php
}
?>
</table> </table>

Loading…
Cancel
Save