示例#1
0
 function __construct()
 {
     $this->__core = Core::getInstance();
     $this->__lib = $this->__core->getLib();
     $this->__uri = $this->__core->getUri();
     $this->__req = $this->__core->getRequest();
 }
示例#2
0
 /**
  * Index action.
  *
  * @return Bengine_Comm_Controller_Index
  */
 public function indexAction()
 {
     Hook::event("CommIndexStart", array($this));
     $this->assign("errorMsg", Core::getRequest()->getGET("error"));
     if ($this->isPost()) {
         $encryption = Core::getOptions("USE_PASSWORD_SALT") ? "md5_salt" : "md5";
         $login = new Bengine_Game_Login($this->getParam("username"), $this->getParam("password"), "game", $encryption);
         $login->setRedirectOnFailure(false)->checkData();
         if ($login->getCanLogin()) {
             Hook::event("PreLogin", array($login));
             $login->startSession();
             Hook::event("PostLogin", array($login));
         } else {
             $this->assign("errorMsg", $login->getErrors()->getFirst());
         }
     }
     if ($this->errorMsg != "") {
         Core::getLang()->load("error");
         $this->assign("errorMsg", Core::getLang()->get($this->errorMsg));
     }
     $this->assign("page", Core::getLang()->getItem("LOGIN"));
     if ($cmsPage = Comm::getCMS()->getPage("index")) {
         $this->assign("page", $cmsPage["title"]);
         $this->assign("content", $cmsPage["content"]);
         $this->setTemplate("cms_page");
     } else {
         $this->assign("showDefaultContent", true);
     }
     Hook::event("CommIndexEnd", array($this));
     return $this;
 }
示例#3
0
 /**
  * Handles the moderator class.
  *
  * @return void
  */
 protected function init()
 {
     Core::getUser()->checkPermissions("CAN_MODERATE_USER");
     Core::getLanguage()->load(array("Prefs", "Statistics", "Registration"));
     $this->userid = Core::getRequest()->getPOST("userid") ? Core::getRequest()->getPOST("userid") : Core::getRequest()->getGET("1");
     parent::init();
 }
示例#4
0
 /**
  * Starts Bengine.
  *
  * @return Game
  */
 public function run()
 {
     parent::run();
     // Update last activity
     Core::getQuery()->update("user", array("last" => TIME, "db_lock" => TIME), "userid = ?", array(Core::getUser()->userid));
     if ($planetid = Core::getRequest()->getPOST("planetid")) {
         Core::getUser()->set("curplanet", $planetid);
     }
     Hook::event("GameStart");
     self::loadResearch();
     self::setPlanet();
     self::setEventHandler();
     self::getEH()->init();
     self::getPlanet()->getProduction()->addProd();
     self::globalTPLAssigns();
     // Asteroid event (Once per week).
     $first = mt_rand(0, 100);
     $second = mt_rand(0, 100);
     if ($first == 42 && $second == 49 && Core::getUser()->get("asteroid") < TIME - 604800) {
         $data["metal"] = mt_rand(1, Core::getOptions()->get("MAX_ASTEROID_SIZE")) * 1000;
         $data["silicon"] = mt_rand(1, $data["metal"] / 1000) * 1000;
         $data["galaxy"] = self::getPlanet()->getData("galaxy");
         $data["system"] = self::getPlanet()->getData("system");
         $data["position"] = self::getPlanet()->getData("position");
         $data["planet"] = self::getPlanet()->getData("planetname");
         Hook::event("GameAsteroidEvent", array(&$data));
         Core::getQuery()->update("user", array("asteroid" => TIME), "userid = ?", array(Core::getUser()->get("userid")));
         $what = self::getPlanet()->getData("ismoon") ? "moonid" : "planetid";
         Core::getDB()->query("UPDATE " . PREFIX . "galaxy SET metal = metal + ?, silicon = silicon + ? WHERE " . $what . " = ?", array($data["metal"], $data["silicon"], self::getPlanet()->getPlanetId()));
         new Bengine_Game_AutoMsg(22, Core::getUser()->get("userid"), TIME, $data);
         Core::getUser()->rebuild();
     }
     $this->dispatch();
     return $this;
 }
