コード例 #1
0
ファイル: traderoute.php プロジェクト: kagetenshi/xenoberage
function traderoute_check_compatible($type1, $type2, $move, $circuit, $src, $dest)
{
    global $playerinfo;
    global $l_tdr_nowlink1, $l_tdr_nowlink2, $l_tdr_sportissrc, $l_tdr_notownplanet, $l_tdr_planetisdest;
    global $l_tdr_samecom, $l_tdr_sportcom, $color_line1, $color_line2, $color_header, $servertimezone;
    global $db;
    global $db_logging;
    // Check circuit compatibility (we only use types 1 and 2 so block anything else)
    if ($circuit != "1" && $circuit != "2") {
        AdminLog::writeLog($db, LOG_RAW, "{$playerinfo['ship_id']}|Tried to use an invalid circuit_type of '{$circuit}', This is normally a result from using an external page and should be banned.");
        traderoute_die("Invalid Circuit type!<br>*** Possible Exploit has been reported to the admin. ***");
    }
    // Check warp links compatibility
    if ($move == 'warp') {
        $query = $db->Execute("SELECT link_id FROM {$db->prefix}links WHERE link_start=? AND link_dest=?;", array($src['sector_id'], $dest['sector_id']));
        db_op_result($db, $query, __LINE__, __FILE__, $db_logging);
        if ($query->EOF) {
            $l_tdr_nowlink1 = str_replace("[tdr_src_sector_id]", $src['sector_id'], $l_tdr_nowlink1);
            $l_tdr_nowlink1 = str_replace("[tdr_dest_sector_id]", $dest['sector_id'], $l_tdr_nowlink1);
            traderoute_die($l_tdr_nowlink1);
        }
        if ($circuit == '2') {
            $query = $db->Execute("SELECT link_id FROM {$db->prefix}links WHERE link_start=? AND link_dest=?;", array($dest['sector_id'], $src['sector_id']));
            db_op_result($db, $query, __LINE__, __FILE__, $db_logging);
            if ($query->EOF) {
                $l_tdr_nowlink2 = str_replace("[tdr_src_sector_id]", $src['sector_id'], $l_tdr_nowlink2);
                $l_tdr_nowlink2 = str_replace("[tdr_dest_sector_id]", $dest['sector_id'], $l_tdr_nowlink2);
                traderoute_die($l_tdr_nowlink2);
            }
        }
    }
    // Check ports compatibility
    if ($type1 == 'port') {
        if ($src['port_type'] == 'special') {
            if ($type2 != 'planet' && $type2 != 'corp_planet') {
                traderoute_die($l_tdr_sportissrc);
            }
            if ($dest['owner'] != $playerinfo['ship_id'] && ($dest['corp'] == 0 || $dest['corp'] != $playerinfo['team'])) {
                traderoute_die($l_tdr_notownplanet);
            }
        } else {
            if ($type2 == 'planet') {
                traderoute_die($l_tdr_planetisdest);
            }
            if ($src['port_type'] == $dest['port_type']) {
                traderoute_die($l_tdr_samecom);
            }
        }
    } else {
        if (array_key_exists('port_type', $dest) == true && $dest['port_type'] == 'special') {
            traderoute_die($l_tdr_sportcom);
        }
    }
}