Example #1
0
 public static function ibankDeposit(\PDO $pdo_db, string $lang, string $account, array $playerinfo)
 {
     // Database driven language entries
     $langvars = \Tki\Translate::load($pdo_db, $lang, array('ibank'));
     $max_credits_allowed = 1.8446744073709E+19;
     $credit_space = $max_credits_allowed - $account['balance'];
     if ($credit_space > $playerinfo['credits']) {
         $credit_space = $playerinfo['credits'];
     }
     if ($credit_space < 0) {
         $credit_space = 0;
     }
     echo "<tr><td height=53 colspan=2 align=center valign=top>" . $langvars['l_ibank_depositfunds'] . "<br>---------------------------------</td></tr>" . "<tr valign=top>" . "<td height=30>" . $langvars['l_ibank_fundsavailable'] . " :</td>" . "<td align=right>" . number_format($playerinfo['credits'], 0, $langvars['local_number_dec_point'], $langvars['local_number_thousands_sep']) . " C<br></td>" . "</tr><tr valign=top>" . "<td height=90>" . $langvars['l_ibank_seldepositamount'] . " :</td><td align=right>" . "<form accept-charset='utf-8' action='ibank.php?command=deposit2' method=post>" . "<input class=term type=text size=15 maxlength=20 name=amount value=0>" . "<br><br><input class=term type=submit value=" . $langvars['l_ibank_deposit'] . ">" . "</form>" . "</td></tr>" . "<tr>" . "  <td height=30  colspan=2 align=left>" . "    <span style='color:\"#00ff00\";'>You can deposit only " . number_format($credit_space, 0, $langvars['local_number_dec_point'], $langvars['local_number_thousands_sep']) . " credits.</span><br>" . "  </td>" . "</tr>" . "<tr valign=bottom>" . "<td><a href='ibank.php?command=login'>" . $langvars['l_ibank_back'] . "</a></td><td align=right>&nbsp;<br><a href=\"main.php\">" . $langvars['l_ibank_logout'] . "</a></td>" . "</tr>";
 }
Example #2
0
 public static function traderouteCheckCompatible(\ADODB_mysqli $db, \PDO $pdo_db, string $lang, $type1, $type2, $move, $circuit, $src, $dest, array $playerinfo, Reg $tkireg, Smarty $template)
 {
     $langvars = \Tki\Translate::load($pdo_db, $lang, array('traderoutes', 'common', 'global_includes', 'global_funcs', 'footer', 'regional'));
     // Check circuit compatibility (we only use types 1 and 2 so block anything else)
     if ($circuit != "1" && $circuit != "2") {
         \Tki\AdminLog::writeLog($pdo_db, LOG_RAW, "{$playerinfo['ship_id']}|Tried to use an invalid circuit_type of '{$circuit}', This is normally a result from using an external page and should be banned.");
         self::traderouteDie($pdo_db, $lang, $tkireg, "Invalid Circuit type!<br>*** Possible Exploit has been reported to the admin. ***", $template);
     }
     // 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']));
         \Tki\Db::LogDbErrors($pdo_db, $query, __LINE__, __FILE__);
         if ($query->EOF) {
             $langvars['l_tdr_nowlink1'] = str_replace("[tdr_src_sector_id]", $src['sector_id'], $langvars['l_tdr_nowlink1']);
             $langvars['l_tdr_nowlink1'] = str_replace("[tdr_dest_sector_id]", $dest['sector_id'], $langvars['l_tdr_nowlink1']);
             self::traderouteDie($pdo_db, $lang, $tkireg, $langvars['l_tdr_nowlink1'], $template);
         }
         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']));
             \Tki\Db::LogDbErrors($pdo_db, $query, __LINE__, __FILE__);
             if ($query->EOF) {
                 $langvars['l_tdr_nowlink2'] = str_replace("[tdr_src_sector_id]", $src['sector_id'], $langvars['l_tdr_nowlink2']);
                 $langvars['l_tdr_nowlink2'] = str_replace("[tdr_dest_sector_id]", $dest['sector_id'], $langvars['l_tdr_nowlink2']);
                 self::traderouteDie($pdo_db, $lang, $tkireg, $langvars['l_tdr_nowlink2'], $template);
             }
         }
     }
     // Check ports compatibility
     if ($type1 == 'port') {
         if ($src['port_type'] == 'special') {
             if ($type2 != 'planet' && $type2 != 'team_planet') {
                 self::traderouteDie($pdo_db, $lang, $tkireg, $langvars['l_tdr_sportissrc'], $template);
             }
             if ($dest['owner'] != $playerinfo['ship_id'] && ($dest['team'] == 0 || $dest['team'] != $playerinfo['team'])) {
                 self::traderouteDie($pdo_db, $lang, $tkireg, $langvars['l_tdr_notownplanet'], $template);
             }
         } else {
             if ($type2 == 'planet') {
                 self::traderouteDie($pdo_db, $lang, $tkireg, $langvars['l_tdr_planetisdest'], $template);
             }
             if ($src['port_type'] == $dest['port_type']) {
                 self::traderouteDie($pdo_db, $lang, $tkireg, $langvars['l_tdr_samecom'], $template);
             }
         }
     } else {
         if (array_key_exists('port_type', $dest) === true && $dest['port_type'] == 'special') {
             self::traderouteDie($pdo_db, $lang, $tkireg, $langvars['l_tdr_sportcom'], $template);
         }
     }
 }
