function sn_ube_simulator_fleet_converter($sym_attacker, $sym_defender) { $combat_data = array(UBE_OPTIONS => array(UBE_SIMULATOR => sys_get_param_int('simulator'), UBE_MISSION_TYPE => MT_ATTACK), UBE_PLAYERS => array(), UBE_FLEETS => array()); sn_ube_simulator_fill_side($combat_data, $sym_defender, false); sn_ube_simulator_fill_side($combat_data, $sym_attacker, true); return $combat_data; }
function scheduler_process() { global $config, $user, $debug, $lang; $is_admin_request = false; $ts_var_stat_update = strtotime($config->db_loadItem('var_stat_update')); $ts_scheduled_update = sys_schedule_get_prev_run($config->db_loadItem('stats_schedule'), $config->var_stat_update); if (sys_get_param_int('admin_update')) { define('USER_LEVEL', isset($user['authlevel']) ? $user['authlevel'] : -1); if (USER_LEVEL > 0) { $is_admin_request = true; $ts_scheduled_update = SN_TIME_NOW; } } if ($ts_scheduled_update > $ts_var_stat_update) { lng_include('admin'); sn_db_transaction_start(); $ts_var_stat_update_end = strtotime($config->db_loadItem('var_stat_update_end')); if (SN_TIME_NOW > $ts_var_stat_update_end) { $old_server_status = $config->db_loadItem('game_disable'); $config->db_saveItem('game_disable', GAME_DISABLE_STAT); $config->db_saveItem('var_stat_update_end', date(FMT_DATE_TIME_SQL, SN_TIME_NOW + ($config->db_loadItem('stats_minimal_interval') ? $config->stats_minimal_interval : 600))); $config->db_saveItem('var_stat_update_msg', 'Update started'); sn_db_transaction_commit(); $msg = $is_admin_request ? 'admin request' : 'scheduler'; $next_run = date(FMT_DATE_TIME_SQL, sys_schedule_get_prev_run($config->stats_schedule, $config->var_stat_update, true)); $msg = "Running stat updates: {$msg}. Config->var_stat_update = " . $config->var_stat_update . ', $ts_scheduled_update = ' . date(FMT_DATE_TIME_SQL, $ts_scheduled_update) . ', next_stat_update = ' . $next_run; $debug->warning($msg, 'Stat update', LOG_INFO_STAT_PROCESS); $total_time = microtime(true); // require_once('../includes/sys_stat.php'); require_once SN_ROOT_PHYSICAL . 'includes/includes/sys_stat.php'; sys_stat_calculate(); $total_time = microtime(true) - $total_time; $msg = "Stat update complete in {$total_time} seconds."; $debug->warning($msg, 'Stat update', LOG_INFO_STAT_PROCESS); $msg = "{$lang['adm_done']}: {$total_time} {$lang['sys_sec']}."; // . date(FMT_DATE_TIME, $ts_scheduled_update) . ' ' . date(FMT_DATE_TIME, $config->var_stat_update); // TODO: Analyze maintenance result. Add record to log if error. Add record to log if OK $maintenance_result = sys_maintenance(); $config->db_saveItem('var_stat_update', SN_TIME_SQL); $config->db_saveItem('var_stat_update_msg', $msg); $config->db_saveItem('var_stat_update_next', $next_run); $config->db_saveItem('var_stat_update_admin_forced', SN_TIME_SQL); $config->db_saveItem('var_stat_update_end', SN_TIME_SQL); $config->db_saveItem('game_disable', $old_server_status); } elseif ($ts_scheduled_update > $ts_var_stat_update) { $timeout = strtotime($config->db_loadItem('var_stat_update_end')) - SN_TIME_NOW; $msg = $config->db_loadItem('var_stat_update_msg'); $msg = "{$msg} ETA {$timeout} seconds. Please wait..."; } sn_db_transaction_rollback(); } elseif ($is_admin_request) { $msg = 'Stat is up to date'; } return $msg; }
function sys_avatar_upload($subject_id, &$avatar_field, $prefix = 'avatar') { global $config, $lang, $user; try { $avatar_filename = $fullsize_filename = SN_ROOT_PHYSICAL . 'images/avatar/' . $prefix . '_' . $subject_id; $avatar_filename .= '.png'; $fullsize_filename .= '_full.png'; if (sys_get_param_int('avatar_remove')) { if (file_exists($avatar_filename) && !unlink($avatar_filename)) { throw new Exception($lang['opt_msg_avatar_error_delete'], ERR_ERROR); } $avatar_field = 0; throw new Exception($lang['opt_msg_avatar_removed'], ERR_NONE); } elseif ($_FILES['avatar']['size']) { if (!in_array($_FILES['avatar']['type'], array('image/gif', 'image/jpeg', 'image/jpg', 'image/pjpeg', 'image/png')) || $_FILES['avatar']['size'] > 204800) { throw new Exception($lang['opt_msg_avatar_error_unsupported'], ERR_WARNING); } if ($_FILES['avatar']['error']) { throw new Exception(sprintf($lang['opt_msg_avatar_error_upload'], $_FILES['avatar']['error']), ERR_ERROR); } if (!($avatar_image = imagecreatefromstring(file_get_contents($_FILES['avatar']['tmp_name'])))) { throw new Exception($lang['opt_msg_avatar_error_unsupported'], ERR_WARNING); } $avatar_size = getimagesize($_FILES['avatar']['tmp_name']); $avatar_max_width = $config->avatar_max_width; $avatar_max_height = $config->avatar_max_height; if ($avatar_size[0] > $avatar_max_width || $avatar_size[1] > $avatar_max_height) { $aspect_ratio = min($avatar_max_width / $avatar_size[0], $avatar_max_height / $avatar_size[1]); $avatar_image_new = imagecreatetruecolor($avatar_size[0] * $aspect_ratio, $avatar_size[0] * $aspect_ratio); $result = imagecopyresized($avatar_image_new, $avatar_image, 0, 0, 0, 0, $avatar_size[0] * $aspect_ratio, $avatar_size[0] * $aspect_ratio, $avatar_size[0], $avatar_size[1]); imagedestroy($avatar_image); $avatar_image = $avatar_image_new; } if (file_exists($avatar_filename) && !unlink($avatar_filename)) { throw new Exception($lang['opt_msg_avatar_error_delete'], ERR_ERROR); } if (!imagepng($avatar_image, $avatar_filename, 9)) { throw new Exception($lang['opt_msg_avatar_error_writing'], ERR_ERROR); } $avatar_field = 1; imagedestroy($avatar_image); throw new Exception($lang['opt_msg_avatar_uploaded'], ERR_NONE); } } catch (Exception $e) { return array('STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, 'MESSAGE' => $e->getMessage()); } }
static function user_time_diff_probe() { // Определяем время в браузере $client_time = strtotime(sys_get_param('client_gmt')); // Попытка определить по GMT-времени браузера. В нём будет часовой пояс (GMT), поэтому время будет автоматически преобразовано в часовой пояс сервера !$client_time ? $client_time = round(sys_get_param_float('timeBrowser') / 1000) : false; // Попытка определить по Date.valueOf() - миллисекунды с начала эпохи UNIX_TIME !$client_time ? $client_time = SN_TIME_NOW : false; // Если все попытки провалились - тупо берем время сервера // TODO - REMOVE // !($client_time = strtotime(sys_get_param('client_gmt'))) // Время в браузере определяется через GMT // ? (!($client_time = sys_get_param_float('timeBrowser') / 1000) // ? $client_time = SN_TIME_NOW : false) // : false; // !($client_time = strtotime(sys_get_param('client_gmt'))) // Время в браузере определяется через GMT // ? $client_time = SN_TIME_NOW // : false; $result = array(PLAYER_OPTION_TIME_DIFF => $client_time - SN_TIME_NOW, PLAYER_OPTION_TIME_DIFF_UTC_OFFSET => ($browser_utc_offset = sys_get_param_int('utc_offset')) ? $browser_utc_offset - date('Z') : 0, PLAYER_OPTION_TIME_DIFF_FORCED => sys_get_param_int('PLAYER_OPTION_TIME_DIFF_FORCED'), PLAYER_OPTION_TIME_DIFF_MEASURE_TIME => SN_TIME_SQL); return $result; }
$detail_url = sys_get_param_str('detail_url'); $mode = sys_get_param_str('mode'); if ($sys_user_logged_in) { doquery("UPDATE {{users}} SET `news_lastread` = 0 WHERE `id` = {$user['id']} LIMIT 1;"); } if ($user['authlevel'] >= 3) { if (!empty($text)) { $idAnnounce = sys_get_param_int('id'); $dtDateTime = empty($announce_time) ? "FROM_UNIXTIME(" . time() . ")" : "'{$announce_time}'"; if ($mode == 'edit') { doquery("UPDATE {{announce}} SET `tsTimeStamp`={$dtDateTime}, `strAnnounce`='{$text}', detail_url = '{$detail_url}' WHERE `idAnnounce`={$idAnnounce}"); } else { doquery("INSERT INTO {{announce}} SET `tsTimeStamp`={$dtDateTime}, `strAnnounce`='{$text}', detail_url = '{$detail_url}'"); } doquery("UPDATE {{users}} SET `news_lastread` = `news_lastread` + 1;"); if (sys_get_param_int('news_mass_mail')) { $text = $_POST['text']; if ($detail_url) { // TODO: Move merging detail url to template $text = "{$text} <a href=\"{$detail_url}\">{$lang['news_more']}</a>"; } msg_send_simple_message('*', 0, 0, MSG_TYPE_ADMIN, $lang['sys_administration'], $lang['news_title'], $text); } $mode = ''; } switch ($mode) { case 'del': doquery("DELETE FROM {{announce}} WHERE `idAnnounce`={$announce_id} LIMIT 1;"); $mode = ''; break; case 'edit':
$blitz_generated[] = "{$row['blitz_name']},{$row['blitz_password']}"; $row['blitz_online'] ? $blitz_prize_players_active++ : false; $blitz_players++; } $blitz_prize_dark_matter = $blitz_prize_players_active * 20000; $blitz_prize_places = ceil($blitz_prize_players_active / 5); /* 'Игрок10' 'Игрок14' 'Игрок23' 'Игрок32' 'Игрок40' */ if (sys_get_param_str('prize_calculate') && $blitz_prize_players_active && ($blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter'))) { // $blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter'); $blitz_prize_places_actual = sys_get_param_int('blitz_prize_places'); sn_db_transaction_start(); $query = doquery("SELECT * FROM {{blitz_registrations}} WHERE `round_number` = {$current_round} ORDER BY `blitz_place` FOR UPDATE;"); while ($row = db_fetch($query)) { if (!$row['blitz_place']) { continue; } $blitz_prize_dark_matter_actual = round($blitz_prize_dark_matter_actual / 2); $blitz_prize_places_actual--; $reward = $blitz_prize_dark_matter_actual - $row['blitz_reward_dark_matter']; pdump("{{$row['id']}} {$row['blitz_name']}, Place {$row['blitz_place']}, Prize places {$blitz_prize_places_actual}, Prize {$reward}", $row['id']); if ($reward) { rpg_points_change($row['user_id'], RPG_BLITZ, $reward, sprintf($lang['sys_blitz_reward_log_message'], $row['blitz_place'], $row['blitz_name'])); doquery("UPDATE {{blitz_registrations}} SET blitz_reward_dark_matter = blitz_reward_dark_matter + ({$reward}) WHERE id = {$row['id']} AND `round_number` = {$current_round};"); } if (!$blitz_prize_places_actual || $blitz_prize_dark_matter_actual < 1000) {
$sym_attacker = $_POST['attacker'] ? $_POST['attacker'] : array(); if ($replay) { $unpacked = sn_ube_simulator_decode_replay($replay); $sym_defender = $unpacked['D']; $sym_attacker = $unpacked['A']; } else { $sym_defender = array(0 => $sym_defender); $sym_attacker = array(1 => $sym_attacker); } if ($_POST['submit'] || $execute) { $replay = sn_ube_simulator_encode_replay($sym_defender, 'D'); $replay .= sn_ube_simulator_encode_replay($sym_attacker, 'A'); $combat_data = sn_ube_simulator_fleet_converter($sym_attacker, $sym_defender); $combat_data[UBE_OPTIONS][UBE_METHOD] = $config->game_ube_method ? $config->game_ube_method : 0; sn_ube_combat($combat_data); if (!sys_get_param_int('simulator') || sys_get_param_str('reload')) { sn_ube_report_save($combat_data); } if (sys_get_param_str('reload')) { $combat_data = sn_ube_report_load($combat_data[UBE_REPORT_CYPHER]); } //debug($combat_data); // Рендерим их в темплейт sn_ube_report_generate($combat_data, $template_result); $template_result['MICROTIME'] = $combat_data[UBE_TIME_SPENT]; $template = gettemplate('ube_combat_report', true); $template->assign_recursive($template_result); display($template, '', false, '', false, false, true); } else { $template = gettemplate('simulator', true); $techs_and_officers = array(TECH_WEAPON, TECH_SHIELD, TECH_ARMOR, MRC_ADMIRAL);
$action = sys_get_param_str('action'); $player_banned_row = db_user_by_username($name_unsafe); if ($mode == 'banit' && $action) { if ($player_banned_row) { $reas = $_POST['why']; $days = $_POST['days']; $hour = $_POST['hour']; $mins = $_POST['mins']; $secs = $_POST['secs']; // $isVacation = $_POST['isVacation']; $BanTime = $days * 86400; $BanTime += $hour * 3600; $BanTime += $mins * 60; $BanTime += $secs; // $BannedUntil = SN_TIME_NOW + $BanTime; sys_admin_player_ban($user, $player_banned_row, $BanTime, $is_vacation = sys_get_param_int('isVacation'), sys_get_param_str('why')); $DoneMessage = "{$lang['adm_bn_thpl']} {$name_output} {$lang['adm_bn_isbn']}"; if ($is_vacation) { $DoneMessage .= $lang['adm_bn_vctn']; } $DoneMessage .= $lang['adm_bn_plnt']; } else { $DoneMessage = sprintf($lang['adm_bn_errr'], $name_output); } AdminMessage($DoneMessage, $lang['adm_ban_title']); } elseif ($mode == 'unbanit' && $action) { sys_admin_player_ban_unset($user, $player_banned_row, ($reason = sys_get_param_str('why')) ? $reason : $lang['sys_unbanned']); $DoneMessage = $lang['adm_unbn_thpl'] . " " . $name_output . " " . $lang['adm_unbn_isbn']; AdminMessage($DoneMessage, $lang['adm_unbn_ttle']); } $parse['name'] = $name_output;
} elseif (sys_get_param_str('abandon')) { //if(sec_password_encode(sys_get_param('abandon_confirm'), $user['salt']) == $user['password']) { if (sec_password_check($user, sys_get_param('abandon_confirm'))) { if ($user['id_planet'] != $user['current_planet'] && $user['current_planet'] == $planet_id) { $destroyed = SN_TIME_NOW + 60 * 60 * 24; db_planet_set_by_id($user['current_planet'], "`destruyed`='{$destroyed}', `id_owner`=0"); db_planet_set_by_parent($user['current_planet'], "`destruyed`='{$destroyed}', `id_owner`=0"); db_user_set_by_id($user['id'], '`current_planet` = `id_planet`'); message($lang['ov_delete_ok'], $lang['colony_abandon'], 'overview.php?mode=manage'); } else { message($lang['ov_delete_wrong_planet'], $lang['colony_abandon'], 'overview.php?mode=manage'); } } else { message($lang['ov_delete_wrong_pass'], $lang['colony_abandon'], 'overview.php?mode=manage'); } } elseif (($hire = sys_get_param_int('hire')) && in_array($hire, sn_get_groups('governors')) && (!get_unit_param($hire, P_MAX_STACK) || $planetrow['PLANET_GOVERNOR_ID'] != $hire || $planetrow['PLANET_GOVERNOR_ID'] == $hire && $planetrow['PLANET_GOVERNOR_LEVEL'] < get_unit_param($hire, P_MAX_STACK))) { sn_db_transaction_start(); $user = db_user_by_id($user['id'], true); $planetrow = db_planet_by_id($planetrow['id'], true); $build_data = eco_get_build_data($user, $planetrow, $hire, $planetrow['PLANET_GOVERNOR_ID'] == $hire ? $planetrow['PLANET_GOVERNOR_LEVEL'] : 0); if ($build_data['CAN'][BUILD_CREATE]) { if ($planetrow['PLANET_GOVERNOR_ID'] == $hire) { $planetrow['PLANET_GOVERNOR_LEVEL']++; $query = '`PLANET_GOVERNOR_LEVEL` + 1'; } else { $planetrow['PLANET_GOVERNOR_LEVEL'] = 1; $planetrow['PLANET_GOVERNOR_ID'] = $hire; $query = '1'; } db_planet_set_by_id($planetrow['id'], "`PLANET_GOVERNOR_ID` = {$hire}, `PLANET_GOVERNOR_LEVEL` = {$query}"); rpg_points_change($user['id'], RPG_GOVERNOR, -$build_data[BUILD_CREATE][RES_DARK_MATTER], sprintf($lang['ov_governor_purchase'], $lang['tech'][$hire], $hire, $planetrow['PLANET_GOVERNOR_LEVEL'], uni_render_planet_full($planetrow, '', false, true)));
$config->uni_price_galaxy = sys_get_param_float('uni_price_galaxy'); $config->uni_price_system = sys_get_param_float('uni_price_system'); $config->user_birthday_gift = sys_get_param_float('user_birthday_gift'); $config->user_birthday_range = sys_get_param_int('user_birthday_range'); $config->stats_hide_admins = sys_get_param_int('stats_hide_admins'); $config->stats_hide_player_list = sys_get_param_str('stats_hide_player_list'); $config->stats_hide_pm_link = sys_get_param_int('stats_hide_pm_link'); $config->stats_schedule = sys_get_param_str('stats_schedule'); $config->empire_mercenary_base_period = sys_get_param_int('empire_mercenary_base_period'); if ($config->empire_mercenary_temporary != sys_get_param_int('empire_mercenary_temporary')) { if ($config->empire_mercenary_temporary) { db_unit_list_admin_delete_mercenaries_finished(); } else { db_unit_list_admin_set_mercenaries_expire_time($config->empire_mercenary_base_period); } $config->empire_mercenary_temporary = sys_get_param_int('empire_mercenary_temporary'); } $config->db_saveAll(); $template->assign_var('MESSAGE', $lang['adm_opt_saved']); } $template->assign_vars(array('ALLOW_BUFFING' => $config->allow_buffing, 'ALLY_HELP_WEAK' => $config->ally_help_weak, 'GAME_EMAIL_PM' => $config->game_email_pm, 'game_mode' => $config->game_mode, 'game_language' => $config->game_default_language, 'ECO_SCALE_STORAGE' => $config->eco_scale_storage, 'USER_VACATION_DISABLE' => $config->user_vacation_disable, 'ADV_LEFT_MENU' => $config->advGoogleLeftMenuIsOn, 'GAME_DISABLE' => $config->game_disable, 'GAME_DEBUG' => $config->debug, 'GAME_COUNTER' => $config->game_counter, 'TPL_MINIFIER' => $config->tpl_minifier, 'EMPIRE_MERCENARY_TEMPORARY' => $config->empire_mercenary_temporary, 'SERVER_UPDATE_CHECK_AUTO' => $config->server_updater_check_auto, 'CHECK_DATE' => $config->server_updater_check_last ? date(FMT_DATE_TIME, $config->server_updater_check_last) : 0, 'CHECK_RESULT' => isset($lang['adm_opt_ver_response'][$config->server_updater_check_result]) ? $lang['adm_opt_ver_response'][$config->server_updater_check_result] : $lang['adm_opt_ver_response'][SNC_VER_UNKNOWN_RESPONSE], 'CHECK_CLASS' => isset($sn_version_check_class[$config->server_updater_check_result]) ? $sn_version_check_class[$config->server_updater_check_result] : $sn_version_check_class[SNC_VER_UNKNOWN_RESPONSE], 'SERVER_UPDATE_ID' => $config->server_updater_id, 'SERVER_UPDATE_KEY' => $config->server_updater_key, 'STATS_HIDE_ADMINS' => $config->stats_hide_admins, 'STATS_HIDE_PM_LINK' => $config->stats_hide_pm_link)); foreach ($lang['sys_game_disable_reason'] as $id => $name) { $template->assign_block_vars('sys_game_disable_reason', array('ID' => $id, 'NAME' => $name)); } foreach ($lang['sys_game_mode'] as $mode_id => $mode_name) { $template->assign_block_vars('game_modes', array('ID' => $mode_id, 'NAME' => $mode_name)); } foreach ($lang['adm_opt_ver_response'] as $ver_id => $ver_response) { $template->assign_block_vars('ver_response', array('ID' => $ver_id, 'NAME' => js_safe_string($ver_response))); } $lang_list = lng_get_list();
<?php /** * login.php * * @version 2.0 Security checks & tests by Gorlum for http://supernova.ws * @version 1.1 Security checks & tests by Gorlum for http://supernova.ws * @version 1.0 * @copyright 2008 by ?????? for XNova */ include 'includes/init.' . substr(strrchr(__FILE__, '.'), 1); lng_include('login'); lng_include('admin'); $id_ref = sys_get_param_int('id_ref'); $username = sys_get_param('username'); $password = sys_get_param('password'); if ($username) { $result = sn_login($username, $password, $_POST['rememberme']); switch ($result['status']) { case LOGIN_SUCCESS: $user = $result['user_row']; header('Location: overview.php'); break; case LOGIN_ERROR_USERNAME: case LOGIN_ERROR_PASSWORD: message($result['error_msg'], $lang['Login_Error']); break; default: } die; } elseif (!empty($_COOKIE[$config->COOKIE_NAME])) {
if ($message_class_id != MSG_TYPE_OUTBOX) { $SubUpdateQry[] = "`{$message_class['name']}` = '0'"; $user[$message_class['name']] = 0; } } $SubUpdateQry = implode(',', $SubUpdateQry); } else { $SubUpdateQry = "`{$sn_message_class_list[$current_class]['name']}` = '0', `{$sn_message_class_list[MSG_TYPE_NEW]['name']}` = `{$sn_message_class_list[MSG_TYPE_NEW]['name']}` - '{$user[$sn_message_class_list[$current_class]['name']]}'"; $SubSelectQry = "AND `message_type` = '{$current_class}'"; $user[$sn_message_class_list[MSG_TYPE_NEW]['name']] -= $user[$sn_message_class_list[$current_class]['name']]; $user[$sn_message_class_list[$current_class]['name']] = 0; } doquery("UPDATE {{users}} SET {$SubUpdateQry} WHERE `id` = '{$user['id']}' LIMIT 1;"); $message_query = "SELECT * FROM {{messages}} WHERE `message_owner` = '{$user['id']}' {$SubSelectQry} ORDER BY `message_time` DESC;"; } if (sys_get_param_int('return')) { header('Location: messages.php'); die; } $template = gettemplate('msg_message_list', true); $message_query = doquery($message_query); while ($message_row = mysql_fetch_assoc($message_query)) { $template->assign_block_vars('messages', array('ID' => $message_row['message_id'], 'DATE' => date(FMT_DATE_TIME, $message_row['message_time']), 'FROM' => htmlspecialchars($message_row['message_from']), 'SUBJ' => htmlspecialchars($message_row['message_subject']), 'TEXT' => in_array($message_row['message_type'], array(MSG_TYPE_PLAYER, MSG_TYPE_ALLIANCE)) && $message_row['message_sender'] ? nl2br(htmlspecialchars($message_row['message_text'])) : nl2br($message_row['message_text']), 'FROM_ID' => $message_row['message_sender'], 'SUBJ_SANITIZED' => htmlspecialchars($message_row['message_subject']), 'STYLE' => $current_class == MSG_TYPE_OUTBOX ? $sn_message_class_list[MSG_TYPE_OUTBOX]['name'] : $sn_message_class_list[$message_row['message_type']]['name'])); } $current_class_text = $lang['msg_class'][$current_class]; $template->assign_vars(array("MESSAGE_CLASS" => $current_class, "MESSAGE_CLASS_TEXT" => $current_class_text)); break; } if (!$template) { $template = gettemplate('msg_message_class', true); $query = doquery("SELECT message_owner, message_type, COUNT(message_owner) AS message_count FROM {{messages}} WHERE `message_owner` = {$user['id']} GROUP BY message_owner, message_type ORDER BY message_owner ASC, message_type;");
<?php require_once 'includes/init.' . substr(strrchr(__FILE__, '.'), 1); $mode = sys_get_param_int('mode'); $ajax = sys_get_param_int('ajax'); $url = 'http://supernova.ws/version_check.php?mode=' . $mode . '&db=' . DB_VERSION . '&release=' . SN_RELEASE . '&version=' . SN_VERSION . '&key=' . urlencode($config->server_updater_key) . '&id=' . urlencode($config->server_updater_id); /* //TODO REMOVE DEBUG!!! $url = 'http://localhost/supernova_site/version_check.php?mode=' . $mode . '&db=' . DB_VERSION . '&release=' . SN_RELEASE . '&version=' . SN_VERSION . '&key=' . urlencode($config->server_updater_key) . '&id=' . urlencode($config->server_updater_id); */ switch ($mode) { case SNC_MODE_REGISTER: if ($config->server_updater_key || $config->server_updater_id) { if ($ajax) { print SNC_VER_REGISTER_ERROR_REGISTERED; } die; } $url .= "&name=" . urlencode($config->game_name) . "&url=" . urlencode(SN_ROOT_VIRTUAL); //TODO REMOVE DEBUG!!! //$url .= "&name=" . urlencode($config->game_name) . "&url=" . urlencode('http://supernova.ws/'); break; } $check_result = sn_get_url_contents($url); if (!$check_result) { $version_check = SNC_VER_ERROR_CONNECT;
<?php include 'common.' . substr(strrchr(__FILE__, '.'), 1); if (sys_get_param_str('return_fleet')) { $fleet_id = sys_get_param_int('fleet_id'); if ($fleet_id) { $FleetRow = doquery("SELECT * FROM {{fleets}} WHERE `fleet_id` = '{$fleet_id}' LIMIT 1;", '', true); if ($FleetRow['fleet_owner'] == $user['id'] && $FleetRow['fleet_mess'] == 0) { $ReturnFlyingTime = ($FleetRow['fleet_end_stay'] != 0 && $FleetRow['fleet_start_time'] < $time_now ? $FleetRow['fleet_start_time'] : $time_now) - $FleetRow['start_time'] + $time_now + 1; doquery("UPDATE {{fleets}} SET `fleet_start_time` = '{$time_now}', `fleet_group` = 0, `fleet_end_stay` = '0', `fleet_end_time` = '{$ReturnFlyingTime}', `fleet_target_owner` = '{$user['id']}', `fleet_mess` = '1' WHERE `fleet_id` = '{$fleet_id}' LIMIT 1;"); // if($FleetRow['fleet_mission'] == MT_AKS) if ($FleetRow['fleet_group']) { // TODO: Make here to delete only one AKS - by adding aks_fleet_count to AKS table doquery('DELETE FROM {{aks}} WHERE `id` NOT IN (SELECT DISTINCT `fleet_group` FROM {{fleets}});'); } } elseif ($FleetRow['fleet_id'] && $FleetRow['fleet_owner'] != $user['id']) { $debug->warning('Trying to return fleet that not belong to user', 'Hack attempt', 302, array('base_dump' => true, 'fleet_row' => $FleetRow)); die('Hack attempt 302'); } } } lng_include('overview'); lng_include('fleet'); $parse = $lang; if (!$planetrow) { $parse_err['title'] = $lang['fl_error']; $parse_err['mes'] = $lang['fl_noplanetrow']; $parse['ErrorNoPlanetRow'] = parsetemplate(gettemplate('message_body'), $parse_err); } CheckPlanetUsedFields($planetrow); $template = gettemplate('flying_fleets', true);
function que_build($user, $planet, $build_mode = BUILD_CREATE, $redirect = true) { global $lang; $unit_amount_qued = 0; try { if (!$user['id']) { throw new exception('{Нет идентификатора пользователя - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION } $unit_id = sys_get_param_int('unit_id'); /* if(!$unit_id && is_array($unit_list = sys_get_param('fmenge'))) { foreach($unit_list as $unit_id => $unit_amount) if($unit_amount) break; } */ if (!$unit_id) { throw new exception('{Нет идентификатора юнита - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION } $que_id = que_get_unit_que($unit_id); if (!$que_id) { throw new exception('{Неправильный тип очереди - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION } if ($build_mode == BUILD_DESTROY && $que_id != QUE_STRUCTURES) { throw new exception('{Уничтожать можно только здания на планете}', ERR_ERROR); // TODO EXCEPTION } $que_data = sn_get_groups('ques'); $que_data = $que_data[$que_id]; // die(); // TODO Переделать под подочереди if ($que_id == QUE_STRUCTURES) { $sn_groups_build_allow = sn_get_groups('build_allow'); $que_data['unit_list'] = $sn_groups_build_allow[$planet['planet_type']]; if (!isset($que_data['unit_list'][$unit_id])) { throw new exception('{Это здание нельзя строить на ' . ($planet['planet_type'] == PT_PLANET ? 'планете' : 'луне'), ERR_ERROR); // TODO EXCEPTION } } /* // TODO Разделить очереди для Верфи и Обороны elseif($que_id == QUE_HANGAR) { $que_data['mercenary'] = in_array($unit_id, sn_get_groups('defense')) ? MRC_FORTIFIER : MRC_ENGINEER; } elseif($que_id == QUE_HANGAR) { $que_data['mercenary'] = in_array($unit_id, sn_get_groups('defense')) ? MRC_FORTIFIER : MRC_ENGINEER; } */ sn_db_transaction_start(); // Это нужно, что бы заблокировать пользователя и работу с очередями $user = db_user_by_id($user['id']); // Это нужно, что бы заблокировать планету от списания ресурсов if (isset($planet['id']) && $planet['id']) { $planet = db_planet_by_id($planet['id'], true); } else { $planet['id'] = 0; } $planet_id = $que_id == QUE_RESEARCH ? 0 : intval($planet['id']); $que = que_get($user['id'], $planet['id'], $que_id, true); $in_que =& $que['in_que'][$que_id][$user['id']][$planet_id]; $que_max_length = que_get_max_que_length($user, $planet, $que_id, $que_data); // TODO Добавить вызовы функций проверок текущей и максимальной длин очередей if (count($in_que) >= $que_max_length) { throw new exception('{Все слоты очереди заняты}', ERR_ERROR); // TODO EXCEPTION } // TODO Отдельно посмотреть на уничтожение зданий - что бы можно было уничтожать их без планов switch (eco_can_build_unit($user, $planet, $unit_id)) { case BUILD_ALLOWED: break; case BUILD_UNIT_BUSY: throw new exception('{Строение занято}', ERR_ERROR); break; // TODO EXCEPTION eco_bld_msg_err_laboratory_upgrading // case BUILD_REQUIRE_NOT_MEET: // TODO EXCEPTION eco_bld_msg_err_laboratory_upgrading // case BUILD_REQUIRE_NOT_MEET: default: if ($build_mode == BUILD_CREATE) { throw new exception('{Требования не удовлетворены}', ERR_ERROR); } break; // TODO EXCEPTION eco_bld_msg_err_requirements_not_meet } $unit_amount = floor(sys_get_param_float('unit_amount', 1)); $unit_amount_qued = $unit_amount; $units_qued = isset($in_que[$unit_id]) ? $in_que[$unit_id] : 0; $unit_level = mrc_get_level($user, $planet, $unit_id, true, true) + $units_qued; if ($unit_max = get_unit_param($unit_id, P_MAX_STACK)) { if ($unit_level >= $unit_max) { throw new exception('{Максимальное количество юнитов данного типа уже достигнуто или будет достигнуто по окончанию очереди}', ERR_ERROR); // TODO EXCEPTION } $unit_amount = max(0, min($unit_amount, $unit_max - $unit_level)); } if ($unit_amount < 1) { throw new exception('{Неправильное количество юнитов - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION } /* if($unit_max && $unit_level + $unit_amount > $unit_max) { throw new exception("Постройка {$unit_amount} {$lang['tech'][$unit_id]} приведет к привышению максимально возможного количества юнитов данного типа", ERR_ERROR); // TODO EXCEPTION } */ // TODO Переделать eco_unit_busy для всех типов зданий // if(eco_unit_busy($user, $planet, $que, $unit_id)) // { // die('Unit busy'); // TODO EXCEPTION // } if (get_unit_param($unit_id, P_STACKABLE)) { // TODO Поле 'max_Lot_size' для ограничения размера стэка в очереди - то ли в юниты, то ли в очередь if (in_array($unit_id, $group_missile = sn_get_groups('missile'))) { // TODO Поле 'container' - указывает на родительску структуру, в которой хранится данный юнит и по вместительности которой нужно применять размер юнита $used_silo = 0; foreach ($group_missile as $missile_id) { $missile_qued = isset($in_que[$missile_id]) ? $in_que[$missile_id] : 0; $used_silo += (mrc_get_level($user, $planet, $missile_id, true, true) + $missile_qued) * get_unit_param($missile_id, P_UNIT_SIZE); } $free_silo = mrc_get_level($user, $planet, STRUC_SILO) * get_unit_param(STRUC_SILO, P_CAPACITY) - $used_silo; if ($free_silo <= 0) { throw new exception('{Ракетная шахта уже заполнена или будет заполнена по окончанию очереди}', ERR_ERROR); // TODO EXCEPTION } $unit_size = get_unit_param($unit_id, P_UNIT_SIZE); if ($free_silo < $unit_size) { throw new exception("{В ракетной шахте нет места для {$lang['tech'][$unit_id]}}", ERR_ERROR); // TODO EXCEPTION } $unit_amount = max(0, min($unit_amount, floor($free_silo / $unit_size))); } $unit_level = $new_unit_level = 0; } else { $unit_amount = 1; if ($que_id == QUE_STRUCTURES) { // if($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $que['sectors'][$planet['id']] <= 0) $sectors_qued = is_array($in_que) ? array_sum($in_que) : 0; if ($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $sectors_qued <= 0) { throw new exception('{Не хватает секторов на планете}', ERR_ERROR); // TODO EXCEPTION } // И что это я такое написал? Зачем? //if($build_mode == BUILD_DESTROY && $planet['field_current'] <= $que['amounts'][$que_id]) //{ // die('Too much buildings'); // TODO EXCEPTION //} } $build_multiplier = $build_mode == BUILD_CREATE ? 1 : -1; $new_unit_level = $unit_level + $unit_amount * $build_multiplier; } $build_data = eco_get_build_data($user, $planet, $unit_id, $unit_level); $unit_amount = min($build_data['CAN'][$build_mode], $unit_amount); if ($unit_amount < 0) { throw new exception('{Не хватает ресурсов}', ERR_ERROR); // TODO EXCEPTION } if ($new_unit_level < 0) { throw new exception('{Нельзя уничтожить больше юнитов, чем есть}', ERR_ERROR); // TODO EXCEPTION } if ($build_data['RESULT'][$build_mode] != BUILD_ALLOWED) { throw new exception('{Строительство блокировано}', ERR_ERROR); // TODO EXCEPTION } // $unit_amount = min($unit_amount, MAX_FLEET_OR_DEFS_PER_ROW); $unit_amount_qued = 0; while ($unit_amount > 0 && count($que['ques'][$que_id][$user['id']][$planet_id]) < $que_max_length) { $place = min($unit_amount, MAX_FLEET_OR_DEFS_PER_ROW); que_add_unit($unit_id, $user, $planet, $build_data, $new_unit_level, $place, $build_mode); $unit_amount -= $place; $que = que_get($user['id'], $planet['id'], $que_id, true); $unit_amount_qued += $place; } // pdump($que); /* pdump($que = que_get($user['id'], $planet['id'], $que_id, true)); */ // die(); // if(count($que['ques'][$que_id][$user['id']][$planet_id]) >= $que_max_length) sn_db_transaction_commit(); if ($redirect) { sys_redirect("{$_SERVER['PHP_SELF']}?mode=" . sys_get_param_str('mode') . "&ally_id=" . sys_get_param_id('ally_id')); die; } $operation_result = array('STATUS' => ERR_NONE, 'MESSAGE' => '{Строительство начато}'); } catch (exception $e) { sn_db_transaction_rollback(); $operation_result = array('STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, 'MESSAGE' => $e->getMessage()); } if (!empty($operation_result['MESSAGE'])) { $operation_result['MESSAGE'] .= ' ' . ($unit_amount_qued ? $unit_amount_qued : $unit_amount) . 'x[' . $lang['tech'][$unit_id] . ']' . (isset($planet['id']) ? ' на ' . $planet['name'] : '') . '}'; } return $operation_result; }
} $rapid = floor($enemy_data['attack'] * (isset($enemy_data['amplify'][$unit_id]) ? $enemy_data['amplify'][$unit_id] : 1) / $unit_durability); if ($rapid >= 1) { $str_rapid_from .= "{$lang['tech'][$enemy_id]} {$lang['nfo_rf_from']} <font color=\"#ff0000\">{$rapid}</font><br>"; } } if ($str_rapid_to && $str_rapid_from) { $str_rapid_to .= '<hr>'; } return array('to' => $str_rapid_to, 'from' => $str_rapid_from); } // ---------------------------------------------------------------------------------------------------------- // Construit la page par rapport a l'information demandée ... // Permet de faire la differance entre les divers types et les pages speciales // $unit_id = sys_get_param_int('gid'); $unit_data = get_unit_param($unit_id); lng_include('infos'); $DestroyTPL = ''; $TableHeadTPL = ''; $parse = $lang; // Données de base $parse['dpath'] = $dpath; $parse['name'] = $lang['tech'][$unit_id]; $parse['image'] = $unit_id; $parse['description'] = $lang['info'][$unit_id]['description']; $unit_info = get_unit_param($unit_id); if ($unit_id >= 1 && $unit_id <= 3) { // Cas des mines $PageTPL = gettemplate('info_buildings_table'); $DestroyTPL = gettemplate('info_buildings_destroy');
<?php define('INSIDE', true); define('INSTALL', false); define('IN_ADMIN', true); require '../common.' . substr(strrchr(__FILE__, '.'), 1); if ($user['authlevel'] < 3) { AdminMessage($lang['adm_err_denied']); } $template = gettemplate('admin/planet_compensate', true); $galaxy_src = sys_get_param_int('galaxy_src'); $system_src = sys_get_param_int('system_src'); $planet_src = sys_get_param_int('planet_src'); $galaxy_dst = sys_get_param_int('galaxy_dst'); $system_dst = sys_get_param_int('system_dst'); $planet_dst = sys_get_param_int('planet_dst'); $bonus = sys_get_param_float('bonus', 1); $username_unsafe = sys_get_param_str_unsafe('username'); $username = sys_get_param_escaped('username'); if ($galaxy_src) { sn_db_transaction_start(); $errors = array(); $owner = db_user_by_username($username_unsafe, false, '*', true, true); $planet = sys_o_get_updated($owner, array('galaxy' => $galaxy_src, 'system' => $system_src, 'planet' => $planet_src, 'planet_type' => 1), SN_TIME_NOW); $que = $planet['que']; $planet = $planet['planet']; if (!$planet) { $errors[] = $lang['adm_pl_comp_err_0']; } if ($planet['destruyed']) { $errors[] = $lang['adm_pl_comp_err_1'];
function sn_options_model() { global $user, $user_option_list, $lang, $template_result, $config; $language_new = sys_get_param_str('langer', $user['lang']); if ($language_new != $user['lang']) { $lang->lng_switch($language_new); } lng_include('options'); lng_include('messages'); $FMT_DATE = preg_replace(array('/d/', '/m/', '/Y/'), array('DD', 'MM', 'YYYY'), FMT_DATE); if (sys_get_param_str('mode') == 'change') { if ($user['authlevel'] > 0) { $planet_protection = sys_get_param_int('adm_pl_prot') ? $user['authlevel'] : 0; db_planet_set_by_owner($user['id'], "`id_level` = '{$planet_protection}'"); db_user_set_by_id($user['id'], "`admin_protection` = '{$planet_protection}'"); $user['admin_protection'] = $planet_protection; } if (sys_get_param_int('vacation') && !$config->user_vacation_disable) { sn_db_transaction_start(); if ($user['authlevel'] < 3) { if ($user['vacation_next'] > SN_TIME_NOW) { message($lang['opt_vacation_err_timeout'], $lang['Error'], 'index.php?page=options', 5); die; } $is_building = doquery("SELECT * FROM `{{fleets}}` WHERE `fleet_owner` = '{$user['id']}' LIMIT 1;", true); if ($is_building) { message($lang['opt_vacation_err_your_fleet'], $lang['Error'], 'index.php?page=options', 5); die; } $que = que_get($user['id'], false); if (!empty($que)) { message($lang['opt_vacation_err_que'], $lang['Error'], 'index.php?page=options', 5); die; } $query = classSupernova::db_get_record_list(LOC_PLANET, "`id_owner` = {$user['id']}"); foreach ($query as $planet) { // $planet = sys_o_get_updated($user, $planet, SN_TIME_NOW); // $planet = $planet['planet']; db_planet_set_by_id($planet['id'], "last_update = " . SN_TIME_NOW . ", energy_used = '0', energy_max = '0',\n metal_perhour = '{$config->metal_basic_income}', crystal_perhour = '{$config->crystal_basic_income}', deuterium_perhour = '{$config->deuterium_basic_income}',\n metal_mine_porcent = '0', crystal_mine_porcent = '0', deuterium_sintetizer_porcent = '0', solar_plant_porcent = '0',\n fusion_plant_porcent = '0', solar_satelit_porcent = '0', ship_sattelite_sloth_porcent = 0"); } $user['vacation'] = SN_TIME_NOW + $config->player_vacation_time; } else { $user['vacation'] = SN_TIME_NOW; } sn_db_transaction_commit(); } foreach ($user_option_list as $option_group_id => $option_group) { foreach ($option_group as $option_name => $option_value) { if ($user[$option_name] !== null) { $user[$option_name] = sys_get_param_str($option_name); } else { $user[$option_name] = $option_value; } } } $options = sys_user_options_pack($user); $player_options = sys_get_param('options'); if (!empty($player_options)) { array_walk($player_options, function (&$value) { // TODO - Когда будет больше параметров - сделать больше проверок $value = intval($value); }); classSupernova::$user_options->offsetSet($player_options); // pdump($player_options);die(); // player_save_option_array($user, $player_options); } $username = substr(sys_get_param_str_unsafe('username'), 0, 32); $username_safe = db_escape($username); if ($username && $user['username'] != $username && $config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_NONE && sys_get_param_int('username_confirm') && !strpbrk($username, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { // проверка на корректность sn_db_transaction_start(); $name_check = doquery("SELECT * FROM {{player_name_history}} WHERE `player_name` LIKE \"{$username_safe}\" LIMIT 1 FOR UPDATE;", true); if (!$name_check || $name_check['player_id'] == $user['id']) { $user = db_user_by_id($user['id'], true); switch ($config->game_user_changename) { case SERVER_PLAYER_NAME_CHANGE_PAY: if (mrc_get_level($user, $planetrow, RES_DARK_MATTER) < $config->game_user_changename_cost) { $template_result['.']['result'][] = array('STATUS' => ERR_ERROR, 'MESSAGE' => $lang['opt_msg_name_change_err_no_dm']); break; } rpg_points_change($user['id'], RPG_NAME_CHANGE, -$config->game_user_changename_cost, sprintf('Пользователь ID %d сменил имя с "%s" на "%s"', $user['id'], $user['username'], $username)); case SERVER_PLAYER_NAME_CHANGE_FREE: db_user_set_by_id($user['id'], "`username` = '{$username_safe}'"); doquery("REPLACE INTO {{player_name_history}} SET `player_id` = {$user['id']}, `player_name` = '{$username_safe}'"); // TODO: Change cookie to not force user relogin // sn_setcookie(SN_COOKIE, '', time() - PERIOD_WEEK, SN_ROOT_RELATIVE); $template_result['.']['result'][] = array('STATUS' => ERR_NONE, 'MESSAGE' => $lang['opt_msg_name_changed']); $user['username'] = $username; break; } } else { $template_result['.']['result'][] = array('STATUS' => ERR_ERROR, 'MESSAGE' => $lang['opt_msg_name_change_err_used_name']); } sn_db_transaction_commit(); } if ($new_password = sys_get_param('newpass1')) { try { if ($new_password != sys_get_param('newpass2')) { throw new Exception($lang['opt_err_pass_unmatched'], ERR_WARNING); } if (!classSupernova::$auth->password_change(sys_get_param('db_password'), $new_password)) { throw new Exception($lang['opt_err_pass_wrong'], ERR_WARNING); } throw new Exception($lang['opt_msg_pass_changed'], ERR_NONE); } catch (Exception $e) { $template_result['.']['result'][] = array('STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, 'MESSAGE' => $e->getMessage()); } } $user['email'] = sys_get_param_str('db_email'); // if(!$template_result[F_ACCOUNT]['account_email'] && ($email_2 = sys_get_param_str('db_email2'))) { // core_auth::email_set($email_2); // } $user['dpath'] = sys_get_param_str('dpath'); $user['lang'] = sys_get_param_str('langer', $user['lang']); // if($lang->lng_switch($user['lang'])) { // lng_include('options'); // lng_include('messages'); // } $user['design'] = sys_get_param_int('design'); $user['noipcheck'] = sys_get_param_int('noipcheck'); // $user['spio_anz'] = sys_get_param_int('spio_anz'); // $user['settings_fleetactions'] = sys_get_param_int('settings_fleetactions', 1); // $user['settings_tooltiptime'] = sys_get_param_int('settings_tooltiptime'); // $user['settings_esp'] = sys_get_param_int('settings_esp'); // $user['settings_wri'] = sys_get_param_int('settings_wri'); // $user['settings_bud'] = sys_get_param_int('settings_bud'); // $user['settings_mis'] = sys_get_param_int('settings_mis'); // $user['settings_statistics'] = sys_get_param_int('settings_statistics'); // $user['settings_info'] = sys_get_param_int('settings_info'); // $user['settings_rep'] = sys_get_param_int('settings_rep'); // $user['planet_sort'] = sys_get_param_int('settings_sort'); // $user['planet_sort_order'] = sys_get_param_int('settings_order'); $user['deltime'] = !sys_get_param_int('deltime') ? 0 : ($user['deltime'] ? $user['deltime'] : SN_TIME_NOW + $config->player_delete_time); $gender = sys_get_param_int('gender', $user['gender']); !isset($lang['sys_gender_list'][$gender]) ? $gender = $user['gender'] : false; $user['gender'] = $user['gender'] == GENDER_UNKNOWN ? $gender : $user['gender']; try { if ($user['birthday']) { throw new exception(); } $user_birthday = sys_get_param_str_unsafe('user_birthday'); if (!$user_birthday || $user_birthday == $FMT_DATE) { throw new exception(); } // Some black magic to parse any valid date format - those that contains all three "d", "m" and "Y" and any of the delimeters "\", "/", ".", "-" $pos['d'] = strpos(FMT_DATE, 'd'); $pos['m'] = strpos(FMT_DATE, 'm'); $pos['Y'] = strpos(FMT_DATE, 'Y'); asort($pos); $i = 0; foreach ($pos as &$position) { $position = ++$i; } $regexp = "/" . preg_replace(array('/\\\\/', '/\\//', '/\\./', '/\\-/', '/d/', '/m/', '/Y/'), array('\\\\\\', '\\/', '\\.', '\\-', '(\\d?\\d)', '(\\d?\\d)', '(\\d{4})'), FMT_DATE) . "/"; if (!preg_match($regexp, $user_birthday, $match)) { throw new exception(); } if (!checkdate($match[$pos['m']], $match[$pos['d']], $match[$pos['Y']])) { throw new exception(); } $user['user_birthday'] = db_escape("{$match[$pos['Y']]}-{$match[$pos['m']]}-{$match[$pos['d']]}"); // EOF black magic! Now we have valid SQL date in $user['user_birthday'] - independent of date format $year = date('Y', SN_TIME_NOW); if (mktime(0, 0, 0, $match[$pos['m']], $match[$pos['d']], $year) > SN_TIME_NOW) { $year--; } $user['user_birthday_celebrated'] = db_escape("{$year}-{$match[$pos['m']]}-{$match[$pos['d']]}"); $user_birthday = ", `user_birthday` = '{$user['user_birthday']}', `user_birthday_celebrated` = '{$user['user_birthday_celebrated']}'"; } catch (exception $e) { $user_birthday = ''; } require_once 'includes/includes/sys_avatar.php'; $avatar_upload_result = sys_avatar_upload($user['id'], $user['avatar']); $template_result['.']['result'][] = $avatar_upload_result; $user_time_diff = playerTimeDiff::user_time_diff_get(); if (sys_get_param_int('PLAYER_OPTION_TIME_DIFF_FORCED')) { playerTimeDiff::user_time_diff_set(array(PLAYER_OPTION_TIME_DIFF => sys_get_param_int('PLAYER_OPTION_TIME_DIFF'), PLAYER_OPTION_TIME_DIFF_UTC_OFFSET => 0, PLAYER_OPTION_TIME_DIFF_FORCED => 1, PLAYER_OPTION_TIME_DIFF_MEASURE_TIME => SN_TIME_SQL)); } elseif (sys_get_param_int('opt_time_diff_clear') || $user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) { playerTimeDiff::user_time_diff_set(array(PLAYER_OPTION_TIME_DIFF => '', PLAYER_OPTION_TIME_DIFF_UTC_OFFSET => 0, PLAYER_OPTION_TIME_DIFF_FORCED => 0, PLAYER_OPTION_TIME_DIFF_MEASURE_TIME => SN_TIME_SQL)); } $user_options_safe = db_escape($user['options']); db_user_set_by_id($user['id'], "`email` = '{$user['email']}', `lang` = '{$user['lang']}', `avatar` = '{$user['avatar']}',\n `dpath` = '{$user['dpath']}', `design` = '{$user['design']}', `noipcheck` = '{$user['noipcheck']}',\n `deltime` = '{$user['deltime']}', `vacation` = '{$user['vacation']}', `options` = '{$user_options_safe}', `gender` = {$user['gender']}\n {$user_birthday}"); $template_result['.']['result'][] = array('STATUS' => ERR_NONE, 'MESSAGE' => $lang['opt_msg_saved']); } elseif (sys_get_param_str('result') == 'ok') { $template_result['.']['result'][] = array('STATUS' => ERR_NONE, 'MESSAGE' => $lang['opt_msg_saved']); } $user = db_user_by_id($user['id']); $options = sys_user_options_unpack($user); }
* @original made by ???? * @copyright 2008 by Pada for XNova.project.es */ include 'common.' . substr(strrchr(__FILE__, '.'), 1); lng_include('overview'); lng_include('universe'); $sensorLevel = mrc_get_level($user, $planetrow, STRUC_MOON_PHALANX); if (!intval($sensorLevel)) { message($lang['phalanx_nosensoravailable'], $lang['tech'][STRUC_MOON_PHALANX], '', 3); } if ($planetrow['planet_type'] != PT_MOON) { message($lang['phalanx_onlyformoons'], $lang['tech'][STRUC_MOON_PHALANX], '', 3); } $scan_galaxy = sys_get_param_int('galaxy'); $scan_system = sys_get_param_int('system'); $scan_planet = sys_get_param_int('planet'); $scan_planet_type = 1; // sys_get_param_int('planettype'); $id = sys_get_param_id('id'); $source_galaxy = $planetrow['galaxy']; $source_system = $planetrow['system']; $source_planet = $planetrow['planet']; $sensorRange = GetPhalanxRange($sensorLevel); $system_distance = abs($source_system - $scan_system); if ($system_distance > $sensorRange || $scan_galaxy != $source_galaxy) { message($lang['phalanx_rangeerror'], $lang['tech'][STRUC_MOON_PHALANX], '', 3); } $cost = $sensorLevel * 1000; if ($planetrow['deuterium'] < $cost) { message($lang['phalanx_nodeuterium'], "phalanx", '', 3); }
/** * eco_build.php * * @version 1.5 - Using PTE (not everywhere) by Gorlum for http://supernova.ws * @version 1.4 - Complying with PCG by Gorlum for http://supernova.ws * @version 1.3 - Security checked for SQL-injection by Gorlum for http://supernova.ws // 1.0 Mise en module initiale (creation) // 1.1 FIX interception cheat +1 // 1.2 FIX interception cheat destruction a -1 * @version 1.1 * @copyright 2008 by Chlorel for XNova */ function eco_build($que_type, $user, &$planet, $que) { global $sn_data, $lang, $config, $time_now; // start transaction here $template = gettemplate('buildings_builds', true); // Caching values that used more then one time into local variables $config_resource_multiplier = $config->resource_multiplier; $planet_type_structs = $sn_data['groups']['build_allow'][$planet['planet_type']]; // Getting parameters $action = sys_get_param_escaped('action'); $unit_id = sys_get_param_int('unit_id'); $unit_level = sys_get_param_int('unit_level'); $GET_listid = $_GET['listid']; $que_type = $que_type == SUBQUE_FLEET || $que_type == SUBQUE_DEFENSE ? QUE_HANGAR : $que_type; CheckPlanetUsedFields($planet); if ($action) { switch ($action) { case 'create': // Add unit to que for build $que = eco_que_add($user, $planet, $que, QUE_STRUCTURES, $unit_id); break; case 'destroy': // Add unit to que for remove $que = eco_que_add($user, $planet, $que, QUE_STRUCTURES, $unit_id, 1, BUILD_DESTROY); break; case 'trim': // Cancel unit from que $que = eco_que_clear($user, $planet, $que, QUE_STRUCTURES, true); break; case 'clear': // Clear que $que = eco_que_clear($user, $planet, $que, QUE_STRUCTURES); break; } header("Location: {$_SERVER['PHP_SELF']}?mode={$que_type}"); } /* // Code for fully working new que system $hangar_busy = count($que['que'][QUE_HANGAR]); $lab_busy = count($que['que'][QUE_RESEARCH]) && !$config->BuildLabWhileRun; */ $que_length = count($que['que'][$que_type]); $can_que_element = $que_length < MAX_BUILDING_QUEUE_SIZE; $fleet_list = flt_get_fleets_to_planet($planet); $caps = ECO_getPlanetCaps($user, &$planet); $planet_fields_max = eco_planet_fields_max($planet); $planet_fields_current = $planet['field_current']; $planet_fields_que = -$que['amounts'][$que_type]; $planet_fields_free = max(0, $planet_fields_max - $planet_fields_current + $planet_fields_que); $planet_fields_queable = $planet_fields_free > 0; $planet_temp_max = $planet['temp_max']; $GLOBALS['user_tech_energy'] = $user['energy_tech']; foreach ($planet_type_structs as $Element) { if (eco_can_build_unit($user, $planet, $Element)) { $element_name = $lang['tech'][$Element]; $element_sn_data =& $sn_data[$Element]; $element_level = $planet[$sn_data[$Element]['name']] + $que['in_que'][$Element]; // show energy on BuildingPage //================================ if ($element_sn_data['production']) { $element_production_energy = $element_sn_data['production'][RES_ENERGY]; $energy_current = floor($element_production_energy($element_level, 10, $planet_temp_max)); $energy_next = floor($element_production_energy($element_level + 1, 10, $planet_temp_max)); if ($Element == STRUC_MINE_SOLAR || $Element == STRUC_MINE_FUSION) { $energy_current = floor(mrc_modify_value($user, $planet, array(MRC_POWERMAN), $energy_current)); $energy_next = floor(mrc_modify_value($user, $planet, array(MRC_POWERMAN), $energy_next)); } $energy_balance = floor($energy_next - $energy_current); } else { $energy_balance = 0; } //================================ $build_data = eco_get_build_data($user, $planet, $Element, $element_level); $temp[RES_METAL] = floor($planet['metal'] + $fleet_list['own']['total'][RES_METAL] - $build_data[BUILD_CREATE][RES_METAL]); $temp[RES_CRYSTAL] = floor($planet['crystal'] + $fleet_list['own']['total'][RES_CRYSTAL] - $build_data[BUILD_CREATE][RES_CRYSTAL]); $temp[RES_DEUTERIUM] = floor($planet['deuterium'] + $fleet_list['own']['total'][RES_DEUTERIUM] - $build_data[BUILD_CREATE][RES_DEUTERIUM]); $template->assign_block_vars('production', array('ID' => $Element, 'NAME' => $element_name, 'DESCRIPTION' => $lang['info'][$Element]['description_short'], 'LEVEL' => $element_level, 'LEVEL_OLD' => $planet[$sn_data[$Element]['name']], 'LEVEL_CHANGE' => $que['in_que'][$Element], 'BUILD_CAN' => $build_data['CAN'][BUILD_CREATE], 'TIME' => pretty_time($build_data[BUILD_CREATE][RES_TIME]), 'METAL' => $build_data[BUILD_CREATE][RES_METAL], 'CRYSTAL' => $build_data[BUILD_CREATE][RES_CRYSTAL], 'DEUTERIUM' => $build_data[BUILD_CREATE][RES_DEUTERIUM], 'DESTROY_CAN' => $build_data['CAN'][BUILD_DESTROY], 'DESTROY_TIME' => pretty_time($build_data[BUILD_DESTROY][RES_TIME]), 'DESTROY_METAL' => $build_data[BUILD_DESTROY][RES_METAL], 'DESTROY_CRYSTAL' => $build_data[BUILD_DESTROY][RES_CRYSTAL], 'DESTROY_DEUTERIUM' => $build_data[BUILD_DESTROY][RES_DEUTERIUM], 'METAL_REST' => pretty_number($temp[RES_METAL], true, true), 'CRYSTAL_REST' => pretty_number($temp[RES_CRYSTAL], true, true), 'DEUTERIUM_REST' => pretty_number($temp[RES_DEUTERIUM], true, true), 'METAL_REST_NUM' => $temp[RES_METAL], 'CRYSTAL_REST_NUM' => $temp[RES_CRYSTAL], 'DEUTERIUM_REST_NUM' => $temp[RES_DEUTERIUM], 'METAL_BALANCE' => $caps['metal_perhour'][$Element], 'CRYSTAL_BALANCE' => $caps['crystal_perhour'][$Element], 'DEUTERIUM_BALANCE' => $caps['deuterium_perhour'][$Element], 'ENERGY_BALANCE' => $energy_balance, 'UNIT_BUSY' => eco_unit_busy($user, $planet, $que, $Element))); } } if (is_array($que['que'][$que_type])) { foreach ($que['que'][$que_type] as $que_element) { $template->assign_block_vars('que', $que_element); } } $template->assign_vars(array('TIME_NOW' => $time_now, 'QUE_ID' => $que_type, 'METAL' => $planet['metal'], 'CRYSTAL' => $planet['crystal'], 'DEUTERIUM' => $planet['deuterium'], 'METAL_INCOMING' => $fleet_list['own']['total'][RES_METAL], 'CRYSTAL_INCOMING' => $fleet_list['own']['total'][RES_CRYSTAL], 'DEUTERIUM_INCOMING' => $fleet_list['own']['total'][RES_DEUTERIUM], 'FIELDS_CURRENT' => $planet_fields_current, 'FIELDS_MAX' => $planet_fields_max, 'FIELDS_FREE' => $planet_fields_free, 'FIELDS_QUE' => $planet_fields_que == 0 ? '' : $planet_fields_que > 0 ? "+{$planet_fields_que}" : $planet_fields_que, 'QUE_HAS_PLACE' => $can_que_element, 'QUE_HAS_FIELDS' => $planet_fields_queable, 'FLEET_OWN' => $fleet_list['own']['count'], 'PAGE_HINT' => $lang['eco_bld_page_hint'])); display(parsetemplate($template), $lang['Builds']); }
foreach ($payment_methods as $payment_method_id => $module_list) { if (empty($module_list)) { continue; } $template_result['.']['payment'][$payment_type_id]['.']['method'][$payment_method_id] = array('ID' => $payment_method_id, 'NAME' => $lang['pay_methods'][$payment_method_id], 'IMAGE' => isset(sn_module_payment::$payment_methods[$payment_type_id][$payment_method_id]['image']) ? sn_module_payment::$payment_methods[$payment_type_id][$payment_method_id]['image'] : '', 'NAME_FORCE' => isset(sn_module_payment::$payment_methods[$payment_type_id][$payment_method_id]['name']), 'BUTTON' => isset(sn_module_payment::$payment_methods[$payment_type_id][$payment_method_id]['button'])); foreach ($module_list as $payment_module_name => $payment_module_method_details) { $template_result['.']['payment'][$payment_type_id]['.']['method'][$payment_method_id]['.']['module'][] = array('MODULE' => $payment_module_name); } } if (empty($template_result['.']['payment'][$payment_type_id]['.'])) { unset($template_result['.']['payment'][$payment_type_id]); } } $template->assign_recursive($template_result); $payment_type_selected = sys_get_param_int('payment_type'); $payment_method_selected = sys_get_param_int('payment_method'); $payment_module_valid = $payment_module_valid && (!$payment_method_selected || isset($payment_methods_available[$payment_type_selected][$payment_method_selected][$module_name])); // If payment_module invalid - making it empty OR if there is only one payment_module - selecting it if ($payment_module_valid) { // $payment_module = $payment_module; // Really - do nothing } elseif ($payment_type_selected && count($payment_methods_available[$payment_type_selected][$payment_method_selected]) == 1) { reset($payment_methods_available[$payment_type_selected][$payment_method_selected]); $payment_module = key($payment_methods_available[$payment_type_selected][$payment_method_selected]); } elseif (count($sn_module_list['payment']) == 1) { $payment_module = $module_name; } else { $payment_module = ''; } if ($payment_type_selected && $payment_method_selected) { foreach ($payment_methods_available[$payment_type_selected][$payment_method_selected] as $module_name => $temp) { $template->assign_block_vars('payment_module', array('ID' => $module_name, 'NAME' => $lang["module_{$module_name}_name"], 'DESCRIPTION' => $lang["module_{$module_name}_description"]));
function sn_chat_msg_view($template = null) { global $config, $skip_fleet_update, $user, $lang; define('IN_AJAX', true); $skip_fleet_update = true; $history = sys_get_param_str('history'); if (!$history) { $config->array_set('users', $user['id'], 'chat_last_refresh', SN_TIME_MICRO); } $page = 0; $last_message = ''; $alliance = 0; $template_result['.']['chat'] = array(); if (!$history && $config->_MODE != CACHER_NO_CACHE && $config->chat_timeout && SN_TIME_MICRO - $config->array_get('users', $user['id'], 'chat_last_activity') > $config->chat_timeout) { $result['disable'] = true; $template_result['.']['chat'][] = array('TIME' => date(FMT_DATE_TIME, htmlentities(SN_CLIENT_TIME_LOCAL, ENT_QUOTES, 'utf-8')), 'DISABLE' => true); } else { $alliance = sys_get_param_str('ally') && $user['ally_id'] ? $user['ally_id'] : 0; $page_limit = 20; // Chat rows Limit $where_add = ''; $last_message = 0; if ($history) { $rows = doquery("SELECT count(1) AS CNT FROM {{chat}} WHERE ally_id = '{$alliance}';", true); $page_count = ceil($rows['CNT'] / $page_limit); for ($i = 0; $i < $page_count; $i++) { $template_result['.']['page'][] = array('NUMBER' => $i); } $page = min($page_count, max(0, sys_get_param_int('sheet'))); } else { $last_message = sys_get_param_id('last_message'); $where_add = $last_message ? "AND `messageid` > {$last_message}" : ''; } $start_row = $page * $page_limit; $query = doquery("SELECT c.*, u.authlevel\n FROM\n {{chat}} AS c\n LEFT JOIN {{users}} AS u ON u.id = c.chat_message_sender_id\n WHERE c.chat_message_recipient_id IS NULL AND c.ally_id = '{$alliance}' {$where_add} ORDER BY messageid DESC LIMIT {$start_row}, {$page_limit};"); while ($chat_row = db_fetch($query)) { // Little magik here - to retain HTML codes from DB and stripping HTML codes from nick $chat_row['user'] = player_nick_render_to_html($chat_row['user']); $nick_stripped = htmlentities(strip_tags($chat_row['user']), ENT_QUOTES, 'utf-8'); $nick = str_replace(strip_tags($chat_row['user']), $nick_stripped, $chat_row['user']); if (!$history) { $nick = "<span style=\"cursor: pointer;\" onclick=\"addSmiley('({$nick_stripped})');\">{$nick}</span>"; } $template_result['.']['chat'][] = array('TIME' => cht_message_parse(date(FMT_DATE_TIME, $chat_row['timestamp'] + SN_CLIENT_TIME_DIFF)), 'NICK' => $nick, 'TEXT' => cht_message_parse($chat_row['message'], false, intval($chat_row['authlevel']))); $last_message = max($last_message, $chat_row['messageid']); } } $template_result['.']['chat'] = array_reverse($template_result['.']['chat']); $template_result += array('PAGE' => $page, 'ALLY' => $alliance, 'HISTORY' => $history); $template = gettemplate('chat_messages', $template); $template->assign_recursive($template_result); if ($history) { display($template, "{$lang['chat_history']} - {$lang[$alliance ? 'chat_ally' : 'chat_common']}", true, '', false, true); } else { $result['last_message'] = $last_message; ob_start(); displayP($template); $result['html'] = ob_get_contents(); ob_end_clean(); print json_encode($result); } die; }
$config->fleet_bashing_waves = sys_get_param_int('fleet_bashing_waves', 3); $config->allow_buffing = sys_get_param_int('allow_buffing'); $config->ally_help_weak = sys_get_param_int('ally_help_weak'); $config->game_email_pm = sys_get_param_int('game_email_pm'); $config->rpg_exchange_metal = sys_get_param_int('rpg_exchange_metal', 1); $config->rpg_exchange_crystal = sys_get_param_int('rpg_exchange_crystal', 2); $config->rpg_exchange_deuterium = sys_get_param_int('rpg_exchange_deuterium', 4); $config->rpg_exchange_darkMatter = sys_get_param_int('rpg_exchange_darkMatter', 1000); $config->initial_fields = sys_get_param_int('initial_fields', 200); $config->metal_basic_income = sys_get_param_int('metal_basic_income', 40); $config->crystal_basic_income = sys_get_param_int('crystal_basic_income', 20); $config->deuterium_basic_income = sys_get_param_int('deuterium_basic_income', 10); $config->energy_basic_income = sys_get_param_int('energy_basic_income'); $config->chat_timeout = sys_get_param_int('chat_timeout', 5); $config->game_news_overview = sys_get_param_int('game_news_overview', 5); $config->advGoogleLeftMenuIsOn = sys_get_param_int('advGoogleLeftMenuIsOn'); $config->advGoogleLeftMenuCode = sys_get_param('advGoogleLeftMenuCode'); $config->debug = sys_get_param_int('debug'); $config->game_counter = sys_get_param_int('game_counter'); $config->db_saveAll(); $template->assign_var('MESSAGE', $lang['adm_opt_saved']); } $template->assign_vars(array('game_disable' => $config->game_disable ? 'checked' : '', 'advGoogleLeftMenuIsOn' => $config->advGoogleLeftMenuIsOn ? 'checked' : '', 'debug' => $config->debug ? 'checked' : '', 'game_counter' => $config->game_counter ? 'checked' : '', 'user_vacation_disable' => $config->user_vacation_disable ? 'checked' : '', 'ALLOW_BUFFING' => $config->allow_buffing, 'ALLY_HELP_WEAK' => $config->ally_help_weak, 'GAME_EMAIL_PM' => $config->game_email_pm, 'game_mode' => $config->game_mode, 'game_language' => $config->game_default_language)); foreach ($lang['sys_game_mode'] as $mode_id => $mode_name) { $template->assign_block_vars('game_modes', array('ID' => $mode_id, 'NAME' => $mode_name)); } $lang_list = lng_get_list(); foreach ($lang_list as $lang_id => $lang_data) { $template->assign_block_vars('game_languages', array('ID' => $lang_id, 'NAME' => "{$lang_data['LANG_NAME_NATIVE']} ({$lang_data['LANG_NAME_ENGLISH']})")); } display(parsetemplate($template), $lang['adm_opt_title'], false, '', true);
/** * admin/adm_message_list.php * * @version 2 * @copyright 2014 by Gorlum for http://supernova.ws/ * */ define('INSIDE', true); define('INSTALL', false); define('IN_ADMIN', true); require '../common.' . substr(strrchr(__FILE__, '.'), 1); if ($user['authlevel'] < 3) { AdminMessage($lang['adm_err_denied']); } $template = gettemplate('admin/adm_messagelist', true); $int_type_selected = sys_get_param_int('int_type_selected', -1); $allowed_types = array(-1 => array('VALUE' => -1, 'TEXT' => $lang['adm_pay_filter_all'])); $template->assign_block_vars('int_type_selected', $allowed_types[-1]); foreach ($sn_message_class_list as $key => $value) { if ($key == MSG_TYPE_NEW || $key == MSG_TYPE_OUTBOX) { continue; } $template->assign_block_vars('int_type_selected', $allowed_types[$key] = array('VALUE' => $key, 'TEXT' => $lang['msg_class'][$key])); } $message_delete = sys_get_param_id('msg_del'); if (sys_get_param('str_delete_selected') && is_array($message_delete = sys_get_param('selected')) && !empty($message_delete)) { $message_delete = implode(', ', $message_delete); } if ($message_delete) { doquery("DELETE FROM {{messages}} WHERE `message_id` in ({$message_delete});"); $template->assign_block_vars('result', array('MESSAGE' => sprintf($lang['mlst_messages_deleted'], $message_delete)));
<?php /** * notes.php * * Changelog: * 2.0 copyright © 2009-2012 Gorlum for http://supernova.ws * [!] Wrote from scratch */ include 'common.' . substr(strrchr(__FILE__, '.'), 1); lng_include('notes'); $template = gettemplate('notes', true); $result = array(); if (($result_message = sys_get_param_str('MESSAGE')) && isset($lang[$result_message])) { $result[] = array('STATUS' => sys_get_param_int('STATUS'), 'MESSAGE' => $lang[$result_message]); } $note_id_edit = sys_get_param_id('note_id_edit'); if (sys_get_param('note_delete')) { try { $not = ''; $query_where = ''; switch (sys_get_param_str('note_delete_range')) { case 'all': break; case 'marked_not': $not = 'NOT'; case 'marked': if (!is_array($notes_marked = sys_get_param('note'))) { throw new exception('note_err_none_selected', ERR_WARNING); } $notes_marked_filtered = array();
* **/ define('INSIDE', true); define('INSTALL', false); define('IN_ADMIN', true); require '../common.' . substr(strrchr(__FILE__, '.'), 1); if ($user['authlevel'] < 3) { AdminMessage($lang['adm_err_denied']); } global $config; ini_set('memory_limit', $config->stats_php_memory ? $config->stats_php_memory : '256M'); lng_include('admin'); $sort_fields = array(SORT_ID => 'id', SORT_NAME => 'username', SORT_EMAIL => 'email', SORT_IP => 'user_lastip', SORT_TIME_REGISTERED => 'register_time', SORT_TIME_LAST_VISIT => 'onlinetime', SORT_TIME_BAN_UNTIL => 'banaday', SORT_REFERRAL_COUNT => 'referral_count', SORT_REFERRAL_DM => 'referral_dm'); $sort = sys_get_param_int('sort', SORT_ID); $sort = $sort_fields[$sort] ? $sort : SORT_ID; if (($action = sys_get_param_int('action')) && ($user_id = sys_get_param_id('uid'))) { $user_selected = db_user_by_id($user_id, false, 'id, username, authlevel'); if ($user_selected['authlevel'] < $user['authlevel'] && $user['authlevel'] >= 3) { switch ($action) { case ACTION_DELETE: DeleteSelectedUser($user_id); sys_redirect("{$_SERVER['SCRIPT_NAME']}?sort={$sort}"); break; case ACTION_USE: // Impersonate sn_sys_impersonate($user_selected); break; } } else { // Restricted try to delete user higher or equal level AdminMessage($lang['adm_err_denied']);
$template = gettemplate('chat_messages', true); $page_limit = 25; // Chat rows Limit $alliance = sys_get_param_str('ally'); if ($alliance && $user['ally_id']) { $alliance = $user['ally_id']; } else { $alliance = 0; } if ($history) { $rows = doquery("SELECT count(1) AS CNT FROM {{chat}} WHERE ally_id = '{$alliance}';", '', true); $page_count = ceil($rows['CNT'] / $page_limit); for ($i = 0; $i < $page_count; $i++) { $template->assign_block_vars('page', array('NUMBER' => $i)); } $page = min($page_count, sys_get_param_int('page')); } else { $page = 0; } $chat = array(); $start_row = $page * $page_limit; $query = doquery("SELECT * FROM {{chat}} WHERE ally_id = '{$alliance}' ORDER BY messageid DESC LIMIT {$start_row}, {$page_limit};"); while ($chat_row = mysql_fetch_object($query)) { // Little magik here - to retain HTML codes from DB and stripping HTML codes from nick $nick_stripped = htmlentities(strip_tags($chat_row->user), ENT_QUOTES, 'cp1251'); $nick = str_replace(strip_tags($chat_row->user), $nick_stripped, $chat_row->user); if (!$history) { $nick = "<span style=\"cursor: pointer;\" onclick=\"addSmiley('[{$nick_stripped}]');\">{$nick}</span>"; } $chat[] = array('TIME' => date(FMT_DATE_TIME, htmlentities($chat_row->timestamp, ENT_QUOTES, 'cp1251')), 'NICK' => $nick, 'TEXT' => CHT_messageParse(htmlentities($chat_row->message, ENT_QUOTES, 'cp1251'))); }
$mode = sys_get_param_int('mode'); switch ($mode) { case ADM_TOOL_CONFIG_RELOAD: $config->db_loadAll(); sys_refresh_tablelist($config->db_prefix); $config->db_loadItem('game_watchlist'); if ($config->game_watchlist) { $config->game_watchlist_array = explode(';', $config->game_watchlist); } else { unset($config->game_watchlist_array); } break; case ADM_TOOL_MD5: $template = gettemplate("admin/md5enc", true); $password_seed = sys_get_param_str_unsafe('seed', SN_SYS_SEC_CHARS_ALLOWED); $password_length = sys_get_param_int('length', 16); $string = ($string = sys_get_param_str_unsafe('string')) ? $string : sys_random_string($password_length, $password_seed); $template->assign_vars(array('SEED' => $password_seed, 'LENGTH' => $password_length, 'STRING' => htmlentities($string), 'MD5' => md5($string))); display($template, $lang['adm_tools_md5_header'], false, '', true); break; case ADM_TOOL_FORCE_ALL: $config->db_saveItem('db_version', 0); require_once '../includes/update.php'; break; case ADM_TOOL_FORCE_LAST: $config->db_saveItem('db_version', floor($config->db_version - 1)); require_once '../includes/update.php'; break; case ADM_TOOL_INFO_PHP: phpinfo(); break;
*/ include 'common.' . substr(strrchr(__FILE__, '.'), 1); lng_include('overview'); lng_include('universe'); if (!intval($planetrow['phalanx'])) { message($lang['phalanx_nosensoravailable'], $lang['tech'][42], "", 3); } if ($planetrow['planet_type'] != PT_MOON) { message($lang['phalanx_onlyformoons'], $lang['tech'][42], "", 3); } $scan_galaxy = sys_get_param_int('galaxy'); $scan_system = sys_get_param_int('system'); $scan_planet = sys_get_param_int('planet'); $scan_planet_type = 1; // sys_get_param_int('planettype'); $id = sys_get_param_int('id'); $source_galaxy = $planetrow['galaxy']; $source_system = $planetrow['system']; $source_planet = $planetrow['planet']; $sensorLevel = $planetrow['phalanx']; $sensorRange = GetPhalanxRange($sensorLevel); $system_distance = abs($source_system - $scan_system); if ($system_distance > $sensorRange || $scan_galaxy != $source_galaxy) { message($lang['phalanx_rangeerror'], $lang['tech'][42], "", 3); } $cost = $sensorLevel * 1000; /* debug(GetTargetDistance($source_galaxy, $scan_galaxy, $source_system, $scan_system, $source_planet, $scan_planet) / $sensorLevel * 10); debug(GetPhalanxRange(1), 1); debug(GetPhalanxRange(2), 2); debug(GetPhalanxRange(3), 3);
foreach ($array as $key => $value) { if ($array_name == 'type' && $who == 2 && !in_array($key, $sn_group_stat_common)) { continue; } $header = isset($value['header']) ? $value['header'] : $lang['stat_type'][$key]; $template->assign_block_vars($array_name, array('ID' => $key, 'HEADER' => $header, 'SELECTED' => $key == $selected)); } } $allow_anonymous = true; include 'common.' . substr(strrchr(__FILE__, '.'), 1); lng_include('stat'); $sn_group_stat_common = sn_get_groups('STAT_COMMON'); $who = sys_get_param_int('who', 1); $type = sys_get_param_int('type'); $type = $who != 1 && !in_array($type, $sn_group_stat_common) ? 1 : $type; $range = sys_get_param_int('range', 1); $source = sys_get_param_str('source'); $template = gettemplate('stat_statistics', true); $subject_list = array(1 => array('header' => $lang['stat_player'])); if (!$source) { $subject_list[2] = array('header' => $lang['stat_allys']); } stat_tpl_assign($template, $who, 'subject', $subject_list, $sn_group_stat_common); $stat_types = array(STAT_TOTAL => array('type' => 'total'), STAT_FLEET => array('type' => 'fleet'), STAT_TECH => array('type' => 'tech'), STAT_BUILDING => array('type' => 'build'), STAT_DEFENSE => array('type' => 'defs'), STAT_RESOURCE => array('type' => 'res'), STAT_RAID_TOTAL => array('type' => 'raids'), STAT_RAID_WON => array('type' => 'raidswin'), STAT_RAID_LOST => array('type' => 'raidsloose'), STAT_LVL_BUILDING => array('type' => 'lvl_minier'), STAT_LVL_TECH => array('type' => 'player_rpg_tech_level'), STAT_LVL_RAID => array('type' => 'lvl_raid')); stat_tpl_assign($template, $type, 'type', $stat_types, $sn_group_stat_common); $Rank = $stat_types[$type]['type']; $is_common_stat = in_array($type, $sn_group_stat_common); $start = floor($range / 100 % 100) * 100; $query = db_stat_list_statistic($who, $is_common_stat, $Rank, $start, $source); // TODO - Не работает, если игроков на Блице > 100 $record_count = $source ? db_num_rows($query) : ($who == 1 ? db_user_count() : db_ally_count());