本文整理汇总了PHP中db_user_by_id函数的典型用法代码示例。如果您正苦于以下问题:PHP db_user_by_id函数的具体用法?PHP db_user_by_id怎么用?PHP db_user_by_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db_user_by_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: msg_send_simple_message
function msg_send_simple_message($owners, $sender, $timestamp, $message_type, $from, $subject, $text, $escaped = false, $force = false)
{
global $config, $user, $sn_message_class_list;
if (!$owners) {
return;
}
$timestamp = $timestamp ? $timestamp : SN_TIME_NOW;
$sender = intval($sender);
if (!is_array($owners)) {
$owners = array($owners);
}
if (!$escaped) {
$from = db_escape($from);
$subject = db_escape($subject);
$text = db_escape($text);
}
$text_unescaped = stripslashes(str_replace(array('\\r\\n', "\r\n"), "<br />", $text));
$message_class = $sn_message_class_list[$message_type];
$message_class_email = $message_class['email'];
$message_class_switchable = $message_class['switchable'];
$message_class_name = $message_class['name'];
$message_class_name_total = $sn_message_class_list[MSG_TYPE_NEW]['name'];
if ($owners[0] == '*') {
if ($user['authlevel'] < 3) {
return false;
}
// TODO Добавить $timestamp - рассылка может быть и отсроченной
// TODO Добавить $sender - рассылка может быть и от кого-то
db_message_insert_all($message_type, $from, $subject, $text);
$owners = array();
} else {
$insert_values = array();
$insert_template = "('%u'," . str_replace('%', '%%', " '{$sender}', '{$timestamp}', '{$message_type}', '{$from}', '{$subject}', '{$text}')");
foreach ($owners as $owner) {
if ($user['id'] != $owner) {
$owner_row = db_user_by_id($owner);
} else {
$owner_row = $user;
}
sys_user_options_unpack($owner_row);
if ($force || !$message_class_switchable || $owner_row["opt_{$message_class_name}"]) {
$insert_values[] = sprintf($insert_template, $owner);
}
if ($message_class_email && $config->game_email_pm && $owner_row["opt_email_{$message_class_name}"]) {
@($result = mymail($owner_row['email'], $subject, $text_unescaped, '', true));
}
}
if (empty($insert_values)) {
return;
}
doquery($QryInsertMessage = 'INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) ' . 'VALUES ' . implode(',', $insert_values));
}
db_user_list_set_mass_mail($owners, "`{$message_class_name}` = `{$message_class_name}` + 1, `{$message_class_name_total}` = `{$message_class_name_total}` + 1");
if (in_array($user['id'], $owners) || $owners[0] == '*') {
$user[$message_class_name]++;
$user[$message_class_name_total]++;
}
}
示例2: uni_create_planet
/**
* @param int $Galaxy
* @param int $System
* @param int $Position
* @param int $PlanetOwnerID
* @param string $planet_name_unsafe
* @param bool|false $HomeWorld
* @param array $options
*
* @return bool
*/
function uni_create_planet($Galaxy, $System, $Position, $PlanetOwnerID, $planet_name_unsafe = '', $HomeWorld = false, $options = array())
{
global $lang, $config;
$Position = intval($Position);
if (!isset($options['skip_check']) && db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) {
return false;
}
$user_row = !empty($options['user_row']) && is_array($options['user_row']) ? $options['user_row'] : db_user_by_id($PlanetOwnerID);
$planet_generator = sn_get_groups('planet_generator');
if ($HomeWorld) {
$position_data = $planet_generator[0];
} else {
$position_data = $planet_generator[$Position >= UNIVERSE_RANDOM_PLANET_START || $Position < 1 ? UNIVERSE_RANDOM_PLANET_START : $Position];
if ($Position >= UNIVERSE_RANDOM_PLANET_START) {
// Корректируем температуру для планеты-странника
$position_data['t_max_max'] -= UNIVERSE_RANDOM_PLANET_TEMPERATURE_DECREASE * ($Position - UNIVERSE_RANDOM_PLANET_START);
}
}
$planet_images = sn_get_groups('planet_images');
$planet_image = $position_data['planet_images'][mt_rand(0, count($position_data['planet_images']) - 1)];
$planet_image .= 'planet' . $planet_images[$planet_image][mt_rand(0, count($planet_images[$planet_image]) - 1)];
$t_max = sn_rand_gauss_range($position_data['t_max_min'], $position_data['t_max_max'], true, 1.3, true);
$t_min = $t_max - sn_rand_gauss_range($position_data['t_delta_min'], $position_data['t_delta_max'], true, 1.3, true);
$planet_sectors = sn_rand_gauss_range($position_data['size_min'], $position_data['size_max'], true, 1.7, true);
// $planet_diameter = round(pow($planet_sectors, 2) * 1000);
$planet_diameter = round(sqrt($planet_sectors) * 1000);
$core_info = uni_create_planet_get_density($position_data, $user_row, $planet_sectors);
$planet_name_unsafe = $user_row['username'] . ' ' . ($planet_name_unsafe ? $planet_name_unsafe : $lang['sys_colo_defaultname']);
$planet['name'] = db_escape(strip_tags(trim($planet_name_unsafe)));
$planet['id_owner'] = $PlanetOwnerID;
$planet['last_update'] = SN_TIME_NOW;
$planet['image'] = $planet_image;
$planet['galaxy'] = $Galaxy;
$planet['system'] = $System;
$planet['planet'] = $planet['position_original'] = $Position;
$planet['planet_type'] = PT_PLANET;
$planet['diameter'] = $planet_diameter;
$planet['field_max'] = $planet['field_max_original'] = $planet_sectors;
$planet['density'] = $core_info[UNIT_PLANET_DENSITY];
$planet['density_index'] = $core_info[UNIT_PLANET_DENSITY_INDEX];
$planet['temp_min'] = $planet['temp_min_original'] = $t_min;
$planet['temp_max'] = $planet['temp_max_original'] = $t_max;
$planet['metal'] = $config->eco_planet_starting_metal;
$planet['crystal'] = $config->eco_planet_starting_crystal;
$planet['deuterium'] = $config->eco_planet_starting_deuterium;
$planet['metal_max'] = $config->eco_planet_storage_metal;
$planet['crystal_max'] = $config->eco_planet_storage_crystal;
$planet['deuterium_max'] = $config->eco_planet_storage_deuterium;
$density_info_resources =& $density_list[$core_info[UNIT_PLANET_DENSITY_INDEX]][UNIT_RESOURCES];
$planet['metal_perhour'] = $config->metal_basic_income * $density_info_resources[RES_METAL];
$planet['crystal_perhour'] = $config->crystal_basic_income * $density_info_resources[RES_CRYSTAL];
$planet['deuterium_perhour'] = $config->deuterium_basic_income * $density_info_resources[RES_DEUTERIUM];
$RetValue = classSupernova::db_ins_record(LOC_PLANET, "`name` = '{$planet['name']}', `id_owner` = '{$planet['id_owner']}', `last_update` = '{$planet['last_update']}', `image` = '{$planet['image']}',\n `galaxy` = '{$planet['galaxy']}', `system` = '{$planet['system']}', `planet` = '{$planet['planet']}', `planet_type` = '{$planet['planet_type']}', `position_original` = '{$planet['position_original']}',\n `diameter` = '{$planet['diameter']}', `field_max` = '{$planet['field_max']}', `field_max_original` = '{$planet['field_max_original']}',\n `density` = '{$planet['density']}', `density_index` = '{$planet['density_index']}',\n `temp_min` = '{$planet['temp_min']}', `temp_max` = '{$planet['temp_max']}', `temp_min_original` = '{$planet['temp_min_original']}', `temp_max_original` = '{$planet['temp_max_original']}',\n `metal` = '{$planet['metal']}', `metal_perhour` = '{$planet['metal_perhour']}', `metal_max` = '{$planet['metal_max']}',\n `crystal` = '{$planet['crystal']}', `crystal_perhour` = '{$planet['crystal_perhour']}', `crystal_max` = '{$planet['crystal_max']}',\n `deuterium` = '{$planet['deuterium']}', `deuterium_perhour` = '{$planet['deuterium_perhour']}', `deuterium_max` = '{$planet['deuterium_max']}'");
return is_array($RetValue) ? $RetValue['id'] : false;
// OK
}
示例3: nws_render
/**
* @param template $template
* @param string $query_where
* @param int $query_limit
*/
function nws_render(&$template, $query_where = '', $query_limit = 20)
{
global $config, $user;
$announce_list = doquery("SELECT a.*, UNIX_TIMESTAMP(`tsTimeStamp`) AS unix_time, u.authlevel, s.*\n FROM\n {{announce}} AS a\n LEFT JOIN {{survey}} AS s ON s.survey_announce_id = a.idAnnounce\n LEFT JOIN {{users}} AS u ON u.id = a.user_id\n {$query_where}\n ORDER BY `tsTimeStamp` DESC, idAnnounce" . ($query_limit ? " LIMIT {$query_limit}" : ''));
$template->assign_var('NEWS_COUNT', db_num_rows($announce_list));
$users = array();
while ($announce = db_fetch($announce_list)) {
if ($announce['user_id'] && !isset($users[$announce['user_id']])) {
$users[$announce['user_id']] = db_user_by_id($announce['user_id']);
}
$survey_vote = array('survey_vote_id' => 1);
$survey_complete = strtotime($announce['survey_until']) < SN_TIME_NOW;
if ($announce['survey_id'] && !empty($user['id'])) {
$survey_vote = !$survey_complete ? $survey_vote = doquery("SELECT `survey_vote_id` FROM `{{survey_votes}}` WHERE survey_parent_id = {$announce['survey_id']} AND survey_vote_user_id = {$user['id']} LIMIT 1;", true) : array();
}
$announce_exploded = explode("<br /><br />", cht_message_parse($announce['strAnnounce'], false, intval($announce['authlevel'])));
$template->assign_block_vars('announces', array('ID' => $announce['idAnnounce'], 'TIME' => date(FMT_DATE_TIME, $announce['unix_time'] + SN_CLIENT_TIME_DIFF), 'ANNOUNCE' => cht_message_parse($announce['strAnnounce'], false, intval($announce['authlevel'])), 'DETAIL_URL' => $announce['detail_url'], 'USER_NAME' => isset($users[$announce['user_id']]) && $users[$announce['user_id']] ? player_nick_render_to_html($users[$announce['user_id']], array('color' => true)) : js_safe_string($announce['user_name']), 'NEW' => $announce['unix_time'] + $config->game_news_actual >= SN_TIME_NOW, 'FUTURE' => $announce['unix_time'] > SN_TIME_NOW, 'SURVEY_ID' => $announce['survey_id'], 'SURVEY_TEXT' => $announce['survey_question'], 'SURVEY_CAN_VOTE' => empty($survey_vote) && !$survey_complete, 'SURVEY_COMPLETE' => $survey_complete, 'SURVEY_UNTIL' => $announce['survey_until']));
foreach ($announce_exploded as $announce_paragraph) {
$template->assign_block_vars('announces.paragraph', array('TEXT' => $announce_paragraph));
}
if ($announce['survey_id']) {
$survey_query = doquery("SELECT survey_answer_text AS `TEXT`, count(DISTINCT survey_vote_id) AS `VOTES`\n FROM `{{survey_answers}}` AS sa\n LEFT JOIN `{{survey_votes}}` AS sv ON sv.survey_parent_answer_id = sa.survey_answer_id\n WHERE sa.survey_parent_id = {$announce['survey_id']}\n GROUP BY survey_answer_id\n ORDER BY survey_answer_id;");
$survey_vote_result = array();
$total_votes = 0;
while ($row = db_fetch($survey_query)) {
$survey_vote_result[] = $row;
$total_votes += $row['VOTES'];
}
if (empty($survey_vote) && !$survey_complete) {
// Can vote
$survey_query = doquery("SELECT * FROM {{survey_answers}} WHERE survey_parent_id = {$announce['survey_id']} ORDER BY survey_answer_id;");
while ($row = db_fetch($survey_query)) {
$template->assign_block_vars('announces.survey_answers', array('ID' => $row['survey_answer_id'], 'TEXT' => $row['survey_answer_text']));
}
} else {
// Show result
foreach ($survey_vote_result as &$vote_result) {
$vote_percent = $total_votes ? $vote_result['VOTES'] / $total_votes * 100 : 0;
$vote_result['PERCENT'] = $vote_percent;
$vote_result['PERCENT_TEXT'] = round($vote_percent, 1);
$vote_result['VOTES'] = pretty_number($vote_result['VOTES']);
$template->assign_block_vars('announces.survey_votes', $vote_result);
}
}
// Dirty hack
$template->assign_block_vars('announces.total_votes', array('TOTAL_VOTES' => $total_votes));
}
}
}
示例4: rpg_points_change
/**
*
* This function changes rpg_points for user
* You should ALWAYS use this function and NEVER directly change rpg_points by yourself
* Otherwise refferal system wouldn't work and no logs would be made
* "No logs" means you can never check if the user cheating with DM
*
* @package rpg
*
*/
function rpg_points_change($user_id, $change_type, $dark_matter, $comment = false, $already_changed = false)
{
global $debug, $config, $dm_change_legit, $user;
if (!$user_id) {
return false;
}
$dm_change_legit = true;
$sn_data_dark_matter_db_name = pname_resource_name(RES_DARK_MATTER);
if ($already_changed) {
$rows_affected = 1;
} else {
$dark_matter_total = $dark_matter > 0 ? $dark_matter : 0;
db_user_set_by_id($user_id, "`{$sn_data_dark_matter_db_name}` = `{$sn_data_dark_matter_db_name}` + '{$dark_matter}', `dark_matter_total` = `dark_matter_total` + '{$dark_matter_total}'");
$rows_affected = db_affected_rows();
}
if ($rows_affected || !$dark_matter) {
$page_url = db_escape($_SERVER['SCRIPT_NAME']);
if (is_array($comment)) {
$comment = call_user_func_array('sprintf', $comment);
}
$comment = db_escape($comment);
$row = db_user_by_id($user_id, false, 'username');
$row['username'] = db_escape($row['username']);
doquery("INSERT INTO {{log_dark_matter}} (`log_dark_matter_username`, `log_dark_matter_reason`,\n `log_dark_matter_amount`, `log_dark_matter_comment`, `log_dark_matter_page`, `log_dark_matter_sender`)\n VALUES (\n '{$row['username']}', {$change_type},\n {$dark_matter}, '{$comment}', '{$page_url}', {$user_id}\n );");
if ($user['id'] == $user_id) {
$user['dark_matter'] += $dark_matter;
}
if ($dark_matter > 0) {
$old_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id} LIMIT 1 FOR UPDATE;", '', true);
if ($old_referral['id']) {
doquery("UPDATE {{referrals}} SET dark_matter = dark_matter + '{$dark_matter}' WHERE `id` = {$user_id} LIMIT 1;");
$new_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id} LIMIT 1;", '', true);
$partner_bonus = floor($new_referral['dark_matter'] / $config->rpg_bonus_divisor) - ($old_referral['dark_matter'] >= $config->rpg_bonus_minimum ? floor($old_referral['dark_matter'] / $config->rpg_bonus_divisor) : 0);
if ($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) {
rpg_points_change($new_referral['id_partner'], RPG_REFERRAL, $partner_bonus, "Incoming From Referral ID {$user_id}");
}
}
}
} else {
$debug->warning("Error adjusting Dark Matter for player ID {$user_id} (Player Not Found?) with {$dark_matter}. Reason: {$comment}", 'Dark Matter Change', 402);
}
$dm_change_legit = false;
return $rows_affected;
}
示例5: ube_attack_prepare_player
function ube_attack_prepare_player(&$combat_data, $player_id, $is_attacker)
{
global $ube_convert_techs;
if (!isset($combat_data[UBE_PLAYERS][$player_id])) {
$combat_data[UBE_PLAYERS][$player_id] = array(UBE_ATTACKER => $is_attacker);
$player_info =& $combat_data[UBE_PLAYERS][$player_id];
$player_data = db_user_by_id($player_id, true);
$player_info[UBE_NAME] = $player_data['username'];
$player_info[UBE_AUTH_LEVEL] = $player_data['authlevel'];
$combat_data[UBE_OPTIONS][UBE_COMBAT_ADMIN] = $combat_data[UBE_OPTIONS][UBE_COMBAT_ADMIN] || $player_data['authlevel'];
// Участвует ли админ в бою?
$player_info[UBE_PLAYER_DATA] = $player_data;
$admiral_bonus = mrc_get_level($player_data, false, MRC_ADMIRAL) * get_unit_param(MRC_ADMIRAL, P_BONUS_VALUE) / 100;
foreach ($ube_convert_techs as $unit_id => $ube_id) {
$player_info[UBE_BONUSES][$ube_id] += mrc_get_level($player_data, false, $unit_id) * get_unit_param($unit_id, P_BONUS_VALUE) / 100 + $admiral_bonus;
}
} else {
$combat_data[UBE_PLAYERS][$player_id][UBE_ATTACKER] = $combat_data[UBE_PLAYERS][$player_id][UBE_ATTACKER] || $is_attacker;
}
}
示例6: define
<?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);
示例7: que_process
function que_process(&$user, $planet = null, $on_time = SN_TIME_NOW)
{
sn_db_transaction_check(true);
$que = array();
// Блокируем пользователя. Собственно, запись о нём нам не нужна - будем использовать старую
$user = db_user_by_id($user['id'], true);
$time_left[$user['id']][0] = max(0, $on_time - $user['que_processed']);
if ($planet === null && !$time_left[$user['id']][0]) {
// TODO
return $que;
}
// Определяем, какие очереди нам нужны и получаем их
$que_type_id = $planet === null ? QUE_RESEARCH : false;
$planet = intval(is_array($planet) ? $planet['id'] : $planet);
// В $planet у нас теперь только её ID или шаблон null/0/false
$que = que_get($user['id'], $planet, $que_type_id, true);
//pdump($que);
if (empty($que['items'])) {
return $que;
}
$planet_list = array();
if ($planet !== null) {
// Если нужно изменять данные на планетах - блокируем планеты и получаем данные о них
// TODO - от них не надо ничего, кроме ID и que_processed
// $planet_query = db_planet_list_by_user_or_planet($user['id'], $planet);
// foreach($planet_query as $planet_row)
$planet_row = db_planet_list_by_user_or_planet($user['id'], $planet);
$planet_list[$planet_row['id']] = $planet_row;
$time_left[$planet_row['id_owner']][$planet_row['id']] = max(0, $on_time - $planet_row['que_processed']);
}
// pdump($time_left);
// Теперь в $time_left лежит время обсчета всех очередей по каждой из планеты
if (array_sum($time_left[$user['id']]) == 0) {
return $que;
}
// pdump($que);
$db_changeset = array();
$unit_changes = array();
foreach ($que['items'] as &$que_item) {
$que_player_id =& $que_item['que_player_id'];
$que_planet_id = intval($que_item['que_planet_id']);
// $que_type = &$que_item['que_type'];
$que_time_left =& $que['time_left'][$que_player_id][$que_planet_id][$que_item['que_type']];
if (!isset($que_time_left)) {
$que_time_left = $time_left[$que_player_id][$que_planet_id];
}
if ($que_time_left <= 0 || $que_item['que_unit_amount'] <= 0) {
continue;
}
// Дальше мы идем, если только осталось время в очереди И юниты к постройке
// Вычисляем, сколько целых юнитов будет построено - от 0 до количества юнитов в очереди
$unit_processed = min($que_item['que_unit_amount'] - 1, floor($que_time_left / $que_item['que_unit_time']));
// Вычитаем это время из остатков
$que_time_left -= $unit_processed * $que_item['que_unit_time'];
// Теперь работаем с остатком времени на юните. Оно не может быть равно или меньше нуля
// Если времени в очереди осталось не меньше, чем время текущего юнита - значит мы достроили юнит
if ($que_time_left >= $que_item['que_time_left']) {
// Увеличиваем количество отстроенных юнитов
$unit_processed++;
// Вычитаем из времени очереди потраченное на постройку время
$que_time_left -= $que_item['que_time_left'];
// Полное время юнита равно времени нового юнита
$que_item['que_time_left'] = $que_item['que_unit_time'];
// Тут у нас может остатся время очереди - если постройка была не последняя
}
// Изменяем количество оставшихся юнитов
$que_item['que_unit_amount'] -= $unit_processed;
// Если еще остались юниты - значит ВСЁ оставшееся время приходится на достройку следующего юнита
if ($que_item['que_unit_amount'] > 0) {
$que_item['que_time_left'] = $que_item['que_time_left'] - $que_time_left;
$que_time_left = 0;
}
if ($que_item['que_unit_amount'] <= 0) {
$db_changeset['que'][] = array('action' => SQL_OP_DELETE, P_VERSION => 1, 'where' => array("que_id" => $que_item['que_id']));
} else {
$db_changeset['que'][] = array('action' => SQL_OP_UPDATE, P_VERSION => 1, 'where' => array("que_id" => $que_item['que_id']), 'fields' => array('que_unit_amount' => array('delta' => -$unit_processed), 'que_time_left' => array('set' => $que_item['que_time_left'])));
}
if ($unit_processed) {
$unit_processed_delta = $unit_processed * ($que_item['que_unit_mode'] == BUILD_CREATE ? 1 : -1);
$unit_changes[$que_player_id][$que_planet_id][$que_item['que_unit_id']] += $unit_processed_delta;
}
}
foreach ($time_left as $player_id => $planet_data) {
foreach ($planet_data as $planet_id => $time_on_planet) {
$table = $planet_id ? 'planets' : 'users';
$id = $planet_id ? $planet_id : $player_id;
$db_changeset[$table][] = array('action' => SQL_OP_UPDATE, P_VERSION => 1, 'where' => array("id" => $id), 'fields' => array('que_processed' => array('set' => $on_time)));
if (is_array($unit_changes[$player_id][$planet_id])) {
foreach ($unit_changes[$player_id][$planet_id] as $unit_id => $unit_amount) {
$db_changeset['unit'][] = sn_db_unit_changeset_prepare($unit_id, $unit_amount, $user, $planet_id ? $planet_id : null);
}
}
}
}
//pdump($db_changeset, '$db_changeset');
$que = que_recalculate($que);
//pdump($que, '$que');
// TODO: Re-enable quests for Alliances
if (!empty($unit_changes) && !$user['user_as_ally']) {
$quest_list = qst_get_quests($user['id']);
//.........这里部分代码省略.........
示例8: sys_get_param_int
$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) {
$subject = substr($subject, strlen($lang['msg_answer_prefix']));
示例9: substr
<?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)));
示例10: int_banner_create
/**
* int_banner_create.php
* @version 2.0
* @copyright 2010 Gorlum for http://supernova.ws
*
* heavily based on
* CreateBanner.php
* @version 1.2 by Ihor
* @version 1.0 copyright 2008 By e-Zobar for XNova
*/
function int_banner_create($id, $type = 'userbar', $format = 'png')
{
// banner.php?id=<userid>&type=<banner|userbar>&format=<png>
global $config, $lang;
$id = intval($id);
switch ($type) {
case 'banner':
$img_name = $config->int_banner_background;
break;
default:
$img_name = $config->int_userbar_background;
break;
}
$size = getimagesize(SN_ROOT_PHYSICAL . $img_name);
$im = imagecreatefrompng(SN_ROOT_PHYSICAL . $img_name);
$image = imagecreatetruecolor($size[0], $size[1]);
imagecopy($image, $im, 0, 0, 0, 0, $size[0], $size[1]);
imagedestroy($im);
// Colors
$color = "FFFFFF";
$red = hexdec(substr($color, 0, 2));
$green = hexdec(substr($color, 2, 4));
$blue = hexdec(substr($color, 4, 6));
$select = imagecolorallocate($image, $red, $green, $blue);
$txt_shadow = imagecolorallocatealpha($image, 255, 255, 255, 255);
$txt_color = imagecolorallocatealpha($image, 255, 255, 255, 2);
$txt_shadow2 = imagecolorallocatealpha($image, 255, 255, 255, 255);
$txt_color2 = imagecolorallocatealpha($image, 255, 255, 255, 40);
$fonts = array('userbar' => SN_ROOT_PHYSICAL . "design/fonts/" . $config->int_userbar_font, 'universe' => SN_ROOT_PHYSICAL . "design/fonts/" . $config->int_banner_fontUniverse, 'raids' => SN_ROOT_PHYSICAL . "design/fonts/" . $config->int_banner_fontRaids, 'info' => SN_ROOT_PHYSICAL . "design/fonts/" . $config->int_banner_fontInfo);
if ($id) {
// Querys
$user = db_user_by_id($id);
$planet_row = db_planet_by_id($user['id_planet']);
// Variables
$b_user = $user['username'];
$b_ally = $user['ally_name'];
$b_planet = $planet_row['name'];
$b_xyz = "[" . $planet_row['galaxy'] . ":" . $planet_row['system'] . ":" . $planet_row['planet'] . "]";
$b_lvl = ($user['total_rank'] ? $user['total_rank'] : $config->users_amount) . "/{$config->users_amount}";
} else {
$b_user = $lang['ov_banner_empty_id'];
}
$b_univ = $config->game_name;
switch ($type) {
case 'banner':
// Banner size 416 x 58
$fsize = 15;
$is = imagettfbbox($fsize, 0, $fonts['universe'], $b_univ);
imagettftext($image, $fsize, 0, $size[0] - 4 - $is[2], $size[1] - 2, $txt_shadow, $fonts['universe'], $b_univ);
imagettftext($image, $fsize, 0, $size[0] - 6 - $is[2], $size[1] - 4, $txt_color, $fonts['universe'], $b_univ);
// Player name
imagettftext($image, 11, 0, 8, 26, $txt_shadow, $fonts['info'], $b_user);
imagettftext($image, 11, 0, 6, 23, $txt_color, $fonts['info'], $b_user);
if ($id) {
// Player level - right-alligned
$is = imagettfbbox(11, 0, $fonts['info'], $b_lvl);
imagettftext($image, 11, 0, $size[0] - 4 - $is[2], 25, $txt_shadow, $fonts['info'], $b_lvl);
imagettftext($image, 11, 0, $size[0] - 6 - $is[2], 23, $txt_color, $fonts['info'], $b_lvl);
// Ally name
$is = imagettfbbox(9, 0, $fonts['info'], $b_ally);
imagettftext($image, 9, 0, 412 - $is[2], 37, $txt_shadow, $fonts['info'], $b_ally);
imagettftext($image, 9, 0, 410 - $is[2], 35, $txt_color, $fonts['info'], $b_ally);
// Player b_planet
imagettftext($image, 6, 0, 8, 10, $txt_shadow2, $fonts['raids'], $b_planet . " " . $b_xyz);
imagettftext($image, 6, 0, 6, 9, $txt_color2, $fonts['raids'], $b_planet . " " . $b_xyz);
//StatPoint
$b_points = $lang['ov_points'] . ": " . pretty_number($user['total_points']);
$is = imagettfbbox(8, 0, $fonts['info'], $b_points);
imagettftext($image, 8, 0, 412 - $is[2], 11, $txt_shadow, $fonts['info'], $b_points);
imagettftext($image, 8, 0, 410 - $is[2], 9, $txt_color, $fonts['info'], $b_points);
//Raids Total
imagettftext($image, 6, 0, 8, 37, $txt_shadow2, $fonts['raids'], $lang['NumberOfRaids']);
imagettftext($image, 6, 0, 6, 35, $txt_color2, $fonts['raids'], $lang['NumberOfRaids']);
$b_points = ": " . pretty_number($user['raids']);
imagettftext($image, 6, 0, 61, 37, $txt_shadow2, $fonts['raids'], $b_points);
imagettftext($image, 6, 0, 59, 35, $txt_color2, $fonts['raids'], $b_points);
//Raids Won
imagettftext($image, 6, 0, 8, 47, $txt_shadow2, $fonts['raids'], $lang['RaidsWin']);
imagettftext($image, 6, 0, 6, 45, $txt_color2, $fonts['raids'], $lang['RaidsWin']);
$b_points = ": " . pretty_number($user['raidswin']);
imagettftext($image, 6, 0, 61, 47, $txt_shadow2, $fonts['raids'], $b_points);
imagettftext($image, 6, 0, 59, 45, $txt_color2, $fonts['raids'], $b_points);
//Raids Lost
imagettftext($image, 6, 0, 8, 57, $txt_shadow2, $fonts['raids'], $lang['RaidsLoose']);
imagettftext($image, 6, 0, 6, 55, $txt_color2, $fonts['raids'], $lang['RaidsLoose']);
$b_points = ": " . pretty_number($user['raidsloose']);
imagettftext($image, 6, 0, 61, 57, $txt_shadow2, $fonts['raids'], $b_points);
imagettftext($image, 6, 0, 59, 55, $txt_color2, $fonts['raids'], $b_points);
}
break;
//.........这里部分代码省略.........
示例11: sec_password_get
/**
* Получение пароля пользователя по его ID или записи
*
* @param int|array $user ID или запись пользователя
*
* @return array|bool Массив [password, salt] или FALSE в случае неудачи
*/
function sec_password_get($user)
{
if (!is_array($user) && ($user = intval($user))) {
// Это ID
$user = db_user_by_id($user);
}
if (is_array($user) && !empty($user['password'])) {
return array('password' => $user['password'], 'salt' => $user['salt']);
} else {
return false;
}
}
示例12: db_user_list_by_id
/**
* Выбирает записи игроков по списку их ID
*
* @param $user_id_list
*
* @return array
*/
function db_user_list_by_id($user_id_list)
{
!is_array($user_id_list) ? $user_id_list = array($user_id_list) : false;
$user_list = array();
foreach ($user_id_list as $user_id_unsafe) {
$user = db_user_by_id($user_id_unsafe);
!empty($user) ? $user_list[$user_id_unsafe] = $user : false;
}
return $user_list;
}
示例13: sn_options_model
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);
}
//.........这里部分代码省略.........
示例14: coe_o_missile_calculate
/**
* Copyright (c) 2009-2010 by Gorlum for http://supernova.ws
* OpenSource as long as you don't remove this Copyright
* V3 2009-11-13
* V2 2009-10-10
*/
function coe_o_missile_calculate()
{
sn_db_transaction_check(true);
global $lang;
$iraks = doquery("SELECT * FROM {{iraks}} WHERE `fleet_end_time` <= " . SN_TIME_NOW . " FOR UPDATE;");
while ($fleetRow = db_fetch($iraks)) {
set_time_limit(15);
$db_changeset = array();
$targetUser = db_user_by_id($fleetRow['fleet_target_owner'], true);
$target_planet_row = sys_o_get_updated($targetUser, array('galaxy' => $fleetRow['fleet_end_galaxy'], 'system' => $fleetRow['fleet_end_system'], 'planet' => $fleetRow['fleet_end_planet'], 'planet_type' => PT_PLANET), SN_TIME_NOW);
$target_planet_row = $target_planet_row['planet'];
$rowAttacker = db_user_by_id($fleetRow['fleet_owner'], true);
if ($target_planet_row['id']) {
$planetDefense = array();
foreach (sn_get_groups('defense_active') as $unit_id) {
$planetDefense[$unit_id] = array(mrc_get_level($targetUser, $target_planet_row, $unit_id, true, true));
}
$message = '';
$interceptors = mrc_get_level($targetUser, $target_planet_row, UNIT_DEF_MISSILE_INTERCEPTOR, true, true);
//$target_planet_row[$interceptor_db_name]; // Number of interceptors
$missiles = $fleetRow['fleet_amount'];
// Number of MIP
if ($interceptors >= $missiles) {
$message = $lang['mip_all_destroyed'];
$db_changeset['unit'][] = sn_db_unit_changeset_prepare(UNIT_DEF_MISSILE_INTERCEPTOR, -$missiles, $targetUser, $target_planet_row['id']);
} else {
if ($interceptors) {
$message = sprintf($lang['mip_destroyed'], $interceptors);
$db_changeset['unit'][] = sn_db_unit_changeset_prepare(UNIT_DEF_MISSILE_INTERCEPTOR, -$interceptors, $targetUser, $target_planet_row['id']);
}
// $message .= $lang['mip_defense_destroyed'];
$attackResult = COE_missileAttack($targetUser, $rowAttacker, $missiles - $interceptors, $planetDefense, $fleetRow['primaer']);
foreach ($attackResult['structures'] as $key => $structure) {
$destroyed = $planetDefense[$key][0] - $structure[0];
if ($destroyed) {
$db_changeset['unit'][] = sn_db_unit_changeset_prepare($key, -$destroyed, $targetUser, $target_planet_row['id']);
$message .= " {$lang['tech'][$key]} - {$destroyed} {$lang['quantity']}<br>";
}
}
if (!empty($message)) {
$message = $lang['mip_defense_destroyed'] . $message . "{$lang['mip_recycled']}{$lang['Metal']}: {$attackResult['metal']}, {$lang['Crystal']}: {$attackResult['crystal']}<br>";
db_planet_set_by_id($target_planet_row['id'], "`metal` = `metal` + {$attackResult['metal']}, `crystal` = `crystal` + {$attackResult['crystal']}");
}
// $message .= "{$lang['mip_recycled']}{$lang['Metal']}: {$attackResult['metal']}, {$lang['Crystal']}: {$attackResult['crystal']}<br>";
}
db_changeset_apply($db_changeset);
$fleetRow['fleet_start_type'] = PT_PLANET;
$sourcePlanet = db_planet_by_vector($fleetRow, 'fleet_start_', false, 'name');
$message_vorlage = sprintf($lang['mip_body_attack'], $fleetRow['fleet_amount'], addslashes($sourcePlanet['name']), $fleetRow['fleet_start_galaxy'], $fleetRow['fleet_start_system'], $fleetRow['fleet_start_planet'], addslashes($target_planet_row['name']), $fleetRow['fleet_end_galaxy'], $fleetRow['fleet_end_system'], $fleetRow['fleet_end_planet']);
empty($message) ? $message = $lang['mip_no_defense'] : false;
// empty($message) && ($message = $lang['mip_no_defense']);
msg_send_simple_message($fleetRow['fleet_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, $lang['mip_sender_amd'], $lang['mip_subject_amd'], $message_vorlage . $message);
msg_send_simple_message($fleetRow['fleet_target_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, $lang['mip_sender_amd'], $lang['mip_subject_amd'], $message_vorlage . $message);
}
doquery("DELETE FROM {{iraks}} WHERE id = '{$fleetRow['id']}';");
}
}
示例15: define
<?php
/**
* adm_flying_fleets.php
*
* @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'] < 2)
if ($user['authlevel'] < 3) {
AdminMessage($lang['adm_err_denied']);
}
$template = gettemplate('admin/adm_flying_fleets', true);
$FlyingFleets = db_fleet_list_with_usernames();
while ($CurrentFleet = db_fetch($FlyingFleets)) {
$FleetOwner = db_user_by_id($CurrentFleet['fleet_owner']);
$fleet_data = tpl_parse_fleet_db($CurrentFleet, ++$i, $FleetOwner);
$fleet_data['fleet']['OWNER_NAME'] = htmlentities($FleetOwner['username'], ENT_COMPAT, 'UTF-8');
$fleet_data['fleet']['TARGET_OWNER_NAME'] = htmlentities($CurrentFleet['username'], ENT_COMPAT, 'UTF-8');
$fleet_data['fleet']['STAY_TIME_INT'] = $CurrentFleet['fleet_end_stay'];
$template->assign_block_vars('fleets', $fleet_data['fleet']);
foreach ($fleet_data['ships'] as $ship_data) {
$template->assign_block_vars('fleets.ships', $ship_data);
}
}
display($template, $lang['flt_title'], false, '', true);