Odyssey
unlockbulk.prg
1 <?php
2 $monLibrary= dirname(__FILE__) . "/../library";
3 require_once("$monLibrary/cu_top.i");
4 require_once("$monLibrary/ck_hticket.i");
5 
6  if (isset($w) == false || $w > 2) $w = "1";
7 
8  $dbh = $link;
9 
10  if (!CheckPerm($link, $Hu, basename($_SERVER['SCRIPT_NAME']), $_SERVER['REMOTE_ADDR'])) {
11  // ** Permissions failed
12  // ** redirect to new page
13  header("Location: /hcuadm/hcu_noperm.prg");
14  exit;
15  }
16 $dms_ok=array('cu'=>'string','w'=>'string','msg'=>'string','chkCULock'=>'string');
17 $chkCULock = isset($chkCULock) ? trim($chkCULock) : "";
18 
19 dms_import($dms_ok);
20 
21  // *** FIRST GET THE CREDIT UNION ID
22  $sql = "SELECT cu, coalesce(retrylimit,5), coalesce(gracelimit,3)
23  FROM cuadmin
24  WHERE user_name = '" . prep_save($cu) . "'";
25  $cu_rs = db_query($sql, $dbh);
26  list($cu_code, $retry, $grace) = db_fetch_array($cu_rs);
27  $cu_code = trim($cu_code);
28  db_free_result($cu_rs);
29 
30  switch ($w):
31 
32  case "1":
33  cu_header("Unlock Member Accounts");
34 
35  $sql = "SELECT COUNT(user_name) FROM {$cu_code}user
36  WHERE failedremain = 0 OR (forcechange = 'Y' AND forceremain <= 0) OR ((userflags & 2::int = 2) AND forceremain <= 0)";
37  $cnt_rs = db_query($sql, $dbh);
38  list($login_fails) = db_fetch_array($cnt_rs);
39  db_free_result($cnt_rs);
40 
41  $sql = "SELECT COUNT(user_name) FROM {$cu_code}user WHERE failedremain < 0";
42  $cnt_rs = db_query($sql, $dbh);
43  list($login_culock) = db_fetch_array($cnt_rs);
44  db_free_result($cnt_rs);
45 
46 ?>
47  <form action="<?php echo $_SERVER['PHP_SELF']; ?>?cu=<?php echo $cu; ?>" method="post">
48  <input type="hidden" value="2" name="w">
49  <table border=0 align=center cellpadding=3 cellspacing=0 width=500 class="dmsbg"><tr><td>
50  <table border=0 cellpadding=1 cellspacing=0 width="100%" bgcolor=white>
51  <tr>
52  <td class='bar' align=center>
53  Unlock Members
54  </td>
55  </tr>
56  <?php if (isset($msg)): ?>
57  <tr>
58  <td class='dtl' align=center>
59  I have a message for you:<br><br><?php echo $msg; ?>
60  </td>
61  </tr>
62  <?php endif; ?>
63  <tr>
64  <td align=center class='dtl'>
65  <font size="4" color="red">
66  WARNING!<br>
67  This will unlock the members for <?php echo $cu; ?>. <br>Be sure this is what you want to do.
68  </font>
69  </td>
70  </tr>
71  <tr>
72  <td class='dtl' align=center>
73  <table border=1 cellpadding=0 cellspacing=0>
74  <tr>
75  <td colspan="2" class="hdr" align="center">
76  &nbsp;Current Locked Members&nbsp;
77  </td>
78  </tr>
79  <tr>
80  <td class="dtl" align="left">
81  &nbsp;Failed Logins&nbsp;
82  </td>
83  <td class="dtl" align="right">
84  &nbsp;<?php echo $login_fails; ?>&nbsp;
85  </td>
86  </tr>
87  <tr>
88  <td class="dtl" align="left">
89  &nbsp;Credit Union Locked&nbsp;
90  </td>
91  <td class="dtl" align="right">
92  &nbsp;<?php echo $login_culock; ?>&nbsp;
93  </td>
94  </tr>
95  <tr>
96  <td class="dtl" align="left">
97  &nbsp;Total:&nbsp;
98  </td>
99  <td class="dtl" align="right">
100  &nbsp;<?php echo ($login_fails + $login_culock); ?>&nbsp;
101  </td>
102  </tr>
103  </table>
104  </td>
105  </tr>
106  <tr>
107  <td class='dtl' align=center>
108  <input type='checkbox' name='chkCULock' value='Y'>Include members 'Locked by Credit Union'?
109  </td>
110  </tr>
111  <tr>
112  <td class='dtl' align=center>
113  <hr>
114  </td>
115  </tr>
116  <tr>
117  <td class='dtl'>
118  Are you sure you want to unlock the members for <?php echo strtoupper($cu); ?>?
119  </td>
120  </tr>
121  <tr>
122  <td class='dtl'>
123  <input type="submit" value="Yes, please do it NOW!!" name="btnUnlock">
124  <!-- <input type="submit" value="No" name="keep_daz"> -->
125  </td>
126  </tr>
127  </table>
128  </td></tr></table>
129  </form>
130  </body>
131  </html>
132 <?php
133  break;
134  case "2":
135 
136 
137  // *** FIRST GET THE CREDIT UNION ID
138  $sql = "SELECT cu, coalesce(retrylimit,5), coalesce(gracelimit,3)
139  FROM cuadmin
140  WHERE user_name = '" . prep_save($cu) . "'";
141  $cu_rs = db_query($sql, $dbh);
142  list($cu_code, $retry, $grace) = db_fetch_array($cu_rs);
143  $cu_code = trim($cu_code);
144  db_free_result($cu_code);
145 
146  if ($cu_code != "") {
147  // ** I HAVE THE CODE -- UPDATE THE cuusers table
148 
149  // ** CREATE QUERY BASED ON OPTIONS
150  if ($chkCULock == "Y") {
151  $sql_opr = "<=";
152  } else {
153  $sql_opr = "=";
154  }
155 
156  $upd_sql = "UPDATE {$cu_code}user SET forceremain = $grace, failedremain = $retry
157  WHERE failedremain $sql_opr 0 OR (forcechange = 'Y' AND forceremain <= 0) OR ((userflags & 2::int = 2) AND forceremain <= 0)";
158 
159  if ($upd_rs = db_query($upd_sql, $dbh)) {
160  $upd_msg = "I have unlocked " . db_affected_rows($upd_rs) . " members. I hope this helped.";
161  } else {
162  $upd_msg = "The members were NOT unlocked. Please contact a system administrator to unlock the members.";
163  }
164  } else {
165  // *** CU CODE NOT VALID
166  $upd_msg = "The credit union code is NOT valid. Please contact a system administrator to unlock the members.";
167  }
168 
169  header("Location: {$_SERVER['PHP_SELF']}?cu={$cu}&msg=" . urlencode($upd_msg));
170  exit;
171  break;
172  endswitch;
173 ?>