Ejemplo n.º 1
0
 public function setUniverse(Universe $universe, $sync = true)
 {
     $this->universe = $universe;
     if ($sync) {
         $universe->addCelestialBodyTypeSpecs($this, false);
     }
 }
Ejemplo n.º 2
0
 function show()
 {
     global $LNG;
     $referralID = HTTP::_GP('ref', 0);
     if (!empty($referralID)) {
         $this->redirectTo('index.php?page=register&referralID=' . $referralID);
     }
     $universeSelect = array();
     foreach (Universe::availableUniverses() as $uniId) {
         $config = Config::get($uniId);
         $universeSelect[$uniId] = $config->uni_name . ($config->game_disable == 0 ? $LNG['uni_closed'] : '');
     }
     $Code = HTTP::_GP('code', 0);
     $loginCode = false;
     if (isset($LNG['login_error_' . $Code])) {
         $loginCode = $LNG['login_error_' . $Code];
     }
     $config = Config::get();
     $this->assign(array('universeSelect' => $universeSelect, 'code' => $loginCode, 'descHeader' => sprintf($LNG['loginWelcome'], $config->game_name), 'descText' => sprintf($LNG['loginServerDesc'], $config->game_name), 'loginInfo' => sprintf($LNG['loginInfo'], '<a href="index.php?page=rules">' . $LNG['menu_rules'] . '</a>')));
     $screenshots = array();
     $directoryIterator = new DirectoryIterator('styles/resource/images/login/screens/');
     foreach ($directoryIterator as $fileInfo) {
         /** @var $fileInfo DirectoryIterator */
         if (!$fileInfo->isFile()) {
             continue;
         }
         $thumbnail = 'styles/resource/images/login/screens/' . $fileInfo->getFilename();
         if (file_exists('styles/resource/images/login/screens/thumbnails/' . $fileInfo->getFilename())) {
             $thumbnail = 'styles/resource/images/login/screens/thumbnails/' . $fileInfo->getFilename();
         }
         $screenshots[] = array('path' => 'styles/resource/images/login/screens/' . $fileInfo->getFilename(), 'thumbnail' => $thumbnail);
     }
     $this->assign(array('screenshots' => $screenshots));
     $this->display('page.index.default.tpl');
 }
Ejemplo n.º 3
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.º 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');
 }
Ejemplo n.º 5
0
/**
 *  2Moons
 *  Copyright (C) 2012 Jan Kröpke
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @package 2Moons
 * @author Jan Kröpke <*****@*****.**>
 * @copyright 2012 Jan Kröpke <*****@*****.**>
 * @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License
 * @version 1.7.2 (2013-03-18)
 * @info $Id$
 * @link http://2moons.cc/
 */
function ShowMenuPage()
{
    global $USER;
    $template = new template();
    $template->assign_vars(array('supportticks' => $GLOBALS['DATABASE']->getFirstCell("SELECT COUNT(*) FROM " . TICKETS . " WHERE universe = " . Universe::getEmulated() . " AND status = 0;")));
    $template->show('ShowMenuPage.tpl');
}
Ejemplo n.º 6
0
 function send()
 {
     global $USER, $LNG;
     $ticketID = HTTP::_GP('id', 0);
     $message = HTTP::_GP('message', '', true);
     $change = HTTP::_GP('change_status', 0);
     $ticketDetail = $GLOBALS['DATABASE']->getFirstRow("SELECT ownerID, subject, status FROM " . TICKETS . " WHERE ticketID = " . $ticketID . ";");
     $status = $change ? $ticketDetail['status'] <= 1 ? 2 : 1 : 1;
     if (!$change && empty($message)) {
         HTTP::redirectTo('admin.php?page=support&mode=view&id=' . $ticketID);
     }
     $subject = "RE: " . $ticketDetail['subject'];
     if ($change && $status == 1) {
         $this->ticketObj->createAnswer($ticketID, $USER['id'], $USER['username'], $subject, $LNG['ti_admin_open'], $status);
     }
     if (!empty($message)) {
         $this->ticketObj->createAnswer($ticketID, $USER['id'], $USER['username'], $subject, $message, $status);
     }
     if ($change && $status == 2) {
         $this->ticketObj->createAnswer($ticketID, $USER['id'], $USER['username'], $subject, $LNG['ti_admin_close'], $status);
     }
     $subject = sprintf($LNG['sp_answer_message_title'], $ticketID);
     $text = sprintf($LNG['sp_answer_message'], $ticketID);
     PlayerUtil::sendMessage($ticketDetail['ownerID'], $USER['id'], $USER['username'], 4, $subject, $text, TIMESTAMP, NULL, 1, Universe::getEmulated());
     HTTP::redirectTo('admin.php?page=support');
 }