Example #3
0
 public static function display(\PDO $pdo_db, string $lang, Reg $tkireg, Smarty $template)
 {
     $request = Request::createFromGlobals();
     // Now set a container for the variables and langvars and send them off to the template system
     $variables = array();
     $langvars = array();
     $online = (int) 0;
     if (Db::isActive($pdo_db)) {
         $stamp = date("Y-m-d H:i:s", time());
         // Now (as seen by PHP)
         $since_stamp = date("Y-m-d H:i:s", time() - 5 * 60);
         // Five minutes ago
         $players_gateway = new Players\PlayersGateway($pdo_db);
         // Build a player gateway object to handle the SQL calls
         $online = $players_gateway->selectPlayersLoggedIn($since_stamp, $stamp);
         // Online is the (int) count of the numbers of players currently logged in via SQL select
     }
     $elapsed = (int) 999;
     // Default value for elapsed, overridden with an actual value if its available
     if ($tkireg !== null) {
         if (property_exists($tkireg, 'tkitimer')) {
             $tkireg->tkitimer->stop();
             $elapsed = $tkireg->tkitimer->elapsed();
         }
     }
     // Suppress the news ticker on the IBANK and index pages
     $news_ticker_active = !(preg_match("/index.php/i", $request->server->get('SCRIPT_NAME')) || preg_match("/ibank.php/i", $request->server->get('SCRIPT_NAME')) || preg_match("/new.php/i", $request->server->get('SCRIPT_NAME')));
     // Suppress the news ticker if the database is not active
     if (!Db::isActive($pdo_db)) {
         $news_ticker_active = false;
     }
     // Update counter
     $scheduler_gateway = new Scheduler\SchedulerGateway($pdo_db);
     // Build a scheduler gateway object to handle the SQL calls
     $last_run = $scheduler_gateway->selectSchedulerLastRun();
     // Last run is the (int) count of the numbers of players currently logged in via SQL select or false if DB is not active
     if ($last_run !== false) {
         $seconds_left = $tkireg->sched_ticks * 60 - (time() - $last_run);
         $show_update_ticker = true;
     } else {
         $seconds_left = (int) 0;
         $show_update_ticker = false;
     }
     // End update counter
     if ($tkireg->footer_show_debug === true) {
         $sf_logo_type = '14';
         $sf_logo_width = "150";
         $sf_logo_height = "40";
     } else {
         $sf_logo_type = '11';
         $sf_logo_width = "120";
         $sf_logo_height = "30";
     }
     if ($news_ticker_active === true) {
         // Database driven language entries
         $langvars_temp = Translate::load($pdo_db, $lang, array('news', 'common', 'footer', 'global_includes', 'logout'));
         // Use array merge so that we do not clobber the langvars array, and only add to it the items needed for footer
         $langvars = array_merge($langvars, $langvars_temp);
         // Use array unique so that we don't end up with duplicate lang array entries
         // This is resulting in an array with blank values for specific keys, so array_unique isn't entirely what we want
         // $langvars = array_unique ($langvars);
         // SQL call that selects all of the news items between the start date beginning of day, and the end of day.
         $news_gateway = new News\NewsGateway($pdo_db);
         // Build a scheduler gateway object to handle the SQL calls
         $row = $news_gateway->selectNewsByDay(date('Y-m-d'));
         $news_ticker = array();
         if (count($row) == 0) {
             array_push($news_ticker, array('url' => null, 'text' => $langvars['l_news_none'], 'type' => null, 'delay' => 5));
         } else {
             foreach ($row as $item) {
                 array_push($news_ticker, array('url' => "news.php", 'text' => $item['headline'], 'type' => $item['news_type'], 'delay' => 5));
             }
             array_push($news_ticker, array('url' => null, 'text' => "End of News", 'type' => null, 'delay' => 5));
         }
         $news_ticker['container'] = "article";
         $template->addVariables("news", $news_ticker);
     } else {
         $sf_logo_type++;
         // Make the SF logo darker for all pages except login. No need to change the sizes as 12 is the same size as 11 and 15 is the same size as 14.
     }
     $sf_logo_link = null;
     $mem_peak_usage = floor(memory_get_peak_usage() / 1024);
     $public_pages = array('ranking.php', 'new.php', 'faq.php', 'settings.php', 'news.php', 'index.php');
     $slash_position = mb_strrpos($request->server->get('SCRIPT_NAME'), '/') + 1;
     $current_page = mb_substr($request->server->get('SCRIPT_NAME'), $slash_position);
     if (in_array($current_page, $public_pages)) {
         // If it is a non-login required page, such as ranking, new, faq, settings, news, and index use the public SF logo, which increases project stats.
         $variables['suppress_logo'] = false;
     } else {
         // Else suppress the logo, so it is as fast as possible.
         $variables['suppress_logo'] = true;
     }
     // Set array with all used variables in page
     $variables['update_ticker'] = array("display" => $show_update_ticker, "seconds_left" => $seconds_left, "sched_ticks" => $tkireg->sched_ticks);
     $variables['players_online'] = $online;
     $variables['sf_logo_type'] = $sf_logo_type;
     $variables['sf_logo_height'] = $sf_logo_height;
     $variables['sf_logo_width'] = $sf_logo_width;
     $variables['sf_logo_link'] = $sf_logo_link;
     $variables['elapsed'] = $elapsed;
     $variables['mem_peak_usage'] = $mem_peak_usage;
     $variables['footer_show_debug'] = $tkireg->footer_show_debug;
     $variables['cur_year'] = date('Y');
     $template->addVariables('langvars', $langvars);
     $template->addVariables('variables', $variables);
     $template->display('footer.tpl');
 }
Example #4
0
 public static function traderouteResultsDisplaySummary(\PDO $pdo_db, string $lang, string $tdr_display_creds, $dist, array $playerinfo)
 {
     $langvars = \Tki\Translate::load($pdo_db, $lang, array('traderoutes', 'common', 'global_includes', 'global_funcs', 'footer', 'regional'));
     echo "\n<font size='3' color='white'><strong>" . $langvars['l_tdr_turnsused'] . " : <font style='color:#f00;'>{$dist['triptime']}</font></strong></font><br>";
     echo "\n<font size='3' color='white'><strong>" . $langvars['l_tdr_turnsleft'] . " : <font style='color:#0f0;'>{$playerinfo['turns']}</font></strong></font><br>";
     echo "\n<font size='3' color='white'><strong>" . $langvars['l_tdr_credits'] . " : <font style='color:#0f0;'> {$tdr_display_creds}\n</font></strong></font><br> </strong></font></center>\n";
     //echo "<font size='2'>\n";
 }