function upgrade_database($version, $opts) { $conn = mysql_up(); switch ($version) { case '075-080': # Migrating position IDs correctly requires having loaded the correct LRB used in the v0.75 league. global $DEA, $stars, $skillarray; # Make global so that below include()s will overwrite their values. switch ($opts['lrb']) { case '5': require 'lib/game_data.php'; break; # Load LRB5 # Load LRB5 case '6x': require 'lib/game_data_lrb6x.php'; break; # Load LRB6x # Load LRB6x default: break; # LRB6 already loaded by default. } break; default: break; } require_once 'lib/class_sqlcore.php'; require_once 'lib/mysql_upgrade_queries.php'; // Modules echo "<b>Running SQLs for modules upgrade...</b><br>\n"; foreach (Module::getAllUpgradeSQLs($version) as $modname => $SQLs) { if (empty($SQLs)) { continue; } $status = true; foreach ($SQLs as $query) { $status &= (mysql_query($query) or die(mysql_error())); } echo $status ? "<font color='green'>OK — SQLs of {$modname}</font><br>\n" : "<font color='red'>FAILED — SQLs of {$modname}</font><br>\n"; } // Core echo "<b>Running tasks for core system upgrade...</b><br>\n"; if ($upgradeSettings[$version]['sync_gamedata']) { echo SQLCore::syncGameData() ? "<font color='green'>OK — Synchronized game data with database</font><br>\n" : "<font color='red'>FAILED — Error whilst synchronizing game data with database</font><br>\n"; } echo SQLCore::installProcsAndFuncs(true) ? "<font color='green'>OK — created MySQL functions/procedures</font><br>\n" : "<font color='red'>FAILED — could not create MySQL functions/procedures</font><br>\n"; if (isset($upgradeSQLs[$version])) { $core_SQLs = $upgradeSQLs[$version]; $status = true; foreach ($core_SQLs as $query) { $status &= (mysql_query($query) or die(mysql_error() . "\n<br>SQL:\n<br>---\n<br>" . $query)); } $cnt = "(" . count($core_SQLs) . " total)"; echo $status ? "<font color='green'>OK — Core SQLs</font> {$cnt}<br>\n" : "<font color='red'>FAILED — Core SQLs</font> {$cnt}<br>\n"; } if (isset($upgradeFuncs[$version])) { $core_Funcs = $upgradeFuncs[$version]; $status = true; foreach ($core_Funcs as $func) { $status &= call_user_func($func); } echo $status ? "<font color='green'>OK — Custom PHP upgrade code (<i>" . implode(', ', $core_Funcs) . "</i>)</font><br>\n" : "<font color='red'>FAILED — Custom PHP upgrade code</font><br>\n"; } if ($upgradeSettings[$version]['syncall']) { echo SQLCore::installMVs() ? "<font color='green'>OK — created MV tables</font><br>\n" : "<font color='red'>FAILED — could not create MV tables</font><br>\n"; list($status, $added, $dropped) = SQLCore::reviseEStables(); echo $status ? "<font color='green'>OK — create/update ES tables</font><br>\n" . '<!-- DEV. INFO: Added new cols: ' . implode(', ', $added) . '. Removed cols: ' . implode(', ', $dropped) . '.-->' : "<font color='red'>FAILED — create/update ES tables</font><br>\n"; } if ($upgradeSettings[$version]['reload_indexes']) { echo SQLCore::installTableIndexes() ? "<font color='green'>OK — applied table indexes</font><br>\n" : "<font color='red'>FAILED — could not apply one more more table indexes</font><br>\n"; } switch ($version) { case '075-080': # Convert league to LRB6. global $DEA, $stars, $skillarray; # Make global so that below include()s will overwrite their values. require 'lib/game_data_lrb6.php'; # Load LRB6. SQLCore::syncGameData(); default: break; } if ($upgradeSettings[$version]['syncall']) { echo mysql_query("CALL syncAll()") ? "<font color='green'>OK — synchronised all dynamic stats and properties</font><br>\n" : "<font color='red'>FAILED — could not synchronise all dynamic stats and properties</font><br>\n"; } // Done! mysql_close($conn); return $upgradeMsgs[$version]; }
<b>Need help? Encountering errors?</b><br> — If you are encountering errors please visit <a href='http://code.google.com/p/obblm/issues/list'>code.google.com/p/obblm</a> and create a bug report.<br> EOL; echo "<br><br>"; HTMLOUT::dnt(); } else { echo "<br><b><font color='red'>Failed</font></b>"; echo <<<EOL <br><br> <b>Need help? Encountering errors?</b><br> — If you are encountering errors please visit <a href='http://code.google.com/p/obblm/issues/list'>code.google.com/p/obblm</a> and create a bug report.<br> EOL; } } else { // Make sure OBBLM is not already installed $conn = mysql_up(); if (mysql_query("DESCRIBE coaches")) { echo <<<EOL It seems OBBLM is already installed.<br>You can safely delete the file <i>install.php</i> and go to the main page. <br><br>If you need help please visit <a href='http://code.google.com/p/obblm/issues/list'>code.google.com/p/obblm</a> and create a bug report.<br> EOL; } else { ?> Please, <b>before starting the installation process</b>, make sure that the MySQL user and database you have specified in <i>settings.php</i> exist and are valid.<br><br>When ready, press the button below :<br><br> <form method="POST"> <input type="submit" name="setup" value="Setup DB for OBBLM"> </form> <?php } }
require_once 'lib/class_race_htmlout.php'; require_once 'lib/class_match_htmlout.php'; require_once 'lib/class_mobile_htmlout.php'; /******************** * Final setup ********************/ if (!is_writable(IMG)) { die('OBBLM needs to be able to write to the <i>images</i> directory in order to work properly. Please check the directory permissions.'); } sortgamedata(); # Game data files are unsorted, make them pretty for display purposes. /******************** * Globals/Startup ********************/ if (defined('T_NO_STARTUP')) { Coach::logout(); require_once 'modules/modsheader.php'; # Registration of modules. } else { $conn = mysql_up(defined('T_NO_TBL_CHK') ? !T_NO_TBL_CHK : true); # MySQL connect. setupGlobalVars(T_SETUP_GLOBAL_VARS__COMMON); require_once 'modules/modsheader.php'; # Registration of modules. setupGlobalVars(T_SETUP_GLOBAL_VARS__POST_LOAD_MODULES); /****************************** Translate skills globally ******************************/ global $lng; $lng->TranslateSkills(); }
function setup_database() { global $core_tables; $conn = mysql_up(); require_once 'lib/class_sqlcore.php'; // Create core tables. echo "<b>Creating core tables...</b><br>\n"; foreach ($core_tables as $tblName => $def) { echo Table::createTable($tblName, $def) ? "<font color='green'>OK — {$tblName}</font><br>\n" : "<font color='red'>FAILED — {$tblName}</font><br>\n"; } // Create tables used by modules. echo "<b>Creating module tables...</b><br>\n"; foreach (Module::createAllRequiredTables() as $module => $tables) { foreach ($tables as $name => $tblStat) { echo $tblStat ? "<font color='green'>OK — {$name}</font><br>\n" : "<font color='red'>FAILED — {$name}</font><br>\n"; } } echo "<b>Other tasks...</b><br>\n"; echo SQLCore::syncGameData() ? "<font color='green'>OK — Synchronize game data with database</font><br>\n" : "<font color='red'>FAILED — Error whilst synchronizing game data with database</font><br>\n"; echo SQLCore::installTableIndexes() ? "<font color='green'>OK — applied table indexes</font><br>\n" : "<font color='red'>FAILED — could not apply one more more table indexes</font><br>\n"; echo SQLCore::installProcsAndFuncs(true) ? "<font color='green'>OK — created MySQL functions/procedures</font><br>\n" : "<font color='red'>FAILED — could not create MySQL functions/procedures</font><br>\n"; // Create root user and leave welcome message on messageboard global $rootpass; $rootpass = isset($rootpass) ? $rootpass : '******'; echo Coach::create(array('name' => 'root', 'realname' => 'root', 'passwd' => $rootpass, 'ring' => Coach::T_RING_GLOBAL_ADMIN, 'mail' => '', 'phone' => '', 'settings' => array(), 'def_leagues' => array())) ? "<font color=green>OK — root user created.</font><br>\n" : "<font color=red>FAILED — root user was not created.</font><br>\n"; Message::create(array('f_coach_id' => 1, 'f_lid' => Message::T_BROADCAST, 'title' => 'OBBLM installed!', 'msg' => 'Congratulations! You have successfully installed Online Blood Bowl League Manager. See "about" and "introduction" for more information.')); // Done! mysql_close($conn); return true; }