function create_tracking_table($substatus, $textstat) { global $status, $login_id; $action = ""; $issue['id'] = "Bug ID"; $issue['title'] = "Bug Title"; $issue['status'] = "Status"; $issue['login_id'] = "Submitted By"; $issue['action'] = "Action(s)"; $out = make_table($issue, "WIDTH=55%"); $counter = 0; db("SELECT id, title, login_id FROM server_issuetracking WHERE status= " . $status . $substatus); while ($issues = dbr(1)) { $action = "<a href='{$_SERVER['PHP_SELF']}?status={$status}&id={$issues['id']}&action=view'>View</a>"; if ($login_id == OWNER_ID) { //server admin only if ($status == 1) { $action .= " - <a href='{$_SERVER['PHP_SELF']}?&status={$status}&id={$issues['id']}&action=forward'>Outstanding</a>"; $action .= " - <a href='{$_SERVER['PHP_SELF']}?&status={$status}&id={$issues['id']}&action=resolve'>Close</a>"; } elseif ($status == 2) { $action .= " - <a href='{$_SERVER['PHP_SELF']}?&status={$status}&id={$issues['id']}&action=forward'>Close</a>"; $action .= " - <a href='{$_SERVER['PHP_SELF']}?&status={$status}&id={$issues['id']}&action=up'>Up</a>"; $action .= " - <a href='{$_SERVER['PHP_SELF']}?&status={$status}&id={$issues['id']}&action=down'>Down</a>"; } elseif ($status == 3) { $action .= " - <a href='{$_SERVER['PHP_SELF']}?&status={$status}&id={$issues['id']}&action=reopen'>Reopen</a>"; $action .= " - <a href='{$_SERVER['PHP_SELF']}?&status={$status}&id={$issues['id']}&action=up'>Up</a>"; $action .= " - <a href='{$_SERVER['PHP_SELF']}?&status={$status}&id={$issues['id']}&action=down'>Down</a>"; } } //end of admin only. $issue['id'] = $issues['id']; $issue['title'] = $issues['title']; $issue['status'] = $textstat; db2("select login_name from user_accounts where login_id = '{$issues['login_id']}'"); $temp_store = dbr2(1); $issue['login_id'] = $temp_store['login_name']; $issue['action'] = $action; $out .= make_row($issue); $counter++; } if ($counter == 0) { //if no bugs $issue['id'] = "NONE"; $issue['title'] = ""; $issue['status'] = ""; $issue['login_id'] = ""; $issue['action'] = ""; $out .= make_row($issue); } $out .= "</table>"; return " - {$counter} Entries<br />" . $out; }
} */ if (!$show_galaxies) { echo '<p>Vous êtes en mode vacances, pour revenir en mode normal allez au menu <a href="user_extra.php">compte & parrainage</a>.</p>'; } ?> </div> <div id="accueilColonne2" style="width: 400px;"> <?php $alpha_text = ""; $beta_text = ""; if (!$p_user['ban'] && $show_galaxies) { //cycle through the games that are running. db2("select name, db_name, paused, game_id, days_left, description from se_games where status = '1' order by last_reset asc"); while ($game_stat = dbr2(1)) { $stat = " - " . popup_help("game_info.php?db_name={$game_stat['db_name']}", 600, 450); if ($game_stat['paused'] == 1) { $stat .= " - (" . $cw['paused'] . ")"; } db("select {$game_stat['db_name']}_value as value from se_db_vars where name = 'sudden_death'"); $sd = dbr(1); if ($sd['value'] == 1) { $stat .= " - (" . $cw['sudden_death'] . ")"; } db("select {$game_stat['db_name']}_value as value from se_db_vars where name = 'new_logins'"); $sd = dbr(1); if ($sd['value'] == 0) { $stat .= " - (" . $st[810] . ")"; } db("select {$game_stat['db_name']}_value as value from se_db_vars where name = 'game_length'");
//done with the text $text = mcit($text); } //send messages // if there are more than 100 characters in a line with no spaces, then complain. if (preg_match("/\\S{100,}/", $text)) { print_page($cw['error'], $st[908] . " ;-)"); } //send a message to each of the clan mates. if ($target_id == -2) { db2("select login_id from {$db_name}_users where clan_id='{$clan_id}' && clan_id > 0"); $target_member = dbr2(1); while ($target_member) { send_message($target_member['login_id'], $text); send_templated_email($target_member['login_id'], 'message'); $target_member = dbr2(1); } $error_str = $st[909]; //send message to all players in the game } elseif ($target_id == -4) { $error_str = message_all_players($text, $db_name, $st[910], "<b class=\"b1\">" . $cw['admin'] . "</b>"); //send message to clan forum } elseif ($target_id == -5 && $clan_id > 0) { send_message($target_id, $text, $clan_id); $error_str = $cw['message_sent'] . "."; //send message to central forum } elseif ($target_id == -99 || $target_id == -50) { if ($user['login_id'] == OWNER_ID) { //server admin $sender_name = "<b class=\"b1\">" . $p_user['login_name'] . "</b> (" . $cw['server_admin'] . ")"; } elseif ($user['login_id'] == 1) {
function scramble_explored(&$target) { global $db_name, $cw, $st; $new_array = array(); if ($target['explored_sys'] != -1) { //loop through all system explored (if not explored whole universe). foreach (explode(",", $target['explored_sys']) as $value) { //delete value if not sys 1, not present location, and randomly says so. if ($value == 1 || $value == $target['location'] || mt_rand(0, 6) < 4) { $new_array[] = $value; } } //user has explored whole universe, so going to have to do this the hard way. :) } else { db2("select count(star_id) from {$db_name}_stars"); $total_num_stars = dbr2(); //loop through all existing system for ($i = 1; $i <= $total_num_stars[0]; $i++) { //delete value if not sys 1, not present location, and randomly says so. if ($i == 1 || $i == $target['location'] || mt_rand(0, 6) < 4) { $new_array[] = $i; } } } $target['explored_sys'] = implode(",", $new_array); dbn("update {$db_name}_users set explored_sys = '{$target['explored_sys']}' where login_id = '{$target['login_id']}'"); }
while ($data = dbr()) { $out .= $data['login_name'] . ' - ' . $data['nb'] . '<br />'; mysql_query("update user_accounts set ban=1, raison='Multi-compte interdit' where last_ip='" . $data['last_ip'] . "' AND passwd = '" . $data['passwd'] . "' ORDER BY `signed_up` DESC LIMIT " . ($data['nb'] - 1)); // $out .= "<br/>update user_accounts set ban=0, raison='Multi-compte interdit' where last_ip='" . $data['last_ip'] ."' AND passwd = '" . $data['passwd'] ."' ORDER BY `signed_up` DESC LIMIT ".($data['nb'] - 1)."<br/>"; } //Moriarty's Multi Checker $pass_check = array(); //store for all passwords $dup_pass = array(); //Store for duplicate passwords $ip_check = array(); //store for all passwords $ip_pass = array(); //Store for duplicate passwords db2("select a.login_name,a.login_id,a.passwd,a.last_ip,a.email_address,s.login_id from user_accounts a, {$db_name}_users s where a.login_id > 5 && s.login_id = a.login_id order by last_ip"); while ($m_check = dbr2()) { $x_pa = $pass_check; //This loop finds same pass's while ($var = each($x_pa)) { if ($var['value'] == $m_check['passwd']) { //A duplicate password $dup_pass[$m_check['login_id']] = $m_check['passwd']; $dup_pass[$var['key']] = $var['value']; } } $pass_check[$m_check['login_id']] = $m_check['passwd']; $x_ip = $ip_check; //this loop finds same IP's if ($m_check['last_ip']) { while ($var = each($ip_check)) { if ($var['value'] == $m_check['last_ip']) {
function calc_values() { global $db_name, $final_str, $GAME_VARS, $mining_drone_cost, $research_fac_cost, $st, $cw; //work out the value of all extra equip. //delta bomb costs MINIMUM of 15 regular bombs db2("select sum(cash + (genesis * {$GAME_VARS['cost_genesis_device']}) + ((alpha + gamma + (delta * 15)) * {$GAME_VARS['bomb_cost']})) as value, login_id from {$db_name}_users group by login_id"); //loop through all players while ($p_val = dbr2(1)) { $t_value = $p_val['value']; $l_id = $p_val['login_id']; //work out value of ships db("select sum(s.cost + (u.fighters * {$GAME_VARS['fighter_cost_earth']}) + (u.metal * {$GAME_VARS['buy_metal']}) + (u.fuel * {$GAME_VARS['buy_fuel']}) + (u.elect * {$GAME_VARS['buy_elect']}) + (u.colon * {$GAME_VARS['cost_colonist']})) as value from {$db_name}_ships u, se_ship_types s where u.login_id = '{$l_id}' && u.shipclass = s.type_id"); $temp = dbr(1); $t_value += $temp['value']; //value of planets db("select sum(cash + (fighters * {$GAME_VARS['fighter_cost_earth']}) + (metal * {$GAME_VARS['buy_metal']}) + (fuel * {$GAME_VARS['buy_fuel']}) + (elect * {$GAME_VARS['buy_elect']}) + (colon * {$GAME_VARS['cost_colonist']}) + (research_fac * {$research_fac_cost}) + (mining_drones * {$mining_drone_cost})) as value from {$db_name}_planets where login_id = '{$l_id}'"); $temp = dbr(1); $t_value += $temp['value']; dbn("update {$db_name}_users set approx_value = '{$t_value}' where login_id = '{$p_val['login_id']}'"); } }
} else { db("select ship_id from {$db_name}_ships where login_id = '{$ships['login_id']}' && location='{$user['location']}' && config REGEXP 'ls' limit 1"); $to_attack = dbr(1); $error_str .= " - <a href='attack.php?target={$to_attack['ship_id']}'>" . $cw['attack'] . "</a><br />"; } //cloaked ships are all grouped together. } else { $cloaked_ships += $ships['total']; if (config_check("sc", $user_ship) && config_check("hs", $ships)) { $cloaked_figs += $ships['fighters']; db("select ship_id from {$db_name}_ships where login_id = '{$ships['login_id']}' && location='{$user['location']}' && config REGEXP 'hs' limit 1"); $to_attack = dbr(1); $cloaked_attack_link = " - <a href='attack.php?target={$to_attack['ship_id']}'>" . $cw['attack'] . "</a>"; } } $ships = dbr2(1); } # end of loop of other players ships. #cloaked ships the player cannot tell many details about. //these are at the bottom of the page, and are all grouped together. if ($cloaked_figs) { $error_str .= sprintf($st[66], $cloaked_ships, $cloaked_figs) . $cloaked_attack_link . "<br />"; } elseif ($cloaked_ships) { $error_str .= "<b class=cloak><b>{$cloaked_ships}</b> " . $cw['cloaked_ships'] . "</b><br />"; } unset($ships); } } //ensure everything is outputed for this frame $error_str .= "<br />{$temp_str}"; //end the cell that has the data in it, and create a cell for minimap and such data
} $new_page .= "<p />" . $st[940] . " <input type=radio name=what_to_do value=1 CHECKED /> / " . $st[941] . "<input type='radio' name='what_to_do' value='2' /><p /><input type='submit' value='Submit' /></form>"; print_page($cw['retiring'], $new_page); //disbanding the clan } elseif ($clan['members'] < 2 || isset($_POST['what_to_do']) && $_POST['what_to_do'] == 1) { dbn("update {$db_name}_users set clan_id = 0 where clan_id = '{$user['clan_id']}'"); dbn("update {$db_name}_planets set clan_id = -1 where clan_id = '{$user['clan_id']}'"); dbn("delete from {$db_name}_clans where clan_id = '{$user['clan_id']}'"); dbn("delete from {$db_name}_messages where clan_id = '{$user['clan_id']}'"); //choosing a new leader } elseif (isset($_POST['what_to_do']) && $_POST['what_to_do'] == 2 && !isset($_POST['leader_id'])) { $new_page = $st[942]; $new_page .= "<form action='options.php' method='POST' name='retiring2'>"; db2("select login_id,login_name from {$db_name}_users where clan_id = '{$user['clan_id']}' && login_id != '{$user['login_id']}'"); $new_page .= "<select name='leader_id'>"; while ($member_name = dbr2(1)) { $new_page .= "<option value='{$member_name['login_id']}'>{$member_name['login_name']}</option>"; } $new_page .= "</select>"; foreach ($_POST as $var => $value) { $new_page .= "<input type='hidden' name='{$var}' value='{$value}' />"; } $new_page .= "<p /><input type='submit' value='Submit' /></form>"; print_page($st[943], $new_page); } } retire_user($user['login_id']); $rs = "<p /><a href='game_listing.php'>" . $st[944] . "</a>"; print_header($cw['account_removed']); insert_history($user['login_id'], $cw['retired_from_game']); echo $st[945];
function load_unload_planet($selected_ships, $load_or_unload, $do_ship = 0) { global $user, $user_ship, $db_name, $tech_mat, $text_mat, $planet, $sure, $type, $dump_all, $cw, $st; discern_type($type); $extra_where = ""; $captaining = 0; if ($selected_ships == 1) { foreach ($do_ship as $ship_id) { $extra_where .= "ship_id = '{$ship_id}' || "; if ($ship_id == $user['ship_id']) { $captaining = 1; } } $extra_where = preg_replace("/\\|\\| \$/", "", $extra_where); $extra_where = "&& ({$extra_where})"; } if ($load_or_unload == 2) { //unloading the ship //select all ships that are valid db("select sum({$tech_mat}) as goods, count(ship_id) as ship_count from {$db_name}_ships where login_id = '{$user['login_id']}' && location = '{$user['location']}' && {$tech_mat} > 0 " . $extra_where); $results = dbr(1); $turn_cost = ceil($results['ship_count'] * 0.75); $max_reached = ""; if (!isset($results['goods'])) { //no goods on any ships return sprintf($st[1535], $text_mat); } elseif ($user['turns'] < $turn_cost && !isset($dump_all)) { //insufficient turns return sprintf($st[1536], $turn_cost); unset($results); } elseif ($results['goods'] + $planet['colon'] > $planet['max_population'] && $type == 1) { $max_reached = "<b class='b1'>" . $cw['warning'] . "</b>: " . $st[1537]; } elseif (!isset($sure) && $selected_ships == 0 && !isset($dump_all)) { //confirmation get_var($st[1538] . " {$text_mat}", 'planet.php', sprintf($st[1539], $text_mat, $results[goods], $results[ship_count], $turn_cost) . $max_reached, 'sure', 'yes'); } else { //finish unloading the planets. $t_cost_str = ""; dbn("update {$db_name}_planets set {$tech_mat} = {$tech_mat} + '{$results['goods']}' where planet_id = '{$user['on_planet']}'"); dbn("update {$db_name}_ships set {$tech_mat} = 0 where login_id = '{$user['login_id']}' && location = '{$user['location']}' && {$tech_mat} > 0 " . $extra_where); if (!isset($dump_all)) { charge_turns($turn_cost); $t_cost_str = " pour un coût total de <b>{$turn_cost}</b> cycles."; } if ($captaining == 1 || $selected_ships == 0 && $user_ship[$tech_mat] > 0) { $user_ship[$tech_mat] = 0; empty_bays($user_ship); } $planet[$tech_mat] += $results['goods']; return "<b>{$results['goods']}</b> " . sprintf($st[1540], $text_mat, $results[ship_count]) . $t_cost_str; } } else { //loading the ship $taken = 0; //goods taken from planet so far. $ship_counter = 0; if ($planet[$tech_mat] < 1) { //can't take stuff if there isn't any to take return sprintf($st[1541], $text_mat); } elseif ($type == 0) { //fighters db2("select ship_id,(max_fighters - fighters) as free,ship_name, {$tech_mat} from {$db_name}_ships where login_id = '{$user['login_id']}' && location = '{$user['location']}' && (max_fighters - fighters) > 0 {$extra_where} order by free desc"); } elseif ($type != 0) { db2("select ship_id, (cargo_bays - metal - fuel - elect - colon) as free, ship_name, {$tech_mat} from {$db_name}_ships where login_id = '{$user['login_id']}' && location = '{$user['location']}' && (cargo_bays - metal - fuel - elect - colon) > 0 {$extra_where} order by free desc"); } $ships = dbr2(1); $first_mess = ""; $sec_mess = ""; $turns_txt = ""; $out = ""; if ($type == 0 && $planet['allocated_to_fleet'] > 0) { //warning about fighter allocation $first_mess = $cw['warning'] . ".<br /> " . $st[1542]; $sec_mess = $cw['warning'] . ":<br />" . $st[1543]; } if (!isset($ships['ship_id']) && $selected_ships == 0) { //check to see if there are any ships return $st[1544] . " <b class='b1'>{$text_mat}</b>."; } elseif (!isset($ships['ship_id']) && $selected_ships == 1) { //check to see if there are any ships return $st[1545] . " <b class='b1'>{$text_mat}</b>."; } else { while ($ships) { $ship_counter++; //planet can load ship w/ spare fighters. if ($ships['free'] < $planet[$tech_mat] - $taken) { if (isset($sure) || $selected_ships == 1) { //only run during the real thing. dbn("update {$db_name}_ships set {$tech_mat} = {$tech_mat} + '{$ships['free']}' where ship_id = '{$ships['ship_id']}'"); $out .= "<br /><b class='b1'>{$ships['ship_name']}</b> : " . sprintf($st[1546], $ships[free], $text_mat); if ($ships['ship_id'] == $user_ship['ship_id'] && $type == 0) { #update user ship $user_ship['fighters'] = $user_ship['max_fighters']; } elseif ($ships['ship_id'] == $user_ship['ship_id'] && $type > 0) { #update user ship $user_ship[$tech_mat] += $ships['free']; $user_ship['empty_bays'] -= $ships['free']; } } $taken += $ships['free']; //ensure user has enough turns, or stop the loop where the user is. if ($user['turns'] <= ceil($ship_counter * 0.75)) { $turns_txt = $st[1547]; $out .= $st[1548]; unset($ships); break; } //planet will run out of fighters. } elseif ($ships['free'] >= $planet[$tech_mat] - $taken) { $t868 = $ships[$tech_mat] + ($planet[$tech_mat] - $taken); if (isset($sure) || $selected_ships == 1) { #only run during the real thing. dbn("update {$db_name}_ships set {$tech_mat} = '{$t868}' where ship_id = '{$ships['ship_id']}'"); $out .= "<br /><b class='b1'>{$ships['ship_name']}</b>s " . $st[1549] . " <b>{$t868}</b> <b class='b1'>{$text_mat}</b>"; if ($ships['ship_id'] == $user_ship['ship_id'] && $type == 0) { #update user ship $user_ship['fighters'] = $t868; } elseif ($ships['ship_id'] == $user_ship['ship_id'] && $type > 0) { #update user ship $user_ship[$tech_mat] = $t868; empty_bays($user_ship); } } $taken += $t868 - $ships[$tech_mat]; unset($ships); break; } $ships = dbr2(1); } #end loop of ships $turn_cost = ceil($ship_counter * 0.75); if (!isset($sure) && $selected_ships == 0) { get_var($st[1550], 'planet.php', $turns_txt . sprintf($st[1551], $ship_counter, $taken, $text_mat, $turn_cost) . "<p />" . $first_mess, 'sure', 'yes'); } else { dbn("update {$db_name}_planets set {$tech_mat} = {$tech_mat} - '{$taken}' where planet_id = '{$user['on_planet']}'"); $planet[$tech_mat] -= $taken; if ($planet['allocated_to_fleet'] > 0 && $type == 0) { dbn("update {$db_name}_planets set allocated_to_fleet = 0 where planet_id = '{$user['on_planet']}'"); } charge_turns($turn_cost); if ($type == 1) { #colonists $planet['alloc_fight'] = 0; $planet['alloc_elect'] = 0; dbn("update {$db_name}_planets set alloc_fight = 0, alloc_elect=0 where planet_id = '{$user['on_planet']}'"); $out .= $st[1552]; } return "<b>{$ship_counter}</b>" . sprintf($st[1553], $taken, $text_mat) . " <b class='b1'>{$planet['planet_name']}</b>:<br />" . $out . "<p />" . $st[1554] . " <b>{$turn_cost}</b>.<p />" . $sec_mess; } } } }
function backup_db() { global $db_name, $final_str, $directories, $comp, $db_func_query; set_time_limit(500); //this could take time (get's done inside 1 sec on my comp, but servers arn't that dedicated. Plus they have more db entries. :) //can compress the files. if (extension_loaded("zlib")) { $ext = ".gz"; $comp = true; } else { //unable to compress $ext = ".sql"; $comp = false; } //specify, and open the file. $file_name = DATABASE . "_db_backup-" . date("G.i-M.d.Y") . $ext; $fp = fopen("../{$directories['backups']}/{$file_name}", "wb"); $counter = 0; //select all tables from DB and loop through them db2("SHOW TABLE STATUS"); while ($tables = dbr2(1)) { $counter++; $tab_str = "\n\nDROP TABLE IF EXISTS {$tables['Name']};\nCREATE TABLE {$tables['Name']} ("; $col_count = 0; //create table structure for table db("SHOW COLUMNS FROM {$tables['Name']}"); while ($cols = dbr(1)) { $tab_str .= "\n{$cols['Field']} {$cols['Type']} "; if (!isset($cols['null'])) { //set not null $tab_str .= "NOT NULL"; } else { $tab_str .= "NULL"; } if ($cols['Default'] != '') { //place default $tab_str .= " default '{$cols['Default']}'"; } if ($cols['Extra'] == 'auto_increment') { //place auto incremement $tab_str .= " auto_increment"; } $tab_str .= ","; //end row $col_count++; } //end looping through columns unset($cols); mysql_free_result($db_func_query); $keys_array = array(); //work out what the keys are for the table. db("SHOW INDEX FROM {$tables['Name']}"); while ($keys = dbr(1)) { if ($keys['Non_unique'] == 0 && $keys['Key_name'] != "PRIMARY") { //a unique key. $keys_array['UNIQUE'] = (isset($keys_array['UNIQUE']) ? $keys_array['UNIQUE'] : "") . "UNIQUE KEY {$keys['Key_name']} ({$keys['Column_name']}), "; } else { //non primary (foreign?) $keys_array[$keys['Key_name']] = (isset($keys_array[$keys['Key_name']]) ? $keys_array[$keys['Key_name']] : "") . "{$keys['Column_name']}, "; } } //end collecting key info unset($keys); mysql_free_result($db_func_query); //loop through the array of keys, and list the keys at the bottom foreach ($keys_array as $key_type => $val) { $tab_str .= "\n"; if ($key_type != "UNIQUE") { if ($key_type != "PRIMARY") { $tab_str .= "KEY "; } else { $key_type .= " KEY"; //apend "key" to "primary" } $tab_str .= "{$key_type} (" . preg_replace("/, \$/", "", $val) . "),"; } else { $tab_str .= $val; } } //end sorting out key info unset($keys_array); //remove trailing comma, and end table creation. $tab_str = preg_replace("/, \$/", "", $tab_str) . "\n)ENGINE={$tables['Engine']};"; if ($comp) { //compress before writing $tab_str = gzencode($tab_str . "\n\n"); } //save table structure to file now. fwrite($fp, $tab_str); fflush($fp); $tab_str = ""; $ins_count = 0; //get the table's actual data for the inserts //MUST use numerical array (rather than associative) db("select * from {$tables['Name']}"); while ($rows = dbr()) { $tab_str .= "\nINSERT INTO {$tables['Name']} VALUES ("; $ins_count++; //increment row counter //create the values for the insert statement for ($i = 0; $i < $col_count; $i++) { $tab_str .= "'" . mysql_escape_string($rows[$i]) . "', "; } $tab_str = preg_replace("/, \$/", "", $tab_str) . ");"; //remove trailing comma //every 100 rows, dump them to the file (save memory, and stops from crashing). //100 seems to be the optimal number. /* Do it every 1000, it takes about 5 times as long. do it every 10, it takes about 3 times as long. But 90-100 seems to be a magic number. At least one my PC. */ if ($ins_count == 100) { if ($comp) { //compress before writing $tab_str = gzencode($tab_str); } //save table structure to file now. fwrite($fp, $tab_str); fflush($fp); $tab_str = ""; $tab_str = ""; //clear tab_str. otherwise might have major issues. $ins_count = 0; //reset counter } } unset($rows); mysql_free_result($db_func_query); if ($comp) { //compress before writing $tab_str = gzencode($tab_str . "\n\n"); } //save table structure to file now. fwrite($fp, $tab_str); fflush($fp); $tab_str = ""; } //end table loop //all done fclose($fp); $final_str .= "\n<br />{$counter} tables backed up to '{$file_name}'...<br />\n"; }
} //something went wrong and there were no ships to update?!?!?! if (empty($update_ships_sql_friends) || isset($updated_friends_1) && $updated_friends_1 < 1) { print_page($st[268]); } } /************** * Enemy ships into array **************/ //no need to collect foes ships if attacking a planet. if ($planet_attack == 0) { //select all Enemy ships and dump them into an array. db2("select s.*" . $enemy_ship_counter_sql . " group by s.ship_id order by fighters {$dir_foe_ships}"); $update_ships_sql_enemies = ""; //loop through friendlies and put them all into a array while ($loop_enemies = dbr2(1)) { $loop_enemies['approx_damage'] = $loop_enemies['shields'] + $loop_enemies['fighters'] + $loop_enemies['armour'] * $armour_multiplier; $loop_enemies['ship_allocated'] = 0; $loop_enemies['friend_foe'] = 2; if ($loop_enemies['approx_damage'] < 1) { //ship has no damage absorb cap. So kill it outright. $loop_enemies['ship_destroyed'] = 1; } else { $loop_enemies['ship_destroyed'] = 0; } $target_ships[$loop_enemies['ship_id']] = $loop_enemies; $update_ships_sql_enemies .= "ship_id = '{$loop_enemies['ship_id']}' || "; $players_array[$loop_enemies['login_id']]['total_fighters'] += $loop_enemies['fighters']; } if ($simulate_attack == 0) { //replace only the last '|| ' from the string so it can be used as a viable sql string.
function black_hole($user, $star) { global $db_name, $user_ship; $bh_text = "Attention ! Attention ! Un trou noir a été détecté dans le systéme <b{$star['star_id']}</b>.<br />Vous manquez de peu d'être aspiré dedans mais vous parvenez à vous échapper au dernier moment. Vous prenez la fuite mais votre flotte à été dispersée dans la galaxie !"; db("select count(star_id) from {$db_name}_stars"); $total1 = dbr(); $total = $total1[0]; if ($user_ship['ship_id']) { $n_text = ""; db2("select ship_id,shields,fighters,ship_name from {$db_name}_ships where fleet_id = '{$user_ship['fleet_id']}' and location = '{$user_ship['location']}' && login_id = '{$user['login_id']}'"); while ($tow_ship = dbr2()) { $rand_star = random_system_num(); dbn("update {$db_name}_ships set location = '{$rand_star}', mine_mode=0 where ship_id = {$tow_ship['ship_id']}"); $totaldefs = $tow_ship['shields'] + $tow_ship['fighters']; if ($totaldefs > 9) { $damtodo = round($totaldefs / 100 * 5); $damtodo2 = $damtodo; $shield_damage = $damtodo; if ($shield_damage > $tow_ship['shields']) { $shield_damage = $tow_ship['shields']; } $damtodo -= $shield_damage; dbn("update {$db_name}_ships set fighters = fighters - {$damtodo}, shields = shields - {$shield_damage} where ship_id = '{$tow_ship['ship_id']}'"); $n_text .= "<br />The <b class=b1>{$tow_ship['ship_name']}</b> took <b>{$damtodo2}</b> damage and was thrown to system #<b>{$rand_star}</b>."; } } $rand_star = mt_rand(2, $total); if ($star['star_id'] == $rand_star) { if ($rand_star != $total) { $rand_star++; } else { $rand_star = $rand_star - 1; } } dbn("update {$db_name}_ships set location = {$rand_star}, mine_mode=0 where ship_id = {$user_ship['ship_id']}"); $totaldefs = $user_ship['shields'] + $user_ship['fighters']; if ($totaldefs > 9) { $damtodo = round($totaldefs / 100 * 5); $damtodo2 = $damtodo; $shield_damage = $damtodo; if ($shield_damage > $user_ship['shields']) { $shield_damage = $user_ship['shields']; } $damtodo -= $shield_damage; dbn("update {$db_name}_ships set fighters = fighters - {$damtodo}, shields = shields - {$shield_damage} where ship_id = '{$user_ship['ship_id']}'"); $m_text .= "<p />The <b class=b1>{$user_ship['ship_name']}</b> took <b>{$damtodo2}</b> damage and was thrown to system #<b>{$rand_star}</b>."; $user_ship['shields'] -= $shield_damage; $user_ship['fighters'] -= $damtodo; } $bh_text .= $m_text; if (!empty($n_text)) { $bh_text .= "<p />Reports from the rest of the Fleet Follow:<br />"; $bh_text .= $n_text; } $tow_ship = $user_ship; dbn("update {$db_name}_users set location = {$rand_star} where login_id = '{$user['login_id']}'"); dbn("update {$db_name}_ships set location = {$rand_star} where ship_id = '{$user['ship_id']}'"); } post_news("Mayday, Mayday. Ici le capitaine <b class=b1>{$user['login_name']}</b>. Nous avons rencontré un trou noir...... *crackle* ..... besoin d'aide.... *static*", "random_event, ship"); print_page("Location", $bh_text); }
function mail_ood_users() { global $db_name, $final_str, $cw, $st; //get galaxy name db2("select name from se_games where db_name='{$db_name}' LIMIT 1"); $galaxy_name = dbr2(1); $galaxy_name = $galaxy_name['name']; //select users who have been inactive in a game for a while. $time = time() - 7 * 86400; $q = "select {$db_name}_users.login_id, {$db_name}_users.login_name,\r\n\tuser_accounts.last_reminder,\r\n\tuser_accounts.email_address\r\n\tfrom {$db_name}_users\r\n\tleft join user_accounts on {$db_name}_users.login_id = user_accounts.login_id\r\n\twhere {$db_name}_users.login_id > 5\r\n\t&& {$db_name}_users.joined_game < '{$time}'\r\n\t&& {$db_name}_users.last_request < '{$time}'\r\n\t&& ({$db_name}_users.banned_time < " . time() . " || {$db_name}_users.banned_time = 0)\r\n\t&& user_accounts.last_reminder = 0\r\n\t"; db($q); // echo 'a ajuns'; // var_dump($q); while ($users = dbr(1)) { // echo 'a intrat'; if (filter_var($users['email_address'], FILTER_VALIDATE_EMAIL)) { $contactname = $users['login_name']; $contactemail = $users['email_address']; include '../includes/email_templates/days7.php'; $message = str_replace(array("{nickname}", "{galaxy_name}"), array($contactname, $galaxy_name), $message); //the line bellow is for testing only //$contactemail = '*****@*****.**'; $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/plain; charset=iso-8859-1\n"; $headers .= "X-Priority: 1\n"; $headers .= "X-MSMail-Priority: High\n"; $headers .= "X-Mailer: php\n"; $headers .= "From: \"" . SERVER_NAME . "\" <*****@*****.**>\n"; mail("\"" . $contactname . "\" <" . $contactemail . ">", $subject, $message, $headers); dbn("update user_accounts set last_reminder = '" . time() . "' where login_id = '{$users['login_id']}'"); $final_str .= "\n<br />{$users['login_name']} Reminded through email"; } } }
$text .= $st[151]; } $text .= $st[160]; } else { if ($num_ent[0] < $max) { $text .= "<p /><br /><a href='{$filename}?add=1'>" . $cw['add_entry'] . "</a>"; } else { $text .= $st[161]; } $text .= $st[162]; $text .= make_table(array($cw['date_entered'], $cw['entry'])); if ($num_ent[0] > 1) { $text .= "<FORM method=POST action=diary.php name=quick_del><input type=hidden name=del_select value=1 />"; } db2("select * from {$db_name}_diary where login_id = '{$user['login_id']}' order by timestamp desc"); while ($entry = dbr2(1)) { //list entries $entry['entry'] = stripslashes($entry['entry']); $entry['entry'] = mcit($entry['entry']); $e_num = $entry['entry_id']; $entry['entry_id'] = "- <a href='{$filename}?edit={$e_num}'>" . $cw['edit'] . "</a> - <a href='{$filename}?delete={$e_num}'>" . $cw['delete'] . "</a>"; if ($num_ent[0] > 1) { $entry['entry_id'] .= "- <input type=checkbox name=del_ent[{$e_num}] value={$e_num} />"; } $text .= make_row(array("<b>" . date("M d - H:i", $entry['timestamp']) . "</b>", $entry['entry'], $entry['entry_id'])); } $text .= "</table><br />"; } if ($num_ent[0] > 1) { //show the big delete options $text .= "<br /><input type='submit' value='" . $cw['delete_selected_entries'] . "' /> - <a href=javascript:TickAll(\"quick_del\")>" . $cw['invert_entry_selection'] . "</a></form><br />";
$graph = new PHPlot(); $data_array = array(); $data_array[] = ""; $legend_array = array(); $cheap_counter = 0; //select the values from the db, and put them into an array. db2("select login_name, {$element} from {$db} where {$element} > 0 && login_id > 5 order by {$element} desc limit {$players_selected}"); while ($temp_store = dbr2(1)) { $cheap_counter += $temp_store[$element]; $data_array[] = $temp_store[$element]; $legend_array[] = $temp_store['login_name']; } if ($remaining == 1) { //include remaining players, only if wanted db2("select sum({$element}) as all_users from {$db} where {$element} > 0 && login_id > 5"); $temp_store2 = dbr2(1); $data_array[] = $temp_store2['all_users'] - $cheap_counter; $legend_array[] = $cw['all_other_players']; } if (count($data_array) < 2) { //don't bother trying to make a graph, if no users. exit; } //Set some data if ($graph_type == 1) { //text-data (no time) $example_data = array($data_array, $data_array); } else { //data-data (any extra entries are time). $example_data = array($data_array); }
if (is_dir($file) && $file != "." && $file != "..") { $dir_array[] = $dir_value . $file . "/"; } elseif (is_file($file)) { $file_size += filesize($file); } } closedir($dir_stream); } $out_str .= "<p>SE File Installation size: " . number_format($file_size / 1024) . " KBytes"; print_page("Server Details", $out_str); //List information about each of the games. } elseif (isset($_GET['game_details'])) { $out_str .= "<p />Game Details:"; //loop through games db2("select * from se_games order by name"); while ($game = dbr2()) { $db_name = $game['db_name']; db("select count(login_id),sum(cash),sum(turns),sum(turns_run),sum(ships_killed), sum(fighters_lost) as lost_fighters, sum(fighters_killed) as killed_fighters from {$db_name}_users where login_id > 5"); $ct = dbr(); db("select count(login_id) from {$db_name}_users where ship_id != 1 && login_id > 5"); $ct2 = dbr(); db("select count(login_id),sum(fighters) from {$db_name}_ships where login_id > 5"); $ct3 = dbr(); db("select count(planet_id),sum(fighters),sum(colon),sum(elect),sum(metal),sum(fuel) from {$db_name}_planets where login_id != 1"); $ct4 = dbr(); db("select count(distinct clan_id),count(login_id) from {$db_name}_users where clan_id > 0 && login_id > 5"); $ct5 = dbr(); db("select count(*) from {$db_name}_news"); $ct6 = dbr(); db("select count(message_id) from {$db_name}_messages where login_id = -1"); $forum_posts = dbr();
function load_admin_vars() { global $GAME_VARS, $db_name; $GAME_VARS = array(); db2("select {$db_name}_value as value, name from se_db_vars"); while ($result = dbr2(1)) { $GAME_VARS[$result['name']] = $result['value']; } }
$last = $player[$order_by_sql]; if ($ct2 > 1) { $ct1 = $ct2; } } $option = ""; if ($user['clan_id'] == 0 && $clan['members'] < $GAME_VARS['clan_member_limit'] || $user['login_id'] == 1) { $option = "<a href='clan.php?join={$clan['clan_id']}'>Rejoindre</a>"; } elseif ($clan['members'] >= $GAME_VARS['clan_member_limit']) { $option = "Full"; } elseif ($clan['clan_id'] == $user['clan_id']) { $option = "<a href='clan.php'>" . $cw['view'] . "</a>"; } $error_str .= make_row(array($ct1, "<b class='b1'>{$clan['clan_name']}</b>(<b><font color={$clan['sym_color']}>{$clan['symbol']}</font></b>)", $clan['members'], $clan['fkilled'], $clan['flost'], $clan['skilled'], $clan['slost'], $clan['trun'], $clan['score'], $option, "<a href='clan.php?clan_info=1&target={$clan['clan_id']}'>" . $cw['details'] . "</a>")); $ct2++; $clan = dbr2(1); } $error_str .= "</table>"; } else { $error_str .= sprintf($st[547], $GAME_VARS[clans_max]); } if ($user['clan_id'] == 0 && $clan_count[0] < $GAME_VARS['clans_max'] || $user['login_id'] == 1) { $error_str .= $st[548]; if ($user['cash'] >= 10000) { $error_str .= "<p /><a href='clan.php?create=1'>" . $cw['create_a_new_clan'] . "</a><br />"; } } elseif ($clan_count[0] >= $GAME_VARS['clans_max']) { $error_str .= sprintf($st[549], $GAME_VARS[clans_max]); } print_page($cw['clan_rankings'], $error_str); }
} } elseif ($user_ship['shipclass'] < 3) { print_page($cw['Error'], $st[736]); } if (isset($do_ship)) { //user has selected stuff to transfer $num_ships = count($do_ship); $target_ship_count = ship_counter($target['login_id']); $estimated_cost = $num_ships * $cost_per_transfer; $loop_txt = ""; $rs .= "<p /><a href='send_ship.php?target={$target['login_id']}'>" . $cw['tranfer_another_ship'] . "</a><br />"; #var_dump($target_ship_count); db2("select * from user_accounts where login_id = '" . $target['login_id'] . "' LIMIT 1"); $user_transferto = dbr2(); db2("select * from user_accounts where login_id = '" . $user['login_id'] . "' LIMIT 1"); $user_transferfrom = dbr2(); if ($user['cash'] < $estimated_cost) { # ensure have enough cash $text .= sprintf($st[737], $estimated_cost, $estimated_cost) . $cw['credits'] . "."; } elseif ($num_ships < 1) { $text .= $st[738]; } elseif ($target_ship_count['other_reached'] == 1 && $target_ship_count['war_reached'] == 1) { $text .= "<b class='b1'>{$target['login_name']}</b> " . $st[739]; } elseif ($user_transferfrom['last_ip'] == $user_transferto['last_ip']) { $text .= sprintf($st[1890], $user_transferto['login_name']); } else { //can transfer ships. $transfer_counter = 0; //loops through the ships. foreach ($do_ship as $ship_id) { if ($ship_id == 1) {
function get_cost($lookup) { db2("select cost, tech_cost from se_config_list where config_id = '{$lookup}'"); return dbr2(1); }
$out .= make_row($planet_listing); $planet_listing = dbr(1); } $out .= "</table>"; print_page("Planet List", $out); } else { $out .= "There are no planets in the game.<p />"; } //give listing of all players in game to admin, and some of their details. } elseif (isset($_GET['player_list'])) { db("select login_id, cash, turns, turns_run, tech, game_login_count, genesis, one_brob, alpha, gamma, delta from {$db_name}_users where login_id > 5"); while ($player_info = dbr(1)) { db2("select count(planet_id), sum(fighters), sum(cash), sum(tech), sum(colon), sum(mining_drones), sum(metal), sum(fuel), sum(elect) from {$db_name}_planets where login_id = '{$player_info['login_id']}'"); $planet_info = dbr2(1); db2("select count(ship_id), sum(fighters), sum(shields), sum(armour), sum(cargo_bays), sum(metal), sum(fuel), sum(elect), sum(colon), sum(point_value), count(distinct location) from {$db_name}_ships where login_id = '{$player_info['login_id']}'"); $ship_info = dbr2(1); $out .= "<center><hr width = '200'></center><table cellspacing='1' cellpadding='2' border='0' bgcolor='#111111'><tr><th align='left'>" . print_name($player_info) . "</th></tr><tr><td>"; unset($player_info['login_id']); $player_info['one_brob'] = num_flagships($player_info['one_brob']); //player info $out .= make_table(array("Account Cash", "Turns", "Turns Run", "Account Tech", "Logins to game", "Genesis", "Flagship Count", "Alphas", "Gammas", "Delta")); $out .= make_row($player_info); //planet info $out .= "</table><br />Planets<br />" . make_table(array("Planet Count", "Planet Fighters", "Planet Cash", "Tech", "Colonists", "Mining Drones", "Metal", "Fuel", "Electronics")); $out .= make_row($planet_info); //ship info $out .= "</table><br />Ships<br />" . make_table(array("Ship<br />Count", "Ship<br />Fighters", "Shields", "Armour", "Cargo<br />Bays", "Metal", "Fuel", "Electronics", "Colonists", "Point<br />Value", "# Systems <br />with ships")); $out .= make_row($ship_info); $out .= "</table></td></tr></table>"; } print_page("Player Info", $out);
$text .= "</table>"; } } if ($show_won) { #Show items user has won. db2("select item_name,item_type,item_id from {$db_name}_bilkos where active=0 && bidder_id='{$user['login_id']}'"); $collect = dbr2(1); if ($collect) { $text .= "<p />"; $text .= $st[360]; $text .= make_table(array("Item Name", "Item Type")); while ($collect) { if ($collect[item_type] == 1) { $collect[item_type] = $cw['ship']; } elseif ($collect[item_type] == 2) { $collect[item_type] = $cw['equipment']; } elseif ($collect[item_type] == 3) { $collect[item_type] = $cw['upgrade']; } elseif ($collect[item_type] == 4) { $collect[item_type] = $cw['misc']; } elseif ($collect[item_type] == 5) { $collect[item_type] = $cw['planetary']; } $collect[item_id] = " - <a href='bilkos.php?show_won=1&collect={$collect['item_id']}'>Collect</a>"; $text .= make_row($collect); $collect = dbr2(1); } $text .= "</table>"; } } print_page($st[361], $text);