sql_query($sql)) ) { report_error(CRITICAL_MESSAGE,sprintf('Unable to query table: %s',USERS_TABLE),NULL,$sql,__FILE__,__LINE__); } } $sql = sprintf("SELECT * FROM %s", CONFIG_TABLE); if ( !($result = $db->sql_query($sql)) ) { report_error(CRITICAL_ERROR,sprintf('Unable to query table: %s',CONFIG_TABLE),$sql,__FILE__,__LINE__); } unset($watchdog); while ( $row = $db->sql_fetchrow($result) ) { $config_name = $row['config_name']; $config_value = $row['config_value']; $default_config[$config_name] = isset($_POST['submit']) ? str_replace("'","\'",$config_value) : $config_value; $new[$config_name] = isset($_POST[$config_name]) ? $_POST[$config_name] : $default_config[$config_name]; $new[$config_name] = str_replace("//","/",$new[$config_name]); $new[$config_name] = str_replace("\'","''",$new[$config_name]); if ( isset($default_quota) && preg_match('/default_quota/',$config_name) ) { if ( !($new[$config_name] == $config['default_quota']) ) { $new[$config_name] = convert_quota($default_quota,TRUE); ratify_quota($new[$config_name],0); } } if ( preg_match('/default_folders/',$config_name) ) { $split_folders = explode(",",$new[$config_name]); unset($new[$config_name]); while ( list(,$var) = @each($split_folders) ) { if ( !empty($var) ) { $new[$config_name] = isset($new[$config_name]) ? $new[$config_name].','.trim($var) : trim($var); } } } if ( isset($mailbox_limit) && preg_match('/mailbox_limit/',$config_name) && !($new[$config_name] == $config['mailbox_limit']) ) { ratify_mailbox($new[$config_name],'limit_mailbox',0); } if ( isset($alias_limit) && preg_match('/alias_limit/',$config_name) && !($new[$config_name] == $config['alias_limit']) ) { ratify_mailbox($new[$config_name],'limit_alias',0); } if ( isset($permit_userprefs) && preg_match('/permit_userprefs/',$config_name) && !($new[$config_name] == $config['permit_userprefs']) ) { ratify_spamassassin_preferences($new[$config_name],0); } if ( isset($permit_virus_filter) && preg_match('/permit_virus_filter/',$config_name) && !($new[$config_name] == $config['permit_virus_filter']) ) { ratify_clam_scanning($new[$config_name],0); } if ( isset($enable_email_forwarding) && preg_match('/enable_email_forwarding/',$config_name) && !($new[$config_name] == $config['enable_email_forwarding']) ) { ratify_mail_forwaring($new[$config_name],0); } if ( isset($enable_mail_filtering) && preg_match('/enable_mail_filtering/',$config_name) && !($new[$config_name] == $config['enable_mail_filtering']) ) { ratify_mail_filtering($new[$config_name],0); } if ( isset($enable_autoresponse) && preg_match('/enable_autoresponse/',$config_name) && !($new[$config_name] == $config['enable_autoresponse']) ) { ratify_virtual_vacation($new[$config_name],0); } if ( isset($allow_useradd) && preg_match('/allow_useradd/',$config_name) && !($new[$config_name] == $config['allow_useradd']) ) { ratify_mailbox($new[$config_name],'permit_user_add_alias',0); } if ( isset($require_activation) && preg_match('/require_activation/',$config_name) && !($new[$config_name] == $config['require_activation']) ) { ratify_mailbox($new[$config_name],'require_alias_activation',0); } /** * * Toggle active state for aliases, domains * and mailboxes * **/ if ( isset($vma_disable) && preg_match('/vma_disable/',$config_name) && !($new[$config_name] == $config_name) ) { vma_utility_switch(($new[$config_name] ? DISABLE : ENABLE),'vma'); } $required = array('vuser_root','suser_root','cache_directory'); if ( in_array($config_name,$required) ) { switch ( $config_name ) { case 'vuser_root': case 'suser_root': if ( !(substr($new[$config_name],0,1) == '/') || (substr($new[$config_name],-1,1) == '/') ) { report_error(GENERAL_ERROR,sprintf(_('Path to %s should begin with / (forward slash) but not end in with a / (forward slash).'),$config_name)); } break; case 'cache_directory': if ( (substr($new[$config_name],0,1) == '/') || (substr($new[$config_name],-1,1) == '/') ) { report_error(GENERAL_ERROR,sprintf(_('Path to %s cannot have a / (forward slash) at the beginning nor end of path'),$config_name)); } break; } } if ( isset($user_root) && preg_match('/user_root/',$config_name) && !($new[$config_name] == $config[$config_name]) ) { $sql = sprintf("UPDATE %s SET homedir = '%s' WHERE domain_id <> '%d' AND user_id <> '%d'", USERS_TABLE,str_replace("\'","''",$new[$config_name]),ROOT,ANONYMOUS); if ( !($db->sql_query($sql)) ) { report_error(CRITICAL_MESSAGE,'Error 1122: '.sprintf(_('Unable to update: %s'),USERS_TABLE),$sql,__FILE__,__LINE__); } watchdog($sql); } if ( isset($reply_email) && preg_match('/reply_email/',$config_name) ) { list($tmp1,$tmp2) = preg_split('/@/',$new[$config_name]); $new[$config_name] = $tmp1; } if ( isset($script_path) && preg_match('/script_path/',$config_name) ) { if ( strlen($new[$config_name]) == 1 && $new[$config_name]{0} == '/' ) { $new[$config_name] = ''; } } if ( preg_match('/server_secure/',$config_name) || preg_match('/server_port/',$config_name) ) { if ( isset($server_secure) && isset($server_port) ) { if ( preg_match('/server_port/',$config_name) ) { if ( $new[$config_name] < 0 || $new[$config_name] > 65500 ) { report_error(GENERAL_ERROR,_('You have specified an invalid port.')); } } } } if ( isset($_POST[$config_name]) ) { $sql = sprintf("UPDATE %s SET config_value = '%s' WHERE config_name = '%s'", CONFIG_TABLE,str_replace("\'","''",$new[$config_name]),$config_name); if ( !($db->sql_query($sql)) ) { report_error(CRITICAL_MESSAGE,'Error 1123: '.sprintf(_('Unable to update: %s'),$config_name),$sql,__FILE__,__LINE__); } $watchdog = isset($watchdog) ? sprintf('%s
%s',$watchdog,$sql) : $sql; } } watchdog($watchdog); end_transaction(GENERAL_MESSAGE,_('General preferences have been updated'),(empty($zone) ? append_sid($base) : append_sid(sprintf('%s&zone=%s',$base,$zone)))); ?>