コード例 #1
0
ファイル: ShowRecordsPage.php プロジェクト: sonicmaster/RPG
function ShowRecordsPage()
{
    global $USER, $PLANET, $LNG, $resource, $db, $CONF, $UNI;
    $PlanetRess = new ResourceUpdate();
    $PlanetRess->CalcResource();
    $PlanetRess->SavePlanetToDB();
    $template = new template();
    $Records = new records();
    $RecordsArray = $Records->GetRecords($UNI);
    foreach ($RecordsArray as $ElementID => $ElementIDArray) {
        if ($ElementID >= 1 && $ElementID <= 39 || $ElementID == 44) {
            $Builds[$LNG['tech'][$ElementID]] = array('winner' => $ElementIDArray['maxlvl'] != 0 ? $ElementIDArray['username'] : $LNG['rec_rien'], 'count' => $ElementIDArray['maxlvl'] != 0 ? pretty_number($ElementIDArray['maxlvl']) : $LNG['rec_rien']);
        } elseif ($ElementID >= 41 && $ElementID <= 99 && $ElementID != 44) {
            $MoonsBuilds[$LNG['tech'][$ElementID]] = array('winner' => $ElementIDArray['maxlvl'] != 0 ? $ElementIDArray['username'] : $LNG['rec_rien'], 'count' => $ElementIDArray['maxlvl'] != 0 ? pretty_number($ElementIDArray['maxlvl']) : $LNG['rec_rien']);
        } elseif ($ElementID >= 101 && $ElementID <= 199) {
            $Techno[$LNG['tech'][$ElementID]] = array('winner' => $ElementIDArray['maxlvl'] != 0 ? $ElementIDArray['username'] : $LNG['rec_rien'], 'count' => $ElementIDArray['maxlvl'] != 0 ? pretty_number($ElementIDArray['maxlvl']) : $LNG['rec_rien']);
        } elseif ($ElementID >= 201 && $ElementID <= 399) {
            $Fleet[$LNG['tech'][$ElementID]] = array('winner' => $ElementIDArray['maxlvl'] != 0 ? $ElementIDArray['username'] : $LNG['rec_rien'], 'count' => $ElementIDArray['maxlvl'] != 0 ? pretty_number($ElementIDArray['maxlvl']) : $LNG['rec_rien']);
        } elseif ($ElementID >= 401 && $ElementID <= 599) {
            $Defense[$LNG['tech'][$ElementID]] = array('winner' => $ElementIDArray['maxlvl'] != 0 ? $ElementIDArray['username'] : $LNG['rec_rien'], 'count' => $ElementIDArray['maxlvl'] != 0 ? pretty_number($ElementIDArray['maxlvl']) : $LNG['rec_rien']);
        }
    }
    $Records = array($LNG['rec_build'] => $Builds, $LNG['rec_specb'] => $MoonsBuilds, $LNG['rec_techn'] => $Techno, $LNG['rec_fleet'] => $Fleet, $LNG['rec_defes'] => $Defense);
    $template->assign_vars(array('Records' => $Records, 'update' => sprintf($LNG['rec_last_update_on'], date(TDFORMAT, $CONF['stat_last_update'])), 'level' => $LNG['rec_level'], 'player' => $LNG['rec_playe']));
    $template->show("records_overview.tpl");
}
コード例 #2
0
ファイル: ShowTopKB.php プロジェクト: sonicmaster/RPG
/**
 _  \_/ |\ | /¯¯\ \  / /\    |¯¯) |_¯ \  / /¯¯\ |  |   |´¯|¯` | /¯¯\ |\ |5
 ¯  /¯\ | \| \__/  \/ /--\   |¯¯\ |__  \/  \__/ |__ \_/   |   | \__/ | \|Core.
 * @author: Copyright (C) 2011 by Brayan Narvaez (Prinick) developer of xNova Revolution
 * @link: http://www.xnovarevolution.con.ar

 * @package 2Moons
 * @author Slaver <*****@*****.**>
 * @copyright 2009 Lucky <*****@*****.**> (XGProyecto)
 * @copyright 2011 Slaver <*****@*****.**> (Fork/2Moons)
 * @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License
 * @version 1.3 (2011-01-21)
 * @link http://code.google.com/p/2moons/

 * Please do not remove the credits
*/
function ShowTopKB()
{
    global $USER, $PLANET, $LNG, $UNI, $db, $LANG;
    $mode = request_var('mode', '');
    $template = new template();
    switch ($mode) {
        case "showkb":
            $template->isPopup(true);
            $LANG->includeLang(array('FLEET'));
            $ReportID = request_var('rid', '');
            if (file_exists(ROOT_PATH . 'raports/topkb_' . $ReportID . '.php')) {
                require_once ROOT_PATH . 'raports/topkb_' . $ReportID . '.php';
                $RaportRAW = $db->uniquequery("SELECT `angreifer`, `defender` FROM " . TOPKB . " WHERE `rid` = '" . $db->sql_escape($ReportID) . "';");
            }
            foreach ($LNG['tech_rc'] as $id => $s_name) {
                $ship[] = "[ship[" . $id . "]]";
                $shipname[] = $s_name;
            }
            $template->assign_vars(array('attacker' => $RaportRAW['angreifer'], 'defender' => $RaportRAW['defender'], 'report' => $raport));
            $template->show("topkb_report.tpl");
            break;
        default:
            $PlanetRess = new ResourceUpdate();
            $PlanetRess->CalcResource();
            $PlanetRess->SavePlanetToDB();
            $top = $db->query("SELECT * FROM " . TOPKB . " WHERE `universe` = '" . $UNI . "' ORDER BY gesamtunits DESC LIMIT 100;");
            while ($data = $db->fetch_array($top)) {
                $TopKBList[] = array('result' => $data['fleetresult'], 'time' => date(TDFORMAT, $data['time']), 'units' => pretty_number($data['gesamtunits']), 'rid' => $data['rid'], 'attacker' => $data['angreifer'], 'defender' => $data['defender'], 'result' => $data['fleetresult']);
            }
            $db->free_result($top);
            $template->assign_vars(array('tkb_units' => $LNG['tkb_units'], 'tkb_datum' => $LNG['tkb_datum'], 'tkb_owners' => $LNG['tkb_owners'], 'tkb_platz' => $LNG['tkb_platz'], 'tkb_top' => $LNG['tkb_top'], 'tkb_gratz' => $LNG['tkb_gratz'], 'tkb_legende' => $LNG['tkb_legende'], 'tkb_gewinner' => $LNG['tkb_gewinner'], 'tkb_verlierer' => $LNG['tkb_verlierer'], 'TopKBList' => $TopKBList));
            $template->show("topkb_overview.tpl");
            break;
    }
}
コード例 #3
0
ファイル: ShowTechTreePage.php プロジェクト: sonicmaster/RPG
/**
 _  \_/ |\ | /¯¯\ \  / /\    |¯¯) |_¯ \  / /¯¯\ |  |   |´¯|¯` | /¯¯\ |\ |5
 ¯  /¯\ | \| \__/  \/ /--\   |¯¯\ |__  \/  \__/ |__ \_/   |   | \__/ | \|Core.
 * @author: Copyright (C) 2011 by Brayan Narvaez (Prinick) developer of xNova Revolution
 * @link: http://www.xnovarevolution.con.ar

 * @package 2Moons
 * @author Slaver <*****@*****.**>
 * @copyright 2009 Lucky <*****@*****.**> (XGProyecto)
 * @copyright 2011 Slaver <*****@*****.**> (Fork/2Moons)
 * @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License
 * @version 1.3 (2011-01-21)
 * @link http://code.google.com/p/2moons/

 * Please do not remove the credits
*/
function ShowTechTreePage()
{
    global $resource, $requeriments, $LNG, $reslist, $USER, $PLANET;
    $PlanetRess = new ResourceUpdate();
    $PlanetRess->CalcResource();
    $PlanetRess->SavePlanetToDB();
    $template = new template();
    $RequeriList = array();
    foreach ($LNG['tech'] as $Element => $ElementName) {
        if (in_array($Element, $reslist['dmfunc'])) {
            continue;
        }
        if (!isset($resource[$Element])) {
            $TechTreeList[] = $ElementName;
        } else {
            $RequeriList = array();
            if (isset($requeriments[$Element])) {
                foreach ($requeriments[$Element] as $RegID => $RedCount) {
                    $RequeriList[$Element][] = array('id' => $RegID, 'count' => $RedCount, 'own' => isset($PLANET[$resource[$RegID]]) ? $PLANET[$resource[$RegID]] : $USER[$resource[$RegID]]);
                }
            }
            $TechTreeList[] = array('id' => $Element, 'name' => $ElementName, 'need' => $RequeriList);
        }
    }
    $template->assign_vars(array('TechTreeList' => $TechTreeList, 'tt_requirements' => $LNG['tt_requirements'], 'LNG' => $LNG['tech'], 'tt_lvl' => $LNG['tt_lvl']));
    $template->show("techtree_overview.tpl");
}
コード例 #4
0
/**
 _  \_/ |\ | /¯¯\ \  / /\    |¯¯) |_¯ \  / /¯¯\ |  |   |´¯|¯` | /¯¯\ |\ |5
 ¯  /¯\ | \| \__/  \/ /--\   |¯¯\ |__  \/  \__/ |__ \_/   |   | \__/ | \|Core.
 * @author: Copyright (C) 2011 by Brayan Narvaez (Prinick) developer of xNova Revolution
 * @link: http://www.xnovarevolution.con.ar

 * @package 2Moons
 * @author Slaver <*****@*****.**>
 * @copyright 2009 Lucky <*****@*****.**> (XGProyecto)
 * @copyright 2011 Slaver <*****@*****.**> (Fork/2Moons)
 * @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License
 * @version 1.3 (2011-01-21)
 * @link http://code.google.com/p/2moons/

 * Please do not remove the credits
*/
function ShowFleetTraderPage()
{
    global $USER, $PLANET, $LNG, $CONF, $pricelist, $resource;
    $PlanetRess = new ResourceUpdate();
    $PlanetRess->CalcResource();
    $CONF['trade_allowed_ships'] = explode(',', $CONF['trade_allowed_ships']);
    $ID = request_var('id', 0);
    if (!empty($ID) && in_array($ID, $CONF['trade_allowed_ships'])) {
        $Count = max(min(request_var('count', '0'), $PLANET[$resource[$ID]]), 0);
        $PLANET['metal'] = bcadd($PLANET['metal'], bcmul($Count, bcmul($pricelist[$ID]['metal'], (double) (1 - $CONF['trade_charge']))));
        $PLANET['crystal'] = bcadd($PLANET['crystal'], bcmul($Count, bcmul($pricelist[$ID]['crystal'], (double) (1 - $CONF['trade_charge']))));
        $PLANET['deuterium'] = bcadd($PLANET['deuterium'], bcmul($Count, bcmul($pricelist[$ID]['deuterium'], (double) (1 - $CONF['trade_charge']))));
        $PLANET['norio'] = bcadd($PLANET['norio'], bcmul($Count, bcmul($pricelist[$ID]['norio'], (double) (1 - $CONF['trade_charge']))));
        $USER['darkmatter'] = bcadd($USER['darkmatter'], bcmul($Count, bcmul($pricelist[$ID]['darkmatter'], (double) (1 - $CONF['trade_charge']))));
        $PlanetRess->Builded[$ID] = bcadd(bcmul('-1', $Count), $PlanetRess->Builded[$ID]);
    }
    $PlanetRess->SavePlanetToDB();
    $template = new template();
    $template->loadscript('fleettrader.js');
    $template->execscript('updateVars();');
    $Cost = array();
    foreach ($CONF['trade_allowed_ships'] as $ID) {
        $Cost[$ID] = array($PLANET[$resource[$ID]], $pricelist[$ID]['metal'], $pricelist[$ID]['crystal'], $pricelist[$ID]['deuterium'], $pricelist[$ID]['darkmatter'], $pricelist[$ID]['norio']);
    }
    $template->assign_vars(array('tech' => $LNG['tech'], 'ft_head' => $LNG['ft_head'], 'ft_count' => $LNG['ft_count'], 'ft_max' => $LNG['ft_max'], 'ft_total' => $LNG['ft_total'], 'ft_charge' => $LNG['ft_charge'], 'ft_absenden' => $LNG['ft_absenden'], 'trade_allowed_ships' => $CONF['trade_allowed_ships'], 'CostInfos' => json_encode($Cost), 'Charge' => $CONF['trade_charge']));
    $template->show("fleettrader_overview.tpl");
}
コード例 #5
0
 public function __construct()
 {
     global $CONF, $dpath, $LNG, $db, $USER, $PLANET;
     $mode = request_var('mode', '');
     $msg = request_var('msg', '', true);
     $ctype = request_var('chat_type', '');
     $MessageID = request_var('id', 0);
     switch ($mode) {
         case "delete":
             $this->DelMeassageFromChat($MessageID);
             break;
         case "send":
             $this->SetMeassageInChat($ctype, $msg);
             break;
         case "call":
             $this->GetMessages($ctype);
             break;
         default:
             $template = new template();
             $template->execscript("showMessage();setInterval(showMessage, 10000);");
             $template->loadscript("chat.js");
             if (empty($ctype)) {
                 $PlanetRess = new ResourceUpdate();
                 $PlanetRess->CalcResource();
                 $PlanetRess->SavePlanetToDB();
             } else {
                 $template->isPopup(true);
             }
             $template->assign_vars(array('ctype' => $ctype, 'chat_send' => $LNG['chat_send'], 'chat_disc' => $LNG['chat_disc'], 'chat_message' => $LNG['chat_message'], 'chat_bbcode' => $LNG['chat_bbcode'], 'chat_fontcolor' => $LNG['chat_fontcolor'], 'chat_color_white' => $LNG['chat_color_white'], 'chat_color_blue' => $LNG['chat_color_blue'], 'chat_color_yellow' => $LNG['chat_color_yellow'], 'chat_color_green' => $LNG['chat_color_green'], 'chat_color_pink' => $LNG['chat_color_pink'], 'chat_color_red' => $LNG['chat_color_red'], 'chat_color_orange' => $LNG['chat_color_orange'], 'chat_notext' => $LNG['chat_notext'], 'chat_request_url' => $LNG['chat_request_url'], 'chat_request_url_desc' => $LNG['chat_request_url_desc']));
             $template->show("chat_overview.tpl");
             break;
     }
 }
コード例 #6
0
ファイル: ShowCreditsPage.php プロジェクト: sonicmaster/RPG
/**
 _  \_/ |\ | /¯¯\ \  / /\    |¯¯) |_¯ \  / /¯¯\ |  |   |´¯|¯` | /¯¯\ |\ |5
 ¯  /¯\ | \| \__/  \/ /--\   |¯¯\ |__  \/  \__/ |__ \_/   |   | \__/ | \|Core.
 * @author: Copyright (C) 2011 by Brayan Narvaez (Prinick) developer of xNova Revolution
 * @link: http://www.xnovarevolution.con.ar
 *
 * Please do not remove the credits
*/
function ShowCreditsPage()
{
    global $USER, $PLANET, $LNG, $LANG;
    $PlanetRess = new ResourceUpdate();
    $PlanetRess->CalcResource();
    $PlanetRess->SavePlanetToDB();
    $template = new template();
    $template->show("creditos_overview.tpl");
}
コード例 #7
0
ファイル: ShowChangelogPage.php プロジェクト: sonicmaster/RPG
/**
 _  \_/ |\ | /¯¯\ \  / /\    |¯¯) |_¯ \  / /¯¯\ |  |   |´¯|¯` | /¯¯\ |\ |5
 ¯  /¯\ | \| \__/  \/ /--\   |¯¯\ |__  \/  \__/ |__ \_/   |   | \__/ | \|Core.
 * @author: Copyright (C) 2011 by Brayan Narvaez (Prinick) developer of xNova Revolution
 * @link: http://www.xnovarevolution.con.ar

 * @package 2Moons
 * @author Slaver <*****@*****.**>
 * @copyright 2009 Lucky <*****@*****.**> (XGProyecto)
 * @copyright 2011 Slaver <*****@*****.**> (Fork/2Moons)
 * @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License
 * @version 1.3 (2011-01-21)
 * @link http://code.google.com/p/2moons/

 * Please do not remove the credits
*/
function ShowChangelogPage()
{
    global $USER, $PLANET, $LNG, $LANG;
    $PlanetRess = new ResourceUpdate();
    $PlanetRess->CalcResource();
    $PlanetRess->SavePlanetToDB();
    $template = new template();
    $LANG->includeLang(array('CHANGELOG'));
    $template->assign_vars(array('ChangelogList' => array_map('makebr', $LNG['changelog']), 'Version' => $LNG['Version'], 'Description' => $LNG['Description']));
    $template->show("changelog_overview.tpl");
}
コード例 #8
0
ファイル: ShowFAQ.php プロジェクト: sonicmaster/RPG
/**
 *  2Moons
 *  Copyright (C) 2011  Slaver
 *
 * 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 Slaver <*****@*****.**>
 * @copyright 2009 Lucky <*****@*****.**> (XGProyecto)
 * @copyright 2011 Slaver <*****@*****.**> (Fork/2Moons)
 * @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License
 * @version 1.3 (2011-01-21)
 * @link http://code.google.com/p/2moons/
 */
