25 $SHOW_SETTINGS = Array(
'PASSWORD' => 0,
'SECURITY' => 0,
'CONFIDENCE' => 0);
26 $SHOW_SETTINGS_TOTAL_SECURITY = 3;
31 $SHOW_SETTINGS[
'PASSWORD'] = 0;
32 $SHOW_SETTINGS[
'EMAIL'] = 0;
33 $SHOW_SETTINGS[
'SECURITY'] = 1;
34 $SHOW_SETTINGS[
'CONFIDENCE'] = 1;
37 $SHOW_SETTINGS[
'PASSWORD'] = 0;
38 $SHOW_SETTINGS[
'EMAIL'] = 0;
39 $SHOW_SETTINGS[
'SECURITY'] = 1;
40 $SHOW_SETTINGS[
'CONFIDENCE'] = 1;
43 $SHOW_SETTINGS[
'PASSWORD'] = 1;
44 $SHOW_SETTINGS[
'EMAIL'] = 1;
45 $SHOW_SETTINGS[
'SECURITY'] = 1;
46 $SHOW_SETTINGS[
'CONFIDENCE'] = 1;
50 $SQL_FIELDS_UPDATE =
"";
51 $SQL_FIELDS_UPDATE_SECURITY =
"";
52 $FORM_VALIDATION_ERROR =
"";
53 $form_validated_device =
false;
56 $JSON_FormPopulate =
"";
59 define(
"LOCAL_USER_QUERY_SRC_USERID", 1);
60 define(
"LOCAL_USER_QUERY_SRC_EMAIL", 0);
61 define(
"REFRESH_USER_DATA",
true);
63 $DMSAPP_QuestMaster_Ary = array();
65 $sql =
"SELECT * FROM cuquestmaster WHERE quest_lang = 'en_US' ORDER BY quest_text ";
66 $qst_rs = db_query($sql, $dbh);
68 while ($qst_row = db_fetch_array($qst_rs, $qst_cnt++)){
69 $DMSAPP_QuestMaster_Ary[$qst_row[
'quest_id']] = disp_text($qst_row[
'quest_text']);
71 db_free_result($qst_rs);
74 if (isset($_POST[
'savesettings']) && isset($_POST[
'form_key'])) {
78 if ($DMSAPP_CURRENTUSERID ==
"" && isset($_POST[
'form_key'])) {
79 $l_user = decrypt($_POST[
'form_key'], $MasterKey);
81 if ($l_user == intval($l_user)) {
83 $DMSAPP_CURRENTUSERID = $l_user;
85 $FORM_VALIDATION_ERROR =
"An error occurred.";
90 $user_row = ReturnUserRecord(LOCAL_USER_QUERY_SRC_USERID, $DMSAPP_CURRENTUSERID);
97 if ($SHOW_SETTINGS[
'EMAIL']) {
99 if (trim(strtolower($_POST[
'chg_email'])) != trim(strtolower($user_row[
'email']))) {
101 $sql =
"SELECT count(*) FROM {$DB_TABLE_PREFIX}user where email = '" . save_text(strtolower($_POST[
'chg_email']), 50) .
"' AND cu = '" . save_text($DMSAPP_CURRENTCUCODE) .
"' AND coalesce(userlogintype, '') <> 'H' ";
103 $email_rs = db_query($sql, $dbh);
104 list ($email_row_count) = db_fetch_row($email_rs);
105 if ($email_row_count > 0 ) {
107 $FORM_VALIDATION_ERROR .=
"<li>The email you entered has already been used.</li>";
109 if ($FORM_VALIDATION_ERROR ==
"") {
111 $SQL_FIELDS_UPDATE .= ($SQL_FIELDS_UPDATE ==
"" ?
"" :
", ") .
" email = '" . save_text(strtolower($_POST[
'chg_email']), 50) .
"' ";
112 $user_sql_where =
" AND NOT EXISTS (SELECT * FROM {$DB_TABLE_PREFIX}user WHERE email = '" . save_text(strtolower($_POST[
'chg_email']), 50) .
"' AND cu = '" . save_text($DMSAPP_CURRENTCUCODE) .
"' AND coalesce(userlogintype, '') <> 'H') ";
116 $JSON_FormPopulate .= ($JSON_FormPopulate !=
'' ?
", " :
"") .
"'chg_email':'" . disp_text($_POST[
'chg_email']) .
"' ";
120 if ($SHOW_SETTINGS[
'PASSWORD']) {
123 if (strlen($_POST[
'chg_pwd_new']) > 0 || strlen($_POST[
'chg_pwd_conf']) > 0) {
125 if ($_POST[
'chg_pwd_new'] <> $_POST[
'chg_pwd_conf']) {
127 $FORM_VALIDATION_ERROR .=
"<li>The new passwords do not match.</li>";
130 if ($_POST[
'chg_pwd_old'] ==
'') {
131 $FORM_VALIDATION_ERROR .=
"<li>The current password must entered to make changes.</li>";
134 if (trim($user_row[
'pwd']) ==
'' || !password_verify(trim($_POST[
'chg_pwd_old']), trim($user_row[
'pwd']))) {
135 $FORM_VALIDATION_ERROR .=
"<li>The current password is not correct.</li>";
139 $passwordNew = $_POST[
'chg_pwd_new'];
141 if (key_exists(
"configPassword", $configOptions)) {
142 $pwdRules = json_decode($configOptions[
'configPassword'],
true);
144 $pwdRules[
"len"] = 8;
145 $pwdRules[
"upper"] = 1;
146 $pwdRules[
"lower"] = 1;
147 $pwdRules[
"spec"] = 0;
148 $pwdRules[
"digit"] = 1;
151 if ( strlen($passwordNew) < $pwdRules[
"len"] ) {
152 $mpmsg .=
"Password is too short<br>";
154 if ( strlen($passwordNew) > 20 ) {
155 $mpmsg .=
"Password is too long<br>";
158 $numUpperCharCount = 0;
159 $numLowerCharCount = 0;
160 $numSpecialCharCount = 0;
161 $notAllowedCount = 0;
162 for ( $i = 0; $i < strlen( $passwordNew ); $i++ )
164 $ch = substr( $passwordNew, $i, 1 );
165 if ($ch >=
'0' && $ch <=
'9') { $numDigitCount++; }
166 else if ($ch >=
'A' && $ch <=
'Z') { $numUpperCharCount++; }
167 else if ($ch >=
'a' && $ch <=
'z') { $numLowerCharCount++; }
168 else if ( $ch !=
',' && strpos( $passSpecial, $ch ) >= 0 ) { $numSpecialCharCount++; }
169 else { $notAllowedCount++; }
171 if ( $pwdRules[
"upper"] > 0 && $numUpperCharCount < $pwdRules[
"upper"] )
173 $plural = $pwdRules[
"upper"] > 1 ?
's' :
'';
174 $mpmsg .=
"Need at least {$pwdRules["upper
"]} UPPER CASE letter$plural<br>";
176 if ( $pwdRules[
"lower"] > 0 && $numLowerCharCount < $pwdRules[
"lower"] )
178 $plural = $pwdRules[
"lower"] > 1 ?
's' :
'';
179 $mpmsg .=
"Need at least {$pwdRules["lower
"]} lower case letter$plural<br>";
181 if ( $pwdRules[
"spec"] > 0 && $numSpecialCharCount < $pwdRules[
"spec"] )
183 $plural = $pwdRules[
"spec"] > 1 ?
's' :
'';
184 $mpmsg .=
"Need at least {$pwdRules["spec
"]} special character$plural<br>";
186 if ( $pwdRules[
"digit"] > 0 && $numDigitCount < $pwdRules[
"digit"] )
188 $plural = $pwdRules[
"digit"] > 1 ?
's' :
'';
189 $mpmsg .=
"Need at least {$pwdRules["digit
"]} digit$plural<br>";
192 if ( strlen( $mpmsg ) > 0 ) {
193 $FORM_VALIDATION_ERROR .= $mpmsg;
199 if ($FORM_VALIDATION_ERROR ==
"") {
201 $SQL_FIELDS_UPDATE .= ($SQL_FIELDS_UPDATE ==
"" ?
"" :
", ") .
" pwd = '" . password_hash($_POST[
'chg_pwd_conf'], PASSWORD_DEFAULT) .
"' ";
208 $user_auto_set_pwd = 0;
211 if ($SHOW_SETTINGS[
'SECURITY']) {
214 $selected_questid =
"";
216 if ($form_code ==
'confirmuser' || $form_code ==
'newuser' || $form_code ==
"newmiruser" ) {
220 $sql =
"SELECT COUNT(u_qs.userid) as quest_select 221 FROM {$DB_TABLE_PREFIX}user_questselect as u_qs 222 WHERE u_qs.userid = " . $user_row[
'userid'];
223 $cnt_rs = db_query($sql, $dbh);
224 $cnt_row = db_fetch_assoc($cnt_rs);
226 if ($cnt_row[
'quest_select'] == 0) {
228 $user_auto_set_pwd = 1;
232 for ($idx = 0; $idx < $SHOW_SETTINGS_TOTAL_SECURITY; $idx++) {
234 $fld_quest =
"chg_qst_$idx";
235 $fld_resp =
"chg_resp_$idx";
237 if (strlen($_POST[$fld_quest]) == 0) {
239 $FORM_VALIDATION_ERROR .=
"<li>A challenge question must be select for question " . ($idx + 1) .
".</li>";
243 if (strstr($selected_questid,
":" . intval($_POST[$fld_quest]) .
":")) {
245 $FORM_VALIDATION_ERROR .=
"<li>The challenge question for question " . ($idx + 1) .
" has already been used.</li>";
247 $selected_questid .=
":" . intval($_POST[$fld_quest]) .
":";
251 if (strlen($_POST[$fld_resp]) == 0) {
253 $FORM_VALIDATION_ERROR .=
"<li>A response must be entered for question " . ($idx + 1) .
"</li>";
256 if ($FORM_VALIDATION_ERROR ==
"") {
257 $SQL_FIELDS_UPDATE_SECURITY .=
"INSERT INTO {$DB_TABLE_PREFIX}user_questselect (userid, questid, user_answer) VALUES ('" . intval($DMSAPP_CURRENTUSERID) .
"', " . intval($_POST[$fld_quest]) .
", '" . save_text($_POST[$fld_resp]) .
"'); ";
259 $JSON_FormPopulate .= ($JSON_FormPopulate !=
"" ?
", " :
"") .
"$fld_quest: '" . disp_text($_POST[$fld_quest],
true) .
"', $fld_resp: '" . disp_text($_POST[$fld_resp],
true) .
"' ";
263 if ($SHOW_SETTINGS[
'CONFIDENCE']) {
265 if (strlen($_POST[
'app_confword']) == 0) {
267 $FORM_VALIDATION_ERROR .=
"<li>A confidence word must be entered to continue.</li>";
269 if ($FORM_VALIDATION_ERROR ==
"") {
271 $SQL_FIELDS_UPDATE .= ($SQL_FIELDS_UPDATE ==
"" ?
"" :
", ") .
" confidenceword = '" . save_text($_POST[
'app_confword']) .
"' ";
273 $JSON_FormPopulate .= ($JSON_FormPopulate !=
"" ?
", " :
"") .
"app_confword: '" . disp_text($_POST[
'app_confword'],
true) .
"' ";
276 $user_sql_update =
"";
277 if ($FORM_VALIDATION_ERROR ==
"") {
280 if (strlen($SQL_FIELDS_UPDATE) > 0) {
281 $user_sql_update .=
"UPDATE {$DB_TABLE_PREFIX}user 282 SET $SQL_FIELDS_UPDATE 283 WHERE userid = " . intval($DMSAPP_CURRENTUSERID) .
" 286 if (strlen($SQL_FIELDS_UPDATE_SECURITY) > 0) {
287 $user_sql_update .=
" DELETE FROM {$DB_TABLE_PREFIX}user_questselect WHERE userid = '" . intval($DMSAPP_CURRENTUSERID) .
"'; " . $SQL_FIELDS_UPDATE_SECURITY;
291 if ($user_sql_update !=
"") {
294 $upd_rs = db_query($user_sql_update, $dbh);
308 $user_row = ReturnUserRecord(LOCAL_USER_QUERY_SRC_USERID, $DMSAPP_CURRENTUSERID, REFRESH_USER_DATA);
311 $loginType = $user_row[
"userlogintype"];
312 $user_device_cookiename = ReturnDeviceCookieName($DMSAPP_CURRENTCUCODE, $loginType, trim($user_row[
'email']), $user_row[
'userid']);
313 $setCookieVal = sha1($DMSAPP_SECRET_KEY . trim($user_row[
'pwd']) . trim($user_row[
'email']) . trim($user_row[
'confidenceword']) . trim($user_row[
'banking_user_id']));
318 $pSessionCookie = $_POST[
"chksecure"] !=
"Y";
319 SetLnappDeviceCookie($HB_ENV, $user_device_cookiename, $setCookieVal, $pSessionCookie);
321 if ($user_auto_set_pwd == 1) {
322 DMSAppSetCookie($HB_ENV, $user_row[
'userid'], $loginType);
325 $set_desc =
"User settings successfully updated.";
326 header(
"Location: {$self}f=portal&msg=" . urlencode($set_desc));
332 $error_save_form =
" ERROR Saving";
333 print $error_save_form;
339 $error_save_form =
" ERROR Saving -- validation";
341 }
else if($form_code ==
"confirmuser") {
343 $user_failedloginattempts = 0;
344 if (isset($_POST[
'confchallenge'])) {
354 $user_row = ReturnUserRecord(LOCAL_USER_QUERY_SRC_EMAIL, strtolower($_POST[
'loginemail']));
359 $user_failedloginattempts = intval($user_row[
'failedloginattempts']);
360 if (isset($user_row)) {
362 $sql =
"SELECT user_answer 363 FROM {$DB_TABLE_PREFIX}user_questselect as u_qs 364 JOIN {$DB_TABLE_PREFIX}user as u on u.challenge_quest_id = u_qs.questid and u.userid = u_qs.userid 365 WHERE u.email = '" . save_text(strtolower($_POST[
'loginemail']), 50) .
"' 366 AND u.cu = '" . save_text($DMSAPP_CURRENTCUCODE) .
"' 367 AND coalesce(userlogintype, '') <> 'H' ";
368 $valid_rs = db_query($sql, $dbh);
370 $valid_row = db_fetch_array($valid_rs);
372 if (trim(strtolower($valid_row[
'user_answer'])) == trim(strtolower($_POST[
'chg_resp']))) {
375 $user_device_cookiename = ReturnDeviceCookieName($DMSAPP_CURRENTCUCODE, DMSAPP_CONST_APP_LOGIN, trim(strtolower($_POST[
'loginemail'])), $user_row[
'userid']);
377 $setCookieVal = sha1($DMSAPP_SECRET_KEY . trim($user_row[
'pwd']) . trim($user_row[
'email']) . trim($user_row[
'confidenceword']) . trim($user_row[
'banking_user_id']));
379 $pSessionCookie = $_POST[
"chksecure"] !=
"Y";
381 SetLnappDeviceCookie($HB_ENV, $user_device_cookiename, $setCookieVal, $pSessionCookie);
386 $sql =
"UPDATE {$DB_TABLE_PREFIX}user 387 SET challenge_quest_id = -1 388 WHERE email = '" . save_text(strtolower($_POST[
'loginemail']), 50) .
"' 389 AND cu = '" . save_text($DMSAPP_CURRENTCUCODE) .
"' 390 AND coalesce(userlogintype, '') <> 'H' ";
391 $upd_rs = db_query($sql, $dbh);
396 $form_validated_device =
true;
400 $sql =
"UPDATE {$DB_TABLE_PREFIX}user 401 SET failedloginattempts = COALESCE(failedloginattempts, 0) + 1 402 WHERE email = '" . save_text(strtolower($_POST[
'loginemail']), 50) .
"' 403 AND cu = '" . save_text($DMSAPP_CURRENTCUCODE) .
"' 404 AND coalesce(userlogintype, '') <> 'H' ";
405 $upd_rs = db_query($sql, $dbh);
407 $user_failedloginattempts += 1;
409 $FORM_VALIDATION_ERROR .=
"Your answer did not match the answer on record for this question.";
414 $FORM_VALIDATION_ERROR .=
"The user record was not found.";
417 } elseif (isset($_POST[
'confpassword'])) {
429 $user_row = ReturnUserRecord(LOCAL_USER_QUERY_SRC_EMAIL, strtolower($_POST[
'loginemail']));
430 $user_failedloginattempts = intval($user_row[
'failedloginattempts']);
437 if (password_verify($_POST[
'loginpassword'], trim($user_row[
'pwd']))) {
444 $sql =
"UPDATE {$DB_TABLE_PREFIX}user 445 SET failedloginattempts = 0 446 WHERE email = '" . save_text(strtolower($_POST[
'loginemail']), 50) .
"' 447 AND cu = '" . save_text($DMSAPP_CURRENTCUCODE) .
"' 448 AND coalesce(userlogintype, '') <> 'H' ";
449 $upd_rs = db_query($sql, $dbh);
452 $sql =
"SELECT COUNT(u_qs.userid) as quest_select 453 FROM {$DB_TABLE_PREFIX}user_questselect as u_qs 454 WHERE u_qs.userid = " . $user_row[
'userid'];
455 $cnt_rs = db_query($sql, $dbh);
456 $cnt_row = db_fetch_assoc($cnt_rs);
458 $user_failedloginattempts = 0;
459 if ($cnt_row[
'quest_select'] == 0) {
464 $DMSAPP_CURRENTUSERID = $user_row[
'userid'];
466 $form_code =
"newuser";
470 DMSAppSetCookie($HB_ENV, $user_row[
'userid'], DMSAPP_CONST_APP_LOGIN);
472 header(
"Location: {$self}f=portal");
480 $sql =
"UPDATE {$DB_TABLE_PREFIX}user 481 SET failedloginattempts = COALESCE(failedloginattempts, 0) + 1 482 WHERE email = '" . save_text(strtolower($_POST[
'loginemail']), 50) .
"' 483 AND cu = '" . save_text($DMSAPP_CURRENTCUCODE) .
"' 484 AND coalesce(userlogintype, '') <> 'H' ";
485 $upd_rs = db_query($sql, $dbh);
487 $user_failedloginattempts += 1;
489 $FORM_VALIDATION_ERROR .=
"<li>The password you entered did not match.</li>";
500 if ($DMSAPP_CURRENTUSERID > 0 && $DMSAPP_CURRENTEMAIL !=
'') {
501 $FORM_VALIDATION_ERROR .=
"<li>Your session has expired. Please confirm your password.</li>";
514 if ($DMSAPP_CURRENTUSERID !=
"" && $form_code ==
"modifyuser") {
516 $sql =
"SELECT * FROM {$DB_TABLE_PREFIX}user 517 WHERE userid = '$DMSAPP_CURRENTUSERID'";
519 $user_rs = db_query($sql, $dbh);
521 $user_row = db_fetch_array($user_rs);
523 if (trim($user_row[
'cu']) == $DMSAPP_CURRENTCUCODE) {
528 if ($SHOW_SETTINGS[
'CONFIDENCE']) {
529 $JSON_FormPopulate .= ($JSON_FormPopulate !=
'' ?
", " :
"") .
"app_confword: '" . disp_text($user_row[
'confidenceword']) .
"' ";
531 if ($SHOW_SETTINGS[
'EMAIL']) {
532 $JSON_FormPopulate .= ($JSON_FormPopulate !=
'' ?
", " :
"") .
"'chg_email':'" . disp_text($user_row[
'email']) .
"' ";
535 $sql =
"SELECT * FROM {$DB_TABLE_PREFIX}user_questselect 536 WHERE userid = '$DMSAPP_CURRENTUSERID'";
537 $secur_rs = db_query($sql, $dbh);
539 while ($secur_row = db_fetch_array($secur_rs, $secur_idx)) {
542 $JSON_FormPopulate .= ($JSON_FormPopulate !=
'' ?
", " :
"") .
"chg_qst_$secur_idx: '" . disp_text($secur_row[
'questid']) .
"', chg_resp_$secur_idx: '" . disp_text($secur_row[
'user_answer']) .
"' ";
564 if ($DMSAPP_CURRENTUSERID ==
"") {
569 $sql =
"SELECT count(*) as email_login_count 570 FROM {$DB_TABLE_PREFIX}user 571 WHERE email = '" . save_text(strtolower($_POST[
'confirmemail']), 50) .
"' 572 AND cu = '" . save_text($DMSAPP_CURRENTCUCODE) .
"' 573 AND coalesce(userlogintype, '') <> 'H' ";
575 $h_resp = db_query($sql, $dbh);
578 list($email_login_count) = db_fetch_array($h_resp, 0);
579 if ($email_login_count == 0) {
581 $passwordNew = $_POST[
"apppasswd"];
582 $passwordConfirm = $_POST[
"confirmpasswd"];
585 if ( $passwordNew <> $passwordConfirm ) {
587 $passwdMsg .=
"<li>The new passwords do not match.</li>";
591 if (key_exists(
"configPassword", $configOptions)) {
592 $pwdRules = json_decode($configOptions[
'configPassword'],
true);
594 $pwdRules[
"len"] = 8;
595 $pwdRules[
"upper"] = 1;
596 $pwdRules[
"lower"] = 1;
597 $pwdRules[
"spec"] = 0;
598 $pwdRules[
"digit"] = 1;
601 if ( strlen($passwordNew) < $pwdRules[
"len"] ) {
602 $mpmsg .=
"Password is too short, ";
604 if ( strlen($passwordNew) > 20 ) {
605 $mpmsg .=
"Password is too long, ";
608 $numUpperCharCount = 0;
609 $numLowerCharCount = 0;
610 $numSpecialCharCount = 0;
611 $passSpecial = Get_PwdSpecialCharacters();
612 $notAllowedCount = 0;
613 for ( $i = 0; $i < strlen( $passwordNew ); $i++ )
615 $ch = substr( $passwordNew, $i, 1 );
616 if ($ch >=
'0' && $ch <=
'9') { $numDigitCount++; }
617 else if ($ch >=
'A' && $ch <=
'Z') { $numUpperCharCount++; }
618 else if ($ch >=
'a' && $ch <=
'z') { $numLowerCharCount++; }
619 else if ( $ch !=
',' && strpos( $passSpecial, $ch ) >= 0 ) { $numSpecialCharCount++; }
620 else { $notAllowedCount++; }
622 if ( $pwdRules[
"upper"] > 0 && $numUpperCharCount < $pwdRules[
"upper"] )
624 $plural = $pwdRules[
"upper"] > 1 ?
's' :
'';
625 $mpmsg .=
"Need at least {$pwdRules["upper
"]} UPPER CASE letter$plural, ";
627 if ( $pwdRules[
"lower"] > 0 && $numLowerCharCount < $pwdRules[
"lower"] )
629 $plural = $pwdRules[
"lower"] > 1 ?
's' :
'';
630 $mpmsg .=
"Need at least {$pwdRules["lower
"]} lower case letter$plural, ";
632 if ( $pwdRules[
"spec"] > 0 && $numSpecialCharCount < $pwdRules[
"spec"] )
634 $plural = $pwdRules[
"spec"] > 1 ?
's' :
'';
635 $mpmsg .=
"Need at least {$pwdRules["spec
"]} special character$plural, ";
637 if ( $pwdRules[
"digit"] > 0 && $numDigitCount < $pwdRules[
"digit"] )
639 $plural = $pwdRules[
"digit"] > 1 ?
's' :
'';
640 $mpmsg .=
"Need at least {$pwdRules["digit
"]} digit$plural, ";
643 if ( strlen( $mpmsg ) > 0 ) {
644 $passwdMsg .= urlencode($mpmsg);
646 header(
"Location: {$self}status=11&msg=$passwdMsg");
652 $sql =
"SELECT nextval('{$DB_TABLE_PREFIX}user_userid_seq'::text) as userid ";
653 $id_rs = db_query($sql, $dbh);
654 list($user_id) = db_fetch_array($id_rs);
655 db_free_result($id_rs);
657 $saved_pwd = password_hash($_POST[
'confirmpasswd'], PASSWORD_DEFAULT);
660 $sql =
"INSERT INTO {$DB_TABLE_PREFIX}user 661 (userid, email, pwd, allow_e_comm, cu) 664 '" . save_text(strtolower($_POST[
'confirmemail']), 50) .
"', 665 '" . save_text($saved_pwd) .
"', 667 '" . save_text($DMSAPP_CURRENTCUCODE) .
"' 669 WHERE NOT EXISTS (SELECT * FROM {$DB_TABLE_PREFIX}user WHERE 670 email = '". save_text(strtolower($_POST[
'confirmemail']), 50) .
"' 671 AND cu = '" . save_text($DMSAPP_CURRENTCUCODE) .
"' 672 AND coalesce(userlogintype, '') <> 'H'))" 676 $saved_resp = db_query($sql, $dbh);
677 if (db_affected_rows($saved_resp) == 0) {
683 header(
"Location: {$self}status=1");
689 DMSAppSetCookie($HB_ENV, $user_id, DMSAPP_CONST_APP_LOGIN,
true);
691 $DMSAPP_CURRENTUSERID = $user_id;
698 header(
"Location: {$self}status=1");
714 if ($error_loadform == 0):
716 if ( $form_code ==
"newmiruser" ) {
719 FROM {$DB_TABLE_PREFIX}user 720 WHERE session_account = '" . save_text($_POST[
'member'], 12) .
"' 721 AND cu = '$DMSAPP_CURRENTCUCODE' 722 AND userlogintype = 'N'";
724 $user_rs = db_query($sql, $dbh);
725 if ( $user_row = db_fetch_array($user_rs) ) {
727 $DMSAPP_CURRENTUSERID = $user_row[
"userid"];
730 header(
"Location: {$self}f=intro&status=999");
737 $JSON_FormPopulate =
"{" . $JSON_FormPopulate .
"}";
740 if (key_exists(
"configPassword", $configOptions)) {
741 $pwdRules = json_decode($configOptions[
'configPassword'],
true);
743 $pwdRules[
"len"] = 8;
744 $pwdRules[
"upper"] = 1;
745 $pwdRules[
"lower"] = 1;
746 $pwdRules[
"spec"] = 0;
747 $pwdRules[
"digit"] = 1;
750 $passwordRequirements =
"";
751 $passwordRequirements .=
"• At least {$pwdRules["len
"]} characters<br>";
752 if ( $pwdRules[
"upper"] > 0 ) {
753 $plural = $pwdRules[
"upper"] > 1 ?
"s" :
"";
754 $passwordRequirements .=
"• At least {$pwdRules["upper
"]} UPPER CASE character$plural<br>";
756 if ( $pwdRules[
"lower"] > 0 ) {
757 $plural = $pwdRules[
"lower"] > 1 ?
"s" :
"";
758 $passwordRequirements .=
"• At least {$pwdRules["lower
"]} lower case character$plural<br>";
760 if ( $pwdRules[
"spec"] > 0 ) {
761 $specialCharList = Get_PwdSpecialCharacters();
762 $plural = $pwdRules[
"spec"] > 1 ?
"s" :
"";
763 $passwordRequirements .=
"• At least {$pwdRules["spec
"]} special character$plural ($specialCharList)<br>";
765 if ( $pwdRules[
"digit"] > 0 ) {
766 $plural = $pwdRules[
"digit"] > 1 ?
"s" :
"";
767 $passwordRequirements .=
"• At least {$pwdRules["digit
"]} digit$plural<br>";
772 .input input { margin-left:1em;}
773 .input label { margin-left:0px; font-size:larger; padding:1em;}
774 @media only screen and (max-width: 479px) {
775 .passwordrequirements {display:
inline-block; float:none; margin-left:20px;}
778 <div
class=
"container-fluid">
781 <div
class=
"lnapp-form-section lnapp-summary-wrap col-xs-12 col-md-offset-3 col-md-6" style=
"">
782 <div
id=
"summary-container" class=
"validity-summary-container errors" >
783 <div
class=
"alert alert-danger">
784 <p><em>You may not
continue. the following errors were encountered:</em></p>
786 <?php echo $FORM_VALIDATION_ERROR; ?>
796 <form
id=
"app_settings" name=
"app_settings" action=
"<?php echo $self; ?>f=<?php echo $form_code; ?>" method=
"post">
797 <input type=
"hidden" name=
"form_set" value=
"<?php echo $form_code; ?>">
798 <input type=
"hidden" name=
"form_key" value=
"<?php echo encrypt($DMSAPP_CURRENTUSERID, $MasterKey); ?>">
799 <div
id=
"content-single">
800 <div
class=
"form-container">
801 <?php
if ($SHOW_SETTINGS[
'EMAIL']): ?>
804 <div
class=
"col-xs-12 col-sm-offset-3 col-sm-6">
805 <div
class=
"panel panel-default">
806 <div
class=
"panel-heading">
807 <h2
class=
"panel-title">Email</h2>
809 <div
class=
"panel-body">
811 <div
class=
"form-horizontal">
812 <div
class=
"form-group">
813 <label
for=
"chg_email" class=
"col-sm-2 control-label">Email</label>
814 <div
class=
"col-sm-10">
815 <input
id=
"chg_email" name=
"chg_email" type=
"text" x-size=
"20" class=
"email form-control" title=
"Email" value=
""/>
827 <?php
if ($SHOW_SETTINGS[
'PASSWORD']): ?>
832 <div
class=
"col-xs-12 col-sm-offset-3 col-sm-6">
833 <div
class=
"panel panel-default">
834 <div
class=
"panel-heading">
835 <h2
class=
"panel-title">Password</h2>
837 <div
class=
"panel-body">
839 <div
class=
"form-horizontal">
840 <div
class=
"form-group">
841 <label
for=
"chg_pwd_old" class=
"col-sm-2 control-label">Current Password</label>
842 <div
class=
"col-sm-10">
843 <input
id=
"chg_pwd_old" name=
"chg_pwd_old" type=
"password" x-size=
"12" class=
"curpwd form-control" title=
"Current Password"/>
847 <div
class=
"col-xs-12 col-sm-6">
848 <div
class=
"form-group">
849 <label
for=
"chg_pwd_new" class=
"col-sm-4 control-label">New Password</label>
850 <div
class=
"col-sm-8">
851 <input
id=
"chg_pwd_new" name=
"chg_pwd_new" type=
"password" size=
"12" class=
"newpwd form-control"title=
"New Password"/>
854 <div
class=
"form-group">
855 <label
for=
"chg_pwd_conf" class=
"col-sm-4 control-label">Confirm</label>
856 <div
class=
"col-sm-8">
857 <input
id=
"chg_pwd_conf" name=
"chg_pwd_conf" type=
"password" size=
"12" class=
"newpwd form-control" title=
"Confirmation Password"/>
861 <div
class=
"col-xs-12 col-sm-6">
862 <div
class=
"alert alert-info ">
863 <div style=
"color:red; margin-top:5px;">Password Requirements</div>
864 <?php echo $passwordRequirements ?>
877 <?php
if ($SHOW_SETTINGS[
'SECURITY']): ?>
880 <div
class=
"col-xs-12 col-sm-offset-3 col-sm-6">
881 <div
class=
"panel panel-default">
882 <div
class=
"panel-heading">
883 <h2
class=
"panel-title">Challenge Questions</h2>
885 <div
class=
"panel-body">
887 <div
class=
"form-horizontal">
888 <div
class=
"form-group">
889 <label
for=
"chg_qst_0" class=
"col-xs-12 ">Question 1</label>
890 <div
class=
"col-xs-12">
891 <select
id=
"chg_qst_0" name=
"chg_qst_0" class=
"form-control" title=
"Question 1">
892 <option value=
"">Please select a challenge question</option>
893 <?php print ReturnQuestMasterOption(); ?>
897 <div
class=
"form-group">
898 <label
for=
"chg_resp_0" class=
"sr-only col-xs-12">Response 1</label>
899 <div
class=
"col-xs-12">
900 <input
id=
"chg_resp_0" class=
"form-control" name=
"chg_resp_0" type=
"text" size=
"30" maxlength=
"100" placeholder=
"Response 1" title=
"Response 1"/>
904 <div
class=
"form-group">
905 <label
for=
"chg_qst_1" class=
"col-xs-12">Question 2</label>
906 <div
class=
"col-xs-12">
907 <select
id=
"chg_qst_1" name=
"chg_qst_1" class=
"form-control" title=
"Question 2">
908 <option value=
"">Please select a challenge question</option>
909 <?php print ReturnQuestMasterOption(); ?>
913 <div
class=
"form-group">
914 <label
for=
"chg_resp_1" class=
"sr-only col-sm-2 control-label">Response 2</label>
915 <div
class=
"col-xs-12">
916 <input
id=
"chg_resp_1" class=
"form-control" name=
"chg_resp_1" type=
"text" size=
"30" maxlength=
"100" placeholder=
"Response 2" title=
"Response 2"/>
920 <div
class=
"form-group">
921 <label
for=
"chg_qst_2" class=
"col-xs-12">Question 3</label>
922 <div
class=
"col-xs-12">
923 <select
id=
"chg_qst_2" name=
"chg_qst_2" class=
"form-control" title=
"Question 3">
924 <option value=
"">Please select a challenge question</option>
925 <?php print ReturnQuestMasterOption(); ?>
929 <div
class=
"form-group">
930 <label
for=
"chg_resp_2" class=
"sr-only col-sm-2 control-label">Response 3</label>
931 <div
class=
"col-xs-12">
932 <input
id=
"chg_resp_2" class=
"form-control" name=
"chg_resp_2" type=
"text" size=
"30" maxlength=
"100" placeholder=
"Response 3" title=
"Response 3"/>
946 <?php
if ($SHOW_SETTINGS[
'CONFIDENCE']): ?>
949 <div
class=
"col-xs-12 col-sm-offset-3 col-sm-6">
950 <div
class=
"panel panel-default">
951 <div
class=
"panel-heading">
952 <h2
class=
"panel-title">Confidence Word</h2>
954 <div
class=
"panel-body">
956 <div
class=
"form-horizontal">
957 <div
class=
"form-group">
959 <label
for=
"app_confword" class=
"sr-only control-label col-sm-2">Confidence Word</label>
960 <div
class=
"col-sm-10">
961 <input
id=
"app_confword" class=
"form-control" name=
"app_confword" type=
"text" size=
"30" maxlength=
"30" class=
"confidence" placeholder=
"Confidence Word" title=
"Confidence Word"/>
977 <div
class=
"col-xs-12 col-sm-offset-3 col-sm-6">
979 <label
class=
"submit">
980 <a
class=
"k-button k-primary" role=
"button" href=
"#" id=
'linkFormPost' label=
'Submit'><span>Save Settings</span></a>
981 <input type=
"hidden" name=
"savesettings" value=
"1">
982 <script language=
"javascript">
984 $(
'a[id^=linkFormPost]').click(
function(){
985 $(
'#app_settings').submit();
994 <script language=
"javascript">
995 $.validity.setup({ outputMode:
"summary" });
998 $(
"#app_settings").validity(
function() {
1001 <?php
if ($SHOW_SETTINGS[
'PASSWORD']): ?>
1002 if ($(
"#chg_pwd_new").val() !=
"") {
1004 .require(
'Current password must be entered to enter new password.');
1007 var newPassword = $(
"#chg_pwd_new").val();
1008 $(
"#chg_pwd_new").minLength(<?php echo $pwdRules[
"len"] ?>,
"New password too short.");
1010 if ( <?php echo $pwdRules[
"digit"] ?> > 0 ) {
1011 var test = newPassword;
1012 if ( test.replace(/[^0-9]/g,
"").length < <?php echo $pwdRules[
"digit"] ?> ) {
1013 $(
"#chg_pwd_new").assert(
false,
"Not enough digits in password.");
1017 if ( <?php echo $pwdRules[
"upper"] ?> > 0 ) {
1018 var test = newPassword;
1019 if ( test.replace(/[^A-Z]/g,
"").length < <?php echo $pwdRules[
"upper"] ?> ) {
1020 $(
"#chg_pwd_new").assert(
false,
"Not enough upper-case characters in password.");
1024 if ( <?php echo $pwdRules[
"lower"] ?> > 0 ) {
1025 var test = newPassword;
1026 if ( test.replace(/[^a-z]/g,
"").length < <?php echo $pwdRules[
"lower"] ?> ) {
1027 $(
"#chg_pwd_new").assert(
false,
"Not enough lower-case characters in password.");
1031 $(
'input.newpwd').equal(
"New passwords field do not match.");
1033 <?php
if ($SHOW_SETTINGS[
'EMAIL']): ?>
1035 .require(
'#{field} is required')
1036 .match(
'email',
'#{field} must be formatted as an email.')
1039 <?php
if ($SHOW_SETTINGS[
'SECURITY']): ?>
1040 $(
"[id^='chg_resp']")
1041 .require(
'#{field} is required');
1042 $(
"[id^='chg_qst']")
1043 .require(
'#{field} is required')
1044 .distinct(
'Different challenge questions must be selected.');
1046 <?php
if ($SHOW_SETTINGS[
'CONFIDENCE']): ?>
1047 $(
"[id^='app_confword']")
1048 .require(
'#{field} is required');
1051 <?php print ($FORM_VALIDATION_ERROR !=
"" ?
"$('#summary-container').css('display', 'inline-block');" :
""); ?>
1053 <?php print (strlen($JSON_FormPopulate) > 0 ?
"$('#app_settings').populate($JSON_FormPopulate);\n" :
""); ?>
1076 if (isset($_POST[
'loginemail'])) {
1077 $l_email = trim(strtolower($_POST[
'loginemail']));
1079 $l_email = $DMSAPP_CURRENTEMAIL;
1081 $user_row = ReturnUserRecord(LOCAL_USER_QUERY_SRC_EMAIL, $l_email);
1082 if (isset($user_row[
'userid'])) {
1083 if (intval($user_row[
'failedloginattempts']) >= $DMSAPP_FAILEDLOGINATTEMPTS) {
1084 header(
"Location: {$self}f=intro&status=8");
1088 $user_device_cookiename = ReturnDeviceCookieName($DMSAPP_CURRENTCUCODE, DMSAPP_CONST_APP_LOGIN, $l_email, $user_row[
'userid']);
1089 $User_Device_Set = 0;
1091 $User_Quest_Set = 0;
1107 if ($form_validated_device) {
1109 $User_Device_Set = 1;
1111 } elseif (isset($_COOKIE[$user_device_cookiename])) {
1115 $expectedCookieVal = sha1($DMSAPP_SECRET_KEY . trim($user_row[
'pwd']) . trim($user_row[
'email']) . trim($user_row[
'confidenceword']) . trim($user_row[
'banking_user_id']));
1118 if ($expectedCookieVal == $_COOKIE[$user_device_cookiename]) {
1120 $User_Device_Set = 1;
1123 $User_Device_Set = 0;
1128 $User_Device_Set = 0;
1135 if (isset($_POST[
'loginemail'])) {
1136 header(
"Location: {$self}f=intro&status=2");
1139 header(
"Location: {$self}f=intro");
1159 $form_pwd_script =
" 1161 " . ($FORM_VALIDATION_ERROR !=
"" ?
"$('#summary-container').css('display', 'inline-block');" :
"") .
" 1165 $sql =
"SELECT COUNT(u_qs.userid) as quest_select 1166 FROM {$DB_TABLE_PREFIX}user_questselect as u_qs 1167 JOIN {$DB_TABLE_PREFIX}user as u on u.userid = u_qs.userid 1168 WHERE email = '" . save_text($l_email, 50) .
"' 1169 AND cu = '" . save_text($DMSAPP_CURRENTCUCODE) .
"' 1170 AND coalesce(userlogintype, '') <> 'H' ";
1171 $cnt_rs = db_query($sql, $dbh);
1172 $cnt_row = db_fetch_assoc($cnt_rs);
1174 if ($cnt_row[
'quest_select'] == 0) {
1178 $User_Quest_Set = 0;
1180 $User_Quest_Set = 1;
1183 if ($User_Device_Set == 0 && $User_Quest_Set > 0) {
1188 if ($user_row[
'challenge_quest_id'] > 0) {
1189 $select_questid = $user_row[
'challenge_quest_id'];
1197 FROM {$DB_TABLE_PREFIX}user_questselect as u_qs 1198 JOIN {$DB_TABLE_PREFIX}user as u on u.userid = u_qs.userid 1199 WHERE email = '" . save_text($l_email, 50) .
"' 1200 AND cu = '" . save_text($DMSAPP_CURRENTCUCODE) .
"' 1201 AND coalesce(userlogintype, '') <> 'H' 1202 ORDER BY RANDOM() LIMIT 1";
1204 $qst_rs = db_query($sql, $dbh);
1205 $qst_row = db_fetch_array($qst_rs);
1207 $select_questid = $qst_row[
'questid'];
1209 $sql =
"UPDATE {$DB_TABLE_PREFIX}user 1210 SET challenge_quest_id = " . intval($select_questid) .
" 1211 WHERE email = '" . save_text($l_email, 50) .
"' 1212 AND cu = '" . save_text($DMSAPP_CURRENTCUCODE) .
"' 1213 AND coalesce(userlogintype, '') <> 'H' ";
1216 if (!$upd_rs = db_query($sql, $dbh)) {
1218 header(
"Location: {$self}f=intro&status=999");
1225 $challenge_quest_text = $DMSAPP_QuestMaster_Ary[$select_questid];
1227 print <<< challenge_form
1229 <div
class=
"container-fluid">
1232 <div
class=
"lnapp-form-section lnapp-summary-wrap col-xs-12 col-md-offset-3 col-md-6" style=
"">
1233 <div
id=
"summary-container" class=
"validity-summary-container errors" >
1234 <div
class=
"alert alert-danger">
1235 <p><em>You may not
continue. the following errors were encountered:</em></p>
1237 $FORM_VALIDATION_ERROR
1244 <form
id=
"app_settings" name=
"app_settings" action=
"{$self}f=confirmuser" method=
"post">
1245 <input type=
"hidden" name=
"form_set" value=
"$form_code">
1246 <input type=
"hidden" name=
"loginemail" value=
"$l_email">
1249 <div
class=
"col-xs-12 col-sm-offset-3 col-sm-6">
1251 <div
class=
"alert alert-warning" role=
"alert">
1252 <strong>We
do not recognize the device you are
using.</strong><br>
1253 Please answer the question below to confirm your identity.
1256 <div
class=
"panel panel-default">
1257 <div
class=
"panel-heading">
1258 <h2
class=
"panel-title">Challenge Question</h2>
1260 <div
class=
"panel-body">
1261 <div
class=
"form-horizontal">
1262 <div
class=
"form-group">
1263 <label
class=
'col-xs-12' for=
"chg_resp">$challenge_quest_text</label>
1264 <div
class=
"col-xs-12">
1265 <input
id=
"chg_resp" class=
"form-control" name=
"chg_resp" type=
"text" size=
"30" maxlength=
"100" class=
"text-input"/>
1269 <div
class=
"form-group">
1270 <div
class=
"col-xs-12">
1273 <input type=
'radio' id=
'chksecureY' name=
'chksecure' value=
'Y' checked/>
1279 For your convenience, we will not require additional authentication when you log in from
this device.
1280 We may occasionally require additional authentication to make sure you still want the system to recognize
this device.
1285 <div
class=
"col-xs-12">
1288 <input type=
'radio' id=
'chksecureN' name=
'chksecure' value=
'N' />
1289 No,
do not remember it
1294 We will
continue to require additional authentication whenever you log in from
this device.
1306 <div
class=
"col-xs-12 col-sm-offset-3 col-sm-6">
1308 <input type=
"hidden" name=
"confchallenge" value=
"Confirm Answer">
1309 <a
class=
"k-button k-primary" href=
"#" id=
'linkFormPost' label=
'Submit'><span>Confirm Answer</span></a>
1316 <script type=
"text/javascript">
1317 $(document).ready(
function() {
1319 \$(
'#app_settings').bind(
"keydown",
function(event) {
1321 var keycode = (
event.keyCode ?
event.keyCode : (
event.which ?
event.which :
event.charCode));
1322 if (keycode == 13) {
1324 \$(
'#app_settings').submit();
1331 \$(
'#linkFormPost').click(
function() {
1332 \$(
"#app_settings").submit();
1334 $(
'#chg_resp').focus();
1342 }
else if ($User_Pwd_Set == 0) {
1345 $print_confword =
'';
1346 if ($User_Quest_Set > 0 ) {
1347 $confWord =
"" . disp_text($user_row[
'confidenceword']);
1348 $print_confword =
"<label class='col-xs-12' for='chg_resp'>Confidence Word:</label><div class='col-xs-12'><input id='chg_resp' class='form-control' name='chg_resp' type='text' size='30' maxlength='100' class='text-input' value='$confWord' disabled/></div>";
1351 if ($FORM_VALIDATION_ERROR ==
'') {
1352 $FORM_VALIDATION_ERROR =
"User registration was not completed. Please confirm your password.";
1355 if ($FORM_VALIDATION_ERROR !=
'') {
1357 print <<< password_form
1359 <div
class=
"container-fluid">
1361 <div
class=
"lnapp-form-section lnapp-summary-wrap col-xs-12 col-md-offset-3 col-md-6">
1362 <div
id=
"summary-container" class=
"validity-summary-container errors" >
1363 <div
class=
"alert alert-danger">
1364 <p><em>You may not
continue. the following errors were encountered:</em></p>
1366 $FORM_VALIDATION_ERROR
1373 <form
id=
"app_settings" name=
"app_settings" action=
"{$self}f=confirmuser" method=
"post">
1374 <input type=
"hidden" name=
"form_set" value=
"$form_code">
1375 <input type=
"hidden" name=
"loginemail" value=
"$l_email">
1377 <div
class=
"col-xs-12 col-sm-offset-3 col-sm-6">
1378 <div
class=
"panel panel-default">
1379 <div
class=
"panel-heading">
1380 <h2
class=
"panel-title">Enter Password</h2>
1382 <div
class=
"panel-body">
1383 <div
class=
"form-horizontal">
1384 <div
class=
"form-group">
1387 <div
class=
"form-group">
1388 <label
class=
'col-xs-12' for=
"loginpassword">Password:</label>
1389 <div
class=
"col-xs-12">
1390 <input
id=
"loginpassword" name=
"loginpassword" type=
"password" size=
"30" maxlength=
"100" class=
"form-control"/>
1395 <div
class=
"col-xs-12 col-sm-6">
1396 <input type=
"hidden" name=
"confpassword" value=
"Login">
1397 <a
class=
"k-button k-primary" href=
"#" id=
'linkFormPost' label=
'Submit'><span>Login</span></a>
1402 <script type=
"text/javascript">
1403 $(document).ready(
function() {
1405 \$(
'#app_settings').bind(
"keydown",
function(event) {
1407 var keycode = (
event.keyCode ?
event.keyCode : (
event.which ?
event.which :
event.charCode));
1408 if (keycode == 13) {
1410 \$(
'#app_settings').submit();
1417 \$(
'#linkFormPost').click(
function() {
1418 \$(
"#app_settings").submit();
1421 $(
'#loginpassword').focus();
1431 if ($FORM_VALIDATION_ERROR !=
'') {
1432 print
"<script language='javascript'>$('#summary-container').css('display', 'inline-block');</script>";
1438 header(
"Location: {$self}f=intro&status=999");
1451 $error_loadform = 2;
1454 function ReturnQuestMasterOption() {
1455 global $DMSAPP_QuestMaster_Ary;
1459 foreach ($DMSAPP_QuestMaster_Ary as $rowkey => $rowval) {
1460 $Ret_Option .=
"<option value='$rowkey'>$rowval</option>";
1470 function ReturnUserRecord($p_SrcType, $p_SrcValue, $p_RefreshData =
false) {
1471 global $dbh, $DB_TABLE_PREFIX, $DMSAPP_CURRENTCUCODE;
1472 static $l_user_rs, $l_user_row;
1479 if ((!isset($l_user_rs) && !isset($l_user_row) && isset($dbh)) || (isset($dbh) && $p_RefreshData)) {
1482 FROM {$DB_TABLE_PREFIX}user ";
1484 $sql .=
" WHERE userid = " . intval($p_SrcValue) .
"; ";
1486 $sql .=
" WHERE email = '" . save_text($p_SrcValue, 50) .
"' AND cu = '" . save_text($DMSAPP_CURRENTCUCODE) .
"'; ";
1489 $l_user_rs = db_query($sql, $dbh);
1491 $l_user_row = db_fetch_array($l_user_rs);