当前位置: 首页>>代码示例>>PHP>>正文


PHP Response::redirect方法代码示例

本文整理汇总了PHP中Phalcon\Http\Response::redirect方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::redirect方法的具体用法?PHP Response::redirect怎么用?PHP Response::redirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Phalcon\Http\Response的用法示例。


在下文中一共展示了Response::redirect方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: logoutAction

 /**
  * Logout user, destroying session and invalidating remember me cookie. Forwards to login form.
  */
 public function logoutAction()
 {
     $response = new Response();
     $response->setCookies($this->cookies->set('username', '', strtotime('-1 year')));
     $response->setCookies($this->cookies->set('password', '', strtotime('-1 year')));
     $this->session->destroy();
     return $response->redirect('session/index');
 }
开发者ID:joszz,项目名称:Chell-PHP-Portal,代码行数:11,代码来源:SessionController.php

示例2: redirect

 /**
  * Returns an Redirect to the given url.
  * 
  * @param string $url
  * @return \Phalcon\Http\Response
  */
 protected function redirect($url, $extraParams = array())
 {
     $response = new Response();
     $response->redirect($url);
     $formReflectionManager = new FormReflectionManager($this->flash);
     $formReflectionManager->add($extraParams + $this->request->get());
     return $response;
 }
开发者ID:sweetdevel,项目名称:pingaroo,代码行数:14,代码来源:BaseController.php

示例3: indexAction

 /**
  * Render to dashboard page.
  */
 public function indexAction()
 {
     $uid = $this->session->get('uid');
     $currentUser = $this->getCurrentUserObject($this->session);
     $redirectUrl = '/dashboard/issues';
     if ($currentUser->getUserGroup()->getUserGroupSlug() == 'administrator') {
         $redirectUrl = '/administration';
     }
     $response = new Response();
     $response->redirect($redirectUrl);
     return $response;
 }
开发者ID:kelliany,项目名称:TestZilla,代码行数:15,代码来源:DashboardController.php

示例4: authorizeFinish

 /**
  * Overrule this method when you want to display a nice page when
  * the authorization is finished.  This function does not know if the authorization was
  * succesfull, you need to check the token in the database.
  *
  * @param boolean authorized	if the current token (oauth_token param) is authorized or not
  * @param int user_id			user for which the token was authorized (or denied)
  * @return string verifier  For 1.0a Compatibility
  */
 public function authorizeFinish($authorized, IIdentity $account, $token, $callback)
 {
     //$token = $this->request->getParam('oauth_token', true);
     $verifier = null;
     if ($this->session->get('verify_oauth_token') == $token) {
         // Flag the token as authorized, or remove the token when not authorized
         $store = $this->store;
         // Fetch the referrer host from the oauth callback parameter
         $referrer_host = '';
         $oauth_callback = false;
         $verify_oauth_callback = $callback;
         if (!empty($verify_oauth_callback) && $verify_oauth_callback != 'oob') {
             $oauth_callback = $callback;
             $ps = parse_url($oauth_callback);
             if (isset($ps['host'])) {
                 $referrer_host = $ps['host'];
             }
         }
         if ($authorized) {
             //$this->logger->addNote('Authorized token "'.$token.'" for user '.$account->email.' with referrer "'.$referrer_host.'"');
             // 1.0a Compatibility : create a verifier code
             $verifier = $store->authorizeConsumerRequestToken($token, $account, $referrer_host);
         } else {
             //$this->logger->addNote('Authorization rejected for token "'.$token.'" for user '.$account->email."\nToken has been deleted");
             $store->deleteConsumerRequestToken($token);
         }
         //$logger->alert("service: callback ze sešny: ".$oauth_callback);
         if (!empty($oauth_callback)) {
             //$params = array('oauth_token' => rawurlencode($token));
             // 1.0a Compatibility : if verifier code has been generated, add it to the URL
             //if ($verifier) {
             //    $params['oauth_verifier'] = $verifier;
             //}
             $uri = preg_replace('/\\s/', '%20', $oauth_callback);
             if (!empty($this->allowed_uri_schemes)) {
                 if (!in_array(substr($uri, 0, strpos($uri, '://')), $this->allowed_uri_schemes)) {
                     throw new OauthException('Illegal protocol in redirect uri ' . $uri);
                 }
             } else {
                 if (!empty($this->disallowed_uri_schemes)) {
                     if (in_array(substr($uri, 0, strpos($uri, '://')), $this->disallowed_uri_schemes)) {
                         throw new OauthException('Illegal protocol in redirect uri ' . $uri);
                     }
                 }
             }
             $oauth_callback = $oauth_callback . "?oauth_token=" . rawurlencode($token);
             return $this->response->redirect($oauth_callback, true);
         }
     }
 }
开发者ID:kathynka,项目名称:Foundation,代码行数:59,代码来源:OauthService.php

