當前位置: 首頁>>代碼示例>>PHP>>正文


PHP HttpFoundation\ServerBag類代碼示例

本文整理匯總了PHP中Symfony\Component\HttpFoundation\ServerBag的典型用法代碼示例。如果您正苦於以下問題:PHP ServerBag類的具體用法?PHP ServerBag怎麽用?PHP ServerBag使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ServerBag類的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: authenticate

 /**
  * @param string $filePath
  * @param \Symfony\Component\HttpFoundation\ServerBag $server
  *
  * @return bool
  */
 private function authenticate($filePath, ServerBag $server)
 {
     $passFile = $this->kernel->getRootDir() . '/../web/var/export/' . substr($filePath, 0, strrpos($filePath, '/')) . '/.htpasswd';
     list($auth['user'], $auth['pass']) = explode(':', file_get_contents($passFile));
     $user = $server->get('PHP_AUTH_USER');
     $pass = crypt($server->get('PHP_AUTH_PW'), md5($server->get('PHP_AUTH_PW')));
     return $user == $auth['user'] && $pass == $auth['pass'];
 }
開發者ID:kamilmusial,項目名稱:EzSystemsRecommendationBundle,代碼行數:14,代碼來源:ExportController.php

示例2:

 function it_does_not_provides_server_version_of_pim_host_if_request_is_null($requestStack, $versionProvider, ServerBag $serverBag)
 {
     $versionProvider->getPatch()->willReturn('1.4.0');
     $versionProvider->getEdition()->willReturn('CE');
     $requestStack->getCurrentRequest()->willReturn(null);
     $serverBag->get(Argument::type('string'))->shouldNotBeCalled();
     $this->collect()->shouldReturn(['pim_edition' => 'CE', 'pim_version' => '1.4.0', 'pim_environment' => 'prod', 'pim_install_time' => '2015-09-16T10:10:32+02:00', 'server_version' => '']);
 }
開發者ID:a2xchip,項目名稱:pim-community-dev,代碼行數:8,代碼來源:VersionDataCollectorSpec.php

示例3: get

 /**
  * Method to get the system information
  *
  * @return string[]
  */
 public function get()
 {
     $server = new ServerBag($GLOBALS['_SERVER']);
     $info = [];
     $info['php'] = php_uname();
     if ($pdo = App::db()->getWrappedConnection() and $pdo instanceof PDOConnection) {
         $info['dbdriver'] = $pdo->getAttribute(\PDO::ATTR_DRIVER_NAME);
         $info['dbversion'] = $pdo->getAttribute(\PDO::ATTR_SERVER_VERSION);
         $info['dbclient'] = $pdo->getAttribute(\PDO::ATTR_CLIENT_VERSION);
     }
     $info['phpversion'] = phpversion();
     $info['server'] = $server->get('SERVER_SOFTWARE', getenv('SERVER_SOFTWARE'));
     $info['sapi_name'] = php_sapi_name();
     $info['version'] = App::version();
     $info['useragent'] = $server->get('HTTP_USER_AGENT');
     $info['extensions'] = implode(", ", get_loaded_extensions());
     $info['directories'] = $this->getDirectories();
     return $info;
 }
開發者ID:LibraryOfLawrence,項目名稱:pagekit,代碼行數:24,代碼來源:InfoHelper.php

示例4: testHttpBasicAuthWithPhpCgiEmptyPassword

    public function testHttpBasicAuthWithPhpCgiEmptyPassword()
    {
        $bag = new ServerBag(array('HTTP_AUTHORIZATION' => 'Basic '.base64_encode('foo:')));

        $this->assertEquals(array(
            'AUTHORIZATION' => 'Basic '.base64_encode('foo:'),
            'PHP_AUTH_USER' => 'foo',
            'PHP_AUTH_PW' => ''
        ), $bag->getHeaders());
    }
開發者ID:redpanda,項目名稱:symfony,代碼行數:10,代碼來源:ServerBagTest.php

示例5: testHttpPasswordIsOptional

 public function testHttpPasswordIsOptional()
 {
     $bag = new ServerBag(array('PHP_AUTH_USER' => 'foo'));
     $this->assertEquals(array('AUTHORIZATION' => 'Basic ' . base64_encode('foo:')), $bag->getHeaders());
 }
開發者ID:robertowest,項目名稱:CuteFlow-V4,代碼行數:5,代碼來源:ServerBagTest.php

示例6: testOAuthBearerAuth

 public function testOAuthBearerAuth()
 {
     $headerContent = 'Bearer L-yLEOr9zhmUYRkzN1jwwxwQ-PBNiKDc8dgfB4hTfvo';
     $bag = new ServerBag(array('HTTP_AUTHORIZATION' => $headerContent));
     $this->assertEquals(array('AUTHORIZATION' => $headerContent), $bag->getHeaders());
 }
開發者ID:Rudi9719,項目名稱:stein-syn,代碼行數:6,代碼來源:ServerBagTest.php