Ejemplo n.º 7
0
function ShowMultiIPPage()
{
    global $LNG;
    switch ($_GET['action']) {
        case 'known':
            $GLOBALS['DATABASE']->query("INSERT INTO " . MULTI . " SET userID = " . (int) $_GET['id'] . ";");
            HTTP::redirectTo("admin.php?page=multiips");
            break;
        case 'unknown':
            $GLOBALS['DATABASE']->query("DELETE FROM " . MULTI . " WHERE userID = " . (int) $_GET['id'] . ";");
            HTTP::redirectTo("admin.php?page=multiips");
            break;
    }
    $Query = $GLOBALS['DATABASE']->query("SELECT id, username, email, register_time, onlinetime, user_lastip, IFNULL(multiID, 0) as isKnown FROM " . USERS . " LEFT JOIN " . MULTI . " ON userID = id WHERE `universe` = '" . Universe::getEmulated() . "' AND user_lastip IN (SELECT user_lastip FROM " . USERS . " WHERE `universe` = '" . Universe::getEmulated() . "' GROUP BY user_lastip HAVING COUNT(*)>1) ORDER BY user_lastip, id ASC;");
    $IPs = array();
    while ($Data = $GLOBALS['DATABASE']->fetch_array($Query)) {
        if (!isset($IPs[$Data['user_lastip']])) {
            $IPs[$Data['user_lastip']] = array();
        }
        $Data['register_time'] = _date($LNG['php_tdformat'], $Data['register_time']);
        $Data['onlinetime'] = _date($LNG['php_tdformat'], $Data['onlinetime']);
        $IPs[$Data['user_lastip']][$Data['id']] = $Data;
    }
    $template = new template();
    $template->assign_vars(array('multiGroups' => $IPs));
    $template->show('MultiIPs.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.º 9
0
function ShowTeamspeakPage()
{
    global $LNG;
    $config = Config::get(Universe::getEmulated());
    if ($_POST) {
        $config_before = array('ts_timeout' => $config->ts_timeout, 'ts_modon' => $config->ts_modon, 'ts_server' => $config->ts_server, 'ts_tcpport' => $config->ts_tcpport, 'ts_udpport' => $config->ts_udpport, 'ts_version' => $config->ts_version, 'ts_login' => $config->ts_login, 'ts_password' => $config->ts_password, 'ts_cron_interval' => $config->ts_cron_interval);
        $ts_modon = isset($_POST['ts_on']) && $_POST['ts_on'] == 'on' ? 1 : 0;
        $ts_server = HTTP::_GP('ts_ip', '');
        $ts_tcpport = HTTP::_GP('ts_tcp', 0);
        $ts_udpport = HTTP::_GP('ts_udp', 0);
        $ts_timeout = HTTP::_GP('ts_to', 0);
        $ts_version = HTTP::_GP('ts_v', 0);
        $ts_login = HTTP::_GP('ts_login', '');
        $ts_password = HTTP::_GP('ts_password', '', true);
        $ts_cron_interval = HTTP::_GP('ts_cron', 0);
        $config_after = array('ts_timeout' => $ts_timeout, 'ts_modon' => $ts_modon, 'ts_server' => $ts_server, 'ts_tcpport' => $ts_tcpport, 'ts_udpport' => $ts_udpport, 'ts_version' => $ts_version, 'ts_login' => $ts_login, 'ts_password' => $ts_password, 'ts_cron_interval' => $ts_cron_interval);
        foreach ($config_after as $key => $value) {
            $config->{$key} = $value;
        }
        $config->save();
        $sql = "UPDATE %%CRONJOBS%%\n\t\tSET isActive = :isActive, `lock` = NULL, nextTime = 0\n\t\tWHERE name = 'teamspeak';";
        Database::get()->update($sql, array(':isActive' => $ts_modon));
        $LOG = new Log(3);
        $LOG->target = 4;
        $LOG->old = $config_before;
        $LOG->new = $config_after;
        $LOG->save();
    }
    $template = new template();
    $template->assign_vars(array('se_save_parameters' => $LNG['se_save_parameters'], 'ts_tcpport' => $LNG['ts_tcpport'], 'ts_serverip' => $LNG['ts_serverip'], 'ts_version' => $LNG['ts_version'], 'ts_active' => $LNG['ts_active'], 'ts_settings' => $LNG['ts_settings'], 'ts_udpport' => $LNG['ts_udpport'], 'ts_timeout' => $LNG['ts_timeout'], 'ts_server_query' => $LNG['ts_server_query'], 'ts_sq_login' => $LNG['ts_login'], 'ts_sq_pass' => $LNG['ts_pass'], 'ts_lng_cron' => $LNG['ts_cron'], 'ts_to' => $config->ts_timeout, 'ts_on' => $config->ts_modon, 'ts_ip' => $config->ts_server, 'ts_tcp' => $config->ts_tcpport, 'ts_udp' => $config->ts_udpport, 'ts_v' => $config->ts_version, 'ts_login' => $config->ts_login, 'ts_password' => $config->ts_password, 'ts_cron' => $config->ts_cron_interval));
    $template->show('TeamspeakPage.tpl');
}
Ejemplo n.º 10
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');
 }
Ejemplo n.º 11
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.º 12
0
function ShowChatConfigPage()
{
    global $LNG;
    $config = Config::get(Universe::getEmulated());
    if (!empty($_POST)) {
        $config_before = array('chat_closed' => $config->chat_closed, 'chat_allowchan' => $config->chat_allowchan, 'chat_allowmes' => $config->chat_allowmes, 'chat_allowdelmes' => $config->chat_allowdelmes, 'chat_logmessage' => $config->chat_logmessage, 'chat_nickchange' => $config->chat_nickchange, 'chat_botname' => $config->chat_botname, 'chat_channelname' => $config->chat_channelname);
        $chat_allowchan = isset($_POST['chat_allowchan']) && $_POST['chat_allowchan'] == 'on' ? 1 : 0;
        $chat_allowmes = isset($_POST['chat_allowmes']) && $_POST['chat_allowmes'] == 'on' ? 1 : 0;
        $chat_allowdelmes = isset($_POST['chat_allowdelmes']) && $_POST['chat_allowdelmes'] == 'on' ? 1 : 0;
        $chat_logmessage = isset($_POST['chat_logmessage']) && $_POST['chat_logmessage'] == 'on' ? 1 : 0;
        $chat_nickchange = isset($_POST['chat_nickchange']) && $_POST['chat_nickchange'] == 'on' ? 1 : 0;
        $chat_closed = isset($_POST['chat_closed']) && $_POST['chat_closed'] == 'on' ? 1 : 0;
        $chat_channelname = HTTP::_GP('chat_channelname', '', true);
        $chat_botname = HTTP::_GP('chat_botname', '', true);
        $config_after = array('chat_closed' => $chat_closed, 'chat_allowchan' => $chat_allowchan, 'chat_allowmes' => $chat_allowmes, 'chat_allowdelmes' => $chat_allowdelmes, 'chat_logmessage' => $chat_logmessage, 'chat_nickchange' => $chat_nickchange, 'chat_botname' => $chat_botname, 'chat_channelname' => $chat_channelname);
        foreach ($config_after as $key => $value) {
            $config->{$key} = $value;
        }
        $config->save();
        $LOG = new Log(3);
        $LOG->target = 3;
        $LOG->old = $config_before;
        $LOG->new = $config_after;
        $LOG->save();
    }
    $template = new template();
    $template->assign_vars(array('chat_closed' => $config->chat_closed, 'chat_allowchan' => $config->chat_allowchan, 'chat_allowmes' => $config->chat_allowmes, 'chat_logmessage' => $config->chat_logmessage, 'chat_nickchange' => $config->chat_nickchange, 'chat_botname' => $config->chat_botname, 'chat_channelname' => $config->chat_channelname, 'se_server_parameters' => $LNG['se_server_parameters'], 'se_save_parameters' => $LNG['se_save_parameters'], 'ch_closed' => $LNG['ch_closed'], 'ch_allowchan' => $LNG['ch_allowchan'], 'ch_allowmes' => $LNG['ch_allowmes'], 'ch_allowdelmes' => $LNG['ch_allowdelmes'], 'ch_logmessage' => $LNG['ch_logmessage'], 'ch_nickchange' => $LNG['ch_nickchange'], 'ch_botname' => $LNG['ch_botname'], 'ch_channelname' => $LNG['ch_channelname']));
    $template->show('ChatConfigBody.tpl');
}
Ejemplo n.º 13
0
function ShowDisclamerPage()
{
    global $LNG;
    $config = Config::get(Universe::getEmulated());
    if (!empty($_POST)) {
        $config_before = array('disclamerAddress' => $config->disclamerAddress, 'disclamerPhone' => $config->disclamerPhone, 'disclamerMail' => $config->disclamerMail, 'disclamerNotice' => $config->disclamerNotice);
        $disclaimerAddress = HTTP::_GP('disclaimerAddress', '', true);
        $disclaimerPhone = HTTP::_GP('disclaimerPhone', '', true);
        $disclaimerMail = HTTP::_GP('disclaimerMail', '', true);
        $disclaimerNotice = HTTP::_GP('disclaimerNotice', '', true);
        $config_after = array('disclamerAddress' => $disclaimerAddress, 'disclamerPhone' => $disclaimerPhone, 'disclamerMail' => $disclaimerMail, 'disclamerNotice' => $disclaimerNotice);
        foreach ($config_after as $key => $value) {
            $config->{$key} = $value;
        }
        $config->save();
        $LOG = new Log(3);
        $LOG->target = 5;
        $LOG->old = $config_before;
        $LOG->new = $config_after;
        $LOG->save();
    }
    $template = new template();
    $template->loadscript('../base/jquery.autosize-min.js');
    $template->execscript('$(\'textarea\').autosize();');
    $template->assign_vars(array('disclaimerAddress' => $config->disclamerAddress, 'disclaimerPhone' => $config->disclamerPhone, 'disclaimerMail' => $config->disclamerMail, 'disclaimerNotice' => $config->disclamerNotice, 'se_server_parameters' => $LNG['mu_disclaimer'], 'se_save_parameters' => $LNG['se_save_parameters'], 'se_disclaimerAddress' => $LNG['se_disclaimerAddress'], 'se_disclaimerPhone' => $LNG['se_disclaimerPhone'], 'se_disclaimerMail' => $LNG['se_disclaimerMail'], 'se_disclaimerNotice' => $LNG['se_disclaimerNotice']));
    $template->show('DisclamerConfigBody.tpl');
}
Ejemplo n.º 14
0
function ShowFlyingFleetPage()
{
    global $LNG;
    $id = HTTP::_GP('id', 0);
    if (!empty($id)) {
        $lock = HTTP::_GP('lock', 0);
        $GLOBALS['DATABASE']->query("UPDATE " . FLEETS . " SET `fleet_busy` = '" . $lock . "' WHERE `fleet_id` = '" . $id . "' AND `fleet_universe` = '" . Universe::getEmulated() . "';");
        $SQL = $lock == 0 ? "NULL" : "'ADM_LOCK'";
        $GLOBALS['DATABASE']->query("UPDATE " . FLEETS_EVENT . " SET `lock` = " . $SQL . " WHERE `fleetID` = " . $id . ";");
    }
    $orderBy = "fleet_id";
    $fleetResult = $GLOBALS['DATABASE']->query("SELECT \n\tfleet.*,\n\tevent.`lock`,\n\tCOUNT(event.fleetID) as error,\n\tpstart.name as startPlanetName,\n\tptarget.name as targetPlanetName,\n\tustart.username as startUserName,\n\tutarget.username as targetUserName,\n\tacs.name as acsName\n\tFROM " . FLEETS . " fleet\n\tLEFT JOIN " . FLEETS_EVENT . " event ON fleetID = fleet_id\n\tLEFT JOIN " . PLANETS . " pstart ON pstart.id = fleet_start_id\n\tLEFT JOIN " . PLANETS . " ptarget ON ptarget.id = fleet_end_id\n\tLEFT JOIN " . USERS . " ustart ON ustart.id = fleet_owner\n\tLEFT JOIN " . USERS . " utarget ON utarget.id = fleet_target_owner\n\tLEFT JOIN " . AKS . " acs ON acs.id = fleet_group\n\tWHERE fleet_universe = " . Universe::getEmulated() . "\n\tGROUP BY event.fleetID\n\tORDER BY " . $orderBy . ";");
    $FleetList = array();
    while ($fleetRow = $GLOBALS['DATABASE']->fetch_array($fleetResult)) {
        $shipList = array();
        $shipArray = array_filter(explode(';', $fleetRow['fleet_array']));
        foreach ($shipArray as $ship) {
            $shipDetail = explode(',', $ship);
            $shipList[$shipDetail[0]] = $shipDetail[1];
        }
        $FleetList[] = array('fleetID' => $fleetRow['fleet_id'], 'lock' => !empty($fleetRow['lock']), 'count' => $fleetRow['fleet_amount'], 'error' => !$fleetRow['error'], 'ships' => $shipList, 'state' => $fleetRow['fleet_mess'], 'starttime' => _date($LNG['php_tdformat'], $fleetRow['start_time'], $USER['timezone']), 'arrivaltime' => _date($LNG['php_tdformat'], $fleetRow['fleet_start_time'], $USER['timezone']), 'stayhour' => round(($fleetRow['fleet_end_stay'] - $fleetRow['fleet_start_time']) / 3600), 'staytime' => $fleetRow['fleet_start_time'] !== $fleetRow['fleet_end_stay'] ? _date($LNG['php_tdformat'], $fleetRow['fleet_end_stay'], $USER['timezone']) : 0, 'endtime' => _date($LNG['php_tdformat'], $fleetRow['fleet_end_time'], $USER['timezone']), 'missionID' => $fleetRow['fleet_mission'], 'acsID' => $fleetRow['fleet_group'], 'acsName' => $fleetRow['acsName'], 'startUserID' => $fleetRow['fleet_owner'], 'startUserName' => $fleetRow['startUserName'], 'startPlanetID' => $fleetRow['fleet_start_id'], 'startPlanetName' => $fleetRow['startPlanetName'], 'startPlanetGalaxy' => $fleetRow['fleet_start_galaxy'], 'startPlanetSystem' => $fleetRow['fleet_start_system'], 'startPlanetPlanet' => $fleetRow['fleet_start_planet'], 'startPlanetType' => $fleetRow['fleet_start_type'], 'targetUserID' => $fleetRow['fleet_target_owner'], 'targetUserName' => $fleetRow['targetUserName'], 'targetPlanetID' => $fleetRow['fleet_end_id'], 'targetPlanetName' => $fleetRow['targetPlanetName'], 'targetPlanetGalaxy' => $fleetRow['fleet_end_galaxy'], 'targetPlanetSystem' => $fleetRow['fleet_end_system'], 'targetPlanetPlanet' => $fleetRow['fleet_end_planet'], 'targetPlanetType' => $fleetRow['fleet_end_type'], 'resource' => array(901 => $fleetRow['fleet_resource_metal'], 902 => $fleetRow['fleet_resource_crystal'], 903 => $fleetRow['fleet_resource_deuterium'], 921 => $fleetRow['fleet_resource_darkmatter']));
    }
    $GLOBALS['DATABASE']->free_result($fleetResult);
    $template = new template();
    $template->assign_vars(array('FleetList' => $FleetList));
    $template->show('FlyingFleetPage.tpl');
}
Ejemplo n.º 15
0
 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.º 16
0
function ShowSendMessagesPage()
{
    global $USER, $LNG;
    $ACTION = HTTP::_GP('action', '');
    if ($ACTION == 'send') {
        switch ($USER['authlevel']) {
            case AUTH_MOD:
                $class = 'mod';
                break;
            case AUTH_OPS:
                $class = 'ops';
                break;
            case AUTH_ADM:
                $class = 'admin';
                break;
            default:
                $class = '';
                break;
        }
        $Subject = HTTP::_GP('subject', '', true);
        $Message = HTTP::_GP('text', '', true);
        $Mode = HTTP::_GP('mode', 0);
        $Lang = HTTP::_GP('lang', '');
        if (!empty($Message) && !empty($Subject)) {
            require 'includes/classes/BBCode.class.php';
            if ($Mode == 0 || $Mode == 2) {
                $From = '<span class="' . $class . '">' . $LNG['user_level'][$USER['authlevel']] . ' ' . $USER['username'] . '</span>';
                $pmSubject = '<span class="' . $class . '">' . $Subject . '</span>';
                $pmMessage = '<span class="' . $class . '">' . BBCode::parse($Message) . '</span>';
                $USERS = $GLOBALS['DATABASE']->query("SELECT `id`, `username` FROM " . USERS . " WHERE `universe` = '" . Universe::getEmulated() . "'" . (!empty($Lang) ? " AND `lang` = '" . $GLOBALS['DATABASE']->sql_escape($Lang) . "'" : "") . ";");
                while ($UserData = $GLOBALS['DATABASE']->fetch_array($USERS)) {
                    $sendMessage = str_replace('{USERNAME}', $UserData['username'], $pmMessage);
                    PlayerUtil::sendMessage($UserData['id'], $USER['id'], $From, 50, $pmSubject, $sendMessage, TIMESTAMP, NULL, 1, Universe::getEmulated());
                }
            }
            if ($Mode == 1 || $Mode == 2) {
                require 'includes/classes/Mail.class.php';
                $userList = array();
                $USERS = $GLOBALS['DATABASE']->query("SELECT `email`, `username` FROM " . USERS . " WHERE `universe` = '" . Universe::getEmulated() . "'" . (!empty($Lang) ? " AND `lang` = '" . $GLOBALS['DATABASE']->sql_escape($Lang) . "'" : "") . ";");
                while ($UserData = $GLOBALS['DATABASE']->fetch_array($USERS)) {
                    $userList[$UserData['email']] = array('username' => $UserData['username'], 'body' => BBCode::parse(str_replace('{USERNAME}', $UserData['username'], $Message)));
                }
                Mail::multiSend($userList, strip_tags($Subject));
            }
            exit($LNG['ma_message_sended']);
        } else {
            exit($LNG['ma_subject_needed']);
        }
    }
    $sendModes = $LNG['ma_modes'];
    if (Config::get()->mail_active == 0) {
        unset($sendModes[1]);
        unset($sendModes[2]);
    }
    $template = new template();
    $template->assign_vars(array('langSelector' => array_merge(array('' => $LNG['ma_all']), $LNG->getAllowedLangs(false)), 'modes' => $sendModes));
    $template->show('SendMessagesPage.tpl');
}
Ejemplo n.º 17
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.º 18
0
function ShowMessageListPage()
{
    global $LNG;
    $page = HTTP::_GP('side', 1);
    $type = HTTP::_GP('type', 100);
    $sender = HTTP::_GP('sender', '', UTF8_SUPPORT);
    $receiver = HTTP::_GP('receiver', '', UTF8_SUPPORT);
    $dateStart = HTTP::_GP('dateStart', array());
    $dateEnd = HTTP::_GP('dateEnd', array());
    $perSide = 50;
    $messageList = array();
    $userWhereSQL = '';
    $dateWhereSQL = '';
    $countJoinSQL = '';
    $categories = $LNG['mg_type'];
    unset($categories[999]);
    $dateStart = array_filter($dateStart, 'is_numeric');
    $dateEnd = array_filter($dateEnd, 'is_numeric');
    $useDateStart = count($dateStart) == 3;
    $useDateEnd = count($dateEnd) == 3;
    if ($useDateStart && $useDateEnd) {
        $dateWhereSQL = ' AND message_time BETWEEN ' . mktime(0, 0, 0, (int) $dateStart['month'], (int) $dateStart['day'], (int) $dateStart['year']) . ' AND ' . mktime(23, 59, 59, (int) $dateEnd['month'], (int) $dateEnd['day'], (int) $dateEnd['year']);
    } elseif ($useDateStart) {
        $dateWhereSQL = ' AND message_time > ' . mktime(0, 0, 0, (int) $dateStart['month'], (int) $dateStart['day'], (int) $dateStart['year']);
    } elseif ($useDateStart) {
        $dateWhereSQL = ' AND message_time < ' . mktime(23, 59, 59, (int) $dateEnd['month'], (int) $dateEnd['day'], (int) $dateEnd['year']);
    }
    if (!empty($sender)) {
        $countJoinSQL .= ' LEFT JOIN ' . USERS . ' as us ON message_sender = us.id';
        $userWhereSQL .= ' AND us.username = "******"';
    }
    if (!empty($receiver)) {
        $countJoinSQL .= ' LEFT JOIN ' . USERS . ' as u ON message_owner = u.id';
        $userWhereSQL .= ' AND u.username = "******"';
    }
    if ($type != 100) {
        $MessageCount = $GLOBALS['DATABASE']->getFirstCell("SELECT COUNT(*) FROM " . MESSAGES . $countJoinSQL . " WHERE message_type = " . $type . " AND message_universe = " . Universe::getEmulated() . $dateWhereSQL . $userWhereSQL . ";");
    } else {
        $MessageCount = $GLOBALS['DATABASE']->getFirstCell("SELECT COUNT(*) FROM " . MESSAGES . $countJoinSQL . " WHERE message_universe = " . Universe::getEmulated() . $dateWhereSQL . $userWhereSQL . ";");
    }
    $maxPage = max(1, ceil($MessageCount / $perSide));
    $page = max(1, min($page, $maxPage));
    $sqlLimit = ($page - 1) * $perSide . ", " . ($perSide - 1);
    if ($type == 100) {
        $messageRaw = $GLOBALS['DATABASE']->query("SELECT u.username, us.username as senderName, m.* \n\t\tFROM " . MESSAGES . " as m \n\t\tLEFT JOIN " . USERS . " as u ON m.message_owner = u.id \n\t\tLEFT JOIN " . USERS . " as us ON m.message_sender = us.id\n\t\tWHERE m.message_universe = " . Universe::getEmulated() . "\n\t\t" . $dateWhereSQL . "\n\t\t" . $userWhereSQL . "\n\t\tORDER BY message_time DESC, message_id DESC\n\t\tLIMIT " . $sqlLimit . ";");
    } else {
        $messageRaw = $GLOBALS['DATABASE']->query("SELECT u.username, us.username as senderName, m.* \n\t\tFROM " . MESSAGES . " as m\n\t\tLEFT JOIN " . USERS . " as u ON m.message_owner = u.id\n\t\tLEFT JOIN " . USERS . " as us ON m.message_sender = us.id\n\t\tWHERE m.message_type = " . $type . " AND message_universe = " . Universe::getEmulated() . "\n\t\t" . $dateWhereSQL . "\n\t\t" . $userWhereSQL . "\n\t\tORDER BY message_time DESC, message_id DESC\n\t\tLIMIT " . $sqlLimit . ";");
    }
    while ($messageRow = $GLOBALS['DATABASE']->fetch_array($messageRaw)) {
        $messageList[$messageRow['message_id']] = array('sender' => empty($messageRow['senderName']) ? $messageRow['message_from'] : $messageRow['senderName'] . ' (ID:&nbsp;' . $messageRow['message_sender'] . ')', 'receiver' => $messageRow['username'] . ' (ID:&nbsp;' . $messageRow['message_owner'] . ')', 'subject' => $messageRow['message_subject'], 'text' => $messageRow['message_text'], 'type' => $messageRow['message_type'], 'time' => str_replace(' ', '&nbsp;', _date($LNG['php_tdformat'], $messageRow['message_time']), $USER['timezone']));
    }
    $template = new template();
    $template->assign_vars(array('categories' => $categories, 'maxPage' => $maxPage, 'page' => $page, 'messageList' => $messageList, 'type' => $type, 'dateStart' => $dateStart, 'dateEnd' => $dateEnd, 'sender' => $sender, 'receiver' => $receiver));
    $template->show('MessageList.tpl');
}
Ejemplo n.º 19
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.º 20
0
 public static function setEmulated($universeId)
 {
     if (!self::exists($universeId)) {
         throw new Exception('Unknown universe ID: ' . $universeId);
     }
     $session = Session::load();
     $session->emulatedUniverse = $universeId;
     $session->save();
     self::$emulatedUniverse = $universeId;
     return true;
 }
Ejemplo n.º 21
0
/**
 *  2Moons
 *  Copyright (C) 2012 Jan Kröpke
 *
 * For the full copyright and license information, please view the LICENSE
 *
 * @package 2Moons
 * @author Jan Kröpke <*****@*****.**>
 * @copyright 2012 Jan Kröpke <*****@*****.**>
 * @licence MIT
 * @version 1.7.2 (2013-03-18)
 * @info $Id$
 * @link http://2moons.cc/
 */
function ShowTopnavPage()
{
    global $LNG, $USER;
    $template = new template();
    $universeSelect = array();
    foreach (Universe::availableUniverses() as $uniId) {
        $config = Config::get($uniId);
        $universeSelect[$uniId] = sprintf('%s (ID: %d)', $config->uni_name, $uniId);
    }
    ksort($universeSelect);
    $template->assign_vars(array('ad_authlevel_title' => $LNG['ad_authlevel_title'], 're_reset_universe' => $LNG['re_reset_universe'], 'mu_universe' => $LNG['mu_universe'], 'mu_moderation_page' => $LNG['mu_moderation_page'], 'adm_cp_title' => $LNG['adm_cp_title'], 'adm_cp_index' => $LNG['adm_cp_index'], 'adm_cp_logout' => $LNG['adm_cp_logout'], 'sid' => session_id(), 'id' => $USER['id'], 'authlevel' => $USER['authlevel'], 'AvailableUnis' => $universeSelect, 'UNI' => Universe::getEmulated()));
    $template->show('ShowTopnavPage.tpl');
}
Ejemplo n.º 22
0
function ShowGiveaway()
{
    global $LNG, $resource, $reslist;
    $template = new template();
    $action = HTTP::_GP('action', '');
    if ($action == 'send') {
        $planet = HTTP::_GP('planet', 0);
        $moon = HTTP::_GP('moon', 0);
        $mainplanet = HTTP::_GP('mainplanet', 0);
        $no_inactive = HTTP::_GP('no_inactive', 0);
        if (!$planet && !$moon) {
            $template->message($LNG['ga_selectplanettype']);
            exit;
        }
        $planetIN = array();
        if ($planet) {
            $planetIN[] = "'1'";
        }
        if ($moon) {
            $planetIN[] = "'3'";
        }
        $data = array();
        $DataIDs = array_merge($reslist['resstype'][1], $reslist['resstype'][3], $reslist['build'], $reslist['tech'], $reslist['fleet'], $reslist['defense'], $reslist['officier']);
        $logOld = array();
        $logNew = array();
        foreach ($DataIDs as $ID) {
            $amount = max(0, round(HTTP::_GP('element_' . $ID, 0.0)));
            $data[] = $resource[$ID] . " = " . $resource[$ID] . " + " . $amount;
            $logOld[$ID] = 0;
            $logNew[$ID] = $amount;
        }
        $SQL = "UPDATE " . PLANETS . " p INNER JOIN " . USERS . " u ON p.id_owner = u.id";
        if ($mainplanet == true) {
            $SQL .= " AND p.id = u.id_planet";
        }
        if ($no_inactive == true) {
            $SQL .= " AND u.onlinetime > " . (TIMESTAMP - INACTIVE);
        }
        $SQL .= " SET " . implode(', ', $data) . " WHERE p.universe = " . Universe::getEmulated() . " AND p.planet_type IN (" . implode(',', $planetIN) . ")";
        $GLOBALS['DATABASE']->query($SQL);
        $LOG = new Log(4);
        $LOG->target = 0;
        $LOG->old = $logOld;
        $LOG->new = $logNew;
        $LOG->save();
        $template->message($LNG['ga_success']);
        exit;
    }
    $template->assign_vars(array('reslist' => $reslist));
    $template->show("giveaway.tpl");
}
Ejemplo n.º 23
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.º 24
0
function ShowActivePage()
{
    global $LNG, $USER;
    $id = HTTP::_GP('id', 0);
    if ($_GET['action'] == 'delete' && !empty($id)) {
        $GLOBALS['DATABASE']->query("DELETE FROM " . USERS_VALID . " WHERE `validationID` = '" . $id . "' AND `universe` = '" . Universe::getEmulated() . "';");
    }
    $query = $GLOBALS['DATABASE']->query("SELECT * FROM " . USERS_VALID . " WHERE `universe` = '" . Universe::getEmulated() . "' ORDER BY validationID ASC");
    $Users = array();
    while ($User = $GLOBALS['DATABASE']->fetch_array($query)) {
        $Users[] = array('id' => $User['validationID'], 'name' => $User['userName'], 'date' => _date($LNG['php_tdformat'], $User['date'], $USER['timezone']), 'email' => $User['email'], 'ip' => $User['ip'], 'password' => $User['password'], 'validationKey' => $User['validationKey']);
    }
    $template = new template();
    $template->assign_vars(array('Users' => $Users, 'uni' => Universe::getEmulated()));
    $template->show('ActivePage.tpl');
}
Ejemplo n.º 25
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.º 26
0
function ShowFacebookPage()
{
    global $LNG;
    $config = Config::get(Universe::getEmulated());
    if ($_POST) {
        $fb_on = isset($_POST['fb_on']) && $_POST['fb_on'] == 'on' && !empty($_POST['fb_skey']) && !empty($_POST['fb_apikey']) ? 1 : 0;
        $fb_apikey = HTTP::_GP('fb_apikey', '');
        $fb_skey = HTTP::_GP('fb_skey', '');
        foreach (array('fb_on' => $fb_on, 'fb_apikey' => $fb_apikey, 'fb_skey' => $fb_skey) as $key => $value) {
            $config->{$key} = $value;
        }
        $config->save();
    }
    $template = new template();
    $template->assign_vars(array('se_save_parameters' => $LNG['se_save_parameters'], 'fb_info' => $LNG['fb_info'], 'fb_secrectkey' => $LNG['fb_secrectkey'], 'fb_api_key' => $LNG['fb_api_key'], 'fb_active' => $LNG['fb_active'], 'fb_settings' => $LNG['fb_settings'], 'fb_on' => $config->fb_on, 'fb_apikey' => $config->fb_apikey, 'fb_skey' => $config->fb_skey, 'fb_curl' => function_exists('curl_init') ? 1 : 0, 'fb_curl_info' => function_exists('curl_init') ? $LNG['fb_curl_yes'] : $LNG['fb_curl_no']));
    $template->show('FacebookPage.tpl');
}
Ejemplo n.º 27
0
function ShowConfigBasicPage()
{
    global $LNG;
    $config = Config::get(Universe::getEmulated());
    if (!empty($_POST)) {
        $config_before = array('ttf_file' => $config->ttf_file, 'game_name' => $config->game_name, 'mail_active' => $config->mail_active, 'mail_use' => $config->mail_use, 'smail_path' => $config->smail_path, 'smtp_host' => $config->smtp_host, 'smtp_port' => $config->smtp_port, 'smtp_user' => $config->smtp_user, 'smtp_pass' => $config->smtp_pass, 'smtp_ssl' => $config->smtp_ssl, 'smtp_sendmail' => $config->smtp_sendmail, 'ga_active' => $config->ga_active, 'ga_key' => $config->ga_key, 'capaktiv' => $config->capaktiv, 'cappublic' => $config->cappublic, 'capprivate' => $config->capprivate, 'del_oldstuff' => $config->del_oldstuff, 'del_user_manually' => $config->del_user_manually, 'del_user_automatic' => $config->del_user_automatic, 'del_user_sendmail' => $config->del_user_sendmail, 'sendmail_inactive' => $config->sendmail_inactive, 'timezone' => $config->timezone, 'dst' => $config->dst, 'close_reason' => $config->close_reason);
        $capaktiv = isset($_POST['capaktiv']) && $_POST['capaktiv'] == 'on' ? 1 : 0;
        $ga_active = isset($_POST['ga_active']) && $_POST['ga_active'] == 'on' ? 1 : 0;
        $sendmail_inactive = isset($_POST['sendmail_inactive']) && $_POST['sendmail_inactive'] == 'on' ? 1 : 0;
        $mail_active = isset($_POST['mail_active']) && $_POST['mail_active'] == 'on' ? 1 : 0;
        $ttf_file = HTTP::_GP('ttf_file', '');
        $close_reason = HTTP::_GP('close_reason', '', true);
        $game_name = HTTP::_GP('game_name', '', true);
        $capprivate = HTTP::_GP('capprivate', '');
        $cappublic = HTTP::_GP('cappublic', '');
        $ga_key = HTTP::_GP('ga_key', '', true);
        $mail_use = HTTP::_GP('mail_use', 0);
        $smail_path = HTTP::_GP('smail_path', '');
        $smtp_host = HTTP::_GP('smtp_host', '', true);
        $smtp_port = HTTP::_GP('smtp_port', 0);
        $smtp_user = HTTP::_GP('smtp_user', '', true);
        $smtp_sendmail = HTTP::_GP('smtp_sendmail', '', true);
        $smtp_pass = HTTP::_GP('smtp_pass', '', true);
        $smtp_ssl = HTTP::_GP('smtp_ssl', '');
        $del_oldstuff = HTTP::_GP('del_oldstuff', 0);
        $del_user_manually = HTTP::_GP('del_user_manually', 0);
        $del_user_automatic = HTTP::_GP('del_user_automatic', 0);
        $del_user_sendmail = HTTP::_GP('del_user_sendmail', 0);
        $timezone = HTTP::_GP('timezone', '');
        $dst = HTTP::_GP('dst', 0);
        $config_after = array('ttf_file' => $ttf_file, 'game_name' => $game_name, 'mail_active' => $mail_active, 'mail_use' => $mail_use, 'smail_path' => $smail_path, 'smtp_host' => $smtp_host, 'smtp_port' => $smtp_port, 'smtp_user' => $smtp_user, 'smtp_pass' => $smtp_pass, 'smtp_ssl' => $smtp_ssl, 'smtp_sendmail' => $smtp_sendmail, 'ga_active' => $ga_active, 'ga_key' => $ga_key, 'capaktiv' => $capaktiv, 'cappublic' => $cappublic, 'capprivate' => $capprivate, 'del_oldstuff' => $del_oldstuff, 'del_user_manually' => $del_user_manually, 'del_user_automatic' => $del_user_automatic, 'del_user_sendmail' => $del_user_sendmail, 'sendmail_inactive' => $sendmail_inactive, 'timezone' => $timezone, 'dst' => $dst, 'close_reason' => $close_reason);
        foreach ($config_after as $key => $value) {
            $config->{$key} = $value;
        }
        $config->save();
        $LOG = new Log(3);
        $LOG->target = 0;
        $LOG->old = $config_before;
        $LOG->new = $config_after;
        $LOG->save();
    }
    $TimeZones = get_timezone_selector();
    $template = new template();
    $template->assign_vars(array('del_oldstuff' => $config->del_oldstuff, 'del_user_manually' => $config->del_user_manually, 'del_user_automatic' => $config->del_user_automatic, 'del_user_sendmail' => $config->del_user_sendmail, 'sendmail_inactive' => $config->sendmail_inactive, 'ttf_file' => $config->ttf_file, 'game_name' => $config->game_name, 'mail_active' => $config->mail_active, 'mail_use' => $config->mail_use, 'smail_path' => $config->smail_path, 'smtp_host' => $config->smtp_host, 'smtp_port' => $config->smtp_port, 'smtp_user' => $config->smtp_user, 'smtp_pass' => $config->smtp_pass, 'smtp_sendmail' => $config->smtp_sendmail, 'smtp_ssl' => $config->smtp_ssl, 'capprivate' => $config->capprivate, 'cappublic' => $config->cappublic, 'capaktiv' => $config->capaktiv, 'ga_active' => $config->ga_active, 'ga_key' => $config->ga_key, 'timezone' => $config->timezone, 'dst' => $config->dst, 'Selector' => array('timezone' => $TimeZones, 'mail' => $LNG['se_mail_sel'], 'encry' => array('' => $LNG['se_smtp_ssl_1'], 'ssl' => $LNG['se_smtp_ssl_2'], 'tls' => $LNG['se_smtp_ssl_3']))));
    $template->show('ConfigBasicBody.tpl');
}
Ejemplo n.º 28
0
    function run()
    {
        $config = Config::get(ROOT_UNI);
        $unis = Universe::availableUniverses();
        //Delete old messages
        $del_before = TIMESTAMP - $config->del_oldstuff * 86400;
        $del_inactive = TIMESTAMP - $config->del_user_automatic * 86400;
        $del_deleted = TIMESTAMP - $config->del_user_manually * 86400;
        if ($del_inactive === TIMESTAMP) {
            $del_inactive = 2147483647;
        }
        $sql = 'DELETE FROM %%MESSAGES%% WHERE `message_time` < :time;';
        Database::get()->delete($sql, array(':time' => $del_before));
        $sql = 'DELETE FROM %%ALLIANCE%% WHERE `ally_members` = 0;';
        Database::get()->delete($sql);
        $sql = 'DELETE FROM %%PLANETS%% WHERE `destruyed` < :time AND `destruyed` != 0;';
        Database::get()->delete($sql, array(':time' => TIMESTAMP));
        $sql = 'DELETE FROM %%SESSION%% WHERE `lastonline` < :time;';
        Database::get()->delete($sql, array(':time' => TIMESTAMP - SESSION_LIFETIME));
        $sql = 'DELETE FROM %%FLEETS_EVENT%% WHERE fleetID NOT IN (SELECT fleet_id FROM %%FLEETS%%);';
        Database::get()->delete($sql);
        $sql = 'UPDATE %%USERS%% SET `email_2` = `email` WHERE `setmail` < :time;';
        Database::get()->update($sql, array(':time' => TIMESTAMP));
        $sql = 'SELECT `id` FROM %%USERS%% WHERE `authlevel` = :authlevel
		AND ((`db_deaktjava` != 0 AND `db_deaktjava` < :timeDeleted) OR `onlinetime` < :timeInactive);';
        $deleteUserIds = Database::get()->select($sql, array(':authlevel' => AUTH_USR, ':timeDeleted' => $del_deleted, ':timeInactive' => $del_inactive));
        if (empty($deleteUserIds)) {
            foreach ($deleteUserIds as $dataRow) {
                PlayerUtil::deletePlayer($dataRow['id']);
            }
        }
        foreach ($unis as $uni) {
            $sql = 'SELECT units FROM %%TOPKB%% WHERE `universe` = :universe ORDER BY units DESC LIMIT 99,1;';
            $battleHallLowest = Database::get()->selectSingle($sql, array(':universe' => $uni), 'units');
            if (!is_null($battleHallLowest)) {
                $sql = 'DELETE %%TOPKB%%, %%TOPKB_USERS%%
				FROM %%TOPKB%%
				INNER JOIN %%TOPKB_USERS%% USING (rid)
				WHERE `universe` = :universe AND `units` < :battleHallLowest;';
                Database::get()->delete($sql, array(':universe' => $uni, ':battleHallLowest' => $battleHallLowest));
            }
        }
        $sql = 'DELETE FROM %%RW%% WHERE `time` < :time AND `rid` NOT IN (SELECT `rid` FROM %%TOPKB%%);';
        Database::get()->delete($sql, array(':time' => $del_before));
    }
Ejemplo n.º 29
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.º 30
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');
 }