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.
225 lines
7.5 KiB
225 lines
7.5 KiB
<?php
|
|
/*
|
|
*
|
|
* @copyright (c) 2010 animegame.eu
|
|
* @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/config.inc.php');
|
|
include_once(ROOT_PATH.'/include/fehlerausgabe.inc.php');
|
|
include_once(ROOT_PATH.'/include/designfunctions.inc.php');
|
|
include_once(ROOT_PATH.'/include/parse.inc.php');
|
|
include_once(ROOT_PATH.'/include/erstellfunctions.inc.php');
|
|
include_once(ROOT_PATH.'/include/semaphore.inc.php');
|
|
|
|
// GET-Section
|
|
// Kritisch (SQL-Injections)
|
|
// Nothing
|
|
// Unkritisch
|
|
$charm = $_GET['charm'];
|
|
$wunsch = $_GET['wunsch'];
|
|
$h_name = validateName($_GET['h_name']);
|
|
|
|
|
|
// Nicht viel aber eine große Auswirkung
|
|
function wuenscheGeld($user){
|
|
mysql_query('UPDATE user SET geld=geld+10000000 WHERE id='.$user['id']);
|
|
return true;
|
|
}
|
|
|
|
function wuenschePotaras($user){
|
|
mysql_query('INSERT sp_ware SET item=1, user='.$user['id']);
|
|
mysql_query('INSERT sp_ware SET item=1, user='.$user['id']);
|
|
return true;
|
|
}
|
|
|
|
function wuenscheTeufelsfrucht($user){
|
|
$teufelsseele = mysql_fetch_assoc(mysql_query('SELECT count(id) as anzahl FROM sp_ware WHERE item=33 AND user='.$user['id']));
|
|
|
|
if($teufelsseele['anzahl'] <= 0) {
|
|
displayErrorMessage(NULL,'Du besitzt das benötigte Item nicht!!',displayHistoryBackLink());
|
|
return false;
|
|
}
|
|
mysql_query('DELETE FROM sp_ware WHERE item=33 AND user='.$user['id'].' LIMIT 1');
|
|
|
|
$sum = mysql_fetch_assoc(mysql_query('SELECT sum(verteilung) as gesamt FROM wochen_markt WHERE art=\'natur\''));
|
|
if($sum['gesamt'] != 100){
|
|
displayErrorMessage(NULL,'Die Wahrscheinlichkeit eine Frucht zu bekommen entspricht nicht 100%, Melde dich bei einem der GM!!',displayHistoryBackLink());
|
|
return false;
|
|
}
|
|
$natur_frucht = mysql_query('SELECT item, id,verteilung FROM wochen_markt WHERE art=\'natur\' order by id'); ///wieviel TF gibt es?.
|
|
$value = mt_rand(1,100);
|
|
|
|
|
|
$peak = 0;
|
|
while($row = mysql_fetch_assoc($natur_frucht)){
|
|
$peak += $row['verteilung'];
|
|
if($value <= $peak){
|
|
break;
|
|
}
|
|
}
|
|
displayErrorMessage(NULL,'Du hast eine '.$row['item'].' bekommen!!','');
|
|
mysql_query('INSERT wochen_ware SET item='.$row['id'].', user='.$user['id']);
|
|
return true;
|
|
}
|
|
|
|
function wuenscheSpecialChar($user, $specialcharname, $newname = ''){
|
|
if($specialcharname == 'Kaioshin'){
|
|
$spitem = 3;
|
|
} else if($specialcharname == 'Shichibukai'){
|
|
$spitem = 15;
|
|
} else{
|
|
displayErrorMessage(NULL,'Es koennen nur Kaioshin und Shichibukai gewünscht werden!!',displayHistoryBackLink());
|
|
return false;
|
|
}
|
|
|
|
if($newname == ''){
|
|
displayErrorMessage(NULL,'Der Name ist ungueltig!!',displayHistoryBackLink());
|
|
return false;
|
|
}
|
|
|
|
// Hat der User überhaupt das Item ???
|
|
$qry = mysql_query('SELECT count(*) AS anzahl FROM sp_ware WHERE item='.$spitem.' AND user='.$user['id']);
|
|
$row = mysql_fetch_assoc($qry);
|
|
if($row['anzahl'] < 1){
|
|
// Er hat das Item garnicht!!
|
|
displayErrorMessage(NULL,'Du kannst dir einen '.$specialcharname.' nur mit dem richtigen Item wünschen!!',displayHistoryBackLink());
|
|
return false;
|
|
}
|
|
|
|
$kaioshin = mysql_fetch_assoc(mysql_query('SELECT char_type,name from chars WHERE (rasse = \''.$specialcharname.'\' or fusion_rasse = \''.$specialcharname.'\') and besitzer='.$user['id']));
|
|
if($kaioshin != null){
|
|
displayErrorMessage(NULL,'Der '.$specialcharname.'-Slot ist schon durch '.$kaioshin['name'].' belegt!!',displayHistoryBackLink());
|
|
return false;
|
|
}
|
|
|
|
// Kleine Funktion grosse Wirkung
|
|
if(!erstelleChar($user, $specialcharname, $newname)){
|
|
return false;
|
|
}
|
|
|
|
// Slotüberprüfung beendet!
|
|
mysql_query('DELETE FROM sp_ware WHERE item='.$spitem.' AND user='.$user['id'].' LIMIT 1');
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
function wuenscheUserRename($user, $newname){
|
|
if($newname == null || strlen(trim($newname)) < 3) {
|
|
return false;
|
|
}
|
|
$sql = 'Insert into user_rename(pre_name, post_name, datum, userid, wunsch) values(\''.$user['nickname'].'\', \''.$newname.'\', now(), '.$user['id'].', 1)';
|
|
mysql_query($sql);
|
|
mysql_query('Update user set nickname = \''.$newname.'\' WHERE id = '.$user['id']);
|
|
return true;
|
|
}
|
|
|
|
function worker($charm,$wunsch,$user,$newname){
|
|
$ressource = 'User:'.$user['id'];
|
|
// Wichtig, die Semaphore!!
|
|
if(!semaphoreUP($ressource)){ // TRUE, diese Anfrage darf bearbeitet werden
|
|
displayErrorMessage(NULL,'Verarbeitung gerade in Gange, bitte warten...', displayHistoryBackLink());
|
|
return;
|
|
}
|
|
|
|
$dragonballs = mysql_fetch_assoc(mysql_query('SELECT count(id) as anzahl FROM sp_ware WHERE user='.$user['id'].' AND item=11'));
|
|
if($dragonballs['anzahl'] < 7) {
|
|
displayErrorMessage(NULL,'Du hast keine 7 Dragonballs!!',displayHistoryBackLink());
|
|
semaphoreDown($ressource);
|
|
return;
|
|
}
|
|
|
|
$sql = 'DELETE FROM sp_ware WHERE item=11 AND user='.$user['id'].' LIMIT 7';
|
|
mysql_query($sql);
|
|
|
|
$result = true;
|
|
if($charm == 1) {
|
|
if($wunsch == 1) {
|
|
$result = wuenscheGeld($user);
|
|
} else if($wunsch == 2) {
|
|
$result = wuenschePotaras($user);
|
|
} else if($wunsch == 3) {
|
|
$result = wuenscheSpecialChar($user,'Kaioshin',$newname);
|
|
} else if($wunsch == 4) {
|
|
$result = wuenscheSpecialChar($user,'Shichibukai',$newname);
|
|
} else if($wunsch == 5) {
|
|
$result = wuenscheTeufelsfrucht($user);
|
|
} else if($wunsch == 6) {
|
|
$result = wuenscheUserRename($user,$newname);
|
|
}
|
|
}
|
|
if($result){
|
|
displayErrorMessage('Änderungen übernommen!','Dragonballs erfolgreich eingesetzt!!','<a href="index.php?as=dragonballs">weiter</a>');
|
|
} else{
|
|
mysql_query('INSERT sp_ware SET item=11, user='.$user['id']); // 1
|
|
mysql_query('INSERT sp_ware SET item=11, user='.$user['id']); // 2
|
|
mysql_query('INSERT sp_ware SET item=11, user='.$user['id']); // 3
|
|
mysql_query('INSERT sp_ware SET item=11, user='.$user['id']); // 4
|
|
mysql_query('INSERT sp_ware SET item=11, user='.$user['id']); // 5
|
|
mysql_query('INSERT sp_ware SET item=11, user='.$user['id']); // 6
|
|
mysql_query('INSERT sp_ware SET item=11, user='.$user['id']); // 7
|
|
}
|
|
semaphoreDown($ressource);
|
|
return;
|
|
}
|
|
|
|
|
|
function displayWuensche($user){
|
|
$items = mysql_query('SELECT distinct(i1.id) FROM sp_ware i INNER JOIN sp_item i1 ON(i.item=i1.id) WHERE i.user='.$user['id']);
|
|
|
|
?>
|
|
|
|
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
|
|
<input type="hidden" name="as" value="dragonballs">
|
|
<input type="hidden" name="charm" value="1">
|
|
<table cellpadding="0" cellspacing="0" width="100%">
|
|
<!-- MSTableType="layout" -->
|
|
<tr>
|
|
<th align="center">Wünsch dir etwas</th>
|
|
</tr>
|
|
<tr>
|
|
<td align="center">
|
|
<select id="input" name="wunsch">
|
|
<option value="1">10.000.000 ¥</option>
|
|
<option value="2">2x Potara Ohrringe</option>
|
|
<option value="6">Nutzernamen ändern</option>
|
|
<?php
|
|
|
|
while($row = mysql_fetch_assoc($items)) {
|
|
if($row['id'] == 3) { ?>
|
|
<option value="3">Kaioshin befreien</option>
|
|
<?php
|
|
} else if($row['id'] == 15) { ?>
|
|
<option value="4">Shichibukai befreien</option>
|
|
<?php
|
|
} else if($row['id'] == 33) { ?>
|
|
<option value="5">Naturfrucht</option>
|
|
<?php
|
|
}
|
|
}
|
|
?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<th align="center">
|
|
<br>Name nur bei Erschaffung von Specialchars oder Änderung des Nutzernamens
|
|
</th>
|
|
</tr>
|
|
<tr>
|
|
<td align="center">
|
|
<input id="input" name="h_name" value="" size="20"><br> <br>
|
|
<input id="input" type=submit value="Shenlong erscheine und erfülle mir meinen Wunsch!"></td>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<?php
|
|
}
|
|
|
|
if($charm !== NULL && $wunsch !== NULL){
|
|
worker($charm, $wunsch,$user_ida,$h_name);
|
|
} else{
|
|
displayWuensche($user_ida);
|
|
}
|
|
?>
|