function ShowFAQPage()
{
    global $USER, $PLANET, $LNG, $LANG;
    $PlanetRess = new ResourceUpdate();
    $PlanetRess->CalcResource();
    $PlanetRess->SavePlanetToDB();
    $template = new template();
    $LANG->includeLang(array('FAQ'));
    $template->assign_vars(array('FAQList' => $LNG['faq'], 'faq_overview' => $LNG['faq_overview']));
    $template->show("faq_overview.tpl");
}
コード例 #9
0
ファイル: ShowSearchPage.php プロジェクト: sonicmaster/RPG
function ShowSearchPage()
{
    global $USER, $PLANET, $dpath, $LNG, $db;
    $PlanetRess = new ResourceUpdate();
    $PlanetRess->CalcResource();
    $PlanetRess->SavePlanetToDB();
    $template = new template();
    $template->page_header();
    $template->page_topnav();
    $template->page_leftmenu();
    $template->page_planetmenu();
    $template->page_footer();
    $type = request_var('type', '');
    $searchtext = request_var('searchtext', '');
    switch ($type) {
        case 'playername':
            $search = $db->query("SELECT a.id, a.username, a.ally_id, a.ally_name, a.galaxy, a.system, a.planet, b.name, c.total_rank FROM " . USERS . " as a LEFT JOIN " . PLANETS . " as b ON b.id = a.id_planet LEFT JOIN " . STATPOINTS . " as c ON c.stat_type = 1 AND c.id_owner = a.id WHERE a.username LIKE '%" . $db->sql_escape($searchtext, true) . "%' LIMIT 25;");
            while ($s = $db->fetch_array($search)) {
                $SearchResult[] = array('planetname' => $s['name'], 'username' => $s['username'], 'userid' => $s['id'], 'allyname' => $s['ally_name'], 'allyid' => $s['ally_id'], 'galaxy' => $s['galaxy'], 'system' => $s['system'], 'planet' => $s['planet'], 'rank' => $s['total_rank']);
            }
            $db->free_result($search);
            break;
        case 'planetname':
            $search = $db->query("SELECT a.name, a.galaxy, a.planet, a.system, b.ally_name, b.id, b.ally_id, b.username, c.total_rank FROM " . PLANETS . " as a LEFT JOIN " . USERS . " as b ON b.id = a.id_owner LEFT JOIN  " . STATPOINTS . " as c ON c.stat_type = 1 AND c.id_owner = b.id  WHERE a.name LIKE '%" . $db->sql_escape($searchtext, true) . "%' LIMIT 25;");
            while ($s = $db->fetch_array($search)) {
                $SearchResult[] = array('planetname' => $s['name'], 'username' => $s['username'], 'userid' => $s['id'], 'allyname' => $s['ally_name'], 'allyid' => $s['ally_id'], 'galaxy' => $s['galaxy'], 'system' => $s['system'], 'planet' => $s['planet'], 'rank' => $s['total_rank']);
            }
            $db->free_result($search);
            break;
        case "allytag":
            $search = $db->query("SELECT a.ally_name, a.ally_tag, a.ally_members, b.total_points FROM " . ALLIANCE . " as a, " . STATPOINTS . " as b WHERE b.stat_type = 1 AND b.id_owner = a.id AND a.ally_tag LIKE '%" . $db->sql_escape($searchtext, true) . "%' LIMIT 25;");
            while ($s = $db->fetch_array($search)) {
                $SearchResult[] = array('allypoints' => pretty_number($s['total_points']), 'allytag' => $s['ally_tag'], 'allymembers' => $s['ally_members'], 'allyname' => $s['ally_name']);
            }
            $db->free_result($search);
            break;
        case "allyname":
            $search = $db->query("SELECT a.ally_name, a.ally_tag, a.ally_members, b.total_points FROM " . ALLIANCE . " as a, " . STATPOINTS . " as b WHERE b.stat_type = 1 AND b.id_owner = a.id AND a.ally_name LIKE '%" . $db->sql_escape($searchtext, true) . "%' LIMIT 25;");
            while ($s = $db->fetch_array($search)) {
                $SearchResult[] = array('allypoints' => pretty_number($s['total_points']), 'allytag' => $s['ally_tag'], 'allymembers' => $s['ally_members'], 'allyname' => $s['ally_name']);
            }
            $db->free_result($search);
            break;
    }
    $SeachTypes = array("playername" => $LNG['sh_player_name'], "planetname" => $LNG['sh_planet_name'], "allytag" => $LNG['sh_alliance_tag'], "allyname" => $LNG['sh_alliance_name']);
    $template->assign_vars(array('SearchResult' => $SearchResult, 'SeachTypes' => $SeachTypes, 'SeachInput' => $searchtext, 'SeachType' => $type, 'sh_search' => $LNG['sh_search'], 'sh_search_in_the_universe' => $LNG['sh_search_in_the_universe'], 'sh_buddy_request' => $LNG['sh_buddy_request'], 'sh_write_message' => $LNG['sh_write_message'], 'sh_name' => $LNG['sh_name'], 'sh_alliance' => $LNG['sh_alliance'], 'sh_planet' => $LNG['sh_planet'], 'sh_coords' => $LNG['sh_coords'], 'sh_position' => $LNG['sh_position'], 'sh_tag' => $LNG['sh_tag'], 'sh_members' => $LNG['sh_members'], 'sh_points' => $LNG['sh_points']));
    $template->show("search_body.tpl");
}
コード例 #10
0
ファイル: ShowBannedPage.php プロジェクト: sonicmaster/RPG
/**
 _  \_/ |\ | /¯¯\ \  / /\    |¯¯) |_¯ \  / /¯¯\ |  |   |´¯|¯` | /¯¯\ |\ |5
 ¯  /¯\ | \| \__/  \/ /--\   |¯¯\ |__  \/  \__/ |__ \_/   |   | \__/ | \|Core.
 * @author: Copyright (C) 2011 by Brayan Narvaez (Prinick) developer of xNova Revolution
 * @link: http://www.xnovarevolution.con.ar

 * @package 2Moons
 * @author Slaver <*****@*****.**>
 * @copyright 2009 Lucky <*****@*****.**> (XGProyecto)
 * @copyright 2011 Slaver <*****@*****.**> (Fork/2Moons)
 * @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License
 * @version 1.3 (2011-01-21)
 * @link http://code.google.com/p/2moons/

 * Please do not remove the credits
*/
function ShowBannedPage()
{
    global $USER, $PLANET, $LNG, $db;
    $PlanetRess = new ResourceUpdate();
    $PlanetRess->CalcResource();
    $PlanetRess->SavePlanetToDB();
    $template = new template();
    $query = $db->query("SELECT * FROM " . BANNED . " ORDER BY `id`;");
    $PrangerList = array();
    while ($u = $db->fetch_array($query)) {
        $PrangerList[] = array('player' => $u['who'], 'theme' => $u['theme'], 'from' => date(TDFORMAT, $u['time']), 'to' => date(TDFORMAT, $u['longer']), 'admin' => $u['author'], 'mail' => $u['email'], 'info' => sprintf($LNG['bn_writemail'], $u['author']));
    }
    $db->free_result($query);
    $template->assign_vars(array('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->show("banned_overview.tpl");
}
コード例 #11
0
ファイル: ShowFAQ.php プロジェクト: sonicmaster/RPG
function ShowFAQPage()
{
    global $USER, $PLANET, $LNG;
    $PlanetRess = new ResourceUpdate();
    $PlanetRess->CalcResource();
    $PlanetRess->SavePlanetToDB();
    $template = new template();
    $template->page_header();
    $template->page_topnav();
    $template->page_leftmenu();
    $template->page_planetmenu();
    $template->page_footer();
    includeLang('FAQ');
    $template->assign_vars(array('FAQList' => $LNG['faq'], 'faq_overview' => $LNG['faq_overview']));
    $template->show("faq_overview.tpl");
}
コード例 #12
0
ファイル: ShowImperiumPage.php プロジェクト: sonicmaster/RPG
function ShowImperiumPage()
{
    global $LNG, $USER, $PLANET, $resource, $reslist, $db;
    $PlanetRess = new ResourceUpdate();
    $PlanetRess->CalcResource();
    $PlanetRess->SavePlanetToDB();
    $template = new template();
    $template->loadscript("trader.js");
    $template->page_topnav();
    $template->page_header();
    $template->page_leftmenu();
    $template->page_planetmenu();
    $template->page_footer();
    $SQLArray = array_merge($reslist['build'], $reslist['fleet'], $reslist['defense']);
    $Query = "";
    foreach ($SQLArray as $id => $gid) {
        $Query .= ",`" . $resource[$gid] . "`";
    }
    if ($USER['planet_sort'] == 0) {
        $Order = "`id` ";
    } elseif ($USER['planet_sort'] == 1) {
        $Order = "`galaxy`, `system`, `planet`, `planet_type` ";
    } elseif ($USER['planet_sort'] == 2) {
        $Order = "`name` ";
    }
    $Order .= $USER['planet_sort_order'] == 1 ? "DESC" : "ASC";
    $PlanetsRAW = $db->query("\r\n\tSELECT `id`,`name`,`galaxy`,`system`,`planet`,`planet_type`,\r\n\t`image`,`field_current`,`field_max`,`metal`,`crystal`,`deuterium`,\r\n\t`energy_used`,`energy_max` " . $Query . " FROM " . PLANETS . " WHERE `id_owner` = '" . $USER['id'] . "' AND `destruyed` = '0' ORDER BY " . $Order . ";");
    while ($Planet = $db->fetch_array($PlanetsRAW)) {
        $InfoList = array('id' => $Planet['id'], 'name' => $Planet['name'], 'image' => $Planet['image'], 'galaxy' => $Planet['galaxy'], 'system' => $Planet['system'], 'planet' => $Planet['planet'], 'field_current' => $Planet['field_current'], 'field_max' => CalculateMaxPlanetFields($Planet), 'metal' => pretty_number($Planet['metal']), 'crystal' => pretty_number($Planet['crystal']), 'deuterium' => pretty_number($Planet['deuterium']), 'energy_used' => pretty_number($Planet['energy_max'] + $Planet['energy_used']), 'energy_max' => pretty_number($Planet['energy_max']));
        foreach ($reslist['build'] as $gid) {
            $BuildsList[$gid] = pretty_number($Planet[$resource[$gid]]);
        }
        foreach ($reslist['fleet'] as $gid) {
            $FleetsList[$gid] = pretty_number($Planet[$resource[$gid]]);
        }
        foreach ($reslist['defense'] as $gid) {
            $DefensesList[$gid] = pretty_number($Planet[$resource[$gid]]);
        }
        $PlanetsList[] = array('InfoList' => $InfoList, 'BuildsList' => $BuildsList, 'FleetsList' => $FleetsList, 'DefensesList' => $DefensesList);
    }
    foreach ($reslist['tech'] as $gid) {
        $ResearchList[$gid] = pretty_number($USER[$resource[$gid]]);
    }
    $template->assign_vars(array('colspan' => count($PlanetsList) + 1, 'PlanetsList' => $PlanetsList, 'ResearchList' => $ResearchList, 'iv_imperium_title' => $LNG['iv_imperium_title'], 'iv_planet' => $LNG['iv_planet'], 'iv_name' => $LNG['iv_name'], 'iv_coords' => $LNG['iv_coords'], 'iv_fields' => $LNG['iv_fields'], 'iv_resources' => $LNG['iv_resources'], 'Metal' => $LNG['Metal'], 'Crystal' => $LNG['Crystal'], 'Deuterium' => $LNG['Deuterium'], 'Energy' => $LNG['Energy'], 'iv_buildings' => $LNG['iv_buildings'], 'iv_technology' => $LNG['iv_technology'], 'iv_ships' => $LNG['iv_ships'], 'iv_defenses' => $LNG['iv_defenses'], 'tech' => $LNG['tech'], 'build' => $reslist['build'], 'fleet' => $reslist['fleet'], 'defense' => $reslist['defense'], 'research' => $reslist['tech']));
    $template->show("empire_overview.tpl");
}
コード例 #13
0
ファイル: ShowOverviewPage.php プロジェクト: sonicmaster/RPG
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");
}
コード例 #14
0
ファイル: ShowSupportPage.php プロジェクト: sonicmaster/RPG
 public function ShowSupportPage()
 {
     $action = request_var('action', "");
     $id = request_var('id', 0);
     $PlanetRess = new ResourceUpdate();
     $PlanetRess->CalcResource();
     $PlanetRess->SavePlanetToDB();
     switch ($action) {
         case 'newticket':
             $this->CreaeTicket();
             break;
         case 'send':
             $this->UpdateTicket($id);
             break;
         default:
             $this->ShowSupportTickets();
             break;
     }
 }
コード例 #15
0
 public function __construct()
 {
     global $USER, $PLANET, $resource, $reslist, $LNG, $db, $ExtraDM;
     $action = request_var('action', '');
     $Offi = request_var('offi', 0);
     $Extra = request_var('extra', 0);
     $PlanetRess = new ResourceUpdate();
     $PlanetRess->CalcResource();
     if ($action == "send" && $USER['urlaubs_modus'] == 0) {
         if (!empty($Offi) && !CheckModule(8)) {
             $this->UpdateOfficier($Offi);
         } elseif (!empty($Extra) && !CheckModule(18)) {
             $this->UpdateExtra($Extra);
         }
     }
     $PlanetRess->SavePlanetToDB();
     $template = new template();
     $template->loadscript('officier.js');
     $template->page_header();
     $template->page_topnav();
     $template->page_leftmenu();
     $template->page_planetmenu();
     $template->page_footer();
     if (!CheckModule(8)) {
         foreach ($reslist['dmfunc'] as $Element) {
             if ($USER[$resource[$Element]] > TIMESTAMP) {
                 $template->execscript("GetOfficerTime(" . $Element . ", " . ($USER[$resource[$Element]] - TIMESTAMP) . ");");
             }
             $ExtraDMList[] = array('id' => $Element, 'active' => $USER[$resource[$Element]] - TIMESTAMP, 'price' => pretty_number($ExtraDM[$Element]['darkmatter']), 'isok' => $USER['darkmatter'] - $ExtraDM[$Element]['darkmatter'] >= 0 ? true : false, 'time' => pretty_time($ExtraDM[$Element]['time'] * 3600), 'name' => $LNG['tech'][$Element], 'desc' => sprintf($LNG['res']['descriptions'][$Element], $ExtraDM[$Element]['add'] * 100));
         }
     }
     if (!CheckModule(18)) {
         foreach ($reslist['officier'] as $Element) {
             if (($Result = $this->IsOfficierAccessible($Element)) === 0) {
                 continue;
             }
             $OfficierList[] = array('id' => $Element, 'level' => $USER[$resource[$Element]], 'name' => $LNG['tech'][$Element], 'desc' => $LNG['res']['descriptions'][$Element], 'Result' => $Result);
         }
     }
     $template->assign_vars(array('ExtraDMList' => $ExtraDMList, 'OfficierList' => $OfficierList, 'user_darkmatter' => floor($USER['darkmatter'] / DM_PRO_OFFICIER_LEVEL), 'of_max_lvl' => $LNG['of_max_lvl'], 'of_recruit' => $LNG['of_recruit'], 'of_darkmatter' => sprintf($LNG['of_points_per_thousand_darkmatter'], DM_PRO_OFFICIER_LEVEL, $LNG['Darkmatter']), 'of_available_points' => $LNG['of_available_points'], 'alv_points' => $LNG['alv_points'], 'of_lvl' => $LNG['of_lvl'], 'in_dest_durati' => $LNG['in_dest_durati'], 'of_still' => $LNG['of_still'], 'of_active' => $LNG['of_active'], 'of_update' => $LNG['of_update'], 'in_dest_durati' => $LNG['in_dest_durati'], 'of_dm_trade' => sprintf($LNG['of_dm_trade'], $LNG['Darkmatter'])));
     $template->show("officier_overview.tpl");
 }
コード例 #16
0
ファイル: class.bot.php プロジェクト: joancefet/Beta7
 function Play()
 {
     $this->getPlanet();
     $PlanetRess = new ResourceUpdate();
     list($this->USER, $this->PLANET) = $PlanetRess->CalcResource($this->USER, $this->PLANET);
     if ($this->getChance(self::CHANCE_BUILD)) {
         self::log("Success Chance: Build");
         if ($this->getChance(self::CHANCE_BUILD_ECO)) {
             $this->BuildEco();
         }
         if ($this->getPlanetResource(4) <= 5 && $this->getChance(self::CHANCE_BUILD_SPECIAL)) {
             $this->BuildSpecialBuildings();
         }
     }
     self::log("Lab Level: " . $this->getPlanetResource(31));
     if ($this->getPlanetResource(31) > 0 && $this->getChance(self::CHANCE_TECH)) {
         self::log("Success Chance: Tech");
         $this->ResearchTechs();
     }
     self::log("Roboter Level: " . $this->getPlanetResource(14));
     self::log("Shipyard Level: " . $this->getPlanetResource(21));
     if ($this->getPlanetResource(21) > 0 && $this->getChance(self::CHANCE_SHIPYARD)) {
         self::log("Success Chance: Shipyard");
         $this->BuildShipyard();
     }
     if ($this->getChance(self::CHANCE_FLEETS_COLONIZE)) {
         if ($this->Colonizeable()) {
             $this->Colonize();
         }
     }
     /* 		if(self::BOTS_ALLOW_SAVE && (self::BOTS_SAVE_FROM <= $Hour || self::BOTS_SAVE_TO > $Hour) && $this->getChance(self::CHANCE_FLEETS_SAVE)) {
     			$this->SaveFleets();
     		} */
     $PlanetRess->SavePlanetToDB($this->USER, $this->PLANET);
     $this->saveBot();
 }
コード例 #17
0
ファイル: ShowResourcesPage.php プロジェクト: sonicmaster/RPG
/**
 *  2Moons
 *  Copyright (C) 2011  Slaver
 *
 * 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 Slaver <*****@*****.**>
 * @copyright 2009 Lucky <*****@*****.**> (XGProyecto)
 * @copyright 2011 Slaver <*****@*****.**> (Fork/2Moons)
 * @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License
 * @version 1.3 (2011-01-21)
 * @link http://code.google.com/p/2moons/
 */
function ShowResourcesPage()
{
    global $LNG, $ProdGrid, $resource, $reslist, $CONF, $db, $ExtraDM, $USER, $PLANET, $OfficerInfo;
    if ($PLANET['planet_type'] == 3 || $USER['urlaubs_modus'] == 1) {
        $CONF['metal_basic_income'] = 0;
        $CONF['crystal_basic_income'] = 0;
        $CONF['deuterium_basic_income'] = 0;
    }
    $SubQry = "";
    if ($_POST && $USER['urlaubs_modus'] == 0) {
        foreach ($_POST as $Field => $Value) {
            $FieldName = $Field . "_porcent";
            if (isset($PLANET[$FieldName]) && in_array($Value, $reslist['procent'])) {
                $Value = $Value / 10;
                $PLANET[$FieldName] = $Value;
                $SubQry .= ", `" . $FieldName . "` = '" . $Value . "'";
            }
        }
        if (isset($SubQry)) {
            $QryUpdatePlanet = "UPDATE " . PLANETS . " SET ";
            $QryUpdatePlanet .= "`id` = '" . $PLANET['id'] . "' ";
            $QryUpdatePlanet .= $SubQry;
            $QryUpdatePlanet .= "WHERE ";
            $QryUpdatePlanet .= "`id` = '" . $PLANET['id'] . "';";
            $db->query($QryUpdatePlanet);
        }
        redirectTo("game.php?page=resources");
        exit;
    }
    $PlanetRess = new ResourceUpdate();
    $PlanetRess->CalcResource();
    $PlanetRess->SavePlanetToDB();
    $template = new template();
    if ($PLANET['energy_max'] == 0 && $PLANET['energy_used'] > 0) {
        $post_porcent = 0;
    } elseif ($PLANET['energy_max'] > 0 && abs($PLANET['energy_used']) > $PLANET['energy_max']) {
        $post_porcent = floor($PLANET['energy_max'] / ($PLANET['energy_used'] * -1) * 100);
    } elseif ($PLANET['energy_max'] == 0 && abs($PLANET['energy_used']) > $PLANET['energy_max']) {
        $post_porcent = 0;
    } else {
        $post_porcent = 100;
    }
    if ($post_porcent > 100) {
        $post_porcent = 100;
    }
    $BuildTemp = $PLANET['temp_max'];
    $BuildEnergy = $USER[$resource[113]];
    $metal = array();
    $crystal = array();
    $deuterium = array();
    $deu_en = array();
    $energy = array();
    $energy_en = array();
    foreach ($reslist['prod'] as $ProdID) {
        if ($PLANET[$resource[$ProdID]] > 0 && isset($ProdGrid[$ProdID])) {
            $BuildLevelFactor = $PLANET[$resource[$ProdID] . "_porcent"];
            $BuildLevel = $PLANET[$resource[$ProdID]];
            $metal[$ProdID] = floor(eval($ProdGrid[$ProdID]['formule']['metal']) * (0.01 * $post_porcent) * $CONF['resource_multiplier']);
            $crystal[$ProdID] = floor(eval($ProdGrid[$ProdID]['formule']['crystal']) * (0.01 * $post_porcent) * $CONF['resource_multiplier']);
            if ($ProdID < 4) {
                $deuterium[$ProdID] = floor(eval($ProdGrid[$ProdID]['formule']['deuterium']) * (0.01 * $post_porcent) * $CONF['resource_multiplier']);
                $energy[$ProdID] = floor(eval($ProdGrid[$ProdID]['formule']['energy']) * $CONF['resource_multiplier']);
            } else {
                if ($ProdID == 12 && $PLANET['deuterium'] == 0) {
                    continue;
                }
                $deu_en[$ProdID] = floor(eval($ProdGrid[$ProdID]['formule']['deuterium']) * $CONF['resource_multiplier']);
                $energy_en[$ProdID] = floor(eval($ProdGrid[$ProdID]['formule']['energy']) * $CONF['resource_multiplier']);
            }
            $thisdeu = isset($deuterium[$ProdID]) ? $deuterium[$ProdID] : $deu_en[$ProdID];
            $thisenergy = isset($energy[$ProdID]) ? $energy[$ProdID] : $energy_en[$ProdID];
            $CurrPlanetList[] = array('name' => $resource[$ProdID], 'type' => $LNG['tech'][$ProdID], 'level' => $ProdID > 200 ? $LNG['rs_amount'] : $LNG['rs_lvl'], 'level_type' => $PLANET[$resource[$ProdID]], 'metal_type' => colorNumber(pretty_number($metal[$ProdID])), 'crystal_type' => colorNumber(pretty_number($crystal[$ProdID])), 'deuterium_type' => colorNumber(pretty_number($thisdeu)), 'energy_type' => colorNumber(pretty_number($thisenergy)), 'optionsel' => $PLANET[$resource[$ProdID] . "_porcent"] * 10);
        }
    }
    $metal_total = $PLANET['metal_perhour'] + $CONF['metal_basic_income'] * $CONF['resource_multiplier'];
    $crystal_total = $PLANET['crystal_perhour'] + $CONF['crystal_basic_income'] * $CONF['resource_multiplier'];
    $deuterium_total = $PLANET['deuterium_perhour'] + $CONF['deuterium_basic_income'] * $CONF['resource_multiplier'];
    $energy_total = $PLANET['energy_max'] + $CONF['energy_basic_income'] * $CONF['resource_multiplier'] - abs($PLANET['energy_used']);
    foreach ($reslist['procent'] as $procent) {
        $OptionSelector[$procent] = $procent . "%";
    }
    $template->assign_vars(array('bonus_metal' => colorNumber(pretty_number(array_sum($metal) * ($USER['rpg_geologue'] * $OfficerInfo[601]['info'] + $USER['metal_proc_tech'] * 0.02 + (TIMESTAMP - $USER[$resource[703]] <= 0 ? $ExtraDM[703]['add'] : 0)))), 'bonus_crystal' => colorNumber(pretty_number(array_sum($crystal) * ($USER['rpg_geologue'] * $OfficerInfo[601]['info'] + $USER['crystal_proc_tech'] * 0.02 + (TIMESTAMP - $USER[$resource[703]] <= 0 ? $ExtraDM[703]['add'] : 0)))), 'bonus_deuterium' => colorNumber(pretty_number(array_sum($deuterium) * ($USER['rpg_geologue'] * $OfficerInfo[601]['info'] + $USER['deuterium_proc_tech'] * 0.02 + (TIMESTAMP - $USER[$resource[703]] <= 0 ? $ExtraDM[703]['add'] : 0)))), 'bonus_energy' => colorNumber(pretty_number(array_sum($energy_en) * ($USER['rpg_ingenieur'] * $OfficerInfo[603]['info'] + (TIMESTAMP - $USER[$resource[704]] <= 0 ? $ExtraDM[704]['add'] : 0)))), 'CurrPlanetList' => $CurrPlanetList, 'Production_of_resources_in_the_planet' => str_replace('%s', $PLANET['name'], $LNG['rs_production_on_planet']), 'metal_basic_income' => $CONF['metal_basic_income'] * $CONF['resource_multiplier'], 'crystal_basic_income' => $CONF['crystal_basic_income'] * $CONF['resource_multiplier'], 'deuterium_basic_income' => $CONF['deuterium_basic_income'] * $CONF['resource_multiplier'], 'energy_basic_income' => $CONF['energy_basic_income'] * $CONF['resource_multiplier'], 'metalmax' => colorNumber($PLANET['metal_max'] / 1000, pretty_number($PLANET['metal_max'] / 1000) . "k"), 'crystalmax' => colorNumber($PLANET['crystal_max'] / 1000, pretty_number($PLANET['crystal_max'] / 1000) . "k"), 'deuteriummax' => colorNumber($PLANET['deuterium_max'] / 1000, pretty_number($PLANET['deuterium_max'] / 1000) . "k"), 'metal_total' => colorNumber(pretty_number($metal_total)), 'crystal_total' => colorNumber(pretty_number($crystal_total)), 'option' => $OptionSelector, 'deuterium_total' => colorNumber(pretty_number($deuterium_total)), 'energy_total' => colorNumber(pretty_number($energy_total)), 'daily_metal' => colorNumber(pretty_number(floor($metal_total * 24))), 'weekly_metal' => colorNumber(pretty_number(floor($metal_total * 24 * 7))), 'daily_crystal' => colorNumber(pretty_number(floor($crystal_total * 24))), 'weekly_crystal' => colorNumber(pretty_number(floor($crystal_total * 24 * 7))), 'daily_deuterium' => colorNumber(pretty_number(floor($deuterium_total * 24))), 'weekly_deuterium' => colorNumber(pretty_number(floor($deuterium_total * 24 * 7))), 'Metal' => $LNG['Metal'], 'Crystal' => $LNG['Crystal'], 'Deuterium' => $LNG['Deuterium'], 'Energy' => $LNG['Energy'], 'rs_basic_income' => $LNG['rs_basic_income'], 'rs_storage_capacity' => $LNG['rs_storage_capacity'], 'rs_sum' => $LNG['rs_sum'], 'rs_daily' => $LNG['rs_daily'], 'rs_weekly' => $LNG['rs_weekly'], 'rs_calculate' => $LNG['rs_calculate'], 'rs_ress_bonus' => $LNG['rs_ress_bonus']));
    $template->show("resources_overview.tpl");
}
コード例 #18
0
 public function SetNextQueueTechOnTop()
 {
     global $resource, $LNG;
     if (empty($this->USER['b_tech_queue'])) {
         $this->USER['b_tech'] = 0;
         $this->USER['b_tech_id'] = 0;
         $this->USER['b_tech_planet'] = 0;
         $this->USER['b_tech_queue'] = '';
         return false;
     }
     $CurrentQueue = unserialize($this->USER['b_tech_queue']);
     $Loop = true;
     while ($Loop == true) {
         $ListIDArray = $CurrentQueue[0];
         if ($ListIDArray[4] != $this->PLANET['id']) {
             $PLANET = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . PLANETS . " WHERE id = '" . $ListIDArray[4] . "';");
         } else {
             $PLANET = $this->PLANET;
         }
         $PLANET[$resource[31] . '_inter'] = self::getNetworkLevel($this->USER, $PLANET);
         $Element = $ListIDArray[0];
         $Level = $ListIDArray[1];
         $costRessources = BuildFunctions::getElementPrice($this->USER, $PLANET, $Element);
         $BuildTime = BuildFunctions::getBuildingTime($this->USER, $PLANET, $Element, $costRessources);
         $HaveRessources = BuildFunctions::isElementBuyable($this->USER, $PLANET, $Element, $costRessources);
         $BuildEndTime = $this->USER['b_tech'] + $BuildTime;
         $CurrentQueue[0] = array($Element, $Level, $BuildTime, $BuildEndTime, $PLANET['id']);
         $isAnotherPlanet = $ListIDArray[4] != $this->PLANET['id'];
         if ($isAnotherPlanet) {
             $IsHash = !in_array($Element, array(131, 132, 133));
             $RPLANET = new ResourceUpdate(true, false);
             list(, $PLANET) = $RPLANET->CalcResource($this->USER, $PLANET, false, $this->USER['b_tech'], $IsHash);
         }
         if ($HaveRessources == true) {
             if (isset($costRessources[901])) {
                 $PLANET[$resource[901]] -= $costRessources[901];
             }
             if (isset($costRessources[902])) {
                 $PLANET[$resource[902]] -= $costRessources[902];
             }
             if (isset($costRessources[903])) {
                 $PLANET[$resource[903]] -= $costRessources[903];
             }
             if (isset($costRessources[904])) {
                 $PLANET[$resource[904]] -= $costRessources[904];
             }
             if (isset($costRessources[921])) {
                 $this->USER[$resource[921]] -= $costRessources[921];
             }
             $this->USER['b_tech_id'] = $Element;
             $this->USER['b_tech'] = $BuildEndTime;
             $this->USER['b_tech_planet'] = $PLANET['id'];
             $this->USER['b_tech_queue'] = serialize($CurrentQueue);
             $Loop = false;
         } else {
             if ($this->USER['hof'] == 1) {
                 if (!isset($costRessources[901])) {
                     $costRessources[901] = 0;
                 }
                 if (!isset($costRessources[902])) {
                     $costRessources[902] = 0;
                 }
                 if (!isset($costRessources[903])) {
                     $costRessources[903] = 0;
                 }
                 if (!isset($costRessources[904])) {
                     $costRessources[904] = 0;
                 }
                 $Message = sprintf($LNG['sys_notenough_money'], $PLANET['name'], $PLANET['id'], $PLANET['galaxy'], $PLANET['system'], $PLANET['planet'], $LNG['tech'][$Element], pretty_number($PLANET['metal']), $LNG['tech'][901], pretty_number($PLANET['crystal']), $LNG['tech'][902], pretty_number($PLANET['deuterium']), $LNG['tech'][903], pretty_number($costRessources[901]), $LNG['tech'][901], pretty_number($costRessources[902]), $LNG['tech'][902], pretty_number($costRessources[903]), $LNG['tech'][903], pretty_number($costRessources[904]), $LNG['tech'][904]);
                 SendSimpleMessage($this->USER['id'], 0, $this->USER['b_tech'], 99, $LNG['sys_techlist'], $LNG['sys_buildlist_fail'], $Message);
             }
             array_shift($CurrentQueue);
             if (count($CurrentQueue) == 0) {
                 $this->USER['b_tech'] = 0;
                 $this->USER['b_tech_id'] = 0;
                 $this->USER['b_tech_planet'] = 0;
                 $this->USER['b_tech_queue'] = '';
                 $Loop = false;
             } else {
                 $BaseTime = $BuildEndTime - $BuildTime;
                 $NewQueue = array();
                 foreach ($CurrentQueue as $ListIDArray) {
                     $ListIDArray[2] = BuildFunctions::getBuildingTime($this->USER, $PLANET, $ListIDArray[0]);
                     $BaseTime += $ListIDArray[2];
                     $ListIDArray[3] = $BaseTime;
                     $NewQueue[] = $ListIDArray;
                 }
                 $CurrentQueue = $NewQueue;
             }
         }
         if ($isAnotherPlanet) {
             $RPLANET->SavePlanetToDB($this->USER, $PLANET);
         } else {
             $this->PLANET = $PLANET;
         }
     }
 }
