Odyssey
hcuForms.prg
1 <?php
2  /*
3  * File: hcuForms
4  *
5  * Purpose: Get the custom content for a credit union's secure forms. Simply display the content
6  * or a message if no content exists.
7  *
8  */
9 
10  // ** SET SCRIPT LEVEL VARIABLES
11  $serviceShowInfo = true;
12  $serviceLoadMenu = true;
13  $serviceShowMenu = true;
14  $serviceAllowReadonly = false;
15 
16  // ** INCLUDE MAIN GLOBAL SCRIPT -- Handles security / global variable values
17  require_once(dirname(__FILE__) . '/../library/hcuService.i');
18 
19  /*
20  * ** CHECK USER FEATURE PERMISSIONS **
21  * NOTE: DOES NOT RETURN ON FAILURE
22  */
23  PermCheckFeatureScreen($dbh, $HB_ENV, $MC, FEATURE_BASIC);
24 
25 
26  // ** INCLUDE PRE CONTENT SCRIPT
27  require_once(dirname(__FILE__) . '/../includes/hcuPreContent.i');
28 
29  // ** INSERT BUSINESS LOGIC FOR THIS FORM
30  $Cu = $HB_ENV["Cu"];
31  $Cn = $HB_ENV["Cn"];
32  $chome = $HB_ENV["chome"];
33  $Flang = $HB_ENV["Flang"];
34 
35  // get any passed variables
36  $dms_ok = array( "target" => "string", "x" => "string" );
37 
38  dms_import_v2($HB_ENV, 'HCUPOST', $dms_ok);
39 
40  try {
41  $Flang = (trim($Flang) == "" ? "en_US" : trim($Flang));
42 
43  if ( $HB_ENV['offline'] != "N" ) {
44  $thisPageErrors = $HB_ENV["offlinemsg"];
45  throw new Exception( json_encode( $thisPageErrors ) );
46  }
47 
48  /*
49  * RETRIEVE the secure forms page. NOTE: Never a popup.
50  *
51  */
52  // see if opening a specific target form
53  $target = $HB_ENV["HCUPOST"]["target"];
54  if ( strlen( $target ) ) {
55  // build a path to the file
56  $formFileName = basename(trim($target)); // NOTE: the file name is what is passed in (nothing added)
57  $formFileDir = "/home/{$HB_ENV['chome']}/public_html/bankingIncludes/";
58 
59  $displayContent = "";
60 
61  // try to read the language file, or english if no language
62  $formFilePath = "";
63  if (is_readable($formFileDir . "/" . $Flang . "/" . $formFileName)) {
64  $formFilePath = $formFileDir . "/" . $Flang . "/" . $formFileName;
65  } else if (is_readable($formFileDir . "/en_US/" . $formFileName)) {
66  $formFilePath = $formFileDir . "/en_US/" . $formFileName;
67  } else {
68  // ** NO FILE TO READ
69  }
70 
71  if ( $formFilePath != "" && is_readable($formFilePath)) {
72  $displayContent = file_get_contents($formFilePath);
73  }
74 
75  if ( $displayContent == "" ) {
76  $displayContent = $MC->msg( "Not Found", HCU_DISPLAY_AS_HTML );
77  }
78 
79  } else if ( strlen( $HB_ENV["HCUPOST"]["x"] ) ) {
80  /* Note: This functionality isn't used for now. 04/10/2014
81  *
82  */
83 
84  $valuesJsonString = hcu_decrypturl($HB_ENV['HCUPOST']['x'], $GLOBALS['hcuViewNoticeKey']);
85  $formValues = json_decode($valuesJsonString, true);
86  $formFileName = basename(trim($formValues["target"])); // NOTE: the file name is what is passed in as the target (nothing added)
87  $formFileDir = "/home/{$HB_ENV['chome']}/public_html/";
88  $formFileDir = "/fi/{$HB_ENV['chome']}";
89 
90  print "Form Name: $formFileName<br>";
91 
92  $displayContent = "";
93 
94  // try to read the file
95  $formFilePath = $formFileDir . "/" . $formFileName;
96 
97  if ( $formFilePath != "" ) {
98  //$displayContent = file_get_contents($formFilePath);
99  //$displayContent = "<iframe src=\"$formFilePath\"></iframe>";
100  $displayContent = "<iframe src=\"$formFilePath\" width='700px' height='200px' id='iframe1' marginheight='0' frameborder='0' onLoad=\"autoResize('iframe1');\"></iframe>";
101  }
102 
103  if ( $displayContent == "" ) {
104  $displayContent = $MC->msg( "Not Found", HCU_DISPLAY_AS_HTML );
105  }
106  } else {
107  // see if there is an extra file on the path
108  $formFileName = basename( HCU_array_key_value("PATH_INFO", $_SERVER) );
109  // print "<br>Form: $formFileName";
110 
111  if ( strlen( $formFileName ) && $formFileName != __FILE__ ) {
112  $formFileDir = "/home/{$HB_ENV['chome']}/public_html/";
113 
114  // make sure user didn't try to get to bankingIncludes directory
115  $tryingBankingIncludes = strstr( HCU_array_key_value("PATH_INFO", $_SERVER), "bankingIncludes" );
116 
117  //print "Form Name: $formFileName<br>";
118 
119  $displayContent = "";
120 
121  // try to read the file
122  $formFilePath = $formFileDir . "/" . $formFileName;
123  if ( $formFilePath != "" && !$tryingBankingIncludes && is_readable($formFilePath)) {
124  $displayContent = file_get_contents($formFilePath);
125  }
126 
127  if ( $displayContent == "" || $tryingBankingIncludes ) {
128  $displayContent = $MC->msg( "Not Found", HCU_DISPLAY_AS_HTML );
129  }
130  } else {
131  $formsContentAry = Get_NoticeInfo($dbh, $HB_ENV, $MC, "R", "SecureForms", true);
132 
133  $displayContent = "";
134  if ( $formsContentAry["status"]["code"] == "000" && $formsContentAry["notice"][0]["notice_id"] ) {
135  $displayContent = $formsContentAry['notice'][0]["notice_text"];
136  }
137 
138  if ( $displayContent == "" ) {
139  $displayContent = $MC->msg( "Verify routing no match", HCU_DISPLAY_AS_HTML );
140  }
141 
142  /*
143  * We were thinking of encrypting the url so the users wouldn't see secure form file names.
144  *
145  $secureFormOptions = Array (
146  'target' => "e_noticefrmB.html"
147  );
148 
149  $encryptedOptions = hcu_encrypturl(json_encode($secureFormOptions), $GLOBALS['hcuViewNoticeKey']);
150 
151  print "Test e_noticefrm: x=" . urlencode($encryptedOptions);
152 
153  $secureFormOptions = Array (
154  'target' => "addchangefrm.html"
155  );
156 
157  $encryptedOptions = hcu_encrypturl(json_encode($secureFormOptions), $GLOBALS['hcuViewNoticeKey']);
158 
159  print "<br>Test addchangefrm: x=" . urlencode($encryptedOptions);
160  */
161  }
162  }
163 ?>
164 
165 <!-- prevents zoom on mobile that covers up submit buttons -->
166 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"/> <!--320-->
167 
168 <style>
169 ul {
170  list-style-type: none;
171  font-size: 14px;
172 }
173 li {
174  font-size: 14px;
175 }
176 </style>
177  <div class="k-content" style='font-size:12px;'>
178 
179  <div class="container-fluid">
180 
181  <?php echo $displayContent; ?>
182 
183  </div>
184 
185  </div>
186 
187  <script>
188 
189  // Arg1: content (url), Arg2: title, Arg3: width, Arg4: height
190  function ShowSecureForm(noticeContent) {
191  var noticeTitle;
192  var filePath = arguments[0];
193 
194  if ( arguments.length > 1 ) {
195  // ** Argument 2 is the noticeTitle
196  if (arguments[1]) {
197  noticeTitle = arguments[1];
198  }
199  }
200 
201  var windowWidth = 700;
202  if ( arguments.length > 2 ) {
203  // ** Argument 3 is the notice window width
204  if (arguments[2]) {
205  windowWidth = arguments[2];
206  }
207  } else {
208  windowWidth = "85%";
209  }
210 
211  var windowHeight = 300;
212  if ( arguments.length > 3 ) {
213  // ** Argument 4 is the notice window height
214  if (arguments[3]) {
215  windowHeight = arguments[3];
216  }
217  } else {
218  windowHeight = "85%";
219  }
220 
221  $(document.body).append('<div id="formWindow" ></div>');
222 
223  // set up a indeterminate progress bar
224  ShowWaitWindow();
225 
226  // window will need to be closed manually
227  $('#formWindow').kendoWindow({
228  visible: false,
229  iframe: true,
230  height: windowHeight,
231  width: windowWidth,
232  title: noticeTitle,
233  modal: true,
234  resizable: true,
235  refresh: function() {
236  this.center();
237  },
238  close: function(e) {
239  var dialog = $("#formWindow").data("kendoWindow");
240  dialog.destroy();
241  },
242  activate: function(e) {
243  CloseWaitWindow();
244  },
245  content: noticeContent
246  });
247 
248  // doing it this way for IE8
249  var dialog = $("#formWindow").data('kendoWindow');
250  dialog.center().open();
251 
252  }
253 
254  </script>
255 
256 <?php
257  /*
258  * ** END CONTENT
259  */
260  } catch (Exception $ex) {
261  //Return error message
262  $thisPageErrors = json_decode($ex->getMessage());
263  // ** Handle Errors on this screen
264  $serviceErrorCode = '917';
265  $serviceErrorMsgs = $thisPageErrors;
266 
267  require_once(dirname(__FILE__) . '/../includes/hcuErrorPage.i');
268  // drop through to close the page
269  }
270 
271  // ** INCLUDE POST CONTENT SCRIPT
272  require_once(dirname(__FILE__) . '/../includes/hcuPostContent.i');
273