|
|
|
@ -225,7 +225,6 @@ if (api_get_setting('allow_terms_conditions')=='true') { |
|
|
|
$sql = "SELECT user_id, username, password, auth_source, active, expiration_date |
|
|
|
$sql = "SELECT user_id, username, password, auth_source, active, expiration_date |
|
|
|
FROM $user_table |
|
|
|
FROM $user_table |
|
|
|
WHERE username = '".trim(addslashes($login))."'"; |
|
|
|
WHERE username = '".trim(addslashes($login))."'"; |
|
|
|
|
|
|
|
|
|
|
|
$result = Database::query($sql); |
|
|
|
$result = Database::query($sql); |
|
|
|
|
|
|
|
|
|
|
|
if (Database::num_rows($result) > 0) { |
|
|
|
if (Database::num_rows($result) > 0) { |
|
|
|
@ -266,16 +265,16 @@ if (api_get_setting('allow_terms_conditions')=='true') { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// check the user's password |
|
|
|
// Check the user's password |
|
|
|
if ($password == $uData['password'] AND (trim($login) == $uData['username'])) { |
|
|
|
if ($password == $uData['password'] AND (trim($login) == $uData['username'])) { |
|
|
|
// check if the account is active (not locked) |
|
|
|
// Check if the account is active (not locked) |
|
|
|
if ($uData['active']=='1') { |
|
|
|
if ($uData['active']=='1') { |
|
|
|
// check if the expiration date has not been reached |
|
|
|
// Check if the expiration date has not been reached |
|
|
|
if ($uData['expiration_date']>date('Y-m-d H:i:s') OR $uData['expiration_date']=='0000-00-00 00:00:00') { |
|
|
|
if ($uData['expiration_date']>date('Y-m-d H:i:s') OR $uData['expiration_date']=='0000-00-00 00:00:00') { |
|
|
|
global $_configuration; |
|
|
|
global $_configuration; |
|
|
|
if ($_configuration['multiple_access_urls']==true) { |
|
|
|
if ($_configuration['multiple_access_urls']==true) { |
|
|
|
//check the access_url configuration setting if the user is registered in the access_url_rel_user table |
|
|
|
//Check the access_url configuration setting if the user is registered in the access_url_rel_user table |
|
|
|
//getting the current access_url_id of the platform |
|
|
|
//Getting the current access_url_id of the platform |
|
|
|
$current_access_url_id = api_get_current_access_url_id(); |
|
|
|
$current_access_url_id = api_get_current_access_url_id(); |
|
|
|
// my user is subscribed in these sites => $my_url_list |
|
|
|
// my user is subscribed in these sites => $my_url_list |
|
|
|
$my_url_list = api_get_access_url_from_user($uData['user_id']); |
|
|
|
$my_url_list = api_get_access_url_from_user($uData['user_id']); |
|
|
|
@ -293,7 +292,6 @@ if (api_get_setting('allow_terms_conditions')=='true') { |
|
|
|
exit; |
|
|
|
exit; |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
$loginFailed = true; |
|
|
|
$loginFailed = true; |
|
|
|
api_session_unregister('_uid'); |
|
|
|
api_session_unregister('_uid'); |
|
|
|
header('Location: '.api_get_path(WEB_PATH).'index.php?loginFailed=1&error=access_url_inactive'); |
|
|
|
header('Location: '.api_get_path(WEB_PATH).'index.php?loginFailed=1&error=access_url_inactive'); |
|
|
|
@ -302,9 +300,7 @@ if (api_get_setting('allow_terms_conditions')=='true') { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$_user['user_id'] = $uData['user_id']; |
|
|
|
$_user['user_id'] = $uData['user_id']; |
|
|
|
api_session_register('_user'); |
|
|
|
api_session_register('_user'); |
|
|
|
|
|
|
|
|
|
|
|
event_login(); |
|
|
|
event_login(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$loginFailed = true; |
|
|
|
$loginFailed = true; |
|
|
|
@ -357,12 +353,9 @@ if (api_get_setting('allow_terms_conditions')=='true') { |
|
|
|
if (isset($param)) { |
|
|
|
if (isset($param)) { |
|
|
|
header('location: '.api_get_path(WEB_PATH).api_get_setting('page_after_login').$param); |
|
|
|
header('location: '.api_get_path(WEB_PATH).api_get_setting('page_after_login').$param); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
// here is the main redirect of a *normal* login page in Dokeos |
|
|
|
// here is the main redirect of a *normal* login page in Dokeos |
|
|
|
header('location: '.api_get_path(WEB_PATH).api_get_setting('page_after_login')); |
|
|
|
header('location: '.api_get_path(WEB_PATH).api_get_setting('page_after_login')); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// login failed, Database::num_rows($result) <= 0 |
|
|
|
// login failed, Database::num_rows($result) <= 0 |
|
|
|
@ -475,7 +468,6 @@ if (api_get_setting('allow_terms_conditions')=='true') { |
|
|
|
api_session_register('_user'); |
|
|
|
api_session_register('_user'); |
|
|
|
event_login(); |
|
|
|
event_login(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Redirect to homepage |
|
|
|
// Redirect to homepage |
|
|
|
$sso_target = isset($sso['target']) ? $sso['target'] : api_get_path(WEB_PATH) .'.index.php'; |
|
|
|
$sso_target = isset($sso['target']) ? $sso['target'] : api_get_path(WEB_PATH) .'.index.php'; |
|
|
|
header('Location: '. $sso_target); |
|
|
|
header('Location: '. $sso_target); |
|
|
|
@ -497,9 +489,7 @@ if (api_get_setting('allow_terms_conditions')=='true') { |
|
|
|
//single URL access |
|
|
|
//single URL access |
|
|
|
$_user['user_id'] = $uData['user_id']; |
|
|
|
$_user['user_id'] = $uData['user_id']; |
|
|
|
api_session_register('_user'); |
|
|
|
api_session_register('_user'); |
|
|
|
|
|
|
|
|
|
|
|
event_login(); |
|
|
|
event_login(); |
|
|
|
|
|
|
|
|
|
|
|
// Redirect to homepage |
|
|
|
// Redirect to homepage |
|
|
|
$sso_target = isset($sso['target']) ? $sso['target'] : api_get_path(WEB_PATH) .'.index.php'; |
|
|
|
$sso_target = isset($sso['target']) ? $sso['target'] : api_get_path(WEB_PATH) .'.index.php'; |
|
|
|
header('Location: '. $sso_target); |
|
|
|
header('Location: '. $sso_target); |
|
|
|
@ -554,8 +544,8 @@ if (api_get_setting('allow_terms_conditions')=='true') { |
|
|
|
openid_begin(trim($_POST['openid_url']),api_get_path(WEB_PATH).'index.php'); |
|
|
|
openid_begin(trim($_POST['openid_url']),api_get_path(WEB_PATH).'index.php'); |
|
|
|
//this last function should trigger a redirect, so we can die here safely |
|
|
|
//this last function should trigger a redirect, so we can die here safely |
|
|
|
die('Openid login redirection should be in progress'); |
|
|
|
die('Openid login redirection should be in progress'); |
|
|
|
} elseif (!empty($_GET['openid_identity'])) |
|
|
|
} elseif (!empty($_GET['openid_identity'])) { |
|
|
|
{ //it's usual for PHP to replace '.' (dot) by '_' (underscore) in URL parameters |
|
|
|
//it's usual for PHP to replace '.' (dot) by '_' (underscore) in URL parameters |
|
|
|
include('main/auth/openid/login.php'); |
|
|
|
include('main/auth/openid/login.php'); |
|
|
|
$res = openid_complete($_GET); |
|
|
|
$res = openid_complete($_GET); |
|
|
|
if ($res['status'] == 'success') { |
|
|
|
if ($res['status'] == 'success') { |
|
|
|
@ -583,9 +573,7 @@ if (api_get_setting('allow_terms_conditions')=='true') { |
|
|
|
if ($uData['expiration_date']>date('Y-m-d H:i:s') OR $uData['expiration_date']=='0000-00-00 00:00:00') { |
|
|
|
if ($uData['expiration_date']>date('Y-m-d H:i:s') OR $uData['expiration_date']=='0000-00-00 00:00:00') { |
|
|
|
$_user['user_id'] = $uData['user_id']; |
|
|
|
$_user['user_id'] = $uData['user_id']; |
|
|
|
api_session_register('_user'); |
|
|
|
api_session_register('_user'); |
|
|
|
|
|
|
|
|
|
|
|
event_login(); |
|
|
|
event_login(); |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$loginFailed = true; |
|
|
|
$loginFailed = true; |
|
|
|
api_session_unregister('_uid'); |
|
|
|
api_session_unregister('_uid'); |
|
|
|
@ -598,9 +586,7 @@ if (api_get_setting('allow_terms_conditions')=='true') { |
|
|
|
header('Location: index.php?loginFailed=1&error=account_inactive'); |
|
|
|
header('Location: index.php?loginFailed=1&error=account_inactive'); |
|
|
|
exit; |
|
|
|
exit; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (isset($uData['creator_id']) && $_user['user_id'] != $uData['creator_id']) { |
|
|
|
if (isset($uData['creator_id']) && $_user['user_id'] != $uData['creator_id']) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
//first login for a not self registred |
|
|
|
//first login for a not self registred |
|
|
|
//e.g. registered by a teacher |
|
|
|
//e.g. registered by a teacher |
|
|
|
//do nothing (code may be added later) |
|
|
|
//do nothing (code may be added later) |
|
|
|
@ -670,8 +656,7 @@ if (isset($uidReset) && $uidReset) // session data refresh requested |
|
|
|
$user_table = Database::get_main_table(TABLE_MAIN_USER); |
|
|
|
$user_table = Database::get_main_table(TABLE_MAIN_USER); |
|
|
|
$admin_table = Database::get_main_table(TABLE_MAIN_ADMIN); |
|
|
|
$admin_table = Database::get_main_table(TABLE_MAIN_ADMIN); |
|
|
|
if ($_configuration['tracking_enabled']) { |
|
|
|
if ($_configuration['tracking_enabled']) { |
|
|
|
$sql = "SELECT user.*, a.user_id is_admin, |
|
|
|
$sql = "SELECT user.*, a.user_id is_admin, UNIX_TIMESTAMP(login.login_date) login_date |
|
|
|
UNIX_TIMESTAMP(login.login_date) login_date |
|
|
|
|
|
|
|
FROM $user_table |
|
|
|
FROM $user_table |
|
|
|
LEFT JOIN $admin_table a |
|
|
|
LEFT JOIN $admin_table a |
|
|
|
ON user.user_id = a.user_id |
|
|
|
ON user.user_id = a.user_id |
|
|
|
@ -779,7 +764,7 @@ if (isset($cidReset) && $cidReset) { // course session data refresh requested or |
|
|
|
$tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
|
|
|
$tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
|
|
|
|
|
|
|
|
|
|
|
if (!empty($_GET['id_session'])) { |
|
|
|
if (!empty($_GET['id_session'])) { |
|
|
|
$_SESSION['id_session'] = Database::escape_string($_GET['id_session']); |
|
|
|
$_SESSION['id_session'] = intval($_GET['id_session']); |
|
|
|
$sql = 'SELECT name FROM '.$tbl_session . ' WHERE id="'.intval($_SESSION['id_session']) . '"'; |
|
|
|
$sql = 'SELECT name FROM '.$tbl_session . ' WHERE id="'.intval($_SESSION['id_session']) . '"'; |
|
|
|
$rs = Database::query($sql); |
|
|
|
$rs = Database::query($sql); |
|
|
|
list($_SESSION['session_name']) = Database::fetch_array($rs); |
|
|
|
list($_SESSION['session_name']) = Database::fetch_array($rs); |
|
|
|
@ -797,7 +782,6 @@ if (isset($cidReset) && $cidReset) { // course session data refresh requested or |
|
|
|
"VALUES('".$_course['sysCode']."', '".$_user['user_id']."', '$time', '$time', '1', ".api_get_session_id().")"; |
|
|
|
"VALUES('".$_course['sysCode']."', '".$_user['user_id']."', '$time', '$time', '1', ".api_get_session_id().")"; |
|
|
|
Database::query($sql); |
|
|
|
Database::query($sql); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
//exit("WARNING UNDEFINED CID !! "); |
|
|
|
//exit("WARNING UNDEFINED CID !! "); |
|
|
|
header('location:'.api_get_path(WEB_PATH)); |
|
|
|
header('location:'.api_get_path(WEB_PATH)); |
|
|
|
@ -819,7 +803,7 @@ if (isset($cidReset) && $cidReset) { // course session data refresh requested or |
|
|
|
// Moreover, if we want to track a course with another session it can be usefull |
|
|
|
// Moreover, if we want to track a course with another session it can be usefull |
|
|
|
if (!empty($_GET['id_session'])) { |
|
|
|
if (!empty($_GET['id_session'])) { |
|
|
|
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); |
|
|
|
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); |
|
|
|
$_SESSION['id_session'] = Database::escape_string($_GET['id_session']); |
|
|
|
$_SESSION['id_session'] = intval($_GET['id_session']); |
|
|
|
$sql = 'SELECT name FROM '.$tbl_session . ' WHERE id="'.intval($_SESSION['id_session']). '"'; |
|
|
|
$sql = 'SELECT name FROM '.$tbl_session . ' WHERE id="'.intval($_SESSION['id_session']). '"'; |
|
|
|
$rs = Database::query($sql); |
|
|
|
$rs = Database::query($sql); |
|
|
|
list($_SESSION['session_name']) = Database::fetch_array($rs); |
|
|
|
list($_SESSION['session_name']) = Database::fetch_array($rs); |
|
|
|
|