From 4fa32e79ce54032079918e1da9b16cd2f0b69c81 Mon Sep 17 00:00:00 2001 From: slawkens1 Date: Tue, 6 Jun 2017 23:19:15 +0200 Subject: [PATCH] added id field on monsters, so you can delete in phpmyadmin fixed adding some creatures with ' and " --- common.php | 2 +- install/includes/schema.sql | 4 +++- system/migrations/4.php | 3 +++ system/pages/characters.php | 2 +- system/pages/creatures.php | 10 ++++++++-- 5 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 system/migrations/4.php diff --git a/common.php b/common.php index 802b5744..1387ed91 100644 --- a/common.php +++ b/common.php @@ -28,7 +28,7 @@ session_start(); define('MYAAC', true); define('MYAAC_VERSION', '0.2.3'); -define('DATABASE_VERSION', 3); +define('DATABASE_VERSION', 4); define('TABLE_PREFIX', 'myaac_'); define('START_TIME', microtime(true)); define('MYAAC_OS', (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? 'WINDOWS' : 'LINUX'); diff --git a/install/includes/schema.sql b/install/includes/schema.sql index 55b6fb88..b79805dd 100644 --- a/install/includes/schema.sql +++ b/install/includes/schema.sql @@ -116,6 +116,7 @@ CREATE TABLE `myaac_hooks` ) ENGINE = MyISAM; CREATE TABLE `myaac_monsters` ( + `id` int(11) NOT NULL AUTO_INCREMENT, `hide_creature` tinyint(1) NOT NULL default '0', `name` varchar(255) NOT NULL, `mana` int(11) NOT NULL, @@ -129,7 +130,8 @@ CREATE TABLE `myaac_monsters` ( `convinceable` tinyint(1) NOT NULL, `race` varchar(255) NOT NULL, `gfx_name` varchar(255) NOT NULL, - `file_path` varchar(255) NOT NULL + `file_path` varchar(255) NOT NULL, + PRIMARY KEY (`id`) ) ENGINE = MyISAM; CREATE TABLE `myaac_movies` diff --git a/system/migrations/4.php b/system/migrations/4.php new file mode 100644 index 00000000..774b2d5f --- /dev/null +++ b/system/migrations/4.php @@ -0,0 +1,3 @@ +query("ALTER TABLE `" . TABLE_PREFIX . "monsters` ADD `id` int(11) NOT NULL AUTO_INCREMENT primary key FIRST;"); +?> \ No newline at end of file diff --git a/system/pages/characters.php b/system/pages/characters.php index 0afbd55c..d4f84251 100644 --- a/system/pages/characters.php +++ b/system/pages/characters.php @@ -505,7 +505,7 @@ WHERE killers.death_id = '".$death['id']."' ORDER BY killers.final_hit DESC, kil if($mostdmg) { $mostdmg = ($death['mostdamage_is_player']) ? getPlayerLink($death['mostdamage_by']) : $death['mostdamage_by']; - $dead_add_content .= '
and by ' . $mostdmg; + $dead_add_content .= ' and by ' . $mostdmg; if ($death['mostdamage_unjustified']) { $dead_add_content .= " (unjustified)"; diff --git a/system/pages/creatures.php b/system/pages/creatures.php index 49e36ec4..b54bdab6 100644 --- a/system/pages/creatures.php +++ b/system/pages/creatures.php @@ -135,9 +135,15 @@ if(isset($_POST['reload_monsters']) && $canEdit) $flags['convinceable'] = '0'; if(!in_array($name, $names_added)) { - try { $db->query("INSERT INTO myaac_monsters (hide_creature, name, mana, exp, health, speed_lvl, use_haste, voices, immunities, summonable, convinceable, race, gfx_name, file_path) VALUES (0, '".$name."', '".$mana."', '".$exp."', '".$health."', '".$speed_lvl."', '".$use_haste."', '".$voices_string."', '".$immunities_string."', '".$flags['summonable']."', '".$flags['convinceable']."', '".$race."', '".$gfx_name."', '" . $allmonsters->currentFile() . "')"); } catch(PDOException $error) {} + try { + $db->query("INSERT INTO myaac_monsters (hide_creature, name, mana, exp, health, speed_lvl, use_haste, voices, immunities, summonable, convinceable, race, gfx_name, file_path) VALUES (0, ".$db->quote($name).", '".$mana."', '".$exp."', '".$health."', '".$speed_lvl."', '".$use_haste."', ".$db->quote($voices_string).", ".$db->quote($immunities_string).", '".$flags['summonable']."', '".$flags['convinceable']."', '".$race."', ".$db->quote($gfx_name).", " . $db->quote($allmonsters->currentFile()) . ")"); + echo "Added: ".$name."
"; + } + catch(PDOException $error) { + echo 'Error while adding monster (' . $name . '): ' . $error->getMessage(); + } + $names_added[] = $name; - echo "Added: ".$name."
"; } } }