13 $monLibrary = dirname(__FILE__) .
"/../library";
14 require_once(
"$monLibrary/cu_top.i");
15 require_once(
"$monLibrary/ck_hticket.i");
18 if (!CheckPerm($link, $Hu,
'siteSetColor', $_SERVER[
'REMOTE_ADDR'])) {
21 header(
"Location: /hcuadm/hcu_noperm.prg");
32 $array = array(
"filter" => FILTER_DEFAULT);
33 $string = array(
"filter" => FILTER_SANITIZE_STRING);
35 $homecuOkay = array(
'user_name' => $string,
'loadSettings' => $string,
'postStyleSettings' => $array);
37 HCU_ImportVars($HB_ENV,
'HCUPOST', $homecuOkay);
40 $retStatus_ary = Array(
42 'homecuErrors' => Array(),
46 $styleDefaults = array(
47 "fontFamily" =>
"Helvetica, \"Helvetica Neue\", Arial, sans-serif",
48 "headerBackground" =>
"#24417A",
49 "headerForeground" =>
"#FFFFFF",
50 "headerBorder" =>
"#2A2D33",
51 "footerBackground" =>
"#E7E8EA",
52 "footerForeground" =>
"#777777",
53 "menuGroupBackground" =>
"#1B8DD6",
54 "menuGroupBackgroundLighter" =>
"#2198E3",
55 "menuGroupForeground" =>
"#FFFFFF",
56 "menuForeground" =>
"#337AB7",
57 "menuForegroundHover" =>
"#23527C",
58 "menuBackgroundHover" =>
"#EEEEEE",
59 "menuBackground" =>
"#F8F8F8",
60 "slideinBackground" =>
"#808080",
61 "slideinForeground" =>
"#FFFFFF",
62 "contentBackground" =>
"#FFFFFF",
63 "contentForeground" =>
"#333333",
64 "logoHeightDesktop" =>
"75px",
65 "logoHeightMobile" =>
"35px",
66 "logoBackground" =>
"transparent",
67 "contentBorderWidth" =>
"0px",
68 "contentBorderStyle" =>
"solid",
69 "contentBorderColor" =>
"#000000",
70 "navBadgeColor" =>
"#777777",
71 "navIconColor" =>
"#9D9D9D",
72 "navIconColorHover" =>
"#FFFFFF",
73 "navBackground" =>
"transparent",
74 "navForeground" =>
"#FFFFFF",
75 "navActiveBorder" =>
"#FF0000",
76 "bannerBackground" =>
"#161620",
77 "bannerHeight" =>
"60px",
78 "bannerWidth" =>
"100%" 83 $cuSettingsFileName =
"brand.css";
84 $cuSettingsFileProdName =
"brand.{$HB_ENV['HCUPOST']['user_name']}.css";
86 $cuSettingsDir =
"/home/{$HB_ENV['HCUPOST']['user_name']}/public_html/bankingIncludes/";
87 $cuPublicDir =
"/home/{$HB_ENV['HCUPOST']['user_name']}/public_html/";
88 $templateSettingsDir =
"/home/homecu/public_html/bankingIncludes/css/";
90 if ($HB_ENV[
'HCUPOST'][
'loadSettings'] ==
'preview' || $HB_ENV[
'HCUPOST'][
'loadSettings'] ==
'production') {
99 $cuSaveSettingsDir = $cuSettingsDir . $HB_ENV[
'HCUPOST'][
'loadSettings'] .
'/css/';
102 $cuDefaultSettingsDir =
"/home/httpd/homecu/bankingIncludes/";
103 $cuLoadSettingsFile =
'';
104 if (is_dir($cuSaveSettingsDir) && is_writable($cuSaveSettingsDir)) {
106 $filename = $HB_ENV[
'HCUPOST'][
'loadSettings'] ==
'production' ? $cuSaveSettingsDir . $cuSettingsFileProdName : $cuSaveSettingsDir . $cuSettingsFileName;
107 if (is_readable($filename)) {
110 copy($filename, $cuSaveSettingsDir .
'.' . $cuSettingsFileName);
113 if (is_readable($templateSettingsDir . $cuSettingsFileName)) {
114 $brandOptions = HCU_JsonDecode($HB_ENV[
'HCUPOST'][
'postStyleSettings']);
115 $styleContent = file_get_contents($templateSettingsDir . $cuSettingsFileName);
117 foreach($styleDefaults as $key => $value) {
118 $value = HCU_array_key_exists($key, $brandOptions) ? $brandOptions[$key] : $value;
119 $value = isset($value) ? trim($value) :
"inherit";
120 $styleContent = str_replace(
'{{' . $key .
'}}', $value, $styleContent);
124 $styleContent = explode(
'/* customBranding */', $styleContent, 2);
125 $styleContent = trim($styleContent[0]);
126 if ($brandOptions[
"customBranding"] !=
"") {
127 $styleContent .=
"\n\n" .
'/* customBranding */' .
"\n" . $brandOptions[
"customBranding"];
131 $fhSettings = fopen($filename,
'w');
132 fwrite($fhSettings, $styleContent);
134 $retStatus_ary[
'homecuInfo'] =
"Credit union {$HB_ENV['HCUPOST']['loadSettings']} branding updated.";
137 throw new Exception(
'Template file not found.');
141 throw new Exception(
"Directory {$cuSaveSettingsDir} not found for the credit union.");
143 } elseif ($HB_ENV[
'HCUPOST'][
'loadSettings'] ==
'savetoproduction') {
146 $cuSourceSettingsDir = $cuSettingsDir .
'preview/css/';
147 $cuDestSettingsDir = $cuSettingsDir .
'production/css/';
148 if (is_readable($cuSourceSettingsDir . $cuSettingsFileName)) {
149 if (is_readable($cuDestSettingsDir . $cuSettingsFileProdName)) {
152 copy($cuDestSettingsDir . $cuSettingsFileProdName, $cuDestSettingsDir .
'.' . $cuSettingsFileName);
154 copy($cuSourceSettingsDir . $cuSettingsFileName, $cuDestSettingsDir . $cuSettingsFileProdName);
155 $retStatus_ary[
'homecuInfo'] =
'Credit Union Preview branding saved to production.';
157 throw new Exception(
'Preview branding file not found. Unable to save to production.');
161 throw new Exception(
'Invalid parameter setting. Action cancelled.');
163 }
catch (Exception $ex) {
165 $retStatus_ary[
'homecuErrors'][] =
"Unexpected error while saving. " . $ex->getMessage();
168 header(
'Content-type: application/json');
170 print HCU_JsonEncode(Array(
"Results" => Array($retStatus_ary)));