示例#5
0
 /**
  * Constructor. Handles requests for this page.
  *
  * @return Bengine_Game_Controller_Mission
  */
 protected function init()
 {
     Core::getTPL()->addHTMLHeaderFile("fleet.js", "js");
     Core::getLanguage()->load(array("info", "mission"));
     if (!Core::getUser()->get("umode") && $this->isPost()) {
         if ($this->getParam("stargatejump")) {
             $this->starGateJump(Core::getRequest()->getPOST());
         }
         if ($this->getParam("execjump")) {
             $this->executeJump($this->getParam("moonid"));
         }
         if ($this->getParam("retreat")) {
             $this->retreatFleet($this->getParam("id"));
         }
         if ($this->getParam("formation")) {
             $this->formation($this->getParam("id"));
         }
         if ($this->getParam("invite")) {
             $this->invite($this->getParam("id"), $this->getParam("name"), $this->getParam("username"));
         }
         if ($this->getParam("step2")) {
             $this->selectCoordinates($this->getParam("galaxy"), $this->getParam("system"), $this->getParam("position"), $this->getParam("targetType"), $this->getParam("code"), Core::getRequest()->getPOST());
         }
         if ($this->getParam("step3")) {
             $this->selectMission($this->getParam("galaxy"), $this->getParam("system"), $this->getParam("position"), $this->getParam("targetType"), $this->getParam("speed"), $this->getParam("code"), $this->getParam("formation"));
         }
         if ($this->getParam("step4")) {
             $this->sendFleet($this->getParam("mode"), $this->getParam("metal"), $this->getParam("silicon"), $this->getParam("hydrogen"), $this->getParam("holdingtime"));
         }
     }
     return parent::init();
 }
示例#6
0
 /**
  * @return Bengine_Admin_Controller_Auth
  */
 protected function logoutAction()
 {
     if (Core::getUser()->getSid()) {
         Core::getCache()->cleanUserCache(Core::getUser()->get("userid"));
         Core::getRequest()->setCookie("sid", "", TIME - 1);
     }
     $this->redirect("admin/auth");
     return $this;
 }
示例#7
0
 /**
  * Constructor.
  *
  * @param string	Path to upload
  * @param string	File to upload
  *
  * @return void
  */
 public function __construct($path, $file)
 {
     $this->path = $this->validatePath($path);
     $this->file = is_array($file) ? $file : Core::getRequest()->getFILES($file);
     $this->filename = $this->file["name"];
     $this->setExtension($this->filename);
     Hook::event("StartFileUpload", array($this));
     return;
 }
示例#8
0
 /**
  * @param array $delete
  * @param array $perms
  * @return Bengine_Admin_Controller_Permissions
  */
 protected function update(array $delete, array $perms)
 {
     foreach ($delete as $pid) {
         Core::getQuery()->delete("permissions", "permissionid = ?", null, null, array($pid));
     }
     foreach ($perms as $pid) {
         Core::getQuery()->update("permissions", array("permission" => Core::getRequest()->getPOST("perm_" . $pid)), "permissionid = ?", array($pid));
     }
     return $this;
 }
示例#9
0
 /**
  * Main method to display a sun system.
  *
  * @return Bengine_Game_Controller_Galaxy
  */
 protected function init()
 {
     Core::getLanguage()->load(array("Galaxy", "Statistics"));
     $this->missileRange = Game::getRocketRange();
     $this->viewConsumption = (int) Core::getOptions()->get("GALAXY_VIEW_CONSUMPTION");
     if (Core::getRequest()->getGET("1") && Core::getRequest()->getGET("2")) {
         $this->setCoordinatesByGet(Core::getRequest()->getGET("1"), Core::getRequest()->getGET("2"));
     }
     return parent::init();
 }
    /**
     * Show share button code.
     *
     * @return string
     */
    public function onFrontHtmlEnd()
    {
        switch (Core::getRequest()->getGET("controller")) {
            case "combat":
            case "alliance":
                return '<div style="margin: 1em 3em 1em 0; text-align: right;">
<a href="http://twitter.com/share" class="twitter-share-button" data-count="none">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script><br/>
<a name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php">Teilen</a>
<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script><br/>
<g:plusone size="tall"></g:plusone>
<script type="text/javascript">window.___gcfg={lang:"' . Core::getLang()->getOpt("code") . '"};(function(){var po=document.createElement("script");po.type="text/javascript";po.async=true;po.src="https://apis.google.com/js/plusone.js";var s=document.getElementsByTagName("script")[0];s.parentNode.insertBefore(po,s);})();</script>
</div>';
                break;
        }
        return null;
    }