示例7: testItDoesNotOverwriteTheAuthorizationHeaderIfItIsAlreadySet

 /**
  * @see https://github.com/symfony/symfony/issues/17345
  */
 public function testItDoesNotOverwriteTheAuthorizationHeaderIfItIsAlreadySet()
 {
     $headerContent = 'Bearer L-yLEOr9zhmUYRkzN1jwwxwQ-PBNiKDc8dgfB4hTfvo';
     $bag = new ServerBag(array('PHP_AUTH_USER' => 'foo', 'HTTP_AUTHORIZATION' => $headerContent));
     $this->assertEquals(array('AUTHORIZATION' => $headerContent, 'PHP_AUTH_USER' => 'foo', 'PHP_AUTH_PW' => ''), $bag->getHeaders());
 }
開發者ID:Ener-Getick,項目名稱:symfony,代碼行數:9,代碼來源:ServerBagTest.php

示例8: testShouldExtractHeadersFromServerArray

 public function testShouldExtractHeadersFromServerArray()
 {
     $server = array('SOME_SERVER_VARIABLE' => 'value', 'SOME_SERVER_VARIABLE2' => 'value', 'ROOT' => 'value', 'HTTP_CONTENT_TYPE' => 'text/html', 'HTTP_CONTENT_LENGTH' => '0', 'HTTP_ETAG' => 'asdf');
     $bag = new ServerBag($server);
     $this->assertEquals(array('CONTENT_TYPE' => 'text/html', 'CONTENT_LENGTH' => '0', 'ETAG' => 'asdf'), $bag->getHeaders());
 }
開發者ID:nickaggarwal,項目名稱:sample-symfony2,代碼行數:6,代碼來源:ServerBagTest.php

示例9: getHeaders

 /**
  * information about case sensitivity:
  * @link http://stackoverflow.com/questions/7718476/are-http-headers-content-type-c-case-sensitive
  * @return array
  */
 private function getHeaders()
 {
     $headers = [];
     foreach ($this->serverBag->getHeaders() as $key => $value) {
         $key = str_replace(' ', '-', str_replace('_', ' ', $key));
         $headers[] = '-H \'' . $key . ': ' . $value . '\'';
     }
     return $headers;
 }
開發者ID:yapro,項目名稱:debug,代碼行數:14,代碼來源:RequestAsCurl.php

示例10: parseAcceptLanguage

 /**
  * Parst den ACCEPT-LANGUAGE Header des Browsers
  * und gibt die präferierten Sprachen zurück
  *
  * @return array
  */
 public function parseAcceptLanguage()
 {
     $locales = [];
     if ($this->server->has('HTTP_ACCEPT_LANGUAGE')) {
         $matches = [];
         preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\\s*(;\\s*q\\s*=\\s*(1|0\\.[0-9]+))?/i', $this->server->get('HTTP_ACCEPT_LANGUAGE'), $matches);
         if (!empty($matches[1])) {
             $locales = array_combine($matches[1], $matches[4]);
             // Für Einträge ohne q-Faktor, Wert auf 1 setzen
             foreach ($locales as $locale => $val) {
                 if ($val === '') {
                     $locales[$locale] = 1;
                 }
             }
             // Liste nach Sprachpräferenz sortieren
             arsort($locales, SORT_NUMERIC);
         }
     }
     return $locales;
 }
開發者ID:acp3,項目名稱:core,代碼行數:26,代碼來源:UserAgent.php

示例11: prepareBasePath

 /**
  * Prepares the base path.
  *
  * @return string base path
  */
 protected function prepareBasePath()
 {
     $filename = basename($this->server->get('SCRIPT_FILENAME'));
     $baseUrl = $this->getBaseUrl();
     if (empty($baseUrl)) {
         return '';
     }
     if (basename($baseUrl) === $filename) {
         $basePath = dirname($baseUrl);
     } else {
         $basePath = $baseUrl;
     }
     if ('\\' === DIRECTORY_SEPARATOR) {
         $basePath = str_replace('\\', '/', $basePath);
     }
     return rtrim($basePath, '/');
 }
開發者ID:krisldz,項目名稱:Gekosale2,代碼行數:22,代碼來源:Request.php

示例12: isFromTrustedProxy

 private function isFromTrustedProxy()
 {
     return self::$trustedProxies && IpUtils::checkIp($this->server->get('REMOTE_ADDR'), self::$trustedProxies);
 }
開發者ID:mesushan,項目名稱:FirstRepo,代碼行數:4,代碼來源:Request.php

示例13: getRealMethod

 /**
  * Gets the "real" request method.
  *
  * @return string The request method
  *
  * @see getMethod
  */
 public function getRealMethod()
 {
     return strtoupper($this->server->get('REQUEST_METHOD', 'GET'));
 }
開發者ID:BozzaCoon,項目名稱:SPHERE-Framework,代碼行數:11,代碼來源:Request.php


注:本文中的Symfony\Component\HttpFoundation\ServerBag類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。