2011-06-03 18:40:51 -04:00
|
|
|
<?php
|
2011-06-06 06:23:18 -04:00
|
|
|
$data = $_POST['form'];
|
2011-06-03 18:40:51 -04:00
|
|
|
global $RBAC;
|
|
|
|
|
require_once PATH_RBAC."model/RbacUsers.php";
|
2011-10-10 19:02:17 -04:00
|
|
|
G::LoadClass('pmFunctions');
|
2011-06-06 06:23:18 -04:00
|
|
|
require_once 'classes/model/Users.php';
|
|
|
|
|
G::LoadClass("system");
|
|
|
|
|
|
|
|
|
|
$rbacUser = new RbacUsers();
|
|
|
|
|
$user = new Users();
|
|
|
|
|
|
|
|
|
|
$userData = $rbacUser->getByUsername($data['USR_USERNAME']);
|
|
|
|
|
|
2014-04-30 02:59:55 -04:00
|
|
|
if ($userData['USR_EMAIL'] != '' && $userData['USR_EMAIL'] === $data['USR_EMAIL'] && ($userData['USR_AUTH_TYPE'] === '' || $userData['USR_AUTH_TYPE'] == 'MYSQL') ) {
|
2014-04-29 15:18:46 -04:00
|
|
|
$aSetup = System::getEmailConfiguration();
|
2012-10-16 18:08:45 +00:00
|
|
|
if (count($aSetup) == 0 || !isset($aSetup['MESS_ENGINE'])) {
|
|
|
|
|
G::SendTemporalMessage ('ID_EMAIL_ENGINE_IS_NOT_ENABLED', "warning");
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
$aData['USR_UID'] = $userData['USR_UID'];
|
2014-10-02 16:31:50 -04:00
|
|
|
$aData['USR_PASSWORD'] = Bootstrap::hashPassword($newPass);
|
2012-10-16 18:08:45 +00:00
|
|
|
/* **Save after sending the mail
|
|
|
|
|
$rbacUser->update($aData);
|
|
|
|
|
$user->update($aData);
|
|
|
|
|
*/
|
2014-04-29 15:18:46 -04:00
|
|
|
|
2014-04-30 02:59:55 -04:00
|
|
|
$sFrom = G::buildFrom($aSetup, $sFrom);
|
2014-04-29 15:18:46 -04:00
|
|
|
|
2012-10-16 18:08:45 +00:00
|
|
|
$sSubject = G::LoadTranslation('ID_RESET_PASSWORD').' - ProcessMaker' ;
|
|
|
|
|
$msg = '<h3>ProcessMaker Forgot password Service</h3>';
|
|
|
|
|
$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>';
|
|
|
|
|
switch ($aSetup['MESS_ENGINE']) {
|
|
|
|
|
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
|
|
|
|
2012-10-16 18:08:45 +00:00
|
|
|
$sBody = "
|
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%'>
|
|
|
|
|
<tbody><tr><td><img id='logo' src='http://".$_SERVER['SERVER_NAME']."/images/processmaker.logo.jpg' /></td></tr>
|
|
|
|
|
<tr><td style='font-size: 14px;'>$msg</td></tr>
|
|
|
|
|
<tr><td style='vertical-align:middel;'>
|
|
|
|
|
<br /><hr><b>This Business Process is powered by ProcessMaker ver. ".System::getVersion().".<b><br />
|
|
|
|
|
<a href='http://www.processmaker.com' style='color:#c40000;'>www.processmaker.com</a><br /></td>
|
|
|
|
|
</tr></tbody></table>";
|
|
|
|
|
|
2012-10-16 18:08:45 +00:00
|
|
|
G::LoadClass('spool');
|
|
|
|
|
|
2014-04-29 15:18:46 -04:00
|
|
|
$oSpool = new spoolRun();
|
2012-10-16 18:08:45 +00:00
|
|
|
|
2014-04-29 15:18:46 -04:00
|
|
|
$oSpool->setConfig($aSetup);
|
2012-10-16 18:08:45 +00:00
|
|
|
$oSpool->create(array(
|
|
|
|
|
'msg_uid' => '',
|
|
|
|
|
'app_uid' => '',
|
|
|
|
|
'del_index' => 0,
|
|
|
|
|
'app_msg_type' => 'TEST',
|
|
|
|
|
'app_msg_subject' => $sSubject,
|
|
|
|
|
'app_msg_from' => $sFrom,
|
|
|
|
|
'app_msg_to' => $data['USR_EMAIL'],
|
|
|
|
|
'app_msg_body' => $sBody,
|
|
|
|
|
'app_msg_cc' => '',
|
|
|
|
|
'app_msg_bcc' => '',
|
|
|
|
|
'app_msg_attach' => '',
|
|
|
|
|
'app_msg_template' => '',
|
|
|
|
|
'app_msg_status' => 'pending',
|
|
|
|
|
'app_msg_attach'=>''
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$oSpool->sendMail();
|
|
|
|
|
$rbacUser->update($aData);
|
|
|
|
|
$user->update($aData);
|
2014-04-30 02:59:55 -04:00
|
|
|
G::header ("location: login");
|
2012-10-16 18:08:45 +00:00
|
|
|
G::SendTemporalMessage ('ID_NEW_PASSWORD_SENT', "info");
|
|
|
|
|
} catch (phpmailerException $e) {
|
2014-04-30 02:59:55 -04:00
|
|
|
G::header ("location: login");
|
2012-10-16 18:08:45 +00:00
|
|
|
G::SendTemporalMessage (G::LoadTranslation('MISSING_OR_NOT_CONFIGURED_SMTP'), "warning", 'string');
|
|
|
|
|
} catch (Exception $e) {
|
2014-04-30 02:59:55 -04:00
|
|
|
G::header ("location: login");
|
2012-10-16 18:08:45 +00:00
|
|
|
G::SendTemporalMessage ($e->getMessage(), "warning", 'string');
|
|
|
|
|
}
|
2011-06-06 06:23:18 -04:00
|
|
|
} else {
|
2014-12-09 09:59:41 -04:00
|
|
|
if ($userData['USR_AUTH_TYPE'] === '' || $userData['USR_AUTH_TYPE'] === 'MYSQL') {
|
2014-01-15 16:47:14 -04:00
|
|
|
$msg = G::LoadTranslation('ID_USER') . ' ' . htmlentities($data['USR_USERNAME'], ENT_QUOTES, 'UTF-8') . ' '. G::LoadTranslation('ID_IS_NOT_REGISTERED');
|
2014-01-15 16:44:31 -04:00
|
|
|
} else {
|
|
|
|
|
$msg = G::LoadTranslation('ID_USER_NOT_FUNCTIONALITY');
|
|
|
|
|
}
|
2012-10-16 18:08:45 +00:00
|
|
|
G::SendTemporalMessage ($msg, "warning", 'string');
|
|
|
|
|
G::header('location: forgotPassword');
|
2011-06-03 18:40:51 -04:00
|
|
|
}
|
|
|
|
|
|