Ejemplo n.º 1
0
 function show()
 {
     global $USER, $LNG;
     $order = HTTP::_GP('order', 'units');
     $sort = HTTP::_GP('sort', 'desc');
     $sort = strtoupper($sort) === "DESC" ? "DESC" : "ASC";
     switch ($order) {
         case 'date':
             $key = '%%TOPKB%%.time ' . $sort;
             break;
         case 'units':
         default:
             $key = '%%TOPKB%%.units ' . $sort;
             break;
     }
     $db = Database::get();
     $sql = "SELECT *, (\n\t\t\tSELECT DISTINCT\n\t\t\tIF(%%TOPKB_USERS%%.username = '', GROUP_CONCAT(%%USERS%%.username SEPARATOR ' & '), GROUP_CONCAT(%%TOPKB_USERS%%.username SEPARATOR ' & '))\n\t\t\tFROM %%TOPKB_USERS%%\n\t\t\tLEFT JOIN %%USERS%% ON uid = %%USERS%%.id\n\t\t\tWHERE %%TOPKB_USERS%%.rid = %%TOPKB%%.rid AND role = 1\n\t\t) as attacker,\n\t\t(\n\t\t\tSELECT DISTINCT\n\t\t\tIF(%%TOPKB_USERS%%.username = '', GROUP_CONCAT(%%USERS%%.username SEPARATOR ' & '), GROUP_CONCAT(%%TOPKB_USERS%%.username SEPARATOR ' & '))\n\t\t\tFROM %%TOPKB_USERS%% INNER JOIN %%USERS%% ON uid = id\n\t\t\tWHERE %%TOPKB_USERS%%.rid = %%TOPKB%%.`rid` AND `role` = 2\n\t\t) as defender\n\t\tFROM %%TOPKB%% WHERE universe = :universe ORDER BY " . $key . " LIMIT 100;";
     $top = $db->select($sql, array(':universe' => Universe::current()));
     $TopKBList = array();
     foreach ($top as $data) {
         $TopKBList[] = array('result' => $data['result'], 'date' => _date($LNG['php_tdformat'], $data['time'], $USER['timezone']), 'time' => TIMESTAMP - $data['time'], 'units' => $data['units'], 'rid' => $data['rid'], 'attacker' => $data['attacker'], 'defender' => $data['defender']);
     }
     $this->assign(array('TopKBList' => $TopKBList, 'sort' => $sort, 'order' => $order));
     $this->display('page.battleHall.default.tpl');
 }
 public function show()
 {
     global $USER, $PLANET, $LNG;
     $this->tplObj->loadscript('flotten.js');
     $targetGalaxy = HTTP::_GP('galaxy', 0);
     $targetSystem = HTTP::_GP('system', 0);
     $targetPlanet = HTTP::_GP('planet', 0);
     $targetType = HTTP::_GP('type', 0);
     $targetMission = HTTP::_GP('target_mission', 0);
     $fleetSpeed = HTTP::_GP('speed', 0);
     $fleetGroup = HTTP::_GP('fleet_group', 0);
     $token = HTTP::_GP('token', '');
     if (!isset($_SESSION['fleet'][$token])) {
         FleetFunctions::GotoFleetPage();
     }
     $fleetArray = $_SESSION['fleet'][$token]['fleet'];
     $db = Database::get();
     $sql = "SELECT id, id_owner, der_metal, der_crystal FROM %%PLANETS%% WHERE universe = :universe AND galaxy = :targetGalaxy AND system = :targetSystem AND planet = :targetPlanet AND planet_type = '1';";
     $targetPlanetData = $db->selectSingle($sql, array(':universe' => Universe::current(), ':targetGalaxy' => $targetGalaxy, ':targetSystem' => $targetSystem, ':targetPlanet' => $targetPlanet));
     if ($targetType == 2 && $targetPlanetData['der_metal'] == 0 && $targetPlanetData['der_crystal'] == 0) {
         $this->printMessage($LNG['fl_error_empty_derbis'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleet1')));
     }
     $MisInfo = array();
     $MisInfo['galaxy'] = $targetGalaxy;
     $MisInfo['system'] = $targetSystem;
     $MisInfo['planet'] = $targetPlanet;
     $MisInfo['planettype'] = $targetType;
     $MisInfo['IsAKS'] = $fleetGroup;
     $MisInfo['Ship'] = $fleetArray;
     $MissionOutput = FleetFunctions::GetFleetMissions($USER, $MisInfo, $targetPlanetData);
     if (empty($MissionOutput['MissionSelector'])) {
         $this->printMessage($LNG['fl_empty_target'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleet1')));
     }
     $GameSpeedFactor = FleetFunctions::GetGameSpeedFactor();
     $MaxFleetSpeed = FleetFunctions::GetFleetMaxSpeed($fleetArray, $USER);
     $distance = FleetFunctions::GetTargetDistance(array($PLANET['galaxy'], $PLANET['system'], $PLANET['planet']), array($targetGalaxy, $targetSystem, $targetPlanet));
     $duration = FleetFunctions::GetMissionDuration($fleetSpeed, $MaxFleetSpeed, $distance, $GameSpeedFactor, $USER);
     $consumption = FleetFunctions::GetFleetConsumption($fleetArray, $duration, $distance, $USER, $GameSpeedFactor);
     if ($consumption > $PLANET['deuterium']) {
         $this->printMessage($LNG['fl_not_enough_deuterium'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleetTable')));
     }
     if (!FleetFunctions::CheckUserSpeed($fleetSpeed)) {
         FleetFunctions::GotoFleetPage(0);
     }
     $_SESSION['fleet'][$token]['speed'] = $MaxFleetSpeed;
     $_SESSION['fleet'][$token]['distance'] = $distance;
     $_SESSION['fleet'][$token]['targetGalaxy'] = $targetGalaxy;
     $_SESSION['fleet'][$token]['targetSystem'] = $targetSystem;
     $_SESSION['fleet'][$token]['targetPlanet'] = $targetPlanet;
     $_SESSION['fleet'][$token]['targetType'] = $targetType;
     $_SESSION['fleet'][$token]['fleetGroup'] = $fleetGroup;
     $_SESSION['fleet'][$token]['fleetSpeed'] = $fleetSpeed;
     if (!empty($fleet_group)) {
         $targetMission = 2;
     }
     $fleetData = array('fleetroom' => floatToString($_SESSION['fleet'][$token]['fleetRoom']), 'consumption' => floatToString($consumption));
     $this->tplObj->execscript('calculateTransportCapacity();');
     $this->assign(array('fleetdata' => $fleetData, 'consumption' => floatToString($consumption), 'mission' => $targetMission, 'galaxy' => $PLANET['galaxy'], 'system' => $PLANET['system'], 'planet' => $PLANET['planet'], 'type' => $PLANET['planet_type'], 'MissionSelector' => $MissionOutput['MissionSelector'], 'StaySelector' => $MissionOutput['StayBlock'], 'fl_dm_alert_message' => sprintf($LNG['fl_dm_alert_message'], $LNG['type_mission'][11], $LNG['tech'][921]), 'fl_continue' => $LNG['fl_continue'], 'token' => $token));
     $this->display('page.fleetStep2.default.tpl');
 }
Ejemplo n.º 3
0
 function show()
 {
     if (empty($_POST)) {
         HTTP::redirectTo('index.php');
     }
     $db = Database::get();
     $username = HTTP::_GP('username', '', UTF8_SUPPORT);
     $password = HTTP::_GP('password', '', true);
     $sql = "SELECT id, password FROM %%USERS%% WHERE universe = :universe AND username = :username;";
     $loginData = $db->selectSingle($sql, array(':universe' => Universe::current(), ':username' => $username));
     if (isset($loginData)) {
         $hashedPassword = PlayerUtil::cryptPassword($password);
         if ($loginData['password'] != $hashedPassword) {
             // Fallback pre 1.7
             if ($loginData['password'] == md5($password)) {
                 $sql = "UPDATE %%USERS%% SET password = :hashedPassword WHERE id = :loginID;";
                 $db->update($sql, array(':hashedPassword' => $hashedPassword, ':loginID' => $loginData['id']));
             } else {
                 HTTP::redirectTo('index.php?code=1');
             }
         }
         $session = Session::create();
         $session->userId = (int) $loginData['id'];
         $session->adminAccess = 0;
         $session->save();
         HTTP::redirectTo('game.php');
     } else {
         HTTP::redirectTo('index.php?code=1');
     }
 }
Ejemplo n.º 4
0
 function show()
 {
     global $PLANET, $LNG, $resource;
     $this->initTemplate();
     $this->setWindow('popup');
     $this->tplObj->loadscript('phalanx.js');
     $Galaxy = HTTP::_GP('galaxy', 0);
     $System = HTTP::_GP('system', 0);
     $Planet = HTTP::_GP('planet', 0);
     if (!$this->allowPhalanx($Galaxy, $System)) {
         $this->printMessage($LNG['px_out_of_range']);
     }
     if ($PLANET[$resource[903]] < PHALANX_DEUTERIUM) {
         $this->printMessage($LNG['px_no_deuterium']);
     }
     $db = Database::get();
     $sql = "UPDATE %%PLANETS%% SET deuterium = deuterium - :phalanxDeuterium WHERE id = :planetID;";
     $db->update($sql, array(':phalanxDeuterium' => PHALANX_DEUTERIUM, ':planetID' => $PLANET['id']));
     $sql = "SELECT id, name, id_owner FROM %%PLANETS%% WHERE universe = :universe\n\t\tAND galaxy = :galaxy AND system = :system AND planet = :planet AND :type;";
     $TargetInfo = $db->selectSingle($sql, array(':universe' => Universe::current(), ':galaxy' => $Galaxy, ':system' => $System, ':planet' => $Planet, ':type' => 1));
     if (empty($TargetInfo)) {
         $this->printMessage($LNG['px_out_of_range']);
     }
     require 'includes/classes/class.FlyingFleetsTable.php';
     $fleetTableObj = new FlyingFleetsTable();
     $fleetTableObj->setPhalanxMode();
     $fleetTableObj->setUser($TargetInfo['id_owner']);
     $fleetTableObj->setPlanet($TargetInfo['id']);
     $fleetTable = $fleetTableObj->renderTable();
     $this->assign(array('galaxy' => $Galaxy, 'system' => $System, 'planet' => $Planet, 'name' => $TargetInfo['name'], 'fleetTable' => $fleetTable));
     $this->display('page.phalanx.default.tpl');
 }
 function send()
 {
     global $USER, $LNG;
     $this->initTemplate();
     $this->setWindow('popup');
     $this->tplObj->execscript('window.setTimeout(parent.$.fancybox.close, 2000);');
     $id = HTTP::_GP('id', 0);
     $text = HTTP::_GP('text', '', UTF8_SUPPORT);
     if ($id == $USER['id']) {
         $this->printMessage($LNG['bu_cannot_request_yourself']);
     }
     $db = Database::get();
     $sql = "SELECT COUNT(*) as count FROM %%BUDDY%% WHERE (sender = :userID AND owner = :friendID) OR (owner = :userID AND sender = :friendID);";
     $exists = $db->selectSingle($sql, array(':userID' => $USER['id'], ':friendID' => $id), 'count');
     if ($exists != 0) {
         $this->printMessage($LNG['bu_request_exists']);
     }
     $sql = "INSERT INTO %%BUDDY%% SET sender = :userID,\towner = :friendID, universe = :universe;";
     $db->insert($sql, array(':userID' => $USER['id'], ':friendID' => $id, ':universe' => Universe::current()));
     $buddyID = $db->lastInsertId();
     $sql = "INSERT INTO %%BUDDY_REQUEST%% SET id = :buddyID, text = :text;";
     $db->insert($sql, array(':buddyID' => $buddyID, ':text' => $text));
     $sql = "SELECT username FROM %%USERS%% WHERE id = :friendID;";
     $username = $db->selectSingle($sql, array(':friendID' => $id), 'username');
     PlayerUtil::sendMessage($id, $USER['id'], $USER['username'], 4, $LNG['bu_new_request_title'], sprintf($LNG['bu_new_request_body'], $username, $USER['username']), TIMESTAMP);
     $this->printMessage($LNG['bu_request_send']);
 }
Ejemplo n.º 6
0
 function show()
 {
     global $USER, $LNG, $reslist;
     $db = Database::get();
     $sql = "SELECT elementID, level, userID, username\n\t\tFROM %%USERS%%\n\t\tINNER JOIN %%RECORDS%% ON userID = id\n\t\tWHERE universe = :universe;";
     $recordResult = $db->select($sql, array(':universe' => Universe::current()));
     $defenseList = array_fill_keys($reslist['defense'], array());
     $fleetList = array_fill_keys($reslist['fleet'], array());
     $researchList = array_fill_keys($reslist['tech'], array());
     $buildList = array_fill_keys($reslist['build'], array());
     foreach ($recordResult as $recordRow) {
         if (in_array($recordRow['elementID'], $reslist['defense'])) {
             $defenseList[$recordRow['elementID']][] = $recordRow;
         } elseif (in_array($recordRow['elementID'], $reslist['fleet'])) {
             $fleetList[$recordRow['elementID']][] = $recordRow;
         } elseif (in_array($recordRow['elementID'], $reslist['tech'])) {
             $researchList[$recordRow['elementID']][] = $recordRow;
         } elseif (in_array($recordRow['elementID'], $reslist['build'])) {
             $buildList[$recordRow['elementID']][] = $recordRow;
         }
     }
     require_once 'includes/classes/Cronjob.class.php';
     $this->assign(array('defenseList' => $defenseList, 'fleetList' => $fleetList, 'researchList' => $researchList, 'buildList' => $buildList, 'update' => _date($LNG['php_tdformat'], Cronjob::getLastExecutionTime('statistic'), $USER['timezone'])));
     $this->display('page.records.default.tpl');
 }
Ejemplo n.º 7
0
    public function getLoginData()
    {
        $uid = $this->getAccount();
        $sql = 'SELECT user.id, id_planet
		FROM %%USERS_AUTH%% auth
		INNER JOIN %%USERS%% user ON auth.id = user.id AND user.universe = :universe
		WHERE auth.account = :accountId AND mode = :mode;';
        return Database::get()->selectSingle($sql, array(':mode' => 'facebook', ':accountId' => $uid, ':universe' => Universe::current()));
    }
Ejemplo n.º 8
0
    public function createTicket($ownerID, $categoryID, $subject)
    {
        $sql = 'INSERT INTO %%TICKETS%% SET
		ownerID		= :ownerId,
		universe	= :universe,
		categoryID	= :categoryId,
		subject		= :subject,
		time		= :time;';
        Database::get()->insert($sql, array(':ownerId' => $ownerID, ':universe' => Universe::current(), ':categoryId' => $categoryID, ':subject' => $subject, ':time' => TIMESTAMP));
        return Database::get()->lastInsertId();
    }
Ejemplo n.º 9
0
 /**
  * Return an config object for the requested universe
  *
  * @param int $universe Universe ID
  *
  * @return Config
  */
 public static function get($universe = 0)
 {
     if (empty(self::$instances)) {
         self::generateInstances();
     }
     if ($universe === 0) {
         $universe = Universe::current();
     }
     if (!isset(self::$instances[$universe])) {
         throw new Exception("Unknown universe id: " . $universe);
     }
     return self::$instances[$universe];
 }
Ejemplo n.º 10
0
 function show()
 {
     global $LNG;
     $db = Database::get();
     $sql = "SELECT *, (\n\t\t\tSELECT DISTINCT\n\t\t\tIF(%%TOPKB_USERS%%.username = '', GROUP_CONCAT(%%USERS%%.username SEPARATOR ' & '), GROUP_CONCAT(%%TOPKB_USERS%%.username SEPARATOR ' & '))\n\t\t\tFROM %%TOPKB_USERS%%\n\t\t\tLEFT JOIN %%USERS%% ON uid = %%USERS%%.id\n\t\t\tWHERE %%TOPKB_USERS%%.`rid` = %%TOPKB%%.`rid` AND `role` = 1\n\t\t) as `attacker`,\n\t\t(\n\t\t\tSELECT DISTINCT\n\t\t\tIF(%%TOPKB_USERS%%.username = '', GROUP_CONCAT(%%USERS%%.username SEPARATOR ' & '), GROUP_CONCAT(%%TOPKB_USERS%%.username SEPARATOR ' & '))\n\t\t\tFROM %%TOPKB_USERS%% INNER JOIN %%USERS%% ON uid = id\n\t\t\tWHERE %%TOPKB_USERS%%.`rid` = %%TOPKB%%.`rid` AND `role` = 2\n\t\t) as `defender`\n\t\tFROM %%TOPKB%% WHERE `universe` = :universe ORDER BY units DESC LIMIT 100;";
     $hallRaw = $db->select($sql, array(':universe' => Universe::current()));
     $hallList = array();
     foreach ($hallRaw as $hallRow) {
         $hallList[] = array('result' => $hallRow['result'], 'time' => _date($LNG['php_tdformat'], $hallRow['time']), 'units' => $hallRow['units'], 'rid' => $hallRow['rid'], 'attacker' => $hallRow['attacker'], 'defender' => $hallRow['defender']);
     }
     $universeSelect = $this->getUniverseSelector();
     $this->assign(array('universeSelect' => $universeSelect, 'hallList' => $hallList));
     $this->display('page.battleHall.default.tpl');
 }
Ejemplo n.º 11
0
 function send()
 {
     global $LNG;
     $username = HTTP::_GP('username', '', UTF8_SUPPORT);
     $mail = HTTP::_GP('mail', '', true);
     $errorMessages = array();
     if (empty($username)) {
         $errorMessages[] = $LNG['passwordUsernameEmpty'];
     }
     if (empty($mail)) {
         $errorMessages[] = $LNG['passwordErrorMailEmpty'];
     }
     $config = Config::get();
     if ($config->capaktiv == 1) {
         require_once 'includes/libs/reCAPTCHA/recaptchalib.php';
         $recaptcha_challenge_field = HTTP::_GP('recaptcha_challenge_field', '');
         $recaptcha_response_field = HTTP::_GP('recaptcha_response_field', '');
         $resp = recaptcha_check_answer($config->capprivate, Session::getClientIp(), $recaptcha_challenge_field, $recaptcha_response_field);
         if (!$resp->is_valid) {
             $errorMessages[] = $LNG['registerErrorCaptcha'];
         }
     }
     if (!empty($errorMessages)) {
         $message = implode("<br>\r\n", $errorMessages);
         $this->printMessage($message, array(array('label' => $LNG['passwordBack'], 'url' => 'index.php?page=lostPassword')));
     }
     $db = Database::get();
     $sql = "SELECT id FROM %%USERS%% WHERE universe = :universe AND username = :username AND email_2 = :mail;";
     $userID = $db->selectSingle($sql, array(':universe' => Universe::current(), ':username' => $username, ':mail' => $mail), 'id');
     if (empty($userID)) {
         $this->printMessage($LNG['passwordErrorUnknown'], array(array('label' => $LNG['passwordBack'], 'url' => 'index.php?page=lostPassword')));
     }
     $sql = "SELECT COUNT(*) as state FROM %%LOSTPASSWORD%% WHERE userID = :userID AND time > :time AND hasChanged = 0;";
     $hasChanged = $db->selectSingle($sql, array(':userID' => $userID, ':time' => TIMESTAMP - 86400), 'state');
     if (!empty($hasChanged)) {
         $this->printMessage($LNG['passwordErrorOnePerDay'], array(array('label' => $LNG['passwordBack'], 'url' => 'index.php?page=lostPassword')));
     }
     $validationKey = md5(uniqid());
     $MailRAW = $LNG->getTemplate('email_lost_password_validation');
     $MailContent = str_replace(array('{USERNAME}', '{GAMENAME}', '{VALIDURL}'), array($username, $config->game_name . ' - ' . $config->uni_name, HTTP_PATH . 'index.php?page=lostPassword&mode=newPassword&u=' . $userID . '&k=' . $validationKey), $MailRAW);
     require 'includes/classes/Mail.class.php';
     $subject = sprintf($LNG['passwordValidMailTitle'], $config->game_name);
     Mail::send($mail, $username, $subject, $MailContent);
     $sql = "INSERT INTO %%LOSTPASSWORD%% SET userID = :userID, `key` = :validationKey, `time` = :timestamp, fromIP = :remoteAddr;";
     $db->insert($sql, array(':userID' => $userID, ':timestamp' => TIMESTAMP, ':validationKey' => $validationKey, ':remoteAddr' => Session::getClientIp()));
     $this->printMessage($LNG['passwordValidMailSend'], array(array('label' => $LNG['passwordNext'], 'url' => 'index.php')));
 }
Ejemplo n.º 12
0
 function show()
 {
     global $USER, $LNG;
     $page = HTTP::_GP('side', 1);
     $db = Database::get();
     $sql = "SELECT COUNT(*) as count FROM %%BANNED%% WHERE universe = :universe ORDER BY time DESC;";
     $banCount = $db->selectSingle($sql, array(':universe' => Universe::current()), 'count');
     $maxPage = ceil($banCount / BANNED_USERS_PER_PAGE);
     $page = max(1, min($page, $maxPage));
     $sql = "SELECT * FROM %%BANNED%% WHERE universe = :universe ORDER BY time DESC LIMIT :offset, :limit;";
     $banResult = $db->select($sql, array(':universe' => Universe::current(), ':offset' => ($page - 1) * BANNED_USERS_PER_PAGE, ':limit' => BANNED_USERS_PER_PAGE));
     $banList = array();
     foreach ($banResult as $banRow) {
         $banList[] = array('player' => $banRow['who'], 'theme' => $banRow['theme'], 'from' => _date($LNG['php_tdformat'], $banRow['time'], $USER['timezone']), 'to' => _date($LNG['php_tdformat'], $banRow['longer'], $USER['timezone']), 'admin' => $banRow['author'], 'mail' => $banRow['email'], 'info' => sprintf($LNG['bn_writemail'], $banRow['author']));
     }
     $this->assign(array('banList' => $banList, 'banCount' => $banCount, 'page' => $page, 'maxPage' => $maxPage));
     $this->display('page.banList.default.tpl');
 }
Ejemplo n.º 13
0
 public function insert()
 {
     global $LNG, $USER;
     $priority = HTTP::_GP('priority', 1);
     $title = HTTP::_GP('title', '', true);
     $text = HTTP::_GP('text', '', true);
     $id = HTTP::_GP('id', 0);
     $title = !empty($title) ? $title : $LNG['nt_no_title'];
     $text = !empty($text) ? $text : $LNG['nt_no_text'];
     $db = Database::get();
     if ($id == 0) {
         $sql = "INSERT INTO %%NOTES%% SET owner = :userID, time = :time, priority = :priority, title = :title, text = :text, universe = :universe;";
         $db->insert($sql, array(':userID' => $USER['id'], ':time' => TIMESTAMP, ':priority' => $priority, ':title' => $title, ':text' => $text, ':universe' => Universe::current()));
     } else {
         $sql = "UPDATE %%NOTES%% SET time = :time, priority = :priority, title = :title, text = :text WHERE id = :noteID;";
         $db->update($sql, array(':noteID' => $id, ':time' => TIMESTAMP, ':priority' => $priority, ':title' => $title, ':text' => $text));
     }
     $this->redirectTo('game.php?page=notes');
 }
Ejemplo n.º 14
0
    public function getGalaxyData()
    {
        global $USER;
        $sql = 'SELECT SQL_BIG_RESULT DISTINCT
		p.galaxy, p.system, p.planet, p.id, p.id_owner, p.name, p.image, p.last_update, p.diameter, p.temp_min, p.destruyed, p.der_metal, p.der_crystal, p.id_luna, 
		u.id as userid, u.ally_id, u.username, u.onlinetime, u.urlaubs_modus, u.banaday, 
		m.id as m_id, m.diameter as m_diameter, m.name as m_name, m.temp_min as m_temp_min, m.last_update as m_last_update,
		s.total_points, s.total_rank, 
		a.id as allyid, a.ally_tag, a.ally_web, a.ally_members, a.ally_name, 
		allys.total_rank as ally_rank,
		COUNT(buddy.id) as buddy,
		d.level as diploLevel
		FROM %%PLANETS%% p
		LEFT JOIN %%USERS%% u ON p.id_owner = u.id
		LEFT JOIN %%PLANETS%% m ON m.id = p.id_luna
		LEFT JOIN %%STATPOINTS%% s ON s.id_owner = u.id AND s.stat_type = :statTypeUser
		LEFT JOIN %%ALLIANCE%% a ON a.id = u.ally_id
		LEFT JOIN %%DIPLO%% as d ON (d.owner_1 = :allianceId AND d.owner_2 = a.id) OR (d.owner_1 = a.id AND d.owner_2 = :allianceId) AND d.accept = :accept
		LEFT JOIN %%STATPOINTS%% allys ON allys.stat_type = :statTypeAlliance AND allys.id_owner = a.id
		LEFT JOIN %%BUDDY%% buddy ON (buddy.sender = :userId AND buddy.owner = u.id) OR (buddy.sender = u.id AND buddy.owner = :userId)
		WHERE p.universe = :universe AND p.galaxy = :galaxy AND p.system = :system AND p.planet_type = :planetTypePlanet
		GROUP BY p.id;';
        $galaxyResult = Database::get()->select($sql, array(':statTypeUser' => 1, ':statTypeAlliance' => 2, ':allianceId' => $USER['ally_id'], ':userId' => $USER['id'], ':universe' => Universe::current(), ':galaxy' => $this->Galaxy, ':system' => $this->System, ':planetTypePlanet' => 1, ':accept' => 1));
        foreach ($galaxyResult as $galaxyRow) {
            $this->galaxyRow = $galaxyRow;
            if ($this->galaxyRow['destruyed'] != 0) {
                $this->galaxyData[$this->galaxyRow['planet']] = self::PLANET_DESTROYED;
                continue;
            }
            $this->galaxyData[$this->galaxyRow['planet']] = array();
            $this->isOwnPlanet();
            $this->setLastActivity();
            $this->getAllowedMissions();
            $this->getPlayerData();
            $this->getPlanetData();
            $this->getAllianceData();
            $this->getDebrisData();
            $this->getMoonData();
            $this->getActionButtons();
        }
        return $this->galaxyData;
    }
Ejemplo n.º 15
0
 private function _activeUser()
 {
     global $LNG;
     $validationID = HTTP::_GP('i', 0);
     $validationKey = HTTP::_GP('k', '');
     $db = Database::get();
     $sql = "SELECT * FROM %%USERS_VALID%%\n\t\tWHERE validationID\t= :validationID\n\t\tAND validationKey\t= :validationKey\n\t\tAND universe\t\t= :universe;";
     $userData = $db->selectSingle($sql, array(':validationKey' => $validationKey, ':validationID' => $validationID, ':universe' => Universe::current()));
     if (empty($userData)) {
         $this->printMessage($LNG['vertifyNoUserFound']);
     }
     $config = Config::get();
     $sql = "DELETE FROM %%USERS_VALID%% WHERE validationID = :validationID;";
     $db->delete($sql, array(':validationID' => $validationID));
     list($userID, $planetID) = PlayerUtil::createPlayer($userData['universe'], $userData['userName'], $userData['password'], $userData['email'], $userData['language']);
     if ($config->mail_active == 1) {
         require 'includes/classes/Mail.class.php';
         $MailSubject = sprintf($LNG['registerMailCompleteTitle'], $config->game_name, Universe::current());
         $MailRAW = $LNG->getTemplate('email_reg_done');
         $MailContent = str_replace(array('{USERNAME}', '{GAMENAME}', '{GAMEMAIL}'), array($userData['userName'], $config->game_name . ' - ' . $config->uni_name, $config->smtp_sendmail), $MailRAW);
         try {
             Mail::send($userData['email'], $userData['userName'], $MailSubject, $MailContent);
         } catch (Exception $e) {
             // This mail is wayne.
         }
     }
     if (!empty($userData['referralID'])) {
         $sql = "UPDATE %%USERS%% SET\n\t\t\t`ref_id`\t= :referralId,\n\t\t\t`ref_bonus`\t= 1\n\t\t\tWHERE\n\t\t\t`id`\t\t= :userID;";
         $db->update($sql, array(':referralId' => $userData['referralID'], ':userID' => $userID));
     }
     if (!empty($userData['externalAuthUID'])) {
         $sql = "INSERT INTO %%USERS_AUTH%% SET\n\t\t\t`id`\t\t= :userID,\n\t\t\t`account`\t= :externalAuthUID,\n\t\t\t`mode`\t\t= :externalAuthMethod;";
         $db->insert($sql, array(':userID' => $userID, ':externalAuthUID' => $userData['externalAuthUID'], ':externalAuthMethod' => $userData['externalAuthMethod']));
     }
     $senderName = $LNG['registerWelcomePMSenderName'];
     $subject = $LNG['registerWelcomePMSubject'];
     $message = sprintf($LNG['registerWelcomePMText'], $config->game_name, $userData['universe']);
     PlayerUtil::sendMessage($userID, 1, $senderName, 1, $subject, $message, TIMESTAMP);
     return array('userID' => $userID, 'userName' => $userData['userName'], 'planetID' => $planetID);
 }
Ejemplo n.º 16
0
 function show()
 {
     global $USER, $LNG;
     $this->setWindow('popup');
     $this->initTemplate();
     $db = Database::get();
     $PlayerID = HTTP::_GP('id', 0);
     $sql = "SELECT \n\t\t\t\tu.username, u.galaxy, u.system, u.planet, u.wons, u.loos, u.draws, u.kbmetal, u.kbcrystal, u.lostunits, u.desunits, u.ally_id,\n\t\t\t\tp.name,\n\t\t\t\ts.tech_rank, s.tech_points, s.build_rank, s.build_points, s.defs_rank, s.defs_points, s.fleet_rank, s.fleet_points, s.total_rank, s.total_points,\n\t\t\t\ta.ally_name\n\t\t\t\tFROM %%USERS%% u\n\t\t\t\tINNER JOIN %%PLANETS%% p ON p.id = u.id_planet\n\t\t\t\tLEFT JOIN %%STATPOINTS%% s ON s.id_owner = u.id AND s.stat_type = 1\n\t\t\t\tLEFT JOIN %%ALLIANCE%% a ON a.id = u.ally_id\n\t\t\t\tWHERE u.id = :playerID AND u.universe = :universe;";
     $query = $db->selectSingle($sql, array(':universe' => Universe::current(), ':playerID' => $PlayerID));
     $totalfights = $query['wons'] + $query['loos'] + $query['draws'];
     if ($totalfights == 0) {
         $siegprozent = 0;
         $loosprozent = 0;
         $drawsprozent = 0;
     } else {
         $siegprozent = 100 / $totalfights * $query['wons'];
         $loosprozent = 100 / $totalfights * $query['loos'];
         $drawsprozent = 100 / $totalfights * $query['draws'];
     }
     $this->assign(array('id' => $PlayerID, 'yourid' => $USER['id'], 'name' => $query['username'], 'homeplanet' => $query['name'], 'galaxy' => $query['galaxy'], 'system' => $query['system'], 'planet' => $query['planet'], 'allyid' => $query['ally_id'], 'tech_rank' => pretty_number($query['tech_rank']), 'tech_points' => pretty_number($query['tech_points']), 'build_rank' => pretty_number($query['build_rank']), 'build_points' => pretty_number($query['build_points']), 'defs_rank' => pretty_number($query['defs_rank']), 'defs_points' => pretty_number($query['defs_points']), 'fleet_rank' => pretty_number($query['fleet_rank']), 'fleet_points' => pretty_number($query['fleet_points']), 'total_rank' => pretty_number($query['total_rank']), 'total_points' => pretty_number($query['total_points']), 'allyname' => $query['ally_name'], 'playerdestory' => sprintf($LNG['pl_destroy'], $query['username']), 'wons' => pretty_number($query['wons']), 'loos' => pretty_number($query['loos']), 'draws' => pretty_number($query['draws']), 'kbmetal' => pretty_number($query['kbmetal']), 'kbcrystal' => pretty_number($query['kbcrystal']), 'lostunits' => pretty_number($query['lostunits']), 'desunits' => pretty_number($query['desunits']), 'totalfights' => pretty_number($totalfights), 'siegprozent' => round($siegprozent, 2), 'loosprozent' => round($loosprozent, 2), 'drawsprozent' => round($drawsprozent, 2)));
     $this->display('page.playerCard.default.tpl');
 }
Ejemplo n.º 17
0
 static function _getSearchList($searchMode, $searchText, $maxResult)
 {
     $db = Database::get();
     $limit = $maxResult === -1 ? '' : 'LIMIT :limit';
     $searchList = array();
     switch ($searchMode) {
         case 'playername':
             $sql = "SELECT a.id, a.username, a.ally_id, a.galaxy, a.system, a.planet, b.name, c.total_rank, d.ally_name\n\t\t\t\tFROM %%USERS%% as a\n\t\t\t\tINNER JOIN %%PLANETS%% as b ON b.id = a.id_planet\n\t\t\t\tLEFT JOIN %%STATPOINTS%% as c ON c.id_owner = a.id AND c.stat_type = 1\n\t\t\t\tLEFT JOIN %%ALLIANCE%% as d ON d.id = a.ally_id\n\t\t\t\tWHERE a.universe = :universe AND a.username LIKE :searchTextLike\n\t\t\t\tORDER BY (\n\t\t\t\t  IF(a.username = :searchText, 1, 0)\n\t\t\t\t  + IF(a.username LIKE :searchTextLike, 1, 0)\n\t\t\t\t) DESC, a.username ASC\n\t\t\t\t" . $limit . ";";
             $searchResult = $db->select($sql, array(':universe' => Universe::current(), ':searchText' => $searchText, ':searchTextLike' => '%' . $searchText . '%', ':limit' => $maxResult));
             foreach ($searchResult as $searchRow) {
                 $searchList[] = array('planetname' => $searchRow['name'], 'username' => $searchRow['username'], 'userid' => $searchRow['id'], 'allyname' => $searchRow['ally_name'], 'allyid' => $searchRow['ally_id'], 'galaxy' => $searchRow['galaxy'], 'system' => $searchRow['system'], 'planet' => $searchRow['planet'], 'rank' => $searchRow['total_rank']);
             }
             break;
         case 'planetname':
             $sql = "SELECT a.name, a.galaxy, a.planet, a.system,\n\t\t\t\tb.id, b.ally_id, b.username,\n\t\t\t\tc.total_rank,\n\t\t\t\td.ally_name\n\t\t\t\tFROM %%PLANETS%% as a\n\t\t\t\tINNER JOIN %%USERS%% as b ON b.id = a.id_owner\n\t\t\t\tLEFT JOIN  %%STATPOINTS%% as c ON c.id_owner = b.id AND c.stat_type = 1\n\t\t\t\tLEFT JOIN %%ALLIANCE%% as d ON d.id = b.ally_id\n\t\t\t\tWHERE a.universe = :universe AND a.name LIKE :searchTextLike\n\t\t\t\tORDER BY (\n\t\t\t\t  IF(a.name = :searchText, 1, 0)\n\t\t\t\t  + IF(a.name LIKE :searchTextLike, 1, 0)\n\t\t\t\t) DESC, a.name ASC\n\t\t\t\t" . $limit . ";";
             $searchResult = $db->select($sql, array(':universe' => Universe::current(), ':searchText' => $searchText, ':searchTextLike' => '%' . $searchText . '%', ':limit' => $maxResult));
             foreach ($searchResult as $searchRow) {
                 $searchList[] = array('planetname' => $searchRow['name'], 'username' => $searchRow['username'], 'userid' => $searchRow['id'], 'allyname' => $searchRow['ally_name'], 'allyid' => $searchRow['ally_id'], 'galaxy' => $searchRow['galaxy'], 'system' => $searchRow['system'], 'planet' => $searchRow['planet'], 'rank' => $searchRow['total_rank']);
             }
             break;
         case "allytag":
             $sql = "SELECT a.id, a.ally_name, a.ally_tag, a.ally_members,\n\t\t\t\tc.total_points FROM %%ALLIANCE%% as a\n\t\t\t\tLEFT JOIN %%STATPOINTS%% as c ON c.stat_type = 1 AND c.id_owner = a.id\n\t\t\t\tWHERE a.ally_universe = :universe AND a.ally_tag LIKE :searchTextLike\n\t\t\t\tORDER BY (\n\t\t\t\t  IF(a.ally_tag = :searchText, 1, 0)\n\t\t\t\t  + IF(a.ally_tag LIKE :searchTextLike, 1, 0)\n\t\t\t\t) DESC, a.ally_tag ASC\n\t\t\t\t" . $limit . ";";
             $searchResult = $db->select($sql, array(':universe' => Universe::current(), ':searchText' => $searchText, ':searchTextLike' => '%' . $searchText . '%', ':limit' => $maxResult));
             foreach ($searchResult as $searchRow) {
                 $searchList[] = array('allypoints' => pretty_number($searchRow['total_points']), 'allytag' => $searchRow['ally_tag'], 'allymembers' => $searchRow['ally_members'], 'allyname' => $searchRow['ally_name']);
             }
             break;
         case "allyname":
             $sql = "SELECT a.ally_name, a.ally_tag, a.ally_members,\n\t\t\t\tb.total_points FROM %%ALLIANCE%% as a\n\t\t\t\tLEFT JOIN %%STATPOINTS%% as b ON b.stat_type = 1 AND b.id_owner = a.id\n\t\t\t\tWHERE a.ally_universe = :universe AND a.ally_name LIKE :searchTextLike\n\t\t\t\tORDER BY (\n\t\t\t\t  IF(a.ally_name = :searchText, 1, 0)\n\t\t\t\t  + IF(a.ally_name LIKE :searchTextLike, 1, 0)\n\t\t\t\t) DESC,a.ally_name ASC\n\t\t\t\t" . $limit . ";";
             $searchResult = $db->select($sql, array(':universe' => Universe::current(), ':searchText' => $searchText, ':searchTextLike' => '%' . $searchText . '%', ':limit' => $maxResult));
             foreach ($searchResult as $searchRow) {
                 $searchList[] = array('allypoints' => pretty_number($searchRow['total_points']), 'allytag' => $searchRow['ally_tag'], 'allymembers' => $searchRow['ally_members'], 'allyname' => $searchRow['ally_name']);
             }
             break;
     }
     return $searchList;
 }
Ejemplo n.º 18
0
 public function getACSPageData($fleetID)
 {
     global $USER, $LNG;
     $db = Database::get();
     $sql = "SELECT fleet_start_time, fleet_end_id, fleet_group, fleet_mess FROM %%FLEETS%% WHERE fleet_id = :fleetID;";
     $fleetData = $db->selectSingle($sql, array(':fleetID' => $fleetID));
     if ($db->rowCount() != 1) {
         return array();
     }
     if ($fleetData['fleet_mess'] == 1 || $fleetData['fleet_start_time'] <= TIMESTAMP) {
         return array();
     }
     if ($fleetData['fleet_group'] == 0) {
         $acsData = $this->createACS($fleetID, $fleetData);
     } else {
         $acsData = $this->loadACS($fleetData);
     }
     if (empty($acsData)) {
         return array();
     }
     $acsName = HTTP::_GP('acsName', '', UTF8_SUPPORT);
     if (!empty($acsName)) {
         if (PlayerUtil::isNameValid($acsName)) {
             $this->sendJSON($LNG['fl_acs_newname_alphanum']);
         }
         $sql = "UPDATE %%AKS%% SET name = acsName WHERE id = :acsID;";
         $db->update($sql, array(':acsName' => $acsName, ':acsID' => $acsData['id']));
         $this->sendJSON(false);
     }
     $invitedUsers = array();
     $sql = "SELECT id, username FROM %%USERS_ACS%% INNER JOIN %%USERS%% ON userID = id WHERE acsID = :acsID;";
     $userResult = $db->select($sql, array(':acsID' => $acsData['id']));
     foreach ($userResult as $userRow) {
         $invitedUsers[$userRow['id']] = $userRow['username'];
     }
     $newUser = HTTP::_GP('username', '', UTF8_SUPPORT);
     $statusMessage = "";
     if (!empty($newUser)) {
         $sql = "SELECT id FROM %%USERS%% WHERE universe = :universe AND username = :username;";
         $newUserID = $db->selectSingle($sql, array(':universe' => Universe::current(), ':username' => $newUser), 'id');
         if (empty($newUserID)) {
             $statusMessage = $LNG['fl_player'] . " " . $newUser . " " . $LNG['fl_dont_exist'];
         } elseif (isset($invitedUsers[$newUserID])) {
             $statusMessage = $LNG['fl_player'] . " " . $newUser . " " . $LNG['fl_already_invited'];
         } else {
             $statusMessage = $LNG['fl_player'] . " " . $newUser . " " . $LNG['fl_add_to_attack'];
             $sql = "INSERT INTO %%USERS_ACS%% SET acsID = :acsID, userID = :newUserID;";
             $db->insert($sql, array(':acsID' => $acsData['id'], ':newUserID' => $newUserID));
             $invitedUsers[$newUserID] = $newUser;
             $inviteTitle = $LNG['fl_acs_invitation_title'];
             $inviteMessage = $LNG['fl_player'] . $USER['username'] . $LNG['fl_acs_invitation_message'];
             PlayerUtil::sendMessage($newUserID, $USER['id'], TIMESTAMP, 1, $USER['username'], $inviteTitle, $inviteMessage);
         }
     }
     return array('invitedUsers' => $invitedUsers, 'acsName' => $acsData['name'], 'mainFleetID' => $fleetID, 'statusMessage' => $statusMessage);
 }
Ejemplo n.º 19
0
 $USER = $db->selectSingle($sql, array(':unread' => 1, ':userId' => $session->userId));
 if (empty($USER)) {
     HTTP::redirectTo('index.php?code=3');
 }
 $LNG = new Language($USER['lang']);
 $LNG->includeData(array('L18N', 'INGAME', 'TECH', 'CUSTOM'));
 $THEME->setUserTheme($USER['dpath']);
 if ($config->game_disable == 0 && $USER['authlevel'] == AUTH_USR) {
     ShowErrorPage::printError($LNG['sys_closed_game'] . '<br><br>' . $config->close_reason, false);
 }
 if ($USER['bana'] == 1) {
     ShowErrorPage::printError("<font size=\"6px\">" . $LNG['css_account_banned_message'] . "</font><br><br>" . sprintf($LNG['css_account_banned_expire'], _date($LNG['php_tdformat'], $USER['banaday'], $USER['timezone'])) . "<br><br>" . $LNG['css_goto_homeside'], false);
 }
 if (MODE === 'INGAME') {
     $universeAmount = count(Universe::availableUniverses());
     if (Universe::current() != $USER['universe'] && $universeAmount > 1) {
         HTTP::redirectToUniverse($USER['universe']);
     }
     $session->selectActivePlanet();
     $sql = "SELECT * FROM %%PLANETS%% WHERE id = :planetId;";
     $PLANET = $db->selectSingle($sql, array(':planetId' => $session->planetId));
     if (empty($PLANET)) {
         $sql = "SELECT * FROM %%PLANETS%% WHERE id = :planetId;";
         $PLANET = $db->selectSingle($sql, array(':planetId' => $USER['id_planet']));
         if (empty($PLANET)) {
             throw new Exception("Main Planet does not exist!");
         } else {
             $session->planetId = $USER['id_planet'];
         }
     }
     $USER['factor'] = getFactors($USER);
Ejemplo n.º 20
0
    function show()
    {
        global $LNG, $PLANET, $USER;
        $AdminsOnline = array();
        $chatOnline = array();
        $AllPlanets = array();
        $Moon = array();
        $RefLinks = array();
        $db = Database::get();
        foreach ($USER['PLANETS'] as $ID => $CPLANET) {
            if ($ID == $PLANET['id'] || $CPLANET['planet_type'] == 3) {
                continue;
            }
            if (!empty($CPLANET['b_building']) && $CPLANET['b_building'] > TIMESTAMP) {
                $Queue = unserialize($CPLANET['b_building_id']);
                $BuildPlanet = $LNG['tech'][$Queue[0][0]] . " (" . $Queue[0][1] . ")<br><span style=\"color:#7F7F7F;\">(" . pretty_time($Queue[0][3] - TIMESTAMP) . ")</span>";
            } else {
                $BuildPlanet = $LNG['ov_free'];
            }
            $AllPlanets[] = array('id' => $CPLANET['id'], 'name' => $CPLANET['name'], 'image' => $CPLANET['image'], 'build' => $BuildPlanet);
        }
        if ($PLANET['id_luna'] != 0) {
            $sql = "SELECT id, name FROM %%PLANETS%% WHERE id = :lunaID;";
            $Moon = $db->selectSingle($sql, array(':lunaID' => $PLANET['id_luna']));
        }
        if ($PLANET['b_building'] - TIMESTAMP > 0) {
            $Queue = unserialize($PLANET['b_building_id']);
            $buildInfo['buildings'] = array('id' => $Queue[0][0], 'level' => $Queue[0][1], 'timeleft' => $PLANET['b_building'] - TIMESTAMP, 'time' => $PLANET['b_building'], 'starttime' => pretty_time($PLANET['b_building'] - TIMESTAMP));
        } else {
            $buildInfo['buildings'] = false;
        }
        /* As FR#206 (http://tracker.2moons.cc/view.php?id=206), i added the shipyard and research status here, but i add not them the template. */
        if (!empty($PLANET['b_hangar_id'])) {
            $Queue = unserialize($PLANET['b_hangar_id']);
            $time = BuildFunctions::getBuildingTime($USER, $PLANET, $Queue[0][0]) * $Queue[0][1];
            $buildInfo['fleet'] = array('id' => $Queue[0][0], 'level' => $Queue[0][1], 'timeleft' => $time - $PLANET['b_hangar'], 'time' => $time, 'starttime' => pretty_time($time - $PLANET['b_hangar']));
        } else {
            $buildInfo['fleet'] = false;
        }
        if ($USER['b_tech'] - TIMESTAMP > 0) {
            $Queue = unserialize($USER['b_tech_queue']);
            $buildInfo['tech'] = array('id' => $Queue[0][0], 'level' => $Queue[0][1], 'timeleft' => $USER['b_tech'] - TIMESTAMP, 'time' => $USER['b_tech'], 'starttime' => pretty_time($USER['b_tech'] - TIMESTAMP));
        } else {
            $buildInfo['tech'] = false;
        }
        $sql = "SELECT id,username FROM %%USERS%% WHERE universe = :universe AND onlinetime >= :onlinetime AND authlevel > :authlevel;";
        $onlineAdmins = $db->select($sql, array(':universe' => Universe::current(), ':onlinetime' => TIMESTAMP - 10 * 60, ':authlevel' => AUTH_USR));
        foreach ($onlineAdmins as $AdminRow) {
            $AdminsOnline[$AdminRow['id']] = $AdminRow['username'];
        }
        $sql = "SELECT userName FROM %%CHAT_ON%% WHERE dateTime > DATE_SUB(NOW(), interval 2 MINUTE) AND channel = 0";
        $chatUsers = $db->select($sql);
        foreach ($chatUsers as $chatRow) {
            $chatOnline[] = $chatRow['userName'];
        }
        $Messages = $USER['messages'];
        // Fehler: Wenn Spieler gelöscht werden, werden sie nicht mehr in der Tabelle angezeigt.
        $sql = "SELECT u.id, u.username, s.total_points FROM %%USERS%% as u\n\t\tLEFT JOIN %%STATPOINTS%% as s ON s.id_owner = u.id AND s.stat_type = '1' WHERE ref_id = :userID;";
        $RefLinksRAW = $db->select($sql, array(':userID' => $USER['id']));
        $config = Config::get();
        if ($config->ref_active) {
            foreach ($RefLinksRAW as $RefRow) {
                $RefLinks[$RefRow['id']] = array('username' => $RefRow['username'], 'points' => min($RefRow['total_points'], $config->ref_minpoints));
            }
        }
        $sql = 'SELECT total_points, total_rank
		FROM %%STATPOINTS%%
		WHERE id_owner = :userId AND stat_type = :statType';
        $statData = Database::get()->selectSingle($sql, array(':userId' => $USER['id'], ':statType' => 1));
        if ($statData['total_rank'] == 0) {
            $rankInfo = "-";
        } else {
            $rankInfo = sprintf($LNG['ov_userrank_info'], pretty_number($statData['total_points']), $LNG['ov_place'], $statData['total_rank'], $statData['total_rank'], $LNG['ov_of'], $config->users_amount);
        }
        $this->assign(array('rankInfo' => $rankInfo, 'is_news' => $config->OverviewNewsFrame, 'news' => makebr($config->OverviewNewsText), 'planetname' => $PLANET['name'], 'planetimage' => $PLANET['image'], 'galaxy' => $PLANET['galaxy'], 'system' => $PLANET['system'], 'planet' => $PLANET['planet'], 'planet_type' => $PLANET['planet_type'], 'username' => $USER['username'], 'userid' => $USER['id'], 'buildInfo' => $buildInfo, 'Moon' => $Moon, 'fleets' => $this->GetFleets(), 'AllPlanets' => $AllPlanets, 'AdminsOnline' => $AdminsOnline, 'teamspeakData' => $this->GetTeamspeakData(), 'messages' => $Messages > 0 ? $Messages == 1 ? $LNG['ov_have_new_message'] : sprintf($LNG['ov_have_new_messages'], pretty_number($Messages)) : false, 'planet_diameter' => pretty_number($PLANET['diameter']), 'planet_field_current' => $PLANET['field_current'], 'planet_field_max' => CalculateMaxPlanetFields($PLANET), 'planet_temp_min' => $PLANET['temp_min'], 'planet_temp_max' => $PLANET['temp_max'], 'ref_active' => $config->ref_active, 'ref_minpoints' => $config->ref_minpoints, 'RefLinks' => $RefLinks, 'chatOnline' => $chatOnline, 'servertime' => _date("M D d H:i:s", TIMESTAMP, $USER['timezone']), 'path' => HTTP_PATH));
        $this->display('page.overview.default.tpl');
    }
Ejemplo n.º 21
0
 function send()
 {
     global $LNG;
     $config = Config::get();
     if ($config->game_disable == 0 || $config->reg_closed == 1) {
         $this->printMessage($LNG['registerErrorUniClosed'], array(array('label' => $LNG['registerBack'], 'url' => 'javascript:window.history.back()')));
     }
     $userName = HTTP::_GP('username', '', UTF8_SUPPORT);
     $password = HTTP::_GP('password', '', true);
     $password2 = HTTP::_GP('passwordReplay', '', true);
     $mailAddress = HTTP::_GP('email', '');
     $mailAddress2 = HTTP::_GP('emailReplay', '');
     $rulesChecked = HTTP::_GP('rules', 0);
     $language = HTTP::_GP('lang', '');
     $referralID = HTTP::_GP('referralID', 0);
     $externalAuth = HTTP::_GP('externalAuth', array());
     if (!isset($externalAuth['account'], $externalAuth['method'])) {
         $externalAuthUID = 0;
         $externalAuthMethod = '';
     } else {
         $externalAuthUID = $externalAuth['account'];
         $externalAuthMethod = strtolower(str_replace(array('_', '\\', '/', '.', ""), '', $externalAuth['method']));
     }
     $errors = array();
     if (empty($userName)) {
         $errors[] = $LNG['registerErrorUsernameEmpty'];
     }
     if (!PlayerUtil::isNameValid($userName)) {
         $errors[] = $LNG['registerErrorUsernameChar'];
     }
     if (strlen($password) < 6) {
         $errors[] = $LNG['registerErrorPasswordLength'];
     }
     if ($password != $password2) {
         $errors[] = $LNG['registerErrorPasswordSame'];
     }
     if (!PlayerUtil::isMailValid($mailAddress)) {
         $errors[] = $LNG['registerErrorMailInvalid'];
     }
     if (empty($mailAddress)) {
         $errors[] = $LNG['registerErrorMailEmpty'];
     }
     if ($mailAddress != $mailAddress2) {
         $errors[] = $LNG['registerErrorMailSame'];
     }
     if ($rulesChecked != 1) {
         $errors[] = $LNG['registerErrorRules'];
     }
     $db = Database::get();
     $sql = "SELECT (\n\t\t\t\tSELECT COUNT(*)\n\t\t\t\tFROM %%USERS%%\n\t\t\t\tWHERE universe = :universe\n\t\t\t\tAND username = :userName\n\t\t\t) + (\n\t\t\t\tSELECT COUNT(*)\n\t\t\t\tFROM %%USERS_VALID%%\n\t\t\t\tWHERE universe = :universe\n\t\t\t\tAND username = :userName\n\t\t\t) as count;";
     $countUsername = $db->selectSingle($sql, array(':universe' => Universe::current(), ':userName' => $userName), 'count');
     $sql = "SELECT (\n\t\t\tSELECT COUNT(*)\n\t\t\tFROM %%USERS%%\n\t\t\tWHERE universe = :universe\n\t\t\tAND (\n\t\t\t\temail = :mailAddress\n\t\t\t\tOR email_2 = :mailAddress\n\t\t\t)\n\t\t) + (\n\t\t\tSELECT COUNT(*)\n\t\t\tFROM %%USERS_VALID%%\n\t\t\tWHERE universe = :universe\n\t\t\tAND email = :mailAddress\n\t\t) as count;";
     $countMail = $db->selectSingle($sql, array(':universe' => Universe::current(), ':mailAddress' => $mailAddress), 'count');
     if ($countUsername != 0) {
         $errors[] = $LNG['registerErrorUsernameExist'];
     }
     if ($countMail != 0) {
         $errors[] = $LNG['registerErrorMailExist'];
     }
     if ($config->capaktiv === '1') {
         require_once 'includes/libs/reCAPTCHA/recaptchalib.php';
         $recaptcha_challenge_field = HTTP::_GP('recaptcha_challenge_field', '');
         $recaptcha_response_field = HTTP::_GP('recaptcha_response_field', '');
         $resp = recaptcha_check_answer($config->capprivate, Session::getClientIp(), $recaptcha_challenge_field, $recaptcha_response_field);
         if (!$resp->is_valid) {
             $errors[] = $LNG['registerErrorCaptcha'];
         }
     }
     if (!empty($errors)) {
         $this->printMessage(implode("<br>\r\n", $errors), array(array('label' => $LNG['registerBack'], 'url' => 'javascript:window.history.back()')));
     }
     $path = 'includes/extauth/' . $externalAuthMethod . '.class.php';
     if (!empty($externalAuth['account']) && file_exists($path)) {
         require $path;
         $methodClass = ucwords($externalAuthMethod) . 'Auth';
         /** @var $authObj externalAuth */
         $authObj = new $methodClass();
         $externalAuthUID = 0;
         if ($authObj->isActiveMode() && $authObj->isValid()) {
             $externalAuthUID = $authObj->getAccount();
         }
     }
     if ($config->ref_active == 1 && !empty($referralID)) {
         $sql = "SELECT COUNT(*) as state FROM %%USERS%% WHERE id = :referralID AND universe = :universe;";
         $Count = $db->selectSingle($sql, array(':referralID' => $referralID, ':universe' => Universe::current()), 'state');
         if ($Count == 0) {
             $referralID = 0;
         }
     } else {
         $referralID = 0;
     }
     $validationKey = md5(uniqid('2m'));
     $sql = "INSERT INTO %%USERS_VALID%% SET\n\t\t\t\t`userName` = :userName,\n\t\t\t\t`validationKey` = :validationKey,\n\t\t\t\t`password` = :password,\n\t\t\t\t`email` = :mailAddress,\n\t\t\t\t`date` = :timestamp,\n\t\t\t\t`ip` = :remoteAddr,\n\t\t\t\t`language` = :language,\n\t\t\t\t`universe` = :universe,\n\t\t\t\t`referralID` = :referralID,\n\t\t\t\t`externalAuthUID` = :externalAuthUID,\n\t\t\t\t`externalAuthMethod` = :externalAuthMethod;";
     $db->insert($sql, array(':userName' => $userName, ':validationKey' => $validationKey, ':password' => PlayerUtil::cryptPassword($password), ':mailAddress' => $mailAddress, ':timestamp' => TIMESTAMP, ':remoteAddr' => Session::getClientIp(), ':language' => $language, ':universe' => Universe::current(), ':referralID' => $referralID, ':externalAuthUID' => $externalAuthUID, ':externalAuthMethod' => $externalAuthMethod));
     $validationID = $db->lastInsertId();
     $verifyURL = 'index.php?page=vertify&i=' . $validationID . '&k=' . $validationKey;
     if ($config->user_valid == 0 || !empty($externalAuthUID)) {
         $this->redirectTo($verifyURL);
     } else {
         require 'includes/classes/Mail.class.php';
         $MailRAW = $LNG->getTemplate('email_vaild_reg');
         $MailContent = str_replace(array('{USERNAME}', '{PASSWORD}', '{GAMENAME}', '{VERTIFYURL}', '{GAMEMAIL}'), array($userName, $password, $config->game_name . ' - ' . $config->uni_name, HTTP_PATH . $verifyURL, $config->smtp_sendmail), $MailRAW);
         $subject = sprintf($LNG['registerMailVertifyTitle'], $config->game_name);
         Mail::send($mailAddress, $userName, $subject, $MailContent);
         $this->printMessage($LNG['registerSendComplete']);
     }
 }
Ejemplo n.º 22
0
    public function show()
    {
        global $USER, $PLANET, $resource, $LNG;
        if (IsVacationMode($USER)) {
            FleetFunctions::GotoFleetPage(0);
        }
        $targetMission = HTTP::_GP('mission', 3);
        $TransportMetal = max(0, round(HTTP::_GP('metal', 0.0)));
        $TransportCrystal = max(0, round(HTTP::_GP('crystal', 0.0)));
        $TransportDeuterium = max(0, round(HTTP::_GP('deuterium', 0.0)));
        $stayTime = HTTP::_GP('staytime', 0);
        $token = HTTP::_GP('token', '');
        $config = Config::get();
        if (!isset($_SESSION['fleet'][$token])) {
            FleetFunctions::GotoFleetPage(1);
        }
        if ($_SESSION['fleet'][$token]['time'] < TIMESTAMP - 600) {
            unset($_SESSION['fleet'][$token]);
            FleetFunctions::GotoFleetPage(0);
        }
        $formData = $_SESSION['fleet'][$token];
        unset($_SESSION['fleet'][$token]);
        $distance = $formData['distance'];
        $targetGalaxy = $formData['targetGalaxy'];
        $targetSystem = $formData['targetSystem'];
        $targetPlanet = $formData['targetPlanet'];
        $targetType = $formData['targetType'];
        $fleetGroup = $formData['fleetGroup'];
        $fleetArray = $formData['fleet'];
        $fleetStorage = $formData['fleetRoom'];
        $fleetSpeed = $formData['fleetSpeed'];
        if ($targetMission != 2) {
            $fleetGroup = 0;
        }
        if ($PLANET['galaxy'] == $targetGalaxy && $PLANET['system'] == $targetSystem && $PLANET['planet'] == $targetPlanet && $PLANET['planet_type'] == $targetType) {
            $this->printMessage($LNG['fl_error_same_planet'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleet1')));
        }
        if ($targetGalaxy < 1 || $targetGalaxy > $config->max_galaxy || $targetSystem < 1 || $targetSystem > $config->max_system || $targetPlanet < 1 || $targetPlanet > $config->max_planets + 1 || $targetType !== 1 && $targetType !== 2 && $targetType !== 3) {
            $this->printMessage($LNG['fl_invalid_target'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleet1')));
        }
        if ($targetMission == 3 && $TransportMetal + $TransportCrystal + $TransportDeuterium < 1) {
            $this->printMessage($LNG['fl_no_noresource'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleet2')));
        }
        $ActualFleets = FleetFunctions::GetCurrentFleets($USER['id']);
        if (FleetFunctions::GetMaxFleetSlots($USER) <= $ActualFleets) {
            $this->printMessage($LNG['fl_no_slots'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleetTable')));
        }
        $ACSTime = 0;
        $db = Database::get();
        if (!empty($fleetGroup)) {
            $sql = "SELECT ankunft FROM %%USERS_ACS%% INNER JOIN %%AKS%% ON id = acsID\n\t\t\tWHERE acsID = :acsID AND :maxFleets > (SELECT COUNT(*) FROM %%FLEETS%% WHERE fleet_group = :acsID);";
            $ACSTime = $db->selectSingle($sql, array(':acsID' => $fleetGroup, ':maxFleets' => $config->max_fleets_per_acs), 'ankunft');
            if (empty($ACSTime)) {
                $fleetGroup = 0;
                $targetMission = 1;
            }
        }
        $sql = "SELECT id, id_owner, der_metal, der_crystal, destruyed, ally_deposit FROM %%PLANETS%% WHERE universe = :universe AND galaxy = :targetGalaxy AND system = :targetSystem AND planet = :targetPlanet AND planet_type = :targetType;";
        $targetPlanetData = $db->selectSingle($sql, array(':universe' => Universe::current(), ':targetGalaxy' => $targetGalaxy, ':targetSystem' => $targetSystem, ':targetPlanet' => $targetPlanet, ':targetType' => $targetType == 2 ? 1 : $targetType));
        if ($targetMission == 7) {
            if (!empty($targetPlanetData)) {
                $this->printMessage($LNG['fl_target_exists'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleet1')));
            }
            if ($targetType != 1) {
                $this->printMessage($LNG['fl_only_planets_colonizable'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleet1')));
            }
        }
        if ($targetMission == 7 || $targetMission == 15) {
            $targetPlanetData = array('id' => 0, 'id_owner' => 0, 'planettype' => 1);
        } else {
            if ($targetPlanetData["destruyed"] != 0) {
                $this->printMessage($LNG['fl_no_target'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleet1')));
            }
            if (empty($targetPlanetData)) {
                $this->printMessage($LNG['fl_no_target'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleet1')));
            }
        }
        foreach ($fleetArray as $Ship => $Count) {
            if ($Count > $PLANET[$resource[$Ship]]) {
                $this->printMessage($LNG['fl_not_all_ship_avalible'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleetTable')));
            }
        }
        if ($targetMission == 11) {
            $activeExpedition = FleetFunctions::GetCurrentFleets($USER['id'], 11, true);
            $maxExpedition = FleetFunctions::getDMMissionLimit($USER);
            if ($activeExpedition >= $maxExpedition) {
                $this->printMessage($LNG['fl_no_expedition_slot'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleetTable')));
            }
        } elseif ($targetMission == 15) {
            $activeExpedition = FleetFunctions::GetCurrentFleets($USER['id'], 15, true);
            $maxExpedition = FleetFunctions::getExpeditionLimit($USER);
            if ($activeExpedition >= $maxExpedition) {
                $this->printMessage($LNG['fl_no_expedition_slot'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleetTable')));
            }
        }
        $usedPlanet = isset($targetPlanetData['id_owner']);
        $myPlanet = $usedPlanet && $targetPlanetData['id_owner'] == $USER['id'];
        $targetPlayerData = array();
        if ($targetMission == 7 || $targetMission == 15) {
            $targetPlayerData = array('id' => 0, 'onlinetime' => TIMESTAMP, 'ally_id' => 0, 'urlaubs_modus' => 0, 'authattack' => 0, 'total_points' => 0);
        } elseif ($myPlanet) {
            $targetPlayerData = $USER;
        } elseif (!empty($targetPlanetData['id_owner'])) {
            $sql = "SELECT user.id, user.onlinetime, user.ally_id, user.urlaubs_modus, user.banaday, user.authattack,\n                stat.total_points\n                FROM %%USERS%% as user\n                LEFT JOIN %%STATPOINTS%% as stat ON stat.id_owner = user.id AND stat.stat_type = '1'\n                WHERE user.id = :ownerID;";
            $targetPlayerData = $db->selectSingle($sql, array(':ownerID' => $targetPlanetData['id_owner']));
        }
        if (empty($targetPlayerData)) {
            $this->printMessage($LNG['fl_empty_target'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleet1')));
        }
        $MisInfo = array();
        $MisInfo['galaxy'] = $targetGalaxy;
        $MisInfo['system'] = $targetSystem;
        $MisInfo['planet'] = $targetPlanet;
        $MisInfo['planettype'] = $targetType;
        $MisInfo['IsAKS'] = $fleetGroup;
        $MisInfo['Ship'] = $fleetArray;
        $availableMissions = FleetFunctions::GetFleetMissions($USER, $MisInfo, $targetPlanetData);
        if (!in_array($targetMission, $availableMissions['MissionSelector'])) {
            $this->printMessage($LNG['fl_invalid_mission'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleet2')));
        }
        if ($targetMission != 8 && IsVacationMode($targetPlayerData)) {
            $this->printMessage($LNG['fl_target_exists'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleet1')));
        }
        if ($targetMission == 1 || $targetMission == 2 || $targetMission == 9) {
            if (FleetFunctions::CheckBash($targetPlanetData['id'])) {
                $this->printMessage($LNG['fl_bash_protection'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleetTable')));
            }
        }
        if ($targetMission == 1 || $targetMission == 2 || $targetMission == 5 || $targetMission == 6 || $targetMission == 9) {
            if (Config::get()->adm_attack == 1 && $targetPlayerData['authattack'] > $USER['authlevel']) {
                $this->printMessage($LNG['fl_admin_attack'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleetTable')));
            }
            $sql = 'SELECT total_points
			FROM %%STATPOINTS%%
			WHERE id_owner = :userId AND stat_type = :statType';
            $USER += Database::get()->selectSingle($sql, array(':userId' => $USER['id'], ':statType' => 1));
            $IsNoobProtec = CheckNoobProtec($USER, $targetPlayerData, $targetPlayerData);
            if ($IsNoobProtec['NoobPlayer']) {
                $this->printMessage($LNG['fl_player_is_noob'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleetTable')));
            }
            if ($IsNoobProtec['StrongPlayer']) {
                $this->printMessage($LNG['fl_player_is_strong'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleetTable')));
            }
        }
        if ($targetMission == 5) {
            if ($targetPlayerData['ally_id'] != $USER['ally_id']) {
                $sql = "SELECT COUNT(*) as state FROM %%BUDDY%%\n\t\t\t\tWHERE id NOT IN (SELECT id FROM %%BUDDY_REQUEST%% WHERE %%BUDDY_REQUEST%%.id = %%BUDDY%%.id) AND\n\t\t\t\t(owner = :ownerID AND sender = :userID) OR (owner = :userID AND sender = :ownerID);";
                $buddy = $db->selectSingle($sql, array(':ownerID' => $targetPlayerData['id'], ':userID' => $USER['id']), 'state');
                if ($buddy == 0) {
                    $this->printMessage($LNG['fl_no_same_alliance'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleetTable')));
                }
            }
        }
        $fleetMaxSpeed = FleetFunctions::GetFleetMaxSpeed($fleetArray, $USER);
        $SpeedFactor = FleetFunctions::GetGameSpeedFactor();
        $duration = FleetFunctions::GetMissionDuration($fleetSpeed, $fleetMaxSpeed, $distance, $SpeedFactor, $USER);
        $consumption = FleetFunctions::GetFleetConsumption($fleetArray, $duration, $distance, $USER, $SpeedFactor);
        if ($PLANET[$resource[903]] < $consumption) {
            $this->printMessage($LNG['fl_not_enough_deuterium'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleetTable')));
        }
        $StayDuration = 0;
        if ($targetMission == 5 || $targetMission == 11 || $targetMission == 15) {
            if (!isset($availableMissions['StayBlock'][$stayTime])) {
                $this->printMessage($LNG['fl_hold_time_not_exists'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleetTable')));
            }
            $StayDuration = round($availableMissions['StayBlock'][$stayTime] * 3600, 0);
        }
        $fleetStorage -= $consumption;
        $fleetResource = array(901 => min($TransportMetal, floor($PLANET[$resource[901]])), 902 => min($TransportCrystal, floor($PLANET[$resource[902]])), 903 => min($TransportDeuterium, floor($PLANET[$resource[903]] - $consumption)));
        $StorageNeeded = array_sum($fleetResource);
        if ($StorageNeeded > $fleetStorage) {
            $this->printMessage($LNG['fl_not_enough_space'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=fleetTable')));
        }
        $PLANET[$resource[901]] -= $fleetResource[901];
        $PLANET[$resource[902]] -= $fleetResource[902];
        $PLANET[$resource[903]] -= $fleetResource[903] + $consumption;
        $fleetStartTime = $duration + TIMESTAMP;
        $timeDifference = round(max(0, $fleetStartTime - $ACSTime));
        if ($fleetGroup != 0) {
            if ($timeDifference != 0) {
                FleetFunctions::setACSTime($timeDifference, $fleetGroup);
            } else {
                $fleetStartTime = $ACSTime;
            }
        }
        $fleetStayTime = $fleetStartTime + $StayDuration;
        $fleetEndTime = $fleetStayTime + $duration;
        FleetFunctions::sendFleet($fleetArray, $targetMission, $USER['id'], $PLANET['id'], $PLANET['galaxy'], $PLANET['system'], $PLANET['planet'], $PLANET['planet_type'], $targetPlanetData['id_owner'], $targetPlanetData['id'], $targetGalaxy, $targetSystem, $targetPlanet, $targetType, $fleetResource, $fleetStartTime, $fleetStayTime, $fleetEndTime, $fleetGroup);
        foreach ($fleetArray as $Ship => $Count) {
            $fleetList[$LNG['tech'][$Ship]] = $Count;
        }
        $this->tplObj->gotoside('game.php?page=fleetTable');
        $this->assign(array('targetMission' => $targetMission, 'distance' => $distance, 'consumption' => $consumption, 'from' => $PLANET['galaxy'] . ":" . $PLANET['system'] . ":" . $PLANET['planet'], 'destination' => $targetGalaxy . ":" . $targetSystem . ":" . $targetPlanet, 'fleetStartTime' => _date($LNG['php_tdformat'], $fleetStartTime, $USER['timezone']), 'fleetEndTime' => _date($LNG['php_tdformat'], $fleetEndTime, $USER['timezone']), 'MaxFleetSpeed' => $fleetMaxSpeed, 'FleetList' => $fleetArray));
        $this->display('page.fleetStep3.default.tpl');
    }
Ejemplo n.º 23
0
 protected function getPageData()
 {
     global $LNG;
     $config = Config::get();
     $this->tplObj->assign_vars(array('recaptchaEnable' => $config->capaktiv, 'recaptchaPublicKey' => $config->cappublic, 'gameName' => $config->game_name, 'facebookEnable' => $config->fb_on, 'fb_key' => $config->fb_apikey, 'mailEnable' => $config->mail_active, 'reg_close' => $config->reg_closed, 'referralEnable' => $config->ref_active, 'analyticsEnable' => $config->ga_active, 'analyticsUID' => $config->ga_key, 'lang' => $LNG->getLanguage(), 'UNI' => Universe::current(), 'VERSION' => $config->VERSION, 'REV' => substr($config->VERSION, -4), 'languages' => Language::getAllowedLangs(false), 'loginInfo' => '', 'universeSelect' => $this->getUniverseSelector(), 'lastUni' => Universe::getLastUni(), 'metaTitle' => $LNG['metaTitle'], 'metaDescription' => $LNG['metaDescription'], 'metaKeywords' => $LNG['metaKeywords']));
 }
Ejemplo n.º 24
0
    public function getLoginData()
    {
        $user = $this->oidObj->getAttributes();
        $sql = 'SELECT
		user.id, user.username, user.dpath, user.authlevel, user.id_planet
		FROM %%USERS_AUTH%%
		INNER JOIN %%USERS%% user ON auth.id = user.id AND user.universe = :universe
		WHERE auth.account = :email AND mode = :mode;';
        return Database::get()->select($sql, array(':universe' => Universe::current(), ':email' => $user['contact/email'], ':mode' => $this->oidObj->identity));
    }
Ejemplo n.º 25
0
 public static function sendMessage($userId, $senderId, $senderName, $messageType, $subject, $text, $time, $parentID = NULL, $unread = 1, $universe = NULL)
 {
     if (is_null($universe)) {
         $universe = Universe::current();
     }
     $db = Database::get();
     $sql = "INSERT INTO %%MESSAGES%% SET\n\t\tmessage_owner\t\t= :userId,\n\t\tmessage_sender\t\t= :sender,\n\t\tmessage_time\t\t= :time,\n\t\tmessage_type\t\t= :type,\n\t\tmessage_from\t\t= :from,\n\t\tmessage_subject \t= :subject,\n\t\tmessage_text\t\t= :text,\n\t\tmessage_unread\t\t= :unread,\n\t\tmessage_universe \t= :universe;";
     $db->insert($sql, array(':userId' => $userId, ':sender' => $senderId, ':time' => $time, ':type' => $messageType, ':from' => $senderName, ':subject' => $subject, ':text' => $text, ':unread' => $unread, ':universe' => $universe));
 }
Ejemplo n.º 26
0
 function show()
 {
     global $USER, $LNG;
     $who = HTTP::_GP('who', 1);
     $type = HTTP::_GP('type', 1);
     $range = HTTP::_GP('range', 1);
     switch ($type) {
         case 2:
             $Order = "fleet_rank";
             $Points = "fleet_points";
             $Rank = "fleet_rank";
             $OldRank = "fleet_old_rank";
             break;
         case 3:
             $Order = "tech_rank";
             $Points = "tech_points";
             $Rank = "tech_rank";
             $OldRank = "tech_old_rank";
             break;
         case 4:
             $Order = "build_rank";
             $Points = "build_points";
             $Rank = "build_rank";
             $OldRank = "build_old_rank";
             break;
         case 5:
             $Order = "defs_rank";
             $Points = "defs_points";
             $Rank = "defs_rank";
             $OldRank = "defs_old_rank";
             break;
         default:
             $Order = "total_rank";
             $Points = "total_points";
             $Rank = "total_rank";
             $OldRank = "total_old_rank";
             break;
     }
     $RangeList = array();
     $db = Database::get();
     $config = Config::get();
     switch ($who) {
         case 1:
             $MaxUsers = $config->users_amount;
             $range = min($range, $MaxUsers);
             $LastPage = max(1, ceil($MaxUsers / 100));
             for ($Page = 0; $Page < $LastPage; $Page++) {
                 $PageValue = $Page * 100 + 1;
                 $PageRange = $PageValue + 99;
                 $Selector['range'][$PageValue] = $PageValue . "-" . $PageRange;
             }
             $start = max(floor(($range - 1) / 100) * 100, 0);
             if ($config->stat == 2) {
                 $sql = "SELECT DISTINCT s.*, u.id, u.username, u.ally_id, a.ally_name FROM %%STATPOINTS%% as s\n\t\t\t\t\tINNER JOIN %%USERS%% as u ON u.id = s.id_owner\n\t\t\t\t\tLEFT JOIN %%ALLIANCE%% as a ON a.id = s.id_ally\n\t\t\t\t\tWHERE s.universe = :universe AND s.stat_type = 1 AND u.authlevel < :authLevel\n\t\t\t\t\tORDER BY " . $Order . " ASC LIMIT :offset, :limit;";
                 $query = $db->select($sql, array(':universe' => Universe::current(), ':authLevel' => $config->stat_level, ':offset' => $start, ':limit' => 100));
             } else {
                 $sql = "SELECT DISTINCT s.*, u.id, u.username, u.ally_id, a.ally_name FROM %%STATPOINTS%% as s\n\t\t\t\t\tINNER JOIN %%USERS%% as u ON u.id = s.id_owner\n\t\t\t\t\tLEFT JOIN %%ALLIANCE%% as a ON a.id = s.id_ally\n\t\t\t\t\tWHERE s.universe = :universe AND s.stat_type = 1\n\t\t\t\t\tORDER BY " . $Order . " ASC LIMIT :offset, :limit;";
                 $query = $db->select($sql, array(':universe' => Universe::current(), ':offset' => $start, ':limit' => 100));
             }
             $RangeList = array();
             foreach ($query as $StatRow) {
                 $RangeList[] = array('id' => $StatRow['id'], 'name' => $StatRow['username'], 'points' => pretty_number($StatRow[$Points]), 'allyid' => $StatRow['ally_id'], 'rank' => $StatRow[$Rank], 'allyname' => $StatRow['ally_name'], 'ranking' => $StatRow[$OldRank] - $StatRow[$Rank]);
             }
             break;
         case 2:
             $sql = "SELECT COUNT(*) as state FROM %%ALLIANCE%% WHERE `ally_universe` = :universe;";
             $MaxAllys = $db->selectSingle($sql, array(':universe' => Universe::current()), 'state');
             $range = min($range, $MaxAllys);
             $LastPage = max(1, ceil($MaxAllys / 100));
             for ($Page = 0; $Page < $LastPage; $Page++) {
                 $PageValue = $Page * 100 + 1;
                 $PageRange = $PageValue + 99;
                 $Selector['range'][$PageValue] = $PageValue . "-" . $PageRange;
             }
             $start = max(floor(($range - 1) / 100) * 100, 0);
             $sql = 'SELECT DISTINCT s.*, a.id, a.ally_members, a.ally_name FROM %%STATPOINTS%% as s
             INNER JOIN %%ALLIANCE%% as a ON a.id = s.id_owner
             WHERE universe = :universe AND stat_type = 2
             ORDER BY ' . $Order . ' ASC LIMIT :offset, :limit;';
             $query = $db->select($sql, array(':universe' => Universe::current(), ':offset' => $start, ':limit' => 100));
             foreach ($query as $StatRow) {
                 $RangeList[] = array('id' => $StatRow['id'], 'name' => $StatRow['ally_name'], 'members' => $StatRow['ally_members'], 'rank' => $StatRow[$Rank], 'mppoints' => pretty_number(floor($StatRow[$Points] / $StatRow['ally_members'])), 'points' => pretty_number($StatRow[$Points]), 'ranking' => $StatRow[$OldRank] - $StatRow[$Rank]);
             }
             break;
     }
     $Selector['who'] = array(1 => $LNG['st_player'], 2 => $LNG['st_alliance']);
     $Selector['type'] = array(1 => $LNG['st_points'], 2 => $LNG['st_fleets'], 3 => $LNG['st_researh'], 4 => $LNG['st_buildings'], 5 => $LNG['st_defenses']);
     require_once 'includes/classes/Cronjob.class.php';
     $this->assign(array('Selectors' => $Selector, 'who' => $who, 'type' => $type, 'range' => floor(($range - 1) / 100) * 100 + 1, 'RangeList' => $RangeList, 'CUser_ally' => $USER['ally_id'], 'CUser_id' => $USER['id'], 'stat_date' => _date($LNG['php_tdformat'], Cronjob::getLastExecutionTime('statistic'), $USER['timezone'])));
     $this->display('page.statistics.default.tpl');
 }
Ejemplo n.º 27
0
                break;
            case 7:
                $template->show('ins_acc.tpl');
                break;
            case 8:
                $username = HTTP::_GP('username', '', UTF8_SUPPORT);
                $password = HTTP::_GP('password', '', true);
                $mail = HTTP::_GP('email', '');
                // Get Salt.
                require 'includes/config.php';
                require 'includes/vars.php';
                $hashPassword = PlayerUtil::cryptPassword($password);
                if (empty($username) || empty($password) || empty($mail)) {
                    $template->assign(array('message' => $LNG['step8_need_fields'], 'username' => $username, 'mail' => $mail));
                    $template->show('ins_step8error.tpl');
                    exit;
                }
                list($userId, $planetId) = PlayerUtil::createPlayer(Universe::current(), $username, $hashPassword, $mail, $LNG->getLanguage(), 1, 1, 2, NULL, AUTH_ADM);
                $session = Session::create();
                $session->userId = $userId;
                $session->adminAccess = 1;
                @unlink($enableInstallToolFile);
                $template->show('ins_step8.tpl');
                break;
        }
        break;
    default:
        $template->assign(array('intro_text' => $LNG['intro_text'], 'intro_welcome' => $LNG['intro_welcome'], 'intro_install' => $LNG['intro_install']));
        $template->show('ins_intro.tpl');
        break;
}
Ejemplo n.º 28
0
    function checkTarget()
    {
        global $PLANET, $LNG, $USER, $resource;
        $targetGalaxy = HTTP::_GP('galaxy', 0);
        $targetSystem = HTTP::_GP('system', 0);
        $targetPlanet = HTTP::_GP('planet', 0);
        $targetPlanetType = HTTP::_GP('planet_type', 1);
        if ($targetGalaxy == $PLANET['galaxy'] && $targetSystem == $PLANET['system'] && $targetPlanet == $PLANET['planet'] && $targetPlanetType == $PLANET['planet_type']) {
            $this->sendJSON($LNG['fl_error_same_planet']);
        }
        // If target is expedition
        if ($targetPlanet != Config::get()->max_planets + 1) {
            $db = Database::get();
            $sql = "SELECT u.id, u.urlaubs_modus, u.user_lastip, u.authattack,\n            \tp.destruyed, p.der_metal, p.der_crystal, p.destruyed\n                FROM %%USERS%% as u, %%PLANETS%% as p WHERE\n                p.universe = :universe AND\n                p.galaxy = :targetGalaxy AND\n                p.system = :targetSystem AND\n                p.planet = :targetPlanet  AND\n                p.planet_type = :targetType AND\n                u.id = p.id_owner;";
            $planetData = $db->selectSingle($sql, array(':universe' => Universe::current(), ':targetGalaxy' => $targetGalaxy, ':targetSystem' => $targetSystem, ':targetPlanet' => $targetPlanet, ':targetType' => $targetPlanetType == 2 ? 1 : $targetPlanetType));
            if ($targetPlanetType == 3 && !isset($planetData)) {
                $this->sendJSON($LNG['fl_error_no_moon']);
            }
            if ($targetPlanetType != 2 && $planetData['urlaubs_modus']) {
                $this->sendJSON($LNG['fl_in_vacation_player']);
            }
            if ($planetData['id'] != $USER['id'] && Config::get()->adm_attack == 1 && $planetData['authattack'] > $USER['authlevel']) {
                $this->sendJSON($LNG['fl_admin_attack']);
            }
            if ($planetData['destruyed'] != 0) {
                $this->sendJSON($LNG['fl_error_not_avalible']);
            }
            if ($targetPlanetType == 2 && $planetData['der_metal'] == 0 && $planetData['der_crystal'] == 0) {
                $this->sendJSON($LNG['fl_error_empty_derbis']);
            }
            $sql = 'SELECT (
				(SELECT COUNT(*) FROM %%MULTI%% WHERE userID = :userID) +
				(SELECT COUNT(*) FROM %%MULTI%% WHERE userID = :dataID)
			) as count;';
            $multiCount = $db->selectSingle($sql, array(':userID' => $USER['id'], ':dataID' => $planetData['id']), 'count');
            if (ENABLE_MULTIALERT && $USER['id'] != $planetData['id'] && $USER['authlevel'] != AUTH_ADM && $USER['user_lastip'] == $planetData['user_lastip'] && $multiCount != 2) {
                $this->sendJSON($LNG['fl_multi_alarm']);
            }
        } else {
            if ($USER[$resource[124]] == 0) {
                $this->sendJSON($LNG['fl_target_not_exists']);
            }
            $activeExpedition = FleetFunctions::GetCurrentFleets($USER['id'], 15, true);
            if ($activeExpedition >= FleetFunctions::getExpeditionLimit($USER)) {
                $this->sendJSON($LNG['fl_no_expedition_slot']);
            }
        }
        $this->sendJSON('OK');
    }
Ejemplo n.º 29
0
    public function show()
    {
        global $USER, $PLANET, $LNG, $reslist, $resource;
        $missileCount = $PLANET['interplanetary_misil'];
        $targetGalaxy = HTTP::_GP('galaxy', 0);
        $targetSystem = HTTP::_GP('system', 0);
        $targetPlanet = HTTP::_GP('planet', 0);
        $targetType = HTTP::_GP('type', 0);
        $anz = min(HTTP::_GP('SendMI', 0), $missileCount);
        $primaryTarget = HTTP::_GP('Target', 0);
        $db = Database::get();
        $sql = "SELECT id, id_owner FROM %%PLANETS%%\n        WHERE universe = :universe AND galaxy = :targetGalaxy\n        AND system = :targetSystem AND planet = :targetPlanet AND planet_type = :targetType;";
        $target = $db->selectSingle($sql, array(':universe' => Universe::current(), ':targetGalaxy' => $targetGalaxy, ':targetSystem' => $targetSystem, ':targetPlanet' => $targetPlanet, ':targetType' => $targetType));
        $Range = FleetFunctions::GetMissileRange($USER[$resource[117]]);
        $systemMin = $PLANET['system'] - $Range;
        $systemMax = $PLANET['system'] + $Range;
        $error = "";
        if (IsVacationMode($USER)) {
            $error = $LNG['fl_vacation_mode_active'];
        } elseif ($PLANET['silo'] < 4) {
            $error = $LNG['ma_silo_level'];
        } elseif ($USER['impulse_motor_tech'] == 0) {
            $error = $LNG['ma_impulse_drive_required'];
        } elseif ($targetGalaxy != $PLANET['galaxy'] || $targetSystem < $systemMin || $targetSystem > $systemMax) {
            $error = $LNG['ma_not_send_other_galaxy'];
        } elseif (!$target) {
            $error = $LNG['ma_planet_doesnt_exists'];
        } elseif (!in_array($primaryTarget, $reslist['defense']) && $primaryTarget != 0) {
            $error = $LNG['ma_wrong_target'];
        } elseif ($missileCount == 0) {
            $error = $LNG['ma_no_missiles'];
        } elseif ($anz <= 0) {
            $error = $LNG['ma_add_missile_number'];
        }
        $targetUser = GetUserByID($target['id_owner'], array('onlinetime', 'banaday', 'urlaubs_modus', 'authattack'));
        if (Config::get()->adm_attack == 1 && $targetUser['authattack'] > $USER['authlevel']) {
            $error = $LNG['fl_admin_attack'];
        } elseif ($targetUser['urlaubs_modus']) {
            $error = $LNG['fl_in_vacation_player'];
        }
        $sql = "SELECT total_points FROM %%STATPOINTS%% WHERE stat_type = '1' AND id_owner = :ownerId;";
        $User2Points = $db->selectSingle($sql, array(':ownerId' => $target['id_owner']));
        $sql = 'SELECT total_points
		FROM %%STATPOINTS%%
		WHERE id_owner = :userId AND stat_type = :statType';
        $USER += Database::get()->selectSingle($sql, array(':userId' => $USER['id'], ':statType' => 1));
        $IsNoobProtec = CheckNoobProtec($USER, $User2Points, $targetUser);
        if ($IsNoobProtec['NoobPlayer']) {
            $error = $LNG['fl_week_player'];
        } elseif ($IsNoobProtec['StrongPlayer']) {
            $error = $LNG['fl_strong_player'];
        }
        if ($error != "") {
            $this->printMessage($error);
        }
        $Duration = FleetFunctions::GetMIPDuration($PLANET['system'], $targetSystem);
        $DefenseLabel = $primaryTarget == 0 ? $LNG['ma_all'] : $LNG['tech'][$primaryTarget];
        $fleetArray = array(503 => $anz);
        $fleetStartTime = TIMESTAMP + $Duration;
        $fleetStayTime = $fleetStartTime;
        $fleetEndTime = $fleetStartTime;
        $fleetResource = array(901 => 0, 902 => 0, 903 => 0);
        FleetFunctions::sendFleet($fleetArray, 10, $USER['id'], $PLANET['id'], $PLANET['galaxy'], $PLANET['system'], $PLANET['planet'], $PLANET['planet_type'], $target['id_owner'], $target['id'], $targetGalaxy, $targetSystem, $targetPlanet, $targetType, $fleetResource, $fleetStartTime, $fleetStayTime, $fleetEndTime, 0, $primaryTarget);
        $this->printMessage("<b>" . $anz . "</b>" . $LNG['ma_missiles_sended'] . $DefenseLabel);
    }
Ejemplo n.º 30
0
 private function sendDefault()
 {
     global $USER, $LNG, $THEME;
     $adminprotection = HTTP::_GP('adminprotection', 0);
     $username = HTTP::_GP('username', $USER['username'], UTF8_SUPPORT);
     $password = HTTP::_GP('password', '');
     $newpassword = HTTP::_GP('newpassword', '');
     $newpassword2 = HTTP::_GP('newpassword2', '');
     $email = HTTP::_GP('email', $USER['email']);
     $timezone = HTTP::_GP('timezone', '');
     $language = HTTP::_GP('language', '');
     $planetSort = HTTP::_GP('planetSort', 0);
     $planetOrder = HTTP::_GP('planetOrder', 0);
     $theme = HTTP::_GP('theme', $THEME->getThemeName());
     $queueMessages = HTTP::_GP('queueMessages', 0);
     $spyMessagesMode = HTTP::_GP('spyMessagesMode', 0);
     $spycount = HTTP::_GP('spycount', 1.0);
     $fleetactions = HTTP::_GP('fleetactions', 5);
     $galaxySpy = HTTP::_GP('galaxySpy', 0);
     $galaxyMessage = HTTP::_GP('galaxyMessage', 0);
     $galaxyBuddyList = HTTP::_GP('galaxyBuddyList', 0);
     $galaxyMissle = HTTP::_GP('galaxyMissle', 0);
     $blockPM = HTTP::_GP('blockPM', 0);
     $vacation = HTTP::_GP('vacation', 0);
     $delete = HTTP::_GP('delete', 0);
     // Vertify
     $adminprotection = $adminprotection == 1 && $USER['authlevel'] != AUTH_USR ? $USER['authlevel'] : 0;
     $spycount = min(max(round($spycount), 1), 4294967295);
     $fleetactions = min(max($fleetactions, 1), 99);
     $language = array_key_exists($language, $LNG->getAllowedLangs(false)) ? $language : $LNG->getLanguage();
     $theme = array_key_exists($theme, Theme::getAvalibleSkins()) ? $theme : $THEME->getThemeName();
     $db = Database::get();
     if (!empty($username) && $USER['username'] != $username) {
         if (PlayerUtil::isNameValid($username)) {
             $this->printMessage($LNG['op_user_name_no_alphanumeric'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=settings')));
         } elseif ($USER['uctime'] >= TIMESTAMP - USERNAME_CHANGETIME) {
             $this->printMessage($LNG['op_change_name_pro_week'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=settings')));
         } else {
             $sql = "SELECT\n\t\t\t\t\t(SELECT COUNT(*) FROM %%USERS%% WHERE universe = :universe AND username = :username) +\n\t\t\t\t\t(SELECT COUNT(*) FROM %%USERS_VALID%% WHERE universe = :universe AND username = :username)\n\t\t\t\tAS count";
             $Count = $db->selectSingle($sql, array(':universe' => Universe::current(), ':username' => $username), 'count');
             if (!empty($Count)) {
                 $this->printMessage(sprintf($LNG['op_change_name_exist'], $username), array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=settings')));
             } else {
                 $sql = "UPDATE %%USERS%% SET username = :username, uctime = :timestampt WHERE id = :userID;";
                 $db->update($sql, array(':username' => $username, ':userID' => $USER['id'], ':timestamp' => TIMESTAMP));
                 Session::load()->delete();
             }
         }
     }
     if (!empty($newpassword) && PlayerUtil::cryptPassword($password) == $USER["password"] && $newpassword == $newpassword2) {
         $newpass = PlayerUtil::cryptPassword($newpassword);
         $sql = "UPDATE %%USERS%% SET password = :newpass WHERE id = :userID;";
         $db->update($sql, array(':newpass' => $newpass, ':userID' => $USER['id']));
         Session::load()->delete();
     }
     if (!empty($email) && $email != $USER['email']) {
         if (PlayerUtil::cryptPassword($password) != $USER['password']) {
             $this->printMessage($LNG['op_need_pass_mail'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=settings')));
         } elseif (!ValidateAddress($email)) {
             $this->printMessage($LNG['op_not_vaild_mail'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=settings')));
         } else {
             $sql = "SELECT\n\t\t\t\t\t\t\t(SELECT COUNT(*) FROM %%USERS%% WHERE id != :userID AND universe = :universe AND (email = :email OR email_2 = :email)) +\n\t\t\t\t\t\t\t(SELECT COUNT(*) FROM %%USERS_VALID%% WHERE universe = :universe AND email = :email)\n\t\t\t\t\t\tas COUNT";
             $Count = $db->selectSingle($sql, array(':universe' => Universe::current(), ':userID' => $USER['id'], ':email' => $email), 'count');
             if (!empty($Count)) {
                 $this->printMessage(sprintf($LNG['op_change_mail_exist'], $email), array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=settings')));
             } else {
                 $sql = "UPDATE %%USERS%% SET email = :email, setmail = :time WHERE id = :userID;";
                 $db->update($sql, array(':email' => $email, ':time' => TIMESTAMP + 604800, ':userID' => $USER['id']));
             }
         }
     }
     if ($vacation == 1) {
         if (!$this->CheckVMode()) {
             $this->printMessage($LNG['op_cant_activate_vacation_mode'], array(array('label' => $LNG['sys_back'], 'url' => 'game.php?page=settings')));
         } else {
             $sql = "UPDATE %%USERS%% SET urlaubs_modus = '1', urlaubs_until = :time WHERE id = :userID";
             $db->update($sql, array(':userID' => $USER['id'], ':time' => TIMESTAMP + Config::get()->vmode_min_time));
             $sql = "UPDATE %%PLANETS%% SET energy_used = '0', energy = '0', metal_mine_porcent = '0', crystal_mine_porcent = '0', deuterium_sintetizer_porcent = '0', solar_plant_porcent = '0', fusion_plant_porcent = '0', solar_satelit_porcent = '0', metal_perhour = '0', crystal_perhour = '0', deuterium_perhour = '0' WHERE id_owner = :userID;";
             $db->update($sql, array(':userID' => $USER['id']));
         }
     }
     if ($delete == 1) {
         $sql = "UPDATE %%USERS%% SET db_deaktjava = :timestamp WHERE id = :userID;";
         $db->update($sql, array(':userID' => $USER['id'], ':timestamp' => TIMESTAMP));
     } else {
         $sql = "UPDATE %%USERS%% SET db_deaktjava = 0 WHERE id = :userID;";
         $db->update($sql, array(':userID' => $USER['id']));
     }
     $sql = "UPDATE %%USERS%% SET\n\t\tdpath\t\t\t\t\t= :theme,\n\t\ttimezone\t\t\t\t= :timezone,\n\t\tplanet_sort\t\t\t\t= :planetSort,\n\t\tplanet_sort_order\t\t= :planetOrder,\n\t\tspio_anz\t\t\t\t= :spyCount,\n\t\tsettings_fleetactions\t= :fleetActions,\n\t\tsettings_esp\t\t\t= :galaxySpy,\n\t\tsettings_wri\t\t\t= :galaxyMessage,\n\t\tsettings_bud\t\t\t= :galaxyBuddyList,\n\t\tsettings_mis\t\t\t= :galaxyMissle,\n\t\tsettings_blockPM\t\t= :blockPM,\n\t\tauthattack\t\t\t\t= :adminProtection,\n\t\tlang\t\t\t\t\t= :language,\n\t\thof\t\t\t\t\t\t= :queueMessages,\n\t\tspyMessagesMode\t\t\t= :spyMessagesMode\n\t\tWHERE id = :userID;";
     $db->update($sql, array(':theme' => $theme, ':timezone' => $timezone, ':planetSort' => $planetSort, ':planetOrder' => $planetOrder, ':spyCount' => $spycount, ':fleetActions' => $fleetactions, ':galaxySpy' => $galaxySpy, ':galaxyMessage' => $galaxyMessage, ':galaxyBuddyList' => $galaxyBuddyList, ':galaxyMissle' => $galaxyMissle, ':blockPM' => $blockPM, ':adminProtection' => $adminprotection, ':language' => $language, ':queueMessages' => $queueMessages, ':spyMessagesMode' => $spyMessagesMode, ':userID' => $USER['id']));
     $this->printMessage($LNG['op_options_changed'], array(array('label' => $LNG['sys_forward'], 'url' => 'game.php?page=settings')));
 }