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


PHP Request::getHttpHost方法代码示例

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


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

示例1: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $pipe = $request->pipe;
     if ($pipe) {
         $finalServer = $this->resolver->resolve($pipe);
         if ($finalServer != $request->getHttpHost()) {
             return redirect(str_replace($request->getHttpHost(), $finalServer, $request->getUri()), 307);
         }
     }
     return $next($request);
 }
开发者ID:nicolacimmino,项目名称:RIoT,代码行数:18,代码来源:RiotRouter.php

示例2: authLogin

 /**
  * @param Request $request
  * @return \BladeView|bool|\Illuminate\Http\RedirectResponse|\Illuminate\View\View|\Symfony\Component\HttpFoundation\Response
  */
 public function authLogin(Request $request)
 {
     $authService = new authService();
     $host = explode('.', $request->getHttpHost());
     $role = $host[0];
     $email = $request->input('email', false);
     $password = $request->input('password', false);
     $postAjax = $request->ajax();
     try {
         $results = $authService->login($email, $password, $role);
         if (!$postAjax) {
             if ($results['ok']) {
                 return redirect()->intended('/');
             } else {
                 return view('auth.login', $results);
             }
         } else {
             return response()->json($results);
         }
     } catch (\Exception $e) {
         // @codeCoverageIgnoreStart
         $return['error'] = $e->getMessage();
         // @codeCoverageIgnoreEnd
     }
     return view('auth.login');
 }
开发者ID:kacana,项目名称:kacana.com,代码行数:30,代码来源:AuthController.php

示例3: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $host = preg_replace('"^\\w+://(www\\.)?"i', '', \Config::get('app.url'));
     $test = str_replace($host, '', $request->getHttpHost());
     preg_match("'^([^\\.]+)\\.\$'", $test, $m);
     static::subdomen(@$m[1]);
     return $next($request);
 }
开发者ID:ankhzet,项目名称:Ankh,代码行数:15,代码来源:Subdomens.php

示例4: handle

 /**
  * This middleware forces the entire application to use SSL. We like that, because it's secure.
  *
  * Shamelessly copied from: http://stackoverflow.com/questions/28402726/laravel-5-redirect-to-https
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $force = env('FORCE_DOMAIN', null);
     if ($force != null && $request->getHttpHost() != $force) {
         return redirect()->to(env('APP_URL') . '/' . ($request->path() == '/' ? '' : $request->path()));
     }
     return $next($request);
 }
开发者ID:saproto,项目名称:saproto,代码行数:17,代码来源:ForceDomain.php

示例5: handle

 /**
  * Handle an incoming request.
  *
  * The following filter simply retrieves the current account based on the request information
  * and then sets this value for future retrieval. If no account can be found for the request,
  * then two things need to happen:
  *
  * 1. Check to see if ANY accounts have been configured if no accounts exist then
  * 2. Ask the user if they'd like to setup the default (first) account. This is required
  *    for new installations.
  * 3. If an account does exist but does not match the domain, then we throw an account
  *    not found exception and deal with that later.
  *
  * @throws AccountNotFoundException
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $account = CurrentAccount::determine($request->getHttpHost());
     if (!$account) {
         $count = $this->accountService->totalNumberOfAccounts();
         if ($count === 0) {
             return redirect()->route('install');
         }
         throw new AccountNotFoundException();
     }
     CurrentAccount::set($account);
     return $next($request);
 }
开发者ID:kamaroly,项目名称:shift,代码行数:32,代码来源:AccountMiddleware.php

示例6: resolve

 /**
  * Resolve locale using domain name
  *
  * @return mixed
  */
 public function resolve()
 {
     $httpHost = $this->request->getHttpHost();
     $domains = explode('.', $httpHost);
     $level = config('localizer.domain.level', 3);
     return ($total = count($domains)) >= $level ? $domains[$total - $level] : null;
 }
开发者ID:adminarchitect,项目名称:localizer,代码行数:12,代码来源:DomainResolver.php

示例7: localizedURL

 /**
  * Returns an URL adapted to locale
  *
  * @param  string $locale
  * @return string
  */
 private function localizedURL($locale)
 {
     // Default language doesn't get a special subdomain
     $locale = $locale !== $this->defaultLocale ? strtolower($locale) . '.' : '';
     // URL elements
     $uri = $this->request->getRequestUri();
     $scheme = $this->request->getScheme();
     // Get host
     $array = explode('.', $this->request->getHttpHost());
     $host = (array_key_exists(count($array) - 2, $array) ? $array[count($array) - 2] : '') . '.' . $array[count($array) - 1];
     // Create URL from template
     $url = str_replace(['[scheme]', '[locale]', '[host]', '[uri]'], [$scheme, $locale, $host, $uri], $this->config['locale_url']);
     return url($url);
 }
开发者ID:torann,项目名称:laravel-meta-tags,代码行数:20,代码来源:MetaTag.php

