7 $string = array(
"filter" => HCUFILTER_INPUT_STRING);
8 $parameters = array(
"a" => array(
"operation" =>
""));
9 HCU_ImportVars($parameters,
"a", array(
"operation" => $string,
"fileIndex" => $string));
10 extract($parameters[
"a"]);
12 $operation = isset($operation) ? trim($operation) :
"";
13 $fileIndex = isset($fileIndex) ? trim($fileIndex) :
"";
19 function GetTocFile() {
20 return "duediligence.toc";
27 function GetAuditDir() {
28 return "/home/homecu/audit";
36 return "main.prg?ft=14";
48 PrintPage(GetFileList());
62 function GetFileList() {
64 $auditDir = GetAuditDir();
65 $tocFile = GetTocFile();
66 $fullFile =
"$auditDir/$tocFile";
68 if (!is_readable($fullFile)) {
69 throw new exception(
"File is not readable.", 2);
72 $tocFP = fopen($fullFile,
"r");
76 throw new exception(
"File handle is not found.", 1);
79 while (($row = fgetcsv($tocFP)) !==
false) {
81 if (count($row) == 1 && !isset($row[0])) {
86 if (count($row) < 3) {
90 $fileList[] = array(
"text" => $row[0],
"filename" => $row[1],
"filetype" => $row[2]);
93 return array(
"list" => $fileList,
"error" =>
"",
"code" => 0);
94 }
catch (exception $e) {
95 return array(
"list" => array(),
"error" => $e->getMessage(),
"code" => $e->getCode());
106 function ShowFile($fileIndex) {
108 $auditDir = GetAuditDir();
109 $fileList = GetFileList();
111 if ($fileList[
"code"] != 0) {
112 throw new exception(
"File list handle was not found.", 1);
115 $fileList = $fileList[
"list"];
117 if (!HCU_array_key_exists($fileIndex, $fileList)) {
118 throw new exception(
"File index was not found.", 2);
121 $fileRow = $fileList[$fileIndex];
123 if ($fileRow[
"filename"] ==
"") {
124 throw new exception(
"Filename is not set.", 4);
127 if (basename($fileRow[
"filename"]) != $fileRow[
"filename"]) {
128 throw new exception(
"Do not allow filename to traverse the filesystem.", 5);
131 $file = realpath(
"$auditDir/" . $fileRow[
"filename"]);
133 if (!is_readable($file)) {
134 throw new exception(
"File is not readable.", 3);
137 switch($fileRow[
"filetype"]) {
139 $fileContents = file_get_contents($file);
140 $exgmt = gmdate(
"D M d Y H:i:s", time() + 60);
141 header(
"Expires: $exgmt GMT");
142 header(
"Content-type: application/pdf");
143 header(
"Content-Disposition: inline; filename=\"" . $fileRow[
"text"] .
".pdf\"");
144 header(
'Content-Transfer-Encoding: binary');
149 throw new exception(
"File is not in a format this script handles.", 4);
154 }
catch (exception $e) {
155 PrintNotFoundFilePage();
164 function PrintNotFoundFilePage() { ?>
167 <title>404 Not Found</title>
171 <p>The requested file was not found on the server.</p>
182 function PrintPage($fileList) {
183 $self = GetSelf(); ?>
184 <div
class=
"container-fluid userAlertsDiv vsgPrimary" id=
"auditDiv">
186 <div
id=
"formValidateAlertsDiv" class=
"k-block k-error-colored formValidateDiv" style=
"display:none;"></div>
188 <div
class=
"well well-sm">
190 <h3
class=
"col-xs-12">Confidentially Notice</h3>
193 <div
class=
"col-xs-12">
194 This Confidential Information is intended solely
for Home CU, LLC., customers and their employees, agents, consultants, subcontractors, or regulatory agencies. Any review, retransmission, dissemination or other use of
this information by persons or entities other than the intended recipient is prohibited.
198 <div
class=
"col-xs-12">
199 By clicking the link below you agree to these confidentiality terms.
203 <div
class=
"well well-sm">
204 <?php
if ($fileList[
"code"] != 0 || count($fileList[
"list"]) == 0) { ?>
205 <div
class=
"row hcu-secondary">
206 <div
class=
"col-xs-12 vsgSecondary hcu-note">
212 <?php
foreach ($fileList[
"list"] as $index => $fileRow) { ?>
213 <a
class=
"col-xs-12" href=
"<?php echo $self; ?>&operation=showFile&fileIndex=<?php echo $index; ?>" target=
"HCUaudit"><?php echo $fileRow[
"text"]; ?></a>