Odyssey
lnappsecurity.i
1 <?php
2  /*
3  * Form: lnappsecurity
4  * Purpose: To retrieve security information for several purposes
5  * Usage: For now i am writing this so when it is needed it will be included
6  * using the include_once function.
7  * Requirements:
8  * Some variables will need to be set prior to including this function
9  * so it can properly redirect the information.. I am thinking about
10  * redirect after posting to itself.
11  *
12  * Required Variables:
13  * lnapp_security_return_form_code - This is the form_code value that will
14  * be redirected to after the information is confirmed..
15  * form name $_POST['ret_fc']
16  * lnapp_security_params - This is a single variable containing the list of
17  * URL parameters that will be redirected to the form_code (along with the
18  * security token)
19  * form name $_POST['ret_param']
20  * lnapp_security_respid {PENDING}- This is a required field containg the respid that
21  * I need to possibly authenticate against...
22  * form name $_POST['ret_rid']
23  *
24  * Variables Set:
25  * This routine will take the pieces of information given to it and create
26  * a sha1 hash value and forward this value to the redirected form in
27  * the variable 'confid'
28  */
29 
30  $FORM_VALIDATION_ERROR = '';
31  // ** IF we are handling a post of the current security form then I need to
32  // * confirm the information is all entered.
33  // * If the information is all there then I will need to create confid and
34  // * redirect to the correct form_code
35  if (HCU_array_key_value('confirmsecurity', $_POST)) {
36  // * *Be sure all fields are entered.
37 
38  // * SSN
39  if (trim($_POST['app_ssn']) == '') {
40  $FORM_VALIDATION_ERROR .= '<li>SSN must be entered.</li>';
41  }
42  // * Date of Birth
43  if (trim($_POST['app_dob']) == '') {
44  $FORM_VALIDATION_ERROR .= '<li>Date of Birth must be entered.</li>';
45  }
46 
47  if ($FORM_VALIDATION_ERROR != '') {
48  $FORM_VALIDATION_ERROR = "<br>Please check the errors and try again.<br>$FORM_VALIDATION_ERROR";
49  } else {
50  // ** The information looked okay, so i will now redirect to the referenced
51  // * form_code that was in the lnapp_security_return_form_code variable
52 
53  // * Create the confid value
54  $l_cookiename = ReturnDeviceCookieName($DMSAPP_CURRENTCUCODE, $DMSAPP_LOGINTYPE, $DMSAPP_CURRENTEMAIL, $DMSAPP_CURRENTUSERID);
55  // ** Get Cookie Contents and include it with the value being crypted
56  $l_cookieval = $_COOKIE[$l_cookiename];
57 
58  //$confid = crypt(sha1($DMSAPP_SECRET_KEY . strtolower(trim($_POST['app_fname'])) . strtolower(trim($_POST['app_lname'])) . trim($_POST['app_ssn']) . date('mdY', strtotime($_POST['app_dob'])) . $l_cookieval));
59  $confid = crypt(sha1($DMSAPP_SECRET_KEY . trim($_POST['app_ssn']) . date('mdY', strtotime($_POST['app_dob'])) . $l_cookieval), '');
60 
61  header("HTTP/1.1 303 See Other"); // Try setting the 303 response -- this directive should allow the redirect page to NOT be part of the history.. it is the preferred method for Post/Redirect/Get
62  header("Location: {$self}f=" . $_POST['ret_fc'] . "&confid=" . urlencode($confid) . "&" . $_POST['ret_param']);
63  exit;
64  }
65  }
66 
67 ?>
68  <form id="app_security" class="form-horizontal" name="app_security" action="<?php print $self; ?>" method="post">
69  <input type="hidden" name="form_set" value="<?php echo $form_code; ?>">
70  <input type="hidden" name="f" value="checksecurity">
71  <input type="hidden" name="ret_fc" value="<?php echo dms_disphtml($lnapp_security_return_form_code); ?>">
72  <input type="hidden" name="ret_param" value="<?php echo dms_disphtml($lnapp_security_params); ?>">
73  <input type="hidden" name="ret_rid" value="<?php echo dms_disphtml($lnapp_security_respid); ?>">
74 
75  <div class="container-fluid" >
76  <div class="row">
77  <div class="col-xs-12 col-md-6 col-lg-4">
78  <div class="panel panel-default">
79  <div class="panel-heading">
80  <p class="panel-title">Confirm Information</p>
81  </div>
82  <div class="panel-body">
83  <div id="content-single">
84  <p class="h4">Please confirm the following information on this loan.</p>
85 
86  <div class="form-group ">
87  <label class='col-md-3 control-label' for='app_ssn'>SSN:</label>
88  <div class="col-md-9">
89  <input id="app_ssn" name="app_ssn" type="ssn" size="12" class="ssn hcu-all-100" title="SSN"/><span id='eg_ssn' class='egtext'>###-##-####</span>
90  <span id='error_$formfieldname' class=''></span>
91  </div>
92  </div>
93 
94  <div class="form-group ">
95  <label class='col-md-3 control-label' for='app_dob'>Date of Birth:</label>
96  <div class="col-md-9">
97  <input id="app_dob" name="app_dob" type="text" size="12" class=" hcu-all-100" title="Date of Birth"/><span id='eg_dob' class='egtext'>MM/DD/YYYY</span>
98  <span id='error_$formfieldname' class=''></span>
99  </div>
100  </div>
101 
102  </div>
103  </div>
104  </div>
105 
106  <div id="disclosure-buttons" class="">
107 
108  <a class="" href="<?php echo $self_full_url; ?>?f=portal" style="margin-left: 6px" id='btnCancel' label=''><span>Cancel</span></a>
109 
110  <a class="k-button k-primary" href="#" id='linkFormPost' label='Submit'><span>Continue</span></a>
111 
112  <input type="hidden" name="confirmsecurity" value="1">
113  <script language="javascript">
114  $(function(){
115  $('a[id^=linkFormPost]').click(function(){
116  $('#app_security').submit();
117  });
118  });
119  </script>
120  </div>
121  </div>
122  </div>
123  </div>
124  </form>
125  <script language="javascript">
126  $.validity.setup({ outputMode:"custom" });
127  $('#app_ssn').focus();
128 
129  $(document).ready(function() {
130 
131  // ** This line does not bind to the submit button
132  $.homecuValidator.setup( {formValidate: "app_security", formStatusField: 'formStatus'} );
133 
134  $.homecuValidator.settings.formErrorTitle = 'The following error(s) occurred:';
135  $.homecuValidator.displayMessage([""], $.homecuValidator.settings.statusError);
136  $.homecuValidator.settings.formErrorTitle = 'The following error(s) occurred:';
137 
138  //$("input").bind("keydown", function(event) {
139  $('#app_security').bind("keydown", function(event) {
140  // track enter key
141  var keycode = (event.keyCode ? event.keyCode : (event.which ? event.which : event.charCode));
142  if (keycode == 13) { // keycode for enter key
143  // force the 'Enter Key' to implicitly click the Update button
144  //document.getElementById('defaultActionButton').click();
145  $('#app_security').submit();
146  return false;
147  } else {
148  return true;
149  }
150  }); // end of function
151 
152  $("#app_ssn").kendoMaskedTextBox({mask:"###-##-####"});
153  $("#app_dob").kendoMaskedTextBox({mask: "00/00/0000",promptChar: "_"});
154 
155  /* FORM ERRORS */
156  <?php if ($FORM_VALIDATION_ERROR != '') { ?>
157  $.homecuValidator.displayMessage('<?php echo addslashes($FORM_VALIDATION_ERROR); ?>', $.homecuValidator.settings.statusError);
158  <?php } ?>
159 
160  });
161  $(function() {
162  $("#app_security").validity(function() {
163 
164  $('#app_ssn').require();
165  $('input.ssn').match(/^\d{3}-\d{2}-\d{4}$/, "#{field} needs to be in the format of ###-##-####.");
166 
167  $('#app_dob').require();
168  $('input.date').match('date', '#{field} is not a valid date ##/##/####.');
169 
170  });
171  <?php print ($FORM_VALIDATION_ERROR != "" ? "$('#summary-container').css('display', 'inline-block');" : ""); ?>
172  });
173 
174 
175 
176 
177 
178 
179 
180 
181 
182  var pghdr_title = "";
183  var target=null;
184  var lastGroupGo = "";
185  var lastSecurePage = "";
186 
187  /* ** VALIDITY DEFAULTS ** */
188  var
189  // Container contains the summary. This is the element that is shown or hidden.
190  container = ".validity-summary-container",
191 
192  // Erroneous refers to an input with an invalid value,
193  // not the error message itself.
194  erroneous = "validity-erroneous",
195 
196  // Selector for erroneous inputs.
197  errors = "." + erroneous,
198 
199  // The wrapper for entries in the summary.
200  wrapper = "<li/>",
201 
202  // Buffer to contain all the error messages that build up during validation.
203  // When validation ends, it'll be flushed into the summary.
204  // This way, the summary doesn't flicker empty then fill up.
205  buffer = [];
206 
207 
208  $(document).ready(function() {
209 
210 
211  /* ** CONFIGURE VALIDITY ** */
212  $.validity.outputs.custom = {
213  cssClass:"error",
214 
215  start:function() {
216  // Remove all the existing error labels.
217  $("." + $.validity.settings.cssClass)
218  .remove();
219 
220  // ** Reset container errors
221  $(errors).removeClass(erroneous);
222  buffer = [];
223  // ** reset Link Arrow Errors
224  $('li[id ^= "group"]').removeClass('grouperror');
225  $('span[id ^= "error_formfield"]').removeClass('error');
226  $('span[id ^= "error_formfield"]').hide();
227 
228  },
229 
230  end:function(results) {
231  // If not valid and scrollTo is enabled, scroll the page to the first error.
232  if (!results.valid && $.validity.settings.scrollTo) {
233  location.hash = $("." + $.validity.outputs.custom.cssClass + ":eq(0)").attr('for');
234  }
235  // ** SET the container to view Errors
236 
237  // If there are any errors at all:
238  // (Otherwise the container shouldn't be shown):
239  if (buffer.length) {
240  // Use integer based iteration for solution to Issue 7.
241 
242 
243  // * Use Validator message to show summary
244  $.homecuValidator.displayMessage(buffer, $.homecuValidator.settings.statusError);
245 
246  // If scrollTo is enabled, scroll the page to the first error.
247  if ($.validity.settings.scrollTo) {
248  location.hash = $(errors + ":eq(0)").attr("id");
249  }
250  }
251  },
252 
253  raise:function($obj, msg) {
254  var labelSelector = "#error_" + getIdentifier($obj);
255 
256  var field_msg = "";
257  var re = new RegExp('is required.\$');
258  if (msg.match(re)) {
259  field_msg = "Required";
260  } else {
261  field_msg = msg;
262  }
263  field_msg = '<i class="fa fa-exclamation-triangle" aria-hidden="true"></i>&nbsp;' + field_msg;
264  // If an error label already exists for the bad input just update its text:
265  if ($(labelSelector).length) {
266  //$(labelSelector).text(field_msg);
267  // * Use html function to allow font awesome icon
268  $(labelSelector).html(field_msg);
269 
270  $(labelSelector).addClass('error');
271  $(labelSelector).show();
272  }
273 
274  // Otherwize create a new one and stick it after the input:
275  else {
276 
277  labelSelector = "." + $.validity.outputs.custom.cssClass + "[for='" + getIdentifier($obj) + "']";
278  $("<label/>")
279  .attr("for", "error_" + getIdentifier($obj))
280  .attr("id", "error_" + getIdentifier($obj))
281  .addClass($.validity.outputs.custom.cssClass)
282  .html(field_msg)
283  // .text(field_msg)
284 
285  // In the case that the element does not have an id
286  // then the for attribute in the label will not cause
287  // clicking the label to focus the element. This line
288  // will make that happen.
289  .click(function() {
290  if ($obj.length) {
291  $obj[0].select();
292  }
293  })
294 
295  .insertAfter($obj);
296  //.appendTo($obj);
297  }
298 
299  // ** Prepare the container information -- add message to the buffer of messages
300  buffer.push(msg);
301 
302  /*
303  * Add the erroneous class to the input -- Some elements may put this on alternate location
304  */
305  if ($obj.attr('data-role') === 'numerictextbox') {
306  if ($obj.parent().parent('.k-numerictextbox').length > 0) {
307  $obj.parent().parent('.k-numerictextbox').addClass(erroneous);
308  } else {
309  $obj.addClass(erroneous);
310  }
311  } else if ($obj.attr('data-role') === 'dropdownlist') {
312  if ($obj.parent('.k-dropdown').children('.k-dropdown-wrap').length > 0) {
313  $obj.parent('.k-dropdown').children('.k-dropdown-wrap').addClass(erroneous);
314  } else {
315  $obj.addClass(erroneous);
316  }
317  } else if ($obj.attr('data-role') === 'maskedtextbox') {
318  if ($obj.parent().parent('.k-maskedtextbox').length > 0) {
319  $obj.parent().parent('.k-maskedtextbox').addClass(erroneous);
320  } else {
321  $obj.addClass(erroneous);
322  }
323  } else {
324  /*
325  * DEFAULT error class
326  */
327  $obj.addClass(erroneous);
328  }
329  // ** Add arrow to the group link
330  var field_attr = $obj.attr("group");
331  // Find the object and add class of grouperror
332  $('#' + field_attr).addClass('grouperror');
333  },
334 
335  raiseAggregate:function($obj, msg) {
336  // Just raise the error on the last input.
337 
338  this.raise($obj, msg);
339  },
340  container:function() {
341 
342  }
343  };
344 
345 
346 
347 
348  });
349 
350  function getIdentifier($obj) {
351  return $obj.attr('id').length ? $obj.attr('id') : $obj.attr('name');
352  }
353 
354 
355 
356 
357 
358 
359 
360 
361 
362 
363 
364 
365  </script>