示例5: registerAction

 public function registerAction()
 {
     if ($this->request->isPost()) {
         $newUser = new Users();
         $newUser->user_name = $this->request->getPost('user_name');
         $newUser->first_name = $this->request->getPost('first_name');
         $newUser->last_name = $this->request->getPost('last_name');
         $newUser->email = $this->request->getPost('email');
         $passwordText = $this->request->getPost('password');
         $password = md5($passwordText, false);
         $newUser->password = $password;
         if (!$newUser->save()) {
             foreach ($newUser->getMessages() as $message) {
                 $this->flash->error($message);
             }
             return $this->dispatcher->forward(array('module' => 'anonymous', "controller" => "user", "action" => "register"));
         }
         $this->flash->success("user was created successfully");
         //redirect to other module cannot use forward
         $response = new Response();
         return $response->redirect('student/index/');
     }
 }
开发者ID:nhannv56,项目名称:hoctap,代码行数:23,代码来源:UserController.php

示例6: Application

     */
    require ROOT_DIR . 'core/config/services.php';
    /**
     * Handle the request
     */
    $application = new Application();
    /**
     * Assign the DI
     */
    $application->setDI($di);
    /**
     * Include modules
     */
    $application->registerModules(require ROOT_DIR . 'core/config/modules.php');
    /**
     * Sets the event manager
     */
    $application->setEventsManager($eventsManager);
    echo $application->handle()->getContent();
} catch (Exception $e) {
    echo $e->getMessage();
    echo $e->getTraceAsString();
    /**
     * Show an static error page
     */
    if (!$di->get('config')->application->debug) {
        $response = new Response();
        $response->redirect('errors/503');
        $response->send();
    }
}
开发者ID:kjmtrue,项目名称:phanbook,代码行数:31,代码来源:index.php

示例7: FactoryDefault

 * Include composer autoloader
 */
require APP_PATH . "/vendor/autoload.php";
try {
    /**
     * The FactoryDefault Dependency Injector automatically register the right services providing a full stack framework
     */
    $di = new FactoryDefault();
    /**
     * Include the application services
     */
    require APP_PATH . "/app/config/services.php";
    /**
     * Handle the request
     */
    $application = new Application($di);
    echo $application->handle()->getContent();
} catch (Exception $e) {
    /**
     * Log the exception
     */
    $logger = new Logger(APP_PATH . '/app/logs/error.log');
    $logger->error($e->getMessage());
    $logger->error($e->getTraceAsString());
    /**
     * Show an static error page
     */
    $response = new Response();
    $response->redirect('505.html');
    $response->send();
}
开发者ID:atsuyim,项目名称:forum,代码行数:31,代码来源:index.php

