2011-06-03 18:40:51 -04:00
|
|
|
<?php
|
2017-08-14 16:13:46 -04:00
|
|
|
|
|
|
|
|
use ProcessMaker\Core\System;
|
|
|
|
|
|
2011-06-06 06:23:18 -04:00
|
|
|
$data = $_POST['form'];
|
2011-06-03 18:40:51 -04:00
|
|
|
global $RBAC;
|
2011-06-06 06:23:18 -04:00
|
|
|
|
|
|
|
|
$rbacUser = new RbacUsers();
|
|
|
|
|
$user = new Users();
|
2014-12-19 09:56:39 -04:00
|
|
|
$data['USR_USERNAME'] = strip_tags($data['USR_USERNAME']);
|
2020-08-19 16:45:08 -04:00
|
|
|
$data['USR_EMAIL'] = strtolower($data['USR_EMAIL']);
|
2011-06-06 06:23:18 -04:00
|
|
|
$userData = $rbacUser->getByUsername($data['USR_USERNAME']);
|
2018-01-18 12:41:16 -04:00
|
|
|
$userExists = $userData === false ? false : true;
|
2011-06-06 06:23:18 -04:00
|
|
|
|
2018-01-18 14:27:58 -04:00
|
|
|
if ($userExists === true && $userData['USR_EMAIL'] != '' && $userData['USR_EMAIL'] === $data['USR_EMAIL'] && ($userData['USR_AUTH_TYPE'] === '' || $userData['USR_AUTH_TYPE'] == 'MYSQL')) {
|
2018-04-04 09:21:59 -04:00
|
|
|
$setup = System::getEmailConfiguration();
|
|
|
|
|
if (count($setup) == 0 || !isset($setup['MESS_ENGINE'])) {
|
2018-01-18 12:41:16 -04:00
|
|
|
G::SendTemporalMessage('ID_EMAIL_ENGINE_IS_NOT_ENABLED', "warning");
|
2012-10-16 18:08:45 +00:00
|
|
|
G::header('location: forgotPassword');
|
|
|
|
|
die;
|
|
|
|
|
}
|
2012-07-25 18:47:13 -04:00
|
|
|
|
2012-10-16 18:08:45 +00:00
|
|
|
$newPass = G::generate_password();
|
|
|
|
|
|
2018-04-04 09:21:59 -04:00
|
|
|
$infoUser = [];
|
|
|
|
|
$infoUser['USR_UID'] = $userData['USR_UID'];
|
|
|
|
|
$infoUser['USR_PASSWORD'] = Bootstrap::hashPassword($newPass);
|
|
|
|
|
$userProperty = new UsersProperties();
|
|
|
|
|
$aUserPropertyData = $userProperty->load($infoUser['USR_UID']);
|
2016-04-13 15:41:31 -04:00
|
|
|
if (is_array($aUserPropertyData)) {
|
|
|
|
|
$aUserPropertyData['USR_LOGGED_NEXT_TIME'] = 1;
|
2018-04-04 09:21:59 -04:00
|
|
|
$userProperty = $userProperty->update($aUserPropertyData);
|
2016-04-13 15:41:31 -04:00
|
|
|
}
|
2014-04-29 15:18:46 -04:00
|
|
|
|
2018-04-04 09:21:59 -04:00
|
|
|
if (!isset($from)) {
|
|
|
|
|
$from = '';
|
2018-01-25 08:30:55 -04:00
|
|
|
}
|
2018-04-04 09:21:59 -04:00
|
|
|
$from = G::buildFrom($setup, $from);
|
2014-04-29 15:18:46 -04:00
|
|
|
|
2018-04-04 09:21:59 -04:00
|
|
|
$subject = G::LoadTranslation('ID_RESET_PASSWORD') . ' - ProcessMaker';
|
2012-10-16 18:08:45 +00:00
|
|
|
$msg = '<h3>ProcessMaker Forgot password Service</h3>';
|
2018-01-18 12:41:16 -04:00
|
|
|
$msg .= '<p>' . G::LoadTranslation('ID_YOUR_USERMANE_IS') . ' : <strong>' . $userData['USR_USERNAME'] . '</strong></p>';
|
|
|
|
|
$msg .= '<p>' . G::LoadTranslation('ID_YOUR_PASSWORD_IS') . ' : <strong>' . $newPass . '</strong></p>';
|
2018-04-04 09:21:59 -04:00
|
|
|
switch ($setup['MESS_ENGINE']) {
|
2012-10-16 18:08:45 +00:00
|
|
|
case 'MAIL':
|
|
|
|
|
$engine = G::LoadTranslation('ID_MESS_ENGINE_TYPE_1');
|
|
|
|
|
break;
|
|
|
|
|
case 'PHPMAILER':
|
|
|
|
|
$engine = G::LoadTranslation('ID_MESS_ENGINE_TYPE_2');
|
|
|
|
|
break;
|
|
|
|
|
case 'OPENMAIL':
|
|
|
|
|
$engine = G::LoadTranslation('ID_MESS_ENGINE_TYPE_3');
|
|
|
|
|
break;
|
|
|
|
|
}
|
2011-06-03 18:40:51 -04:00
|
|
|
|
2018-04-04 09:21:59 -04:00
|
|
|
$body = "
|
2011-06-03 18:40:51 -04:00
|
|
|
<table style=\"background-color: white; font-family: Arial,Helvetica,sans-serif; color: black; font-size: 11px; text-align: left;\" cellpadding='10' cellspacing='0' width='100%'>
|
2025-04-13 15:23:31 +00:00
|
|
|
<tbody><tr><td><img id='logo' src='http://" . $_SERVER['SERVER_NAME'] . "/images/lurana.logo.png' /></td></tr>
|
2011-06-03 18:40:51 -04:00
|
|
|
<tr><td style='font-size: 14px;'>$msg</td></tr>
|
|
|
|
|
<tr><td style='vertical-align:middel;'>
|
2018-01-18 12:41:16 -04:00
|
|
|
<br /><hr><b>This Business Process is powered by ProcessMaker ver. " . System::getVersion() . ".<b><br />
|
2011-06-03 18:40:51 -04:00
|
|
|
<a href='http://www.processmaker.com' style='color:#c40000;'>www.processmaker.com</a><br /></td>
|
|
|
|
|
</tr></tbody></table>";
|
|
|
|
|
|
2018-04-04 09:21:59 -04:00
|
|
|
$spool = new SpoolRun();
|
2012-10-16 18:08:45 +00:00
|
|
|
|
2018-04-04 09:21:59 -04:00
|
|
|
$spool->setConfig($setup);
|
|
|
|
|
$messageArray = AppMessage::buildMessageRow(
|
|
|
|
|
'',
|
|
|
|
|
'',
|
|
|
|
|
0,
|
2019-03-29 10:00:39 -04:00
|
|
|
WsBase::MESSAGE_TYPE_RETRIEVE_PASSWORD,
|
2018-04-04 09:21:59 -04:00
|
|
|
$subject,
|
|
|
|
|
$from,
|
|
|
|
|
$data['USR_EMAIL'],
|
|
|
|
|
$body,
|
|
|
|
|
'',
|
|
|
|
|
'',
|
|
|
|
|
'',
|
|
|
|
|
'',
|
|
|
|
|
'pending'
|
|
|
|
|
);
|
|
|
|
|
$spool->create($messageArray);
|
2012-10-16 18:08:45 +00:00
|
|
|
|
|
|
|
|
try {
|
2018-04-04 09:21:59 -04:00
|
|
|
$spool->sendMail();
|
|
|
|
|
$rbacUser->update($infoUser);
|
|
|
|
|
$user->update($infoUser);
|
2016-04-13 15:41:31 -04:00
|
|
|
G::header("location: login");
|
|
|
|
|
G::SendTemporalMessage('ID_NEW_PASSWORD_SENT', "info");
|
2012-10-16 18:08:45 +00:00
|
|
|
} catch (phpmailerException $e) {
|
2016-04-13 15:41:31 -04:00
|
|
|
G::header("location: login");
|
|
|
|
|
G::SendTemporalMessage(G::LoadTranslation('MISSING_OR_NOT_CONFIGURED_SMTP'), "warning", 'string');
|
2012-10-16 18:08:45 +00:00
|
|
|
} catch (Exception $e) {
|
2016-04-13 15:41:31 -04:00
|
|
|
G::header("location: login");
|
|
|
|
|
G::SendTemporalMessage($e->getMessage(), "warning", 'string');
|
2012-10-16 18:08:45 +00:00
|
|
|
}
|
2011-06-06 06:23:18 -04:00
|
|
|
} else {
|
2018-02-02 12:12:50 -04:00
|
|
|
$msg = G::LoadTranslation('ID_THE_USERNAME_EMAIL_IS_INCORRECT');
|
|
|
|
|
if ($userData !== false && $userData['USR_AUTH_TYPE'] !== '' && $userData['USR_EMAIL'] === $data['USR_EMAIL']) {
|
|
|
|
|
$msg = G::LoadTranslation('ID_USER_NOT_FUNCTIONALITY');
|
2014-01-15 16:44:31 -04:00
|
|
|
}
|
2018-01-18 12:41:16 -04:00
|
|
|
G::SendTemporalMessage($msg, "warning", 'string');
|
2012-10-16 18:08:45 +00:00
|
|
|
G::header('location: forgotPassword');
|
2011-06-03 18:40:51 -04:00
|
|
|
}
|