Ejemplo n.º 1
0
function survey_vote(&$user)
{
    if (empty($user['id'])) {
        return true;
    }
    sn_db_transaction_start();
    $survey_id = sys_get_param_id('survey_id');
    $is_voted = doquery("SELECT `survey_vote_id` FROM `{{survey_votes}}` WHERE survey_parent_id = {$survey_id} AND survey_vote_user_id = {$user['id']} FOR UPDATE;", true);
    if (empty($is_voted)) {
        $survey_vote_id = sys_get_param_id('survey_vote');
        $is_answer_exists = doquery("SELECT `survey_answer_id` FROM `{{survey_answers}}` WHERE survey_parent_id = {$survey_id} AND survey_answer_id = {$survey_vote_id};", true);
        if (!empty($is_answer_exists)) {
            $user_name_safe = db_escape($user['username']);
            doquery("INSERT INTO {{survey_votes}} SET `survey_parent_id` = {$survey_id}, `survey_parent_answer_id` = {$survey_vote_id}, `survey_vote_user_id` = {$user['id']}, `survey_vote_user_name` = '{$user_name_safe}';");
        }
    }
    sn_db_transaction_commit();
    return true;
}
Ejemplo n.º 2
0
<?php

/**
 * announce.php
 *
 * @v4 Security checks by Gorlum for http://supernova.ws
 * @v2 (c) copyright 2010 by Gorlum for http://supernova.ws
 * based on admin/activeplanet.php (c) 2008 for XNova
 */
