예제 #1
0
 protected function getNavigationData()
 {
     global $PLANET, $LNG, $USER, $THEME, $resource, $reslist;
     $config = Config::get();
     $PlanetSelect = array();
     if (isset($USER['PLANETS'])) {
         $USER['PLANETS'] = getPlanets($USER);
     }
     foreach ($USER['PLANETS'] as $PlanetQuery) {
         $PlanetSelect[$PlanetQuery['id']] = $PlanetQuery['name'] . ($PlanetQuery['planet_type'] == 3 ? " (" . $LNG['fcm_moon'] . ")" : "") . " [" . $PlanetQuery['galaxy'] . ":" . $PlanetQuery['system'] . ":" . $PlanetQuery['planet'] . "]";
     }
     $resourceTable = array();
     $resourceSpeed = $config->resource_multiplier;
     foreach ($reslist['resstype'][1] as $resourceID) {
         $resourceTable[$resourceID]['name'] = $resource[$resourceID];
         $resourceTable[$resourceID]['current'] = $PLANET[$resource[$resourceID]];
         $resourceTable[$resourceID]['max'] = $PLANET[$resource[$resourceID] . '_max'];
         if ($USER['urlaubs_modus'] == 1 || $PLANET['planet_type'] != 1) {
             $resourceTable[$resourceID]['production'] = $PLANET[$resource[$resourceID] . '_perhour'];
         } else {
             $resourceTable[$resourceID]['production'] = $PLANET[$resource[$resourceID] . '_perhour'] + $config->{$resource[$resourceID] . '_basic_income'} * $resourceSpeed;
         }
     }
     foreach ($reslist['resstype'][2] as $resourceID) {
         $resourceTable[$resourceID]['name'] = $resource[$resourceID];
         $resourceTable[$resourceID]['used'] = $PLANET[$resource[$resourceID] . '_used'];
         $resourceTable[$resourceID]['max'] = $PLANET[$resource[$resourceID]];
     }
     foreach ($reslist['resstype'][3] as $resourceID) {
         $resourceTable[$resourceID]['name'] = $resource[$resourceID];
         $resourceTable[$resourceID]['current'] = $USER[$resource[$resourceID]];
     }
     $themeSettings = $THEME->getStyleSettings();
     $this->assign(array('PlanetSelect' => $PlanetSelect, 'new_message' => $USER['messages'], 'vacation' => $USER['urlaubs_modus'] ? _date($LNG['php_tdformat'], $USER['urlaubs_until'], $USER['timezone']) : false, 'delete' => $USER['db_deaktjava'] ? sprintf($LNG['tn_delete_mode'], _date($LNG['php_tdformat'], $USER['db_deaktjava'] + $config->del_user_manually * 86400), $USER['timezone']) : false, 'darkmatter' => $USER['darkmatter'], 'current_pid' => $PLANET['id'], 'image' => $PLANET['image'], 'resourceTable' => $resourceTable, 'shortlyNumber' => $themeSettings['TOPNAV_SHORTLY_NUMBER'], 'closed' => !$config->game_disable, 'hasBoard' => filter_var($config->forum_url, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED), 'hasAdminAccess' => !empty(Session::load()->adminAccess), 'hasGate' => $PLANET[$resource[43]] > 0));
 }