示例#11
0
 /**
  * Edit user profile.
  *
  * @param integer $user_id
  *
  * @return Bengine_Game_Controller_Profile
  */
 protected function editAction($user_id = 0)
 {
     if (!$user_id) {
         $user_id = Core::getUser()->get("userid");
     }
     if ($user_id != Core::getUser()->get("userid")) {
         Core::getUser()->checkPermissions(array("CAN_EDIT_PROFILES"));
     }
     $this->assign("user_id", $user_id);
     $profile = Game::getCollection("game/profile");
     $profile->addUserFilter($user_id)->addSortIndex();
     if ($this->isPost() && $this->getParam("save")) {
         $this->save(Core::getRequest()->getPOST(), $profile);
     }
     $this->backLink = Link::get("game/" . SID . "/Profile/Page/" . $user_id, Core::getLang()->get("BACK_TO_PROFILE"));
     Core::getTPL()->addLoop("profile", $profile);
     return $this;
 }
示例#12
0
 /**
  * Update pages in DB (from main page)
  *
  * @param array $delete
  * @param array $pages
  *
  * @return Bengine_Admin_Controller_Cms
  */
 protected function updatePagesAction($delete, $pages)
 {
     foreach ($delete as $id) {
         Core::getQuery()->delete("page", "pageid = ?", null, null, array($id));
     }
     foreach ($pages as $id) {
         $spec = array("displayorder" => Core::getRequest()->getPOST("displayorder_" . $id), "title" => Core::getRequest()->getPOST("title_" . $id), "position" => Core::getRequest()->getPOST("position_" . $id));
         Core::getQuery()->update("page", $spec, "pageid = ?", array($id));
     }
     return $this;
 }
示例#13
0
 /**
  * Generates a full readable url.
  *
  * @param string $url				The url parameters
  * @param boolean $appendSession	Append session id to url
  *
  * @return string
  */
 public static function url($url, $appendSession = false)
 {
     $session = Core::getRequest()->getGET("sid");
     if (!COOKIE_SESSION && $appendSession && $session) {
         if (Str::inString("?", $url)) {
             $url .= "?sid=" . $session;
         } else {
             $url .= "&amp;sid=" . $session;
         }
     }
     $lang = Core::getRequest()->getPOST("lang") ? Core::getRequest()->getPOST("lang") : Core::getRequest()->getGET("lang");
     if (self::APPEND_LANG_TO_URL && $lang) {
         if (Str::inString("?", $url)) {
             $url = $url . "?lang=" . $lang;
         } else {
             $url = $url . "&amp;lang=" . $lang;
         }
     } else {
         if (!Link::isExternal($url) && !preg_match("~^" . BASE_URL . "~si", $url) && self::APPEND_HOST_PATH) {
             $url = BASE_URL . $url;
         }
     }
     return $url;
 }
示例#14
0
 /**
  * Saves resource production factor.
  *
  * @return Bengine_Game_Controller_Resource
  */
 protected function updateAction()
 {
     if (!Core::getUser()->get("umode")) {
         $post = Core::getRequest()->getPOST();
         Hook::event("SaveResources");
         foreach ($this->data as $key => $value) {
             if ($value["level"] > 0) {
                 $factor = abs(isset($post[$key]) ? $post[$key] : 100);
                 $factor = $factor > 100 ? 100 : $factor;
                 Core::getQuery()->update("building2planet", array("prod_factor" => $factor), "buildingid = ? AND planetid = ?", array($key, Core::getUser()->get("curplanet")));
             }
         }
         if (Game::getPlanet()->getBuilding(Bengine_Game_Planet::SOLAR_SAT_ID) > 0) {
             $satelliteProd = abs($post[39]);
             $satelliteProd = $satelliteProd > 100 ? 100 : $satelliteProd;
             Core::getQuery()->update("planet", array("solar_satellite_prod" => $satelliteProd), "planetid = ?", array(Core::getUser()->get("curplanet")));
         }
     }
     $this->redirect("game/" . SID . "/Resource");
     return $this;
 }