示例8: passThrouthMiddleWares

 public function passThrouthMiddleWares(Request $request, Response $response, Dispatcher $dispatcher)
 {
     $route = $this->getMatchedRoute();
     if (null == $route) {
         $r = $this->getDI()->get('router');
         $r->handle($request->getURI());
         $route = $r->getMatchedRoute();
         //为什么搜索“装备”会出现找不到路由的问题?估计与字符处理有关系
         if (null == $route) {
             die('url地址无效,找不到对应的路由设置!');
         }
     }
     $pattern = $route->getPattern();
     //对每个路由都进行验证的中间件! @todo 如果是get方式的话,目标对象如何获取呢?当前用户是否拥有该资源?
     foreach ($this->middlewaresForEveryRoute as $validator) {
         $data = null;
         if (preg_match('|.*:.*|', $validator)) {
             //此处设置了可以带中间件参数
             list($validator, $data) = explode(':', $validator);
             $data = $dispatcher->getParam($data);
         }
         /** @var myValidation $validator */
         $validator = new $validator();
         if (!in_array($route->getName(), $validator->excludedRoutes) and !$validator->isValid($data)) {
             $url = $validator->getRedirectedUrl();
             //                    dd($url);
             $response->redirect($url, true);
             return false;
         }
     }
     //@todo 如果是get方式的如何过滤呢?应该如何设置才是正常的呢?例如get方式的search的过滤,单独处理?也许吧?
     if ($this->hasMatchedMiddleWares($pattern) and $request->isPost()) {
         $middleWares = $this->getMiddleWares($pattern);
         foreach ($middleWares as $validator) {
             $data = $request->getPost();
             //                dd($validator);
             if (preg_match('|[^:]+:[^:]+|', $validator)) {
                 list($validator, $data) = explode(':', $validator);
                 $data = $dispatcher->getParam($data);
             }
             if (preg_match('|.*Rules$|', $validator)) {
                 $rules = new $validator();
                 $validator = (new myValidation())->take($rules);
             } else {
                 $validator = new $validator();
             }
             if (!$validator->isValid($data)) {
                 $url = $validator->getRedirectedUrl();
                 //                    dd($url);
                 $response->redirect($url, true);
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:huoybb,项目名称:standard,代码行数:56,代码来源:myRouter.php

示例9: redirect

 public function redirect($url = null, $externalRedirect = false, $statusCode = 302)
 {
     $response = new Response();
     return $response->redirect($this->createUrl($url), $externalRedirect, $statusCode);
 }
开发者ID:remk-wadriga,项目名称:itm-phalcon-project,代码行数:5,代码来源:ControllerAbstract.php

示例10: redirect

 public function redirect($location = null, $externalRedirect = false, $statusCode = 302)
 {
     return parent::redirect($location, $externalRedirect, $statusCode);
 }
开发者ID:mattvb91,项目名称:cphalcon,代码行数:4,代码来源:Response.php

示例11: newIssueAction

 /**
  * Render to new issue page to create an issue.
  * @param  long $productId - the unique ID of the product
  */
 public function newIssueAction($productId)
 {
     if (!$this->isLoggedIn($this->session)) {
         $response = new Response();
         $response->redirect("/accounts/signin?forward=/product/{$productId}/new-issue");
         return $response;
     }
     $productService = ServiceFactory::getService('ProductService');
     $issueService = ServiceFactory::getService('IssueService');
     $product = $productService->getProductUsingId($productId);
     if ($product == NULL) {
         $this->forward('errors/resourceNotFound');
         return;
     }
     $product = $this->getProductInBestLanguage($product);
     $issueCategories = $this->getIssueCategoriesInBestLanguage($issueService->getIssueCategories());
     $this->tag->prependTitle($this->localization['products.new-issue.title'] . ' · ' . $product['productName']);
     $this->view->setVar('product', $product);
     $this->view->setVar('issueCategories', $issueCategories);
 }
开发者ID:kelliany,项目名称:TestZilla,代码行数:24,代码来源:ProductsController.php

示例12: passThrouthMiddleWares

 public function passThrouthMiddleWares(Request $request, Response $response, Dispatcher $dispatcher)
 {
     $route = $this->getMatchedRoute();
     if (null == $route) {
         die('url is invalid, their is no matched route for this url!');
     }
     $pattern = $route->getPattern();
     //对每个路由都进行验证的中间件! @todo 如果是get方式的话,目标对象如何获取呢?当前用户是否拥有该资源?
     foreach ($this->middlewaresForEveryRoute as $validator) {
         $data = null;
         if (preg_match('|.*:.*|', $validator)) {
             //此处设置了可以带中间件参数
             list($validator, $data) = explode(':', $validator);
             $data = $dispatcher->getParam($data);
         }
         $validator = new $validator();
         if (!in_array($route->getName(), $validator->excludedRoutes) and !$validator->isValid($data)) {
             $url = $validator->getRedirectedUrl();
             //                    dd($url);
             $response->redirect($url, true);
             return false;
         }
     }
     //@todo 如果是get方式的如何过滤呢?应该如何设置才是正常的呢?例如get方式的search的过滤,单独处理?也许吧?
     if ($this->hasMatchedMiddleWares($pattern) and $request->isPost()) {
         $middleWares = $this->getMiddleWares($pattern);
         foreach ($middleWares as $validator) {
             $data = $request->getPost();
             //                dd($validator);
             if (preg_match('|.*:.*|', $validator)) {
                 list($validator, $data) = explode(':', $validator);
                 $data = $dispatcher->getParam($data);
             }
             $validator = new $validator();
             if (!$validator->isValid($data)) {
                 $url = $validator->getRedirectedUrl();
                 //                    dd($url);
                 $response->redirect($url, true);
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:huoybb,项目名称:movie,代码行数:44,代码来源:myRouter.php

示例13: getSignOutAction

 /**
  * 用户注销页
  */
 public function getSignOutAction()
 {
     $this->session->has('auth') and $this->session->remove('auth');
     $response = new Response();
     $response->redirect(isset($_GET['callback']) ? $_GET['callback'] : $this->url->get('signin'), true);
     $response->send();
 }
开发者ID:sujinw,项目名称:passport,代码行数:10,代码来源:MainController.php

示例14: resetPasswordAction

 /**
  * Render to reset password page.
  */
 public function resetPasswordAction()
 {
     $email = $this->request->get('email');
     $token = $this->request->get('token');
     $isTokenSet = !empty($token);
     $isTokenValid = false;
     if ($this->isLoggedIn($this->session)) {
         $response = new Response();
         $response->redirect('/');
         return $response;
     }
     if ($isTokenSet) {
         $userService = ServiceFactory::getService('UserService');
         $isTokenValid = $userService->isEmailTokenValid($email, $token);
     }
     $this->tag->prependTitle($this->localization['accounts.reset-password.title']);
     $this->view->setVar('email', $email);
     $this->view->setVar('token', $token);
     $this->view->setVar('isTokenSet', $isTokenSet);
     $this->view->setVar('isTokenValid', $isTokenValid);
 }
开发者ID:kelliany,项目名称:TestZilla,代码行数:24,代码来源:AccountsController.php


注:本文中的Phalcon\Http\Response::redirect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。