$variables['update_ticks_results']['sched'] = $tkireg->sched_ticks; $local_table_timer = new Tki\Timer(); $now = time(); $local_table_timer->start(); // Start benchmarking for turns scheduler $sched_file = 'sched_turns.php'; $sql = "INSERT INTO ::prefix::scheduler (run_once, ticks_full, sched_file, last_run) VALUES ('N', :ticks_full, :sched_file, :last_run)"; $stmt = $pdo_db->prepare($sql); $stmt->bindParam(':ticks_full', $tkireg->sched_turns); $stmt->bindParam(':sched_file', $sched_file); $stmt->bindParam(':last_run', $now); $resxx = $stmt->execute(); $variables['update_turns_results']['result'] = Tki\Db::logDbErrors($pdo_db, $resxx, __LINE__, __FILE__); $variables['update_turns_results']['sched'] = $tkireg->sched_turns; $local_table_timer->stop(); $variables['update_turns_results']['elapsed'] = $local_table_timer->elapsed(); $local_table_timer->start(); // Start benchmarking for Xenobe $sql = "INSERT INTO ::prefix::scheduler (run_once, ticks_full, sched_file, last_run) VALUES ('N', :ticks_full, :sched_file, :last_run)"; $stmt = $pdo_db->prepare($sql); $stmt->bindParam(':ticks_full', $tkireg->sched_turns); $stmt->bindValue(':sched_file', 'sched_xenobe.php'); $stmt->bindParam(':last_run', $now); $resxx = $stmt->execute(); $variables['update_xenobe_results']['result'] = Tki\Db::LogDbErrors($pdo_db, $resxx, __LINE__, __FILE__); $variables['update_xenobe_results']['sched'] = $tkireg->sched_turns; $local_table_timer->stop(); $variables['update_xenobe_results']['elapsed'] = $local_table_timer->elapsed(); $local_table_timer->start(); // Start benchmarking for Ibank scheduler $sched_file = 'sched_ibank.php';
// Database driven language entries $langvars = Tki\Translate::load($pdo_db, $lang, array('common', 'regional', 'footer', 'global_includes', 'create_universe', 'news')); $local_table_timer = new Tki\Timer(); $z = 0; $i = 0; $language_files = new DirectoryIterator("languages/"); $lang_file_import_results = array(); foreach ($language_files as $language_filename) { if ($language_filename->isFile() && $language_filename->getExtension() == 'ini') { $lang_name = mb_substr($language_filename->getFilename(), 0, -4); // Import Languages $local_table_timer->start(); // Start benchmarking $lang_result = Tki\File::iniToDb($pdo_db, "languages/" . $language_filename->getFilename(), "languages", $lang_name, $tkireg); $local_table_timer->stop(); $variables['import_lang_results'][$i]['time'] = $local_table_timer->elapsed(); $variables['import_lang_results'][$i]['name'] = ucwords($lang_name); $variables['import_lang_results'][$i]['result'] = $lang_result; $catch_results[$z] = $lang_result; $z++; $i++; } } $variables['language_count'] = $i - 1; $local_table_timer->start(); // Start benchmarking $gameconfig_result = Tki\File::iniToDb($pdo_db, "config/classic_config.ini", "gameconfig", "game", $tkireg); $local_table_timer->stop(); if ($gameconfig_result === true) { $variables['import_config_results']['result'] = true; $variables['import_config_results']['time'] = $local_table_timer->elapsed();
$initsorganics = $tkireg->organics_limit * $variables['initscommod'] / 100.0; $initsgoods = $tkireg->goods_limit * $variables['initscommod'] / 100.0; $initsenergy = $tkireg->energy_limit * $variables['initscommod'] / 100.0; $initbore = $tkireg->ore_limit * $variables['initbcommod'] / 100.0; $initborganics = $tkireg->organics_limit * $variables['initbcommod'] / 100.0; $initbgoods = $tkireg->goods_limit * $variables['initbcommod'] / 100.0; $initbenergy = $tkireg->energy_limit * $variables['initbcommod'] / 100.0; $local_table_timer = new Tki\Timer(); $local_table_timer->start(); // Start benchmarking $insert = $pdo_db->exec("INSERT INTO ::prefix::universe (sector_id, sector_name, zone_id, port_type, port_organics, port_ore, port_goods, port_energy, beacon, angle1, angle2, distance) VALUES ('1', 'Sol', '1', 'special', '0', '0', '0', '0', 'Sol: Hub of the Universe', '0', '0', '0')"); $variables['create_sol_results']['result'] = Tki\Db::logDbErrors($pdo_db, $insert, __LINE__, __FILE__); $catch_results[$z] = $variables['create_sol_results']['result']; $z++; $local_table_timer->stop(); $variables['create_sol_results']['time'] = $local_table_timer->elapsed(); $local_table_timer->start(); // Start benchmarking $insert = $pdo_db->exec("INSERT INTO ::prefix::universe (sector_id, sector_name, zone_id, port_type, port_organics, port_ore, port_goods, port_energy, beacon, angle1, angle2, distance) VALUES ('2', 'Alpha Centauri', '1', 'energy', '0', '0', '0', '0', 'Alpha Centauri: Gateway to the Galaxy', '0', '0', '1')"); $variables['create_ac_results']['result'] = Tki\Db::logDbErrors($pdo_db, $insert, __LINE__, __FILE__); $catch_results[$z] = $variables['create_ac_results']['result']; $z++; $local_table_timer->stop(); $variables['create_ac_results']['time'] = $local_table_timer->elapsed(); $loopsize = 1000; $loops = round($tkireg->max_sectors / $loopsize); if ($loops <= 0) { $loops = 1; } $variables['insert_sector_loops'] = $loops; $finish = $loopsize;
} else { if ($p_add < $variables['nump']) { // Add a line of values for every iteration - but only one, not random amounts $planet_insert_sql .= ", (2, 0, 0, {$default_prod_ore}, {$default_prod_organics}, {$default_prod_goods}, {$default_prod_energy}, {$default_prod_fighters}, {$default_prod_torp}, {$open_sectors_array[$p_add]})"; $p_add++; } } } while ($p_add < $variables['nump']); // Only add as many planets as requested // Insert all of the planets in one mega sql shot $insert = $pdo_db->exec($planet_insert_sql); $variables['setup_unowned_results']['result'] = Tki\Db::logDbErrors($pdo_db, $insert, __LINE__, __FILE__); $catch_results[$z] = $variables['setup_unowned_results']['result']; $z++; $local_table_timer->stop(); $variables['setup_unowned_results']['elapsed'] = $local_table_timer->elapsed(); $variables['setup_unowned_results']['nump'] = $variables['nump']; // Adds Sector Size * 2 amount of links to the links table $loopsize = 1000; $loops = round($tkireg->max_sectors / $loopsize); if ($loops <= 0) { $loops = 1; } $variables['insert_link_loops'] = $loops; $finish = $loopsize; if ($finish > $tkireg->max_sectors) { $finish = $tkireg->max_sectors; } $start = 1; for ($i = 1; $i <= $loops; $i++) { $local_table_timer->start();