コード例 #19
0
 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;
     }
 }
コード例 #20
0
 public function SetNextQueueTechOnTop()
 {
     global $resource, $LNG;
     if (empty($this->USER['b_tech_queue'])) {
         $this->USER['b_tech'] = 0;
         $this->USER['b_tech_id'] = 0;
         $this->USER['b_tech_planet'] = 0;
         $this->USER['b_tech_queue'] = '';
         return false;
     }
     $CurrentQueue = unserialize($this->USER['b_tech_queue']);
     $Loop = true;
     while ($Loop == true) {
         $ListIDArray = $CurrentQueue[0];
         $isAnotherPlanet = $ListIDArray[4] != $this->PLANET['id'];
         if ($isAnotherPlanet) {
             $sql = 'SELECT * FROM %%PLANETS%% WHERE id = :planetId;';
             $PLANET = Database::get()->selectSingle($sql, array(':planetId' => $ListIDArray[4]));
             $RPLANET = new ResourceUpdate(true, false);
             list(, $PLANET) = $RPLANET->CalcResource($this->USER, $PLANET, false, $this->USER['b_tech']);
         } else {
             $PLANET = $this->PLANET;
         }
         $PLANET[$resource[31] . '_inter'] = self::getNetworkLevel($this->USER, $PLANET);
         $Element = $ListIDArray[0];
         $Level = $ListIDArray[1];
         $costResources = BuildFunctions::getElementPrice($this->USER, $PLANET, $Element);
         $BuildTime = BuildFunctions::getBuildingTime($this->USER, $PLANET, $Element, $costResources);
         $HaveResources = BuildFunctions::isElementBuyable($this->USER, $PLANET, $Element, $costResources);
         $BuildEndTime = $this->USER['b_tech'] + $BuildTime;
         $CurrentQueue[0] = array($Element, $Level, $BuildTime, $BuildEndTime, $PLANET['id']);
         if ($HaveResources == true) {
             if (isset($costResources[901])) {
                 $PLANET[$resource[901]] -= $costResources[901];
             }
             if (isset($costResources[902])) {
                 $PLANET[$resource[902]] -= $costResources[902];
             }
             if (isset($costResources[903])) {
                 $PLANET[$resource[903]] -= $costResources[903];
             }
             if (isset($costResources[921])) {
                 $this->USER[$resource[921]] -= $costResources[921];
             }
             $this->USER['b_tech_id'] = $Element;
             $this->USER['b_tech'] = $BuildEndTime;
             $this->USER['b_tech_planet'] = $PLANET['id'];
             $this->USER['b_tech_queue'] = serialize($CurrentQueue);
             $Loop = false;
         } else {
             if ($this->USER['hof'] == 1) {
                 if (!isset($costResources[901])) {
                     $costResources[901] = 0;
                 }
                 if (!isset($costResources[902])) {
                     $costResources[902] = 0;
                 }
                 if (!isset($costResources[903])) {
                     $costResources[903] = 0;
                 }
                 $Message = sprintf($LNG['sys_notenough_money'], $PLANET['name'], $PLANET['id'], $PLANET['galaxy'], $PLANET['system'], $PLANET['planet'], $LNG['tech'][$Element], pretty_number($PLANET['metal']), $LNG['tech'][901], pretty_number($PLANET['crystal']), $LNG['tech'][902], pretty_number($PLANET['deuterium']), $LNG['tech'][903], pretty_number($costResources[901]), $LNG['tech'][901], pretty_number($costResources[902]), $LNG['tech'][902], pretty_number($costResources[903]), $LNG['tech'][903]);
                 PlayerUtil::sendMessage($this->USER['id'], 0, $this->USER['b_tech'], 99, $LNG['sys_techlist'], $LNG['sys_buildlist_fail'], $Message);
             }
             array_shift($CurrentQueue);
             if (count($CurrentQueue) == 0) {
                 $this->USER['b_tech'] = 0;
                 $this->USER['b_tech_id'] = 0;
                 $this->USER['b_tech_planet'] = 0;
                 $this->USER['b_tech_queue'] = '';
                 $Loop = false;
             } else {
                 $BaseTime = $BuildEndTime - $BuildTime;
                 $NewQueue = array();
                 foreach ($CurrentQueue as $ListIDArray) {
                     $ListIDArray[2] = BuildFunctions::getBuildingTime($this->USER, $PLANET, $ListIDArray[0]);
                     $BaseTime += $ListIDArray[2];
                     $ListIDArray[3] = $BaseTime;
                     $NewQueue[] = $ListIDArray;
                 }
                 $CurrentQueue = $NewQueue;
             }
         }
         if ($isAnotherPlanet) {
             $RPLANET->SavePlanetToDB($this->USER, $PLANET);
             $RPLANET = NULL;
             unset($RPLANET);
         } else {
             $this->PLANET = $PLANET;
         }
     }
     return true;
 }
