function TargetEvent()
    {
        global $resource, $reslist;
        $db = Database::get();
        $fleetAttack = array();
        $fleetDefend = array();
        $userAttack = array();
        $userDefend = array();
        $incomingFleets = array();
        $stealResource = array(901 => 0, 902 => 0, 903 => 0);
        $debris = array();
        $planetDebris = array();
        $debrisResource = array(901, 902);
        $messageHTML = <<<HTML
<div class="raportMessage">
\t<table>
\t\t<tr>
\t\t\t<td colspan="2"><a href="game.php?page=raport&raport=%s" target="_blank"><span class="%s">%s %s (%s)</span></a></td>
\t\t</tr>
\t\t<tr>
\t\t\t<td>%s</td><td><span class="%s">%s: %s</span>&nbsp;<span class="%s">%s: %s</span></td>
\t\t</tr>
\t\t<tr>
\t\t\t<td>%s</td><td><span>%s:&nbsp;<span class="reportSteal element901">%s</span>&nbsp;</span><span>%s:&nbsp;<span class="reportSteal element902">%s</span>&nbsp;</span><span>%s:&nbsp;<span class="reportSteal element903">%s</span></span></td>
\t\t</tr>
\t\t<tr>
\t\t\t<td>%s</td><td><span>%s:&nbsp;<span class="reportDebris element901">%s</span>&nbsp;</span><span>%s:&nbsp;<span class="reportDebris element902">%s</span></span></td>
\t\t</tr>
\t</table>
</div>
HTML;
        //Minize HTML
        $messageHTML = str_replace(array("\n", "\t", "\r"), "", $messageHTML);
        $sql = "SELECT * FROM %%PLANETS%% WHERE id = :planetId;";
        $targetPlanet = $db->selectSingle($sql, array(':planetId' => $this->_fleet['fleet_end_id']));
        $sql = "SELECT * FROM %%USERS%% WHERE id = :userId;";
        $targetUser = $db->selectSingle($sql, array(':userId' => $targetPlanet['id_owner']));
        $targetUser['factor'] = getFactors($targetUser, 'basic', $this->_fleet['fleet_start_time']);
        $planetUpdater = new ResourceUpdate();
        list($targetUser, $targetPlanet) = $planetUpdater->CalcResource($targetUser, $targetPlanet, true, $this->_fleet['fleet_start_time']);
        if ($this->_fleet['fleet_group'] != 0) {
            $sql = "DELETE FROM %%AKS%% WHERE id = :acsId;";
            $db->delete($sql, array(':acsId' => $this->_fleet['fleet_group']));
            $sql = "SELECT * FROM %%FLEETS%% WHERE fleet_group = :acsId;";
            $incomingFleetsResult = $db->select($sql, array(':acsId' => $this->_fleet['fleet_group']));
            foreach ($incomingFleetsResult as $incomingFleetRow) {
                $incomingFleets[$incomingFleetRow['fleet_id']] = $incomingFleetRow;
            }
            unset($incomingFleetsResult);
        } else {
            $incomingFleets = array($this->_fleet['fleet_id'] => $this->_fleet);
        }
        foreach ($incomingFleets as $fleetID => $fleetDetail) {
            $sql = "SELECT * FROM %%USERS%% WHERE id = :userId;";
            $fleetAttack[$fleetID]['player'] = $db->selectSingle($sql, array(':userId' => $fleetDetail['fleet_owner']));
            $fleetAttack[$fleetID]['player']['factor'] = getFactors($fleetAttack[$fleetID]['player'], 'attack', $this->_fleet['fleet_start_time']);
            $fleetAttack[$fleetID]['fleetDetail'] = $fleetDetail;
            $fleetAttack[$fleetID]['unit'] = FleetFunctions::unserialize($fleetDetail['fleet_array']);
            $userAttack[$fleetAttack[$fleetID]['player']['id']] = $fleetAttack[$fleetID]['player']['username'];
        }
        $sql = "SELECT * FROM %%FLEETS%%\n\t\tWHERE fleet_mission\t\t= :mission\n\t\tAND fleet_end_id\t\t= :fleetEndId\n\t\tAND fleet_start_time \t<= :timeStamp\n\t\tAND fleet_end_stay \t\t>= :timeStamp;";
        $targetFleetsResult = $db->select($sql, array(':mission' => 5, ':fleetEndId' => $this->_fleet['fleet_end_id'], ':timeStamp' => TIMESTAMP));
        foreach ($targetFleetsResult as $fleetDetail) {
            $fleetID = $fleetDetail['fleet_id'];
            $sql = "SELECT * FROM %%USERS%% WHERE id = :userId;";
            $fleetDefend[$fleetID]['player'] = $db->selectSingle($sql, array(':userId' => $fleetDetail['fleet_owner']));
            $fleetDefend[$fleetID]['player']['factor'] = getFactors($fleetDefend[$fleetID]['player'], 'attack', $this->_fleet['fleet_start_time']);
            $fleetDefend[$fleetID]['fleetDetail'] = $fleetDetail;
            $fleetDefend[$fleetID]['unit'] = FleetFunctions::unserialize($fleetDetail['fleet_array']);
            $userDefend[$fleetDefend[$fleetID]['player']['id']] = $fleetDefend[$fleetID]['player']['username'];
        }
        unset($targetFleetsResult);
        $fleetDefend[0]['player'] = $targetUser;
        $fleetDefend[0]['player']['factor'] = getFactors($fleetDefend[0]['player'], 'attack', $this->_fleet['fleet_start_time']);
        $fleetDefend[0]['fleetDetail'] = array('fleet_start_galaxy' => $targetPlanet['galaxy'], 'fleet_start_system' => $targetPlanet['system'], 'fleet_start_planet' => $targetPlanet['planet'], 'fleet_start_type' => $targetPlanet['planet_type']);
        $fleetDefend[0]['unit'] = array();
        foreach (array_merge($reslist['fleet'], $reslist['defense']) as $elementID) {
            if (empty($targetPlanet[$resource[$elementID]])) {
                continue;
            }
            $fleetDefend[0]['unit'][$elementID] = $targetPlanet[$resource[$elementID]];
        }
        $userDefend[$fleetDefend[0]['player']['id']] = $fleetDefend[0]['player']['username'];
        require_once 'includes/classes/missions/functions/calculateAttack.php';
        $fleetIntoDebris = Config::get($this->_fleet['fleet_universe'])->Fleet_Cdr;
        $defIntoDebris = Config::get($this->_fleet['fleet_universe'])->Defs_Cdr;
        $combatResult = calculateAttack($fleetAttack, $fleetDefend, $fleetIntoDebris, $defIntoDebris);
        foreach ($fleetAttack as $fleetID => $fleetDetail) {
            $fleetArray = '';
            $totalCount = 0;
            $fleetDetail['unit'] = array_filter($fleetDetail['unit']);
            foreach ($fleetDetail['unit'] as $elementID => $amount) {
                $fleetArray .= $elementID . ',' . floattostring($amount) . ';';
                $totalCount += $amount;
            }
            if ($totalCount == 0) {
                if ($this->_fleet['fleet_id'] == $fleetID) {
                    $this->KillFleet();
                } else {
                    $sql = 'DELETE %%FLEETS%%, %%FLEETS_EVENT%%
					FROM %%FLEETS%%
					INNER JOIN %%FLEETS_EVENT%% ON fleetID = fleet_id
					WHERE fleet_id = :fleetId;';
                    $db->delete($sql, array(':fleetId' => $fleetID));
                }
                $sql = 'UPDATE %%LOG_FLEETS%% SET fleet_state = :fleetState WHERE fleet_id = :fleetId;';
                $db->update($sql, array(':fleetId' => $fleetID, ':fleetState' => FLEET_HOLD));
                unset($fleetAttack[$fleetID]);
            } elseif ($totalCount > 0) {
                $sql = "UPDATE %%FLEETS%% fleet, %%LOG_FLEETS%% log SET\n\t\t\t\tfleet.fleet_array\t= :fleetData,\n\t\t\t\tfleet.fleet_amount\t= :fleetCount,\n\t\t\t\tlog.fleet_array\t\t= :fleetData,\n\t\t\t\tlog.fleet_amount\t= :fleetCount\n\t\t\t\tWHERE log.fleet_id = :fleetId AND log.fleet_id = :fleetId;";
                $db->update($sql, array(':fleetData' => substr($fleetArray, 0, -1), ':fleetCount' => $totalCount, ':fleetId' => $fleetID));
            } else {
                throw new OutOfRangeException("Negative Fleet amount ....");
            }
        }
        foreach ($fleetDefend as $fleetID => $fleetDetail) {
            if ($fleetID != 0) {
                // Stay fleet
                $fleetArray = '';
                $totalCount = 0;
                $fleetDetail['unit'] = array_filter($fleetDetail['unit']);
                foreach ($fleetDetail['unit'] as $elementID => $amount) {
                    $fleetArray .= $elementID . ',' . floattostring($amount) . ';';
                    $totalCount += $amount;
                }
                if ($totalCount == 0) {
                    $sql = 'DELETE %%FLEETS%%, %%FLEETS_EVENT%%
					FROM %%FLEETS%%
					INNER JOIN %%FLEETS_EVENT%% ON fleetID = fleet_id
					WHERE fleet_id = :fleetId;';
                    $db->delete($sql, array(':fleetId' => $fleetID));
                    $sql = 'UPDATE %%LOG_FLEETS%% SET fleet_state = :fleetState WHERE fleet_id = :fleetId;';
                    $db->update($sql, array(':fleetId' => $fleetID, ':fleetState' => FLEET_HOLD));
                    unset($fleetAttack[$fleetID]);
                } elseif ($totalCount > 0) {
                    $sql = "UPDATE %%FLEETS%% fleet, %%LOG_FLEETS%% log SET\n\t\t\t\t\tfleet.fleet_array\t= :fleetData,\n\t\t\t\t\tfleet.fleet_amount\t= :fleetCount,\n\t\t\t\t\tlog.fleet_array\t\t= :fleetData,\n\t\t\t\t\tlog.fleet_amount\t= :fleetCount\n\t\t\t\t\tWHERE log.fleet_id = :fleetId AND log.fleet_id = :fleetId;";
                    $db->update($sql, array(':fleetData' => substr($fleetArray, 0, -1), ':fleetCount' => $totalCount, ':fleetId' => $fleetID));
                } else {
                    throw new OutOfRangeException("Negative Fleet amount ....");
                }
            } else {
                $params = array(':planetId' => $this->_fleet['fleet_end_id']);
                // Planet fleet
                $fleetArray = array();
                foreach ($fleetDetail['unit'] as $elementID => $amount) {
                    $fleetArray[] = '`' . $resource[$elementID] . '` = :' . $resource[$elementID];
                    $params[':' . $resource[$elementID]] = $amount;
                }
                if (!empty($fleetArray)) {
                    $sql = 'UPDATE %%PLANETS%% SET ' . implode(', ', $fleetArray) . ' WHERE id = :planetId;';
                    $db->update($sql, $params);
                }
            }
        }
        if ($combatResult['won'] == "a") {
            require_once 'includes/classes/missions/functions/calculateSteal.php';
            $stealResource = calculateSteal($fleetAttack, $targetPlanet);
        }
        if ($this->_fleet['fleet_end_type'] == 3) {
            // Use planet debris, if attack on moons
            $sql = "SELECT der_metal, der_crystal FROM %%PLANETS%% WHERE id_luna = :moonId;";
            $targetDebris = $db->selectSingle($sql, array(':moonId' => $this->_fleet['fleet_end_id']));
            $targetPlanet += $targetDebris;
        }
        foreach ($debrisResource as $elementID) {
            $debris[$elementID] = $combatResult['debris']['attacker'][$elementID] + $combatResult['debris']['defender'][$elementID];
            $planetDebris[$elementID] = $targetPlanet['der_' . $resource[$elementID]] + $debris[$elementID];
        }
        $reportInfo = array('thisFleet' => $this->_fleet, 'debris' => $debris, 'stealResource' => $stealResource, 'moonChance' => NULL, 'moonDestroy' => true, 'moonName' => NULL, 'moonDestroyChance' => NULL, 'moonDestroySuccess' => NULL, 'fleetDestroyChance' => NULL, 'fleetDestroySuccess' => false);
        switch ($combatResult['won']) {
            case "a":
                $moonDestroyChance = round((100 - sqrt($targetPlanet['diameter'])) * sqrt($fleetAttack[$this->_fleet['fleet_id']]['unit'][214]), 1);
                // Max 100% | Min 0%
                $moonDestroyChance = min($moonDestroyChance, 100);
                $moonDestroyChance = max($moonDestroyChance, 0);
                $randChance = mt_rand(1, 100);
                if ($randChance <= $moonDestroyChance) {
                    $sql = 'SELECT id FROM %%PLANETS%% WHERE id_luna = :moonId;';
                    $planetID = $db->selectSingle($sql, array(':moonId' => $targetPlanet['id']), 'id');
                    $sql = 'UPDATE %%FLEETS%% SET
					fleet_start_type		= 1,
					fleet_start_id			= :planetId
					WHERE fleet_start_id	= :moonId;';
                    $db->update($sql, array(':planetId' => $planetID, ':moonId' => $targetPlanet['id']));
                    $sql = 'UPDATE %%FLEETS%% SET
					fleet_end_type	= 1,
					fleet_end_id	= :moonId,
					fleet_mission	= IF(fleet_mission = 9, 1, fleet_mission)
					WHERE fleet_end_id = :planetId
					AND fleet_id != :fleetId;';
                    $db->update($sql, array(':planetId' => $planetID, ':moonId' => $targetPlanet['id'], ':fleetId' => $this->_fleet['fleet_id']));
                    $sql = "UPDATE %%AKS%% SET target = :planetId WHERE target = :moonId;";
                    $db->update($sql, array(':planetId' => $planetID, ':moonId' => $targetPlanet['id']));
                    PlayerUtil::deletePlanet($targetPlanet['id']);
                    $reportInfo['moonDestroySuccess'] = 1;
                } else {
                    $reportInfo['moonDestroySuccess'] = 0;
                }
                $fleetDestroyChance = round(sqrt($targetPlanet['diameter']) / 2);
                $randChance = mt_rand(1, 100);
                if ($randChance <= $fleetDestroyChance) {
                    $this->KillFleet();
                    $reportInfo['fleetDestroySuccess'] = true;
                } else {
                    $reportInfo['fleetDestroySuccess'] = false;
                }
                $reportInfo['moonDestroyChance'] = $moonDestroyChance;
                $reportInfo['fleetDestroyChance'] = $fleetDestroyChance;
                // Win
                $attackStatus = 'wons';
                $defendStatus = 'loos';
                $class = array('raportWin', 'raportLose');
                break;
            case "r":
                // Lose
                $attackStatus = 'loos';
                $defendStatus = 'wons';
                $class = array('raportLose', 'raportWin');
                $reportInfo['moonDestroySuccess'] = -1;
                break;
            default:
                // Draw
                $attackStatus = 'draws';
                $defendStatus = 'draws';
                $class = array('raportDraw', 'raportDraw');
                $reportInfo['moonDestroySuccess'] = -1;
                break;
        }
        require_once 'includes/classes/missions/functions/GenerateReport.php';
        $reportData = GenerateReport($combatResult, $reportInfo);
        $reportID = md5(uniqid('', true) . TIMESTAMP);
        $sql = 'INSERT INTO %%RW%% SET
		rid 		= :reportId,
		raport 		= :reportData,
		time 		= :time,
		attacker	= :attackers,
		defender	= :defenders;';
        $db->insert($sql, array(':reportId' => $reportID, ':reportData' => serialize($reportData), ':time' => $this->_fleet['fleet_start_time'], ':attackers' => implode(',', array_keys($userAttack)), ':defenders' => implode(',', array_keys($userDefend))));
        $i = 0;
        foreach (array($userAttack, $userDefend) as $data) {
            $thisClass = $class[$i];
            foreach ($data as $userID => $userName) {
                $LNG = $this->getLanguage(NULL, $userID);
                $message = sprintf($messageHTML, $reportID, $thisClass[$i], $LNG['sys_mess_attack_report'], sprintf($LNG['sys_adress_planet'], $this->_fleet['fleet_end_galaxy'], $this->_fleet['fleet_end_system'], $this->_fleet['fleet_end_planet']), $LNG['type_planet_short'][$this->_fleet['fleet_end_type']], $LNG['sys_lost'], $thisClass[0], $LNG['sys_attack_attacker_pos'], pretty_number($combatResult['unitLost']['attacker']), $thisClass[1], $LNG['sys_attack_defender_pos'], pretty_number($combatResult['unitLost']['defender']), $LNG['sys_gain'], $LNG['tech'][901], pretty_number($stealResource[901]), $LNG['tech'][902], pretty_number($stealResource[902]), $LNG['tech'][903], pretty_number($stealResource[903]), $LNG['sys_debris'], $LNG['tech'][901], pretty_number($debris[901]), $LNG['tech'][902], pretty_number($debris[902]));
                PlayerUtil::sendMessage($userID, 0, $LNG['sys_mess_tower'], 3, $LNG['sys_mess_attack_report'], $message, $this->_fleet['fleet_start_time'], NULL, 1, $this->_fleet['fleet_universe']);
                $sql = "INSERT INTO %%TOPKB_USERS%% SET\n\t\t\t\trid\t\t\t= :reportId,\n\t\t\t\trole\t\t= :userRole,\n\t\t\t\tusername\t= :username,\n\t\t\t\tuid\t\t\t= :userId;";
                $db->insert($sql, array(':reportId' => $reportID, ':userRole' => 1, ':username' => $userName, ':userId' => $userID));
            }
            $i++;
        }
        if ($this->_fleet['fleet_end_type'] == 3) {
            $debrisType = 'id_luna';
        } else {
            $debrisType = 'id';
        }
        $sql = 'UPDATE %%PLANETS%% SET
		der_metal	= :metal,
		der_crystal	= :crystal
		WHERE ' . $debrisType . ' = :planetId;';
        $db->update($sql, array(':metal' => $planetDebris[901], ':crystal' => $planetDebris[902], ':planetId' => $this->_fleet['fleet_end_id']));
        $sql = 'UPDATE %%PLANETS%% SET
		metal		= metal - :metal,
		crystal		= crystal - :crystal,
		deuterium	= deuterium - :deuterium
		WHERE id = :planetId;';
        $db->update($sql, array(':metal' => $stealResource[901], ':crystal' => $stealResource[902], ':deuterium' => $stealResource[903], ':planetId' => $this->_fleet['fleet_end_id']));
        $sql = 'INSERT INTO %%TOPKB%% SET
		units 		= :units,
		rid			= :reportId,
		time		= :time,
		universe	= :universe,
		result		= :result;';
        $db->insert($sql, array(':units' => $combatResult['unitLost']['attacker'] + $combatResult['unitLost']['defender'], ':reportId' => $reportID, ':time' => $this->_fleet['fleet_start_time'], ':universe' => $this->_fleet['fleet_universe'], ':result' => $combatResult['won']));
        $sql = 'UPDATE %%USERS%% SET
		`' . $attackStatus . '` = `' . $attackStatus . '` + 1,
		kbmetal		= kbmetal + :debrisMetal,
		kbcrystal	= kbcrystal + :debrisCrystal,
		lostunits	= lostunits + :lostUnits,
		desunits	= desunits + :destroyedUnits
		WHERE id IN (' . implode(',', array_keys($userAttack)) . ');';
        $db->update($sql, array(':debrisMetal' => $debris[901], ':debrisCrystal' => $debris[902], ':lostUnits' => $combatResult['unitLost']['attacker'], ':destroyedUnits' => $combatResult['unitLost']['defender']));
        $sql = 'UPDATE %%USERS%% SET
		`' . $defendStatus . '` = `' . $defendStatus . '` + 1,
		kbmetal		= kbmetal + :debrisMetal,
		kbcrystal	= kbcrystal + :debrisCrystal,
		lostunits	= lostunits + :lostUnits,
		desunits	= desunits + :destroyedUnits
		WHERE id IN (' . implode(',', array_keys($userDefend)) . ');';
        $db->update($sql, array(':debrisMetal' => $debris[901], ':debrisCrystal' => $debris[902], ':lostUnits' => $combatResult['unitLost']['defender'], ':destroyedUnits' => $combatResult['unitLost']['attacker']));
        $this->setState(FLEET_RETURN);
        $this->SaveFleet();
    }