예제 #2
0
파일: common.php 프로젝트: bergi9/2Moons
            HTTP::redirectToUniverse($USER['universe']);
        }
        $session->selectActivePlanet();
        $sql = "SELECT * FROM %%PLANETS%% WHERE id = :planetId;";
        $PLANET = $db->selectSingle($sql, array(':planetId' => $session->planetId));
        if (empty($PLANET)) {
            $sql = "SELECT * FROM %%PLANETS%% WHERE id = :planetId;";
            $PLANET = $db->selectSingle($sql, array(':planetId' => $USER['id_planet']));
            if (empty($PLANET)) {
                throw new Exception("Main Planet does not exist!");
            } else {
                $session->planetId = $USER['id_planet'];
            }
        }
        $USER['factor'] = getFactors($USER);
        $USER['PLANETS'] = getPlanets($USER);
    } elseif (MODE === 'ADMIN') {
        error_reporting(E_ERROR | E_WARNING | E_PARSE);
        $USER['rights'] = unserialize($USER['rights']);
        $LNG->includeData(array('ADMIN', 'CUSTOM'));
    }
} elseif (MODE === 'LOGIN') {
    $LNG = new Language();
    $LNG->getUserAgentLanguage();
    $LNG->includeData(array('L18N', 'INGAME', 'PUBLIC', 'CUSTOM'));
} elseif (MODE === 'CHAT') {
    $session = Session::load();
    if (!$session->isValidSession()) {
        HTTP::redirectTo('index.php?code=3');
    }
}
 function show()
 {
     global $CONF, $LNG, $PLANET, $USER, $resource, $UNI;
     if ($USER['harvest_delay'] < TIMESTAMP - 24 * 60 * 60) {
         if ($USER['harvest_time'] < 5) {
             $time = TIMESTAMP;
             $GLOBALS['DATABASE']->query("UPDATE `uni1_users` SET `harvest_time` = 5,  `harvest_delay` = " . $time . " where `id` = " . $USER['id'] . ";");
             $this->printMessage("We are setting back your harvest counters to 5.", true, array('game.php?page=harvest', 2));
             die;
         } else {
             $time = TIMESTAMP;
             $GLOBALS['DATABASE']->query("UPDATE `uni1_users` SET `harvest_delay` = " . $time . " where `id` = " . $USER['id'] . ";");
             $this->printMessage("Loading your data.", true, array('game.php?page=harvest', 2));
             die;
         }
     }
     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;
     }
     if ($_POST) {
         $mode = HTTP::_GP('con', '');
         switch ($mode) {
             case 'extra':
                 $take = HTTP::_GP('buy', 0);
                 $take = $GLOBALS['DATABASE']->escape($take);
                 if (!array_key_exists($take, $this->HarvestPrice)) {
                     $this->printMessage("Invalid Option", true, array('?page=Harvest', 3));
                 } else {
                     //option is ok . go forward
                     //enough dm ?
                     if ($USER['darkmatter'] < $this->HarvestPrice[$take]) {
                         $this->printMessage("Not enough DM", true, array('?page=Harvest', 3));
                         die;
                     }
                     $USER['darkmatter'] -= $this->HarvestPrice[$take];
                     $GLOBALS['DATABASE']->query("Update " . USERS . " SET `harvest_time` = `harvest_time` + " . $take . " WHERE `id` = " . $USER['id'] . " ; ");
                     $this->printMessage("You have bought " . $take . " Harvest Points", true, array('?page=Harvest', 3));
                     die;
                 }
                 break;
             case 'gather':
                 if ($USER['harvest_time'] == 0) {
                     $this->printMessage("No Harvest Points Left!", true, array('game.php?page=Harvest', 2));
                     die;
                 }
                 if (!isset($_POST['check_planet']) && !isset($_POST['check_moons'])) {
                     $this->redirectTo('game.php?page=harvest');
                 }
                 if (!isset($_POST['check_planet'])) {
                     $_POST['check_planet'] = array();
                 }
                 foreach ($_POST['check_planet'] as $ID => $Value) {
                     $sur = $GLOBALS['DATABASE']->uniquequery("SELECT M7 FROM " . PLANETS . " where `id` = '" . $Value . "';");
                     $GLOBALS['DATABASE']->multi_query("LOCK TABLE " . PLANETS . " WRITE; UPDATE " . PLANETS . " SET `M7` = M7 - " . $sur['M7'] . " WHERE `id` = '" . $Value . "'; UNLOCK TABLES;");
                     $PLANET['M7'] += $sur['M7'];
                 }
                 if (!isset($_POST['check_moons'])) {
                     $_POST['check_moons'] = array();
                 }
                 foreach ($_POST['check_moons'] as $ID => $Value) {
                     $surr = $GLOBALS['DATABASE']->uniquequery("SELECT M7 FROM " . PLANETS . " where `id` = '" . $Value . "';");
                     $GLOBALS['DATABASE']->multi_query("LOCK TABLE " . PLANETS . " WRITE; UPDATE " . PLANETS . " SET `M7` = M7 - " . $surr['M7'] . " WHERE `id` = '" . $Value . "'; UNLOCK TABLES;");
                     $PLANET['M7'] += $surr['M7'];
                 }
                 $GLOBALS['DATABASE']->query("UPDATE " . USERS . " SET `harvest_time` = `harvest_time` - 1 where `id` = '" . $USER['id'] . "';");
                 $this->printMessage($LNG['h_ok'], true, array('game.php?page=harvest', 4));
                 break;
         }
     }
     $Planets = array();
     $Moons = array();
     if (isset($USER['PLANETS'])) {
         $USER['PLANETS'] = getPlanets($USER);
     }
     foreach ($USER['PLANETS'] as $ID => $PlanetQuery) {
         if ($ID == $PLANET['id']) {
             continue;
         }
         if ($PlanetQuery['planet_type'] == 3) {
             $Moons[$PlanetQuery['id']] = " [" . $PlanetQuery['galaxy'] . ":" . $PlanetQuery['system'] . ":" . $PlanetQuery['planet'] . "]";
         } elseif ($PlanetQuery['planet_type'] == 1) {
             $Planets[$PlanetQuery['id']] = " [" . $PlanetQuery['galaxy'] . ":" . $PlanetQuery['system'] . ":" . $PlanetQuery['planet'] . "]";
         }
     }
     $this->tplObj->loadscript("jquery.countdown.js");
     $this->tplObj->assign_vars(array('prices' => $this->HarvestPrice, 'PlanetsList' => $Planets, 'MoonsList' => $Moons, 'harvest' => $USER['harvest_time'], 'p_state' => $USER['harvest_time'], 'p_delay' => $USER['harvest_delay'] + 24 * 60 * 60 < TIMESTAMP ? true : $USER['harvest_delay'] + 24 * 60 * 60 - TIMESTAMP));
     $this->display('page.harvestfleet.default.tpl');
 }
 function show()
 {
     global $CONF, $LNG, $PLANET, $USER, $resource, $UNI;
     $act = HTTP::_GP('act', '');
     $transCoasts = 2500;
     if ($act == "take") {
         if (!isset($_POST['check_planet']) && !isset($_POST['check_moons'])) {
             $this->redirectTo('game.php?page=Reduceresources');
         }
         if ($transCoasts > $USER['darkmatter']) {
             $this->printMessage('Not enough darkmater', true, array('game.php?page=harvest', 4));
         } else {
             $USER['darkmatter'] -= $transCoasts;
             if (!isset($_POST['check_planet'])) {
                 $_POST['check_planet'] = array();
             }
             foreach ($_POST['check_planet'] as $ID => $Value) {
                 $sur = $GLOBALS['DATABASE']->uniquequery("SELECT id, metal, crystal, deuterium FROM " . PLANETS . " where `id` = '" . $Value . "';");
                 $GLOBALS['DATABASE']->multi_query("LOCK TABLE " . PLANETS . " WRITE; UPDATE " . PLANETS . " SET `metal` = metal - " . $sur['metal'] . ", `crystal` = crystal - " . $sur['crystal'] . ", `deuterium` = deuterium - " . $sur['deuterium'] . " WHERE `id` = '" . $Value . "'; UNLOCK TABLES;");
                 if ($sur['id'] == $PLANET['id']) {
                     continue;
                 }
                 $PLANET['metal'] += $sur['metal'];
                 $PLANET['crystal'] += $sur['crystal'];
                 $PLANET['deuterium'] += $sur['deuterium'];
             }
             if (!isset($_POST['check_moons'])) {
                 $_POST['check_moons'] = array();
             }
             foreach ($_POST['check_moons'] as $ID => $Value) {
                 $sur = $GLOBALS['DATABASE']->uniquequery("SELECT id, metal, crystal, deuterium FROM " . PLANETS . " where `id` = '" . $Value . "';");
                 $GLOBALS['DATABASE']->multi_query("LOCK TABLE " . PLANETS . " WRITE; UPDATE " . PLANETS . " SET `metal` = metal - " . $sur['metal'] . ", `crystal` = crystal - " . $sur['crystal'] . ", `deuterium` = deuterium - " . $sur['deuterium'] . " WHERE `id` = '" . $Value . "'; UNLOCK TABLES;");
                 if ($sur['id'] == $PLANET['id']) {
                     continue;
                 }
                 $PLANET['metal'] += $sur['metal'];
                 $PLANET['crystal'] += $sur['crystal'];
                 $PLANET['deuterium'] += $sur['deuterium'];
             }
             $this->printMessage('All your ressource are gathered on the planet', true, array('game.php?page=Reduceresources', 4));
         }
     } else {
         $Planets = array();
         $Moons = array();
         if (isset($USER['PLANETS'])) {
             $USER['PLANETS'] = getPlanets($USER);
         }
         foreach ($USER['PLANETS'] as $ID => $PlanetQuery) {
             if ($ID == $PLANET['id']) {
                 continue;
             }
             if ($PlanetQuery['planet_type'] == 3) {
                 $Moons[$PlanetQuery['id']] = $PlanetQuery['name'] . " [" . $PlanetQuery['galaxy'] . ":" . $PlanetQuery['system'] . ":" . $PlanetQuery['planet'] . "]";
             } elseif ($PlanetQuery['planet_type'] == 1) {
                 $Planets[$PlanetQuery['id']] = $PlanetQuery['name'] . " [" . $PlanetQuery['galaxy'] . ":" . $PlanetQuery['system'] . ":" . $PlanetQuery['planet'] . "]";
             }
         }
         //			$this->tplObj->loadscript("jquery.countdown.js");
         $this->tplObj->assign_vars(array('PlanetsList' => $Planets, 'MoonsList' => $Moons));
         $this->display('page.harvest.default.tpl');
     }
 }
