Odyssey
lnappuserchooser.i
1 <?php
2 /*
3  * Test to find out how the user will be authenticating:
4  * 1. Already in lnappuser table = use userlogintype.
5  * 2. Not in lnappuser table = check homebanking table.
6  * 3. None of the above then use the MIR packet, if configured.
7  * 4. All else fails = return to login screen.
8  *
9 */
10  $loadScript = "lnappintro.i"; // default to intro screen
11  /*
12  * hbssouser - This code is used WHEN initially logging in from home banking.
13  * the member must have a valid session
14  */
15  if (isset($_POST['applogin']) || ($hbuser_cookie_user && $DMSAPP_CURRENTUSERID > 0) || $form_code == 'hbssouser') {
16  // * we are posting from the intro screen
17  $loginUser = save_text( trim( $_POST['hbusername'] ), 12 );
18  // Not needed - it will end up being directed below to hcuLogin page.
19  // if ( preg_match("/\D/", $loginUser) ) {
20  // //this is an alias and only can be home banking
21  // $loadScript = "lnapphbuser.i";
22  // } else
23  if ($loginUser != '') {
24  // test if already in lnappuser table
25  $sql = "SELECT *
26  FROM {$DB_TABLE_PREFIX}user
27  WHERE cu = '$DMSAPP_CURRENTCUCODE'
28  AND session_account = '$loginUser' ";
29  $user_rs = db_query($sql, $dbh);
30 
31  $data['cu'] = $DMSAPP_CURRENTCUCODE;
32  $data['username'] = $loginUser;
33  $data['btnLogin'] = '1';
34  $payload = http_build_query($data, '', '&');
35  $cuServer = $_SERVER['SERVER_NAME'];
36  if($cuServer == 'localhost'){
37  $url = "http://${cuServer}:8000/banking/hcuLogin.prg?" . $payload;
38  } else {
39  $url = "http://my.homecu.net/banking/hcuLogin.prg?" . $payload;
40  }
41 
42  if ($user_row = db_fetch_assoc($user_rs)) {
43  // figure out what kind of user
44  if ( $user_row["userlogintype"] == DMSAPP_CONST_HB_LOGIN ) {
45  // $loadScript = "lnapphbuser.i";
46  // Force to login screen
47  header("Location: {$url}");
48  exit;
49  } else if ( $user_row["userlogintype"] == DMSAPP_CONST_MIR_LOGIN ) {
50  $loadScript = "lnappmiruser.i";
51  }
52  } else {
53 
54  // wasn't in the lnappuser table, so check the home banking table
55  $sql = "SELECT user_id, group_id, user_name, email, failedremain, passwd, confidence
56  FROM {$DMSAPP_CURRENTCUCODE}user
57  WHERE user_name = '{$loginUser}'; ";
58 
59  $hb_rs = db_query($sql, $dbh);
60  if ($hb_row = db_fetch_assoc($hb_rs)) {
61  // Force to login screen
62  header("Location: {$url}");
63  exit;
64 
65  } else {
66  // see if configured to allow MIR packet
67 
68  if ( $DMSAPP_FETCHMIR ) {
69  $loadScript = "lnappmiruser.i";
70  } else {
71  // let the old error system handle it
72  $loadScript = "lnapphbuser.i";
73  }
74  }
75  }
76  } else if ( $hbuser_cookie_user || $form_code == 'hbssouser' ) {
77  $loadScript = "lnapphbuser.i";
78  } else if ( $miruser_cookie_user ) {
79  $loadScript = "lnappmiruser.i";
80  }
81  }
82 
83  require_once( $loadScript );
84