コード例 #21
0
 public function __construct()
 {
     global $USER, $PLANET, $CONF, $LNG, $LANG, $UNI, $db, $SESSION, $THEME;
     $mode = request_var('mode', '');
     $exit = request_var('exit_modus', '');
     $db_deaktjava = request_var('db_deaktjava', '');
     $PlanetRess = new ResourceUpdate();
     $PlanetRess->CalcResource();
     $PlanetRess->SavePlanetToDB();
     $template = new template();
     $SQLQuery = "";
     switch ($mode) {
         case "exit":
             if ($exit == 'on' and $USER['urlaubs_until'] <= TIMESTAMP) {
                 $SQLQuery .= "UPDATE " . USERS . " SET `urlaubs_modus` = '0', `urlaubs_until` = '0' WHERE `id` = '" . $USER['id'] . "' LIMIT 1;UPDATE " . PLANETS . " SET `last_update` = '" . TIMESTAMP . "', `energy_used` = '10', `energy_max` = '10', `metal_mine_porcent` = '10', `crystal_mine_porcent` = '10', `deuterium_sintetizer_porcent` = '10', `solar_plant_porcent` = '10', `fusion_plant_porcent` = '10', `solar_satelit_porcent` = '10' WHERE `id_owner` = '" . $USER["id"] . "';";
             }
             $SQLQuery .= $db_deaktjava == 'on' ? "UPDATE " . USERS . " SET `db_deaktjava` = '" . TIMESTAMP . "' WHERE `id` = '" . $USER['id'] . "' LIMIT 1;" : "UPDATE " . USERS . " SET `db_deaktjava` = '0' WHERE `id` = '" . $USER['id'] . "' LIMIT 1;";
             $db->multi_query($SQLQuery);
             $template->message($LNG['op_options_changed'], '?page=options', 1);
             break;
         case "change":
             $design = request_var('design', '');
             $noipcheck = request_var('noipcheck', '');
             $USERname = request_var('db_character', $USER['username'], UTF8_SUPPORT);
             $db_email = request_var('db_email', $USER['email']);
             $spio_anz = max(request_var('spio_anz', 5), 1);
             $settings_tooltiptime = request_var('settings_tooltiptime', 1);
             $settings_fleetactions = max(request_var('settings_fleetactions', 1), 1);
             $settings_planetmenu = request_var('settings_planetmenu', '');
             $settings_esp = request_var('settings_esp', '');
             $settings_wri = request_var('settings_wri', '');
             $settings_bud = request_var('settings_bud', '');
             $settings_mis = request_var('settings_mis', '');
             $settings_rep = request_var('settings_rep', '');
             $settings_tnstor = request_var('settings_tnstor', '');
             $urlaubs_modus = request_var('urlaubs_modus', '');
             $SetSort = request_var('settings_sort', 0);
             $SetOrder = request_var('settings_order', 0);
             $db_password = request_var('db_password', '');
             $newpass1 = request_var('newpass1', '');
             $newpass2 = request_var('newpass2', '');
             $hof = request_var('hof', '');
             $adm_pl_prot = request_var('adm_pl_prot', '');
             $langs = request_var('langs', $LANG->getUser());
             $dpath = request_var('dpath', $THEME->getThemeName());
             $design = $design == 'on' ? 1 : 0;
             $hof = $hof == 'on' ? 1 : 0;
             $noipcheck = $noipcheck == 'on' ? 1 : 0;
             $settings_esp = $settings_esp == 'on' ? 1 : 0;
             $settings_wri = $settings_wri == 'on' ? 1 : 0;
             $settings_bud = $settings_bud == 'on' ? 1 : 0;
             $settings_mis = $settings_mis == 'on' ? 1 : 0;
             $settings_rep = $settings_rep == 'on' ? 1 : 0;
             $settings_tnstor = $settings_tnstor == 'on' ? 1 : 0;
             $settings_planetmenu = $settings_planetmenu == 'on' ? 1 : 0;
             $db_deaktjava = $db_deaktjava == 'on' ? TIMESTAMP : 0;
             $langs = in_array($langs, $LANG->getAllowedLangs()) ? $langs : $LANG->getUser();
             $dpath = in_array($dpath, Theme::getAvalibleSkins()) ? $dpath : $THEME->getThemeName();
             if ($urlaubs_modus == 'on') {
                 if (!$this->CheckVMode()) {
                     $template->message($LNG['op_cant_activate_vacation_mode'], '?page=options', 3);
                     exit;
                 }
                 $SQLQuery .= "UPDATE " . USERS . " SET \r\n\t\t\t\t\t\t\t\t\t`urlaubs_modus` = '1',\r\n\t\t\t\t\t\t\t\t\t`urlaubs_until` = '" . (TIMESTAMP + VACATION_MIN_TIME) . "'\r\n\t\t\t\t\t\t\t\t\tWHERE `id` = '" . $USER["id"] . "';\r\n\t\t\t\t\t\t\t\t\tUPDATE " . PLANETS . " SET\r\n\t\t\t\t\t\t\t\t\t`energy_used` = '0',\r\n\t\t\t\t\t\t\t\t\t`energy_max` = '0',\r\n\t\t\t\t\t\t\t\t\t`metal_mine_porcent` = '0',\r\n\t\t\t\t\t\t\t\t\t`crystal_mine_porcent` = '0',\r\n\t\t\t\t\t\t\t\t\t`deuterium_sintetizer_porcent` = '0',\r\n\t\t\t\t\t\t\t\t\t`solar_plant_porcent` = '0',\r\n\t\t\t\t\t\t\t\t\t`fusion_plant_porcent` = '0',\r\n\t\t\t\t\t\t\t\t\t`solar_satelit_porcent` = '0',\r\n\t\t\t\t\t\t\t\t\t`metal_perhour`    =    '0',\r\n                                    `crystal_perhour`    =    '0',\r\n                                    `deuterium_perhour`    =    '0'\r\n                                    WHERE `id_owner` = '" . $USER["id"] . "';";
             }
             $SQLQuery .= "UPDATE " . USERS . " SET\r\n\t\t\t\t\t\t\t\t`dpath` = '" . $db->sql_escape($dpath) . "',\r\n\t\t\t\t\t\t\t\t`design` = '" . $design . "',\r\n\t\t\t\t\t\t\t\t`noipcheck` = '" . $noipcheck . "',\r\n\t\t\t\t\t\t\t\t`planet_sort` = '" . $SetSort . "',\r\n\t\t\t\t\t\t\t\t`planet_sort_order` = '" . $SetOrder . "',\r\n\t\t\t\t\t\t\t\t`spio_anz` = '" . $spio_anz . "',\r\n\t\t\t\t\t\t\t\t`settings_tooltiptime` = '" . $settings_tooltiptime . "',\r\n\t\t\t\t\t\t\t\t`settings_fleetactions` = '" . $settings_fleetactions . "',\r\n\t\t\t\t\t\t\t\t`settings_planetmenu` = '" . $settings_planetmenu . "',\r\n\t\t\t\t\t\t\t\t`settings_esp` = '" . $settings_esp . "',\r\n\t\t\t\t\t\t\t\t`settings_wri` = '" . $settings_wri . "',\r\n\t\t\t\t\t\t\t\t`settings_bud` = '" . $settings_bud . "',\r\n\t\t\t\t\t\t\t\t`settings_mis` = '" . $settings_mis . "',\r\n\t\t\t\t\t\t\t\t`settings_tnstor` = '" . $settings_tnstor . "',\r\n\t\t\t\t\t\t\t\t`db_deaktjava` = '" . $db_deaktjava . "',\r\n\t\t\t\t\t\t\t\t`lang` = '" . $langs . "',\r\n\t\t\t\t\t\t\t\t`hof` = '" . $hof . "',\r\n\t\t\t\t\t\t\t\t`settings_rep` = '" . $settings_rep . "' \r\n\t\t\t\t\t\t\t\tWHERE `id` = '" . $USER["id"] . "';";
             if ($USER['authlevel'] > 0) {
                 $SQLQuery .= $adm_pl_prot == 'on' ? "UPDATE " . PLANETS . " SET `id_level` = '" . $USER['authlevel'] . "' WHERE `id_owner` = '" . $USER['id'] . "';" : "UPDATE " . PLANETS . " SET `id_level` = '0' WHERE `id_owner` = '" . $USER['id'] . "';";
             }
             if (!empty($db_email) && $db_email != $USER['email'] && md5($db_password) == $USER['password']) {
                 if (!ValidateAddress($db_email)) {
                     $template->message($LNG['op_not_vaild_mail'], '?page=options', 3);
                     exit;
                 }
                 $query = $db->uniquequery("SELECT id FROM " . USERS . " WHERE email = '" . $db->sql_escape($db_email) . "' OR email_2 = '" . $db->sql_escape($db_email) . "';");
                 if (!empty($query)) {
                     $template->message(sprintf($LNG['op_change_mail_exist'], $db_email), '?page=options', 3);
                     exit;
                 }
                 $SQLQuery .= "UPDATE " . USERS . " SET `email` = '" . $db->sql_escape($db_email) . "', `setmail` = '" . (TIMESTAMP + 604800) . "' WHERE `id` = '" . $USER['id'] . "';";
             }
             if (!empty($newpass1) && md5($db_password) == $USER["password"] && $newpass1 == $newpass2) {
                 $newpass = md5($newpass1);
                 $SQLQuery .= "UPDATE " . USERS . " SET `password` = '" . $newpass . "' WHERE `id` = '" . $USER['id'] . "';";
                 $SESSION->DestroySession();
                 $template->message($LNG['op_password_changed'], "index.php", 3);
             } elseif ($USER['username'] != $USERname) {
                 if (!CheckName($USERname)) {
                     $template->message($LNG['op_user_name_no_alphanumeric'], '?page=options', 3);
                 } elseif ($USER['uctime'] >= TIMESTAMP - 60 * 60 * 24 * 7) {
                     $template->message($LNG['op_change_name_pro_week'], '?page=options', 3);
                 } else {
                     $query = $db->uniquequery("SELECT id FROM " . USERS . " WHERE username='******';");
                     if (!empty($query)) {
                         $template->message(sprintf($LNG['op_change_name_exist'], $USERname), '?page=options', 3);
                     } else {
                         require ROOT_PATH . 'includes/classes/class.Records.php';
                         $Records = new records();
                         $RecordsArray = $Records->RenameRecordOwner($USER['username'], $USERname, $UNI);
                         $SQLQuery .= "UPDATE " . USERS . " SET `username` = '" . $db->sql_escape($USERname) . "', `uctime` = '" . TIMESTAMP . "' WHERE `id`= '" . $USER['id'] . "';";
                         $SESSION->DestroySession();
                         $template->message($LNG['op_username_changed'], 'index.php', 3);
                     }
                 }
             } else {
                 $template->message($LNG['op_options_changed'], '?page=options', 3);
             }
             $db->multi_query($SQLQuery);
             break;
         default:
             if ($USER['urlaubs_modus'] == 1) {
                 $template->assign_vars(array('vacation_until' => date(TDFORMAT, $USER['urlaubs_until']), 'op_save_changes' => $LNG['op_save_changes'], 'op_end_vacation_mode' => $LNG['op_end_vacation_mode'], 'op_vacation_mode_active_message' => $LNG['op_vacation_mode_active_message'], 'op_dlte_account_descrip' => $LNG['op_dlte_account_descrip'], 'op_dlte_account' => $LNG['op_dlte_account'], 'opt_delac_data' => $USER['db_deaktjava'], 'is_deak_vacation' => $USER['urlaubs_until'] <= TIMESTAMP ? true : false));
                 $template->show("options_overview_vmode.tpl");
             } else {
                 $template->assign_vars(array('opt_usern_data' => $USER['username'], 'opt_mail1_data' => $USER['email'], 'opt_mail2_data' => $USER['email_2'], 'opt_dpath_data' => $USER['dpath'], 'opt_dpath_data_sel' => substr($USER['dpath'], 13, -1), 'opt_probe_data' => $USER['spio_anz'], 'opt_toolt_data' => $USER['settings_tooltiptime'], 'opt_fleet_data' => $USER['settings_fleetactions'], 'opt_sskin_data' => $USER['design'], 'opt_noipc_data' => $USER['noipcheck'], 'opt_allyl_data' => $USER['settings_planetmenu'], 'opt_delac_data' => $USER['db_deaktjava'], 'opt_stor_data' => $USER['settings_tnstor'], 'user_settings_rep' => $USER['settings_rep'], 'user_settings_esp' => $USER['settings_esp'], 'user_settings_wri' => $USER['settings_wri'], 'user_settings_mis' => $USER['settings_mis'], 'user_settings_bud' => $USER['settings_bud'], 'opt_hof' => $USER['hof'], 'langs' => $USER['lang'], 'adm_pl_prot_data' => $PLANET['id_level'], 'user_authlevel' => $USER['authlevel'], 'Selectors' => array('Sort' => array(0 => $LNG['op_sort_normal'], 1 => $LNG['op_sort_koords'], 2 => $LNG['op_sort_abc']), 'SortUpDown' => array(0 => $LNG['op_sort_up'], 1 => $LNG['op_sort_down']), 'Skins' => Theme::getAvalibleSkins(), 'lang' => $LANG->getAllowedLangs(false)), 'planet_sort' => $USER['planet_sort'], 'planet_sort_order' => $USER['planet_sort_order'], 'uctime' => TIMESTAMP - $USER['uctime'] >= 60 * 60 * 24 * 7 ? true : false, 'op_admin_planets_protection' => $LNG['op_admin_planets_protection'], 'op_admin_title_options' => $LNG['op_admin_title_options'], 'op_user_data' => $LNG['op_user_data'], 'op_username' => $LNG['op_username'], 'op_old_pass' => $LNG['op_old_pass'], 'op_new_pass' => $LNG['op_new_pass'], 'op_repeat_new_pass' => $LNG['op_repeat_new_pass'], 'op_email_adress_descrip' => $LNG['op_email_adress_descrip'], 'op_email_adress' => $LNG['op_email_adress'], 'op_permanent_email_adress' => $LNG['op_permanent_email_adress'], 'op_general_settings' => $LNG['op_general_settings'], 'op_lang' => $LNG['op_lang'], 'op_sort_planets_by' => $LNG['op_sort_planets_by'], 'op_sort_kind' => $LNG['op_sort_kind'], 'op_skin_example' => $LNG['op_skin_example'], 'op_show_skin' => $LNG['op_show_skin'], 'op_active_build_messages' => $LNG['op_active_build_messages'], 'op_deactivate_ipcheck_descrip' => $LNG['op_deactivate_ipcheck_descrip'], 'op_deactivate_ipcheck' => $LNG['op_deactivate_ipcheck'], 'op_galaxy_settings' => $LNG['op_galaxy_settings'], 'op_spy_probes_number_descrip' => $LNG['op_spy_probes_number_descrip'], 'op_spy_probes_number' => $LNG['op_spy_probes_number'], 'op_seconds' => $LNG['op_seconds'], 'op_toolt_data' => $LNG['op_toolt_data'], 'op_max_fleets_messages' => $LNG['op_max_fleets_messages'], 'op_show_planetmenu' => $LNG['op_show_planetmenu'], 'op_shortcut' => $LNG['op_shortcut'], 'op_show' => $LNG['op_show'], 'op_spy' => $LNG['op_spy'], 'op_write_message' => $LNG['op_write_message'], 'op_add_to_buddy_list' => $LNG['op_add_to_buddy_list'], 'op_missile_attack' => $LNG['op_missile_attack'], 'op_send_report' => $LNG['op_send_report'], 'op_vacation_delete_mode' => $LNG['op_vacation_delete_mode'], 'op_activate_vacation_mode_descrip' => $LNG['op_activate_vacation_mode_descrip'], 'op_activate_vacation_mode' => $LNG['op_activate_vacation_mode'], 'op_dlte_account_descrip' => $LNG['op_dlte_account_descrip'], 'op_dlte_account' => $LNG['op_dlte_account'], 'op_save_changes' => $LNG['op_save_changes'], 'op_small_storage' => $LNG['op_small_storage']));
                 $template->show("options_overview.tpl");
             }
             break;
     }
 }
