Пример #1
0
 /**
  * Activates an account, if key exists.
  * Starts log in on success.
  *
  * @return Bengine_Game_Account_Activation
  */
 protected function activateAccount()
 {
     if (!empty($this->key)) {
         $result = Core::getQuery()->select("user u", array("u.userid", "u.username", "p.password", "temp_email"), "LEFT JOIN " . PREFIX . "password p ON (p.userid = u.userid)", Core::getDB()->quoteInto("u.activation = ?", $this->getKey()));
         if ($row = $result->fetchRow()) {
             $result->closeCursor();
             Hook::event("ActivateAccount", array($this));
             Core::getQuery()->update("user", array("activation" => "", "email" => $row["temp_email"]), "userid = ?", array($row["userid"]));
             $login = new Bengine_Game_Login($row["username"], $row["password"], "game", "trim");
             $login->setCountLoginAttempts(false);
             $login->checkData();
             $login->startSession();
             return $this;
         }
         $result->closeCursor();
     }
     Recipe_Header::redirect("?error=ACTIVATION_FAILED", false);
     return $this;
 }
Пример #2
0
 /**
  * Demolish a building ...
  *
  * @param integer $id
  * @throws Recipe_Exception_Generic
  * @return Bengine_Game_Controller_Constructions
  */
 protected function demolishAction($id)
 {
     if ($this->event != false || Core::getUser()->get("umode")) {
         Recipe_Header::redirect("game/" . SID . "/Constructions", false);
     }
     $result = Core::getQuery()->select("building2planet b2p", array("c.basic_metal", "c.basic_silicon", "c.basic_hydrogen", "c.charge_metal", "c.charge_silicon", "c.charge_hydrogen", "c.name", "c.demolish"), "LEFT JOIN " . PREFIX . "construction c ON (c.buildingid = b2p.buildingid)", Core::getDB()->quoteInto("b2p.buildingid = ?", $id));
     if (!($row = $result->fetchRow())) {
         $result->closeCursor();
         throw new Recipe_Exception_Generic("Unkown building :(");
     }
     $result->closeCursor();
     $level = Game::getPlanet()->getBuilding($id);
     if ($level < 1) {
         throw new Recipe_Exception_Generic("Wut?");
     }
     if ($id == 12 && Game::getEH()->getResearchEvent()) {
         throw new Recipe_Exception_Generic("Do not mess with the url.");
     }
     $shipyardSize = Game::getEH()->getShipyardEvents()->getCalculatedSize();
     if (($id == 8 || $id == 7) && $shipyardSize > 0) {
         throw new Recipe_Exception_Generic("Do not mess with the url.");
     }
     Hook::event("DemolishBuldingFirst", array(&$row, $level));
     $data["metal"] = 0;
     $data["silicon"] = 0;
     $data["hydrogen"] = 0;
     $data["level"] = $level - 1;
     if ($row["basic_metal"] > 0) {
         $data["metal"] = parseFormula($row["charge_metal"], $row["basic_metal"], $level);
     }
     if ($row["basic_silicon"] > 0) {
         $data["silicon"] = parseFormula($row["charge_silicon"], $row["basic_silicon"], $level);
     }
     if ($row["basic_hydrogen"] > 0) {
         $data["hydrogen"] = parseFormula($row["charge_hydrogen"], $row["basic_hydrogen"], $level);
     }
     $factor = floatval($row["demolish"]);
     if ($factor <= 0.0) {
         throw new Recipe_Exception_Generic("The building cannot be demolished.");
     }
     $data["metal"] = 1 / $factor * $data["metal"];
     $data["silicon"] = 1 / $factor * $data["silicon"];
     $data["hydrogen"] = 1 / $factor * $data["hydrogen"];
     if ($data["metal"] <= Game::getPlanet()->getData("metal") && $data["silicon"] <= Game::getPlanet()->getData("silicon") && $data["hydrogen"] <= Game::getPlanet()->getData("hydrogen")) {
         $data["buildingname"] = $row["name"];
         $data["buildingid"] = $id;
         $time = getBuildTime($data["metal"], $data["silicon"], self::BUILDING_CONSTRUCTION_TYPE);
         Hook::event("DemolishBuldingLast", array(&$data, &$time));
         Game::getEH()->addEvent(2, $time + TIME, Core::getUser()->get("curplanet"), Core::getUser()->get("userid"), null, $data);
         $this->redirect("game/" . SID . "/Constructions");
     } else {
         throw new Recipe_Exception_Generic("Not enough resources to build this.");
     }
     return $this;
 }
Пример #3
0
 /**
  * Executes a redirection.
  *
  * @param string $url		Uri or Url
  * @param boolean $session	Append session? [optional]
  *
  * @return Bengine_Game_Controller_Abstract
  */
 protected function redirect($url, $session = false)
 {
     Recipe_Header::redirect($url, $session);
     return $this;
 }
Пример #4
0
/**
 * Perform an header redirection.
 *
 * @param string $url
 * @param bool $appendSession
 * @return void
 */
function doHeaderRedirection($url, $appendSession = false)
{
    Recipe_Header::redirect($url, $appendSession);
}
Пример #5
0
 /**
  * Sends header information to client and compress output.
  *
  * @return Recipe_Template_Adapter_Abstract
  */
 public function sendHeader()
 {
     if (!Recipe_Header::isSend()) {
         if (extension_loaded("zlib") && strtolower(ini_get("zlib.output_compression")) == "off" && !$this->compressed && GZIP_ACITVATED) {
             ob_start("ob_gzhandler");
             $this->compressed = true;
         }
         Recipe_Header::add("Content-Type", $this->contentType . "; charset=" . CHARACTER_SET);
         Recipe_Header::send();
     }
     return $this;
 }
Пример #6
0
 /**
  * Sets and/or returns the HTTP protocol version.
  *
  * @param string $protocol	Protocol version [optional]
  *
  * @return string	Protocol version
  */
 public static function protocol($protocol = null)
 {
     if (!is_null($protocol)) {
         self::$protocol = $protocol;
     }
     return self::$protocol;
 }