public function createAction() { $request = $this->app->request; $resp = new Response(); $errors = array(); $title = $request->getPostParam('title'); $content = $request->getPostParam('content'); if (!$title) { $errors['title'] = 'Введите заголовок'; } if (!$content) { $errors['content'] = 'Введите текст'; } if (!$errors) { $post = new Post(array('user_id' => $this->app->user->getId(), 'title' => $title, 'content' => $content)); if ($id = $post->save()) { $resp->redirect($this->app->router->path('post.show', array($id))); return $resp; } else { $errors[] = 'Не удалось добавить пост'; } } $resp->setTplVars(array('values' => array('title' => $title, 'content' => $content))); $resp->setTplVars(array('errors' => $errors)); $resp->setTemplate('new_post.html'); return $resp; }
public function comment($section, $newsId) { $comment = Input::get('comment'); $user = User::get(); Comment::Insert(array('newsId' => $newsId, 'userId' => $user->id, 'comment' => $comment)); Response::redirect('/' . $section . '/' . $newsId); }
public function logoutAction() { $this->app->user->logout(); $resp = new Response(); $resp->redirect($this->app->router->path('home')); return $resp; }
public function Lockscreen() { global $user; if (isset($_POST['email']) && isset($_POST['passwd'])) { $result = array("status" => 0, "message" => "验证失败"); $passwd = htmlspecialchars($_POST['passwd']); $result['passwd'] = $passwd; $user = User::getInstance(); $user = $user->GetUserByEmail($user->email); $result['obj'] = $user; if ($user->verifyPassword($passwd)) { Util::setToken(); $result['status'] = 1; $result['message'] = "验证成功, 将跳转到 >> 仪表盘"; } else { $result['message'] = "我跟你讲, 你密码错的在试2遍就给你锁了."; } echo json_encode($result); exit; } else { if (!\Helper\Listener::checkLogin()) { \Core\Response::redirect('/Auth/login'); exit; } include Template::load('/panel/lockscreen'); } exit; }
/** * Common method to get a project * * @access protected * @param integer $project_id Default project id * @return array */ protected function getProject($project_id = 0) { $project_id = $this->request->getIntegerParam('project_id', $project_id); $project = $this->project->getById($project_id); if (!$project) { $this->session->flashError(t('Project not found.')); $this->response->redirect('?controller=project'); } return $project; }
/** * Common method to get a project * * @access protected * @param integer $project_id Default project id * @return array */ protected function getProject($project_id = 0) { $project_id = $this->request->getIntegerParam('project_id', $project_id); $project = $this->project->getById($project_id); if (empty($project)) { $this->session->flashError(t('Project not found.')); $this->response->redirect($this->helper->url->to('project', 'index')); } return $project; }
public function subscribe() { $user = Input::get('user'); $password = Input::get('password'); $name = Input::get('name'); $email = Input::get('email'); $address = Input::get('address'); $gender = Input::get('gender'); $result = User::query()->where('user', '=', $user)->first(); if (!is_null($result)) { return Response::redirect('/login?error=subscribe'); } User::insert(array('user' => $user, 'password' => md5($password), 'name' => $name, 'email' => $email, 'address' => $address, 'gender' => $gender)); return Response::redirect('/login'); }
public function initSalt() { $lockFile = ROOT_PATH . 'install.lock'; $configFile = DATA_PATH . 'Config.php'; // sql //Migrations //判断是否已经安装. if (!file_exists($configFile)) { copy(DATA_PATH . 'Config.simple.php', $configFile); } if (!file_exists($lockFile)) { Key::SetConfig("ENCRYPT_KEY", Key::CreateKey()); Key::SetConfig("COOKIE_KEY", Key::CreateKey()); file_put_contents($lockFile, ""); echo "安装成功..即将跳转"; Response::redirect("/"); } else { throw new Error("程序已经安装,重置KEY将导致账户无法登陆,已禁止操作。<br/>若要强制重置,请删除程序目录下的install.lock", 555); } }
public function __construct() { global $user; $user = User::getInstance(); if (!$user->uid) { Response::redirect('/Auth/login'); } if (LOCKSCREEN) { // check LOACKSCREEN define if (!empty(@$_COOKIE['token'])) { $token = Util::getToken(); if ($token > 3600 && stristr(\Core\Request::getRequestPath(), 'lockscreen') == false) { Response::redirect('/Auth/lockscreen'); } } else { Response::redirect('/Auth/lockscreen'); } } $user = $user->GetUserByEmail($user->email); }
/** * Redirection when there is no project in the database * * @access protected */ protected function redirectNoProject() { $this->session->flash(t('There is no active project, the first step is to create a new project.')); $this->response->redirect('?controller=project&action=create'); }
public function delete($newsId) { $news = News::findById($newsId); $news->delete(); Response::redirect('/admin/news'); }
public function help() { Response::redirect("http://www.ishadowsocks.org/"); }
public function index() { Response::redirect("/Admin/user"); }
public function index() { Response::redirect('admin/home'); }