コード例 #22
0
/**
 _  \_/ |\ | /¯¯\ \  / /\    |¯¯) |_¯ \  / /¯¯\ |  |   |´¯|¯` | /¯¯\ |\ |5
 ¯  /¯\ | \| \__/  \/ /--\   |¯¯\ |__  \/  \__/ |__ \_/   |   | \__/ | \|Core.
 * @author: Copyright (C) 2011 by Brayan Narvaez (Prinick) developer of xNova Revolution
 * @link: http://www.xnovarevolution.con.ar

 * @package 2Moons
 * @author Slaver <*****@*****.**>
 * @copyright 2009 Lucky <*****@*****.**> (XGProyecto)
 * @copyright 2011 Slaver <*****@*****.**> (Fork/2Moons)
 * @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License
 * @version 1.3 (2011-01-21)
 * @link http://code.google.com/p/2moons/

 * Please do not remove the credits
*/
function ShowStatisticsPage()
{
    global $USER, $PLANET, $CONF, $dpath, $LNG, $db, $UNI;
    $PlanetRess = new ResourceUpdate();
    $PlanetRess->CalcResource();
    $PlanetRess->SavePlanetToDB();
    $template = new template();
    $who = request_var('who', 1);
    $type = request_var('type', 1);
    $range = request_var('range', 1);
    switch ($type) {
        case 2:
            $Order = "fleet_rank";
            $Points = "fleet_points";
            $Counts = "fleet_count";
            $Rank = "fleet_rank";
            $OldRank = "fleet_old_rank";
            break;
        case 3:
            $Order = "tech_rank";
            $Points = "tech_points";
            $Counts = "tech_count";
            $Rank = "tech_rank";
            $OldRank = "tech_old_rank";
            break;
        case 4:
            $Order = "build_rank";
            $Points = "build_points";
            $Counts = "build_count";
            $Rank = "build_rank";
            $OldRank = "build_old_rank";
            break;
        case 5:
            $Order = "defs_rank";
            $Points = "defs_points";
            $Counts = "defs_count";
            $Rank = "defs_rank";
            $OldRank = "defs_old_rank";
            break;
        default:
            $Order = "total_rank";
            $Points = "total_points";
            $Counts = "total_count";
            $Rank = "total_rank";
            $OldRank = "total_old_rank";
            break;
    }
    switch ($who) {
        case 1:
            $MaxUsers = $CONF['users_amount'];
            $range = min($range, $MaxUsers);
            $LastPage = ceil($MaxUsers / 100);
            for ($Page = 0; $Page < $LastPage; $Page++) {
                $PageValue = $Page * 100 + 1;
                $PageRange = $PageValue + 99;
                $Selector['range'][$PageValue] = $PageValue . "-" . $PageRange;
            }
            $start = max(floor(($range - 1) / 100) * 100, 0);
            $stats_sql = 'SELECT DISTINCT s.*, u.id, u.username, u.ally_id, u.ally_name FROM ' . STATPOINTS . ' as s
			INNER JOIN ' . USERS . ' as u ON u.id = s.id_owner
			WHERE s.`universe` = ' . $UNI . ' AND s.`stat_type` = 1 ' . ($CONF['stat'] == 2 ? 'AND u.`authlevel` < ' . $CONF['stat_level'] . ' ' : '') . '
			ORDER BY `' . $Order . '` ASC LIMIT ' . $start . ',100;';
            $query = $db->query($stats_sql);
            while ($StatRow = $db->fetch_array($query)) {
                $RangeList[] = array('id' => $StatRow['id'], 'name' => $StatRow['username'], 'points' => pretty_number($StatRow[$Points]), 'allyid' => $StatRow['ally_id'], 'rank' => $StatRow[$Rank], 'allyname' => $StatRow['ally_name'], 'ranking' => $StatRow[$OldRank] - $StatRow[$Rank]);
            }
            $db->free_result($query);
            break;
        case 2:
            $MaxAllys = $db->countquery("SELECT COUNT(*) FROM " . ALLIANCE . " WHERE `ally_universe` = '" . $UNI . "';");
            $range = min($range, $MaxAllys);
            $LastPage = ceil($MaxAllys / 100);
            for ($Page = 0; $Page < $LastPage; $Page++) {
                $PageValue = $Page * 100 + 1;
                $PageRange = $PageValue + 99;
                $Selector['range'][$PageValue] = $PageValue . "-" . $PageRange;
            }
            $start = max(floor(($range - 1) / 100) * 100, 0);
            $stats_sql = 'SELECT DISTINCT s.*, a.id, a.ally_members, a.ally_name FROM ' . STATPOINTS . ' as s
			INNER JOIN ' . ALLIANCE . ' as a ON a.id = s.id_owner
			WHERE `universe` = ' . $UNI . ' AND `stat_type` = 2
			ORDER BY `' . $Order . '` ASC LIMIT ' . $start . ',100;';
            $query = $db->query($stats_sql);
            while ($StatRow = $db->fetch_array($query)) {
                $RangeList[] = array('id' => $StatRow['id'], 'name' => $StatRow['ally_name'], 'members' => $StatRow['ally_members'], 'rank' => $StatRow[$Rank], 'mppoints' => pretty_number(floor($StatRow[$Points] / $StatRow['ally_members'])), 'points' => pretty_number($StatRow[$Points]), 'ranking' => $StatRow[$OldRank] - $StatRow[$Rank]);
            }
            $db->free_result($query);
            break;
    }
    $Selector['who'] = array(1 => $LNG['st_player'], 2 => $LNG['st_alliance']);
    $Selector['type'] = array(1 => $LNG['st_points'], 2 => $LNG['st_fleets'], 3 => $LNG['st_researh'], 4 => $LNG['st_buildings'], 5 => $LNG['st_defenses']);
    $template->assign_vars(array('Selectors' => $Selector, 'who' => $who, 'type' => $type, 'range' => floor(($range - 1) / 100) * 100 + 1, 'RangeList' => $RangeList, 'CUser_ally' => $USER['ally_id'], 'CUser_id' => $USER['id'], 'st_members' => $LNG['st_members'], 'st_per_member' => $LNG['st_per_member'], 'st_position' => $LNG['st_position'], 'st_player' => $LNG['st_player'], 'st_alliance' => $LNG['st_alliance'], 'st_write_message' => $LNG['st_write_message'], 'st_points' => $LNG['st_points'], 'st_per' => $LNG['st_per'], 'st_statistics' => $LNG['st_statistics'], 'st_updated' => $LNG['st_updated'], 'stat_date' => date(TDFORMAT, $CONF['stat_last_update']), 'st_show' => $LNG['st_show'], 'st_in_the_positions' => $LNG['st_in_the_positions']));
    $template->show("stat_overview.tpl");
}
コード例 #23
0
 function show()
 {
     global $CONF, $LNG, $PLANET, $USER, $db, $resource, $UNI;
     //$db->query("UPDATE ".USERS." set `res_bonus_time` = 0;");
     $PlanetRess = new ResourceUpdate();
     $PlanetRess->CalcResource();
     $PlanetRess->SavePlanetToDB();
     //start the template
     $this->tplObj->loadscript('countdown.js');
     $dm_cost = 300000;
     $am_cost = 1;
     if (!empty($USER['urlaubs_modus'])) {
         $this->printMessage("You can't access this page while you are in V mode!", true, array('game.php?page=overview', 2));
         die;
     }
     //fetch the best planet
     $za_planet1 = $GLOBALS['DATABASE']->uniquequery("SELECT *FROM " . PLANETS . " where `id_owner` = " . $USER['id'] . " order by `metal_perhour` DESC limit 1;");
     $za_planet2 = $GLOBALS['DATABASE']->uniquequery("SELECT *FROM " . PLANETS . " where `id_owner` = " . $USER['id'] . " order by `crystal_perhour` DESC limit 1;");
     $za_planet3 = $GLOBALS['DATABASE']->uniquequery("SELECT *FROM " . PLANETS . " where `id_owner` = " . $USER['id'] . " order by `deuterium_perhour` DESC limit 1;");
     $buy_type = HTTP::_GP('buy', '');
     $metal = 24 * $za_planet1['metal_perhour'];
     $crystal = 24 * $za_planet2['crystal_perhour'];
     $deuterium = 24 * $za_planet3['deuterium_perhour'];
     $metal2 = 36 * $za_planet1['metal_perhour'];
     $crystal2 = 36 * $za_planet2['crystal_perhour'];
     $deuterium2 = 36 * $za_planet3['deuterium_perhour'];
     $time = "1 HOUR";
     if ($_POST) {
         if ($buy_type == 'Buy With Antimatter') {
             if ($USER['antimatter'] >= $am_cost) {
                 if ($USER['res_bonus_time'] + 12 * 60 * 60 < TIMESTAMP) {
                     //update
                     if ($USER['premium_until'] < TIMESTAMP) {
                         $GLOBALS['DATABASE']->query("UPDATE " . USERS . " set `res_bonus_time` = '" . TIMESTAMP . "', antimatter = antimatter - {$am_cost} where `id` = '" . $USER['id'] . "';");
                         $PLANET['metal'] += $metal;
                         $PLANET['crystal'] += $crystal;
                         $PLANET['deuterium'] += $deuterium;
                         $this->printMessage("Pack has been bought and the account has been updated succesfully!", true, array('game.php?page=ResBonus', 2));
                         die;
                         die;
                     } elseif ($USER['premium_until'] > TIMESTAMP) {
                         $GLOBALS['DATABASE']->query("UPDATE " . USERS . " SET antimatter = antimatter - {$am_cost} where `id` = '" . $USER['id'] . "';");
                         $GLOBALS['DATABASE']->query("UPDATE " . USERS . " set `res_bonus_time` = '" . TIMESTAMP . "' where `id` = '" . $USER['id'] . "';");
                         $PLANET['metal'] += $metal2;
                         $PLANET['crystal'] += $crystal2;
                         $PLANET['deuterium'] += $deuterium2;
                         $this->printMessage("Pack has been bought and the account has been updated succesfully!", true, array('game.php?page=ResBonus', 2));
                         die;
                         die;
                     }
                 } else {
                     $this->printMessage("You can use this pack Twice at every 12 hours!", true, array('game.php?page=ResBonus', 2));
                     die;
                 }
             } else {
                 $this->printMessage("You do not have enough Antimatter!", true, array('game.php?page=ResBonus', 2));
                 die;
             }
         } elseif ($buy_type == 'Buy With Darkmatter') {
             if ($USER['darkmatter'] >= $dm_cost) {
                 if ($USER['res_bonus_time'] + 12 * 60 * 60 < TIMESTAMP) {
                     if ($USER['premium_until'] < TIMESTAMP) {
                         $USER['darkmatter'] -= $dm_cost;
                         $GLOBALS['DATABASE']->query("UPDATE " . USERS . " set `res_bonus_time` = '" . TIMESTAMP . "' where `id` = '" . $USER['id'] . "';");
                         $PLANET['metal'] += $metal;
                         $PLANET['crystal'] += $crystal;
                         $PLANET['deuterium'] += $deuterium;
                         $this->printMessage("Pack has been bought and the account has been updated succesfully!", true, array('game.php?page=ResBonus', 2));
                         die;
                         die;
                     } elseif ($USER['premium_until'] > TIMESTAMP) {
                         $USER['darkmatter'] -= $dm_cost;
                         $GLOBALS['DATABASE']->query("UPDATE " . USERS . " set `res_bonus_time` = '" . TIMESTAMP . "' where `id` = '" . $USER['id'] . "';");
                         $PLANET['metal'] += $metal2;
                         $PLANET['crystal'] += $crystal2;
                         $PLANET['deuterium'] += $deuterium2;
                         $this->printMessage("Pack has been bought and the account has been updated succesfully!", true, array('game.php?page=ResBonus', 2));
                         die;
                         die;
                     }
                 } else {
                     $this->printMessage("You can use this pack Twice at every 12 hours!", true, array('game.php?page=ResBonus', 2));
                     die;
                 }
             } else {
                 $this->printMessage("You do not have enough DarkMatter!", true, array('game.php?page=ResBonus', 2));
                 die;
             }
         }
         //verificam daca au trecut 24h
     }
     $this->tplObj->assign_vars(array('cost' => pretty_number($dm_cost), 'time' => $time, 'price_metal' => pretty_number($metal), 'price_crystal' => pretty_number($crystal), 'price_deuterium' => pretty_number($deuterium), 'price_metal2' => pretty_number($metal2), 'price_crystal2' => pretty_number($crystal2), 'price_deuterium2' => pretty_number($deuterium2), 'dm' => $USER['darkmatter'], 'am' => $USER['antimatter'], 'p_state' => $USER['premium_until'] > TIMESTAMP ? "You have premium account until" : "You don't have premium account active", 'premium_active' => !empty($USER['premium_until']) && $USER['premium_until'] > TIMESTAMP ? $USER['premium_until'] - TIMESTAMP : 0, 'status' => $USER['res_bonus_time'] + 12 * 60 * 60 < TIMESTAMP ? true : $USER['res_bonus_time'] + 12 * 60 * 60 - TIMESTAMP));
     $this->display('page.resbonus.default.tpl');
 }
