/** * This function inititalizes Group-Office. It starts the session,registers * error logging functions, class autoloading and set's PHP defaults. */ public static function init() { if (self::$initialized) { throw new \Exception("Group-Office was already initialized"); } self::$initialized = true; //register our custom error handler here set_error_handler(array('GO', 'errorHandler')); register_shutdown_function(array('GO', 'shutdown')); spl_autoload_register(array('GO', 'autoload')); //Start session here. Important that it's called before \GO::config(). \GO::session(); if (!empty(\GO::config()->debug_usernames)) { $usernames = explode(',', \GO::config()->debug_usernames); $currentUserModel = \GO::user(); if (!empty($currentUserModel) && in_array($currentUserModel->username, $usernames)) { \GO::config()->debug = true; } } if (\GO::config()->debug) { error_reporting(E_ALL | E_STRICT); } if (!self::isInstalled()) { return; } if (\GO::config()->debug) { self::$_scriptStartTime = \GO\Base\Util\Date::getmicrotime(); } date_default_timezone_set(\GO::user() ? \GO::user()->timezone : \GO::config()->default_timezone); //set local to utf-8 so functions will behave consistently if (!empty(\GO::config()->locale_all)) { setlocale(LC_CTYPE, \GO::config()->locale_all); putenv('LC_ALL=' . \GO::config()->locale_all); } else { //for escape shell arg if (!isset(\GO::session()->values['locale_all'])) { $currentlocale = \GO::session()->values['locale_all'] = setlocale(LC_CTYPE, "0"); if (stripos($currentlocale, 'utf') == false && function_exists('exec')) { @exec('locale -a', $output); // var_dump($output); if (isset($output) && is_array($output)) { foreach ($output as $locale) { if (stripos($locale, 'utf') !== false) { setlocale(LC_CTYPE, $locale); \GO::session()->values['locale_all'] = $locale; break; } } } \GO::debug("WARNING: could not find UTF8 locale. Run locale -a and set \$config['locale_all']. See https://www.group-office.com/wiki/Configuration_file#Localization_settings_list"); } } // exit(\GO::session()->values['locale_all']); setlocale(LC_CTYPE, \GO::session()->values['locale_all']); putenv('LC_ALL=' . \GO::session()->values['locale_all']); } if (!empty(\GO::session()->values['debug'])) { \GO::config()->debug = true; } if (\GO::config()->debug || \GO::config()->debug_log) { $log = '[' . date('Y-m-d H:i') . '] INIT'; \GO::debug($log); } if (\GO::config()->debug_display_errors) { ini_set("display_errors", "On"); } elseif (PHP_SAPI != 'cli') { ini_set("display_errors", "Off"); } if (self::config()->firephp) { if (self::requireExists('FirePHPCore/fb.php')) { require_once 'FirePHPCore/fb.php'; } } if (!defined('GO_LOADED')) { //check if old Group-Office.php was loaded self::_undoMagicQuotes(); //set umask to 0 so we can create new files with mask defined in \GO::config()->file_create_mode umask(0); //We use UTF8 by default. if (function_exists('mb_internal_encoding')) { mb_internal_encoding("UTF-8"); } } //Every logged on user get's a personal temp dir. if (!empty(self::session()->values['user_id'])) { self::config()->tmpdir = self::config()->getTempFolder()->path() . '/'; } if (isset(GO::config()->init_script)) { require GO::config()->init_script; } }