2 $monLibrary= dirname(__FILE__) .
"/../library";
3 $sharedLibrary= dirname(__FILE__) .
"/../../shared/library";
4 require_once(
"$monLibrary/cu_top.i");
5 require_once(
"$monLibrary/ck_hticket.i");
6 require_once(
"$sharedLibrary/cu_flagconst.i");
8 if (!CheckPerm($link, $Hu, basename($_SERVER[
'SCRIPT_NAME']), $_SERVER[
'REMOTE_ADDR'])) {
11 header(
"Location: /hcuadm/hcu_noperm.prg");
15 $dms_ok=array(
'report'=>
'digits',
'csv'=>
'string',
'pos'=>
'digits',
'cdate'=>
'string',
'ctime'=>
'string',
16 's0'=>
'digits',
's1'=>
'digits',
's2'=>
'digits',
's3'=>
'digits',
's4'=>
'digits',
's5'=>
'digits',
's6'=>
'digits',
's7'=>
'digits');
19 $report = (isset($report) ? $report : 0);
20 $cdate = isset($cdate) ? $cdate :
"NONE";
21 $ctime = isset($ctime) ? $ctime :
"NONE";
22 $s0 = isset($s0) ? $s0 : 0;
23 $s1 = isset($s1) ? $s1 : 0;
24 $s2 = isset($s2) ? $s2 : 0;
25 $s3 = isset($s3) ? $s3 : 0;
26 $s4 = isset($s4) ? $s4 : 0;
27 $s5 = isset($s5) ? $s5 : 0;
28 $s6 = isset($s6) ? $s6 : 0;
29 $s7 = isset($s7) ? $s7 : 0;
30 $csv = isset($csv) ? $csv :
"";
32 $self = $_SERVER[
'PHP_SELF'];
34 if ($report == 2) {$cdate=
'NONE';$ctime=
'NONE';}
35 if ($report == 3) {$ctime=
'NONE';}
38 if ($cdate && $cdate !=
'NONE' && !(preg_match(
"/^\d{8}$/",$cdate))) {
39 $msg .=
"Please use 'YYYYMMDD' format for cutoff date<br>";
42 if ($cdate && $cdate <=
'20030101') {
43 $msg .=
"Please provide a cutoff date after 20030101<br>";
46 if ($s0 && $s0 != 1 && $s0 != 0) {
47 $msg .=
"Invalid setting for 'Summary Only'<br>";
50 if ($ctime && $ctime !=
'NONE' && !(preg_match(
"/^\d{2}:\d{2}:\d{2}$/",$ctime))) {
51 $msg .=
"Please use 'HH:MM:SS' format for cutoff time<br>";
55 if ($report && $cdate && $ctime) {
58 $rptname=
'stmntcount';
61 $rptname=
'stmntfrags';
64 $rptname=
'stmntstatus';
68 $q=
"cdate=$cdate&ctime=$ctime";
69 if ($s0 == 1) {$q .=
"&s0=1";}
71 if ($s1 == 1) {array_push($servers,
"www");$q .=
"&s1=1";}
72 if ($s3 == 1) {array_push($servers,
"www3");$q .=
"&s3=1";}
73 if ($s5 == 1) {array_push($servers,
"www5");$q .=
"&s5=1";}
74 if ($s6 == 1) {array_push($servers,
"www6");$q .=
"&s6=1";}
75 if ($s7 == 1) {array_push($servers,
"my");$q .=
"&s7=1";}
76 if (
sizeof($servers) == 0) {
77 $servers=array(
'www3',
'www5',
'www6',
'my');
80 foreach ($servers as $ask) {
88 $cmd =
"https://$ask.homecu.net/monitor/cgi-bin/$rptname.mp?csv=raw&$q";
90 $cmd =
"https://$ask.homecu.net/hcuadm/$rptname.pl?csv=raw&$q";
94 $curlcookies .=
"HCUTicket=" . urlencode($_COOKIE[
'HCUTicket']);
98 $curlcookies .=
";homecu_dev_oauth2_proxy={$_COOKIE['homecu_dev_oauth2_proxy']}";
101 curl_setopt($ch,CURLOPT_COOKIE,$curlcookies);
102 curl_setopt($ch,CURLOPT_USERPWD,
"nobody:no1home");
103 curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); #
get response as
string 104 $rawresp=curl_exec($ch);
108 foreach(explode(
"\r\n",$rawresp) as $get_line) {
109 if (trim($get_line) !=
"") {
110 $response[] = $get_line;
115 # $cmd = "https://nobody:no1home@$ask.homecu.net/hcuadm/{$rptname}.pl?csv=raw&$q"; 117 # $cmd = "/usr/bin/curl " . escapeshellarg("-b HCUTicket=" . urlencode($_COOKIE['HCUTicket'])) . " " . escapeshellarg("$cmd"); 118 # // ** Now pass the command to the command line 119 # $response = Array(); // Reset the array 120 # // ** Take the command -- open a pipe -- then retrieve the information -- stuff into an array 121 # if ($handle = popen($cmd, 'r')) { 122 # while (!feof ($handle)) { 123 # $get_line = fgets($handle, 4096); 124 # if (trim($get_line) != "") { 125 # $response[] = $get_line; 129 # // ** Be sure to close the handle 133 if (
sizeof($response)) {
134 $titles = explode(
"\t",rtrim(array_shift($response),
"\r\n"));
135 $ftypes = explode(
"\t",rtrim(array_shift($response),
"\r\n"));
136 array_walk($response,
'save_server',
"$ask");
137 array_walk($response,
'sort_by', key($servers));
138 array_push($titles,
"Server");
139 array_push($ftypes,
"char");
140 $culist = array_merge($culist, $response);
145 $culist = array_unique($culist);
147 $title = array_shift($titles);
148 $num_fields =
sizeof($titles);
149 $num_rows =
sizeof($culist);
151 if (($csv ==
'csv') &&
sizeof($culist)) {
157 # First record has the field names 159 for ($i_field = 0; $i_field < $num_fields; $i_field++) {
160 $field_name = $titles[$i_field];
161 $ostring .=
"$osep\"$field_name\"";
169 foreach ($culist as $cu) {
172 $row = explode(
"\t",$cu);
174 # throw away the sort column 177 $hdrdtl=array_shift($row);
179 for ($i_field = 0; $i_field < $num_fields; $i_field++) {
180 $field_type = $ftypes[$i_field];
181 if (preg_match(
"/(int|numeric)/i", $field_type)) {
182 $ostring .=
"${osep}${row[$i_field]}";
183 } elseif (preg_match(
"/(text|char)/i", $field_type)) {
184 $ostring .=
"${osep}\"${row[$i_field]}\"";
185 } elseif ($field_type ==
"bool") {
186 $ostring .=
"${osep}\"${row[$i_field]}\"";
188 $ostring .=
"${osep}\"${row[$i_field]}\"";
196 header(
"Content-length: " . strlen( $ostring ) );
197 header(
"Content-type: application/octetstream");
198 header(
"Content-disposition: inline; filename=\"${Cu}report${report}.csv\"");
203 $cfgShowBlob =
false;
209 $strShowingRecords =
"Showing records ";
211 $strPrevious =
"Previous";
216 $strEmptySet =
"No records found";
221 $pos_next = $pos + $cfgMaxRows;
222 $pos_prev = $pos - $cfgMaxRows;
224 $num_rows =
sizeof($culist);
226 $num_fields =
sizeof($ftypes);
228 $iNumRows = $num_rows;
229 if ($num_rows < $pos_next) {
230 $pos_next = $num_rows;
234 $strNavigation .=
"<table border=0 width='100%' cellspacing=0 cellpadding=2><tr>\n";
235 $strNavigation .=
"<td align=left class='dtl'>";
236 if ($pos >= $cfgMaxRows) {
238 $strNavigation .=
"<a href=\"$self?report=$report&title=$title&sql_order=" . urlencode($sql_order) .
"&pos=0$q\"><< $strPos1 </a> | ";
240 $strNavigation .=
" <a href=\"$self?report=$report&title=$title&sql_order=" . urlencode($sql_order) .
"&pos=$pos_prev$q\">< $strPrevious </a> | ";
242 $strNavigation .=
" ";
244 $strNavigation .=
"</td>\n";
246 $strNavigation .=
"<td align=center class='dtl'>\n";
249 if (empty($cfgMaxPages)) {
253 $iCount = $pos - ($cfgMaxRows * $cfgMaxPages);
257 $iPageCnt = (int)($iCount / $cfgMaxRows);
258 $iPageStop = $pos + ($cfgMaxRows * ($cfgMaxPages + 1));
261 for (; $iCount < $iNumRows && $iCount < $iPageStop; $iCount += $cfgMaxRows) {
264 if ($iCount != $pos) {
265 $strPages .=
"<a href=\"$self?report=$report&title=".urlencode($title).
"&sql_order=".urlencode($sql_order).
"&pos=$iCount$q\">$iPageCnt</a> | ";
267 if ($iNumRows > $cfgMaxRows) {
268 $strPages .=
"$iPageCnt | ";
272 $strNavigation .= preg_replace(
"/ \| $/",
"", $strPages);
274 $strNavigation .=
"</td>\n";
276 $strNavigation .=
"<td align=right class='dtl'>";
277 if ($pos_next < $num_rows) {
278 $strNavigation .=
" | <a href=\"$self?report=$report&title=".urlencode($title).
"&sql_order=".urlencode($sql_order).
"&pos=$pos_next$q\"> $strNext ></a>";
281 $pos_end = $num_rows - $cfgMaxRows;
282 $strNavigation .=
" | <a href=\"$self?report=$report&title=".urlencode($title).
"&sql_order=".urlencode($sql_order).
"&pos=$pos_end$q\"> $strEnd >></a>";
284 $strNavigation .=
" ";
286 $strNavigation .=
"</td>\n";
287 $strNavigation .=
"</tr></table>\n";
289 header(
"Expires: Sat 20 May 1995 03:32:38 GMT");
290 header(
"Pragma: no-cache");
291 header(
"Cache-Control: no-cache, must-revalidate");
293 echo
"<table border=0 align=center width='90%' class='dmsbg' cellpadding=3 cellspacing=0><tr><td>";
294 echo
"<table border=0 align=center width='100%' bgcolor=white cellpadding=2 cellspacing=0>";
295 echo
"<tr><td class='dtl' align='left'>";
296 echo
"<a href='$produrl/hcuadm/cuilist.prg'>Credit Union List</a> 297 <a href='$self?report=0'>Report Menu</a> 298 <A HREF='$self?csv=csv&report=$report&$q'>Download CSV</a></td><td class='dtl' align='right'> ";
300 echo
"$strShowingRecords $pos - $pos_next ($num_rows $strTotal)";
302 echo
"</td></tr></table>";
305 echo
"<table cellspacing=0 border=$cfgBorder align=center width='100%'>";
306 echo
"<tr><td class='hdr' colspan='$num_fields' align='center'>$title</td></tr><tr>";
308 for ($i_field = 0; $i_field < $num_fields; $i_field++) {
309 $field_name = $titles[$i_field];
310 echo
"<th class='hdr'>$field_name</th>";
313 if ((
sizeof($culist)) < 1) {
314 echo
"<tr class='odd'><td class='dtl' colspan='$num_fields'>$strEmptySet</td></tr>";
317 for ($i_row = $pos; $i_row < $pos_next; $i_row++) {
318 $row = explode(
"\t",rtrim($culist[$i_row],
"\r\n"));
320 # throw away the sort column 324 $hdrdtl=array_shift($row);
326 $rbg=($hdrdtl ==
's' ?
'dtl' :
'odd_small');
328 echo
"<tr class=$rbg>";
329 for ($i_field = 0; $i_field <
sizeof($row); $i_field++) {
330 if (!isset($row[$i_field]))
331 unset($row[$i_field]);
332 $field_type = $ftypes[$i_field];
333 $field_name = $titles[$i_field];
334 if (preg_match(
"/(int|numeric)/i", $field_type)) {
336 echo
"<td class='$rbg' align=right valign=top> $row[$i_field] </td>\n";
337 } elseif ($cfgShowBlob ==
false && preg_match(
"/BLOB/i", $field_type)) {
338 echo
"<td class='$rbg' align=right valign=top> [BLOB] </td>\n";
339 } elseif (preg_match(
"/(text|char)/i", $field_type)) {
341 if (strlen($row[$i_field]) > $cfgMaxText && !empty($cfgMaxText)) {
342 $strLgText = nl2br(htmlspecialchars(substr($row[$i_field], 0, $cfgMaxText))) .
" <br><b>... $strMore ...</b>";
344 $strLgText = nl2br(htmlspecialchars($row[$i_field]));
346 echo
"<td class='$rbg' valign=top> $strLgText</td>\n";
347 } elseif ($field_type ==
"bool") {
348 echo
"<td class='$rbg' valign=top> ", bool_YesNo($row[$i_field]),
" </td>\n";
350 echo
"<td class='$rbg' valign=top> ", nl2br(htmlspecialchars($row[$i_field])),
" </td>\n";
361 echo
"</td></tr></table>";
365 # show list of selections 366 header(
"Expires: Sat 20 May 1995 03:32:38 GMT");
367 header(
"Pragma: no-cache");
368 header(
"Cache-Control: no-cache, must-revalidate");
369 cu_header(
"Select Report");
371 <form action=
'$self' method=
'GET'>
372 <table width=
'500' border=
'0' align=
'center' cellpadding=3 cellspacing=0
class=
'dmsbg'><tr><td>
373 <table width=
'100%' border=
'0' align=
'center' bgcolor=white cellpadding2 cellspacing=0>
374 <tr
class=
'barb'><td align=
'center'><font size=+1>Please Select Report</font></td></tr>
375 <tr><td><a href=
"$produrl/hcuadm/cuilist.prg" target=
"parent">Credit Union List</a></td></tr>
376 <tr
class=
'hdr'><td>E-Statement Reports</td></tr>
377 <tr
class=
'msg'><td>$msg</td></tr>
378 <tr
class=
'odd_small'><td> <input type=
'radio' name=
'report' value=
'1'> E-Statement Count</td></tr>
379 <tr
class=
'even_small'><td> <input type=
'radio' name=
'report' value=
'2'> Missing Fragments</td></tr>
380 <tr
class=
'odd_small'><td> <input type=
'radio' name=
'report' value=
'3'> Last Status</td></tr>
381 <tr
class=
'hdr'><td> </td></tr>
382 <tr
class=
'odd_small'><td>
383 <table align=
'center'><tr><td
class=
'odd_small'> Cutoff Date (YYYYMMDD)</td><td> <input type=
'text' size=
'10' maxlength=
'8' name=
'cdate'></td></tr>
384 <tr><td
class=
'odd_small'> Cutoff Time (HH:MM:SS)</td><td> <input type=
'text' name=
'ctime' value=
'00:00:00' size=
'10' maxlength=
'8'></td></tr>
385 <tr><td colspan=2
class=
'odd_small'><input type=
'checkbox' name=
's0' value=
'1'> Summary Only </td></tr></table>
387 <tr
class=
'hdr'><td> </td></tr>
388 <tr
class=
'odd_small'><td> Include Data from <br>
389 <!-- <input type=
'checkbox' name=
's1' value=
'1'> www
390 <input type=
'checkbox' name=
's2' value=
'1'> www2
391 <input type=
'checkbox' name=
's4' value=
'1'> www4-->
392 <input type=
'checkbox' name=
's3' value=
'1'> www3
393 <input type=
'checkbox' name=
's5' value=
'1'> www5
394 <input type=
'checkbox' name=
's6' value=
'1'> www6
395 <input type=
'checkbox' name=
's7' value=
'1'> Odyssey
397 <tr
class=
'hdr'><td> </td></tr>
398 <tr
class=
'hdrc'><td><input type=
'submit' value=
'Go'></td></tr>
405 function save_server(&$response, $key, $server)
407 $row = explode(
"\t",$response);
408 if ($row[0]==
's' || $row[0]==
'T') {
409 $response = rtrim($response,
"\r\n") .
"\t$server\r\n";
411 $response = rtrim($response,
"\r\n") .
"\t\r\n";
415 function sort_by(&$response, $key, $server)
417 $row = explode(
"\t",$response);
419 $response =
"zzzzzzzz" . $row[1] . $server . sprintf(
'%05d',$key) .
"\t$response";
421 $response = $row[1] . $server . sprintf(
'%05d',$key) .
"\t$response";