function db_message_list_outbox_by_user_id($user_id) { // return ($user_id = intval($user_id)) return ($user_id = idval($user_id)) ? doquery("SELECT {{messages}}.message_id, {{messages}}.message_owner, {{users}}.id AS message_sender, {{messages}}.message_time,\n {{messages}}.message_type, {{users}}.username AS message_from, {{messages}}.message_subject, {{messages}}.message_text\n FROM\n {{messages}} LEFT JOIN {{users}} ON {{users}}.id = {{messages}}.message_owner WHERE `message_sender` = '{$user_id}' AND `message_type` = 1\n ORDER BY `message_time` DESC;") : false; }
function db_planet_count_by_type($ui_user_id, $ui_planet_type = PT_PLANET) { // $si_user_id = intval($ui_user_id); $si_user_id = idval($ui_user_id); $si_planet_type = intval($ui_planet_type); // Лочим запись-родителя - если она есть и еще не залочена $record_list = classSupernova::db_get_record_list(LOC_PLANET, "`id_owner` = {$si_user_id} AND `planet_type` = {$si_planet_type}"); return is_array($record_list) ? count($record_list) : 0; // $planets = doquery("SELECT COUNT(*) AS planet_count FROM {{planets}} WHERE `id_owner` = {$si_user_id} AND `planet_type` = {$si_planet_type}", true); // return isset($planets['planet_count']) ? $planets['planet_count'] : 0; }
function db_unit_list_delete($user_id = 0, $unit_location_type, $unit_location_id, $unit_snid = 0) { return classSupernova::db_del_record_list(LOC_UNIT, "`unit_location_type` = {$unit_location_type} AND `unit_location_id` = {$unit_location_id}" . ($user_id = idval($user_id) ? " AND `unit_player_id` = {$user_id}" : '') . ($unit_snid = idval($unit_snid) ? " AND `unit_snid` = {$unit_snid}" : '')); }
if (sys_get_param('note_delete')) { try { $not = ''; $query_where = ''; switch (sys_get_param_str('note_delete_range')) { case 'all': break; case 'marked_not': $not = 'NOT'; case 'marked': if (!is_array($notes_marked = sys_get_param('note'))) { throw new exception('note_err_none_selected', ERR_WARNING); } $notes_marked_filtered = array(); foreach ($notes_marked as $note_id => $note_select) { if ($note_select == 'on' && ($note_id = idval($note_id))) { $notes_marked_filtered[] = $note_id; } } if (empty($notes_marked_filtered)) { throw new exception('note_err_none_selected', ERR_WARNING); } $notes_marked_filtered = implode(',', $notes_marked_filtered); $query_where = "AND `id` {$not} IN ({$notes_marked_filtered})"; break; default: throw new exception('note_warn_no_range', ERR_WARNING); break; } sn_db_transaction_start(); doquery("DELETE FROM {{notes}} WHERE `owner` = {$user['id']} {$query_where};");
public static function db_que_list_by_type_location($user_id, $planet_id = null, $que_type = false, $for_update = false) { if (!$user_id) { pdump(debug_backtrace()); die('No user_id for que_get_que()'); } $ques = array(); $query = array(); // if($user_id = intval($user_id)) if ($user_id = idval($user_id)) { $query[] = "`que_player_id` = {$user_id}"; } if ($que_type == QUE_RESEARCH || $planet_id === null) { $query[] = "`que_planet_id` IS NULL"; } elseif ($planet_id) { $query[] = "(`que_planet_id` = {$planet_id}" . ($que_type ? '' : ' OR que_planet_id IS NULL') . ")"; } if ($que_type) { $query[] = "`que_type` = {$que_type}"; } /* $sql = ''; $sql .= $user_id ? " AND `que_player_id` = {$user_id}" : ''; $sql .= $que_type == QUE_RESEARCH || $planet_id === null ? " AND `que_planet_id` IS NULL" : ($planet_id ? " AND (`que_planet_id` = {$planet_id}" . ($que_type ? '' : ' OR que_planet_id IS NULL') . ")" : ''); $sql .= $que_type ? " AND `que_type` = {$que_type}" : ''; pdump($sql); pdump(implode(' AND ', $query)); $que_query = ($sql = implode(' AND ', $query)) ? doquery("SELECT * FROM {{que}} WHERE {$sql} ORDER BY que_id" . ($for_update ? ' FOR UPDATE' : '')) : false; if($que_query) { while($row = db_fetch($que_query)) { $ques['items'][] = $row; } } */ $ques['items'] = static::db_get_record_list(LOC_QUE, implode(' AND ', $query)); return que_recalculate($ques); }
function db_unit_list_delete($user_id = 0, $unit_location_type, $unit_location_id, $unit_snid = 0) { return classSupernova::db_del_record_list(LOC_UNIT, "`unit_location_type` = {$unit_location_type} AND `unit_location_id` = {$unit_location_id}" . ($user_id = idval($user_id) ? " AND `unit_player_id` = {$user_id}" : '') . ($unit_snid = idval($unit_snid) ? " AND `unit_snid` = {$unit_snid}" : '')); return doquery("DELETE FROM {{unit}}\n WHERE unit_location_type = {$unit_location_type} AND unit_location_id = {$unit_location_id}" . ($user_id = idval($user_id) ? " AND unit_player_id = {$user_id}" : '') . ($unit_snid = idval($unit_snid) ? " AND unit_snid = {$unit_snid}" : '')); }
<?php include 'common.' . substr(strrchr(__FILE__, '.'), 1); if (!empty($_POST['return']) && is_array($_POST['return'])) { foreach ($_POST['return'] as $fleet_id) { if ($fleet_id = idval($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;