コード例 #1
0
ファイル: Index.php プロジェクト: enriquesomolinos/Bengine
 /**
  * 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;
 }
コード例 #2
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;
 }
コード例 #3
0
 /**
  * Switch to user account.
  *
  * @return Bengine_Game_Controller_Moderator
  */
 protected function switchUserAction()
 {
     Core::getUser()->checkPermissions(array("CAN_SWITCH_USER"));
     $result = Core::getQuery()->select("user u", array("u.username", "p.password"), "LEFT JOIN " . PREFIX . "password p ON p.userid = u.userid", Core::getDB()->quoteInto("u.userid = ?", $this->userid));
     if ($row = $result->fetchRow()) {
         $result->closeCursor();
         $login = new Bengine_Game_Login($row["username"], $row["password"], "game", "trim");
         $login->setCountLoginAttempts(false);
         $login->checkData();
         $login->startSession();
     }
     $result->closeCursor();
     return $this;
 }