Esempio n. 2
0
function ShowSearchPage()
{
    global $LNG, $USER;
    if ($_GET['delete'] == 'user') {
        PlayerUtil::deletePlayer((int) $_GET['user']);
        message($LNG['se_delete_succes_p'], '?page=search&search=users&minimize=on', 2);
    } elseif ($_GET['delete'] == 'planet') {
        PlayerUtil::deletePlanet((int) $_GET['planet']);
        message($LNG['se_delete_succes_p'], '?page=search&search=planet&minimize=on', 2);
    }
    $SearchFile = HTTP::_GP('search', '');
    $SearchFor = HTTP::_GP('search_in', '');
    $SearchMethod = HTTP::_GP('fuki', '');
    $SearchKey = HTTP::_GP('key_user', '', UTF8_SUPPORT);
    $Page = HTTP::_GP('side', 0);
    $Order = HTTP::_GP('key_order', '');
    $OrderBY = HTTP::_GP('key_acc', '');
    $limit = HTTP::_GP('limit', 25);
    $Selector = array('list' => array('users' => $LNG['se_users'], 'planet' => $LNG['se_planets'], 'moon' => $LNG['se_moons'], 'alliance' => $LNG['se_allys'], 'vacation' => $LNG['se_vacations'], 'banned' => $LNG['se_suspended'], 'admin' => $LNG['se_authlevels'], 'inactives' => $LNG['se_inactives'], 'online' => $LNG['online_users'], 'p_connect' => $LNG['se_planets_act']), 'search' => array('name' => $LNG['se_input_name'], 'id' => $LNG['input_id']), 'filter' => array('normal' => $LNG['se_type_all'], 'exacto' => $LNG['se_type_exact'], 'last' => $LNG['se_type_last'], 'first' => $LNG['se_type_first']), 'order' => array('ASC' => $LNG['se_input_asc'], 'DESC' => $LNG['se_input_desc']), 'limit' => array('1' => '1', '5' => '5', '10' => '10', '15' => '15', '20' => '20', '25' => '25', '50' => '50', '100' => '100', '200' => '200', '500' => '500'));
    $template = new template();
    if (HTTP::_GP('minimize', '') == 'on') {
        $Minimize = "&amp;minimize=on";
        $template->assign_vars(array('minimize' => 'checked = "checked"', 'diisplaay' => 'style="display:none;"'));
    }
    switch ($SearchMethod) {
        case 'exacto':
            $SpecifyWhere = "= '" . $GLOBALS['DATABASE']->sql_escape($SearchKey) . "'";
            break;
        case 'last':
            $SpecifyWhere = "LIKE '" . $GLOBALS['DATABASE']->sql_escape($SearchKey, true) . "%'";
            break;
        case 'first':
            $SpecifyWhere = "LIKE '%" . $GLOBALS['DATABASE']->sql_escape($SearchKey, true) . "'";
            break;
        default:
            $SpecifyWhere = "LIKE '%" . $GLOBALS['DATABASE']->sql_escape($SearchKey, true) . "%'";
            break;
    }
    if (!empty($SearchFile)) {
        $ArrayUsers = array("users", "vacation", "admin", "inactives", "online");
        $ArrayPlanets = array("planet", "moon", "p_connect");
        $ArrayBanned = array("banned");
        $ArrayAlliance = array("alliance");
        if (in_array($SearchFile, $ArrayUsers)) {
            $Table = "users";
            $NameLang = $LNG['se_search_users'];
            $SpecifyItems = "id,username,email_2,onlinetime,register_time,user_lastip,authlevel,bana,urlaubs_modus";
            $SName = $LNG['se_input_userss'];
            $SpecialSpecify = "";
            if ($SearchFile == "vacation") {
                $SpecialSpecify = "AND urlaubs_modus = '1'";
                $SName = $LNG['se_input_vacatii'];
            }
            if ($SearchFile == "online") {
                $SpecialSpecify = "AND onlinetime >= '" . (TIMESTAMP - 15 * 60) . "'";
                $SName = $LNG['se_input_connect'];
            }
            if ($SearchFile == "inactives") {
                $SpecialSpecify = "AND onlinetime < '" . (TIMESTAMP - 60 * 60 * 24 * 7) . "'";
                $SName = $LNG['se_input_inact'];
            }
            if ($SearchFile == "admin") {
                $SpecialSpecify = "AND authlevel <= '" . $USER['authlevel'] . "' AND authlevel > '0'";
                $SName = $LNG['se_input_admm'];
            }
            $SpecialSpecify .= " AND universe = '" . Universe::getEmulated() . "'";
            $SearchFor == "name" ? $WhereItem = "WHERE username" : ($WhereItem = "WHERE id");
            $ArrayOSec = array("id", "username", "email_2", "onlinetime", "register_time", "user_lastip", "authlevel", "bana", "urlaubs_modus");
            $Array0SecCount = count($ArrayOSec);
            for ($OrderNum = 0; $OrderNum < $Array0SecCount; $OrderNum++) {
                $OrderBYParse[$ArrayOSec[$OrderNum]] = $LNG['se_search_users'][$OrderNum];
            }
        } elseif (in_array($SearchFile, $ArrayPlanets)) {
            $Table = "planets p";
            $TableUsers = "2";
            $NameLang = $LNG['se_search_planets'];
            $SpecifyItems = "p.id,p.name,CONCAT(u.username, ' (ID:&nbsp;', p.id_owner, ')'),p.last_update,p.galaxy,p.system,p.planet,p.id_luna";
            if ($SearchFile == "planet") {
                $SpecialSpecify = "AND planet_type = '1'";
                $SName = $LNG['se_input_planett'];
            } elseif ($SearchFile == "moon") {
                $SpecialSpecify = "AND planet_type = '3'";
                $SName = $LNG['se_input_moonn'];
            } elseif ($SearchFile == "p_connect") {
                $SpecialSpecify = "AND last_update >= " . (TIMESTAMP - 60 * 60) . "";
                $SName = $LNG['se_input_act_pla'];
            }
            $SpecialSpecify .= " AND p.universe = " . Universe::getEmulated();
            $WhereItem = "LEFT JOIN " . USERS . " u ON u.id = p.id_owner ";
            if ($SearchFor == "name") {
                $WhereItem .= "WHERE p.name";
            } else {
                $WhereItem .= "WHERE p.id";
            }
            $ArrayOSec = array("id", "name", "id_owner", "id_luna", "last_update", "galaxy", "system", "planet");
            $Array0SecCount = count($ArrayOSec);
            for ($OrderNum = 0; $OrderNum < $Array0SecCount; $OrderNum++) {
                $OrderBYParse[$ArrayOSec[$OrderNum]] = $LNG['se_search_planets'][$OrderNum];
            }
        } elseif (in_array($SearchFile, $ArrayBanned)) {
            $Table = "banned";
            $NameLang = $LNG['se_search_banned'];
            $SpecifyItems = "id,who,time,longer,theme,author";
            $SName = $LNG['se_input_susss'];
            $SpecialSpecify = " AND universe = '" . Universe::getEmulated() . "'";
            $SearchFor == "name" ? $WhereItem = "WHERE who" : ($WhereItem = "WHERE id");
            $ArrayOSec = array("id", "who", "time", "longer", "theme", "author");
            $Array0SecCount = count($ArrayOSec);
            for ($OrderNum = 0; $OrderNum < $Array0SecCount; $OrderNum++) {
                $OrderBYParse[$ArrayOSec[$OrderNum]] = $LNG['se_search_banned'][$OrderNum];
            }
        } elseif (in_array($SearchFile, $ArrayAlliance)) {
            $Table = "alliance";
            $NameLang = $LNG['se_search_alliance'];
            $SpecifyItems = "id,ally_name,ally_tag,ally_owner,ally_register_time,ally_members";
            $SName = $LNG['se_input_allyy'];
            $SpecialSpecify = " AND ally_universe = '" . Universe::getEmulated() . "'";
            $SearchFor == "name" ? $WhereItem = "WHERE ally_name" : ($WhereItem = "WHERE id");
            $ArrayOSec = array("id", "ally_name", "ally_tag", "ally_owner", "ally_register_time", "ally_members");
            $Array0SecCount = count($ArrayOSec);
            for ($OrderNum = 0; $OrderNum < $Array0SecCount; $OrderNum++) {
                $OrderBYParse[$ArrayOSec[$OrderNum]] = $LNG['se_search_alliance'][$OrderNum];
            }
        }
        $RESULT = MyCrazyLittleSearch($SpecifyItems, $WhereItem, $SpecifyWhere, $SpecialSpecify, $Order, $OrderBY, $limit, $Table, $Page, $NameLang, $ArrayOSec, $Minimize, $SName, $SearchFile);
    }
    $template->assign_vars(array('Selector' => $Selector, 'limit' => $limit, 'search' => $SearchKey, 'SearchFile' => $SearchFile, 'SearchFor' => $SearchFor, 'SearchMethod' => $SearchMethod, 'Order' => $Order, 'OrderBY' => $OrderBY, 'OrderBYParse' => $OrderBYParse, 'se_search' => $LNG['se_search'], 'se_limit' => $LNG['se_limit'], 'se_asc_desc' => $LNG['se_asc_desc'], 'se_filter_title' => $LNG['se_filter_title'], 'se_search_in' => $LNG['se_search_in'], 'se_type_typee' => $LNG['se_type_typee'], 'se_intro' => $LNG['se_intro'], 'se_search_title' => $LNG['se_search_title'], 'se_contrac' => $LNG['se_contrac'], 'se_search_order' => $LNG['se_search_order'], 'ac_minimize_maximize' => $LNG['ac_minimize_maximize'], 'LIST' => $RESULT['LIST'], 'PAGES' => $RESULT['PAGES']));
    $template->show('SearchPage.tpl');
}