/**
  * @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'];
 }
 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' => '']);
 }
예제 #3
0
 /**
  * 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;
 }
예제 #4
0
파일: UserAgent.php 프로젝트: acp3/core
 /**
  * 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;
 }
예제 #5
0
 /**
  * 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, '/');
 }
예제 #6
0
 private function isFromTrustedProxy()
 {
     return self::$trustedProxies && IpUtils::checkIp($this->server->get('REMOTE_ADDR'), self::$trustedProxies);
 }
예제 #7
0
 /**
  * Gets the "real" request method.
  *
  * @return string The request method
  *
  * @see getMethod
  */
 public function getRealMethod()
 {
     return strtoupper($this->server->get('REQUEST_METHOD', 'GET'));
 }