Ejemplo n.º 1
0
 function execute()
 {
     $connections = Core::getConfig('db');
     $result = array();
     foreach ($connections as $connect) {
         $result[] = $connect;
     }
     $this->smarty->assign('connections', $result);
 }
 function execute()
 {
     $domain = Core::getConfig('domain');
     $domain_list = array();
     foreach ($domain as $value) {
         //            $domain_list[] = array('name' => $value, 'status' => file_get_contents('http://'.$value.'/administrator/test_domain/') == 'ok' ? 1 : 0);
         $domain_list[] = array('name' => $value);
     }
     $this->smarty->assign('domain_list', $domain_list);
     $this->smarty->assign('route', Core::getConfigRoute());
 }
Ejemplo n.º 3
0
 /**
  * Shows the pillory.
  *
  * @return Bengine_Comm_Controller_Pillory
  */
 public function indexAction()
 {
     Core::getTPL()->clearHTMLHeaderFiles();
     Core::getTPL()->addHTMLHeaderFile("game.css", "css");
     Core::getTPL()->addHTMLHeaderFile("lib/jquery.js", "js");
     $result = Core::getQuery()->select("ban_u", array("banid"));
     $pagination = new Pagination(Core::getConfig()->get("PILLORY_ITEMS_PER_PAGE"), $result->rowCount());
     $pagination->setConfig("page_url", Core::getLang()->getOpt("langcode") . "/pillory/index/%d")->setConfig("main_element_class", "pagination center-table")->setMaxPagesToShow(Core::getConfig()->get("MAX_PILLORY_PAGES"))->setCurrentPage($this->getParam("1"))->setConfig("base_url", Core::getLang()->getOpt("langcode") . "/pillory");
     Core::getTPL()->addLoop("bans", $this->getBans($pagination->getStart(), Core::getConfig()->get("PILLORY_ITEMS_PER_PAGE")));
     $this->assign("pagination", $pagination);
     return $this;
 }
Ejemplo n.º 4
0
 /**
  * Executes all events that are queued, but max 1000 events.
  *
  * @return Bengine_Game_Cronjob_EventExecution
  */
 protected function _execute()
 {
     require_once "Bengine/Game.php";
     $raceConditionKey = Str::substring(md5(microtime(true)), 0, 16);
     /* @var Bengine_Game_Model_Collection_Event $collection */
     $collection = Application::getModel("game/event")->getCollection();
     $collection->addRaceConditionFilter($raceConditionKey, Core::getConfig()->get("CRONJOB_MAX_EVENT_EXECUTION"));
     $collection->executeAll();
     if ($collection->count() > 0) {
         Core::getQuery()->delete("events", "prev_rc = ?", null, null, array($raceConditionKey));
     }
     return $this;
 }
Ejemplo n.º 5
0
 /**
  * Index action.
  *
  * @return Bengine_Game_Controller_Resource
  */
 protected function indexAction()
 {
     Hook::event("ShowResourcesBefore", array($this));
     Core::getTPL()->addLoop("data", $this->data);
     $productFactor = (double) Core::getConfig()->get("PRODUCTION_FACTOR");
     $isMoon = (bool) Game::getPlanet()->getData("ismoon");
     // Basic prod
     $basicMetal = $isMoon ? 0 : Core::getOptions()->get("METAL_BASIC_PROD");
     Core::getTPL()->assign("basicMetal", fNumber($basicMetal * $productFactor));
     $basicSilicon = $isMoon ? 0 : Core::getOptions()->get("SILICON_BASIC_PROD");
     Core::getTPL()->assign("basicSilicon", fNumber($basicSilicon * $productFactor));
     $basicHydrogen = $isMoon ? 0 : Core::getOptions()->get("HYDROGEN_BASIC_PROD");
     Core::getTPL()->assign("basicHydrogen", fNumber($basicHydrogen * $productFactor));
     Core::getTPL()->assign("sats", Game::getPlanet()->getBuilding(Bengine_Game_Planet::SOLAR_SAT_ID));
     if (Game::getPlanet()->getBuilding(Bengine_Game_Planet::SOLAR_SAT_ID) > 0) {
         Core::getTPL()->assign("satsNum", fNumber(Game::getPlanet()->getBuilding(Bengine_Game_Planet::SOLAR_SAT_ID)));
         $solarSatProduction = Game::getPlanet()->getBuildingProd("energy", Bengine_Game_Planet::SOLAR_SAT_ID);
         Core::getTPL()->assign("satsProd", fNumber($solarSatProduction));
         Core::getLang()->assign("prodPerSat", floor($solarSatProduction / Game::getPlanet()->getBuilding(Bengine_Game_Planet::SOLAR_SAT_ID)));
         Core::getTPL()->assign("solar_satellite_prod", Game::getPlanet()->getData("solar_satellite_prod"));
     }
     // Storage capacity
     Core::getTPL()->assign("storageMetal", fNumber(Game::getPlanet()->getStorage("metal") / 1000) . "k");
     Core::getTPL()->assign("storageSilicon", fNumber(Game::getPlanet()->getStorage("silicon") / 1000) . "k");
     Core::getTPL()->assign("sotrageHydrogen", fNumber(Game::getPlanet()->getStorage("hydrogen") / 1000) . "k");
     // Total prod
     Core::getTPL()->assign("totalMetal", fNumber(Game::getPlanet()->getProd("metal")));
     Core::getTPL()->assign("totalSilicon", fNumber(Game::getPlanet()->getProd("silicon")));
     Core::getTPL()->assign("totalHydrogen", fNumber(Game::getPlanet()->getProd("hydrogen")));
     Core::getTPL()->assign("totalEnergy", fNumber(Game::getPlanet()->getEnergy()));
     // Daily prod
     Core::getTPL()->assign("dailyMetal", fNumber(Game::getPlanet()->getProd("metal") * 24));
     Core::getTPL()->assign("dailySilicon", fNumber(Game::getPlanet()->getProd("silicon") * 24));
     Core::getTPL()->assign("dailyHydrogen", fNumber(Game::getPlanet()->getProd("hydrogen") * 24));
     // Weekly prod
     Core::getTPL()->assign("weeklyMetal", fNumber(Game::getPlanet()->getProd("metal") * 168));
     Core::getTPL()->assign("weeklySilicon", fNumber(Game::getPlanet()->getProd("silicon") * 168));
     Core::getTPL()->assign("weeklyHydrogen", fNumber(Game::getPlanet()->getProd("hydrogen") * 168));
     // Monthly prod
     Core::getTPL()->assign("monthlyMetal", fNumber(Game::getPlanet()->getProd("metal") * 720));
     Core::getTPL()->assign("monthlySilicon", fNumber(Game::getPlanet()->getProd("silicon") * 720));
     Core::getTPL()->assign("monthlyHydrogen", fNumber(Game::getPlanet()->getProd("hydrogen") * 720));
     $selectBox = "";
     for ($i = 10; $i >= 0; $i--) {
         $selectBox .= createOption($i * 10, $i * 10, 0);
     }
     Core::getTPL()->assign("selectProd", $selectBox);
     Hook::event("ShowResourcesAfter");
     $this->assign("updateAction", BASE_URL . "game/" . SID . "/Resource/Update");
     return $this;
 }
