Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php if (!defined('SM_PATH')) { define('SM_PATH', '../'); } if (!defined("ENM_HTTP_DIR"..

Decoded Output download

<?php 
 if (!defined('SM_PATH')) { define('SM_PATH', '../'); } if (!defined("ENM_HTTP_DIR")) { define("ENM_HTTP_DIR", SM_PATH); } require_once("EnmObject.php"); class EnmConfig extends EnmObject { private $configFile; private $defaultPrefFile; private $supportedLanguages = array('bg_BG'=>'Bulgarian', 'bn_BD'=>'Bengali (Bangladesh)', 'bn_IN'=>'Bengali (India)', 'ca_ES'=>'Catalan', 'cs_CZ'=>'Czech', 'cy_GB'=>'Welsh', 'da_DK'=>'Danish', 'de_DE'=>'German', 'el_GR'=>'Greek', 'en_US'=>'English', 'es_ES'=>'Spanish', 'et_EE'=>'Estonian', 'eu_ES'=>'Basque', 'fi_FI'=>'Finnish', 'fo_FO'=>'Faroese', 'fr_FR'=>'French', 'fy'=>'Frisian', 'hr_HR'=>'Croatian', 'hu_HU'=>'Hungarian', 'id_ID'=>'Bahasa Indonesia', 'is_IS'=>'Icelandic', 'it_IT'=>'Italian', 'ja_JP'=>'Japanese', 'ka'=>'Georgian', 'km'=>'Khmer', 'ko_KR'=>'Korean', 'lv_LV'=>'Latvian', 'lt_LT'=>'Lithuanian', 'mk'=>'Macedonian', 'ms_MY'=>'Bahasa Melayu', 'nl_NL'=>'Dutch', 'nb_NO'=>'Norwegian (Bokm&aring;l)', 'nn_NO'=>'Norwegian (Nynorsk)', 'pl_PL'=>'Polish', 'pt_PT'=>'Portuguese (Portugal)', 'pt_BR'=>'Portuguese (Brazil)', 'ro_RO'=>'Romanian', 'ru_RU'=>'Russian', 'sk_SK'=>'Slovak', 'sl_SI'=>'Slovenian', 'sr_YU'=>'Serbian', 'sv_SE'=>'Swedish', 'ta_LK'=>'Tamil', 'tr_TR'=>'Turkish', 'zh_TW'=>'Chinese Trad', 'zh_CN'=>'Chinese Simp', 'uk_UA'=>'Ukrainian', 'vi_VN'=>'Vietnamese', 'ar'=>'Arabic', 'fa_IR'=>'Persian', 'he_IL'=>'Hebrew', 'ug'=>'Uighur'); private $installedSkins; private $type; function __construct($configFile, $defaultPrefFile) { $this->configFile = $configFile; $this->defaultPrefFile = $defaultPrefFile; } public static function customerAreaLink() { return "<a target='_blank' href='http://store.ensigniamail.com/customers/index.php?task=my_packages&tab=licenses'>customer area</a>"; } private function getErrorCode($text) { return "<div class='errorItem'><table><tr><td style='width:10%'><img src='" . ENM_HTTP_DIR . "enm/images/error.png' alt='' /></td><td><span>$text</span></td></tr></table></div>"; } private function checkWritable($fileName, &$errorText, $entity = "file") { if (!is_writable($fileName)) { $errorText .= $this->getErrorCode("The $entity '$fileName' is not writable. Please change the $entity permissions to allow the program to write to it."); return false; } return true; } private function formatDirectory($dir, $forDisplay = false) { $smPath = $forDisplay ? "" : SM_PATH; $prefix = substr($dir, 0, 1) == "/" ? "" : $smPath; $dir = $prefix . $this->addTrailingSlash($dir); return substr($dir, 0, 3) == "../" ? substr($dir, 3) : $dir; } public static function getHead() { return "<script type='text/javascript'> 
                                $(document).ready(function() { 
                                        $('.tooltipElement').hover( 
                                                function(e) { 
                                                        $(this).contents('.tooltip').css('top', (Math.round($(this).position().top) + 25) + 'px').css('left', Math.round($(this).position().left - 340) + 'px'); 
                                                        $(this).contents('.tooltip').show(); 
                                                }, 
                                                function () { $(this).contents('.tooltip').hide(); } 
                                        ); 
                                }); 
                                $(document).keydown(function(e) {       if (e.keyCode == 27) ensignia.skinPreviewHide(); }); 
                        </script>". "<link rel='stylesheet' type='text/css' href='" . ENM_HTTP_DIR . "enm/enm.css' />
". "<script type='text/javascript' src='" . ENM_HTTP_DIR . "enm/enm.js'></script>
"; } public static function getCombo($name, $selected, $values = array('true'=>'Yes', 'false'=>'No'), $additionalSelectCode = false) { if (is_bool($selected)) $selected = $selected ? "true" : "false"; $output = ""; foreach ($values as $key=>$val) $output .= "<option value='$key'" . ($selected == $key ? " selected='selected'" : "") . ">$val</option>"; return "<select name='$name'" . ($additionalSelectCode ? " " . $additionalSelectCode : "") . ">$output</select>"; } private function valueNeedsQuotes($value) { return $value != "false" && $value != "true" && !is_numeric($value) && substr($value, 0, 6) != "array("; } private function arrayToString($array) { $output = ""; foreach ($array as $val) $output .= '"' . $val . '", '; if ($output) $output = substr($output, 0, -2); return "array($output)"; } public static function getSkinPreviewCode() { return "<div id='previewBoxOverlay'>". "<div id='previewBox'>". "<div>". "<input type='hidden' id='skinPreviewName' value='' />". "<input type='hidden' id='skinPreviewIndex' value='0' />". "<input type='hidden' id='skinPreviewPath' value='' />". "</div>". "<div id='previewBoxImage'>". "<img id='skinPreviewImage' src='" . ENM_HTTP_DIR . "enm/images/loaderBig.gif' alt='' />". "</div>". "<div id='previewBoxNav' class='buttonBox'>". "<a href='javascript:void(0)' class='button' id='previewBoxPrev' onclick='ensignia.skinPreviewPrev()'>&lt; Previous</a>". "<a href='javascript:void(0)' class='button' id='previewBoxNext' onclick='ensignia.skinPreviewNext()'>Next &gt;</a>". "<a href='javascript:void(0)' class='button' id='previewBoxClose' onclick='ensignia.skinPreviewHide()'>Close</a>". "</div>". "</div>". "</div>"; } public static function makeRow($label, $input, $info, $special = false, $additionalRowCode = false, $additionalCellCode = false) { return "<tr" . ($additionalRowCode ? " " . $additionalRowCode : "") . ">". "<td class='label'" . ($additionalCellCode ? " " . $additionalCellCode: "") . ">$label </td>". "<td class='input'" . ($additionalCellCode ? " " . $additionalCellCode: "") . ">$input</td>". "<td class='info'" . ($additionalCellCode ? " " . $additionalCellCode: "") . ">". ($special == "skinPreviewDesktop" ? "<a href='javascript:void(0)' onclick='ensignia.skinPreviewShow(\"" . ENM_HTTP_DIR . "\", 0)'><img src='" . ENM_HTTP_DIR . "enm/images/preview.png' /></a>" : ""). ($special == "skinPreviewMobile" ? "<a href='javascript:void(0)' onclick='ensignia.skinPreviewShow(\"" . ENM_HTTP_DIR . "\", 1)'><img src='" . ENM_HTTP_DIR . "enm/images/preview.png' /></a>" : ""). "<span class='tooltipElement'><img src='" . ENM_HTTP_DIR . "enm/images/info.png' />". "<span class='tooltip'>$info</span></span></td>". "</tr>"; } private function getSkinCombo($selectedSkin, $mobile = false) { $skin_array = EnmObject::skinArray(); $output = $mobile ? "<option value=''>- Use desktop skin -</option>" : ""; $hasSkins = false; foreach ($skin_array as $key => $val) { if ($mobile) { if (strpos($key, "mobile") === false) continue; } else { if (strpos($key, "mobile") !== false) continue; } $output .= "<option value='" . $this->v($key) . "'" . ($key == $selectedSkin ? " selected='selected'" : "") . ">" . $this->v($val) . "</option>"; $hasSkins = true; } $skinTypeText = $mobile ? "mobile" : "desktop"; if ($output) return '<select id="default_skin_' . $skinTypeText . '" name="default_skin_' . $skinTypeText . '">' . $output . '</select>'. ($mobile && !$hasSkins ? "<p class='subscript'>You don't have any mobile skins installed. Mobile skins make it easy to access e-mail from devices like iPhone.</p>" : ""); return ""; } private function makePluginRow($name, $type, $enabled) { return array($name=>"<td class='plugin label'>$name</td><td class='plugin input'>" . $this->getCombo(($type == "desktop" ? "sm_plugin_" : "sm_plugin_mobile_") . (int)$enabled . "_" . $name, $enabled, array("true"=>"Enabled", "false"=>"Disabled")) . "</td><td class='info'></td>"); } private function getPluginCode($type) { $output = ""; $pluginList = array(); include $this->configFile; $configContents = @file_get_contents(SM_PATH . "config/config.php"); if (!$configContents) return "<p>The file config/config.php is not accessible.</p>"; foreach (explode("
", $configContents) as $val) { if ($type == "desktop") $pluginPos = strpos($val, '$plugins['); else $pluginPos = strpos($val, '$plugins_mobile['); if ($pluginPos !== false) { $i = strpos($val, "=", $pluginPos); if (!$i) continue; $j = strpos($val, ";", $i); if (!$j) continue; $name = preg_replace("/[^A-Za-z\-_]/", "", substr($val, $i, $j - $i)); if (!is_dir(SM_PATH . "plugins/" . $name)) continue; $enabled = !(strpos($val, "//") < $pluginPos); $pluginList += $this->makePluginRow($name, $type, $enabled); } } ksort($pluginList); $alternate = false; foreach ($pluginList as $key=>$val) { $output .= "<tr" . ($alternate ? " class='alternate'" : "") . ">$val</tr>"; $alternate = !$alternate; } if ($output) return "<table class='tableBorder'><tr><th><span>Plugin name</span></th><th><span>Enabled</span></th><th><span>&nbsp;</span></th></tr>$output</table>"; return "<p>No $type plugins are available.</p>"; } function replaceSetting(&$config, &$default, $setting, $value, $addSmPath = false) { if ($setting == "left_size" || $setting == "show_html_default" || $setting == "compose_window_type") { $i = strpos($default, $setting); if ($i === false) return; $j = strpos($default, "
", $i); if ($j === false) $j = strlen($default); $default = substr_replace($default, $setting . "=" . $value, $i, $j - $i); return; } if (strpos($setting, "sm_plugin_") === 0) { $mobile = strpos($setting, "sm_plugin_mobile_") === 0; $prevValue = substr($setting, $mobile ? 17 : 10, 1); if (($prevValue == "1" && $value == "true") || ($prevValue == "0" && $value == "false")) return; $name = substr($setting, $mobile ? 19 : 12); $pluginPos = 0; while ($pluginPos !== false) { $pluginPos = strpos($config, '$plugins' . ($mobile ? "_mobile" : "") . "[", $pluginPos + 1); if ($pluginPos === false) return; $i = strpos($config, "=", $pluginPos); if (!$i) return; $j = strpos($config, ";", $i); if (!$j) return; if ($name != preg_replace("/[^A-Za-z\-_]/", "", substr($config, $i, $j - $i))) continue; $n = $this->backwardStrpos($config, "
", $pluginPos); if (!$n) return; $config = substr_replace($config, ($value == "true" ? "" : "//"), $n + 1, $pluginPos - $n - 1); } return; } $i = 0; while ($i !== false) { $i = strpos($config, $setting, $i + 1); if ($i !== false) { $lineStart = strrpos(substr($config, 0, $i), "
"); $string = substr($config, $lineStart, $i - $lineStart - 1); if (strpos($string, "//") !== false || strpos($string, "*") !== false) { continue; } $j = strpos($config, "
", $i); if ($j === false) $j = strlen($config); $m = $i; $k = false; while ($m !== false && $m < $j) { $m = strpos($config, ";", $m + 1); if ($m !== false && $m < $j) $k = $m; } if ($k !== false && $k < $j) { $quote = $this->valueNeedsQuotes($value) ? '"' : ""; $config = substr_replace($config, $setting . ' = ' . ($addSmPath ? "SM_PATH . " : "") . $quote . $value . $quote, $i, $k - $i); return; } } } } private function writeSettings(&$errorText) { $config = @file_get_contents($this->configFile); if (!$config) { $errorText = "Cannot open the configuration file for editing."; return false; } if ($this->defaultPrefFile === false) $default = ""; else { $default = @file_get_contents($this->defaultPrefFile); if (!$default) { $errorText = "Cannot open 'default_pref' for editing."; return false; } } $configOriginal = $config; $defaultOriginal = $default; foreach ($_POST as $key=>$val) { $val = trim(htmlspecialchars(strip_tags($val), ENT_QUOTES, "UTF-8")); $addSmPath = false; if ($key == "data_dir" || $key == "attachment_dir") { if (!$val) continue; $val = $this->addTrailingSlash($val); $addSmPath = substr($val, 0, 1) != "/"; $dir = $addSmPath ? SM_PATH . $val : $val; if (!is_writable($dir)) { if ($key == "data_dir") $errorText = "The data directory '$val' is not writable. (See tab 'Paths')"; else $errorText = "The attachment directory '$val' is not writable. (See tab 'Paths')"; return false; } if ($key == "data_dir" && !file_exists($dir . "default_pref")) { $errorText = "The file 'default_pref' does not exist in the data directory as specified in the Path tab."; return false; } } $this->replaceSetting($config, $default, $key, $val, $addSmPath); if ($key == "org_name") $this->replaceSetting($config, $default, "org_title", $val); } if ($this->defaultPrefFile !== false && $default != $defaultOriginal) { if (@file_put_contents($this->defaultPrefFile, $default) === false) { $errorText = "Cannot save information in 'default_pref'. Please make sure that the file is writable."; return false; } } if ($config != $configOriginal) { if (@file_put_contents($this->configFile, $config) === false) { $errorText = "Cannot save information in '" . $this->configFile . "'. Please make sure that the file is writable."; return false; } } global $init_setup_completed; if (!$init_setup_completed) { header('Location: ' . SM_PATH . 'src/login.php'); exit(); } return true; } public function getOutput($tabsDashboardLink = false) { global $username, $enmDemo; $errorText = ""; $message = false; $additionalPageCode = ""; $showTab = false; if (!$enmDemo && isset($_POST['init_setup_completed'])) { if ($enmDemo) $message .= "<div class='writeSuccess messageBox'>DEMO VERSION: Saving configuration disabled.</div>"; else { if ($this->writeSettings($errorText)) $message .= "<div class='writeSuccess messageBox'>The configuration has been saved.". " <a href='../src/webmail.php?right_frame=options.php' target='_top'>Refresh page</a>.</div>"; else $message .= "<div class='writeError messageBox'>$errorText</div>"; } } if ($username) { $usersAppendCode = "<h3>User preference replacement</h3>". "<p>Using this form you can replace user preference values in all the .pref files located in your data directory.</p>". "<p>Please note that this replacement will only affect the users who are not currently logged in. The logged in users have ". "their settings stored in the session and they will be written to their .pref file on logout ". "overwriting the replacements that you will make here.</p>". "<p>Use with caution! This function makes direct changes to the user .pref files!</p>". "<table>". "<tr><td>Key:</td><td><input id='pref_replace_key' value='' /></td></tr>". "<tr><td>Value:</td><td><input id='pref_replace_value' value='' /></td></tr>". "</table>". "<p><a href='javascript:void(0)' class='button' onclick='ensignia.pref_replace()'>Replace</a></p>". "<p id='pref_replace_result'></p>"; } else { $usersAppendCode = ""; } $tabContents = array( "enm_license"=>array( "title"=>"License", "options"=>"", "tableWrap"=>true, "explanation"=>"", "append" => "", ), "enm_basic"=>array( "title"=>"Basic", "options"=>"", "tableWrap"=>true, "explanation"=>"", "append" => "", ), "enm_server"=>array( "title"=>"Server", "options"=>"", "tableWrap"=>true, "explanation"=>"", "append" => "", ), "enm_folders"=>array( "title"=>"Folders", "options"=>"", "tableWrap"=>true, "explanation"=>"", "append" => "", ), "enm_users"=>array( "title"=>"Users", "options"=>"", "tableWrap"=>true, "explanation"=>"", "append" => $usersAppendCode, ), "enm_defaults"=>array( "title"=>"Defaults", "options"=>"", "tableWrap"=>true, "explanation"=>"Settings that will be applied to all newly created accounts. Individual users will be able to customize those settings in their account options.", "append" => "", ), "enm_paths"=>array( "title"=>"Paths", "options"=>"", "tableWrap"=>true, "explanation"=>"", "append" => "", ), "enm_desktop_plugins"=>array( "title"=>"Desktop plugins", "options"=>"", "tableWrap"=>false, "explanation"=>"On this page you can enable or disable the plugins available for desktop browsers.", "append" => "", ), "enm_mobile_plugins"=>array( "title"=>"Mobile plugins", "options"=>"", "tableWrap"=>false, "explanation"=>"On this page you can enable or disable the plugins available for mobile browsers.", "append" => "", ), ); try { $this->installedSkins = EnmObject::skinArray(); if (!count($this->installedSkins)) throw new Exception($this->getErrorCode("The program could not find any Ensignia skins. Please copy the skins you have purchased to the appropriate folders.")); if (!include(SM_PATH . "config/config.php")) throw new Exception($this->getErrorCode("The config file cannot be loaded.")); $tabContents["enm_desktop_plugins"]["options"] = $this->getPluginCode("desktop"); $tabContents["enm_mobile_plugins"]["options"] = $this->getPluginCode("mobile"); if ($this->defaultPrefFile !== false) { $prefFileContents = @file_get_contents($this->defaultPrefFile); if (!$prefFileContents) throw new Exception($this->getErrorCode("The default_pref file cannot be loaded.")); $default_pref = array(); foreach (explode("
", $prefFileContents) as $val) { $a = explode("=", $val); if (count($a) == 2) $default_pref += array(trim($a[0])=>trim($a[1])); } if (!array_key_exists('left_size', $default_pref) || ($default_pref['left_size'] < 100 && $default_pref['left_size'] > 600)) $default_pref['left_size'] = 280; if (!array_key_exists('show_html_default', $default_pref) || ($default_pref['show_html_default'] != '0' && $default_pref['show_html_default'] != '1')) $default_pref['show_html_default'] = '1'; if (!array_key_exists('compose_window_type', $default_pref) || ($default_pref['compose_window_type'] != 'html' && $default_pref['compose_window_type'] != 'plain')) $default_pref['compose_window_type'] = 'html'; } $errorText = ""; $this->checkWritable($this->configFile, $errorText); if ($this->defaultPrefFile !== false) $this->checkWritable($this->defaultPrefFile, $errorText); if (isset($data_dir)) $this->checkWritable($data_dir, $errorText, "directory"); if (isset($attachment_dir)) $this->checkWritable($attachment_dir, $errorText, "directory"); if ($errorText) throw new Exception($errorText); } catch (Exception $e) { return "<div id='errorBox'>". (@$username ? "" : "<p>Before you can run the configuration program, you must fix the following problems:</p>"). $e->getMessage() . "<p>Please correct the problems and click the 'Try again' button.</p>". "<div class='buttonBox'><a href='javascript:void(0)' onClick='window.location.reload()' class='button'>Try again</a></div>". "</div>"; } if (isset($_POST['data_dir'])) { foreach ($_POST as $key => $val) { $$key = $val; } } global $enmKeyData, $enmLicenseErrors; $format = "Y-m-d"; $licenseStatus = isset($enmKeyData["status"]) ? ucfirst($enmKeyData["status"]) : "Invalid"; $licenseType = "Unknown"; if (isset($enmKeyData['license_key_string'])) { if (strpos($enmKeyData['license_key_string'], "ENU-") === 0) { $licenseType = "Unlimited"; } else if (strpos($enmKeyData['license_key_string'], "ENE-") === 0) { $licenseType = "Enterprise"; } else if (strpos($enmKeyData['license_key_string'], "ENS-") === 0) { $licenseType = "Startup"; } else if (strpos($enmKeyData['license_key_string'], "TRIAL-") === 0) { $licenseType = "Trial version"; } } if (isset($enmKeyData["license_expires"]) && $enmKeyData["license_expires"]) $licenseExpiry = is_numeric($enmKeyData["license_expires"]) ? date($format, $enmKeyData["license_expires"]) : ucfirst($enmKeyData["license_expires"]); else $licenseExpiry = "-"; $showLicenseKey = $enmDemo ? "XXX-XXX-XXX" : $license_key; $tabContents["enm_basic"]["explanation"] = "A valid license key enables the skins you purchased. If the key is invalid or expired, Ensignia will continue to function, but it will use the gray Monochrome skin instead. You can find your license key by clicking 'Licenses' in the " . EnmConfig::customerAreaLink(); $tabContents["enm_basic"]["options"] .= $this->makeRow("License key:", "<input type='text' name='license_key' value='" . $this->v($showLicenseKey) . "' />", "Type your Ensignia license key to enable the skins you purchased."); $tabContents["enm_basic"]["options"] .= $this->makeRow("License status:", $licenseStatus, "Shows the validity of the specified license key."); $tabContents["enm_basic"]["options"] .= $this->makeRow("License type:", $licenseType, "Shows the type of the specified license key."); $tabContents["enm_basic"]["options"] .= $this->makeRow("License expiry:", $licenseExpiry, "Shows the expiry date of the specified license key."); if (isset($org_name)) $tabContents["enm_basic"]["options"] .= $this->makeRow("Organization name:", "<input type='text' name='org_name' value='" . $this->v($org_name) . "' />", "This is the name of your company or organization."); if (isset($default_skin_desktop)) $tabContents["enm_basic"]["options"] .= $this->makeRow("Default desktop skin:", $this->getSkinCombo($default_skin_desktop), "Specifies the default skin that will be used for all new users, as well as for the login and logout pages.", "skinPreviewDesktop"); if (isset($default_skin_mobile)) $tabContents["enm_basic"]["options"] .= $this->makeRow("Default mobile skin:", $this->getSkinCombo($default_skin_mobile, true), "Specifies the default skin that will be displayed when a mobile device like iPhone is used.", "skinPreviewMobile"); if (isset($config_admin_account)) $tabContents["enm_basic"]["options"] .= $this->makeRow("Administrator's login:", "<input type='text' name='config_admin_account' value='" . $this->v($config_admin_account) . "' />", "The user logging in using this login name will be able to launch this configuration program from the Options page of his or her account. If you leave this field blank, you will not be able to access this configuration program any more and any future changes to the options will need to be made by manually editing the configuration files."); if (isset($motd)) $tabContents["enm_basic"]["options"] .= $this->makeRow("Login message:", "<input type='text' name='motd' value='" . $this->v($motd) . "' />", "This is a message that is displayed immediately after a user logs in. Leave blank if you don't want to display any message."); if (isset($ie6_warning_text)) $tabContents["enm_basic"]["options"] .= $this->makeRow("Internet Explorer 6 warning:", "<input type='text' name='ie6_warning_text' value='" . $this->v($ie6_warning_text) . "' />", "Specify the text that will appear to the users who browse using Internet Explorer 6. Ensignia skins do not support Internet Explorer 6, so the Monochrome skin will be displayed."); if (isset($cookie_warning_enable)) $tabContents["enm_basic"]["options"] .= $this->makeRow("Enable European Union cookie warning:", $this->getCombo('cookie_warning_enable', $cookie_warning_enable, array('true'=>'Yes', 'false'=>'No')), "Websites hosted in the European Union must obtain permission before storing cookies on the visitor's computer. Enabling this option will show a cookie notification on the login screen."); if (isset($cookie_warning_text)) $tabContents["enm_basic"]["options"] .= $this->makeRow("Cookie warning notfication:", "<input type='text' name='cookie_warning_text' value='" . $this->v($cookie_warning_text) . "' />", "Specify the cookie warning notification text that will appear on the login screen."); if (isset($squirrelmail_default_language)) $tabContents["enm_basic"]["options"] .= $this->makeRow("Default language:", $this->getCombo('squirrelmail_default_language', $squirrelmail_default_language, $this->supportedLanguages), "This is the default language. It is used as a last resort if the program can't figure out which language to display."); if (isset($default_charset)) $tabContents["enm_basic"]["options"] .= $this->makeRow("Default character set:", "<input type='text' name='default_charset' value='" . $this->v($default_charset) . "' />", "This option controls what character set is used when sending mail and when sending HTML to the browser. This option is active only when default language is English. In other cases the program uses charset that depends on default language."); if (isset($skin_logo_url)) $tabContents["enm_basic"]["options"] .= $this->makeRow("Skin logo path:", "<input type='text' name='skin_logo_url' value='" . $this->v($skin_logo_url) . "' />", "Full HTTP path to the location where custom company logo images are stored, for example, http://company.com/logos. Skin images must be PNG files of the same size as the originals and named the same as the skins they will appear in, for example, outlook_blue.png. If this path is specified, you should provide custom images for all the skins, otherwise empty image placeholders will be displayed in the skins with missing images. If this path is left blank, default logo images will be used."); if (isset($use_transparent_security_image)) $tabContents["enm_basic"]["options"] .= $this->makeRow("Security image type:", $this->getCombo('use_transparent_security_image', $use_transparent_security_image, array('true'=>'Transparent', 'false'=>'With text')), "Switches between using a transparent image and one that states 'This image has been removed for security reasons.'"); if (isset($imapServerAddress)) $tabContents["enm_server"]["options"] .= $this->makeRow("IMAP server address:", "<input type='text' name='imapServerAddress' value='" . $this->v($imapServerAddress) . "' />", "The dns name (or IP address) for your imap server."); if (isset($imapPort)) $tabContents["enm_server"]["options"] .= $this->makeRow("IMAP server port:", "<input type='text' name='imapPort' value='" . $this->v($imapPort) . "' />", "Port used by your imap server. (Usually 143)"); if (isset($imap_server_type)) $tabContents["enm_server"]["options"] .= $this->makeRow("IMAP server type:", $this->getCombo('imap_server_type', $imap_server_type, array("courier"=>"courier", "cyrus"=>"cyrus", "exchange"=>"exchange", "uw"=>"uw", "macosx"=>"macosx", "hmailserver"=>"hmailserver", "other"=>"other")), "The type of IMAP server you are running. If you select a specific server, you may need to adjust several other options (see doc/presets.txt for details)."); if (isset($imap_auth_mech)) $tabContents["enm_server"]["options"] .= $this->makeRow("IMAP authentication mechanism:", $this->getCombo('imap_auth_mech', $imap_auth_mech, array('login'=>'login', 'plain'=>'plain', 'cram-md5'=>'cram-md5', 'digest-md5'=>'digest-md5')), "Specifies the IMAP authentication mechanism."); if (isset($allow_charset_search)) $tabContents["enm_server"]["options"] .= $this->makeRow("IMAP charset search:", $this->getCombo('allow_charset_search', $allow_charset_search, array('true'=>'Yes', 'false'=>'No')), "This option allows you to choose if charset search will be used. Your imap server should support SEARCH CHARSET command for this to work."); if (isset($optional_delimiter)) $tabContents["enm_server"]["options"] .= $this->makeRow("IMAP folder delimiter:", "<input type='text' name='optional_delimiter' value='" . $this->v($optional_delimiter) . "' />", "This is the delimiter that your IMAP server uses to distinguish between folders. For example, Cyrus uses '.' as the delimiter and a complete folder would look like 'INBOX.Friends.Bob', while UW uses '/' and would look like 'INBOX/Friends/Bob'.  Normally this should be left at 'detect' but if you are sure you know what delimiter your server uses, you can specify it here."); if (isset($invert_time)) $tabContents["enm_server"]["options"] .= $this->makeRow("Time offset inversion:", $this->getCombo('invert_time', $invert_time), "If you are running on a machine that doesn't have the tm_gmtoff value in your time structure and if you are in a time zone that has a negative offset, you need to set this value to 1. This is typically people in the US that are running Solaris 7."); if (isset($uid_support)) $tabContents["enm_server"]["options"] .= $this->makeRow("Enable IMAP UID:", $this->getCombo('uid_support', $uid_support), "This option allows you to enable unique identifier (UID) support."); if (isset($useSendmail)) $tabContents["enm_server"]["options"] .= $this->makeRow("Send method:", $this->getCombo('useSendmail', $useSendmail, array('true'=>'Sendmail', 'false'=>'SMTP')), "What should be used when sending email. If SMTP is selected, the SMTP options below will be used. If Sendmail is selected the Sendmail options will be used."); if (isset($sendmail_path)) $tabContents["enm_server"]["options"] .= $this->makeRow("Path to Sendmail:", "<input type='text' name='sendmail_path' value='" . $this->v($sendmail_path) . "' />", "(Applicable only if send method is set to 'Sendmail'). Program that should be used when sending email. SquirrelMail expects that this program will follow options used by original Sendmail."); if (isset($sendmail_args)) $tabContents["enm_server"]["options"] .= $this->makeRow("Extra Sendmail command arguments:", "<input type='text' name='sendmail_args' value='" . $this->v($sendmail_args) . "' />", "(Applicable only if send method is set to 'Sendmail'). Sets additional sendmail command arguments. Make sure that arguments are supported by your sendmail program. -f argument is added automatically by SquirrelMail scripts. Variable defaults to standard /usr/sbin/sendmail arguments. If you use qmail-inject, nbsmtp or any other sendmail wrapper, which does not support -t and -i arguments, set variable to empty string or use arguments suitable for your mailer."); if (isset($smtpServerAddress)) $tabContents["enm_server"]["options"] .= $this->makeRow("SMTP server address:", "<input type='text' name='smtpServerAddress' value='" . $this->v($smtpServerAddress) . "' />", "(Applicable only if send method is set to 'SMTP'). Your SMTP server (usually the same as the IMAP server)."); if (isset($smtpPort)) $tabContents["enm_server"]["options"] .= $this->makeRow("SMTP server port:", "<input type='text' name='smtpPort' value='" . $this->v($smtpPort) . "' />", "(Applicable only if send method is set to 'SMTP'). Your SMTP port number (usually 25)."); if (isset($smtp_sitewide_user)) $tabContents["enm_server"]["options"] .= $this->makeRow("SMTP authentication username:", "<input type='text' name='smtp_sitewide_user' value='" . $this->v($smtp_sitewide_user) . "' />", "(Applicable only if send method is set to 'SMTP'). If this is left blank, the IMAP user name will be used."); if (isset($smtp_sitewide_pass)) $tabContents["enm_server"]["options"] .= $this->makeRow("SMTP authentication password:", "<input type='text' name='smtp_sitewide_pass' value='" . $this->v($smtp_sitewide_pass) . "' />", "(Applicable only if send method is set to 'SMTP'). If this is left blank, the IMAP user password will be used."); if (isset($smtp_auth_mech)) $tabContents["enm_server"]["options"] .= $this->makeRow("SMTP authentication mechanism:", $this->getCombo('smtp_auth_mech', $smtp_auth_mech, array('none'=>'none', 'login'=>'login', 'plain'=>'plain', 'cram-md5'=>'cram-md5', 'digest-md5'=>'digest-md5')), "(Applicable only if send method is set to 'SMTP'). Specifies the SMTP authentication mechanism."); if (isset($pop_before_smtp)) $tabContents["enm_server"]["options"] .= $this->makeRow("POP before SMTP:", $this->getCombo('pop_before_smtp', $pop_before_smtp), "Do you wish to use POP3 before SMTP?  Your server must support this in order for SquirrelMail to work with it."); if (isset($signout_page)) $tabContents["enm_server"]["options"] .= $this->makeRow("Signout page:", "<input type='text' name='signout_page' value='" . $this->v($signout_page) . "' />", "Setting this option allows you to sign the user out and then redirect to whatever page you want. For example, specifying / will redirect the users to your home page. Leave blank to use the logout page."); if (isset($lossy_encoding)) $tabContents["enm_server"]["options"] .= $this->makeRow("Lossy encoding:", $this->getCombo('lossy_encoding', $lossy_encoding), "This option allows charset conversions when output charset does not support all symbols used in original charset. Symbols unsupported by output charset will be replaced with question marks."); if (isset($check_mail_mechanism)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Check mail mechanism:", $this->getCombo('check_mail_mechanism', $check_mail_mechanism, array('meta'=>'META tag', 'basic'=>'Basic JavaScript (most compatible; slightly fallible)', 'advanced'=>'Advanced JavaScript (less compatible; most accurate)')), "Determine the mechanism used to refresh the folder list (when user has enabled such in their preferences.)"); if (isset($default_folder_prefix)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Default IMAP folder prefix:", "<input type='text' name='default_folder_prefix' value='" . $this->v($default_folder_prefix) . "' />", "Many servers store mail in your home directory. With this, they store them in a subdirectory: mail/ or Mail/, etc. If your server does this, please set this to what the default mail folder should be. This is still a user preference, so they can change it if it is different for each user."); if (isset($trash_folder)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Trash folder:", "<input type='text' name='trash_folder' value='" . $this->v($trash_folder) . "' />", "This is the path to the default trash folder. For Cyrus IMAP, it would be 'INBOX.Trash', but for UW it would be 'Trash'. We need the full path name here."); if (isset($sent_folder)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Sent folder:", "<input type='text' name='sent_folder' value='" . $this->v($sent_folder) . "' />", "This is the patch to where Draft messages will be stored."); if (isset($draft_folder)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Draft folder:", "<input type='text' name='draft_folder' value='" . $this->v($draft_folder) . "' />", "This is the path to where Sent messages will be stored."); if (isset($default_move_to_trash)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Move to trash:", $this->getCombo('default_move_to_trash', $default_move_to_trash), "If this is set to 'Yes', when 'delete' is pressed, it will attempt to move the selected messages to the trash folder. If it's set to 'No', we won't even attempt to move the messages, just delete them."); if (isset($default_move_to_sent)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Move to sent:", $this->getCombo('default_move_to_sent', $default_move_to_sent), "If this is set to 'Yes', sent messages will be stored in the sent folder by default."); if (isset($default_save_as_draft)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Save as draft:", $this->getCombo('default_save_as_draft', $default_save_as_draft), "If this is set to 'Yes', users are able to use the draft folder to store their unfinished messages."); if (isset($show_prefix_option)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Allow users to change prefix:", $this->getCombo('show_prefix_option', $show_prefix_option), "If you do not wish to give them the option to change this, set it to 'no'. Otherwise, if it is true, they can change the folder prefix to be anything."); if (isset($list_special_folders_first)) $tabContents["enm_folders"]["options"] .= $this->makeRow("List special folders first:", $this->getCombo('list_special_folders_first', $list_special_folders_first), "Whether or not to list the special folders first."); if (isset($auto_expunge)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Auto expunge:", $this->getCombo('auto_expunge', $auto_expunge), "If this option is set, when a message is moved or copied, the  source mailbox will get expunged, removing all messages marked 'Deleted'."); if (isset($default_sub_of_inbox)) $tabContents["enm_folders"]["options"] .= $this->makeRow("All folders under inbox:", $this->getCombo('default_sub_of_inbox', $default_sub_of_inbox), "Are all your folders subfolders of INBOX (i.e. cyrus IMAP server)? If you are unsure, set it to 'no'."); if (isset($show_contain_subfolders_option)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Display subfolder option:", $this->getCombo('show_contain_subfolders_option', $show_contain_subfolders_option), "Some IMAP daemons (UW) only allow a folder to contain either messages or other folders, not both at the same time. This option controls whether or not to display an option during folder creation. The option toggles which type of folder it should be. If you are not sure, set it to 'yes'."); if (isset($default_unseen_notify)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Display unseen in folders:", $this->getCombo('default_unseen_notify', $default_unseen_notify, array('1'=>'None', '2'=>'Inbox', '3'=>'All')), "Specifies whether or not the users will see the number of unseen in each folder by default and also which folders to do this to."); if (isset($default_unseen_type)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Unseen notification type:", $this->getCombo('default_unseen_type', $default_unseen_type, array('1'=>'(4)', '2'=>'(4,25)')), "Specifies the type of notification to give the users by default."); if (isset($auto_create_special)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Create special folders:", $this->getCombo('auto_create_special', $auto_create_special), "Should the program create the Sent and Trash folders automatically for a new user that doesn't already have them created?"); if (isset($delete_folder)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Delete folders permanently:", $this->getCombo('delete_folder', $delete_folder), "If this is true, when a folder is deleted then it will not get moved into the Trash folder."); if (isset($noselect_fix_enable)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Cyrus 'no select' fix:", $this->getCombo('noselect_fix_enable', $noselect_fix_enable), "This enables the no select fix for Cyrus when subfolders exist but parent folders do not."); if (isset($default_pref['left_size'])) $tabContents["enm_defaults"]["options"] .= $this->makeRow("Default width of folder list:", "<input type='text' name='left_size' value='" . $this->v($default_pref['left_size']) . "' />", "This is the default width of the folder list in pixels. Users will be able to change this option in their account configuration."); if (isset($default_pref['show_html_default'])) $tabContents["enm_defaults"]["options"] .= $this->makeRow("Display mail as HTML:", $this->getCombo('show_html_default', $default_pref['show_html_default'], array('1'=>'Yes', '0'=>'No')), "This option specifies whether e-mails will be displayed using formatted HTML or plain text. Users will be able to change this option in their account configuration."); if (isset($default_pref['compose_window_type'])) $tabContents["enm_defaults"]["options"] .= $this->makeRow("Compose using formatted text:", $this->getCombo('compose_window_type', $default_pref['compose_window_type'], array('html'=>'Yes', 'plain'=>'No')), "This option specifies whether e-mails will be composed using formatted HTML or plain text. Users will be able to change this option in their account configuration."); if (isset($force_username_lowercase)) $tabContents["enm_users"]["options"] .= $this->makeRow("Force lowercase usernames:", $this->getCombo('force_username_lowercase', $force_username_lowercase), "Some IMAP servers allow a username (like 'bob') to log in if they use uppercase in their name (like 'Bob' or 'BOB'). This creates extra preference files. Setting this option to 'yes' will transparently change all usernames to lowercase."); if (isset($default_use_priority)) $tabContents["enm_users"]["options"] .= $this->makeRow("Enable e-mail priority flags:", $this->getCombo('default_use_priority', $default_use_priority), "This option enables use of email priority flags by end users."); if (isset($default_use_mdn)) $tabContents["enm_users"]["options"] .= $this->makeRow("Enable read/delivery receipts:", $this->getCombo('default_use_mdn', $default_use_mdn), "This option enables use of read/delivery receipts by end users."); if (isset($edit_identity)) $tabContents["enm_users"]["options"] .= $this->makeRow("Allow users to change e-mail address:", $this->getCombo('edit_identity', $edit_identity), "Allows users to change their email address."); if (isset($edit_name)) $tabContents["enm_users"]["options"] .= $this->makeRow("Allow users to change name:", $this->getCombo('edit_name', $edit_name), "Allows users to change their name. This option has no effect unless 'Allow users to change e-mail address' is set to 'no'."); if (isset($hide_auth_header)) $tabContents["enm_users"]["options"] .= $this->makeRow("Hide username header:", $this->getCombo('hide_auth_header', $hide_auth_header), "SquirrelMail adds username information to every sent email. It is done in order to prevent possible sender forging when end users are allowed to change their email and name information. You can disable this header, if you think that it violates user's privacy or security. Please note, that setting will work only when users are not allowed to change their e-mail address."); if (isset($default_use_javascript_addr_book)) $tabContents["enm_users"]["options"] .= $this->makeRow("Use Javascript in addressbook:", $this->getCombo('default_use_javascript_addr_book', $default_use_javascript_addr_book), "Users may search their addressbook via either a plain HTML or Javascript enhanced user interface. This option allows you to set the default choice."); if (isset($data_dir)) $tabContents["enm_paths"]["options"] .= $this->makeRow("Data directory:", "<input type='text' name='data_dir' value='" . $this->v($this->formatDirectory($data_dir, true)) . "' />", "Path to the data/ directory. It is a possible security hole to have a writable directory under the web server's root directory (ex: /home/httpd/html). It is possible to put the data directory anywhere you would like; it is strongly advised that it is NOT directly web-accessible."); if (isset($attachment_dir)) $tabContents["enm_paths"]["options"] .= $this->makeRow("Attachment directory:", "<input type='text' name='attachment_dir' value='" . $this->v($this->formatDirectory($attachment_dir, true)) . "' />", "Path to directory used for storing attachments while a mail is being sent. There are a few security considerations regarding this directory: (1) It should have the permission 733 (rwx-wx-wx) to make it impossible for a random person with access to the webserver to list files in this directory. Confidential data might be laying around there. (2) Since the webserver is not able to list the files in the content is also impossible for the webserver to delete files lying around there for too long. (3) It should probably be another directory than the data directory."); $output = ""; $tabs = $tabsDashboardLink ? "<div id='tabDashboardLink'><a href='javascript:void(0)' onclick='window.location=\"$tabsDashboardLink\"'></a></div>" : ""; if (!$showTab) $showTab = @$_GET['tab']; if (!array_key_exists($showTab, $tabContents) || !$tabContents[$showTab]['options']) $showTab = false; $tabNumber = 1; $visibleTab = false; foreach ($tabContents as $key=>$val) { if (!$val['options']) continue; if (!$showTab && !$visibleTab) { $showTab = $key; $visibleTab = true; } $output .= "<div id='tabs-$tabNumber' class='tabPage" . ($key == $showTab ? " tabVisible" : "") . "'>". ($val['explanation'] ? "<div class='explanation'>" . $val['explanation'] . "</div>" : ""). ($key == "enm_basic" && $enmLicenseErrors && $enmLicenseErrors != "-" ? "<div class='writeError error'>$enmLicenseErrors</div>" : "") . ($val['tableWrap'] ? "<table>" : "") . $val['options']. ($val['tableWrap'] ? "</table>" : "") . $val['append']. "</div>"; $tabs .= "<a href='#tabs-$tabNumber'" . ($key == $showTab ? " class='tabVisible'" : "") . " onclick='return ensignia.showTab(this)'>{$val['title']}</a></li>"; $tabNumber++; } if ($output) $output = $this->getSkinPreviewCode(). "<form name='enmForm' action='' method='post' accept-charset='UTF-8'>". "<input type='hidden' name='init_setup_completed' value='true' />". "<div id='tabFrame'>". "<div class='tabLinks'>$tabs</div>". $output. "</div>". "<div class='buttonBox'>". "<a class='button' onclick='" . ($enmDemo ? "alert(\"Saving options is disabled in demo mode.\")" : "ensignia.verifyForm()") . "'>Save options</a>". "</div>". "</form>". $additionalPageCode. "<script type='text/javascript'>formValues = ensignia.saveFormValues()</script>"; return $message . $output; } public function processAjax() { global $enmDemo; if (isset($_POST['pref_replace_key'])) { if ($enmDemo) { exit(json_encode(array("result" => "Disabled in demo."))); } $this->changePrefSetting($_POST['pref_replace_key'], $_POST['pref_replace_value'], $modified, $errors); exit(json_encode(array("result" => "Modified files: $modified, errors: $errors."))); } } public function changePrefSetting($setting, $newValue, &$modified, &$errors) { global $data_dir; $dir = rtrim($data_dir, "/") . "/"; $setting = trim($setting); $newValue = trim($newValue); $modified = 0; $errors = 0; foreach (glob($dir . "*.pref") as $file) { $array = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); foreach ($array as $key => $line) { $pair = explode("=", $line); if (count($pair) == 2 && trim($pair[0]) == $setting) { $array[$key] = "$setting=$newValue"; if (@file_put_contents($file, implode("
", $array)) === false) { $errors++; } else { $modified++; } break; } } } } } ?>

Did this file decode correctly?

Original Code

<?php
 if (!defined('SM_PATH')) { define('SM_PATH', '../'); } if (!defined("ENM_HTTP_DIR")) { define("ENM_HTTP_DIR", SM_PATH); } require_once("EnmObject.php"); class EnmConfig extends EnmObject { private $configFile; private $defaultPrefFile; private $supportedLanguages = array('bg_BG'=>'Bulgarian', 'bn_BD'=>'Bengali (Bangladesh)', 'bn_IN'=>'Bengali (India)', 'ca_ES'=>'Catalan', 'cs_CZ'=>'Czech', 'cy_GB'=>'Welsh', 'da_DK'=>'Danish', 'de_DE'=>'German', 'el_GR'=>'Greek', 'en_US'=>'English', 'es_ES'=>'Spanish', 'et_EE'=>'Estonian', 'eu_ES'=>'Basque', 'fi_FI'=>'Finnish', 'fo_FO'=>'Faroese', 'fr_FR'=>'French', 'fy'=>'Frisian', 'hr_HR'=>'Croatian', 'hu_HU'=>'Hungarian', 'id_ID'=>'Bahasa Indonesia', 'is_IS'=>'Icelandic', 'it_IT'=>'Italian', 'ja_JP'=>'Japanese', 'ka'=>'Georgian', 'km'=>'Khmer', 'ko_KR'=>'Korean', 'lv_LV'=>'Latvian', 'lt_LT'=>'Lithuanian', 'mk'=>'Macedonian', 'ms_MY'=>'Bahasa Melayu', 'nl_NL'=>'Dutch', 'nb_NO'=>'Norwegian (Bokm&aring;l)', 'nn_NO'=>'Norwegian (Nynorsk)', 'pl_PL'=>'Polish', 'pt_PT'=>'Portuguese (Portugal)', 'pt_BR'=>'Portuguese (Brazil)', 'ro_RO'=>'Romanian', 'ru_RU'=>'Russian', 'sk_SK'=>'Slovak', 'sl_SI'=>'Slovenian', 'sr_YU'=>'Serbian', 'sv_SE'=>'Swedish', 'ta_LK'=>'Tamil', 'tr_TR'=>'Turkish', 'zh_TW'=>'Chinese Trad', 'zh_CN'=>'Chinese Simp', 'uk_UA'=>'Ukrainian', 'vi_VN'=>'Vietnamese', 'ar'=>'Arabic', 'fa_IR'=>'Persian', 'he_IL'=>'Hebrew', 'ug'=>'Uighur'); private $installedSkins; private $type; function __construct($configFile, $defaultPrefFile) { $this->configFile = $configFile; $this->defaultPrefFile = $defaultPrefFile; } public static function customerAreaLink() { return "<a target='_blank' href='http://store.ensigniamail.com/customers/index.php?task=my_packages&tab=licenses'>customer area</a>"; } private function getErrorCode($text) { return "<div class='errorItem'><table><tr><td style='width:10%'><img src='" . ENM_HTTP_DIR . "enm/images/error.png' alt='' /></td><td><span>$text</span></td></tr></table></div>"; } private function checkWritable($fileName, &$errorText, $entity = "file") { if (!is_writable($fileName)) { $errorText .= $this->getErrorCode("The $entity '$fileName' is not writable. Please change the $entity permissions to allow the program to write to it."); return false; } return true; } private function formatDirectory($dir, $forDisplay = false) { $smPath = $forDisplay ? "" : SM_PATH; $prefix = substr($dir, 0, 1) == "/" ? "" : $smPath; $dir = $prefix . $this->addTrailingSlash($dir); return substr($dir, 0, 3) == "../" ? substr($dir, 3) : $dir; } public static function getHead() { return "<script type='text/javascript'>
                                $(document).ready(function() {
                                        $('.tooltipElement').hover(
                                                function(e) {
                                                        $(this).contents('.tooltip').css('top', (Math.round($(this).position().top) + 25) + 'px').css('left', Math.round($(this).position().left - 340) + 'px');
                                                        $(this).contents('.tooltip').show();
                                                },
                                                function () { $(this).contents('.tooltip').hide(); }
                                        );
                                });
                                $(document).keydown(function(e) {       if (e.keyCode == 27) ensignia.skinPreviewHide(); });
                        </script>". "<link rel='stylesheet' type='text/css' href='" . ENM_HTTP_DIR . "enm/enm.css' />\n". "<script type='text/javascript' src='" . ENM_HTTP_DIR . "enm/enm.js'></script>\n"; } public static function getCombo($name, $selected, $values = array('true'=>'Yes', 'false'=>'No'), $additionalSelectCode = false) { if (is_bool($selected)) $selected = $selected ? "true" : "false"; $output = ""; foreach ($values as $key=>$val) $output .= "<option value='$key'" . ($selected == $key ? " selected='selected'" : "") . ">$val</option>"; return "<select name='$name'" . ($additionalSelectCode ? " " . $additionalSelectCode : "") . ">$output</select>"; } private function valueNeedsQuotes($value) { return $value != "false" && $value != "true" && !is_numeric($value) && substr($value, 0, 6) != "array("; } private function arrayToString($array) { $output = ""; foreach ($array as $val) $output .= '"' . $val . '", '; if ($output) $output = substr($output, 0, -2); return "array($output)"; } public static function getSkinPreviewCode() { return "<div id='previewBoxOverlay'>". "<div id='previewBox'>". "<div>". "<input type='hidden' id='skinPreviewName' value='' />". "<input type='hidden' id='skinPreviewIndex' value='0' />". "<input type='hidden' id='skinPreviewPath' value='' />". "</div>". "<div id='previewBoxImage'>". "<img id='skinPreviewImage' src='" . ENM_HTTP_DIR . "enm/images/loaderBig.gif' alt='' />". "</div>". "<div id='previewBoxNav' class='buttonBox'>". "<a href='javascript:void(0)' class='button' id='previewBoxPrev' onclick='ensignia.skinPreviewPrev()'>&lt; Previous</a>". "<a href='javascript:void(0)' class='button' id='previewBoxNext' onclick='ensignia.skinPreviewNext()'>Next &gt;</a>". "<a href='javascript:void(0)' class='button' id='previewBoxClose' onclick='ensignia.skinPreviewHide()'>Close</a>". "</div>". "</div>". "</div>"; } public static function makeRow($label, $input, $info, $special = false, $additionalRowCode = false, $additionalCellCode = false) { return "<tr" . ($additionalRowCode ? " " . $additionalRowCode : "") . ">". "<td class='label'" . ($additionalCellCode ? " " . $additionalCellCode: "") . ">$label </td>". "<td class='input'" . ($additionalCellCode ? " " . $additionalCellCode: "") . ">$input</td>". "<td class='info'" . ($additionalCellCode ? " " . $additionalCellCode: "") . ">". ($special == "skinPreviewDesktop" ? "<a href='javascript:void(0)' onclick='ensignia.skinPreviewShow(\"" . ENM_HTTP_DIR . "\", 0)'><img src='" . ENM_HTTP_DIR . "enm/images/preview.png' /></a>" : ""). ($special == "skinPreviewMobile" ? "<a href='javascript:void(0)' onclick='ensignia.skinPreviewShow(\"" . ENM_HTTP_DIR . "\", 1)'><img src='" . ENM_HTTP_DIR . "enm/images/preview.png' /></a>" : ""). "<span class='tooltipElement'><img src='" . ENM_HTTP_DIR . "enm/images/info.png' />". "<span class='tooltip'>$info</span></span></td>". "</tr>"; } private function getSkinCombo($selectedSkin, $mobile = false) { $skin_array = EnmObject::skinArray(); $output = $mobile ? "<option value=''>- Use desktop skin -</option>" : ""; $hasSkins = false; foreach ($skin_array as $key => $val) { if ($mobile) { if (strpos($key, "mobile") === false) continue; } else { if (strpos($key, "mobile") !== false) continue; } $output .= "<option value='" . $this->v($key) . "'" . ($key == $selectedSkin ? " selected='selected'" : "") . ">" . $this->v($val) . "</option>"; $hasSkins = true; } $skinTypeText = $mobile ? "mobile" : "desktop"; if ($output) return '<select id="default_skin_' . $skinTypeText . '" name="default_skin_' . $skinTypeText . '">' . $output . '</select>'. ($mobile && !$hasSkins ? "<p class='subscript'>You don't have any mobile skins installed. Mobile skins make it easy to access e-mail from devices like iPhone.</p>" : ""); return ""; } private function makePluginRow($name, $type, $enabled) { return array($name=>"<td class='plugin label'>$name</td><td class='plugin input'>" . $this->getCombo(($type == "desktop" ? "sm_plugin_" : "sm_plugin_mobile_") . (int)$enabled . "_" . $name, $enabled, array("true"=>"Enabled", "false"=>"Disabled")) . "</td><td class='info'></td>"); } private function getPluginCode($type) { $output = ""; $pluginList = array(); include $this->configFile; $configContents = @file_get_contents(SM_PATH . "config/config.php"); if (!$configContents) return "<p>The file config/config.php is not accessible.</p>"; foreach (explode("\n", $configContents) as $val) { if ($type == "desktop") $pluginPos = strpos($val, '$plugins['); else $pluginPos = strpos($val, '$plugins_mobile['); if ($pluginPos !== false) { $i = strpos($val, "=", $pluginPos); if (!$i) continue; $j = strpos($val, ";", $i); if (!$j) continue; $name = preg_replace("/[^A-Za-z\-_]/", "", substr($val, $i, $j - $i)); if (!is_dir(SM_PATH . "plugins/" . $name)) continue; $enabled = !(strpos($val, "//") < $pluginPos); $pluginList += $this->makePluginRow($name, $type, $enabled); } } ksort($pluginList); $alternate = false; foreach ($pluginList as $key=>$val) { $output .= "<tr" . ($alternate ? " class='alternate'" : "") . ">$val</tr>"; $alternate = !$alternate; } if ($output) return "<table class='tableBorder'><tr><th><span>Plugin name</span></th><th><span>Enabled</span></th><th><span>&nbsp;</span></th></tr>$output</table>"; return "<p>No $type plugins are available.</p>"; } function replaceSetting(&$config, &$default, $setting, $value, $addSmPath = false) { if ($setting == "left_size" || $setting == "show_html_default" || $setting == "compose_window_type") { $i = strpos($default, $setting); if ($i === false) return; $j = strpos($default, "\n", $i); if ($j === false) $j = strlen($default); $default = substr_replace($default, $setting . "=" . $value, $i, $j - $i); return; } if (strpos($setting, "sm_plugin_") === 0) { $mobile = strpos($setting, "sm_plugin_mobile_") === 0; $prevValue = substr($setting, $mobile ? 17 : 10, 1); if (($prevValue == "1" && $value == "true") || ($prevValue == "0" && $value == "false")) return; $name = substr($setting, $mobile ? 19 : 12); $pluginPos = 0; while ($pluginPos !== false) { $pluginPos = strpos($config, '$plugins' . ($mobile ? "_mobile" : "") . "[", $pluginPos + 1); if ($pluginPos === false) return; $i = strpos($config, "=", $pluginPos); if (!$i) return; $j = strpos($config, ";", $i); if (!$j) return; if ($name != preg_replace("/[^A-Za-z\-_]/", "", substr($config, $i, $j - $i))) continue; $n = $this->backwardStrpos($config, "\n", $pluginPos); if (!$n) return; $config = substr_replace($config, ($value == "true" ? "" : "//"), $n + 1, $pluginPos - $n - 1); } return; } $i = 0; while ($i !== false) { $i = strpos($config, $setting, $i + 1); if ($i !== false) { $lineStart = strrpos(substr($config, 0, $i), "\n"); $string = substr($config, $lineStart, $i - $lineStart - 1); if (strpos($string, "//") !== false || strpos($string, "*") !== false) { continue; } $j = strpos($config, "\n", $i); if ($j === false) $j = strlen($config); $m = $i; $k = false; while ($m !== false && $m < $j) { $m = strpos($config, ";", $m + 1); if ($m !== false && $m < $j) $k = $m; } if ($k !== false && $k < $j) { $quote = $this->valueNeedsQuotes($value) ? '"' : ""; $config = substr_replace($config, $setting . ' = ' . ($addSmPath ? "SM_PATH . " : "") . $quote . $value . $quote, $i, $k - $i); return; } } } } private function writeSettings(&$errorText) { $config = @file_get_contents($this->configFile); if (!$config) { $errorText = "Cannot open the configuration file for editing."; return false; } if ($this->defaultPrefFile === false) $default = ""; else { $default = @file_get_contents($this->defaultPrefFile); if (!$default) { $errorText = "Cannot open 'default_pref' for editing."; return false; } } $configOriginal = $config; $defaultOriginal = $default; foreach ($_POST as $key=>$val) { $val = trim(htmlspecialchars(strip_tags($val), ENT_QUOTES, "UTF-8")); $addSmPath = false; if ($key == "data_dir" || $key == "attachment_dir") { if (!$val) continue; $val = $this->addTrailingSlash($val); $addSmPath = substr($val, 0, 1) != "/"; $dir = $addSmPath ? SM_PATH . $val : $val; if (!is_writable($dir)) { if ($key == "data_dir") $errorText = "The data directory '$val' is not writable. (See tab 'Paths')"; else $errorText = "The attachment directory '$val' is not writable. (See tab 'Paths')"; return false; } if ($key == "data_dir" && !file_exists($dir . "default_pref")) { $errorText = "The file 'default_pref' does not exist in the data directory as specified in the Path tab."; return false; } } $this->replaceSetting($config, $default, $key, $val, $addSmPath); if ($key == "org_name") $this->replaceSetting($config, $default, "org_title", $val); } if ($this->defaultPrefFile !== false && $default != $defaultOriginal) { if (@file_put_contents($this->defaultPrefFile, $default) === false) { $errorText = "Cannot save information in 'default_pref'. Please make sure that the file is writable."; return false; } } if ($config != $configOriginal) { if (@file_put_contents($this->configFile, $config) === false) { $errorText = "Cannot save information in '" . $this->configFile . "'. Please make sure that the file is writable."; return false; } } global $init_setup_completed; if (!$init_setup_completed) { header('Location: ' . SM_PATH . 'src/login.php'); exit(); } return true; } public function getOutput($tabsDashboardLink = false) { global $username, $enmDemo; $errorText = ""; $message = false; $additionalPageCode = ""; $showTab = false; if (!$enmDemo && isset($_POST['init_setup_completed'])) { if ($enmDemo) $message .= "<div class='writeSuccess messageBox'>DEMO VERSION: Saving configuration disabled.</div>"; else { if ($this->writeSettings($errorText)) $message .= "<div class='writeSuccess messageBox'>The configuration has been saved.". " <a href='../src/webmail.php?right_frame=options.php' target='_top'>Refresh page</a>.</div>"; else $message .= "<div class='writeError messageBox'>$errorText</div>"; } } if ($username) { $usersAppendCode = "<h3>User preference replacement</h3>". "<p>Using this form you can replace user preference values in all the .pref files located in your data directory.</p>". "<p>Please note that this replacement will only affect the users who are not currently logged in. The logged in users have ". "their settings stored in the session and they will be written to their .pref file on logout ". "overwriting the replacements that you will make here.</p>". "<p>Use with caution! This function makes direct changes to the user .pref files!</p>". "<table>". "<tr><td>Key:</td><td><input id='pref_replace_key' value='' /></td></tr>". "<tr><td>Value:</td><td><input id='pref_replace_value' value='' /></td></tr>". "</table>". "<p><a href='javascript:void(0)' class='button' onclick='ensignia.pref_replace()'>Replace</a></p>". "<p id='pref_replace_result'></p>"; } else { $usersAppendCode = ""; } $tabContents = array( "enm_license"=>array( "title"=>"License", "options"=>"", "tableWrap"=>true, "explanation"=>"", "append" => "", ), "enm_basic"=>array( "title"=>"Basic", "options"=>"", "tableWrap"=>true, "explanation"=>"", "append" => "", ), "enm_server"=>array( "title"=>"Server", "options"=>"", "tableWrap"=>true, "explanation"=>"", "append" => "", ), "enm_folders"=>array( "title"=>"Folders", "options"=>"", "tableWrap"=>true, "explanation"=>"", "append" => "", ), "enm_users"=>array( "title"=>"Users", "options"=>"", "tableWrap"=>true, "explanation"=>"", "append" => $usersAppendCode, ), "enm_defaults"=>array( "title"=>"Defaults", "options"=>"", "tableWrap"=>true, "explanation"=>"Settings that will be applied to all newly created accounts. Individual users will be able to customize those settings in their account options.", "append" => "", ), "enm_paths"=>array( "title"=>"Paths", "options"=>"", "tableWrap"=>true, "explanation"=>"", "append" => "", ), "enm_desktop_plugins"=>array( "title"=>"Desktop plugins", "options"=>"", "tableWrap"=>false, "explanation"=>"On this page you can enable or disable the plugins available for desktop browsers.", "append" => "", ), "enm_mobile_plugins"=>array( "title"=>"Mobile plugins", "options"=>"", "tableWrap"=>false, "explanation"=>"On this page you can enable or disable the plugins available for mobile browsers.", "append" => "", ), ); try { $this->installedSkins = EnmObject::skinArray(); if (!count($this->installedSkins)) throw new Exception($this->getErrorCode("The program could not find any Ensignia skins. Please copy the skins you have purchased to the appropriate folders.")); if (!include(SM_PATH . "config/config.php")) throw new Exception($this->getErrorCode("The config file cannot be loaded.")); $tabContents["enm_desktop_plugins"]["options"] = $this->getPluginCode("desktop"); $tabContents["enm_mobile_plugins"]["options"] = $this->getPluginCode("mobile"); if ($this->defaultPrefFile !== false) { $prefFileContents = @file_get_contents($this->defaultPrefFile); if (!$prefFileContents) throw new Exception($this->getErrorCode("The default_pref file cannot be loaded.")); $default_pref = array(); foreach (explode("\n", $prefFileContents) as $val) { $a = explode("=", $val); if (count($a) == 2) $default_pref += array(trim($a[0])=>trim($a[1])); } if (!array_key_exists('left_size', $default_pref) || ($default_pref['left_size'] < 100 && $default_pref['left_size'] > 600)) $default_pref['left_size'] = 280; if (!array_key_exists('show_html_default', $default_pref) || ($default_pref['show_html_default'] != '0' && $default_pref['show_html_default'] != '1')) $default_pref['show_html_default'] = '1'; if (!array_key_exists('compose_window_type', $default_pref) || ($default_pref['compose_window_type'] != 'html' && $default_pref['compose_window_type'] != 'plain')) $default_pref['compose_window_type'] = 'html'; } $errorText = ""; $this->checkWritable($this->configFile, $errorText); if ($this->defaultPrefFile !== false) $this->checkWritable($this->defaultPrefFile, $errorText); if (isset($data_dir)) $this->checkWritable($data_dir, $errorText, "directory"); if (isset($attachment_dir)) $this->checkWritable($attachment_dir, $errorText, "directory"); if ($errorText) throw new Exception($errorText); } catch (Exception $e) { return "<div id='errorBox'>". (@$username ? "" : "<p>Before you can run the configuration program, you must fix the following problems:</p>"). $e->getMessage() . "<p>Please correct the problems and click the 'Try again' button.</p>". "<div class='buttonBox'><a href='javascript:void(0)' onClick='window.location.reload()' class='button'>Try again</a></div>". "</div>"; } if (isset($_POST['data_dir'])) { foreach ($_POST as $key => $val) { $$key = $val; } } global $enmKeyData, $enmLicenseErrors; $format = "Y-m-d"; $licenseStatus = isset($enmKeyData["status"]) ? ucfirst($enmKeyData["status"]) : "Invalid"; $licenseType = "Unknown"; if (isset($enmKeyData['license_key_string'])) { if (strpos($enmKeyData['license_key_string'], "ENU-") === 0) { $licenseType = "Unlimited"; } else if (strpos($enmKeyData['license_key_string'], "ENE-") === 0) { $licenseType = "Enterprise"; } else if (strpos($enmKeyData['license_key_string'], "ENS-") === 0) { $licenseType = "Startup"; } else if (strpos($enmKeyData['license_key_string'], "TRIAL-") === 0) { $licenseType = "Trial version"; } } if (isset($enmKeyData["license_expires"]) && $enmKeyData["license_expires"]) $licenseExpiry = is_numeric($enmKeyData["license_expires"]) ? date($format, $enmKeyData["license_expires"]) : ucfirst($enmKeyData["license_expires"]); else $licenseExpiry = "-"; $showLicenseKey = $enmDemo ? "XXX-XXX-XXX" : $license_key; $tabContents["enm_basic"]["explanation"] = "A valid license key enables the skins you purchased. If the key is invalid or expired, Ensignia will continue to function, but it will use the gray Monochrome skin instead. You can find your license key by clicking 'Licenses' in the " . EnmConfig::customerAreaLink(); $tabContents["enm_basic"]["options"] .= $this->makeRow("License key:", "<input type='text' name='license_key' value='" . $this->v($showLicenseKey) . "' />", "Type your Ensignia license key to enable the skins you purchased."); $tabContents["enm_basic"]["options"] .= $this->makeRow("License status:", $licenseStatus, "Shows the validity of the specified license key."); $tabContents["enm_basic"]["options"] .= $this->makeRow("License type:", $licenseType, "Shows the type of the specified license key."); $tabContents["enm_basic"]["options"] .= $this->makeRow("License expiry:", $licenseExpiry, "Shows the expiry date of the specified license key."); if (isset($org_name)) $tabContents["enm_basic"]["options"] .= $this->makeRow("Organization name:", "<input type='text' name='org_name' value='" . $this->v($org_name) . "' />", "This is the name of your company or organization."); if (isset($default_skin_desktop)) $tabContents["enm_basic"]["options"] .= $this->makeRow("Default desktop skin:", $this->getSkinCombo($default_skin_desktop), "Specifies the default skin that will be used for all new users, as well as for the login and logout pages.", "skinPreviewDesktop"); if (isset($default_skin_mobile)) $tabContents["enm_basic"]["options"] .= $this->makeRow("Default mobile skin:", $this->getSkinCombo($default_skin_mobile, true), "Specifies the default skin that will be displayed when a mobile device like iPhone is used.", "skinPreviewMobile"); if (isset($config_admin_account)) $tabContents["enm_basic"]["options"] .= $this->makeRow("Administrator's login:", "<input type='text' name='config_admin_account' value='" . $this->v($config_admin_account) . "' />", "The user logging in using this login name will be able to launch this configuration program from the Options page of his or her account. If you leave this field blank, you will not be able to access this configuration program any more and any future changes to the options will need to be made by manually editing the configuration files."); if (isset($motd)) $tabContents["enm_basic"]["options"] .= $this->makeRow("Login message:", "<input type='text' name='motd' value='" . $this->v($motd) . "' />", "This is a message that is displayed immediately after a user logs in. Leave blank if you don't want to display any message."); if (isset($ie6_warning_text)) $tabContents["enm_basic"]["options"] .= $this->makeRow("Internet Explorer 6 warning:", "<input type='text' name='ie6_warning_text' value='" . $this->v($ie6_warning_text) . "' />", "Specify the text that will appear to the users who browse using Internet Explorer 6. Ensignia skins do not support Internet Explorer 6, so the Monochrome skin will be displayed."); if (isset($cookie_warning_enable)) $tabContents["enm_basic"]["options"] .= $this->makeRow("Enable European Union cookie warning:", $this->getCombo('cookie_warning_enable', $cookie_warning_enable, array('true'=>'Yes', 'false'=>'No')), "Websites hosted in the European Union must obtain permission before storing cookies on the visitor's computer. Enabling this option will show a cookie notification on the login screen."); if (isset($cookie_warning_text)) $tabContents["enm_basic"]["options"] .= $this->makeRow("Cookie warning notfication:", "<input type='text' name='cookie_warning_text' value='" . $this->v($cookie_warning_text) . "' />", "Specify the cookie warning notification text that will appear on the login screen."); if (isset($squirrelmail_default_language)) $tabContents["enm_basic"]["options"] .= $this->makeRow("Default language:", $this->getCombo('squirrelmail_default_language', $squirrelmail_default_language, $this->supportedLanguages), "This is the default language. It is used as a last resort if the program can't figure out which language to display."); if (isset($default_charset)) $tabContents["enm_basic"]["options"] .= $this->makeRow("Default character set:", "<input type='text' name='default_charset' value='" . $this->v($default_charset) . "' />", "This option controls what character set is used when sending mail and when sending HTML to the browser. This option is active only when default language is English. In other cases the program uses charset that depends on default language."); if (isset($skin_logo_url)) $tabContents["enm_basic"]["options"] .= $this->makeRow("Skin logo path:", "<input type='text' name='skin_logo_url' value='" . $this->v($skin_logo_url) . "' />", "Full HTTP path to the location where custom company logo images are stored, for example, http://company.com/logos. Skin images must be PNG files of the same size as the originals and named the same as the skins they will appear in, for example, outlook_blue.png. If this path is specified, you should provide custom images for all the skins, otherwise empty image placeholders will be displayed in the skins with missing images. If this path is left blank, default logo images will be used."); if (isset($use_transparent_security_image)) $tabContents["enm_basic"]["options"] .= $this->makeRow("Security image type:", $this->getCombo('use_transparent_security_image', $use_transparent_security_image, array('true'=>'Transparent', 'false'=>'With text')), "Switches between using a transparent image and one that states 'This image has been removed for security reasons.'"); if (isset($imapServerAddress)) $tabContents["enm_server"]["options"] .= $this->makeRow("IMAP server address:", "<input type='text' name='imapServerAddress' value='" . $this->v($imapServerAddress) . "' />", "The dns name (or IP address) for your imap server."); if (isset($imapPort)) $tabContents["enm_server"]["options"] .= $this->makeRow("IMAP server port:", "<input type='text' name='imapPort' value='" . $this->v($imapPort) . "' />", "Port used by your imap server. (Usually 143)"); if (isset($imap_server_type)) $tabContents["enm_server"]["options"] .= $this->makeRow("IMAP server type:", $this->getCombo('imap_server_type', $imap_server_type, array("courier"=>"courier", "cyrus"=>"cyrus", "exchange"=>"exchange", "uw"=>"uw", "macosx"=>"macosx", "hmailserver"=>"hmailserver", "other"=>"other")), "The type of IMAP server you are running. If you select a specific server, you may need to adjust several other options (see doc/presets.txt for details)."); if (isset($imap_auth_mech)) $tabContents["enm_server"]["options"] .= $this->makeRow("IMAP authentication mechanism:", $this->getCombo('imap_auth_mech', $imap_auth_mech, array('login'=>'login', 'plain'=>'plain', 'cram-md5'=>'cram-md5', 'digest-md5'=>'digest-md5')), "Specifies the IMAP authentication mechanism."); if (isset($allow_charset_search)) $tabContents["enm_server"]["options"] .= $this->makeRow("IMAP charset search:", $this->getCombo('allow_charset_search', $allow_charset_search, array('true'=>'Yes', 'false'=>'No')), "This option allows you to choose if charset search will be used. Your imap server should support SEARCH CHARSET command for this to work."); if (isset($optional_delimiter)) $tabContents["enm_server"]["options"] .= $this->makeRow("IMAP folder delimiter:", "<input type='text' name='optional_delimiter' value='" . $this->v($optional_delimiter) . "' />", "This is the delimiter that your IMAP server uses to distinguish between folders. For example, Cyrus uses '.' as the delimiter and a complete folder would look like 'INBOX.Friends.Bob', while UW uses '/' and would look like 'INBOX/Friends/Bob'.  Normally this should be left at 'detect' but if you are sure you know what delimiter your server uses, you can specify it here."); if (isset($invert_time)) $tabContents["enm_server"]["options"] .= $this->makeRow("Time offset inversion:", $this->getCombo('invert_time', $invert_time), "If you are running on a machine that doesn't have the tm_gmtoff value in your time structure and if you are in a time zone that has a negative offset, you need to set this value to 1. This is typically people in the US that are running Solaris 7."); if (isset($uid_support)) $tabContents["enm_server"]["options"] .= $this->makeRow("Enable IMAP UID:", $this->getCombo('uid_support', $uid_support), "This option allows you to enable unique identifier (UID) support."); if (isset($useSendmail)) $tabContents["enm_server"]["options"] .= $this->makeRow("Send method:", $this->getCombo('useSendmail', $useSendmail, array('true'=>'Sendmail', 'false'=>'SMTP')), "What should be used when sending email. If SMTP is selected, the SMTP options below will be used. If Sendmail is selected the Sendmail options will be used."); if (isset($sendmail_path)) $tabContents["enm_server"]["options"] .= $this->makeRow("Path to Sendmail:", "<input type='text' name='sendmail_path' value='" . $this->v($sendmail_path) . "' />", "(Applicable only if send method is set to 'Sendmail'). Program that should be used when sending email. SquirrelMail expects that this program will follow options used by original Sendmail."); if (isset($sendmail_args)) $tabContents["enm_server"]["options"] .= $this->makeRow("Extra Sendmail command arguments:", "<input type='text' name='sendmail_args' value='" . $this->v($sendmail_args) . "' />", "(Applicable only if send method is set to 'Sendmail'). Sets additional sendmail command arguments. Make sure that arguments are supported by your sendmail program. -f argument is added automatically by SquirrelMail scripts. Variable defaults to standard /usr/sbin/sendmail arguments. If you use qmail-inject, nbsmtp or any other sendmail wrapper, which does not support -t and -i arguments, set variable to empty string or use arguments suitable for your mailer."); if (isset($smtpServerAddress)) $tabContents["enm_server"]["options"] .= $this->makeRow("SMTP server address:", "<input type='text' name='smtpServerAddress' value='" . $this->v($smtpServerAddress) . "' />", "(Applicable only if send method is set to 'SMTP'). Your SMTP server (usually the same as the IMAP server)."); if (isset($smtpPort)) $tabContents["enm_server"]["options"] .= $this->makeRow("SMTP server port:", "<input type='text' name='smtpPort' value='" . $this->v($smtpPort) . "' />", "(Applicable only if send method is set to 'SMTP'). Your SMTP port number (usually 25)."); if (isset($smtp_sitewide_user)) $tabContents["enm_server"]["options"] .= $this->makeRow("SMTP authentication username:", "<input type='text' name='smtp_sitewide_user' value='" . $this->v($smtp_sitewide_user) . "' />", "(Applicable only if send method is set to 'SMTP'). If this is left blank, the IMAP user name will be used."); if (isset($smtp_sitewide_pass)) $tabContents["enm_server"]["options"] .= $this->makeRow("SMTP authentication password:", "<input type='text' name='smtp_sitewide_pass' value='" . $this->v($smtp_sitewide_pass) . "' />", "(Applicable only if send method is set to 'SMTP'). If this is left blank, the IMAP user password will be used."); if (isset($smtp_auth_mech)) $tabContents["enm_server"]["options"] .= $this->makeRow("SMTP authentication mechanism:", $this->getCombo('smtp_auth_mech', $smtp_auth_mech, array('none'=>'none', 'login'=>'login', 'plain'=>'plain', 'cram-md5'=>'cram-md5', 'digest-md5'=>'digest-md5')), "(Applicable only if send method is set to 'SMTP'). Specifies the SMTP authentication mechanism."); if (isset($pop_before_smtp)) $tabContents["enm_server"]["options"] .= $this->makeRow("POP before SMTP:", $this->getCombo('pop_before_smtp', $pop_before_smtp), "Do you wish to use POP3 before SMTP?  Your server must support this in order for SquirrelMail to work with it."); if (isset($signout_page)) $tabContents["enm_server"]["options"] .= $this->makeRow("Signout page:", "<input type='text' name='signout_page' value='" . $this->v($signout_page) . "' />", "Setting this option allows you to sign the user out and then redirect to whatever page you want. For example, specifying / will redirect the users to your home page. Leave blank to use the logout page."); if (isset($lossy_encoding)) $tabContents["enm_server"]["options"] .= $this->makeRow("Lossy encoding:", $this->getCombo('lossy_encoding', $lossy_encoding), "This option allows charset conversions when output charset does not support all symbols used in original charset. Symbols unsupported by output charset will be replaced with question marks."); if (isset($check_mail_mechanism)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Check mail mechanism:", $this->getCombo('check_mail_mechanism', $check_mail_mechanism, array('meta'=>'META tag', 'basic'=>'Basic JavaScript (most compatible; slightly fallible)', 'advanced'=>'Advanced JavaScript (less compatible; most accurate)')), "Determine the mechanism used to refresh the folder list (when user has enabled such in their preferences.)"); if (isset($default_folder_prefix)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Default IMAP folder prefix:", "<input type='text' name='default_folder_prefix' value='" . $this->v($default_folder_prefix) . "' />", "Many servers store mail in your home directory. With this, they store them in a subdirectory: mail/ or Mail/, etc. If your server does this, please set this to what the default mail folder should be. This is still a user preference, so they can change it if it is different for each user."); if (isset($trash_folder)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Trash folder:", "<input type='text' name='trash_folder' value='" . $this->v($trash_folder) . "' />", "This is the path to the default trash folder. For Cyrus IMAP, it would be 'INBOX.Trash', but for UW it would be 'Trash'. We need the full path name here."); if (isset($sent_folder)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Sent folder:", "<input type='text' name='sent_folder' value='" . $this->v($sent_folder) . "' />", "This is the patch to where Draft messages will be stored."); if (isset($draft_folder)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Draft folder:", "<input type='text' name='draft_folder' value='" . $this->v($draft_folder) . "' />", "This is the path to where Sent messages will be stored."); if (isset($default_move_to_trash)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Move to trash:", $this->getCombo('default_move_to_trash', $default_move_to_trash), "If this is set to 'Yes', when 'delete' is pressed, it will attempt to move the selected messages to the trash folder. If it's set to 'No', we won't even attempt to move the messages, just delete them."); if (isset($default_move_to_sent)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Move to sent:", $this->getCombo('default_move_to_sent', $default_move_to_sent), "If this is set to 'Yes', sent messages will be stored in the sent folder by default."); if (isset($default_save_as_draft)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Save as draft:", $this->getCombo('default_save_as_draft', $default_save_as_draft), "If this is set to 'Yes', users are able to use the draft folder to store their unfinished messages."); if (isset($show_prefix_option)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Allow users to change prefix:", $this->getCombo('show_prefix_option', $show_prefix_option), "If you do not wish to give them the option to change this, set it to 'no'. Otherwise, if it is true, they can change the folder prefix to be anything."); if (isset($list_special_folders_first)) $tabContents["enm_folders"]["options"] .= $this->makeRow("List special folders first:", $this->getCombo('list_special_folders_first', $list_special_folders_first), "Whether or not to list the special folders first."); if (isset($auto_expunge)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Auto expunge:", $this->getCombo('auto_expunge', $auto_expunge), "If this option is set, when a message is moved or copied, the  source mailbox will get expunged, removing all messages marked 'Deleted'."); if (isset($default_sub_of_inbox)) $tabContents["enm_folders"]["options"] .= $this->makeRow("All folders under inbox:", $this->getCombo('default_sub_of_inbox', $default_sub_of_inbox), "Are all your folders subfolders of INBOX (i.e. cyrus IMAP server)? If you are unsure, set it to 'no'."); if (isset($show_contain_subfolders_option)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Display subfolder option:", $this->getCombo('show_contain_subfolders_option', $show_contain_subfolders_option), "Some IMAP daemons (UW) only allow a folder to contain either messages or other folders, not both at the same time. This option controls whether or not to display an option during folder creation. The option toggles which type of folder it should be. If you are not sure, set it to 'yes'."); if (isset($default_unseen_notify)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Display unseen in folders:", $this->getCombo('default_unseen_notify', $default_unseen_notify, array('1'=>'None', '2'=>'Inbox', '3'=>'All')), "Specifies whether or not the users will see the number of unseen in each folder by default and also which folders to do this to."); if (isset($default_unseen_type)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Unseen notification type:", $this->getCombo('default_unseen_type', $default_unseen_type, array('1'=>'(4)', '2'=>'(4,25)')), "Specifies the type of notification to give the users by default."); if (isset($auto_create_special)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Create special folders:", $this->getCombo('auto_create_special', $auto_create_special), "Should the program create the Sent and Trash folders automatically for a new user that doesn't already have them created?"); if (isset($delete_folder)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Delete folders permanently:", $this->getCombo('delete_folder', $delete_folder), "If this is true, when a folder is deleted then it will not get moved into the Trash folder."); if (isset($noselect_fix_enable)) $tabContents["enm_folders"]["options"] .= $this->makeRow("Cyrus 'no select' fix:", $this->getCombo('noselect_fix_enable', $noselect_fix_enable), "This enables the no select fix for Cyrus when subfolders exist but parent folders do not."); if (isset($default_pref['left_size'])) $tabContents["enm_defaults"]["options"] .= $this->makeRow("Default width of folder list:", "<input type='text' name='left_size' value='" . $this->v($default_pref['left_size']) . "' />", "This is the default width of the folder list in pixels. Users will be able to change this option in their account configuration."); if (isset($default_pref['show_html_default'])) $tabContents["enm_defaults"]["options"] .= $this->makeRow("Display mail as HTML:", $this->getCombo('show_html_default', $default_pref['show_html_default'], array('1'=>'Yes', '0'=>'No')), "This option specifies whether e-mails will be displayed using formatted HTML or plain text. Users will be able to change this option in their account configuration."); if (isset($default_pref['compose_window_type'])) $tabContents["enm_defaults"]["options"] .= $this->makeRow("Compose using formatted text:", $this->getCombo('compose_window_type', $default_pref['compose_window_type'], array('html'=>'Yes', 'plain'=>'No')), "This option specifies whether e-mails will be composed using formatted HTML or plain text. Users will be able to change this option in their account configuration."); if (isset($force_username_lowercase)) $tabContents["enm_users"]["options"] .= $this->makeRow("Force lowercase usernames:", $this->getCombo('force_username_lowercase', $force_username_lowercase), "Some IMAP servers allow a username (like 'bob') to log in if they use uppercase in their name (like 'Bob' or 'BOB'). This creates extra preference files. Setting this option to 'yes' will transparently change all usernames to lowercase."); if (isset($default_use_priority)) $tabContents["enm_users"]["options"] .= $this->makeRow("Enable e-mail priority flags:", $this->getCombo('default_use_priority', $default_use_priority), "This option enables use of email priority flags by end users."); if (isset($default_use_mdn)) $tabContents["enm_users"]["options"] .= $this->makeRow("Enable read/delivery receipts:", $this->getCombo('default_use_mdn', $default_use_mdn), "This option enables use of read/delivery receipts by end users."); if (isset($edit_identity)) $tabContents["enm_users"]["options"] .= $this->makeRow("Allow users to change e-mail address:", $this->getCombo('edit_identity', $edit_identity), "Allows users to change their email address."); if (isset($edit_name)) $tabContents["enm_users"]["options"] .= $this->makeRow("Allow users to change name:", $this->getCombo('edit_name', $edit_name), "Allows users to change their name. This option has no effect unless 'Allow users to change e-mail address' is set to 'no'."); if (isset($hide_auth_header)) $tabContents["enm_users"]["options"] .= $this->makeRow("Hide username header:", $this->getCombo('hide_auth_header', $hide_auth_header), "SquirrelMail adds username information to every sent email. It is done in order to prevent possible sender forging when end users are allowed to change their email and name information. You can disable this header, if you think that it violates user's privacy or security. Please note, that setting will work only when users are not allowed to change their e-mail address."); if (isset($default_use_javascript_addr_book)) $tabContents["enm_users"]["options"] .= $this->makeRow("Use Javascript in addressbook:", $this->getCombo('default_use_javascript_addr_book', $default_use_javascript_addr_book), "Users may search their addressbook via either a plain HTML or Javascript enhanced user interface. This option allows you to set the default choice."); if (isset($data_dir)) $tabContents["enm_paths"]["options"] .= $this->makeRow("Data directory:", "<input type='text' name='data_dir' value='" . $this->v($this->formatDirectory($data_dir, true)) . "' />", "Path to the data/ directory. It is a possible security hole to have a writable directory under the web server's root directory (ex: /home/httpd/html). It is possible to put the data directory anywhere you would like; it is strongly advised that it is NOT directly web-accessible."); if (isset($attachment_dir)) $tabContents["enm_paths"]["options"] .= $this->makeRow("Attachment directory:", "<input type='text' name='attachment_dir' value='" . $this->v($this->formatDirectory($attachment_dir, true)) . "' />", "Path to directory used for storing attachments while a mail is being sent. There are a few security considerations regarding this directory: (1) It should have the permission 733 (rwx-wx-wx) to make it impossible for a random person with access to the webserver to list files in this directory. Confidential data might be laying around there. (2) Since the webserver is not able to list the files in the content is also impossible for the webserver to delete files lying around there for too long. (3) It should probably be another directory than the data directory."); $output = ""; $tabs = $tabsDashboardLink ? "<div id='tabDashboardLink'><a href='javascript:void(0)' onclick='window.location=\"$tabsDashboardLink\"'></a></div>" : ""; if (!$showTab) $showTab = @$_GET['tab']; if (!array_key_exists($showTab, $tabContents) || !$tabContents[$showTab]['options']) $showTab = false; $tabNumber = 1; $visibleTab = false; foreach ($tabContents as $key=>$val) { if (!$val['options']) continue; if (!$showTab && !$visibleTab) { $showTab = $key; $visibleTab = true; } $output .= "<div id='tabs-$tabNumber' class='tabPage" . ($key == $showTab ? " tabVisible" : "") . "'>". ($val['explanation'] ? "<div class='explanation'>" . $val['explanation'] . "</div>" : ""). ($key == "enm_basic" && $enmLicenseErrors && $enmLicenseErrors != "-" ? "<div class='writeError error'>$enmLicenseErrors</div>" : "") . ($val['tableWrap'] ? "<table>" : "") . $val['options']. ($val['tableWrap'] ? "</table>" : "") . $val['append']. "</div>"; $tabs .= "<a href='#tabs-$tabNumber'" . ($key == $showTab ? " class='tabVisible'" : "") . " onclick='return ensignia.showTab(this)'>{$val['title']}</a></li>"; $tabNumber++; } if ($output) $output = $this->getSkinPreviewCode(). "<form name='enmForm' action='' method='post' accept-charset='UTF-8'>". "<input type='hidden' name='init_setup_completed' value='true' />". "<div id='tabFrame'>". "<div class='tabLinks'>$tabs</div>". $output. "</div>". "<div class='buttonBox'>". "<a class='button' onclick='" . ($enmDemo ? "alert(\"Saving options is disabled in demo mode.\")" : "ensignia.verifyForm()") . "'>Save options</a>". "</div>". "</form>". $additionalPageCode. "<script type='text/javascript'>formValues = ensignia.saveFormValues()</script>"; return $message . $output; } public function processAjax() { global $enmDemo; if (isset($_POST['pref_replace_key'])) { if ($enmDemo) { exit(json_encode(array("result" => "Disabled in demo."))); } $this->changePrefSetting($_POST['pref_replace_key'], $_POST['pref_replace_value'], $modified, $errors); exit(json_encode(array("result" => "Modified files: $modified, errors: $errors."))); } } public function changePrefSetting($setting, $newValue, &$modified, &$errors) { global $data_dir; $dir = rtrim($data_dir, "/") . "/"; $setting = trim($setting); $newValue = trim($newValue); $modified = 0; $errors = 0; foreach (glob($dir . "*.pref") as $file) { $array = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); foreach ($array as $key => $line) { $pair = explode("=", $line); if (count($pair) == 2 && trim($pair[0]) == $setting) { $array[$key] = "$setting=$newValue"; if (@file_put_contents($file, implode("\n", $array)) === false) { $errors++; } else { $modified++; } break; } } } } }

Function Calls

defined 1

Variables

None

Stats

MD5 fd4fec9b26381570387659457e01e0e0
Eval Count 0
Decode Time 244 ms