本文整理汇总了PHP中Response::redirect方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::redirect方法的具体用法?PHP Response::redirect怎么用?PHP Response::redirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Response
的用法示例。
在下文中一共展示了Response::redirect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* default action 'index'
* @param Request $request
* @param Response $response
*/
public function index(Request $request, Response $response)
{
if (Common_Model::admin_logined()) {
$response->redirect('/home');
} else {
$response->redirect('/login');
}
}
示例2: resolveRoute
public function resolveRoute()
{
$request_uri = $this->request->request_uri();
if ($request_uri != '/') {
$controllerName = $this->getControllerName($request_uri);
if (strpos($controllerName, '\\')) {
return $controllerName;
}
return $this->namespace . '\\' . $controllerName;
}
$this->response->redirect(Response::REDIRECT_LOGIN);
}
示例3: action_index
/**
* The index action
*
* @access public
* @return void
*/
public function action_index()
{
$settings = \Config::load('autoresponder.db');
// $autoResponder = Model_Setting::find(array('where' => array(array('meta_key', '=', 'auto-responders'))));
if (\Input::post()) {
$input = \Input::post();
if (!\Input::is_ajax()) {
$val = Model_Setting::validate('create');
if (!$val->run()) {
if ($val->error() != array()) {
// show validation errors
\Messages::error('<strong>There was an error while trying to create settings</strong>');
foreach ($val->error() as $e) {
\Messages::error($e->get_message());
}
}
} else {
try {
\Config::save('autoresponder.db', array('logo_url' => $input['logo_url'], 'company_name' => $input['company_name'], 'address' => $input['address'], 'website' => $input['website'], 'phone' => $input['phone'], 'email_address' => $input['email_address'], 'sender_email_address' => $input['sender_email_address'], 'contact_us_email_address' => $input['contact_us_email_address'], 'instagram_account_name' => $input['instagram_account_name'], 'facebook_account_name' => $input['facebook_account_name']));
// $setting->save();
\Messages::success('Settings successfully created.');
\Response::redirect('admin/settings');
} catch (\Database_Exception $e) {
// show validation errors
\Messages::error('<strong>There was an error while trying to create settings.</strong>');
// Uncomment lines below to show database errors
$errors = $e->getMessage();
\Messages::error($errors);
}
}
}
}
\View::set_global('title', 'Settings');
\Theme::instance()->set_partial('content', $this->view_dir . 'index')->set('settings', $settings, false);
}
示例4: before
/**
* @param none
* @throws none
* @returns void
*/
public function before()
{
$result = array();
// users need to be logged in to access this controller
if (!\Sentry::check()) {
$result = array('message' => 'You need to be logged in to access that page.', 'url' => '/admin/login');
// Don't show this message if url is just 'admin'
if (\Uri::string() == 'admin/admin/index') {
unset($result['message']);
}
\Session::set('redirect_to', \Uri::admin('current'));
} else {
if (!\Sentry::user()->is_admin()) {
$result = array('message' => 'Access denied. You need to be a member of staff to access that page.', 'url' => '/admin/login');
\Session::set('redirect_to', \Uri::admin('current'));
}
}
if (!empty($result)) {
if (\Input::is_ajax()) {
\Messages::error('You need to be logged in to complete this action.');
echo \Messages::display('left', false);
exit;
} else {
if (isset($result['message'])) {
\Messages::warning($result['message']);
}
\Response::redirect($result['url']);
}
}
parent::before();
}
示例5: action_edit
public function action_edit($id = null)
{
parent::has_access("create_employee");
is_null($id) and Response::redirect('employees/view' . $id);
if (!($bank = Model_Bank::find('first', array('where' => array('employee_id' => $id))))) {
Session::set_flash('error', 'Could not find user #' . $id);
Response::redirect('employees/view/' . $id);
}
if (Input::method() == 'POST') {
$bank->account_no = Input::post('account_no');
$bank->account_type = Input::post('account_type');
$bank->branch = Input::post('branch');
$bank->city = Input::post('city');
$bank->state = Input::post('state');
$bank->ifsc_code = Input::post('ifsc_code');
$bank->payment_type = Input::post('payment_type');
if ($bank->save()) {
Session::set_flash('success', 'Updated bank details #' . $id);
Response::redirect('employees/view/' . $id);
} else {
Session::set_flash('error', 'Could not update bank #' . $id);
}
}
$this->template->title = "Banks";
$this->template->content = View::forge('banks/edit');
}
示例6: testRedirect
/**
* @runInSeparateProcess
*/
public function testRedirect()
{
$response = new Response($this->makeRequest());
$response->exitAfterRedirect(false);
$response->redirect('test.php', false);
$this->assertContains('Location: test.php', xdebug_get_headers());
}
示例7: action_edit
public function action_edit($id = null)
{
$student = Model_Student::find('first', ['where' => ['user_id' => $id]]);
if (!$student) {
$student = Model_Student::forge(['user_id' => $id]);
}
$val = Model_Student::validate('edit');
if ($val->run()) {
$student->user_id = Input::post('user_id');
$student->year_level = Input::post('year_level');
$student->course_id = Input::post('course_id');
if ($student->save()) {
Session::set_flash('success', e('Updated student #' . $id));
Response::redirect('site/student');
} else {
Session::set_flash('error', e('Could not update student #' . $id));
}
} else {
if (Input::method() == 'POST') {
$student->user_id = $val->validated('user_id');
$student->year_level = $val->validated('year_level');
$student->course_id = $val->validated('course_id');
Session::set_flash('error', $val->error());
}
$this->template->set_global('student', $student, false);
}
$this->template->title = "Students";
$this->template->content = View::forge('site/student/edit');
}
示例8: action_edit
public function action_edit($id = null)
{
is_null($id) and Response::redirect('date');
if (!($date = Model_Date::find($id))) {
Session::set_flash('error', 'Could not find Date' . $id);
Response::redirect('date');
}
$val = Model_Date::validate('date');
if ($val->run()) {
$date->title = Input::post('title');
$date->summary = Input::post('summary');
$date->date = strtotime(Input::post('date'));
$date->date_keywords = Input::post('date_keywords');
if ($date->save()) {
Session::set_flash('success', 'Updated Dates #' . $id);
Response::redirect('admin/date');
} else {
Session::set_flash('error', 'Could not update date #' . $id);
}
} else {
if (Input::method() == 'POST') {
$date->title = Input::post('title');
$date->summary = Input::post('summary');
$date->date = Input::post('date');
$date->date_keywords = Input::post('date_keywords');
Session::set_flash('error', $val->error());
}
$this->template->set_global('date', $date, false);
}
$this->template->title = "Dates";
$this->template->content = View::forge('admin/date/create');
}
示例9: action_new
public function action_new()
{
$data = [];
if (Input::post("firstname", null) != null and Security::check_token()) {
$email = Input::post("email", null);
if ($email != $this->user->email) {
$check_user = Model_User::find("first", ["where" => [["email" => $email]]]);
if ($check_user == null) {
$this->email = $email;
} else {
$data["error"] = "This email is already in use.";
}
}
if (!isset($data["error"])) {
$this->user->firstname = Input::post("firstname", "");
$this->user->middlename = Input::post("middlename", "");
$this->user->lastname = Input::post("lastname", "");
$this->user->google_account = Input::post("google_account", "");
$this->user->password = Auth::instance()->hash_password(Input::post('password', ""));
$this->user->birthday = Input::post("year") . "-" . Input::post("month") . "-" . Input::post("day");
$this->user->google_account = Input::post("google_account");
$this->user->need_reservation_email = Input::post("need_reservation_email");
$this->user->need_news_email = Input::post("need_news_email");
$this->user->timezone = Input::post("timezone");
$this->user->save();
Response::redirect("students");
}
}
$data['pasts'] = Model_Lessontime::find("all", ["where" => [["student_id", $this->user->id], ["status", 2], ["language", Input::get("course", 0)], ["deleted_at", 0]]]);
$data["donetrial"] = Model_Lessontime::find("all", ["where" => [["student_id", $this->user->id], ["status", 2], ["language", Input::get("course", -1)], ["deleted_at", 0]]]);
$view = View::forge("students/setting_new", $data);
$this->template->content = $view;
}
示例10: action_viewtype
/**
* Mmeber setting timeline_view
*
* @access public
* @return Response
*/
public function action_viewtype()
{
$page_name = term('timeline', 'site.view', 'site.setting');
$val = \Form_MemberConfig::get_validation($this->u->id, 'timeline_viewType');
if (Input::method() == 'POST') {
Util_security::check_csrf();
try {
if (!$val->run()) {
throw new \FuelException($val->show_errors());
}
$post = $val->validated();
\DB::start_transaction();
\Form_MemberConfig::save($this->u->id, $val, $post);
\DB::commit_transaction();
\Session::set_flash('message', $page_name . 'を変更しました。');
\Response::redirect('member/setting');
} catch (\FuelException $e) {
if (\DB::in_transaction()) {
\DB::rollback_transaction();
}
\Session::set_flash('error', $e->getMessage());
}
}
$this->set_title_and_breadcrumbs($page_name, array('member/setting' => term('site.setting', 'form.update')), $this->u);
$this->template->content = \View::forge('member/setting/timeline_viewtype', array('val' => $val));
}
示例11: action_usercp
public function action_usercp()
{
if (!$this->current_user->logged_in()) {
Session::set_flash('error', 'You need to be logged in to access is page');
Session::set_flash('login_redirect', Uri::current());
Response::redirect('login');
}
$this->title('UserCP');
$this->view = $this->theme->view('users/usercp');
if (Input::param() != array()) {
// Set name and email
$this->current_user->name = Input::param('name');
$this->current_user->email = Input::param('email');
// Set new password
if (Input::param('new_password')) {
$this->current_user->password = Input::param('new_password');
}
// Check if the current password is valid...
$auth = Model_User::authenticate_login($this->current_user->username, Input::param('current_password'));
if ($this->current_user->is_valid() and $auth) {
$this->current_user->save();
Session::set_flash('success', 'Details saved');
Response::redirect('usercp');
} else {
$errors = $this->current_user->errors();
if (!$auth) {
$errors = array('Current password is invalid.') + $errors;
}
}
$this->view->set('errors', isset($errors) ? $errors : array());
}
}
示例12: action_detail
public function action_detail($id = 0)
{
$data["forum"] = Model_Forum::find($id);
if ($data["forum"] == null) {
Response::redirect("/teachers/forum/");
}
if (Input::get("del_id", null) != null) {
$del_comment = Model_Comment::find(Input::get("del_id", 0));
if ($del_comment->user_id == $this->user->id) {
$del_comment->deleted_at = time();
$del_comment->save();
}
}
// add
if (Input::post("body", "") != "" and Security::check_token()) {
// save
$comment = Model_Comment::forge();
$comment->body = Input::post("body", "");
$comment->forum_id = $id;
$comment->user_id = $this->user->id;
$comment->save();
}
$data["user"] = $this->user;
$view = View::forge("teachers/forum/detail", $data);
$this->template->content = $view;
}
示例13: action_submit
public function action_submit()
{
if (!Security::check_token()) {
Response::redirect('_404_');
}
if (Session::get_flash('name')) {
$contact = Model_Contact::forge();
$contact->title = Session::get_flash("title");
$contact->body = Session::get_flash("body");
$body = View::forge("email/contact");
$body->set("name", Session::get_flash('name'));
$body->set("email", Session::get_flash('email'));
$body->set("body", Session::get_flash('body'));
$sendmail = Email::forge("JIS");
$sendmail->from(Config::get("statics.info_email"), Config::get("statics.info_name"));
$sendmail->to(Config::get("statics.info_email"));
$sendmail->subject("We got contact/ Game-bootcamp");
$sendmail->body($body);
$sendmail->send();
}
$this->template->title = "Contact";
$this->template->sub = "How can we help you?";
$view = View::forge("contacts/send");
$this->template->content = $view;
}
示例14: action_edit
public function action_edit($id = null, $one = null, $two = null)
{
$redirect = $two ? $one . '/' . $two : $one;
$auction = Model_Auction::find($id);
$val = Model_Auction::validate_edit();
if ($val->run()) {
$auction->item_count = Input::post('item_count');
$auction->price = Input::post('price');
$auction->memo = Input::post('memo');
if (\Security::check_token() && $auction->save()) {
Session::set_flash('success', e('Updated auction #' . $auction->auc_id));
Response::redirect('admin/' . $redirect);
} else {
Session::set_flash('error', e('Could not update auction #' . $auction->auc_id));
}
} else {
if (Input::method() == 'POST') {
$auction->item_count = $val->validated('item_count');
$auction->price = $val->validated('price');
$auction->memo = $val->validated('memo');
Session::set_flash('error', $val->error());
}
$this->template->set_global('auction', $auction, false);
}
$this->template->set_global('redirect', $redirect, false);
$this->template->title = $auction->title;
$this->template->content = View::forge('admin/auction/edit');
}
示例15: action_index
/**
* The basic welcome message
*
* @access public
* @return Response
*/
public function action_index()
{
if (!\Auth::check()) {
return \Response::redirect('cmsadmin/auth/index');
}
return \Response::forge(\View::forge('welcome/index'));
}