From e4110a698172a067fe4b0280b000a544551818a4 Mon Sep 17 00:00:00 2001 From: slawkens1 Date: Thu, 21 Dec 2017 22:08:47 +0100 Subject: [PATCH] * automatically update highscores_ids_hidden for users who installed myaac before * update TODO --- TODO | 3 +++ common.php | 2 +- system/init.php | 2 +- system/migrations/20.php | 39 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 system/migrations/20.php diff --git a/TODO b/TODO index 626c7c8d..804cca81 100644 --- a/TODO +++ b/TODO @@ -9,10 +9,13 @@ * update Twig to the latest version from 1.x branch * semantic versioning support for plugins (github.com/composer/semver) * add some notice to the user that installing step "Import Schema" will take some time + * check user IP on installing to prevent install by random user 1.0: * i18n support (issue #1 on github) * New Admin Panel layout and interface + * add changelog management interface + * remove tibiacom template, and include it as a plugin 2.0 * remove compat functions diff --git a/common.php b/common.php index bee8d578..84977f1d 100644 --- a/common.php +++ b/common.php @@ -27,7 +27,7 @@ session_start(); define('MYAAC', true); define('MYAAC_VERSION', '0.7.3'); -define('DATABASE_VERSION', 19); +define('DATABASE_VERSION', 20); define('TABLE_PREFIX', 'myaac_'); define('START_TIME', microtime(true)); define('MYAAC_OS', (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? 'WINDOWS' : (strtoupper(PHP_OS) == 'DARWIN' ? 'MAC' : 'LINUX')); diff --git a/system/init.php b/system/init.php index da60a5d1..3441c695 100644 --- a/system/init.php +++ b/system/init.php @@ -150,7 +150,7 @@ unset($tmp); // new config values for compability if(!isset($config['highscores_ids_hidden'])) { - $config['highscores_ids_hidden'] = array(); + $config['highscores_ids_hidden'] = array(0); } // POT diff --git a/system/migrations/20.php b/system/migrations/20.php new file mode 100644 index 00000000..2d625748 --- /dev/null +++ b/system/migrations/20.php @@ -0,0 +1,39 @@ +query("SELECT `id` FROM `players` WHERE (`name` = " . $db->quote("Rook Sample") . " OR `name` = " . $db->quote("Sorcerer Sample") . " OR `name` = " . $db->quote("Druid Sample") . " OR `name` = " . $db->quote("Paladin Sample") . " OR `name` = " . $db->quote("Knight Sample") . ") ORDER BY `id`;"); + +$highscores_ignored_ids = array(); +if($query->rowCount() > 0) { + foreach($query->fetchAll() as $result) + $highscores_ignored_ids[] = $result['id']; +} +else { + $highscores_ignored_ids[] = 0; +} + +$php_on_end = substr($content_of_file, -2, 2) == '?>'; +$content = PHP_EOL; +if($php_on_end) { + $content .= ''; +} + +file_put_contents($config_file, $content, FILE_APPEND); +?> \ No newline at end of file