Ejemplo n.º 6
0
 /**
  * Perfom log out proccess.
  *
  * @return Bengine_Game_Controller_Logout
  */
 protected function indexAction()
 {
     Hook::event("DoLogout");
     Core::getCache()->cleanUserCache(Core::getUser()->get("userid"));
     Core::getQuery()->update("sessions", array("logged" => 0), "userid = ?", array(Core::getUser()->get("userid")));
     if (Core::getConfig()->exists("SESSION_SAVING_DAYS")) {
         $days = (int) Core::getConfig()->get("SESSION_SAVING_DAYS");
     } else {
         $days = self::SESSION_SAVING_DAYS;
     }
     $deleteTime = TIME - 86400 * $days;
     Core::getQuery()->delete("sessions", "time < ?", null, null, array($deleteTime));
     Game::unlock();
     $this->redirect(BASE_URL);
     return $this;
 }
    /**
     * Show Google Analytics code.
     *
     * @return string
     */
    public function onFrontHtmlEnd()
    {
        if (Core::getConfig()->get("GOOGLE_ANALYTICS_ACCOUNT")) {
            return '<script type="text/javascript">
//<![CDATA[
var gaJsHost=(("https:"==document.location.protocol)?"https://ssl.":"http://www.");document.write(unescape("%3Cscript src=\'"+gaJsHost+"google-analytics.com/ga.js\' type=\'text/javascript\'%3E%3C/script%3E"));
//]]>
</script>
<script type="text/javascript">
//<![CDATA[
try{var pageTracker=_gat._getTracker("' . Core::getConfig()->get("GOOGLE_ANALYTICS_ACCOUNT") . '");pageTracker._trackPageview();}catch(err){}
//]]>
</script>';
        }
        return null;
    }
Ejemplo n.º 8
0
 /**
  * Sends the reminder mails.
  *
  * @return Bengine_Game_Cronjob_Reminder
  */
 protected function sendReminders()
 {
     $time = TIME - Core::getConfig()->get("REMINDER_MAIL_TIME") * 86400;
     $select = new Recipe_Database_Select();
     $select->from("user")->attributes(array("username", "email", "last"))->where("last < ?", $time);
     $result = $select->getStatement();
     Core::getLang()->load(array("Registration"));
     foreach ($result->fetchAll() as $row) {
         Core::getLang()->assign("username", $row["username"]);
         Core::getLang()->assign("reminderLast", Date::timeToString(2, $row["last"]));
         $template = new Recipe_Email_Template("reminder");
         $mail = new Email(array($row["email"] => $row["username"]), Core::getLang()->get("REMINDER_MAIL_SUBJECT"));
         $template->send($mail);
     }
     return $this;
 }
Ejemplo n.º 9
0
 static function getFiles()
 {
     $files = File::readDirFiles(TEMP_DIR);
     $config = Core::getConfig('temp');
     $info = array();
     foreach ($files as $name => $dir) {
         $file = new File(TEMP_DIR . DS . $name);
         $file_info = array();
         $file_info['name'] = str_replace('.' . $file->extension, '', $file->name);
         $file_info['size'] = $file->size;
         $file_info['create'] = $file->create_date;
         $file_info['info'] = array_key_exists($file_info['name'], $config) ? $config[$file_info['name']] : '[`Title file cache no information`]';
         $info[] = $file_info;
     }
     return $info;
 }
Ejemplo n.º 10
0
 /**
  * Starts the application.
  *
  * @return void
  */
 public function run()
 {
     Hook::event("PreRun");
     self::loadMeta();
     Core::getTPL()->assign("charset", CHARACTER_SET);
     Core::getTPL()->assign("langcode", Core::getLang()->getOpt("langcode"));
     Core::getTPL()->assign("formaction", Core::getRequest()->getRequestedUrl());
     $pageTitle = array();
     if ($titlePrefix = Core::getConfig()->get("TITLE_PREFIX")) {
         $pageTitle[] = $titlePrefix;
     }
     $pageTitle[] = Core::getConfig()->get("pagetitle");
     if ($titleSuffix = Core::getConfig()->get("TITLE_SUFFIX")) {
         $pageTitle[] = $titleSuffix;
     }
     Core::getTPL()->assign("pageTitle", implode(Core::getConfig()->get("TITLE_GLUE"), $pageTitle));
     Hook::event("PostRun");
     return;
 }
Ejemplo n.º 11
0
 /**
  * Removes inactive users.
  *
  * @return Bengine_Game_Cronjob_RemoveInactiveUser
  */
 protected function removeInactiveUsers()
 {
     $deleteTime = TIME - Core::getConfig()->get("USER_DELETE_TIME") * 86400;
     $where = Core::getDB()->quoteInto("(u.last < ? OR (u.`delete` < '" . TIME . "' AND u.`delete` > '0')) AND ((u2g.usergroupid != '2' AND u2g.usergroupid != '4') OR u2g.usergroupid IS NULL)", $deleteTime);
     $result = Core::getQuery()->select("user u", "u.userid", "LEFT JOIN " . PREFIX . "user2group u2g ON (u2g.userid = u.userid)", $where);
     foreach ($result->fetchAll() as $row) {
         $userid = $row["userid"];
         $_result = Core::getQuery()->select("planet", array("planetid", "ismoon"), "", Core::getDB()->quoteInto("userid = ?", $userid));
         foreach ($_result->fetchAll() as $_row) {
             if (!$_row["ismoon"]) {
                 deletePlanet($_row["planetid"], $userid, false);
             }
         }
         $_result->closeCursor();
         $_result = Core::getQuery()->select("alliance", "aid", "", Core::getDB()->quoteInto("founder = ?", $userid));
         if ($_row = $_result->fetchRow()) {
             deleteAlliance($_row["aid"]);
         }
         $_result->closeCursor();
         Core::getQuery()->delete("user", "userid = ?", null, null, array($userid));
     }
     $result->closeCursor();
     return $this;
 }
