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


PHP Request::isSecure方法代码示例

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


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

示例1: fromRequest

 public function fromRequest(Request $request)
 {
     $this->setBaseUrl($request->getBaseUrl());
     $this->setMethod($request->getMethod());
     $this->setHost($request->getHost());
     $this->setScheme($request->getScheme());
     $this->setHttpPort($request->isSecure() ? $this->httpPort : $request->getPort());
     $this->setHttpsPort($request->isSecure() ? $request->getPort() : $this->httpsPort);
 }
开发者ID:laubosslink,项目名称:lab,代码行数:9,代码来源:RequestContext.php

示例2: getPath

 /**
  * {@inheritDoc}
  */
 public function getPath($relativePath, $isFlushable)
 {
     $container = $this->container;
     $object = $container->get_object($relativePath);
     if ($this->request && $this->request->isSecure()) {
         return $object->public_ssl_uri();
     } else {
         return $object->public_uri();
     }
 }
开发者ID:geoffreytran,项目名称:zym,代码行数:13,代码来源:RackspaceCloudfiles.php

示例3: fromRequest

 /**
  * Updates the RequestContext info based on a HttpFoundation Request.
  *
  * @param Request $request A Request instance
  */
 public function fromRequest(Request $request)
 {
     $this->setBaseUrl($request->getBaseUrl());
     $this->setPathInfo($request->getPathInfo());
     $this->setMethod($request->getMethod());
     $this->setHost($request->getHost());
     $this->setScheme($request->getScheme());
     $this->setHttpPort($request->isSecure() ? $this->httpPort : $request->getPort());
     $this->setHttpsPort($request->isSecure() ? $request->getPort() : $this->httpsPort);
     $this->setQueryString($request->server->get('QUERY_STRING', ''));
 }
开发者ID:kchhainarong,项目名称:chantuchP,代码行数:16,代码来源:RequestContext.php

示例4: initializeRequestAttributes

 protected function initializeRequestAttributes(Request $request, $master)
 {
     if ($master) {
         // set the context even if the parsing does not need to be done
         // to have correct link generation
         $this->router->setContext(array('base_url' => $request->getBaseUrl(), 'method' => $request->getMethod(), 'host' => $request->getHost(), 'port' => $request->getPort(), 'is_secure' => $request->isSecure()));
     }
     if ($request->attributes->has('_controller')) {
         // routing is already done
         return;
     }
     // add attributes based on the path info (routing)
     try {
         $parameters = $this->router->match($request->getPathInfo());
         if (null !== $this->logger) {
             $this->logger->info(sprintf('Matched route "%s" (parameters: %s)', $parameters['_route'], json_encode($parameters)));
         }
         $request->attributes->add($parameters);
         if ($locale = $request->attributes->get('_locale')) {
             $request->getSession()->setLocale($locale);
         }
     } catch (NotFoundException $e) {
         $message = sprintf('No route found for "%s %s"', $request->getMethod(), $request->getPathInfo());
         if (null !== $this->logger) {
             $this->logger->err($message);
         }
         throw new NotFoundHttpException($message, $e);
     } catch (MethodNotAllowedException $e) {
         $message = sprintf('No route found for "%s %s": Method Not Allowed (Allow: %s)', $request->getMethod(), $request->getPathInfo(), strtoupper(implode(', ', $e->getAllowedMethods())));
         if (null !== $this->logger) {
             $this->logger->err($message);
         }
         throw new MethodNotAllowedHttpException($e->getAllowedMethods(), $message, $e);
     }
 }
开发者ID:nickaggarwal,项目名称:sample-symfony2,代码行数:35,代码来源:RequestListener.php

示例5: isSecure

 /**
  * {@inheritdoc}
  */
 public function isSecure()
 {
     if (null !== $this->isSecure) {
         return $this->isSecure;
     }
     if (parent::isSecure()) {
         return $this->isSecure = true;
     }
     // It may happen that some misconfigured environments won't set
     // the $_SERVER['HTTPS'] variable, we need another way to detect
     // this, either using Drupal, or port in use.
     if (443 === (int) $this->server->get('SERVER_PORT', 80)) {
         return $this->isSecure = true;
     }
     // Worst than misconfigured, we actually have no idea about what's
     // what because FPM or any other CGI gives us nothing goog to read,
     // let's just trust Drupal and pray.
     if ($GLOBALS['is_https']) {
         return $this->isSecure = true;
     }
     // The Drupal base URL might have been hardcoded in settings.php so
     // let's use that as last resort.
     if ('https://' === substr($GLOBALS['base_url'], 0, 8)) {
         return $this->isSecure = true;
     }
     return $this->isSecure = false;
 }