コード例 #24
0
ファイル: ShowTraderPage.php プロジェクト: sonicmaster/RPG
/**
 *  2Moons
 *  Copyright (C) 2011  Slaver
 *
 * 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 Slaver <*****@*****.**>
 * @copyright 2009 Lucky <*****@*****.**> (XGProyecto)
 * @copyright 2011 Slaver <*****@*****.**> (Fork/2Moons)
 * @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License
 * @version 1.3 (2011-01-21)
 * @link http://code.google.com/p/2moons/
 */
function ShowTraderPage()
{
    global $USER, $PLANET, $LNG, $db;
    $ress = request_var('ress', '');
    $action = request_var('action', '');
    $metal = round(request_var('metal', 0.0), 0);
    $crystal = round(request_var('crystal', 0.0), 0);
    $deut = round(request_var('deuterium', 0.0), 0);
    $PlanetRess = new ResourceUpdate();
    $template = new template();
    $template->loadscript("trader.js");
    if ($ress != '') {
        switch ($ress) {
            case 'metal':
                if ($action == "trade") {
                    if ($USER['darkmatter'] < DARKMATTER_FOR_TRADER) {
                        $template->message(sprintf($LNG['tr_empty_darkmatter'], $LNG['Darkmatter']), "game.php?page=trader", 1);
                    } elseif ($crystal < 0 || $deut < 0) {
                        $template->message($LNG['tr_only_positive_numbers'], "game.php?page=trader", 1);
                    } else {
                        $trade = $crystal * 2 + $deut * 4;
                        $PlanetRess->CalcResource();
                        if ($PLANET['metal'] > $trade) {
                            $PLANET['metal'] -= $trade;
                            $PLANET['crystal'] += $crystal;
                            $PLANET['deuterium'] += $deut;
                            $USER['darkmatter'] -= DARKMATTER_FOR_TRADER;
                            $template->message($LNG['tr_exchange_done'], "game.php?page=trader", 1);
                        } else {
                            $template->message($LNG['tr_not_enought_metal'], "game.php?page=trader", 1);
                        }
                        $PlanetRess->SavePlanetToDB();
                    }
                } else {
                    $template->assign_vars(array('tr_resource' => $LNG['tr_resource'], 'tr_sell_metal' => $LNG['tr_sell_metal'], 'tr_amount' => $LNG['tr_amount'], 'tr_exchange' => $LNG['tr_exchange'], 'tr_quota_exchange' => $LNG['tr_quota_exchange'], 'Metal' => $LNG['Metal'], 'Crystal' => $LNG['Crystal'], 'Deuterium' => $LNG['Deuterium'], 'mod_ma_res_a' => "2", 'mod_ma_res_b' => "4", 'ress' => $ress));
                    $template->show("trader_metal.tpl");
                }
                break;
            case 'crystal':
                if ($action == "trade") {
                    if ($USER['darkmatter'] < DARKMATTER_FOR_TRADER) {
                        $template->message(sprintf($LNG['tr_empty_darkmatter'], $LNG['Darkmatter']), "game.php?page=trader", 1);
                    } elseif ($metal < 0 || $deut < 0) {
                        $template->message($LNG['tr_only_positive_numbers'], "game.php?page=trader", 1);
                    } else {
                        $trade = $metal * 0.5 + $deut * 2;
                        $PlanetRess->CalcResource();
                        if ($PLANET['crystal'] > $trade) {
                            $PLANET['metal'] += $metal;
                            $PLANET['crystal'] -= $trade;
                            $PLANET['deuterium'] += $deut;
                            $USER['darkmatter'] -= DARKMATTER_FOR_TRADER;
                            $template->message($LNG['tr_exchange_done'], "game.php?page=trader", 1);
                        } else {
                            $template->message($LNG['tr_not_enought_crystal'], "game.php?page=trader", 1);
                        }
                        $PlanetRess->SavePlanetToDB();
                    }
                } else {
                    $template->assign_vars(array('tr_resource' => $LNG['tr_resource'], 'tr_sell_crystal' => $LNG['tr_sell_crystal'], 'tr_amount' => $LNG['tr_amount'], 'tr_exchange' => $LNG['tr_exchange'], 'tr_quota_exchange' => $LNG['tr_quota_exchange'], 'Metal' => $LNG['Metal'], 'Crystal' => $LNG['Crystal'], 'Deuterium' => $LNG['Deuterium'], 'mod_ma_res_a' => "0.5", 'mod_ma_res_b' => "2", 'ress' => $ress));
                    $template->show("trader_crystal.tpl");
                }
                break;
            case 'deuterium':
                if ($action == "trade") {
                    if ($USER['darkmatter'] < DARKMATTER_FOR_TRADER) {
                        $template->message(sprintf($LNG['tr_empty_darkmatter'], $LNG['Darkmatter']), "game.php?page=trader", 1);
                    } elseif ($metal < 0 || $crystal < 0) {
                        message($LNG['tr_only_positive_numbers'], "game.php?page=trader", 1);
                    } else {
                        $trade = $metal * 0.25 + $crystal * 0.5;
                        $PlanetRess->CalcResource();
                        if ($PLANET['deuterium'] > $trade) {
                            $PLANET['metal'] += $metal;
                            $PLANET['crystal'] += $crystal;
                            $PLANET['deuterium'] -= $trade;
                            $USER['darkmatter'] -= DARKMATTER_FOR_TRADER;
                            $template->message($LNG['tr_exchange_done'], "game.php?page=trader", 1);
                        } else {
                            $template->message($LNG['tr_not_enought_deuterium'], "game.php?page=trader", 1);
                        }
                        $PlanetRess->SavePlanetToDB();
                    }
                } else {
                    $template->assign_vars(array('tr_resource' => $LNG['tr_resource'], 'tr_sell_deuterium' => $LNG['tr_sell_deuterium'], 'tr_amount' => $LNG['tr_amount'], 'tr_exchange' => $LNG['tr_exchange'], 'tr_quota_exchange' => $LNG['tr_quota_exchange'], 'Metal' => $LNG['Metal'], 'Crystal' => $LNG['Crystal'], 'Deuterium' => $LNG['Deuterium'], 'mod_ma_res_a' => "0.25", 'mod_ma_res_b' => "0.5", 'ress' => $ress));
                    $template->show("trader_deuterium.tpl");
                }
                break;
        }
    } else {
        $PlanetRess->CalcResource();
        $PlanetRess->SavePlanetToDB();
        $template->assign_vars(array('tr_cost_dm_trader' => sprintf($LNG['tr_cost_dm_trader'], pretty_number(DARKMATTER_FOR_TRADER), $LNG['Darkmatter']), 'tr_call_trader_who_buys' => $LNG['tr_call_trader_who_buys'], 'tr_call_trader' => $LNG['tr_call_trader'], 'tr_exchange_quota' => $LNG['tr_exchange_quota'], 'tr_call_trader_submit' => $LNG['tr_call_trader_submit'], 'Metal' => $LNG['Metal'], 'Crystal' => $LNG['Crystal'], 'Deuterium' => $LNG['Deuterium']));
        $template->show("trader_overview.tpl");
    }
}
コード例 #25
0
ファイル: ShowOverviewPage.php プロジェクト: sonicmaster/RPG
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");
}
コード例 #26
0
ファイル: ShowBattleSimPage.php プロジェクト: sonicmaster/RPG
function ShowBattleSimPage()
{
    global $USER, $PLANET, $reslist, $pricelist, $LNG, $db, $ExtraDM, $LANG, $CONF;
    $action = request_var('action', '');
    $Slots = request_var('slots', 1);
    if (isset($_REQUEST['im'])) {
        $Array = $_REQUEST['im'];
        foreach ($Array as $ID => $Count) {
            $BattleArray[0][1][$ID] = floattostring($Count);
        }
    } elseif (isset($_REQUEST['battleinput'])) {
        $BattleArray = $_REQUEST['battleinput'];
    } else {
        $BattleArray = array();
    }
    if ($action == 'send') {
        $Counts = array(0, 0);
        foreach ($BattleArray as $BattleSlotID => $BattleSlot) {
            if (isset($BattleSlot[0]) && (array_sum($BattleSlot[0]) > 0 || $BattleSlotID == 0)) {
                $Att = mt_rand(1, 1000);
                $attack[$Att]['fleet'] = array('fleet_start_galaxy' => 1, 'fleet_start_system' => 33, 'fleet_start_planet' => 7, 'fleet_end_galaxy' => 1, 'fleet_end_system' => 33, 'fleet_end_planet' => 7, 'metal' => 0, 'crystal' => 0, 'deuterium' => 0);
                $attack[$Att]['user'] = array('username' => $LNG['bs_atter'] . ' Nr.' . ($BattleSlotID + 1), 'military_tech' => $BattleSlot[0][109], 'defence_tech' => $BattleSlot[0][110], 'shield_tech' => $BattleSlot[0][111], 0, 'dm_defensive' => 0, 'dm_attack' => 0);
                foreach ($BattleSlot[0] as $ID => $Count) {
                    if (!in_array($ID, $reslist['fleet']) || $BattleSlot[0][$ID] <= 0) {
                        unset($BattleSlot[0][$ID]);
                    }
                }
                if ($Counts[0] == 0 && $BattleSlotID != 0) {
                    exit('ERROR');
                }
                $Counts[0] = $Counts[0] + array_sum($BattleSlot[1]);
                $attack[$Att]['detail'] = $BattleSlot[0];
            }
            if (isset($BattleSlot[1]) && (array_sum($BattleSlot[1]) > 0 || $BattleSlotID == 0)) {
                $Def = mt_rand(1, 1000);
                $defense[$Def]['fleet'] = array('fleet_start_galaxy' => 1, 'fleet_start_system' => 33, 'fleet_start_planet' => 7, 'fleet_end_galaxy' => 1, 'fleet_end_system' => 33, 'fleet_end_planet' => 7, 'metal' => 0, 'crystal' => 0, 'deuterium' => 0);
                $defense[$Def]['user'] = array('username' => $LNG['bs_deffer'] . ' Nr.' . ($BattleSlotID + 1), 'military_tech' => $BattleSlot[1][109], 'defence_tech' => $BattleSlot[1][110], 'shield_tech' => $BattleSlot[1][111], 0, 'dm_defensive' => 0, 'dm_attack' => 0);
                foreach ($BattleSlot[1] as $ID => $Count) {
                    if (!in_array($ID, $reslist['fleet']) && !in_array($ID, $reslist['defense'])) {
                        unset($BattleSlot[1][$ID]);
                    }
                }
                if ($Countd[1] == 0 && $BattleSlotID != 0) {
                    exit('ERROR');
                }
                $Countd[1] = $Countd[1] + array_sum($BattleSlot[1]);
                $defense[$Def]['def'] = $BattleSlot[1];
            }
        }
        $LANG->includeLang(array('FLEET'));
        require_once ROOT_PATH . 'includes/classes/missions/calculateAttack.php';
        require_once ROOT_PATH . 'includes/classes/missions/calculateSteal.php';
        require_once ROOT_PATH . 'includes/classes/missions/GenerateReport.php';
        $start = microtime(true);
        $result = calculateAttack($attack, $defense, $CONF['Fleet_Cdr'], $CONF['Defs_Cdr']);
        $totaltime = microtime(true) - $start;
        $steal = $result['won'] == "a" ? calculateSteal($attack, array('metal' => $BattleArray[0][1][1], 'crystal' => $BattleArray[0][1][2], 'deuterium' => $BattleArray[0][1][3]), true) : array('metal' => 0, 'crystal' => 0, 'deuterium' => 0);
        $FleetDebris = $result['debree']['att'][0] + $result['debree']['def'][0] + $result['debree']['att'][1] + $result['debree']['def'][1];
        $StrAttackerUnits = sprintf($LNG['sys_attacker_lostunits'], $result['lost']['att']);
        $StrDefenderUnits = sprintf($LNG['sys_defender_lostunits'], $result['lost']['def']);
        $StrRuins = sprintf($LNG['sys_gcdrunits'], $result['debree']['def'][0] + $result['debree']['att'][0], $LNG['Metal'], $result['debree']['def'][1] + $result['debree']['att'][1], $LNG['Crystal']);
        $DebrisField = $StrAttackerUnits . "<br>" . $StrDefenderUnits . "<br>" . $StrRuins;
        $MoonChance = min(round($FleetDebris / 100000, 0), 20);
        $AllSteal = array_sum($steal);
        $RaportInfo = sprintf($LNG['bs_derbis_raport'], ceil($FleetDebris / $pricelist[219]['capacity']), $LNG['tech'][219], ceil($FleetDebris / $pricelist[209]['capacity']), $LNG['tech'][209]) . "<br>";
        $RaportInfo .= sprintf($LNG['bs_steal_raport'], ceil($AllSteal / $pricelist[202]['capacity']), $LNG['tech'][202], ceil($AllSteal / $pricelist[203]['capacity']), $LNG['tech'][203], ceil($AllSteal / $pricelist[217]['capacity']), $LNG['tech'][217]) . "<br>";
        $INFO['moon']['battlesim'] = $RaportInfo;
        $INFO['steal'] = $steal;
        $INFO['fleet_start_time'] = TIMESTAMP;
        $INFO['moon']['des'] = 0;
        $INFO['moon']['chance'] = $MoonChance;
        $raport = GenerateReport($result, $INFO);
        $rid = md5(microtime(true));
        file_put_contents(ROOT_PATH . 'raports/raport_' . $rid . '.php', '<?php' . "\n" . '$raport = ' . $raport . ';' . "\n" . '?>');
        $SQLQuery = "INSERT INTO " . RW . " SET ";
        $SQLQuery .= "`time` = '" . TIMESTAMP . "', ";
        $SQLQuery .= "`owners` = '" . $USER['id'] . ",0', ";
        $SQLQuery .= "`rid` = '" . $rid . "';";
        $db->query($SQLQuery);
        echo $rid;
        exit;
    }
    $PlanetRess = new ResourceUpdate();
    $PlanetRess->CalcResource();
    $PlanetRess->SavePlanetToDB();
    foreach ($reslist['fleet'] as $ID) {
        $GetFleet[$ID] = $LNG['tech'][$ID];
    }
    foreach ($reslist['defense'] as $ID) {
        if ($ID >= 501) {
            break;
        }
        $GetDef[$ID] = $LNG['tech'][$ID];
    }
    $template = new template();
    $template->loadscript('battlesim.js');
    $template->assign_vars(array('lm_battlesim' => $LNG['lm_battlesim'], 'bs_names' => $LNG['bs_names'], 'bs_atter' => $LNG['bs_atter'], 'bs_deffer' => $LNG['bs_deffer'], 'bs_steal' => $LNG['bs_steal'], 'bs_techno' => $LNG['bs_techno'], 'bs_send' => $LNG['bs_send'], 'bs_cancel' => $LNG['bs_cancel'], 'bs_wait' => $LNG['bs_wait'], 'Metal' => $LNG['Metal'], 'Crystal' => $LNG['Crystal'], 'Deuterium' => $LNG['Deuterium'], 'attack_tech' => $LNG['tech'][109], 'shield_tech' => $LNG['tech'][110], 'tank_tech' => $LNG['tech'][111], 'GetFleet' => $GetFleet, 'GetDef' => $GetDef, 'Slots' => $Slots, 'battleinput' => $BattleArray));
    $template->show("battlesim.tpl");
}
コード例 #27
0
 protected function save()
 {
     if (isset($this->ecoObj)) {
         $this->ecoObj->SavePlanetToDB();
     }
 }
