2010-12-02 23:34:41 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* authentication.php
|
|
|
|
|
*
|
|
|
|
|
* ProcessMaker Open Source Edition
|
|
|
|
|
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* 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 Affero General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*
|
|
|
|
|
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
|
|
|
|
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
try {
|
2015-11-27 15:38:27 -04:00
|
|
|
$usr = '';
|
|
|
|
|
$pwd = '';
|
|
|
|
|
|
|
|
|
|
if (strpos($_SERVER['HTTP_REFERER'], 'home/login') !== false) {
|
|
|
|
|
$urlLogin = '../home/login';
|
|
|
|
|
} else {
|
|
|
|
|
$urlLogin = (substr(SYS_SKIN, 0, 2) !== 'ux')? 'login' : '../main/login';
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-04 19:01:31 -04:00
|
|
|
if (!$RBAC->singleSignOn) {
|
2016-03-23 18:23:20 -04:00
|
|
|
setcookie("singleSignOn", '0', time() + (24 * 60 * 60), '/');
|
2012-07-04 19:01:31 -04:00
|
|
|
if (!isset($_POST['form']) ) {
|
|
|
|
|
G::SendTemporalMessage ('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error');
|
|
|
|
|
G::header('Location: login');
|
|
|
|
|
die();
|
|
|
|
|
}
|
2011-08-24 19:30:03 -04:00
|
|
|
|
2012-07-04 19:01:31 -04:00
|
|
|
$frm = $_POST['form'];
|
2011-08-24 19:34:44 -04:00
|
|
|
|
2012-07-04 19:01:31 -04:00
|
|
|
if (isset($frm['USR_USERNAME'])) {
|
2013-01-02 11:53:19 -04:00
|
|
|
$usr = mb_strtolower(trim($frm['USR_USERNAME']), 'UTF-8');
|
2012-07-04 19:01:31 -04:00
|
|
|
$pwd = trim($frm['USR_PASSWORD']);
|
|
|
|
|
}
|
2014-11-24 11:06:28 -04:00
|
|
|
/*----------------------------------********---------------------------------*/
|
2014-09-22 09:58:50 -04:00
|
|
|
require_once PATH_CORE . 'methods' . PATH_SEP . 'enterprise' . PATH_SEP . 'enterprise.php';
|
|
|
|
|
|
|
|
|
|
if (!file_exists(PATH_DATA_SITE . "plugin.singleton")) {
|
2014-09-25 16:55:16 -04:00
|
|
|
$enterprise = new enterprisePlugin('enterprise');
|
2014-09-22 09:58:50 -04:00
|
|
|
$enterprise->enable();
|
2014-09-25 16:55:16 -04:00
|
|
|
$enterprise->setup();
|
2014-09-22 09:58:50 -04:00
|
|
|
}
|
2014-11-24 11:06:28 -04:00
|
|
|
/*----------------------------------********---------------------------------*/
|
2012-07-04 19:01:31 -04:00
|
|
|
$uid = $RBAC->VerifyLogin($usr , $pwd);
|
|
|
|
|
$RBAC->cleanSessionFiles(72); //cleaning session files older than 72 hours
|
|
|
|
|
|
|
|
|
|
switch ($uid) {
|
|
|
|
|
//The user does doesn't exist
|
|
|
|
|
case -1:
|
2013-03-04 11:32:49 -04:00
|
|
|
$errLabel = 'WRONG_LOGIN_CREDENTIALS';
|
2012-07-04 19:01:31 -04:00
|
|
|
break;
|
|
|
|
|
//The password is incorrect
|
|
|
|
|
case -2:
|
2013-03-04 11:32:49 -04:00
|
|
|
$errLabel = 'WRONG_LOGIN_CREDENTIALS';
|
2012-07-04 19:01:31 -04:00
|
|
|
if (isset($_SESSION['__AUTH_ERROR__'])) {
|
|
|
|
|
G::SendMessageText($_SESSION['__AUTH_ERROR__'], "warning");
|
|
|
|
|
unset($_SESSION['__AUTH_ERROR__']);
|
2014-07-03 10:32:25 -04:00
|
|
|
}
|
2012-07-04 19:01:31 -04:00
|
|
|
break;
|
|
|
|
|
//The user is inactive
|
|
|
|
|
case -3:
|
|
|
|
|
require_once 'classes/model/Users.php';
|
2012-09-13 14:54:38 -04:00
|
|
|
$user = new Users();
|
2012-07-04 19:01:31 -04:00
|
|
|
$aUser = $user->loadByUsernameInArray($usr);
|
2012-02-24 19:32:24 -04:00
|
|
|
|
2012-07-04 19:01:31 -04:00
|
|
|
switch ($aUser['USR_STATUS']) {
|
|
|
|
|
case 'VACATION':
|
2012-09-13 14:54:38 -04:00
|
|
|
$uid = $aUser['USR_UID'];
|
|
|
|
|
$RBAC->changeUserStatus($uid, 1);
|
|
|
|
|
$aUser['USR_STATUS'] = 'ACTIVE';
|
|
|
|
|
$user->update($aUser);
|
2012-07-04 19:01:31 -04:00
|
|
|
break;
|
|
|
|
|
case 'INACTIVE':
|
|
|
|
|
$errLabel = 'ID_USER_INACTIVE';
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
//The Due date is finished
|
|
|
|
|
case -4:
|
|
|
|
|
$errLabel = 'ID_USER_INACTIVE_BY_DATE';
|
|
|
|
|
break;
|
|
|
|
|
case -5:
|
|
|
|
|
$errLabel = 'ID_AUTHENTICATION_SOURCE_INVALID';
|
|
|
|
|
break;
|
2013-12-09 14:58:41 -04:00
|
|
|
case -6:
|
|
|
|
|
$errLabel = 'ID_ROLE_INACTIVE';
|
|
|
|
|
break;
|
2014-12-03 13:42:09 -04:00
|
|
|
case -7:
|
|
|
|
|
$errLabel = 'ID_LECA';
|
|
|
|
|
break;
|
2011-08-24 19:30:03 -04:00
|
|
|
}
|
2012-02-24 19:32:24 -04:00
|
|
|
|
2012-07-04 19:01:31 -04:00
|
|
|
//to avoid empty string in user field. This will avoid a weird message "this row doesn't exist"
|
|
|
|
|
if ( !isset($uid) ) {
|
|
|
|
|
$uid = -1;
|
2013-03-04 11:32:49 -04:00
|
|
|
$errLabel = 'WRONG_LOGIN_CREDENTIALS';
|
2011-08-24 19:30:03 -04:00
|
|
|
}
|
2012-02-24 19:32:24 -04:00
|
|
|
|
2014-09-23 17:16:31 -04:00
|
|
|
$_SESSION["USERNAME_PREVIOUS1"] = (isset($_SESSION["USERNAME_PREVIOUS2"]))? $_SESSION["USERNAME_PREVIOUS2"] : "";
|
2014-09-19 10:45:24 -04:00
|
|
|
$_SESSION["USERNAME_PREVIOUS2"] = $usr;
|
2016-09-15 11:53:35 -04:00
|
|
|
$_SESSION["FAILED_LOGINS"] = (isset($frm['FAILED_LOGINS']))? $frm['FAILED_LOGINS'] : 0;
|
2014-09-19 10:45:24 -04:00
|
|
|
|
2012-07-04 19:01:31 -04:00
|
|
|
if (!isset($uid) || $uid < 0) {
|
2014-09-19 10:45:24 -04:00
|
|
|
if ($_SESSION["USERNAME_PREVIOUS1"] != "" && $_SESSION["USERNAME_PREVIOUS2"] != "" && $_SESSION["USERNAME_PREVIOUS1"] != $_SESSION["USERNAME_PREVIOUS2"]) {
|
|
|
|
|
$_SESSION["FAILED_LOGINS"] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-11 12:07:24 -04:00
|
|
|
if (isset($_SESSION['FAILED_LOGINS']) && ($uid == -1 || $uid == -2)) {
|
2012-07-04 19:01:31 -04:00
|
|
|
$_SESSION['FAILED_LOGINS']++;
|
|
|
|
|
}
|
|
|
|
|
if (!defined('PPP_FAILED_LOGINS')) {
|
|
|
|
|
define('PPP_FAILED_LOGINS', 0);
|
|
|
|
|
}
|
|
|
|
|
if (PPP_FAILED_LOGINS > 0) {
|
|
|
|
|
if ($_SESSION['FAILED_LOGINS'] >= PPP_FAILED_LOGINS) {
|
|
|
|
|
$oConnection = Propel::getConnection('rbac');
|
2014-09-17 10:57:33 -04:00
|
|
|
$oStatement = $oConnection->prepareStatement("SELECT USR_UID FROM RBAC_USERS WHERE USR_USERNAME = '" . $usr . "'");
|
2012-07-04 19:01:31 -04:00
|
|
|
$oDataset = $oStatement->executeQuery();
|
|
|
|
|
if ($oDataset->next()) {
|
|
|
|
|
$sUserUID = $oDataset->getString('USR_UID');
|
|
|
|
|
$oConnection = Propel::getConnection('rbac');
|
2014-09-17 10:57:33 -04:00
|
|
|
$oStatement = $oConnection->prepareStatement("UPDATE RBAC_USERS SET USR_STATUS = 0 WHERE USR_UID = '" . $sUserUID . "'");
|
2012-07-04 19:01:31 -04:00
|
|
|
$oStatement->executeQuery();
|
|
|
|
|
$oConnection = Propel::getConnection('workflow');
|
|
|
|
|
$oStatement = $oConnection->prepareStatement("UPDATE USERS SET USR_STATUS = 'INACTIVE' WHERE USR_UID = '" . $sUserUID . "'");
|
|
|
|
|
$oStatement->executeQuery();
|
|
|
|
|
unset($_SESSION['FAILED_LOGINS']);
|
2014-07-11 12:07:24 -04:00
|
|
|
$errLabel = G::LoadTranslation('ID_ACCOUNT') . ' "' . $usr . '" ' . G::LoadTranslation('ID_ACCOUNT_DISABLED_CONTACT_ADMIN');
|
2012-07-04 19:01:31 -04:00
|
|
|
}
|
2014-07-11 12:07:24 -04:00
|
|
|
//Log failed authentications
|
|
|
|
|
$message = "| Many failed authentication attempts for USER: " . $usr . " | IP: " . G::getIpAddress() . " | WS: " . SYS_SYS;
|
2014-10-03 11:09:45 -04:00
|
|
|
$message .= " | BROWSER: " . $_SERVER['HTTP_USER_AGENT'];
|
2014-07-11 12:07:24 -04:00
|
|
|
|
|
|
|
|
G::log($message, PATH_DATA, 'loginFailed.log');
|
2012-07-04 19:01:31 -04:00
|
|
|
}
|
|
|
|
|
}
|
2011-08-24 19:30:03 -04:00
|
|
|
|
2012-07-04 19:01:31 -04:00
|
|
|
if (strpos($_SERVER['HTTP_REFERER'], 'home/login') !== false) {
|
2015-11-27 15:38:27 -04:00
|
|
|
$d = serialize(['u' => $usr, 'p' => $pwd, 'm' => G::LoadTranslation($errLabel)]);
|
|
|
|
|
$urlLogin = $urlLogin . '?d=' . base64_encode($d);
|
2012-07-04 19:01:31 -04:00
|
|
|
} else {
|
|
|
|
|
G::SendTemporalMessage($errLabel, "warning");
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-17 17:04:14 -04:00
|
|
|
$u = (array_key_exists('form', $_POST) && array_key_exists('URL', $_POST['form']))? 'u=' . urlencode(htmlspecialchars_decode($_POST['form']['URL'])) : '';
|
2016-07-28 18:27:20 -04:00
|
|
|
|
|
|
|
|
if ($u != '') {
|
|
|
|
|
$urlLogin = $urlLogin . ((preg_match('/^.+\?.+$/', $urlLogin))? '&' : '?') . $u;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-27 15:38:27 -04:00
|
|
|
G::header('Location: ' . $urlLogin);
|
|
|
|
|
exit(0);
|
2012-03-29 16:42:09 -04:00
|
|
|
}
|
2012-02-24 19:32:24 -04:00
|
|
|
|
2012-07-04 19:01:31 -04:00
|
|
|
if (!isset( $_SESSION['WORKSPACE'] ) ) {
|
|
|
|
|
$_SESSION['WORKSPACE'] = SYS_SYS;
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-07-04 19:01:31 -04:00
|
|
|
//Execute the SSO Script from plugin
|
|
|
|
|
$oPluginRegistry =& PMPluginRegistry::getSingleton();
|
2014-09-25 16:55:16 -04:00
|
|
|
$lSession="";
|
|
|
|
|
$loginInfo = new loginInfo ($usr, $pwd, $lSession );
|
2012-07-04 19:01:31 -04:00
|
|
|
if ($oPluginRegistry->existsTrigger ( PM_LOGIN )) {
|
|
|
|
|
$oPluginRegistry->executeTriggers ( PM_LOGIN , $loginInfo );
|
|
|
|
|
}
|
2014-09-25 16:55:16 -04:00
|
|
|
G::LoadClass("enterprise");
|
|
|
|
|
enterpriseClass::enterpriseSystemUpdate($loginInfo);
|
2012-07-04 19:01:31 -04:00
|
|
|
$_SESSION['USER_LOGGED'] = $uid;
|
|
|
|
|
$_SESSION['USR_USERNAME'] = $usr;
|
|
|
|
|
} else {
|
2016-03-23 18:23:20 -04:00
|
|
|
setcookie("singleSignOn", '1', time() + (24 * 60 * 60), '/');
|
2012-07-04 19:01:31 -04:00
|
|
|
$uid = $RBAC->userObj->fields['USR_UID'];
|
|
|
|
|
$usr = $RBAC->userObj->fields['USR_USERNAME'];
|
|
|
|
|
$_SESSION['USER_LOGGED'] = $uid;
|
|
|
|
|
$_SESSION['USR_USERNAME'] = $usr;
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
2015-12-09 17:33:31 -04:00
|
|
|
//Set default Languaje
|
|
|
|
|
if (isset($frm['USER_LANG'])) {
|
|
|
|
|
if ($frm['USER_LANG'] != '') {
|
|
|
|
|
$lang = $frm['USER_LANG'];
|
|
|
|
|
if($frm['USER_LANG'] == "default"){
|
|
|
|
|
//Check the USR_DEFAULT_LANG
|
|
|
|
|
require_once 'classes/model/Users.php';
|
|
|
|
|
$user = new Users();
|
|
|
|
|
$rsUser = $user->userLanguaje($_SESSION['USER_LOGGED']);
|
|
|
|
|
$rsUser->next();
|
|
|
|
|
$rowUser = $rsUser->getRow();
|
|
|
|
|
if( isset($rowUser["USR_DEFAULT_LANG"]) && $rowUser["USR_DEFAULT_LANG"]!=''){
|
|
|
|
|
$lang = $rowUser["USR_DEFAULT_LANG"];
|
|
|
|
|
} else {
|
|
|
|
|
//Check the login_defaultLanguage
|
|
|
|
|
$oConf = new Configurations();
|
|
|
|
|
$oConf->loadConfig($obj, 'ENVIRONMENT_SETTINGS', '');
|
|
|
|
|
if (isset($oConf->aConfig["login_defaultLanguage"]) && $oConf->aConfig["login_defaultLanguage"] != "") {
|
|
|
|
|
$lang = $oConf->aConfig["login_defaultLanguage"];
|
|
|
|
|
}else{
|
|
|
|
|
if(SYS_LANG != ''){
|
|
|
|
|
$lang = SYS_LANG;
|
|
|
|
|
}else{
|
|
|
|
|
$lang = 'en';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$lang = $frm['USER_LANG'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (defined("SYS_LANG") && SYS_LANG != "") {
|
|
|
|
|
$lang = SYS_LANG;
|
|
|
|
|
} else {
|
|
|
|
|
$lang = 'en';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 16:43:45 -04:00
|
|
|
/*----------------------------------********---------------------------------*/
|
|
|
|
|
if (PMLicensedFeatures::getSingleton()->verifyfeature('oq3S29xemxEZXJpZEIzN01qenJUaStSekY4cTdJVm5vbWtVM0d4S2lJSS9qUT0=')) {
|
|
|
|
|
//Update User Time Zone
|
|
|
|
|
if (isset($_POST['form']['BROWSER_TIME_ZONE'])) {
|
|
|
|
|
$user = new Users();
|
|
|
|
|
$user->update(['USR_UID' => $_SESSION['USER_LOGGED'], 'USR_TIME_ZONE' => $_POST['form']['BROWSER_TIME_ZONE']]);
|
|
|
|
|
}
|
2015-11-27 15:38:27 -04:00
|
|
|
}
|
2015-12-04 16:43:45 -04:00
|
|
|
/*----------------------------------********---------------------------------*/
|
2015-11-27 15:38:27 -04:00
|
|
|
|
2015-11-26 20:11:58 -04:00
|
|
|
//Set User Time Zone
|
|
|
|
|
$user = UsersPeer::retrieveByPK($_SESSION['USER_LOGGED']);
|
|
|
|
|
|
|
|
|
|
if (!is_null($user)) {
|
|
|
|
|
$userTimeZone = $user->getUsrTimeZone();
|
|
|
|
|
|
|
|
|
|
if (trim($userTimeZone) == '') {
|
|
|
|
|
$arraySystemConfiguration = System::getSystemConfiguration('', '', SYS_SYS);
|
|
|
|
|
|
|
|
|
|
$userTimeZone = $arraySystemConfiguration['time_zone'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$_SESSION['USR_TIME_ZONE'] = $userTimeZone;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 16:43:45 -04:00
|
|
|
/*----------------------------------********---------------------------------*/
|
|
|
|
|
if (PMLicensedFeatures::getSingleton()->verifyfeature('oq3S29xemxEZXJpZEIzN01qenJUaStSekY4cTdJVm5vbWtVM0d4S2lJSS9qUT0=')) {
|
|
|
|
|
if (isset($_SESSION['__SYSTEM_UTC_TIME_ZONE__']) && $_SESSION['__SYSTEM_UTC_TIME_ZONE__']) {
|
|
|
|
|
$dateTime = new \ProcessMaker\Util\DateTime();
|
2015-11-27 15:38:27 -04:00
|
|
|
|
2015-12-04 16:43:45 -04:00
|
|
|
$timeZoneOffset = $dateTime->getTimeZoneOffsetByTimeZoneId($_SESSION['USR_TIME_ZONE']);
|
2015-11-27 15:38:27 -04:00
|
|
|
|
2015-12-04 16:43:45 -04:00
|
|
|
if ($timeZoneOffset === false || $timeZoneOffset != (int)($_POST['form']['BROWSER_TIME_ZONE_OFFSET'])) {
|
|
|
|
|
$_SESSION['__TIME_ZONE_FAILED__'] = true;
|
|
|
|
|
$_SESSION['USR_USERNAME'] = $usr;
|
|
|
|
|
$_SESSION['USR_PASSWORD'] = $pwd;
|
2015-11-27 15:38:27 -04:00
|
|
|
|
2015-12-04 16:43:45 -04:00
|
|
|
$_SESSION['BROWSER_TIME_ZONE'] = $dateTime->getTimeZoneIdByTimeZoneOffset((int)($_POST['form']['BROWSER_TIME_ZONE_OFFSET']), false);
|
2016-05-19 14:52:24 -04:00
|
|
|
$_SESSION['URL'] = (isset($_POST['form']['URL']))? $_POST['form']['URL'] : ((isset($_REQUEST['u']))? $_REQUEST['u'] : '');
|
2015-12-09 17:33:31 -04:00
|
|
|
$_SESSION['USER_LANG'] = $lang;
|
|
|
|
|
|
2015-12-04 16:43:45 -04:00
|
|
|
if (strpos($_SERVER['HTTP_REFERER'], 'home/login') !== false) {
|
2015-12-09 17:33:31 -04:00
|
|
|
$d = serialize(['u' => $usr, 'p' => $pwd, 'm' => '', 'timeZoneFailed' => 1, 'userTimeZone' => $_SESSION['USR_TIME_ZONE'], 'browserTimeZone' => $_SESSION['BROWSER_TIME_ZONE'],'USER_LANG' => $lang]);
|
2015-12-04 16:43:45 -04:00
|
|
|
$urlLogin = $urlLogin . '?d=' . base64_encode($d);
|
|
|
|
|
}
|
2015-11-27 15:38:27 -04:00
|
|
|
|
2015-12-04 16:43:45 -04:00
|
|
|
G::header('Location: ' . $urlLogin);
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
2015-11-27 15:38:27 -04:00
|
|
|
}
|
|
|
|
|
}
|
2015-12-04 16:43:45 -04:00
|
|
|
/*----------------------------------********---------------------------------*/
|
2015-11-27 15:38:27 -04:00
|
|
|
|
2015-11-26 20:11:58 -04:00
|
|
|
//Set data
|
2012-07-04 19:01:31 -04:00
|
|
|
$aUser = $RBAC->userObj->load($_SESSION['USER_LOGGED']);
|
|
|
|
|
$RBAC->loadUserRolePermission($RBAC->sSystem, $_SESSION['USER_LOGGED']);
|
|
|
|
|
//$rol = $RBAC->rolesObj->load($RBAC->aUserInfo['PROCESSMAKER']['ROLE']['ROL_UID']);
|
|
|
|
|
$_SESSION['USR_FULLNAME'] = $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'];
|
|
|
|
|
//$_SESSION['USR_ROLENAME'] = $rol['ROL_NAME'];
|
2011-08-24 19:30:03 -04:00
|
|
|
|
2012-07-04 19:01:31 -04:00
|
|
|
unset($_SESSION['FAILED_LOGINS']);
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-07-04 19:01:31 -04:00
|
|
|
// increment logins in heartbeat
|
|
|
|
|
G::LoadClass('serverConfiguration');
|
|
|
|
|
$oServerConf =& serverConf::getSingleton();
|
|
|
|
|
$oServerConf->sucessfulLogin();
|
2011-08-24 19:30:03 -04:00
|
|
|
|
2012-07-04 19:01:31 -04:00
|
|
|
// Assign the uid of user to userloggedobj
|
|
|
|
|
$RBAC->loadUserRolePermission($RBAC->sSystem, $uid);
|
|
|
|
|
$res = $RBAC->userCanAccess('PM_LOGIN');
|
|
|
|
|
if ($res != 1 ) {
|
|
|
|
|
if ($res == -2) {
|
|
|
|
|
G::SendTemporalMessage ('ID_USER_HAVENT_RIGHTS_SYSTEM', "error");
|
|
|
|
|
} else {
|
|
|
|
|
G::SendTemporalMessage ('ID_USER_HAVENT_RIGHTS_PAGE', "error");
|
|
|
|
|
}
|
|
|
|
|
G::header ("location: login.html");
|
|
|
|
|
die;
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-07-04 19:01:31 -04:00
|
|
|
|
|
|
|
|
/**log in table Login**/
|
|
|
|
|
require_once 'classes/model/LoginLog.php';
|
|
|
|
|
$weblog=new LoginLog();
|
|
|
|
|
$aLog['LOG_UID'] = G::generateUniqueID();
|
|
|
|
|
$aLog['LOG_STATUS'] = 'ACTIVE';
|
2014-03-27 10:09:35 -04:00
|
|
|
$aLog['LOG_IP'] = G::getIpAddress();
|
2012-07-04 19:01:31 -04:00
|
|
|
$aLog['LOG_SID'] = session_id();
|
|
|
|
|
$aLog['LOG_INIT_DATE'] = date('Y-m-d H:i:s');
|
|
|
|
|
//$aLog['LOG_END_DATE'] = '0000-00-00 00:00:00';
|
|
|
|
|
$aLog['LOG_CLIENT_HOSTNAME']= $_SERVER['HTTP_HOST'];
|
|
|
|
|
$aLog['USR_UID'] = $_SESSION['USER_LOGGED'];
|
|
|
|
|
$weblog->create($aLog);
|
|
|
|
|
/**end log**/
|
2011-08-24 19:30:03 -04:00
|
|
|
|
2012-07-04 19:01:31 -04:00
|
|
|
//************** background processes, here we are putting some back office routines **********
|
2012-09-24 14:44:08 -04:00
|
|
|
$heartBeatNWIDate = $oServerConf->getHeartbeatProperty('HB_NEXT_GWI_DATE','HEART_BEAT_CONF');
|
|
|
|
|
if (is_null($heartBeatNWIDate)) {
|
2012-10-16 18:08:45 +00:00
|
|
|
$heartBeatNWIDate = time();
|
2012-09-24 14:44:08 -04:00
|
|
|
}
|
|
|
|
|
if (time() >= $heartBeatNWIDate) {
|
2012-10-16 18:08:45 +00:00
|
|
|
$oServerConf->setHeartbeatProperty('HB_NEXT_GWI_DATE', strtotime('+1 day'), 'HEART_BEAT_CONF');
|
2012-09-24 14:44:08 -04:00
|
|
|
}
|
2011-08-24 19:30:03 -04:00
|
|
|
|
2012-07-04 19:01:31 -04:00
|
|
|
//**** defining and saving server info, this file has the values of the global array $_SERVER ****
|
|
|
|
|
//this file is useful for command line environment (no Browser), I mean for triggers, crons and other executed over command line
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-07-04 19:01:31 -04:00
|
|
|
$_CSERVER = $_SERVER;
|
|
|
|
|
unset($_CSERVER['REQUEST_TIME']);
|
|
|
|
|
unset($_CSERVER['REMOTE_PORT']);
|
|
|
|
|
$cput = serialize($_CSERVER);
|
2015-05-10 17:16:34 -04:00
|
|
|
if (!is_file(PATH_DATA_SITE . '.server_info')) {
|
|
|
|
|
file_put_contents(PATH_DATA_SITE . '.server_info', $cput);
|
2012-07-04 19:01:31 -04:00
|
|
|
} else {
|
2015-05-10 17:16:34 -04:00
|
|
|
$c = file_get_contents(PATH_DATA_SITE . '.server_info');
|
2015-03-25 16:22:18 -04:00
|
|
|
if (G::encryptOld($c) != G::encryptOld($cput)) {
|
2015-05-10 17:16:34 -04:00
|
|
|
file_put_contents(PATH_DATA_SITE . '.server_info', $cput);
|
2012-07-04 19:01:31 -04:00
|
|
|
}
|
2012-04-05 12:52:33 -04:00
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-07-04 19:01:31 -04:00
|
|
|
/* Check password using policy - Start */
|
|
|
|
|
require_once 'classes/model/UsersProperties.php';
|
|
|
|
|
$oUserProperty = new UsersProperties();
|
2011-10-11 18:33:06 -04:00
|
|
|
|
2012-07-04 19:01:31 -04:00
|
|
|
// getting default user location
|
|
|
|
|
if (isset($_REQUEST['form']['URL']) && $_REQUEST['form']['URL'] != '') {
|
2013-01-08 13:21:40 -04:00
|
|
|
if (isset($_SERVER['HTTP_REFERER'])) {
|
|
|
|
|
if (strpos($_SERVER['HTTP_REFERER'], 'processes/processes_Map?PRO_UID=') !== false) {
|
|
|
|
|
$sLocation = $_SERVER['HTTP_REFERER'];
|
|
|
|
|
} else {
|
2013-11-15 15:29:07 -04:00
|
|
|
$sLocation = G::sanitizeInput($_REQUEST['form']['URL']);
|
2013-01-08 13:21:40 -04:00
|
|
|
}
|
|
|
|
|
} else {
|
2013-11-15 15:29:07 -04:00
|
|
|
$sLocation = G::sanitizeInput($_REQUEST['form']['URL']);
|
2013-01-08 13:21:40 -04:00
|
|
|
}
|
2012-07-04 19:01:31 -04:00
|
|
|
} else {
|
|
|
|
|
if (isset($_REQUEST['u']) && $_REQUEST['u'] != '') {
|
2013-11-15 15:29:07 -04:00
|
|
|
$sLocation = G::sanitizeInput($_REQUEST['u']);
|
2012-07-04 19:01:31 -04:00
|
|
|
} else {
|
|
|
|
|
$sLocation = $oUserProperty->redirectTo($_SESSION['USER_LOGGED'], $lang);
|
|
|
|
|
}
|
2011-10-10 12:14:38 -04:00
|
|
|
}
|
2012-07-04 19:01:31 -04:00
|
|
|
|
|
|
|
|
if ($RBAC->singleSignOn) {
|
|
|
|
|
G::header('Location: ' . $sLocation);
|
|
|
|
|
die();
|
2011-10-10 12:14:38 -04:00
|
|
|
}
|
2012-04-05 12:52:33 -04:00
|
|
|
|
2015-03-25 16:22:18 -04:00
|
|
|
$aUserProperty = $oUserProperty->loadOrCreateIfNotExists($_SESSION['USER_LOGGED'], array('USR_PASSWORD_HISTORY' => serialize(array(G::encryptOld($pwd)))));
|
2014-06-12 16:02:32 -04:00
|
|
|
$aErrors = $oUserProperty->validatePassword($_POST['form']['USR_PASSWORD'], $aUserProperty['USR_LAST_UPDATE_DATE'], $aUserProperty['USR_LOGGED_NEXT_TIME'], true);
|
2011-08-24 19:30:03 -04:00
|
|
|
|
2014-06-12 17:46:42 -04:00
|
|
|
if (!empty($aErrors) && in_array("ID_PPP_CHANGE_PASSWORD_AFTER_NEXT_LOGIN", $aErrors)) {
|
2012-07-04 19:01:31 -04:00
|
|
|
if (!defined('NO_DISPLAY_USERNAME')) {
|
|
|
|
|
define('NO_DISPLAY_USERNAME', 1);
|
|
|
|
|
}
|
|
|
|
|
$aFields = array();
|
|
|
|
|
$aFields['DESCRIPTION'] = '<span style="font-weight:normal;">';
|
|
|
|
|
$aFields['DESCRIPTION'] .= G::LoadTranslation('ID_POLICY_ALERT').':<br /><br />';
|
|
|
|
|
foreach ($aErrors as $sError) {
|
|
|
|
|
switch ($sError) {
|
|
|
|
|
case 'ID_PPP_MINIMUM_LENGTH':
|
|
|
|
|
$aFields['DESCRIPTION'] .= ' - ' . G::LoadTranslation($sError).': ' . PPP_MINIMUM_LENGTH . '<br />';
|
|
|
|
|
$aFields[substr($sError, 3)] = PPP_MINIMUM_LENGTH;
|
2014-05-15 10:25:10 -04:00
|
|
|
$aFields['PPP_MINIMUN_LENGTH'] = PPP_MINIMUM_LENGTH;
|
2012-07-04 19:01:31 -04:00
|
|
|
break;
|
|
|
|
|
case 'ID_PPP_MAXIMUM_LENGTH':
|
|
|
|
|
$aFields['DESCRIPTION'] .= ' - ' . G::LoadTranslation($sError).': ' . PPP_MAXIMUM_LENGTH . '<br />';
|
|
|
|
|
$aFields[substr($sError, 3)] = PPP_MAXIMUM_LENGTH;
|
2014-05-15 10:25:10 -04:00
|
|
|
$aFields['PPP_MAXIMUN_LENGTH'] = PPP_MAXIMUM_LENGTH;
|
2012-07-04 19:01:31 -04:00
|
|
|
break;
|
|
|
|
|
case 'ID_PPP_EXPIRATION_IN':
|
|
|
|
|
$aFields['DESCRIPTION'] .= ' - ' . G::LoadTranslation($sError).' ' . PPP_EXPIRATION_IN . ' ' . G::LoadTranslation('ID_DAYS') . '<br />';
|
|
|
|
|
$aFields[substr($sError, 3)] = PPP_EXPIRATION_IN;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
$aFields['DESCRIPTION'] .= ' - ' . G::LoadTranslation($sError).'<br />';
|
|
|
|
|
$aFields[substr($sError, 3)] = 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$aFields['DESCRIPTION'] .= '<br />' . G::LoadTranslation('ID_PLEASE_CHANGE_PASSWORD_POLICY') . '<br /><br /></span>';
|
|
|
|
|
$G_PUBLISH = new Publisher;
|
2015-09-25 19:55:26 -04:00
|
|
|
$version = explode('.', trim(file_get_contents(PATH_GULLIVER . 'VERSION')));
|
|
|
|
|
$version = isset($version[0]) ? intval($version[0]) : 0;
|
|
|
|
|
if ($version >= 3) {
|
2015-05-07 17:13:45 -04:00
|
|
|
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/changePasswordpm3', '', $aFields, 'changePassword');
|
|
|
|
|
}else{
|
|
|
|
|
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/changePassword', '', $aFields, 'changePassword');
|
|
|
|
|
}
|
2012-07-04 19:01:31 -04:00
|
|
|
G::RenderPage('publish');
|
|
|
|
|
die;
|
2012-04-05 12:52:33 -04:00
|
|
|
}
|
|
|
|
|
|
2016-03-08 18:37:38 -04:00
|
|
|
$configS = System::getSystemConfiguration('', '', SYS_SYS);
|
2016-03-15 11:54:22 -04:00
|
|
|
$activeSession = isset($configS['session_block']) ? !(int)$configS['session_block']:true;
|
2016-03-08 18:37:38 -04:00
|
|
|
if ($activeSession){
|
|
|
|
|
setcookie("PM-TabPrimary", 101010010, time() + (24 * 60 * 60), '/');
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-23 12:12:50 -04:00
|
|
|
$oPluginRegistry =& PMPluginRegistry::getSingleton();
|
|
|
|
|
if ($oPluginRegistry->existsTrigger ( PM_AFTER_LOGIN )) {
|
|
|
|
|
$oPluginRegistry->executeTriggers ( PM_AFTER_LOGIN , $_SESSION['USER_LOGGED'] );
|
2014-07-23 09:20:31 -04:00
|
|
|
}
|
2014-07-23 12:12:50 -04:00
|
|
|
|
2017-06-19 16:21:40 -04:00
|
|
|
G::header('Location: ' . $sLocation);
|
2012-07-04 19:01:31 -04:00
|
|
|
die;
|
|
|
|
|
} catch ( Exception $e ) {
|
|
|
|
|
$aMessage['MESSAGE'] = $e->getMessage();
|
|
|
|
|
$G_PUBLISH = new Publisher;
|
|
|
|
|
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
|
|
|
|
|
G::RenderPage( 'publish' );
|
|
|
|
|
die;
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|