37 protected $SYS_TYPE_UPG_TEST;
40 protected $SYS_TYPE_CLOSED;
43 protected $download =
false;
46 protected $dev_oauth =
null;
49 protected $cu_index =
'hcuadm/cuindex.prg';
52 protected $cu_trusted_url =
'homecu.net/hcuadm/CuVendorListApi.prg';
55 protected $trusted_master =
'cutrustedmaster';
58 protected $cu_admin =
'cuadmin';
61 protected $cu_info =
'cuinfo';
64 protected $cu_data = [];
67 protected $trusted_vendors = [];
70 protected $external_servers = [
'my',
'www3',
'www5',
'www6'];
113 return $this->download ===
true;
122 if (isset($_GET[
'download'])) {
123 $this->download =
true;
136 $length = strlen($content) + 1;
137 header(
"Content-type: bad/type");
138 header(
"Content-length: " . $length);
139 header(
"Content-Disposition: attachment; filename=\"vendor-by-cu-". date(
'Y-m-d') .
".csv\"");
151 $sql =
"select * from {$this->trusted_master} order by trustedvendor";
153 $res = db_query($sql, $this->dbh);
154 }
catch (Exception $e) {
155 throw new Exception(
"Exception getting master data: {$e->getMessage()} " . pg_last_error($this->dbh));
158 while ($row = db_fetch_assoc($res)) {
159 $this->trusted_vendors[$row[
'trustedid']] = $row[
'trustedvendor'];
172 $trusted_arr = array_keys($this->trusted_vendors);
174 foreach ($this->external_servers as $server) {
194 while ($row = db_fetch_assoc($res)) {
197 $cu = trim($row[
'cu']);
199 if (! isset($this->cu_data[$cu][
'vendor'])) {
200 $this->cu_data[$cu][
'vendor'] = trim($row[
'vendor']);
201 $this->cu_data[$cu][
'server'] = trim($row[
'www_server']);
202 $this->cu_data[$cu][
'in_setup'] = $row[
'in_setup'];
205 }
catch (Exception $e) {
206 throw new Exception(
"Exception getting CU data: {$e->getMessage()} " . db_last_error());
220 .
" {$this->cu_admin}.cu," 221 .
" upper({$this->cu_info}.user_name)," 224 .
"((coalesce({$this->cu_info}.system_options, 0) & {$this->SYS_TYPE_UPG_TEST}) <> 0)::int as in_setup," 225 .
" {$this->cu_info}.vendor as vendor," 226 .
" {$this->cu_info}.www_server as www_server" 227 .
" from {$this->cu_info}" 228 .
" left join {$this->cu_admin}" 229 .
" on upper({$this->cu_admin}.user_name) = upper({$this->cu_info}.user_name)" 230 .
" where {$this->cu_info}.system_options & {$this->SYS_TYPE_CLOSED} = 0" 231 .
" order by {$this->cu_info}.user_name asc";
242 $params = http_build_query([
'Cu' =>
'',
'trustedids' => json_encode($ids)]);
243 $protocol = ($server ==
'localhost')?
'http' :
'https';
244 $cmd =
"$protocol://$server.{$this->cu_trusted_url}";
246 $ch = curl_init($cmd);
248 curl_setopt($ch,CURLOPT_USERPWD,
"nobody:no1home");
249 curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
250 curl_setopt($ch,CURLOPT_POST,
true);
251 curl_setopt($ch,CURLOPT_POSTFIELDS, $params);
254 $rawresp = curl_exec($ch);
256 return HCU_JsonDecode($rawresp,
true);
266 $cookies =
"HCUTicket={$_COOKIE['HCUTicket']};";
268 if ($server ==
'my') {
270 if ($this->dev_oauth) {
271 $cookies .=
";homecu_dev_oauth2_proxy={$this->dev_oauth}";
275 if (isset($_COOKIE[
'homecu_dev_oauth2_proxy'])) {
276 $cookies .=
";homecu_dev_oauth2_proxy={$_COOKIE['homecu_dev_oauth2_proxy']}";
296 foreach ($external_data[
'data'] as $key => $vendor_arr) {
299 list ($cu, $vendor) = explode(
'|', $key);
310 $this->cu_data[$cu][
'trustedid'][] = strtoupper($vendor);
325 if ($server ==
'my') {
326 $server .=
'.homecu.net';
329 if (isset($this->cu_data[$cu][
'server'])) {
330 return $this->cu_data[$cu][
'server'] == $server;
344 array_key_exists(
'status', $result) &&
345 array_key_exists(
'Response', $result[
'status']) &&
346 ($result[
'status'][
'Response'] ==
true) &&
347 array_key_exists(
'data', $result) &&
348 is_array($result[
'data']);
359 return array_key_exists($cu, $this->cu_data);
373 isset($this->cu_data[$cu][
'trustedid']) &&
374 is_array($this->cu_data[$cu][
'trustedid'])
376 return in_array($vendor, $this->cu_data[$cu][
'trustedid']);
397 $header =
'"Credit Union"' .
',';
399 foreach ($this->trusted_vendors as $vendor_id => $name) {
400 $header .=
'"' . $vendor_id .
'",';
403 return rtrim($header,
"\t") . PHP_EOL;
416 <p style=\"text-align:center\"><strong><em>If the CU does not have trusted vendors listed, 417 there are no trusted vendors set up in their Trusted Details.</em></strong></p> 418 <table id=\"report-by-vendor-table\"> 420 <th id=\"tv-hd-$id\" class=\"cu-name\"> </th> 423 foreach ($this->trusted_vendors as $vendor_id => $name) {
426 $title = (! empty($name))? $name : str_replace(
'_',
' ', $vendor_id);
429 <th id=\"tv-hd-$id\" class=\"rotate\" title=\"$title\"><div><span>" 430 . str_replace(
'_',
' ', $vendor_id) .
"</span></div></th>";
458 foreach ($this->cu_data as $cu => $trusted_array) {
472 $row =
'"' . $cu .
'",';
474 foreach ($this->trusted_vendors as $vendor_id => $name) {
477 $row .=
'"' . $used .
'",';
480 $row = rtrim($row,
',') . PHP_EOL;
494 isset($this->cu_data[$cu][
'trustedid']) &&
495 is_array($this->cu_data[$cu][
'trustedid']) &&
496 in_array(strtoupper($vendor_id), $this->cu_data[$cu][
'trustedid'])
513 foreach ($this->cu_data as $cu => $vendors_array) {
514 $toggle = ($toggle ==
'even')?
'odd' :
'even';
533 <tr class=\"$toggle\"> 534 <td><a href=\"$link\">$cu</a></td>";
536 foreach ($this->trusted_vendors as $vendor_id => $name) {
539 $row .=
"<td class=\"$class\" title=\"$vendor_id $usage by $cu\">$txt</td>";
557 isset($this->cu_data[$cu][
'vendor']) &&
558 isset($this->cu_data[$cu][
'server'])
564 .
"&vc={$this->cu_data[$cu]['vendor']}" 565 .
"&wc={$this->cu_data[$cu]['server']}";
575 ($_SERVER[
'REQUEST_SCHEME'] !=
'https') &&
576 (getenv(
'HTTP_X_FORWARDED_PROTO') !=
'https')
580 return $protocol .
'://' . strtolower($_SERVER[
'HTTP_HOST']) .
'/' . $this->cu_index;
593 isset($this->cu_data[$cu][
'trustedid']) &&
594 is_array($this->cu_data[$cu][
'trustedid']) &&
595 in_array(strtoupper($vendor_id), $this->cu_data[$cu][
'trustedid'])
597 return [
'used',
'✔',
'used'];
600 return [
'not-used',
'x',
'not used'];
615 $count = count($this->trusted_vendors) + 1;
619 <td id="vendor-by-cu-footer" colspan="' . $count .
'"> 620 <a href="?download" target="_blank">Download</a> 633 public function set ($prop, $value)
635 $this->{$prop} = $value;
SetCellAttributes($cu, $vendor_id)
isRealServer($server, $cu)
setCsvCellContent($vendor_id, $cu)
VendorExistsInData($cu, $vendor)
OutputHtmlDataRow($cu, $toggle)
MergeClientsToCuData($server, $external_data)
GetExternalTrustedData($server, $ids)