コード例 #28
0
 public function DefensesBuildingPage()
 {
     global $USER, $PLANET, $LNG, $resource, $dpath, $reslist;
     include_once ROOT_PATH . 'includes/functions/IsTechnologieAccessible.php';
     include_once ROOT_PATH . 'includes/functions/GetElementPrice.php';
     $template = new template();
     if ($PLANET[$resource[21]] == 0) {
         $template->message($LNG['bd_shipyard_required']);
         exit;
     }
     $fmenge = $_POST['fmenge'];
     $cancel = request_var('auftr', range(0, MAX_FLEET_OR_DEFS_IN_BUILD - 1));
     $action = request_var('action', '');
     $PlanetRess = new ResourceUpdate();
     $PlanetRess->CalcResource();
     $NotBuilding = true;
     if (!empty($PLANET['b_building_id'])) {
         $CurrentQueue = $PLANET['b_building_id'];
         $QueueArray = explode(";", $CurrentQueue);
         for ($i = 0; $i < count($QueueArray); $i++) {
             $ListIDArray = explode(",", $QueueArray[$i]);
             if ($ListIDArray[0] == 21 || $ListIDArray[0] == 15) {
                 $NotBuilding = false;
                 break;
             }
         }
     }
     if (isset($fmenge) && $NotBuilding == true && $USER['urlaubs_modus'] == 0) {
         $ebuild = explode(";", $PLANET['b_hangar_id']);
         if (count($ebuild) - 1 >= MAX_FLEET_OR_DEFS_IN_BUILD) {
             $template->message(sprintf($LNG['bd_max_builds'], MAX_FLEET_OR_DEFS_IN_BUILD), "?page=buildings&mode=fleet", 3);
             exit;
         }
         $Missiles[502] = $PLANET[$resource[502]];
         $Missiles[503] = $PLANET[$resource[503]];
         $SiloSize = $PLANET[$resource[44]];
         $MaxMissiles = $SiloSize * 10;
         $BuildQueue = $PLANET['b_hangar_id'];
         $BuildArray = explode(";", $BuildQueue);
         for ($QElement = 0; $QElement < count($BuildArray); $QElement++) {
             $ElmentArray = explode(",", $BuildArray[$QElement]);
             if (isset($Missiles[$ElmentArray[0]])) {
                 $Missiles[$ElmentArray[0]] += $ElmentArray[1];
             }
         }
         foreach ($fmenge as $Element => $Count) {
             if (empty($Count) || !in_array($Element, $reslist['defense'])) {
                 continue;
             }
             $Count = is_numeric($Count) ? $Count : 0;
             $Count = max(min($Count, MAX_FLEET_OR_DEFS_PER_ROW), 0);
             $MaxElements = $this->GetMaxConstructibleElements($Element);
             if (empty($Element) || empty($Count) || empty($MaxElements) || !IsTechnologieAccessible($USER, $PLANET, $Element)) {
                 continue;
             }
             if ($Element == 502 || $Element == 503) {
                 $ActuMissiles = $Missiles[502] + 2 * $Missiles[503];
                 $MissilesSpace = $MaxMissiles - $ActuMissiles;
                 $Count = $Element == 502 ? min($Count, $MissilesSpace) : min($Count, floor($MissilesSpace / 2));
                 $Count = min($Count, $MaxElements);
                 $Missiles[$Element] += $Count;
             } elseif (in_array($Element, $reslist['one'])) {
                 $Count = $PLANET[$resource[$Element]] == 0 && strpos($PLANET['b_hangar_id'], $Element . ',') === false ? 1 : 0;
             } else {
                 $Count = min($Count, $MaxElements);
             }
             if ($Count < 1) {
                 continue;
             }
             $Ressource = $this->GetElementRessources($Element, $Count);
             $PLANET['metal'] -= $Ressource['metal'];
             $PLANET['crystal'] -= $Ressource['crystal'];
             $PLANET['deuterium'] -= $Ressource['deuterium'];
             $PLANET['norio'] -= $Ressource['norio'];
             $USER['darkmatter'] -= $Ressource['darkmatter'];
             $PLANET['b_hangar_id'] .= $Element . ',' . floattostring($Count) . ';';
         }
     }
     if ($action == "delete" && is_array($cancel) && $USER['urlaubs_modus'] == 0) {
         $this->CancelAuftr($cancel);
     }
     $PlanetRess->SavePlanetToDB();
     foreach ($reslist['defense'] as $Element) {
         if (!IsTechnologieAccessible($USER, $PLANET, $Element)) {
             continue;
         }
         $DefenseList[] = array('id' => $Element, 'name' => $LNG['tech'][$Element], 'descriptions' => $LNG['res']['descriptions'][$Element], 'price' => GetElementPrice($USER, $PLANET, $Element, false), 'restprice' => $this->GetRestPrice($Element), 'time' => pretty_time(GetBuildingTime($USER, $PLANET, $Element)), 'IsAvailable' => IsElementBuyable($USER, $PLANET, $Element, false), 'GetMaxAmount' => floattostring($this->GetMaxConstructibleElements($Element)), 'Available' => pretty_number($PLANET[$resource[$Element]]), 'AlreadyBuild' => in_array($Element, $reslist['one']) && (strpos($PLANET['b_hangar_id'], $Element . ",") !== false || $PLANET[$resource[$Element]] != 0) ? true : false);
     }
     $Buildlist = array();
     if (!empty($PLANET['b_hangar_id'])) {
         $ElementQueue = explode(';', $PLANET['b_hangar_id']);
         $Shipyard = array();
         $QueueTime = 0;
         foreach ($ElementQueue as $ElementLine => $Element) {
             if (empty($Element)) {
                 continue;
             }
             $Element = explode(',', $Element);
             $ElementTime = GetBuildingTime($USER, $PLANET, $Element[0]);
             $QueueTime += $ElementTime * $Element[1];
             $Shipyard[] = array($LNG['tech'][$Element[0]], $Element[1], $ElementTime);
         }
         $template->loadscript('bcmath.js');
         $template->loadscript('shipyard.js');
         $template->execscript('ShipyardInit();');
         $Buildlist = array('Queue' => $Shipyard, 'b_hangar_id_plus' => $PLANET['b_hangar'], 'pretty_time_b_hangar' => pretty_time(max($QueueTime - $PLANET['b_hangar'], 0)));
     }
     $template->assign_vars(array('DefenseList' => $DefenseList, 'NotBuilding' => $NotBuilding, 'bd_available' => $LNG['bd_available'], 'bd_remaining' => $LNG['bd_remaining'], 'fgf_time' => $LNG['fgf_time'], 'bd_build_ships' => $LNG['bd_build_ships'], 'bd_building_shipyard' => $LNG['bd_building_shipyard'], 'bd_protection_shield_only_one' => $LNG['bd_protection_shield_only_one'], 'bd_cancel_warning' => $LNG['bd_cancel_warning'], 'bd_cancel_send' => $LNG['bd_cancel_send'], 'bd_operating' => $LNG['bd_operating'], 'bd_actual_production' => $LNG['bd_actual_production'], 'BuildList' => json_encode($Buildlist), 'maxlength' => strlen(MAX_FLEET_OR_DEFS_PER_ROW)));
     $template->show("shipyard_defense.tpl");
 }