示例#15
0
 /**
  * Returns a request parameter.
  *
  * @param string $param		Parameter name
  * @param mixed $default	Default return value
  *
  * @return mixed
  */
 protected function getParam($param, $default = null)
 {
     if (empty($param)) {
         return $default;
     }
     if (($value = Core::getRequest()->getPOST($param, null)) !== null) {
         return $value;
     }
     return Core::getRequest()->getGET($param, $default);
 }
示例#16
0
 /**
  * Start a new session and destroy old sessions.
  *
  * @return Login
  */
 public function startSession()
 {
     if (!$this->dataChecked) {
         $this->checkData();
     }
     // Disables old sessions.
     if ($this->cacheActive) {
         Core::getCache()->cleanUserCache($this->userid);
     }
     Core::getQuery()->update("sessions", array("logged" => 0), "userid = ?", array($this->userid));
     // Start new session.
     $sessionSeed = Str::encode((string) microtime(1));
     $this->sid = Str::substring($sessionSeed, 0, $this->getSessionLength());
     unset($sessionSeed);
     $spec = array("sessionid" => $this->sid, "userid" => $this->userid, "ipaddress" => IPADDRESS, "useragent" => isset($_SERVER["HTTP_USER_AGENT"]) ? $_SERVER["HTTP_USER_AGENT"] : "", "time" => TIME, "logged" => 1);
     Core::getQuery()->insert("sessions", $spec);
     if ($this->canLogin) {
         if (COOKIE_SESSION) {
             Core::getRequest()->setCookie("sid", $this->sid, $this->getCookieExpire());
             $this->sessionUrl = $this->redirection;
         } else {
             if (Str::inString("?", $this->redirection)) {
                 $this->sessionUrl = $this->redirection . "&sid=" . $this->sid . "&login=true";
             } else {
                 $this->sessionUrl = $this->redirection . "?sid=" . $this->sid . "&login=true";
             }
         }
         if ($this->cacheActive) {
             Core::getCache()->buildUserCache($this->sid);
         }
         Hook::event("StartSession", array($this, $this->sessionUrl));
         if ($this->redirectOnSuccess) {
             doHeaderRedirection($this->sessionUrl, true);
         }
     } else {
         $this->loginFailed("CANNOT_LOGIN");
     }
     return $this;
 }
示例#17
0
 /**
  * @param array $phraseids
  * @return Bengine_Admin_Controller_Language
  */
 protected function savePhrases(array $phraseids)
 {
     foreach ($phraseids as $id) {
         $spec = array("languageid" => Core::getRequest()->getPOST("language_" . $id), "phrasegroupid" => Core::getRequest()->getPOST("phrasegroup_" . $id), "title" => Core::getRequest()->getPOST("title_" . $id), "content" => Core::getRequest()->getPOST("content_" . $id));
         Core::getQuery()->update("phrases", $spec, "phraseid = ?", array($id));
     }
     Admin::rebuildCache("lang", array("language" => Core::getRequest()->getGET("1")));
     return $this;
 }
示例#18
0
 /**
  * @param integer $id
  * @return Bengine_Admin_Controller_Config
  */
 protected function saveVars($id)
 {
     $result = Core::getQuery()->select("config", array("var", "type"), "", Core::getDB()->quoteInto("groupid = ? AND islisted = '1'", $id), "sort_index ASC");
     foreach ($result->fetchAll() as $row) {
         $value = Core::getRequest()->getPOST($row["var"]);
         Core::getQuery()->update("config", array("value" => $this->convertRawValue($value, $row["type"])), "var = ?", array($row["var"]));
     }
     Admin::rebuildCache("config");
     return $this;
 }
示例#19
0
 /**
  * Run dispatch process.
  *
  * @return mixed
  */
 protected function dispatch()
 {
     Hook::event("PreDispatch");
     $controllerName = Core::getRequest()->getGET("controller", "index");
     $package = Core::getRequest()->getGET("package", DEFAULT_PACKAGE);
     $overridePackage = null;
     if (strpos($controllerName, ".")) {
         list($overridePackage, $controllerName) = explode(".", $controllerName);
     }
     self::$controllerName = $controllerName;
     $config = array("action" => Core::getRequest()->getGET("action", "index"));
     $class = ($overridePackage !== null ? $overridePackage : $package) . "/controller_" . lcfirst($controllerName);
     self::$controller = self::factory($class, $config);
     if (!self::$controller) {
         self::$controller = self::factory($package . "/controller_index", array("action" => "noroute"));
     }
     Hook::event("PostDispatch");
     return self::$controller->run();
 }
