//login $user_manager =& $GLOBALS['current_user']->getAclManager(); if (!$login_user_use_idst) { $username = '******' . $login_user; $user_info = $user_manager->getUser(false, $username); } else { // use idst instead of username $user_info = $user_manager->getUser($login_user); if (!empty($user_info)) { $username = $user_info[ACL_INFO_USERID]; } } if ($user_info != false) { $du = new DoceboUser($username, 'public_area'); Lang::set($du->preference->getLanguage()); $du->setLastEnter(date("Y-m-d H:i:s")); $_SESSION['user_enter_mark'] = time(); $du->loadUserSectionST(); $du->SaveInSession(); $GLOBALS['current_user'] = $du; $id_course = Get::req('id_course', DOTY_INT, 0); $next_action = Get::req('act', DOTY_STRING, 'none'); $id_item = Get::req('id_item', DOTY_INT, ''); $chapter = Get::req('chapter', DOTY_MIXED, false); if ($id_course) { // if we have a id_course setted we will log the user into the course, // if no specific action are required we will redirect the user into the first page // otherwise we will continue to another option require_once _lms_ . '/lib/lib.course.php'; logIntoCourse($id_course, $next_action == false || $next_action == 'none' ? true : false); // specific action required
/** * static public function for load user from login e password * @param string $login login of the user * @param string $password password of the user in clear text * @param string $prefix optional prefix for session publiciables * @return mixed DoceboUser instance of logged in user if success in login * FALSE otherwise **/ public static function &createDoceboUserFromLogin($login, $password, $prefix = 'base', $new_lang = false) { if ($login == '') { $false_public = FALSE; return $false_public; } $user_manager = new DoceboACLManager(); $user_info = $user_manager->getUser(false, $login); // first login $ret_value = false; if ($user_info === false) { return $ret_value; } if ($user_info[ACL_INFO_VALID] != '1') { return $ret_value; } if (Get::sett('ldap_used') == 'on') { if ($password == '') { $false_public = FALSE; return $false_public; } //connect to ldap server if (!($ldap_conn = @ldap_connect(Get::sett('ldap_server'), Get::sett('ldap_port', '389')))) { die("Could not connect to ldap server"); } //bind on server $ldap_user = ereg_replace('\\$user', $login, Get::sett('ldap_user_string')); if (!@ldap_bind($ldap_conn, $ldap_user, $password)) { ldap_close($ldap_conn); // Edited by Claudio Redaelli if (Get::sett('ldap_alternate_check') == 'on') { if ($user_info[ACL_INFO_PASS] != $user_manager->encrypt($password)) { return $ret_value; } } else { $false_public = FALSE; return $false_public; } // End edit } ldap_close($ldap_conn); } elseif ($user_info[ACL_INFO_PASS] != $user_manager->encrypt($password)) { return $ret_value; } unset($_SESSION[$prefix . "_idst"]); $du = new DoceboUser($login, $prefix); $_SESSION['last_enter'] = $user_info[ACL_INFO_LASTENTER]; $du->setLastEnter(date("Y-m-d H:i:s")); $_SESSION['user_enter_mark'] = time(); // language policy if (!$new_lang && isset($_SESSION['forced_lang'])) { $new_lang = Lang::get(); } if ($new_lang != false) { $du->preference->setLanguage($new_lang); } else { if (!Get::cfg('demo_mode', false)) { Lang::set($du->preference->getLanguage()); } } if (function_exists('session_regenerate_id')) { session_regenerate_id(); } return $du; }