NPC-Attacken können nun eingestellt werden.

Ein paar Sicherheitsprüfungen bei Funktionen was Attackenset angeht eingebaut.
main
radiskull 13 years ago
parent 2978ec551c
commit ba60bdcdf0

@ -245,7 +245,7 @@ if(checkLoginData($_SESSION['user'],$_SESSION['password'])){
} else if($_REQUEST['choose'] == 'cheat'){ } else if($_REQUEST['choose'] == 'cheat'){
displayCheater($_REQUEST['action'], $_REQUEST['from'], $_REQUEST['until'], $_REQUEST['user1'], $_REQUEST['user2'], $_REQUEST['tradeid'], $_REQUEST['verify']); displayCheater($_REQUEST['action'], $_REQUEST['from'], $_REQUEST['until'], $_REQUEST['user1'], $_REQUEST['user2'], $_REQUEST['tradeid'], $_REQUEST['verify']);
} else if($_REQUEST['choose'] == 'npc'){ } else if($_REQUEST['choose'] == 'npc'){
displayNPC($_REQUEST['action'], $_REQUEST['task'], $_REQUEST['charid'], $_REQUEST['table'], $_REQUEST['page'], $_REQUEST['data']); displayNPC($_REQUEST['action'], $_REQUEST['task'], $_REQUEST['charid'], $_REQUEST['table'], $_REQUEST['page'], $_REQUEST['data'], $_REQUEST['att_ids']);
} else if($_REQUEST['choose'] == 'shop'){ } else if($_REQUEST['choose'] == 'shop'){
displayShop($_REQUEST['action'], $_REQUEST['s_id'],$_REQUEST['info'], $_REQUEST['s_name'] , $_REQUEST['s2_name'], $_REQUEST['s3_name'], $_REQUEST['s_typ'], $_REQUEST['preis'], $_REQUEST['frei'], $_REQUEST['anzahl']); displayShop($_REQUEST['action'], $_REQUEST['s_id'],$_REQUEST['info'], $_REQUEST['s_name'] , $_REQUEST['s2_name'], $_REQUEST['s3_name'], $_REQUEST['s_typ'], $_REQUEST['preis'], $_REQUEST['frei'], $_REQUEST['anzahl']);
} else if($_REQUEST['choose'] == 'usergroups'){ } else if($_REQUEST['choose'] == 'usergroups'){

@ -9,144 +9,272 @@
?> ?>
<?php <?php
function displayNPC($action, $task, $charid, $table, $page, $data){ include_once($_SERVER['DOCUMENT_ROOT'].'ag/include/attackenset.inc.php');
echo '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">'."\n";
echo "\t".'<input type="hidden" name="choose" value="npc"></input>'."\n";
echo "\t".'<input type="hidden" name="charid" value="'.$charid.'"></input>'."\n";
echo "\t".'<table width="80%">'."\n";
if($action == 'edit'){
echo "\t".'<input type="hidden" name="action" value="edit"></input>'."\n";
if($task == 'dochange') {
$d_array = array('name', 'type', 'hp', 'mp', 'starke', 'verteidigung', 'speed',
'ausdauer', 'glueck', 'level', 'bild');
$sql = 'UPDATE chars c INNER JOIN kampf_list kl ON c.id=kl.charakter SET c.'; function getNPCAttacks() {
$sql .= $d_array[0].' = \''.encodeNoHTMLWithBB($data[$d_array[0]]).'\''; $qry = mysql_query('SELECT name,id FROM attacken a WHERE info like "%NPC%";');
$set = array();
for($i=1;$i<count($d_array);$i++){ while ($result = mysql_fetch_assoc($qry)) {
$sql .= ', c.'.$d_array[$i].' = \''.encodeNoHTMLWithBB($data[$d_array[$i]]).'\''; $set[$result['id']] = $result['name'];
} }
$d_array = array('zeit_rec', 'lvlmin', 'lvlmax'); return $set;
for($i=0;$i<count($d_array);$i++){ }
$sql .= ', kl.'. $d_array[$i].' = \''.encodeNoHTMLWithBB($data[$d_array[$i]]).'\'';
}
$sql .= ' WHERE c.id=\''.$charid.'\''; function learnNewAttacks($charid, $att_ids) {
//echo $sql.'<br>'; //auslesen der gelernten Attacken
$u = mysql_query($sql); $sql = 'SELECT at_id, id FROM lernen WHERE besitzer = '.$charid.' AND at_id in ('.implode(',', $att_ids).');';
if(mysql_affected_rows() == 0 || $u2 === FALSE) { $qry = mysql_query($sql);
echo "\t\t\t".'<tr><td colspan="2" style="color:red">Fehler! Änderungen konnten nicht übernommen werden!</td></tr>';
} else{ $learned_atts = array();
logaction('Ein NPC wurde geändert (id = '.$charid.','.encodeNoHTMLWithBB(join($data,',')).')'); while($result = mysql_fetch_assoc($qry)) {
echo "\t\t\t".'<tr><td colspan="2">Änderungen wurden übernommen!</td></tr>'; $learned_atts[$result['at_id']] = $result['id'];
} }
displayNPC($action, null, $charid, $table, $page, $data);
//Namen der Attacken auslesen
$sql = 'SELECT id,name FROM attacken WHERE id in ('.implode(',', $att_ids).');';
$qry = mysql_query($sql);
$att_names = array();
while($result = mysql_fetch_assoc($qry)) {
$att_names[$result['id']] = $result['name'];
}
foreach ($att_ids as $att) {
if($learned_atts[$att] == NULL) {
/*
* Keine Gute Lösung, es wird zwar von der db verhindert, dass doppelte Einträge gespeichert werden
* aber ungebrauchte Attacken werden so auch nicht gelöscht (höchstens der NPC wird gelöscht)
*/
mysql_query('INSERT INTO lernen(name,at_id,besitzer,aktiv) VALUES(\''.$att_names[$att].'\','.$att.','.$charid.',1);');
}
}
}
function getAttackSet($charid, $att_ids) {
$sql = 'SELECT at_id, id FROM lernen WHERE besitzer = '.$charid.' AND at_id in ('.implode(',', $att_ids).');';
$qry = mysql_query($sql);
$learned_atts = array();
while($result = mysql_fetch_assoc($qry)) {
$learned_atts[$result['at_id']] = $result['id'];
}
$attset = array();
$i = 1;
foreach ($att_ids as $att) {
if($learned_atts[$att] != NULL) {
$attset[$i] = $learned_atts[$att];
} else { } else {
echo "\t".'<input type="hidden" name="task" value="dochange"></input>'."\n"; $attset[$i] = $att;
$d_select_array = array(array('Dragonball', 'Onepiece'), array(300, 1200, 3600)); }
$d_array = array('charakter', 'name', 'type', 'hp', 'mp', 'starke', 'verteidigung', 'speed', $i++;
}
return $attset;
}
function buildAttackSet($charid, $att_ids) {
learnNewAttacks($charid, $att_ids);
return getAttackSet($charid, $att_ids);
}
function displayEditNPC($charid) {
echo "\t".'<input type="hidden" name="action" value="edit"></input>'."\n";
echo "\t".'<input type="hidden" name="task" value="dochange"></input>'."\n";
$d_select_array = array(array('Dragonball', 'Onepiece'), array(300, 1200, 3600));
$d_array = array('charakter', 'name', 'type', 'hp', 'mp', 'starke', 'verteidigung', 'speed',
'ausdauer', 'glueck', 'zeit_rec', 'level', 'lvlmin', 'lvlmax', 'bild'); 'ausdauer', 'glueck', 'zeit_rec', 'level', 'lvlmin', 'lvlmax', 'bild');
$desc_select_array = array(array('Dragonball', 'Onepiece'), array('5min', '20min', '60min')); $desc_select_array = array(array('Dragonball', 'Onepiece'), array('5min', '20min', '60min'));
$desc_array = array('ID', 'Name', 'Type', 'HP', 'MP', 'Stärke', 'Verteidigung', 'Geschwindigkeit', $desc_array = array('ID', 'Name', 'Type', 'HP', 'MP', 'Stärke', 'Verteidigung', 'Geschwindigkeit',
'Ausdauer', 'Glück', 'Kampfdauer in Sekunden', 'Level', 'Min-Level', 'Max-Level', 'Bild'); 'Ausdauer', 'Glück', 'Kampfdauer in Sekunden', 'Level', 'Min-Level', 'Max-Level', 'Bild');
$attset = getCharAttackSet($charid, NORMALKAMPF);
$attset_names = getAttackNamesFromAttackSet($attset);
$attacks = getNPCAttacks();
$sql = 'SELECT * FROM chars c inner join npc_item ni on ni.charakter = c.id inner join kampf_list kl on ni.charakter = kl.charakter WHERE c.id ='.$charid;
$qry = mysql_query($sql);
$row = mysql_fetch_assoc($qry);
$colspan = 2;
$sql = 'SELECT * FROM chars c inner join npc_item ni on ni.charakter = c.id inner join kampf_list kl on ni.charakter = kl.charakter WHERE c.id ='.$charid; echo "\t".'<tr><td colspan="'.$colspan.'"><h1 style="text-align:center">NPC bearbeiten</h1></td></tr>'."\n";
$qry = mysql_query($sql); echo "\t\t".'<tr><td>'.$desc_array[0].'</td><td style="text-align:center">'.$row[$d_array[0]].'</td></tr>'."\n";
$row = mysql_fetch_assoc($qry); $j = 0;
$colspan = 2; //allgemeine informationen
for($i = 1;$i<count($d_array);$i++){
echo "\t".'<tr><td colspan="'.$colspan.'"><h1 style="text-align:center">NPC bearbeiten</h1></td></tr>'."\n"; if($i == 2 || $i == 10) {
echo "\t\t".'<tr><td>'.$desc_array[0].'</td><td style="text-align:center">'.$row[$d_array[0]].'</td></tr>'."\n"; echo "\t\t".'<tr><td>'.$desc_array[$i].'</td><td style="text-align:center"><select id="input" name="data['.$d_array[$i].']">';
$j = 0; for($k = 0; $k < count($d_select_array[$j]); $k++) {
for($i = 1;$i<count($d_array);$i++){ echo "<option value=\"".$d_select_array[$j][$k]."\" ";
if($i == 2 || $i == 10) { if($d_select_array[$j][$k] == debbcode($row[$d_array[$i]])) {
echo "\t\t".'<tr><td>'.$desc_array[$i].'</td><td style="text-align:center"><select id="input" name="data['.$d_array[$i].']">'; echo " selected";
for($k = 0; $k < count($d_select_array[$j]); $k++) {
echo "<option value=\"".$d_select_array[$j][$k]."\" ";
if($d_select_array[$j][$k] == debbcode($row[$d_array[$i]])) {
echo " selected";
}
echo ">".$desc_select_array[$j][$k]."</option>";
}
echo '</select></td></tr>'."\n";
$j++;
} else {
echo "\t\t".'<tr><td>'.$desc_array[$i].'</td><td style="text-align:center"><input name="data['.$d_array[$i].']" value="'.debbcode($row[$d_array[$i]]).'"></input></td></tr>'."\n";
} }
echo ">".$desc_select_array[$j][$k]."</option>";
} }
echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center"><input type="submit" value="speichern"></td></tr>'."\n"; echo '</select></td></tr>'."\n";
echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center"><a href="'.$_SERVER['PHP_SELF'].'?choose=npc">NPC Übersicht</a></td></tr>'."\n"; $j++;
} else {
echo "\t\t".'<tr><td>'.$desc_array[$i].'</td><td style="text-align:center"><input name="data['.$d_array[$i].']" value="'.debbcode($row[$d_array[$i]]).'"></input></td></tr>'."\n";
} }
} else if($action == 'create'){ }
$colspan = 1;
echo "\t".'<tr><td colspan="'.$colspan.'"><h1 style="text-align:center">NPC erstellen</h1></td></tr>'."\n";;
echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center"><a href="'.$_SERVER['PHP_SELF'].'?choose=npc">NPC Übersicht</a></td></tr>'."\n"; //attacken informationen
} else if($action == 'delete'){ echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center">Attacken bearbeiten</td></tr>'."\n";
$colspan = 1; for($i = 1;$i<11;$i++){
echo "\t\t".'<tr><td>Runde '.$i.'</td><td style="text-align:center"><select id="input" name="att_ids['.$i.']">';
$sql = 'SELECT * FROM chars WHERE id = '.$charid; echo "<option value=\"".$attset[$i]."\" selected> ".$attset_names[$attset[$i]]."</option>";
$qry = mysql_query($sql); foreach($attacks as $key => $value) {
$row = mysql_fetch_assoc($qry); echo "<option value=\"".$key."\"> ".$value."</option>";
echo "\t".'<tr><td colspan="'.$colspan.'"><h1 style="text-align:center">NPC löschen</h1></td></tr>'."\n";;
if(is_null($task)){
echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center">Soll der NPC '.$row['name'].' wirklich gelöscht werden</td></tr>'."\n";;
echo "\t".'<tr><td style="text-align:center"><a href="'.$_SERVER['PHP_SELF'].'?choose=npc&action=delete&task=do&charid='.$charid.'">ja</a>, <a href="'.$_SERVER['PHP_SELF'].'?choose=npc&action=">nein</a>, <a href="'.$_SERVER['PHP_SELF'].'?choose=npc&action=delete&charid='.$charid.'">vielleicht</a></td></tr>'."\n";
} else {
$sql = 'DELETE c,ni,kl,l FROM chars c inner join npc_item ni on ni.charakter = c.id inner join kampf_list kl on ni.charakter = kl.charakter inner join lernen l on l.besitzer = c.id where c.id = '.$charid;
// echo $sql.'<br>';
$qry = mysql_query($sql);
if($qry === FALSE || mysql_affected_rows() <= 0){
echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center;color:red">Der NPC '.$row['name'].' konnte nicht gelöscht werden!</td></tr>'."\n";;
} else {
echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center">Der NPC '.$row['name'].' wurde gelöscht!</td></tr>'."\n";;
}
// SELECT * FROM chars c inner join npc_item ni on ni.charakter = c.id inner join kampf_list kl on ni.charakter = kl.charakter
} }
echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center"><a href="'.$_SERVER['PHP_SELF'].'?choose=npc">NPC Übersicht</a></td></tr>'."\n"; echo '</select></td></tr>'."\n";
}
echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center"><input type="submit" value="speichern"></td></tr>'."\n";
echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center"><a href="'.$_SERVER['PHP_SELF'].'?choose=npc">NPC Übersicht</a></td></tr>'."\n";
}
function editNPC($charid, $data, $att_ids) {
$attset = buildAttackSet($charid, $att_ids);
$error = validateAttackSetTypes($attset);
$d_array = array('name', 'type', 'hp', 'mp', 'starke', 'verteidigung', 'speed',
'ausdauer', 'glueck', 'level', 'bild');
$sql = 'UPDATE chars c INNER JOIN kampf_list kl ON c.id=kl.charakter SET c.';
$sql .= $d_array[0].' = \''.encodeNoHTMLWithBB($data[$d_array[0]]).'\'';
for($i=1;$i<count($d_array);$i++){
$sql .= ', c.'.$d_array[$i].' = \''.encodeNoHTMLWithBB($data[$d_array[$i]]).'\'';
}
$d_array = array('zeit_rec', 'lvlmin', 'lvlmax');
for($i=0;$i<count($d_array);$i++){
$sql .= ', kl.'. $d_array[$i].' = \''.encodeNoHTMLWithBB($data[$d_array[$i]]).'\'';
}
$sql .= ' WHERE c.id=\''.$charid.'\'';
$u = mysql_query($sql);
$log = 0;
if(mysql_affected_rows() == 0 || $u === FALSE) {
echo "\t\t\t".'<tr><td colspan="2" style="color:red">Stats wurden nicht geändert oder es gab Fehler!</td></tr>';
} else{ } else{
$d_array = array('id', 'name', 'level'); echo "\t\t\t".'<tr><td colspan="2">Änderungen wurden übernommen!</td></tr>';
$desc_array = array('id', 'Name', 'Level'); $log++;
}
$sql = 'SELECT '.join($d_array,',').' from chars where rasse = \'NPC\' ORDER BY level';
$qry = mysql_query($sql.' LIMIT '.($page*20).', 20'); if($error == NULL) {
$anzahlSeiten = ceil(mysql_num_rows(mysql_query($sql))/20); updateCharAttackSet($charid, $attset, NORMALKAMPF);
$colspan = count($d_array); //alter müll
echo "\t".'<tr><td colspan="'.$colspan.'"><h1 style="text-align:center">Übersicht</h1></td></tr>'."\n";; $qry = 'UPDATE chars SET attacken=\''.implode(',', $attset).'\', '.
'attacken2=\''.implode(',', $attset).'\' WHERE id='.$charid.' LIMIT 1';
mysql_query($qry);
$log++;
echo "\t\t\t".'<tr><td colspan="2">Attacken übernommen!</td></tr>';
} else {
echo "\t\t\t".'<tr><td colspan="2" style="color:red">'.$error.'</td></tr>';
}
if($log >= 1) {
logaction('Ein NPC wurde geändert (id = '.$charid.','.encodeNoHTMLWithBB(join($data,',')).')');
}
}
function displayCreateNPC() {
$colspan = 1;
echo "\t".'<tr><td colspan="'.$colspan.'"><h1 style="text-align:center">NPC erstellen</h1></td></tr>'."\n";;
echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center"><a href="'.$_SERVER['PHP_SELF'].'?choose=npc">NPC Übersicht</a></td></tr>'."\n";
}
function displayDeleteNPC($charid) {
$colspan = 1;
$sql = 'SELECT * FROM chars WHERE id = '.$charid;
$qry = mysql_query($sql);
$row = mysql_fetch_assoc($qry);
echo "\t".'<tr><td colspan="'.$colspan.'"><h1 style="text-align:center">NPC löschen</h1></td></tr>'."\n";
echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center">Soll der NPC '.$row['name'].' wirklich gelöscht werden</td></tr>'."\n";
echo "\t".'<tr><td style="text-align:center"><a href="'.$_SERVER['PHP_SELF'].'?choose=npc&action=delete&task=dodelete&charid='.$charid.'">ja</a>, <a href="'.$_SERVER['PHP_SELF'].'?choose=npc&action=">nein</a></td></tr>'."\n";
}
function deleteNPC($charid) {
$colspan = 1;
$sql = 'DELETE FROM chars WHERE id = '.$charid.';';
$qry = mysql_query($sql);
if($qry === FALSE || mysql_affected_rows() <= 0){
echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center;color:red">Der NPC '.$row['name'].' konnte nicht gelöscht werden!</td></tr>'."\n";;
} else {
echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center">Der NPC '.$row['name'].' wurde gelöscht!</td></tr>'."\n";;
}
echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center"><a href="'.$_SERVER['PHP_SELF'].'?choose=npc">NPC Übersicht</a></td></tr>'."\n";
}
function displayNPCOverview() {
$d_array = array('id', 'name', 'level');
$desc_array = array('id', 'Name', 'Level');
$sql = 'SELECT '.join($d_array,',').' from chars where rasse = \'NPC\' ORDER BY level';
$qry = mysql_query($sql.' LIMIT '.($page*20).', 20');
$anzahlSeiten = ceil(mysql_num_rows(mysql_query($sql))/20);
$colspan = count($d_array);
echo "\t".'<tr><td colspan="'.$colspan.'"><h1 style="text-align:center">Übersicht</h1></td></tr>'."\n";;
echo "\t".'<tr>'."\n";
for($i=1;$i<count($d_array);$i++){
echo "\t\t".'<td>'.$desc_array[$i].'</td>'."\n";
}
echo "\t\t".'<td style="text-align:center">Bearbeiten</td>'."\n";
echo "\t".'</tr>'."\n";
echo "\t".'<tr><td colspan="'.$colspan.'"><hr></td></tr>'."\n";
while($row = mysql_fetch_assoc($qry)){
echo "\t".'<tr>'."\n"; echo "\t".'<tr>'."\n";
for($i=1;$i<count($d_array);$i++){ for($i=1;$i<count($d_array);$i++){
echo "\t\t".'<td>'.$desc_array[$i].'</td>'."\n"; echo "\t\t".'<td>'.$row[$d_array[$i]].'</td>'."\n";
} }
echo "\t\t".'<td style="text-align:center">Bearbeiten</td>'."\n";
echo "\t".'</tr>'."\n";
echo "\t".'<tr><td colspan="'.$colspan.'"><hr></td></tr>'."\n"; echo "\t\t".'<td style="text-align:center">'."\n";
while($row = mysql_fetch_assoc($qry)){ // Echo the delete and the edit button :)
echo "\t".'<tr>'."\n"; echo "\t\t\t".'<a href="'.$_SERVER['PHP_SELF'].'?choose=npc&action=edit&charid='.$row[$d_array[0]].'">Edit</a>, '."\n";
for($i=1;$i<count($d_array);$i++){ echo "\t\t\t".'<a href="'.$_SERVER['PHP_SELF'].'?choose=npc&action=delete&charid='.$row[$d_array[0]].'">Delete</a>'."\n";
echo "\t\t".'<td>'.$row[$d_array[$i]].'</td>'."\n";
}
echo "\t\t".'<td style="text-align:center">'."\n"; echo "\t\t".'</td>'."\n";
echo "\t".'</tr>'."\n";
// Echo the delete and the edit button :) }
echo "\t\t\t".'<a href="'.$_SERVER['PHP_SELF'].'?choose=npc&action=edit&charid='.$row[$d_array[0]].'">Edit</a>, '."\n";
echo "\t\t\t".'<a href="'.$_SERVER['PHP_SELF'].'?choose=npc&action=delete&charid='.$row[$d_array[0]].'">Delete</a>'."\n";
echo "\t\t".'</td>'."\n"; echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center"><a href="'.$_SERVER['PHP_SELF'].'?choose=npc&action=create">Create a new NPC</a></td></tr>'."\n";
echo "\t".'</tr>'."\n"; echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center"><hr></td></tr>'."\n";
}
function displayNPC($action, $task, $charid, $table, $page, $data, $att_ids){
$colspan = 3;
echo '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">'."\n";
echo "\t".'<input type="hidden" name="choose" value="npc"></input>'."\n";
echo "\t".'<input type="hidden" name="charid" value="'.$charid.'"></input>'."\n";
echo "\t".'<table width="80%" border="0">'."\n";
if($action == 'edit'){
echo "\t".'<input type="hidden" name="action" value="edit"></input>'."\n";
if($task == 'dochange') {
editNPC($charid, $data, $att_ids);
displayEditNPC($charid);
} else {
displayEditNPC($charid);
} }
} else if($action == 'create'){
echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center"><a href="'.$_SERVER['PHP_SELF'].'?choose=npc&action=create">Create a new NPC</a></td></tr>'."\n"; displayCreateNPC();
echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center"><hr></td></tr>'."\n"; } else if($action == 'delete'){
if($task == 'dodelete') {
deleteNPC($charid);
} else {
displayDeleteNPC($charid);
}
} else{
displayNPCOverview();
} }
//TODO: ändern, dass man nicht 2x Zum Hauptmenü hat xD
echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center"><a href="'.$_SERVER['PHP_SELF'].'">Zum Hauptmenu</a></td></tr>'."\n"; echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center"><a href="'.$_SERVER['PHP_SELF'].'">Zum Hauptmenu</a></td></tr>'."\n";
echo "\t".'</table>'."\n"; echo "\t".'</table>'."\n";
echo '</form>'."\n"; echo '</form>'."\n";
} }
?> ?>

@ -85,8 +85,11 @@ function getAttackNamesFromAttackSet($attset) {
} }
function getAttackTypesFromAttackSet($attset) { function getAttackTypesFromAttackSet($attset) {
$qry = mysql_query('SELECT l.id,a.type FROM attacken a INNER JOIN lernen l ON a.id=l.at_id WHERE l.id in ('.implode(',', $attset).');'); if($attset == NULL || count($attset) == 0) {
return array();
}
$qry = mysql_query('SELECT l.id,a.type FROM attacken a INNER JOIN lernen l ON a.id=l.at_id WHERE l.id in ('.implode(',', $attset).');');
while ($result = mysql_fetch_assoc($qry)) { while ($result = mysql_fetch_assoc($qry)) {
$set[$result['id']] = $result['type']; $set[$result['id']] = $result['type'];
} }
@ -95,7 +98,15 @@ function getAttackTypesFromAttackSet($attset) {
} }
function validateAttackSetTypes($attset) { function validateAttackSetTypes($attset) {
if($attset == NULL) {
return 'Es wurden garkeine Attacken ausgewählt!';
}
$types = getAttackTypesFromAttackSet($attset); $types = getAttackTypesFromAttackSet($attset);
if(count($types)==0) {
return 'Es wurden garkeine Attacken ausgewählt!';
}
foreach ($attset as $att_id) { foreach ($attset as $att_id) {
if($types[$att_id] == "tausch") { $kampf_tausch_n++; if($types[$att_id] == "tausch") { $kampf_tausch_n++;
}elseif($types[$att_id] == "SSJ") { $kampf_ssj_n++; }elseif($types[$att_id] == "SSJ") { $kampf_ssj_n++;

Loading…
Cancel
Save