示例#20
0
<?php

/**
 * Assures anonym refering to hide session id.
 *
 * @package Bengine
 * @copyright Copyright protected by / Urheberrechtlich geschützt durch "Sebastian Noll" <*****@*****.**>
 * @version $Id: refdir.php 8 2010-10-17 20:55:04Z secretchampion $
 */
require_once "./global.inc.php";
new Core();
if ($url = Core::getRequest()->getGET("url")) {
    Core::getTPL()->assign("link", $url);
    Core::getTPL()->assign("charset", CHARACTER_SET);
    Core::getTPL()->addHTMLHeaderFile("game.css", "css");
    $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));
    Core::getTPL()->display("externlink", true);
}
示例#21
0
 /**
  * Shows the fleet events of the stated planet.
  * Firstly, check for validation (Range, consumption, ...)
  *
  * @return Bengine_Game_Controller_MonitorPlanet
  */
 protected function init()
 {
     $this->planetid = Core::getRequest()->getGET("1");
     $this->planetData = Game::getModel("game/planet")->load($this->planetid);
     return parent::init();
 }
示例#22
0
 /**
  * Returns whether the universe is selected as default.
  *
  * @return boolean
  */
 public function isSelected()
 {
     return Core::getRequest()->getCOOKIE("uni") == $this->getName() ? true : false;
 }
示例#23
0
 /**
  * @param string $function
  * @param string $param
  *
  * @return string
  */
 protected function func($function, $param = null)
 {
     $function = strtolower($function);
     switch ($function) {
         case "version":
             return "v" . Game::getVersion();
             break;
         case "const":
             return constant($param);
             break;
         case "config":
             return Core::getConfig()->get($param);
             break;
         case "user":
             return Core::getUser()->get($param);
             break;
         case "cookie":
             return Core::getRequest()->getCOOKIE($param);
             break;
         case "image":
             return Image::getImage($param, "");
             break;
         case "callback":
             return call_user_func_array($param["function"], $param["arguments"]);
             break;
     }
     return "";
 }
示例#24
0
 /**
  * @return Bengine_Game_Controller_Shipyard
  */
 protected function cancelAction()
 {
     $events = Core::getRequest()->getPOST("shipyard_events");
     foreach ($events as $eventId) {
         $event = Game::getModel("game/event")->load((int) $eventId);
         if ($event->get("userid") == Core::getUser()->get("userid")) {
             Game::getEH()->removeEvent($event);
         }
     }
     $this->redirect("game/" . SID . "/" . Core::getRequest()->getGET("controller"));
     return $this;
 }
