Example #1
0
function ShowSendMessagesPage()
{
    global $USER, $LNG, $db;
    if ($_GET['mode'] == 'send') {
        switch ($USER['authlevel']) {
            case AUTH_MOD:
                $color = 'yellow';
                break;
            case AUTH_OPS:
                $color = 'skyblue';
                break;
            case AUTH_ADM:
                $color = 'red';
                break;
        }
        $Subject = makebr(request_var('subject', '', true));
        $Message = makebr(request_var('text', '', true));
        if (!empty($Message) && !empty($Subject)) {
            require_once ROOT_PATH . 'includes/functions/BBCode.php';
            $Time = TIMESTAMP;
            $From = '<span style="color:' . $color . ';">' . $LNG['user_level'][$USER['authlevel']] . ' ' . $USER['username'] . '</span>';
            $Subject = '<span style="color:' . $color . ';">' . $Subject . '</span>';
            $Message = '<span style="color:' . $color . ';font-weight:bold;">' . bbcode($Message) . '</span>';
            SendSimpleMessage(0, $USER['id'], TIMESTAMP, 50, $From, $Subject, $Message, 0, $_SESSION['adminuni']);
            $db->query("UPDATE " . USERS . " SET `new_gmessage` = `new_gmessage` + '1', `new_message` = `new_message` + '1' WHERE `universe` = '" . $_SESSION['adminuni'] . "';");
            exit($LNG['ma_message_sended']);
        } else {
            exit($LNG['ma_subject_needed']);
        }
    }
    $template = new template();
    $template->assign_vars(array('mg_empty_text' => $LNG['mg_empty_text'], 'ma_subject' => $LNG['ma_subject'], 'ma_none' => $LNG['ma_none'], 'ma_message' => $LNG['ma_message'], 'ma_send_global_message' => $LNG['ma_send_global_message'], 'ma_characters' => $LNG['ma_characters'], 'button_submit' => $LNG['button_submit']));
    $template->show('adm/SendMessagesPage.tpl');
}
Example #2
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.3 (2013-05-19)
 * @info $Id: BBCode.php 2640 2013-03-23 19:23:26Z slaver7 $
 * @link http://2moons.cc/
 */