コード例 #29
0
 public static function ShowFleet3Page()
 {
     global $USER, $PLANET, $resource, $pricelist, $reslist, $CONF, $db, $LNG;
     include_once ROOT_PATH . 'includes/functions/IsVacationMode.' . PHP_EXT;
     $template = new template();
     $template->loadscript('flotten.js');
     $template->gotoside('?page=fleet');
     $template->page_header();
     $template->page_topnav();
     $template->page_leftmenu();
     $template->page_planetmenu();
     $template->page_footer();
     $mission = request_var('mission', 3);
     $galaxy = request_var('galaxy', 0);
     $system = request_var('system', 0);
     $planet = request_var('planet', 0);
     $planettype = request_var('planettype', 0);
     $fleet_group = request_var('fleet_group', 0);
     $GenFleetSpeed = request_var('speed', 0);
     $TransportMetal = round(request_var('metal', 0.0), 0);
     $TransportCrystal = round(request_var('crystal', 0.0), 0);
     $TransportDeuterium = round(request_var('deuterium', 0.0), 0);
     $holdingtime = request_var('holdingtime', 0);
     $rawfleetarray = request_var('usedfleet', '', true);
     $thisgalaxy = $PLANET['galaxy'];
     $thissystem = $PLANET['system'];
     $thisplanet = $PLANET['planet'];
     $thisplanettype = $PLANET['planet_type'];
     if (IsVacationMode($USER)) {
         exit($template->message($LNG['fl_vacation_mode_active'], 'game.php?page=overview', 2));
     }
     if ($_SESSION['db']['user_side'] != 'game.php?page=fleet2') {
         parent::GotoFleetPage();
     }
     if (!($planettype >= 1 || $planettype <= 3)) {
         parent::GotoFleetPage();
     }
     if ($PLANET['galaxy'] == $galaxy && $PLANET['system'] == $system && $PLANET['planet'] == $planet && $PLANET['planet_type'] == $planettype) {
         parent::GotoFleetPage();
     }
     if ($galaxy > MAX_GALAXY_IN_WORLD || $galaxy < 1 || $system > MAX_SYSTEM_IN_GALAXY || $system < 1 || $planet > MAX_PLANET_IN_SYSTEM + 1 || $planet < 1) {
         parent::GotoFleetPage();
     }
     if (empty($mission)) {
         parent::GotoFleetPage();
     }
     if (!is_numeric($TransportMetal) || !is_numeric($TransportCrystal) || !is_numeric($TransportDeuterium)) {
         parent::GotoFleetPage();
     }
     if ($TransportMetal + $TransportCrystal + $TransportDeuterium < 1 && $mission == 3) {
         $template->message("<font color=\"lime\"><b>" . $LNG['fl_empty_transport'] . "</b></font>", "game." . PHP_EXT . "?page=fleet", 1);
         exit;
     }
     $ActualFleets = parent::GetCurrentFleets($USER['id']);
     if (parent::GetMaxFleetSlots($USER) <= $ActualFleets) {
         $template->message($LNG['fl_no_slots'], "game." . PHP_EXT . "?page=fleet", 1);
         exit;
     }
     $fleet_group_mr = 0;
     if (!empty($fleet_group) && $mission == 2) {
         $aks_count_mr = $db->uniquequery("SELECT COUNT(*) as state FROM " . AKS . " WHERE `id` = '" . $fleet_group . "' AND `eingeladen` LIKE '%" . $USER['id'] . "%';");
         if ($aks_count_mr['state'] > 0) {
             $fleet_group_mr = $fleet_group;
         } else {
             $mission = 1;
         }
     }
     $ActualFleets = parent::GetCurrentFleets($USER['id']);
     $TargetPlanet = $db->uniquequery("SELECT `id_owner`,`id_level`,`destruyed`,`ally_deposit` FROM " . PLANETS . " WHERE `galaxy` = '" . $db->sql_escape($galaxy) . "' AND `system` = '" . $db->sql_escape($system) . "' AND `planet` = '" . $db->sql_escape($planet) . "' AND `planet_type` = '" . $db->sql_escape($planettype) . "';");
     if ($mission != 15 && $mission != 8 && $TargetPlanet["destruyed"] != 0 || $mission != 15 && $mission != 7 && $mission != 8 && empty($TargetPlanet['id_owner'])) {
         parent::GotoFleetPage();
     }
     $MyDBRec = $USER;
     $FleetArray = parent::GetFleetArray($rawfleetarray);
     if (!is_array($FleetArray)) {
         parent::GotoFleetPage();
     }
     $FleetStorage = 0;
     $FleetShipCount = 0;
     $fleet_array = "";
     $FleetSubQRY = "";
     foreach ($FleetArray as $Ship => $Count) {
         if ($Count > $PLANET[$resource[$Ship]] || $Count < 0) {
             parent::GotoFleetPage();
         }
         $FleetStorage += $pricelist[$Ship]["capacity"] * $Count;
         $FleetShipCount += $Count;
         $fleet_array .= $Ship . "," . $Count . ";";
         $FleetSubQRY .= "`" . $resource[$Ship] . "` = `" . $resource[$Ship] . "` - '" . floattostring($Count) . "', ";
     }
     $error = 0;
     $fleetmission = $mission;
     $YourPlanet = false;
     $UsedPlanet = false;
     if ($mission == 11) {
         $maxexpde = parent::GetCurrentFleets($USER['id'], 11);
         if ($maxexpde >= MAX_DM_MISSIONS) {
             $template->message("<font color=\"red\"><b>" . $LNG['fl_expedition_fleets_limit'] . "</b></font>", "game." . PHP_EXT . "?page=fleet", 2);
             exit;
         }
     } elseif ($mission == 15) {
         $MaxExpedition = $USER[$resource[124]];
         if ($MaxExpedition == 0) {
             $template->message("<font color=\"red\"><b>" . $LNG['fl_expedition_tech_required'] . "</b></font>", "game." . PHP_EXT . "?page=fleet", 2);
             exit;
         }
         $ExpeditionEnCours = parent::GetCurrentFleets($USER['id'], 15);
         $EnvoiMaxExpedition = floor(sqrt($MaxExpedition));
         if ($ExpeditionEnCours >= $EnvoiMaxExpedition) {
             $template->message("<font color=\"red\"><b>" . $LNG['fl_expedition_fleets_limit'] . "</b></font>", "game." . PHP_EXT . "?page=fleet", 2);
             exit;
         }
     }
     $YourPlanet = isset($TargetPlanet['id_owner']) && $TargetPlanet['id_owner'] == $USER['id'] ? true : false;
     $UsedPlanet = isset($TargetPlanet['id_owner']) ? true : false;
     $HeDBRec = $YourPlanet ? $MyDBRec : GetUserByID($TargetPlanet['id_owner'], array('id', 'onlinetime', 'ally_id', 'urlaubs_modus'));
     if ($HeDBRec['urlaubs_modus'] && $mission != 8) {
         $template->message("<font color=\"lime\"><b>" . $LNG['fl_in_vacation_player'] . "</b></font>", "game." . PHP_EXT . "?page=fleet", 2);
         exit;
     }
     if (!$YourPlanet && ($mission == 1 || $mission == 2 || $mission == 5 || $mission == 6 || $mission == 9)) {
         if ($TargetPlanet['id_level'] > $USER['authlevel'] && $CONF['adm_attack'] == 0) {
             $template->message("<font color=\"red\"><b>" . $LNG['fl_admins_cannot_be_attacked'] . "</b></font>", "game." . PHP_EXT . "?page=fleet", 2);
             exit;
         }
         $UserPoints = $USER;
         $User2Points = $db->uniquequery("SELECT `total_points` FROM " . STATPOINTS . " WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . $HeDBRec['id'] . "';");
         $IsNoobProtec = CheckNoobProtec($UserPoints, $User2Points, $HeDBRec['onlinetime']);
         if ($IsNoobProtec['NoobPlayer']) {
             $template->message("<font color=\"lime\"><b>" . $LNG['fl_week_player'] . "</b></font>", "game." . PHP_EXT . "?page=fleet", 2);
             exit;
         } elseif ($IsNoobProtec['StrongPlayer']) {
             $template->message("<font color=\"red\"><b>" . $LNG['fl_strong_player'] . "</b></font>", "game." . PHP_EXT . "?page=fleet", 2);
             exit;
         }
     }
     if ($mission == 5) {
         if ($TargetPlanet['ally_deposit'] < 1) {
             $template->message("<font color=\"red\"><b>" . $LNG['fl_not_ally_deposit'] . "</b></font>", "game." . PHP_EXT . "?page=fleet", 2);
             exit;
         }
         $buddy = $db->uniquequery("SELECT COUNT(*) as state FROM " . BUDDY . " WHERE `active` = '1' AND (`owner` = '" . $HeDBRec['id'] . "' AND `sender` = '" . $MyDBRec['id'] . "') OR (`owner` = '" . $MyDBRec['id'] . "' AND `sender` = '" . $HeDBRec['id'] . "');");
         if ($HeDBRec['ally_id'] != $MyDBRec['ally_id'] && $buddy['state'] == 0) {
             $template->message("<font color=\"red\"><b>" . $LNG['fl_no_same_alliance'] . "</b></font>", "game." . PHP_EXT . "?page=fleet", 2);
             exit;
         }
     }
     if (parent::CheckUserSpeed() || !array_key_exists($mission, parent::GetAvailableMissions(array('CurrentUser' => $USER, 'galaxy' => $galaxy, 'system' => $system, 'planet' => $planet, 'planettype' => $planettype, 'IsAKS' => $fleet_group, 'Ship' => $FleetArray)))) {
         parent::GotoFleetPage();
     }
     $MaxFleetSpeed = parent::GetFleetMaxSpeed($FleetArray, $USER);
     $SpeedFactor = parent::GetGameSpeedFactor();
     $distance = parent::GetTargetDistance($thisgalaxy, $galaxy, $thissystem, $system, $thisplanet, $planet);
     $duration = parent::GetMissionDuration($GenFleetSpeed, $MaxFleetSpeed, $distance, $SpeedFactor, $USER);
     $consumption = parent::GetFleetConsumption($FleetArray, $duration, $distance, $MaxFleetSpeed, $USER, $SpeedFactor);
     $fleet['start_time'] = $duration + TIMESTAMP;
     if ($mission == 15) {
         $StayDuration = max($holdingtime, 1) * 3600 / $CONF['halt_speed'];
         $StayTime = $fleet['start_time'] + $StayDuration;
     } elseif ($mission == 5) {
         $StayDuration = $holdingtime * 3600;
         $StayTime = $fleet['start_time'] + $StayDuration;
     } elseif ($mission == 11) {
         $StayDuration = 3600 / $CONF['halt_speed'];
         $StayTime = $fleet['start_time'] + $StayDuration;
     } else {
         $StayDuration = 0;
         $StayTime = 0;
     }
     $fleet['end_time'] = $StayDuration + 2 * $duration + TIMESTAMP;
     $FleetStorage -= $consumption;
     $PlanetRess = new ResourceUpdate();
     $PlanetRess->CalcResource();
     $TransportMetal = min($TransportMetal, $PLANET['metal']);
     $TransportCrystal = min($TransportCrystal, $PLANET['crystal']);
     $TransportDeuterium = min($TransportDeuterium, $PLANET['deuterium'] - $consumption);
     $StorageNeeded = $TransportMetal + $TransportCrystal + $TransportDeuterium;
     $StockMetal = $PLANET['metal'];
     $StockCrystal = $PLANET['crystal'];
     $StockDeuterium = $PLANET['deuterium'];
     $StockDeuterium -= $consumption;
     if ($PLANET['deuterium'] < $consumption) {
         $template->message("<font color=\"red\"><b>" . sprintf($LNG['fl_no_enought_deuterium'], $LNG['Deuterium'], pretty_number($consumption - $PLANET['deuterium']), $LNG['Deuterium']) . "</b></font>", "game." . PHP_EXT . "?page=fleet", 2);
         exit;
     }
     if ($StorageNeeded > $FleetStorage) {
         $template->message("<font color=\"red\"><b>" . $LNG['fl_no_enought_cargo_capacity'] . pretty_number($StorageNeeded - $FleetStorage) . "</b></font>", "game." . PHP_EXT . "?page=fleet", 2);
         exit;
     }
     if ($TargetPlanet['id_level'] > $USER['authlevel'] && $CONF['adm_attack'] == 0) {
         $template->message($LNG['fl_admins_cannot_be_attacked'], "game." . PHP_EXT . "?page=fleet", 2);
         exit;
     }
     $PLANET['metal'] -= $TransportMetal;
     $PLANET['crystal'] -= $TransportCrystal;
     $PLANET['deuterium'] -= $TransportDeuterium + $consumption;
     $PlanetRess->SavePlanetToDB();
     if (connection_aborted()) {
         exit;
     }
     if ($fleet_group_mr != 0) {
         $AksStartTime = $db->uniquequery("SELECT MAX(`fleet_start_time`) AS Start FROM " . FLEETS . " WHERE `fleet_group` = '" . $fleet_group_mr . "' AND '" . MAX_FLEETS_PER_ACS . "' > (SELECT COUNT(*) FROM " . FLEETS . " WHERE `fleet_group` = '" . $fleet_group_mr . "');");
         if (isset($AksStartTime)) {
             if ($AksStartTime['Start'] >= $fleet['start_time']) {
                 $fleet['end_time'] += $AksStartTime['Start'] - $fleet['start_time'];
                 $fleet['start_time'] = $AksStartTime['Start'];
             } else {
                 $QryUpdateFleets = "UPDATE " . FLEETS . " SET ";
                 $QryUpdateFleets .= "`fleet_start_time` = '" . $fleet['start_time'] . "', ";
                 $QryUpdateFleets .= "`fleet_end_time` = fleet_end_time + '" . ($fleet['start_time'] - $AksStartTime['Start']) . "' ";
                 $QryUpdateFleets .= "WHERE ";
                 $QryUpdateFleets .= "`fleet_group` = '" . $fleet_group_mr . "';";
                 $db->query($QryUpdateFleets);
                 $fleet['end_time'] += $fleet['start_time'] - $AksStartTime['Start'];
             }
         } else {
             $mission = 1;
         }
     }
     $QryInsertFleet = "LOCK TABLE " . FLEETS . " WRITE, " . PLANETS . " WRITE;\r\n\t\t\t\t\t\t\tINSERT INTO " . FLEETS . " SET \r\n\t\t\t\t\t\t\t`fleet_owner` = '" . $USER['id'] . "', \r\n\t\t\t\t\t\t\t`fleet_mission` = '" . $mission . "',\r\n\t\t\t\t\t\t\t`fleet_amount` = '" . $FleetShipCount . "',\r\n\t\t\t\t\t\t    `fleet_array` = '" . $fleet_array . "',\r\n\t\t\t\t\t\t\t`fleet_start_time` = '" . $fleet['start_time'] . "',\r\n\t\t\t\t\t\t\t`fleet_start_galaxy` = '" . $thisgalaxy . "',\r\n\t\t\t\t\t\t\t`fleet_start_system` = '" . $thissystem . "',\r\n\t\t\t\t\t\t\t`fleet_start_planet` = '" . $thisplanet . "',\r\n\t\t\t\t\t\t\t`fleet_start_type` = '" . $thisplanettype . "',\r\n\t\t\t\t\t\t\t`fleet_end_time` = '" . $fleet['end_time'] . "',\r\n\t\t\t\t\t\t\t`fleet_end_stay` = '" . $StayTime . "',\r\n\t\t\t\t\t\t\t`fleet_end_galaxy` = '" . $galaxy . "',\r\n\t\t\t\t\t\t\t`fleet_end_system` = '" . $system . "',\r\n\t\t\t\t\t\t\t`fleet_end_planet` = '" . $planet . "',\r\n\t\t\t\t\t\t\t`fleet_end_type` = '" . $planettype . "',\r\n\t\t\t\t\t\t\t`fleet_resource_metal` = '" . floattostring($TransportMetal) . "',\r\n\t\t\t\t\t\t\t`fleet_resource_crystal` = '" . floattostring($TransportCrystal) . "',\r\n\t\t\t\t\t\t\t`fleet_resource_deuterium` = '" . floattostring($TransportDeuterium) . "',\r\n\t\t\t\t\t\t\t`fleet_target_owner` = '" . $TargetPlanet['id_owner'] . "',\r\n\t\t\t\t\t\t\t`fleet_group` = '" . $fleet_group_mr . "',\r\n\t\t\t\t\t\t\t`start_time` = '" . TIMESTAMP . "';\r\n\t\t\t\t\t\t\tUPDATE `" . PLANETS . "` SET\r\n\t\t\t\t\t\t\t" . substr($FleetSubQRY, 0, -2) . "\r\n\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t`id` = " . $PLANET['id'] . " LIMIT 1;\r\n\t\t\t\t\t\t\tUNLOCK TABLES;";
     $db->multi_query($QryInsertFleet);
     foreach ($FleetArray as $Ship => $Count) {
         $FleetList[$LNG['tech'][$Ship]] = pretty_number($Count);
     }
     $template->assign_vars(array('mission' => $LNG['type_mission'][$mission], 'distance' => pretty_number($distance), 'consumption' => pretty_number($consumption), 'from' => $thisgalaxy . ":" . $thissystem . ":" . $thisplanet, 'destination' => $galaxy . ":" . $system . ":" . $planet, 'start_time' => date("M D d H:i:s", $fleet['start_time']), 'end_time' => date("M D d H:i:s", $fleet['end_time']), 'speedallsmin' => $MaxFleetSpeed, 'FleetList' => $FleetList, 'fl_fleet_sended' => $LNG['fl_fleet_sended'], 'fl_mission' => $LNG['fl_mission'], 'fl_from' => $LNG['fl_from'], 'fl_destiny' => $LNG['fl_destiny'], 'fl_distance' => $LNG['fl_distance'], 'fl_fleet_speed' => $LNG['fl_fleet_speed'], 'fl_fuel_consumption' => $LNG['fl_fuel_consumption'], 'fl_fromfl_destiny' => $LNG['fl_fromfl_destiny'], 'fl_arrival_time' => $LNG['fl_arrival_time'], 'fl_return_time' => $LNG['fl_return_time'], 'fl_fleet' => $LNG['fl_fleet']));
     $template->show('fleet3_table.tpl');
 }
コード例 #30
0
 public function __construct()
 {
     global $PLANET, $USER, $LNG, $resource, $reslist, $CONF, $db, $pricelist;
     include_once ROOT_PATH . 'includes/functions/IsTechnologieAccessible.' . PHP_EXT;
     include_once ROOT_PATH . 'includes/functions/GetElementPrice.' . PHP_EXT;
     $template = new template();
     $template->page_header();
     $template->page_topnav();
     $template->page_leftmenu();
     $template->page_planetmenu();
     $template->page_footer();
     if ($PLANET[$resource[31]] == 0) {
         $template->message($LNG['bd_lab_required']);
         exit;
     }
     $bContinue = $this->CheckLabSettingsInQueue($PLANET) ? true : false;
     $PLANET[$resource[31] . '_inter'] = $this->CheckAndGetLabLevel($USER, $PLANET);
     $TheCommand = request_var('cmd', '');
     $Element = request_var('tech', 0);
     $PlanetRess = new ResourceUpdate();
     if ($USER['urlaubs_modus'] == 0 && !empty($TheCommand) && $bContinue) {
         switch ($TheCommand) {
             case 'cancel':
                 if (empty($USER['b_tech'])) {
                     break;
                 }
                 $costs = GetBuildingPrice($USER, $PLANET, $USER['b_tech_id']);
                 if ($PLANET['id'] == $USER['b_tech_planet']) {
                     $PLANET['metal'] += $costs['metal'];
                     $PLANET['crystal'] += $costs['crystal'];
                     $PLANET['deuterium'] += $costs['deuterium'];
                 } else {
                     $db->query("UPDATE " . PLANETS . " SET `metal` = `metal` + '" . $costs['metal'] . "', `crystal` = `crystal` + '" . $costs['crystal'] . "', `deuterium` = `deuterium` + '" . $costs['deuterium'] . "' WHERE `id` = '" . $USER['b_tech_planet'] . "';");
                 }
                 $USER['darkmatter'] += $costs['darkmatter'];
                 $USER['b_tech_id'] = 0;
                 $USER['b_tech'] = 0;
                 $USER['b_tech_planet'] = 0;
                 break;
             case 'search':
                 if (!empty($USER['b_tech']) || empty($Element) || !in_array($Element, $reslist['tech']) || $USER[$resource[$Element]] >= $pricelist[$Element]['max'] || !IsTechnologieAccessible($USER, $PLANET, $Element) || !IsElementBuyable($USER, $PLANET, $Element)) {
                     break;
                 }
                 $costs = GetBuildingPrice($USER, $PLANET, $Element);
                 $PLANET['metal'] -= $costs['metal'];
                 $PLANET['crystal'] -= $costs['crystal'];
                 $PLANET['deuterium'] -= $costs['deuterium'];
                 $USER['darkmatter'] -= $costs['darkmatter'];
                 $USER['b_tech_id'] = $Element;
                 $USER['b_tech'] = TIMESTAMP + GetBuildingTime($USER, $PLANET, $Element);
                 $USER['b_tech_planet'] = $PLANET['id'];
                 break;
         }
     }
     $PlanetRess->CalcResource();
     $PlanetRess->SavePlanetToDB();
     $ScriptInfo = array();
     foreach ($reslist['tech'] as $ID => $Element) {
         if (IsTechnologieAccessible($USER, $PLANET, $Element)) {
             $CanBeDone = IsElementBuyable($USER, $PLANET, $Element);
             if (isset($pricelist[$Element]['max']) && $USER[$resource[$Element]] >= $pricelist[$Element]['max']) {
                 $TechnoLink = "<font color=\"#FF0000\">" . $LNG['bd_maxlevel'] . "</font>";
             } elseif ($USER['b_tech_id'] == 0) {
                 $LevelToDo = 1 + $USER[$resource[$Element]];
                 if ($CanBeDone && $this->CheckLabSettingsInQueue($PLANET)) {
                     $TechnoLink = "<a href=\"game.php?page=buildings&amp;mode=research&amp;cmd=search&amp;tech=" . $Element . "\"><font color=\"#00FF00\">" . $LNG['bd_research'] . ($LevelToDo == 1 ? "" : "<br>" . $LNG['bd_lvl'] . " " . $LevelToDo) . "</font></a>";
                 } else {
                     $TechnoLink = "<font color=\"#FF0000\">" . $LNG['bd_research'] . ($LevelToDo == 1 ? "" : "<br>" . $LNG['bd_lvl'] . " " . $LevelToDo) . "</font>";
                 }
             } else {
                 if ($USER['b_tech_id'] == $Element) {
                     if ($USER['b_tech_planet'] == $PLANET['id']) {
                         $template->loadscript('research.js');
                         $ScriptInfo = array('tech_time' => $USER['b_tech'], 'tech_name' => '', 'game_name' => $CONF['game_name'], 'tech_lang' => $LNG['tech'][$USER['b_tech_id']], 'tech_home' => $USER['b_tech_planet'], 'tech_id' => $USER['b_tech_id'], 'bd_cancel' => $LNG['bd_cancel'], 'bd_ready' => $LNG['bd_ready'], 'bd_continue' => $LNG['bd_continue']);
                     } else {
                         $THEPLANET = $db->uniquequery("SELECT `name` FROM " . PLANETS . " WHERE `id` = '" . $USER['b_tech_planet'] . "';");
                         $template->loadscript('research.js');
                         $ScriptInfo = array('tech_time' => $USER['b_tech'], 'tech_name' => $LNG['bd_on'] . '<br>' . $THEPLANET['name'], 'tech_home' => $USER['b_tech_planet'], 'tech_id' => $USER['b_tech_id'], 'game_name' => $CONF['game_name'], 'tech_lang' => $LNG['tech'][$USER['b_tech_id']], 'bd_cancel' => $LNG['bd_cancel'], 'bd_ready' => $LNG['bd_ready'], 'bd_continue' => $LNG['bd_continue']);
                     }
                     $TechnoLink = '<div id="research"></div>';
                 } else {
                     $TechnoLink = '<center>-</center>';
                 }
             }
             $ResearchList[] = array('id' => $Element, 'maxinfo' => isset($pricelist[$Element]['max']) && $pricelist[$Element]['max'] != 255 ? sprintf($LNG['bd_max_lvl'], $pricelist[$Element]['max']) : '', 'name' => $LNG['tech'][$Element], 'descr' => $LNG['res']['descriptions'][$Element], 'price' => GetElementPrice($USER, $PLANET, $Element), 'time' => pretty_time(GetBuildingTime($USER, $PLANET, $Element)), 'restprice' => $this->GetRestPrice($Element), 'elvl' => $Element == 106 ? $USER['rpg_espion'] * ESPION . " (" . $LNG['tech'][610] . ")" : ($Element == 108 ? $USER['rpg_commandant'] * COMMANDANT . " (" . $LNG['tech'][611] . ")" : false), 'lvl' => $USER[$resource[$Element]], 'link' => $TechnoLink);
         }
     }
     $template->assign_vars(array('ResearchList' => $ResearchList, 'IsLabinBuild' => !$bContinue, 'ScriptInfo' => json_encode($ScriptInfo), 'bd_building_lab' => $LNG['bd_building_lab'], 'bd_remaining' => $LNG['bd_remaining'], 'bd_lvl' => $LNG['bd_lvl'], 'fgf_time' => $LNG['fgf_time']));
     $template->show('buildings_research.tpl');
 }