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.

181 lines
5.9 KiB

14 years ago
<?php
/*
*
* @copyright (c) 2010 animegame.eu
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public Licence
*
*/
/**
* Diese Datei wird aufgerufen wenn "Charakter erstellen" ausgewaehlt wurde.
* TODO: Layout anpassen (keine <center>, <font> und <strong> Tags mehr)
* TODO: Alle "" Strings in '' Strings umwandeln
* TODO: Funktioneller Aufruf, damit exit-Tags verschwinden koennen und somit der Chat angezeigt werden kann!!
*/
include_once($_SERVER['DOCUMENT_ROOT'].'ag/include/config.inc.php');
include_once($_SERVER['DOCUMENT_ROOT'].'ag/include/designfunctions.inc.php');
include_once($_SERVER['DOCUMENT_ROOT'].'ag/include/fehlerausgabe.inc.php');
include_once($_SERVER['DOCUMENT_ROOT'].'ag/include/erstellfunctions.inc.php');
include_once($_SERVER['DOCUMENT_ROOT'].'ag/include/parse.inc.php');
// GET-Section
// Kritisch (SQL-Injections)
$char_name = validateName($_GET['char_name']);
$char_1_type = validateString($_GET['char_1_Type']);
$char_bild = validateURL($_GET['char_bild']);
// Unkritisch
$charm = $_GET['charm'];
$char_type = $_GET['char_type'];
?>
<SCRIPT language="JavaScript">
<!--
function isAPhoneNumber(){
var s = "" + document.charz.char_name.value; //Umwandlung in eine Zeichenkette
var zeichen = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_ !" //Gueltige Zeichen
for (var i=0; i<s.length; i++){
if (zeichen.indexOf(s.charAt(i))==-1){
//kein gueltiges Zeichen
return false;
}
}
return true;
}
-->
</SCRIPT>
<?php
//if($charm == 2) {
// $user_ida, $char_1_Type, $char_name
function handleErstelleCharRequest($user, $type, $name, $bild){
if($type != 'Mensch' && $type != 'Saiyajin' && $type != 'Dämon' && $type != 'Mutant' && $type != 'Cyborg' && $type != 'Namekianer' && $type != 'Pirat' && $type != 'Schwertkämpfer' && $type != 'Grandline Maschine'){
displayErrorMessage(NULL,'Rasse kann nicht erstellt werden!',displayHistoryBackLink());
return;
}
if(erstelleChar($user, $type, $name,$bild)){
displayErrorMessage('&Auml;nderungen &uuml;bernommen','','<a href="index.php?as=char">weiter</a>');
}
}
//if($charm !== NULL) {
function handleSecondPhase($type, $name){
?>
<form action="index.php" method="get">
<input type="hidden" name="as" value="char">
<input type="hidden" name="charm" value="2">
<input type="hidden" name="char_name" value="<?php echo $name; ?>">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" height="20">
<tr>
<th colspan="2" align="center">Charakter erstellen (2/2)</th>
</tr>
<tr>
<th align="left">Rasse:</td>
<td>
<select id="input" name="char_1_Type">
<?php
if($type == 'Dragonball') {
?>
<option value="Mensch">Mensch</option>
<option value="Saiyajin">Saiyajin</option>
<option value="Dämon">D&auml;mon</option>
<option value="Mutant">Mutant</option>
<option value="Cyborg">Cyborg</option>
<option value="Namekianer">Namekianer</option>
<?php
} else if($type == 'Onepiece') {
?>
<option value="Pirat">Pirat</option>
<option value="Schwertkämpfer">Schwertk&auml;mpfer</option>
<option value="Grandline Maschine">Grandline Maschine</option>
<?php
} else{
?>
<option value="Cheater">Cheater</option>
<?php
}
?>
</select>
</td>
</tr>
<tr>
<th align="left">Charakter Bild (75x75):</th>
<td>
<input name="char_bild" id="input">
</td>
</tr>
<tr>
<td></td>
<td>
<input id="input" type=submit value="weiter">
</td>
</tr>
</table>
</form>
<?php
}
function handleFirstPhase(){
?>
<form action="index.php" method="get" name="charz" onsubmit="return isAPhoneNumber()">
<input type="hidden" name="as" value="char">
<input type="hidden" name="charm" value="1">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" height="25">
<tr>
<th colspan="2" align="center">Charakter Erstellen (1/2)</th>
</tr>
<tr>
<th align="center">Charaktername</th>
<td>
<input id="input" name="char_name" size="20"></input> (Buchstaben)
</td>
</tr>
<tr>
<th align="center">Type</th>
<td>
<select id="input" name="char_type">
<option value="Dragonball">Dragonball</option>
<option value="Onepiece">Onepiece</option>
</select>
</td>
</tr>
<tr>
<td></td>
<td><input id="input" type="submit" value="weiter"></td>
</tr>
</table>
</form>
<?php
}
$user_daten= mysql_fetch_assoc(mysql_query("SELECT char_max, id FROM user WHERE nickname='".$_COOKIE[name]."' LIMIT 1"));
$anzahl_spezialchars = mysql_num_rows(mysql_query('SELECT char_type,name from chars WHERE (rasse = "Kaioshin" OR fusion_rasse = "Kaioshin" OR rasse = "Shichibukai" OR fusion_rasse = "Shichibukai") AND besitzer='.$user_daten['id']));
$anzahl_charactere= mysql_num_rows(mysql_query("SELECT id FROM chars WHERE besitzer='".$user_daten[id]."'"));
if ($anzahl_spezialchars >= 1 AND $user_daten['char_max'] == 7) {
$chars_max= 8;
} else {
$chars_max= $user_daten['char_max'];
}
if ($anzahl_charactere < $chars_max) {
if($charm === NULL){
handleFirstPhase($user_daten,$anzahl_charactere);
} else if($charm == 1){
handleSecondPhase($char_type, $char_name);
} else if($charm == 2){
handleErstelleCharRequest($user_ida, $char_1_type, $char_name, $char_bild);
}
} else {
echo 'Du hast bereits die maximal mögliche Menge an Characteren erstellt, die du erstellen kannst.<br />Nämlich '.$anzahl_charactere.' von '.$chars_max.' Charaktere.';
}
?>