Odyssey
LoanApp.prg
1 <?php
2  /*
3  * Script: AppMain
4  * Purpose: To be the container script for all the pages.. Gives the commone
5  * layout and calls the appropriate scripts for css layout, which I
6  * am hoping can be possibly branded.. including the menu, logo,
7  * etc.. fingers crossed
8  *
9  * -- Thinking this may exist in admbin, this directory is common for all
10  * servers..little outside of normal useage
11 
12  * Need to define how I setup the permissions to work IF the credit union is offline/
13  * There are 3 variables that are set
14  * DMSAPP_CULIVE - {true, false} This is the live setting of the credit union / this is
15  * determined by the location of the script running /hculive7 is live, else batch
16  *
17  * DMSAPP_ONLINE - {1, 0} This is ONLY set for DMSAPP_CULIVE set to true, Batch may NOT be online
18  * This will determine if loans are submitted to their core system.
19  * This value can be overriden using the configuration options for the CU
20  *
21  * DMSAPP_SUBMITMBR - {1, 0} This is ONLY set if we need to send the member Number to the Core
22  * Has NO affect if DMSAPP_ONLINE is false
23  * 1 - ie CRUISE - Loans are based on the primary member applying
24  * 0 - ie CU-CENTRIC
25  *
26  * DMSAPP_LOANFORMAT - {SERIAL, JSON, XML} This is the type of data that is sent to the core.
27  * SERIAL - PHP Serialized object is sent to core
28  * JSON - JSON encoded object is sent to core
29  * XML - data is encoded with XML tags and sent to core
30  *
31  * DMSAPP_FETCHMIR - {1, 0} This value is set from the configuration options for the CU, but will
32  * ALWAYS be 0 for batch and only allowed to be set for live.
33  *
34  * DMSAPP_SSOONLY - {1, 0 default} This will determine if the stand alone login feature is disabled.
35  * 1 - Standalone Login is disabled, 0 - Standalone login is allowed
36  *
37  * DMSAPP_DISABLEEMAIL - {1, 0 default} This determines if the loan application system allows login outside of home banking
38  * 1 - Login via email (not linked from home banking) is not allowed, 0 - user may login by email or Home Banking Credentials
39  *
40  * DMSAPP_MODE_ARY['offline'] - {true, false} This is the value returned from hcu_checkoffline
41  * True if the script may continue, false if we stop
42  * DMSAPP_MODE_ARY['offlineReadonly'] - {true, false} this is True only when the offline status
43  * is R, this is needed because some scripts allow readonly status
44  * , but I want to limit procedures within those scripts.
45  *
46  * DMSAPP_LOANDATAONLY - {1, 0 (default)} Restrict submitting field if it is empty?
47  * 1 - ONLY fields with data will be submitted to the core
48  * 0 - ALL defined fields will be submitted to the core
49  *
50  * DMSAPP_HOST - The hostname where the loan app is currently running ie wwwX.homecu.net
51  *
52  *
53  * ACTION DMSAPP_CULIVE DMSAPP_ONLINE MODE['offline'] MODE['offlineReadonly']
54  * Log into system
55  * FALSE false 0 false {true, false}
56  * TRUE {true, false} 1 {true, false} {true, false}
57  *
58  * Portal screen
59  * - ADD new app / edit current app
60  * false false 0 true {true}
61  * true {true, false} {0, 1} {true} {true, false}
62  *
63  * - Inquire Application
64  * false false 0 {true, false} {true, false}
65  * false true 1 false N/A
66  * false true 0 {true, false} N/A
67  * true true 1 {true} N/A
68  *
69  * Entry Screen
70  * - Save app
71  * true -- If I can access it, I will allow save, limiting is done in previous step
72  *
73  * - Submit Application to core
74  * false {true, false} 0 {true, false} {true, false}
75  * false true 1 false false
76  * true true 1 true N/A
77  *
78  *
79 */
80 
81  // ** DEFINE CONSTANTS (but using variable definition style
82  $cloudfrontDomainName = 'd1kryjpwpzirc7.cloudfront.net';
83  $homecuKendoVersion = 'v2017.3.913';
84 
85  $DB_TABLE_PREFIX = "lnapp";
86  $DMSAPP_CHALLENGEQUESTIONS_COUNT = 3;
87  $DMSAPP_PRODUCTNAME = "Online Loan App";
88  $DMSAPP_HOST = $_SERVER['HTTP_HOST'];
89 
90  /*
91  * * SET DEFAULT VALUES FOR SCRIPT FLAGS
92  */
93  $serviceMinimal = (!isset($serviceMinimal) ? false : $serviceMinimal);
94  $serviceSkipCredentials = (!isset($serviceSkipCredentials) ? false : $serviceSkipCredentials);
95  $serviceSkipSecurity = (!isset($serviceSkipSecurity) ? false : $serviceSkipSecurity);
96  $serviceAllowReadonly = (!isset($serviceAllowReadonly) ? false : $serviceAllowReadonly);
97  $serviceShowInfo = (!isset($serviceShowInfo) ? false : $serviceShowInfo);
98  $serviceLoadMenu = (!isset($serviceLoadMenu) ? false : $serviceLoadMenu);
99  $serviceShowMenu = (!isset($serviceShowMenu) ? false : $serviceShowMenu);
100  // * DO NOT default serviceMenuScript to anything
101  $serviceMenuScript = (!isset($serviceMenuScript) ? "" : $serviceMenuScript);
102  //$serviceMenuScript = (!isset($serviceMenuScript) ? "hcuAccounts" : $serviceMenuScript);
103  $serviceLiveCheck = (!isset($serviceLiveCheck) ? false : $serviceLiveCheck);
104  $serviceLoadCuInfo = (!isset($serviceLoadCuInfo) ? true : $serviceLoadCuInfo);
105  $serviceSuppressBanner = (!isset($serviceSuppressBanner) ? false : $serviceSuppressBanner);
106 
107  $validLanguageCodes = Array("en_US", "es_US", "pl_US");
108  $serviceViewFromCuAdmin= false;
109 
110  /**
111  * DECLARE HB_ENV as an array
112  */
113  $HB_ENV = Array();
114 
115 // $fetcher = "http://192.168.169.11/hculive/hculiveapp.mp";
116 
117 
118  $inc_path = dirname(__FILE__) . '/../includes/';
119  $lib_path = dirname(__FILE__) . '/../library/';
120 
121 
122  // ** Include the Global Script for Error Handling
123  require_once(dirname(__FILE__) . '/../../shared/library/hcuLogError.i');
124  require_once(dirname(__FILE__) . '/../../shared/library/hcuCommon.i');
125  require_once(dirname(__FILE__) . '/../../shared/library/logging.i');
126  require_once(dirname(__FILE__) . '/../../shared/library/hcuEnv.i');
127  require_once(dirname(__FILE__) . '/../../shared/library/cu_flagconst.i');
128  require_once(dirname(__FILE__) . '/../../shared/library/cu_fun.i');
129  require_once(dirname(__FILE__) . '/../../shared/library/errormail.i');
130  require_once(dirname(__FILE__) . '/../../shared/library/cu_func.i');
131  require_once(dirname(__FILE__) . '/../../shared/library/commonJsFunctions.i');
132  require_once(dirname(__FILE__) . '/../../shared/library/cu_data.i');
133  require_once(dirname(__FILE__) . '/../../banking/library/cu_credentials.i');
134  require_once(dirname(__FILE__) . "/../../shared/library/hcuTranslate.i");
135  require_once(dirname(__FILE__) . '/../../shared/library/dms_imp_val.i');
136  require_once(dirname(__FILE__) . '/../../monitor/library/monitorFunctions.i');
137  require_once(dirname(__FILE__) . '/../../shared/library/cuDataModel.i');
138 
139  // ** Home Banking Desktop Functions
140  require_once(dirname(__FILE__) . '/../../banking/library/hcuDispFunctions.i');
141  require_once(dirname(__FILE__) . '/../../shared/library/hcuFunctions.i');
142 
143  // ** Feature Gate support
144  require_once(dirname(__FILE__) . '/../../shared/library/FeatureGateConfig.i');
145  require_once(dirname(__FILE__) . '/../../shared/library/CreditUnionGate.i');
146 
147  /* LOAD ENVIRONMENT DATA */
148  // set up the environment based on environment variables
149  $HB_ENV['SYSENV'] = LoadSystemEnv("eforms");
150 
151 // $errHndlr = new CatchErrorHandler(HCU_PRODUCT_BANKING, $HB_ENV['SYSENV']['logger'], $HB_ENV['SYSENV']['devmode']);
152 // $excHndlr = new CatchExceptionHandler(HCU_PRODUCT_BANKING, $HB_ENV['SYSENV']['logger'], $HB_ENV['SYSENV']['devmode']);
153 
154  // ** SET ENVIRONMENT VARIABLES
155  SetEnvStatic( $HB_ENV );
156 
157  /**
158  * Setup the error handling class
159  *
160  */
161 // set_error_handler(array($errHndlr, "catchError"));
162 // set_exception_handler(array($excHndlr, "catchException"));
163 
164  $dbPluginFile = "db." . $HB_ENV['SYSENV']['db']['platform'] . ".i";
165  // ** Include the database plugin file. This file will include the database function declarations
166  include (dirname(__FILE__) . '/../../shared/library/' . $dbPluginFile);
167 
168 
169  // get and save the DB handle (call after SYSENV is set up)
170  $dbh = GetDBH( $HB_ENV['SYSENV']['db'] );
171  $HB_ENV["dbh"] = $dbh;
172 
173  $HB_ENV['Flang'] = "en_US";
174  $MC = new hcu_talk_base($HB_ENV['Flang']);
175  $HB_ENV["MC"] = $MC;
176 
177  // ** This will be the base path using http reference -- for INCLUDE directories
178  $http_script_path = "/eforms/static/";
179 
180  // ** self now includes the ? at the end, any reference to self will not need a separator by default
181  $self = $_SERVER['PHP_SELF'] . "?";
182  $self_container = $_SERVER['SCRIPT_NAME'];
183 
184  $self_full_url = $_SERVER['SCRIPT_URI'];
185 
186  define("DMSAPP_CONST_HB_LOGIN", "H");
187  define("DMSAPP_CONST_MIR_LOGIN", "N");
188  define("DMSAPP_CONST_APP_LOGIN", "L");
189 
190  // ** DMSAPP_ID_CookieString -- This is an encoded value of the CU Code
191  // -- use decrypt function with the MasterKey to retrieve the CU Code
192  $DMSAPP_ID_CookieString = "{$DB_TABLE_PREFIX}id";
193  // ** UserID_CookieString -- This cookie will contain the userid of the
194  // Current logged in userid..
195  $DMSAPP_USERID_CookieString = "{$DB_TABLE_PREFIX}uid";
196  // ** DEVICEID_CookieString -- This cookie will contain the
197  // * This string is not a constant as it will be created based on the
198  // The string sha1{DB_TABLE_PREFIX}{cucode}Tu0geethSaith7ch{email}
199  // The value set will be a sha1({ENCRYPTEDPWD}{email}{confword})
200 
201  $DMSAPP_CUHOME_PATH = ""; // * THIS will be the path to the CU Directory where disclosure fragments/files will be saved
202  $DMSAPP_ALLOW_HB_LOGIN = 1; // Does the Loan application login allow for the member using their homeCU Credentials
203 
204  $DMSAPP_SSOONLY = 0; // * Default is to allow access from Home Banking Menu and Direct login
205  $DMSAPP_DISABLEEMAIL = 0; // * Default is to allow email login from Direct Login screen
206  $DMSAPP_LOANDATAONLY = 0; // * Default is to submit all defined fields
207 
208  // * Product Name
209  $DMSAPP_PRODUCTNAME = '';
210  // * Credit Union Name
211  $DMSAPP_CUNAME = '';
212 
213 // MWS DEBUG -- Change back to 15
214  $DMSAPP_Cookie_ExpireTime = 100;
215  $DMSAPP_Cookie_Domain = "localhost:8000";
216  $DMSAPP_SECRET_KEY = 'c8Zg6X57yA7R5lv57hHH0oBrn0bZRPEl';
217 
218  $DMSAPP_FAILEDLOGINATTEMPTS = 5; // set the number of failed login attempts the user may have before failing
219  // ** Device Cookie is valid for 94 days
220  $DMSAPP_Device_Cookie_ExpireTime = 8121600;
221 
222 
223  $DMSAPP_CURRENTUSERID = "";
224  $DMSAPP_CURRENTEMAIL = "";
225  $DMSAPP_CURRENTCUCODE = "";
226 
227  /**
228  * *
229  * LOAD CONFIGURATION
230  * *
231  *
232  */
233 
234 
235  $DMSAPP_LOGINTYPE = ""; // ** This value should be either H or L for verified login
236 
237  // * SET THE CU TYPE
238  // {true - LIVE / false - BATCH }
239  $DMSAPP_CULIVE = (substr(dirname($_SERVER['PHP_SELF']), 0, strlen('/hculive7')) == '/hculive7');
240 
241  $DMSAPP_ONLINE = ($DMSAPP_CULIVE ? "1" : "0"); // ** This will determine if the throtlpkt is loaded and whether loans are even sent to the core
242  // ** NOTE:: we should allow a "live" CU to have this loan app, but not be posting to the core.
243  // ** prevent batch credit unions from having the online status set -- eventually this is where the setting will be for live cu's that do
244  // * do NOT post this app to core
245  $DMSAPP_FORMAT = "SERIAL"; // ** DEFAULT FORMAT TYPE -- MATCHES CU-CENTRIC
246  $DMSAPP_FETCHMIR = 0;
247  // ** offline Readonly is to help me to identify if the credit union is offline for readonly mode
248  // ** some scripts I will have different permissions. I will allow the script as a whole to be executed
249  // ** however, I will NOT let them do certain features for READONLY
250  $DMSAPP_MODE_ARY = Array("offline" => "", "offlineReadonly" => false, "offlineDesc" => ""); // ** Combined with DMSAPP_ONLINE will allow the loan system
251  // * to either shut off completely or to still allow some submissions.
252 
253 
254  $DMSAPP_CSS = "/eforms/static/css/style.css";
255  // ** set the default login messages for member / non members.
256  // ** these are used in lnappintro to display on the intro screen
257  $DMSAPP_MBRMSG = "";
258  $DMSAPP_NONMBRMSG = "";
259 
260  // ** SET VALUE EMPTY SO IT MAY NOT BE hacked
261  $Admin_View_App = 0;
262 
263  $serviceShowInfo = false;
264 
265  // ** Default Values Defined
266  // form2load - this is the name of the script that I will be loading.
267  $form2load = "";
268  // ** By default we ALWAYS load the template screen -- BUT for other purposes
269  // * This may skipped -- Setting this to true will ONLY load script and skip
270  // * the template container
271  $load_scriptonly = false;
272  // error_loadform -- This is a variable to handle erros
273  /*
274  * Possible values {0} - NO ERROR
275  * {1} - ERROR -- FORM NOT FOUND
276  * {2} - ERROR -- FORM FOUND -- BUT UNEXPECTED ERROR (ie database lost connection)
277  */
278  $error_loadform = 0;
279 
280  // ** INCLUDE LOAN APP FUNCTIONS
281  include_once($lib_path . "lnappfunctions.i");
282 
283  /**
284  * GET POSSIBLE VALUES FROM THE URL
285  * id - This is a encrypted value of the CU Code
286  * f - this helps determine where the information is coming from
287  * hbssouser - This will load the online banking user with a sort of SSO Verification
288  */
289  $loadedValues = array();
290  HCU_ImportVars($loadedValues, "url", array("id" => HCUFILTER_INPUT_STRING, "f" => HCUFILTER_INPUT_STRING, "appinit" => HCUFILTER_INPUT_STRING, "review" => HCUFILTER_INPUT_DIGITS));
291 
292 
293  // GET the current ID -- there are these possiblities
294  /* Cookie['dmsappid'] --- Get['id']
295  * cookie['dmsappid'] is set and Get['id'] is NOT set -- then use the cookie id
296  * cookie['dmsappid'] is NOT set and get['id'] is set -- use the get id AND set the cookie
297  * cookie['dmsappid'] is set and get['id'] is set --
298  * If they are equal use the cookie['dmsappid']
299  * If they are NOT equal, then there is a problem
300  * The cookie should clear with the browser
301  */
302 
303  /*
304  * id_status possible values
305  * -1 - Error occurred - This is a generic error
306  * -2 - Error occurred - The browser needs to be closed -- ids do not match
307  * 0 - No Error - use Cookie id value
308  * 1 - No Error - use url id value / SET the cookie value
309  */
310  $id_status = "";
311  // if appinit is set to 1, then USE THE id value, not the cookie
312 
313  // if (!isset($_COOKIE[$DMSAPP_ID_CookieString]) && !isset($_GET['id'])) {
314  if (!isset($_COOKIE[$DMSAPP_ID_CookieString]) && !hcu_array_key_exists('id', $loadedValues['url'])){
315  // ** PROBLEM -- NO ID is set
316  $id_status = -1;
317  //} elseif (isset($_GET['appinit']) && isset($_GET['id'])) {
318  } elseif (hcu_array_key_exists('appinit', $loadedValues['url']) && hcu_array_key_exists('id', $loadedValues['url'])) {
319  // * if appinit IS set and so is the ID, then LOAD THE id from URL, NOT COOKIE
320  $id_status = 1;
321  //} elseif (!isset($_COOKIE[$DMSAPP_ID_CookieString]) && isset($_GET['id'])) {
322  } elseif (!isset($_COOKIE[$DMSAPP_ID_CookieString]) && hcu_array_key_exists('id', $loadedValues['url'])) {
323  // ** Use ID from the URL /set cookie
324  $id_status = 1;
325  //} elseif (isset($_COOKIE[$DMSAPP_ID_CookieString]) && !isset($_GET['id'])) {
326  } elseif (isset($_COOKIE[$DMSAPP_ID_CookieString]) && !hcu_array_key_exists('id', $loadedValues['url'])) {
327  // **Use the Cookie ID
328  $id_status = 0;
329  //} elseif (isset($_COOKIE[$DMSAPP_ID_CookieString]) && isset($_GET['id'])) {
330  } elseif (isset($_COOKIE[$DMSAPP_ID_CookieString]) && hcu_array_key_exists('id', $loadedValues['url'])) {
331  //if ($_COOKIE[$DMSAPP_ID_CookieString] == $_GET['id']) {
332  if ($_COOKIE[$DMSAPP_ID_CookieString] == $loadedValues['url']['id']) {
333  // ** Use the Cookie ID
334  $id_status = 0;
335  } else {
336  // ** They do NOT equal -- they are already using the application for
337  // * They will need to start over by closing browsers
338  $id_status = -2;
339  }
340  } else {
341  // ** SHOULD NOT GET HERE -- GENERAL ERROR
342  $id_status = -1;
343  }
344 
345  switch ($id_status) {
346  case -1:
347  // ** Is cookie support enabled??
348  case -2:
349  // ** ERROR OUT
350  break;
351  case 1:
352 
353  // ** Retrieve the id // SEt the cookie
354  $l_cucode_hash = hcu_array_key_value('id', $loadedValues['url']);
355  HCU_setcookie_env($HB_ENV['SYSENV'], $DMSAPP_ID_CookieString, $l_cucode_hash);
356  break;
357  case 0:
358  $l_cucode_hash = $_COOKIE[$DMSAPP_ID_CookieString];
359  break;
360  }
361 
362  // ** Now decrypt the code and retrieve the cucode
363  if ($id_status == 0 || $id_status == 1 && $l_cucode_hash != '') {
364  $self .= "id=" . urlencode($l_cucode_hash) . "&";
365  // * Check here for the form to load
366  $form_code = strtolower(hcu_array_key_value('f', $loadedValues['url']));
367  $check_credentials = True; // ** Assume we check, unless set otherwise
368  $hbuser_cookie_user = False; // ** Use the user_id from teh cookie to lookup the current user,
369 
370  // ** DECODE TEHE VALUE I HAVE
371  $DMSAPP_CURRENTCUCODE = trim(decrypt($l_cucode_hash, $MasterKey));
372 
373  // ** Verify the CU Code looks correct. An invalid hash will come back with bad results
374  if (preg_match('/^[\w\W\d]{2,10}$/', $DMSAPP_CURRENTCUCODE)) {
375 
376  // ** IF I have all I need, Load the REQUIRED FILES
377  // ** REQUIRE FILES
378  $cu = $DMSAPP_CURRENTCUCODE;
379 
380  /*
381  * Setup all needed information in HB_ENV
382  */
383  $HB_ENV['cu'] = $DMSAPP_CURRENTCUCODE;
384  $HB_ENV['Cu'] = $DMSAPP_CURRENTCUCODE;
385  $HB_ENV['chome'] = strtolower($DMSAPP_CURRENTCUCODE);
386  $HB_ENV['live'] = $DMSAPP_CULIVE;
387  $HB_ENV['testmenu'] = 0;
388  $HB_ENV['DB_TABLE_PREFIX'] = $DB_TABLE_PREFIX;
389  $HB_ENV['DMSAPP_ONLINE'] = $DMSAPP_ONLINE;
390  $HB_ENV['DMSAPP_MODE_ARY'] = $DMSAPP_MODE_ARY;
391 
392  // ** Determine platform -- For now this is hardcoded to DESKTOP
393  $HB_ENV['platform'] = 'DSK';
394 
395 
396  LoadCUAdmin( $dbh, $HB_ENV['cu'], $HB_ENV );
397 
398  /* Deprecated libraries
399  require_once(dirname(__FILE__) . '/../../../shared/library/''/home/httpd/hcuinc/dbfunc.i');
400  require_once(dirname(__FILE__) . '/../../../shared/library/''/home/httpd/hcuinc/dbenv.i');
401  require_once(dirname(__FILE__) . '/../../../shared/library/''/home/httpd/hcuinc/cu_common_intl.i');
402  require_once(dirname(__FILE__) . '/../../../shared/library/''/home/httpd/hcuinc/setLang.i');
403  require_once(dirname(__FILE__) . '/../../../shared/library/''/home/httpd/hcuinc/hcutalk.i');
404 
405 
406 
407  //** OPEN DB Connection
408  $dbh = db_pconnect();
409  */
410 
411 
412  // ** We now know the credit union. --
413  // ** determine the offline stat
414 
415 
416  /*
417  // * Retrieve the cookie for user ID
418  if (isset($_COOKIE[$DMSAPP_USERID_CookieString])) {
419 
420  $l_check_userid = trim(decrypt($_COOKIE[$DMSAPP_USERID_CookieString], $MasterKey));
421  if (intval($l_check_userid) == $l_check_userid) {
422 
423  // * Get the current user
424  $DMSAPP_CURRENTUSERID = $l_check_userid;
425  // ** I know it is extra, but RIGHT here I am going to check to authenticate
426  // * this userid is setup for the $DMSAPP_CURRENTCUCODE (cu).. Otherwise I will fall out. gracefully??
427  $sql = "SELECT *
428  FROM {$DB_TABLE_PREFIX}user
429  WHERE userid = '" . intval($DMSAPP_CURRENTUSERID) . "' ";
430  } else {
431  // SOMETHING is wrong with the cookie value -- do NOT set the current userid..
432 
433  }
434  }
435 */
436 
437  // ** LOAD INFORMATION FROM cuadmin
438  $sql = "SELECT pname, min_chlng_qst, retrylimit, orgname, flagset2, livebatch
439  FROM cuadmin
440  WHERE cu = '" . prep_save($cu, 12) . "'; ";
441  $cu_rs = db_query($sql, $dbh);
442 
443  if (db_num_rows($cu_rs) > 0) {
444 
445 
446  // ** Load other fields from database
447  $cu_row = db_fetch_assoc($cu_rs);
448  // ** OVERRIDE DEFAULT VALUES
449 
450  // * SET THE CU TYPE
451  // {true - LIVE / false - BATCH }
452  $DMSAPP_CULIVE = (trim($cu_row['livebatch']) == 'L' ? true : false);
453 
454  $DMSAPP_ONLINE = ($DMSAPP_CULIVE ? "1" : "0"); // ** This will determine if the throtlpkt is loaded and whether loans are even sent to the core
455  // ** NOTE:: we should allow a "live" CU to have this loan app, but not be posting to the core.
456  // ** prevent batch credit unions from having the online status set -- eventually this is where the setting will be for live cu's that do
457  // * do NOT post this app to core
458 
459 
460  // ** Min Challenge Questions
461  $DMSAPP_CHALLENGEQUESTIONS_COUNT = intval($cu_row['min_chlng_qst']);
462  // * Product Name
463  $DMSAPP_PRODUCTNAME = trim($cu_row['pname']);
464  // * Credit Union Name
465  $DMSAPP_CUNAME = trim($cu_row['orgname']);
466  // ** Allowed Number of Failed Logins
467  $DMSAPP_FAILEDLOGINATTEMPTS = intval($cu_row['retrylimit']);
468  // capture the flag set for later evaluation
469  $DMSAPP_CUFLAGSET2 = $cu_row['flagset2'];
470 
471 
472 
473  // ** LOAD CONFIG OPTIONS IF ANY FROM THE lnappconfig table
474  $sql = "SELECT cu, appconfig
475  FROM lnappconfig
476  WHERE cu = '" . prep_save($cu, 12) . "';";
477  $config_rs = db_query($sql, $dbh);
478  if ($config_row = db_fetch_assoc($config_rs)) {
479  // * Load Values from the configuration
480  // $DMSAPP_ONLINE = "1"; // ** This will determine if the throtlpkt is loaded and whether loans are even sent to the core
481  // $DMSAPP_CSS = ""; // ** this is the URL of the Styles used by this credit union for the online loans
482  $configOptions = json_decode($config_row['appconfig'], true);
483  if (json_last_error() == JSON_ERROR_NONE) {
484  // ** Use the options for the loan app
485  if (key_exists("configLoanSubmit", $configOptions)) {
486  $DMSAPP_ONLINE = (intval($configOptions['configLoanSubmit']) == 1 ? 1 : 0);
487  }
488  if (key_exists("configLoanSubmitMember", $configOptions)) {
489  $DMSAPP_SUBMITMBR = (intval($configOptions['configLoanSubmitMember']) == 1 ? 1 : 0);
490  }
491  if (key_exists("configLoanFormat", $configOptions)) {
492  $DMSAPP_LOANFORMAT = ($configOptions['configLoanFormat'] != '' ? $configOptions['configLoanFormat'] : $DMSAPP_LOANFORMAT);
493  }
494  if (key_exists("configSSOOnly", $configOptions)) {
495  $DMSAPP_SSOONLY = $configOptions['configSSOOnly'];
496  }
497  if (key_exists("configDisableEmail", $configOptions)) {
498  $DMSAPP_DISABLEEMAIL = $configOptions['configDisableEmail'];
499  }
500  if (key_exists("configHomeLogin", $configOptions)) {
501  $DMSAPP_ALLOW_HB_LOGIN = (intval($configOptions['configHomeLogin']) == 1 ? 1 : 0);
502  }
503  if (key_exists("configLoanCSS", $configOptions)) {
504  $DMSAPP_CSS = $configOptions['configLoanCSS'];
505  }
506  if (key_exists("configLoanIntroMbr", $configOptions)) {
507  $DMSAPP_MBRMSG = $configOptions['configLoanIntroMbr'];
508  }
509  if (key_exists("configLoanIntroNonHBMbr", $configOptions)) {
510  $DMSAPP_NON_HB_MBR_MSG = $configOptions['configLoanIntroNonHBMbr'];
511  }
512  if (key_exists("configLoanIntroNon", $configOptions)) {
513  $DMSAPP_NONMBRMSG = $configOptions['configLoanIntroNon'];
514  }
515  if (key_exists("configLoanMIR", $configOptions) && $DMSAPP_CULIVE) {
516  $DMSAPP_FETCHMIR = (intval($configOptions['configLoanMIR']) == 1 ? 1 : 0);
517  }
518  if (key_exists("configLoanDataOnly", $configOptions)) {
519  $DMSAPP_LOANDATAONLY = (intval($configOptions['configLoanDataOnly']) == 1 ? 1 : 0);
520  }
521  }
522  }
523  } else {
524  // ** We have an error ---
525  // Force them back thru Loan App Error
526  $form_code = "ERROR";
527  }
528  } else {
529  // * INVALID CU CODE -- PAGE ERROR
530  $form_code = "ERROR";
531  $serviceErrorCode = '999';
532  require_once(dirname(__FILE__) . '/../../banking/includes/hcuErrorPage.i');
533  exit;
534  }
535  // ** NOW DETERMINE IF WE LOAD THE Throttle Packet Script
536  if ($DMSAPP_ONLINE && $DMSAPP_CULIVE) {
537  // ** Appliance API Script
538  require_once(dirname(__FILE__) . '/../../shared/library/sAPIAppl.i');
539 
540  // ** Load the specific plugin for this appliance configuration
541  IncludeApplPlugin($HB_ENV);
542 
543  }
544 
545  // ** Depending on the form to load
546  // ** used when a cookie times out and they used hbuser to login
547  $formAllowReadonly = false;
548  switch ($form_code) {
549  case "refresh":
550  $form2load = "lnapprefresh.i";
551  $load_scriptonly = true;
552  $check_credentials = false; // * This form will have CREDENTIAL CHECKS WITHIN IT..
553  $formAllowReadonly = true;
554  break;
555  case "modifyuser":
556  $serviceShowInfo = true;
557  case "newuser":
558  case "confirmuser":
559  if ($DMSAPP_DISABLEEMAIL != 1) {
560  if ($form_code != "modifyuser") {
561  $check_credentials = false;
562  }
563  if ($form_code == "confirmuser") {
564  $formAllowReadonly = true;
565  }
566  $form2load = "lnappusermaint.i";
567  } else {
568  // They may not login using email -- ALWAYS GO BACK TO THIS SCREEN?
569  $form2load = "lnappintro.i";
570  }
571  break;
572  case "hbuser":
573  case "hbssouser":
574  // ** For Home banking users I will be using a different process.
575  $check_credentials = false;
576  $form2load = "lnapphbuser.i";
577  $formAllowReadonly = true;
578  break;
579  case "miruser":
580  // ** For members that aren't homebanking users but are cu members
581  $check_credentials = false; // important cookie likely not set up yet.
582  $miruser_cookie_user = false;
583  $form2load = "lnappmiruser.i";
584  $formAllowReadonly = true;
585  break;
586  case "newmiruser":
587  $check_credentials = false; // important cookie likely not set up yet.
588  $form2load = "lnappusermaint.i";
589  $formAllowReadonly = true;
590  break;
591  case "cuuser":
592  // ** We don't know if HB user or MIR/CU user
593  $check_credentials = false;
594  $form2load = "lnappuserchooser.i";
595  $formAllowReadonly = true;
596  break;
597  case "portal":
598 
599  // * this is the main menu / portal for the loans, it will be where
600  // * member decides which loans to start or status/...
601  // This will have to ensure credentials are correct
602  $form2load = "lnappportal.i";
603  $serviceShowInfo = true;
604  $formAllowReadonly = true;
605  break;
606  case "entry":
607  $form2load = "lnappentry.i";
608  $serviceShowInfo = true;
609  $serviceShowMenu = true;
610  $serviceLoadMenu = true;
611  $random = rand(1, 999999);
612 
613  // setcookie("ENTRYCOOKIE", $random,0, "/", $DMSAPP_Cookie_Domain, 1);
614  HCU_setcookie_env($HB_ENV['SYSENV'], "ENTRYCOOKIE", $random, 0);
615 
616 
617 
618  /**
619  *
620  * Added to try and prevent the user from using the back button on the browser
621  * The user would post the form and then use the back button and they would
622  * be able to repost the data.
623  *
624  * I noticed when using the back button the form does NOT get a HTTP_REFERER
625  * so if I am loading a form and there is no referer I will simply redirect them
626  * to the main portal page
627  */
628 /*
629  if ($_SERVER['HTTP_REFERER'] == '') {
630  header("Location: {$self}f=portal");
631  }
632 */
633 
634  break;
635  case "signout":
636  $form2load = "lnappsignout.i";
637 
638  $check_credentials = false;
639  $formAllowReadonly = true;
640  break;
641  case "calculators":
642  $form2load = "lnappcalc.i";
643  $serviceShowInfo = true;
644  $formAllowReadonly = true;
645  break;
646  case "loandelete":
647  $form2load = "lnappedit.i";
648  $serviceShowInfo = true;
649  break;
650  case "viewapplication":
651  $form2load = "lnappview.i";
652  $formAllowReadonly = true;
653  break;
654  case "checksecurity":
655  $form2load = "lnappsecurity.i";
656  $serviceShowInfo = true;
657  $formAllowReadonly = true;
658  break;
659  case "viewdisclosure":
660  $form2load = "lnappdisclosure.i";
661  $lnapp_disclosure_standalone = true;
662  $lnapp_disclosure_loanid = intval(hcu_array_key_value('review', $loadedValues['url']));
663  $formAllowReadonly = true;
664 
665  break;
666  case "ERROR":
667  $id_status = -1;
668  $check_credentials = false;
669  $form2load = "lnapperror.i";
670  $formAllowReadonly = true;
671  break;
672  default:
673  $form2load = "lnappintro.i";
674  $check_credentials = False;
675  $formAllowReadonly = true;
676 
677 
678  }
679 
680  // if we are being asked to keep the timeout timer going, do it now
681  if ( $form_code == "keepalive" ) {
682  $refreshStatus = RefreshCookie($HB_ENV);
683 
684  if ( $refreshStatus == "True" ) {
685  // the caller is expecting this message back
686  print "OK";
687  }
688 
689  // * exit - no reason to go further
690  exit;
691  }
692 
693  // ** DO NOT ALLOW ANY allowReadOnly if we are ONLINE
694  $formAllowReadonly = ($DMSAPP_ONLINE == "1" ? false : $formAllowReadonly);
695  // ** CHECK for offline status here
696  // * SET OFFLINE
697  $DMSAPP_MODE_ARY = SetAppMode($dbh, $DMSAPP_CURRENTCUCODE, $DMSAPP_ONLINE, $formAllowReadonly);
698  if ($check_credentials) {
699  list($check_status, $check_user, $check_email, $check_logintype) = Check_Credentials();
700 
701  if (intval($check_user) == $check_user) {
702  $DMSAPP_CURRENTUSERID = $check_user;
703  $DMSAPP_CURRENTEMAIL = strtolower($check_email);
704  $DMSAPP_LOGINTYPE = $check_logintype;
705 
706  if ($check_status == 0) {
707  // ** REDIRECT TO LOGIN SCREEN IF CREDENTIALS FAIL
708  if ($check_logintype == DMSAPP_CONST_APP_LOGIN) {
709  $form_code = "confirmuser";
710  $form2load = "lnappusermaint.i";
711  } elseif ($check_logintype == DMSAPP_CONST_HB_LOGIN ) {
712  $hbuser_cookie_user = True;
713  $form2load = "lnapphbuser.i";
714  } elseif ($check_logintype == DMSAPP_CONST_MIR_LOGIN) {
715  $miruser_cookie_user = True;
716  // not loading lnappmiruser.i, need to stay with loading the lnappportal.i
717  } else {
718  // ** UNKNOWN ERROR
719  header("Location: {$self}status=999");
720  exit;
721  }
722  }
723  $DMSAPP_CUHOME_PATH = '/home/' . strtolower($DMSAPP_CURRENTCUCODE) . '/public_html/';
724  } else {
725  // The check_user returned was not an integer
726  header("Location: {$self}status=999");
727  exit;
728  }
729  }
730 
731  if (!$DMSAPP_MODE_ARY['offline']) {
732  $id_status = -3;
733  $form2load = "lnapperror.i";
734  $load_scriptonly = false; // Always force into the main screen
735  }
736  if ($load_scriptonly) {
737  // ** ONLY INCLUDE THE SCRIPT -- DO NOT LOAD THE CONTAINER
738  if (isset($form2load) && strlen($form2load) > 0 && file_exists($inc_path . $form2load)) {
739  include_once($inc_path . $form2load);
740  }
741  // ** DO NOTHING IF NOT FOUND
742  exit;
743  }
744 
745  } else {
746  // ** INITIALIZE INFO ERROR -- We are reporting an error
747  // The form apperror needs to be setup for possible errors, I would like to make it for all errors
748  $serviceShowInfo = false;
749  $form2load = "lnapperror.i";
750  }
751 
752  /**
753  * LOAD THE FIRST PART OF THE PAGE
754  */
755  include_once("../includes/lnappPreContent.i");
756 
757 
758  /**
759  * LOAD THE CONTENT OF THE PAGE
760  */
761  // ** INCLUDE THE SCRIPT HERE
762  if ($form2load == 'lnappintro.i' && $DMSAPP_SSOONLY == 1) {
763  include_once($inc_path . "lnapperror.i");
764  } else {
765  if (isset($form2load) && strlen($form2load) > 0 && file_exists($inc_path . $form2load)) {
766  include_once($inc_path . $form2load);
767  } else {
768  // ** SET ERROR CATCHING
769  $error_loadform = 1;
770  }
771  if ($error_loadform > 0) {
772  // include this form when the one we are looking for is NOT found
773  include_once($inc_path . "lnappnotfound.i");
774  }
775  }
776  // ** Allow ONE redirect for the current FORM?!?
777 
778 
779 
780  /**
781  * LOAD THE FOOTER OF THE PAGE
782  */
783  include_once("../includes/lnappPostContent.i");
784 
785 exit;