示例#1
0
function search_by_proximity_hook($hook, $type, $return, $params)
{
    $query = $params['query'];
    $coords = elgg_geocode_location($query);
    if (!$coords) {
        return $return;
    }
    $registered_entities = elgg_get_config('registered_entities');
    $options = array('types' => array('object', 'user', 'group'), 'subtypes' => array_merge($registered_entities['object'], $registered_entities['user'], $registered_entities['group']), 'limit' => get_input('limit', 20), 'offset' => get_input('proximity_offset', 0), 'offset_key' => 'proximity_offset', 'count' => true);
    $options = add_order_by_proximity_clauses($options, $coords['lat'], $coords['long']);
    $options = add_distance_constraint_clauses($options, $coords['lat'], $coords['long'], SEARCH_RADIUS);
    $count = elgg_get_entities($options);
    if ($count) {
        $options['count'] = false;
        $entities = elgg_get_entities($options);
    }
    if ($entities) {
        foreach ($entities as $entity) {
            $name = search_get_highlighted_relevant_substrings(isset($entity->name) ? $entity->name : $entity->title, $query);
            $entity->setVolatileData('search_matched_title', $name);
            $location = search_get_highlighted_relevant_substrings($entity->getLocation(), $query);
            $entity->setVolatileData('search_matched_location', $location);
            $distance = get_distance($entity->getLatitude(), $entity->getLongitude(), $coords['lat'], $coords['long']);
            // distance in metres
            $distance = round($distance / 1000, 2);
            // distance in km
            $distance_str = elgg_echo('geo:search:proximity', array($query, $distance));
            $entity->setVolatileData('search_proximity', $distance_str);
        }
    }
    return array('entities' => $entities, 'count' => $count);
}
示例#2
0
文件: ceshi.php 项目: kison30/new
function search_shop($db, $user_comment, $user_order, $shop_info)
{
    $userLng = isset($_REQUEST['user_lng']) ? $_REQUEST['user_lng'] : '116.641485';
    $userLat = isset($_REQUEST['user_lat']) ? $_REQUEST['user_lat'] : '23.419546';
    $page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : '1';
    $keyword = isset($_REQUEST['keyword']) ? trim($_REQUEST['keyword']) : '';
    $strSQL = "SELECT id,shop_name,logo,bid_price,distribution_charge,average_service_time,delivery_time,longitude,latitude FROM `shop_info` WHERE is_del=0 AND status=1 AND shop_name LIKE '%{$keyword}%' ";
    $rs = $db->get_results($strSQL);
    if ($rs == null) {
        $rs = array();
        $result = array('success' => true, 'result' => $rs, 'error_msg' => "查找记录为空!");
        return $result;
    }
    foreach ($rs as $key => $rows) {
        $s = get_distance($userLng, $userLat, $rows->longitude, $rows->latitude, $len_type = 2, $decimal = 2);
        if ($s > 10) {
            unset($rs[$key]);
        }
    }
    if ($rs == null) {
        $rs = array();
        $result = array('success' => true, 'result' => $rs, 'error_msg' => "查找记录为空!");
        return $result;
    }
    foreach ($rs as $key => $row) {
        $info[$key]['id'] = $row->id;
        $info[$key]['shop_name'] = $row->shop_name;
        $info[$key]['logo'] = $GLOBALS['IMAGE_URL'] . "shop_logo/" . $row->logo;
        $info[$key]['bid_price'] = $row->bid_price;
        $info[$key]['distribution_charge'] = $row->distribution_charge;
        $info[$key]['average_service_time'] = $row->average_service_time;
        $info[$key]['shop_score'] = $user_comment->get_shop_score($row->id);
        $info[$key]['order_num'] = $user_order->get_order_num($row->id);
        $info[$key]['distance'] = get_distance($userLng, $userLat, $row->longitude, $row->latitude, $len_type = 2, $decimal = 2);
        $info[$key]['comment_num'] = $user_comment->get_comment_num($row->id);
        $info[$key]['is_work'] = is_work($row->delivery_time);
    }
    if (is_array($info)) {
        foreach ($info as $key => $row) {
            $distance[$key] = $row['distance'];
            $is_work[$key] = $row['is_work'];
        }
        array_multisort($is_work, SORT_DESC, $distance, SORT_ASC, $info);
    }
    $recordCount = count($info);
    $rs = arrSort($info, $recordCount, $page, $pageSize = 5);
    if ($rs == null) {
        $rs = array();
        $result = array('success' => true, 'result' => $rs, 'error_msg' => "查找记录为空!");
        return $result;
    }
    $result = array('success' => true, 'result' => $rs, 'error_msg' => "获取成功!");
    return $result;
}
示例#3
0
function send_auctioned_ship($ship_id, $dest)
{
    global $db, $ACTUAL_TICK;
    $sql = 'SELECT s.ship_id, s.user_id, -s.fleet_id AS start,
                   st.value_10 AS max_warp_speed,
                   s1.system_id AS start_system_id, s1.system_global_x AS start_x, s1.system_global_y AS start_y,
                   s2.system_id AS dest_system_id, s2.system_global_x AS dest_x, s2.system_global_y AS dest_y
            FROM (ships s)
            INNER JOIN (ship_templates st) ON st.id = s.template_id
            INNER JOIN (planets p1) ON p1.planet_id = -s.fleet_id
            INNER JOIN (starsystems s1) ON s1.system_id = p1.system_id
            INNER JOIN (planets p2) ON p2.planet_id = ' . $dest . '
            INNER JOIN (starsystems s2) ON s2.system_id = p2.system_id
            WHERE s.ship_id = ' . $ship_id;
    if (($ship = $db->queryrow($sql)) === false) {
        message(DATABASE_ERROR, 'Could not query ship data');
    }
    if (empty($ship['ship_id'])) {
        message(GENERAL, 'Ship for auction does not exist', '$ship[\'ship_id\'] = empty');
    }
    if ($ship['max_warp_speed'] > 9.99) {
        $ship['max_warp_speed'] = 9.99;
    }
    if ($ship['start_system_id'] == $ship['dest_system_id']) {
        $distance = $velocity = 0;
        $min_time = 6;
    } else {
        $distance = get_distance(array($ship['start_x'], $ship['start_y']), array($ship['dest_x'], $ship['dest_y']));
        $velocity = warpf($ship['max_warp_speed']);
        $min_time = ceil($distance / $velocity / TICK_DURATION);
    }
    if ($min_time < 1) {
        $min_time = 1;
    }
    $sql = 'INSERT INTO scheduler_shipmovement (user_id, move_status, move_exec_started, start, dest, total_distance, remaining_distance, tick_speed, move_begin, move_finish, n_ships, action_code, action_data)
            VALUES (' . $ship['user_id'] . ', 0, 0, ' . $ship['start'] . ', ' . $dest . ', ' . $distance . ', ' . $distance . ', ' . $velocity * TICK_DURATION . ', ' . $ACTUAL_TICK . ', ' . ($ACTUAL_TICK + $min_time) . ', 1, 33, "")';
    if (!$db->query($sql)) {
        message(DATABASE_ERROR, 'Could not insert new movement data');
    }
    $new_move_id = $db->insert_id();
    if (empty($new_move_id)) {
        message(GENERAL, 'Could not send auction fleet', '$new_move_id = empty');
    }
    $sql = 'INSERT INTO ship_fleets (fleet_name, user_id, planet_id, move_id, n_ships)
            VALUES ("Auction ' . $ship_id . '", ' . $ship['user_id'] . ', 0, ' . $new_move_id . ', 1)';
    if (!$db->query($sql)) {
        message(DATABASE_ERROR, 'Could not insert new auction fleet data');
    }
    $new_fleet_id = $db->insert_id();
    if (empty($new_fleet_id)) {
        message(GENERAL, 'Could not find new auction fleet', '$new_fleet_id = empty');
    }
    $sql = 'UPDATE ships
            SET fleet_id = ' . $new_fleet_id . '
            WHERE ship_id = ' . $ship_id;
    if (!$db->query($sql)) {
        message(DATABASE_ERROR, 'Could not update ships data');
    }
    return true;
}
示例#4
0
 $ship_cargo_cap = $api["ship"]->{"cargo"}->{"capacity"};
 $ship_cargo_used = $api["ship"]->{"cargo"}->{"qty"};
 /**
  * additional ship info
  */
 $ship_value = number_format($api["ship"]->{"value"}->{"total"});
 $ship_hull_value = number_format($api["ship"]->{"value"}->{"hull"});
 $ship_modules_value = number_format($api["ship"]->{"value"}->{"modules"});
 if (isset($api["stored_ships"])) {
     $stored_ships = "<br /><br /><strong>Stored ships</strong><br />";
     foreach ($api["stored_ships"] as $shipId => $stored_ship) {
         if ($shipId != $api["commander"]->{"currentShipId"}) {
             $ship_name = ship_name($stored_ship->{"name"});
             $docked_at_station = $stored_ship->{"station"}->{"name"};
             $docked_at_system = $stored_ship->{"starsystem"}->{"name"};
             $distance = get_distance($docked_at_system);
             $stored_ships .= $ship_name . ' (' . $distance . ')<br />';
             $stored_ships .= $docked_at_station . ' at <a href="/System?system_name=' . urlencode($docked_at_system) . '">';
             $stored_ships .= $docked_at_system . '</a><br /><br />';
         }
     }
 }
 $additional = '<div id="ship_status_mi" style="display:none">';
 $additional .= '<strong>Ship value:</strong> ' . $ship_value . ' CR<br />';
 $additional .= 'Hull: ' . $ship_hull_value . ' CR<br />';
 $additional .= 'Modules: ' . $ship_modules_value . ' CR' . $stored_ships;
 $additional .= '</div>';
 $data["ship_status"] = '<img src="/style/img/ship.png" class="icon" alt="Ship hull" />' . $ship_health . ' %';
 $data["ship_status"] .= '<img src="/style/img/fuel.png" class="icon24" style="margin-left:6px;margin-bottom:4px" alt="Ship fuel" />' . $ship_fuel . ' %';
 $data["ship_status"] .= '<img src="/style/img/cargo.png" class="icon24" style="margin-left:6px" alt="Ship cargo" />' . $ship_cargo_used . '/' . $ship_cargo_cap;
 $data["ship_status"] .= $additional;
