| | |
| | | | rcube_install.php | |
| | | | | |
| | | | This file is part of the RoundCube Webmail package | |
| | | | Copyright (C) 2008, RoundCube Dev. - Switzerland | |
| | | | Copyright (C) 2008-2009, RoundCube Dev. - Switzerland | |
| | | | Licensed under the GNU Public License | |
| | | +-----------------------------------------------------------------------+ |
| | | |
| | |
| | | // these config options are optional or can be set to null |
| | | var $optional_config = array( |
| | | 'log_driver', 'syslog_id', 'syslog_facility', 'imap_auth_type', |
| | | 'smtp_helo_host', 'sendmail_delay', 'double_auth', 'language', |
| | | 'mail_header_delimiter', 'create_default_folders', |
| | | 'smtp_helo_host', 'smtp_auth_type', 'sendmail_delay', 'double_auth', |
| | | 'language', 'mail_header_delimiter', 'create_default_folders', |
| | | 'quota_zero_as_unlimited', 'spellcheck_uri', 'spellcheck_languages', |
| | | 'http_received_header', 'session_domain', 'mime_magic', 'log_logins', |
| | | 'enable_installer', 'skin_include_php'); |
| | | 'enable_installer', 'skin_include_php', 'imap_root', 'imap_delimiter', |
| | | 'virtuser_file', 'virtuser_query', 'dont_override'); |
| | | |
| | | /** |
| | | * Constructor |
| | |
| | | */ |
| | | function create_config($which, $force = false) |
| | | { |
| | | $out = file_get_contents(RCMAIL_CONFIG_DIR . "/{$which}.inc.php.dist"); |
| | | $out = @file_get_contents(RCMAIL_CONFIG_DIR . "/{$which}.inc.php.dist"); |
| | | |
| | | if (!$out) |
| | | return '[Warning: could not read the template file]'; |
| | | return '[Warning: could not read the config template file]'; |
| | | |
| | | foreach ($this->config as $prop => $default) { |
| | | $value = (isset($_POST["_$prop"]) || $this->bool_config_props[$prop]) ? $_POST["_$prop"] : $default; |
| | |
| | | else if ($prop == 'smtp_pass' && !empty($_POST['_smtp_user_u'])) { |
| | | $value = '%p'; |
| | | } |
| | | else if ($prop == 'default_imap_folders'){ |
| | | $value = Array(); |
| | | foreach($this->config['default_imap_folders'] as $_folder){ |
| | | switch($_folder) { |
| | | case 'Drafts': $_folder = $this->config['drafts_mbox']; break; |
| | | case 'Sent': $_folder = $this->config['sent_mbox']; break; |
| | | case 'Junk': $_folder = $this->config['junk_mbox']; break; |
| | | case 'Trash': $_folder = $this->config['trash_mbox']; break; |
| | | } |
| | | if (!in_array($_folder, $value)) $value[] = $_folder; |
| | | } |
| | | } |
| | | else if (is_bool($default)) { |
| | | $value = (bool)$value; |
| | | } |
| | |
| | | // replace the matching line in config file |
| | | $out = preg_replace( |
| | | '/(\$rcmail_config\[\''.preg_quote($prop).'\'\])\s+=\s+(.+);/Uie', |
| | | "'\\1 = ' . var_export(\$value, true) . ';'", |
| | | "'\\1 = ' . rcube_install::_dump_var(\$value) . ';'", |
| | | $out); |
| | | } |
| | | |
| | |
| | | $out['dependencies'][] = array('prop' => 'spellcheck_engine', |
| | | 'explain' => 'This requires the <tt>pspell</tt> extension which could not be loaded.'); |
| | | } |
| | | if (empty($this->config['spellcheck_languages'])) { |
| | | $out['dependencies'][] = array('prop' => 'spellcheck_languages', |
| | | 'explain' => 'You should specify the list of languages supported by your local pspell installation.'); |
| | | if (!empty($this->config['spellcheck_languages'])) { |
| | | foreach ($this->config['spellcheck_languages'] as $lang => $descr) |
| | | if (!pspell_new($lang)) |
| | | $out['dependencies'][] = array('prop' => 'spellcheck_languages', |
| | | 'explain' => "You are missing pspell support for language $lang ($descr)"); |
| | | } |
| | | } |
| | | |
| | |
| | | $out['dependencies'][] = array('prop' => 'syslog_id', |
| | | 'explain' => 'Using <tt>syslog</tt> for logging requires a syslog ID to be configured'); |
| | | } |
| | | |
| | | } |
| | | |
| | | // check ldap_public sources having global_search enabled |
| | | if (is_array($this->config['ldap_public']) && !is_array($this->config['autocomplete_addressbooks'])) { |
| | | foreach ($this->config['ldap_public'] as $ldap_public) { |
| | | if ($ldap_public['global_search']) { |
| | | $out['replaced'][] = array('prop' => 'ldap_public::global_search', 'replacement' => 'autocomplete_addressbooks'); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return $out; |
| | |
| | | unset($current[$prop]); |
| | | } |
| | | |
| | | $this->config = array_merge($current, $this->config); |
| | | // add all ldap_public sources having global_search enabled to autocomplete_addressbooks |
| | | if (is_array($current['ldap_public'])) { |
| | | foreach ($current['ldap_public'] as $key => $ldap_public) { |
| | | if ($ldap_public['global_search']) { |
| | | $this->config['autocomplete_addressbooks'][] = $key; |
| | | unset($current['ldap_public'][$key]['global_search']); |
| | | } |
| | | } |
| | | } |
| | | |
| | | $this->config = array_merge($this->config, $current); |
| | | |
| | | foreach ((array)$current['ldap_public'] as $key => $values) { |
| | | $this->config['ldap_public'][$key] = $current['ldap_public'][$key]; |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | echo Q($name) . ': <span class="fail">NOT OK</span>'; |
| | | $this->_showhint($message, $url); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Display an error status for optional settings/features |
| | | * |
| | | * @param string Test name |
| | | * @param string Error message |
| | | * @param string URL for details |
| | | */ |
| | | function optfail($name, $message = '', $url = '') |
| | | { |
| | | echo Q($name) . ': <span class="na">NOT OK</span>'; |
| | | $this->_showhint($message, $url); |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | |
| | | function _clean_array($arr) |
| | | static function _clean_array($arr) |
| | | { |
| | | $out = array(); |
| | | |
| | | foreach (array_unique($arr) as $i => $val) |
| | | if (!empty($val)) |
| | | $out[] = $val; |
| | | foreach (array_unique($arr) as $k => $val) { |
| | | if (!empty($val)) { |
| | | if (is_numeric($k)) |
| | | $out[] = $val; |
| | | else |
| | | $out[$k] = $val; |
| | | } |
| | | } |
| | | |
| | | return $out; |
| | | } |
| | | |
| | | |
| | | static function _dump_var($var) { |
| | | if (is_array($var)) { |
| | | if (empty($var)) { |
| | | return 'array()'; |
| | | } |
| | | else { // check if all keys are numeric |
| | | $isnum = true; |
| | | foreach ($var as $key => $value) { |
| | | if (!is_numeric($key)) { |
| | | $isnum = false; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if ($isnum) |
| | | return 'array(' . join(', ', array_map(array('rcube_install', '_dump_var'), $var)) . ')'; |
| | | } |
| | | } |
| | | |
| | | return var_export($var, true); |
| | | } |
| | | |
| | | |
| | |
| | | if ($lines = @file($fname, FILE_SKIP_EMPTY_LINES)) { |
| | | $buff = ''; |
| | | foreach ($lines as $i => $line) { |
| | | if (eregi('^--', $line)) |
| | | if (preg_match('/^--/', $line)) |
| | | continue; |
| | | |
| | | $buff .= $line . "\n"; |
| | | if (eregi(';$', trim($line))) { |
| | | if (preg_match('/;$/', trim($line))) { |
| | | $DB->query($buff); |
| | | $buff = ''; |
| | | if ($this->get_error()) |