17 $monLibrary= dirname(__FILE__) .
"/../library";
18 require_once(
"$monLibrary/cu_top.i");
19 require_once(
"$monLibrary/ck_hticket.i");
22 if (!CheckPerm($link, $Hu,
'siteSettings', $_SERVER[
'REMOTE_ADDR'])) {
25 header(
"Location: /hcuadm/hcu_noperm.prg");
44 $string = array(
"filter" => FILTER_SANITIZE_STRING);
45 $array = HCUFILTER_INPUT_ARRAY;
46 $encodedArray = array(
"filter" => FILTER_DEFAULT);
47 $dms_ok = Array(
'user_name' => $string,
'loadSettings' => $string,
'langSelect' => $array,
'postScriptProxy' => $string,
'postContentTheme' => $string,
48 "postLogout" => array(
'filter' => FILTER_SANITIZE_STRING,
'options' => array(
"flags" => FILTER_FLAG_NO_ENCODE_QUOTES)),
"postil" => $encodedArray,
"operation" => $string,
"fileNames" => $string);
49 HCU_ImportVars($HB_ENV,
'HCUPOST', $dms_ok);
51 $username = HCU_array_key_exists(
"user_name", $HB_ENV[
"HCUPOST"]) ? trim($HB_ENV[
"HCUPOST"][
"user_name"]) :
"";
52 $operation = HCU_array_key_exists(
"operation", $HB_ENV[
"HCUPOST"]) ? trim($HB_ENV[
"HCUPOST"][
"operation"]) :
"";
53 $fileNames = HCU_array_key_exists(
"fileNames", $HB_ENV[
"HCUPOST"]) ? trim($HB_ENV[
"HCUPOST"][
"fileNames"]) :
"";
55 $retStatus_ary = Array(
57 'homecuErrors' => Array(),
65 if ($operation ==
"loadImage") {
69 "1" =>
"1: The file you tried to upload is just too big. The allowable limit is 10MB.",
70 "2" =>
"2: The file you tried to upload is just too big. The allowable limit is 10MB.",
71 "3" =>
"3: The file was only partially uploaded",
72 "4" =>
"4: no file was uploaded");
74 $fileDir =
"/home/$username/public_html/images/";
75 if (!is_writable($fileDir)) {
76 throw new exception(
"Image Directory is not set up correctly.", 1);
79 $file = $_FILES[
'photoUpload'];
80 $filepath = $fileDir . basename($file[
"name"]);
82 if ($file[
"error"] != 0) {
83 $errorInt = $file[
"error"];
84 throw new exception(HCU_array_key_exists($errorInt, $fileErrors) ? $fileErrors[$errorInt] :
"$errorInt: Unknown error.", 2);
87 $filetmp = $file[
'tmp_name'];
88 if (!@move_uploaded_file($filetmp, $filepath)) {
90 throw new exception(
"Couldn't post the file where it belongs.", 3);
93 @chmod($filepath, 0644);
94 $returnArray = array(
"code" =>
"000");
95 }
catch(exception $e) {
96 $returnArray = array(
"error" => $e->getMessage(),
"code" => $e->getCode());
99 header(
'Content-type: application/json');
100 print HCU_JsonEncode($returnArray);
103 }
else if ($operation ==
"removeImage") {
106 $fileDir =
"/home/$username/public_html/images/";
107 if (!is_writable($fileDir)) {
108 throw new exception(
"Image Directory is not set up correctly.", 1);
111 $filepath = $fileDir . $fileNames;
112 if (@file_exists($filepath) && !@unlink($filepath)) {
113 throw new exception(
"File could not be deleted.", 2);
117 }
catch(exception $e) {
118 $returnValue = $e->getMessage();
125 if ($HB_ENV[
'HCUPOST'][
'loadSettings'] ==
'preview' || $HB_ENV[
'HCUPOST'][
'loadSettings'] ==
'production') {
135 $masterLangList = returnMasterLanguageList();
138 $langSelect = HCU_array_key_value(
"langSelect", $HB_ENV[
"HCUPOST"]);
139 $langSelect = $langSelect ===
false || !is_array($langSelect) ? array() : $langSelect;
140 $HB_ENV[
"HCUPOST"][
"langSelect"] = $langSelect;
144 array_push($HB_ENV[
'HCUPOST'][
'langSelect'],
'en_US');
146 $selectedLang = array_intersect_key($masterLangList, array_flip($HB_ENV[
'HCUPOST'][
'langSelect']));
149 'language' => $selectedLang,
150 'contentTheme' => $HB_ENV[
'HCUPOST'][
'postContentTheme'],
151 'Logout' => $HB_ENV[
'HCUPOST'][
'postLogout'],
152 "imageLocations" => HCU_JsonDecode($HB_ENV[
"HCUPOST"][
"postil"])
154 } elseif ($HB_ENV[
'HCUPOST'][
'loadSettings'] ==
'savetoproduction') {
159 throw new Exception(
'Invalid parameter setting. Action cancelled.');
170 $cuSettingsFileName =
"hcuSettings.i";
172 $cuSettingsDir =
"/home/{$HB_ENV['HCUPOST']['user_name']}/public_html/bankingIncludes/";
173 $cuPublicDir =
"/home/{$HB_ENV['HCUPOST']['user_name']}/public_html/";
176 if ($HB_ENV[
'HCUPOST'][
'loadSettings'] ==
'preview' || $HB_ENV[
'HCUPOST'][
'loadSettings'] ==
'production') {
177 $cuSaveSettingsDir = $cuSettingsDir . $HB_ENV[
'HCUPOST'][
'loadSettings'] .
'/';
179 $cuDefaultSettingsDir =
"/home/httpd/homecu/bankingIncludes/";
180 $cuLoadSettingsFile =
'';
181 if (is_dir($cuSaveSettingsDir)) {
183 if (is_readable($cuSaveSettingsDir . $cuSettingsFileName)) {
186 copy($cuSaveSettingsDir . $cuSettingsFileName, $cuSaveSettingsDir .
'.' . $cuSettingsFileName);
188 $fhSettings = fopen($cuSaveSettingsDir . $cuSettingsFileName,
'w');
189 fwrite($fhSettings, HCU_JsonEncode($cuSettings));
191 $retStatus_ary[
'homecuInfo'] =
"Credit union {$HB_ENV['HCUPOST']['loadSettings']} settings updated.";
194 throw new Exception(
'Directory not found for the credit union.');
198 $cuSourceSettingsDir = $cuSettingsDir .
'preview/';
199 $cuDestSettingsDir = $cuSettingsDir .
'production/';
200 if (is_readable($cuSourceSettingsDir . $cuSettingsFileName)) {
201 if (is_readable($cuDestSettingsDir . $cuSettingsFileName)) {
204 copy($cuDestSettingsDir . $cuSettingsFileName, $cuDestSettingsDir .
'.' . $cuSettingsFileName);
206 copy($cuSourceSettingsDir . $cuSettingsFileName, $cuDestSettingsDir . $cuSettingsFileName);
207 $retStatus_ary[
'homecuInfo'] =
'Credit Union Preview settings saved to production.';
209 throw new Exception(
'Preview settings not found. Unable to save to production.');
213 }
catch (Exception $ex) {
214 $retStatus_ary[
'homecuErrors'][] =
"Unexpected error while saving. " . $ex->getMessage();
217 header(
'Content-type: application/json');
219 print HCU_JsonEncode(Array(
"Results" => Array($retStatus_ary)));