예제 #5
0
 protected function getNavigationData()
 {
     global $PLANET, $LNG, $USER, $THEME, $resource, $reslist;
     if ($PLANET[$resource[43]] > 0) {
         $this->tplObj->loadscript("gate.js");
     }
     $this->tplObj->loadscript("topnav.js");
     $PlanetSelect = array();
     if (isset($USER['PLANETS'])) {
         $USER['PLANETS'] = getPlanets($USER);
     }
     foreach ($USER['PLANETS'] as $CurPlanetID => $PlanetQuery) {
         $PlanetSelect[$PlanetQuery['id']] = $PlanetQuery['name'] . ($PlanetQuery['planet_type'] == 3 ? " (" . $LNG['fcm_moon'] . ")" : "") . " [" . $PlanetQuery['galaxy'] . ":" . $PlanetQuery['system'] . ":" . $PlanetQuery['planet'] . "]";
     }
     $resourceTable = array();
     $resourceSpeed = Config::get('resource_multiplier');
     foreach ($reslist['resstype'][1] as $resourceID) {
         $resourceTable[$resourceID]['name'] = $resource[$resourceID];
         $resourceTable[$resourceID]['current'] = $PLANET[$resource[$resourceID]];
         $resourceTable[$resourceID]['max'] = $PLANET[$resource[$resourceID] . '_max'];
         $resourceTable[$resourceID]['bunker'] = $PLANET[$resource[$resourceID] . '_bunker'];
         $resourceTable[$resourceID]['percent'] = round($PLANET[$resource[$resourceID]] * 100 / $PLANET[$resource[$resourceID] . '_max']);
         if ($USER['urlaubs_modus'] == 1 || $PLANET['planet_type'] != 1) {
             $resourceTable[$resourceID]['production'] = $PLANET[$resource[$resourceID] . '_perhour'];
         } else {
             $resourceTable[$resourceID]['production'] = $PLANET[$resource[$resourceID] . '_perhour'] + Config::get($resource[$resourceID] . '_basic_income') * $resourceSpeed;
         }
     }
     foreach ($reslist['resstype'][2] as $resourceID) {
         $resourceTable[$resourceID]['name'] = $resource[$resourceID];
         $resourceTable[$resourceID]['used'] = $PLANET[$resource[$resourceID] . '_used'];
         $resourceTable[$resourceID]['max'] = $PLANET[$resource[$resourceID]];
     }
     $themeSettings = $THEME->getStyleSettings();
     $this->tplObj->assign_vars(array('PlanetSelect' => $PlanetSelect, 'new_message' => $USER['messages'], 'playerName' => $USER['username'], 'Alliance_tag' => $this->getAllianceTag($USER['ally_id']), 'custom_color' => $USER['custom_color'], 'vacation' => $USER['urlaubs_modus'] ? _date($LNG['php_tdformat'], $USER['urlaubs_until'], $USER['timezone']) : false, 'delete' => $USER['db_deaktjava'] ? sprintf($LNG['tn_delete_mode'], _date($LNG['php_tdformat'], $USER['db_deaktjava'] + Config::get('del_user_manually') * 86400), $USER['timezone']) : false, 'darkmatter' => $USER['darkmatter'], 'current_pid' => $PLANET['id'], 'image' => $PLANET['image'], 'resourceTable' => $resourceTable, 'shortlyNumber' => $themeSettings['TOPNAV_SHORTLY_NUMBER'], 'closed' => !Config::get('game_disable'), 'hasBoard' => filter_var(Config::get('forum_url'), FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED), 'hasAdminAccess' => isset($_SESSION['admin_login'])));
 }