示例#25
0
 /**
  * Saves the entered data.
  *
  * @param integer $unitid
  * @param string $nameId
  * @param string $name
  * @param integer $allowOnMoon
  * @param string $desc
  * @param string $fullDesc
  * @param integer $basicMetal
  * @param integer $basicSilicon
  * @param integer $basicHydrogen
  * @param integer $basicEnergy
  * @param integer $capacity
  * @param integer $speed
  * @param integer $consumption
  * @param integer $attack
  * @param integer $shield
  * @param integer $baseEngine
  * @param integer $extentedEngine
  * @param integer $extentedEngineLevel
  * @param integer $extentedEngineSpeed
  * @param integer $rfDelete
  * @param integer $rfNew
  * @param integer $rfNewValue
  *
  * @return Bengine_Game_Controller_Unit
  */
 protected function saveConstruction($unitid, $nameId, $name, $allowOnMoon, $desc, $fullDesc, $basicMetal, $basicSilicon, $basicHydrogen, $basicEnergy, $capacity, $speed, $consumption, $attack, $shield, $baseEngine, $extentedEngine, $extentedEngineLevel, $extentedEngineSpeed, $rfDelete, $rfNew, $rfNewValue)
 {
     Hook::event("EditUnitSave");
     $languageid = Core::getLang()->getOpt("languageid");
     $spec = array("allow_on_moon" => $allowOnMoon, "basic_metal" => $basicMetal, "basic_silicon" => $basicSilicon, "basic_hydrogen" => $basicHydrogen, "basic_energy" => $basicEnergy);
     Core::getQuery()->update("construction", $spec, "name = ?", array($nameId));
     $spec = array("capicity" => $capacity, "speed" => $speed, "consume" => $consumption, "attack" => $attack, "shield" => $shield);
     Core::getQuery()->update("ship_datasheet", $spec, "unitid = ?", array($unitid));
     Core::getQuery()->update("ship2engine", array("engineid" => $baseEngine), "unitid = ? AND base = ?", array($unitid, 1));
     Core::getQuery()->delete("ship2engine", "unitid = ? AND base = ?", null, null, array($unitid, 0));
     if ($extentedEngineLevel > 0) {
         Core::getQuery()->insert("ship2engine", array("engineid" => $extentedEngine, "unitid" => $unitid, "level" => $extentedEngineLevel, "base_speed" => $extentedEngineSpeed, "base" => 0));
     }
     if (Str::length($name) > 0) {
         $result = Core::getQuery()->select("phrases", "phraseid", "", Core::getDB()->quoteInto("title = ?", $nameId));
         if ($result->rowCount() > 0) {
             Core::getQuery()->update("phrases", array("content" => convertSpecialChars($name)), "title = ?", array($nameId));
         } else {
             Core::getQuery()->insert("phrases", array("languageid" => $languageid, "phrasegroupid" => 4, "title" => $nameId, "content" => convertSpecialChars($name)));
         }
         $result->closeCursor();
     }
     if (Str::length($desc) > 0) {
         $result = Core::getQuery()->select("phrases", "phraseid", "", Core::getDB()->quoteInto("title = ?", $nameId . "_DESC"));
         if ($result->rowCount() > 0) {
             Core::getQuery()->update("phrases", array("content" => convertSpecialChars($desc)), "title = ?", array($nameId . "_DESC"));
         } else {
             Core::getQuery()->insert("phrases", array("languageid" => $languageid, "phrasegroupid" => 4, "title" => $nameId . "_DESC", "content" => convertSpecialChars($desc)));
         }
         $result->closeCursor();
     }
     if (Str::length($fullDesc) > 0) {
         $result = Core::getQuery()->select("phrases", "phraseid", "", Core::getDB()->quoteInto("title = ?", $nameId . "_FULL_DESC"));
         if ($result->rowCount() > 0) {
             Core::getQuery()->update("phrases", array("content" => convertSpecialChars($fullDesc)), "title = ?", array($nameId . "_FULL_DESC"));
         } else {
             Core::getQuery()->insert("phrases", array("languageid" => $languageid, "phrasegroupid" => 4, "title" => $nameId . "_FULL_DESC", "content" => convertSpecialChars($fullDesc)));
         }
         $result->closeCursor();
     }
     Core::getLang()->rebuild("info");
     // Rapidfire
     $result = Core::getQuery()->select("rapidfire", array("target", "value"), "", Core::getDB()->quoteInto("unitid = ?", $this->id));
     foreach ($result->fetchAll() as $row) {
         if (is_array($rfDelete) && in_array($row["target"], $rfDelete)) {
             Core::getQuery()->delete("rapidfire", "unitid = ? AND target = ?", null, null, array($this->id, $row["target"]));
         } else {
             if (Core::getRequest()->getPOST("rf_" . $row["target"]) != $row["value"]) {
                 Core::getQuery()->update("rapidfire", array("value" => Core::getRequest()->getPOST("rf_" . $row["target"])), "unitid = ? AND target = ?", array($this->id, $row["target"]));
             }
         }
     }
     if ($rfNew > 0 && $rfNewValue > 0) {
         Core::getQuery()->delete("rapidfire", "unitid = ? AND target = ?", null, null, array($this->id, $rfNew));
         Core::getQuery()->insert("rapidfire", array("unitid" => $this->id, "target" => $rfNew, "value" => $rfNewValue));
     }
     return $this;
 }
