X-Git-Url: https://git-public.kairo.at/?p=authserver.git;a=blobdiff_plain;f=app%2Fauthsystem.inc.php;h=45d0e0fb64fb78e84594e27c9b3aab7fe5fa620f;hp=6e30200293422d7fa3dd9fd5c26d6c7669649b1c;hb=2b9aa8f3c5aeb5d3fa414a985ad14b351a12cfcd;hpb=7d51fe69654d1997f4f48eb7b928c5352da8eb63 diff --git a/app/authsystem.inc.php b/app/authsystem.inc.php index 6e30200..45d0e0f 100644 --- a/app/authsystem.inc.php +++ b/app/authsystem.inc.php @@ -20,19 +20,42 @@ $settings = json_decode(file_get_contents('/etc/kairo/auth_settings.json'), true if (!is_array($settings)) { trigger_error('Auth settings not found', E_USER_ERROR); } // Extended DOM document class -require_once('../kairo-utils/document.php-class'); -// Class for sending emails -require_once('../kairo-utils/email.php-class'); +require_once(__DIR__.'/../php-utility-classes/classes/document.php-class'); // Class for sending emails +require_once(__DIR__.'/../php-utility-classes/classes/email.php-class'); +// Composer-provided libraries (oauth2-server-php, doctrine DBAL) +require_once(__DIR__.'/../vendor/autoload.php'); +// Connect to our MySQL DB +$db = new PDO($dbdata['dsn'], $dbdata['username'], $dbdata['password']); +// Authentication utilities require_once(__DIR__.'/authutils.php-class'); +// Instantiate server utils. +try { + $utils = new AuthUtils($settings, $db); +} +catch (Exception $e) { + $utils = null; +} -bindtextdomain('kairo_auth', 'en'); // XXX: Should negotiate locale. -bind_textdomain_codeset('kairo_auth', 'utf-8'); +// This is an array of locale tags in browser style mapping to unix system locale codes to use with gettext. +$supported_locales = array( + 'en-US' => 'en_US', + 'de' => 'de_DE', +); -// Connect to our MySQL DB -$db = new PDO($dbdata['dsn'], $dbdata['username'], $dbdata['password']); -// Instantiate auth utils. -$utils = new AuthUtils($settings, $db); +$textdomain = 'kairo_auth'; +$textlocale = $utils->negotiateLocale(array_keys($supported_locales)); +putenv('LC_ALL='.$supported_locales[$textlocale]); +$selectedlocale = setlocale(LC_ALL, $supported_locales[$textlocale]); +bindtextdomain($textdomain, '../locale'); +bind_textdomain_codeset($textdomain, 'utf-8'); +textdomain($textdomain); + +// Sanitize settings. +$settings['piwik_enabled'] = (@$settings['piwik_enabled']) ? true : false; +$settings['piwik_site_id'] = intval(@$settings['piwik_site_id']); +$settings['piwik_url'] = strlen(@$settings['piwik_url']) ? $settings['piwik_url'] : '/piwik/'; +$settings['piwik_tracker_path'] = strlen(@$settings['piwik_tracker_path']) ? $settings['piwik_tracker_path'] : '../vendor/piwik/piwik-php-tracker/'; /* Creating the DB tables: CREATE TABLE `auth_sessions` (