function bbcode($text)
{
    require_once 'includes/classes/class.BBCode.php';
    $bbcode = new BBCode();
    $bbcode->addParser('list', 'bbcode_stripcontents');
    //Block-Elements
    $bbcode->addCode("quote", "callback_replace", "bbcode_quote", array(), "block", array("block"), array('inline', 'link', 'list'));
    $bbcode->addCode("align", "callback_replace", "bbcode_align", array(), "block", array("block"), array('inline', 'link', 'list'));
    $bbcode->addCode("spoiler", "simple_replace", null, array('start_tag' => '<div class="bbcode_spoiler"><p><b>Spoiler:</b></p><div>', 'end_tag' => '</div></div>'), "block", array("block"), array('inline', 'link', 'list'));
    $bbcode->addCode("bg", "usecontent?", "bbcode_background", array('usecontent_param' => 'default'), 'link', array('block', 'inline', 'listitem'), array('link'));
    $bbcode->addCode("bgcolor", "callback_replace", "bbcode_bgcolor", array(), 'inline', array('block', 'inline', 'link', 'listitem'), array());
    //Inline-Elements
    $bbcode->addCode("b", "simple_replace", null, array('start_tag' => '<b>', 'end_tag' => '</b>'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
    $bbcode->addCode("i", "simple_replace", null, array('start_tag' => '<i>', 'end_tag' => '</i>'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
    $bbcode->addCode("u", "simple_replace", null, array('start_tag' => '<u>', 'end_tag' => '</u>'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
    $bbcode->addCode("s", "simple_replace", null, array('start_tag' => '<s>', 'end_tag' => '</s>'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
    $bbcode->addCode("size", "callback_replace", "bbcode_size", array(), 'inline', array('block', 'inline', 'link', 'listitem'), array());
    $bbcode->addCode("color", "callback_replace", "bbcode_color", array(), 'inline', array('block', 'inline', 'link', 'listitem'), array());
    $bbcode->addCode("rouge", "callback_replace", "bbcode_rouge", array('start_tag' => '[rouge]', 'end_tag' => '[/rouge]'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
    $bbcode->addCode("orange", "callback_replace", "bbcode_orange", array('start_tag' => '[orange]', 'end_tag' => '[/orange]'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
    $bbcode->addCode("jaune", "callback_replace", "bbcode_jaune", array('start_tag' => '[jaune]', 'end_tag' => '[/jaune]'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
    $bbcode->addCode("chartreuse", "callback_replace", "bbcode_chartreuse", array('start_tag' => '[chartreuse]', 'end_tag' => '[/chartreuse]'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
    $bbcode->addCode("vert", "callback_replace", "bbcode_vert", array('start_tag' => '[vert]', 'end_tag' => '[/vert]'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
    $bbcode->addCode("cyan", "callback_replace", "bbcode_cyan", array('start_tag' => '[cyan]', 'end_tag' => '[/cyan]'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
    $bbcode->addCode("bleu", "callback_replace", "bbcode_bleu", array('start_tag' => '[bleu]', 'end_tag' => '[/bleu]'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
    $bbcode->addCode("violet", "callback_replace", "bbcode_violet", array('start_tag' => '[violet]', 'end_tag' => '[/violet]'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
    $bbcode->addCode("rose", "callback_replace", "bbcode_rose", array('start_tag' => '[rose]', 'end_tag' => '[/rose]'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
    $bbcode->addCode("gris", "callback_replace", "bbcode_gris", array('start_tag' => '[gris]', 'end_tag' => '[/gris]'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
    $bbcode->addCode("blanc", "callback_replace", "bbcode_blanc", array('start_tag' => '[blanc]', 'end_tag' => '[/blanc]'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
    //Link-Elements
    $bbcode->addCode("url", "usecontent?", "bbcode_url", array('usecontent_param' => 'default'), 'link', array('block', 'inline', 'listitem'), array('link'));
    $bbcode->addCode("link", "usecontent?", "bbcode_url", array('usecontent_param' => 'default'), 'link', array('block', 'inline', 'listitem'), array('link'));
    $bbcode->addCode("mailto", "usecontent?", "bbcode_mailto", array('usecontent_param' => 'default'), 'link', array('block', 'inline', 'listitem'), array('link'));
    $bbcode->addCode("email", "usecontent?", "bbcode_mailto", array('usecontent_param' => 'default'), 'link', array('block', 'inline', 'listitem'), array('link'));
    $bbcode->addCode("mail", "usecontent?", "bbcode_mailto", array('usecontent_param' => 'default'), 'link', array('block', 'inline', 'listitem'), array('link'));
    //Code-Elements
    $bbcode->addCode("code", "usecontent", "bbcode_code", array('php' => false), 'code', array('block'), array('inline', 'link', 'list'));
    $bbcode->addCode("php", "usecontent", "bbcode_code", array('php' => true), 'code', array('block'), array('inline', 'link', 'list'));
    //List-Elements
    $bbcode->addCode("list", "callback_replace", "bbcode_list", array(), "list", array('block', 'listitem'), array('inline', 'link'));
    $bbcode->addCode("*", "simple_replace", null, array('start_tag' => '<li>', 'end_tag' => '</li>'), "listitem", array('list'), array());
    //Image-Element
    $bbcode->addCode("img", "usecontent", "bbcode_img", array(), "image", array('block', 'inline', 'link', 'listitem'), array());
    //Flags
    $bbcode->setCodeFlag('*', 'closetag', BBCODE_CLOSETAG_OPTIONAL);
    $bbcode->setGlobalCaseSensitive(false);
    //New-Line-Drops
    $bbcode->setCodeFlag('*', 'closetag.before.newline', BBCODE_NEWLINE_DROP);
    $bbcode->setCodeFlag('list', 'opentag.before.newline', BBCODE_NEWLINE_DROP);
    $bbcode->setCodeFlag('list', 'closetag.before.newline', BBCODE_NEWLINE_DROP);
    $codes = array('code', 'php', 'quote', 'spoiler');
    $flags = array('opentag.before.newline', 'opentag.after.newline', 'closetag.before.newline', 'closetag.after.newline');
    foreach ($codes as $code) {
        foreach ($flags as $flag) {
            $bbcode->setCodeFlag($code, $flag, BBCODE_NEWLINE_DROP);
        }
    }
    return str_replace('&amp;amp;', '&amp;', makebr($bbcode->parse($text)));
}
Example #3
0
 function show()
 {
     $newsResult = $GLOBALS['DATABASE']->query("SELECT date, title, text, user FROM " . NEWS . " ORDER BY id DESC;");
     $newsList = array();
     while ($newsRow = $GLOBALS['DATABASE']->fetchArray($newsResult)) {
         $newsList[] = array('title' => $newsRow['title'], 'from' => t('news_from', _date(t('php_tdformat'), $newsRow['date']), $newsRow['user']), 'text' => makebr($newsRow['text']));
     }
     $this->assign(array('newsList' => $newsList));
     $this->render('page.news.default.tpl');
 }
 function show()
 {
     global $LNG;
     $sql = "SELECT date, title, text, user FROM %%NEWS%% ORDER BY id DESC;";
     $newsResult = Database::get()->select($sql);
     $newsList = array();
     foreach ($newsResult as $newsRow) {
         $newsList[] = array('title' => $newsRow['title'], 'from' => sprintf($LNG['news_from'], _date($LNG['php_tdformat'], $newsRow['date']), $newsRow['user']), 'text' => makebr($newsRow['text']));
     }
     $this->assign(array('newsList' => $newsList));
     $this->display('page.news.default.tpl');
 }
Example #5
0
 private function UpdateTicket($TicketID)
 {
     global $USER, $db, $LNG;
     $text = request_var('text', '', true);
     $template = new template();
     if (empty($text)) {
         exit($template->message($LNG['sendit_error_msg'], "game.php?page=support", 3));
     }
     $ticket = $db->uniquequery("SELECT text FROM " . SUPP . " WHERE `id` = '" . $TicketID . "';");
     $text = $ticket['text'] . '<br><br><hr>' . $USER['username'] . ' schreib am ' . date("d. M Y H:i:s", TIMESTAMP) . '<br><br>' . makebr($text) . '';
     $db->query("UPDATE " . SUPP . " SET `text` = '" . $db->sql_escape($text) . "',`status` = '3' WHERE `id` = '" . $db->sql_escape($TicketID) . "';");
     $template->message($LNG['sendit_a'], "game.php?page=support", 3);
 }
Example #6
0
function bbcode($text)
{
    require_once ROOT_PATH . 'includes/classes/class.BBCode.' . PHP_EXT;
    $bbcode = new BBCode();
    $bbcode->addParser('list', 'bbcode_stripcontents');
    //Block-Elements
    $bbcode->addCode("quote", "callback_replace", "bbcode_quote", array(), "block", array("block"), array('inline', 'link', 'list'));
    $bbcode->addCode("align", "callback_replace", "bbcode_align", array(), "block", array("block"), array('inline', 'link', 'list'));
    $bbcode->addCode("spoiler", "simple_replace", null, array('start_tag' => '<div class="bbcode_spoiler"><p><b>Spoiler:</b></p><div>', 'end_tag' => '</div></div>'), "block", array("block"), array('inline', 'link', 'list'));
    $bbcode->addCode("bg", "usecontent?", "bbcode_background", array('usecontent_param' => 'default'), 'link', array('block', 'inline', 'listitem'), array('link'));
    $bbcode->addCode("bgcolor", "callback_replace", "bbcode_bgcolor", array(), 'inline', array('block', 'inline', 'link', 'listitem'), array());
    //Inline-Elements
    $bbcode->addCode("b", "simple_replace", null, array('start_tag' => '<b>', 'end_tag' => '</b>'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
    $bbcode->addCode("i", "simple_replace", null, array('start_tag' => '<i>', 'end_tag' => '</i>'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
    $bbcode->addCode("u", "simple_replace", null, array('start_tag' => '<u>', 'end_tag' => '</u>'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
    $bbcode->addCode("s", "simple_replace", null, array('start_tag' => '<s>', 'end_tag' => '</s>'), 'inline', array('block', 'inline', 'link', 'listitem'), array());
    $bbcode->addCode("size", "callback_replace", "bbcode_size", array(), 'inline', array('block', 'inline', 'link', 'listitem'), array());
    $bbcode->addCode("color", "callback_replace", "bbcode_color", array(), 'inline', array('block', 'inline', 'link', 'listitem'), array());
    //Link-Elements
    $bbcode->addCode("url", "usecontent?", "bbcode_url", array('usecontent_param' => 'default'), 'link', array('block', 'inline', 'listitem'), array('link'));
    $bbcode->addCode("link", "usecontent?", "bbcode_url", array('usecontent_param' => 'default'), 'link', array('block', 'inline', 'listitem'), array('link'));
    $bbcode->addCode("mailto", "usecontent?", "bbcode_mailto", array('usecontent_param' => 'default'), 'link', array('block', 'inline', 'listitem'), array('link'));
    $bbcode->addCode("email", "usecontent?", "bbcode_mailto", array('usecontent_param' => 'default'), 'link', array('block', 'inline', 'listitem'), array('link'));
    $bbcode->addCode("mail", "usecontent?", "bbcode_mailto", array('usecontent_param' => 'default'), 'link', array('block', 'inline', 'listitem'), array('link'));
    //Code-Elements
    $bbcode->addCode("code", "usecontent", "bbcode_code", array('php' => false), 'code', array('block'), array('inline', 'link', 'list'));
    $bbcode->addCode("php", "usecontent", "bbcode_code", array('php' => true), 'code', array('block'), array('inline', 'link', 'list'));
    //List-Elements
    $bbcode->addCode("list", "callback_replace", "bbcode_list", array(), "list", array('block', 'listitem'), array('inline', 'link'));
    $bbcode->addCode("*", "simple_replace", null, array('start_tag' => '<li>', 'end_tag' => '</li>'), "listitem", array('list'), array());
    //Image-Element
    $bbcode->addCode("img", "usecontent", "bbcode_img", array(), "image", array('block', 'inline', 'link', 'listitem'), array());
    //Flags
    $bbcode->setCodeFlag('*', 'closetag', BBCODE_CLOSETAG_OPTIONAL);
    $bbcode->setGlobalCaseSensitive(false);
    //New-Line-Drops
    $bbcode->setCodeFlag('*', 'closetag.before.newline', BBCODE_NEWLINE_DROP);
    $bbcode->setCodeFlag('list', 'opentag.before.newline', BBCODE_NEWLINE_DROP);
    $bbcode->setCodeFlag('list', 'closetag.before.newline', BBCODE_NEWLINE_DROP);
    $codes = array('code', 'php', 'quote', 'spoiler');
    $flags = array('opentag.before.newline', 'opentag.after.newline', 'closetag.before.newline', 'closetag.after.newline');
    foreach ($codes as $code) {
        foreach ($flags as $flag) {
            $bbcode->setCodeFlag($code, $flag, BBCODE_NEWLINE_DROP);
        }
    }
    return makebr($bbcode->parse($text));
}
 function show()
 {
     global $LNG;
     $newsResult = $GLOBALS['DATABASE']->query("SELECT id, date, title, text, user FROM " . NEWS . " ORDER BY id DESC LIMIT 5;");
     $newsList = array();
     while ($newsRow = $GLOBALS['DATABASE']->fetchArray($newsResult)) {
         $newsList[] = array('id' => $newsRow['id'], 'title' => $newsRow['title'], 'from' => t('news_from', _date(t('php_tdformat'), $newsRow['date']), $newsRow['user']), 'text' => makebr($newsRow['text']), 'date' => _date($LNG['php_tdformat'], $newsRow['date'], $newsRow['user']));
     }
     $topicsResult = $GLOBALS['DATABASE']->query("SELECT tid, title, last_post, topic_firstpost, title_seo FROM forum_topics WHERE tdelete_time = '0' ORDER BY last_post DESC LIMIT 5;");
     $topicsList = array();
     while ($topicsRow = $GLOBALS['DATABASE']->fetchArray($topicsResult)) {
         $topicsList[] = array('id' => $topicsRow['tid'], 'title' => $topicsRow['title'], 'topic_firstpost' => $topicsRow['topic_firstpost'], 'title_seo' => $topicsRow['title_seo'], 'date' => _date($LNG['php_tdformat'], $topicsRow['last_post'], 1));
     }
     $this->assign(array('newsList' => $newsList, 'topicsList' => $topicsList));
     $this->render('page.about.default.tpl');
 }
 function show()
 {
     global $LNG;
     $newsResult = $GLOBALS['DATABASE']->query("SELECT id, date, title, text, user, catID FROM " . NEWS . " ORDER BY id DESC;");
     $newsList = array();
     while ($newsRow = $GLOBALS['DATABASE']->fetchArray($newsResult)) {
         $newsList[] = array('id' => $newsRow['id'], 'title' => $newsRow['title'], 'from' => t('news_from', _date(t('php_tdformat'), $newsRow['date']), $newsRow['user']), 'text' => substr($newsRow['text'], 0, 160) . "...", 'date' => _date($LNG['php_tdformat'], $newsRow['date'], $newsRow['user']), 'image' => 'images/' . $newsRow['catID'] . '.jpg');
     }
     $topicsResult = $GLOBALS['DATABASE']->query("SELECT tid, title, last_post, topic_firstpost, title_seo FROM forum_topics WHERE tdelete_time = '0' ORDER BY last_post DESC LIMIT 5;");
     $topicsList = array();
     while ($topicsRow = $GLOBALS['DATABASE']->fetchArray($topicsResult)) {
         $topicsList[] = array('id' => $topicsRow['tid'], 'title' => $topicsRow['title'], 'topic_firstpost' => $topicsRow['topic_firstpost'], 'title_seo' => $topicsRow['title_seo'], 'date' => _date($LNG['php_tdformat'], $topicsRow['last_post'], 1));
     }
     $this->assign(array('disclamerAddress' => makebr(Config::get('disclamerAddress')), 'disclamerPhone' => Config::get('disclamerPhone'), 'disclamerMail' => Config::get('disclamerMail'), 'disclamerNotice' => Config::get('disclamerNotice'), 'newsList' => $newsList, 'topicsList' => $topicsList));
     $this->render('page.disclamer.default.tpl');
 }
Example #9
0
function ShowOverviewPage()
{
    global $CONF, $LNG, $PLANET, $USER, $db, $resource, $UNI;
    $PlanetRess = new ResourceUpdate();
    $PlanetRess->CalcResource();
    $PlanetRess->SavePlanetToDB();
    $template = new template();
    $template->getplanets();
    $AdminsOnline = $AllPlanets = $Moon = array();
    foreach ($template->UserPlanets as $ID => $CPLANET) {
        if ($ID == $_SESSION['planet'] || $CPLANET['planet_type'] == 3) {
            continue;
        }
        if (!empty($CPLANET['b_building']) && $CPLANET['b_building'] > TIMESTAMP) {
            $Queue = explode(';', $CPLANET['b_building_id']);
            $CurrBuild = explode(',', $Queue[0]);
            $BuildPlanet = $LNG['tech'][$CurrBuild[0]] . " (" . $CurrBuild[1] . ")<br><span style=\"color:#7F7F7F;\">(" . pretty_time($CurrBuild[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) {
        $Moon = $db->uniquequery("SELECT `id`, `name` FROM " . PLANETS . " WHERE `id` = '" . $PLANET['id_luna'] . "';");
    }
    if (!empty($PLANET['b_building'])) {
        $Queue = explode(';', $PLANET['b_building_id']);
        $CurrBuild = explode(',', $Queue[0]);
        $Build = $LNG['tech'][$CurrBuild[0]] . ' (' . $CurrBuild[1] . ')<br><div id="blc">"' . pretty_time($PLANET['b_building'] - TIMESTAMP) . '</div>';
        $template->execscript('BuildTime();');
    } else {
        $Build = $LNG['ov_free'];
    }
    $OnlineAdmins = $db->query("SELECT `id`,`username` FROM " . USERS . " WHERE `universe` = '" . $UNI . "' AND `onlinetime` >= '" . (TIMESTAMP - 10 * 60) . "' AND `authlevel` > '0';");
    while ($AdminRow = $db->fetch_array($OnlineAdmins)) {
        $AdminsOnline[$AdminRow['id']] = $AdminRow['username'];
    }
    $db->free_result($OnlineAdmins);
    $template->loadscript('mbContainer.js');
    $template->loadscript('overview.js');
    $template->execscript('GetFleets(true);');
    $template->assign_vars(array('user_rank' => sprintf($LNG['ov_userrank_info'], pretty_number($USER['total_points']), $LNG['ov_place'], $USER['total_rank'], $USER['total_rank'], $LNG['ov_of'], $CONF['users_amount']), 'is_news' => $CONF['OverviewNewsFrame'], 'news' => makebr($CONF['OverviewNewsText']), 'planetname' => $PLANET['name'], 'planetimage' => $PLANET['image'], 'galaxy' => $PLANET['galaxy'], 'system' => $PLANET['system'], 'planet' => $PLANET['planet'], 'buildtime' => $PLANET['b_building'], 'userid' => $USER['id'], 'username' => $USER['username'], 'build' => $Build, 'Moon' => $Moon, 'AllPlanets' => $AllPlanets, 'AdminsOnline' => $AdminsOnline, 'Teamspeak' => GetTeamspeakData(), 'messages' => $USER['new_message'] > 0 ? $USER['new_message'] == 1 ? $LNG['ov_have_new_message'] : sprintf($LNG['ov_have_new_messages'], pretty_number($USER['new_message'])) : 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'], 'ov_news' => $LNG['ov_news'], 'fcm_moon' => $LNG['fcm_moon'], 'ov_server_time' => $LNG['ov_server_time'], 'ov_planet' => $LNG['ov_planet'], 'ov_planetmenu' => $LNG['ov_planetmenu'], 'ov_diameter' => $LNG['ov_diameter'], 'ov_distance_unit' => $LNG['ov_distance_unit'], 'ov_developed_fields' => $LNG['ov_developed_fields'], 'ov_max_developed_fields' => $LNG['ov_max_developed_fields'], 'ov_fields' => $LNG['ov_fields'], 'ov_temperature' => $LNG['ov_temperature'], 'ov_aprox' => $LNG['ov_aprox'], 'ov_temp_unit' => $LNG['ov_temp_unit'], 'ov_to' => $LNG['ov_to'], 'ov_position' => $LNG['ov_position'], 'ov_points' => $LNG['ov_points'], 'ov_events' => $LNG['ov_events'], 'ov_admins_online' => $LNG['ov_admins_online'], 'ov_no_admins_online' => $LNG['ov_no_admins_online'], 'ov_userbanner' => $LNG['ov_userbanner'], 'ov_teamspeak' => $LNG['ov_teamspeak'], 'ov_your_planet' => $LNG['ov_your_planet'], 'ov_coords' => $LNG['ov_coords'], 'ov_planet_name' => $LNG['ov_planet_name'], 'ov_actions' => $LNG['ov_actions'], 'ov_abandon_planet' => $LNG['ov_abandon_planet'], 'ov_planet_rename' => $LNG['ov_planet_rename'], 'ov_planet_rename_action' => $LNG['ov_planet_rename_action'], 'ov_password' => $LNG['ov_password'], 'ov_with_pass' => $LNG['ov_with_pass'], 'ov_security_confirm' => $LNG['ov_security_confirm'], 'ov_security_request' => $LNG['ov_security_request'], 'ov_delete_planet' => $LNG['ov_delete_planet'], 'ov_planet_abandoned' => $LNG['ov_planet_abandoned'], 'path' => PROTOCOL . $_SERVER['HTTP_HOST'] . HTTP_ROOT));
    $template->show("overview_body.tpl");
}
 function info()
 {
     global $LNG, $USER;
     $id = HTTP::_GP('id', '');
     $newsResult = $GLOBALS['DATABASE']->query("SELECT id, date, title, text, catID FROM uni1_jobs WHERE is_active = '1' AND id = '" . $id . "' ;");
     $newsList = array();
     while ($newsRow = $GLOBALS['DATABASE']->fetchArray($newsResult)) {
         $newsList[] = array('id' => $newsRow['id'], 'title' => $newsRow['title'], 'text' => makebr($newsRow['text']), 'date' => _date($LNG['php_tdformat'], $newsRow['date'], $USER), 'image' => 'images/jobs/' . $newsRow['catID'] . '.png');
     }
     $newsResult1 = $GLOBALS['DATABASE']->query("SELECT id, date, title, text, catID FROM uni1_jobs WHERE is_active = '1' ORDER BY id DESC LIMIT 6;");
     $newsList1 = array();
     while ($newsRow1 = $GLOBALS['DATABASE']->fetchArray($newsResult1)) {
         $newsList1[] = array('id' => $newsRow1['id'], 'title' => $newsRow1['title'], 'text' => makebr($newsRow1['text']), 'date' => _date($LNG['php_tdformat'], $newsRow1['date'], $USER), 'image' => 'images/jobs/' . $newsRow1['catID'] . '.png');
     }
     $topicsResult = $GLOBALS['DATABASE']->query("SELECT tid, title, last_post, topic_firstpost, title_seo FROM forum_topics WHERE tdelete_time = '0' ORDER BY last_post DESC LIMIT 5;");
     $topicsList = array();
     while ($topicsRow = $GLOBALS['DATABASE']->fetchArray($topicsResult)) {
         $topicsList[] = array('id' => $topicsRow['tid'], 'title' => $topicsRow['title'], 'topic_firstpost' => $topicsRow['topic_firstpost'], 'title_seo' => $topicsRow['title_seo'], 'date' => _date($LNG['php_tdformat'], $topicsRow['last_post'], 1));
     }
     $this->assign(array('newsList' => $newsList, 'newsList1' => $newsList1, 'topicsList' => $topicsList, 'notif' => 'Jobs', 'info' => '', 'actual_link' => 'http://' . $_SERVER['HTTP_HOST'] . '' . $_SERVER['REQUEST_URI'] . ''));
     $this->render('page.jobs.show.tpl');
 }
 function show()
 {
     global $LNG;
     $id = HTTP::_GP('id', '');
     $newsResult = $GLOBALS['DATABASE']->query("SELECT id, date, title, text, catID, user FROM " . NEWS . " WHERE id = '" . $id . "';");
     $newsList = array();
     while ($newsRow = $GLOBALS['DATABASE']->fetchArray($newsResult)) {
         $newsList[] = array('id' => $newsRow['id'], 'title' => $newsRow['title'], 'from' => t('news_from', _date(t('php_tdformat'), $newsRow['date']), $newsRow['user']), 'text' => makebr($newsRow['text']), 'date' => _date($LNG['php_tdformat'], $newsRow['date'], $newsRow['user']), 'image' => 'images/' . $newsRow['catID'] . '.jpg');
     }
     $topicsResult = $GLOBALS['DATABASE']->query("SELECT tid, title, last_post, topic_firstpost, title_seo FROM forum_topics WHERE tdelete_time = '0' ORDER BY last_post DESC LIMIT 5;");
     $topicsList = array();
     while ($topicsRow = $GLOBALS['DATABASE']->fetchArray($topicsResult)) {
         $topicsList[] = array('id' => $topicsRow['tid'], 'title' => $topicsRow['title'], 'topic_firstpost' => $topicsRow['topic_firstpost'], 'title_seo' => $topicsRow['title_seo'], 'date' => _date($LNG['php_tdformat'], $topicsRow['last_post'], 1));
     }
     $newsResult1 = $GLOBALS['DATABASE']->query("SELECT id, date, title, text, catID, user FROM " . NEWS . " ORDER BY id DESC LIMIT 5;");
     $newsList1 = array();
     while ($newsRow1 = $GLOBALS['DATABASE']->fetchArray($newsResult1)) {
         $newsList1[] = array('id' => $newsRow1['id'], 'title' => $newsRow1['title'], 'from' => t('news_from', _date(t('php_tdformat'), $newsRow1['date']), $newsRow1['user']), 'text' => makebr($newsRow1['text']), 'date' => _date($LNG['php_tdformat'], $newsRow1['date'], $newsRow1['user']), 'image' => 'images/' . $newsRow1['catID'] . '.jpg');
     }
     $this->assign(array('topicsList' => $topicsList, 'newsList' => $newsList, 'newsList1' => $newsList1, 'actual_link' => 'http://' . $_SERVER['HTTP_HOST'] . '' . $_SERVER['REQUEST_URI'] . ''));
     $this->render('page.news.details.tpl');
 }
Example #12
0
function exception_handler($exception)
{
    global $CONF;
    echo '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">';
    echo '<html>';
    echo '<head>';
    echo '<meta http-equiv="content-type" content="text/html; charset=UTF-8">';
    echo '<meta http-equiv="content-script-type" content="text/javascript">';
    echo '<meta http-equiv="content-style-type" content="text/css">';
    echo '<meta http-equiv="content-language" content="de">';
    echo '<title>' . $CONF['game_name'] . ' - FATAL ERROR</title>';
    echo '<link rel="shortcut icon" href="./favicon.ico">';
    echo '<link rel="stylesheet" type="text/css" href="./styles/theme/' . DEFAULT_THEME . '/formate.css">';
    echo '<script type="text/javascript"> ';
    echo 'function blockError(){return true;} ';
    echo 'window.onerror = blockError; ';
    echo '</script>';
    echo '</head>';
    echo '<body>';
    echo '<table width="80%">';
    echo '<tr>';
    echo '<th>';
    echo 'Error:';
    echo '</th>';
    echo '</tr>';
    echo '<tr>';
    echo '<td class="left"><b>Message: </b>' . $exception->getMessage() . '<br>';
    echo '<b>File: </b>' . $exception->getFile() . '<br>';
    echo '<b>Line: </b>' . $exception->getLine() . '<br>';
    echo '<b>PHP-Version: </b>' . PHP_VERSION . '<br>';
    echo '<b>PHP-API: </b>' . php_sapi_name() . '<br>';
    echo '<b>2Moons Version: </b>' . $CONF['VERSION'] . '<br>';
    echo '<b>Debug Backtrace:</b><br>' . makebr(str_replace($_SERVER['DOCUMENT_ROOT'], '.', htmlspecialchars($exception->getTraceAsString()))) . '</th>';
    echo '</tr>';
    echo '</table>';
    echo '</body>';
    echo '</html>';
    exit;
}
 function send()
 {
     global $USER, $LNG;
     require_once 'includes/functions/BBCode.php';
     $receiverID = HTTP::_GP('id', 0);
     $Subject = HTTP::_GP('subject', $LNG['mg_no_subject'], true);
     $Message = makebr(HTTP::_GP('text', '', true));
     $From = $USER['username'] . ' [' . $USER['galaxy'] . ':' . $USER['system'] . ':' . $USER['planet'] . ']';
     if ($USER['message_ban'] == 1 && $USER['message_ban_time'] > TIMESTAMP) {
         $this->sendJSON("You have been banned for sending privates messages");
     } else {
         if (empty($receiverID) || empty($Message) || !isset($_SESSION['messtoken']) || $_SESSION['messtoken'] != md5($USER['id'] . '|' . $receiverID)) {
             $this->sendJSON($LNG['mg_error']);
         }
         unset($_SESSION['messtoken']);
         if (empty($Subject)) {
             $Subject = $LNG['mg_no_subject'];
         }
         $healthy = array("madnessogame", "moon-xnova", "corrado-game", "zyperaxgalaxy");
         $yummy = array("dark-space", "dark-space", "dark-space", "dark-space");
         $newphrase = str_replace($healthy, $yummy, $Message);
         $newphrase = bbcode($newphrase);
         $cautare = $GLOBALS['DATABASE']->query("SELECT *FROM " . MESSAGES . " where\t`message_sender` = '" . $USER['id'] . "' order by `message_time` DESC LIMIT 10");
         $count = 0;
         while ($x = $GLOBALS['DATABASE']->fetch_array($cautare)) {
             similar_text($x['message_text'], $newphrase, $percent);
             if ($percent >= 75) {
                 $count++;
             }
         }
         if ($count >= 3) {
             $GLOBALS['DATABASE']->query("UPDATE " . USERS . " set `message_ban` = '1', `message_ban_time` = " . (TIMESTAMP + 72 * 60 * 60) . " where `id` = '" . $USER['id'] . "';");
             $HLM = "INSERT INTO uni1_message_banned SET ";
             $HLM .= "`who` = '" . $USER['username'] . "', ";
             $HLM .= "`theme` = 'Advertising/Spamming', ";
             $HLM .= "`time` = '" . TIMESTAMP . "', ";
             $HLM .= "`longer` = '" . (TIMESTAMP + 72 * 60 * 60) . "', ";
             $HLM .= "`author` = 'iiNSick', ";
             $HLM .= "`universe` = '1', ";
             $HLM .= "`email` = '*****@*****.**';";
             $GLOBALS['DATABASE']->query($HLM);
             SendSimpleMessage(1, $USER['id'], TIMESTAMP, 1, $From, $Subject, 'Player ' . $USER['username'] . ' is spamming...');
             $this->sendJSON("Message has been sent");
         } else {
             SendSimpleMessage($receiverID, $USER['id'], TIMESTAMP, 1, $From, $Subject, $newphrase);
             $this->sendJSON($LNG['mg_message_send']);
         }
     }
 }
Example #14
0
function ShowMessagesPage()
{
    global $USER, $PLANET, $CONF, $dpath, $LNG, $db;
    $MessCategory = request_var('messcat', 0);
    $MessPageMode = request_var('mode', '');
    $DeleteWhat = request_var('deletemessages', '');
    $Send = request_var('send', 0);
    $OwnerID = request_var('id', 0);
    $Subject = request_var('subject', '', true);
    $MessageType = array(0, 1, 2, 3, 4, 5, 15, 50, 99, 100, 999);
    $TitleColor = array(0 => '#FFFF00', 1 => '#FF6699', 2 => '#FF3300', 3 => '#FF9900', 4 => '#773399', 5 => '#009933', 15 => '#6495ed', 50 => '#666600', 99 => '#007070', 100 => '#ABABAB', 999 => '#CCCCCC');
    $template = new template();
    switch ($MessPageMode) {
        case 'write':
            $template->page_header();
            $template->page_footer();
            $OwnerRecord = $db->uniquequery("SELECT a.galaxy, a.system, a.planet, b.username, b.id_planet FROM " . PLANETS . " as a, " . USERS . " as b WHERE b.id = '" . $OwnerID . "' AND a.id = b.id_planet;");
            if (!$OwnerRecord) {
                $template->message($LNG['mg_error'], false, 0, true);
            }
            if ($Send) {
                $Owner = $OwnerID;
                $Message = makebr(request_var('text', '', true));
                $From = $USER['username'] . ' [' . $USER['galaxy'] . ':' . $USER['system'] . ':' . $USER['planet'] . ']';
                SendSimpleMessage($OwnerID, $USER['id'], '', 1, $From, $Subject, $Message);
                exit($LNG['mg_message_send']);
            }
            $template->assign_vars(array('mg_send_new' => $LNG['mg_send_new'], 'mg_send_to' => $LNG['mg_send_to'], 'mg_send' => $LNG['mg_send'], 'mg_message' => $LNG['mg_message'], 'mg_characters' => $LNG['mg_characters'], 'mg_subject' => $LNG['mg_subject'], 'mg_empty_text' => $LNG['mg_empty_text'], 'subject' => empty($Subject) ? $LNG['mg_no_subject'] : $Subject, 'id' => $OwnerID, 'username' => $OwnerRecord['username'], 'galaxy' => $OwnerRecord['galaxy'], 'system' => $OwnerRecord['system'], 'planet' => $OwnerRecord['planet']));
            $template->show("message_send_form.tpl");
            break;
        default:
            $PlanetRess = new ResourceUpdate();
            $PlanetRess->CalcResource();
            $PlanetRess->SavePlanetToDB();
            $template->loadscript('message.js');
            $template->page_header();
            $template->page_topnav();
            $template->page_leftmenu();
            $template->page_planetmenu();
            $template->page_footer();
            $UsrMess = $db->query("SELECT `message_type`, `message_unread` FROM " . MESSAGES . " WHERE `message_owner` = '" . $USER['id'] . "' OR `message_type` = '50';");
            $GameOps = $db->query("SELECT `username`, `email` FROM " . USERS . " WHERE `authlevel` != '0' ORDER BY `username` ASC;");
            $MessOut = $db->uniquequery("SELECT COUNT(*) as count FROM " . MESSAGES . " WHERE message_sender = '" . $USER['id'] . "';");
            while ($Ops = $db->fetch_array($GameOps)) {
                $OpsList[] = array('username' => $Ops['username'], 'email' => $Ops['email']);
            }
            $db->free_result($GameOps);
            while ($CurMess = $db->fetch_array($UsrMess)) {
                $UnRead[$CurMess['message_type']] += $CurMess['message_unread'];
                $TotalMess[$CurMess['message_type']] += 1;
            }
            $db->free_result($UsrMess);
            $UnRead[50] += $USER['new_gmessage'];
            $UnRead[100] = is_array($UnRead) ? array_sum($UnRead) : 0;
            $TotalMess[100] = is_array($TotalMess) ? array_sum($TotalMess) - $TotalMess[50] : 0;
            $TotalMess[999] = $MessOut['count'];
            foreach ($TitleColor as $MessageID => $MessageColor) {
                $MessageList[$MessageID] = array('color' => $MessageColor, 'unread' => !empty($UnRead[$MessageID]) ? $UnRead[$MessageID] : 0, 'total' => !empty($TotalMess[$MessageID]) ? $TotalMess[$MessageID] : 0, 'lang' => $LNG['mg_type'][$MessageID]);
            }
            $template->assign_vars(array('MessageList' => $MessageList, 'OpsList' => $OpsList, 'mg_overview' => $LNG['mg_overview'], 'mg_game_operators' => $LNG['mg_game_operators']));
            $template->show("message_overview.tpl");
            break;
    }
}
 public function __construct()
 {
     global $USER, $PLANET, $LNG, $db, $UNI;
     $parse = $LNG;
     $mode = request_var('mode', '');
     $a = request_var('a', 1);
     $sort1 = request_var('sort1', '');
     $sort2 = request_var('sort2', '');
     $edit = request_var('edit', '');
     $rank = request_var('rank', '');
     $kick = request_var('kick', '');
     $id = request_var('id', '');
     $action = request_var('action', '');
     $allyid = request_var('allyid', '');
     $tag = request_var('tag', '');
     $PlanetRess = new ResourceUpdate();
     $PlanetRess->CalcResource();
     $PlanetRess->SavePlanetToDB();
     $template = new template();
     if ($USER['ally_id'] != 0 && $USER['ally_request'] != 0) {
         $db->query("UPDATE `" . USERS . "` SET `ally_id` = 0 WHERE `id` = " . $USER['id'] . ";");
         redirectTo("game.php?page=alliance");
     }
     switch ($USER['ally_id']) {
         case 0:
             switch ($mode) {
                 case 'ainfo':
                     $allyrow = $db->uniquequery("SELECT * FROM " . ALLIANCE . " WHERE ally_tag='" . $db->sql_escape($tag) . "' OR id='" . $db->sql_escape($a) . "';");
                     if (!$allyrow) {
                         die(redirectTo("game.php?page=alliance"));
                     }
                     $this->ainfo($allyrow, $template);
                     break;
                 case 'make':
                     if ($USER['ally_request'] == 0) {
                         if ($action == "send") {
                             $atag = request_var('atag', '', UTF8_SUPPORT);
                             $aname = request_var('aname', '', UTF8_SUPPORT);
                             if (empty($atag)) {
                                 $template->message($LNG['al_tag_required'], "?page=alliance&mode=make", 3);
                             }
                             if (empty($aname)) {
                                 $template->message($LNG['al_name_required'], "?page=alliance&mode=make", 3);
                             }
                             if (!CheckName($aname) || !CheckName($atag)) {
                                 $template->message(UTF8_SUPPORT ? $LNG['al_newname_no_space'] : $LNG['al_newname_alphanum'], "?page=alliance&mode=make", 3);
                             }
                             $tagquery = $db->countquery("SELECT COUNT(*) FROM `" . ALLIANCE . "` WHERE `ally_universe` = '" . $UNI . "' AND (ally_tag = '" . $db->sql_escape($atag) . "' OR ally_name = '" . $db->sql_escape($aname) . "');");
                             if ($tagquery == 0) {
                                 $template->message(sprintf($LNG['al_already_exists'], $aname), "?page=alliance&mode=make", 3);
                             }
                             $db->multi_query("INSERT INTO " . ALLIANCE . " SET\r\n                                `ally_name`='" . $db->sql_escape($aname) . "',\r\n                                `ally_tag`='" . $db->sql_escape($atag) . "' ,\r\n                                `ally_owner`='" . $USER['id'] . "',\r\n                                `ally_owner_range`='Leader',\r\n                                `ally_members`='1',\r\n                                `ally_register_time`='" . TIMESTAMP . "',\r\n\t\t\t\t\t\t\t\t`ally_universe` ='" . $UNI . "';\r\n                                UPDATE " . USERS . " SET\r\n                                `ally_id`= (SELECT `id` FROM " . ALLIANCE . " WHERE ally_name = '" . $db->sql_escape($aname) . "'),\r\n                                `ally_name` = '" . $db->sql_escape($aname) . "',\r\n                                `ally_register_time` = '" . TIMESTAMP . "'\r\n                                WHERE `id` = '" . $USER['id'] . "';\r\n                                UPDATE " . STATPOINTS . " SET\r\n                                `id_ally` = (SELECT `id` FROM " . ALLIANCE . " WHERE ally_name = '" . $db->sql_escape($aname) . "')\r\n                                WHERE `id_owner` = '" . $USER['id'] . "';");
                             $template->message(sprintf($LNG['al_created'], $atag), "?page=alliance", 3);
                         } else {
                             $template->assign_vars(array('al_make_alliance' => $LNG['al_make_alliance'], 'al_make_ally_tag_required' => $LNG['al_make_ally_tag_required'], 'al_make_ally_name_required' => $LNG['al_make_ally_name_required'], 'al_make_submit' => $LNG['al_make_submit']));
                             $template->show("alliance_make.tpl");
                         }
                     } else {
                         redirectTo("game.php?page=alliance");
                     }
                     break;
                 case 'search':
                     if ($USER['ally_request'] == 0) {
                         $searchtext = request_var('searchtext', '', UTF8_SUPPORT);
                         if (!empty($searchtext)) {
                             $Search = $db->query("SELECT id, ally_tag, ally_name, ally_members FROM " . ALLIANCE . " WHERE ally_name LIKE '%" . $db->sql_escape($searchtext, true) . "%' OR ally_tag LIKE '%" . $db->sql_escape($searchtext, true) . "%' LIMIT 30;");
                             $SeachResult = array();
                             while ($CurrRow = $db->fetch_array($Search)) {
                                 $SeachResult[] = array('id' => $CurrRow['id'], 'tag' => $CurrRow['ally_tag'], 'name' => $CurrRow['ally_name'], 'members' => $CurrRow['ally_members']);
                             }
                         }
                         $template->assign_vars(array('searchtext' => $searchtext, 'SeachResult' => $SeachResult, 'al_find_submit' => $LNG['al_find_submit'], 'al_find_text' => $LNG['al_find_text'], 'al_find_alliances' => $LNG['al_find_alliances'], 'al_make_submit' => $LNG['al_make_submit'], 'al_find_no_alliances' => $LNG['al_find_no_alliances'], 'al_ally_info_members' => $LNG['al_ally_info_members'], 'al_ally_info_name' => $LNG['al_ally_info_name'], 'al_ally_info_tag' => $LNG['al_ally_info_tag']));
                         $template->show("alliance_searchform.tpl");
                     } else {
                         redirectTo("game.php" . "?page=alliance");
                     }
                     break;
                 case 'apply':
                     if ($USER['ally_request'] == 0) {
                         $text = request_var('text', '', true);
                         $allyrow = $db->uniquequery("SELECT `ally_tag`, `ally_request`, `ally_request_notallow` FROM " . ALLIANCE . " WHERE id='" . $db->sql_escape($allyid) . "';");
                         if (!$allyrow) {
                             redirectTo("game.php?page=alliance");
                         }
                         if ($allyrow['ally_request_notallow'] == 1) {
                             $template->message($LNG['al_alliance_closed']);
                             exit;
                         } else {
                             if ($action == "send") {
                                 $db->query("UPDATE " . USERS . " SET `ally_request`='" . $db->sql_escape($allyid) . "', ally_request_text='" . $db->sql_escape($text) . "', ally_register_time='" . TIMESTAMP . "' WHERE `id`='" . $USER['id'] . "';");
                                 $template->message($LNG['al_request_confirmation_message'], "?page=alliance");
                             } else {
                                 $template->assign_vars(array('allyid' => $allyid, 'al_your_request_title' => $LNG['al_your_request_title'], 'applytext' => !empty($allyrow['ally_request']) ? $allyrow['ally_request'] : $LNG['al_default_request_text'], 'al_write_request' => sprintf($LNG['al_write_request'], $allyrow['ally_tag']), 'al_applyform_reload' => $LNG['al_applyform_reload'], 'al_applyform_send' => $LNG['al_applyform_send'], 'al_message' => $LNG['al_message']));
                                 $template->show("alliance_applyform.tpl");
                             }
                         }
                     } else {
                         redirectTo("game.php?page=alliance");
                     }
                     break;
                 default:
                     if ($USER['ally_request'] != 0) {
                         $allyquery = $db->uniquequery("SELECT ally_tag FROM " . ALLIANCE . " WHERE id = '" . $USER['ally_request'] . "' ORDER BY `id`;");
                         $bcancel = request_var('bcancel', '');
                         if ($bcancel) {
                             $db->query("UPDATE " . USERS . " SET `ally_request`= 0 WHERE `id`='" . $USER['id'] . "';");
                             $template->assign_vars(array('al_your_request_title' => $LNG['al_your_request_title'], 'button_text' => $LNG['al_continue'], 'request_text' => sprintf($LNG['al_request_deleted'], $allyquery['ally_tag']), 'al_make_submit' => $LNG['al_continue']));
                         } else {
                             $template->assign_vars(array('al_your_request_title' => $LNG['al_your_request_title'], 'button_text' => $LNG['al_delete_request'], 'request_text' => sprintf($LNG['al_request_wait_message'], $allyquery['ally_tag']), 'al_make_submit' => $LNG['al_make_submit']));
                         }
                         $template->show("alliance_apply_waitform.tpl");
                     } else {
                         $template->assign_vars(array('al_alliance_search' => $LNG['al_alliance_search'], 'al_alliance_make' => $LNG['al_alliance_make'], 'al_alliance' => $LNG['al_alliance']));
                         $template->show("alliance_defaultmenu.tpl");
                     }
                     break;
             }
             break;
         default:
             $ally = $db->uniquequery("SELECT * FROM " . ALLIANCE . " WHERE id='" . $USER['ally_id'] . "';");
             if (!$ally) {
                 $db->query("UPDATE `" . USERS . "` SET `ally_id` = 0 WHERE `id` = " . $USER['id'] . ";");
                 redirectTo("game.php?page=alliance");
             }
             $ally_ranks = unserialize($ally['ally_ranks']);
             $USER['rights']['memberlist_on'] = $ally_ranks[$USER['ally_rank_id'] - 1]['onlinestatus'] == 1 || $ally['ally_owner'] == $USER['id'] ? true : false;
             $USER['rights']['memberlist'] = $ally_ranks[$USER['ally_rank_id'] - 1]['memberlist'] == 1 || $ally['ally_owner'] == $USER['id'] ? true : false;
             $USER['rights']['roundmail'] = $ally_ranks[$USER['ally_rank_id'] - 1]['mails'] == 1 || $ally['ally_owner'] == $USER['id'] ? true : false;
             $USER['rights']['kick'] = $ally_ranks[$USER['ally_rank_id'] - 1]['kick'] == 1 || $ally['ally_owner'] == $USER['id'] ? true : false;
             $USER['rights']['righthand'] = $ally_ranks[$USER['ally_rank_id'] - 1]['rechtehand'] == 1 || $ally['ally_owner'] == $USER['id'] ? true : false;
             $USER['rights']['close'] = $ally_ranks[$USER['ally_rank_id'] - 1]['delete'] == 1 || $ally['ally_owner'] == $USER['id'] ? true : false;
             $USER['rights']['seeapply'] = $ally_ranks[$USER['ally_rank_id'] - 1]['bewerbungen'] == 1 || $ally['ally_owner'] == $USER['id'] ? true : false;
             $USER['rights']['changeapply'] = $ally_ranks[$USER['ally_rank_id'] - 1]['bewerbungenbearbeiten'] == 1 || $ally['ally_owner'] == $USER['id'] ? true : false;
             $USER['rights']['admin'] = $ally_ranks[$USER['ally_rank_id'] - 1]['administrieren'] == 1 || $ally['ally_owner'] == $USER['id'] ? true : false;
             switch ($mode) {
                 case 'ainfo':
                     $allyrow = $db->uniquequery("SELECT * FROM " . ALLIANCE . " WHERE ally_tag='" . $db->sql_escape($tag) . "' OR id='" . $db->sql_escape($a) . "';");
                     if (!$allyrow) {
                         redirectTo("game.php?page=alliance");
                     }
                     $this->ainfo($allyrow, $template);
                     break;
                 case 'exit':
                     if ($ally['ally_owner'] == $USER['id']) {
                         $template->message($LNG['al_founder_cant_leave_alliance'], "?page=alliance", 3);
                     } elseif ($action = "send") {
                         $db->multi_query("UPDATE " . USERS . " SET `ally_id` = 0, `ally_name` = '', ally_rank_id = 0 WHERE `id`='" . $USER['id'] . "';UPDATE " . ALLIANCE . " SET `ally_members` = `ally_members` - 1 WHERE `id`='" . $ally['id'] . "';UPDATE " . STATPOINTS . " SET `id_ally` = '0' WHERE `id_ally` = '" . $ally['id'] . "' AND `id_owner` = '" . $USER['id'] . "';");
                         $template->message(sprintf($LNG['al_leave_sucess'], $ally['ally_name']), "game.php?page=alliance", 2);
                     } else {
                         $template->message(sprintf($LNG['al_do_you_really_want_to_go_out'], $ally['ally_name']) . "<br><a href=\"?page=alliance&amp;mode=exit&amp;action=send\">" . $LNG['al_go_out_yes'] . "</a>");
                     }
                     break;
                 case 'memberslist':
                     if (!$USER['rights']['memberlist']) {
                         redirectTo("game.php?page=alliance");
                     }
                     if ($sort1 && $sort2) {
                         switch ($sort1) {
                             case 1:
                                 $sort = " ORDER BY `username`";
                                 break;
                             case 2:
                                 $sort = " ORDER BY `ally_rank_id`";
                                 break;
                             case 3:
                                 $sort = " ORDER BY `total_points`";
                                 break;
                             case 4:
                                 $sort = " ORDER BY `ally_register_time`";
                                 break;
                             case 5:
                                 $sort = " ORDER BY `onlinetime`";
                                 break;
                             default:
                                 $sort = " ORDER BY `id`";
                                 break;
                         }
                         if ($sort2 == 1) {
                             $sort .= " DESC;";
                         } elseif ($sort2 == 2) {
                             $sort .= " ASC;";
                         }
                         $listuser = $db->query("SELECT DISTINCT u.id, u.username,u.galaxy, u.system, u.planet, u.ally_register_time, u.onlinetime, u.ally_rank_id, s.total_points FROM `" . USERS . "` as u LEFT JOIN " . STATPOINTS . " as s ON s.`stat_type` = '1' AND s.`id_owner` = u.`id` WHERE ally_id = '" . $USER['ally_id'] . "'" . $sort . ";");
                     } else {
                         $listuser = $db->query("SELECT DISTINCT u.id, u.username,u.galaxy, u.system, u.planet, u.ally_register_time, u.onlinetime, u.ally_rank_id, s.total_points FROM `" . USERS . "` as u LEFT JOIN " . STATPOINTS . " as s ON s.`stat_type` = '1' AND s.`id_owner` = u.`id` WHERE `ally_id` = '" . $USER['ally_id'] . "';");
                     }
                     while ($UserRow = $db->fetch_array($listuser)) {
                         if ($ally['ally_owner'] == $UserRow['id']) {
                             $UserRow['ally_range'] = $ally['ally_owner_range'] == '' ? $LNG['al_founder_rank_text'] : $ally['ally_owner_range'];
                         } elseif ($UserRow['ally_rank_id'] != 0) {
                             $UserRow['ally_range'] = $ally_ranks[$UserRow['ally_rank_id'] - 1]['name'];
                         } else {
                             $UserRow['ally_range'] = $LNG['al_new_member_rank_text'];
                         }
                         $Memberlist[] = array('id' => $UserRow['id'], 'username' => $UserRow['username'], 'galaxy' => $UserRow['galaxy'], 'system' => $UserRow['system'], 'planet' => $UserRow['planet'], 'register_time' => date(TDFORMAT, $UserRow['ally_register_time']), 'points' => pretty_number($UserRow['total_points']), 'range' => $UserRow['ally_range'], 'onlinetime' => floor((TIMESTAMP - $UserRow['onlinetime']) / 60));
                     }
                     if (count($Memberlist) != $ally['ally_members']) {
                         $db->query("UPDATE " . ALLIANCE . " SET `ally_members`='" . count($Memberlist) . "' WHERE `id`='" . $ally['id'] . "';");
                     }
                     $template->assign_vars(array('Memberlist' => $Memberlist, 'sort' => $sort2 == 1 ? 2 : 1, 'seeonline' => $USER['rights']['memberlist_on'], 'al_users_list' => sprintf($LNG['al_users_list'], count($Memberlist)), 'al_num' => $LNG['al_num'], 'al_back' => $LNG['al_back'], 'al_message' => $LNG['al_message'], 'al_member' => $LNG['al_member'], 'al_position' => $LNG['al_position'], 'al_points' => $LNG['al_points'], 'al_coords' => $LNG['al_coords'], 'al_member_since' => $LNG['al_member_since'], 'al_estate' => $LNG['al_estate'], 'al_memberlist_on' => $LNG['al_memberlist_on'], 'al_memberlist_off' => $LNG['al_memberlist_off'], 'al_memberlist_min' => $LNG['al_memberlist_min']));
                     $template->show("alliance_memberslist.tpl");
                     break;
                 case 'circular':
                     if (!$USER['rights']['roundmail']) {
                         redirectTo("game.php?page=alliance");
                     }
                     if ($action == "send") {
                         $r = request_var('r', 0);
                         $subject = request_var('subject', '', true);
                         $text = makebr(request_var('text', '', true));
                         $sq = $r == 0 ? $db->query("SELECT id, username FROM " . USERS . " WHERE `ally_id` = '" . $USER['ally_id'] . "';") : $db->query("SELECT id, username FROM " . USERS . " WHERE `ally_id` = '" . $USER['ally_id'] . "' AND `ally_rank_id` = '" . $r . "';");
                         $list = '';
                         $title = $LNG['al_circular_alliance'] . $ally['ally_tag'];
                         $text = sprintf($LNG['al_circular_front_text'], $USER['username']) . "<br>" . $text;
                         while ($u = $db->fetch_array($sq)) {
                             SendSimpleMessage($u['id'], $USER['id'], '', 2, $title, $subject, $text);
                             $list .= "\n" . $u['username'];
                         }
                         exit($LNG['al_circular_sended'] . $list);
                     }
                     $RangeList[] = $LNG['al_all_players'];
                     if (is_array($ally_ranks)) {
                         foreach ($ally_ranks as $id => $array) {
                             $RangeList[$id + 1] = $array['name'];
                         }
                     }
                     $template->assign_vars(array('RangeList' => $RangeList, 'al_circular_send_ciruclar' => $LNG['al_circular_send_ciruclar'], 'al_circular_reset' => $LNG['al_circular_reset'], 'al_receiveral_message' => $LNG['al_receiveral_message'], 'al_circular_send_submit' => $LNG['al_circular_send_submit'], 'al_characters' => $LNG['al_characters'], 'al_receiver' => $LNG['al_receiver'], 'mg_subject' => $LNG['mg_subject'], 'mg_no_subject' => $LNG['mg_no_subject'], 'mg_empty_text' => $LNG['mg_empty_text']));
                     $template->show("alliance_circular.tpl");
                     break;
                 case 'admin':
                     if (!$USER['rights']['admin']) {
                         exit(redirectTo("game.php?page=alliance"));
                     }
                     switch ($edit) {
                         case 'rights':
                             if (!$USER['rights']['righthand']) {
                                 exit(redirectTo("game.php?page=alliance"));
                             }
                             $rankname = request_var('newrangname', '', UTF8_SUPPORT);
                             $pid = $_POST['id'];
                             $d = request_var('d', 1337);
                             if (!empty($rankname)) {
                                 $pid = request_var('id', '');
                                 $ally_ranks[] = array('name' => $rankname, 'mails' => 0, 'delete' => 0, 'kick' => 0, 'bewerbungen' => 0, 'administrieren' => 0, 'bewerbungenbearbeiten' => 0, 'memberlist' => 0, 'onlinestatus' => 0, 'rechtehand' => 0);
                                 $ranks = serialize($ally_ranks);
                                 $db->query("UPDATE " . ALLIANCE . " SET `ally_ranks`='" . $ranks . "' WHERE `id`='" . $ally['id'] . "';");
                                 redirectTo("game.php?page=alliance&mode=admin&edit=rights");
                                 exit;
                             } elseif (is_array($pid)) {
                                 $ally_ranks_new = array();
                                 foreach ($pid as $id) {
                                     $ally_ranks_new[$id]['name'] = $ally_ranks[$id]['name'];
                                     $ally_ranks_new[$id]['delete'] = isset($_POST['u' . $id . 'r0']) && $USER['rights']['close'] ? 1 : 0;
                                     $ally_ranks_new[$id]['kick'] = isset($_POST['u' . $id . 'r1']) && $USER['rights']['kick'] ? 1 : 0;
                                     $ally_ranks_new[$id]['bewerbungen'] = isset($_POST['u' . $id . 'r2']) && $USER['rights']['seeapply'] ? 1 : 0;
                                     $ally_ranks_new[$id]['memberlist'] = isset($_POST['u' . $id . 'r3']) && $USER['rights']['memberlist'] ? 1 : 0;
                                     $ally_ranks_new[$id]['bewerbungenbearbeiten'] = isset($_POST['u' . $id . 'r4']) && $USER['rights']['changeapply'] ? 1 : 0;
                                     $ally_ranks_new[$id]['administrieren'] = isset($_POST['u' . $id . 'r5']) && $USER['rights']['admin'] ? 1 : 0;
                                     $ally_ranks_new[$id]['onlinestatus'] = isset($_POST['u' . $id . 'r6']) && $USER['rights']['memberlist_on'] ? 1 : 0;
                                     $ally_ranks_new[$id]['mails'] = isset($_POST['u' . $id . 'r7']) && $USER['rights']['roundmail'] ? 1 : 0;
                                     $ally_ranks_new[$id]['rechtehand'] = isset($_POST['u' . $id . 'r8']) && $USER['rights']['righthand'] ? 1 : 0;
                                 }
                                 $ranks = serialize($ally_ranks_new);
                                 $db->query("UPDATE " . ALLIANCE . " SET `ally_ranks`='" . $ranks . "' WHERE `id`='" . $ally['id'] . "';");
                                 redirectTo("game.php?page=alliance&mode=admin&edit=rights");
                                 exit;
                             } elseif (isset($ally_ranks[$d])) {
                                 unset($ally_ranks[$d]);
                                 $db->query("UPDATE " . ALLIANCE . " SET `ally_ranks`='" . serialize($ally_ranks) . "' WHERE `id`='" . $ally['id'] . "';");
                             }
                             if (is_array($ally_ranks)) {
                                 foreach ($ally_ranks as $a => $b) {
                                     $AllyRanks[] = array('id' => $a, 'name' => $b['name'], 'memberlist_on' => $b['onlinestatus'], 'memberlist' => $b['memberlist'], 'roundmail' => $b['mails'], 'kick' => $b['kick'], 'righthand' => $b['rechtehand'], 'close' => $b['delete'], 'seeapply' => $b['bewerbungen'], 'changeapply' => $b['bewerbungenbearbeiten'], 'admin' => $b['administrieren']);
                                 }
                             }
                             $template->assign_vars(array('AllyRanks' => $AllyRanks, 'memberlist_on' => $USER['rights']['memberlist_on'], 'memberlist' => $USER['rights']['memberlist'], 'roundmail' => $USER['rights']['roundmail'], 'kick' => $USER['rights']['kick'], 'righthand' => $USER['rights']['righthand'], 'close' => $USER['rights']['close'], 'seeapply' => $USER['rights']['seeapply'], 'changeapply' => $USER['rights']['changeapply'], 'admin' => $USER['rights']['admin'], 'al_configura_ranks' => $LNG['al_configura_ranks'], 'al_save' => $LNG['al_configura_ranks'], 'Delete_range' => $LNG['Delete_range'], 'al_rank_name' => $LNG['al_rank_name'], 'al_dlte' => $LNG['al_dlte'], 'al_create' => $LNG['al_create'], 'al_rank_name' => $LNG['al_rank_name'], 'al_create_new_rank' => $LNG['al_create_new_rank'], 'al_back' => $LNG['al_back'], 'al_legend' => $LNG['al_legend'], 'al_no_ranks_defined' => $LNG['al_no_ranks_defined'], 'al_legend_kick_users' => $LNG['al_legend_kick_users'], 'al_legend_disolve_alliance' => $LNG['al_legend_disolve_alliance'], 'al_legend_see_requests' => $LNG['al_legend_see_requests'], 'al_legend_see_users_list' => $LNG['al_legend_see_users_list'], 'al_legend_check_requests' => $LNG['al_legend_check_requests'], 'al_legend_admin_alliance' => $LNG['al_legend_admin_alliance'], 'al_legend_see_connected_users' => $LNG['al_legend_see_connected_users'], 'al_legend_create_circular' => $LNG['al_legend_create_circular'], 'al_legend_right_hand' => $LNG['al_legend_right_hand']));
                             $template->show("alliance_admin_ranks.tpl");
                             break;
                         case 'members':
                             $NewRang = request_var('newrang', '');
                             if ($NewRang != '') {
                                 $q = $db->uniquequery("SELECT id FROM " . USERS . " WHERE id='" . $db->sql_escape($id) . "';");
                                 isset($ally_ranks[$NewRang - 1]) && $q['id'] != $ally['ally_owner'] ? $db->query("UPDATE " . USERS . " SET `ally_rank_id`='" . $db->sql_escape($NewRang) . "' WHERE `id`='" . $db->sql_escape($id) . "';") : '';
                             } elseif ($action == "kick" && !empty($id) && $USER['rights']['kick']) {
                                 $u = $db->uniquequery("SELECT id FROM " . USERS . " WHERE id = '" . $db->sql_escape($id) . "' AND `ally_id` = '" . $ally['id'] . "' AND 'id' != '" . $ally['ally_owner'] . "';");
                                 !empty($u['id']) ? $db->multi_query("UPDATE " . USERS . " SET `ally_id` = '0', `ally_name` = '', `ally_rank_id` = 0 WHERE `id` = '" . $u['id'] . "';UPDATE " . ALLIANCE . " SET `ally_members` = ally_members - 1 WHERE `id` = '" . $ally['id'] . "';UPDATE " . STATPOINTS . " SET `id_ally` = '0' WHERE `id_ally` = '" . $ally['id'] . "' AND `id_owner` = '" . $u['id'] . "';") : '';
                             }
                             if ($sort1 && $sort2) {
                                 switch ($sort1) {
                                     case 1:
                                         $sort = " ORDER BY `username`";
                                         break;
                                     case 2:
                                         $sort = " ORDER BY `ally_rank_id`";
                                         break;
                                     case 3:
                                         $sort = " ORDER BY `total_points`";
                                         break;
                                     case 4:
                                         $sort = " ORDER BY `ally_register_time`";
                                         break;
                                     case 5:
                                         $sort = " ORDER BY `onlinetime`";
                                         break;
                                     default:
                                         $sort = " ORDER BY `id`";
                                         break;
                                 }
                                 if ($sort2 == 1) {
                                     $sort .= " DESC;";
                                 } elseif ($sort2 == 2) {
                                     $sort .= " ASC;";
                                 }
                                 $listuser = $db->query("SELECT DISTINCT u.id, u.username,u.galaxy, u.system, u.planet, u.ally_register_time, u.ally_rank_id, u.onlinetime, s.total_points FROM `" . USERS . "` as u LEFT JOIN " . STATPOINTS . " as s ON s.`stat_type` = '1' AND s.`id_owner` = u.`id` WHERE ally_id = '" . $USER['ally_id'] . "'" . $sort . ";");
                             } else {
                                 $listuser = $db->query("SELECT DISTINCT u.id, u.username,u.galaxy, u.system, u.planet, u.ally_register_time, u.ally_rank_id, u.onlinetime, s.total_points FROM `" . USERS . "` as u LEFT JOIN " . STATPOINTS . " as s ON s.`stat_type` = '1' AND s.`id_owner` = u.`id` WHERE `ally_id` = '" . $USER['ally_id'] . "';");
                             }
                             $Selector[0] = $LNG['al_new_member_rank_text'];
                             if (is_array($ally_ranks)) {
                                 foreach ($ally_ranks as $a => $b) {
                                     $Selector[$a + 1] = $b['name'];
                                 }
                             }
                             while ($UserRow = $db->fetch_array($listuser)) {
                                 if ($ally['ally_owner'] == $UserRow['id']) {
                                     $UserRow['ally_range'] = $ally['ally_owner_range'] == '' ? $LNG['al_founder_rank_text'] : $ally['ally_owner_range'];
                                 } elseif ($UserRow['ally_rank_id'] == 0) {
                                     $UserRow['ally_range'] = $LNG['al_new_member_rank_text'];
                                 } else {
                                     $UserRow['ally_range'] = $ally_ranks[$UserRow['ally_rank_id'] - 1]['name'];
                                 }
                                 $Memberlist[] = array('id' => $UserRow['id'], 'username' => $UserRow['username'], 'galaxy' => $UserRow['galaxy'], 'system' => $UserRow['system'], 'planet' => $UserRow['planet'], 'rank_id' => $UserRow['ally_rank_id'] - 1, 'register_time' => date(TDFORMAT, $UserRow['ally_register_time']), 'points' => pretty_number($UserRow['total_points']), 'range' => $UserRow['ally_range'], 'onlinetime' => sprintf("%d d", floor(TIMESTAMP - $UserRow['onlinetime']) / 86400), 'action' => $ally['ally_owner'] == $UserRow['id'] || $rank == $UserRow['id'] ? 0 : ($USER['rights']['kick'] == 1 ? 2 : 1), 'kick' => sprintf($LNG['al_kick_player'], $UserRow['username']));
                             }
                             count($Memberlist) != $ally['ally_members'] ? $db->query("UPDATE " . ALLIANCE . " SET `ally_members`='" . count($Memberlist) . "' WHERE `id`='" . $ally['id'] . "';") : '';
                             $template->assign_vars(array('Selector' => $Selector, 'Memberlist' => $Memberlist, 'sort' => $sort2 == 1 ? 2 : 1, 'seeonline' => $USER['rights']['memberlist_on'], 'al_users_list' => sprintf($LNG['al_users_list'], count($Memberlist)), 'id' => $NewRang == '' ? $id : 0, 'al_num' => $LNG['al_num'], 'al_back' => $LNG['al_back'], 'al_message' => $LNG['al_message'], 'al_member' => $LNG['al_member'], 'al_position' => $LNG['al_position'], 'al_points' => $LNG['al_points'], 'al_coords' => $LNG['al_coords'], 'al_member_since' => $LNG['al_member_since'], 'al_estate' => $LNG['al_estate'], 'al_actions' => $LNG['al_actions'], 'al_ok' => $LNG['al_ok']));
                             $template->show("alliance_admin_members.tpl");
                             break;
                         case 'diplo':
                             !$USER['rights']['righthand'] ? redirectTo("game.php?page=alliance") : '';
                             $action = request_var('action', '');
                             $id = request_var('id', 0);
                             $Level = request_var('level', 0);
                             $DiploInfo = $this->GetDiplo($ally['id']);
                             switch ($action) {
                                 case 'new':
                                     if (!empty($id)) {
                                         $text = request_var('text', '', true);
                                         $Alliances = $db->uniquequery("SELECT `ally_tag`, `ally_name` FROM " . ALLIANCE . " WHERE id = '" . $id . "';");
                                         if ($Level == 4) {
                                             $AllyUsers = $db->query("SELECT `id` FROM " . USERS . " as s WHERE s.ally_id = '" . $ally['id'] . "' OR s.ally_id = '" . $id . "';");
                                             while ($User = $db->fetch_array($AllyUsers)) {
                                                 SendSimpleMessage($User['id'], $USER['id'], '', 2, $LNG['al_circular_alliance'] . $ally['ally_tag'] . " &amp; " . $Alliances['ally_tag'], $LNG['al_diplo_war'], sprintf($LNG['al_diplo_war_mes'], $ally['ally_name'], $Alliances['ally_name'], $LNG['al_diplo_level'][$Level], $text));
                                             }
                                         } else {
                                             $RanksRAW = $db->uniquequery("SELECT `ally_ranks`, `ally_owner` FROM " . ALLIANCE . " WHERE id = '" . $id . "';");
                                             $Ranks = unserialize($RanksRAW['ally_ranks']);
                                             if (is_array($Ranks)) {
                                                 foreach ($Ranks as $ID => $RankInfo) {
                                                     if ($RankInfo['rechtehand'] == 0) {
                                                         continue;
                                                     }
                                                     $SendRank[1] = "`ally_rank_id` ='" . ($ID + 1) . "' OR ";
                                                 }
                                             }
                                             if (is_array($ally_ranks)) {
                                                 foreach ($ally_ranks as $ID => $RankInfo) {
                                                     if ($RankInfo['rechtehand'] == 0) {
                                                         continue;
                                                     }
                                                     $SendRank[0] = "`ally_rank_id` ='" . ($ID + 1) . "' OR ";
                                                 }
                                             }
                                             $AllyUsers = $db->query("SELECT `id` FROM " . USERS . " WHERE (ally_id = '" . $ally['id'] . "' AND (" . $SendRank[0] . "`id` = '" . $ally['ally_owner'] . "')) OR (ally_id = '" . $id . "' AND (" . $SendRank[1] . "`id` = '" . $RanksRAW['ally_owner'] . "'));");
                                             while ($User = $db->fetch_array($AllyUsers)) {
                                                 SendSimpleMessage($User['id'], $USER['id'], '', 2, $LNG['al_circular_alliance'] . $ally['ally_tag'] . " &amp; " . $Alliances['ally_tag'], $LNG['al_diplo_ask'], sprintf($LNG['al_diplo_ask_mes'], $LNG['al_diplo_level'][$Level], $ally['ally_name'], $Alliances['ally_name'], $text));
                                             }
                                         }
                                         $db->query("INSERT INTO " . DIPLO . " (`id` ,`owner_1` ,`owner_2` ,`level` ,`accept` ,`accept_text`) VALUES (NULL , '" . $ally['id'] . "', '" . $id . "', '" . $Level . "', '" . ($Level == 4 ? 1 : 0) . "', '" . $db->sql_escape($text) . "');");
                                         exit($LNG['al_diplo_create_done']);
                                     }
                                     $Alliances = $db->query("SELECT `id`, `ally_name` FROM " . ALLIANCE . " WHERE id != '" . $ally['id'] . "';");
                                     while ($Alliance = $db->fetch_array($Alliances)) {
                                         $AllianceList[$Alliance['id']] = $Alliance['ally_name'];
                                     }
                                     $template->assign_vars(array('AllianceList' => $AllianceList, 'al_diplo_create' => $LNG['al_diplo_create'], 'al_diplo_ally' => $LNG['al_diplo_ally'], 'al_diplo_level' => $LNG['al_diplo_level'], 'al_diplo_text' => $LNG['al_diplo_text'], 'al_diplo_level_des' => $LNG['al_diplo_level_des'], 'al_applyform_send' => $LNG['al_applyform_send'], 'mg_empty_text' => $LNG['mg_empty_text']));
                                     $template->show("alliance_admin_diplo_form.tpl");
                                     break;
                                 case 'accept':
                                     if (!empty($id)) {
                                         $AllyUsers = $db->query("SELECT `id` FROM " . USERS . " as s WHERE s.ally_id = '" . $ally['id'] . "' OR s.ally_id = '" . $DiploInfo[5][$id][1] . "';");
                                         while ($User = $db->fetch_array($AllyUsers)) {
                                             SendSimpleMessage($User['id'], $USER['id'], '', 2, $LNG['al_circular_alliance'] . $ally['ally_tag'] . " &amp; " . $DiploInfo[5][$id][5], $LNG['al_diplo_accept_yes'], sprintf($LNG['al_diplo_accept_yes_mes'], $LNG['al_diplo_level'][$Level], $ally['ally_name'], $DiploInfo[5][$id][0]));
                                         }
                                         $db->query("UPDATE " . DIPLO . " SET `accept` = '1', `accept_text` = '' WHERE `id`='" . $id . "' LIMIT 1;");
                                     }
                                     redirectTo("game.php?page=alliance&mode=admin&edit=diplo");
                                     break;
                                 case 'decline':
                                     if (!empty($id)) {
                                         $AllyUsers = $db->query("SELECT `id` FROM " . USERS . " as s WHERE s.ally_id = '" . $ally['id'] . "' OR s.ally_id = '" . $DiploInfo[5][$id][1] . "';");
                                         while ($User = $db->fetch_array($AllyUsers)) {
                                             SendSimpleMessage($User['id'], $USER['id'], '', 2, $LNG['al_circular_alliance'] . $ally['ally_tag'] . " &amp; " . $DiploInfo[5][$id][5], $LNG['al_diplo_accept_no'], sprintf($LNG['al_diplo_accept_no_mes'], $LNG['al_diplo_level'][$Level], $ally['ally_name'], $DiploInfo[5][$id][0]));
                                         }
                                         $db->query("DELETE FROM " . DIPLO . " WHERE `id` ='" . $id . "' LIMIT 1;");
                                     }
                                     redirectTo("game.php?page=alliance&mode=admin&edit=diplo");
                                     break;
                                 case 'delete':
                                     if (!empty($id)) {
                                         if (isset($DiploInfo[$Level][$id][1])) {
                                             $AllyUsers = $db->query("SELECT `id` FROM " . USERS . " as s WHERE s.ally_id = '" . $ally['id'] . "' OR s.ally_id = '" . $DiploInfo[$Level][$id][1] . "';");
                                             while ($User = $db->fetch_array($AllyUsers)) {
                                                 SendSimpleMessage($User['id'], $USER['id'], '', 2, $LNG['al_circular_alliance'] . $ally['ally_tag'] . " &amp; " . $DiploInfo[$Level][$id][3], $LNG['al_diplo_delete'], sprintf($LNG['al_diplo_delete_mes'], $LNG['al_diplo_level'][$Level], $ally['ally_name'], $DiploInfo[$Level][$id][0]));
                                             }
                                         }
                                         $db->query("DELETE FROM " . DIPLO . " WHERE `id` ='" . $id . "' LIMIT 1;");
                                     }
                                     redirectTo("game.php?page=alliance&mode=admin&edit=diplo");
                                     break;
                                 default:
                                     $template->assign_vars(array('DiploInfo' => $DiploInfo, 'al_diplo_create' => $LNG['al_diplo_create'], 'al_diplo_level' => $LNG['al_diplo_level'], 'al_diplo_accept' => $LNG['al_diplo_accept'], 'al_diplo_accept_send' => $LNG['al_diplo_accept_send'], 'al_diplo_no_entry' => $LNG['al_diplo_no_entry'], 'al_diplo_no_accept' => $LNG['al_diplo_no_accept'], 'al_diplo_confirm_delete' => $LNG['al_diplo_confirm_delete'], 'al_diplo_accept_yes_confirm' => $LNG['al_diplo_accept_yes_confirm'], 'al_diplo_accept_no_confirm' => $LNG['al_diplo_accept_no_confirm'], 'al_diplo_ground' => $LNG['al_diplo_ground'], 'al_back' => $LNG['al_back'], 'ally_id' => $ally['id']));
                                     $template->show("alliance_admin_diplo.tpl");
                                     break;
                             }
                             break;
                         case 'requests':
                             !$USER['rights']['seeapply'] || !$USER['rights']['changeapply'] ? redirectTo("game.php?page=alliance") : '';
                             $text = makebr(request_var('text', '', true));
                             if ($action == $LNG['al_acept_request']) {
                                 $db->multi_query("UPDATE " . ALLIANCE . " SET `ally_members` = `ally_members` + 1 WHERE id='" . $ally['id'] . "';UPDATE " . USERS . " SET ally_name='" . $ally['ally_name'] . "', ally_request_text='', ally_request='0', ally_id='" . $ally['id'] . "' WHERE id='" . $db->sql_escape($id) . "';UPDATE " . STATPOINTS . " SET `id_ally` = '" . $ally['id'] . "' WHERE `id_owner` = '" . $id . "';");
                                 SendSimpleMessage($id, $USER['id'], '', 2, $ally['ally_tag'], $LNG['al_you_was_acceted'] . $ally['ally_name'], $LNG['al_hi_the_alliance'] . $ally['ally_name'] . $LNG['al_has_accepted'] . $text);
                                 redirectTo('game.php?page=alliance&mode=admin&edit=ally');
                             } elseif ($action == $LNG['al_decline_request']) {
                                 $db->query("UPDATE " . USERS . " SET ally_request_text='',ally_request='0',ally_id='0' WHERE id='" . $db->sql_escape($id) . "';");
                                 SendSimpleMessage($id, $USER['id'], '', 2, $ally['ally_tag'], $LNG['al_you_was_declined'] . $ally['ally_name'], $LNG['al_hi_the_alliance'] . $ally['ally_name'] . $LNG['al_has_declined'] . $text);
                                 redirectTo('game.php?page=alliance&mode=admin&edit=ally');
                             }
                             $query = $db->query("SELECT id,username,ally_request_text,ally_register_time FROM " . USERS . " WHERE ally_request='" . $ally['id'] . "';");
                             while ($RequestRow = $db->fetch_array($query)) {
                                 $RequestList[] = array('username' => $RequestRow['username'], 'text' => makebr($RequestRow['ally_request_text']), 'id' => $RequestRow['id'], 'time' => date(TDFORMAT, $RequestRow['ally_register_time']));
                             }
                             $template->assign_vars(array('RequestList' => $RequestList, 'requestcount' => sprintf($LNG['al_no_request_pending'], count($RequestList)), 'al_no_requests' => $LNG['al_no_requests'], 'al_candidate' => $LNG['al_candidate'], 'al_request_date' => $LNG['al_request_date'], 'al_request_list' => $LNG['al_request_list'], 'al_back' => $LNG['al_back'], 'al_reason' => $LNG['al_reason'], 'al_characters' => $LNG['al_characters'], 'al_request_from_user' => $LNG['al_request_from_user'], 'al_acept_request' => $LNG['al_acept_request'], 'al_decline_request' => $LNG['al_decline_request'], 'al_reply_to_request' => $LNG['al_reply_to_request']));
                             $template->show("alliance_admin_request.tpl");
                             break;
                         case 'tag':
                             $name = request_var('newname', '', UTF8_SUPPORT);
                             !empty($name) ? $db->query("UPDATE " . ALLIANCE . " SET `ally_tag` = '" . $db->sql_escape($name) . "' WHERE `id` = '" . $USER['ally_id'] . "';") : '';
                             $template->assign_vars(array('caso' => $LNG['al_tag'], 'caso_titulo' => $LNG['al_new_tag'], 'al_change_submit' => $LNG['al_change_submit'], 'al_back' => $LNG['al_back']));
                             $template->show("alliance_admin_rename.tpl");
                             break;
                         case 'name':
                             $name = request_var('newname', '', UTF8_SUPPORT);
                             !empty($name) ? $db->multi_query("UPDATE " . ALLIANCE . " SET `ally_name` = '" . $db->sql_escape($name) . "' WHERE `id` = '" . $USER['ally_id'] . "';UPDATE " . USERS . " SET `ally_name` = '" . $db->sql_escape($name) . "' WHERE `ally_id` = '" . $ally['id'] . "';") : '';
                             $template->assign_vars(array('caso' => $LNG['al_name'], 'caso_titulo' => $LNG['al_new_name'], 'al_change_submit' => $LNG['al_change_submit'], 'al_back' => $LNG['al_back']));
                             $template->show("alliance_admin_rename.tpl");
                             break;
                         case 'exit':
                             !$USER['rights']['close'] ? redirectTo("game.php?page=alliance") : '';
                             $db->multi_query("UPDATE " . USERS . " SET `ally_name` = '', `ally_id` = '0' WHERE `ally_id`='" . $ally['id'] . "';UPDATE " . STATPOINTS . " SET `id_ally` = '0' WHERE `id_ally` = '" . $ally['id'] . "';DELETE FROM " . ALLIANCE . " WHERE id = '" . $ally['id'] . "';DELETE FROM " . DIPLO . " WHERE `owner_1` = '" . $ally['id'] . "' OR `owner_2` = '" . $ally['id'] . "';");
                             redirectTo("game.php?page=alliance");
                             break;
                         case 'transfer':
                             $ally['ally_owner'] != $USER['id'] ? redirectTo("game.php?page=alliance") : '';
                             $postleader = request_var('newleader', 0);
                             if (!empty($postleader)) {
                                 $Rank = $db->uniquequery("SELECT `ally_rank_id` FROM " . USERS . " WHERE `id` = '" . $postleader . "';");
                                 $db->multi_query("UPDATE " . USERS . " SET `ally_rank_id` = '" . $Rank['ally_rank_id'] . "' WHERE `id` = '" . $USER['id'] . "';UPDATE " . USERS . " SET `ally_rank_id`= '0' WHERE `id` = '" . $postleader . "';UPDATE " . ALLIANCE . " SET `ally_owner` = '" . $postleader . "' WHERE `id` = '" . $USER['ally_id'] . "';");
                                 redirectTo("game.php?page=alliance");
                             } else {
                                 $listuser = $db->query("SELECT id,ally_rank_id,username FROM " . USERS . " WHERE ally_id = '" . $USER['ally_id'] . "';");
                                 while ($u = $db->fetch_array($listuser)) {
                                     $TransferUsers[$u['id']] = !empty($u['ally_rank_id']) && $ally['ally_owner'] != $u['id'] && $ally_ranks[$u['ally_rank_id'] - 1]['rechtehand'] == 1 ? $u['username'] . " [" . $ally_ranks[$u['ally_rank_id'] - 1]['name'] . "]" : '';
                                 }
                                 $template->assign_vars(array('TransferUsers' => $TransferUsers, 'al_transfer_alliance' => $LNG['al_transfer_alliance'], 'al_transfer_to' => $LNG['al_transfer_to'], 'al_back' => $LNG['al_back'], 'al_transfer_submit' => $LNG['al_transfer_submit']));
                                 $template->show("alliance_admin_transfer.tpl");
                             }
                             break;
                         default:
                             $text = request_var('text', '0', true);
                             $t = request_var('t', 1);
                             if (isset($_POST['options'])) {
                                 $ally['ally_owner_range'] = request_var('owner_range', '', true);
                                 $ally['ally_web'] = request_var('web', '');
                                 $ally['ally_image'] = request_var('image', '');
                                 $ally['ally_request_notallow'] = request_var('request_notallow', 0);
                                 $ally['ally_stats'] = request_var('stats', 0);
                                 $ally['ally_diplo'] = request_var('diplo', 0);
                                 if ($ally['ally_request_notallow'] != 0 && $ally['ally_request_notallow'] != 1) {
                                     exit(redirectTo("game.php" . "?page=alliance"));
                                 }
                                 $db->query("UPDATE " . ALLIANCE . " SET\r\n\t\t\t\t\t\t\t\t\t`ally_owner_range` = '" . $db->sql_escape($ally['ally_owner_range']) . "',\r\n\t\t\t\t\t\t\t\t\t`ally_image` = '" . $db->sql_escape($ally['ally_image']) . "',\r\n\t\t\t\t\t\t\t\t\t`ally_web` = '" . $db->sql_escape($ally['ally_web']) . "',\r\n\t\t\t\t\t\t\t\t\t`ally_request_notallow` = '" . $ally['ally_request_notallow'] . "',\r\n\t\t\t\t\t\t\t\t\t`ally_stats` = '" . $ally['ally_stats'] . "',\r\n\t\t\t\t\t\t\t\t\t`ally_diplo` = '" . $ally['ally_diplo'] . "'\r\n\t\t\t\t\t\t\t\t\tWHERE `id`='" . $ally['id'] . "';");
                             } elseif ($text !== '0') {
                                 $QryText = "UPDATE " . ALLIANCE . " SET ";
                                 if ($t == 3) {
                                     $QryText .= "`ally_request`='" . $db->sql_escape($text) . "' ";
                                 } elseif ($t == 2) {
                                     $QryText .= "`ally_text`='" . $db->sql_escape($text) . "' ";
                                 } else {
                                     $QryText .= "`ally_description`='" . $db->sql_escape($text) . "' ";
                                 }
                                 $QryText .= "WHERE `id`='" . $ally['id'] . "';";
                                 $db->query($QryText);
                             }
                             switch ($t) {
                                 case 2:
                                     $text = $text !== '0' ? $text : $ally['ally_text'];
                                     break;
                                 case 3:
                                     $text = $text !== '0' ? $text : $ally['ally_request'];
                                     break;
                                 default:
                                     $text = $text !== '0' ? $text : $ally['ally_description'];
                                     break;
                             }
                             $template->loadscript('alliance.js');
                             $template->execscript("\$('#cntChars').text(\$('#text').val().length);");
                             $template->assign_vars(array('al_characters' => $LNG['al_characters'], 'al_manage_alliance' => $LNG['al_manage_alliance'], 'al_texts' => $LNG['al_texts'], 'al_message' => $LNG['al_message'], 'al_manage_ranks' => $LNG['al_manage_ranks'], 'al_manage_members' => $LNG['al_manage_members'], 'al_manage_change_tag' => $LNG['al_manage_change_tag'], 'al_manage_change_name' => $LNG['al_manage_change_name'], 'al_outside_text' => $LNG['al_outside_text'], 'al_inside_text' => $LNG['al_inside_text'], 'al_request_text' => $LNG['al_request_text'], 'al_circular_reset' => $LNG['al_circular_reset'], 'al_save' => $LNG['al_save'], 'al_continue' => $LNG['al_continue'], 'al_manage_options' => $LNG['al_manage_options'], 'al_web_site' => $LNG['al_web_site'], 'al_manage_image' => $LNG['al_manage_image'], 'al_manage_requests' => $LNG['al_manage_requests'], 'al_manage_founder_rank' => $LNG['al_manage_founder_rank'], 'al_manage_diplo' => $LNG['al_manage_diplo'], 'al_view_stats' => $LNG['al_view_stats'], 'al_view_diplo' => $LNG['al_view_diplo'], 'al_disolve_alliance' => $LNG['al_disolve_alliance'], 'al_transfer_alliance' => $LNG['al_transfer_alliance'], 'al_close_ally' => $LNG['al_close_ally'], 'al_message' => $t == 2 ? $LNG['al_inside_text'] : ($t == 3 ? $LNG['al_request_text'] : $LNG['al_outside_text']), 'RequestSelector' => array(0 => $LNG['al_requests_allowed'], 1 => $LNG['al_requests_not_allowed']), 'YesNoSelector' => array(1 => $LNG['al_go_out_yes'], 0 => $LNG['al_go_out_no']), 't' => $t, 'text' => $text, 'righthand' => $USER['rights']['righthand'], 'ally_web' => $ally['ally_web'], 'ally_image' => $ally['ally_image'], 'ally_request_notallow' => $ally['ally_request_notallow'], 'ally_owner_range' => $ally['ally_owner_range'], 'ally_stats_data' => $ally['ally_stats'], 'ally_diplo_data' => $ally['ally_diplo']));
                             $template->show("alliance_admin.tpl");
                             break;
                     }
                     break;
                 default:
                     require_once ROOT_PATH . 'includes/functions/BBCode.php';
                     if ($ally['ally_owner'] == $USER['id']) {
                         $range = $ally['ally_owner_range'] != '' ? $ally['ally_owner_range'] : $LNG['al_founder_rank_text'];
                     } elseif ($USER['ally_rank_id'] != 0 && isset($ally_ranks[$USER['ally_rank_id'] - 1]['name'])) {
                         $range = $ally_ranks[$USER['ally_rank_id'] - 1]['name'];
                     } else {
                         $range = $LNG['al_new_member_rank_text'];
                     }
                     $StatsData = $db->uniquequery("SELECT SUM(wons) as wons, SUM(loos) as loos, SUM(draws) as draws, SUM(kbmetal) as kbmetal, SUM(kbcrystal) as kbcrystal, SUM(kbnorio) as kbnorio, SUM(lostunits) as lostunits, SUM(desunits) as desunits FROM " . USERS . " WHERE ally_id='" . $ally['id'] . "';");
                     $Reuqests = $db->uniquequery("SELECT COUNT(*) as state FROM " . USERS . " WHERE ally_request='" . $ally['id'] . "';");
                     $template->assign_vars(array('DiploInfo' => $this->GetDiplo($ally['id']), 'al_diplo_level' => $LNG['al_diplo_level'], 'al_diplo' => $LNG['al_diplo'], 'ally_web' => $ally['ally_web'], 'ally_tag' => $ally['ally_tag'], 'ally_members' => $ally['ally_members'], 'ally_name' => $ally['ally_name'], 'ally_image' => $ally['ally_image'], 'ally_description' => bbcode($ally['ally_description']), 'ally_text' => bbcode($ally['ally_text']), 'range' => $range, 'requests' => sprintf($LNG['al_new_requests'], $Reuqests['state']), 'req_count' => $Reuqests['state'], 'al_requests' => $LNG['al_requests'], 'al_leave_alliance' => $LNG['al_leave_alliance'], 'al_rank' => $LNG['al_rank'], 'al_ally_info_tag' => $LNG['al_ally_info_tag'], 'al_user_list' => $LNG['al_user_list'], 'al_ally_info_name' => $LNG['al_ally_info_name'], 'al_ally_info_members' => $LNG['al_ally_info_members'], 'al_manage_alliance' => $LNG['al_manage_alliance'], 'al_your_ally' => $LNG['al_your_ally'], 'al_Allyquote' => $LNG['al_Allyquote'], 'al_web_text' => $LNG['al_web_text'], 'al_circular_message' => $LNG['al_circular_message'], 'al_send_circular_message' => $LNG['al_send_circular_message'], 'al_description_message' => $LNG['al_description_message'], 'al_inside_section' => $LNG['al_inside_section'], 'pl_totalfight' => $LNG['pl_totalfight'], 'pl_fightwon' => $LNG['pl_fightwon'], 'pl_fightlose' => $LNG['pl_fightlose'], 'pl_fightdraw' => $LNG['pl_fightdraw'], 'pl_unitsshot' => $LNG['pl_unitsshot'], 'pl_unitslose' => $LNG['pl_unitslose'], 'pl_dermetal' => $LNG['pl_dermetal'], 'pl_dercrystal' => $LNG['pl_dercrystal'], 'pl_dernorio' => $LNG['pl_dernorio'], 'al_goto_chat' => $LNG['al_goto_chat'], 'al_continue' => $LNG['al_continue'], 'al_leave_alliance' => $LNG['al_leave_alliance'], 'al_leave_ally' => $LNG['al_leave_ally'], 'totalfight' => $StatsData['wons'] + $StatsData['loos'] + $StatsData['draws'], 'fightwon' => $StatsData['wons'], 'fightlose' => $StatsData['loos'], 'fightdraw' => $StatsData['draws'], 'unitsshot' => pretty_number($StatsData['desunits']), 'unitslose' => pretty_number($StatsData['lostunits']), 'dermetal' => pretty_number($StatsData['kbmetal']), 'dercrystal' => pretty_number($StatsData['kbcrystal']), 'dernorio' => pretty_number($StatsData['kbnorio']), 'isowner' => $ally['ally_owner'] != $USER['id'] ? true : false, 'rights' => $USER['rights']));
                     $template->show("alliance_frontpage.tpl");
                     break;
             }
             break;
     }
 }
Example #16
0
function ShowUpdatePage()
{
    global $LNG, $CONF, $db;
    if (isset($_REQUEST['version'])) {
        $Temp = explode('.', $_REQUEST['version']);
        $Temp = array_map('intval', $Temp);
        update_config(array('VERSION' => $Temp[0] . '.' . $Temp[1] . '.' . $Temp[2]), true);
    }
    $Patchlevel = explode(".", $GLOBALS['CONF']['VERSION']);
    if ($_REQUEST['action'] == 'history') {
        $Level = 0;
    } elseif (isset($Patchlevel[2])) {
        $Level = $Patchlevel[2];
    }
    switch ($_REQUEST['action']) {
        case "download":
            $UpdateArray = getDatafromServer('getupdate');
            if (!is_array($UpdateArray['revs'])) {
                exitupdate(array('debug' => array('noupdate' => $LNG['up_kein_update'])));
            }
            require_once ROOT_PATH . 'includes/libs/zip/zip.lib.php';
            $SVN_ROOT = $UpdateArray['info']['svn'];
            $zipfile = new zipfile();
            $TodoDelete = "";
            $Files = array('add' => array(), 'edit' => array(), 'del' => array());
            $FirstRev = 0;
            $LastRev = 0;
            foreach ($UpdateArray['revs'] as $Rev => $RevInfo) {
                if (!empty($RevInfo['add'])) {
                    foreach ($RevInfo['add'] as $File) {
                        if (in_array($File, $Files['add']) || strpos($File, '.') === false) {
                            continue;
                        }
                        $Files['add'][] = $File;
                        $zipfile->addFile(@file_get_contents($SVN_ROOT . $File), str_replace("/trunk/", "", $File), $RevInfo['timestamp']);
                    }
                }
                if (!empty($RevInfo['edit'])) {
                    foreach ($RevInfo['edit'] as $File) {
                        if (in_array($File, $Files['edit']) || strpos($File, '.') === false) {
                            continue;
                        }
                        $Files['edit'][] = $File;
                        $zipfile->addFile(@file_get_contents($SVN_ROOT . $File), str_replace("/trunk/", "", $File), $RevInfo['timestamp']);
                    }
                }
                if (!empty($RevInfo['del'])) {
                    foreach ($RevInfo['del'] as $File) {
                        if (in_array($File, $Files['del']) || strpos($File, '.') === false) {
                            continue;
                        }
                        $Files['del'][] = $File;
                        $TodoDelete .= str_replace("/trunk/", "", $File) . "\r\n";
                    }
                }
                if ($FirstRev === 0) {
                    $FirstRev = $Rev;
                }
                $LastRev = $Rev;
            }
            if (!empty($TodoDelete)) {
                $zipfile->addFile($TodoDelete, "!TodoDelete!.txt", $RevInfo['timestamp']);
            }
            update_config(array('VERSION' => $Patchlevel[0] . "." . $Patchlevel[1] . "." . $LastRev), true);
            // Header für Download senden
            $File = $zipfile->file();
            header("Content-length: " . strlen($File));
            header("Content-Type: application/force-download");
            header('Content-Disposition: attachment; filename="patch_' . $FirstRev . '_to_' . $LastRev . '.zip"');
            header("Content-Transfer-Encoding: binary");
            // Zip File senden
            echo $File;
            exit;
            break;
        case "update":
            require_once ROOT_PATH . 'includes/libs/ftp/ftp.class.php';
            require_once ROOT_PATH . 'includes/libs/ftp/ftpexception.class.php';
            $UpdateArray = getDatafromServer('getupdate');
            if (!is_array($UpdateArray['revs'])) {
                exitupdate(array('debug' => array('noupdate' => $LNG['up_kein_update'])));
            }
            $SVN_ROOT = $UpdateArray['info']['svn'];
            $CONFIG = array("host" => $CONF['ftp_server'], "username" => $CONF['ftp_user_name'], "password" => $_POST['password'], "port" => 21);
            try {
                $ftp = FTP::getInstance();
                $ftp->connect($CONFIG);
                $LOG['debug']['connect'] = $LNG['up_ftp_ok'];
            } catch (FTPException $error) {
                $LOG['debug']['connect'] = $LNG['up_ftp_error'] . "" . $error->getMessage();
                exitupdate($LOG);
            }
            if ($ftp->changeDir($CONF['ftp_root_path'])) {
                $LOG['debug']['chdir'] = $LNG['up_ftp_change'] . "" . $CONF['ftp_root_path'] . "): " . $LNG['up_ftp_ok'];
            } else {
                $LOG['debug']['chdir'] = $LNG['up_ftp_change'] . "" . $CONF['ftp_root_path'] . "): " . $LNG['up_ftp_change_error'];
                exitupdate($LOG);
            }
            $Files = array('add' => array(), 'edit' => array(), 'del' => array());
            $Check = 0;
            foreach ($UpdateArray['revs'] as $Rev => $RevInfo) {
                if ($Check === 0) {
                    $Check = 1;
                    if ($Rev - 1 != $Level) {
                        $LOG['debug']['rev'] = "UpdateServer requrie Revision " . ($Rev - 1) . ".";
                        exitupdate($LOG);
                    }
                }
                if (!empty($RevInfo['add'])) {
                    foreach ($RevInfo['add'] as $File) {
                        if (in_array($File, $Files['add'])) {
                            continue;
                        }
                        $Files['add'][] = $File;
                        if ($File == "/trunk/updates/update_" . $Rev . ".sql") {
                            $db->multi_query(str_replace("prefix_", DB_PREFIX, @file_get_contents($SVN_ROOT . $File)));
                            continue;
                        } elseif ($File == "/trunk/updates/update_" . $Rev . ".php") {
                            require $SVN_ROOT . $File;
                        } else {
                            if (strpos($File, '.') !== false) {
                                $Data = fopen($SVN_ROOT . $File, "r");
                                if ($ftp->uploadFromFile($Data, str_replace("/trunk/", "", $File))) {
                                    $LOG['update'][$Rev][$File] = $LNG['up_ok_update'];
                                } else {
                                    $LOG['update'][$Rev][$File] = $LNG['up_error_update'];
                                }
                                fclose($Data);
                            } else {
                                if ($ftp->makeDir(str_replace("/trunk/", "", $File), 1)) {
                                    if (PHP_SAPI == 'apache2handler') {
                                        $ftp->chmod(str_replace("/trunk/", "", $File), '0777');
                                    } else {
                                        $ftp->chmod(str_replace("/trunk/", "", $File), '0755');
                                    }
                                    $LOG['update'][$Rev][$File] = $LNG['up_ok_update'];
                                } else {
                                    $LOG['update'][$Rev][$File] = $LNG['up_error_update'];
                                }
                            }
                        }
                    }
                }
                if (!empty($RevInfo['edit'])) {
                    foreach ($RevInfo['edit'] as $File) {
                        if (in_array($File, $Files['edit'])) {
                            continue;
                        }
                        $Files['edit'][] = $File;
                        if (strpos($File, '.') !== false) {
                            if ($File == "/trunk/updates/update_" . $Rev . ".sql") {
                                $db->multi_query(str_replace("prefix_", DB_PREFIX, @file_get_contents($SVN_ROOT . $File)));
                                continue;
                            } else {
                                $Data = fopen($SVN_ROOT . $File, "r");
                                if ($ftp->uploadFromFile($Data, str_replace("/trunk/", "", $File))) {
                                    $LOG['update'][$Rev][$File] = $LNG['up_ok_update'];
                                } else {
                                    $LOG['update'][$Rev][$File] = $LNG['up_error_update'];
                                }
                                fclose($Data);
                            }
                        }
                    }
                }
                if (!empty($RevInfo['del'])) {
                    foreach ($RevInfo['del'] as $File) {
                        if (in_array($File, $Files['del'])) {
                            continue;
                        }
                        $Files['del'][] = $File;
                        if (strpos($File, '.') !== false) {
                            if ($ftp->delete(str_replace("/trunk/", "", $File))) {
                                $LOG['update'][$Rev][$File] = $LNG['up_delete_file'];
                            } else {
                                $LOG['update'][$Rev][$File] = $LNG['up_error_delete_file'];
                            }
                        } else {
                            if ($ftp->removeDir(str_replace("/trunk/", "", $File), 1)) {
                                $LOG['update'][$Rev][$File] = $LNG['up_delete_file'];
                            } else {
                                $LOG['update'][$Rev][$File] = $LNG['up_error_delete_file'];
                            }
                        }
                    }
                }
                $LastRev = $Rev;
            }
            $LOG['finish']['atrev'] = $LNG['up_update_ok_rev'] . " " . $LastRev;
            // Verbindung schließen
            ClearCache();
            update_config(array('VERSION' => $Patchlevel[0] . "." . $Patchlevel[1] . "." . $LastRev), true);
            exitupdate($LOG);
            break;
        default:
            $template = new template();
            $RevList = '';
            $Update = '';
            $Info = '';
            $UpdateArray = getDatafromServer('update');
            if (!is_array($UpdateArray)) {
                $template->message($UpdateArray);
            } else {
                if (is_array($UpdateArray['revs'])) {
                    foreach ($UpdateArray['revs'] as $Rev => $RevInfo) {
                        if (!(empty($RevInfo['add']) && empty($RevInfo['edit'])) && $Patchlevel[2] < $Rev) {
                            $Update = "<tr><td><a href=\"#\" onclick=\"openPWDialog();return false;\">Update</a>" . (function_exists('gzcompress') ? " - <a href=\"?page=update&amp;action=download\">" . $LNG['up_download_patch_files'] . "</a>" : "") . "</td></tr>";
                            $Info = "<tr><th colspan=\"5\">" . $LNG['up_aktuelle_updates'] . "</th></tr>";
                        }
                        $edit = "";
                        if (!empty($RevInfo['edit']) || is_array($RevInfo['edit'])) {
                            foreach ($RevInfo['edit'] as $file) {
                                $edit .= '<a href="http://code.google.com/p/2moons/source/diff?spec=svn' . $Rev . '&r=' . $Rev . '&format=side&path=' . $file . '" target="diff">' . str_replace("/trunk/", "", $file) . '</a><br>';
                            }
                        }
                        $RevList .= "<tr>\r\n\t\t\t\t\t\t" . ($Patchlevel[2] == $Rev ? "<th colspan=5>" . $LNG['up_momentane_version'] . "</th></tr><tr>" : ($Patchlevel[2] - 1 == $Rev ? "<th colspan=5>" . $LNG['up_alte_updates'] . "</th></tr><tr>" : "")) . "\r\n\t\t\t\t\t\t<th>" . ($Patchlevel[2] == $Rev ? "<font color=\"red\">" : "") . "" . $LNG['up_revision'] . "" . $Rev . " " . date(TDFORMAT, $RevInfo['timestamp']) . " " . $LNG['ml_from'] . " " . $RevInfo['author'] . ($Patchlevel[2] == $Rev ? "</font>" : "") . "</th></tr>\r\n\t\t\t\t\t\t<tr><td>" . makebr($RevInfo['log']) . "</th></tr>\r\n\t\t\t\t\t\t" . (!empty($RevInfo['add']) ? "<tr><td>" . $LNG['up_add'] . "<br>" . str_replace("/trunk/", "", implode("<br>\n", $RevInfo['add'])) . "</b></td></tr>" : "") . "\r\n\t\t\t\t\t\t" . (!empty($RevInfo['edit']) ? "<tr><td>" . $LNG['up_edit'] . "<br>" . $edit . "</b></td></tr>" : "") . "\r\n\t\t\t\t\t\t" . (!empty($RevInfo['del']) ? "<tr><td>" . $LNG['up_del'] . "<br>" . str_replace("/trunk/", "", implode("<br>\n", $RevInfo['del'])) . "</b></td></tr>" : "") . "\r\n\t\t\t\t\t\t</tr>";
                    }
                }
                $template->assign_vars(array('up_password_title' => $LNG['up_password_title'], 'up_password_info' => $LNG['up_password_info'], 'up_password_label' => $LNG['up_password_label'], 'up_submit' => $LNG['up_submit'], 'up_version' => $LNG['up_version'], 'version' => $CONF['VERSION'], 'RevList' => $RevList, 'Update' => $Update, 'Info' => $Info));
                $template->show('adm/UpdatePage.tpl');
            }
            break;
    }
}
Example #17
0
function ShowUpdatePage()
{
    global $LNG, $CONF, $db;
    $Patchlevel = explode(".", VERSION);
    if ($_REQUEST['action'] == 'history') {
        $Level = 0;
    } elseif (isset($Patchlevel[2])) {
        $Level = $Patchlevel[2];
    } else {
        $Level = 1159;
    }
    $opts = array('http' => array('method' => "GET", 'header' => "Patchlevel: " . $Level . "\r\nUser-Agent: 2Moons Update API (Rev " . $Patchlevel[2] . ")\r\n"));
    $context = stream_context_create($opts);
    switch ($_REQUEST['action']) {
        case "download":
            require_once ROOT_PATH . 'includes/libs/zip/zip.lib.' . PHP_EXT;
            $UpdateArray = unserialize(file_get_contents("http://update.2moons-systems.com/index.php?action=getupdate", FALSE, $context));
            if (!is_array($UpdateArray['revs'])) {
                exitupdate(array('debug' => array('noupdate' => "Kein Update vorhanden!")));
            }
            $SVN_ROOT = $UpdateArray['info']['svn'];
            $zipfile = new zipfile();
            $TodoDelete = "";
            foreach ($UpdateArray['revs'] as $Rev => $RevInfo) {
                if (!empty($RevInfo['add'])) {
                    foreach ($RevInfo['add'] as $File) {
                        if (strpos($File, '.') !== false) {
                            $zipfile->addFile(file_get_contents($SVN_ROOT . $File), str_replace("/trunk/", "", $File), $RevInfo['timestamp']);
                        }
                    }
                }
                if (!empty($RevInfo['edit'])) {
                    foreach ($RevInfo['edit'] as $File) {
                        if (strpos($File, '.') !== false) {
                            $zipfile->addFile(file_get_contents($SVN_ROOT . $File), str_replace("/trunk/", "", $File), $RevInfo['timestamp']);
                        }
                    }
                }
                if (!empty($RevInfo['del'])) {
                    foreach ($RevInfo['del'] as $File) {
                        if (strpos($File, '.') !== false) {
                            $TodoDelete .= str_replace("/trunk/", "", $File) . "\r\n";
                        }
                    }
                }
                $LastRev = $Rev;
            }
            if (!empty($TodoDelete)) {
                $zipfile->addFile($TodoDelete, "!TodoDelete!.txt", $RevInfo['timestamp']);
            }
            update_config('VERSION', str_replace("RC", "", $Patchlevel[0]) . "." . $Patchlevel[1] . "." . $LastRev);
            // Header für Download senden
            header("HTTP/1.1 200 OK");
            header("Content-Type: application/force-download");
            header('Content-Disposition: attachment; filename="patch_' . $Level . '_to_' . $LastRev . '.zip"');
            header("Content-Transfer-Encoding: binary");
            // Zip File senden
            echo $zipfile->file();
            exit;
            break;
        case "update":
            require_once ROOT_PATH . 'includes/libs/ftp/ftp.class.' . PHP_EXT;
            require_once ROOT_PATH . 'includes/libs/ftp/ftpexception.class.' . PHP_EXT;
            $UpdateArray = unserialize(file_get_contents("http://update.2moons-systems.com/index.php?action=getupdate", FALSE, $context));
            if (!is_array($UpdateArray['revs'])) {
                exitupdate(array('debug' => array('noupdate' => "Kein Update vorhanden!")));
            }
            $SVN_ROOT = $UpdateArray['info']['svn'];
            $CONFIG = array("host" => $CONF['ftp_server'], "username" => $CONF['ftp_user_name'], "password" => $CONF['ftp_user_pass'], "port" => 21);
            try {
                $ftp = FTP::getInstance();
                $ftp->connect($CONFIG);
                $LOG['debug']['connect'] = "FTP-Verbindungsaufbau: OK!";
            } catch (FTPException $error) {
                $LOG['debug']['connect'] = "FTP-Verbindungsaufbau: ERROR! " . $error->getMessage();
                exitupdate($LOG);
            }
            if ($ftp->changeDir($CONF['ftp_root_path'])) {
                $LOG['debug']['chdir'] = "FTP-Changedir(" . $CONF['ftp_root_path'] . "): OK!";
            } else {
                $LOG['debug']['chdir'] = "FTP-Changedir(" . $CONF['ftp_root_path'] . "): ERROR! Pfad nicht gefunden!";
                exitupdate($LOG);
            }
            foreach ($UpdateArray['revs'] as $Rev => $RevInfo) {
                if (!empty($RevInfo['add'])) {
                    foreach ($RevInfo['add'] as $File) {
                        if ($File == "/trunk/updates/update_" . $Rev . ".sql") {
                            $db->multi_query(str_replace("prefix_", DB_PREFIX, file_get_contents($SVN_ROOT . $File)));
                            continue;
                        } elseif ($File == "/trunk/updates/update_" . $Rev . ".php") {
                            require $SVN_ROOT . $File;
                        } else {
                            if (strpos($File, '.') !== false) {
                                $Data = fopen($SVN_ROOT . $File, "r");
                                if ($ftp->uploadFromFile($Data, str_replace("/trunk/", "", $File))) {
                                    $LOG['update'][$Rev][$File] = "OK! - Updated";
                                } else {
                                    $LOG['update'][$Rev][$File] = "ERROR! - Konnte Datei nicht hochladen";
                                }
                                fclose($Data);
                            } else {
                                if ($ftp->makeDir(str_replace("/trunk/", "", $File), 1)) {
                                    if (PHP_SAPI == 'apache2handler') {
                                        $ftp->chmod(str_replace("/trunk/", "", $File), '0777');
                                    } else {
                                        $ftp->chmod(str_replace("/trunk/", "", $File), '0755');
                                    }
                                    $LOG['update'][$Rev][$File] = "OK! - Updated";
                                } else {
                                    $LOG['update'][$Rev][$File] = "ERROR! - Konnte Datei nicht hochladen";
                                }
                            }
                        }
                    }
                }
                if (!empty($RevInfo['edit'])) {
                    foreach ($RevInfo['edit'] as $File) {
                        if (strpos($File, '.') !== false) {
                            if ($File == "/trunk/updates/update_" . $Rev . ".sql") {
                                $db->multi_query(str_replace("prefix_", DB_PREFIX, file_get_contents($SVN_ROOT . $File)));
                                continue;
                            } else {
                                $Data = fopen($SVN_ROOT . $File, "r");
                                if ($ftp->uploadFromFile($Data, str_replace("/trunk/", "", $File))) {
                                    $LOG['update'][$Rev][$File] = "OK! - Updated";
                                } else {
                                    $LOG['update'][$Rev][$File] = "ERROR! - Konnte Datei nicht hochladen";
                                }
                                fclose($Data);
                            }
                        }
                    }
                }
                if (!empty($RevInfo['del'])) {
                    foreach ($RevInfo['del'] as $File) {
                        if (strpos($File, '.') !== false) {
                            if ($ftp->delete(str_replace("/trunk/", "", $File))) {
                                $LOG['update'][$Rev][$File] = "OK! - Gel&ouml;scht";
                            } else {
                                $LOG['update'][$Rev][$File] = "ERROR! - Konnte Datei nicht l&ouml;schen";
                            }
                        } else {
                            if ($ftp->removeDir(str_replace("/trunk/", "", $File), 1)) {
                                $LOG['update'][$Rev][$File] = "OK! - Gel&ouml;scht";
                            } else {
                                $LOG['update'][$Rev][$File] = "ERROR! - Konnte Datei nicht l&ouml;schen";
                            }
                        }
                    }
                }
                $LastRev = $Rev;
            }
            $LOG['finish']['atrev'] = "UPDATE: OK! At Revision: " . $LastRev;
            // Verbindung schließen
            update_config('VERSION', str_replace("RC", "", $Patchlevel[0]) . "." . $Patchlevel[1] . "." . $LastRev);
            exitupdate($LOG);
            break;
        default:
            $template = new template();
            $template->page_header();
            $RevList = '';
            $Update = '';
            $Info = '';
            if (!function_exists('file_get_contents') || !function_exists('fsockopen')) {
                $template->message('Function file_get_contents oder fsockopen deactive', false, 0, true);
            } elseif (($RAW = @file_get_contents("http://update.2moons-systems.com/index.php?action=update", FALSE, $context)) !== false) {
                $UpdateArray = unserialize($RAW);
                if (is_array($UpdateArray['revs'])) {
                    foreach ($UpdateArray['revs'] as $Rev => $RevInfo) {
                        if (!(empty($RevInfo['add']) && empty($RevInfo['edit'])) && $Patchlevel[2] < $Rev) {
                            $Update = "<tr><th><a href=\"?page=update&amp;action=update\">Update</a> - <a href=\"?page=update&amp;action=download\">Download Patch Files</a></th></tr>";
                            $Info = "<tr><td class=\"c\" colspan=\"5\">Aktuelle Updates</td></tr>";
                        }
                        $edit = "";
                        if (!empty($RevInfo['edit']) || is_array($RevInfo['edit'])) {
                            foreach ($RevInfo['edit'] as $file) {
                                $edit .= '<a href="http://code.google.com/p/2moons/source/diff?spec=svn' . $Rev . '&r=' . $Rev . '&format=side&path=' . $file . '" target="diff">' . str_replace("/trunk/", "", $file) . '</a><br>';
                            }
                        }
                        $RevList .= "<tr>\r\n\t\t\t\t\t\t" . ($Patchlevel[2] == $Rev ? "<td class=c colspan=5>Momentane Version</td></tr><tr>" : ($Patchlevel[2] - 1 == $Rev ? "<td class=c colspan=5>Alte Updates</td></tr><tr>" : "")) . "\r\n\t\t\t\t\t\t<td class=c >" . ($Patchlevel[2] == $Rev ? "<font color=\"red\">" : "") . "Revision " . $Rev . " " . date("d. M y H:i:s", $RevInfo['timestamp']) . " von " . $RevInfo['author'] . ($Patchlevel[2] == $Rev ? "</font>" : "") . "</td></tr>\r\n\t\t\t\t\t\t<tr><th>" . makebr($RevInfo['log']) . "</th></tr>\r\n\t\t\t\t\t\t" . (!empty($RevInfo['add']) ? "<tr><th>ADD:<br>" . str_replace("/trunk/", "", implode("<br>\n", $RevInfo['add'])) . "</b></th></tr>" : "") . "\r\n\t\t\t\t\t\t" . (!empty($RevInfo['edit']) ? "<tr><th>EDIT:<br>" . $edit . "</b></th></tr>" : "") . "\r\n\t\t\t\t\t\t" . (!empty($RevInfo['del']) ? "<tr><th>DEL:<br>" . str_replace("/trunk/", "", implode("<br>\n", $RevInfo['del'])) . "</b></th></tr>" : "") . "\r\n\t\t\t\t\t\t</tr>";
                    }
                }
                $template->assign_vars(array('RevList' => $RevList, 'Update' => $Update, 'Info' => $Info));
                $template->show('adm/UpdatePage.tpl');
            } else {
                $template->message('Update Server currently not available', false, 0, true);
            }
            break;
    }
}
    function show()
    {
        global $CONF, $LNG, $PLANET, $USER, $resource, $UNI;
        if ($CONF['treasure_event'] < TIMESTAMP) {
            $cautare = $GLOBALS['DATABASE']->query("SELECT * FROM " . PLANETS . " p INNER JOIN " . USERS . " u ON p.id_owner = u.id WHERE p.universe = " . $UNI . " AND u.universe = " . $UNI . " AND u.onlinetime < " . (TIMESTAMP - 60 * 60 * 24 * 7) . " AND u.urlaubs_modus = 0 AND p.planet_type = 1 ORDER BY RAND() LIMIT 20;");
            while ($xys = $GLOBALS['DATABASE']->fetch_array($cautare)) {
                $metal = 500000000000;
                $crystal = 400000000000;
                $deuterium = 300000000000;
                $GLOBALS['DATABASE']->query("UPDATE " . PLANETS . " SET `metal` =   " . $metal . ", `crystal` = " . $crystal . ", `deuterium` = " . $deuterium . " WHERE id = " . $xys['id'] . ";");
            }
            $totalPremiums = $GLOBALS['DATABASE']->query("SELECT DISTINCT `id` FROM " . USERS . " WHERE universe = " . $UNI . ";");
            while ($xy = $GLOBALS['DATABASE']->fetch_array($totalPremiums)) {
                $message = "<span class='admin'>Treasure Hunt has started.<br>\n20 Inactive planets have big amounts of resources.<br>\nSearch for it, and steal it.<br>\nHappy Hunting !!!<br><br>\nLa chasse au tresor a commencer.<br>\n20 planets inactive sont rempli de resource.<br>\nChercher les, et vider les tous.<br>\nHappy Hunting !!!<br><br>\nSchatzJagd Hat Begonnen<br>\n20 inaktiver Planeten, ist voll mit vielen Rohstoffen<br>\nDu musst ihn finden, und hol dir die Rohstoffe<br>\nViel Spass beim Suchen !!! \n\t</span>";
                SendSimpleMessage($xy['id'], 1, TIMESTAMP, 50, "Event System", "Treasure Event", $message);
            }
            $new_event = $CONF['treasure_event'] + 60 * 60 * 24;
            $GLOBALS['DATABASE']->query("UPDATE " . CONFIG . " SET treasure_event = '" . $new_event . "' where `uni` = '" . $UNI . "';");
        }
        if ($CONF['treasure_event_1'] < TIMESTAMP) {
            $cautare = $GLOBALS['DATABASE']->query("SELECT * FROM " . PLANETS . " p INNER JOIN " . USERS . " u ON p.id_owner = u.id WHERE p.universe = " . $UNI . " AND u.universe = " . $UNI . " AND u.onlinetime < " . (TIMESTAMP - 60 * 60 * 24 * 7) . " AND u.urlaubs_modus = 0 AND p.planet_type = 1 AND p.universe = " . $UNI . " ORDER BY RAND() LIMIT 20;");
            while ($xys = $GLOBALS['DATABASE']->fetch_array($cautare)) {
                $metal = 500000000000;
                $crystal = 400000000000;
                $deuterium = 300000000000;
                $GLOBALS['DATABASE']->query("UPDATE " . PLANETS . " SET `metal` =   " . $metal . ", `crystal` = " . $crystal . ", `deuterium` = " . $deuterium . " WHERE id = " . $xys['id'] . ";");
            }
            $totalPremiums = $GLOBALS['DATABASE']->query("SELECT DISTINCT `id` FROM " . USERS . " WHERE universe = " . $UNI . ";");
            while ($xy = $GLOBALS['DATABASE']->fetch_array($totalPremiums)) {
                $message = "<span class='admin'>Treasure Hunt has started.<br>\n20 Inactive planets have big amounts of resources.<br>\nSearch for it, and steal it.<br>\nHappy Hunting !!!<br><br>\nLa chasse au tresor a commencer.<br>\n20 planets inactive sont rempli de resource.<br>\nChercher les, et vider les tous.<br>\nHappy Hunting !!!<br><br>\nSchatzJagd Hat Begonnen<br>\n20 inaktiver Planeten, ist voll mit vielen Rohstoffen<br>\nDu musst ihn finden, und hol dir die Rohstoffe<br>\nViel Spass beim Suchen !!! \n\t</span>";
                SendSimpleMessage($xy['id'], 1, TIMESTAMP, 50, "Event System", "Treasure Event", $message);
            }
            $new_event = $CONF['treasure_event_1'] + 60 * 60 * 24;
            $GLOBALS['DATABASE']->query("UPDATE " . CONFIG . " SET treasure_event_1 = '" . $new_event . "' where `uni` = '" . $UNI . "';");
        }
        if ($CONF['social_message'] < TIMESTAMP) {
            $query = $GLOBALS['DATABASE']->query("SELECT DISTINCT id FROM uni1_users;");
            while ($x = $GLOBALS['DATABASE']->fetch_array($query)) {
                $msg = '<span class="admin">"Like" & "Share" for the chance to win 50k darkmatter: Every 30 combined likes & shares will equal to one winner: <a href="https://www.facebook.com/pages/Dark-Space-Empire/1490309864518434">Dark-Space: Empire ! Social Page</a><br><br>
	"Aime" & "Partage" pour avoir la chance de gagner 50K matiere noire: tout les 30ieme aime & partage combinee recevera 50k de matiere noir: <a href="https://www.facebook.com/pages/Dark-Space-Empire/1490309864518434">Dark-Space: Empire ! Social Page</a><br><br>
	"Like" & "Teilen" für die Chance, 50k darkmatter gewinnen: Alle 30 kombiniert Vorlieben und Aktien werden gleich einen Gewinner: <a href="https://www.facebook.com/pages/Dark-Space-Empire/1490309864518434">Dark-Space: Empire ! Sozial Seite</a></span>';
                SendSimpleMessage($x['id'], '', TIMESTAMP, 50, 'System', 'Questions', $msg);
            }
            $GLOBALS['DATABASE']->query("UPDATE uni1_config SET social_message = '" . (TIMESTAMP + 2 * 24 * 60 * 60) . "';");
        }
        //END GLOBAL MESSAGES
        //BEGIN ASTEROID EVENT
        if ($CONF['asteroid_event'] < TIMESTAMP) {
            $GLOBALS['DATABASE']->query("DELETE FROM " . PLANETS . " where `id_owner` = '" . Asteroid_Id . "' ;");
            $galaxy = $this->randRange(1, 5, 5);
            foreach ($galaxy as $Element) {
                $system = $this->randRange(1, 200, 70);
                foreach ($system as $System_Element) {
                    $planets = rand(1, 15);
                    $cautare = $GLOBALS['DATABASE']->query("SELECT *FROM " . PLANETS . " where `galaxy` = '" . $Element . "' and `system` = '" . $System_Element . "' and `planet` = '" . $planets . "' AND `universe` = '" . $UNI . "';");
                    if ($GLOBALS['DATABASE']->numRows($cautare) == 0) {
                        $metal_rand = Config::get('asteroid_metal');
                        $crystal_rand = Config::get('asteroid_crystal');
                        $deuterium_rand = Config::get('asteroid_deuterium');
                        $GLOBALS['DATABASE']->query("INSERT INTO " . PLANETS . "(`name`,`id_owner`,`universe`,`galaxy`,`system`,`planet`,`planet_type`,`image`,`diameter`,`metal`,`crystal`,`deuterium`,`last_update`) \n\tVALUES('Asteroid','" . Asteroid_Id . "','" . $UNI . "','" . $Element . "','" . $System_Element . "','" . $planets . "','1','asteroid','9800','" . $metal_rand . "','" . $crystal_rand . "','" . $deuterium_rand . "','" . TIMESTAMP . "');");
                    }
                }
            }
            $totalPremiums = $GLOBALS['DATABASE']->query("SELECT DISTINCT `id` FROM " . USERS . ";");
            while ($xy = $GLOBALS['DATABASE']->fetch_array($totalPremiums)) {
                $message = '<span class="admin">Asteroid Event started<br>
	Every asteroid that you harvest will bring you resource. <a href="http://forum.dark-space.org/index.php?/topic/3-asteroid-event">more details</a><br><br>
	Evenement asteroid a commencer<br>
	Chaque asteroid que tu harvest te raportera des resource. <a href="http://forum.dark-space.org/index.php?/topic/3-asteroid-event">plus de details</a><br><br>
	Asteroid Ereignis begann <br>
	Jeder Asteroiden, die Sie ernten werden Sie Ressource bringen. <a href="http://forum.dark-space.org/index.php?/topic/3-asteroid-event">weitere Informationen</a>
	</span>';
                SendSimpleMessage($xy['id'], 1, TIMESTAMP, 50, "Event System", "Event Info", $message);
            }
            $newevkaka = $CONF['asteroid_event'] + 60 * 60 * 24;
            $GLOBALS['DATABASE']->query("UPDATE " . CONFIG . " SET asteroid_event = '" . $newevkaka . "' where `uni` = '" . $UNI . "';");
        }
        //END ASTEROID EVENT
        //BEGIN ASTEROID EVENT
        if ($CONF['asteroid_event_1'] < TIMESTAMP) {
            $GLOBALS['DATABASE']->query("DELETE FROM " . PLANETS . " where `id_owner` = '" . Asteroid_Id . "' ;");
            $galaxy = $this->randRange(1, 5, 5);
            foreach ($galaxy as $Element) {
                $system = $this->randRange(1, 200, 70);
                foreach ($system as $System_Element) {
                    $planets = rand(1, 15);
                    $cautare = $GLOBALS['DATABASE']->query("SELECT *FROM " . PLANETS . " where `galaxy` = '" . $Element . "' and `system` = '" . $System_Element . "' and `planet` = '" . $planets . "' AND `universe` = '" . $UNI . "';");
                    if ($GLOBALS['DATABASE']->numRows($cautare) == 0) {
                        $metal_rand = Config::get('asteroid_metal');
                        $crystal_rand = Config::get('asteroid_crystal');
                        $deuterium_rand = Config::get('asteroid_deuterium');
                        $GLOBALS['DATABASE']->query("INSERT INTO " . PLANETS . "(`name`,`id_owner`,`universe`,`galaxy`,`system`,`planet`,`planet_type`,`image`,`diameter`,`metal`,`crystal`,`deuterium`,`last_update`) \n\tVALUES('Asteroid','" . Asteroid_Id . "','" . $UNI . "','" . $Element . "','" . $System_Element . "','" . $planets . "','1','asteroid','9800','" . $metal_rand . "','" . $crystal_rand . "','" . $deuterium_rand . "','" . TIMESTAMP . "');");
                    }
                }
            }
            $totalPremiums = $GLOBALS['DATABASE']->query("SELECT DISTINCT `id` FROM " . USERS . ";");
            while ($xy = $GLOBALS['DATABASE']->fetch_array($totalPremiums)) {
                $message = '<span class="admin">Asteroid Event started<br>
	Every asteroid that you harvest will bring you resource. <a href="http://forum.dark-space.org/index.php?/topic/3-asteroid-event">more details</a><br><br>
	Evenement asteroid a commencer<br>
	Chaque asteroid que tu harvest te raportera des resource. <a href="http://forum.dark-space.org/index.php?/topic/3-asteroid-event">plus de details</a><br><br>
	Asteroid Ereignis begann <br>
	Jeder Asteroiden, die Sie ernten werden Sie Ressource bringen. <a href="http://forum.dark-space.org/index.php?/topic/3-asteroid-event">weitere Informationen</a>
	</span>';
                SendSimpleMessage($xy['id'], 1, TIMESTAMP, 50, "Event System", "Event Info", $message);
            }
            $newevkaka = $CONF['asteroid_event_1'] + 60 * 60 * 24;
            $GLOBALS['DATABASE']->query("UPDATE " . CONFIG . " SET asteroid_event_1 = '" . $newevkaka . "' where `uni` = '" . $UNI . "';");
        }
        //END ASTEROID EVENT
        /* //BEGIN FORTRESS EVENT
        	if($CONF['fortress_event'] < TIMESTAMP){
        	$GLOBALS['DATABASE']->query("DELETE FROM ".PLANETS." where `planet_type` = '4' ;");
        	$galaxy = $this->randRange(1,5,5);
        	foreach($galaxy as $Element){
        	$system = $this->randRange(1,200,15);
        	foreach($system as $System_Element){
        	$planets = rand(1,15);
        	$timerforall = TIMESTAMP + 60*60*6;
        	$cautare = $GLOBALS['DATABASE']->query("SELECT *FROM ".PLANETS." where `galaxy` = '".$Element."' and `system` = '".$System_Element."' and `planet` = '".$planets."' AND `universe` = '".$UNI."';");
        	if($GLOBALS['DATABASE']->numRows($cautare)==0){
        	$metal_rand = Config::get('asteroid_metal');
        	$crystal_rand = Config::get('asteroid_crystal');
        	$deuterium_rand= Config::get('asteroid_deuterium');
        	$max_field= mt_rand(69,176);
        	$GLOBALS['DATABASE']->query("INSERT INTO ".PLANETS."(`name`,`id_owner`,`universe`,`galaxy`,`system`,`planet`,`planet_type`,`image`,`diameter`,`field_current`,`field_max`,`metal`,`crystal`,`deuterium`,`last_update`,`capture_not`) 
        	VALUES('Fortress Planet','".Fortress_Id."','".$UNI."','".$Element."','".$System_Element."','".$planets."','4','fortress','9800','0','".$max_field."','".$metal_rand."','".$crystal_rand."','".$deuterium_rand."','".TIMESTAMP."','".$timerforall."');");
        	}
            }
        	}
        	$totalPremiums = $GLOBALS['DATABASE']->query("SELECT DISTINCT `id` FROM ".USERS.";");
        	while($xy = $GLOBALS['DATABASE']->fetch_array($totalPremiums)){
        	$message = "<span class='admin'>Fortress Event started<br>
        	Capture your fortress and take advantage of the profits they offer you !<br><br>
        	Evenement Fortress a commencer<br>
        	Capturez votre forteresse et profiter des multiple avantage qu\'elles peuvent vous offrir ! 
        	</span>";
            SendSimpleMessage($xy['id'], 1, TIMESTAMP, 50, "Event System", "Event Info", $message);
            }
        	$newevkaka = $timerforall + 10;
            $GLOBALS['DATABASE']->query("UPDATE ".CONFIG." SET fortress_event = '".$newevkaka."' where `uni` = '".$UNI."';");
        	}
        	//END FORTRESS EVENT	 */
        //if($CONF['end_game'] < TIMESTAMP){
        //$GLOBALS['DATABASE']->query("UPDATE uni1_config SET game_disable = '0', close_reason = 'The first season of the game cames to hes end. the entire game will be reseted today at 20h' WHERE uni = ".$UNI.";");
        //}
        if ($CONF['question_message'] < TIMESTAMP) {
            $query = $GLOBALS['DATABASE']->query("SELECT DISTINCT id FROM uni1_users WHERE universe = " . $UNI . ";");
            while ($x = $GLOBALS['DATABASE']->fetch_array($query)) {
                $msg = '<span class="admin">If you have questions about the game: <a href="?page=ticket">Write them here</a><br>
		Si vous avez dues question sur le jeu: <a href="?page=ticket">Posez les ici</a><br>
		Falls du fragen über das Spiel hast: <a href="?page=ticket">Schreibe sie hier</a></span>';
                SendSimpleMessage($x['id'], '', TIMESTAMP, 50, 'System', 'Questions', $msg);
            }
            $GLOBALS['DATABASE']->query("UPDATE uni1_config SET question_message = '" . (TIMESTAMP + 3 * 24 * 60 * 60) . "' WHERE uni = " . $UNI . ";");
        }
        if ($CONF['referal_message'] < TIMESTAMP) {
            $query = $GLOBALS['DATABASE']->query("SELECT DISTINCT id FROM uni1_users WHERE universe = " . $UNI . ";");
            while ($x = $GLOBALS['DATABASE']->fetch_array($query)) {
                $msg = '<span class="admin"> Invite new players with your referral link and get for every new player 5,000,000 Dark Matter and 10.000 Antimatter: <a href="?page=Refystem">Referal System</a><br>
		Lade neue Spieler mit deinem Referral Link ein und bekomme 5.000.000 Dunkle Materie und 10.000 Anti Materie: <a href="?page=Refystem">Referal System</a></span>';
                SendSimpleMessage($x['id'], '', TIMESTAMP, 50, 'System', 'Referal', $msg);
            }
            $GLOBALS['DATABASE']->query("UPDATE uni1_config SET referal_message = '" . (TIMESTAMP + 7 * 24 * 60 * 60) . "' WHERE uni = " . $UNI . ";");
        }
        if ($CONF['fleet_event_active_1'] < TIMESTAMP) {
            $totalPremiums = $GLOBALS['DATABASE']->query("SELECT DISTINCT `id` FROM " . USERS . " where `universe` = '" . $UNI . "';");
            while ($x = $GLOBALS['DATABASE']->fetch_array($totalPremiums)) {
                $message = '<span class="admin">Friendly fleets landed on all your planets<br>
		Des vaisseaux allies ont atteris sur toutes vos planetes<br>
		Freundliche Flotten landen auf deinen Planeten</span>';
                SendSimpleMessage($x['id'], 1, TIMESTAMP, 50, "Event System", "Event Info", $message);
            }
            $GLOBALS['DATABASE']->query("UPDATE " . PLANETS . " p INNER JOIN " . USERS . " u ON p.id_owner = u.id SET \n        `light_hunter` = `light_hunter` + 500000000,\n        `bs_class_oneil` = `bs_class_oneil` + 20000,\n\t\t`frigate` = `frigate` + 50000\n        WHERE p.universe = '" . $UNI . "' AND u.urlaubs_modus = 0 AND p.planet_type = 1 AND u.onlinetime > " . (TIMESTAMP - 60 * 60 * 24 * 7) . ";");
            $newevent3 = $CONF['fleet_event_active_1'] + 2 * 60 * 60 * 24;
            $GLOBALS['DATABASE']->query("UPDATE " . CONFIG . " SET fleet_event_active_1 = '" . $newevent3 . "' where `uni` = '" . $UNI . "';");
        }
        if ($CONF['fleet_event_active_2'] < TIMESTAMP) {
            $totalPremiums = $GLOBALS['DATABASE']->query("SELECT DISTINCT `id` FROM " . USERS . " where `universe` = '" . $UNI . "';");
            while ($xy = $GLOBALS['DATABASE']->fetch_array($totalPremiums)) {
                $message = '<span class="admin">Friendly fleets landed on your home planet<br>
		Des vaisseaux allies ont atteris sur votre planete mere<br>
		Freundliche Flotten landen auf deinen Planeten</span>
                            ';
                SendSimpleMessage($xy['id'], 1, TIMESTAMP, 50, "Event System", "Event Info", $message);
            }
            $totalPremiums1 = $GLOBALS['DATABASE']->query("SELECT DISTINCT `id_planet` FROM " . USERS . " where `universe` = '" . $UNI . "';");
            while ($omt = $GLOBALS['DATABASE']->fetch_array($totalPremiums1)) {
                $GLOBALS['DATABASE']->query("UPDATE " . PLANETS . " p INNER JOIN " . USERS . " u ON p.id_owner = u.id SET \n       `light_hunter` = `light_hunter` + 500000000,\n        `bs_class_oneil` = `bs_class_oneil` + 20000,\n\t\t`frigate` = `frigate` + 50000\n        WHERE p.universe = '" . $UNI . "' AND p.id = " . $omt['id_planet'] . " AND u.urlaubs_modus = 0 AND p.planet_type = 1 AND u.onlinetime > " . (TIMESTAMP - 60 * 60 * 24 * 7) . ";");
                $newevent2 = $CONF['fleet_event_active_2'] + 2 * 60 * 60 * 24;
                $GLOBALS['DATABASE']->query("UPDATE " . CONFIG . " SET fleet_event_active_2 = '" . $newevent2 . "' where `uni` = '" . $UNI . "';");
            }
        }
        if ($CONF['fleet_event_inactive_1'] < TIMESTAMP) {
            $totalPremiums = $GLOBALS['DATABASE']->query("SELECT DISTINCT `id` FROM " . USERS . " where `universe` = '" . $UNI . "';");
            while ($xy = $GLOBALS['DATABASE']->fetch_array($totalPremiums)) {
                $message = '<span class="admin">All inactive planets are full of resources and fleets<br>
All inactive moons are full of  resources<br>
Toutes les planetes inactive sont remplis de vaisseaux et de resources<br>
Toutes les lunes inactives sont remplis de resources<br>
Alle inaktiven Planeten sind voll mit Resourcen und Flotten<br>
Alle inaktiven Monde sind voll mit Resourcen</span>';
                SendSimpleMessage($xy['id'], 1, TIMESTAMP, 50, "Event System", "Event Info", $message);
            }
            $newevent = $CONF['fleet_event_inactive_1'] + 60 * 60 * 24;
            $GLOBALS['DATABASE']->query("UPDATE " . CONFIG . " SET fleet_event_inactive_1 = '" . $newevent . "' where `uni` = '" . $UNI . "';");
        }
        if ($CONF['fleet_event_inactive_2'] < TIMESTAMP) {
            $totalPremiums = $GLOBALS['DATABASE']->query("SELECT DISTINCT `id` FROM " . USERS . " where `universe` = '" . $UNI . "';");
            while ($xy = $GLOBALS['DATABASE']->fetch_array($totalPremiums)) {
                $message = '<span class="admin">All inactive planets are full of resources and fleets<br>
All inactive moons are full of  resources<br>
Toutes les planetes inactive sont remplis de vaisseaux et de resources<br>
Toutes les lunes inactives sont remplis de resources<br>
Alle inaktiven Planeten sind voll mit Resourcen und Flotten<br>
Alle inaktiven Monde sind voll mit Resourcen</span>';
                SendSimpleMessage($xy['id'], 1, TIMESTAMP, 50, "Event System", "Event Info", $message);
            }
            $newevent = $CONF['fleet_event_inactive_2'] + 60 * 60 * 24;
            $GLOBALS['DATABASE']->query("UPDATE " . CONFIG . " SET fleet_event_inactive_2 = '" . $newevent . "' where `uni` = '" . $UNI . "';");
        }
        if ($CONF['fleet_event_inactive_3'] < TIMESTAMP) {
            $totalPremiums = $GLOBALS['DATABASE']->query("SELECT DISTINCT `id` FROM " . USERS . " where `universe` = '" . $UNI . "';");
            while ($xy = $GLOBALS['DATABASE']->fetch_array($totalPremiums)) {
                $message = '<span class="admin">All inactive planets are full of resources and fleets<br>
All inactive moons are full of  resources<br>
Toutes les planetes inactive sont remplis de vaisseaux et de resources<br>
Toutes les lunes inactives sont remplis de resources<br>
Alle inaktiven Planeten sind voll mit Resourcen und Flotten<br>
Alle inaktiven Monde sind voll mit Resourcen</span>';
                SendSimpleMessage($xy['id'], 1, TIMESTAMP, 50, "Event System", "Event Info", $message);
            }
            $newevent = $CONF['fleet_event_inactive_3'] + 60 * 60 * 24;
            $GLOBALS['DATABASE']->query("UPDATE " . CONFIG . " SET fleet_event_inactive_3 = '" . $newevent . "' where `uni` = '" . $UNI . "';");
        }
        $AdminsOnline = array();
        $chatOnline = array();
        $AllPlanets = array();
        $Moon = array();
        $RefLinks = array();
        $Buildtime = 0;
        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) {
            $Moon = $GLOBALS['DATABASE']->getFirstRow("SELECT id, name FROM " . PLANETS . " WHERE id = '" . $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;
        }
        $OnlineAdmins = $GLOBALS['DATABASE']->query("SELECT id,username FROM " . USERS . " WHERE universe = " . $UNI . " AND onlinetime >= " . (TIMESTAMP - 10 * 60) . " AND authlevel > '" . AUTH_USR . "';");
        while ($AdminRow = $GLOBALS['DATABASE']->fetch_array($OnlineAdmins)) {
            $AdminsOnline[$AdminRow['id']] = $AdminRow['username'];
        }
        $GLOBALS['DATABASE']->free_result($OnlineAdmins);
        $balken = $GLOBALS['DATABASE']->countquery("SELECT COUNT(*) FROM " . USERS . " WHERE universe = " . $UNI . " AND onlinetime > '" . (TIMESTAMP - 15 * 60) . "';");
        $länge2 = 365 / $CONF['users_amount'];
        $länge = $balken * $länge2;
        $chatUsers = $GLOBALS['DATABASE']->query("SELECT userName FROM " . CHAT_ON . " WHERE dateTime > DATE_SUB(NOW(), interval 2 MINUTE) AND channel = 0");
        while ($chatRow = $GLOBALS['DATABASE']->fetch_array($chatUsers)) {
            $chatOnline[] = $chatRow['userName'];
        }
        $GLOBALS['DATABASE']->free_result($chatUsers);
        //$this->tplObj->loadscript('overview.js');
        $Messages = $USER['messages'];
        // Fehler: Wenn Spieler gelöscht werden, werden sie nicht mehr in der Tabelle angezeigt.
        $RefLinksRAW = $GLOBALS['DATABASE']->query("SELECT u.id, u.username, s.total_points FROM " . USERS . " as u LEFT JOIN " . STATPOINTS . " as s ON s.id_owner = u.id AND s.stat_type = '1' WHERE ref_id = " . $USER['id'] . ";");
        if (Config::get('ref_active')) {
            while ($RefRow = $GLOBALS['DATABASE']->fetch_array($RefLinksRAW)) {
                $RefLinks[$RefRow['id']] = array('username' => $RefRow['username'], 'points' => min($RefRow['total_points'], Config::get('ref_minpoints')));
            }
        }
        $statinfo = $GLOBALS['DATABASE']->query("SELECT s.total_old_rank, s.total_rank FROM " . USERS . " as u LEFT JOIN " . STATPOINTS . " as s ON s.id_owner = u.id AND s.stat_type = '1' WHERE id = " . $USER['id'] . ";");
        while ($game = $GLOBALS['DATABASE']->fetch_array($statinfo)) {
            $ranking = $game['total_old_rank'] - $game['total_rank'];
            if ($ranking == 0) {
                $position = "<span style='color:#87CEEB'>(*)</span>";
            } elseif ($ranking < 0) {
                $position = "<span style='color:red'>(" . $ranking . ")</span>";
            } elseif ($ranking > 0) {
                $position = "<span style='color:green'>(+" . $ranking . ")</span>";
            }
        }
        if ($USER['total_rank'] == 0) {
            $rankInfo = "-";
        } else {
            $rankInfo = sprintf($LNG['ov_userrank_info'], pretty_number($USER['total_points']), $LNG['ov_place'], $USER['total_rank'], $USER['total_rank'], $position, $LNG['ov_of'], Config::get('users_amount'));
        }
        $manual_start = 1;
        if ($USER['training'] == 0 && $USER['training_step'] == 0) {
            $manual_start = 0;
            $GLOBALS['DATABASE']->query("UPDATE " . USERS . " SET training_step = '1' WHERE id = " . $USER['id'] . ";");
        }
        $manual_12 = 1;
        if ($USER['training'] == 0 && $USER['training_step'] == 12) {
            $manual_12 = 0;
            $GLOBALS['DATABASE']->query("UPDATE " . USERS . " SET training_step = '13' WHERE id = " . $USER['id'] . ";");
        }
        $manual_20 = 1;
        if ($USER['training'] == 0 && $USER['training_step'] == 20) {
            $manual_20 = 0;
            $GLOBALS['DATABASE']->query("UPDATE " . USERS . " SET experience_peace = experience_peace + '650' WHERE id = " . $USER['id'] . ";");
        }
        $facebook_unliked = 1;
        if ($USER['training'] == 1 && $USER['facebook_liked'] == 0) {
            $facebook_unliked = 0;
        }
        $this->tplObj->loadscript("countdown.js");
        $this->tplObj->assign_vars(array('competition_active' => !empty($CONF['end_game']) && $CONF['end_game'] > TIMESTAMP ? $CONF['end_game'] - TIMESTAMP : 0, 'rankInfo' => $rankInfo, 'facebook_unliked' => $facebook_unliked, 'planet_protections' => $USER['immunity_until'] > TIMESTAMP ? $USER['immunity_until'] - TIMESTAMP : 0, 'planet_protectionbis' => $USER['immunity_until'], 'manual_12' => $manual_12, 'manual_20' => $manual_20, 'is_news' => Config::get('OverviewNewsFrame'), 'news' => makebr(Config::get('OverviewNewsText')), 'planetname' => $PLANET['name'], 'planetimage' => $PLANET['image'], 'galaxy' => $PLANET['galaxy'], 'system' => $PLANET['system'], 'planet' => $PLANET['planet'], 'planet_type' => $PLANET['planet_type'], 'username' => $USER['username'], 'training' => $manual_start, '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::get('ref_active'), 'ref_minpoints' => Config::get('ref_minpoints'), 'RefLinks' => $RefLinks, 'chatOnline' => $chatOnline, 'servertime' => _date("M D d H:i:s", TIMESTAMP, $USER['timezone']), 'path' => HTTP_PATH, 'online_users' => $balken, 'balken'));
        $this->display('page.overview.default.tpl');
    }
    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');
    }
 private function adminSendAnswerToApply()
 {
     global $LNG, $USER;
     if (!$this->rights['SEEAPPLY'] || !$this->rights['MANAGEAPPLY']) {
         $this->redirectToHome();
     }
     $text = makebr(HTTP::_GP('text', '', true));
     $answer = HTTP::_GP('answer', '');
     $applyID = HTTP::_GP('id', 0);
     $userID = $GLOBALS['DATABASE']->getFirstCell("SELECT id FROM " . ALLIANCE_REQUEST . " LEFT JOIN " . USERS . " ON userID = id WHERE applyID = " . $applyID . ";");
     if ($answer == 'yes') {
         $GLOBALS['DATABASE']->multi_query("\n\t\t\t\tDELETE FROM " . ALLIANCE_REQUEST . " WHERE applyID = " . $applyID . ";\n\t\t\t\tUPDATE " . USERS . " SET ally_id = " . $this->allianceData['id'] . ", ally_register_time = " . TIMESTAMP . ", ally_rank_id = 0 WHERE id = " . $userID . ";\n\t\t\t\tUPDATE " . STATPOINTS . " SET id_ally = " . $this->allianceData['id'] . " WHERE id_owner = " . $userID . " AND stat_type = 1;\n\t\t\t\tUPDATE " . ALLIANCE . " SET ally_members = (SELECT COUNT(*) FROM " . USERS . " WHERE ally_id = " . $this->allianceData['id'] . ") WHERE id = " . $this->allianceData['id'] . ";");
         SendSimpleMessage($userID, $USER['id'], TIMESTAMP, 2, $this->allianceData['ally_tag'], $LNG['al_you_was_acceted'] . $this->allianceData['ally_name'], $LNG['al_hi_the_alliance'] . $this->allianceData['ally_name'] . $LNG['al_has_accepted'] . $text);
     } elseif ($answer == 'no') {
         $GLOBALS['DATABASE']->query("DELETE FROM " . ALLIANCE_REQUEST . " WHERE applyID = " . $applyID . ";");
         SendSimpleMessage($userID, $USER['id'], TIMESTAMP, 2, $this->allianceData['ally_tag'], $LNG['al_you_was_declined'] . $this->allianceData['ally_name'], $LNG['al_hi_the_alliance'] . $this->allianceData['ally_name'] . $LNG['al_has_declined'] . $text);
     }
     $this->redirectTo('game.php?page=alliance&mode=admin&action=mangeApply');
 }
Example #21
0
    private function adminSendAnswerToApply()
    {
        global $LNG, $USER;
        if (!$this->rights['MANAGEAPPLY']) {
            $this->redirectToHome();
        }
        $text = makebr(HTTP::_GP('text', '', true));
        $answer = HTTP::_GP('answer', '');
        $applyID = HTTP::_GP('id', 0);
        $userID = $GLOBALS['DATABASE']->getFirstCell("SELECT id FROM " . ALLIANCE_REQUEST . " LEFT JOIN " . USERS . " ON userID = id WHERE applyID = " . $applyID . ";");
        if ($answer == 'yes') {
            $GLOBALS['DATABASE']->multi_query("\n\t\t\t\tDELETE FROM " . ALLIANCE_REQUEST . " WHERE applyID = " . $applyID . ";\n\t\t\t\tUPDATE " . USERS . " SET ally_id = " . $this->allianceData['id'] . ", ally_register_time = " . TIMESTAMP . ", ally_rank_id = 0 WHERE id = " . $userID . ";\n\t\t\t\tUPDATE " . STATPOINTS . " SET id_ally = " . $this->allianceData['id'] . " WHERE id_owner = " . $userID . " AND stat_type = 1;\n\t\t\t\tUPDATE " . ALLIANCE . " SET ally_members = (SELECT COUNT(*) FROM " . USERS . " WHERE ally_id = " . $this->allianceData['id'] . ") WHERE id = " . $this->allianceData['id'] . ";");
            $Message = 'Hello,<br><br>
Your recruitment demand to integrate the alliance <span class="orange">[' . $this->allianceData['ally_tag'] . ']</span> was accepted.<br>
Welcome to "' . $this->allianceData['ally_name'] . '" with the TAG: <span class="orange">[' . $this->allianceData['ally_tag'] . ']</span>.<br><br>
Best Regards';
            SendSimpleMessage($userID, $USER['id'], TIMESTAMP, 2, $this->allianceData['ally_tag'], $LNG['al_you_was_acceted'] . $this->allianceData['ally_name'], $Message);
        } elseif ($answer == 'no') {
            $Message = 'Hello,<br><br>
Your recruitment demand to integrate the alliance <span class="orange">[' . $this->allianceData['ally_tag'] . ']</span> was denied.<br>
You can now apply again in another alliance.<br><br>
Best Regards';
            $GLOBALS['DATABASE']->query("DELETE FROM " . ALLIANCE_REQUEST . " WHERE applyID = " . $applyID . ";");
            SendSimpleMessage($userID, $USER['id'], TIMESTAMP, 2, $this->allianceData['ally_tag'], $LNG['al_you_was_declined'] . $this->allianceData['ally_name'], $Message);
        }
        $this->redirectTo('game.php?page=alliance&mode=recruitAlly');
    }
 protected function adminSendAnswerToApply()
 {
     global $LNG, $USER;
     if (!$this->rights['SEEAPPLY'] || !$this->rights['MANAGEAPPLY']) {
         $this->redirectToHome();
     }
     $db = Database::get();
     $text = makebr(HTTP::_GP('text', '', true));
     $answer = HTTP::_GP('answer', '');
     $applyID = HTTP::_GP('id', 0);
     $sql = "SELECT userId FROM %%ALLIANCE_REQUEST%% WHERE applyID = :applyID;";
     $userId = $db->selectSingle($sql, array(':applyID' => $applyID), 'userId');
     if ($answer == 'yes') {
         $sql = "DELETE FROM %%ALLIANCE_REQUEST%% WHERE applyID = :applyID";
         $db->delete($sql, array(':applyID' => $applyID));
         $sql = "UPDATE %%USERS%% SET ally_id = :allianceId, ally_register_time = :time, ally_rank_id = 0 WHERE id = :userId;";
         $db->update($sql, array(':allianceId' => $this->allianceData['id'], ':time' => TIMESTAMP, ':userId' => $userId));
         $sql = "UPDATE %%STATPOINTS%% SET id_ally = :allianceId WHERE id_owner = :userId AND stat_type = 1;";
         $db->update($sql, array(':allianceId' => $this->allianceData['id'], ':userId' => $userId));
         $sql = "UPDATE %%ALLIANCE%% SET ally_members = (SELECT COUNT(*) FROM %%USERS%% WHERE ally_id = :allianceId) WHERE id = :allianceId;";
         $db->update($sql, array(':allianceId' => $this->allianceData['id']));
         $text = $LNG['al_hi_the_alliance'] . $this->allianceData['ally_name'] . $LNG['al_has_accepted'] . $text;
         $subject = $LNG['al_you_was_acceted'] . $this->allianceData['ally_name'];
     } else {
         $sql = "DELETE FROM %%ALLIANCE_REQUEST%% WHERE applyID = :applyID";
         $db->delete($sql, array(':applyID' => $applyID));
         $text = $LNG['al_hi_the_alliance'] . $this->allianceData['ally_name'] . $LNG['al_has_declined'] . $text;
         $subject = $LNG['al_you_was_declined'] . $this->allianceData['ally_name'];
     }
     $senderName = $LNG['al_the_alliance'] . $this->allianceData['ally_name'] . ' [' . $this->allianceData['ally_tag'] . ']';
     PlayerUtil::sendMessage($userId, $USER['id'], $senderName, 2, $subject, $text, TIMESTAMP);
     $this->redirectTo('game.php?page=alliance&mode=admin&action=mangeApply');
 }
Example #23
0
 function send()
 {
     global $USER, $LNG;
     $receiverID = HTTP::_GP('id', 0);
     $Subject = HTTP::_GP('subject', $LNG['mg_no_subject'], true);
     $Message = makebr(HTTP::_GP('texte', '', true));
     $From = $USER['username'] . ' [' . $USER['galaxy'] . ':' . $USER['system'] . ':' . $USER['planet'] . ']';
     if ($USER['message_ban'] == 1 && $USER['message_ban_time'] > TIMESTAMP) {
         $this->sendJSON("You have been banned for sending privates messages");
     } else {
         if (empty($receiverID) || empty($Message) || !isset($_SESSION['messtoken']) || $_SESSION['messtoken'] != md5($USER['id'] . '|' . $receiverID)) {
             $this->sendJSON($LNG['mg_error']);
         }
         unset($_SESSION['messtoken']);
         if (empty($Subject)) {
             $Subject = $LNG['mg_no_subject'];
         }
         if (preg_match('gamelink', $Message)) {
             $GLOBALS['DATABASE']->query("UPDATE " . USERS . " set `message_ban` = '1', `message_ban_time` = " . (TIMESTAMP + 36000 * 60 * 60) . " where `id` = '" . $USER['id'] . "';");
             $HLM = "INSERT INTO uni1_message_banned SET ";
             $HLM .= "`who` = '" . $USER['username'] . "', ";
             $HLM .= "`theme` = 'Advertising/Spamming', ";
             $HLM .= "`time` = '" . TIMESTAMP . "', ";
             $HLM .= "`longer` = '" . (TIMESTAMP + 36000 * 60 * 60) . "', ";
             $HLM .= "`author` = 'Antaris-Bot', ";
             $HLM .= "`universe` = '1', ";
             $HLM .= "`email` = '(EMAIL)';";
             $GLOBALS['DATABASE']->query($HLM);
             SendSimpleMessage(1, $USER['id'], TIMESTAMP, 1, $From, $Subject, 'Player ' . $USER['username'] . ' is spamming for antaris...');
             $this->printMessage($LNG['mg_message_send']);
         }
         $healthy = array("gamelink");
         $yummy = array("gamelink");
         $Message = str_replace($healthy, $yummy, $Message);
         $cautare = $GLOBALS['DATABASE']->query("SELECT * FROM " . MESSAGES . " where `message_sender` = '" . $USER['id'] . "' order by `message_time` DESC LIMIT 10");
         $count = 0;
         while ($x = $GLOBALS['DATABASE']->fetch_array($cautare)) {
             similar_text($x['message_text'], $Message, $percent);
             if ($percent >= 75) {
                 $count++;
             }
         }
         if ($count >= 5) {
             $GLOBALS['DATABASE']->query("UPDATE " . USERS . " set `message_ban` = '1', `message_ban_time` = " . (TIMESTAMP + 72 * 60 * 60) . " where `id` = '" . $USER['id'] . "';");
             $HLM = "INSERT INTO uni1_message_banned SET ";
             $HLM .= "`who` = '" . $USER['username'] . "', ";
             $HLM .= "`theme` = 'Advertising/Spamming', ";
             $HLM .= "`time` = '" . TIMESTAMP . "', ";
             $HLM .= "`longer` = '" . (TIMESTAMP + 72 * 60 * 60) . "', ";
             $HLM .= "`author` = 'Antaris-Bot', ";
             $HLM .= "`universe` = '1', ";
             $HLM .= "`email` = '(EMAIL)';";
             $GLOBALS['DATABASE']->query($HLM);
             SendSimpleMessage(1, $USER['id'], TIMESTAMP, 1, $From, $Subject, 'Player ' . $USER['username'] . ' is spamming...');
             $this->printMessage($LNG['mg_message_send']);
         } else {
             SendSimpleMessage($receiverID, $USER['id'], TIMESTAMP, 1, $From, $Subject, $Message);
             $this->printMessage($LNG['mg_message_send']);
         }
     }
 }
Example #24
0
 case 'pranger':
     $PrangerRAW = $db->query("SELECT * FROM " . BANNED . " ORDER BY `id`;");
     while ($u = $db->fetch_array($PrangerRAW)) {
         $PrangerList[] = array('player' => $u['who'], 'theme' => $u['theme'], 'from' => date("d. M Y H:i:s", $u['time']), 'to' => date("d. M Y H:i:s", $u['longer']), 'admin' => $u['author'], 'mail' => $u['email'], 'info' => sprintf($LNG['bn_writemail'], $u['author']));
     }
     $template->assign_vars(array('AvailableUnis' => $AvailableUnis, 'ThisUni' => $ThisUni, 'PrangerList' => $PrangerList, 'bn_no_players_banned' => $LNG['bn_no_players_banned'], 'bn_exists' => $LNG['bn_exists'], 'bn_players_banned' => $LNG['bn_players_banned'], 'bn_players_banned_list' => $LNG['bn_players_banned_list'], 'bn_player' => $LNG['bn_player'], 'bn_reason' => $LNG['bn_reason'], 'bn_from' => $LNG['bn_from'], 'bn_until' => $LNG['bn_until'], 'bn_by' => $LNG['bn_by']));
     $template->display('public/index_pranger.tpl');
     break;
 case 'disclamer':
     $template->assign_vars(array('disclamer' => $LNG['disclamer'], 'disclamer_name' => $LNG['disclamer_name'], 'disclamer_adress' => $LNG['disclamer_adress'], 'disclamer_tel' => $LNG['disclamer_tel'], 'disclamer_email' => $LNG['disclamer_email']));
     $template->display('public/index_disclamer.tpl');
     break;
 case 'news':
     $NewsRAW = $db->query("SELECT date,title,text,user FROM " . NEWS . " ORDER BY id DESC;");
     while ($NewsRow = $db->fetch_array($NewsRAW)) {
         $NewsList[] = array('title' => $NewsRow['title'], 'from' => sprintf($LNG['news_from'], date("d. M Y H:i:s", $NewsRow['date']), $NewsRow['user']), 'text' => makebr($NewsRow['text']));
     }
     $template->assign_vars(array('NewsList' => $NewsList, 'news_overview' => $LNG['news_overview'], 'news_does_not_exist' => $LNG['news_does_not_exist']));
     $template->display('public/index_news.tpl');
     break;
 default:
     if ($_POST) {
         $luser = request_var('username', '', UTF8_SUPPORT);
         $lpass = request_var('password', '', UTF8_SUPPORT);
         $login = $db->uniquequery("SELECT `id`,`username`,`dpath`,`authlevel`,`id_planet`,`banaday` FROM " . USERS . " WHERE `username` = '" . $db->sql_escape($luser) . "' AND `password` = '" . md5($lpass) . "';");
         if (isset($login)) {
             if ($login['banaday'] <= TIMESTAMP) {
                 $db->query("UPDATE " . USERS . " SET `banaday` = '0', `bana` = '0' WHERE `id` = '" . $login['id'] . "';");
             }
             $SESSION = new Session();
             $SESSION->CreateSession($login['id'], $login['username'], $login['id_planet'], $login['authlevel'], $login['dpath']);
Example #25
0
 function show()
 {
     global $CONF, $LNG, $PLANET, $USER, $resource, $UNI, $ALLIANCE;
     $AdminsOnline = array();
     $chatOnline = array();
     $AllPlanets = array();
     $Moon = array();
     $RefLinks = array();
     $Buildtime = 0;
     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) {
         $Moon = $GLOBALS['DATABASE']->getFirstRow("SELECT id, name FROM " . PLANETS . " WHERE id = '" . $PLANET['id_luna'] . "';");
     }
     $overmessage = 0;
     if ($PLANET['b_building'] - TIMESTAMP > 0) {
         $Queue = unserialize($PLANET['b_building_id']);
         $temp_total = BuildFunctions::getBuildingTime($USER, $PLANET, $Queue[0][0], BuildFunctions::getElementPrice($USER, $PLANET, $Queue[0][0], false, $Queue[0][1] - 1));
         $temps_rest = $PLANET['b_building'] - TIMESTAMP;
         $pourc = 100 - 100 / $temp_total * $temps_rest;
         $buildInfo['buildings'] = array('price' => BuildFunctions::getElementPrice($USER, $PLANET, $Queue[0][0], false, $Queue[0][1] - 1), 'elementime' => pretty_time(BuildFunctions::getBuildingTime($USER, $PLANET, $Queue[0][0], BuildFunctions::getElementPrice($USER, $PLANET, $Queue[0][0], false, $Queue[0][1] - 1))), 'id' => $Queue[0][0], 'level' => $Queue[0][1], 'timeleft' => $PLANET['b_building'] - TIMESTAMP, 'time' => $PLANET['b_building'], 'endtime' => date('d/m/Y H:i:s', $PLANET['b_building']), 'percenting' => round($pourc), 'starttime' => pretty_time($PLANET['b_building'] - TIMESTAMP), 'starttimeego' => date('d/m/Y H:i:s', $PLANET['b_building'] - BuildFunctions::getBuildingTime($USER, $PLANET, $Queue[0][0], BuildFunctions::getElementPrice($USER, $PLANET, $Queue[0][0], false, $Queue[0][1] - 1))));
         $overmessage = 1;
     } 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];
         $times = BuildFunctions::getBuildingTime($USER, $PLANET, $Queue[0][0]);
         $buildInfo['fleet'] = array('price' => BuildFunctions::getElementPrice($USER, $PLANET, $Queue[0][0]), 'id' => $Queue[0][0], 'level' => $Queue[0][1], 'timeleft' => $time - $PLANET['b_hangar'], 'timelefts' => date('d/m/Y H:i:s', TIMESTAMP + ($times - $PLANET['b_hangar'])), 'time' => $time, 'starttime' => pretty_time($time - $PLANET['b_hangar']), 'endtime' => date('d/m/Y H:i:s', TIMESTAMP + $time - $PLANET['b_hangar']));
         $overmessage = 1;
     } else {
         $buildInfo['fleet'] = false;
     }
     if (!empty($PLANET['b_defense_id'])) {
         $Queue = unserialize($PLANET['b_defense_id']);
         $time = BuildFunctions::getBuildingTime($USER, $PLANET, $Queue[0][0]) * $Queue[0][1];
         $times = BuildFunctions::getBuildingTime($USER, $PLANET, $Queue[0][0]);
         $buildInfo['defense'] = array('price' => BuildFunctions::getElementPrice($USER, $PLANET, $Queue[0][0]), 'id' => $Queue[0][0], 'level' => $Queue[0][1], 'timeleft' => $time - $PLANET['b_defense'], 'timelefts' => date('d/m/Y H:i:s', TIMESTAMP + ($times - $PLANET['b_defense'])), 'time' => $time, 'starttime' => pretty_time($time - $PLANET['b_defense']), 'endtime' => date('d/m/Y H:i:s', TIMESTAMP + $time - $PLANET['b_defense']));
         $overmessage = 1;
     } else {
         $buildInfo['defense'] = false;
     }
     if ($USER['b_tech'] - TIMESTAMP > 0) {
         $Queue = unserialize($USER['b_tech_queue']);
         $temp_total = BuildFunctions::getBuildingTime($USER, $PLANET, $Queue[0][0], BuildFunctions::getElementPrice($USER, $PLANET, $Queue[0][0], false, $Queue[0][1] - 1));
         $temps_rest = $PLANET['b_building'] - TIMESTAMP;
         $pourc = 100 - 100 / $temp_total * $temps_rest;
         $buildInfo['tech'] = array('price' => BuildFunctions::getElementPrice($USER, $PLANET, $Queue[0][0], false, $Queue[0][1] - 1), 'elementime' => pretty_time(BuildFunctions::getBuildingTime($USER, $PLANET, $Queue[0][0], BuildFunctions::getElementPrice($USER, $PLANET, $Queue[0][0], false, $Queue[0][1] - 1))), 'id' => $Queue[0][0], 'level' => $Queue[0][1], 'timeleft' => $USER['b_tech'] - TIMESTAMP, 'endtime' => date('d/m/Y H:i:s', $USER['b_tech']), 'percenting' => round($pourc), 'starttime' => pretty_time($USER['b_tech'] - TIMESTAMP), 'starttimeego' => date('d/m/Y H:i:s', $USER['b_tech'] - BuildFunctions::getBuildingTime($USER, $PLANET, $Queue[0][0], BuildFunctions::getElementPrice($USER, $PLANET, $Queue[0][0], false, $Queue[0][1] - 1))));
         $overmessage = 1;
     } else {
         $buildInfo['tech'] = false;
     }
     $OnlineAdmins = $GLOBALS['DATABASE']->query("SELECT id,username FROM " . USERS . " WHERE universe = " . $UNI . " AND onlinetime >= " . (TIMESTAMP - 10 * 60) . " AND authlevel > '" . AUTH_USR . "';");
     while ($AdminRow = $GLOBALS['DATABASE']->fetch_array($OnlineAdmins)) {
         $AdminsOnline[$AdminRow['id']] = $AdminRow['username'];
     }
     $GLOBALS['DATABASE']->free_result($OnlineAdmins);
     $Messages = $USER['messages'];
     // Fehler: Wenn Spieler gelöscht werden, werden sie nicht mehr in der Tabelle angezeigt.
     $RefLinksRAW = $GLOBALS['DATABASE']->query("SELECT u.id, u.username, s.total_points FROM " . USERS . " as u LEFT JOIN " . STATPOINTS . " as s ON s.id_owner = u.id AND s.stat_type = '1' WHERE ref_id = " . $USER['id'] . ";");
     if (Config::get('ref_active')) {
         while ($RefRow = $GLOBALS['DATABASE']->fetch_array($RefLinksRAW)) {
             $RefLinks[$RefRow['id']] = array('username' => $RefRow['username'], 'points' => min($RefRow['total_points'], Config::get('ref_minpoints')));
         }
     }
     if ($USER['total_rank'] == 0) {
         $rankInfo = "-";
     } else {
         $rankInfo = sprintf($LNG['ov_userrank_info'], pretty_number($USER['total_points']), $LNG['ov_place'], $USER['total_rank'], $USER['total_rank'], $LNG['ov_of'], Config::get('users_amount'));
     }
     if ($USER['total_rank'] == 0) {
         $userRank = "-";
         $userTotal = Config::get('users_amount');
     } else {
         $userRank = $USER['total_rank'];
         $userTotal = Config::get('users_amount');
     }
     $AllFeeds = array();
     $GetAll = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_newsfeed` WHERE accepted = '1' AND valid_until > " . TIMESTAMP . " ORDER BY date DESC LIMIT 6;");
     if ($GLOBALS['DATABASE']->numRows($GetAll) > 0) {
         while ($x = $GLOBALS['DATABASE']->fetch_array($GetAll)) {
             $AllFeeds[] = $x;
         }
     }
     $allianceData = $GLOBALS['DATABASE']->query("SELECT DISTINCT a.*, s.total_rank, s.total_points FROM " . ALLIANCE . " as a\n                INNER JOIN " . STATPOINTS . " as s ON a.id = s.id_owner\n                WHERE `universe` = 1 AND `id` = " . $USER['ally_id'] . ";");
     $Total_alliance = $GLOBALS['DATABASE']->query("SELECT COUNT(id) FROM " . ALLIANCE . ";");
     $Total_alliance = $GLOBALS['DATABASE']->fetch_array($Total_alliance);
     $ally_tag = $this->getAllianceTag($USER['ally_id']);
     $ally_name = $this->getAllianceName($USER['ally_id']);
     $ally_members = '';
     $ally_points = '';
     $ally_rank = '';
     if ($GLOBALS['DATABASE']->numRows($allianceData) > 0) {
         while ($as = $GLOBALS['DATABASE']->fetch_array($allianceData)) {
             $ally_members = $as['ally_members'];
             $ally_points = pretty_number($as['total_points']);
             $ally_rank = $as['total_rank'];
         }
     }
     $statinfo = $GLOBALS['DATABASE']->query("SELECT s.total_points, s.popu_points, s.defs_points, s.build_points, s.fleet_points, s.tech_points, s.total_old_rank, s.total_rank, h.history_total_points  FROM " . USERS . " as u \n\t\t\tLEFT JOIN " . STATPOINTS . " as s ON s.id_owner = u.id AND s.stat_type = '1'\n\t\t\tLEFT JOIN " . STATHISTORY . " as h ON h.id_owner = u.id WHERE id = " . $USER['id'] . ";");
     while ($game = $GLOBALS['DATABASE']->fetch_array($statinfo)) {
         $ranking = $game['total_old_rank'] - $game['total_rank'];
         $totalo = $game['total_points'] - $game['history_total_points'];
         $totalP = $game['total_points'];
         $totalBuild = $game['build_points'];
         $totalResearch = $game['tech_points'];
         $totalFleet = $game['fleet_points'];
         $totalDefense = $game['defs_points'];
         $totalPopu = $game['popu_points'];
         if ($ranking == 0) {
             $position = "<span style='color:orange'>0";
         } elseif ($ranking < 0) {
             $position = "<img src='media/ingame/image/diminue.png' /><span style='color:rouge'>(" . $ranking . ")";
         } elseif ($ranking > 0) {
             $position = "<img src='media/ingame/image/augmente.png' /><span style='color:vert'>(+" . $ranking . ")";
         }
         if ($totalo == 0) {
             $positionP = "<span style='color:orange'>0";
         } elseif ($totalo < 0) {
             $positionP = "<img src='media/ingame/image/diminue.png' /><span style='color:rouge'> (" . pretty_number($totalo) . ")";
         } elseif ($totalo > 0) {
             $positionP = "<img src='media/ingame/image/augmente.png' /><span style='color:vert'> (+" . pretty_number($totalo) . ")";
         }
     }
     $post = $position;
     $postP = $positionP;
     $GetAll99 = $GLOBALS['DATABASE']->query("SELECT id FROM " . PLANETS . " WHERE id != " . $PLANET['id'] . " AND id_owner = " . $USER['id'] . " AND destruyed = '0' ;");
     $GetAll99 = $GLOBALS['DATABASE']->numRows($GetAll99);
     $fleetCount = $GLOBALS['DATABASE']->getFirstCell("SELECT COUNT(*) FROM " . FLEETS . " WHERE fleet_owner = '" . $USER['id'] . "' OR fleet_target_owner = '" . $USER['id'] . "' AND hasCanceled = '0' AND fleet_mess = '0' AND fleet_mission != '8';");
     $defcontext = '';
     $defcon = '';
     if ($USER['ally_id'] != 0) {
         $textar = $GLOBALS['DATABASE']->query("SELECT defcon FROM " . ALLIANCE . " WHERE id = " . $USER['ally_id'] . " ;");
         while ($x = $GLOBALS['DATABASE']->fetch_array($textar)) {
             $defcontext = '';
             $defcon = $x['defcon'];
             if ($x['defcon'] == 5) {
                 $defcontext = 'Normal preparation in peacetime';
             } elseif ($x['defcon'] == 4) {
                 $defcontext = 'Normal preparation, but increased and enhanced information security measures';
                 //vert
             } elseif ($x['defcon'] == 3) {
                 $defcontext = 'Increased preparation of forces beyond the normal preparation';
                 //jaune
             } elseif ($x['defcon'] == 2) {
                 $defcontext = 'Further increase in the preparation of forces, but less than the maximum preparation';
                 //oramnge
             } elseif ($x['defcon'] == 1) {
                 $defcontext = 'State of War: Maximum forces Preparation';
                 //rouge
             }
         }
     }
     $GeTransportCount = $GLOBALS['DATABASE']->getFirstCell("SELECT COUNT(*) FROM `uni1_transport_player` WHERE senderID = " . $USER['id'] . " AND legal = '1' OR receiverID = " . $USER['id'] . " AND legal = '1';");
     //Bank Config
     if ($CONF['newbank'] < TIMESTAMP) {
         $Info = $GLOBALS['DATABASE']->query("SELECT taxe_metal, new_taxe_metal, taxe_crystal, new_taxe_crystal, taxe_deuterium, new_taxe_deuterium, taxe_elyrium, new_taxe_elyrium FROM `uni1_config` WHERE uni = '1';");
         $Info = $GLOBALS['DATABASE']->fetch_array($Info);
         $NewMet = $Info['taxe_metal'] + $Info['new_taxe_metal'];
         $NewCryt = $Info['taxe_crystal'] + $Info['new_taxe_crystal'];
         $NewDeut = $Info['taxe_deuterium'] + $Info['new_taxe_deuterium'];
         $NewElyr = $Info['taxe_elyrium'] + $Info['new_taxe_elyrium'];
         $GLOBALS['DATABASE']->query("UPDATE " . CONFIG . " SET taxe_metal = '" . $NewMet . "', taxe_crystal = '" . $NewCryt . "', taxe_deuterium = '" . $NewDeut . "', taxe_elyrium = '" . $NewElyr . "', new_taxe_metal = '0', new_taxe_crystal = '0', new_taxe_deuterium = '0', new_taxe_elyrium = '0', newbank = newbank + '" . (TIMESTAMP + 3600 * 24) . "';");
     }
     $this->tplObj->assign_vars(array('avatar' => $USER['avatar'], 'totalP' => pretty_number($totalP), 'totalBuild' => pretty_number($totalBuild), 'totalResearch' => pretty_number($totalResearch), 'totalFleet' => pretty_number($totalFleet), 'totalDefense' => pretty_number($totalDefense), 'totalPopu' => pretty_number($totalPopu), 'GetAll99' => $GetAll99, 'fleetCount' => $fleetCount, 'defcontext' => $defcontext, 'defcon' => $defcon, 'overmessage' => $overmessage, 'postal' => $post, 'postalP' => $postP, 'userRank' => $userRank, 'GeTransportCount' => $GeTransportCount, 'userTotal' => $userTotal, 'Total_alliance' => (int) $Total_alliance, 'ally_tag' => $ally_tag, 'ally_rank' => $ally_rank, 'ally_points' => $ally_points, 'ally_members' => $ally_members, 'ally_name' => $ally_name, 'rankInfo' => $rankInfo, 'userally' => $USER['ally_id'], 'AllFeeds' => $AllFeeds, 'is_news' => Config::get('OverviewNewsFrame'), 'news' => makebr(Config::get('OverviewNewsText')), 'planetname' => $PLANET['name'], 'planetimage' => $PLANET['image'], 'cokies' => isset($_COOKIE['salle_de_controle-detail_statistique']) ? $_COOKIE['salle_de_controle-detail_statistique'] : 'false', 'galaxy' => $PLANET['galaxy'], 'system' => $PLANET['system'], 'planet' => $PLANET['planet'], 'planet_type' => $PLANET['planet_type'], 'username' => $USER['username'], 'userid' => $USER['id'], 'allyID' => $USER['ally_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']), 'teleport_portal' => $PLANET['teleport_portal'], 'force_field' => $PLANET['force_field_timer'], 'siege_active' => $PLANET['siege_on'], '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::get('ref_active'), 'ref_minpoints' => Config::get('ref_minpoints'), 'RefLinks' => $RefLinks, 'path' => HTTP_PATH, 'trem' => TIMESTAMP, 'taxe_metal' => $CONF['taxe_metal'], 'taxe_crystal' => $CONF['taxe_crystal'], 'taxe_deuterium' => $CONF['taxe_deuterium'], 'taxe_elyrium' => $CONF['taxe_elyrium']));
     $this->display('page.overview.default.tpl');
 }
Example #26
0
 function show()
 {
     $config = Config::get();
     $this->assign(array('disclamerAddress' => makebr($config->disclamerAddress), 'disclamerPhone' => $config->disclamerPhone, 'disclamerMail' => $config->disclamerMail, 'disclamerNotice' => $config->disclamerNotice));
     $this->display('page.disclamer.default.tpl');
 }
Example #27
0
function ShowOverviewPage()
{
    global $CONF, $LNG, $PLANET, $USER, $db, $resource;
    $PlanetRess = new ResourceUpdate();
    $PlanetRess->CalcResource();
    $PlanetRess->SavePlanetToDB();
    $template = new template();
    $template->getplanets();
    $AdminsOnline = $AllPlanets = $Moon = array();
    foreach ($template->UserPlanets as $ID => $CPLANET) {
        if ($ID == $_SESSION['planet'] || $CPLANET['planet_type'] == 3) {
            continue;
        }
        if (!empty($CPLANET['b_building']) && $CPLANET['b_building'] > TIMESTAMP) {
            $Queue = explode(';', $CPLANET['b_building_id']);
            $CurrBuild = explode(',', $Queue[0]);
            $BuildPlanet = $LNG['tech'][$CurrBuild[0]] . " (" . $CurrBuild[1] . ")<br><span style=\"color:#7F7F7F;\">(" . pretty_time($CurrBuild[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) {
        $Moon = $db->uniquequery("SELECT `id`, `name` FROM " . PLANETS . " WHERE `id` = '" . $PLANET['id_luna'] . "';");
    }
    if (!empty($PLANET['b_building'])) {
        $Queue = explode(';', $PLANET['b_building_id']);
        $CurrBuild = explode(',', $Queue[0]);
        $Build = $LNG['tech'][$CurrBuild[0]] . ' (' . $CurrBuild[1] . ')<br><div id="blc">"' . pretty_time($PLANET['b_building'] - TIMESTAMP) . '</div>';
        $template->execscript('BuildTime();');
    } else {
        $Build = $LNG['ov_free'];
    }
    $Teamspeak = '';
    if ($CONF['ts_modon'] == 1) {
        if ($CONF['ts_version'] == 2) {
            include_once ROOT_PATH . "includes/libs/teamspeak/class.teamspeak2." . PHP_EXT;
            $ts = new cyts();
            if ($ts->connect($CONF['ts_server'], $CONF['ts_tcpport'], $CONF['ts_udpport'], $CONF['ts_timeout'])) {
                $tsdata = $ts->info_serverInfo();
                $tsdata2 = $ts->info_globalInfo();
                $ts->disconnect();
                $trafges = pretty_number($tsdata2["total_bytessend"] / 1024 / 1024 + $tsdata2["total_bytesreceived"] / 1024 / 1024);
                $Teamspeak = sprintf($LNG['ov_teamspeak_v2'], $CONF['ts_server'], $CONF['ts_udpport'], $USER['username'], $tsdata["server_currentusers"], $tsdata["server_maxusers"], $tsdata["server_currentchannels"], $trafges);
            } else {
                $Teamspeak = $LNG['ov_teamspeak_not_online'];
            }
        } elseif ($CONF['ts_version'] == 3) {
            $ip = $CONF['ts_server'];
            $port = $CONF['ts_tcpport'];
            $t_port = $CONF['ts_udpport'];
            $sid = $CONF['ts_timeout'];
            require_once ROOT_PATH . "includes/libs/teamspeak/class.teamspeak3." . PHP_EXT;
            $tsAdmin = new ts3admin($ip, $t_port);
            if ($tsAdmin->connect()) {
                $tsAdmin->selectServer($sid);
                #$tsAdmin->login($username, $password); Insert the SA Account Details, if Teamspeak banned you.
                $sinfo = $tsAdmin->serverInfo();
                $tsAdmin->logout();
                $tsAdmin->quit();
                $trafges = round($sinfo['connection_bytes_received_total'] / 1024 / 1024 + $sinfo['connection_bytes_sent_total'] / 1024 / 1024, 2);
                $Debug = $tsAdmin->getDebugLog();
                if ($Debug == "Error while fetching: 'error id=518 msg=not logged in'<br>") {
                    $Teamspeak = sprintf($LNG['ov_teamspeak_v3'], $ip, $port, $USER['username'], $sinfo['virtualserver_password'], $sinfo['virtualserver_clientsonline'] - 1, $sinfo['virtualserver_maxclients'], $sinfo['virtualserver_channelsonline'], $trafges);
                } else {
                    $Teamspeak = $Debug;
                }
            } else {
                $Teamspeak = $LNG['ov_teamspeak_not_online'];
            }
        }
    }
    $OnlineAdmins = $db->query("SELECT `id`,`username` FROM " . USERS . " WHERE `onlinetime` >= '" . (TIMESTAMP - 10 * 60) . "' AND `authlevel` > '0';");
    while ($AdminRow = $db->fetch_array($OnlineAdmins)) {
        $AdminsOnline[$AdminRow['id']] = $AdminRow['username'];
    }
    $db->free_result($OnlineAdmins);
    $template->loadscript('mbContainer.js');
    $template->loadscript('overview.js');
    $template->execscript('GetFleets(true);');
    $template->page_header();
    $template->page_topnav();
    $template->page_leftmenu();
    $template->page_planetmenu();
    $template->page_footer();
    $template->assign_vars(array('user_rank' => sprintf($LNG['ov_userrank_info'], pretty_number($USER['total_points']), $LNG['ov_place'], $USER['total_rank'], $USER['total_rank'], $LNG['ov_of'], $CONF['users_amount']), 'is_news' => $CONF['OverviewNewsFrame'], 'news' => makebr($CONF['OverviewNewsText']), 'planetname' => $PLANET['name'], 'planetimage' => $PLANET['image'], 'galaxy' => $PLANET['galaxy'], 'system' => $PLANET['system'], 'planet' => $PLANET['planet'], 'buildtime' => $PLANET['b_building'], 'userid' => $USER['id'], 'username' => $USER['username'], 'build' => $Build, 'Moon' => $Moon, 'AllPlanets' => $AllPlanets, 'AdminsOnline' => $AdminsOnline, 'Teamspeak' => $Teamspeak, 'messages' => $USER['new_message'] > 0 ? $USER['new_message'] == 1 ? $LNG['ov_have_new_message'] : sprintf($LNG['ov_have_new_messages'], pretty_number($USER['new_message'])) : 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'], 'ov_news' => $LNG['ov_news'], 'fcm_moon' => $LNG['fcm_moon'], 'ov_server_time' => $LNG['ov_server_time'], 'ov_planet' => $LNG['ov_planet'], 'ov_planetmenu' => $LNG['ov_planetmenu'], 'ov_diameter' => $LNG['ov_diameter'], 'ov_distance_unit' => $LNG['ov_distance_unit'], 'ov_developed_fields' => $LNG['ov_developed_fields'], 'ov_max_developed_fields' => $LNG['ov_max_developed_fields'], 'ov_fields' => $LNG['ov_fields'], 'ov_temperature' => $LNG['ov_temperature'], 'ov_aprox' => $LNG['ov_aprox'], 'ov_temp_unit' => $LNG['ov_temp_unit'], 'ov_to' => $LNG['ov_to'], 'ov_position' => $LNG['ov_position'], 'ov_points' => $LNG['ov_points'], 'ov_events' => $LNG['ov_events'], 'ov_admins_online' => $LNG['ov_admins_online'], 'ov_no_admins_online' => $LNG['ov_no_admins_online'], 'ov_userbanner' => $LNG['ov_userbanner'], 'ov_teamspeak' => $LNG['ov_teamspeak'], 'ov_your_planet' => $LNG['ov_your_planet'], 'ov_coords' => $LNG['ov_coords'], 'ov_planet_name' => $LNG['ov_planet_name'], 'ov_actions' => $LNG['ov_actions'], 'ov_abandon_planet' => $LNG['ov_abandon_planet'], 'ov_planet_rename' => $LNG['ov_planet_rename'], 'ov_planet_rename_action' => $LNG['ov_planet_rename_action'], 'ov_password' => $LNG['ov_password'], 'ov_with_pass' => $LNG['ov_with_pass'], 'ov_security_confirm' => $LNG['ov_security_confirm'], 'ov_security_request' => $LNG['ov_security_request'], 'ov_delete_planet' => $LNG['ov_delete_planet'], 'ov_planet_abandoned' => $LNG['ov_planet_abandoned'], 'path' => PROTOCOL . $_SERVER['HTTP_HOST'] . HTTP_ROOT));
    $template->show("overview_body.tpl");
}
function exceptionHandler($exception)
{
    global $CONF;
    if (!headers_sent()) {
        if (!class_exists('HTTP', false)) {
            require_once 'includes/classes/HTTP.class.php';
        }
        HTTP::sendHeader('HTTP/1.1 503 Service Unavailable');
    }
    if (method_exists($exception, 'getSeverity')) {
        $errno = $exception->getSeverity();
    } else {
        $errno = E_USER_ERROR;
    }
    $errorType = array(E_ERROR => 'ERROR', E_WARNING => 'WARNING', E_PARSE => 'PARSING ERROR', E_NOTICE => 'NOTICE', E_CORE_ERROR => 'CORE ERROR', E_CORE_WARNING => 'CORE WARNING', E_COMPILE_ERROR => 'COMPILE ERROR', E_COMPILE_WARNING => 'COMPILE WARNING', E_USER_ERROR => 'USER ERROR', E_USER_WARNING => 'USER WARNING', E_USER_NOTICE => 'USER NOTICE', E_STRICT => 'STRICT NOTICE', E_RECOVERABLE_ERROR => 'RECOVERABLE ERROR');
    try {
        if (!class_exists('Config', false)) {
            throw new Exception("No config class");
        }
        $VERSION = Config::get('VERSION');
    } catch (Exception $e) {
        if (file_exists(ROOT_PATH . 'install/VERSION')) {
            $VERSION = file_get_contents(ROOT_PATH . 'install/VERSION') . ' (FILE)';
        } else {
            $VERSION = 'UNKNOWN';
        }
    }
    try {
        if (!class_exists('Config', false)) {
            throw new Exception("No config class");
        }
        $gameName = Config::get('game_name');
    } catch (Exception $e) {
        $gameName = '-';
    }
    $DIR = MODE == 'INSTALL' ? '..' : '.';
    ob_start();
    echo '<!DOCTYPE html>
<!--[if lt IE 7 ]> <html lang="de" class="no-js ie6"> <![endif]-->
<!--[if IE 7 ]>    <html lang="de" class="no-js ie7"> <![endif]-->
<!--[if IE 8 ]>    <html lang="de" class="no-js ie8"> <![endif]-->
<!--[if IE 9 ]>    <html lang="de" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="de" class="no-js"> <!--<![endif]-->
<head>
	<title>' . $errorType[$errno] . '</title>
	<meta name="generator" content="2Moons ' . $VERSION . '">
	<!-- 
		This website is powered by 2Moons ' . $VERSION . '
		2Moons is a free Space Browsergame initially created by Jan Kr�pke and licensed under GNU/GPL.
		2Moons is copyright 2009-2013 of Jan Kröpke. Extensions are copyright of their respective owners.
		Information and contribution at http://2moons.cc/
	-->
	<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body id="overview" class="full">
<style>
body {
    background:#0F0F3D;
    color:#ffffff;
    font-family:courier;
    font-size:12pt;
    text-align:center;
    margin:100px;
}

blink {
    color:yellow;
}

.neg {
    background:#fff;
    color:#0F0F3D;
    padding:2px 8px;
    font-weight:bold;
}

p {
    margin:30px 100px;
    text-align:left;
}

a,a:hover {
    color:inherit;
    font:inherit;
}

.menu {
    text-align:center;
    margin-top:50px;
}
</style>

<span class="neg">' . $errorType[$errno] . '</span>
<p>Seems something went wrong! Copy paste this error and send via Support Ticket, so we can fix this issue.</p>

		<p class="left">
			<b>Issue: </b>' . $exception->getMessage() . '<br>
			<b>File: </b>' . $exception->getFile() . ' (Line ' . $exception->getLine() . ')<br>
			<b>URL: </b>' . PROTOCOL . HTTP_HOST . $_SERVER['REQUEST_URI'] . '<br>
			<b>PHP: Version </b>' . PHP_VERSION . ' [ ' . php_sapi_name() . ' ]<br>
			<b>MySQL: </b>' . mysqli_get_client_info() . '<br><br>
			<b>Debug Track:</b><br>' . makebr(htmlspecialchars($exception->getTraceAsString())) . '
		</p>

		<div class="menu">
<a href="' . $DIR . '/game.php">Return to Game</a> | 
<a href="' . $DIR . '/game.php?page=ticket">Contact Support Ticket</a> 
</div>

</body>
</html>';
    echo str_replace(array('\\', ROOT_PATH, substr(ROOT_PATH, 0, 15)), array('/', '/', 'FILEPATH '), ob_get_clean());
    $errorText = date("[d-M-Y H:i:s]", TIMESTAMP) . ' ' . $errorType[$errno] . ': "' . strip_tags($exception->getMessage()) . "\"\r\n";
    $errorText .= 'File: ' . $exception->getFile() . ' | Line: ' . $exception->getLine() . "\r\n";
    $errorText .= 'URL: ' . PROTOCOL . HTTP_HOST . $_SERVER['REQUEST_URI'] . ' | Version: ' . $VERSION . "\r\n";
    $errorText .= "Stack trace:\r\n";
    $errorText .= str_replace(ROOT_PATH, '/', htmlspecialchars(str_replace('\\', '/', $exception->getTraceAsString()))) . "\r\n";
    if (is_writable('includes/error.log')) {
        file_put_contents('includes/error.log', $errorText, FILE_APPEND);
    }
}
Example #29
0
function GetLogs($fromRev)
{
    global $LNG;
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_AUTOREFERER, true);
    curl_setopt($ch, CURLOPT_URL, 'http://2moons.googlecode.com/svn/trunk/');
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type' => 'text/xml', 'Depth' => 1));
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'REPORT');
    curl_setopt($ch, CURLOPT_USERAGENT, "2Moons Update API");
    curl_setopt($ch, CURLOPT_CRLF, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, sprintf('<?xml version="1.0" encoding="utf-8"?> <S:log-report xmlns:S="svn:"> <S:start-revision>%d</S:start-revision><S:end-revision>%d</S:end-revision><S:path></S:path><S:discover-changed-paths/></S:log-report>', $fromRev, -1));
    $DATA = curl_exec($ch);
    curl_close($ch);
    if (function_exists('xml_parser_create')) {
        $xml2Array = new xml2Array();
        $arrOutput = $xml2Array->xmlParse($DATA);
        if ((array) $arrOutput['children'] === $arrOutput['children']) {
            $fileLogs = array();
            foreach ($arrOutput['children'] as $value) {
                if (empty($value['children'])) {
                    continue;
                }
                $array = array();
                $array['add'] = array();
                $array['edit'] = array();
                $array['del'] = array();
                foreach ($value['children'] as $entry) {
                    if ($entry['name'] == 'D:VERSION-NAME') {
                        $array['version'] = $entry['tagData'];
                    }
                    if ($entry['name'] == 'D:CREATOR-DISPLAYNAME') {
                        $array['author'] = $entry['tagData'];
                    }
                    if ($entry['name'] == 'S:DATE') {
                        $array['date'] = _date($LNG['php_tdformat'], strtotime($entry['tagData']), $USER['timezone']);
                    }
                    if ($entry['name'] == 'D:COMMENT') {
                        $array['comment'] = makebr($entry['tagData']);
                    }
                    if ($entry['name'] == 'S:ADDED-PATH' || $entry['name'] == 'S:MODIFIED-PATH' || $entry['name'] == 'S:DELETED-PATH') {
                        if (strpos($entry['tagData'], 'trunk/') === false) {
                            continue;
                        } else {
                            $entry['tagData'] = substr($entry['tagData'], 7);
                        }
                        if ($entry['name'] == 'S:ADDED-PATH') {
                            $array['add'][] = $entry['tagData'];
                        }
                        if ($entry['name'] == 'S:MODIFIED-PATH') {
                            $array['edit'][] = $entry['tagData'];
                        }
                        if ($entry['name'] == 'S:DELETED-PATH') {
                            $array['del'][] = $entry['tagData'];
                        }
                    }
                }
                array_push($fileLogs, $array);
            }
        } else {
            $fileLogs = array(array('error' => $LNG['up_offline']));
        }
    } else {
        $fileLogs = array(array('error' => $LNG['up_no_xml_ext']));
    }
    return $fileLogs;
}
Example #30
0
function exceptionHandler($exception)
{
    /** @var $exception ErrorException|Exception */
    if (!headers_sent()) {
        if (!class_exists('HTTP', false)) {
            require_once 'includes/classes/HTTP.class.php';
        }
        HTTP::sendHeader('HTTP/1.1 503 Service Unavailable');
    }
    if (method_exists($exception, 'getSeverity')) {
        $errno = $exception->getSeverity();
    } else {
        $errno = E_USER_ERROR;
    }
    $errorType = array(E_ERROR => 'ERROR', E_WARNING => 'WARNING', E_PARSE => 'PARSING ERROR', E_NOTICE => 'NOTICE', E_CORE_ERROR => 'CORE ERROR', E_CORE_WARNING => 'CORE WARNING', E_COMPILE_ERROR => 'COMPILE ERROR', E_COMPILE_WARNING => 'COMPILE WARNING', E_USER_ERROR => 'USER ERROR', E_USER_WARNING => 'USER WARNING', E_USER_NOTICE => 'USER NOTICE', E_STRICT => 'STRICT NOTICE', E_RECOVERABLE_ERROR => 'RECOVERABLE ERROR');
    if (file_exists(ROOT_PATH . 'install/VERSION')) {
        $VERSION = file_get_contents(ROOT_PATH . 'install/VERSION') . ' (FILE)';
    } else {
        $VERSION = 'UNKNOWN';
    }
    $gameName = '-';
    if (MODE !== 'INSTALL') {
        try {
            $config = Config::get();
            $gameName = $config->game_name;
            $VERSION = $config->VERSION;
        } catch (ErrorException $e) {
        }
    }
    $DIR = MODE == 'INSTALL' ? '..' : '.';
    ob_start();
    echo '<!DOCTYPE html>
<!--[if lt IE 7 ]> <html lang="de" class="no-js ie6"> <![endif]-->
<!--[if IE 7 ]>    <html lang="de" class="no-js ie7"> <![endif]-->
<!--[if IE 8 ]>    <html lang="de" class="no-js ie8"> <![endif]-->
<!--[if IE 9 ]>    <html lang="de" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="de" class="no-js"> <!--<![endif]-->
<head>
	<title>' . $gameName . ' - ' . $errorType[$errno] . '</title>
	<meta name="generator" content="2Moons ' . $VERSION . '">
	<!-- 
		This website is powered by 2Moons ' . $VERSION . '
		2Moons is a free Space Browsergame initially created by Jan Kröpke and licensed under GNU/GPL.
		2Moons is copyright 2009-2013 of Jan Kröpke. Extensions are copyright of their respective owners.
		Information and contribution at http://2moons.cc/
	-->
	<meta http-equiv="content-type" content="text/html; charset=UTF-8">
	<link rel="stylesheet" type="text/css" href="' . $DIR . '/styles/resource/css/base/boilerplate.css?v=' . $VERSION . '">
	<link rel="stylesheet" type="text/css" href="' . $DIR . '/styles/resource/css/ingame/main.css?v=' . $VERSION . '">
	<link rel="stylesheet" type="text/css" href="' . $DIR . '/styles/resource/css/base/jquery.css?v=' . $VERSION . '">
	<link rel="stylesheet" type="text/css" href="' . $DIR . '/styles/theme/gow/formate.css?v=' . $VERSION . '">
	<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon">
	<script type="text/javascript">
	var ServerTimezoneOffset = -3600;
	var serverTime 	= new Date(2012, 2, 12, 14, 43, 36);
	var startTime	= serverTime.getTime();
	var localTime 	= serverTime;
	var localTS 	= startTime;
	var Gamename	= document.title;
	var Ready		= "Fertig";
	var Skin		= "' . $DIR . '/styles/theme/gow/";
	var Lang		= "de";
	var head_info	= "Information";
	var auth		= 3;
	var days 		= ["So","Mo","Di","Mi","Do","Fr","Sa"] 
	var months 		= ["Jan","Feb","Mar","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez"] ;
	var tdformat	= "[M] [D] [d] [H]:[i]:[s]";
	var queryString	= "";

	setInterval(function() {
		serverTime.setSeconds(serverTime.getSeconds()+1);
	}, 1000);
	</script>
	<script type="text/javascript" src="' . $DIR . '/scripts/base/jquery.js?v=2123"></script>
	<script type="text/javascript" src="' . $DIR . '/scripts/base/jquery.ui.js?v=2123"></script>
	<script type="text/javascript" src="' . $DIR . '/scripts/base/jquery.cookie.js?v=2123"></script>
	<script type="text/javascript" src="' . $DIR . '/scripts/base/jquery.fancybox.js?v=2123"></script>
	<script type="text/javascript" src="' . $DIR . '/scripts/base/jquery.validationEngine.js?v=2123"></script>
	<script type="text/javascript" src="' . $DIR . '/scripts/base/tooltip.js?v=2123"></script>
	<script type="text/javascript" src="' . $DIR . '/scripts/game/base.js?v=2123"></script>
</head>
<body id="overview" class="full">
<table width="960">
	<tr>
		<th>' . $errorType[$errno] . '</th>
	</tr>
	<tr>
		<td class="left">
			<b>Message: </b>' . $exception->getMessage() . '<br>
			<b>File: </b>' . $exception->getFile() . '<br>
			<b>Line: </b>' . $exception->getLine() . '<br>
			<b>URL: </b>' . PROTOCOL . HTTP_HOST . $_SERVER['REQUEST_URI'] . '<br>
			<b>PHP-Version: </b>' . PHP_VERSION . '<br>
			<b>PHP-API: </b>' . php_sapi_name() . '<br>
			<b>MySQL-Cleint-Version: </b>' . mysqli_get_client_info() . '<br>
			<b>2Moons Version: </b>' . $VERSION . '<br>
			<b>Debug Backtrace:</b><br>' . makebr(htmlspecialchars($exception->getTraceAsString())) . '
		</td>
	</tr>
</table>
</body>
</html>';
    echo str_replace(array('\\', ROOT_PATH, substr(ROOT_PATH, 0, 15)), array('/', '/', 'FILEPATH '), ob_get_clean());
    $errorText = date("[d-M-Y H:i:s]", TIMESTAMP) . ' ' . $errorType[$errno] . ': "' . strip_tags($exception->getMessage()) . "\"\r\n";
    $errorText .= 'File: ' . $exception->getFile() . ' | Line: ' . $exception->getLine() . "\r\n";
    $errorText .= 'URL: ' . PROTOCOL . HTTP_HOST . $_SERVER['REQUEST_URI'] . ' | Version: ' . $VERSION . "\r\n";
    $errorText .= "Stack trace:\r\n";
    $errorText .= str_replace(ROOT_PATH, '/', htmlspecialchars(str_replace('\\', '/', $exception->getTraceAsString()))) . "\r\n";
    if (is_writable('includes/error.log')) {
        file_put_contents('includes/error.log', $errorText, FILE_APPEND);
    }
}