} else { $langvars['l_mines_dfighter'] = str_replace("[fighters]", $numfighters, $langvars['l_mines_dfighter']); $langvars['l_mines_dfighter'] = str_replace("[mode]", $mode, $langvars['l_mines_dfighter']); echo $langvars['l_mines_dfighter'] . "<br>"; } $stamp = date("Y-m-d H:i:s"); if ($numfighters > 0) { if ($fighter_id != 0) { $update = $db->Execute("UPDATE {$db->prefix}sector_defense SET quantity = quantity + ? ,fm_setting = ? WHERE defense_id = ?;", array($numfighters, $mode, $fighter_id)); Tki\Db::LogDbErrors($pdo_db, $update, __LINE__, __FILE__); } else { $update = $db->Execute("INSERT INTO {$db->prefix}sector_defense (ship_id, sector_id, defense_type, quantity, fm_setting) values (?, ?, ?, ?, ?);", array($playerinfo['ship_id'], $playerinfo['sector'], 'F', $numfighters, $mode)); Tki\Db::LogDbErrors($pdo_db, $update, __LINE__, __FILE__); echo $db->ErrorMsg(); } } if ($nummines > 0) { if ($mine_id != 0) { $update = $db->Execute("UPDATE {$db->prefix}sector_defense SET quantity = quantity + ?, fm_setting = ? WHERE defense_id = ?;", array($nummines, $mode, $mine_id)); Tki\Db::LogDbErrors($pdo_db, $update, __LINE__, __FILE__); } else { $update = $db->Execute("INSERT INTO {$db->prefix}sector_defense (ship_id, sector_id, defense_type, quantity, fm_setting) values (?, ?, ?, ?, ?);", array($playerinfo['ship_id'], $playerinfo['sector'], 'M', $nummines, $mode)); Tki\Db::LogDbErrors($pdo_db, $update, __LINE__, __FILE__); } } $update = $db->Execute("UPDATE {$db->prefix}ships SET last_login = ?, turns = turns - 1, turns_used = turns_used + 1, ship_fighters = ship_fighters - ?, torps = torps - ? WHERE ship_id = ?;", array($stamp, $numfighters, $nummines, $playerinfo['ship_id'])); Tki\Db::LogDbErrors($pdo_db, $update, __LINE__, __FILE__); } } Tki\Text::gotomain($pdo_db, $lang); Tki\Footer::display($pdo_db, $lang, $tkireg, $template);
} else { $selected = null; } $charname = $res->fields['character_name']; $ship_id = $res->fields['ship_id']; echo "<option value={$ship_id} {$selected}>{$charname}</option>"; $res->MoveNext(); } echo "</select></td></tr>"; echo "<tr><td>" . $langvars['l_by_amount'] . ":</td><td><input type=text name=amount size=20 maxlength=20></td></tr>"; echo "<tr><td></td><td><input type=submit value=" . $langvars['l_by_place'] . "><input type=reset value=Clear></td>"; echo "</table>"; echo "<input type=hidden name=response value=place>"; echo "</form>"; $result3 = $db->Execute("SELECT bounty_on, SUM(amount) as total_bounty FROM {$db->prefix}bounty GROUP BY bounty_on;"); Tki\Db::LogDbErrors($pdo_db, $result3, __LINE__, __FILE__); $i = 0; if ($result3) { while (!$result3->EOF) { $bounties[$i] = $result3->fields; $i++; $result3->MoveNext(); } } $num_bounties = $i; if ($num_bounties < 1) { echo $langvars['l_by_nobounties'] . "<br>"; } else { echo $langvars['l_by_moredetails'] . "<br><br>"; echo "<table width=\"100%\" border=0 cellspacing=0 cellpadding=2>"; echo "<tr bgcolor=\"{$tkireg->color_header}\">";
// Either we got an error in the SQL Query or <> 1 records was changed. echo $langvars['l_opt2_passchangeerr'] . "<br><br>"; } else { // Log user in $_SESSION['password'] = $newpass1; $_SESSION['logged_in'] = true; $_SESSION['username'] = $playerinfo['email']; } // Send email to user & admin notifying of password change $langvars['l_mail_message'] = str_replace("[ip]", $request->server->get('REMOTE_ADDR'), $langvars['l_mail_message']); $langvars['l_mail_message'] = str_replace("[game_name]", $tkireg->game_name, $langvars['l_mail_message']); // Some reason \r\n is broken, so replace them now. $langvars['l_mail_message'] = str_replace('\\r\\n', "\r\n", $langvars['l_mail_message']); // Need to set the topic with the game name. $langvars['l_mail_topic'] = str_replace("[game_name]", $tkireg->game_name, $langvars['l_mail_topic']); mail($playerinfo['email'], $langvars['l_mail_topic'], $langvars['l_mail_message'], "From: {$tkireg->admin_mail}\r\nReply-To: {$tkireg->admin_mail}\r\nX-Mailer: PHP/" . phpversion()); // Reset recovery_time to zero $recovery_update_result = $db->Execute("UPDATE {$db->prefix}ships SET recovery_time = null WHERE email = ?;", array($playerinfo['email'])); Tki\Db::LogDbErrors($pdo_db, $recovery_update_result, __LINE__, __FILE__); echo $langvars['l_pwr_success'] . "<br><br>"; echo str_replace("[here]", "<a href='main.php'>" . $langvars['l_here'] . "</a>", $langvars['l_global_mmenu']); // Redirect to game header('Refresh: 5;url=main.php'); } } } else { // This reset code is not valid. echo $langvars['l_pwr_invalid']; // Admin log this attempt to use an invalid code } Tki\Footer::display($pdo_db, $lang, $tkireg, $template);
<?php // The Kabal Invasion - A web-based 4X space game // Copyright © 2014 The Kabal Invasion development team, Ron Harwood, and the BNT development team // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // // File: sched_ibank.php $exponinter = pow($tkireg->ibank_interest + 1, $multiplier); $expoloan = pow($tkireg->ibank_loaninterest + 1, $multiplier); echo "<strong>IBANK</strong><p>"; $ibank_result = $db->Execute("UPDATE {$db->prefix}ibank_accounts SET balance = balance * ?, loan = loan * ?", array($exponinter, $expoloan)); Tki\Db::LogDbErrors($pdo_db, $ibank_result, __LINE__, __FILE__); echo "All IBANK accounts updated ({$multiplier} times).<p>"; $multiplier = 0;
// You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // // File: sched_tow.php echo "<strong>ZONES</strong><br><br>"; echo "Towing bigger players out of restricted zones..."; $num_to_tow = 0; do { $res = $db->Execute("SELECT ship_id,character_name,hull,sector,{$db->prefix}universe.zone_id,max_hull FROM {$db->prefix}ships,{$db->prefix}universe,{$db->prefix}zones WHERE sector=sector_id AND {$db->prefix}universe.zone_id={$db->prefix}zones.zone_id AND max_hull<>0 AND (({$db->prefix}ships.hull + {$db->prefix}ships.engines + {$db->prefix}ships.computer + {$db->prefix}ships.beams + {$db->prefix}ships.torp_launchers + {$db->prefix}ships.shields + {$db->prefix}ships.armor)/7) >max_hull AND ship_destroyed='N'"); Tki\Db::LogDbErrors($pdo_db, $res, __LINE__, __FILE__); if ($res) { $num_to_tow = $res->RecordCount(); echo "<br>{$num_to_tow} players to tow:<br>"; while (!$res->EOF) { $row = $res->fields; echo "...towing {$row['character_name']} out of {$row['sector']} ..."; $newsector = random_int(0, (int) $max_sectors - 1); echo " to sector {$newsector}.<br>"; $query = $db->Execute("UPDATE {$db->prefix}ships SET sector = ?, cleared_defenses=' ' WHERE ship_id=?", array($newsector, $row['ship_id'])); Tki\Db::LogDbErrors($pdo_db, $query, __LINE__, __FILE__); Tki\PlayerLog::WriteLog($pdo_db, $row['ship_id'], LOG_TOW, "{$row['sector']}|{$newsector}|{$row['max_hull']}"); Tki\LogMove::writeLog($pdo_db, $row['ship_id'], $newsector); $res->MoveNext(); } } else { echo "<br>No players to tow.<br>"; } } while ($num_to_tow); echo "<br>"; $multiplier = 0; // No need to run this again
<?php // The Kabal Invasion - A web-based 4X space game // Copyright © 2014 The Kabal Invasion development team, Ron Harwood, and the BNT development team // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // // File: sched_turns.php echo "<strong>TURNS</strong><br><br>"; echo "Adding turns..."; $resa = $db->Execute("UPDATE {$db->prefix}ships SET turns = LEAST (turns + ({$tkireg->turns_per_tick} * {$multiplier}), {$tkireg->max_turns}) WHERE turns < {$tkireg->max_turns}"); //$resa = $db->Execute("UPDATE {$db->prefix}ships SET turns = LEAST (turns + (? * ?), ?) WHERE turns < ?", array($tkireg->turns_per_tick, $multiplier, $tkireg->max_turns, $tkireg->max_turns)); $debug = Tki\Db::LogDbErrors($pdo_db, $resa, __LINE__, __FILE__); isQueryOk($pdo_db, $debug); echo "<br>"; $multiplier = 0;
$free_power = Tki\CalcLevels::energy($playerinfo['power'], $tkireg) - $playerinfo['ship_energy']; $total_cost = $trade_ore * $ore_price + $trade_organics * $organics_price + $trade_goods * $goods_price + $trade_energy * $energy_price; if ($free_holds < $cargo_exchanged) { echo $langvars['l_notenough_cargo'] . " <a href=planet.php?planet_id={$planet_id}>" . $langvars['l_clickme'] . "</a> " . $langvars['l_toplanetmenu'] . "<br><br>"; } elseif ($trade_energy > $free_power) { echo $langvars['l_notenough_power'] . " <a href=planet.php?planet_id={$planet_id}>" . $langvars['l_clickme'] . "</a> " . $langvars['l_toplanetmenu'] . "<br><br>"; } elseif ($playerinfo['turns'] < 1) { echo $langvars['l_notenough_turns'] . "<br><br>"; } elseif ($playerinfo['credits'] < $total_cost) { echo $langvars['l_notenough_credits'] . "<br><br>"; } elseif ($trade_organics > $planetinfo['organics']) { echo $langvars['l_exceed_organics'] . " "; } elseif ($trade_ore > $planetinfo['ore']) { echo $langvars['l_exceed_ore'] . " "; } elseif ($trade_goods > $planetinfo['goods']) { echo $langvars['l_exceed_goods'] . " "; } elseif ($trade_energy > $planetinfo['energy']) { echo $langvars['l_exceed_energy'] . " "; } else { echo $langvars['l_totalcost'] . ": {$total_cost}<br>" . $langvars['l_traded_ore'] . ": {$trade_ore}<br>" . $langvars['l_traded_organics'] . ": {$trade_organics}<br>" . $langvars['l_traded_goods'] . ": {$trade_goods}<br>" . $langvars['l_traded_energy'] . ": {$trade_energy}<br><br>"; // Update ship cargo, credits and turns $trade_result = $db->Execute("UPDATE {$db->prefix}ships SET turns = turns - 1, turns_used = turns_used + 1, credits = credits - ?, ship_ore = ship_ore + ?, ship_organics = ship_organics + ?, " . "ship_goods = ship_goods + ?, ship_energy = ship_energy + ? WHERE ship_id = ?;", array($total_cost, $trade_ore, $trade_organics, $trade_goods, $trade_energy, $playerinfo['ship_id'])); Tki\Db::LogDbErrors($pdo_db, $trade_result, __LINE__, __FILE__); $trade_result2 = $db->Execute("UPDATE {$db->prefix}planets SET ore = ore - ?, organics = organics - ?, goods = goods - ?, energy = energy - ?, credits = credits + ? WHERE planet_id = ?;", array($trade_ore, $trade_organics, $trade_goods, $trade_energy, $total_cost, $planet_id)); Tki\Db::LogDbErrors($pdo_db, $trade_result2, __LINE__, __FILE__); echo $langvars['l_trade_complete'] . "<br><br>"; } } Tki\Score::updateScore($pdo_db, $playerinfo['ship_id'], $tkireg, $playerinfo); Tki\Text::gotomain($pdo_db, $lang); Tki\Footer::display($pdo_db, $lang, $tkireg, $template);
Tki\Db::LogDbErrors($pdo_db, $resa, __LINE__, __FILE__); // Begin transaction while (!$result->EOF) { $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'])); Tki\Db::LogDbErrors($pdo_db, $resx, __LINE__, __FILE__); $changed_sectors[$i] = str_replace("[sector]", $row['sector_id'], $langvars['l_admin_updated_distance']); $changed_sectors[$i] = str_replace("[distance]", $distance, $changed_sectors[$i]); $i++; $result->MoveNext(); } // End transaction $trans_status = $db->CompleteTrans(); // Complete the transaction Tki\Db::LogDbErrors($pdo_db, $trans_status, __LINE__, __FILE__); } } $title = $langvars['l_change_uni_title']; // Set array with all used variables in page $variables['lang'] = $lang; $variables['changed_sectors'] = $changed_sectors; $variables['swordfish'] = $swordfish; $variables['universe_size'] = $universe_size; $variables['action'] = $action; $variables['radius'] = $radius; // Set the module name. $variables['module'] = $module_name; // Now set a container for the variables and langvars and send them off to the template system $variables['container'] = "variable"; $langvars['container'] = "langvar";
$search_query = $search_query . ",a" . $j . ".link_dest "; } $search_query = $search_query . ")"; } $search_query = $search_query . "ORDER BY a1.link_start, a1.link_dest "; for ($i = 2; $i <= $search_depth; $i++) { $search_query = $search_query . ", a" . $i . ".link_dest"; } $search_query = $search_query . " LIMIT 1"; //echo "$search_query\n\n"; $db->SetFetchMode(ADODB_FETCH_NUM); $search_result = $db->Execute($search_query); if ($search_result === false) { die('Invalid query'); } else { Tki\Db::LogDbErrors($pdo_db, $search_result, __LINE__, __FILE__); $found = $search_result->RecordCount(); if ($found > 0) { break; } } } if ($found > 0) { echo "<h3>" . $langvars['l_nav_pathfnd'] . "</h3>\n"; $links = $search_result->fields; echo $links[0]; for ($i = 1; $i < $search_depth + 1; $i++) { echo " >> " . $links[$i]; } $db->SetFetchMode(ADODB_FETCH_ASSOC); echo "<br><br>";
$stmt->bindParam(':sched_file', $sched_file); $stmt->bindParam(':last_run', $now); $resxx = $stmt->execute(); $variables['update_turns_results']['result'] = Tki\Db::logDbErrors($pdo_db, $resxx, __LINE__, __FILE__); $variables['update_turns_results']['sched'] = $tkireg->sched_turns; $local_table_timer->stop(); $variables['update_turns_results']['elapsed'] = $local_table_timer->elapsed(); $local_table_timer->start(); // Start benchmarking for Xenobe $sql = "INSERT INTO ::prefix::scheduler (run_once, ticks_full, sched_file, last_run) VALUES ('N', :ticks_full, :sched_file, :last_run)"; $stmt = $pdo_db->prepare($sql); $stmt->bindParam(':ticks_full', $tkireg->sched_turns); $stmt->bindValue(':sched_file', 'sched_xenobe.php'); $stmt->bindParam(':last_run', $now); $resxx = $stmt->execute(); $variables['update_xenobe_results']['result'] = Tki\Db::LogDbErrors($pdo_db, $resxx, __LINE__, __FILE__); $variables['update_xenobe_results']['sched'] = $tkireg->sched_turns; $local_table_timer->stop(); $variables['update_xenobe_results']['elapsed'] = $local_table_timer->elapsed(); $local_table_timer->start(); // Start benchmarking for Ibank scheduler $sched_file = 'sched_ibank.php'; $sql = "INSERT INTO ::prefix::scheduler (run_once, ticks_full, sched_file, last_run) VALUES ('N', :ticks_full, :sched_file, :last_run)"; $stmt = $pdo_db->prepare($sql); $stmt->bindParam(':ticks_full', $tkireg->sched_ibank); $stmt->bindParam(':sched_file', $sched_file); $stmt->bindParam(':last_run', $now); $resxx = $stmt->execute(); $variables['update_ibank_results']['result'] = Tki\Db::logDbErrors($pdo_db, $resxx, __LINE__, __FILE__); $variables['update_ibank_results']['sched'] = $tkireg->sched_ibank; $local_table_timer->stop();
// Checking IBANK Loan Credits if ($bankinfo['loan'] < 0) { echo "'-> <span style='color:#f00;'>Detected Loan Credits Flip on IBANK Account: {$bankinfo['ship_id']}.</span> <span style='color:#0f0;'>*** FIXED ***</span><br>\n"; $resk = $db->Execute("UPDATE {$db->prefix}ibank_accounts SET loan = ? WHERE ship_id = ? LIMIT 1;", array(0, $bankinfo['ship_id'])); Tki\Db::LogDbErrors($pdo_db, $resk, __LINE__, __FILE__); if ($db->ErrorNo() > 0) { echo "error: " . $db->ErrorMsg() . "<br>\n"; } $detected = (bool) true; Tki\AdminLog::writeLog($pdo_db, 960, "21|{$bankinfo['ship_id']}|{$bankinfo['balance']}"); } $tdres->MoveNext(); } echo "Validating IBANK Transfer Amount Credits...<br>\n"; $tdres = $db->Execute("SELECT transfer_id, source_id, dest_id, amount FROM {$db->prefix}ibank_transfers"); Tki\Db::LogDbErrors($pdo_db, $tdres, __LINE__, __FILE__); /* while (!$tdres->EOF) { $transferinfo = $tdres->fields; // Checking IBANK Transfer Amount Credits if ($transferinfo['amount'] < 0) { echo "'-> <span style='color:#f00;'>Detected Transfer Amount Credits Flip on IBANK Transfer: {$transferinfo['ship_id']}.</span> <span style='color:#0f0;'>*** FIXED ***</span><br>\n"; $db->Execute ("UPDATE {$db->prefix}ibank_transfers SET amount = ? WHERE transfer_id = ? LIMIT 1;", array(0, $transferinfo['transfer_id'])); if ($db->ErrorNo() > 0) { echo "error: ". $db->ErrorMsg() . "<br>\n"; } $detected = (bool) true;