예제 #6
0
 protected function getNavigationData()
 {
     global $PLANET, $LNG, $USER, $THEME, $resource, $reslist;
     $buscarTick = $GLOBALS['DATABASE']->query("SELECT tick FROM " . CONFIG . "");
     $tickatual = $GLOBALS['DATABASE']->fetch_array($buscarTick);
     $tickatual = $tickatual['tick'];
     if ($PLANET[$resource[43]] > 0) {
         $this->tplObj->loadscript("gate.js");
     }
     $this->tplObj->loadscript("topnav.js");
     $this->tplObj->loadscript("planetmenu.js");
     $PlanetSelect = array();
     if (isset($USER['PLANETS'])) {
         $USER['PLANETS'] = getPlanets($USER);
     }
     foreach ($USER['PLANETS'] as $CurPlanetID => $PlanetQuery) {
         $PlanetSelect[$PlanetQuery['id']] = $PlanetQuery['name'] . ($PlanetQuery['planet_type'] == 3 ? " (" . $LNG['fcm_moon'] . ")" : "") . " [" . $PlanetQuery['galaxy'] . ":" . $PlanetQuery['system'] . ":" . $PlanetQuery['planet'] . "]";
     }
     $resourceTable = array();
     $resourceSpeed = Config::get('resource_multiplier');
     foreach ($reslist['resstype'][1] as $resourceID) {
         $resourceTable[$resourceID]['name'] = $resource[$resourceID];
         $resourceTable[$resourceID]['current'] = $PLANET[$resource[$resourceID]];
         $resourceTable[$resourceID]['max'] = $PLANET[$resource[$resourceID] . '_max'];
         $resourceTable[$resourceID]['percent'] = round($PLANET[$resource[$resourceID]] * 100 / $PLANET[$resource[$resourceID] . '_max']);
         if ($PLANET['planet_type'] == 1) {
             $resourceTable[$resourceID]['information'] = pretty_number($PLANET[$resource[$resourceID] . '_perhour'] + Config::get($resource[$resourceID] . '_basic_income') * $resourceSpeed);
             $resourceTable[$resourceID]['informationd'] = pretty_number(($PLANET[$resource[$resourceID] . '_perhour'] + Config::get($resource[$resourceID] . '_basic_income') * $resourceSpeed) * 24);
             $resourceTable[$resourceID]['informationz'] = pretty_number(($PLANET[$resource[$resourceID] . '_perhour'] + Config::get($resource[$resourceID] . '_basic_income') * $resourceSpeed) * 24 * 7);
         } else {
             $resourceTable[$resourceID]['information'] = 0;
             $resourceTable[$resourceID]['informationd'] = 0;
             $resourceTable[$resourceID]['informationz'] = 0;
         }
         if ($USER['urlaubs_modus'] == 1 || $PLANET['planet_type'] != 1) {
             $resourceTable[$resourceID]['production'] = $PLANET[$resource[$resourceID] . '_perhour'];
         } else {
             $resourceTable[$resourceID]['production'] = $PLANET[$resource[$resourceID] . '_perhour'] + Config::get($resource[$resourceID] . '_basic_income') * $resourceSpeed;
         }
     }
     foreach ($reslist['resstype'][2] as $resourceID) {
         $resourceTable[$resourceID]['name'] = $resource[$resourceID];
         $resourceTable[$resourceID]['used'] = $PLANET[$resource[$resourceID] . '_used'];
         $resourceTable[$resourceID]['max'] = $PLANET[$resource[$resourceID]];
         $resourceTable[$resourceID]['used1'] = abs($PLANET[$resource[$resourceID] . '_used']);
         if ($PLANET[$resource[$resourceID]] == 0) {
             $resourceTable[$resourceID]['percent'] = 0;
             $resourceTable[$resourceID]['percenta'] = 0;
         } else {
             $resourceTable[$resourceID]['percent'] = 100 / $PLANET[$resource[$resourceID]] * ($PLANET[$resource[$resourceID]] - abs($PLANET[$resource[$resourceID] . '_used'])) / 2;
             $resourceTable[$resourceID]['percenta'] = abs(100 / $PLANET[$resource[$resourceID]] * ($PLANET[$resource[$resourceID]] - abs($PLANET[$resource[$resourceID] . '_used'])) / 2);
         }
     }
     foreach ($reslist['resstype'][3] as $resourceID) {
         $resourceTable[$resourceID]['name'] = $resource[$resourceID];
         $resourceTable[$resourceID]['current'] = $USER[$resource[$resourceID]];
     }
     $themeSettings = $THEME->getStyleSettings();
     $this->tplObj->assign_vars(array('PlanetSelect' => $PlanetSelect, 'new_message' => $USER['messages'], 'vacation' => $USER['urlaubs_modus'] ? _date($LNG['php_tdformat'], $USER['urlaubs_until'], $USER['timezone']) : false, 'delete' => $USER['db_deaktjava'] ? sprintf($LNG['tn_delete_mode'], _date($LNG['php_tdformat'], $USER['db_deaktjava'] + Config::get('del_user_manually') * 86400), $USER['timezone']) : false, 'darkmatter' => $USER['darkmatter'], 'antimatte' => $USER['antimatter'], 'antimatter' => pretty_number($USER['antimatter']), 'darkmatte' => pretty_number($USER['darkmatter']), 'current_pid' => $PLANET['id'], 'image' => $PLANET['image'], 'resourceTable' => $resourceTable, 'shortlyNumber' => $themeSettings['TOPNAV_SHORTLY_NUMBER'], 'closed' => !Config::get('game_disable'), 'hasBoard' => filter_var(Config::get('forum_url'), FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED), 'hasAdminAccess' => isset($_SESSION['admin_login']), 'servertime' => _date("M D d H:i:s", TIMESTAMP, $USER['timezone']), 'tickatual' => $tickatual, 'AUPLANETS' => $PLANET['name'], 'AUGAL' => $PLANET['galaxy'], 'AUST' => $PLANET['system'], 'AUPLA' => $PLANET['planet'], 'bonus_timer' => $USER['bonus_timer'], 'usr_id' => $USER['id'], 'TIME' => TIMESTAMP, 'premium' => IsPremiumUser($USER)));
 }