// Need this include for the compression constants used in the config file require_once GITPHP_GITOBJECTDIR . 'Archive.class.php'; // Test these executables early require_once GITPHP_GITOBJECTDIR . 'GitExe.class.php'; require_once GITPHP_GITOBJECTDIR . 'DiffExe.class.php'; date_default_timezone_set('UTC'); /* * Set the locale based on the user's preference */ if (!isset($_COOKIE[GITPHP_LOCALE_COOKIE]) || empty($_COOKIE[GITPHP_LOCALE_COOKIE])) { /* * User's first time here, try by HTTP_ACCEPT_LANGUAGE */ if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $httpAcceptLang = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); $preferredLocale = GitPHP_Resource::FindPreferredLocale($_SERVER['HTTP_ACCEPT_LANGUAGE']); if (!empty($preferredLocale)) { setcookie(GITPHP_LOCALE_COOKIE, $preferredLocale, time() + GITPHP_LOCALE_COOKIE_LIFETIME); GitPHP_Resource::Instantiate($preferredLocale); } } if (!GitPHP_Resource::Instantiated()) { /* * Create a dummy cookie to prevent browser delay */ setcookie(GITPHP_LOCALE_COOKIE, 0, time() + GITPHP_LOCALE_COOKIE_LIFETIME); } } else { if (isset($_GET['l']) && !empty($_GET['l'])) { /* * User picked something
/** * Initialize resource manager */ protected function InitializeResource() { $locale = null; $baseurl = GitPHP_Util::BaseUrl(); if (empty($baseurl) && $this->config->GetValue('cleanurl')) { $baseurl = '/'; } if (!empty($this->params['lang'])) { /* * User picked something */ setcookie(GitPHP_Resource::LocaleCookie, $this->params['lang'], time() + GitPHP_Resource::LocaleCookieLifetime, $baseurl); $locale = $this->params['lang']; } else { if (!empty($_COOKIE[GitPHP_Resource::LocaleCookie])) { /** * Returning user with a preference */ $locale = $_COOKIE[GITPHP_Resource::LocaleCookie]; } else { /* * User's first time here, try by HTTP_ACCEPT_LANGUAGE */ if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $locale = GitPHP_Resource::FindPreferredLocale($_SERVER['HTTP_ACCEPT_LANGUAGE']); if (!empty($locale)) { setcookie(GitPHP_Resource::LocaleCookie, $locale, time() + GitPHP_Resource::LocaleCookieLifetime, $baseurl); } } } } if (empty($locale) && $this->config) { /* * No preference, fall back on setting */ $locale = $this->config->GetValue('locale'); } if (!empty($locale) && $locale != 'en_US') { try { $this->resource = new GitPHP_Resource($locale); } catch (Exception $e) { } } }