/** * Gets the current language for the user. This is based on the browsers request. * No lookups are made. * The language must be available in the pool, or set as default, otherwise the default is returned. * @return string The language to use. */ public static final function getLanguage() { $langRequest = self::$defaultLocale; $server = new \System\HTTP\Request\Server(); $browserRequestLang = $server->c_get('HTTP_ACCEPT_LANGUAGE'); if (!empty($browserRequestLang)) { $browserRequestLang = self::callLocaleFunction('acceptFromHttp', $browserRequestLang); if (self::isValidLocale($browserRequestLang)) { $langRequest = $browserRequestLang; } } $cookie = new \System\HTTP\Storage\Cookie(); $cookieRequestLang = $cookie->get(self::COOKIE_KEY); if (!empty($cookieRequestLang)) { if (self::isValidLocale($cookieRequestLang)) { $langRequest = $cookieRequestLang; } } return self::callLocaleFunction('getPrimaryLanguage', self::callLocaleFunction('lookup', self::$languagePool, $langRequest, true, self::$defaultLocale)); }
/** * Establishes a SMTP connection * @return \System\Email\SMTP The SMTP connection */ private static final function getSMTPConnection() { if (!defined('EMAILSYSTEM_SMTP_HOST') || !defined('EMAILSYSTEM_SMTP_PORT') || !defined('EMAILSYSTEM_SMTP_TIMEOUT') || !defined('EMAILSYSTEM_SMTP_PASSWORD') || !defined('EMAILSYSTEM_SMTP_HANDLEMAILS') || !defined('EMAILSYSTEM_SMTP_USERNAME')) { throw new \System\Error\Exception\SystemException('Please set the EMAILSYSTEM_SMTP_HOST, EMAILSYSTEM_SMTP_PORT, EMAILSYSTEM_SMTP_TIMEOUT, EMAILSYSTEM_SMTP_PASSWORD, EMAILSYSTEM_SMTP_HANDLEMAILS and EMAILSYSTEM_SMTP_USERNAME config directives'); } $server = new \System\HTTP\Request\Server(); $smtp = new \System\Email\SMTP(EMAILSYSTEM_SMTP_HOST, EMAILSYSTEM_SMTP_PORT, EMAILSYSTEM_SMTP_TIMEOUT); $smtp->sendCommand('EHLO ' . $server->get('SERVER_ADDR')); $smtp->sendCommand('AUTH LOGIN'); $smtp->sendCommand(base64_encode(EMAILSYSTEM_SMTP_USERNAME)); $smtp->sendCommand(base64_encode(EMAILSYSTEM_SMTP_PASSWORD)); return $smtp; }