diff --git a/admin/bans_editor.php b/admin/bans_editor.php index dc292cf96..b3d304f8d 100644 --- a/admin/bans_editor.php +++ b/admin/bans_editor.php @@ -34,7 +34,7 @@ $bans = null; $players = null; - $res = $db->Execute("SELECT ban_mask FROM {$db->prefix}ip_bans"); + $res = $old_db->Execute("SELECT ban_mask FROM {$old_db->prefix}ip_bans"); Tki\Db::logDbErrors($pdo_db, $res, __LINE__, __FILE__); while (!$res->EOF) { @@ -78,7 +78,7 @@ echo "" . $printban . "" . ""; - $res = $db->Execute("SELECT character_name, ship_id, email FROM {$db->prefix}ships WHERE ip_address LIKE ?;", array($ban)); + $res = $old_db->Execute("SELECT character_name, ship_id, email FROM {$old_db->prefix}ships WHERE ip_address LIKE ?;", array($ban)); Tki\Db::logDbErrors($pdo_db, $res, __LINE__, __FILE__); unset($players); $players = null; @@ -130,7 +130,7 @@ elseif ($command == 'showips') { $ips = array(); - $res = $db->Execute("SELECT DISTINCT ip_address FROM {$db->prefix}ships"); + $res = $old_db->Execute("SELECT DISTINCT ip_address FROM {$old_db->prefix}ships"); Tki\Db::logDbErrors($pdo_db, $res, __LINE__, __FILE__); while (!$res->EOF) { @@ -166,7 +166,7 @@ echo "" . $ip . "" . ""; - $res = $db->Execute("SELECT character_name, ship_id, email FROM {$db->prefix}ships WHERE ip_address = ?;", array($ip)); + $res = $old_db->Execute("SELECT character_name, ship_id, email FROM {$old_db->prefix}ships WHERE ip_address = ?;", array($ip)); Tki\Db::logDbErrors($pdo_db, $res, __LINE__, __FILE__); unset($players); $players = null; @@ -267,9 +267,9 @@ $printban = htmlentities($printban, ENT_QUOTES | ENT_HTML5, 'UTF-8'); echo "" . $langvars['l_admin_ban_success'] . " " . $printban . ".

"; - $resx = $db->Execute("INSERT INTO {$db->prefix}ip_bans values (NULL, ?);", array($banmask)); + $resx = $old_db->Execute("INSERT INTO {$old_db->prefix}ip_bans values (NULL, ?);", array($banmask)); Tki\Db::logDbErrors($pdo_db, $resx, __LINE__, __FILE__); - $res = $db->Execute("SELECT DISTINCT character_name FROM {$db->prefix}ships, {$db->prefix}ip_bans WHERE ip_address LIKE ban_mask"); + $res = $old_db->Execute("SELECT DISTINCT character_name FROM {$old_db->prefix}ships, {$old_db->prefix}ip_bans WHERE ip_address LIKE ban_mask"); Tki\Db::logDbErrors($pdo_db, $res, __LINE__, __FILE__); echo $langvars['l_admin_affected_players'] . " :

"; while (!$res->EOF) @@ -289,12 +289,12 @@ $ip = $_POST['ip']; if ($ban !== null) { - $res = $db->Execute("SELECT * FROM {$db->prefix}ip_bans WHERE ban_mask = ?;", array($ban)); + $res = $old_db->Execute("SELECT * FROM {$old_db->prefix}ip_bans WHERE ban_mask = ?;", array($ban)); Tki\Db::logDbErrors($pdo_db, $res, __LINE__, __FILE__); } else { - $res = $db->Execute("SELECT * FROM {$db->prefix}ip_bans WHERE ? LIKE ban_mask;", array($ip)); + $res = $old_db->Execute("SELECT * FROM {$old_db->prefix}ip_bans WHERE ? LIKE ban_mask;", array($ip)); Tki\Db::logDbErrors($pdo_db, $res, __LINE__, __FILE__); } @@ -309,12 +309,12 @@ if ($ban !== null) { - $resx = $db->Execute("DELETE FROM {$db->prefix}ip_bans WHERE ban_mask = ?;", array($ban)); + $resx = $old_db->Execute("DELETE FROM {$old_db->prefix}ip_bans WHERE ban_mask = ?;", array($ban)); Tki\Db::logDbErrors($pdo_db, $resx, __LINE__, __FILE__); } else { - $resx = $db->Execute("DELETE FROM {$db->prefix}ip_bans WHERE ? LIKE ban_mask;", array($ip)); + $resx = $old_db->Execute("DELETE FROM {$old_db->prefix}ip_bans WHERE ? LIKE ban_mask;", array($ip)); Tki\Db::logDbErrors($pdo_db, $resx, __LINE__, __FILE__); } @@ -324,7 +324,7 @@ $query_string = $query_string . " OR ip_address LIKE '" . $bans[$i]['ban_mask'] . "'"; } - $res = $db->Execute("SELECT DISTINCT character_name FROM {$db->prefix}ships WHERE ?;", array($query_string)); + $res = $old_db->Execute("SELECT DISTINCT character_name FROM {$old_db->prefix}ships WHERE ?;", array($query_string)); Tki\Db::logDbErrors($pdo_db, $res, __LINE__, __FILE__); $nbplayers = $res->RecordCount(); $players = null; diff --git a/admin/log_viewer.php b/admin/log_viewer.php index 3006d5787..f71c1fe6c 100644 --- a/admin/log_viewer.php +++ b/admin/log_viewer.php @@ -23,7 +23,7 @@ */ $players = array(); -$res = $db->Execute("SELECT ship_id, character_name FROM {$db->prefix}ships ORDER BY character_name ASC"); +$res = $old_db->Execute("SELECT ship_id, character_name FROM {$old_db->prefix}ships ORDER BY character_name ASC"); Tki\Db::logDbErrors($pdo_db, $res, __LINE__, __FILE__); while (!$res->EOF) { diff --git a/admin/perf_monitor.php b/admin/perf_monitor.php index 04ecb6575..b5fae7c2c 100644 --- a/admin/perf_monitor.php +++ b/admin/perf_monitor.php @@ -22,8 +22,8 @@ * */ -//adodb_perf::table("{$db->prefix}adodb_logsql"); -$perf = NewPerfMonitor($db); +//adodb_perf::table("{$old_db->prefix}adodb_logsql"); +$perf = NewPerfMonitor($old_db); $pollsecs = 5; $perf->UI($pollsecs); diff --git a/admin/planet_editor.php b/admin/planet_editor.php index dcb108abd..591dd018c 100644 --- a/admin/planet_editor.php +++ b/admin/planet_editor.php @@ -27,7 +27,7 @@ if (empty($planet_id)) { echo ""; - $ressuba = $db->Execute("SELECT ship_id,character_name FROM {$db->prefix}ships ORDER BY character_name"); + $ressuba = $old_db->Execute("SELECT ship_id,character_name FROM {$old_db->prefix}ships ORDER BY character_name"); Tki\Db::logDbErrors($pdo_db, $ressuba, __LINE__, __FILE__); echo ""; while (!$ressuba->EOF) @@ -115,12 +115,12 @@ $_defeated = empty($defeated) ? "N" : "Y"; $_base = empty($base) ? "N" : "Y"; $_sells = empty($sells) ? "N" : "Y"; - $planupdate = $db->Execute("UPDATE {$db->prefix}planets SET sector_id = ?, defeated = ?, name = ?, base = ?, sells = ?, owner = ?, organics = ?, ore = ?, goods = ?, energy = ?, team = ?, colonists = ?,credits = ? ,fighters = ?, torps = ?, prod_organics= ? , prod_ore = ?, prod_goods = ?, prod_energy = ?, prod_fighters = ?, prod_torp = ? WHERE planet_id = ?", array($sector_id, $_defeated, $name, $_base, $_sells, $owner, $organics, $ore, $goods, $energy, $team, $colonists, $credits, $fighters, $torps, $prod_organics, $prod_ore, $prod_goods, $prod_energy, $prod_fighters, $prod_torp, $planet_id)); + $planupdate = $old_db->Execute("UPDATE {$old_db->prefix}planets SET sector_id = ?, defeated = ?, name = ?, base = ?, sells = ?, owner = ?, organics = ?, ore = ?, goods = ?, energy = ?, team = ?, colonists = ?,credits = ? ,fighters = ?, torps = ?, prod_organics= ? , prod_ore = ?, prod_goods = ?, prod_energy = ?, prod_fighters = ?, prod_torp = ? WHERE planet_id = ?", array($sector_id, $_defeated, $name, $_base, $_sells, $owner, $organics, $ore, $goods, $energy, $team, $colonists, $credits, $fighters, $torps, $prod_organics, $prod_ore, $prod_goods, $prod_energy, $prod_fighters, $prod_torp, $planet_id)); Tki\Db::logDbErrors($pdo_db, $planupdate, __LINE__, __FILE__); if (!$planupdate) { echo $langvars['l_admin_changes_failed'] . "

"; - echo $db->ErrorMsg() . "
"; + echo $old_db->ErrorMsg() . "
"; } else { diff --git a/admin/sector_editor.php b/admin/sector_editor.php index 96b05a8d0..4c00a5b63 100644 --- a/admin/sector_editor.php +++ b/admin/sector_editor.php @@ -39,7 +39,7 @@ if ($_POST['sector'] === null) { $sectors = array(); - $res = $db->Execute("SELECT sector_id FROM {$db->prefix}universe ORDER BY sector_id"); + $res = $old_db->Execute("SELECT sector_id FROM {$old_db->prefix}universe ORDER BY sector_id"); Tki\Db::logDbErrors($pdo_db, $res, __LINE__, __FILE__); while (!$res->EOF) { @@ -59,7 +59,7 @@ $variables['sector_name'] = $row['sector_name']; $zones = array(); - $ressubb = $db->Execute("SELECT zone_id,zone_name FROM {$db->prefix}zones ORDER BY zone_name"); + $ressubb = $old_db->Execute("SELECT zone_id,zone_name FROM {$old_db->prefix}zones ORDER BY zone_name"); Tki\Db::logDbErrors($pdo_db, $ressubb, __LINE__, __FILE__); while (!$ressubb->EOF) { @@ -101,13 +101,13 @@ elseif ($_POST['operation'] == "save") { // Update database - $secupdate = $db->Execute("UPDATE {$db->prefix}universe SET sector_name=?, zone_id=?, beacon=?, port_type=?, port_organics=?, port_ore=?, port_goods=?, port_energy=?, distance=?, angle1=?, angle2=? WHERE sector_id=?;", array($_POST['sector_name'], $_POST['zone_id'], $_POST['beacon'], $_POST['port_type'], $_POST['port_organics'], $_POST['port_ore'], $_POST['port_goods'], $_POST['port_energy'], $_POST['distance'], $_POST['angle1'], $_POST['angle2'], $_POST['sector'])); + $secupdate = $old_db->Execute("UPDATE {$old_db->prefix}universe SET sector_name=?, zone_id=?, beacon=?, port_type=?, port_organics=?, port_ore=?, port_goods=?, port_energy=?, distance=?, angle1=?, angle2=? WHERE sector_id=?;", array($_POST['sector_name'], $_POST['zone_id'], $_POST['beacon'], $_POST['port_type'], $_POST['port_organics'], $_POST['port_ore'], $_POST['port_goods'], $_POST['port_energy'], $_POST['distance'], $_POST['angle1'], $_POST['angle2'], $_POST['sector'])); Tki\Db::logDbErrors($pdo_db, $secupdate, __LINE__, __FILE__); if (!$secupdate) { $variables['secupdate'] = false; - $variables['db_error_msg'] = $db->ErrorMsg(); + $variables['db_error_msg'] = $old_db->ErrorMsg(); } else { diff --git a/admin/universe_editor.php b/admin/universe_editor.php index d667a6954..40f704de8 100644 --- a/admin/universe_editor.php +++ b/admin/universe_editor.php @@ -29,12 +29,12 @@ if ($action == "doexpand") { - $result = $db->Execute("SELECT sector_id FROM {$db->prefix}universe ORDER BY sector_id ASC"); + $result = $old_db->Execute("SELECT sector_id FROM {$old_db->prefix}universe ORDER BY sector_id ASC"); Tki\Db::logDbErrors($pdo_db, $result, __LINE__, __FILE__); if (!$result->EOF) { - $resa = $db->StartTrans(); // We enclose the updates in a transaction as it is faster + $resa = $old_db->StartTrans(); // We enclose the updates in a transaction as it is faster Tki\Db::logDbErrors($pdo_db, $resa, __LINE__, __FILE__); // Begin transaction @@ -42,7 +42,7 @@ { $row = $result->fields; $distance = random_int(1, (int) $radius); - $resx = $db->Execute("UPDATE {$db->prefix}universe SET distance = ? WHERE sector_id = ?", array($distance, $row['sector_id'])); + $resx = $old_db->Execute("UPDATE {$old_db->prefix}universe SET distance = ? WHERE sector_id = ?", array($distance, $row['sector_id'])); Tki\Db::logDbErrors($pdo_db, $resx, __LINE__, __FILE__); $changed_sectors[$i] = str_replace("[sector]", $row['sector_id'], $langvars['l_admin_updated_distance']); @@ -52,7 +52,7 @@ } // End transaction - $trans_status = $db->CompleteTrans(); // Complete the transaction + $trans_status = $old_db->CompleteTrans(); // Complete the transaction Tki\Db::logDbErrors($pdo_db, $trans_status, __LINE__, __FILE__); } } diff --git a/admin/user_editor.php b/admin/user_editor.php index 9eec16c4f..880b2431f 100644 --- a/admin/user_editor.php +++ b/admin/user_editor.php @@ -34,7 +34,7 @@ if (empty($_POST['user'])) { $players = array(); - $res = $db->Execute("SELECT ship_id, character_name FROM {$db->prefix}ships ORDER BY character_name"); + $res = $old_db->Execute("SELECT ship_id, character_name FROM {$old_db->prefix}ships ORDER BY character_name"); Tki\Db::logDbErrors($pdo_db, $res, __LINE__, __FILE__); while (!$res->EOF) { @@ -112,7 +112,7 @@ $_dev_fuelscoop = empty($_POST['dev_fuelscoop']) ? "N" : "Y"; $variables['debug'] = $_dev_escapepod; // FUTURE: Needs password updating as well - $resx = $db->Execute("UPDATE {$db->prefix}ships SET character_name=?, email=?, ship_name=?, ship_destroyed=?, hull=?, engines=?, power=?, computer=?, sensors=?, armor=?, shields=?, beams=?, torp_launchers=?, cloak=?, credits=?, turns=?, dev_warpedit=?, dev_genesis=?, dev_beacon=?, dev_emerwarp=?, dev_escapepod=?, dev_fuelscoop=?, dev_minedeflector=?, sector=?, ship_ore=?, ship_organics=?, ship_goods=?, ship_energy=?, ship_colonists=?, ship_fighters=?, torps=?, armor_pts=? WHERE ship_id=?", array($_POST['character_name'], $_POST['email'], $_POST['ship_name'], $_ship_destroyed, $_POST['hull'], $_POST['engines'], $_POST['power'], $_POST['computer'], $_POST['sensors'], $_POST['armor'], $_POST['shields'], $_POST['beams'], $_POST['torp_launchers'], $_POST['cloak'], $_POST['credits'], $_POST['turns'], $_POST['dev_warpedit'], $_POST['dev_genesis'], $_POST['dev_beacon'], $_POST['dev_emerwarp'], $_dev_escapepod, $_dev_fuelscoop, $_POST['dev_minedeflector'], $_POST['sector'], $_POST['ship_ore'], $_POST['ship_organics'], $_POST['ship_goods'], $_POST['ship_energy'], $_POST['ship_colonists'], $_POST['ship_fighters'], $_POST['torps'], $_POST['armor_pts'], $_POST['user'])); + $resx = $old_db->Execute("UPDATE {$old_db->prefix}ships SET character_name=?, email=?, ship_name=?, ship_destroyed=?, hull=?, engines=?, power=?, computer=?, sensors=?, armor=?, shields=?, beams=?, torp_launchers=?, cloak=?, credits=?, turns=?, dev_warpedit=?, dev_genesis=?, dev_beacon=?, dev_emerwarp=?, dev_escapepod=?, dev_fuelscoop=?, dev_minedeflector=?, sector=?, ship_ore=?, ship_organics=?, ship_goods=?, ship_energy=?, ship_colonists=?, ship_fighters=?, torps=?, armor_pts=? WHERE ship_id=?", array($_POST['character_name'], $_POST['email'], $_POST['ship_name'], $_ship_destroyed, $_POST['hull'], $_POST['engines'], $_POST['power'], $_POST['computer'], $_POST['sensors'], $_POST['armor'], $_POST['shields'], $_POST['beams'], $_POST['torp_launchers'], $_POST['cloak'], $_POST['credits'], $_POST['turns'], $_POST['dev_warpedit'], $_POST['dev_genesis'], $_POST['dev_beacon'], $_POST['dev_emerwarp'], $_dev_escapepod, $_dev_fuelscoop, $_POST['dev_minedeflector'], $_POST['sector'], $_POST['ship_ore'], $_POST['ship_organics'], $_POST['ship_goods'], $_POST['ship_energy'], $_POST['ship_colonists'], $_POST['ship_fighters'], $_POST['torps'], $_POST['armor_pts'], $_POST['user'])); Tki\Db::logDbErrors($pdo_db, $resx, __LINE__, __FILE__); $button_main = false; $variables['user'] = ''; diff --git a/admin/zone_editor.php b/admin/zone_editor.php index 6550ddab9..10d9f48e3 100644 --- a/admin/zone_editor.php +++ b/admin/zone_editor.php @@ -34,7 +34,7 @@ { $zones = array(); - $res = $db->Execute("SELECT zone_id, zone_name FROM {$db->prefix}zones ORDER BY zone_name"); + $res = $old_db->Execute("SELECT zone_id, zone_name FROM {$old_db->prefix}zones ORDER BY zone_name"); Tki\Db::logDbErrors($pdo_db, $res, __LINE__, __FILE__); while (!$res->EOF) { @@ -96,7 +96,7 @@ $_zone_attack = empty($zone_attack) ? "N" : "Y"; $_zone_warpedit = empty($zone_warpedit) ? "N" : "Y"; $_zone_planet = empty($zone_planet) ? "N" : "Y"; - $resx = $db->Execute("UPDATE {$db->prefix}zones SET zone_name = ?, allow_beacon = ? , allow_attack= ? , allow_warpedit = ? , allow_planet = ?, max_hull = ? WHERE zone_id = ?;", array($zone_name, $_zone_beacon, $_zone_attack, $_zone_warpedit, $_zone_planet, $zone_hull, $_POST['zone'])); + $resx = $old_db->Execute("UPDATE {$old_db->prefix}zones SET zone_name = ?, allow_beacon = ? , allow_attack= ? , allow_warpedit = ? , allow_planet = ?, max_hull = ? WHERE zone_id = ?;", array($zone_name, $_zone_beacon, $_zone_attack, $_zone_warpedit, $_zone_planet, $zone_hull, $_POST['zone'])); Tki\Db::logDbErrors($pdo_db, $resx, __LINE__, __FILE__); $button_main = false; } diff --git a/attack.php b/attack.php index 31f55787d..e4d063709 100644 --- a/attack.php +++ b/attack.php @@ -114,10 +114,10 @@ $roll = random_int(1, 100); $roll2 = random_int(1, 100); - $res = $db->Execute( - "SELECT allow_attack, {$db->prefix}universe.zone_id FROM {$db->prefix}zones, " . - "{$db->prefix}universe WHERE sector_id = ? AND {$db->prefix}zones.zone_id = " . - "{$db->prefix}universe.zone_id;", + $res = $old_db->Execute( + "SELECT allow_attack, {$old_db->prefix}universe.zone_id FROM {$old_db->prefix}zones, " . + "{$old_db->prefix}universe WHERE sector_id = ? AND {$old_db->prefix}zones.zone_id = " . + "{$old_db->prefix}universe.zone_id;", array($targetinfo['sector']) ); Tki\Db::logDbErrors($pdo_db, $res, __LINE__, __FILE__); @@ -130,8 +130,8 @@ elseif ($flee < $roll2) { echo $langvars['l_att_flee'] . "

"; - $resx = $db->Execute( - "UPDATE {$db->prefix}ships SET turns = turns - 1, turns_used = turns_used + 1 WHERE " . + $resx = $old_db->Execute( + "UPDATE {$old_db->prefix}ships SET turns = turns - 1, turns_used = turns_used + 1 WHERE " . "ship_id = ?;", array($playerinfo['ship_id']) ); @@ -142,8 +142,8 @@ { // If scan fails - inform both player and target. echo $langvars['l_planet_noscan'] . "

"; - $resx = $db->Execute( - "UPDATE {$db->prefix}ships SET turns = turns - 1, turns_used = turns_used + 1 WHERE " . + $resx = $old_db->Execute( + "UPDATE {$old_db->prefix}ships SET turns = turns - 1, turns_used = turns_used + 1 WHERE " . "ship_id = ?;", array($playerinfo['ship_id']) ); @@ -171,16 +171,16 @@ // Need to change warp destination to random sector in universe $rating_change = round($targetinfo['rating'] * .1); $dest_sector = random_int(1, (int) $tkireg->max_sectors - 1); - $resx = $db->Execute( - "UPDATE {$db->prefix}ships SET turns = turns - 1, turns_used = turns_used + 1, " . + $resx = $old_db->Execute( + "UPDATE {$old_db->prefix}ships SET turns = turns - 1, turns_used = turns_used + 1, " . "rating = rating - ? " . "WHERE ship_id = ?;", array($rating_change, $playerinfo['ship_id']) ); Tki\Db::logDbErrors($pdo_db, $resx, __LINE__, __FILE__); Tki\PlayerLog::writeLog($pdo_db, $targetinfo['ship_id'], \Tki\LogEnums::ATTACK_EWD, "$playerinfo[character_name]"); - $result_warp = $db->Execute( - "UPDATE {$db->prefix}ships SET sector = $dest_sector, " . + $result_warp = $old_db->Execute( + "UPDATE {$old_db->prefix}ships SET sector = $dest_sector, " . "dev_emerwarp = dev_emerwarp - 1, cleared_defenses = ' ' " . "WHERE ship_id = ?;", array($targetinfo['ship_id']) @@ -202,8 +202,8 @@ // Check to see if there is Federation bounty on the player. // If there is, people can attack regardless. $btyamount = 0; - $hasbounty = $db->Execute( - "SELECT SUM(amount) AS btytotal FROM {$db->prefix}bounty WHERE " . + $hasbounty = $old_db->Execute( + "SELECT SUM(amount) AS btytotal FROM {$old_db->prefix}bounty WHERE " . "bounty_on = ? AND placed_by = 0;", array($targetinfo['ship_id']) ); @@ -217,8 +217,8 @@ if ($btyamount <= 0) { $bounty = round($playerscore * $max_bountyvalue); - $insert = $db->Execute( - "INSERT INTO {$db->prefix}bounty (bounty_on,placed_by,amount) values " . + $insert = $old_db->Execute( + "INSERT INTO {$old_db->prefix}bounty (bounty_on,placed_by,amount) values " . "(?,?,?);", array($playerinfo['ship_id'], 0 ,$bounty) ); @@ -619,8 +619,8 @@ { $rating = round($targetinfo['rating'] / 2); echo $langvars['l_att_espod'] . " (You destroyed their ship but they got away in their Escape Pod)
"; - $resx = $db->Execute( - "UPDATE {$db->prefix}ships SET hull = 0, engines = 0, power = 0, sensors = 0, computer = 0, beams = 0, torp_launchers = 0, " . + $resx = $old_db->Execute( + "UPDATE {$old_db->prefix}ships SET hull = 0, engines = 0, power = 0, sensors = 0, computer = 0, beams = 0, torp_launchers = 0, " . "torps = 0, armor = 0, armor_pts = 100, cloak = 0, shields = 0, sector = 1, ship_organics = 0, ship_ore = 0, ship_goods = 0, " . "ship_energy = ?, ship_colonists = 0, ship_fighters = 100, dev_warpedit = 0, dev_genesis = 0, dev_beacon = 0, dev_emerwarp = 0, " . "dev_escapepod = 'N', dev_fuelscoop = 'N', dev_minedeflector = 0, on_planet = 'N', rating = ?, cleared_defenses = ' ', " . @@ -655,7 +655,7 @@ // He is a Kabal if (preg_match("/(\@kabal)$/", $targetinfo['email']) !== 0) { - $resx = $db->Execute("UPDATE {$db->prefix}kabal SET active= N WHERE kabal_id = ?;", array($targetinfo['email'])); + $resx = $old_db->Execute("UPDATE {$old_db->prefix}kabal SET active= N WHERE kabal_id = ?;", array($targetinfo['email'])); Tki\Db::logDbErrors($pdo_db, $resx, __LINE__, __FILE__); $admin_log = new Tki\AdminLog(); $admin_log->writeLog($pdo_db, \Tki\LogEnums::ATTACK_DEBUG, "*|{$playerinfo['ship_id']}|{$targetinfo['ship_id']}|Detected as AI."); @@ -734,8 +734,8 @@ $langvars['l_att_ysalv2'] = str_replace("[rating_change]", number_format(abs($rating_change), 0, $langvars['local_number_dec_point'], $langvars['local_number_thousands_sep']), $langvars['l_att_ysalv2']); echo $langvars['l_att_ysalv'] . "
" . $langvars['l_att_ysalv2'] . "
\n"; - $update3 = $db->Execute( - "UPDATE {$db->prefix}ships SET ship_ore = ship_ore + ?, ship_organics = ship_organics + ?, ship_goods = ship_goods + ?, " . + $update3 = $old_db->Execute( + "UPDATE {$old_db->prefix}ships SET ship_ore = ship_ore + ?, ship_organics = ship_organics + ?, ship_goods = ship_goods + ?, " . "credits = credits + ? WHERE ship_id = ?;", array($salv_ore, $salv_organics, $salv_goods, $ship_salvage, $playerinfo['ship_id']) ); @@ -743,8 +743,8 @@ $armor_lost = $playerinfo['armor_pts'] - $playerarmor; $fighters_lost = $playerinfo['ship_fighters'] - $playerfighters; $energy = $playerinfo['ship_energy']; - $update3b = $db->Execute( - "UPDATE {$db->prefix}ships SET ship_energy = ?, ship_fighters = ship_fighters - ?, armor_pts = armor_pts - ?, torps = torps - ?, " . + $update3b = $old_db->Execute( + "UPDATE {$old_db->prefix}ships SET ship_energy = ?, ship_fighters = ship_fighters - ?, armor_pts = armor_pts - ?, torps = torps - ?, " . "turns = turns - 1, turns_used = turns_used + 1, rating = rating - ? " . "WHERE ship_id = ?;", array($energy, $fighters_lost, $armor_lost, $playertorpnum, $rating_change, $playerinfo['ship_id']) @@ -764,8 +764,8 @@ $energy = $targetinfo['ship_energy']; Tki\PlayerLog::writeLog($pdo_db, $targetinfo['ship_id'], \Tki\LogEnums::ATTACKED_WIN, "$playerinfo[character_name]|$armor_lost|$fighters_lost"); - $update4 = $db->Execute( - "UPDATE {$db->prefix}ships SET ship_energy = ?, ship_fighters = ship_fighters - ?, armor_pts = armor_pts - ?, " . + $update4 = $old_db->Execute( + "UPDATE {$old_db->prefix}ships SET ship_energy = ?, ship_fighters = ship_fighters - ?, armor_pts = armor_pts - ?, " . "torps = torps - ? WHERE ship_id = ?;", array($energy, $fighters_lost, $armor_lost, $targettorpnum, $targetinfo['ship_id']) ); @@ -775,8 +775,8 @@ $fighters_lost = $playerinfo['ship_fighters'] - $playerfighters; $energy = $playerinfo['ship_energy']; - $update4b = $db->Execute( - "UPDATE {$db->prefix}ships SET ship_energy = ?, ship_fighters = ship_fighters - ?, armor_pts = armor_pts - ?, torps = torps - ?, " . + $update4b = $old_db->Execute( + "UPDATE {$old_db->prefix}ships SET ship_energy = ?, ship_fighters = ship_fighters - ?, armor_pts = armor_pts - ?, torps = torps - ?, " . "turns = turns - 1, turns_used = turns_used + 1, rating = rating - ? " . "WHERE ship_id = ?;", array($energy, $fighters_lost, $armor_lost, $playertorpnum, $rating_change, $playerinfo['ship_id']) @@ -792,8 +792,8 @@ { $rating = round($playerinfo['rating'] / 2); echo $langvars['l_att_loosepod'] . "

"; - $resx = $db->Execute( - "UPDATE {$db->prefix}ships SET hull = 0, engines = 0, power = 0, sensors = 0, computer = 0, beams = 0, torp_launchers = 0, torps = 0, " . + $resx = $old_db->Execute( + "UPDATE {$old_db->prefix}ships SET hull = 0, engines = 0, power = 0, sensors = 0, computer = 0, beams = 0, torp_launchers = 0, torps = 0, " . "armor = 0, armor_pts = 100, cloak = 0, shields = 0, sector = 1, ship_organics = 0, ship_ore = 0, ship_goods = 0, ship_energy = ?, " . "ship_colonists = 0, ship_fighters = 100, dev_warpedit = 0, dev_genesis = 0, dev_beacon = 0, dev_emerwarp = 0, dev_escapepod = 'N', " . "dev_fuelscoop = 'N', dev_minedeflector = 0, on_planet = 'N', rating = ?, dev_lssd = 'N' " . @@ -875,8 +875,8 @@ $langvars['l_att_salv'] = str_replace("[name]", $targetinfo['character_name'], $langvars['l_att_salv']); echo $langvars['l_att_salv'] . "
"; - $update6 = $db->Execute( - "UPDATE {$db->prefix}ships SET credits = credits + ?," . + $update6 = $old_db->Execute( + "UPDATE {$old_db->prefix}ships SET credits = credits + ?," . "ship_ore = ship_ore + ?, ship_organics = ship_organics + ?, " . "ship_goods = ship_goods + ? WHERE ship_id = ?;", array($ship_salvage, $salv_ore, $salv_organics, $salv_goods, $targetinfo['ship_id']) @@ -885,8 +885,8 @@ $armor_lost = $targetinfo['armor_pts'] - $targetarmor; $fighters_lost = $targetinfo['ship_fighters'] - $targetfighters; $energy = $targetinfo['ship_energy']; - $update6b = $db->Execute( - "UPDATE {$db->prefix}ships SET ship_energy = ?, " . + $update6b = $old_db->Execute( + "UPDATE {$old_db->prefix}ships SET ship_energy = ?, " . "ship_fighters = ship_fighters - ?, armor_pts = armor_pts - ?, " . "torps = torps - ? WHERE ship_id = ?;", array($energy, $fighters_lost, $armor_lost, $targettorpnum, $targetinfo['ship_id']) diff --git a/bounty.php b/bounty.php index d9d73a1e4..60336267e 100644 --- a/bounty.php +++ b/bounty.php @@ -87,7 +87,7 @@ switch ($response) { case 'display': echo "

" . $title . "

\n"; - $res5 = $db->Execute("SELECT * FROM {$db->prefix}ships, {$db->prefix}bounty WHERE bounty_on = ship_id AND bounty_on = ?;", array($bounty_on)); + $res5 = $old_db->Execute("SELECT * FROM {$old_db->prefix}ships, {$old_db->prefix}bounty WHERE bounty_on = ship_id AND bounty_on = ?;", array($bounty_on)); Tki\Db::logDbErrors($pdo_db, $res5, __LINE__, __FILE__); $j = 0; if ($res5) @@ -167,7 +167,7 @@ die(); } - $res = $db->Execute("SELECT * FROM {$db->prefix}bounty WHERE bounty_id = ?;", array($bid)); + $res = $old_db->Execute("SELECT * FROM {$old_db->prefix}bounty WHERE bounty_id = ?;", array($bid)); Tki\Db::logDbErrors($pdo_db, $res, __LINE__, __FILE__); if (!$res || $res->RowCount() == 0) { @@ -190,7 +190,7 @@ die(); } - $del = $db->Execute("DELETE FROM {$db->prefix}bounty WHERE bounty_id = ?;", array($bid)); + $del = $old_db->Execute("DELETE FROM {$old_db->prefix}bounty WHERE bounty_id = ?;", array($bid)); Tki\Db::logDbErrors($pdo_db, $del, __LINE__, __FILE__); $cur_time_stamp = date("Y-m-d H:i:s"); $refund = $bty['amount']; @@ -207,7 +207,7 @@ die(); case 'place': echo "

" . $title . "

\n"; - $ex = $db->Execute("SELECT * FROM {$db->prefix}ships WHERE ship_id = ?;", array($bounty_on)); + $ex = $old_db->Execute("SELECT * FROM {$old_db->prefix}ships WHERE ship_id = ?;", array($bounty_on)); Tki\Db::logDbErrors($pdo_db, $ex, __LINE__, __FILE__); if (!$ex) { @@ -277,7 +277,7 @@ $score = Tki\Score::updateScore($pdo_db, $playerinfo['ship_id'], $tkireg, $playerinfo); $maxtrans = $score * $score * $tkireg->max_bountyvalue; $previous_bounty = 0; - $pb = $db->Execute("SELECT SUM(amount) AS totalbounty FROM {$db->prefix}bounty WHERE bounty_on = ? AND placed_by = ?;", array($bounty_on, $playerinfo['ship_id'])); + $pb = $old_db->Execute("SELECT SUM(amount) AS totalbounty FROM {$old_db->prefix}bounty WHERE bounty_on = ? AND placed_by = ?;", array($bounty_on, $playerinfo['ship_id'])); Tki\Db::logDbErrors($pdo_db, $pb, __LINE__, __FILE__); if ($pb) { @@ -297,7 +297,7 @@ } } - $insert = $db->Execute("INSERT INTO {$db->prefix}bounty (bounty_on, placed_by, amount) values (?, ?, ?);", array($bounty_on, $playerinfo['ship_id'], $amount)); + $insert = $old_db->Execute("INSERT INTO {$old_db->prefix}bounty (bounty_on, placed_by, amount) values (?, ?, ?);", array($bounty_on, $playerinfo['ship_id'], $amount)); Tki\Db::logDbErrors($pdo_db, $insert, __LINE__, __FILE__); $cur_time_stamp = date("Y-m-d H:i:s"); @@ -313,7 +313,7 @@ die(); default: echo "

" . $title . "

\n"; - $res = $db->Execute("SELECT * FROM {$db->prefix}ships WHERE ship_destroyed = 'N' AND ship_id <> ? ORDER BY character_name ASC;", array($playerinfo['ship_id'])); + $res = $old_db->Execute("SELECT * FROM {$old_db->prefix}ships WHERE ship_destroyed = 'N' AND ship_id <> ? ORDER BY character_name ASC;", array($playerinfo['ship_id'])); Tki\Db::logDbErrors($pdo_db, $res, __LINE__, __FILE__); echo "
"; echo ""; @@ -342,7 +342,7 @@ echo ""; echo ""; - $result3 = $db->Execute("SELECT bounty_on, SUM(amount) as total_bounty FROM {$db->prefix}bounty GROUP BY bounty_on;"); + $result3 = $old_db->Execute("SELECT bounty_on, SUM(amount) as total_bounty FROM {$old_db->prefix}bounty GROUP BY bounty_on;"); Tki\Db::logDbErrors($pdo_db, $result3, __LINE__, __FILE__); $i = 0; diff --git a/classes/CheckDefenses.php b/classes/CheckDefenses.php index 389d2397c..877e14f25 100644 --- a/classes/CheckDefenses.php +++ b/classes/CheckDefenses.php @@ -236,7 +236,7 @@ public static function sectorFighters(\PDO $pdo_db, string $lang, int $sector, s } } - public static function fighters(\PDO $pdo_db, $db, string $lang, int $sector, $playerinfo, $tkireg, $title, $calledfrom): void + public static function fighters(\PDO $pdo_db, $old_db, string $lang, int $sector, $playerinfo, $tkireg, $title, $calledfrom): void { // Database driven language entries $langvars = \Tki\Translate::load($pdo_db, $lang, array('check_defenses', 'common', 'global_includes', 'global_funcs', 'combat', 'footer', 'news', 'regional')); @@ -247,7 +247,7 @@ public static function fighters(\PDO $pdo_db, $db, string $lang, int $sector, $p $sectorinfo = $sectors_gateway->selectSectorInfo($sector); */ - $result3 = $db->Execute("SELECT * FROM {$db->prefix}sector_defense WHERE sector_id = ? and defense_type ='F' ORDER BY quantity DESC;", array($sector)); + $result3 = $old_db->Execute("SELECT * FROM {$old_db->prefix}sector_defense WHERE sector_id = ? and defense_type ='F' ORDER BY quantity DESC;", array($sector)); \Tki\Db::logDbErrors($pdo_db, $result3, __LINE__, __FILE__); // Put the defense information into the array defenses @@ -296,7 +296,7 @@ public static function fighters(\PDO $pdo_db, $db, string $lang, int $sector, $p // Find out if the fighter owner and player are on the same team // All sector defenses must be owned by members of the same team $fm_owner = $defenses[0]['ship_id']; - $result2 = $db->Execute("SELECT * FROM {$db->prefix}ships WHERE ship_id = ?;", array($fm_owner)); + $result2 = $old_db->Execute("SELECT * FROM {$old_db->prefix}ships WHERE ship_id = ?;", array($fm_owner)); \Tki\Db::logDbErrors($pdo_db, $result2, __LINE__, __FILE__); $fighters_owner = $result2->fields; if ($fighters_owner['team'] != $playerinfo['team'] || $playerinfo['team'] == 0) @@ -304,17 +304,17 @@ public static function fighters(\PDO $pdo_db, $db, string $lang, int $sector, $p switch ($response) { case "fight": - $resx = $db->Execute("UPDATE {$db->prefix}ships SET cleared_defenses = ' ' WHERE ship_id = ?;", array($playerinfo['ship_id'])); + $resx = $old_db->Execute("UPDATE {$old_db->prefix}ships SET cleared_defenses = ' ' WHERE ship_id = ?;", array($playerinfo['ship_id'])); \Tki\Db::logDbErrors($pdo_db, $resx, __LINE__, __FILE__); echo "

" . $title . "

\n"; \Tki\CheckDefenses::sectorFighters($pdo_db, $lang, $sector, $calledfrom, 0, $playerinfo, $tkireg, $title); break; case "retreat": - $resx = $db->Execute("UPDATE {$db->prefix}ships SET cleared_defenses = ' ' WHERE ship_id = ?;", array($playerinfo['ship_id'])); + $resx = $old_db->Execute("UPDATE {$old_db->prefix}ships SET cleared_defenses = ' ' WHERE ship_id = ?;", array($playerinfo['ship_id'])); \Tki\Db::logDbErrors($pdo_db, $resx, __LINE__, __FILE__); $cur_time_stamp = date("Y-m-d H:i:s"); - $resx = $db->Execute("UPDATE {$db->prefix}ships SET last_login='$cur_time_stamp', turns = turns - 2, turns_used = turns_used + 2, sector=? WHERE ship_id=?;", array($playerinfo['sector'], $playerinfo['ship_id'])); + $resx = $old_db->Execute("UPDATE {$old_db->prefix}ships SET last_login='$cur_time_stamp', turns = turns - 2, turns_used = turns_used + 2, sector=? WHERE ship_id=?;", array($playerinfo['sector'], $playerinfo['ship_id'])); \Tki\Db::logDbErrors($pdo_db, $resx, __LINE__, __FILE__); echo "

" . $title . "

\n"; echo $langvars['l_chf_youretreatback'] . "
"; @@ -322,7 +322,7 @@ public static function fighters(\PDO $pdo_db, $db, string $lang, int $sector, $p die(); case "pay": - $resx = $db->Execute("UPDATE {$db->prefix}ships SET cleared_defenses = ' ' WHERE ship_id = ?;", array($playerinfo['ship_id'])); + $resx = $old_db->Execute("UPDATE {$old_db->prefix}ships SET cleared_defenses = ' ' WHERE ship_id = ?;", array($playerinfo['ship_id'])); \Tki\Db::logDbErrors($pdo_db, $resx, __LINE__, __FILE__); $fighterstoll = (int) round($total_sec_fighters * $tkireg->fighter_price * 0.6); if ($playerinfo['credits'] < $fighterstoll) @@ -331,7 +331,7 @@ public static function fighters(\PDO $pdo_db, $db, string $lang, int $sector, $p echo $langvars['l_chf_movefailed'] . "
"; // Undo the move - $resx = $db->Execute("UPDATE {$db->prefix}ships SET sector=? WHERE ship_id=?;", array($playerinfo['sector'], $playerinfo['ship_id'])); + $resx = $old_db->Execute("UPDATE {$old_db->prefix}ships SET sector=? WHERE ship_id=?;", array($playerinfo['sector'], $playerinfo['ship_id'])); \Tki\Db::logDbErrors($pdo_db, $resx, __LINE__, __FILE__); $ok = 0; } @@ -340,7 +340,7 @@ public static function fighters(\PDO $pdo_db, $db, string $lang, int $sector, $p $tollstring = number_format($fighterstoll, 0, $langvars['local_number_dec_point'], $langvars['local_number_thousands_sep']); $langvars['l_chf_youpaidsometoll'] = str_replace("[chf_tollstring]", $tollstring, $langvars['l_chf_youpaidsometoll']); echo $langvars['l_chf_youpaidsometoll'] . "
"; - $resx = $db->Execute("UPDATE {$db->prefix}ships SET credits=credits - $fighterstoll WHERE ship_id = ?;", array($playerinfo['ship_id'])); + $resx = $old_db->Execute("UPDATE {$old_db->prefix}ships SET credits=credits - $fighterstoll WHERE ship_id = ?;", array($playerinfo['ship_id'])); \Tki\Db::logDbErrors($pdo_db, $resx, __LINE__, __FILE__); \Tki\Toll::distribute($pdo_db, $sector, $fighterstoll, (int) $total_sec_fighters); \Tki\PlayerLog::writeLog($pdo_db, $playerinfo['ship_id'], \Tki\LogEnums::TOLL_PAID, "$tollstring|$sector"); @@ -349,7 +349,7 @@ public static function fighters(\PDO $pdo_db, $db, string $lang, int $sector, $p break; case "sneak": - $resx = $db->Execute("UPDATE {$db->prefix}ships SET cleared_defenses = ' ' WHERE ship_id = ?;", array($playerinfo['ship_id'])); + $resx = $old_db->Execute("UPDATE {$old_db->prefix}ships SET cleared_defenses = ' ' WHERE ship_id = ?;", array($playerinfo['ship_id'])); \Tki\Db::logDbErrors($pdo_db, $resx, __LINE__, __FILE__); $success = \Tki\Scan::success($fighters_owner['sensors'], $playerinfo['cloak']); if ($success < 5) @@ -380,7 +380,7 @@ public static function fighters(\PDO $pdo_db, $db, string $lang, int $sector, $p default: $interface_string = $calledfrom . '?sector=' . $sector . '&destination=' . $destination . '&engage=' . $engage; - $resx = $db->Execute("UPDATE {$db->prefix}ships SET cleared_defenses = ? WHERE ship_id = ?;", array($interface_string, $playerinfo['ship_id'])); + $resx = $old_db->Execute("UPDATE {$old_db->prefix}ships SET cleared_defenses = ? WHERE ship_id = ?;", array($interface_string, $playerinfo['ship_id'])); \Tki\Db::logDbErrors($pdo_db, $resx, __LINE__, __FILE__); $fighterstoll = (int) round($total_sec_fighters * $tkireg->fighter_price * 0.6); echo "

" . $title . "

\n"; @@ -418,13 +418,13 @@ public static function fighters(\PDO $pdo_db, $db, string $lang, int $sector, $p } // Clean up any sectors that have used up all mines or fighters - $resx = $db->Execute("DELETE FROM {$db->prefix}sector_defense WHERE quantity <= 0 "); + $resx = $old_db->Execute("DELETE FROM {$old_db->prefix}sector_defense WHERE quantity <= 0 "); \Tki\Db::logDbErrors($pdo_db, $resx, __LINE__, __FILE__); } } } - public static function mines(\PDO $pdo_db, $db, string $lang, int $sector, string $title, array $playerinfo, $tkireg): void + public static function mines(\PDO $pdo_db, $old_db, string $lang, int $sector, string $title, array $playerinfo, $tkireg): void { // Database driven language entries $langvars = \Tki\Translate::load($pdo_db, $lang, array('check_defenses', 'common', 'global_includes', 'combat', 'footer', 'news')); @@ -434,7 +434,7 @@ public static function mines(\PDO $pdo_db, $db, string $lang, int $sector, strin //$sectorinfo = $sectors_gateway->selectSectorInfo($sector); // Put the defense information into the array defenseinfo - $result3 = $db->Execute("SELECT * FROM {$db->prefix}sector_defense WHERE sector_id = ? and defense_type ='M'", array($sector)); + $result3 = $old_db->Execute("SELECT * FROM {$old_db->prefix}sector_defense WHERE sector_id = ? and defense_type ='M'", array($sector)); \Tki\Db::logDbErrors($pdo_db, $result3, __LINE__, __FILE__); // Correct the targetship bug to reflect the player info @@ -471,7 +471,7 @@ public static function mines(\PDO $pdo_db, $db, string $lang, int $sector, strin { // Find out if the mine owner and player are on the same team $fm_owner = $defenses[0]['ship_id']; - $result2 = $db->Execute("SELECT * FROM {$db->prefix}ships WHERE ship_id = ?;", array($fm_owner)); + $result2 = $old_db->Execute("SELECT * FROM {$old_db->prefix}ships WHERE ship_id = ?;", array($fm_owner)); \Tki\Db::logDbErrors($pdo_db, $result2, __LINE__, __FILE__); $mine_owner = $result2->fields; @@ -504,7 +504,7 @@ public static function mines(\PDO $pdo_db, $db, string $lang, int $sector, strin { $langvars['l_chm_youlostminedeflectors'] = str_replace("[chm_roll]", (string) $roll, $langvars['l_chm_youlostminedeflectors']); echo $langvars['l_chm_youlostminedeflectors'] . "
"; - $result2 = $db->Execute("UPDATE {$db->prefix}ships SET dev_minedeflector = dev_minedeflector - ? WHERE ship_id = ?", array($roll, $playerinfo['ship_id'])); + $result2 = $old_db->Execute("UPDATE {$old_db->prefix}ships SET dev_minedeflector = dev_minedeflector - ? WHERE ship_id = ?", array($roll, $playerinfo['ship_id'])); \Tki\Db::logDbErrors($pdo_db, $result2, __LINE__, __FILE__); } else @@ -531,7 +531,7 @@ public static function mines(\PDO $pdo_db, $db, string $lang, int $sector, strin $langvars['l_chm_yourshieldshitforminesdmg'] = str_replace("[chm_mines_left]", (string) $mines_left, $langvars['l_chm_yourshieldshitforminesdmg']); echo $langvars['l_chm_yourshieldshitforminesdmg'] . "
"; - $result2 = $db->Execute("UPDATE {$db->prefix}ships SET ship_energy = ship_energy - ?, dev_minedeflector = 0 WHERE ship_id = ?", array($mines_left, $playerinfo['ship_id'])); + $result2 = $old_db->Execute("UPDATE {$old_db->prefix}ships SET ship_energy = ship_energy - ?, dev_minedeflector = 0 WHERE ship_id = ?", array($mines_left, $playerinfo['ship_id'])); \Tki\Db::logDbErrors($pdo_db, $result2, __LINE__, __FILE__); if ($playershields == $mines_left) { @@ -547,7 +547,7 @@ public static function mines(\PDO $pdo_db, $db, string $lang, int $sector, strin { $langvars['l_chm_yourarmorhitforminesdmg'] = str_replace("[chm_mines_left]", (string) $mines_left, $langvars['l_chm_yourarmorhitforminesdmg']); echo $langvars['l_chm_yourarmorhitforminesdmg'] . "
"; - $result2 = $db->Execute("UPDATE {$db->prefix}ships SET armor_pts = armor_pts - ?, ship_energy = 0, dev_minedeflector = 0 WHERE ship_id = ?", array($mines_left, $playerinfo['ship_id'])); + $result2 = $old_db->Execute("UPDATE {$old_db->prefix}ships SET armor_pts = armor_pts - ?, ship_energy = 0, dev_minedeflector = 0 WHERE ship_id = ?", array($mines_left, $playerinfo['ship_id'])); \Tki\Db::logDbErrors($pdo_db, $result2, __LINE__, __FILE__); if ($playerinfo['armor_pts'] == $mines_left) { @@ -569,7 +569,7 @@ public static function mines(\PDO $pdo_db, $db, string $lang, int $sector, strin { $rating = round($playerinfo['rating'] / 2); echo $langvars['l_chm_luckescapepod'] . "

"; - $resx = $db->Execute("UPDATE {$db->prefix}ships SET hull=0, engines=0, power=0, sensors=0, computer=0, beams=0, torp_launchers=0, torps=0, armor=0, armor_pts=100, cloak=0, shields=0, sector=1, ship_organics=0, ship_ore=0, ship_goods=0, ship_energy=?, ship_colonists=0, ship_fighters=100, dev_warpedit=0, dev_genesis=0, dev_beacon=0, dev_emerwarp=0, dev_escapepod='N', dev_fuelscoop='N', dev_minedeflector=0, on_planet='N', rating=?, cleared_defenses=' ', dev_lssd='N' WHERE ship_id=?", array(100, $rating, $playerinfo['ship_id'])); + $resx = $old_db->Execute("UPDATE {$old_db->prefix}ships SET hull=0, engines=0, power=0, sensors=0, computer=0, beams=0, torp_launchers=0, torps=0, armor=0, armor_pts=100, cloak=0, shields=0, sector=1, ship_organics=0, ship_ore=0, ship_goods=0, ship_energy=?, ship_colonists=0, ship_fighters=100, dev_warpedit=0, dev_genesis=0, dev_beacon=0, dev_emerwarp=0, dev_escapepod='N', dev_fuelscoop='N', dev_minedeflector=0, on_planet='N', rating=?, cleared_defenses=' ', dev_lssd='N' WHERE ship_id=?", array(100, $rating, $playerinfo['ship_id'])); \Tki\Db::logDbErrors($pdo_db, $resx, __LINE__, __FILE__); $bounty = new \Tki\Bounty(); diff --git a/classes/Db.php b/classes/Db.php index ce9cbbb1f..6c035cf40 100644 --- a/classes/Db.php +++ b/classes/Db.php @@ -66,20 +66,20 @@ public function initDb(string $db_layer) $db_host .= ":$db_port"; } - $db = null; + $old_db = null; // Attempt to connect to the database try { if (SecureConfig::DB_TYPE === 'postgres9') { - $db = \ADONewConnection('postgres9'); + $old_db = \ADONewConnection('postgres9'); } else { - $db = \ADONewConnection('mysqli'); + $old_db = \ADONewConnection('mysqli'); } - $db_init_result = $db->Connect($db_host, $db_user, $db_pwd, $db_name); + $db_init_result = $old_db->Connect($db_host, $db_user, $db_pwd, $db_name); // Returns Bool true or false. // However ADOdb's postgres driver returns null if postgres insn't installed. @@ -90,10 +90,10 @@ public function initDb(string $db_layer) else { // We have connected successfully. Now set our character set to utf-8 - $db->Execute("SET NAMES 'utf8mb4' COLLATE 'utf8mb4_unicode_ci'"); + $old_db->Execute("SET NAMES 'utf8mb4' COLLATE 'utf8mb4_unicode_ci'"); // Set the fetch mode for database calls to be associative by default - $db->SetFetchMode(ADODB_FETCH_ASSOC); + $old_db->SetFetchMode(ADODB_FETCH_ASSOC); } } catch (\Exception $e) @@ -106,7 +106,7 @@ public function initDb(string $db_layer) $db->prefix = $db_prefix; // End of database work - return $db; + return $old_db; } else { diff --git a/classes/KabalHunt.php b/classes/KabalHunt.php index 64773dff9..5b33dfdfc 100644 --- a/classes/KabalHunt.php +++ b/classes/KabalHunt.php @@ -26,10 +26,10 @@ class KabalHunt { - public static function hunt(\PDO $pdo_db, $db, array $playerinfo, int $kabalisdead, array $langvars, Reg $tkireg): void + public static function hunt(\PDO $pdo_db, $old_db, array $playerinfo, int $kabalisdead, array $langvars, Reg $tkireg): void { $targetinfo = array(); - $rescount = $db->Execute("SELECT COUNT(*) AS num_players FROM {$db->prefix}ships WHERE ship_destroyed='N' AND email NOT LIKE '%@kabal' AND ship_id > 1"); + $rescount = $old_db->Execute("SELECT COUNT(*) AS num_players FROM {$old_db->prefix}ships WHERE ship_destroyed='N' AND email NOT LIKE '%@kabal' AND ship_id > 1"); \Tki\Db::logDbErrors($pdo_db, $rescount, __LINE__, __FILE__); $rowcount = $rescount->fields; $topnum = min(10, $rowcount['num_players']); @@ -40,7 +40,7 @@ public static function hunt(\PDO $pdo_db, $db, array $playerinfo, int $kabalisde return; } - $res = $db->SelectLimit("SELECT * FROM {$db->prefix}ships WHERE ship_destroyed='N' AND email NOT LIKE '%@kabal' AND ship_id > 1 ORDER BY score DESC", $topnum); + $res = $old_db->SelectLimit("SELECT * FROM {$old_db->prefix}ships WHERE ship_destroyed='N' AND email NOT LIKE '%@kabal' AND ship_id > 1 ORDER BY score DESC", $topnum); \Tki\Db::logDbErrors($pdo_db, $res, __LINE__, __FILE__); // Choose a target from the top player list @@ -96,7 +96,7 @@ public static function hunt(\PDO $pdo_db, $db, array $playerinfo, int $kabalisde \Tki\PlayerLog::writeLog($pdo_db, $playerinfo['ship_id'], LogEnums::RAW, "Kabal used a wormhole to warp to sector $targetinfo[sector] where he is hunting player $targetinfo[character_name]."); if (!$result) { - $error = $db->ErrorMsg(); + $error = $old_db->ErrorMsg(); \Tki\PlayerLog::writeLog($pdo_db, $playerinfo['ship_id'], LogEnums::RAW, "Move failed with error: $error "); return; @@ -156,7 +156,7 @@ public static function hunt(\PDO $pdo_db, $db, array $playerinfo, int $kabalisde if ($targetinfo['planet_id'] > 0) // Is player target on a planet? { - \Tki\KabalToPlanet::planet($pdo_db, $db, $targetinfo['planet_id'], $tkireg, $playerinfo, $langvars); // Yes, so move to that planet + \Tki\KabalToPlanet::planet($pdo_db, $old_db, $targetinfo['planet_id'], $tkireg, $playerinfo, $langvars); // Yes, so move to that planet } else { diff --git a/classes/KabalMove.php b/classes/KabalMove.php index b09f8c861..ed7e76b2c 100644 --- a/classes/KabalMove.php +++ b/classes/KabalMove.php @@ -26,7 +26,7 @@ class KabalMove { - public static function move(\PDO $pdo_db, $db, array $playerinfo, int $targetlink, array $langvars, Reg $tkireg): void + public static function move(\PDO $pdo_db, $old_db, array $playerinfo, int $targetlink, array $langvars, Reg $tkireg): void { // Obtain a target link if ($targetlink == $playerinfo['sector']) @@ -44,11 +44,11 @@ public static function move(\PDO $pdo_db, $db, array $playerinfo, int $targetlin foreach ($links_present as $row) { // Obtain sector information - $sectres = $db->Execute("SELECT sector_id,zone_id FROM {$db->prefix}universe WHERE sector_id = ?;", array($row['link_dest'])); + $sectres = $old_db->Execute("SELECT sector_id,zone_id FROM {$old_db->prefix}universe WHERE sector_id = ?;", array($row['link_dest'])); \Tki\Db::logDbErrors($pdo_db, $sectres, __LINE__, __FILE__); $sectrow = $sectres->fields; - $zoneres = $db->Execute("SELECT zone_id,allow_attack FROM {$db->prefix}zones WHERE zone_id = ?;", array($sectrow['zone_id'])); + $zoneres = $old_db->Execute("SELECT zone_id,allow_attack FROM {$old_db->prefix}zones WHERE zone_id = ?;", array($sectrow['zone_id'])); \Tki\Db::logDbErrors($pdo_db, $zoneres, __LINE__, __FILE__); $zonerow = $zoneres->fields; if ($zonerow['allow_attack'] == "Y") // Dest link must allow attacking @@ -69,11 +69,11 @@ public static function move(\PDO $pdo_db, $db, array $playerinfo, int $targetlin while (!$targetlink > 0 && $limitloop < 15) { // Obtain sector information - $sectres = $db->Execute("SELECT sector_id,zone_id FROM {$db->prefix}universe WHERE sector_id = ?;", array($wormto)); + $sectres = $old_db->Execute("SELECT sector_id,zone_id FROM {$old_db->prefix}universe WHERE sector_id = ?;", array($wormto)); \Tki\Db::logDbErrors($pdo_db, $sectres, __LINE__, __FILE__); $sectrow = $sectres->fields; - $zoneres = $db->Execute("SELECT zone_id,allow_attack FROM {$db->prefix}zones WHERE zone_id = ?;", array($sectrow['zone_id'])); + $zoneres = $old_db->Execute("SELECT zone_id,allow_attack FROM {$old_db->prefix}zones WHERE zone_id = ?;", array($sectrow['zone_id'])); \Tki\Db::logDbErrors($pdo_db, $zoneres, __LINE__, __FILE__); $zonerow = $zoneres->fields; if ($zonerow['allow_attack'] == "Y") @@ -158,7 +158,7 @@ public static function move(\PDO $pdo_db, $db, array $playerinfo, int $targetlin if (!$result) { - $error = $db->ErrorMsg(); + $error = $old_db->ErrorMsg(); \Tki\PlayerLog::writeLog($pdo_db, $playerinfo['ship_id'], LogEnums::RAW, "Move failed with error: $error "); } } diff --git a/classes/KabalToPlanet.php b/classes/KabalToPlanet.php index 973da4032..2c099ecde 100644 --- a/classes/KabalToPlanet.php +++ b/classes/KabalToPlanet.php @@ -26,7 +26,7 @@ class KabalToPlanet { - public static function planet(\PDO $pdo_db, $db, int $planet_id, Reg $tkireg, array $playerinfo, array $langvars): void + public static function planet(\PDO $pdo_db, $old_db, int $planet_id, Reg $tkireg, array $playerinfo, array $langvars): void { // Get planetinfo from database $planets_gateway = new \Tki\Planets\PlanetsGateway($pdo_db); // Build a planet gateway object to handle the SQL calls @@ -279,7 +279,7 @@ public static function planet(\PDO $pdo_db, $db, int $planet_id, Reg $tkireg, ar \Tki\PlayerLog::writeLog($pdo_db, $planetinfo['owner'], LogEnums::PLANET_NOT_DEFEATED, "$planetinfo[name]|$playerinfo[sector]|Kabal $playerinfo[character_name]|$free_ore|$free_organics|$free_goods|$ship_salvage_rate|$ship_salvage"); // Update planet - $resi = $db->Execute("UPDATE {$db->prefix}planets SET energy = ?, fighters = fighters - ?, torps = torps - ?, ore = ore + ?, goods = goods + ?, organics = organics + ?, credits = credits + ? WHERE planet_id = ?;", array($planetinfo['energy'], $fighters_lost, $targettorps, $free_ore, $free_goods, $free_organics, $ship_salvage, $planetinfo['planet_id'])); + $resi = $old_db->Execute("UPDATE {$old_db->prefix}planets SET energy = ?, fighters = fighters - ?, torps = torps - ?, ore = ore + ?, goods = goods + ?, organics = organics + ?, credits = credits + ? WHERE planet_id = ?;", array($planetinfo['energy'], $fighters_lost, $targettorps, $free_ore, $free_goods, $free_organics, $ship_salvage, $planetinfo['planet_id'])); \Tki\Db::logDbErrors($pdo_db, $resi, __LINE__, __FILE__); } else // Must have made it past planet defenses @@ -289,20 +289,20 @@ public static function planet(\PDO $pdo_db, $db, int $planet_id, Reg $tkireg, ar \Tki\PlayerLog::writeLog($pdo_db, $playerinfo['ship_id'], LogEnums::RAW, "Made it past defenses on planet $planetinfo[name]"); // Update attackers - $resj = $db->Execute("UPDATE {$db->prefix}ships SET ship_energy = ?, ship_fighters = ship_fighters - ?, torps = torps - ?, armor_pts = armor_pts - ? WHERE ship_id = ?;", array($playerinfo['ship_energy'], $fighters_lost, $attackertorps, $armor_lost, $playerinfo['ship_id'])); + $resj = $old_db->Execute("UPDATE {$old_db->prefix}ships SET ship_energy = ?, ship_fighters = ship_fighters - ?, torps = torps - ?, armor_pts = armor_pts - ? WHERE ship_id = ?;", array($playerinfo['ship_energy'], $fighters_lost, $attackertorps, $armor_lost, $playerinfo['ship_id'])); \Tki\Db::logDbErrors($pdo_db, $resj, __LINE__, __FILE__); $playerinfo['ship_fighters'] = $attackerfighters; $playerinfo['torps'] = $attackertorps; $playerinfo['armor_pts'] = $attackerarmor; // Update planet - $resk = $db->Execute("UPDATE {$db->prefix}planets SET energy = ?, fighters = ?, torps = torps - ? WHERE planet_id = ?", array($planetinfo['energy'], $targetfighters, $targettorps, $planetinfo['planet_id'])); + $resk = $old_db->Execute("UPDATE {$old_db->prefix}planets SET energy = ?, fighters = ?, torps = torps - ? WHERE planet_id = ?", array($planetinfo['energy'], $targetfighters, $targettorps, $planetinfo['planet_id'])); \Tki\Db::logDbErrors($pdo_db, $resk, __LINE__, __FILE__); $planetinfo['fighters'] = $targetfighters; $planetinfo['torps'] = $targettorps; // Now we must attack all ships on the planet one by one - $resultps = $db->Execute("SELECT ship_id,ship_name FROM {$db->prefix}ships WHERE planet_id = ? AND on_planet = 'Y'", array($planetinfo['planet_id'])); + $resultps = $old_db->Execute("SELECT ship_id,ship_name FROM {$old_db->prefix}ships WHERE planet_id = ? AND on_planet = 'Y'", array($planetinfo['planet_id'])); \Tki\Db::logDbErrors($pdo_db, $resultps, __LINE__, __FILE__); $shipsonplanet = $resultps->RecordCount(); if ($shipsonplanet > 0) @@ -315,7 +315,7 @@ public static function planet(\PDO $pdo_db, $db, int $planet_id, Reg $tkireg, ar } } - $resultps = $db->Execute("SELECT ship_id,ship_name FROM {$db->prefix}ships WHERE planet_id = ? AND on_planet = 'Y'", array($planetinfo['planet_id'])); + $resultps = $old_db->Execute("SELECT ship_id,ship_name FROM {$old_db->prefix}ships WHERE planet_id = ? AND on_planet = 'Y'", array($planetinfo['planet_id'])); \Tki\Db::logDbErrors($pdo_db, $resultps, __LINE__, __FILE__); $shipsonplanet = $resultps->RecordCount(); if ($shipsonplanet == 0) @@ -327,7 +327,7 @@ public static function planet(\PDO $pdo_db, $db, int $planet_id, Reg $tkireg, ar \Tki\PlayerLog::writeLog($pdo_db, $planetinfo['owner'], LogEnums::PLANET_DEFEATED, "$planetinfo[name]|$playerinfo[sector]|$playerinfo[character_name]"); // Update planet - $resl = $db->Execute("UPDATE {$db->prefix}planets SET fighters=0, torps=0, base='N', owner=0, team=0 WHERE planet_id = ?", array($planetinfo['planet_id'])); + $resl = $old_db->Execute("UPDATE {$old_db->prefix}planets SET fighters=0, torps=0, base='N', owner=0, team=0 WHERE planet_id = ?", array($planetinfo['planet_id'])); \Tki\Db::logDbErrors($pdo_db, $resl, __LINE__, __FILE__); \Tki\Ownership::calc($pdo_db, $planetinfo['sector_id'], $tkireg->min_bases_to_own, $langvars); diff --git a/classes/PlanetCombat.php b/classes/PlanetCombat.php index 8d1fca442..4f5854f87 100644 --- a/classes/PlanetCombat.php +++ b/classes/PlanetCombat.php @@ -26,7 +26,7 @@ class PlanetCombat { - public static function prime(\PDO $pdo_db, $db, string $lang, array $langvars, Reg $tkireg, Smarty $template, array $playerinfo, array $ownerinfo, array $planetinfo): bool + public static function prime(\PDO $pdo_db, $old_db, string $lang, array $langvars, Reg $tkireg, Smarty $template, array $playerinfo, array $ownerinfo, array $planetinfo): bool { if ($playerinfo['turns'] < 1) { @@ -346,7 +346,7 @@ public static function prime(\PDO $pdo_db, $db, string $lang, array $langvars, R echo "
\n"; // Send each docked ship in sequence to attack agressor - $result4 = $db->Execute("SELECT * FROM {$db->prefix}ships WHERE planet_id = ? AND on_planet = 'Y'", array($planetinfo['planet_id'])); + $result4 = $old_db->Execute("SELECT * FROM {$old_db->prefix}ships WHERE planet_id = ? AND on_planet = 'Y'", array($planetinfo['planet_id'])); \Tki\Db::logDbErrors($pdo_db, $result4, __LINE__, __FILE__); $shipsonplanet = $result4->RecordCount(); @@ -466,7 +466,7 @@ public static function prime(\PDO $pdo_db, $db, string $lang, array $langvars, R \Tki\Db::logDbErrors($pdo_db, $sql, __LINE__, __FILE__); } - $result4 = $db->Execute("SELECT * FROM {$db->prefix}ships WHERE planet_id = ? AND on_planet = 'Y';", array($planetinfo['planet_id'])); + $result4 = $old_db->Execute("SELECT * FROM {$old_db->prefix}ships WHERE planet_id = ? AND on_planet = 'Y';", array($planetinfo['planet_id'])); \Tki\Db::logDbErrors($pdo_db, $result4, __LINE__, __FILE__); $shipsonplanet = $result4->RecordCount(); @@ -482,10 +482,10 @@ public static function prime(\PDO $pdo_db, $db, string $lang, array $langvars, R if ($roll > $self_tech) { // Reset Planet Assets. - $sql = "UPDATE {$db->prefix}planets "; + $sql = "UPDATE {$old_db->prefix}planets "; $sql .= "SET organics = '0', ore = '0', goods = '0', energy = '0', colonists = '2', credits = '0', fighters = '0', torps = '0', team = '0', base = 'N', sells = 'N', prod_organics = '20', prod_ore = '20', prod_goods = '20', prod_energy = '20', prod_fighters = '10', prod_torp = '10' "; $sql .= "WHERE planet_id = ? LIMIT 1;"; - $resx = $db->Execute($sql, array($planetinfo['planet_id'])); + $resx = $old_db->Execute($sql, array($planetinfo['planet_id'])); \Tki\Db::logDbErrors($pdo_db, $resx, __LINE__, __FILE__); echo "
The planet become unstable due to not being looked after, and all life and assets have been destroyed.
\n"; } @@ -501,7 +501,7 @@ public static function prime(\PDO $pdo_db, $db, string $lang, array $langvars, R if ($playerscore < $planetscore) { echo "
" . $langvars['l_cmb_citizenswanttodie'] . "


"; - $resx = $db->Execute("DELETE FROM {$db->prefix}planets WHERE planet_id = ?;", array($planetinfo['planet_id'])); + $resx = $old_db->Execute("DELETE FROM {$old_db->prefix}planets WHERE planet_id = ?;", array($planetinfo['planet_id'])); \Tki\Db::logDbErrors($pdo_db, $resx, __LINE__, __FILE__); \Tki\PlayerLog::writeLog($pdo_db, $ownerinfo['ship_id'], LogEnums::PLANET_DEFEATED_D, "$planetinfo[name]|$playerinfo[sector]|$playerinfo[character_name]"); $admin_log = new AdminLog(); @@ -514,7 +514,7 @@ public static function prime(\PDO $pdo_db, $db, string $lang, array $langvars, R echo "
" . $langvars['l_cmb_youmaycapture'] . "


"; \Tki\PlayerLog::writeLog($pdo_db, $ownerinfo['ship_id'], LogEnums::PLANET_DEFEATED, "$planetinfo[name]|$playerinfo[sector]|$playerinfo[character_name]"); \Tki\Score::updateScore($pdo_db, $ownerinfo['ship_id'], $tkireg, $playerinfo); - $update7a = $db->Execute("UPDATE {$db->prefix}planets SET owner=0, fighters=0, torps=torps-?, base='N', defeated='Y' WHERE planet_id = ?;", array($planettorps, $planetinfo['planet_id'])); + $update7a = $old_db->Execute("UPDATE {$old_db->prefix}planets SET owner=0, fighters=0, torps=torps-?, base='N', defeated='Y' WHERE planet_id = ?;", array($planettorps, $planetinfo['planet_id'])); \Tki\Db::logDbErrors($pdo_db, $update7a, __LINE__, __FILE__); } } @@ -524,7 +524,7 @@ public static function prime(\PDO $pdo_db, $db, string $lang, array $langvars, R echo "
" . $langvars['l_cmb_youmaycapture'] . "


"; \Tki\PlayerLog::writeLog($pdo_db, $ownerinfo['ship_id'], LogEnums::PLANET_DEFEATED, "$planetinfo[name]|$playerinfo[sector]|$playerinfo[character_name]"); \Tki\Score::updateScore($pdo_db, $ownerinfo['ship_id'], $tkireg, $playerinfo); - $update7a = $db->Execute("UPDATE {$db->prefix}planets SET owner=0,fighters=0, torps=torps-?, base='N', defeated='Y' WHERE planet_id = ?;", array($planettorps, $planetinfo['planet_id'])); + $update7a = $old_db->Execute("UPDATE {$old_db->prefix}planets SET owner=0,fighters=0, torps=torps-?, base='N', defeated='Y' WHERE planet_id = ?;", array($planettorps, $planetinfo['planet_id'])); \Tki\Db::logDbErrors($pdo_db, $update7a, __LINE__, __FILE__); } @@ -540,8 +540,8 @@ public static function prime(\PDO $pdo_db, $db, string $lang, array $langvars, R $energy = $planetinfo['energy']; \Tki\PlayerLog::writeLog($pdo_db, $ownerinfo['ship_id'], LogEnums::PLANET_NOT_DEFEATED, "$planetinfo[name]|$playerinfo[sector]|$playerinfo[character_name]|$free_ore|$free_organics|$free_goods|$ship_salvage_rate|$ship_salvage"); \Tki\Score::updateScore($pdo_db, $ownerinfo['ship_id'], $tkireg, $playerinfo); - $update7b = $db->Execute( - "UPDATE {$db->prefix}planets SET energy = ?, fighters = fighters - ?, " . + $update7b = $old_db->Execute( + "UPDATE {$old_db->prefix}planets SET energy = ?, fighters = fighters - ?, " . "torps = torps - ?, ore = ore + ?, goods = goods + ?, organics = organics + ?, " . "credits = credits + ? WHERE planet_id = ?;", array($energy, $fighters_lost, $planettorps, $free_ore, $free_goods, $free_organics, $ship_salvage, $planetinfo['planet_id']) diff --git a/classes/PlanetProduction.php b/classes/PlanetProduction.php index 072acf12a..00efd3f0e 100644 --- a/classes/PlanetProduction.php +++ b/classes/PlanetProduction.php @@ -26,7 +26,7 @@ class PlanetProduction { - public static function productionChange(\PDO $pdo_db, $db, array $langvars, array $prodpercentarray, Reg $tkireg): void + public static function productionChange(\PDO $pdo_db, $old_db, array $langvars, array $prodpercentarray, Reg $tkireg): void { // Declare default production values from the config.php file // @@ -51,7 +51,7 @@ public static function productionChange(\PDO $pdo_db, $db, array $langvars, arra // Off the top of my head if we could sort the data passed in, in order of planets we could check before we do the writes // This would save us from having to run through the database a second time checking our work. - $result = $db->Execute("SELECT ship_id, team FROM {$db->prefix}ships WHERE email = ?;", array($_SESSION['username'])); + $result = $old_db->Execute("SELECT ship_id, team FROM {$old_db->prefix}ships WHERE email = ?;", array($_SESSION['username'])); \Tki\Db::logDbErrors($pdo_db, $result, __LINE__, __FILE__); $ship_id = $result->fields['ship_id']; @@ -66,27 +66,27 @@ public static function productionChange(\PDO $pdo_db, $db, array $langvars, arra { if ($commod_type == "prod_ore" || $commod_type == "prod_organics" || $commod_type == "prod_goods" || $commod_type == "prod_energy" || $commod_type == "prod_fighters" || $commod_type == "prod_torp") { - $res = $db->Execute("SELECT COUNT(*) AS owned_planet FROM {$db->prefix}planets WHERE planet_id = ? AND owner = ?;", array($planet_id, $ship_id)); + $res = $old_db->Execute("SELECT COUNT(*) AS owned_planet FROM {$old_db->prefix}planets WHERE planet_id = ? AND owner = ?;", array($planet_id, $ship_id)); \Tki\Db::logDbErrors($pdo_db, $res, __LINE__, __FILE__); - $resx = $db->Execute("UPDATE {$db->prefix}planets SET {$commod_type} = ? WHERE planet_id = ? AND owner = ?;", array($prodpercent, $planet_id, $ship_id)); + $resx = $old_db->Execute("UPDATE {$old_db->prefix}planets SET {$commod_type} = ? WHERE planet_id = ? AND owner = ?;", array($prodpercent, $planet_id, $ship_id)); \Tki\Db::logDbErrors($pdo_db, $resx, __LINE__, __FILE__); - $resy = $db->Execute("UPDATE {$db->prefix}planets SET sells='N' WHERE planet_id = ? AND owner = ?;", array($planet_id, $ship_id)); + $resy = $old_db->Execute("UPDATE {$old_db->prefix}planets SET sells='N' WHERE planet_id = ? AND owner = ?;", array($planet_id, $ship_id)); \Tki\Db::logDbErrors($pdo_db, $resy, __LINE__, __FILE__); - $resz = $db->Execute("UPDATE {$db->prefix}planets SET team=0 WHERE planet_id = ? AND owner = ?;", array($planet_id, $ship_id)); + $resz = $old_db->Execute("UPDATE {$old_db->prefix}planets SET team=0 WHERE planet_id = ? AND owner = ?;", array($planet_id, $ship_id)); \Tki\Db::logDbErrors($pdo_db, $resz, __LINE__, __FILE__); } elseif ($commod_type == "sells") { - $resx = $db->Execute("UPDATE {$db->prefix}planets SET sells='Y' WHERE planet_id = ? AND owner = ?;", array($prodpercent, $ship_id)); + $resx = $old_db->Execute("UPDATE {$old_db->prefix}planets SET sells='Y' WHERE planet_id = ? AND owner = ?;", array($prodpercent, $ship_id)); \Tki\Db::logDbErrors($pdo_db, $resx, __LINE__, __FILE__); } elseif ($commod_type == "team") { // Compare entered team_id and one in the db, if different then use one from db - $res = $db->Execute("SELECT {$db->prefix}ships.team as owner FROM {$db->prefix}ships, {$db->prefix}planets WHERE ( {$db->prefix}ships.ship_id = {$db->prefix}planets.owner ) AND ( {$db->prefix}planets.planet_id = ?);", array($prodpercent)); + $res = $old_db->Execute("SELECT {$old_db->prefix}ships.team as owner FROM {$old_db->prefix}ships, {$old_db->prefix}planets WHERE ( {$old_db->prefix}ships.ship_id = {$old_db->prefix}planets.owner ) AND ( {$old_db->prefix}planets.planet_id = ?);", array($prodpercent)); \Tki\Db::logDbErrors($pdo_db, $res, __LINE__, __FILE__); if ($res) { @@ -97,7 +97,7 @@ public static function productionChange(\PDO $pdo_db, $db, array $langvars, arra $team_id = 0; } - $resx = $db->Execute("UPDATE {$db->prefix}planets SET team = ? WHERE planet_id = ? AND owner = ?;", array($team_id, $prodpercent, $ship_id)); + $resx = $old_db->Execute("UPDATE {$old_db->prefix}planets SET team = ? WHERE planet_id = ? AND owner = ?;", array($team_id, $prodpercent, $ship_id)); \Tki\Db::logDbErrors($pdo_db, $resx, __LINE__, __FILE__); } } @@ -108,7 +108,7 @@ public static function productionChange(\PDO $pdo_db, $db, array $langvars, arra echo $langvars['l_pr_prod_updated'] . "

"; echo $langvars['l_pr_checking_values'] . "

"; - $res = $db->Execute("SELECT * FROM {$db->prefix}planets WHERE owner = ? ORDER BY sector_id;", array($ship_id)); + $res = $old_db->Execute("SELECT * FROM {$old_db->prefix}planets WHERE owner = ? ORDER BY sector_id;", array($ship_id)); \Tki\Db::logDbErrors($pdo_db, $res, __LINE__, __FILE__); $counter = 0; $planets = array(); @@ -167,22 +167,22 @@ public static function productionChange(\PDO $pdo_db, $db, array $langvars, arra echo $temp2 . "
"; } - $resa = $db->Execute("UPDATE {$db->prefix}planets SET prod_ore = ? WHERE planet_id = ?;", array($tkireg->default_prod_ore, $planet['planet_id'])); + $resa = $old_db->Execute("UPDATE {$old_db->prefix}planets SET prod_ore = ? WHERE planet_id = ?;", array($tkireg->default_prod_ore, $planet['planet_id'])); \Tki\Db::logDbErrors($pdo_db, $resa, __LINE__, __FILE__); - $resb = $db->Execute("UPDATE {$db->prefix}planets SET prod_organics = ? WHERE planet_id = ?;", array($tkireg->default_prod_organics, $planet['planet_id'])); + $resb = $old_db->Execute("UPDATE {$old_db->prefix}planets SET prod_organics = ? WHERE planet_id = ?;", array($tkireg->default_prod_organics, $planet['planet_id'])); \Tki\Db::logDbErrors($pdo_db, $resb, __LINE__, __FILE__); - $resc = $db->Execute("UPDATE {$db->prefix}planets SET prod_goods = ? WHERE planet_id = ?;", array($tkireg->default_prod_goods, $planet['planet_id'])); + $resc = $old_db->Execute("UPDATE {$old_db->prefix}planets SET prod_goods = ? WHERE planet_id = ?;", array($tkireg->default_prod_goods, $planet['planet_id'])); \Tki\Db::logDbErrors($pdo_db, $resc, __LINE__, __FILE__); - $resd = $db->Execute("UPDATE {$db->prefix}planets SET prod_energy = ? WHERE planet_id = ?;", array($tkireg->default_prod_energy, $planet['planet_id'])); + $resd = $old_db->Execute("UPDATE {$old_db->prefix}planets SET prod_energy = ? WHERE planet_id = ?;", array($tkireg->default_prod_energy, $planet['planet_id'])); \Tki\Db::logDbErrors($pdo_db, $resd, __LINE__, __FILE__); - $rese = $db->Execute("UPDATE {$db->prefix}planets SET prod_fighters = ? WHERE planet_id = ?;", array($tkireg->default_prod_fighters, $planet['planet_id'])); + $rese = $old_db->Execute("UPDATE {$old_db->prefix}planets SET prod_fighters = ? WHERE planet_id = ?;", array($tkireg->default_prod_fighters, $planet['planet_id'])); \Tki\Db::logDbErrors($pdo_db, $rese, __LINE__, __FILE__); - $resf = $db->Execute("UPDATE {$db->prefix}planets SET prod_torp = ? WHERE planet_id = ?;", array($tkireg->default_prod_torp, $planet['planet_id'])); + $resf = $old_db->Execute("UPDATE {$old_db->prefix}planets SET prod_torp = ? WHERE planet_id = ?;", array($tkireg->default_prod_torp, $planet['planet_id'])); \Tki\Db::logDbErrors($pdo_db, $resf, __LINE__, __FILE__); } } diff --git a/classes/PlanetReportCE.php b/classes/PlanetReportCE.php index 901666827..f57b3e2bf 100644 --- a/classes/PlanetReportCE.php +++ b/classes/PlanetReportCE.php @@ -26,7 +26,7 @@ class PlanetReportCE { - public static function collectCredits(\PDO $pdo_db, $db, array $langvars, array $planetarray, Reg $tkireg): void + public static function collectCredits(\PDO $pdo_db, $old_db, array $langvars, array $planetarray, Reg $tkireg): void { $current_state = "GO"; // Current State $playerinfo = array(); @@ -41,7 +41,7 @@ public static function collectCredits(\PDO $pdo_db, $db, array $langvars, array $temp_count = count($planetarray); for ($i = 0; $i < $temp_count; $i++) { - $res = $db->Execute("SELECT * FROM {$db->prefix}planets WHERE planet_id = ?;", array($planetarray[$i])); + $res = $old_db->Execute("SELECT * FROM {$old_db->prefix}planets WHERE planet_id = ?;", array($planetarray[$i])); \Tki\Db::logDbErrors($pdo_db, $res, __LINE__, __FILE__); // Only add to array if the player owns the planet. diff --git a/classes/Traderoute.php b/classes/Traderoute.php index 53d29bb05..09cf2a79f 100644 --- a/classes/Traderoute.php +++ b/classes/Traderoute.php @@ -26,7 +26,7 @@ class Traderoute { - public static function engage(\PDO $pdo_db, $db, string $lang, int $tr_repeat, array $langvars, Reg $tkireg, array $playerinfo, int $engage, array $traderoutes, ?int $portfull, Smarty $template): void + public static function engage(\PDO $pdo_db, $old_db, string $lang, int $tr_repeat, array $langvars, Reg $tkireg, array $playerinfo, int $engage, array $traderoutes, ?int $portfull, Smarty $template): void { $traderoute = array(); $source = array(); @@ -66,7 +66,7 @@ public static function engage(\PDO $pdo_db, $db, string $lang, int $tr_repeat, a if ($traderoute['source_type'] == 'P') { // Retrieve port info here, we'll need it later anyway - $result = $db->Execute("SELECT * FROM {$db->prefix}universe WHERE sector_id = ?;", array($traderoute['source_id'])); + $result = $old_db->Execute("SELECT * FROM {$old_db->prefix}universe WHERE sector_id = ?;", array($traderoute['source_id'])); \Tki\Db::logDbErrors($pdo_db, $result, __LINE__, __FILE__); if (!$result || $result->EOF) @@ -84,7 +84,7 @@ public static function engage(\PDO $pdo_db, $db, string $lang, int $tr_repeat, a } elseif ($traderoute['source_type'] == 'L' || $traderoute['source_type'] == 'C') // Get data from planet table { - $result = $db->Execute("SELECT * FROM {$db->prefix}planets WHERE planet_id = ? AND (owner = ? OR (team <> 0 AND team = ?));", array($traderoute['source_id'], $playerinfo['ship_id'], $playerinfo['team'])); + $result = $old_db->Execute("SELECT * FROM {$old_db->prefix}planets WHERE planet_id = ? AND (owner = ? OR (team <> 0 AND team = ?));", array($traderoute['source_id'], $playerinfo['ship_id'], $playerinfo['team'])); \Tki\Db::logDbErrors($pdo_db, $result, __LINE__, __FILE__); if (!$result || $result->EOF) { @@ -124,7 +124,7 @@ public static function engage(\PDO $pdo_db, $db, string $lang, int $tr_repeat, a } // Store starting port info, we'll need it later - $result = $db->Execute("SELECT * FROM {$db->prefix}universe WHERE sector_id = ?;", array($source['sector_id'])); + $result = $old_db->Execute("SELECT * FROM {$old_db->prefix}universe WHERE sector_id = ?;", array($source['sector_id'])); \Tki\Db::logDbErrors($pdo_db, $result, __LINE__, __FILE__); if (!$result || $result->EOF) @@ -138,7 +138,7 @@ public static function engage(\PDO $pdo_db, $db, string $lang, int $tr_repeat, a // Destination Check if ($traderoute['dest_type'] == 'P') { - $result = $db->Execute("SELECT * FROM {$db->prefix}universe WHERE sector_id = ?;", array($traderoute['dest_id'])); + $result = $old_db->Execute("SELECT * FROM {$old_db->prefix}universe WHERE sector_id = ?;", array($traderoute['dest_id'])); \Tki\Db::logDbErrors($pdo_db, $result, __LINE__, __FILE__); if (!$result || $result->EOF) @@ -152,7 +152,7 @@ public static function engage(\PDO $pdo_db, $db, string $lang, int $tr_repeat, a { // Check for valid owned source planet // This now only returns planets that the player owns or planets that belong to the team and set as team planets.. - $result = $db->Execute("SELECT * FROM {$db->prefix}planets WHERE planet_id = ? AND (owner = ? OR (team <> 0 AND team = ?));", array($traderoute['dest_id'], $playerinfo['ship_id'], $playerinfo['team'])); + $result = $old_db->Execute("SELECT * FROM {$old_db->prefix}planets WHERE planet_id = ? AND (owner = ? OR (team <> 0 AND team = ?));", array($traderoute['dest_id'], $playerinfo['ship_id'], $playerinfo['team'])); \Tki\Db::logDbErrors($pdo_db, $result, __LINE__, __FILE__); if (!$result || $result->EOF) @@ -181,7 +181,7 @@ public static function engage(\PDO $pdo_db, $db, string $lang, int $tr_repeat, a } } - $result = $db->Execute("SELECT * FROM {$db->prefix}universe WHERE sector_id = ?;", array($dest['sector_id'])); + $result = $old_db->Execute("SELECT * FROM {$old_db->prefix}universe WHERE sector_id = ?;", array($dest['sector_id'])); \Tki\Db::logDbErrors($pdo_db, $result, __LINE__, __FILE__); if (!$result || $result->EOF) { @@ -219,7 +219,7 @@ public static function engage(\PDO $pdo_db, $db, string $lang, int $tr_repeat, a // Sector defense check $hostile = 0; - $result99 = $db->Execute("SELECT * FROM {$db->prefix}sector_defense WHERE sector_id = ? AND ship_id <> ?", array($source['sector_id'], $playerinfo['ship_id'])); + $result99 = $old_db->Execute("SELECT * FROM {$old_db->prefix}sector_defense WHERE sector_id = ? AND ship_id <> ?", array($source['sector_id'], $playerinfo['ship_id'])); \Tki\Db::logDbErrors($pdo_db, $result99, __LINE__, __FILE__); if (!$result99->EOF) { @@ -233,7 +233,7 @@ public static function engage(\PDO $pdo_db, $db, string $lang, int $tr_repeat, a } } - $result98 = $db->Execute("SELECT * FROM {$db->prefix}sector_defense WHERE sector_id = ? AND ship_id <> ?", array($dest['sector_id'], $playerinfo['ship_id'])); + $result98 = $old_db->Execute("SELECT * FROM {$old_db->prefix}sector_defense WHERE sector_id = ? AND ship_id <> ?", array($dest['sector_id'], $playerinfo['ship_id'])); \Tki\Db::logDbErrors($pdo_db, $result98, __LINE__, __FILE__); if (!$result98->EOF) { @@ -894,11 +894,11 @@ public static function engage(\PDO $pdo_db, $db, string $lang, int $tr_repeat, a if ($traderoute['circuit'] == '1') { - $resi = $db->Execute("UPDATE {$db->prefix}ships SET torps = ?, ship_fighters = ?, ship_colonists = ? WHERE ship_id = ?;", array($playerinfo['torps'], $playerinfo['ship_fighters'], $playerinfo['ship_colonists'], $playerinfo['ship_id'])); + $resi = $old_db->Execute("UPDATE {$old_db->prefix}ships SET torps = ?, ship_fighters = ?, ship_colonists = ? WHERE ship_id = ?;", array($playerinfo['torps'], $playerinfo['ship_fighters'], $playerinfo['ship_colonists'], $playerinfo['ship_id'])); \Tki\Db::logDbErrors($pdo_db, $resi, __LINE__, __FILE__); } - $resj = $db->Execute("UPDATE {$db->prefix}planets SET colonists = colonists - ?, torps = torps - ?, fighters = fighters - ? WHERE planet_id = ?;", array($colonists_buy, $torps_buy, $fighters_buy, $source['planet_id'])); + $resj = $old_db->Execute("UPDATE {$old_db->prefix}planets SET colonists = colonists - ?, torps = torps - ?, fighters = fighters - ? WHERE planet_id = ?;", array($colonists_buy, $torps_buy, $fighters_buy, $source['planet_id'])); \Tki\Db::logDbErrors($pdo_db, $resj, __LINE__, __FILE__); } } @@ -1072,7 +1072,7 @@ public static function engage(\PDO $pdo_db, $db, string $lang, int $tr_repeat, a $destcost -= $ore_buy * $tkireg->ore_price; } - $resk = $db->Execute("UPDATE {$db->prefix}universe SET port_ore = port_ore - ?, port_energy = port_energy - ?, port_goods = port_goods - ?, port_organics = port_organics - ? WHERE sector_id = ?;", array($ore_buy, $energy_buy, $goods_buy, $organics_buy, $dest['sector_id'])); + $resk = $old_db->Execute("UPDATE {$old_db->prefix}universe SET port_ore = port_ore - ?, port_energy = port_energy - ?, port_goods = port_goods - ?, port_organics = port_organics - ? WHERE sector_id = ?;", array($ore_buy, $energy_buy, $goods_buy, $organics_buy, $dest['sector_id'])); \Tki\Db::logDbErrors($pdo_db, $resk, __LINE__, __FILE__); } @@ -1154,7 +1154,7 @@ public static function engage(\PDO $pdo_db, $db, string $lang, int $tr_repeat, a $destcost -= $organics_buy * $tkireg->organics_price; } - $resm = $db->Execute("UPDATE {$db->prefix}universe SET port_ore = port_ore - ?, port_energy = port_energy - ?, port_goods = port_goods - ?, port_organics = port_organics - ? WHERE sector_id = ?;", array($ore_buy, $energy_buy, $goods_buy, $organics_buy, $dest['sector_id'])); + $resm = $old_db->Execute("UPDATE {$old_db->prefix}universe SET port_ore = port_ore - ?, port_energy = port_energy - ?, port_goods = port_goods - ?, port_organics = port_organics - ? WHERE sector_id = ?;", array($ore_buy, $energy_buy, $goods_buy, $organics_buy, $dest['sector_id'])); \Tki\Db::logDbErrors($pdo_db, $resm, __LINE__, __FILE__); } @@ -1196,7 +1196,7 @@ public static function engage(\PDO $pdo_db, $db, string $lang, int $tr_repeat, a echo $langvars['l_tdr_nothingtotrade'] . "
"; } - $resn = $db->Execute("UPDATE {$db->prefix}universe SET port_ore = port_ore - ?, port_energy = port_energy - ?, port_goods = port_goods - ?, port_organics = port_organics - ? WHERE sector_id = ?;", array($ore_buy, $energy_buy, $goods_buy, $organics_buy, $dest['sector_id'])); + $resn = $old_db->Execute("UPDATE {$old_db->prefix}universe SET port_ore = port_ore - ?, port_energy = port_energy - ?, port_goods = port_goods - ?, port_organics = port_organics - ? WHERE sector_id = ?;", array($ore_buy, $energy_buy, $goods_buy, $organics_buy, $dest['sector_id'])); \Tki\Db::logDbErrors($pdo_db, $resn, __LINE__, __FILE__); } @@ -1210,7 +1210,7 @@ public static function engage(\PDO $pdo_db, $db, string $lang, int $tr_repeat, a } } - $reso = $db->Execute("UPDATE {$db->prefix}ships SET ship_ore = ?, ship_goods = ?, ship_organics = ?, ship_energy = ? WHERE ship_id = ?;", array($playerinfo['ship_ore'], $playerinfo['ship_goods'], $playerinfo['ship_organics'], $playerinfo['ship_energy'], $playerinfo['ship_id'])); + $reso = $old_db->Execute("UPDATE {$old_db->prefix}ships SET ship_ore = ?, ship_goods = ?, ship_organics = ?, ship_energy = ? WHERE ship_id = ?;", array($playerinfo['ship_ore'], $playerinfo['ship_goods'], $playerinfo['ship_organics'], $playerinfo['ship_energy'], $playerinfo['ship_id'])); \Tki\Db::logDbErrors($pdo_db, $reso, __LINE__, __FILE__); } else // Dest is planet @@ -1310,7 +1310,7 @@ public static function engage(\PDO $pdo_db, $db, string $lang, int $tr_repeat, a } } - $resp = $db->Execute("UPDATE {$db->prefix}planets SET colonists = colonists + ?, fighters = fighters + ?, torps = torps + ? WHERE planet_id = ?;", array($colonists_buy, $fighters_buy, $torps_buy, $traderoute['dest_id'])); + $resp = $old_db->Execute("UPDATE {$old_db->prefix}planets SET colonists = colonists + ?, fighters = fighters + ?, torps = torps + ? WHERE planet_id = ?;", array($colonists_buy, $fighters_buy, $torps_buy, $traderoute['dest_id'])); \Tki\Db::logDbErrors($pdo_db, $resp, __LINE__, __FILE__); if ($traderoute['source_type'] == 'L' || $traderoute['source_type'] == 'C') @@ -1398,7 +1398,7 @@ public static function engage(\PDO $pdo_db, $db, string $lang, int $tr_repeat, a $newsec = $destport['sector_id']; } - $rest = $db->Execute("UPDATE {$db->prefix}ships SET turns = turns - ?, credits = credits + ?, turns_used = turns_used + ?, sector = ? WHERE ship_id = ?;", array($dist['triptime'], $total_profit, $dist['triptime'], $newsec, $playerinfo['ship_id'])); + $rest = $old_db->Execute("UPDATE {$old_db->prefix}ships SET turns = turns - ?, credits = credits + ?, turns_used = turns_used + ?, sector = ? WHERE ship_id = ?;", array($dist['triptime'], $total_profit, $dist['triptime'], $newsec, $playerinfo['ship_id'])); \Tki\Db::logDbErrors($pdo_db, $rest, __LINE__, __FILE__); $playerinfo['credits'] += $total_profit - $sourcecost; $playerinfo['turns'] -= $dist['triptime']; diff --git a/classes/TraderouteBuildCreate.php b/classes/TraderouteBuildCreate.php index c56be4d4a..2da6a522f 100644 --- a/classes/TraderouteBuildCreate.php +++ b/classes/TraderouteBuildCreate.php @@ -26,7 +26,7 @@ class TraderouteBuildCreate { - public static function create(\PDO $pdo_db, $db, string $lang, Reg $tkireg, Smarty $template, array $playerinfo, int $num_traderoutes, string $ptype1, string $ptype2, int $port_id1, int $port_id2, int $team_planet_id1, int $team_planet_id2, string $move_type, int $circuit_type, int $editing, ?int $planet_id1 = null, ?int $planet_id2 = null): void + public static function create(\PDO $pdo_db, $old_db, string $lang, Reg $tkireg, Smarty $template, array $playerinfo, int $num_traderoutes, string $ptype1, string $ptype2, int $port_id1, int $port_id2, int $team_planet_id1, int $team_planet_id2, string $move_type, int $circuit_type, int $editing, ?int $planet_id1 = null, ?int $planet_id2 = null): void { $langvars = \Tki\Translate::load($pdo_db, $lang, array('traderoutes', 'common', 'global_includes', 'global_funcs', 'footer', 'regional')); $admin_log = new AdminLog(); @@ -50,7 +50,7 @@ public static function create(\PDO $pdo_db, $db, string $lang, Reg $tkireg, Smar \Tki\TraderouteDie::die($pdo_db, $lang, $tkireg, $template, $langvars['l_tdr_invalidspoint']); } - $query = $db->Execute("SELECT * FROM {$db->prefix}universe WHERE sector_id = ?;", array($port_id1)); + $query = $old_db->Execute("SELECT * FROM {$old_db->prefix}universe WHERE sector_id = ?;", array($port_id1)); \Tki\Db::logDbErrors($pdo_db, $query, __LINE__, __FILE__); if (!$query || $query->EOF) { @@ -68,7 +68,7 @@ public static function create(\PDO $pdo_db, $db, string $lang, Reg $tkireg, Smar } else { - $query = $db->Execute("SELECT * FROM {$db->prefix}planets WHERE planet_id = ?;", array($planet_id1)); + $query = $old_db->Execute("SELECT * FROM {$old_db->prefix}planets WHERE planet_id = ?;", array($planet_id1)); \Tki\Db::logDbErrors($pdo_db, $query, __LINE__, __FILE__); $source = $query->fields; if (!$query || $query->EOF) @@ -100,7 +100,7 @@ public static function create(\PDO $pdo_db, $db, string $lang, Reg $tkireg, Smar // OK we have $source, *probably* now lets see if we have ever been there // Attempting to fix the map the universe via traderoute bug - $pl1query = $db->Execute("SELECT * FROM {$db->prefix}movement_log WHERE sector_id = ? AND ship_id = ?;", array($source['sector_id'], $playerinfo['ship_id'])); + $pl1query = $old_db->Execute("SELECT * FROM {$old_db->prefix}movement_log WHERE sector_id = ? AND ship_id = ?;", array($source['sector_id'], $playerinfo['ship_id'])); \Tki\Db::logDbErrors($pdo_db, $pl1query, __LINE__, __FILE__); $num_res1 = $pl1query->numRows(); if ($num_res1 == 0) @@ -118,7 +118,7 @@ public static function create(\PDO $pdo_db, $db, string $lang, Reg $tkireg, Smar \Tki\TraderouteDie::die($pdo_db, $lang, $tkireg, $template, $langvars['l_tdr_invaliddport']); } - $query = $db->Execute("SELECT * FROM {$db->prefix}universe WHERE sector_id = ?;", array($port_id2)); + $query = $old_db->Execute("SELECT * FROM {$old_db->prefix}universe WHERE sector_id = ?;", array($port_id2)); \Tki\Db::logDbErrors($pdo_db, $query, __LINE__, __FILE__); if (!$query || $query->EOF) { @@ -136,7 +136,7 @@ public static function create(\PDO $pdo_db, $db, string $lang, Reg $tkireg, Smar } else { - $query = $db->Execute("SELECT * FROM {$db->prefix}planets WHERE planet_id = ?;", array($planet_id2)); + $query = $old_db->Execute("SELECT * FROM {$old_db->prefix}planets WHERE planet_id = ?;", array($planet_id2)); \Tki\Db::logDbErrors($pdo_db, $query, __LINE__, __FILE__); $destination = $query->fields; if (!$query || $query->EOF) @@ -163,7 +163,7 @@ public static function create(\PDO $pdo_db, $db, string $lang, Reg $tkireg, Smar } // OK now we have $destination lets see if we've been there. - $pl2query = $db->Execute("SELECT * FROM {$db->prefix}movement_log WHERE sector_id = ? AND ship_id = ?;", array($destination['sector_id'], $playerinfo['ship_id'])); + $pl2query = $old_db->Execute("SELECT * FROM {$old_db->prefix}movement_log WHERE sector_id = ? AND ship_id = ?;", array($destination['sector_id'], $playerinfo['ship_id'])); \Tki\Db::logDbErrors($pdo_db, $pl2query, __LINE__, __FILE__); $num_res2 = $pl2query->numRows(); if ($num_res2 == 0) @@ -178,7 +178,7 @@ public static function create(\PDO $pdo_db, $db, string $lang, Reg $tkireg, Smar } // Check traderoute for src => dest - \Tki\TraderouteCheck::isCompatible($pdo_db, $db, $lang, $ptype1, $ptype2, $move_type, $circuit_type, $source, $destination, $playerinfo, $tkireg, $template); + \Tki\TraderouteCheck::isCompatible($pdo_db, $old_db, $lang, $ptype1, $ptype2, $move_type, $circuit_type, $source, $destination, $playerinfo, $tkireg, $template); if ($ptype1 == 'port') { @@ -240,13 +240,13 @@ public static function create(\PDO $pdo_db, $db, string $lang, Reg $tkireg, Smar if (empty($editing)) { - $query = $db->Execute("INSERT INTO {$db->prefix}traderoutes VALUES(null, ?, ?, ?, ?, ?, ?, ?);", array($src_id, $dest_id, $src_type, $dest_type, $mtype, $playerinfo['ship_id'], $circuit_type)); + $query = $old_db->Execute("INSERT INTO {$old_db->prefix}traderoutes VALUES(null, ?, ?, ?, ?, ?, ?, ?);", array($src_id, $dest_id, $src_type, $dest_type, $mtype, $playerinfo['ship_id'], $circuit_type)); \Tki\Db::logDbErrors($pdo_db, $query, __LINE__, __FILE__); echo "

" . $langvars['l_tdr_newtdrcreated']; } else { - $query = $db->Execute("UPDATE {$db->prefix}traderoutes SET source_id = ?, dest_id = ?, source_type = ?, dest_type = ?, move_type = ?, owner = ?, circuit = ? WHERE traderoute_id = ?;", array($src_id, $dest_id, $src_type, $dest_type, $mtype, $playerinfo['ship_id'], $circuit_type, $editing)); + $query = $old_db->Execute("UPDATE {$old_db->prefix}traderoutes SET source_id = ?, dest_id = ?, source_type = ?, dest_type = ?, move_type = ?, owner = ?, circuit = ? WHERE traderoute_id = ?;", array($src_id, $dest_id, $src_type, $dest_type, $mtype, $playerinfo['ship_id'], $circuit_type, $editing)); \Tki\Db::logDbErrors($pdo_db, $query, __LINE__, __FILE__); echo "

" . $langvars['l_tdr_modified']; } diff --git a/classes/TraderouteCheck.php b/classes/TraderouteCheck.php index dc82dbeb9..804da3179 100644 --- a/classes/TraderouteCheck.php +++ b/classes/TraderouteCheck.php @@ -26,7 +26,7 @@ class TraderouteCheck { - public static function isCompatible(\PDO $pdo_db, $db, string $lang, string $type1, string $type2, string $move, int $circuit, array $src, array $dest, array $playerinfo, Reg $tkireg, Smarty $template): void + public static function isCompatible(\PDO $pdo_db, $old_db, string $lang, string $type1, string $type2, string $move, int $circuit, array $src, array $dest, array $playerinfo, Reg $tkireg, Smarty $template): void { $langvars = \Tki\Translate::load($pdo_db, $lang, array('traderoutes', 'common', 'global_includes', 'global_funcs', 'footer', 'regional')); $admin_log = new AdminLog(); @@ -41,7 +41,7 @@ public static function isCompatible(\PDO $pdo_db, $db, string $lang, string $typ // Check warp links compatibility if ($move == 'warp') { - $query = $db->Execute("SELECT link_id FROM {$db->prefix}links WHERE link_start = ? AND link_dest = ?;", array($src['sector_id'], $dest['sector_id'])); + $query = $old_db->Execute("SELECT link_id FROM {$old_db->prefix}links WHERE link_start = ? AND link_dest = ?;", array($src['sector_id'], $dest['sector_id'])); \Tki\Db::logDbErrors($pdo_db, $query, __LINE__, __FILE__); if ($query->EOF) { @@ -52,7 +52,7 @@ public static function isCompatible(\PDO $pdo_db, $db, string $lang, string $typ if ($circuit == '2') { - $query = $db->Execute("SELECT link_id FROM {$db->prefix}links WHERE link_start = ? AND link_dest = ?;", array($dest['sector_id'], $src['sector_id'])); + $query = $old_db->Execute("SELECT link_id FROM {$old_db->prefix}links WHERE link_start = ? AND link_dest = ?;", array($dest['sector_id'], $src['sector_id'])); \Tki\Db::logDbErrors($pdo_db, $query, __LINE__, __FILE__); if ($query->EOF) { diff --git a/common.php b/common.php index 6e69c2ccd..08a36aa82 100644 --- a/common.php +++ b/common.php @@ -76,10 +76,10 @@ die($e . ""); } -$db = new Tki\Db(); +$old_db = new Tki\Db(); try { - $db = $db->initDb('adodb'); // Connect to db using adodb also - for now - to be eliminated! + $old_db = $old_db->initDb('adodb'); // Connect to db using adodb also - for now - to be eliminated! } catch (Exception $e) { diff --git a/defense_report.php b/defense_report.php index 921ad58f1..d72ba3716 100644 --- a/defense_report.php +++ b/defense_report.php @@ -41,7 +41,7 @@ $players_gateway = new \Tki\Players\PlayersGateway($pdo_db); // Build a player gateway object to handle the SQL calls $playerinfo = $players_gateway->selectPlayerInfo($_SESSION['username']); -$query = "SELECT * FROM {$db->prefix}sector_defense WHERE ship_id = ?"; +$query = "SELECT * FROM {$old_db->prefix}sector_defense WHERE ship_id = ?"; if (isset($sort)) { $query .= " ORDER BY"; @@ -63,7 +63,7 @@ } } -$res = $db->Execute($query, array($playerinfo['ship_id'])); +$res = $old_db->Execute($query, array($playerinfo['ship_id'])); Tki\Db::logDbErrors($pdo_db, $res, __LINE__, __FILE__); $i = 0; diff --git a/docs/developer-guide.md b/docs/developer-guide.md index c9029a9ac..1030149f1 100644 --- a/docs/developer-guide.md +++ b/docs/developer-guide.md @@ -20,7 +20,7 @@ auto-loaded where possible, files are being converted to use templates for outpu - Translation support is improving in game. Language outputs should be done via the $langvars array, with corresponding entries and categories (which match file names usually) in languages/language.ini - Methods and older functions should have needed variables defined in their calling in the - order ($pdo_db, $db, $langvars, $config, others). + order ($pdo_db, $old_db, $langvars, $config, others). - Anywhere you are unconditionally including a class file, use require_once(). Anywhere you are conditionally including a class file, use include_once(). - All PDO calls with bindParam/bindValue must use PDO datatype constants (Like PDO::PARAM_INT/PDO::PARAM_STR) diff --git a/genesis.php b/genesis.php index 148ac8554..8ef7f5ab1 100644 --- a/genesis.php +++ b/genesis.php @@ -89,7 +89,7 @@ } else { - $res = $db->Execute("SELECT allow_planet, team_zone, owner FROM {$db->prefix}zones WHERE zone_id = ?;", array($sectorinfo['zone_id'])); + $res = $old_db->Execute("SELECT allow_planet, team_zone, owner FROM {$old_db->prefix}zones WHERE zone_id = ?;", array($sectorinfo['zone_id'])); Tki\Db::logDbErrors($pdo_db, $res, __LINE__, __FILE__); $zoneinfo = $res->fields; if ($zoneinfo['allow_planet'] == 'N') @@ -106,7 +106,7 @@ } else { - $res = $db->Execute("SELECT team FROM {$db->prefix}ships WHERE ship_id = ?;", array($zoneinfo['owner'])); + $res = $old_db->Execute("SELECT team FROM {$old_db->prefix}ships WHERE ship_id = ?;", array($zoneinfo['owner'])); Tki\Db::logDbErrors($pdo_db, $res, __LINE__, __FILE__); $ownerinfo = $res->fields; if ($ownerinfo['team'] != $playerinfo['team']) @@ -115,7 +115,7 @@ } else { - $update1 = $db->Execute("INSERT INTO {$db->prefix}planets VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);", array(null, $playerinfo['sector'], $planetname, 0, 0, 0, 0, 0, 0, 0, 0, $playerinfo['ship_id'], 0, 'N', 'N', $tkireg->default_prod_organics, $tkireg->default_prod_ore, $tkireg->default_prod_goods, $tkireg->default_prod_energy, $tkireg->default_prod_fighters, $tkireg->default_prod_torp, 'N')); + $update1 = $old_db->Execute("INSERT INTO {$old_db->prefix}planets VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);", array(null, $playerinfo['sector'], $planetname, 0, 0, 0, 0, 0, 0, 0, 0, $playerinfo['ship_id'], 0, 'N', 'N', $tkireg->default_prod_organics, $tkireg->default_prod_ore, $tkireg->default_prod_goods, $tkireg->default_prod_energy, $tkireg->default_prod_fighters, $tkireg->default_prod_torp, 'N')); Tki\Db::logDbErrors($pdo_db, $update1, __LINE__, __FILE__); $sql = "UPDATE ::prefix::ships SET turns_used = turns_used + 1, turns = turns - 1, dev_genesis = dev_genesis - 1 WHERE ship_id = :ship_id"; @@ -133,7 +133,7 @@ } else { - $update1 = $db->Execute("INSERT INTO {$db->prefix}planets VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);", array(null, $playerinfo['sector'], '$planetname', 0, 0, 0, 0, 0, 0, 0, 0, $playerinfo['ship_id'], 0, 'N', 'N', $tkireg->default_prod_organics, $tkireg->default_prod_ore, $tkireg->default_prod_goods, $tkireg->default_prod_energy, $tkireg->default_prod_fighters, $tkireg->default_prod_torp, 'N')); + $update1 = $old_db->Execute("INSERT INTO {$old_db->prefix}planets VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);", array(null, $playerinfo['sector'], '$planetname', 0, 0, 0, 0, 0, 0, 0, 0, $playerinfo['ship_id'], 0, 'N', 'N', $tkireg->default_prod_organics, $tkireg->default_prod_ore, $tkireg->default_prod_goods, $tkireg->default_prod_energy, $tkireg->default_prod_fighters, $tkireg->default_prod_torp, 'N')); Tki\Db::logDbErrors($pdo_db, $update1, __LINE__, __FILE__); $sql = "UPDATE ::prefix::ships SET turns_used = turns_used + 1, turns = turns - 1, dev_genesis = dev_genesis - 1 WHERE ship_id = :ship_id"; @@ -146,7 +146,7 @@ } else { - $update1 = $db->Execute("INSERT INTO {$db->prefix}planets VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);", array(null, $playerinfo['sector'], $planetname, 0, 0, 0, 0, 0, 0, 0, 0, $playerinfo['ship_id'], 0, 'N', 'N', $tkireg->default_prod_organics, $tkireg->default_prod_ore, $tkireg->default_prod_goods, $tkireg->default_prod_energy, $tkireg->default_prod_fighters, $tkireg->default_prod_torp, 'N')); + $update1 = $old_db->Execute("INSERT INTO {$old_db->prefix}planets VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);", array(null, $playerinfo['sector'], $planetname, 0, 0, 0, 0, 0, 0, 0, 0, $playerinfo['ship_id'], 0, 'N', 'N', $tkireg->default_prod_organics, $tkireg->default_prod_ore, $tkireg->default_prod_goods, $tkireg->default_prod_energy, $tkireg->default_prod_fighters, $tkireg->default_prod_torp, 'N')); Tki\Db::logDbErrors($pdo_db, $update1, __LINE__, __FILE__); $sql = "UPDATE ::prefix::ships SET turns_used = turns_used + 1, turns = turns - 1, dev_genesis = dev_genesis - 1 WHERE ship_id = :ship_id"; diff --git a/info_publiclist.php b/info_publiclist.php index fbe21dc4d..a2d09e0c9 100644 --- a/info_publiclist.php +++ b/info_publiclist.php @@ -29,40 +29,40 @@ $info['GAMENAME'] = $tkireg->game_name; $info['GAMEID'] = md5($tkireg->game_name . $tkireg->tki_ls_key); -$xsql = "SELECT UNIX_TIMESTAMP(time) as x FROM {$db->prefix}movement_log WHERE event_id = 1"; -$res = $db->Execute($xsql); +$xsql = "SELECT UNIX_TIMESTAMP(time) as x FROM {$old_db->prefix}movement_log WHERE event_id = 1"; +$res = $old_db->Execute($xsql); $row = $res->fields; $info['START-DATE'] = $row['x']; $info['G-DURATION'] = -1; -$xsql = "SELECT count(*) as x FROM {$db->prefix}ships"; -$res = $db->Execute($xsql); +$xsql = "SELECT count(*) as x FROM {$old_db->prefix}ships"; +$res = $old_db->Execute($xsql); $row = $res->fields; $info['P-ALL'] = $row['x']; -$xsql = "SELECT count(*) as x FROM {$db->prefix}ships WHERE ship_destroyed = 'N' "; -$res = $db->Execute($xsql); +$xsql = "SELECT count(*) as x FROM {$old_db->prefix}ships WHERE ship_destroyed = 'N' "; +$res = $old_db->Execute($xsql); $row = $res->fields; $info['P-ACTIVE'] = $row['x']; -$xsql = "SELECT count(*) as x FROM {$db->prefix}ships WHERE ship_destroyed = 'N' AND email NOT LIKE '%@kabal'"; -$res = $db->Execute($xsql); +$xsql = "SELECT count(*) as x FROM {$old_db->prefix}ships WHERE ship_destroyed = 'N' AND email NOT LIKE '%@kabal'"; +$res = $old_db->Execute($xsql); $row = $res->fields; $info['P-HUMAN'] = $row['x']; -$xsql = "SELECT COUNT(*) as x FROM {$db->prefix}ships WHERE (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(last_login)) / 60 <= 5 and email NOT LIKE '%@kabal'"; -$res = $db->Execute($xsql); +$xsql = "SELECT COUNT(*) as x FROM {$old_db->prefix}ships WHERE (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(last_login)) / 60 <= 5 and email NOT LIKE '%@kabal'"; +$res = $old_db->Execute($xsql); $row = $res->fields; $info['P-ONLINE'] = $row['x']; -$res = $db->Execute("SELECT AVG(hull) AS a1 , AVG(engines) AS a2 , AVG(power) AS a3 , AVG(computer) AS a4 , AVG(sensors) AS a5 , AVG(beams) AS a6 , AVG(torp_launchers) AS a7 , AVG(shields) AS a8 , AVG(armor) AS a9 , AVG(cloak) AS a10 FROM {$db->prefix}ships WHERE ship_destroyed='N' and email LIKE '%@kabal'"); +$res = $old_db->Execute("SELECT AVG(hull) AS a1 , AVG(engines) AS a2 , AVG(power) AS a3 , AVG(computer) AS a4 , AVG(sensors) AS a5 , AVG(beams) AS a6 , AVG(torp_launchers) AS a7 , AVG(shields) AS a8 , AVG(armor) AS a9 , AVG(cloak) AS a10 FROM {$old_db->prefix}ships WHERE ship_destroyed='N' and email LIKE '%@kabal'"); $row = $res->fields; $dyn_kabal_lvl = $row['a1'] + $row['a2'] + $row['a3'] + $row['a4'] + $row['a5'] + $row['a6'] + $row['a7'] + $row['a8'] + $row['a9'] + $row['a10']; $dyn_kabal_lvl = $dyn_kabal_lvl / 10; $info['P-AI-LVL'] = $dyn_kabal_lvl; -$xsql = "SELECT character_name, score FROM {$db->prefix}ships WHERE ship_destroyed = 'N' ORDER BY score DESC LIMIT 3 "; -$res = $db->Execute($xsql); +$xsql = "SELECT character_name, score FROM {$old_db->prefix}ships WHERE ship_destroyed = 'N' ORDER BY score DESC LIMIT 3 "; +$res = $old_db->Execute($xsql); while (!$res->EOF) { $row = $res->fields; diff --git a/kabal_control.php b/kabal_control.php index 79ba7178c..ad112c0dd 100644 --- a/kabal_control.php +++ b/kabal_control.php @@ -159,7 +159,7 @@ if (empty($user)) { echo ""; echo "" . $langvars['l_team_newc'] . ""; echo "" . $langvars['l_team_selectp'] . ":