示例#5
0
              s.system_id = p.system_id');
while ($coordinates = $db->fetchrow($planetquery)) {
    $planets[$coordinates['tmp4']]['system_global_x'] = $coordinates['system_global_x'];
    $planets[$coordinates['tmp4']]['system_global_y'] = $coordinates['system_global_y'];
}
// 5. Sort the array:
foreach ($planets as $key => $row) {
    $sort[$key] = $row['numerate'];
}
array_multisort($sort, SORT_ASC, $planets);
unset($sort);
// 6. Output data:
foreach ($planets as $key => $planet) {
    /* 21/03/08 - AC: Add distance from currently selected planet */
    if ($planet['planet_id'] != $game->planet['planet_id']) {
        $distance = get_distance(array($game->planet['system_global_x'], $game->planet['system_global_y']), array($planet['system_global_x'], $planet['system_global_y']));
        $distance = round($distance, 2);
        $min_time = ceil($distance / warpf(6) / TICK_DURATION);
        $min_stardate = sprintf('%.1f', $game->config['stardate'] + $min_time / 10);
        $min_stardate_int = str_replace('.', '', $min_stardate);
        if ($distance > 0) {
            $arrival_minutes = ($min_stardate_int - (int) str_replace('.', '', $game->config['stardate'])) * TICK_DURATION;
            $arrival_hours = 0;
            $arrival_days = floor($arrival_minutes / 1440);
            $arrival_minutes -= $arrival_days * 1440;
            while ($arrival_minutes > 59) {
                $arrival_hours++;
                $arrival_minutes -= 60;
            }
        } else {
            $arrival_minutes = 20;
示例#6
0
 function create_sector_map($sector_id)
 {
     include_once 'include/libs/moves.php';
     global $db, $game;
     if ($sector_id < 1 || $sector_id > $this->max_sectors) {
         message(GENERAL, 'Invalid sector id ' . $sector_id);
     }
     //$g_coords = $game->get_sector_global_coords($game->get_sector_name($sector_id));
     $im = imagecreate($this->sector_map_size, $this->sector_map_size);
     //$im = imagecreatefrompng('maps/templates/sector_'.$g_coords[0].'_'.$g_coords[1].'.jpg');
     imagecolorallocate($im, 0, 0, 0);
     $this->draw_stars($im, $this->sector_map_size, 600);
     $this->draw_outer_border($im, $this->sector_map_size, 10);
     $sql = 'SELECT *
             FROM starsystems
             WHERE sector_id = ' . $sector_id;
     if (!($q_systems = $db->query($sql))) {
         message(DATABASE_ERROR, 'Could not query starsystems data');
     }
     $n_systems = $db->num_rows($q_systems);
     if ($n_systems > $this->max_systems_per_sector) {
         message(GENERAL, 'Too many starsystems found in sector ' . $sector_id);
     }
     $map_html = '<map name="sector_map">' . NL;
     $used_fields = array();
     while ($system = $db->fetchrow($q_systems)) {
         $coord_id = $system['system_x'] . $system['system_y'];
         if (isset($used_fields[$coord_id])) {
             message(GENERAL, 'Sector field ' . $system['system_x'] . '|' . $system['system_y'] . ' is used twice [by system ' . $used_fields[$coord_id] . ' and ' . $system['system_id'] . ' in sector ' . $sector_id . ']');
         }
         if ($system['system_x'] > $this->sector_map_split || $system['system_y'] > $this->sector_map_split) {
             message(GENERAL, 'Invalid starsystem coordinates ' . $system['system_x'] . ' | ' . $system['system_y'] . ' by system <i>' . $system['system_id'] . '</i> in sector <i>' . $sector_id . '</i>');
         }
         $star_color = imagecolorallocate($im, $system['system_starcolor_red'], $system['system_starcolor_green'], $system['system_starcolor_blue']);
         $star_size = (double) $system['system_starsize'];
         if ($star_size < $this->starsize_range[0] || $star_size > $this->starsize_range[1]) {
             message(GENERAL, 'Invalid starsize ' . $star_size . ' by system ' . $system['system_id'] . ' in sector ' . $sector_id);
         }
         $star_size *= 0.45;
         imagefilledellipse($im, $system['system_map_x'], $system['system_map_y'], $star_size, $star_size, $star_color);
         ////////////////// Calculate the distance in A.U. between the capital system and the target one
         if ($game->capital_system_id != $system['system_id']) {
             $distance = get_distance(array($game->capital_global_x, $game->capital_global_y), array($system['system_global_x'], $system['system_global_y']));
             $distance = round($distance, 2);
         } else {
             $distance = 0;
         }
         if ($distance > MAX_BOUND_RANGE) {
             $distance_str = ' ' . $this->str_range . $distance . ' A.U.<br>' . $this->str_outrange;
         } else {
             $distance_str = ' ' . $this->str_range . $distance . ' A.U.';
         }
         // DC Try to give more information, just for fun
         $explored_str = '';
         $sql = 'SELECT count(*) as explored FROM starsystems_details
                 WHERE system_id = ' . $system['system_id'] . '
                 AND user_id = ' . $game->player['user_id'];
         if ($res = $db->queryrow($sql)) {
             if ($res['explored'] == 0) {
                 $explored_str = '<br><i>' . $this->str_unch . '</i>';
             }
         }
         // DC Stringa Pianeti
         $planets_str = '';
         if ($res['explored'] == 0) {
             $planets_str = '<br>' . $this->str_planets . ' ' . $system['system_n_planets'];
         } else {
             $sql = 'SELECT p.planet_id, p.planet_distance_id, p.planet_name, p.planet_type, p.planet_owner, u.user_name, p.planet_points, pd.survey_1, pd.survey_2, pd.survey_3
                     FROM (planets p)
                     LEFT JOIN (user u) ON (u.user_id = p.planet_owner AND p.planet_owner > 0)
                     LEFT JOIN (planet_details pd) ON (pd.planet_id = p.planet_id AND pd.log_code = 100 AND pd.user_id = ' . $game->player['user_id'] . ')
                     WHERE p.system_id = ' . $system['system_id'] . '
                     ORDER BY p.planet_distance_id ASC';
             if ($plist = $db->queryrowset($sql)) {
                 $planets_str .= '<br>' . $this->str_planets;
                 foreach ($plist as $pitem) {
                     $planets_str .= '<br>' . ($pitem['planet_distance_id'] + 1) . ': ' . strtoupper($pitem['planet_type']);
                     if (isset($pitem['survey_1'])) {
                         $planets_str .= ' (';
                         switch ($pitem['survey_1']) {
                             case 0:
                                 $planets_str .= '<font color=red>-</font>|';
                                 break;
                             case 1:
                                 $planets_str .= '<font color=grey>=</font>|';
                                 break;
                             case 2:
                                 $planets_str .= '<font color=green>+</font>|';
                                 break;
                         }
                         switch ($pitem['survey_2']) {
                             case 0:
                                 $planets_str .= '<font color=red>-</font>|';
                                 break;
                             case 1:
                                 $planets_str .= '<font color=grey>=</font>|';
                                 break;
                             case 2:
                                 $planets_str .= '<font color=green>+</font>|';
                                 break;
                         }
                         switch ($pitem['survey_3']) {
                             case 0:
                                 $planets_str .= '<font color=red>-</font>';
                                 break;
                             case 1:
                                 $planets_str .= '<font color=grey>=</font>';
                                 break;
                             case 2:
                                 $planets_str .= '<font color=green>+</font>';
                                 break;
                         }
                         $planets_str .= ')';
                     }
                     $planets_str .= !empty($pitem['planet_owner']) ? ' &#34;' . htmlentities($pitem['planet_name']) . '&#34;' : ' <i>' . htmlentities($pitem['planet_name']) . '</i>';
                     if (!empty($pitem['planet_owner'])) {
                         $planets_str .= ' ' . htmlentities($pitem['user_name']) . ' (' . $pitem['planet_points'] . ' pt.)';
                     }
                     $fleet_sensor = false;
                     //Any fleet here?
                     $sql = 'SELECT sf.fleet_name, sf.n_ships FROM ship_fleets sf 
                             WHERE planet_id = ' . $pitem['planet_id'] . ' AND sf.user_id = ' . $game->player['user_id'];
                     if ($fleet_details = $db->queryrowset($sql)) {
                         $fleet_sensor = true;
                         foreach ($fleet_details as $f_i) {
                             $planets_str .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&#187;&nbsp;' . $this->str_fleet_player . ' <b>' . htmlentities($f_i['fleet_name']) . '</b>, ' . $f_i['n_ships'] . ' ' . $this->str_ships;
                         }
                     }
                     //Anu OTHER fleets here?
                     if (!empty($pitem['planet_owner']) && $pitem['planet_owner'] == $game->player['user_id'] || $fleet_sensor) {
                         $sql = 'SELECT user_name, SUM(n_ships) AS n_ships FROM ship_fleets INNER JOIN user USING (user_id) WHERE planet_id = ' . $pitem['planet_id'] . ' AND user_id <> ' . $game->player['user_id'] . ' GROUP BY user_id';
                         if ($flist = $db->queryrowset($sql)) {
                             foreach ($flist as $fitem) {
                                 $planets_str .= '<br>&nbsp;&nbsp;&nbsp;&#183;&#183;&#183;<b>' . $fitem['user_name'] . '</b>, ' . $fitem['n_ships'] . ' ' . $this->str_ships;
                             }
                         }
                     }
                 }
             }
         }
         $private_str = '';
         if (!empty($system['system_owner']) && $system['system_owner'] != $game->player['user_id']) {
             $private_str = '<br><i>' . $this->str_priv . '</i>';
         }
         // ----
         /////////////////
         $map_html .= '<area href="' . parse_link('a=tactical_cartography&system_id=' . encode_system_id($system['system_id'])) . '" shape="circle" coords="' . $system['system_map_x'] . ', ' . $system['system_map_y'] . ', ' . $star_size . '" onmouseover="return overlib(\'' . $system['system_name'] . $distance_str . $planets_str . $explored_str . $private_str . '\', CAPTION, \'' . $this->str_details . '\', WIDTH, 300, ' . OVERLIB_STANDARD . ');" onmouseout="return nd();">';
         $used_fields[$coord_id] = $system['system_id'];
     }
     imagepng($im, 'maps/images/cache/' . md5($game->player['user_id']) . '.png');
     imagedestroy($im);
     $map_html .= '</map>';
     return $map_html;
 }
示例#7
0
        $trow = $model->find($data['num']['tid']);
        $data['num']['fact_money'] = $trow['money'];
        //我的坐标
        $memLocModel = D('member_location');
        $memLocRow = $memLocModel->where("fromuser='******'fromuser'] . "'")->dataRow();
        //发布方若无经纬度,则默认为吴江市政府的坐标,我的坐标默认为0,0
        if (!$trow['latitude']) {
            $trow['latitude'] = 31.144744;
            $trow['longitude'] = 120.651331;
        }
        if (!$memLocRow['latitude']) {
            $memLocRow['latitude'] = 0;
            $memLocRow['longitude'] = 0;
        }
        //计算距离
        $data['info']['distance'] = get_distance($trow['latitude'], $trow['longitude'], $memLocRow['latitude'], $memLocRow['longitude']);
        //职位工作日期
        if ($trow['work_time']) {
            $tempWorkArr = explode(' ', $trow['work_time']);
            $data['info']['task_date'] = $tempWorkArr[0];
        }
        //同一个工作日不能报名两次
        $result1 = $signModel->where("is_valid!=2 and uid=" . $data['num']['uid'] . " and task_date='" . $tempWorkArr[0] . "'")->dataRow();
        if ($result1) {
            die('chongfu');
        }
        $res = $signModel->add($data);
        $res ? die('suc') : die('err');
    }
}
//评论
示例#8
0
     $inter_system = true;
 }
 if ($in_orb) {
     message(NOTICE, constant($game->sprache("TEXT13")));
 }
 if ($starter_atkptc && $free_planet) {
     message(NOTICE, constant($game->sprache("TEXT14")));
 }
 $distance = $velocity = 0;
 if ($game->player['user_auth_level'] == STGC_DEVELOPER) {
     $min_time = 1;
 } elseif ($inter_system) {
     $min_time = 6;
 } else {
     include_once 'include/libs/moves.php';
     $distance = get_distance(array($start_planet['system_global_x'], $start_planet['system_global_y']), array($dest_planet['system_global_x'], $dest_planet['system_global_y']));
     $velocity = warpf($max_warp_speed);
     $min_time = ceil($distance / $velocity / TICK_DURATION);
 }
 $cur_istardate = (int) str_replace('.', '', $game->config['stardate']);
 $min_istardate = $cur_istardate + $min_time;
 $des_istardate = $min_istardate;
 if ($des_istardate < $min_istardate) {
     message(NOTICE, constant($game->sprache("TEXT15")) . ' ' . ($game->config['stardate'] + $min_time / 10));
 }
 $move_time = $des_istardate - $cur_istardate;
 $sql = 'SELECT COUNT(ship_id) AS n_ships
         FROM ships
         WHERE fleet_id = ' . $fleet['fleet_id'];
 //IN ('.implode(',', $fleet_ids).')';
 if (($_nships = $db->queryrow($sql)) === false) {
示例#9
0
    function SendBorgFleet($ACTUAL_TICK, $fleet_id, $dest, $action = 46)
    {
        if ($action == 0) {
            $action = 11;
        }
        $sql = 'SELECT f.fleet_id, f.user_id, f.n_ships, f.planet_id AS start,
		           s1.system_id AS start_system_id, s1.system_global_x AS start_x, s1.system_global_y AS start_y,
		           s2.system_id AS dest_system_id, s2.system_global_x AS dest_x, s2.system_global_y AS dest_y
		    FROM (ship_fleets f)
		    INNER JOIN (planets p1) ON p1.planet_id = f.planet_id
		    INNER JOIN (starsystems s1) ON s1.system_id = p1.system_id
		    INNER JOIN (planets p2) ON p2.planet_id = ' . $dest . '
		    INNER JOIN (starsystems s2) ON s2.system_id = p2.system_id
		    WHERE f.fleet_id = ' . $fleet_id;
        if (($fleet = $this->db->queryrow($sql)) === false) {
            $this->sdl->log('Could not query fleet ' . $fleet_id . ' data', TICK_LOG_FILE_NPC);
            return false;
        }
        if (empty($fleet['fleet_id'])) {
            $this->sdl->log('Borg fleet for mission does not exist, already moving?', TICK_LOG_FILE_NPC);
            return false;
        }
        if ($fleet['start_system_id'] == $fleet['dest_system_id']) {
            $distance = $velocity = 0;
            $min_time = 6;
        } else {
            $distance = get_distance(array($fleet['start_x'], $fleet['start_y']), array($fleet['dest_x'], $fleet['dest_y']));
            $velocity = warpf(10);
            $min_time = ceil($distance / $velocity / TICK_DURATION);
        }
        if ($min_time < 1) {
            $min_time = 1;
        }
        $sql = 'INSERT INTO scheduler_shipmovement (user_id, move_status, move_exec_started, start, dest, total_distance, remaining_distance, tick_speed, move_begin, move_finish, n_ships, action_code, action_data)
		         VALUES (' . $fleet['user_id'] . ', 0, 0, ' . $fleet['start'] . ', ' . $dest . ', ' . $distance . ', ' . $distance . ', ' . $velocity * TICK_DURATION . ', ' . $ACTUAL_TICK . ', ' . ($ACTUAL_TICK + $min_time) . ', ' . $fleet['n_ships'] . ', ' . $action . ', "")';
        if (!$this->db->query($sql)) {
            $this->sdl->log('Could not insert new movement data', TICK_LOG_FILE_NPC);
            return false;
        }
        $new_move_id = $this->db->insert_id();
        if (empty($new_move_id)) {
            $this->sdl->log('Could not send Borg fleet $new_move_id = empty', TICK_LOG_FILE_NPC);
            return false;
        }
        if ($action == 46) {
            $sql = 'UPDATE ship_fleets SET planet_id = 0, move_id = ' . $new_move_id . ', npc_last_action = ' . ($ACTUAL_TICK + $min_time + 60) . ' WHERE fleet_id = ' . $fleet['fleet_id'];
        } else {
            $sql = 'UPDATE ship_fleets SET planet_id = 0, move_id = ' . $new_move_id . ' WHERE fleet_id = ' . $fleet['fleet_id'];
        }
        if (!$this->db->query($sql)) {
            $this->sdl->log('Could not update Borg fleet data', TICK_LOG_FILE_NPC);
            return false;
        }
        return true;
    }
示例#10
0
                case 'GER':
                    $log_title = 'Ferengisteuer';
                    break;
                case 'ITA':
                    $log_title = 'Tasse Ferengi';
                    break;
            }
            /* */
            add_logbook_entry($user['user_id'], LOGBOOK_FERENGITAX, $log_title, $log_data);
            $sdl->log('3');
            $res = $resource[0] + $resource[1] + $resource[2];
            $ships = ceil($res / MAX_TRANSPORT_RESOURCES);
            if (1 == $user['planet_system']) {
                $distance = 6;
            } else {
                $distance = get_distance(array(5, 7), array($user['system_global_x'], $user['system_global_y']));
                $velocity = warpf(6);
                $distance = ceil($distance / $velocity / TICK_DURATION);
            }
            $db->query('INSERT INTO scheduler_resourcetrade (planet,resource_1,resource_2,resource_3,arrival_time) VALUES ("' . $user['user_capital'] . '","' . $resource[0] . '","' . $resource[1] . '","' . $resource[2] . '","' . ($ACTUAL_TICK + $distance) . '")');
            //send_fake_transporter(array(FERENGI_TRADESHIP_ID=>$ships), FERENGI_USERID,5 ,$user['user_capital']);
            $sdl->log('4: ' . $distance);
            $sdl->log('5');
            $sdl->log('Paid ' . $user['user_name'] . ' (' . $user['user_id'] . ')!');
        }
    }
}
$sdl->finish_job('Ferengi Taxes');
// ########################################################################################
// ########################################################################################
// Remove old Resourcetrade
function display_ferengi_transfer($planet_id, $planet_system, $system_x, $system_y, $build_11)
{
    global $game, $db;
    $game->out('<br><br>
<table class="style_outer" width="400" align="center" border="0" cellpadding="2" cellspacing="2"><tr><td>
  <table class="style_inner" wisth0"400" align="center" border="0" cellpadding="2" cellspacing="2">');
    if ($game->option_retr('show_trade') == 0) {
        $game->out('
  <tr>
    <td><b>' . constant($game->sprache("TEXT15")) . '  <b>[<a href="' . parse_link('a=tactical_cartography&planet_id=' . $_GET['planet_id'] . '&strade=1') . '"><i>' . constant($game->sprache("TEXT16")) . '</i></a>]</b></td></tr>');
    } elseif ($build_11 < 1 || $game->planet['building_11'] < 1) {
        $game->out('
  <tr>
    <td><b>' . constant($game->sprache("TEXT15")) . '  <b>[<a href="' . parse_link('a=tactical_cartography&planet_id=' . $_GET['planet_id'] . '"&strade=0') . '"><i>' . constant($game->sprache("TEXT17")) . '</i></a>]</b><br><b><br>' . constant($game->sprache("TEXT18")) . '</b></td></tr>');
    } else {
        $game->out('
    <script language="JavaScript">
    function UpdateValues()
    {
    var i;
        var res_1=eval(document.tradeform.res_1.value);
        var res_2=eval(document.tradeform.res_2.value);
        var res_3=eval(document.tradeform.res_3.value);
        ');
        for ($x = 0; $x < 6; $x++) {
            $game->out('
        if (document.tradeform.unit_' . ($x + 1) . '.value>0)
        {
        res_1+=eval("' . UnitPrice($x, 0, $game->player['user_race']) . '")*eval(document.tradeform.unit_' . ($x + 1) . '.value);
        res_2+=eval("' . UnitPrice($x, 1, $game->player['user_race']) . '")*eval(document.tradeform.unit_' . ($x + 1) . '.value);
        res_3+=eval("' . UnitPrice($x, 2, $game->player['user_race']) . '")*eval(document.tradeform.unit_' . ($x + 1) . '.value);
        }
        ');
        }
        if ($game->planet['system_id'] == $planet_system) {
            $distance = 6;
        } else {
            $distance = get_distance(array($game->planet['system_global_x'], $game->planet['system_global_y']), array($system_x, $system_y));
            $velocity = warpf(6);
            $distance = ceil($distance / $velocity / TICK_DURATION);
        }
        $game->out('
        var ttax_set=' . (0.18 - 0.01 * $game->planet['building_11']) . ';
        document.getElementById( "res1" ).firstChild.nodeValue = Math.round(res_1*ttax_set);
        document.getElementById( "res2" ).firstChild.nodeValue = Math.round(res_2*ttax_set);
        document.getElementById( "res3" ).firstChild.nodeValue = Math.round(res_3*ttax_set);
        window.setTimeout( \'UpdateValues()\', 500 );
    }
    </script>

  <form name="tradeform" method="post" action="' . parse_link('a=tactical_cartography&planet_id=' . $_GET['planet_id']) . '">
  <tr>
    <td colspan=3 align="center"><b>' . constant($game->sprache("TEXT19")) . '<br>(' . constant($game->sprache("TEXT22")) . ' ' . Zeit($distance * TICK_DURATION) . ')</b><br><br>
    </td>
  </tr>
  <tr>
  <td><img src=' . $game->GFX_PATH . 'menu_metal_small.gif>&nbsp;&nbsp;&nbsp;<input class="field"  style="width: 60px;" type="text" name="res_1" value="0" onFocus="UpdateValues();">&nbsp&nbsp</td>
  <td><img src=' . $game->GFX_PATH . 'menu_unit1_small.gif>&nbsp;&nbsp;&nbsp;<input class="field"  style="width: 60px;" type="text" name="unit_1" value="0" onFocus="UpdateValues();">&nbsp&nbsp</td>
  <td><img src=' . $game->GFX_PATH . 'menu_unit4_small.gif>&nbsp;&nbsp;&nbsp;<input class="field"  style="width: 60px;" type="text" name="unit_4" value="0" onFocus="UpdateValues();">&nbsp&nbsp</td>
  </tr>

  <tr>
  <td><img src=' . $game->GFX_PATH . 'menu_mineral_small.gif>&nbsp;&nbsp;&nbsp;<input class="field"  style="width: 60px;" type="text" name="res_2" value="0" onFocus="UpdateValues();">&nbsp&nbsp</td>
  <td><img src=' . $game->GFX_PATH . 'menu_unit2_small.gif>&nbsp;&nbsp;&nbsp;<input class="field"  style="width: 60px;" type="text" name="unit_2" value="0" onFocus="UpdateValues();">&nbsp&nbsp</td>
  <td><img src=' . $game->GFX_PATH . 'menu_unit5_small.gif>&nbsp;&nbsp;&nbsp;<input class="field"  style="width: 60px;" type="text" name="unit_5" value="0" onFocus="UpdateValues();">&nbsp&nbsp</td>
  </tr>

  <tr>
  <td><img src=' . $game->GFX_PATH . 'menu_latinum_small.gif>&nbsp;&nbsp;&nbsp;<input class="field"  style="width: 60px;" type="text" name="res_3" value="0" onFocus="UpdateValues();">&nbsp&nbsp</td>
  <td><img src=' . $game->GFX_PATH . 'menu_unit3_small.gif>&nbsp;&nbsp;&nbsp;<input class="field"  style="width: 60px;" type="text" name="unit_3" value="0" onFocus="UpdateValues();">&nbsp&nbsp</td>
  <td><img src=' . $game->GFX_PATH . 'menu_unit6_small.gif>&nbsp;&nbsp;&nbsp;<input class="field"  style="width: 60px;" type="text" name="unit_6" value="0" onFocus="UpdateValues();">&nbsp&nbsp</td>
  </tr>
  <tr>
  <td colspan=3 align="center">
    <b>' . constant($game->sprache("TEXT20")) . '</b>
    <img src=' . $game->GFX_PATH . 'menu_metal_small.gif>&nbsp;&nbsp;&nbsp;<b id="res1">0</b>
    <img src=' . $game->GFX_PATH . 'menu_mineral_small.gif>&nbsp;&nbsp;&nbsp;<b id="res2">0</b>
    <img src=' . $game->GFX_PATH . 'menu_latinum_small.gif>&nbsp;&nbsp;&nbsp;<b id="res3">0</b>
  </td>
  </tr>
  <tr>
  <td colspan=3 align="center">
    <input class="button" type="submit" name="trade" value="' . constant($game->sprache("TEXT21")) . '"><br><br><b>
    [<a href="' . parse_link('a=tactical_cartography&planet_id=' . $_GET['planet_id'] . '&strade=0') . '"><i>' . constant($game->sprache("TEXT17")) . '</i></a>]</b>
  </td>
  </tr>
  </form>');
    }
    $game->out('</table></td></tr></table><br>');
}
示例#12
0
 function get_distance($s_system, $d_system)
 {
     include_once 'include/libs/moves.php';
     return get_distance($s_system, $d_system);
 }
示例#13
0

<body>


<?php 
//connect to DB
dbConnect('license');
$query = "SELECT * FROM `TABLE 2` WHERE category =" . "\"" . $_GET["category"] . "\"";
//echo $query;
$result = mysql_query($query);
$i = 0;
while ($resultbycat = mysql_fetch_assoc($result)) {
    //print_r($resultbycat);
    //calculate distance here and store project-distance-license in an array
    $distance = get_distance($resultbycat);
    //echo $distance."\n";
    $neighbours[$resultbycat["project"]] = $distance;
}
arsort($neighbours);
echo "<br/><br/>";
//print_r($neighbours);
$neighbours = array_slice($neighbours, 0, 5);
$neighbours = array_keys($neighbours);
echo "<br/><br/>";
//print_r($neighbours);
mysql_query("TRUNCATE TABLE `engine2`");
for ($i = 0; $i < count($neighbours); $i++) {
    $query = "SELECT * from `TABLE 2` where project=" . "\"" . $neighbours[$i] . "\"";
    //echo $query;
    $result = mysql_query($query);