/** * Copyright (C) 2008-2013 Ulteo SAS * http://www.ulteo.com * Author Julien LANGLOIS <*****@*****.**> 2008-2013 * Author Laurent CLOUET <*****@*****.**> 2008-2011 * Author Jeremy DESVAGES <*****@*****.**> 2008-2011 * Author David LECHEVALIER <*****@*****.**> 2012 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ function set_language($lang_) { $language = locale2unix($lang_); setlocale(LC_ALL, $language . '.UTF-8'); putenv('LANGUAGE=' . $language); $domain = 'uovdsmadmin'; bindtextdomain($domain, LOCALE_DIR); textdomain($domain); }
public function getLocale() { if ($this->hasAttribute('countrycode')) { $language = $this->getAttribute('countrycode'); // only works for ISO-3166 } else { $prefs = Preferences::getInstance(); if (!$prefs) { die_error('get Preferences failed', __FILE__, __LINE__); } $default_settings = $prefs->get('general', 'session_settings_defaults'); $language = $default_settings['language']; } $locale = locale2unix($language); return $locale; }
$remote_applications_settings = $user->getSessionSettings('remote_applications_settings'); $remote_applications_enabled = $remote_applications_settings['enabled'] == 1 ? true : false; $bypass_server_restrictions = $default_settings['bypass_servers_restrictions'] == 1; if (isset($sessionManagement->mode)) { if (!in_array('session_mode', $advanced_settings) && $sessionManagement->mode != $session_mode) { throw_response(UNAUTHORIZED); } $session_mode = $sessionManagement->mode; } if (!$user->can_use_session()) { Logger::info('main', '(client/start) User ' . $user->getAttribute('login') . ' cannot start/recover a session because of time restriction policy'); throw_response(UNAUTHORIZED); } $locale = $user->getLocale(); if (isset($sessionManagement->language)) { $locale = locale2unix($sessionManagement->language); } switch ($session_mode) { case Session::MODE_DESKTOP: if (!isset($remote_desktop_enabled) || $remote_desktop_enabled === false) { throw_response(UNAUTHORIZED); } break; case Session::MODE_APPLICATIONS: if (!isset($remote_applications_enabled) || $remote_applications_enabled === false) { throw_response(UNAUTHORIZED); } break; default: throw_response(UNAUTHORIZED); break;
$prefs->deleteConfFile(); $prefs = new Preferences_admin(); } catch (Exception $e) { } $prefs->initialize(); $prefs->set('general', 'sql', $elements_form['general']['sql']); } else { $elements_form = formToArray($_POST); $prefs = new Preferences_admin($elements_form); } $ret = $prefs->isValid(); if ($ret === true) { $ret = $prefs->backup(); if ($ret > 0) { $buf = $prefs->get('general', 'admin_language'); $language = locale2unix($buf); setlocale(LC_ALL, $language . '.UTF-8'); // configuration saved popup_info(_('Configuration successfully saved')); redirect('index.php'); } else { header_static(_('Configuration')); echo 'problem : configuration not saved<br>'; // TODO (class msg...) + gettext footer_static(); } } else { // conf not valid if ($setup) { popup_error('Error : ' . $ret); redirect('configuration.php?action=init');
function get_available_translations($lang) { setlocale(LC_ALL, locale2unix($lang)); $domain = 'uovdclient'; bindtextdomain($domain, LOCALE_DIR); textdomain($domain); $translations = array('close' => _('Close'), 'session_manager' => _('Session Manager'), 'login' => _('Login'), 'login_detected' => _('Login (detected)'), 'password' => _('Password'), 'use_local_credentials' => _('Use local credentials'), 'use_local_credentials_yes' => _('Yes'), 'use_local_credentials_no' => _('No'), 'mode' => _('Mode'), 'mode_desktop' => _('Desktop'), 'mode_portal' => _('Portal'), 'rdp_mode' => _('Type'), 'fullscreen' => _('Fullscreen'), 'fullscreen_yes' => _('Yes'), 'fullscreen_no' => _('No'), 'language' => _('Language'), 'keyboard_layout' => _('Keyboard layout'), 'debug' => _('Debug'), 'debug_yes' => _('Yes'), 'debug_no' => _('No'), 'keyboard_config' => _('Keyboard method'), 'keyboard_config_scancode' => _('Scancode'), 'keyboard_config_unicode' => _('Unicode'), 'keyboard_config_unicode_lime' => _('Unicode use local IME'), 'advanced_settings' => _('Advanced settings'), 'connect' => _('Connect'), 'system_compatibility_check_1' => _('Checking for system compatibility'), 'system_compatibility_check_2' => _('If this is your first time here, a Java security window will show up and you will have to accept it to use the service.'), 'system_compatibility_check_3' => _('You are advised to check the "<em>Always trust content from this publisher</em>" checkbox.'), 'system_compatibility_error_1' => _('System compatibility error'), 'system_compatibility_error_2' => _('Java is either not available on your system or in your web browser.'), 'system_compatibility_error_3' => _('Please install the Java extension for your web browser or contact your administrator.'), 'system_compatibility_error_4' => _('You have not accepted the Java security window.'), 'system_compatibility_error_5' => _('You <strong>cannot</strong> have access to this service.'), 'loading_ovd' => _('Loading Open Virtual Desktop'), 'unloading_ovd' => _('Disconnecting Open Virtual Desktop'), 'welcome' => _('Welcome!'), 'suspend' => _('Suspend'), 'logout' => _('Logout'), 'desktop_fullscreen_text1' => _('The Ulteo OVD session runs in a separate window'), 'desktop_fullscreen_text2' => str_replace(array('[A]', '[/A]'), array('<a href="javascript:;">', '</a>'), _('Click [A]here[/A] to switch back to your session')), 'my_apps' => _('My applications'), 'running_apps' => _('Running applications'), 'my_files' => _('My files')); $js_translations = array('sessionmanager_host_example' => str_replace('%EXAMPLE%', 'sm.test.demo', _('Example: %EXAMPLE%')), 'no_sessionmanager_host' => _('Usage: missing "sessionmanager_host" parameter'), 'no_login_parameter' => _('Usage: missing "login" parameter'), 'no_password_parameter' => _('Usage: missing "password" parameter'), 'unable_to_reach_sm' => _('Unable to reach the Session Manager'), 'auth_failed' => _('Authentication failed: please double-check your password and try again'), 'in_maintenance' => _('The system is in maintenance mode, please contact your administrator for more information'), 'internal_error' => _('An internal error occurred, please contact your administrator'), 'invalid_user' => _('You specified an invalid login, please double-check and try again'), 'service_not_available' => _('The service is not available, please contact your administrator for more information'), 'unauthorized' => _('You are not authorized to launch a session. Please contact your administrator for more information'), 'user_with_active_session' => _('You already have an active session'), 'window_onbeforeunload' => _('You will be disconnected from your OVD session.'), 'session_expire_in_3_minutes' => _('Your session is going to end in 3 minutes, please save all your data now!'), 'session_time_restriction_expire' => _('Your session is going to be disconnected in %MINUTES% minutes because of the logon time restriction policy'), 'session_close_unexpected' => _('Server: session closed unexpectedly'), 'session_end_ok' => _('Your session has ended, you can now close the window'), 'session_end_unexpected' => _('Your session has ended unexpectedly'), 'error_details' => _('error details'), 'close_this_window' => _('Close this window'), 'start_another_session' => str_replace(array('[A]', '[/A]'), array('<a href="javascript:;">', '</a>'), _('Click [A]here[/A] to start a new session')), 'suspend' => _('suspend'), 'resume' => _('resume'), 'want_logout' => _('Are you sure you want to logout (# apps running) ?')); return array($translations, $js_translations); }
$locale = $locales['en']; } if (strlen($locale) == 2) { if (array_key_exists($locale, $locales)) { $locale = $locales[$locale]; } else { $locale = $locale . '_' . strtoupper($locale); } } elseif (strlen($locale) == 5) { $locale = substr($locale, 0, 2) . '_' . strtoupper(substr($locale, -2)); } $locale .= '.UTF-8'; return $locale; } if (array_key_exists('lang', $_REQUEST)) { setlocale(LC_ALL, locale2unix($_REQUEST['lang'])); } $domain = 'uovdclient'; bindtextdomain($domain, LOCALE_DIR); textdomain($domain); header('Content-Type: text/xml; charset=utf-8'); $dom = new DomDocument('1.0', 'utf-8'); $root = $dom->createElement('translations'); $dom->appendChild($root); $translations = array('close' => _('Close'), 'session_manager' => _('Session Manager'), 'login' => _('Login'), 'password' => _('Password'), 'use_local_credentials' => _('Use local credentials'), 'use_local_credentials_yes' => _('Yes'), 'use_local_credentials_no' => _('No'), 'mode' => _('Mode'), 'mode_desktop' => _('Desktop'), 'mode_portal' => _('Portal'), 'fullscreen' => _('Fullscreen'), 'fullscreen_yes' => _('Yes'), 'fullscreen_no' => _('No'), 'language' => _('Language'), 'keyboard_layout' => _('Keyboard layout'), 'debug' => _('Debug'), 'debug_yes' => _('Yes'), 'debug_no' => _('No'), 'advanced_settings' => _('Advanced settings'), 'connect' => _('Connect'), 'system_compatibility_check_1' => _('Checking for system compatibility'), 'system_compatibility_check_2' => _('If this is your first time here, a Java security window will show up and you have to accept it to use the service.'), 'system_compatibility_check_3' => _('You are advised to check the "<em>Always trust content from this publisher</em>" checkbox.'), 'system_compatibility_error_1' => _('System compatibility error'), 'system_compatibility_error_2' => _('Java is not available either on your system or in your web browser.'), 'system_compatibility_error_3' => _('Please install Java extension for your web browser or contact your administrator.'), 'system_compatibility_error_4' => _('You have not accepted the Java security window.'), 'system_compatibility_error_5' => _('You <strong>cannot</strong> have access to this service.'), 'loading_ovd' => _('Loading Open Virtual Desktop'), 'welcome' => _('Welcome!'), 'suspend' => _('Suspend'), 'logout' => _('Logout'), 'desktop_fullscreen_text1' => _('The Ulteo OVD session runs in a separated window'), 'desktop_fullscreen_text2' => str_replace(array('[A]', '[/A]'), array('<a href="javascript:;" onclick="$(\'ulteoapplet\').switchBackFullscreenWindow(); return false;">', '</a>'), _('Click [A]here[/A] to switch back to your session')), 'my_apps' => _('My applications'), 'running_apps' => _('Running applications'), 'my_files' => _('My files')); foreach ($translations as $id => $string) { $node = $dom->createElement('translation'); $node->setAttribute('id', $id); $node->setAttribute('string', $string); $root->appendChild($node); }
} $session_mode = $_SESSION['mode']; } $locale = $user->getLocale(); $protocol_vars = array('session_mode', 'language', 'timeout', 'persistent'); foreach ($protocol_vars as $protocol_var) { if (in_array($protocol_var, $advanced_settings) && isset($_REQUEST[$protocol_var]) && $_REQUEST[$protocol_var] != '') { switch ($protocol_var) { case 'session_mode': if (!in_array('session_mode', $advanced_settings) && $_REQUEST['session_mode'] != $session_mode) { throw_response(UNAUTHORIZED_SESSION_MODE); } $session_mode = $_REQUEST['session_mode']; break; case 'language': $locale = locale2unix($_REQUEST['language']); break; default: ${$protocol_var} = $_REQUEST[$protocol_var]; break; } } } $other_vars = array('timezone'); foreach ($other_vars as $other_var) { if (isset($_REQUEST[$other_var]) && $_REQUEST[$other_var] != '') { ${$other_var} = $_REQUEST[$other_var]; } } switch ($session_mode) { case Session::MODE_DESKTOP:
public function prepareAPSAccess($session_) { $remote_desktop_settings = $this->user->getSessionSettings('remote_desktop_settings'); $default_settings = $this->user->getSessionSettings('session_settings_defaults'); $prepare_servers = array(); # No_desktop option management if (isset($this->no_desktop) && $this->no_desktop === true) { if ($authorize_no_desktop === true) { $no_desktop_process = 1; } else { Logger::warning('main', 'SessionManagement::prepareAPSAccess - Cannot apply no_desktop parameter because policy forbid it'); } } if ($default_settings['use_known_drives'] == 1) { $use_known_drives = 'true'; } $profile_mode = $default_settings['profile_mode']; $use_local_ime = $session_->settings['use_local_ime']; $desktop_icons = $remote_desktop_settings['desktop_icons']; $need_valid_profile = $default_settings['start_without_profile'] == 0; $user_login_aps = $session_->settings['aps_access_login']; $user_password_aps = $session_->settings['aps_access_password']; $user_login_fs = $session_->settings['fs_access_login']; $user_password_fs = $session_->settings['fs_access_password']; $remote_desktop_settings = $this->user->getSessionSettings('remote_desktop_settings'); $allow_external_applications = array_key_exists('allow_external_applications', $remote_desktop_settings) && $remote_desktop_settings['allow_external_applications'] == 1; if (isset($this->language)) { $locale = locale2unix($this->language); } else { $locale = $this->user->getLocale(); } if (isset($this->timezone) && $this->timezone != '') { $timezone = $this->timezone; } if ($session_->mode == Session::MODE_DESKTOP) { $have_external_apps = false; if (array_key_exists(Server::SERVER_ROLE_APS, $session_->servers)) { $have_external_apps |= count($session_->servers[Server::SERVER_ROLE_APS]) > 1; } if (array_key_exists(Server::SERVER_ROLE_WEBAPPS, $session_->servers)) { $have_external_apps |= count($session_->servers[Server::SERVER_ROLE_WEBAPPS]) > 0; } if ($session_->mode == Session::MODE_DESKTOP && $allow_external_applications && $have_external_apps) { $external_apps_token = new Token(gen_unique_string()); $external_apps_token->type = 'external_apps'; $external_apps_token->link_to = $session_->id; $external_apps_token->valid_until = 0; Abstract_Token::save($external_apps_token); } $prepare_servers[] = $session_->server; } if ($session_->mode == Session::MODE_APPLICATIONS || $session_->mode == Session::MODE_DESKTOP && $allow_external_applications) { foreach ($session_->servers[Server::SERVER_ROLE_APS] as $server_id => $data) { if ($session_->mode == Session::MODE_DESKTOP && $allow_external_applications && $server_id == $session_->server) { continue; } $prepare_servers[] = $server_id; } } $count_prepare_servers = 0; foreach ($prepare_servers as $prepare_server) { $count_prepare_servers++; $server = Abstract_Server::load($prepare_server); if (!$server) { continue; } if (!array_key_exists(Server::SERVER_ROLE_APS, $server->getRoles())) { continue; } $server_applications = $server->getApplications(); if (!is_array($server_applications)) { $server_applications = array(); } $available_applications = array(); foreach ($server_applications as $server_application) { $available_applications[] = $server_application->getAttribute('id'); } $dom = new DomDocument('1.0', 'utf-8'); $session_node = $dom->createElement('session'); $session_node->setAttribute('id', $session_->id); $session_node->setAttribute('mode', $session_->mode == Session::MODE_DESKTOP && $count_prepare_servers == 1 ? Session::MODE_DESKTOP : Session::MODE_APPLICATIONS); // OvdShell Configuration $shell_node = $dom->createElement('shell'); $session_node->appendChild($shell_node); if (isset($external_apps_token)) { $setting_node = $dom->createElement('setting'); $setting_node->setAttribute('name', 'external_apps_token'); $setting_node->setAttribute('value', $external_apps_token->id); $shell_node->appendChild($setting_node); } if (isset($this->start_apps) && is_array($this->start_apps)) { $start_apps = $this->start_apps; $applicationDB = ApplicationDB::getInstance(); foreach ($start_apps as $start_app) { $app = $applicationDB->import($start_app['id']); if (!is_object($app)) { Logger::error('main', 'SessionManagement::prepareAPSAccess - No such application for id \'' . $start_app['id'] . '\''); throw_response(SERVICE_NOT_AVAILABLE); } $apps = $session_->getPublishedApplications(); $ok = false; foreach ($apps as $user_app) { if ($user_app->getAttribute('id') == $start_app['id']) { $ok = true; break; } } if ($ok === false) { Logger::error('main', 'SessionManagement::prepareAPSAccess - Application not available for user \'' . $user->getAttribute('login') . '\' id \'' . $start_app['id'] . '\''); return false; } } } foreach (array('no_desktop_process', 'use_known_drives', 'profile_mode', 'use_local_ime') as $parameter) { if (!isset(${$parameter})) { continue; } $setting_node = $dom->createElement('setting'); $setting_node->setAttribute('name', $parameter); $setting_node->setAttribute('value', ${$parameter}); $shell_node->appendChild($setting_node); } foreach (array('desktop_icons', 'locale', 'timezone', 'need_valid_profile') as $parameter) { if (!isset(${$parameter})) { continue; } $parameter_node = $dom->createElement('parameter'); $parameter_node->setAttribute('name', $parameter); $parameter_node->setAttribute('value', ${$parameter}); $session_node->appendChild($parameter_node); } $scripts = $this->user->scripts(); if (is_array($scripts)) { $scripts_node = $dom->createElement('scripts'); foreach ($scripts as $script) { $script_node = $dom->createElement('script'); $script_node->setAttribute('id', $script->getAttribute('id')); $script_node->setAttribute('type', $script->getAttribute('type')); $script_node->setAttribute('name', $script->getAttribute('name')); $scripts_node->appendChild($script_node); } $shell_node->appendChild($scripts_node); } $user_node = $dom->createElement('user'); $user_node->setAttribute('login', $user_login_aps); $user_node->setAttribute('password', $user_password_aps); $user_node->setAttribute('displayName', $this->user->getAttribute('displayname')); $session_node->appendChild($user_node); if (array_key_exists(Server::SERVER_ROLE_FS, $session_->servers)) { foreach ($session_->servers[Server::SERVER_ROLE_FS] as $server_id => $netfolders) { $fs_server = Abstract_Server::load($server_id); foreach ($netfolders as $netfolder) { $uri = 'cifs://' . $fs_server->getExternalName() . '/' . $netfolder['dir']; $netfolder_node = $dom->createElement($netfolder['type']); $netfolder_node->setAttribute('rid', $netfolder['rid']); $netfolder_node->setAttribute('uri', $uri); if ($netfolder['type'] == 'profile') { $netfolder_node->setAttribute('profile_mode', $profile_mode); } if ($netfolder['type'] == 'sharedfolder') { $netfolder_node->setAttribute('name', $netfolder['name']); $netfolder_node->setAttribute('mode', $netfolder['mode']); } $netfolder_node->setAttribute('login', $user_login_fs); $netfolder_node->setAttribute('password', $user_password_fs); $session_node->appendChild($netfolder_node); } } } foreach ($this->forced_sharedfolders as $share) { $sharedfolder_node = $dom->createElement('sharedfolder'); $sharedfolder_node->setAttribute('rid', $share['rid']); $sharedfolder_node->setAttribute('uri', $share['uri']); $sharedfolder_node->setAttribute('name', $share['name']); if (array_key_exists('login', $share) && array_key_exists('password', $share)) { $sharedfolder_node->setAttribute('login', $share['login']); $sharedfolder_node->setAttribute('password', $share['password']); } $session_node->appendChild($sharedfolder_node); } // Pass custom shared folders to the server foreach (Plugin::dispatch('getSharedFolders', $server) as $plugin => $results) { foreach ($results as $sharedfolder) { $sharedfolder_ok = true; $sharedfolder_node = $dom->createElement('sharedfolder'); foreach (array('uri', 'name', 'rid') as $key) { if (array_key_exists($key, $sharedfolder)) { $sharedfolder_node->setAttribute($key, $sharedfolder[$key]); } else { Logger::error('main', 'SharedFolder is missing ' . $key . ' parameter in ' . $plugin); $sharedfolder_ok = false; } } foreach (array('login', 'password') as $key) { if (array_key_exists($key, $sharedfolder)) { $sharedfolder_node->setAttribute($key, $sharedfolder[$key]); } } if (($have_login = array_key_exists('login', $sharedfolder)) != array_key_exists('password', $sharedfolder) && $have_login) { Logger::error('main', 'SharedFolder login and password are both required if one is present in ' . $plugin); $sharedfolder_ok = false; } if ($sharedfolder_ok) { $session_node->appendChild($sharedfolder_node); } } } foreach ($session_->getPublishedApplications() as $application) { if ($application->getAttribute('type') != $server->getAttribute('type')) { continue; } if (!in_array($application->getAttribute('id'), $available_applications)) { continue; } $application_node = $dom->createElement('application'); $application_node->setAttribute('id', $application->getAttribute('id')); $application_node->setAttribute('name', $application->getAttribute('name')); if (!$application->getAttribute('static')) { $application_node->setAttribute('mode', 'local'); } else { $application_node->setAttribute('mode', 'static'); } $session_node->appendChild($application_node); } if (isset($start_apps) && is_array($start_apps)) { $start_node = $dom->createElement('start'); foreach ($start_apps as $start_app) { $application_node = $dom->createElement('application'); $application_node->setAttribute('app_id', $start_app['id']); if (array_key_exists('arg', $start_app) && !is_null($start_app['arg'])) { $application_node->setAttribute('arg', $start_app['arg']); } if (array_key_exists('file', $start_app)) { $file_node = $dom->createElement('file'); $file_node->setAttribute('type', $start_app['file']['type']); $file_node->setAttribute('location', $start_app['file']['location']); $file_node->setAttribute('path', $start_app['file']['path']); $application_node->appendChild($file_node); } $start_node->appendChild($application_node); } $session_node->appendChild($start_node); } $dom->appendChild($session_node); $this->appendToSessionCreateXML($dom); $xml = $dom->saveXML(); $session_create_xml = query_url_post_xml($server->getBaseURL() . '/aps/session/create', $xml); $ret = $this->parseSessionCreate($session_create_xml); if (!$ret) { Logger::critical('main', 'SessionManagement::prepareAPSAccess - Unable to create Session \'' . $session->id . '\' for User \'' . $session->user_login . '\' on Server \'' . $server->fqdn . '\', aborting'); $session->orderDeletion(true, Session::SESSION_END_STATUS_ERROR); return false; } } return true; }