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.

459 lines
14 KiB

<?php
/*
* Created on 31.05.2011
*
* @copyright (c) 2011 animegame.eu
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public Licence
*
*/
?>
<?php
function displayAttackenMenu($action, $attackname, $attackid, $depth, $name, $starke, $verteidigung, $speed, $hp, $mp, $rassen, $level, $geld, $options, $type, $info, $req_atk, $req_lvl, $Frucht, $runden, $maxlvl) {
if($action === NULL){
?>
<table>
<tr>
<th>Attacken</th>
</tr>
<tr>
<td><a
href="<?php echo $_SERVER['PHP_SELF']; ?>?choose=attacken&action=create">Attacke
erstellen</a>
</td>
</tr>
<tr>
<td><a
href="<?php echo $_SERVER['PHP_SELF']; ?>?choose=attacken&action=edit">Attacke
editieren</a>
</td>
</tr>
<tr>
<td><a
href="<?php echo $_SERVER['PHP_SELF']; ?>?choose=attacken&action=delete">Attacke
l&ouml;schen</a>
</td>
</tr>
<tr>
<th>Attackenset-Conditions</th>
</tr>
<tr>
<td><a href="<?php echo $_SERVER['PHP_SELF']; ?>?choose=attacken">Condition
erstellen</a>
</td>
</tr>
<tr>
<td><a href="<?php echo $_SERVER['PHP_SELF']; ?>?choose=attacken">Condition
editieren</a>
</td>
</tr>
<tr>
<td><a href="<?php echo $_SERVER['PHP_SELF']; ?>?choose=attacken">Condition
l&ouml;schen</a>
</td>
</tr>
<tr>
<td><br>
</td>
</tr>
<tr>
<td><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Zum Hauptmenu</a><br>
</td>
</tr>
</table>
<?php
} else if(($action == 'delete' || $action == 'edit') && $attackname === NULL && $attackid === NULL){
searchfirstAttack($action);
} else if(($action == 'delete' || $action == 'edit') && $attackid === NULL){
searchsecondAttack($action, $attackname);
} else if(($action == 'create' || $action == 'edit') && $depth === NULL){
createOrEditAttack($action, $attackid);
} else if($action == 'create' && $depth == 1){
createAttack($attackname, $Frucht, $starke, $verteidigung, $speed, $hp, $mp, $rassen, $level, $geld, $options, $type, $info, $req_atk, $req_lvl, $runden, $maxlvl);
} else if($action == 'delete' && $depth >= 1){
deleteAttack($attackid, $depth);
} else if($action == 'edit' && $depth == 1){
editAttack($attackname, $attackid, $Frucht, $starke, $verteidigung, $speed, $hp, $mp, $rassen, $level, $geld, $options, $type, $info, $req_atk, $req_lvl, $runden, $maxlvl);
}
}
function searchfirstAttack($action) {
?>
<form action="" method="POST">
<input name="choose" value="attacken" type="hidden"></input> <input
name="action" value="<?php echo $action; ?>" type="hidden"></input>
<table>
<tr>
<th colspan="2">Attacke suchen</th>
</tr>
<tr>
<td><input name="attackname">
</td>
<td><input type="submit" name="suche">
</td>
</tr>
<tr>
<td><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Zum Hauptmenu</a><br>
</td>
</tr>
</table>
</form>
<?php
}
function searchsecondAttack($action, $attackname) {
$qry = mysql_query('Select name,id from attacken where name like \'%'.$attackname.'%\'');
?>
<form action="" method="POST">
<input name="choose" value="attacken" type="hidden"></input> <input
name="action" value="<?php echo $action; ?>" type="hidden"></input>
<?php if($action == 'delete'){ echo '<input name="depth" value="1" type="hidden"></input>'; }?>
<table>
<tr>
<th colspan="2">Attacke ausw&auml;hlen</th>
</tr>
<tr>
<td><select name="attackid">
<?php
while($row = mysql_fetch_assoc($qry)){
echo '<option value="'.$row['id'].'">'.$row['name'].'</option>\n';
}
?>
</select>
</td>
<td><input type="submit" name="ausw&auml;hlen">
</td>
</tr>
<tr>
<td><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Zum Hauptmenu</a><br>
</td>
</tr>
</table>
</form>
<?php
}
function createOrEditAttack($action, $attackid) {
if($action == 'edit'){
$row = mysql_fetch_assoc(mysql_query('Select * from attacken where id ='.$attackid));
}
//Alle attacken auslesen
$att_qry = mysql_query('SELECT id,name FROM attacken WHERE info not like \'%NPC%\' ORDER BY name');
$available_attacks = array();
while($attacks = mysql_fetch_assoc($att_qry)) {
$available_attacks[] = array($attacks['id'], $attacks['name']);
}
$used_attacks = explode(',', $row['req_atk']);
?>
<form action="" method="POST">
<input name="choose" value="attacken" type="hidden"></input> <input
name="action" value="<?php echo $action; ?>" type="hidden"></input> <input
name="attackid" value="<?php echo $attackid; ?>" type="hidden"></input>
<input name="depth" value="1" type="hidden"></input>
<table>
<tr>
<th colspan="2">Attacke</th>
</tr>
<tr>
<td>ID:</td>
<td><?php echo $attackid; ?>
</td>
</tr>
<tr>
<td>Name:</td>
<td><input name='attackname'
value='<?php echo $row['name']===NULL?'Attackenname':$row['name']; ?>'></input>
</td>
</tr>
<tr>
<td>St&auml;rke:</td>
<td><input name='starke'
value='<?php echo $row['starke']===NULL?0:$row['starke']; ?>'></input>
</td>
</tr>
<tr>
<td>Verteidigung:</td>
<td><input name='verteidigung'
value='<?php echo $row['verteidigung']===NULL?0:$row['verteidigung']; ?>'></input>
</td>
</tr>
<tr>
<td>Speed:</td>
<td><input name='speed'
value='<?php echo $row['speed']===NULL?0:$row['speed']; ?>'></input>
</td>
</tr>
<tr>
<td>HP:</td>
<td><input name='hp'
value='<?php echo $row['hp']===NULL?0:$row['hp']; ?>'></input>
</td>
</tr>
<tr>
<td>MP:</td>
<td><input name='mp'
value='<?php echo $row['mp']===NULL?0:$row['mp']; ?>'></input>
</td>
</tr>
<tr>
<td>Rassen:</td>
<td><input name='rassen'
value='<?php echo $row['rassen']===NULL?0:$row['rassen']; ?>'></input>
</td>
</tr>
<tr>
<td>Level:</td>
<td><input name='level'
value='<?php echo $row['level']===NULL?0:$row['level']; ?>'></input>
</td>
</tr>
<tr>
<td>Geld:</td>
<td><input name='geld'
value='<?php echo $row['geld']===NULL?0:$row['geld']; ?>'></input>
</td>
</tr>
<tr>
<td>Type:</td>
<td><select name="type">
<?php
$types = array('normal', 'kaioken', 'kaioken2', 'SSJ', 'lose', 'lose2', 'hpmp', 'hp', 'tausch', 'tausch2', 'majin', 'copy', 'runde', 'frucht', 'konterhp', 'generic');
foreach ($types as $type) {
if($row['type'] == $type){
echo '<option value="'.$type.'" selected="selected">'.$type.'</option>';
} else{
echo '<option value="'.$type.'">'.$type.'</option>';
}
}
?>
</select>
</td>
</tr>
<tr>
<td>Options:</td>
<td><input name='options'
value='<?php echo $row['options']===NULL?'{}':$row['options']; ?>'></input>
</td>
</tr>
<tr>
<td>Info:</td>
<td><input name='info'
value='<?php echo $row['info']===NULL?'No Info available yet!':$row['info']; ?>'></input>
</td>
</tr>
<tr>
<td>Required Attacks:</td>
<td><select name="req_atk[0]">
<?php
if($used_attacks[0] == 0){
echo '<option value="0" selected="selected">-Keine-</option>';
} else {
echo '<option value="0">-Keine-</option>';
}
foreach ($available_attacks as $attack) {
if($attack[0] == $used_attacks[0]){
echo '<option value="'.$attack[0].'" selected="selected">'.$attack[1].'</option>';
} else{
echo '<option value="'.$attack[0].'">'.$attack[1].'</option>';
}
}
?>
</select>
</td>
</tr>
<tr>
<td></td>
<td><select name="req_atk[1]">
<?php
if($used_attacks[1] == 0){
echo '<option value="0" selected="selected">-Keine-</option>';
} else {
echo '<option value="0">-Keine-</option>';
}
foreach ($available_attacks as $attack) {
if($attack[0] == $used_attacks[1]){
echo '<option value="'.$attack[0].'" selected="selected">'.$attack[1].'</option>';
} else{
echo '<option value="'.$attack[0].'">'.$attack[1].'</option>';
}
}
?>
</select>
</td>
</tr>
<tr>
<td></td>
<td><select name="req_atk[2]">
<?php
if($used_attacks[2] == 0){
echo '<option value="0" selected="selected">-Keine-</option>';
} else {
echo '<option value="0">-Keine-</option>';
}
foreach ($available_attacks as $attack) {
if($attack[0] == $used_attacks[2]){
echo '<option value="'.$attack[0].'" selected="selected">'.$attack[1].'</option>';
} else{
echo '<option value="'.$attack[0].'">'.$attack[1].'</option>';
}
}
?>
</select>
</td>
</tr>
<tr>
<td>Required Level:</td>
<td><input name='req_lvl'
value='<?php echo $row['req_lvl']===NULL?0:$row['req_lvl']; ?>'></input>
</td>
</tr>
<tr>
<td>Frucht:</td>
<td><select name="Frucht">
<?php
// Fuers dropdown
$f_sql = 'SELECT id, item FROM wochen_markt WHERE type = \'Teufels Frucht\' order by item';
$f_qry = mysql_query($f_sql);
// <input name='Frucht' value='<?php echo $row[Frucht]===NULL?0:$row[Frucht]; '></input>
if($row['Frucht'] === NULL || $row['Frucht'] == 0){
echo '<option value="0" selected="selected">-Keine-</option>';
} else {
echo '<option value="0">-Keine-</option>';
}
while($f_row = mysql_fetch_assoc($f_qry)){
if($f_row['id'] == $row['Frucht']){
echo '<option value="'.$f_row['id'].'" selected="selected">'.$f_row['item'].'</option>';
} else{
echo '<option value="'.$f_row['id'].'">'.$f_row['item'].'</option>';
}
}
?>
</select>
</td>
</tr>
<tr>
<td>Runden:</td>
<td><input name='runden'
value='<?php echo $row['runden']===NULL?0:$row['runden']; ?>'></input>
</td>
</tr>
<tr>
<td>Maxlvl:</td>
<td><input name='maxlvl'
value='<?php echo $row['maxlvl']===NULL?0:$row['maxlvl']; ?>'></input>
</td>
</tr>
<tr>
<td colspan="2"><input type="submit" value='<?php echo $action; ?>'></input>
</td>
</tr>
<tr>
<td><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Zum Hauptmenu</a><br>
</td>
</tr>
</table>
</form>
<?php
}
function createAttack($attackname, $Frucht, $starke, $verteidigung, $speed, $hp, $mp, $rassen, $level, $geld, $options, $type, $info, $req_atk, $req_lvl, $runden, $maxlvl) {
json_decode($options, true);
if(JSON_ERROR_NONE != json_last_error()) {
echo "<br>";
echo "Attacke konnte nicht erstellt werden, syntax f&ouml;r options ist nicht korrekt!";
echo displayHistoryBackLink();
return;
}
if($Frucht != 0){
$sql = 'INSERT into attacken set name = \''.$attackname.'\', starke = '.$starke.', verteidigung = '.$verteidigung.', speed = '.$speed.', hp = '.$hp.', mp = '.$mp.', rassen = \''.$rassen.'\', level = '.$level.', geld = '.$geld.', type = \''.$type.'\', info = \''.$info.'\', req_atk = \''.$req_atk.'\', req_lvl = \''.$req_lvl.'\', Frucht = '.$Frucht.', runden = '.$runden.', maxlvl = '.$maxlvl.', options = \''.addslashes($options).'\'';
} else {
$sql = 'INSERT into attacken set name = \''.$attackname.'\', starke = '.$starke.', verteidigung = '.$verteidigung.', speed = '.$speed.', hp = '.$hp.', mp = '.$mp.', rassen = \''.$rassen.'\', level = '.$level.', geld = '.$geld.', type = \''.$type.'\', info = \''.$info.'\', req_atk = \''.$req_atk.'\', req_lvl = \''.$req_lvl.'\', runden = '.$runden.', maxlvl = '.$maxlvl.', options = \''.addslashes($options).'\'';
}
//echo $sql.'<br>';
if(!mysql_query($sql)){
echo "Fehler beim Erstellen der Attacke: &Uuml;berpr&uuml;fe deine Eingabe und melde erst DANACH dieses Statement einem Entwickler => $sql";
return;
}
logaction('Attacke '.$attackname.' wurde erstellt!');
?>
Attacke sollte nun erstellt sein!!
<br>
<a href="<?php echo $_SERVER['PHP_SELF']; ?>">Zum Hauptmenu</a>
<br>
<?php
}
function deleteAttack($attackid, $depth) {
if($depth == 4){
$sql = 'Delete from attacken where id = '.$attackid;
// echo 'Debugnachricht: '.$sql.'<br>';
mysql_query($sql);
mysql_query('Delete from lernen where at_id = '.$attackid);
logaction('Attacke mit id = '.$attackid.' wurde geloescht!');
} else{
for($i=0;$i<$depth;$i++){
$wirklich .= 'wirklich ';
}
?>
Sind sie sich
<?php echo $wirklich; ?>
sicher??
<a
href="<?php echo $_SERVER['PHP_SELF']; ?>?choose=attacken&action=delete&attackid=<?php echo $attackid; ?>&depth=<?php echo $depth+1; ?>">ja</a>
<br>
<?php
}
?>
<a href="<?php echo $_SERVER['PHP_SELF']; ?>">Zum Hauptmenu</a>
<br>
<?php
}
function editAttack($attackname, $attackid, $Frucht, $starke, $verteidigung, $speed, $hp, $mp, $rassen, $level, $geld, $options, $type, $info, $req_atk, $req_lvl, $runden, $maxlvl) {
$row = mysql_fetch_assoc(mysql_query('Select * from attacken where id ='.$attackid));
$req_atk = implode(',', $req_atk);
json_decode($options, true);
if(JSON_ERROR_NONE != json_last_error()) {
echo "<br>";
echo "Attacke konnte nicht erstellt werden, syntax f&ouml;r options ist nicht korrekt!";
echo "<br>";
echo displayHistoryBackLink();
return;
}
if($Frucht != 0){
$sql = 'UPDATE attacken set name = \''.htmlspecialchars(urldecode($attackname)).'\', starke = '.$starke.', verteidigung = '.$verteidigung.', speed = '.$speed.', hp = '.$hp.', mp = '.$mp.', rassen = \''.$rassen.'\', level = '.$level.', geld = '.$geld.', type = \''.$type.'\', info = \''.$info.'\', req_atk = \''.$req_atk.'\', req_lvl = \''.$req_lvl.'\', Frucht = '.$Frucht.', runden = '.$runden.', maxlvl = '.$maxlvl.', options = \''.$options.'\' where id = '.$attackid;
} else {
$sql = 'UPDATE attacken set name = \''.htmlspecialchars(urldecode($attackname)).'\', starke = '.$starke.', verteidigung = '.$verteidigung.', speed = '.$speed.', hp = '.$hp.', mp = '.$mp.', rassen = \''.$rassen.'\', level = '.$level.', geld = '.$geld.', type = \''.$type.'\', info = \''.$info.'\', req_atk = \''.$req_atk.'\', req_lvl = \''.$req_lvl.'\', Frucht = NULL, runden = '.$runden.', maxlvl = '.$maxlvl.', options = \''.$options.'\' where id = '.$attackid;
}
if($row['name'] != $attackname){
mysql_query('Update lernen set name = \''.$attackname.'\' WHERE at_id ='.$attackid);
}
//echo 'Debugnachricht: '.$sql.'<br>';
if(!mysql_query($sql)){
echo "Fehler beim Editieren der Attacke: &Uuml;berpr&uuml;fe deine Eingabe und melde erst DANACH dieses Statement einem Entwickler => $sql";
return;
}
logaction('Attacke mit dem jetzigen Namen '.$attackname.' wurde editiert!');
?>
<a href="<?php echo $_SERVER['PHP_SELF']; ?>?choose=attacken">Zum
Attackenmenü</a>
,
<a href="<?php echo $_SERVER['PHP_SELF']; ?>">Zum Hauptmenu</a>
<br>
<?php
}
?>