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


PHP Request::getServer方法代码示例

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


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

示例1: authenticate

 /**
  * Attempt to authenticate the current user.  Throws exception if login fails.
  *
  * @param \Zend\Http\PhpEnvironment\Request $request Request object containing
  * account credentials.
  *
  * @throws AuthException
  * @return \VuFind\Db\Row\User Object representing logged-in user.
  */
 public function authenticate($request)
 {
     // Check if username is set.
     $shib = $this->getConfig()->Shibboleth;
     $username = $request->getServer()->get($shib->username);
     if (empty($username)) {
         throw new AuthException('authentication_error_admin');
     }
     // Check if required attributes match up:
     foreach ($this->getRequiredAttributes() as $key => $value) {
         if (!preg_match('/' . $value . '/', $request->getServer()->get($key))) {
             throw new AuthException('authentication_error_denied');
         }
     }
     // If we made it this far, we should log in the user!
     $user = $this->getUserTable()->getByUsername($username);
     // Has the user configured attributes to use for populating the user table?
     $attribsToCheck = array("cat_username", "email", "lastname", "firstname", "college", "major", "home_library");
     foreach ($attribsToCheck as $attribute) {
         if (isset($shib->{$attribute})) {
             $user->{$attribute} = $request->getServer()->get($shib->{$attribute});
         }
     }
     // Save and return the user object:
     $user->save();
     return $user;
 }
开发者ID:no-reply,项目名称:cbpl-vufind,代码行数:36,代码来源:Shibboleth.php

示例2: getPermissions

 /**
  * Return an array of roles which may be granted the permission based on
  * the options.
  *
  * @param mixed $options Options provided from configuration.
  *
  * @return array
  */
 public function getPermissions($options)
 {
     if ($this->request->getServer()->get('Shib-Identity-Provider') === false) {
         $this->logWarning('getPermissions: Shibboleth server params missing');
         return [];
     }
     return parent::getPermissions($options);
 }
开发者ID:htw-pk15,项目名称:vufind,代码行数:16,代码来源:Shibboleth.php

示例3: getPermissions

 /**
  * Return an array of roles which may be granted the permission based on
  * the options.
  *
  * @param mixed $options Options provided from configuration.
  *
  * @return array
  */
 public function getPermissions($options)
 {
     $this->debug('getPermissions: idpServerParam = ' . $this->idpServerParam);
     if ($this->request->getServer()->get($this->idpServerParam) === null) {
         $this->logWarning('getPermissions: Shibboleth server params missing');
         return [];
     }
     return parent::getPermissions($options);
 }
开发者ID:grharry,项目名称:vufind,代码行数:17,代码来源:Shibboleth.php

示例4: getPermissions

 /**
  * Return an array of roles which may be granted the permission based on
  * the options.
  *
  * @param mixed $options Options provided from configuration.
  *
  * @return array
  */
 public function getPermissions($options)
 {
     // Check if any regex matches....
     $ip = $this->request->getServer()->get('REMOTE_ADDR');
     if ($this->ipAddressUtils->isInRange($ip, (array) $options)) {
         // Match? Grant to all users (guest or logged in).
         return ['guest', 'loggedin'];
     }
     //  No match? No permissions.
     return [];
 }
开发者ID:grharry,项目名称:vufind,代码行数:19,代码来源:IpRange.php

