You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			329 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			PHP
		
	
			
		
		
	
	
			329 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			PHP
		
	
| <?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 displayAttackeOptions($action, $attackname, $attackid, $depth, $name, $starke, $verteidigung, $speed, $hp, $mp, $rassen, $level, $geld, $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öschen</a>
 | |
| 				</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){
 | |
| 	?>
 | |
| 		<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
 | |
| 	} else if(($action == 'delete' || $action == 'edit') && $attackid === NULL){
 | |
| 		$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ä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ählen">
 | |
| 					</td>
 | |
| 				</tr>
 | |
| 				<tr>
 | |
| 					<td>
 | |
| 						<a href="<?php echo $_SERVER['PHP_SELF']; ?>">Zum Hauptmenu</a><br>
 | |
| 					</td>
 | |
| 				</tr>
 | |
| 			</table>
 | |
| 		</form>
 | |
| 	<?php
 | |
| 	} else if(($action == 'create' || $action == 'edit') && $depth === NULL){
 | |
| 		if($action == 'edit'){
 | |
| 			$row = mysql_fetch_assoc(mysql_query('Select * from attacken where id ='.$attackid));
 | |
| 		}
 | |
| 		
 | |
| 	?>
 | |
| 		<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ä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>
 | |
| 						<input name='type' value='<?php echo $row[type]===NULL?'normal':$row[type]; ?>'></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>
 | |
| 						<input name='req_atk' value='<?php echo $row[req_atk]===NULL?0:$row[req_atk]; ?>'></input>
 | |
| 					</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	
 | |
| 	} else if($action == 'create' && $depth == 1){
 | |
| 		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;
 | |
| 		} 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;
 | |
| 		}
 | |
| 		echo $sql.'<br>';
 | |
| 		mysql_query($sql);
 | |
| 		logaction('Attacke '.$attackname.' wurde erstellt!');
 | |
| 		?>Attacke sollte nun erstellt sein!!<br><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Zum Hauptmenu</a><br><?php
 | |
| 		
 | |
| 	} else if($action == 'delete' && $depth >= 1){
 | |
| 		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
 | |
| 	} else if($action == 'edit' && $depth == 1){
 | |
| 		$row = mysql_fetch_assoc(mysql_query('Select * from attacken where id ='.$attackid));
 | |
| 		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.' 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.' where id = '.$attackid;
 | |
| 		}
 | |
| 		if($row['name'] != $attackname){
 | |
| 			mysql_query('Update lernen set name = \''.$attackname.'\' WHERE at_id ='.$attackid);
 | |
| 		}
 | |
| //		echo 'Debugnachricht: '.$sql.'<br>';
 | |
| 		mysql_query($sql);
 | |
| 		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
 | |
| 	}
 | |
| 	
 | |
| }
 | |
| 
 | |
| ?>
 |