Ejemplo n.º 12
0
 /**
  * Index action.
  *
  * @return Bengine_Game_Controller_Index
  */
 protected function indexAction()
 {
     Core::getTPL()->addHTMLHeaderFile("lib/jquery.countdown.js", "js");
     Core::getTPL()->addHTMLHeaderFile("lib/jquery.news.js", "js");
     $this->buildingEvent = Game::getEH()->getCurPlanetBuildingEvent();
     // Messages
     $result = Core::getQuery()->select("message", "msgid", "", Core::getDB()->quoteInto("`receiver` = ? AND `read` = '0'", Core::getUser()->get("userid")));
     $msgs = $result->rowCount();
     $result->closeCursor();
     Core::getTPL()->assign("unreadmsg", $msgs);
     if ($msgs == 1) {
         Core::getTPL()->assign("newMessages", Link::get("game/" . SID . "/MSG", Core::getLanguage()->getItem("F_NEW_MESSAGE")));
     } else {
         if ($msgs > 1) {
             Core::getTPL()->assign("newMessages", Link::get("game/" . SID . "/MSG", sprintf(Core::getLanguage()->getItem("F_NEW_MESSAGES"), $msgs)));
         }
     }
     // Fleet events
     $fleetEvent = Game::getEH()->getFleetEvents();
     $fe = array();
     if ($fleetEvent) {
         foreach ($fleetEvent as $f) {
             $fe[$f["eventid"]] = $this->parseEvent($f);
             if (!is_array($fe[$f["eventid"]])) {
                 unset($fe[$f["eventid"]]);
             }
         }
         Hook::event("MainFleetEventsOutput", array(&$fe));
     }
     Core::getTPL()->addLoop("fleetEvents", $fe);
     Core::getTPL()->assign("serverTime", Date::timeToString(1, TIME, "", false));
     Core::getTPL()->assign("buildingEvent", $this->buildingEvent);
     Core::getTPL()->assign("occupiedFields", Game::getPlanet()->getFields(true));
     Core::getTPL()->assign("planetImage", Image::getImage("planets/" . Game::getPlanet()->getData("picture") . Core::getConfig()->get("PLANET_IMG_EXT"), Game::getPlanet()->getData("planetname"), "200px", "200px"));
     Core::getTPL()->assign("freeFields", Game::getPlanet()->getMaxFields());
     Core::getTPL()->assign("planetDiameter", fNumber(Game::getPlanet()->getData("diameter")));
     Core::getTPL()->assign("planetNameLink", Link::get("game/" . SID . "/Index/PlanetOptions", Game::getPlanet()->getData("planetname")));
     Core::getTPL()->assign("planetPosition", Game::getPlanet()->getCoords());
     Core::getTPL()->assign("planetTemp", Game::getPlanet()->getData("temperature"));
     Core::getTPL()->assign("points", Link::get("game/" . SID . "/Ranking", fNumber(floor(Core::getUser()->get("points")))));
     // Points
     $result = Core::getQuery()->select("user", "userid");
     Core::getLang()->assign("totalUsers", fNumber($result->rowCount()));
     $result->closeCursor();
     $where = Core::getDB()->quoteInto("(`username` < ? AND `points` >= {points}) OR `points` > {points}", array(Core::getUser()->get("username")));
     $where = str_replace("{points}", (double) Core::getUser()->get("points"), $where);
     $result = Core::getQuery()->select("user", array("COUNT(`userid`)+1 AS rank"), "", $where, "", 1);
     Core::getLang()->assign("rank", fNumber($result->fetchColumn()));
     $result->closeCursor();
     if (Game::getPlanet()->getData("moonid") > 0) {
         if (Game::getPlanet()->getData("ismoon")) {
             // Planet has moon
             $where = Core::getDB()->quoteInto("g.galaxy = ? AND g.system = ? AND g.position = ?", array(Game::getPlanet()->getData("moongala"), Game::getPlanet()->getData("moonsys"), Game::getPlanet()->getData("moonpos")));
             $result = Core::getQuery()->select("galaxy g", array("p.planetid", "p.planetname", "p.picture"), "LEFT JOIN " . PREFIX . "planet p ON (p.planetid = g.planetid)", $where);
         } else {
             // Planet of current moon
             $where = Core::getDB()->quoteInto("g.galaxy = ? AND g.system = ? AND g.position = ?", array(Game::getPlanet()->getData("galaxy"), Game::getPlanet()->getData("system"), Game::getPlanet()->getData("position")));
             $result = Core::getQuery()->select("galaxy g", array("p.planetid", "p.planetname", "p.picture"), "LEFT JOIN " . PREFIX . "planet p ON (p.planetid = g.moonid)", $where);
         }
         $row = $result->fetchRow();
         $result->closeCursor();
         Core::getTPL()->assign("moon", $row["planetname"]);
         $img = Image::getImage("planets/" . $row["picture"] . Core::getConfig()->get("PLANET_IMG_EXT"), $row["planetname"], 50, 50);
         Core::getTPL()->assign("moonImage", "<a title=\"" . $row["planetname"] . "\" class=\"goto pointer\" href=\"" . $row["planetid"] . "\">" . $img . "</a>");
     } else {
         Core::getTPL()->assign("moon", "");
         Core::getTPL()->assign("moonImage", "");
     }
     // Current events
     $research = Game::getEH()->getResearchEvent();
     Core::getTPL()->assign("research", $research);
     $shipyardMissions = Game::getEH()->getShipyardEvents();
     Core::getTemplate()->assign("shipyardMissions", $shipyardMissions);
     /* @var Bengine_Game_Model_Collection_News $news */
     $news = Game::getCollection("game/news");
     $news->addSortIndexOrder()->addEnabledFilter()->addLanguageFilter();
     Core::getTPL()->addLoop("news", $news);
     Hook::event("GameIndexAction");
     return $this;
 }
Ejemplo n.º 13
0
 /**
  * Sets the default language.
  *
  * @param mixed $langId	Language code or id
  *
  * @return Recipe_Language_Importer
  */
 public function setDefaultLanguage($langId)
 {
     if (!is_numeric($langId)) {
         $result = Core::getQuery()->select("languages", array("languageid"), "", Core::getDB()->quoteInto("langcode = ?", $langId), "", "1");
         if ($row = $result->fetchRow()) {
             $langId = $row["languageid"];
         }
     }
     if (is_numeric($langId)) {
         Core::getConfig()->set("defaultlanguage", $langId);
     }
     return $this;
 }
Ejemplo n.º 14
0
 /**
  * Sets the guest group id.
  *
  * @param integer $guestGroupId	Guest group id [optional]
  *
  * @return Recipe_User
  */
 public function setGuestGroupId($guestGroupId = null)
 {
     if (is_null($guestGroupId)) {
         $guestGroupId = Core::getConfig()->guestgroupid;
     }
     $this->guestGroupId = $guestGroupId;
     return $this;
 }