示例5: authenticate

 /**
  * Attempt to authenticate the current user.  Throws exception if login fails.
  *
  * @param \Zend\Http\PhpEnvironment\Request $request Request object containing
  * account credentials.
  *
  * @throws AuthException
  * @return \VuFind\Db\Row\User Object representing logged-in user.
  */
 public function authenticate($request)
 {
     // Check if username is set.
     $shib = $this->getConfig()->Shibboleth;
     $username = $request->getServer()->get($shib->username);
     if (empty($username)) {
         throw new AuthException('authentication_error_admin');
     }
     // Check if required attributes match up:
     foreach ($this->getRequiredAttributes() as $key => $value) {
         if (!preg_match('/' . $value . '/', $request->getServer()->get($key))) {
             throw new AuthException('authentication_error_denied');
         }
     }
     // If we made it this far, we should log in the user!
     $user = $this->getUserTable()->getByUsername($username);
     // Variable to hold catalog password (handled separately from other
     // attributes since we need to use saveCredentials method to store it):
     $catPassword = null;
     // Has the user configured attributes to use for populating the user table?
     $attribsToCheck = ['cat_username', 'cat_password', 'email', 'lastname', 'firstname', 'college', 'major', 'home_library'];
     foreach ($attribsToCheck as $attribute) {
         if (isset($shib->{$attribute})) {
             $value = $request->getServer()->get($shib->{$attribute});
             if ($attribute != 'cat_password') {
                 // Special case: don't override existing email address:
                 if ($field == 'email') {
                     if (isset($user->email) && trim($user->email) != '') {
                         continue;
                     }
                 }
                 $user->{$attribute} = $value;
             } else {
                 $catPassword = $value;
             }
         }
     }
     // Save credentials if applicable:
     if (!empty($catPassword) && !empty($user->cat_username)) {
         $user->saveCredentials($user->cat_username, $catPassword);
     }
     // Store logout URL in session:
     $config = $this->getConfig()->Shibboleth;
     if (isset($config->logout_attribute)) {
         $url = $request->getServer()->get($config->logout_attribute);
         if ($url) {
             $sessionContainer = new SessionContainer('Shibboleth');
             $sessionContainer['logoutUrl'] = $url;
         }
     }
     // Save and return the user object:
     $user->save();
     return $user;
 }
开发者ID:jlehmus,项目名称:NDL-VuFind2,代码行数:63,代码来源:Shibboleth.php

示例6: executar

 /**
  * Metodo padrão de execução do log
  *
  * @return Log
  */
 public function executar()
 {
     $this->logArquivo->parse();
     $this->logArquivo->getLog()->setInicio(new \Datetime());
     $this->logArquivo->getLog()->setFim(new \Datetime());
     $this->logArquivo->getLog()->setIp($this->request->getServer('REMOTE_ADDR'));
     $this->logArquivo->getLog()->setMensagem('Log arquivo de ' . $this->logArquivo->getTipo() . ': ' . $this->logArquivo->getNome());
     $this->logArquivo->getLog()->setTipo(LogArquivo::TIPO);
     $this->logArquivo->getLog()->setUsuario($this->usuario);
     $this->logArquivo->getLog()->setRoute($this->request->getRequestUri());
     return $this->logArquivo->getLog();
 }
开发者ID:p21sistemas,项目名称:log,代码行数:17,代码来源:ArquivoLog.php

示例7: executar

 /**
  * Metodo padrão de execução do log
  * 
  * @return Log
  */
 public function executar()
 {
     $this->logCadastro->setOperacao($this->operacao);
     $this->logCadastro->parse();
     $this->logCadastro->getLog()->setInicio(new \Datetime());
     $this->logCadastro->getLog()->setFim(new \Datetime());
     $this->logCadastro->getLog()->setIp($this->request->getServer('REMOTE_ADDR'));
     $this->logCadastro->getLog()->setMensagem($this->operacao . ' - ' . get_class($this->logCadastro->getEntity()));
     $this->logCadastro->getLog()->setTipo(LogCadastro::TIPO);
     $this->logCadastro->getLog()->setUsuario($this->usuario);
     $this->logCadastro->getLog()->setRoute($this->request->getRequestUri());
     return $this->logCadastro->getLog();
 }
开发者ID:p21sistemas,项目名称:log,代码行数:18,代码来源:OperacaoLog.php

示例8: getPermissions

 /**
  * Return an array of roles which may be granted the permission based on
  * the options.
  *
  * @param mixed $options Options provided from configuration.
  *
  * @return array
  */
 public function getPermissions($options)
 {
     // Check if any regex matches....
     $ip = $this->request->getServer()->get('REMOTE_ADDR');
     foreach ((array) $options as $current) {
         if (preg_match($current, $ip)) {
             // Match? Grant to all users (guest or logged in).
             return ['guest', 'loggedin'];
         }
     }
     //  No match? No permissions.
     return [];
 }
开发者ID:grharry,项目名称:vufind,代码行数:21,代码来源:IpRegEx.php

示例9: getRemoteAddress

 public function getRemoteAddress()
 {
     $request = new Request();
     $serverParams = $request->getServer();
     $remoteAddress = $serverParams->get('REMOTE_ADDR');
     if ($remoteAddress == '') {
         $remoteAddress = '127.0.0.1';
     }
     return $remoteAddress;
 }
开发者ID:netsensia,项目名称:zf2-foundation,代码行数:10,代码来源:MaxmindLocationService.php

