chache user settings in auto-fight and create fight (if database table is available) ... also moved the awards so they are lower as the advertisement

main
hecht 13 years ago
parent 5d691a9697
commit cb5a20a82c

@ -120,4 +120,35 @@ function encryptPassword($password){
return $result['pw']; return $result['pw'];
} }
function getUserMetaData($userid) {
$sql = 'SELECT * FROM user_meta_data WHERE user_id = ' . $userid;
$qry = mysql_query($sql);
$result = array();
if(!$qry)
{
echo $sql .'<br>';
return $result;
}
while ($row = mysql_fetch_assoc($qry)) {
$result[$row['key']] = $row['value'];
}
return $result;
}
function setUserMetaDataEntry($userid, $key, $value) {
$sql = 'UPDATE user_meta_data SET `value` = \''.$value.'\' WHERE user_id = \''.$userid.'\' and `key` = \''.$key.'\'';
$qry = mysql_query($sql);
if(!qry)
return;
if(mysql_affected_rows() > 0)
return;
$sql = 'INSERT INTO user_meta_data(user_id, `key`, `value`) values (\''.$userid.'\',\''.$key.'\',\''.$value.'\')';
$qry = mysql_query($sql);
}
?> ?>

@ -431,6 +431,28 @@ if($as != "irc" AND $as != "login" AND $as != "anmeldung" AND $as != "info/logs"
</tr> </tr>
</table> </table>
<?php
if($user_ida){
?>
<br>
<table cellpadding="0" cellspacing="0" width="146">
<tr>
<td height="22" width="146" colspan="3" class="ueberschrift">
Werbung<hr id="hru"></td>
</tr>
<tr>
<td height="29" width="6"> </td>
<td height="29" width="134" valign="top">
<?php echo getVerticalAdvertisement(); ?>
</td>
</tr>
</table>
<?php
}
?>
<table cellpadding="0" cellspacing="0" width="146"> <table cellpadding="0" cellspacing="0" width="146">
<tr> <tr>
<td height="22" width="146" colspan="3" class="ueberschrift"> <td height="22" width="146" colspan="3" class="ueberschrift">
@ -452,25 +474,6 @@ if($as != "irc" AND $as != "login" AND $as != "anmeldung" AND $as != "info/logs"
</tr> </tr>
</table> </table>
<?php
if($user_ida){
?>
<br>
<table cellpadding="0" cellspacing="0" width="146">
<tr>
<td height="22" width="146" colspan="3" class="ueberschrift">
Werbung<hr id="hru"></td>
</tr>
<tr>
<td height="29" width="6"> </td>
<td height="29" width="134" valign="top">
<?php echo getVerticalAdvertisement(); ?>
</td>
</tr>
</table>
<?php
}
?>
</td> </td>
<td rowspan="2"> </td> <td rowspan="2"> </td>
</tr> </tr>

@ -8,6 +8,7 @@
include_once('path.inc.php'); // get the path ;) include_once('path.inc.php'); // get the path ;)
include_once(ROOT_PATH.'/include/config.inc.php'); include_once(ROOT_PATH.'/include/config.inc.php');
include_once(ROOT_PATH.'/include/char.inc.php'); include_once(ROOT_PATH.'/include/char.inc.php');
include_once(ROOT_PATH.'/include/user.inc.php');
include_once(ROOT_PATH.'/include/designfunctions.inc.php'); include_once(ROOT_PATH.'/include/designfunctions.inc.php');
include_once(ROOT_PATH.'/include/abholcodes.inc.php'); include_once(ROOT_PATH.'/include/abholcodes.inc.php');
include_once(ROOT_PATH.'/include/parse.inc.php'); include_once(ROOT_PATH.'/include/parse.inc.php');
@ -16,6 +17,18 @@ include_once(ROOT_PATH.'/include/fehlerausgabe.inc.php');
include_once(ROOT_PATH.'/include/img.inc.php'); include_once(ROOT_PATH.'/include/img.inc.php');
include_once(ROOT_PATH.'/include/exp.inc.php'); include_once(ROOT_PATH.'/include/exp.inc.php');
// DEFINES FOR auto filling the forms!
define(AUTO_FIGHT_TIME, 'auto_fight_time');
define(AUTO_FIGHT_NAME, 'auto_fight_name');
define(AUTO_FIGHT_NONAME, 'auto_fight_noname');
define(AUTO_FIGHT_CREATE, 'auto_fight_create');
define(AUTO_FIGHT_LEVEL, 'auto_fight_level');
define(CREATE_FIGHT_TIME, 'create_fight_time');
define(CREATE_FIGHT_NAME, 'create_fight_name');
define(CREATE_FIGHT_LEVEL, 'create_fight_level');
// GET-Section // GET-Section
// Kritisch (SQL-Injections) // Kritisch (SQL-Injections)
$lvl = validateUnsignedInteger($_GET['lvl'], null); $lvl = validateUnsignedInteger($_GET['lvl'], null);
@ -38,6 +51,8 @@ $imgid = $_GET['imgid'];
// Unkritisch // Unkritisch
$charm = $_REQUEST['charm']; $charm = $_REQUEST['charm'];
$noname_autofight = $_GET['noname_autofight'];
$create_autofight = $_GET['create_autofight'];
$auth = true; $auth = true;
@ -256,10 +271,10 @@ function nehmeAutofightAn($user, $charid, $kampf_name, $kampf_zeit, $lvl){
starteFight($char_a, $chara_2, $fight_row); starteFight($char_a, $chara_2, $fight_row);
semaphoreDown($ressource); semaphoreDown($ressource);
return $char_a['name'].': Kampf wurde erfolgreich angenommen!'; return NULL;
} }
function autokampf($user, $kampf_name, $char_id, $kampf_zeit, $lvl){ function autokampf($user, $kampf_name, $char_id, $kampf_zeit, $lvl, $acceptWithoutName, $createAfterAccept){
if(!is_numeric($lvl) || !is_numeric($kampf_zeit) || $kampf_zeit < 0 || c > 4){ if(!is_numeric($lvl) || !is_numeric($kampf_zeit) || $kampf_zeit < 0 || c > 4){
displayErrorMessage(NULL,'Fehlerhafte Eingabe!',displayHistoryBackLink()); displayErrorMessage(NULL,'Fehlerhafte Eingabe!',displayHistoryBackLink());
return; return;
@ -273,12 +288,30 @@ function autokampf($user, $kampf_name, $char_id, $kampf_zeit, $lvl){
displayErrorMessage(NULL,'Verarbeitung gerade in Gange, bitte warten...', displayHistoryBackLink()); displayErrorMessage(NULL,'Verarbeitung gerade in Gange, bitte warten...', displayHistoryBackLink());
return; return;
} }
if(is_array($char_id)){ if(is_array($char_id)){
for($i=0;$i<count($char_id);$i++){ for($i=0;$i<count($char_id);$i++){
if(is_numeric($char_id[$i])){ if(is_numeric($char_id[$i])){
$tmp .= nehmeAutofightAn($user, $char_id[$i], $kampf_name, $kampf_zeit, $lvl)."<br>\n"; $txt = nehmeAutofightAn($user, $char_id[$i], $kampf_name, $kampf_zeit, $lvl);
if($txt != NULL && $acceptWithoutName == 1) {
$txt = nehmeAutofightAn($user, $char_id[$i], '', $kampf_zeit, $lvl);
}
if($txt != NULL && $createAfterAccept == 1) {
// does always return text!!
$txt = erstelleEinenFight($char_id[$i], $user, $kampf_name, '', $kampf_zeit, $lvl);
}
if($txt == NULL) {
$char = getChar($charid[$i]);
$txt = $char['name']. ': Kampf wurde erfolgreich angenommen!';
}
$tmp .= $txt ."<br>\n";
} }
} }
setUserMetaDataEntry($user['id'], AUTO_FIGHT_NAME, $kampf_name);
setUserMetaDataEntry($user['id'], AUTO_FIGHT_TIME, $kampf_zeit/300);
setUserMetaDataEntry($user['id'], AUTO_FIGHT_LEVEL, $lvl);
} else { } else {
$tmp = 'Kein Char ausgew&auml;hlt!'; $tmp = 'Kein Char ausgew&auml;hlt!';
} }
@ -287,8 +320,8 @@ function autokampf($user, $kampf_name, $char_id, $kampf_zeit, $lvl){
semaphoreDown($ressource); semaphoreDown($ressource);
} }
function erstelleFights($user, $kampf_name, $kampf_pw, $char_id, $kampf_zeit, $lvl){ function erstelleFights($user, $kampf_name, $kampf_pw, $char_id, $kampf_zeit, $lvl){
if(!is_numeric($lvl) || !is_numeric($kampf_zeit) || $kampf_zeit < 0 || c > 4){ if(!is_numeric($lvl) || !is_numeric($kampf_zeit) || $kampf_zeit < 0 || c > 4){
displayErrorMessage(NULL,'Fehlerhafte Eingabe!',displayHistoryBackLink()); displayErrorMessage(NULL,'Fehlerhafte Eingabe!',displayHistoryBackLink());
return; return;
@ -313,6 +346,9 @@ function erstelleFights($user, $kampf_name, $kampf_pw, $char_id, $kampf_zeit, $l
if(is_numeric($char_id[$i])){ if(is_numeric($char_id[$i])){
$tmp .= erstelleEinenFight($char_id[$i], $user, $kampf_name, $kampf_pw, $kampf_zeit, $lvl)."<br>\n"; $tmp .= erstelleEinenFight($char_id[$i], $user, $kampf_name, $kampf_pw, $kampf_zeit, $lvl)."<br>\n";
} }
setUserMetaDataEntry($user['id'], CREATE_FIGHT_NAME, $kampf_name);
setUserMetaDataEntry($user['id'], CREATE_FIGHT_TIME, $kampf_zeit/300);
setUserMetaDataEntry($user['id'], CREATE_FIGHT_LEVEL, $lvl);
} }
// Pro erstellter Fight kostet es einen Aktionspunkt! // Pro erstellter Fight kostet es einen Aktionspunkt!
hasDoneAction($user,count($char_id)); hasDoneAction($user,count($char_id));
@ -326,6 +362,7 @@ function erstelleFights($user, $kampf_name, $kampf_pw, $char_id, $kampf_zeit, $l
} }
function displayAutoFights($user, $portal, $pagenum){ function displayAutoFights($user, $portal, $pagenum){
$meta_data = getUserMetaData($user['id']);
?> ?>
<form action="kampf_list.php" method="GET"> <form action="kampf_list.php" method="GET">
<input type="hidden" name="charm" value="3"> <input type="hidden" name="charm" value="3">
@ -337,7 +374,7 @@ function displayAutoFights($user, $portal, $pagenum){
</tr> </tr>
<tr> <tr>
<th id="content" align="center">Kampfname</th> <th id="content" align="center">Kampfname</th>
<td><input id="input" name="kampf_name"/></td> <td><input id="input" name="kampf_name"/ value="<?php echo $meta_data[AUTO_FIGHT_NAME]; ?>"></td>
</tr> </tr>
<tr> <tr>
<th id="content" align="center">Charakter</th> <th id="content" align="center">Charakter</th>
@ -359,9 +396,9 @@ function displayAutoFights($user, $portal, $pagenum){
<th id="content" align="center">Kampf Zeit</th> <th id="content" align="center">Kampf Zeit</th>
<td> <td>
<select id="input" name="kampf_zeit"> <select id="input" name="kampf_zeit">
<option value="1">5min</option> <option value="1" <?php echo $meta_data[AUTO_FIGHT_TIME]==1?'selected="selected"':''; ?>>5min</option>
<option value="4">20min</option> <option value="4" <?php echo $meta_data[AUTO_FIGHT_TIME]==4?'selected="selected"':''; ?>>20min</option>
<option value="12" selected>60min</option> <option value="12" <?php echo $meta_data[AUTO_FIGHT_TIME]==12?'selected="selected"':''; ?>>60min</option>
</select> </select>
</td> </td>
</tr> </tr>
@ -373,7 +410,13 @@ function displayAutoFights($user, $portal, $pagenum){
<?php <?php
// Dynamisches einstellen der Stufen // Dynamisches einstellen der Stufen
for($i=1;$i<10;$i++){ for($i=1;$i<10;$i++){
echo '<option value="'.$i.'">'.$i.'</option>'; if($meta_data[AUTO_FIGHT_LEVEL] == $i) {
$select = 'selected="selected"';
} else {
$select = '';
}
echo '<option value="'.$i.'" '.$select.'>'.$i.'</option>';
} }
?> ?>
</select> </select>
@ -382,8 +425,8 @@ function displayAutoFights($user, $portal, $pagenum){
<tr> <tr>
<th id="content" align="center">Falls kein Kampf gefunden wird:</th> <th id="content" align="center">Falls kein Kampf gefunden wird:</th>
<td id="content" > <td id="content" >
<input type="checkbox" name="noname_autofight"/>Autofight ohne Namensbegrenzung<br> <input type="checkbox" name="noname_autofight" <?php echo $meta_data[AUTO_FIGHT_NONAME]==1?'checked="checked"':''; ?> value="1"/>Autofight ohne Namensbegrenzung<br>
<input type="checkbox" name="create_autofight"/>Kampf erstellen <input type="checkbox" name="create_autofight" <?php echo $meta_data[AUTO_FIGHT_CREATE]==1?'checked="checked"':''; ?> value="1"/>Kampf erstellen
</td> </td>
</tr> </tr>
<tr> <tr>
@ -398,7 +441,8 @@ function displayAutoFights($user, $portal, $pagenum){
} }
function displayKampfErstellen($user, $portal, $pagenum){ function displayKampfErstellen($user, $portal, $pagenum){
// Ermittle ob der User eine Funktionierende Arena besitzt! $meta_data = getUserMetaData($user['id']);
// Ermittle ob der User eine Funktionierende Arena besitzt!
$qry = mysql_query('Select * from arena where besitzer = '.$user['id']); $qry = mysql_query('Select * from arena where besitzer = '.$user['id']);
$arena = mysql_fetch_assoc($qry); $arena = mysql_fetch_assoc($qry);
if(mysql_num_rows($qry) == 0){ if(mysql_num_rows($qry) == 0){
@ -423,7 +467,7 @@ function displayKampfErstellen($user, $portal, $pagenum){
</tr> </tr>
<tr> <tr>
<th id="content" align="center">Kampfname</th> <th id="content" align="center">Kampfname</th>
<td id="content" ><input id="input" name="kampf_name"></td> <td id="content" ><input id="input" name="kampf_name" value="<?php echo $meta_data[CREATE_FIGHT_NAME]; ?>"></td>
</tr> </tr>
<tr> <tr>
<th id="content" align="center">Charakter</th> <th id="content" align="center">Charakter</th>
@ -445,9 +489,9 @@ function displayKampfErstellen($user, $portal, $pagenum){
<th id="content" align="center">Kampf Zeit</th> <th id="content" align="center">Kampf Zeit</th>
<td> <td>
<select id="input" name="kampf_zeit"> <select id="input" name="kampf_zeit">
<option value="1">5min</option> <option value="1" <?php echo $meta_data[CREATE_FIGHT_TIME]==1?'selected="selected"':''; ?>>5min</option>
<option value="4">20min</option> <option value="4" <?php echo $meta_data[CREATE_FIGHT_TIME]==4?'selected="selected"':''; ?>>20min</option>
<option value="12" selected>60min</option> <option value="12" <?php echo $meta_data[CREATE_FIGHT_TIME]==12?'selected="selected"':''; ?>>60min</option>
</select> </select>
</td> </td>
</tr> </tr>
@ -459,7 +503,12 @@ function displayKampfErstellen($user, $portal, $pagenum){
<?php <?php
// Dynamisches einstellen der Stufen // Dynamisches einstellen der Stufen
for($i=1;$i<10;$i++){ for($i=1;$i<10;$i++){
echo '<option value="'.$i.'">'.$i.'</option>'; if($meta_data[CREATE_FIGHT_LEVEL] == $i) {
$select = 'selected="selected"';
} else {
$select = '';
}
echo '<option value="'.$i.'" '.$select.'>'.$i.'</option>';
} }
?> ?>
</select> </select>
@ -729,7 +778,7 @@ if($auth == false){
erstelleFights($user_ida, $kampf_name, $kampf_pw, $char_id, $kampf_zeit, $lvl); erstelleFights($user_ida, $kampf_name, $kampf_pw, $char_id, $kampf_zeit, $lvl);
display($user_ida, $portal, $pagenum); display($user_ida, $portal, $pagenum);
} else if($charm == 3){ } else if($charm == 3){
autokampf($user_ida, $kampf_name, $char_id, $kampf_zeit, $lvl); autokampf($user_ida, $kampf_name, $char_id, $kampf_zeit, $lvl, $noname_autofight, $create_autofight);
display($user_ida, $portal, $pagenum); display($user_ida, $portal, $pagenum);
} else if($charm == 4){ } else if($charm == 4){
displayKampfAnnehmen($user_ida, $kampf_id,$portal, $pagenum); displayKampfAnnehmen($user_ida, $kampf_id,$portal, $pagenum);

@ -1596,6 +1596,21 @@ CREATE TABLE `user_activation` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
DROP TABLE IF EXISTS `user_meta_data`;
CREATE TABLE `user_meta_data` (
`user_id` INTEGER NOT NULL,
`key` VARCHAR(32) NOT NULL,
`value` VARCHAR(32) NOT NULL,
PRIMARY KEY (`user_id`, `key`),
CONSTRAINT `user_meta_data_userid` FOREIGN KEY `user_meta_data_userid` (`user_id`)
REFERENCES `user` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE
)
ENGINE = InnoDB
CHARACTER SET utf8 COLLATE utf8_general_ci;
-- --
-- Definition of table `user_adblock` -- Definition of table `user_adblock`
-- --

Loading…
Cancel
Save