开发者ID:makinacorpus,项目名称:drupal-sf-dic,代码行数:30,代码来源:Request.php

示例6: isUrlLocal

 public function isUrlLocal($link)
 {
     if (!$this->request) {
         return false;
     }
     $parts = parse_url($link);
     $isLocal = true;
     if (!empty($parts['host']) && $parts['host'] !== $this->request->getHost()) {
         $isLocal = false;
     } elseif (!empty($parts['port']) && $parts['port'] !== $this->request->getPort()) {
         $isLocal = false;
     } elseif (!empty($parts['scheme']) && $this->request->isSecure() && $parts['scheme'] !== 'https') {
         // going out from secure connection to insecure page on same domain is not local
         $isLocal = false;
     }
     return $isLocal;
 }
开发者ID:Maksold,项目名称:platform,代码行数:17,代码来源:UrlExtension.php

示例7: authenticationLogin

 /**
  * Login route.
  *
  * @param \Silex\Application $app
  * @param Request            $request
  *
  * @return Response
  */
 public function authenticationLogin(Application $app, Request $request)
 {
     if (!$request->isSecure()) {
         // Log a warning if this route is not HTTPS
         $msg = sprintf("[ClientLogin][Controller]: Login route '%s' is not being served over HTTPS. This is insecure and vulnerable!", $request->getPathInfo());
         $app['logger.system']->critical($msg, ['event' => 'extensions']);
     }
     $this->setFinalRedirectUrl($app, $request);
     $response = $this->getFinalResponse($app, 'login');
     return $response;
 }
开发者ID:annejan,项目名称:bolt-extension-clientlogin,代码行数:19,代码来源:ClientLoginController.php

示例8: getName

 /**
  * Returns the session cookie name.
  *
  * @param \Symfony\Component\HttpFoundation\Request $request
  *   The request.
  *
  * @return string
  *   The name of the session cookie.
  */
 protected function getName(Request $request)
 {
     // To prevent session cookies from being hijacked, a user can configure the
     // SSL version of their website to only transfer session cookies via SSL by
     // using PHP's session.cookie_secure setting. The browser will then use two
     // separate session cookies for the HTTPS and HTTP versions of the site. So
     // we must use different session identifiers for HTTPS and HTTP to prevent a
     // cookie collision.
     $prefix = $request->isSecure() ? 'SSESS' : 'SESS';
     return $prefix . $this->getUnprefixedName($request);
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:20,代码来源:SessionConfiguration.php

示例9: setRequest

 /**
  * Sets all needed values from the request.
  *
  * @param Request $request A request to get values from.
  */
 public function setRequest(Request $request)
 {
     $this->setScheme($request->getScheme());
     $this->setHost($request->getHost());
     $this->setBasePath($request->getBasePath());
     if ($request->isSecure()) {
         $this->setHttpsPort($request->getPort());
     } else {
         $this->setHttpPort($request->getPort());
     }
 }
开发者ID:abhijitroy07,项目名称:mibew,代码行数:16,代码来源:UrlGenerator.php

示例10: sslRedirect

 /**
  * Checks if the user should be forced to use SSL connections.
  *
  * @param Request $request Request to check.
  * @return boolean|\Symfony\Component\HttpFoundation\RedirectResponse False
  *   if the redirect is not needed and redirect response object otherwise.
  */
 protected function sslRedirect(Request $request)
 {
     $need_redirect = Settings::get('enablessl') == '1' && Settings::get('forcessl') == '1' && !$request->isSecure();
     if (!$need_redirect) {
         return false;
     }
     if (null !== ($qs = $request->getQueryString())) {
         $qs = '?' . $qs;
     }
     $path = 'https://' . $request->getHttpHost() . $request->getBasePath() . $request->getPathInfo() . $qs;
     return $this->redirect($path);
 }
开发者ID:aburakovskiy,项目名称:mibew,代码行数:19,代码来源:AbstractController.php

示例11: handle

 /**
  * @param Request $request
  * @return Response
  */
 protected function handle(Request $request)
 {
     $vars = array('isSecure' => $request->isSecure());
     if (array_key_exists('User', $_SESSION) && $_SESSION['User'] == "Default User" && plugin_find_id("auth") >= 0) {
         if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "off") {
             $vars['protocol'] = "HTTPS";
         } else {
             $vars['protocol'] = preg_replace("@/.*@", "", @$_SERVER['SERVER_PROTOCOL']);
         }
         $vars['referrer'] = "?mod=browse";
         $vars['authUrl'] = "?mod=auth";
     }
     return $this->render("home.html.twig", $this->mergeWithDefault($vars));
 }