示例10: authenticate

 /**
  * Attempt to authenticate the current user.  Throws exception if login fails.
  *
  * @param \Zend\Http\PhpEnvironment\Request $request Request object containing
  * account credentials.
  *
  * @throws AuthException
  * @return \VuFind\Db\Row\User Object representing logged-in user.
  */
 public function authenticate($request)
 {
     $assertion = $request->getPost('assertion');
     if ($assertion === null) {
         throw new AuthException('authentication_missing_assertion');
     }
     $protocol = $request->getServer('HTTPS');
     $audience = (empty($protocol) ? 'http://' : 'https://') . $request->getServer('SERVER_NAME') . ':' . $request->getServer('SERVER_PORT');
     $client = $this->httpService->createClient('https://verifier.login.persona.org/verify', \Zend\Http\Request::METHOD_POST);
     $client->setParameterPost(['assertion' => $assertion, 'audience' => $audience]);
     $response = $client->send();
     $result = json_decode($response->getContent());
     if ($result->status !== 'okay') {
         throw new AuthException('authentication_error_invalid');
     }
     $username = $result->email;
     $user = $this->getUserTable()->getByUsername($username, false);
     if ($user === false) {
         $user = $this->createPersonaUser($username, $result->email);
     }
     return $user;
 }
开发者ID:bbeckman,项目名称:NDL-VuFind2,代码行数:31,代码来源:MozillaPersona.php

示例11: processNotAuthorized

 /**
  * Process 401 Response Objects.  This will redirect the visitor to the
  * sites configured login page.
  *
  * @return Response
  */
 protected function processNotAuthorized()
 {
     $loginPage = $this->currentSite->getLoginPage();
     $notAuthorized = $this->currentSite->getNotAuthorizedPage();
     $returnToUrl = urlencode($this->request->getServer('REQUEST_URI'));
     $newResponse = new Response();
     $newResponse->setStatusCode('302');
     if (!$this->userService->hasIdentity()) {
         $newResponse->getHeaders()->addHeaderLine('Location: ' . $loginPage . '?redirect=' . $returnToUrl);
     } else {
         $newResponse->getHeaders()->addHeaderLine('Location: ' . $notAuthorized);
     }
     return $newResponse;
 }
开发者ID:reliv,项目名称:rcm,代码行数:20,代码来源:ResponseHandler.php

示例12: createFromRequest

 public static function createFromRequest(BaseRequest $request)
 {
     $new = static::fromString($request->toString());
     $new->setQuery($request->getQuery());
     $new->setPost($request->getPost());
     $new->setCookies($request->getCookie());
     $new->setFiles($request->getFiles());
     $new->setServer($request->getServer());
     $new->setContent($request->getContent());
     $new->setEnv($request->getEnv());
     $headers = $request->getHeaders();
     $new->setHeaders($headers);
     return $new;
 }
开发者ID:diablomedia,项目名称:oauth2-server-zendhttp-bridge,代码行数:14,代码来源:Request.php

示例13: checkServerParam

 /**
  * Check if a server param matches the option.
  *
  * @param string $option Option
  *
  * @return boolean true if a server param matches, false if not
  */
 protected function checkServerParam($option)
 {
     // split option on spaces unless escaped with backslash
     $optionParts = $this->splitString($option, ' ', '\\');
     if (count($optionParts) < 2) {
         $this->logError("configuration option '{$option}' invalid");
         return false;
     }
     // first part is the server param name
     $serverParamName = array_shift($optionParts);
     if (isset($this->aliases[$serverParamName])) {
         $serverParamName = $this->aliases[$serverParamName];
     }
     // optional modifier follow server param name
     $modifierMatch = in_array($optionParts[0], ['~', '!~']);
     $modifierNot = in_array($optionParts[0], ['!', '!~']);
     if ($modifierNot || $modifierMatch) {
         array_shift($optionParts);
     }
     // remaining parts are the templates for checking the server params
     $templates = $optionParts;
     if (empty($templates)) {
         $this->logError("configuration option '{$option}' invalid");
         return false;
     }
     // server param values to check
     $serverParamString = $this->request->getServer()->get($serverParamName);
     if ($serverParamString === null) {
         // check fails if server param is missing
         return false;
     }
     $serverParams = $this->splitString($serverParamString, $this->serverParamDelimiter, $this->serverParamEscape);
     $result = false;
     // check for each server param ...
     foreach ($serverParams as $serverParam) {
         // ... if it matches one of the templates (OR)
         foreach ($templates as $template) {
             if ($modifierMatch) {
                 $result |= preg_match('/' . $template . '/', $serverParam);
             } else {
                 $result |= $template === $serverParam;
             }
         }
     }
     if ($modifierNot) {
         $result = !$result;
     }
     return $result;
 }
