public function exec() { $db = \Kiki\Core::getDb(); $user = \Kiki\Core::getUser(); $article = new \Kiki\Article($this->instanceId); $this->title = $article->title(); $template = \Kiki\Template::getInstance(); $template->append('stylesheets', \Kiki\Config::$kikiPrefix . "/scripts/prettify/prettify.css"); if ($article->visible() || $article->userId() == $user->id()) { $this->title = $article->title(); $this->status = 200; $this->template = 'pages/default'; $template = new \Kiki\Template('content/pages-single'); $template->assign('page', $article->templateData()); $this->content = $template->fetch(); } }
public function verifyAction() { $this->status = 200; $this->template = 'pages/default'; $this->title = _("Verify account"); $template = new \Kiki\Template('content/account-verify'); $errors = array(); $warnings = array(); $user = \Kiki\Core::getUser(); $token = isset($_GET['token']) ? $_GET['token'] : null; if (empty($token)) { $errors[] = "Auth token missing."; } else { // Get user by auth token. $verifyUserId = $user->getIdByToken($token); if (!$verifyUserId) { $errors[] = "Invalid auth token. Auth tokens expire. [Send new verification e-mail]"; } else { $verifyUser = new \Kiki\User($verifyUserId); $verifyUser->setIsVerified(true); $verifyUser->save(); if ($user->id() && $user->id() != $verifyUser->id()) { $warnings[] = sprintf("Because you verified account <strong>%s</strong> (%d), you are no longer logged in as <strong>%s</strong> (%d).", $verifyUser->email(), $verifyUser->id(), $user->email(), $user->id()); } else { Auth::setCookie($verifyUser->id()); $user = $verifyUser; \Kiki\Core::setUser($verifyUser); $mainTemplate = \Kiki\Template::getInstance(); $mainTemplate->assign('user', $user->templateData()); } } } $template->assign('warnings', $warnings); $template->assign('errors', $errors); $this->content = $template->fetch(); return true; }