开发者ID:DanielDobre,项目名称:fossology,代码行数:18,代码来源:HomePage.php

示例12: getLogin

 /**
  * Login page and "Forgotten password" page.
  *
  * @param \Symfony\Component\HttpFoundation\Request $request
  * @param boolean                                   $resetCookies
  *
  * @return \Bolt\Response\BoltResponse|\Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function getLogin(Request $request, $resetCookies = false)
 {
     $user = $this->getUser();
     if ($user && $user->getEnabled() == 1) {
         return $this->redirectToRoute('dashboard');
     }
     if ($this->getOption('general/enforce_ssl') && !$request->isSecure()) {
         return $this->redirect(preg_replace('/^http:/i', 'https:', $request->getUri()));
     }
     $response = $this->render('@bolt/login/login.twig', ['randomquote' => true]);
     $response->setVary('Cookies', false)->setMaxAge(0)->setPrivate();
     if ($resetCookies) {
         $response->headers->clearCookie($this->app['token.authentication.name']);
     }
     return $response;
 }
开发者ID:nuffer,项目名称:bolt,代码行数:24,代码来源:Authentication.php

示例13: start

 public function start(Request $request, AuthenticationException $authException = null)
 {
     $scheme = $request->isSecure() ? 'http' : 'https';
     if ('http' === $scheme && 80 != $this->httpPort) {
         $port = ':' . $this->httpPort;
     } elseif ('https' === $scheme && 443 != $this->httpsPort) {
         $port = ':' . $this->httpsPort;
     } else {
         $port = '';
     }
     $qs = $request->getQueryString();
     if (null !== $qs) {
         $qs = '?' . $qs;
     }
     $url = $scheme . '://' . $request->getHost() . $port . $request->getBaseUrl() . $request->getPathInfo() . $qs;
     return new RedirectResponse($url, 301);
 }
开发者ID:artz20,项目名称:Tv-shows-zone,代码行数:17,代码来源:RetryAuthenticationEntryPoint.php

示例14: start

 public function start(EventInterface $event, Request $request, AuthenticationException $authException = null)
 {
     $scheme = $request->isSecure() ? 'http' : 'https';
     if ('http' === $scheme && 80 != $this->httpPort) {
         $port = ':' . $this->httpPort;
     } elseif ('https' === $scheme && 443 != $this->httpPort) {
         $port = ':' . $this->httpsPort;
     } else {
         $port = '';
     }
     $qs = $request->getQueryString();
     if (null !== $qs) {
         $qs = '?' . $qs;
     }
     $url = $scheme . '://' . $request->getHost() . $port . $request->getScriptName() . $request->getPathInfo() . $qs;
     $response = new Response();
     $response->setRedirect($url, 301);
     return $response;
 }
开发者ID:faridos,项目名称:ServerGroveLiveChat,代码行数:19,代码来源:RetryAuthenticationEntryPoint.php

示例15: initializeRequestAttributes

 protected function initializeRequestAttributes(Request $request, $master)
 {
     if ($master) {
         // set the context even if the parsing does not need to be done
         // to have correct link generation
         $this->router->setContext(array('base_url' => $request->getBaseUrl(), 'method' => $request->getMethod(), 'host' => $request->getHost(), 'is_secure' => $request->isSecure()));
     }
     if ($request->attributes->has('_controller')) {
         // routing is already done
         return;
     }
     // add attributes based on the path info (routing)
     if (false !== ($parameters = $this->router->match($request->getPathInfo()))) {
         if (null !== $this->logger) {
             $this->logger->info(sprintf('Matched route "%s" (parameters: %s)', $parameters['_route'], str_replace("\n", '', var_export($parameters, true))));
         }
         $request->attributes->add($parameters);
         if ($locale = $request->attributes->get('_locale')) {
             $request->getSession()->setLocale($locale);
         }
     } elseif (null !== $this->logger) {
         $this->logger->err(sprintf('No route found for %s', $request->getPathInfo()));
     }
 }
开发者ID:notbrain,项目名称:symfony,代码行数:24,代码来源:RequestListener.php


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