diff --git a/ag/include/user.inc.php b/ag/include/user.inc.php index 158cd0d..c0ade6b 100644 --- a/ag/include/user.inc.php +++ b/ag/include/user.inc.php @@ -120,4 +120,35 @@ function encryptPassword($password){ 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 .'
'; + 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); +} + + ?> \ No newline at end of file diff --git a/ag/index.php b/ag/index.php index 811d476..6f2383d 100644 --- a/ag/index.php +++ b/ag/index.php @@ -431,6 +431,28 @@ if($as != "irc" AND $as != "login" AND $as != "anmeldung" AND $as != "info/logs" + + +
+ + + + + + + + +
+ Werbung
+ +
+ + +
@@ -452,25 +474,6 @@ if($as != "irc" AND $as != "login" AND $as != "anmeldung" AND $as != "info/logs"
- -
- - - - - - - - -
- Werbung
- -
- diff --git a/ag/kampf_list.php b/ag/kampf_list.php index d595280..9ace299 100644 --- a/ag/kampf_list.php +++ b/ag/kampf_list.php @@ -8,6 +8,7 @@ include_once('path.inc.php'); // get the path ;) include_once(ROOT_PATH.'/include/config.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/abholcodes.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/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 // Kritisch (SQL-Injections) $lvl = validateUnsignedInteger($_GET['lvl'], null); @@ -38,6 +51,8 @@ $imgid = $_GET['imgid']; // Unkritisch $charm = $_REQUEST['charm']; +$noname_autofight = $_GET['noname_autofight']; +$create_autofight = $_GET['create_autofight']; $auth = true; @@ -256,10 +271,10 @@ function nehmeAutofightAn($user, $charid, $kampf_name, $kampf_zeit, $lvl){ starteFight($char_a, $chara_2, $fight_row); 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){ displayErrorMessage(NULL,'Fehlerhafte Eingabe!',displayHistoryBackLink()); return; @@ -273,12 +288,30 @@ function autokampf($user, $kampf_name, $char_id, $kampf_zeit, $lvl){ displayErrorMessage(NULL,'Verarbeitung gerade in Gange, bitte warten...', displayHistoryBackLink()); return; } + if(is_array($char_id)){ for($i=0;$i\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 ."
\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 { $tmp = 'Kein Char ausgewählt!'; } @@ -287,8 +320,8 @@ function autokampf($user, $kampf_name, $char_id, $kampf_zeit, $lvl){ semaphoreDown($ressource); } - 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){ displayErrorMessage(NULL,'Fehlerhafte Eingabe!',displayHistoryBackLink()); return; @@ -313,6 +346,9 @@ function erstelleFights($user, $kampf_name, $kampf_pw, $char_id, $kampf_zeit, $l if(is_numeric($char_id[$i])){ $tmp .= erstelleEinenFight($char_id[$i], $user, $kampf_name, $kampf_pw, $kampf_zeit, $lvl)."
\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! 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){ + $meta_data = getUserMetaData($user['id']); ?>
@@ -337,7 +374,7 @@ function displayAutoFights($user, $portal, $pagenum){ Kampfname - + Charakter @@ -359,9 +396,9 @@ function displayAutoFights($user, $portal, $pagenum){ Kampf Zeit @@ -373,7 +410,13 @@ function displayAutoFights($user, $portal, $pagenum){ '.$i.''; + if($meta_data[AUTO_FIGHT_LEVEL] == $i) { + $select = 'selected="selected"'; + } else { + $select = ''; + } + + echo ''; } ?> @@ -382,8 +425,8 @@ function displayAutoFights($user, $portal, $pagenum){ Falls kein Kampf gefunden wird: - Autofight ohne Namensbegrenzung
- Kampf erstellen + value="1"/>Autofight ohne Namensbegrenzung
+ value="1"/>Kampf erstellen @@ -398,7 +441,8 @@ function displayAutoFights($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']); $arena = mysql_fetch_assoc($qry); if(mysql_num_rows($qry) == 0){ @@ -423,7 +467,7 @@ function displayKampfErstellen($user, $portal, $pagenum){ Kampfname - + Charakter @@ -445,9 +489,9 @@ function displayKampfErstellen($user, $portal, $pagenum){ Kampf Zeit @@ -459,7 +503,12 @@ function displayKampfErstellen($user, $portal, $pagenum){ '.$i.''; + if($meta_data[CREATE_FIGHT_LEVEL] == $i) { + $select = 'selected="selected"'; + } else { + $select = ''; + } + echo ''; } ?> @@ -729,7 +778,7 @@ if($auth == false){ erstelleFights($user_ida, $kampf_name, $kampf_pw, $char_id, $kampf_zeit, $lvl); display($user_ida, $portal, $pagenum); } 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); } else if($charm == 4){ displayKampfAnnehmen($user_ida, $kampf_id,$portal, $pagenum); diff --git a/db/animegame_svn.sql b/db/animegame_svn.sql index d5f918e..bae5ba7 100644 --- a/db/animegame_svn.sql +++ b/db/animegame_svn.sql @@ -1596,6 +1596,21 @@ CREATE TABLE `user_activation` ( ) 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` --