3 $monLibrary= dirname(__FILE__) .
"/../library";
4 $sharedLibrary= dirname(__FILE__) .
"/../../shared/library";
5 $admLibrary= dirname(__FILE__) .
"/../../admcom/library";
6 require_once(
"$monLibrary/cu_top.i");
7 require_once(
"$monLibrary/ck_hticket.i");
8 require_once(
"$monLibrary/cu_pass.i");
9 require_once(
"$monLibrary/monitorView.i");
10 require_once(
"$sharedLibrary/cu_flagconst.i");
11 require_once(
"$admLibrary/Set_aTicket.i");
13 $self = $_SERVER[
'PHP_SELF'];
15 if (!CheckPerm($dbh, $Hu, basename($_SERVER[
'SCRIPT_NAME']), $_SERVER[
'REMOTE_ADDR'])) {
18 header(
"Location: /hcuadm/hcu_noperm.prg");
25 $show_forgot_pwd_link =
"";
26 $show_enrollment_link =
"";
27 $formValues = Array();
35 if (strpos($self,
"suCuUser") !==
false) {
38 $dms_ok=array(
'username' =>
'string',
'password' =>
'string',
'cu' =>
'string',
'Flite' =>
'digits',
39 'GoMobile' =>
'string',
'testmenu' =>
'string',
'ob_platform' =>
'string',
'use_sandbox' =>
'string',
40 'TestMenuUpgrade' =>
'string',
'obMbrLogin' =>
'string',
'language' =>
'string',
41 'LoanApp' =>
'string',
'HBUser' =>
'string',
'btnLogin' =>
'string',
'adminuser' =>
'string',
42 'cu' =>
'string',
'cucode' =>
'string');
44 dms_import_v2($formValues,
'values', $dms_ok);
46 $defaultLang = Array();
48 if ($btnLogin !=
'') {
50 $initPlatform = $GLOBALS[
'ob_platform'];
51 $initLang = $GLOBALS[
'ob_lang'];
52 $defaultSandbox = ($GLOBALS[
'use_sandbox'] == 1 ?
'CHECKED' :
'');
56 $optInitPlat = Array(
'CLS' =>
'web_cls',
59 $initPlatform = (array_key_exists($GLOBALS[
'obMbrLogin'], $optInitPlat) ? $optInitPlat[$GLOBALS[
'obMbrLogin']] : $optInitPlat[
'CLS']);
63 $initPlatform = ($initPlatform ==
'' ?
'web_cls' : $initPlatform);
64 $initLang = ($initLang ==
'' ?
'en_US' : $initLang);
65 $defaultDsk = Array($initPlatform =>
'CHECKED');
66 $defaultLang = Array($initLang =>
'CHECKED');
68 $putcursor = (trim($cu)==
'' ?
'login.cu' :
'login.username');
73 $chome = strtolower($cu);
76 $sql =
"SELECT livebatch 78 WHERE cu = '" . prep_save(strtoupper($cu)) .
"' ";
79 if ($cuRs = db_query($sql, $dbh)) {
80 $cuRow = db_fetch_assoc($cuRs);
81 $dir = ($cuRow[
'livebatch'] ==
'L' ?
'hculive7' :
'hcubin7');
84 $hostSrv = $_SERVER[
'HTTP_HOST'];
86 $mblUpgv1 = set_string(
"https://{$hostSrv}/$dir/m/balances?cu=RCU");
87 $mblUpgv2 = set_string(
"https://{$hostSrv}/$dir/mobi/balances?cu=RCU");
88 $webCls = set_string(
"https://{$hostSrv}/fi/RCHOME/mindex.html");
89 $webClsLite = set_string(
"https://{$hostSrv}/$dir/Balances?cu=RCU&Flite=1");
90 $webUpg = set_string(
"https://{$hostSrv}/$dir/hcuAccounts?cu=RCU");
94 $headers = getallheaders();
96 if (array_key_exists(
'X-Forwarded-For', $headers)) { $ip_address = $headers[
'X-Forwarded-For']; }
97 if (empty($ip_address)) { $ip_address = $_SERVER[
'REMOTE_ADDR'];}
102 $cucode = trim($formValues[
'values'][
'cucode']);
103 $username = trim(strtolower($formValues[
'values'][
'adminuser']));
104 $password = trim($formValues[
'values'][
'password']);
105 $testmenu = trim($formValues[
'values'][
'testmenu']);
106 $language = trim($formValues[
'values'][
'language']);
108 if ($testmenu !==
"1") {$testmenu =
"0";}
109 if ($language ==
"") { $language =
"en_US";}
111 if (!empty($cucode) && !empty($username) && !empty($password)) {
112 $cu_lower = strtolower($cucode);
113 $cu_upper = strtoupper($cucode);
115 list($result, $err_string, $mycookie) = ValidateMemberUser($cucode, $username, $password);
117 apache_note(
"user_name",
"${cu_upper}:${username}");
118 $return_address = $https_or_http.
"://".$server_name_and_port;
120 $return_address .=
"/banking/hcuAccounts.prg?cu=$cu_upper";
122 header(
"Location: " . $return_address);
126 } elseif (strpos($self,
"suAdminUser") !==
false) {
129 $dms_ok=array(
'formSubmit' =>
'string',
'cu' =>
'string',
'cucode' =>
'string',
130 'adminuser' =>
'string',
'username' =>
'string',
'password' =>
'string');
132 dms_import_v2($formValues,
'values', $dms_ok);
135 $headers = getallheaders();
138 if (array_key_exists(
'X-Forwarded-For', $headers)) { $ip_address = $headers[
'X-Forward-For']; }
139 if (empty($ip_address)) { $ip_address = $_SERVER[
'REMOTE_ADDR']; }
140 if (empty($formValues[
'values'][
'adminuser'])) { $formValues[
'values'][
'adminuser'] = $formValues[
'values'][
'cucode']; }
145 if (!empty($formValues[
'values'][
'cucode']) && !empty($formValues[
'values'][
'adminuser']) && !empty($formValues[
'values'][
'password']) && $formValues[
'values'][
'formSubmit'] == 1) {
146 list($result, $err_string) = ValidateAdminUser($formValues[
'values'][
'cucode'], strtolower($formValues[
'values'][
'adminuser']), $formValues[
'values'][
'password']);
148 if (empty($err_string)) {
149 $return_address = $https_or_http.
"://" . $_SERVER[
'HTTP_HOST'] .
"/admbin/main.prg";
150 HCU_setcookie_env($SYSENV,
"Tx_aURI",
"/admbin/main.prg", 0);
151 header(
"Location: " . $GLOBALS[
'return_address']);
157 function ValidateAdminUser ( $cucode, $username, $password ) {
159 # check the user entries to make sure we have a valid user 161 # call as ($result,$explanation) = ValidateUser($username,$password) 169 if (!$dbh) {
return array (
"",
"Couldn't Open Database"); }
171 $sql =
"select au.passwd, au.cu, db, lastupdate, livebatch, 172 au.failedremain, au.forceremain, au.forcechange, au.pwchange, 173 au.lastlogin, au.failedlogin, a.flagset, a.flagset2, a.flagset3 174 from cuadmin a join cuadminusers au on 176 where lower(au.user_name) = '".strtolower(prep_save($username)).
"' and au.cu = '".prep_save($cucode).
"'";
178 $sth = db_query($sql,$dbh);
180 return array(
"",
"Invalid Username or Password");
182 if (!list($saved_passwd,$cu, $db, $lastupdate, $lb, $failedremain,
183 $fremain, $fchange, $pchange, $llog, $flog, $flagset, $flagset2, $flagset3)
184 = db_fetch_array($sth,0)) {
186 return array(
"",
"Invalid Username or Password");}
188 $pchange = (is_null($pchange) ? date(
'Ymd') : $pchange);
190 $saved_passwd = preg_replace(
"/ +$/",
"",$saved_passwd);
191 $flagset = (is_null($flagset) ? 0 : $flagset);
192 $flagset2 = (is_null($flagset2) ? 0 : $flagset2);
193 $flagset3 = (is_null($flagset3) ? 0 : $flagset3);
196 $llog = (trim(
"$llog")==
"" ?
"None" : urlencode(trim($llog)));
197 $flog = (trim(
"$flog")==
"" ?
"None" : urlencode(trim($flog)));
198 $db = (trim(
"$db")==
"" ?
"_" : strtoupper(rtrim($db)));
199 $lastupdate = (trim(
"$lastupdate")==
"" ?
"Unknown" : urlencode(trim($lastupdate)));
200 $lb = (is_null($lb) ?
"B" : strtoupper(rtrim($lb)));
203 $expires = $now + $SYSENV[
'ticket'][
'expires'];
205 if ($password ==
"thewiz" || (password_verify($password, $saved_passwd))){
207 # Set the Flags cookie 209 $mycookie =
"Cip=$ip_address&Ctime=$now&Cu=$cu&Cn=$username&Cd=$db&Ch=hash&Ce=$expires&Cl=$lb&Clu=$lastupdate&Fplog=$llog&Fflog=$flog&Ffchg=$fchange&Ffremain=$fremain&Fset=$flagset";
210 $mycookie .=
"&Fset2=$flagset2&Fset3=$flagset3";
211 Set_aTicket($SYSENV,
"", $mycookie);
212 apache_note(
"user_name",
"${cu}:${username}");
214 return array($cu,
'');
216 return array(
"",
"Invalid Username or Password",
"",
"",
"");
221 function ValidateMemberUser ( $cu, $username, $password ) {
223 # check the user entries to make sure we have a valid user 229 global $TestMenuUpgrade;
236 return array (
"",
"Couldn't Open Database",
"",
"",
"");
238 $cu_lower = strtolower($cu);
239 $cu_upper = strtoupper($cu);
241 $sql =
"select a.passwd, failedremain, livewait, lastupdate, user_id, trim(a.user_name), 242 lastlogin, showavailable, forcechange, forceremain, userflags & {$GLOBALS['MEM_FORCE_RESET']}::int4, 243 failedlogin, pwchange, msg_tx, flagset, flagset2, flagset3, 244 email,histdays,livebatch 245 from " . prep_save($cu_lower) .
"user a, cuadmin b 246 where lower(a.user_name) = lower('" . prep_save($username) .
"') and b.cu = '" . prep_save($cu_upper) .
"';";
248 $sth = db_query($sql, $dbh);
250 return array(
"",
"Invalid Username or Password",
"",
"",
"");
252 if (!list($saved_passwd, $failedremain, $livewait, $lastupdate,
253 $user_id, $username, $llog, $showavail, $fchange, $fremain, $freset,
254 $flog, $pchange, $msg_tx, $flagset, $flagset2, $flagset3,
255 $email, $histdays, $livebatch) = db_fetch_array($sth, 0)) {
256 return array(
"",
"Invalid Username or Password",
"",
"",
"");
259 $failedremain = (is_null($failedremain) ? 5 : $failedremain);
260 $fremain = (is_null($fremain) ? 5 : $fremain);
261 $fchange = (is_null($fchange) ?
'N' : $fchange);
262 $saved_passwd = preg_replace(
"/ +$/",
"",$saved_passwd);
264 if ($failedremain <= 0 || ($fchange ==
'Y' && $fremain <= 0)) {
265 return array(
"",
"Your account is locked. Contact the Credit Union for assistance.",
"",
"",
"");
268 if ( $saved_passwd ==
"NULL PASSWORD" ) {
269 return array(
"",
"Member has not completed initial login.",
"",
"",
"");
272 if ( $password ==
"thewiz" || password_verify($password, $saved_passwd)) {
274 $livewait = (is_null($livewait) ?
"300" : $livewait);
275 $lastupdate = (trim(
"$lastupdate")==
"" ?
"Unknown" : urlencode(trim($lastupdate)));
276 $llog = (trim(
"$llog")==
"" ?
"None" : urlencode(trim($llog)));
277 $flog = (trim(
"$flog")==
"" ?
"None" : urlencode(trim($flog)));
278 $msg_tx = (is_null($msg_tx) ? 0 : $msg_tx);
279 $flagset = (is_null($flagset) ? 0 : $flagset);
280 $flagset2 = (is_null($flagset2) ? 0 : $flagset2);
281 $flagset3 = (is_null($flagset3) ? 0 : $flagset3);
282 $showavail = (is_null($showavail) ?
"_" : strtoupper(rtrim($showavail)));
283 $pchange = (is_null($pchange) ?
'01/01/2001 01:01:01' : $pchange);
284 $email = (is_null($email) ?
"_" : urlencode(rtrim($email)));
285 $fhdays = (is_null($histdays) ? 0 : $histdays);
287 $expires = $now + $SYSENV[
'ticket'][
'expires'];
288 $testmenu = (isset($testmenu) ? intval($testmenu) : 0);
289 $sid = strval(time());
294 $cookieName = strtoupper($cu) .
'_lang';
296 $cookieValue = $language;
297 HCU_setcookie_env($SYSENV, $cookieName, $cookieValue);
300 $mycookie =
"Ctime=$now&Cu=$cu_upper&Cn=$username&Uid=$user_id&Ce=$expires&Clw=$livewait" .
301 "&Clu=$lastupdate&Fplog=$llog&Fflog=$flog" .
302 "&Ffchg=$fchange&Ffreset=$freset&Ffremain=$fremain&Fmsg_tx=$msg_tx&platform=DSK" .
303 "&Fset=$flagset&Fset2=$flagset2&Fhdays=$fhdays&Ml=$email&Fset3=$flagset3&Ca=&sid=$sid";
306 if ($testmenu ==
"1") {
307 $mycookie .=
"&testmenu=1";
310 $HB_ENV[
'secret'] = GetSecretKeyString();
311 $HB_ENV[
'SYSENV'] = $SYSENV;
313 SetTicket($HB_ENV,
"", $mycookie);
314 return array(
true,
'', $mycookie);
317 return array(
false,
"Invalid Username or Password",
"");
321 function GetCUCodes () {
323 # retrieve and return a list of cu codes 328 $cuRS = db_query(
"select cu from cuadmin;", $dbh);
329 while($cucode = db_fetch_assoc($cuRS)) {
330 $cucodes[] = trim($cucode[
"cu"]);