$allow_anonymous = true;
include 'common.' . substr(strrchr(__FILE__, '.'), 1);
global $config;
nws_mark_read($user);
$template = gettemplate('announce', true);
$announce_id = sys_get_param_id('id');
$text = sys_get_param_str('text');
$announce_time = sys_get_param_str('dtDateTime');
$detail_url = sys_get_param_str('detail_url');
$mode = sys_get_param_str('mode');
$announce = array();
if ($user['authlevel'] >= 3) {
    if (!empty($text)) {
        // $idAnnounce = sys_get_param_id('id');
        $announce_time = strtotime($announce_time, SN_TIME_NOW);
        $announce_time = $announce_time ? $announce_time : SN_TIME_NOW;
        if ($mode == 'edit') {
            doquery("UPDATE {{announce}} SET `tsTimeStamp` = FROM_UNIXTIME({$announce_time}), `strAnnounce`='{$text}', detail_url = '{$detail_url}' WHERE `idAnnounce`={$announce_id};");
            doquery("DELETE FROM {{survey}} WHERE `survey_announce_id` = {$announce_id};");
        } else {
            doquery("INSERT INTO {{announce}}\n        SET `tsTimeStamp` = FROM_UNIXTIME({$announce_time}), `strAnnounce`='{$text}', detail_url = '{$detail_url}',\n        `user_id` = {$user['id']}, `user_name` = '" . db_escape($user['username']) . "'");
            $announce_id = db_insert_id();
Ejemplo n.º 3
0
 */
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']);
}
if ($delete = sys_get_param_id('delete')) {
    doquery("DELETE FROM `{{logs}}` WHERE `log_id` = {$delete} LIMIT 1;");
} elseif (sys_get_param_str('delete_update_info')) {
    doquery("DELETE FROM `{{logs}}` WHERE `log_code` in (103, 180, 191);");
} elseif (sys_get_param_str('deleteall') == 'yes') {
    //  doquery("TRUNCATE TABLE `{{logs}}`");
}
if ($detail = sys_get_param_id('detail')) {
    $template = gettemplate('admin/adm_log_main_detail', true);
    $errorInfo = doquery("SELECT * FROM `{{logs}}` WHERE `log_id` = {$detail} LIMIT 1;", true);
    $error_dump = unserialize($errorInfo['log_dump']);
    if (is_array($error_dump)) {
        foreach ($error_dump as $key => $value) {
            $v = array('VAR_NAME' => $key, 'VAR_VALUE' => $key == 'query_log' ? $value : dump($value, $key));
            $template->assign_block_vars('vars', $v);
        }
    }
    $template->assign_vars($errorInfo);
} else {
    $template = gettemplate('admin/adm_log_main', true);
    $i = 0;
    $query = doquery("SELECT * FROM `{{logs}}` ORDER BY log_id DESC LIMIT 100;");
    while ($u = db_fetch($query)) {
Ejemplo n.º 4
0
//      'MESSAGE' => $e->getMessage(),
//    ));
//  }
//}
// Таблица скидок
$prev_discount = 0;
if (isset(sn_module_payment::$bonus_table) && is_array(sn_module_payment::$bonus_table)) {
    foreach (sn_module_payment::$bonus_table as $sum => $discount) {
        if ($discount && $discount != $prev_discount) {
            $template->assign_block_vars('discount', array('SUM' => $sum, 'DISCOUNT' => $discount * 100, 'DISCOUNT_ONE' => 1 + $discount, 'TEXT' => sprintf($lang['pay_mm_bonus_each'], pretty_number($sum), round($discount * 100))));
            $prev_discount = $discount;
        }
    }
}
// Результат платежа
if ($payment_id = sys_get_param_id('payment_id')) {
    $payment = doquery("SELECT * FROM {{payment}} WHERE `payment_id` = {$payment_id} LIMIT 1;", true);
    if ($payment && $payment['payment_user_id'] == $user['id']) {
        if ($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) {
            $template->assign_block_vars('result', array('MESSAGE' => sprintf($lang['pay_msg_mm_purchase_complete'], $payment['payment_dark_matter_paid'], $payment['payment_module_name'], $payment['payment_dark_matter_gained'])));
        }
        if ($payment['payment_status'] == PAYMENT_STATUS_NONE) {
            $template->assign_block_vars('result', array('MESSAGE' => sprintf($lang['pay_msg_mm_purchase_incomplete'], $payment['payment_dark_matter_paid'], $payment['payment_module_name']), 'STATUS' => 1));
        }
        if ($payment['payment_test']) {
            $template->assign_block_vars('result', array('MESSAGE' => sprintf($lang['pay_msg_mm_purchase_test']), 'STATUS' => -1));
        }
    }
}
$unit_available_amount_list =& sn_module_payment::$bonus_table;
$request = array('metamatter' => sys_get_param_float('metamatter'));
Ejemplo n.º 5
0
$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)));
}
if (sys_get_param('str_delete_date') && checkdate($month = sys_get_param_id('delete_month'), $day = sys_get_param_id('delete_day'), $year = sys_get_param_id('delete_year'))) {
    $delete_date = "{$year}-{$month}-{$day}";
    doquery("DELETE FROM {{messages}} WHERE message_time <= UNIX_TIMESTAMP('{$delete_date}')" . ($int_type_selected >= 0 ? " AND `message_type` = {$int_type_selected}" : ''));
    $template->assign_block_vars('result', array('MESSAGE' => sprintf($lang['mlst_messages_deleted_date'], $allowed_types[$int_type_selected]['TEXT'], $delete_date)));
}
$page_max = doquery('SELECT COUNT(*) AS `max` FROM {{messages}}' . ($int_type_selected >= 0 ? " WHERE `message_type` = {$int_type_selected};" : ''), true);
$page_max = ceil($page_max['max'] / 25);
$int_page_current = min(sys_get_param_id('int_page_current', 1), $page_max);
if (sys_get_param('page_prev') && $int_page_current > 1) {
    $int_page_current--;
} elseif (sys_get_param('page_next') && $int_page_current < $page_max) {
    $int_page_current++;
}
for ($i = 1; $i <= $page_max; $i++) {
    $template->assign_block_vars('page', array('NUMBER' => $i));
}
/*
$Prev       = ( !empty($_POST['prev'])   ) ? true : false;
$Next       = ( !empty($_POST['next'])   ) ? true : false;
$DelSel     = ( !empty($_POST['delsel']) ) ? true : false;
$DelDat     = ( !empty($_POST['deldat']) ) ? true : false;
$CurrPage   = ( !empty($_POST['curr'])   ) ? $_POST['curr'] : 1;
$SelType    = $_POST['type'];
Ejemplo n.º 6
0
function tpl_login_lang(&$template)
{
    global $language;
    $url_params = array();
    if ($language) {
        $url_params[] = "lang={$language}";
    }
    if ($id_ref = sys_get_param_id('id_ref')) {
        $url_params[] = "id_ref={$id_ref}";
    }
    $template->assign_vars($q = array('LANG' => $language ? $language : '', 'referral' => $id_ref ? '&id_ref=' . $id_ref : '', 'REQUEST_PARAMS' => !empty($url_params) ? '?' . implode('&', $url_params) : '', 'FILENAME' => basename($_SERVER['PHP_SELF'])));
    foreach (lng_get_list() as $lng_id => $lng_data) {
        if (isset($lng_data['LANG_VARIANTS']) && is_array($lng_data['LANG_VARIANTS'])) {
            foreach ($lng_data['LANG_VARIANTS'] as $lang_variant) {
                $lng_data1 = $lng_data;
                $lng_data1 = array_merge($lng_data1, $lang_variant);
                $template->assign_block_vars('language', $lng_data1);
            }
        } else {
            $template->assign_block_vars('language', $lng_data);
        }
    }
}
Ejemplo n.º 7
0
<?php

include 'common.' . substr(strrchr(__FILE__, '.'), 1);
if (sys_get_param_str('return_fleet')) {
    $fleet_id = sys_get_param_id('fleet_id');
    if ($fleet_id) {
        sn_db_transaction_start();
        $FleetRow = doquery("SELECT * FROM {{fleets}} WHERE `fleet_id` = '{$fleet_id}' LIMIT 1 FOR UPDATE;", '', true);
        if ($FleetRow['fleet_owner'] == $user['id'] && $FleetRow['fleet_mess'] == 0) {
            $ReturnFlyingTime = ($FleetRow['fleet_end_stay'] != 0 && $FleetRow['fleet_start_time'] < SN_TIME_NOW ? $FleetRow['fleet_start_time'] : SN_TIME_NOW) - $FleetRow['start_time'] + SN_TIME_NOW + 1;
            doquery("UPDATE {{fleets}} SET `fleet_start_time` = " . SN_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_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));
            sn_db_transaction_rollback();
            die('Hack attempt 302');
        }
        sn_db_transaction_commit();
    }
}
lng_include('overview');
lng_include('fleet');
if (!$planetrow) {
    message($lang['fl_noplanetrow'], $lang['fl_error']);
}
$template = gettemplate('flying_fleets', true);
$i = 0;
$fleet_query = doquery("SELECT * FROM {{fleets}} WHERE fleet_owner={$user['id']};");
Ejemplo n.º 8
0
function que_delete($que_type, $user = array(), $planet = array(), $clear = false)
{
    $planets_locked = array();
    // TODO: Some checks
    sn_db_transaction_start();
    $user = db_user_by_id($user['id'], true);
    $planet['id'] = $planet['id'] && $que_type !== QUE_RESEARCH ? $planet['id'] : 0;
    $global_que = que_get($user['id'], $planet['id'], $que_type, true);
    //pdump($global_que);
    //pdump($planet['id']);
    //pdump($global_que[$que_type][$planet['id']]);
    if (!empty($global_que['ques'][$que_type][$user['id']][$planet['id']])) {
        $que = array_reverse($global_que['ques'][$que_type][$user['id']][$planet['id']]);
        foreach ($que as $que_item) {
            db_que_delete_by_id($que_item['que_id']);
            if ($que_item['que_planet_id_origin']) {
                $planet['id'] = $que_item['que_planet_id_origin'];
            }
            if (!isset($planets_locked[$planet['id']])) {
                $planets_locked[$planet['id']] = $planet['id'] ? db_planet_by_id($planet['id'], true) : $planet;
            }
            $build_data = sys_unit_str2arr($que_item['que_unit_price']);
            db_change_units($user, $planets_locked[$planet['id']], array(RES_METAL => $build_data[RES_METAL] * $que_item['que_unit_amount'], RES_CRYSTAL => $build_data[RES_CRYSTAL] * $que_item['que_unit_amount'], RES_DEUTERIUM => $build_data[RES_DEUTERIUM] * $que_item['que_unit_amount']));
            if (!$clear) {
                break;
            }
        }
        if (is_numeric($planet['id'])) {
            db_planet_set_by_id($planet['id'], "`que_processed` = UNIX_TIMESTAMP(NOW())");
        } elseif (is_numeric($user['id'])) {
            db_user_set_by_id($user['id'], '`que_processed` = UNIX_TIMESTAMP(NOW())');
        }
        sn_db_transaction_commit();
    } else {
        sn_db_transaction_rollback();
    }
    //die();
    header("Location: {$_SERVER['PHP_SELF']}?mode={$que_type}" . "&ally_id=" . sys_get_param_id('ally_id'));
}
Ejemplo n.º 9
0
function sn_sys_planet_core_transmute(&$user, &$planetrow)
{
    if (!sys_get_param_str('transmute')) {
        return array();
    }
    global $lang;
    try {
        if ($planetrow['planet_type'] != PT_PLANET) {
            throw new exception($lang['ov_core_err_not_a_planet'], ERR_ERROR);
        }
        if ($planetrow['density_index'] == ($new_density_index = sys_get_param_id('density_type'))) {
            throw new exception($lang['ov_core_err_same_density'], ERR_WARNING);
        }
        sn_db_transaction_start();
        $user = db_user_by_id($user['id'], true, '*');
        $planetrow = db_planet_by_id($planetrow['id'], true, '*');
        //    $global_data = sys_o_get_updated($user, $planetrow['id'], SN_TIME_NOW);
        //    $user = $global_data['user'];
        //    $planetrow = $global_data['planet'];
        $planet_density_index = $planetrow['density_index'];
        $density_price_chart = planet_density_price_chart($planet_density_index);
        if (!isset($density_price_chart[$new_density_index])) {
            // Hack attempt
            throw new exception($lang['ov_core_err_denisty_type_wrong'], ERR_ERROR);
        }
        $user_dark_matter = mrc_get_level($user, false, RES_DARK_MATTER);
        $transmute_cost = get_unit_param(UNIT_PLANET_DENSITY, 'cost');
        $transmute_cost = $transmute_cost[RES_DARK_MATTER] * $density_price_chart[$new_density_index];
        if ($user_dark_matter < $transmute_cost) {
            throw new exception($lang['ov_core_err_no_dark_matter'], ERR_ERROR);
        }
        $sn_data_planet_density = sn_get_groups('planet_density');
        foreach ($sn_data_planet_density as $key => $value) {
            if ($key == $new_density_index) {
                break;
            }
            $prev_density_index = $key;
        }
        $new_density = round(($sn_data_planet_density[$new_density_index][UNIT_PLANET_DENSITY] + $sn_data_planet_density[$prev_density_index][UNIT_PLANET_DENSITY]) / 2);
        rpg_points_change($user['id'], RPG_PLANET_DENSITY_CHANGE, -$transmute_cost, array('Planet %1$s ID %2$d at coordinates %3$s changed density type from %4$d "%5$s" to %6$d "%7$s". New density is %8$d kg/m3', $planetrow['name'], $planetrow['id'], uni_render_coordinates($planetrow), $planet_density_index, $lang['uni_planet_density_types'][$planet_density_index], $new_density_index, $lang['uni_planet_density_types'][$new_density_index], $new_density));
        db_planet_set_by_id($planetrow['id'], "`density` = {$new_density}, `density_index` = {$new_density_index}");
        sn_db_transaction_commit();
        $planetrow['density'] = $new_density;
        $planetrow['density_index'] = $new_density_index;
        $result = array('STATUS' => ERR_NONE, 'MESSAGE' => sprintf($lang['ov_core_err_none'], $lang['uni_planet_density_types'][$planet_density_index], $lang['uni_planet_density_types'][$new_density_index], $new_density));
    } catch (exception $e) {
        sn_db_transaction_rollback();
        $result = array('STATUS' => $e->getCode(), 'MESSAGE' => $e->getMessage());
    }
    return $result;
}
Ejemplo n.º 10
0
function sn_eco_build($que_type, &$auser, &$planet)
{
    global $lang, $config;
    if ($ally_id = sys_get_param_id('ally_id')) {
        define('SN_IN_ALLY', true);
        $ranks = ally_get_ranks($auser['ally']);
        if ($ranks[$auser['ally_rank_id']]['admin'] || $auser['ally']['ally_owner'] == $auser['id']) {
            $user =& $auser['ally']['player'];
            $planet = array('metal' => $user['metal'], 'crystal' => $user['crystal'], 'deuterium' => $user['deuterium']);
        }
    }
    if (!$user) {
        $user =& $auser;
    }
    switch ($action = sys_get_param_escaped('action')) {
        case 'create':
            // Add unit to que for build
        // Add unit to que for build
        case 'destroy':
            // Add unit to que for remove
            $operation_result = que_build($user, $planet, $action == 'destroy' ? BUILD_DESTROY : BUILD_CREATE);
            break;
        case 'trim':
            que_delete($que_type, $user, $planet, false);
            break;
        case 'clear':
            que_delete($que_type, $user, $planet, true);
            break;
    }
    $group_missile = sn_get_groups('missile');
    $silo_capacity_free = 0;
    if ($que_type == QUE_STRUCTURES) {
        $build_unit_list = sn_get_groups('build_allow');
        $build_unit_list = $build_unit_list[$planet['planet_type']];
        $artifact_id = ART_NANO_BUILDER;
        $page_header = $lang['tech'][UNIT_STRUCTURES];
    } elseif ($que_type == QUE_RESEARCH) {
        if (!mrc_get_level($user, $planet, STRUC_LABORATORY)) {
            message($lang['no_laboratory'], $lang['tech'][UNIT_TECHNOLOGIES]);
        }
        if (eco_unit_busy($user, $planet, UNIT_TECHNOLOGIES)) {
            message($lang['eco_bld_msg_err_laboratory_upgrading'], $lang['tech'][UNIT_TECHNOLOGIES]);
        }
        $build_unit_list = sn_get_groups('tech');
        $artifact_id = ART_HEURISTIC_CHIP;
        $page_header = $lang['tech'][UNIT_TECHNOLOGIES] . ($user['user_as_ally'] ? "&nbsp;{$lang['sys_of_ally']}&nbsp;{$user['username']}" : '');
    } elseif ($que_type == QUE_MERCENARY) {
        //    if(!mrc_get_level($user, $planet, STRUC_LABORATORY)) {
        //      message($lang['no_laboratory'], $lang['tech'][UNIT_TECHNOLOGIES]);
        //    }
        //    if(eco_unit_busy($user, $planet, UNIT_TECHNOLOGIES)) {
        //      message($lang['eco_bld_msg_err_laboratory_upgrading'], $lang['tech'][UNIT_TECHNOLOGIES]);
        //    }
        $build_unit_list = sn_get_groups('mercenaries');
        $artifact_id = 0;
        $page_header = $lang['tech'][UNIT_MERCENARIES] . ($user['user_as_ally'] ? "&nbsp;{$lang['sys_of_ally']}&nbsp;{$user['username']}" : '');
    } else {
        if (mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) == 0) {
            message($lang['need_hangar'], $lang['tech'][STRUC_FACTORY_HANGAR]);
        }
        $build_unit_list = sn_get_groups($page_mode = $que_type == SUBQUE_FLEET ? 'fleet' : 'defense');
        $page_header = $lang[$page_mode];
        $artifact_id = 0;
        $silo_capacity_free = mrc_get_level($user, $planet, STRUC_SILO) * get_unit_param(STRUC_SILO, P_CAPACITY);
        foreach ($group_missile as $unit_id) {
            $silo_capacity_free -= (mrc_get_level($user, $planet, $unit_id, false, true) + (isset($in_que[$unit_id]) && $in_que[$unit_id] ? $in_que[$unit_id] : 0)) * get_unit_param($unit_id, P_UNIT_SIZE);
        }
        $silo_capacity_free = max(0, $silo_capacity_free);
    }
    // Caching values that used more then one time into local variables
    //  $config_resource_multiplier = $config->resource_multiplier;
    $config_resource_multiplier = game_resource_multiplier();
    /*
    // Code for fully working new que system
    $hangar_busy = count($que['que'][QUE_HANGAR]);
    $lab_busy    = count($que['que'][QUE_RESEARCH]) && !$config->BuildLabWhileRun;
    */
    $template = gettemplate('buildings_builds', true);
    if (!empty($operation_result)) {
        $template->assign_block_vars('result', $operation_result);
    }
    $planet_id = $que_type == QUE_RESEARCH || $que_type == QUE_MERCENARY ? 0 : $planet['id'];
    $ques = que_get($user['id'], $planet_id, $que_type);
    $in_que =& $ques['in_que'][$que_type][$user['id']][$planet_id];
    $que =& $ques['ques'][$que_type][$user['id']][$planet_id];
    que_tpl_parse($template, $que_type, $user, $planet, $que);
    $que_length = count($que);
    $can_que_element = $que_length < que_get_max_que_length($user, $planet, $que_type);
    $fleet_list = flt_get_fleets_to_planet($planet);
    $planet_fields_max = eco_planet_fields_max($planet);
    $planet_fields_current = $planet['field_current'];
    $planet_fields_que = is_array($in_que) ? -array_sum($in_que) : 0;
    $planet_fields_free = max(0, $planet_fields_max - $planet_fields_current + $planet_fields_que);
    $planet_fields_queable = $que_type != QUE_STRUCTURES || $planet_fields_free > 0;
    //$planet_temp_max       = $planet['temp_max'];
    $sn_modifiers_resource = sn_get_groups('modifiers');
    $sn_modifiers_resource = $sn_modifiers_resource[MODIFIER_RESOURCE_PRODUCTION];
    $sn_groups_density = sn_get_groups('planet_density');
    $density_info = $sn_groups_density[$planet['density_index']][UNIT_RESOURCES];
    $user_dark_matter = mrc_get_level($user, null, RES_DARK_MATTER);
    foreach ($build_unit_list as $unit_id) {
        $level_base = mrc_get_level($user, $planet, $unit_id, false, true);
        $level_effective = mrc_get_level($user, $planet, $unit_id);
        $level_in_que = $in_que[$unit_id];
        $level_bonus = max(0, $level_effective - $level_base);
        $level_base_and_que = $level_base + $level_in_que;
        $unit_info = get_unit_param($unit_id);
        // pdump($unit_info, '$unit_info');
        $unit_stackable = isset($unit_info[P_STACKABLE]) && $unit_info[P_STACKABLE];
        $build_data = eco_get_build_data($user, $planet, $unit_id, $level_base_and_que);
        // pdump($build_data, '$build_data');
        $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]);
        $temp[RES_DARK_MATTER] = floor($user_dark_matter - $build_data[BUILD_CREATE][RES_DARK_MATTER]);
        $build_data['RESULT'][BUILD_CREATE] = $build_data['RESULT'][BUILD_CREATE] == BUILD_ALLOWED && !$can_que_element ? BUILD_QUE_FULL : $build_data['RESULT'][BUILD_CREATE];
        // Restricting $can_build by resources on planet and (where applicable) with max count per unit
        $can_build = $unit_info[P_MAX_STACK] ? max(0, $unit_info[P_MAX_STACK] - $level_in_que - $level_effective) : $build_data['CAN'][BUILD_CREATE];
        // Restricting $can_build by free silo capacity
        $can_build = ($unit_is_missile = in_array($unit_id, $group_missile)) ? min($can_build, floor($silo_capacity_free / $unit_info[P_UNIT_SIZE])) : $can_build;
        if (!$can_build) {
            if (!$build_data['CAN'][BUILD_CREATE]) {
                $build_data['RESULT'][BUILD_CREATE] = BUILD_NO_RESOURCES;
            } elseif ($unit_is_missile && $silo_capacity_free < $unit_info[P_UNIT_SIZE]) {
                $build_data['RESULT'][BUILD_CREATE] = BUILD_SILO_FULL;
            } elseif ($unit_info[P_MAX_STACK]) {
                $build_data['RESULT'][BUILD_CREATE] = BUILD_MAX_REACHED;
            }
        }
        $build_result_text = $lang['sys_build_result'][$build_data['RESULT'][BUILD_CREATE]];
        $build_result_text = !is_array($build_result_text) ? $build_result_text : (isset($build_result_text[$unit_id]) ? $build_result_text[$unit_id] : $build_result_text[0]);
        $template->assign_block_vars('production', array('ID' => $unit_id, 'NAME' => $lang['tech'][$unit_id], 'DESCRIPTION' => $lang['info'][$unit_id]['description_short'], 'LEVEL_OLD' => $level_base, 'LEVEL_BONUS' => $level_bonus, 'LEVEL_NEXT' => $level_base + $level_in_que + 1, 'LEVEL_QUED' => $level_in_que, 'LEVEL' => $level_base_and_que, 'CAN_BUILD' => $can_build, 'BUILD_CAN' => $build_data['CAN'][BUILD_CREATE], 'TIME' => pretty_time($build_data[RES_TIME][BUILD_CREATE]), 'TIME_SECONDS' => $build_data[RES_TIME][BUILD_CREATE], 'METAL' => $build_data[BUILD_CREATE][RES_METAL], 'METAL_TEXT' => pretty_number($build_data[BUILD_CREATE][RES_METAL], true, $planet['metal']), 'CRYSTAL' => $build_data[BUILD_CREATE][RES_CRYSTAL], 'CRYSTAL_TEXT' => pretty_number($build_data[BUILD_CREATE][RES_CRYSTAL], true, $planet['crystal']), 'DEUTERIUM' => $build_data[BUILD_CREATE][RES_DEUTERIUM], 'DEUTERIUM_TEXT' => pretty_number($build_data[BUILD_CREATE][RES_DEUTERIUM], true, $planet['deuterium']), 'ENERGY' => $build_data[BUILD_CREATE][RES_ENERGY], 'DARK_MATTER' => $build_data[BUILD_CREATE][RES_DARK_MATTER], 'DARK_MATTER_ONLY' => $build_data[P_OPTIONS][P_ONLY_DARK_MATTER], 'BUILD_RESULT' => $build_data['RESULT'][BUILD_CREATE], 'BUILD_RESULT_TEXT' => $build_result_text, 'DESTROY_RESULT' => $build_data['RESULT'][BUILD_DESTROY], 'DESTROY_CAN' => $build_data['CAN'][BUILD_DESTROY], 'DESTROY_TIME' => pretty_time($build_data[RES_TIME][BUILD_DESTROY]), '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), 'DARK_MATTER_REST' => pretty_number($temp[RES_DARK_MATTER], true, true), 'METAL_REST_NUM' => $temp[RES_METAL], 'CRYSTAL_REST_NUM' => $temp[RES_CRYSTAL], 'DEUTERIUM_REST_NUM' => $temp[RES_DEUTERIUM], 'DARK_MATTER_REST_NUM' => $temp[RES_DARK_MATTER], 'UNIT_BUSY' => eco_unit_busy($user, $planet, $que, $unit_id), 'MAP_IS_RESOURCE' => !empty($unit_info['production'])));
        if ($unit_stackable) {
            $level_production_base = array('ACTUAL_SHIELD' => pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_SHIELD), $unit_info['shield'])), 'ACTUAL_ARMOR' => pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_ARMOR), $unit_info['armor'])), 'ACTUAL_WEAPON' => pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_WEAPON), $unit_info['attack'])));
            if ($unit_info[P_UNIT_TYPE] == UNIT_SHIPS) {
                $ship_data = get_ship_data($unit_id, $user);
                $level_production_base += array('ACTUAL_SPEED' => pretty_number($ship_data['speed']), 'ACTUAL_CONSUMPTION' => pretty_number($ship_data['consumption']), 'ACTUAL_CAPACITY' => pretty_number($ship_data['capacity']));
            }
            if ($unit_info['production']) {
                foreach ($unit_info['production'] as $resource_id => $resource_calc) {
                    if ($resource_income = floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc(1, 10, $user, $planet) * $config_resource_multiplier * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1)))) {
                        $level_production_base['R' . $resource_id] = $resource_income;
                    }
                }
            }
            $template->assign_block_vars('production.resource', $level_production_base);
        } elseif ($unit_info['production']) {
            $level_production_base = array();
            $element_level_start = $level_effective + $in_que[$unit_id];
            foreach ($unit_info['production'] as $resource_id => $resource_calc) {
                if ($resource_income = floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc($element_level_start, 10, $user, $planet) * $config_resource_multiplier * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1)))) {
                    $level_production_base[$resource_id] = $resource_income;
                }
            }
            $level_start = $level_base_and_que > 1 ? $level_effective + $level_in_que - 1 : 1;
            for ($i = 0; $i < 6; $i++) {
                $level_production = array('LEVEL' => $level_start + $i);
                foreach ($unit_info['production'] as $resource_id => $resource_calc) {
                    if ($resource_income = floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc($level_start + $i, 10, $user, $planet) * $config_resource_multiplier * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1)))) {
                        $level_production['R' . $resource_id] = $resource_income;
                        $level_production['D' . $resource_id] = $resource_income - $level_production_base[$resource_id];
                    }
                }
                $template->assign_block_vars('production.resource', $level_production);
            }
        } elseif ($unit_id == TECH_ASTROTECH) {
            $element_level_start = $level_effective + $in_que[$unit_id];
            /*
            foreach($unit_info['production'] as $resource_id => $resource_calc) {
              if($resource_income = floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc($element_level_start, 10, $user, $planet) * $config_resource_multiplier * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1)))) {
                $level_production_base[$resource_id] = $resource_income;
              }
            }
            */
            $level_production_base = array(UNIT_PLAYER_EXPEDITIONS_MAX => get_player_max_expeditons($user, $element_level_start), UNIT_PLAYER_COLONIES_MAX => get_player_max_colonies($user, $element_level_start));
            $level_start = $level_base_and_que > 1 ? $level_effective + $level_in_que - 1 : 1;
            for ($i = 0; $i < 6; $i++) {
                $level_production = array('LEVEL' => $level_start + $i);
                $level_production['R' . UNIT_PLAYER_EXPEDITIONS_MAX] = get_player_max_expeditons($user, $level_start + $i);
                $level_production['D' . UNIT_PLAYER_EXPEDITIONS_MAX] = $level_production['R' . UNIT_PLAYER_EXPEDITIONS_MAX] - $level_production_base[UNIT_PLAYER_EXPEDITIONS_MAX];
                $level_production['R' . UNIT_PLAYER_COLONIES_MAX] = get_player_max_colonies($user, $level_start + $i);
                $level_production['D' . UNIT_PLAYER_COLONIES_MAX] = $level_production['R' . UNIT_PLAYER_COLONIES_MAX] - $level_production_base[UNIT_PLAYER_COLONIES_MAX];
                /*
                        foreach($unit_info['production'] as $resource_id => $resource_calc) {
                          if($resource_income = floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc($level_start + $i, 10, $user, $planet) * $config_resource_multiplier * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1)))) {
                            $level_production['R'.$resource_id] = $resource_income;
                            $level_production['D'.$resource_id] = $resource_income - $level_production_base[$resource_id];
                          }
                        }
                        $template->assign_block_vars('production.resource', $level_production);
                */
                $template->assign_block_vars('production.resource', $level_production);
                $level_production_base = array(UNIT_PLAYER_EXPEDITIONS_MAX => $level_production['R' . UNIT_PLAYER_EXPEDITIONS_MAX], UNIT_PLAYER_COLONIES_MAX => $level_production['R' . UNIT_PLAYER_COLONIES_MAX]);
            }
        }
        //pdump(unit_requirements_render($user, $planet, $unit_id));
        foreach (unit_requirements_render($user, $planet, $unit_id) as $requirement) {
            $template->assign_block_vars('production.require', $requirement);
        }
    }
    $sector_cost = eco_get_build_data($user, $planet, UNIT_SECTOR, mrc_get_level($user, $planet, UNIT_SECTOR), true);
    $sector_cost = $sector_cost[BUILD_CREATE][RES_DARK_MATTER];
    $template->assign_vars(array('ALLY_ID' => $user['user_as_ally'], 'QUE_ID' => $que_type, 'SHOW_SECTORS' => $que_type == QUE_STRUCTURES, 'FLEET_OWN_COUNT' => $fleet_list['own']['count'], 'ARTIFACT_ID' => $artifact_id, 'ARTIFACT_LEVEL' => mrc_get_level($user, array(), $artifact_id), 'ARTIFACT_NAME' => $lang['tech'][$artifact_id], 'REQUEST_URI' => urlencode($_SERVER['REQUEST_URI']), 'PAGE_HEADER' => $page_header, 'TIME_NOW' => SN_TIME_NOW, 'PLN_ID' => $planet['id'], 'METAL' => $planet['metal'], 'CRYSTAL' => $planet['crystal'], 'DEUTERIUM' => $planet['deuterium'], 'DARK_MATTER' => $user_dark_matter, '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, 'PAGE_HINT' => $lang['eco_bld_page_hint'], 'PLANET_TYPE' => $planet['planet_type'], 'SECTOR_CAN_BUY' => $sector_cost <= mrc_get_level($user, null, RES_DARK_MATTER), 'SECTOR_COST' => $sector_cost, 'SECTOR_COST_TEXT' => pretty_number($sector_cost), 'STACKABLE' => $unit_stackable, 'TEMPORARY' => intval($config->empire_mercenary_temporary && $que_type == QUE_MERCENARY), 'STRING_CREATE' => $que_type == QUE_MERCENARY ? $lang['bld_hire'] : ($que_type == QUE_RESEARCH ? $lang['bld_research'] : $lang['bld_create']), 'STRING_BUILD_TIME' => $que_type == QUE_RESEARCH ? $lang['ResearchTime'] : $lang['ConstructionTime'], 'U_opt_int_struc_vertical' => $user['option_list'][OPT_INTERFACE]['opt_int_struc_vertical']));
    display(parsetemplate($template));
    // , $lang['Builds']
}
Ejemplo n.º 11
0
$FlyingFleets = doquery("SELECT COUNT(fleet_id) as Number FROM {{fleets}} WHERE `fleet_owner`='{$user['id']}'", '', true);
$FlyingFleets = $FlyingFleets['Number'];
if ($MaxFleets <= $FlyingFleets && $fleet_page && $fleet_page != 4) {
    message($lang['fl_noslotfree'], $lang['fl_error'], "fleet." . PHP_EX, 5);
}
$MaxExpeditions = get_player_max_expeditons($user);
if ($MaxExpeditions) {
    $FlyingExpeditions = doquery("SELECT COUNT(fleet_owner) AS `expedi` FROM {{fleets}} WHERE `fleet_owner` = {$user['id']} AND `fleet_mission` = '" . MT_EXPLORE . "';", '', true);
    $FlyingExpeditions = $FlyingExpeditions['expedi'];
} else {
    $FlyingExpeditions = 0;
}
switch ($fleet_page) {
    case 3:
    case 2:
        $fleet_group_mr = sys_get_param_id('fleet_group');
        $fleetarray = unserialize(base64_decode(str_rot13(sys_get_param('usedfleet'))));
        $fleetarray = is_array($fleetarray) ? $fleetarray : array();
        foreach ($fleetarray as $ship_id => &$ship_amount) {
            if (!in_array($ship_id, sn_get_groups('fleet')) || (string) floatval($ship_amount) != $ship_amount || $ship_amount < 1) {
                $debug->warning('Supplying wrong ship in ship list on fleet page', 'Hack attempt', 302, array('base_dump' => true));
                die;
            }
            $ship_amount = floatval($ship_amount);
        }
        $UsedPlanet = false;
        $YourPlanet = false;
        $missiontype = array();
        if ($planet > $config->game_maxPlanet) {
            $target_mission = MT_EXPLORE;
            $missiontype[MT_EXPLORE] = $lang['type_mission'][MT_EXPLORE];
Ejemplo n.º 12
0
 *   1.1 - Modified by -MoF- (UGamela germany)
 *   1.0 - Created by Perberos
 * @copyright 2008 by Chlorel for XNova
 */
include 'common.' . substr(strrchr(__FILE__, '.'), 1);
lng_include('universe');
lng_include('stat');
$mode = sys_get_param_str('mode');
$uni_galaxy = sys_get_param_int('galaxy', $planetrow['galaxy']);
$uni_system = sys_get_param_int('system', $planetrow['system']);
$planet = sys_get_param_int('planet', $planetrow['planet']);
if ($mode == 'name') {
    require_once 'includes/includes/uni_rename.php';
}
require_once 'includes/includes/flt_functions.php';
$CurrentPlanetID = sys_get_param_id('current');
$POST_galaxyLeft = sys_get_param_str('galaxyLeft');
$POST_galaxyRight = sys_get_param_str('galaxyRight');
$POST_systemLeft = sys_get_param_str('systemLeft');
$POST_systemRight = sys_get_param_str('systemRight');
$fleetmax = GetMaxFleets($user);
$CurrentPlID = $planetrow['id'];
$CurrentMIP = mrc_get_level($user, $planetrow, UNIT_DEF_MISSILE_INTERPLANET, false, true);
$HavePhalanx = mrc_get_level($user, $planetrow, STRUC_MOON_PHALANX);
$CurrentSystem = $planetrow['system'];
$CurrentGalaxy = $planetrow['galaxy'];
$maxfleet = doquery("SELECT COUNT(*) AS flying_fleet_count FROM {{fleets}} WHERE `fleet_owner` = '{$user['id']}';", '', true);
$maxfleet_count = $maxfleet['flying_fleet_count'];
if ($mode == 1) {
    if ($POST_galaxyLeft) {
        $uni_galaxy--;
Ejemplo n.º 13
0
 protected function payment_request_process($options = array())
 {
     global $lang, $config;
     if (!$this->manifest['active']) {
         throw new Exception($lang['pay_msg_module_disabled'], SN_MODULE_DISABLED);
     }
     // Если есть payment_id - загружаем под него данные
     if (!empty($this->payment_params['payment_id'])) {
         $this->request_payment_id = sys_get_param_id($this->payment_params['payment_id']);
         if (!$this->request_payment_id) {
             throw new Exception($lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_INTERNAL_ID_WRONG);
         }
         if (!$this->db_get_by_id($this->request_payment_id)) {
             throw new Exception($lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_INTERNAL_ID_WRONG);
         }
         // Проверяем - был ли этот платеж обработан?
         // TODO - Статусы бывают разные. Нужен спецфлаг payment_processed
         if ($this->payment_status != PAYMENT_STATUS_NONE) {
             sn_db_transaction_rollback();
             sys_redirect(SN_ROOT_VIRTUAL . 'metamatter.php?payment_id=' . $this->payment_id);
             die;
         }
     }
     // Пытаемся получить из запроса ИД аккаунта
     $request_account_id = !empty($this->payment_params['account_id']) ? sys_get_param_id($this->payment_params['account_id']) : 0;
     // Если в запросе нет ИД аккаунта - пытаемся использовать payment_account_id
     if (empty($request_account_id) && !empty($this->payment_account_id)) {
         $request_account_id = $this->payment_account_id;
     }
     // Если теперь у нас нету ИД аккаунта ни в запросе, ни в записи таблицы - можно паниковать
     if (empty($request_account_id)) {
         // TODO - аккаунт
         throw new Exception($lang['pay_msg_request_user_invalid'], $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options));
     }
     // Если нет записи в таблице - тогда берем payment_account_id из запроса
     if (empty($this->payment_account_id)) {
         $this->payment_account_id = $request_account_id;
     }
     // Если у нас отличаются ИД аккаунта в запросе и ИД аккаунта в записи - тоже можно паниковать
     if ($this->payment_account_id != $request_account_id) {
         // TODO - Поменять сообщение об ошибке
         throw new Exception($lang['pay_msg_request_user_invalid'], $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options));
     }
     // Проверяем существование аккаунта с данным ИД
     if (!$this->account->db_get_by_id($this->payment_account_id)) {
         throw new Exception($lang['pay_msg_request_user_invalid'] . ' ID ' . $this->payment_account_id, $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options));
     }
     // TODO Проверка на сервер_ид - как бы и не нужна, наверное?
     if (!empty($this->payment_params['server_id'])) {
         $this->request_server_id = sys_get_param_str($this->payment_params['server_id']);
         if (SN_ROOT_VIRTUAL != $this->request_server_id) {
             throw new Exception($lang['pay_msg_request_server_wrong'] . " {$this->request_server_id} вместо " . SN_ROOT_VIRTUAL, SN_PAYMENT_REQUEST_SERVER_WRONG);
         }
     }
     // Сверка количества оплаченной ММ с учётом бонусов
     if (!empty($this->payment_params['payment_dark_matter_gained'])) {
         $request_mm_amount = sys_get_param_id($this->payment_params['payment_dark_matter_gained']);
         if ($request_mm_amount != $this->payment_dark_matter_gained && $this->is_loaded) {
             throw new Exception($lang['pay_msg_mm_request_amount_invalid'] . " пришло {$request_mm_amount} ММ вместо {$this->payment_dark_matter_gained} ММ", SN_PAYMENT_REQUEST_MM_AMOUNT_INVALID);
         }
         empty($this->payment_dark_matter_gained) ? $this->payment_dark_matter_gained = $request_mm_amount : false;
     }
     if (empty($this->payment_dark_matter_paid)) {
         // TODO - обратный расчёт из gained
     }
     // Проверка наличия внешнего ИД платежа
     if (!empty($this->payment_params['payment_external_id'])) {
         $request_payment_external_id = sys_get_param_id($this->payment_params['payment_external_id']);
         if (empty($request_payment_external_id)) {
             throw new exception($lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_EXTERNAL_ID_WRONG);
         } elseif (!empty($this->payment_external_id) && $this->payment_external_id != $request_payment_external_id) {
             // TODO - Может быть поменять сообщение
             throw new exception($lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_EXTERNAL_ID_WRONG);
         }
         $this->payment_external_id = $request_payment_external_id;
     }
     // Сверка суммы, запрошенной СН к оплате
     if (!empty($this->payment_params['payment_external_money'])) {
         $request_money_out = sys_get_param_float($this->payment_params['payment_external_money']);
         if ($request_money_out != $this->payment_external_amount && $this->is_loaded) {
             throw new Exception($lang['pay_msg_request_payment_amount_invalid'] . " пришло {$request_money_out} денег вместо {$this->payment_external_amount} денег", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID);
         }
         empty($this->payment_external_amount) ? $this->payment_external_amount = $request_money_out : false;
     }
     // Заполняем поле валюты платёжной системы
     if (!empty($this->payment_params['payment_external_currency'])) {
         $this->payment_external_currency = sys_get_param_str($this->payment_params['payment_external_currency']);
         if (empty($this->payment_external_currency)) {
             // TODO - поменять сообщение
             throw new Exception($lang['pay_msg_request_payment_amount_invalid'] . " {$this->payment_external_currency}", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID);
         }
     }
     if (empty($this->payment_external_currency)) {
         $this->payment_external_currency = $this->config['currency'];
     }
     // Заполнение внутренней суммы и валюты из внешних данных
     if (empty($this->payment_currency)) {
         $this->payment_currency = $config->payment_currency_default;
     }
     if (empty($this->payment_amount) && !empty($this->payment_external_currency)) {
         $this->payment_amount = self::currency_convert($this->payment_external_amount, $this->payment_external_currency, $this->payment_currency);
     }
     // TODO - Тестовый режим
     if (!empty($this->payment_params['test'])) {
         $this->payment_test = $this->config['test'] || sys_get_param_int($this->payment_params['test']);
     }
     $this->generate_description();
     //    // TODO - REMOVE
     //    return array(
     //      'payer' => $this->account,
     //    );
 }
Ejemplo n.º 14
0
$mode = sys_get_param_str('msg_delete') ? 'delete' : sys_get_param_str('mode');
$current_class = sys_get_param_int('message_class');
if (!isset($sn_message_class_list[$current_class])) {
    $current_class = 0;
    $mode = '';
}
switch ($mode) {
    case 'write':
        $error_list = array();
        $template = gettemplate('msg_message_compose', true);
        $recipient_name = sys_get_param_str_unsafe('recipient_name');
        if ($recipient_name) {
            $recipient_row = db_user_by_username($recipient_name);
        }
        if (!$recipient_row) {
            $recipient_id = sys_get_param_id('id');
            $recipient_row = db_user_by_id($recipient_id);
            if (!$recipient_row) {
                $recipient_id = 0;
            }
        }
        if ($recipient_row) {
            $recipient_id = $recipient_row['id'];
            $recipient_name = $recipient_row['username'];
        }
        if ($recipient_id == $user['id']) {
            $error_list[] = array('MESSAGE' => $lang['msg_err_self_send'], 'STATUS' => ERR_ERROR);
        }
        $re = 0;
        $subject = sys_get_param_str('subject');
        while (strpos($subject, $lang['msg_answer_prefix']) !== false) {
Ejemplo n.º 15
0
<?php

/**
 * jumpgate.php
 *
 * Jump Gate interface, I presume
 *
 * @version 1.0st Security checks & tests by Gorlum for http://supernova.ws
 * @version 1
 * @copyright 2008 By Chlorel for XNova
 */
include 'common.' . substr(strrchr(__FILE__, '.'), 1);
lng_include('fleet');
if ($TargetPlanet = sys_get_param_id('jmpto')) {
    sn_db_transaction_start();
    db_user_by_id($user['id'], true, 'id');
    $planetrow = db_planet_by_id($planetrow['id'], true);
    if (!($NextJumpTime = uni_get_time_to_jump($planetrow))) {
        $TargetGate = db_planet_by_id($TargetPlanet, true, '`id`, `last_jump_time`');
        if (mrc_get_level($user, $TargetGate, STRUC_MOON_GATE) > 0) {
            $NextDestTime = uni_get_time_to_jump($TargetGate);
            if (!$NextDestTime) {
                // $SubQueryOri = "";
                // $SubQueryDes = "";
                $ship_list = sys_get_param('ships');
                $db_changeset = array();
                foreach ($ship_list as $ship_id => $ship_count) {
                    if (!in_array($ship_id, sn_get_groups('fleet'))) {
                        continue;
                    }
                    $ship_count = max(0, min(floor($ship_count), mrc_get_level($user, $planetrow, $ship_id)));
Ejemplo n.º 16
0
<?php

/**
 * infos.php
 *
 * Information about every aspect of in-game objects: buildings, officiers, techs etc
 *
 * @version 1.1st Security checks & tests by Gorlum for http://supernova.ws
 * @version 1.1
 * @copyright 2008 By Chlorel for XNova
 */
include 'common.' . substr(strrchr(__FILE__, '.'), 1);
$unit_id = sys_get_param_id('gid');
if ($unit_id == RES_DARK_MATTER) {
    sys_redirect('dark_matter.php');
}
if ($unit_id == RES_METAMATTER) {
    sys_redirect('metamatter.php');
}
lng_include('infos');
if (!$unit_id || !get_unit_param($unit_id) && !isset($lang['info'][$unit_id])) {
    sys_redirect('index.php?page=techtree');
}
$template = gettemplate('novapedia', true);
$unit_data = get_unit_param($unit_id);
$unit_type = $unit_data['type'];
if ($unit_type == UNIT_SHIPS) {
    $template_result['UNIT_IS_SHIP'] = true;
    $ship_data = get_ship_data($unit_id, $user);
    $template_result += array('BASE_SPEED' => pretty_number($ship_data['speed_base']), 'ACTUAL_SPEED' => pretty_number($ship_data['speed']), 'BASE_CONSUMPTION' => pretty_number($ship_data['consumption_base']), 'ACTUAL_CONSUMPTION' => pretty_number($ship_data['consumption']), 'BASE_CAPACITY' => pretty_number($unit_data['capacity']), 'ACTUAL_CAPACITY' => pretty_number($ship_data['capacity']));
    $engine_template_info = array();
Ejemplo n.º 17
0
function qst_render_page()
{
    global $lang, $user, $template, $config;
    $user_id = sys_get_param_id('user_id', false);
    $mode = sys_get_param_str('mode');
    $quest_units_allowed = sn_get_groups(array('structures', 'tech', 'fleet', 'defense'));
    $quest_reward_allowed = sn_get_groups('quest_rewards');
    $in_admin = defined('IN_ADMIN') && IN_ADMIN === true;
    if ($in_admin) {
        $quest_id = sys_get_param_id('id');
        $quest_name = sys_get_param_str_unsafe('QUEST_NAME');
        if (!empty($quest_name)) {
            $quest_description = sys_get_param_str_unsafe('QUEST_DESCRIPTION');
            try {
                $quest_rewards_list = sys_get_param('QUEST_REWARDS_LIST');
                $quest_rewards = array();
                foreach ($quest_rewards_list as $quest_rewards_id => $quest_rewards_amount) {
                    if (!in_array($quest_rewards_id, $quest_reward_allowed)) {
                        throw new Exception($lang['qst_adm_err_reward_type']);
                    }
                    if ($quest_rewards_amount < 0) {
                        throw new Exception($lang['qst_adm_err_reward_amount']);
                    } elseif ($quest_rewards_amount > 0) {
                        $quest_rewards[] = "{$quest_rewards_id},{$quest_rewards_amount}";
                    }
                }
                if (empty($quest_rewards)) {
                    throw new Exception($lang['qst_adm_err_reward_empty']);
                }
                $quest_rewards = implode(';', $quest_rewards);
                $quest_unit_id = sys_get_param_int('QUEST_UNIT_ID');
                if (!in_array($quest_unit_id, $quest_units_allowed)) {
                    throw new Exception($lang['qst_adm_err_unit_id']);
                }
                $quest_unit_amount = sys_get_param_float('QUEST_UNIT_AMOUNT');
                if ($quest_unit_amount <= 0) {
                    throw new Exception($lang['qst_adm_err_unit_amount']);
                }
                $quest_conditions = "{$quest_unit_id},{$quest_unit_amount}";
                // TODO: Change quest type
                $quest_type = 0;
                if ($mode == 'edit') {
                    $quest_name = db_escape($quest_name);
                    $quest_description = db_escape($quest_description);
                    doquery("UPDATE {{quest}} SET\n              `quest_name` = '{$quest_name}',\n              `quest_type` = '{$quest_type}',\n              `quest_description` = '{$quest_description}',\n              `quest_conditions` = '{$quest_conditions}',\n              `quest_rewards` = '{$quest_rewards}'\n            WHERE `quest_id` = {$quest_id} LIMIT 1;");
                } else {
                    sn_db_perform('{{quest}}', array('quest_name' => $quest_name, 'quest_type' => $quest_type, 'quest_description' => $quest_description, 'quest_conditions' => $quest_conditions, 'quest_rewards' => $quest_rewards));
                }
                // TODO: Add mass mail for new quests
                /*
                if(sys_get_param_int('news_mass_mail'))
                {
                  msg_send_simple_message('*', 0, 0, MSG_TYPE_PLAYER, $lang['sys_administration'], $lang['news_title'], $text);
                }
                */
            } catch (Exception $e) {
                message($e->getMessage(), $lang['sys_error']);
            }
            $mode = '';
        }
        switch ($mode) {
            case 'del':
                doquery("DELETE FROM {{quest}} WHERE `quest_id` = {$quest_id} LIMIT 1;");
                $mode = '';
                break;
            case 'edit':
                $template->assign_var('QUEST_ID', $quest_id);
            case 'copy':
                $quest = doquery("SELECT * FROM {{quest}} WHERE `quest_id` = {$quest_id} LIMIT 1;", '', true);
                break;
        }
        $query = doquery("SELECT count(*) AS count FROM {{quest}};", '', true);
        $config->db_saveItem('quest_total', $query['count']);
    } elseif (!$user_id) {
        $user_id = $user['id'];
    }
    $quest_list = qst_get_quests($user_id);
    $template->assign_vars(array('AUTHLEVEL' => $user['authlevel'], 'TOTAL' => count($quest_list), 'mode' => $mode, 'USER_ID' => $user_id, 'IN_ADMIN' => $in_admin));
    if ($quest) {
        $quest_templatized = qst_templatize(qst_quest_parse($quest, false));
    } else {
        $quest_templatized['quest_rewards_list'] = array();
    }
    foreach ($quest_reward_allowed as $unit_id) {
        $found = false;
        foreach ($quest_templatized['quest_rewards_list'] as $quest_templatized_reward) {
            if ($quest_templatized_reward['ID'] == $unit_id) {
                $found = true;
                break;
            }
        }
        if (!$found) {
            $quest_templatized['quest_rewards_list'][$unit_id] = array('ID' => $unit_id, 'NAME' => $lang['tech'][$unit_id], 'AMOUNT' => 0);
        }
    }
    qst_assign_to_template($template, $quest_templatized);
    foreach ($quest_list as $quest_data) {
        qst_assign_to_template($template, qst_templatize($quest_data, true), 'quest');
    }
    foreach ($quest_units_allowed as $unit_id) {
        $template->assign_block_vars('allowed_unit', array('ID' => $unit_id, 'NAME' => $lang['tech'][$unit_id]));
    }
}
Ejemplo n.º 18
0
<?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']);
}
lng_include('admin');
$user_id = sys_get_param_id('uid');
if (!($user_row = db_user_by_id($user_id))) {
    AdminMessage(sprintf($lang['adm_dm_user_none'], $user_id));
}
$template = gettemplate('admin/admin_user', true);
if (!empty($user_row['user_last_browser_id'])) {
    $temp = doquery("SELECT browser_user_agent FROM {{security_browser}} WHERE `browser_id` = {$user_row['user_last_browser_id']}", true);
    $user_row['browser_user_agent'] = $temp['browser_user_agent'];
}
$formats = array('sys_time_human_system' => array('register_time', 'onlinetime', 'ally_register_time', 'news_lastread', 'banaday', 'vacation', 'vacation_next', 'deltime', 'que_processed'), 'pretty_number' => array('metal', 'crystal', 'deuterium', 'dark_matter_total', 'metamatter', 'metamatter_total', 'player_rpg_explore_xp', 'player_rpg_explore_level', 'lvl_minier', 'xpminier', 'player_rpg_tech_xp', 'player_rpg_tech_level', 'lvl_raid', 'xpraid', 'raids', 'raidsloose', 'raidswin', 'total_rank', 'total_points'));
foreach ($formats as $callable => $field_list) {
    foreach ($field_list as $field_name) {
        $user_row[$field_name] = call_user_func($callable, $user_row[$field_name]);
    }
}
$template->assign_vars($user_row);
display($template, htmlentities("[{$user_row['id']}] {$user_row['username']}", ENT_QUOTES, 'UTF-8'), false, '', true);
Ejemplo n.º 19
0
<?php

/**
 * admin/add_moon.php
 *
 * @version 2
 * @copyright 2014 Gorlum for http://supernova.ws
 */
define('INSIDE', true);
define('INSTALL', false);
define('IN_ADMIN', true);
require '../common.' . substr(strrchr(__FILE__, '.'), 1);
// if ($user['authlevel'] < 2)
if ($user['authlevel'] < 3) {
    AdminMessage($lang['adm_err_denied']);
}
$template = gettemplate("admin/add_moon", true);
if (sys_get_param_str('mode') == 'addit') {
    $PlanetID = sys_get_param_id('user');
    $MoonName = sys_get_param_str('name');
    sn_db_transaction_start();
    $PlanetSelected = db_planet_by_id($PlanetID, true, '`galaxy`, `system`, `planet`, `id_owner`');
    uni_create_moon($PlanetSelected['galaxy'], $PlanetSelected['system'], $PlanetSelected['planet'], $PlanetSelected['id_owner'], 0, $MoonName);
    sn_db_transaction_commit();
    AdminMessage($lang['addm_done'], $lang['addm_title']);
}
display($template, $lang['addm_title'], false, '', true);
Ejemplo n.º 20
0
function SetSelectedPlanet(&$user)
{
    $planet_row['id'] = $user['current_planet'];
    // Пытаемся переключить на новую планету
    if (($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) {
        $planet_row = db_planet_by_id_and_owner($selected_planet, $user['id'], false, 'id');
    } else {
        $planet_row = db_planet_by_id($planet_row['id']);
    }
    // Если новая планета не найдена или было переключения - проверяем текущую выбранную планету
    if (!isset($planet_row['id'])) {
        $planet_row = db_planet_by_id_and_owner($user['current_planet'], $user['id'], false, 'id');
        // Если текущей планеты не существует - выставляем Столицу
        if (!isset($planet_row['id'])) {
            $planet_row = db_planet_by_id_and_owner($user['id_planet'], $user['id'], false, 'id');
            // Если и столицы не существует - значит что-то очень не так с записью пользователя
            if (!isset($planet_row['id'])) {
                global $debug;
                $debug->error("User ID {$user['id']} has Capital planet {$user['id_planet']} but this planet does not exists", 'User record error', 502);
            }
        }
    }
    // Если производилось переключение планеты - делаем запись в юзере
    if ($user['current_planet'] != $planet_row['id']) {
        db_user_set_by_id($user['id'], "`current_planet` = '{$planet_row['id']}'");
        $user['current_planet'] = $planet_row['id'];
    }
    return $user['current_planet'];
}
Ejemplo n.º 21
0
             } elseif ($buddy_row['BUDDY_SENDER_ID'] == $user['id']) {
                 doquery("DELETE FROM {{buddy}} WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;");
                 sn_db_transaction_commit();
                 throw new exception('buddy_err_delete_own', ERR_NONE);
             } elseif ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) {
                 msg_send_simple_message($buddy_row['BUDDY_SENDER_ID'], $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_deny_title'], sprintf($lang['buddy_msg_deny_text'], $user['username']));
                 doquery("UPDATE {{buddy}} SET `BUDDY_STATUS` = " . BUDDY_REQUEST_DENIED . " WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;");
                 sn_db_transaction_commit();
                 throw new exception('buddy_err_deny_none', ERR_NONE);
             }
             break;
     }
 }
 // New request?
 // Checking for user ID - in case if it was request from outside buddy system
 if ($new_friend_id = sys_get_param_id('request_user_id')) {
     $new_friend_row = db_user_by_id($new_friend_id, true, '`id`, `username`');
 } elseif ($new_friend_name = sys_get_param_str_unsafe('request_user_name')) {
     $new_friend_row = db_user_by_username($new_friend_name, true, '`id`, `username`');
     $new_friend_name = db_escape($new_friend_name);
 }
 if ($new_friend_row['id'] == $user['id']) {
     unset($new_friend_row);
     throw new exception('buddy_err_adding_self', ERR_ERROR);
 }
 // Checking for user name & request text - in case if it was request to adding new request
 if (isset($new_friend_row['id']) && ($new_request_text = sys_get_param_str('request_text'))) {
     $check_relation = doquery("SELECT `BUDDY_ID` FROM {{buddy}} WHERE\n      (`BUDDY_SENDER_ID` = {$user['id']} AND `BUDDY_OWNER_ID` = {$new_friend_row['id']})\n      OR\n      (`BUDDY_SENDER_ID` = {$new_friend_row['id']} AND `BUDDY_OWNER_ID` = {$user['id']})\n      LIMIT 1 FOR UPDATE;", true);
     if (isset($check_relation['BUDDY_ID'])) {
         throw new exception('buddy_err_adding_exists', ERR_WARNING);
     }
Ejemplo n.º 22
0
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;
}
Ejemplo n.º 23
0
function sn_imperator_view($template = null)
{
    global $template_result, $config, $lang, $user;
    $stat_fields = array('stat_date' => 'STAT_DATE', 'total_rank' => 'TOTAL_RANK', 'total_points' => 'TOTAL_POINTS', 'tech_rank' => 'TECH_RANK', 'tech_points' => 'TECH_POINTS', 'build_rank' => 'BUILD_RANK', 'build_points' => 'BUILD_POINTS', 'defs_rank' => 'DEFS_RANK', 'defs_points' => 'DEFS_POINTS', 'fleet_rank' => 'FLEET_RANK', 'fleet_points' => 'FLEET_POINTS', 'res_rank' => 'RES_RANK', 'res_points' => 'RES_POINTS');
    $user_id = sys_get_param_id('int_user_id', $user['id']);
    $user_data = ($same_user = $user_id == $user['id']) ? $user : db_user_by_id($user_id);
    //  if($user_id == $user['id']) {
    //    $user_data = &$user;
    //    $same_user = true;
    //  } else {
    //    $user_data = db_user_by_id($user_id);
    //    $same_user = false;
    //  }
    if (!$user_data) {
        message($lang['imp_imperator_none'], $lang['sys_error'], 'index.php', 10);
        die;
    }
    $template = gettemplate('imperator', $template);
    $StatRecord = doquery("SELECT * FROM {{statpoints}} WHERE `stat_type` = 1 AND `stat_code` = 1 AND `id_owner` = {$user_id};", true);
    $stat_array = array();
    $query = doquery("SELECT * FROM {{statpoints}} WHERE `stat_type` = 1 AND `id_owner` = {$user_id} ORDER BY `stat_code` DESC;");
    global $link;
    $stat_count = db_affected_rows($link);
    while ($row = db_fetch($query)) {
        foreach ($stat_fields as $field_db_name => $field_template_name) {
            // $stat_count - $row['stat_code'] - для реверсирования ID статы в JS
            $stat_array[$field_template_name]['DATA'][$stat_count - $row['stat_code']] = $row[$field_db_name];
        }
    }
    $stat_array_date = $stat_array['STAT_DATE'];
    foreach ($stat_array_date['DATA'] as $key => $value) {
        $template->assign_block_vars('stat_date', array('ID' => $key, 'VALUE' => $value, 'TEXT' => date(FMT_DATE_TIME, $value)));
    }
    // $stat_count = count($stat_array_date['DATA']);
    // pdump($stat_array_date);
    unset($stat_array['STAT_DATE']);
    $template_data = array();
    foreach ($stat_array as $stat_type => &$stat_type_data) {
        $reverse_min_max = strpos($stat_type, '_RANK') !== false;
        $stat_type_data['MIN'] = $reverse_min_max ? max($stat_type_data['DATA']) : min($stat_type_data['DATA']);
        $stat_type_data['MAX'] = $reverse_min_max ? min($stat_type_data['DATA']) : max($stat_type_data['DATA']);
        $stat_type_data['AVG'] = average($stat_type_data['DATA']);
        foreach ($stat_type_data['DATA'] as $key => $value) {
            // $stat_type_data['PERCENT'][$key] = $stat_type_data['MAX'] - $value ? ($stat_type_data['MAX'] - $stat_type_data['MIN']) / ($stat_type_data['MAX'] - $value) : 100;
            $stat_type_data['PERCENT'][$key] = ($stat_type_data['MAX'] - $value ? ($value - $stat_type_data['MIN']) / ($stat_type_data['MAX'] - $stat_type_data['MIN']) : 1) * 100;
            $template_data[$stat_type][$key]['ID'] = $key;
            $template_data[$stat_type][$key]['VALUE'] = $value;
            $template_data[$stat_type][$key]['DELTA'] = $reverse_min_max ? $stat_type_data['MIN'] - $value : $value - $stat_type_data['MAX'];
            $template_data[$stat_type][$key]['PERCENT'] = $stat_type_data['PERCENT'][$key];
            //$template_data[$stat_type][$key]['PERCENT'] = $key ? $stat_type_data['PERCENT'][$key] : 50; // TODO DEBUG
        }
    }
    // pdump($stat_array['RES_POINTS']);
    foreach ($template_data as $stat_type => $stat_type_data) {
        $template->assign_block_vars('stat', array('TYPE' => $stat_type, 'TEXT' => $lang['imp_stat_types'][$stat_type], 'MIN' => $stat_array[$stat_type]['MIN'], 'MAX' => $stat_array[$stat_type]['MAX'], 'AVG' => $stat_array[$stat_type]['AVG']));
        foreach ($stat_type_data as $stat_entry) {
            $template->assign_block_vars('stat.entry', $stat_entry);
        }
    }
    // pdump($template_data);
    if ($same_user) {
        rpg_level_up($user, RPG_STRUCTURE);
        rpg_level_up($user, RPG_RAID);
        rpg_level_up($user, RPG_TECH);
        rpg_level_up($user, RPG_EXPLORE);
        /*
        // -----------------------------------------------------------------------------------------------
        // News Frame ...
        if ($config->game_news_overview)
        {
          nws_render($template, "WHERE UNIX_TIMESTAMP(`tsTimeStamp`)<=" . SN_TIME_NOW . "", $config->game_news_overview);
        }
        */
    }
    $template->assign_vars(array('USERS_TOTAL' => $config->users_amount, 'USER_ID' => $user_id, 'user_username' => player_nick_render_to_html($user_data, true), 'USER_AVATAR' => $user_data['avatar'], 'VACATION' => $user_data['vacation'], 'GENDER_TEXT' => $lang['sys_gender_list'][$user_data['gender']], 'NEW_MESSAGES' => $user_data['new_message'], 'REGISTRATION_DATE' => date(FMT_DATE_TIME, $user_data['register_time']), 'builder_xp' => pretty_number($user_data['xpminier']), 'builder_lvl' => pretty_number($user_data['lvl_minier']), 'builder_lvl_st' => pretty_number(rpg_get_miner_xp($user_data['lvl_minier'])), 'builder_lvl_up' => pretty_number(rpg_get_miner_xp($user_data['lvl_minier'] + 1)), 'raid_xp' => pretty_number($user_data['xpraid']), 'raid_lvl' => pretty_number($user_data['lvl_raid']), 'raid_lvl_up' => pretty_number(rpg_get_raider_xp($user_data['lvl_raid'] + 1)), 'raids' => pretty_number($user_data['raids']), 'raidswin' => pretty_number($user_data['raidswin']), 'raidsloose' => pretty_number($user_data['raidsloose']), 'tech_xp' => pretty_number($user_data['player_rpg_tech_xp']), 'tech_lvl' => pretty_number($user_data['player_rpg_tech_level']), 'tech_lvl_st' => pretty_number(rpg_get_tech_xp($user_data['player_rpg_tech_level'])), 'tech_lvl_up' => pretty_number(rpg_get_tech_xp($user_data['player_rpg_tech_level'] + 1)), 'explore_xp' => pretty_number($user_data['player_rpg_explore_xp']), 'explore_lvl' => pretty_number($user_data['player_rpg_explore_level']), 'explore_lvl_st' => pretty_number(rpg_get_explore_xp($user_data['player_rpg_explore_level'])), 'explore_lvl_up' => pretty_number(rpg_get_explore_xp($user_data['player_rpg_explore_level'] + 1)), 'build_points' => pretty_number($StatRecord['build_points']), 'tech_points' => pretty_number($StatRecord['tech_points']), 'fleet_points' => pretty_number($StatRecord['fleet_points']), 'defs_points' => pretty_number($StatRecord['defs_points']), 'res_points' => pretty_number($StatRecord['res_points']), 'total_points' => pretty_number($StatRecord['total_points']), 'user_rank' => $StatRecord['total_rank'], 'RANK_DIFF' => $StatRecord['total_old_rank'] - $StatRecord['total_rank'], 'STAT_COUNT' => $stat_count, 'STAT_SPAN' => $stat_count + 1, 'SAME_USER' => $same_user));
    return parsetemplate($template);
}
Ejemplo n.º 24
0
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);
}
$planet_scanned = db_planet_by_gspt($scan_galaxy, $scan_system, $scan_planet, $scan_planet_type);
if (!$planet_scanned['id']) {
    message($lang['phalanx_planet_not_exists'], $lang['tech'][STRUC_MOON_PHALANX], '', 3);
Ejemplo n.º 25
0
 *
**/
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']);
Ejemplo n.º 26
0
 * 1.2 - copyright (c) 2010 by Gorlum for http://supernova.ws
 *     [*] Adjusted layouts of planet infos
 * 1.1 - Security checks by Gorlum for http://supernova.ws
 * @version 1
 * @copyright 2008 By Chlorel for XNova
 */
//define('SN_RENDER_NAVBAR_PLANET', false);
include 'common.' . substr(strrchr(__FILE__, '.'), 1);
lng_include('overview');
switch ($mode = sys_get_param_str('mode')) {
    case 'manage':
        sn_sys_sector_buy('overview.php?mode=manage');
        $user_dark_matter = mrc_get_level($user, false, RES_DARK_MATTER);
        $result = sn_sys_planet_core_transmute($user, $planetrow);
        $template = gettemplate('planet_manage', true);
        $planet_id = sys_get_param_id('planet_id');
        if (sys_get_param_str('rename') && ($new_name = sys_get_param_str('new_name'))) {
            $planetrow['name'] = $new_name;
            $new_name = db_escape($new_name);
            db_planet_set_by_id($planetrow['id'], "`name` = '{$new_name}'");
        } elseif (sys_get_param_str('capital')) {
            try {
                sn_db_transaction_start();
                $user = db_user_by_id($user['id'], true, '*');
                $planetrow = db_planet_by_id($planetrow['id'], true, '*');
                //        $global_data = sys_o_get_updated($user, $planetrow['id'], SN_TIME_NOW);
                //        $user = $global_data['user'];
                //        $planetrow = $global_data['planet'];
                if ($planetrow['planet_type'] != PT_PLANET) {
                    throw new exception($lang['ov_capital_err_not_a_planet'], ERR_ERROR);
                }
Ejemplo n.º 27
0
        sn_db_transaction_rollback();
        $result[] = array('STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, 'MESSAGE' => $lang[$e->getMessage()]);
    }
} elseif (($note_title = sys_get_param_str('note_title')) || ($note_text = sys_get_param_str('note_text'))) {
    $note_title == db_escape($lang['note_new_title']) ? $note_title = '' : false;
    ($note_text = sys_get_param_str('note_text')) == db_escape($lang['note_new_text']) ? $note_text = '' : false;
    try {
        if (!$note_text && !$note_title) {
            throw new exception('note_err_note_empty', ERR_WARNING);
        }
        $note_priority = min(sys_get_param_id('note_priority', 2), count($note_priority_classes) - 1);
        $note_galaxy = max(0, min(sys_get_param_id('note_galaxy'), $config->game_maxGalaxy));
        $note_system = max(0, min(sys_get_param_id('note_system'), $config->game_maxSystem));
        $note_planet = max(0, min(sys_get_param_id('note_planet'), $config->game_maxPlanet + 1));
        $note_planet_type = max(1, min(sys_get_param_id('note_planet_type', 1), count($lang['sys_planet_type'])));
        $note_sticky = intval(sys_get_param_id('note_sticky')) ? 1 : 0;
        sn_db_transaction_start();
        if ($note_id_edit) {
            $check_note_id = doquery("SELECT `id`, `owner` FROM {{notes}} WHERE `id` = {$note_id_edit} LIMIT 1 FOR UPDATE", true);
            if (!$check_note_id) {
                throw new exception('note_err_note_not_found', ERR_ERROR);
            }
        }
        if ($note_id_edit) {
            if ($check_note_id['owner'] != $user['id']) {
                throw new exception('note_err_owner_wrong', ERR_ERROR);
            }
            doquery("UPDATE {{notes}} SET `time` = " . SN_TIME_NOW . ", `priority` = {$note_priority}, `title` = '{$note_title}', `text` = '{$note_text}',\n        `galaxy` = {$note_galaxy}, `system` = {$note_system}, `planet` = {$note_planet}, `planet_type` = {$note_planet_type}, `sticky` = {$note_sticky}\n        WHERE `id` = {$note_id_edit} LIMIT 1;");
        } else {
            doquery("INSERT INTO {{notes}} SET `owner` = {$user['id']}, `time` = " . SN_TIME_NOW . ", `priority` = {$note_priority}, `title` = '{$note_title}', `text` = '{$note_text}',\n        `galaxy` = {$note_galaxy}, `system` = {$note_system}, `planet` = {$note_planet}, `planet_type` = {$note_planet_type}, `sticky` = {$note_sticky};");
        }
Ejemplo n.º 28
0
* @version 1.3s Security checks by Gorlum for http://supernova.ws
* @version 1.3
// History version
// 1.0 - Nettoyage modularisation
// 1.1 - Mise au point, mise en fonction pour linarisation du fonctionnement
// 1.2 - Liste de construction batiments
* @copyright 2008 by Chlorel for XNova
*/
include 'common.' . substr(strrchr(__FILE__, '.'), 1);
define('SN_RENDER_NAVBAR_PLANET', true);
$mode = sys_get_param_escaped('mode');
$mode = !$mode || $mode == 'buildings' ? QUE_STRUCTURES : ($mode == 'fleet' ? SUBQUE_FLEET : ($mode == 'defense' ? SUBQUE_DEFENSE : ($mode == 'research' ? QUE_RESEARCH : $mode)));
if ($building_sort = sys_get_param_id('sort_elements')) {
    if (!empty($lang['player_option_building_sort'][$building_sort])) {
        classSupernova::$user_options[array(PLAYER_OPTION_BUILDING_SORT, $mode)] = $building_sort;
        classSupernova::$user_options[array(PLAYER_OPTION_BUILDING_SORT_INVERSE, $mode)] = sys_get_param_id('sort_elements_inverse', 0);
    }
    die;
}
lng_include('buildings');
lng_include('infos');
sn_sys_sector_buy('buildings.php?mode=' . $mode);
require_once 'includes/includes/eco_bld_structures.php';
switch ($mode) {
    //  case UNIT_MERCENARIES:
    //    require_once('includes/includes/eco_bld_structures.php');
    //    eco_build(QUE_MERCENARY, $user, $planetrow);
    //  break;
    case QUE_RESEARCH:
        defined("GAME_RESEARCH_DISABLED") && GAME_RESEARCH_DISABLED ? eco_build(SUBQUE_FLEET, $user, $planetrow) : eco_build(QUE_RESEARCH, $user, $planetrow);
        break;
Ejemplo n.º 29
0
// TODO ban
if ($template_result[F_BANNED_STATUS] && !$skip_ban_check) {
    if (defined('IN_API')) {
        return;
    }
    $bantime = date(FMT_DATE_TIME, $template_result[F_BANNED_STATUS]);
    // TODO: Add ban reason. Add vacation time. Add message window
    sn_sys_logout(false, true);
    message("{$lang['sys_banned_msg']} {$bantime}", $lang['ban_title']);
    die("{$lang['sys_banned_msg']} {$bantime}");
}
$template_result[F_USER_AUTHORIZED] = $sys_user_logged_in = !empty($user) && isset($user['id']) && $user['id'];
// !!! Просто $allow_anonymous используется в платежных модулях !!!
$allow_anonymous = $allow_anonymous || isset($sn_page_data['allow_anonymous']) && $sn_page_data['allow_anonymous'];
if (!$allow_anonymous && !$sys_user_logged_in) {
    sn_setcookie(SN_COOKIE, '', time() - PERIOD_WEEK, SN_ROOT_RELATIVE);
    sys_redirect(SN_ROOT_VIRTUAL . 'login.php');
}
$user_time_diff = user_time_diff_get();
//defined('SN_CLIENT_TIME_DIFF_SECONDS') or define('SN_CLIENT_TIME_DIFF_SECONDS', $user_time_diff[PLAYER_OPTION_TIME_DIFF]);
//defined('SN_CLIENT_TIME_UTC_OFFSET') or define('SN_CLIENT_TIME_UTC_OFFSET', $user_time_diff[PLAYER_OPTION_TIME_DIFF_UTC_OFFSET]);
//$time_diff = SN_CLIENT_TIME_DIFF_SECONDS + SN_CLIENT_TIME_UTC_OFFSET;
//defined('SN_CLIENT_TIME_DIFF') or define('SN_CLIENT_TIME_DIFF', $time_diff);
//defined('SN_CLIENT_TIME_LOCAL') or define('SN_CLIENT_TIME_LOCAL', SN_TIME_NOW + SN_CLIENT_TIME_DIFF);
global $time_diff;
define('SN_CLIENT_TIME_DIFF', $time_diff = $user_time_diff[PLAYER_OPTION_TIME_DIFF] + $user_time_diff[PLAYER_OPTION_TIME_DIFF_UTC_OFFSET]);
define('SN_CLIENT_TIME_LOCAL', SN_TIME_NOW + SN_CLIENT_TIME_DIFF);
!empty($user) && sys_get_param_id('only_hide_news') ? die(nws_mark_read($user)) : false;
!empty($user) && sys_get_param_id('survey_vote') ? die(survey_vote($user)) : false;
lng_load_i18n($sn_mvc['i18n'][$sn_page_name]);
execute_hooks($sn_mvc['model'][''], $template);