Ejemplo n.º 15
0
    global $config;
    $classFile = $config["dirIntRoot"] . "assets/classes/{$class}.class.php";
    if (file_exists($classFile)) {
        include $classFile;
    }
});
/*
set_error_handler(function($code, $text, $file, $row) {
    echo "Code: " . $code;
    echo "Text: " . $text;
    echo "File: " . $file;
    echo "Row: " . $row;
    debug_print_backtrace();
});*/
if (!is_dir(Core::getConfig("tempDir"))) {
    mkdir(Core::getConfig("tempDir"));
}
include $config["dirIntRoot"] . "assets/frameworks/smarty-3.1.27/Smarty.class.php";
$smarty = new Smarty();
Core::initSmarty($smarty);
PageManager::assignSmarty($smarty);
UserManager::initialize();
// Breadcrumbs
$baseDir = Core::GetConfig("dirRoot");
if (isset($_SERVER['REQUEST_URI'])) {
    $uri = str_replace($baseDir, "", $_SERVER['REQUEST_URI']);
    if (strpos($uri, "?") !== false) {
        $uri = explode("?", $uri);
        $uri = $uri[0];
    }
    $bc = explode("/", $uri);
 function add()
 {
     $this->smarty->assign('domain_list', array_merge(array('*'), Core::getConfig('domain')));
     $this->smarty->assign('app_list', App::getAppsInfo());
 }
Ejemplo n.º 17
0
 /**
  * Constructor.
  *
  * @param string $usr
  * @param string $pw
  * @param string $redirection
  * @param string $encryption
  *
  * @return Login
  */
 public function __construct($usr, $pw, $redirection = "", $encryption = "md5")
 {
     if (!$this->cacheActive) {
         $this->cacheActive = CACHE_ACTIVE;
     }
     if ($length = Core::getConfig()->get("SESSION_ID_LENGTH")) {
         $this->setSessionLength($length);
     }
     $this->setMaxLoginAttempts()->setBannedLoginTime();
     $this->errors = new Map();
     $this->setUsername($usr)->setEncryption($encryption)->setPassword($pw)->setRedirection($redirection);
     Hook::event("BeginLogin", array($this));
     return $this;
 }
Ejemplo n.º 18
0
 /**
  * Index action.
  *
  * @return Bengine_Game_Controller_Galaxy
  */
 protected function indexAction()
 {
     if ($this->isPost()) {
         $this->setCoordinatesByPost($this->getParam("galaxy"), $this->getParam("system"), $this->getParam("submittype"));
     }
     $this->validateInputs()->subtractHydrogen();
     // Star surveillance
     $canMonitorActivity = false;
     if (Game::getPlanet()->getBuilding("STAR_SURVEILLANCE") > 0) {
         $range = pow(Game::getPlanet()->getBuilding("STAR_SURVEILLANCE"), 2) - 1;
         $diff = abs(Game::getPlanet()->getData("system") - $this->system);
         if ($this->galaxy == Game::getPlanet()->getData("galaxy") && $range >= $diff) {
             $canMonitorActivity = true;
         }
     }
     Core::getTPL()->assign("canMonitorActivity", $canMonitorActivity);
     // Images
     $rockimg = Image::getImage("rocket.gif", Core::getLanguage()->getItem("ROCKET_ATTACK"));
     // Get sunsystem data
     $select = array("g.planetid", "g.position", "g.destroyed", "g.metal", "g.silicon", "g.moonid", "p.picture", "p.planetname", "p.last as planetactivity", "u.username", "u.usertitle", "u.userid", "u.points", "u.last as useractivity", "u.umode", "u.level", "m.planetid AS moon", "m.picture AS moonpic", "m.planetname AS moonname", "m.diameter AS moonsize", "m.temperature", "m.last as moonactivity", "a.tag", "a.name", "a.showmember", "a.homepage", "a.showhomepage", "u2a.aid", "b.to");
     $joins = "LEFT JOIN " . PREFIX . "planet p ON (p.planetid = g.planetid)";
     $joins .= "LEFT JOIN " . PREFIX . "user u ON (u.userid = p.userid)";
     $joins .= "LEFT JOIN " . PREFIX . "planet m ON (m.planetid = g.moonid)";
     $joins .= "LEFT JOIN " . PREFIX . "user2ally u2a ON (u2a.userid = u.userid)";
     $joins .= "LEFT JOIN " . PREFIX . "alliance a ON (a.aid = u2a.aid)";
     $joins .= "LEFT JOIN " . PREFIX . "ban_u b ON (b.userid = u.userid AND b.to > '" . TIME . "')";
     $where = Core::getDB()->quoteInto("g.galaxy = ? AND g.system = ?", array($this->galaxy, $this->system));
     $result = Core::getQuery()->select("galaxy g", $select, $joins, $where);
     $UserList = new Bengine_Game_User_List();
     $UserList->setKey("position");
     $UserList->setNewbieProtection(true);
     $UserList->setFetchRank(true);
     $UserList->setTagAsLink(false);
     $UserList->load($result);
     $sys = $UserList->getArray();
     Hook::event("SolarSystemDataBefore", array($this, &$sys));
     for ($i = 1; $i <= 15; $i++) {
         if (isset($sys[$i]) && !$sys[$i]["destroyed"]) {
             $sys[$i]["systempos"] = $i;
             if ($sys[$i]["tag"] != "") {
                 $sys[$i]["allydesc"] = sprintf(Core::getLanguage()->getItem("GALAXY_ALLY_HEADLINE"), $sys[$i]["tag"], $sys[$i]["alliance_rank"]);
             }
             $sys[$i]["metal"] = fNumber($sys[$i]["metal"]);
             $sys[$i]["silicon"] = fNumber($sys[$i]["silicon"]);
             $sys[$i]["picture"] = Image::getImage("planets/small/s_" . $sys[$i]["picture"] . Core::getConfig()->get("PLANET_IMG_EXT"), $sys[$i]["planetname"], 30, 30);
             $sys[$i]["picture"] = Link::get("game/" . SID . "/Mission/Index/" . $this->galaxy . "/" . $this->system . "/" . $i, $sys[$i]["picture"]);
             $sys[$i]["planetname"] = Link::get("game/" . SID . "/Mission/Index/" . $this->galaxy . "/" . $this->system . "/" . $i, $sys[$i]["planetname"]);
             $sys[$i]["moonpicture"] = $sys[$i]["moonpic"] != "" ? Image::getImage("planets/small/s_" . $sys[$i]["moonpic"] . Core::getConfig()->get("PLANET_IMG_EXT"), $sys[$i]["moonname"], 22, 22) : "";
             $sys[$i]["moon"] = sprintf(Core::getLanguage()->getItem("MOON_DESC"), $sys[$i]["moonname"]);
             $sys[$i]["moonsize"] = fNumber($sys[$i]["moonsize"]);
             $sys[$i]["moontemp"] = fNumber($sys[$i]["temperature"]);
             if ($sys[$i]["moonactivity"] > $sys[$i]["planetactivity"]) {
                 $activity = $sys[$i]["moonactivity"];
             } else {
                 $activity = $sys[$i]["planetactivity"];
             }
             if ($activity > TIME - 900 && $sys[$i]["userid"] != Core::getUser()->get("userid")) {
                 $sys[$i]["activity"] = "(*)";
             } else {
                 if ($activity > TIME - 3600 && $sys[$i]["userid"] != Core::getUser()->get("userid")) {
                     $sys[$i]["activity"] = "(" . floor((TIME - $activity) / 60) . " min)";
                 } else {
                     $sys[$i]["activity"] = "";
                 }
             }
             if (Game::getPlanet()->getBuilding("ROCKET_STATION") > 3 && $sys[$i]["userid"] != Core::getUser()->get("userid") && $this->inMissileRange()) {
                 $sys[$i]["rocketattack"] = Link::get("game/" . SID . "/RocketAttack/Index/" . $sys[$i]["planetid"], $rockimg);
                 $sys[$i]["moonrocket"] = "<tr><td colspan=\"3\" class=\"center\">" . Link::get("game/" . SID . "/RocketAttack/Index/" . $sys[$i]["moonid"] . "/1", Core::getLanguage()->getItem("ROCKET_ATTACK")) . "</td></tr>";
             } else {
                 $sys[$i]["rocketattack"] = "";
                 $sys[$i]["moonrocket"] = "";
             }
             $sys[$i]["allypage"] = Str::replace("\"", "", Link::get("game/" . SID . "/Alliance/Page/" . $sys[$i]["aid"], Core::getLanguage()->getItem("ALLIANCE_PAGE"), 1));
             if (($sys[$i]["showhomepage"] || $sys[$i]["aid"] == Core::getUser()->get("aid")) && $sys[$i]["homepage"] != "") {
                 $sys[$i]["homepage"] = "<tr><td>" . Str::replace("'", "\\'", Link::get($sys[$i]["homepage"], Core::getLanguage()->getItem("HOMEPAGE"), 2)) . "</td></tr>";
             } else {
                 $sys[$i]["homepage"] = "";
             }
             if ($sys[$i]["showmember"]) {
                 $sys[$i]["memberlist"] = "<tr><td>" . Str::replace("\"", "", Link::get("game/" . SID . "/Alliance/Memberlist/" . $sys[$i]["aid"], Core::getLanguage()->getItem("SHOW_MEMBERLIST"), 3)) . "</td></tr>";
             }
             $sys[$i]["debris"] = Image::getImage("debris.jpg", "", 25, 25);
         } else {
             if (empty($sys[$i]["destroyed"])) {
                 $sys[$i] = array();
                 $sys[$i]["destroyed"] = false;
                 $sys[$i]["metal"] = 0;
                 $sys[$i]["silicon"] = 0;
                 $sys[$i]["debris"] = "";
                 $sys[$i]["picture"] = "";
                 $sys[$i]["planetname"] = "";
                 $sys[$i]["planetid"] = "";
             } else {
                 $sys[$i]["metal"] = fNumber($sys[$i]["metal"]);
                 $sys[$i]["silicon"] = fNumber($sys[$i]["silicon"]);
                 $sys[$i]["debris"] = Image::getImage("debris.jpg", "", 25, 25);
                 $sys[$i]["picture"] = Image::getImage("planets/small/s_" . $sys[$i]["picture"] . Core::getConfig()->get("PLANET_IMG_EXT"), $sys[$i]["planetname"], 30, 30);
                 $sys[$i]["picture"] = Link::get("game/" . SID . "/Mission/Index/" . $this->galaxy . "/" . $this->system . "/" . $i, $sys[$i]["picture"]);
                 $sys[$i]["planetname"] = Core::getLanguage()->getItem("DESTROYED_PLANET");
                 $sys[$i]["planetname"] = Link::get("game/" . SID . "/Mission/Index/" . $this->galaxy . "/" . $this->system . "/" . $i, $sys[$i]["planetname"]);
             }
             $sys[$i]["systempos"] = $i;
             $sys[$i]["userid"] = null;
             $sys[$i]["moon"] = "";
             $sys[$i]["moonid"] = "";
             $sys[$i]["username"] = "";
             $sys[$i]["alliance"] = "";
             $sys[$i]["activity"] = "";
             $sys[$i]["moonpicture"] = "";
             $sys[$i]["user_status_long"] = "";
         }
     }
     ksort($sys);
     Hook::event("SolarSystemDataAfter", array($this, &$sys));
     Core::getTPL()->assign("sendesp", Image::getImage("esp.gif", Core::getLanguage()->getItem("SEND_ESPIONAGE_PROBE")));
     Core::getTPL()->assign("monitorfleet", Image::getImage("binocular.gif", Core::getLanguage()->getItem("MONITOR_FLEET_ACTIVITY")));
     Core::getTPL()->assign("moon", Str::replace("\"", "", Image::getImage("planets/mond" . Core::getConfig()->get("PLANET_IMG_EXT"), Core::getLanguage()->getItem("MOON"), 75, 75)));
     Core::getTPL()->addLoop("sunsystem", $sys);
     Core::getTPL()->assign("debris", Str::replace("\"", "", Image::getImage("debris.jpg", Core::getLanguage()->getItem("DEBRIS"), 75, 75)));
     Core::getTPL()->assign("galaxy", $this->galaxy);
     Core::getTPL()->assign("system", $this->system);
     return $this;
 }
Ejemplo n.º 19
0
 /**
  * Executes this cronjob.
  *
  * @return Bengine_Game_Cronjob_CleanCombats
  */
 protected function _execute()
 {
     $this->cleanCombats(Core::getConfig()->get("COMBAT_STORE_DAYS"));
     return $this;
 }
Ejemplo n.º 20
0
 /**
  * @param integer $userid
  * @param string $username
  * @param string $email
  * @param integer $languageid
  * @param string $templatepackage
  * @param integer $ipcheck
  * @param string $password
  * @return Bengine_Admin_Controller_User
  */
 protected function saveUser($userid, $username, $email, $languageid, $templatepackage, $ipcheck, $password)
 {
     $spec = array("username" => $username, "email" => $email, "languageid" => $languageid, "templatepackage" => $templatepackage, "ipcheck" => $ipcheck);
     Core::getQuery()->update("user", $spec, "userid = ?", array($userid));
     if ($password != "") {
         $password = Str::encode($password, Core::getConfig()->get("USE_PASSWORD_SALT") ? "md5_salt" : "md5");
         Core::getQuery()->update("password", array("password" => $password, "time" => TIME), "userid = ?", array($userid));
     }
     return $this;
 }
Ejemplo n.º 21
0
 /**
  * Returns the production of a resource.
  *
  * @param string	Resource name
  *
  * @return integer
  */
 public function getProd($resource)
 {
     $productFactor = (double) Core::getConfig()->get("PRODUCTION_FACTOR");
     if ($resource == "energy") {
         $productFactor = 1;
     }
     return isset($this->prod[$resource]) ? $this->prod[$resource] * $productFactor : false;
 }
Ejemplo n.º 22
0
 /**
  * Changes the ships against resources.
  *
  * @return Bengine_Game_Controller_Shipyard
  */
 protected function changeAction()
 {
     if (!Core::getConfig()->get("SCRAP_MERCHANT_RATE")) {
         $this->redirect("game/" . SID . "/Shipyard");
     }
     Core::getLanguage()->load(array("info", "buildings"));
     $selUnits = Core::getRequest()->getPOST("unit");
     /* @var Bengine_Game_Model_Collection_Fleet $availUnits */
     $availUnits = Application::getCollection("game/fleet", "game/unit");
     $availUnits->addPlanetFilter(Core::getUser()->get("curplanet"));
     $metalCredit = 0;
     $siliconCredit = 0;
     $hydrogenCredit = 0;
     $totalQty = 0;
     $realUnits = array();
     $rate = (double) Core::getConfig()->get("SCRAP_MERCHANT_RATE");
     /* @var Bengine_Game_Model_Unit $unit */
     foreach ($availUnits as $unit) {
         $unitId = $unit->getUnitid();
         if (isset($selUnits[$unitId]) && $selUnits[$unitId] > 0) {
             $qty = _pos((int) $selUnits[$unitId]);
             $qty = min($qty, $unit->getQty());
             $metalCredit += $qty * $unit->get("basic_metal");
             $siliconCredit += $qty * $unit->get("basic_silicon");
             $hydrogenCredit += $qty * $unit->get("basic_hydrogen");
             $totalQty += $qty;
             $realUnits[(int) $unitId] = $qty;
         }
     }
     $points = ($metalCredit + $siliconCredit + $hydrogenCredit) / 1000;
     $metalCredit = floor($metalCredit * $rate);
     $siliconCredit = floor($siliconCredit * $rate);
     $hydrogenCredit = floor($hydrogenCredit * $rate);
     Core::getLang()->assign(array("metalCredit" => fNumber($metalCredit), "siliconCredit" => fNumber($siliconCredit), "hydrogenCredit" => fNumber($hydrogenCredit), "totalQty" => fNumber($totalQty)));
     if (Core::getRequest()->getPOST("verify") == "yes") {
         /* @var Bengine_Game_Model_Unit $unit */
         foreach ($availUnits as $unit) {
             $unitId = (int) $unit->getUnitid();
             if (isset($realUnits[$unitId])) {
                 $qty = $realUnits[$unitId];
                 if ($unit->getQty() <= $qty) {
                     Core::getQuery()->delete("unit2shipyard", "`unitid` = ? AND `planetid` = ?", null, null, array($unitId, Core::getUser()->get("curplanet")));
                 } else {
                     $sql = "UPDATE `" . PREFIX . "unit2shipyard` SET `quantity` = `quantity` - ? WHERE `unitid` = ? AND `planetid` = ?";
                     Core::getDatabase()->query($sql, array($qty, $unitId, Core::getUser()->get("curplanet")));
                 }
             }
         }
         $sql = "UPDATE `" . PREFIX . "planet` SET `metal` = `metal` + ?, `silicon` = `silicon` + ?, `hydrogen` = `hydrogen` + ? WHERE `planetid` = ?";
         Core::getDatabase()->query($sql, array($metalCredit, $siliconCredit, $hydrogenCredit, Core::getUser()->get("curplanet")));
         $sql = "UPDATE `" . PREFIX . "user` SET `points` = `points` - ? WHERE `userid` = ?";
         Core::getDatabase()->query($sql, array($points, Core::getUser()->get("userid")));
         $this->redirect("game/" . SID . "/Shipyard");
     }
     $this->setTemplate("shipyard/change");
     $this->assign("units", $realUnits);
     return $this;
 }
 * WolfPanel is licensed under a
 * Creative Commons Attribution-NonCommercial 4.0 International License.
 * 
 * You should have received a copy of the license along with this
 * work. If not, see <http://creativecommons.org/licenses/by-nc/4.0/>. 
 */
include "../core.php";
// Admin Check
$user = UserManager::getLocalUser();
if (!$user->isAdmin()) {
    PageManager::displayErrorPage("access");
    return;
}
$id = isset($_GET["serverid"]) && is_numeric($_GET["serverid"]) ? $_GET["serverid"] : -1;
$port = isset($_GET["port"]) && is_numeric($_GET["port"]) ? $_GET["port"] : -1;
if (!PhysicalServerManager::existsById($id)) {
    Page::renderJson(array("status" => "error", "message" => "Server doesnt exist"));
    return;
}
if ($port < Core::getConfig("port_min") || $port > Core::getConfig("port_max")) {
    Page::renderJson(array("status" => "error", "message" => "Invalid Port"));
    return;
}
$server = new PhysicalServer($id);
if ($server->isPortFree($port)) {
    Page::renderJson(array("status" => "success", "message" => "Port is available"));
    return;
} else {
    Page::renderJson(array("status" => "error", "message" => "Port is not available"));
    return;
}
Ejemplo n.º 24
0
 /**
  * Executes this cronjob.
  *
  * @return Bengine_Game_Cronjob_CleanSessions
  */
 protected function _execute()
 {
     $this->clearSessions(Core::getConfig()->get("SESSION_DELETEION_DAYS"));
     return $this;
 }
Ejemplo n.º 25
0
 private static function getCoreRoute()
 {
     return Core::getConfig('route');
 }
Ejemplo n.º 26
0
 /**
  * Adds an event to all position names.
  *
  * @param Recipe_Template_Adapter_Default $engine
  * @param string $template
  * @param boolean $noLayout
  *
  * @return Plugin_Commercials
  */
 public function onTemplatePreDisplay(Recipe_Template_Adapter_Default $engine, $template, $noLayout)
 {
     if (!$noLayout && Core::getConfig()->get("COMMERCIALS_ENABLED")) {
         $this->loadAds();
         foreach ($this->ads as $position => $none) {
             Hook::addHook($position, $this);
         }
     }
     return $this;
 }
Ejemplo n.º 27
0
 /**
  * Shows all building information.
  *
  * @param integer $id
  * @throws Recipe_Exception_Generic
  * @return Bengine_Game_Controller_Constructions
  */
 protected function infoAction($id)
 {
     $select = array("name", "demolish", "basic_metal", "basic_silicon", "basic_hydrogen", "basic_energy", "prod_metal", "prod_silicon", "prod_hydrogen", "prod_energy", "special", "cons_metal", "cons_silicon", "cons_hydrogen", "cons_energy", "charge_metal", "charge_silicon", "charge_hydrogen", "charge_energy");
     $result = Core::getQuery()->select("construction", $select, "", Core::getDB()->quoteInto("buildingid = ? AND (mode = '1' OR mode = '2' OR mode = '5')", $id));
     if ($row = $result->fetchRow()) {
         $result->closeCursor();
         Core::getLanguage()->load("info,Resource");
         Hook::event("BuildingInfoBefore", array(&$row));
         // Assign general building data
         Core::getTPL()->assign("buildingName", Core::getLanguage()->getItem($row["name"]));
         Core::getTPL()->assign("buildingDesc", Core::getLanguage()->getItem($row["name"] . "_FULL_DESC"));
         Core::getTPL()->assign("buildingImage", Image::getImage("buildings/" . $row["name"] . ".gif", Core::getLanguage()->getItem($row["name"]), null, null, "leftImage"));
         Core::getTPL()->assign("edit", Link::get("game/" . SID . "/Construction_Edit/Index/" . $id, "[" . Core::getLanguage()->getItem("EDIT") . "]"));
         // Production and consumption of the building
         $prodFormula = false;
         if (!empty($row["prod_metal"])) {
             $prodFormula = $row["prod_metal"];
             $baseCost = $row["basic_metal"];
         } else {
             if (!empty($row["prod_silicon"])) {
                 $prodFormula = $row["prod_silicon"];
                 $baseCost = $row["basic_metal"];
             } else {
                 if (!empty($row["prod_hydrogen"])) {
                     $prodFormula = $row["prod_hydrogen"];
                     $baseCost = $row["basic_hydrogen"];
                 } else {
                     if (!empty($row["prod_energy"])) {
                         $prodFormula = $row["prod_energy"];
                         $baseCost = $row["basic_energy"];
                     } else {
                         if (!empty($row["special"])) {
                             $prodFormula = $row["special"];
                             $baseCost = 0;
                         }
                     }
                 }
             }
         }
         $consFormula = false;
         if (!empty($row["cons_metal"])) {
             $consFormula = $row["cons_metal"];
         } else {
             if (!empty($row["cons_silicon"])) {
                 $consFormula = $row["cons_silicon"];
             } else {
                 if (!empty($row["cons_hydrogen"])) {
                     $consFormula = $row["cons_hydrogen"];
                 } else {
                     if (!empty($row["cons_energy"])) {
                         $consFormula = $row["cons_energy"];
                     }
                 }
             }
         }
         // Production and consumption chart
         $chartType = false;
         if ($prodFormula != false || $consFormula != false) {
             $chart = array();
             $chartType = "cons_chart";
             if ($prodFormula && $consFormula) {
                 $chartType = "prod_and_cons_chart";
             } else {
                 if ($prodFormula) {
                     $chartType = "prod_chart";
                 }
             }
             if (Game::getPlanet()->getBuilding($id) - 7 < 0) {
                 $start = 7;
             } else {
                 $start = Game::getPlanet()->getBuilding($id);
             }
             $productionFactor = (double) Core::getConfig()->get("PRODUCTION_FACTOR");
             if (!empty($row["prod_energy"])) {
                 $productionFactor = 1;
             }
             $currentProduction = 0;
             if ($prodFormula) {
                 $currentProduction = parseFormula($prodFormula, $baseCost, Game::getPlanet()->getBuilding($id)) * $productionFactor;
             }
             $currentConsumption = 0;
             if ($consFormula) {
                 $currentConsumption = parseFormula($consFormula, 0, Game::getPlanet()->getBuilding($id));
             }
             for ($i = $start - 7; $i <= Game::getPlanet()->getBuilding($id) + 7; $i++) {
                 $chart[$i]["level"] = $i;
                 $chart[$i]["s_prod"] = $prodFormula ? parseFormula($prodFormula, $baseCost, $i) * $productionFactor : 0;
                 $chart[$i]["s_diffProd"] = $prodFormula ? $chart[$i]["s_prod"] - $currentProduction : 0;
                 $chart[$i]["s_cons"] = $consFormula ? parseFormula($consFormula, 0, $i) : 0;
                 $chart[$i]["s_diffCons"] = $consFormula ? $currentConsumption - $chart[$i]["s_cons"] : 0;
                 $chart[$i]["prod"] = fNumber($chart[$i]["s_prod"]);
                 $chart[$i]["diffProd"] = fNumber($chart[$i]["s_diffProd"]);
                 $chart[$i]["cons"] = fNumber($chart[$i]["s_cons"]);
                 $chart[$i]["diffCons"] = fNumber($chart[$i]["s_diffCons"]);
             }
             Hook::event("BuildingInfoProduction", array(&$chart));
             Core::getTPL()->addLoop("chart", $chart);
         }
         if ($chartType) {
             Core::getTPL()->assign("chartType", "game/constructions/" . $chartType);
         }
         // Show demolish function
         $factor = floatval($row["demolish"]);
         if (Game::getPlanet()->getBuilding($id) > 0 && $factor > 0.0) {
             Core::getTPL()->assign("buildingLevel", Game::getPlanet()->getBuilding($id));
             Core::getTPL()->assign("demolish", true);
             $metal = "";
             $_metal = 0;
             $silicon = "";
             $_silicon = 0;
             $hydrogen = "";
             $_hydrogen = 0;
             if ($row["basic_metal"] > 0) {
                 $_metal = 1 / $factor * parseFormula($row["charge_metal"], $row["basic_metal"], Game::getPlanet()->getBuilding($id));
                 $metal = Core::getLanguage()->getItem("METAL") . ": " . fNumber($_metal);
             }
             Core::getTPL()->assign("metal", $metal);
             if ($row["basic_silicon"] > 0) {
                 $_silicon = 1 / $factor * parseFormula($row["charge_silicon"], $row["basic_silicon"], Game::getPlanet()->getBuilding($id));
                 $silicon = Core::getLanguage()->getItem("SILICON") . ": " . fNumber($_silicon);
             }
             Core::getTPL()->assign("silicon", $silicon);
             if ($row["basic_hydrogen"] > 0) {
                 $_hydrogen = 1 / $factor * parseFormula($row["charge_hydrogen"], $row["basic_hydrogen"], Game::getPlanet()->getBuilding($id));
                 $hydrogen = Core::getLanguage()->getItem("HYDROGEN") . ": " . fNumber($_hydrogen);
             }
             Core::getTPL()->assign("hydrogen", $hydrogen);
             $time = getBuildTime($_metal, $_silicon, self::BUILDING_CONSTRUCTION_TYPE);
             Core::getTPL()->assign("dimolishTime", getTimeTerm($time));
             $showLink = Game::getPlanet()->getData("metal") >= $_metal && Game::getPlanet()->getData("silicon") >= $_silicon && Game::getPlanet()->getData("hydrogen") >= $_hydrogen;
             if ($id == 12 && Game::getEH()->getResearchEvent()) {
                 $showLink = false;
             }
             $shipyardSize = Game::getEH()->getShipyardEvents()->getCalculatedSize();
             if (($id == 8 || $id == 7) && $shipyardSize > 0) {
                 $showLink = false;
             }
             Core::getTPL()->assign("showLink", $showLink && !$this->event && !Core::getUser()->get("umode"));
             Core::getTPL()->assign("demolishNow", Link::get("game/" . SID . "/Constructions/Demolish/{$id}", Core::getLanguage()->getItem("DEMOLISH_NOW")));
         } else {
             Core::getTPL()->assign("demolish", false);
         }
         Hook::event("BuildingInfoAfter", array(&$row));
     } else {
         $result->closeCursor();
         throw new Recipe_Exception_Generic("Unkown building. You'd better don't manipulate the URL. We see everything ;)");
     }
     return $this;
 }
Ejemplo n.º 28
0
 /**
  * Initializing the inactive status.
  *
  * @return Bengine_Game_Model_User
  */
 public function initInactiveStatus()
 {
     $inactive = "";
     if ($this->getLast() <= TIME - Core::getConfig()->get("INACTIVE_USER_TIME_1")) {
         $inactive = " i ";
     }
     if ($this->getLast() <= TIME - Core::getConfig()->get("INACTIVE_USER_TIME_2")) {
         $inactive = " i I ";
     }
     $this->setInacticeStatus($inactive);
     return $this;
 }
Ejemplo n.º 29
0
 /**
  * Generic template assignments.
  *
  * @return void
  */
 protected static function globalTPLAssigns()
 {
     // JavaScript & CSS
     Core::getTPL()->addHTMLHeaderFile("game.css", "css");
     // TODO: change to responsive
     Core::getTPL()->addHTMLHeaderFile("jquery-ui.css", "css");
     Core::getTPL()->addHTMLHeaderFile("lib/jquery.js", "js");
     Core::getTPL()->addHTMLHeaderFile("lib/jquery-ui.js", "js");
     Core::getTPL()->addHTMLHeaderFile("main.js", "js");
     // Set planets for right menu and fill planet stack.
     $planets = array();
     $i = 0;
     $order = "p.sort_index ASC, p.planetid ASC";
     $joins = "LEFT JOIN " . PREFIX . "galaxy g ON (g.planetid = p.planetid)";
     $joins .= "LEFT JOIN " . PREFIX . "planet m ON (g.moonid = m.planetid)";
     $atts = array("p.planetid", "p.ismoon", "p.planetname", "p.picture", "g.galaxy", "g.system", "g.position", "m.planetid AS moonid", "m.planetname AS moon", "m.picture AS mpicture");
     $where = Core::getDB()->quoteInto("p.userid = ?", Core::getUser()->get("userid"));
     $where .= Core::getDB()->quoteInto(" AND p.ismoon = ?", 0);
     $result = Core::getQuery()->select("planet p", $atts, $joins, $where, $order);
     unset($order);
     foreach ($result->fetchAll() as $row) {
         $planets[$i] = $row;
         $coords = $row["galaxy"] . ":" . $row["system"] . ":" . $row["position"];
         $coords = "[" . $coords . "]";
         $planets[$i]["coords"] = $coords;
         $planets[$i]["picture"] = Image::getImage("planets/small/s_" . $row["picture"] . Core::getConfig()->get("PLANET_IMG_EXT"), $row["planetname"] . " " . $coords, 60, 60);
         if ($row["moonid"]) {
             $planets[$i]["mpicture"] = Image::getImage("planets/small/s_" . $row["mpicture"] . Core::getConfig()->get("PLANET_IMG_EXT"), $row["moon"] . " " . $coords, 20, 20);
         }
         self::$planetStack[] = $row["planetid"];
         $i++;
     }
     $result->closeCursor();
     Hook::event("GamePlanetList", array(&$planets));
     Core::getTPL()->addLoop("planetHeaderList", $planets);
     // Menu
     Core::getTPL()->addLoop("navigation", new Bengine_Game_Menu("Menu"));
     // Assignments
     $planet = self::getPlanet();
     Core::getTPL()->assign("themePath", Core::getUser()->get("theme") ? Core::getUser()->get("theme") : HTTP_HOST . REQUEST_DIR);
     Core::getTPL()->assign("planetImageSmall", Image::getImage("planets/small/s_" . $planet->getData("picture") . Core::getConfig()->get("PLANET_IMG_EXT"), $planet->getData("planetname"), 88, 88));
     Core::getTPL()->assign("currentPlanet", Link::get("game/" . SID . "/Index/PlanetOptions", $planet->getData("planetname")));
     Core::getTPL()->assign("currentCoords", $planet->getCoords());
     // Show message if user is in vacation or deletion mode.
     $delete = false;
     if (Core::getUser()->get("delete") > 0) {
         $delete = Core::getLanguage()->getItem("ACCOUNT_WILL_BE_DELETED");
     }
     $umode = false;
     if (Core::getUser()->get("umode")) {
         $umode = Core::getLanguage()->getItem("UMODE_ENABLED");
     }
     Core::getTPL()->assign("delete", $delete);
     Core::getTPL()->assign("umode", $umode);
     return;
 }
Ejemplo n.º 30
0
 /**
  * Select the ships for jump.
  *
  * @param array $ships
  *
  * @return Bengine_Game_Controller_Mission
  */
 protected function starGateJump($ships)
 {
     $this->noAction = true;
     $data = array();
     Core::getQuery()->delete("temp_fleet", "planetid = ?", null, null, array(Core::getUser()->get("curplanet")));
     $select = array("u2s.unitid", "u2s.quantity", "d.capicity", "d.speed", "d.consume", "b.name");
     $joins = "LEFT JOIN " . PREFIX . "construction b ON (b.buildingid = u2s.unitid)";
     $joins .= "LEFT JOIN " . PREFIX . "ship_datasheet d ON (d.unitid = u2s.unitid)";
     $result = Core::getQuery()->select("unit2shipyard u2s", $select, $joins, Core::getDB()->quoteInto("b.mode = '3' AND u2s.planetid = ?", Core::getUser()->get("curplanet")));
     foreach ($result->fetchAll() as $row) {
         $id = $row["unitid"];
         if (isset($ships[$id])) {
             $quantity = _pos($ships[$id]);
             if ($quantity > $row["quantity"]) {
                 $quantity = $row["quantity"];
             }
             if ($quantity > 0) {
                 $data["ships"][$id]["quantity"] = $quantity;
                 $data["ships"][$id]["name"] = $row["name"];
             }
         }
     }
     $result->closeCursor();
     $result = Core::getQuery()->select("stargate_jump", "time", "", Core::getDB()->quoteInto("planetid = ?", Core::getUser()->get("curplanet")), "time DESC");
     $row = $result->fetchRow();
     $result->closeCursor();
     $requiredReloadTime = (int) Core::getConfig()->get("STAR_GATE_RELOAD_TIME") * 60;
     $reloadTime = $row["time"] + $requiredReloadTime;
     if (count($data) > 0 && $reloadTime < TIME) {
         $moons = array();
         $select = new Recipe_Database_Select();
         $select->from(array("p" => "planet"))->attributes(array("p" => array("planetid", "planetname"), "g" => array("galaxy", "system", "position"), "sj" => array("time")));
         $select->join(array("b2p" => "building2planet"), array("b2p" => "planetid", "p" => "planetid"))->join(array("g" => "galaxy"), array("g" => "moonid", "p" => "planetid"))->join(array("sj" => "stargate_jump"), array("sj" => "planetid", "p" => "planetid"))->where(array("p" => "userid"), Core::getUser()->get("userid"))->where(array("p" => "ismoon"), 1)->where(array("p" => "planetid", "!="), Core::getUser()->get("curplanet"))->where(array("b2p" => "buildingid"), 56)->where("IFNULL(sj.time, 0) + ? < UNIX_TIMESTAMP()", $requiredReloadTime)->group(array("p" => "planetid"))->order(array("g" => "galaxy"))->order(array("g" => "system"))->order(array("g" => "position"));
         $result = $select->getStatement();
         foreach ($result->fetchAll() as $row) {
             $moons[] = $row;
             $data["moons"][] = $row["planetid"];
         }
         $result->closeCursor();
         Hook::event("ShowStarGates", array(&$moons, &$data));
         Core::getTPL()->addLoop("moons", $moons);
         $data = serialize($data);
         Core::getQuery()->insert("temp_fleet", array("planetid" => Core::getUser()->get("curplanet"), "data" => $data));
         $this->setTemplate("mission/stargatejump");
     } else {
         if ($reloadTime < TIME) {
             $reloadTime = TIME;
         }
         Core::getLanguage()->assign("reloadTime", fNumber(($reloadTime - TIME) / 60), 2);
         Logger::addMessage("RELOADING_STAR_GATE");
     }
     return $this;
 }