示例#26
0
 /**
  * Rank management for the alliance.
  *
  * @return Bengine_Game_Controller_Alliance
  */
 protected function rightManagementAction()
 {
     $post = Core::getRequest()->getPOST();
     if ($this->getRights(array("CAN_MANAGE"))) {
         if (isset($post["createrank"])) {
             if (Str::length($post["name"]) <= 30) {
                 Core::getQuery()->insert("allyrank", array("aid" => $this->aid, "name" => Str::validateXHTML($post["name"])));
             }
         } else {
             if (isset($post["changerights"])) {
                 $result = Core::getQuery()->select("allyrank", "rankid", "", Core::getDB()->quoteInto("aid = ?", $this->aid));
                 foreach ($result->fetchAll() as $row) {
                     if (isset($post["CAN_SEE_MEMBERLIST_" . $row["rankid"]])) {
                         $can_see_memberlist = 1;
                     } else {
                         $can_see_memberlist = 0;
                     }
                     if (isset($post["CAN_SEE_APPLICATIONS_" . $row["rankid"]])) {
                         $can_sse_applications = 1;
                     } else {
                         $can_sse_applications = 0;
                     }
                     if (isset($post["CAN_MANAGE_" . $row["rankid"]])) {
                         $can_manage = 1;
                     } else {
                         $can_manage = 0;
                     }
                     if (isset($post["CAN_BAN_MEMBER_" . $row["rankid"]])) {
                         $can_ban_member = 1;
                     } else {
                         $can_ban_member = 0;
                     }
                     if (isset($post["CAN_SEE_ONLINE_STATE_" . $row["rankid"]])) {
                         $can_see_onlie_state = 1;
                     } else {
                         $can_see_onlie_state = 0;
                     }
                     if (isset($post["CAN_WRITE_GLOBAL_MAILS_" . $row["rankid"]])) {
                         $can_write_global_mails = 1;
                     } else {
                         $can_write_global_mails = 0;
                     }
                     $spec = array("CAN_SEE_MEMBERLIST" => $can_see_memberlist, "CAN_SEE_APPLICATIONS" => $can_sse_applications, "CAN_MANAGE" => $can_manage, "CAN_BAN_MEMBER" => $can_ban_member, "CAN_SEE_ONLINE_STATE" => $can_see_onlie_state, "CAN_WRITE_GLOBAL_MAILS" => $can_write_global_mails);
                     Core::getQuery()->update("allyrank", $spec, "rankid = ? AND aid = ?", array($row["rankid"], $this->aid));
                 }
                 $result->closeCursor();
             } else {
                 if (!empty($post)) {
                     foreach ($post as $key => $value) {
                         if (preg_match("#^delete\\_#i", $key)) {
                             Core::getQuery()->delete("allyrank", "rankid = ? AND aid = ?", null, null, array(Str::replace("delete_", "", $key), $this->aid));
                             break;
                         }
                     }
                 }
             }
         }
         $select = array("rankid", "name", "CAN_SEE_MEMBERLIST", "CAN_SEE_APPLICATIONS", "CAN_MANAGE", "CAN_BAN_MEMBER", "CAN_SEE_ONLINE_STATE", "CAN_WRITE_GLOBAL_MAILS");
         $result = Core::getQuery()->select("allyrank", $select, "", Core::getDB()->quoteInto("aid = ?", $this->aid));
         Core::getTPL()->assign("num", $result->rowCount());
         Core::getTPL()->addLoop("ranks", $result);
     }
     return $this;
 }
示例#27
0
 /**
  * Initializes the languages.
  *
  * @return void
  */
 protected static function initLanguage()
 {
     $result = Core::getQuery()->select("languages", array("langcode", "title"));
     Core::getTPL()->addLoop("languages", $result->fetchAll());
     Core::getTPL()->assign("langCount", $result->rowCount());
     $selfUrl = "/" . Core::getRequest()->getGET("controller") . "/" . Core::getRequest()->getGET("action");
     Core::getTPL()->assign("selfUrl", Core::getRequest()->getGET("controller", false) ? $selfUrl : "");
     return;
 }
 /**
  * Sets the current page.
  *
  * @param integer
  *
  * @return Pagination
  */
 public function setCurrentPage($currentPage = 0)
 {
     if ($currentPage <= 0) {
         $currentPage = $this->getConfig("rewrite_on") ? Core::getRequest()->getGET("Page", 1) : Core::getRequest()->getGET("page", 1);
         if (empty($currentPage)) {
             $currentPage = 1;
         }
     }
     $this->currentPage = $currentPage;
     return $this;
 }