示例8: setRequestData

 public function setRequestData(\App\Action $action, \Illuminate\Http\Request $request)
 {
     if (!$action->app) {
         $action->app = $request->getHttpHost();
     }
     if (!$action->http_referrer_raw) {
         $action->http_referrer_raw = $request->header('Referer');
     }
     if (!$action->user_agent_raw) {
         $action->user_agent_raw = $request->header('User-Agent');
     }
     if (!$action->ip) {
         // TODO make sure this accounts for CDNs/proxies
         $action->ip = $request->ip();
     }
     // TODO location
 }
开发者ID:jacksteadman,项目名称:tracer2,代码行数:17,代码来源:ActionService.php

示例9: getLocalizedURL

 /**
  * Returns an URL adapted to $locale
  *
  * @throws SupportedLocalesNotDefined
  * @throws UnsupportedLocaleException
  *
  * @param  string|boolean $locale     Locale to adapt, false to remove locale
  * @param  string|false   $url        URL to adapt in the current language. If not passed, the current url would be
  *                                    taken.
  * @param  array          $attributes Attributes to add to the route, if empty, the system would try to extract
  *                                    them from the url.
  *
  *
  * @return string|false                URL translated, False if url does not exist
  */
 public function getLocalizedURL($locale = null, $url = null, $attributes = [])
 {
     // Use default if not set
     if ($locale === null) {
         $locale = $this->getCurrentLocale();
     }
     // Get request Uri
     if (empty($url)) {
         $url = $this->request->getRequestUri();
     } else {
         $parts = parse_url($url);
         $url = $parts['path'] . (isset($parts['query']) ? '?' . $parts['query'] : '');
     }
     $scheme = $this->request->getScheme();
     $locale = $locale && $locale !== $this->getDefaultLocale() ? "{$locale}." : '';
     // Get host
     $array = explode('.', $this->request->getHttpHost());
     $host = (array_key_exists(count($array) - 2, $array) ? $array[count($array) - 2] : '') . '.' . $array[count($array) - 1];
     return app('url')->to("{$scheme}://{$locale}{$host}{$url}", $attributes);
 }
开发者ID:torann,项目名称:localization,代码行数:35,代码来源:LocaleManager.php

示例10: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->guest()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect()->guest('auth/login');
         }
     } else {
         $host = explode('.', $request->getHttpHost());
         $role = $host[0];
         $user = $this->auth->user();
         if ($role == KACANA_USER_ROLE_ADMIN && $user->role == KACANA_USER_ROLE_ADMIN || $role == KACANA_USER_ROLE_PARTNER && $user->role == KACANA_USER_ROLE_PARTNER || $role != KACANA_USER_ROLE_PARTNER && $role != KACANA_USER_ROLE_ADMIN) {
             return $next($request);
         } else {
             \Auth::logout();
             return redirect()->to('auth/login')->with('__error_code_login_one_check__', KACANA_AUTH_LOGIN_ERROR_NOT_PERMISSION);
         }
     }
 }
开发者ID:kacana,项目名称:kacana.com,代码行数:27,代码来源:Authenticate.php

示例11: signup

 /**
  * @param Request $request
  * @return \BladeView|bool|\Illuminate\Http\RedirectResponse|\Illuminate\View\View|\Symfony\Component\HttpFoundation\Response
  */
 public function signup(Request $request)
 {
     $authService = new authService();
     $emailService = new mailService();
     $name = $request->input('name', '');
     $email = $request->input('email', '');
     $phone = $request->input('phone', '');
     $password = $request->input('password', '');
     $confirmPassword = $request->input('confirmPassword', '');
     $postAjax = $request->ajax();
     $host = explode('.', $request->getHttpHost());
     $roleLink = $host[0];
     try {
         if ($request->isMethod('post')) {
             $results = $authService->signup($name, $email, $phone, $password, $confirmPassword);
             if ($results['ok']) {
                 $user = $results['data'];
                 if ($roleLink != KACANA_AUTH_ADMIN_NAME) {
                     \Auth::loginUsingId($user->id, true);
                 }
                 $emailService->sendEmailNewUser($email);
             }
             if ($postAjax) {
                 return response()->json($results);
             } else {
                 if ($results['ok']) {
                     return redirect()->intended('/');
                 } else {
                     return view('auth.signup', $results);
                 }
             }
         }
     } catch (\Exception $e) {
         // @codeCoverageIgnoreStart
         $return['error'] = $e->getMessage();
         // @codeCoverageIgnoreEnd
     }
     return view('auth.signup');
 }
开发者ID:kacana,项目名称:kacana.com,代码行数:43,代码来源:SignupController.php

示例12: getHttpHost

 /**
  * Returns the HTTP host being requested.
  * 
  * The port name will be appended to the host if it's non-standard.
  *
  * @return string 
  * @static 
  */
 public static function getHttpHost()
 {
     //Method inherited from \Symfony\Component\HttpFoundation\Request
     return \Illuminate\Http\Request::getHttpHost();
 }
开发者ID:satriashp,项目名称:tour,代码行数:13,代码来源:_ide_helper.php

示例13: getTld

 /**
  * Get top level domain.
  *
  * @return string
  */
 public function getTld()
 {
     return substr(strrchr($this->request->getHttpHost(), '.'), 0);
 }
开发者ID:edisoncosta,项目名称:laravel-domain-localization,代码行数:9,代码来源:DomainLocalization.php


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