Odyssey
culist.prg
1 <?php
2 
3 $monLibrary = dirname(__FILE__) . "/../library";
4 require_once("$monLibrary/cu_top.i");
5 require_once("$monLibrary/ck_hticket.i");
6 require_once("$monLibrary/cu_pass.i");
7 
8  if (!CheckPerm($link, $Hu, basename($_SERVER['SCRIPT_NAME']), $_SERVER['REMOTE_ADDR'])) {
9 
10  // ** Permissions failed
11  // ** redirect to new page
12  header("Location: /hcuadm/hcu_noperm.prg");
13  exit;
14  }
15 
16 $dms_ok = array('orderby'=>'string','action'=>'string','rowid'=>'string');
17 
18 dms_import($dms_ok);
19 
20  if (empty($orderby)) $orderby = 'cu';
21  if ($orderby == 'start')
22  $sql_order = " coalesce(cuadmin.upllaststart, TIMESTAMP '01-01-1970 12:00:00') desc";
23  elseif ($orderby == 'end')
24  $sql_order = " coalesce(cuadmin.upllastend, TIMESTAMP '01-01-1970 12:00:00') desc";
25  else
26  $sql_order = "upper(cuadmin.$orderby)";
27  $sql = "select cu, user_name, vendor, orgname, upllaststat, histtrunc,
28  to_char(upllaststart, 'MM/DD/YYYY HH24:MI:SS') as upllaststart,
29  to_char(upllastend, 'MM/DD/YYYY HH24:MI:SS') as upllastend,
30  offlinestat
31  from cuadmin order by $sql_order";
32 
33  switch ($orderby) {
34  case "user_name":
35  $use_field = "user_name";
36  break;
37  case "vendor":
38  $use_field = "vendor";
39  break;
40  case "orgname":
41  $use_field = "orgname";
42  break;
43  case "cu":
44  $use_field = "cu";
45  break;
46  default:
47  $use_field = "N";
48  }
49 
50  $sth = db_query($sql, $dbh);
51  if ($sth) {
52  cu_header("Server Status");
53 
54  echo "<a name=\"top\"></a>";
55  echo "<table border=0 cellpadding=3 cellspacing=0 align=center width='100%' class='dmsbg'><tr><td>";
56  echo "<table border=0 cellpadding=2 cellspacing=0 align=center width='100%' bgcolor=white>";
57  echo "<tr><td colspan=6 class=bar align=center>SELECT CREDIT UNION</td></tr>";
58  if ($use_field <> "N") {
59  echo "<tr><td colspan='6' align=center>Index: ";
60  for ($adx=ord("A"); $adx <= ord("Z"); $adx++)
61  echo "<a href=#" . chr($adx) . ">" . chr($adx) . "</a> &nbsp;";
62  echo "</td></tr>";
63  }
64  echo "<tr>
65  <td class='hdr'>
66  <a href={$_SERVER['PHP_SELF']}?action=list&orderby=cu>Credit Union</a></td>
67  <td class='hdr'>
68  <a href={$_SERVER['PHP_SELF']}?action=list&orderby=orgname>CU Name</a></td>
69  <td class='hdr'>
70  <a href={$_SERVER['PHP_SELF']}?action=list&orderby=vendor>Vendor</a></td>
71  <td class='hdr'>
72  <a href={$_SERVER['PHP_SELF']}?action=list&orderby=start>Last Upload Start</a></td>
73  <td class='hdr'>
74  <a href={$_SERVER['PHP_SELF']}?action=list&orderby=end>Last Upload End</a></td>
75  <td class='hdr'>Status</a></td>
76  </tr>";
77  $RGB = "odd";
78  if ($use_field <> "N") {
79  $cur_ascii = ord("A") - 1; // Start at the character before A
80  $lst_ascii = ord("A") - 1; // Start at the character before A
81  }
82  for ($row=0; list($cu, $user_name, $vendor, $orgname, $upllaststat, $histtrunc, $upllaststart, $upllastend, $offlinestat) = db_fetch_array($sth,$row); $row++) {
83  $cu = trim($cu);
84  $user_name = trim($user_name);
85 
86  if ($use_field <> "N") {
87  $cur_ascii = (ord(strtoupper(substr($$use_field, 0, 1))) > $cur_ascii && ord(strtoupper(substr($$use_field, 0, 1))) <= ord("Z") ? ord(strtoupper(substr($$use_field, 0, 1))) : $cur_ascii);
88  if (($cur_ascii <> $lst_ascii) && (($cur_ascii >= ord("A")) && ($cur_ascii <= ord("Z")))) {
89  //Insert links for missing letters, but display only the current letter
90  printf("<tr><td colspan=6>\n");
91  for ($adx = $lst_ascii + 1; $adx < $cur_ascii; $adx++)
92  printf("<a name=%s></a>\n", chr($adx));
93  // Now print the current
94  printf("<a name=%s>%s</a>&nbsp;&nbsp;<a href=#top>back to top</a></td></tr>\n", chr($adx), chr($adx));
95  $lst_ascii = $cur_ascii;
96  }
97  }
98 
99  // display list w/link to self ?action=fetch and ?action=delete
100  $tr_class = ($upllaststat > 0 ? "error" : $RGB);
101  // Now compensate for the Truncate History flag, this will be a Yellow color
102  $tr_class = ($histtrunc == "1" ? "trunc" : $tr_class);
103  $tr_class = ($offlinestat == "Y" || $offlinestat == "U" ? "offstat" : $tr_class);
104  $vend_show = (trim($vendor) == '' ? "" : "&vc=". trim($vendor));
105  $pos = strpos($_SERVER['HTTP_HOST'],".");
106  $shortServer = substr($_SERVER['HTTP_HOST'],0,$pos);
107  $server = in_array($shortServer, array("www", "www3", "www4", "www5", "www6")) ? $shortServer : $_SERVER['HTTP_HOST'];
108  $www_show = "&wc=" . $server;
109  $llink = (trim($upllaststart) == '' ? '' : "<a href='https://" . $shortServer .
110  ".homecu.net/hcuadm/tfiles/$user_name/public_html/status.txt'>Last</a>");
111  $hlink = (trim($upllaststart) == '' ? '' : "<a href='https://" . $shortServer .
112  ".homecu.net/hcuadm/html_hist?rowid=$user_name'>History</a>");
113 
114  printf("<TR class=\"%s\"><td><A HREF=\"%s/hcuadm/cuindex.prg?action=fetch&rowid=%s%s%s\" target=\"_top\">
115  %s</a></td>
116  <td><font size=2>%s&nbsp;</td>
117  <td><font size=2>%s&nbsp;</td>
118  <td><font size=2>%s&nbsp;</td>
119  <td><font size=2>%s&nbsp;</td>
120  <td><font size=2>%s&nbsp;%s&nbsp;</td>
121  </tr>\n",$tr_class,$infourl,$user_name, $vend_show, $www_show,
122  $user_name, $orgname, $vendor, $upllaststart, $upllastend,$llink,$hlink);
123  $RGB = ($RGB == "odd" ? "even" : "odd");
124  }
125 
126  if ($use_field <> "N") {
127  if ($cur_ascii < ord("Z")) {
128  printf("<tr><td colspan=5>\n");
129  for ($adx = $cur_ascii + 1; $adx <= ord("Z"); $adx++)
130  printf("<a name=%s></a>\n", chr($adx));
131  // Now print the current
132  printf("<a href=#top>back to top</a></td></tr>");
133  }
134  }
135  print <<< print_legend
136  <tr><td colspan="6">&nbsp;</td></tr>
137  <tr><td colspan="6" class='bar'>
138  COLOR LEGEND
139  </td></tr>
140  <tr class="error">
141  <td colspan="6">
142  <font size=2>
143  The 'upllaststat' flag is set to 1 for this credit union. It could indicate an error or an upload is in process.
144  </font>
145  </td>
146  </tr>
147  <tr class="trunc">
148  <td colspan="6">
149  <font size=2>
150  The 'histtrunc' flag is set to 1 for this credit union. The next time an upload occurs the history will be truncated.
151  </font>
152  </td>
153  </tr>
154  <tr class="offstat">
155  <td colspan="6">
156  <font size=2>
157  The credit union has been flagged offline by setting the 'offlinestat' flag.
158  </font>
159  </td>
160  </tr>
161 print_legend;
162  echo "</table>
163  </td></tr></table>";
164  cu_footer();
165  }
166 ?>