开发者ID:steenlibrary,项目名称:vufind,代码行数:56,代码来源:ServerParam.php

示例14: authenticate

 /**
  * Attempt to authenticate the current user.  Throws exception if login fails.
  *
  * @param \Zend\Http\PhpEnvironment\Request $request Request object containing
  * account credentials.
  *
  * @throws AuthException
  * @return \VuFind\Db\Row\User Object representing logged-in user.
  */
 public function authenticate($request)
 {
     // Check if username is set.
     $shib = $this->getConfig()->Shibboleth;
     $username = $request->getServer()->get($shib->username);
     if (empty($username)) {
         throw new AuthException('authentication_error_admin');
     }
     // Check if required attributes match up:
     foreach ($this->getRequiredAttributes() as $key => $value) {
         if (!preg_match('/' . $value . '/', $request->getServer()->get($key))) {
             throw new AuthException('authentication_error_denied');
         }
     }
     // If we made it this far, we should log in the user!
     $user = $this->getUserTable()->getByUsername($username);
     // Variable to hold catalog password (handled separately from other
     // attributes since we need to use saveCredentials method to store it):
     $catPassword = null;
     // Has the user configured attributes to use for populating the user table?
     $attribsToCheck = ['cat_username', 'cat_password', 'email', 'lastname', 'firstname', 'college', 'major', 'home_library'];
     foreach ($attribsToCheck as $attribute) {
         if (isset($shib->{$attribute})) {
             $value = $request->getServer()->get($shib->{$attribute});
             if ($attribute != 'cat_password') {
                 $user->{$attribute} = $value === null ? '' : $value;
             } else {
                 $catPassword = $value;
             }
         }
     }
     // Save credentials if applicable. Note that we want to allow empty
     // passwords (see https://github.com/vufind-org/vufind/pull/532), but
     // we also want to be careful not to replace a non-blank password with a
     // blank one in case the auth mechanism fails to provide a password on
     // an occasion after the user has manually stored one. (For discussion,
     // see https://github.com/vufind-org/vufind/pull/612). Note that in the
     // (unlikely) scenario that a password can actually change from non-blank
     // to blank, additional work may need to be done here.
     if (!empty($user->cat_username)) {
         $user->saveCredentials($user->cat_username, empty($catPassword) ? $user->getCatPassword() : $catPassword);
     }
     // Save and return the user object:
     $user->save();
     return $user;
 }
开发者ID:datavoyager,项目名称:vufind,代码行数:55,代码来源:Shibboleth.php

示例15: write

 /**
  * Запись логов
  * @param Request $request
  * @param Response $response
  */
 public function write($request, $response)
 {
     $serverOptions = $request->getServer()->toArray();
     $requestUri = isset($serverOptions['REQUEST_URI']) ? $serverOptions['REQUEST_URI'] : null;
     // Проверка на запись от правильного запроса
     if (is_null($requestUri) || !preg_match($this->_patternRequestWriteLog, $requestUri)) {
         return;
     }
     $remoteAddr = isset($serverOptions['REMOTE_ADDR']) ? $serverOptions['REMOTE_ADDR'] : '';
     $requestTime = isset($serverOptions['REQUEST_TIME']) ? $serverOptions['REQUEST_TIME'] : 0;
     $requestTimeFloat = isset($serverOptions['REQUEST_TIME_FLOAT']) ? $serverOptions['REQUEST_TIME_FLOAT'] : 0;
     /** @var DocumentManager $dm */
     $dm = $this->getServiceLocator()->get('doctrine-document');
     $logsClient = new LogsClient();
     $logsClient->setDatetime((new \DateTime())->setTimestamp($requestTime))->setHeaders($request->getHeaders()->toString())->setRequest($request->getContent())->setResponse($response->getContent())->setIpAddress($remoteAddr)->setDuration(round(microtime(true), 4) - $requestTimeFloat);
     $dm->persist($logsClient);
     $dm->flush();
 }
开发者ID:lexx7,项目名称:course,代码行数:23,代码来源:Logs.php


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