本文整理汇总了PHP中rcube_parse_host函数的典型用法代码示例。如果您正苦于以下问题:PHP rcube_parse_host函数的具体用法?PHP rcube_parse_host怎么用?PHP rcube_parse_host使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rcube_parse_host函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: authenticate
function authenticate($args)
{
// Load plugin's config file
$this->load_config();
$host = rcmail::get_instance()->config->get('http_authentication_host');
if (is_string($host) && trim($host) !== '') {
$args['host'] = rcube_idn_to_ascii(rcube_parse_host($host));
}
// Allow entering other user data in login form,
// e.g. after log out (#1487953)
if (!empty($args['user'])) {
return $args;
}
if (!empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW'])) {
$args['user'] = $_SERVER['PHP_AUTH_USER'];
$args['pass'] = $_SERVER['PHP_AUTH_PW'];
}
$args['cookiecheck'] = false;
$args['valid'] = true;
return $args;
}
示例2: get_hostlist
/**
* Return a list with all imap hosts configured
*
* @return array Clean list with imap hosts
*/
function get_hostlist()
{
$default_hosts = (array) $this->getprop('default_host');
$out = array();
foreach ($default_hosts as $key => $name) {
if (!empty($name)) {
$out[] = rcube_parse_host(is_numeric($key) ? $name : $key);
}
}
return $out;
}
示例3: _connect
/**
* Establish a connection to the LDAP server
*/
private function _connect()
{
global $RCMAIL;
if (!function_exists('ldap_connect')) {
raise_error(array('code' => 100, 'type' => 'ldap', 'file' => __FILE__, 'line' => __LINE__, 'message' => "No ldap support in this installation of PHP"), true, true);
}
if (is_resource($this->conn)) {
return true;
}
if (!is_array($this->prop['hosts'])) {
$this->prop['hosts'] = array($this->prop['hosts']);
}
if (empty($this->prop['ldap_version'])) {
$this->prop['ldap_version'] = 3;
}
foreach ($this->prop['hosts'] as $host) {
$host = idn_to_ascii(rcube_parse_host($host));
$hostname = $host . ($this->prop['port'] ? ':' . $this->prop['port'] : '');
$this->_debug("C: Connect [{$hostname}] [{$this->prop['name']}]");
if ($lc = @ldap_connect($host, $this->prop['port'])) {
if ($this->prop['use_tls'] === true) {
if (!ldap_start_tls($lc)) {
continue;
}
}
$this->_debug("S: OK");
ldap_set_option($lc, LDAP_OPT_PROTOCOL_VERSION, $this->prop['ldap_version']);
$this->prop['host'] = $host;
$this->conn = $lc;
if (isset($this->prop['referrals'])) {
ldap_set_option($lc, LDAP_OPT_REFERRALS, $this->prop['referrals']);
}
break;
}
$this->_debug("S: NOT OK");
}
// See if the directory is writeable.
if ($this->prop['writable']) {
$this->readonly = false;
}
if (!is_resource($this->conn)) {
raise_error(array('code' => 100, 'type' => 'ldap', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Could not connect to any LDAP server, last tried {$hostname}"), true);
return false;
}
$bind_pass = $this->prop['bind_pass'];
$bind_user = $this->prop['bind_user'];
$bind_dn = $this->prop['bind_dn'];
$this->base_dn = $this->prop['base_dn'];
$this->groups_base_dn = $this->prop['groups']['base_dn'] ? $this->prop['groups']['base_dn'] : $this->base_dn;
// User specific access, generate the proper values to use.
if ($this->prop['user_specific']) {
// No password set, use the session password
if (empty($bind_pass)) {
$bind_pass = $RCMAIL->decrypt($_SESSION['password']);
}
// Get the pieces needed for variable replacement.
if ($fu = $RCMAIL->user->get_username()) {
list($u, $d) = explode('@', $fu);
} else {
$d = $this->mail_domain;
}
$dc = 'dc=' . strtr($d, array('.' => ',dc='));
// hierarchal domain string
$replaces = array('%dn' => '', '%dc' => $dc, '%d' => $d, '%fu' => $fu, '%u' => $u);
if ($this->prop['search_base_dn'] && $this->prop['search_filter']) {
if (!empty($this->prop['search_bind_dn']) && !empty($this->prop['search_bind_pw'])) {
$this->bind($this->prop['search_bind_dn'], $this->prop['search_bind_pw']);
}
// Search for the dn to use to authenticate
$this->prop['search_base_dn'] = strtr($this->prop['search_base_dn'], $replaces);
$this->prop['search_filter'] = strtr($this->prop['search_filter'], $replaces);
$this->_debug("S: searching with base {$this->prop['search_base_dn']} for {$this->prop['search_filter']}");
$res = @ldap_search($this->conn, $this->prop['search_base_dn'], $this->prop['search_filter'], array('uid'));
if ($res) {
if (($entry = ldap_first_entry($this->conn, $res)) && ($bind_dn = ldap_get_dn($this->conn, $entry))) {
$this->_debug("S: search returned dn: {$bind_dn}");
$dn = ldap_explode_dn($bind_dn, 1);
$replaces['%dn'] = $dn[0];
}
} else {
$this->_debug("S: " . ldap_error($this->conn));
}
// DN not found
if (empty($replaces['%dn'])) {
if (!empty($this->prop['search_dn_default'])) {
$replaces['%dn'] = $this->prop['search_dn_default'];
} else {
raise_error(array('code' => 100, 'type' => 'ldap', 'file' => __FILE__, 'line' => __LINE__, 'message' => "DN not found using LDAP search."), true);
return false;
}
}
}
// Replace the bind_dn and base_dn variables.
$bind_dn = strtr($bind_dn, $replaces);
$this->base_dn = strtr($this->base_dn, $replaces);
$this->groups_base_dn = strtr($this->groups_base_dn, $replaces);
if (empty($bind_user)) {
//.........这里部分代码省略.........
示例4: managesieve_start
/**
* Loads configuration, initializes plugin (including sieve connection)
*/
function managesieve_start()
{
$this->load_config();
// register UI objects
$this->rc->output->add_handlers(array('filterslist' => array($this, 'filters_list'), 'filtersetslist' => array($this, 'filtersets_list'), 'filterframe' => array($this, 'filter_frame'), 'filterform' => array($this, 'filter_form'), 'filtersetform' => array($this, 'filterset_form')));
// Add include path for internal classes
$include_path = $this->home . '/lib' . PATH_SEPARATOR;
$include_path .= ini_get('include_path');
set_include_path($include_path);
$host = rcube_parse_host($this->rc->config->get('managesieve_host', 'localhost'));
$port = $this->rc->config->get('managesieve_port', 2000);
$host = rcube_idn_to_ascii($host);
$plugin = $this->rc->plugins->exec_hook('managesieve_connect', array('user' => $_SESSION['username'], 'password' => $this->rc->decrypt($_SESSION['password']), 'host' => $host, 'port' => $port, 'auth_type' => $this->rc->config->get('managesieve_auth_type'), 'usetls' => $this->rc->config->get('managesieve_usetls', false), 'disabled' => $this->rc->config->get('managesieve_disabled_extensions'), 'debug' => $this->rc->config->get('managesieve_debug', false), 'auth_cid' => $this->rc->config->get('managesieve_auth_cid'), 'auth_pw' => $this->rc->config->get('managesieve_auth_pw')));
// try to connect to managesieve server and to fetch the script
$this->sieve = new rcube_sieve($plugin['user'], $plugin['password'], $plugin['host'], $plugin['port'], $plugin['auth_type'], $plugin['usetls'], $plugin['disabled'], $plugin['debug'], $plugin['auth_cid'], $plugin['auth_pw']);
if (!($error = $this->sieve->error())) {
// Get list of scripts
$list = $this->list_scripts();
if (!empty($_GET['_set']) || !empty($_POST['_set'])) {
$script_name = get_input_value('_set', RCUBE_INPUT_GPC, true);
} else {
if (!empty($_SESSION['managesieve_current'])) {
$script_name = $_SESSION['managesieve_current'];
} else {
// get (first) active script
if (!empty($this->active[0])) {
$script_name = $this->active[0];
} else {
if ($list) {
$script_name = $list[0];
} else {
// if script not exists build default script contents
$script_file = $this->rc->config->get('managesieve_default');
$script_name = $this->rc->config->get('managesieve_script_name');
if (empty($script_name)) {
$script_name = 'roundcube';
}
if ($script_file && is_readable($script_file)) {
$content = file_get_contents($script_file);
}
// add script and set it active
if ($this->sieve->save_script($script_name, $content)) {
$this->activate_script($script_name);
$this->list[] = $script_name;
}
}
}
}
}
if ($script_name) {
$this->sieve->load($script_name);
}
$error = $this->sieve->error();
}
// finally set script objects
if ($error) {
switch ($error) {
case SIEVE_ERROR_CONNECTION:
case SIEVE_ERROR_LOGIN:
$this->rc->output->show_message('managesieve.filterconnerror', 'error');
break;
default:
$this->rc->output->show_message('managesieve.filterunknownerror', 'error');
break;
}
raise_error(array('code' => 403, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Unable to connect to managesieve on {$host}:{$port}"), true, false);
// to disable 'Add filter' button set env variable
$this->rc->output->set_env('filterconnerror', true);
$this->script = array();
} else {
$this->exts = $this->sieve->get_extensions();
$this->script = $this->sieve->script->as_array();
$this->rc->output->set_env('currentset', $this->sieve->current);
$_SESSION['managesieve_current'] = $this->sieve->current;
}
return $error;
}
示例5: mail_domain
/**
* Return the mail domain configured for the given host
*
* @param string $host IMAP host
* @param boolean $encode If true, domain name will be converted to IDN ASCII
* @return string Resolved SMTP host
*/
public function mail_domain($host, $encode = true)
{
$domain = $host;
if (is_array($this->prop['mail_domain'])) {
if (isset($this->prop['mail_domain'][$host])) {
$domain = $this->prop['mail_domain'][$host];
}
} else {
if (!empty($this->prop['mail_domain'])) {
$domain = rcube_parse_host($this->prop['mail_domain']);
}
}
if ($encode) {
$domain = rcube_idn_to_ascii($domain);
}
return $domain;
}
示例6: _startup
private function _startup()
{
$rcmail = rcmail::get_instance();
if (!$this->sieve) {
include 'lib/Net/Sieve.php';
include 'include/rcube_sieve.php';
include 'include/rcube_sieve_script.php';
$rcmail = rcmail::get_instance();
// try to connect to managesieve server and to fetch the script
$this->sieve = new rcube_sieve($_SESSION['username'], $rcmail->decrypt($_SESSION['password']), rcube_idn_to_ascii(rcube_parse_host($rcmail->config->get('sieverules_host'))), $rcmail->config->get('sieverules_port'), $rcmail->config->get('sieverules_auth_type', NULL), $rcmail->config->get('sieverules_usetls'), $this->current_ruleset, $this->home, $rcmail->config->get('sieverules_use_elsif', true), $rcmail->config->get('sieverules_auth_cid', NULL), $rcmail->config->get('sieverules_auth_pw', NULL));
if ($rcmail->config->get('sieverules_debug', false)) {
$this->sieve->set_debug(true);
}
$this->sieve_error = $this->sieve->error();
if ($this->sieve_error == SIEVE_ERROR_NOT_EXISTS) {
// load default rule set
if ($rcmail->config->get('sieverules_default_file', false) && is_readable($rcmail->config->get('sieverules_default_file')) || sizeof($this->sieve->list) > 0) {
rcmail_overwrite_action('plugin.sieverules.setup');
$this->action = 'plugin.sieverules.setup';
} elseif ($rcmail->config->get('sieverules_default_file', false) && !is_readable($rcmail->config->get('sieverules_default_file'))) {
raise_error(array('code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "SieveRules plugin: Unable to open default rule file"), true, false);
}
// that's not exactly an error
$this->sieve_error = false;
} elseif ($this->sieve_error) {
switch ($this->sieve_error) {
case SIEVE_ERROR_CONNECTION:
case SIEVE_ERROR_LOGIN:
$this->api->output->command('display_message', $this->gettext('filterconnerror'), 'error');
break;
default:
$this->api->output->command('display_message', $this->gettext('filterunknownerror'), 'error');
break;
}
$this->api->output->set_env('sieveruleserror', true);
}
// finally set script objects
if ($this->sieve_error) {
$this->script = array();
} else {
$this->script = $this->sieve->script->as_array();
// load example filters
if ($rcmail->config->get('sieverules_example_file', false) && is_readable($rcmail->config->get('sieverules_example_file'))) {
$this->examples = $this->sieve->script->parse_text(file_get_contents($rcmail->config->get('sieverules_example_file')));
} elseif ($rcmail->config->get('sieverules_example_file', false) && !is_readable($rcmail->config->get('sieverules_example_file'))) {
raise_error(array('code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "SieveRules plugin: Unable to open example rule file"), true, false);
}
}
} else {
$this->sieve->set_ruleset($this->current_ruleset);
$this->script = $this->sieve->script->as_array();
}
}
示例7: connect
/**
* SMTP Connection and authentication
*
* @param string Server host
* @param string Server port
* @param string User name
* @param string Password
*
* @return bool Returns true on success, or false on error
*/
public function connect($host = null, $port = null, $user = null, $pass = null)
{
$RCMAIL = rcmail::get_instance();
// disconnect/destroy $this->conn
$this->disconnect();
// reset error/response var
$this->error = $this->response = null;
// let plugins alter smtp connection config
$CONFIG = $RCMAIL->plugins->exec_hook('smtp_connect', array('smtp_server' => $host ? $host : $RCMAIL->config->get('smtp_server'), 'smtp_port' => $port ? $port : $RCMAIL->config->get('smtp_port', 25), 'smtp_user' => $user ? $user : $RCMAIL->config->get('smtp_user'), 'smtp_pass' => $pass ? $pass : $RCMAIL->config->get('smtp_pass'), 'smtp_auth_cid' => $RCMAIL->config->get('smtp_auth_cid'), 'smtp_auth_pw' => $RCMAIL->config->get('smtp_auth_pw'), 'smtp_auth_type' => $RCMAIL->config->get('smtp_auth_type'), 'smtp_helo_host' => $RCMAIL->config->get('smtp_helo_host'), 'smtp_timeout' => $RCMAIL->config->get('smtp_timeout'), 'smtp_auth_callbacks' => array()));
$smtp_host = rcube_parse_host($CONFIG['smtp_server']);
// when called from Installer it's possible to have empty $smtp_host here
if (!$smtp_host) {
$smtp_host = 'localhost';
}
$smtp_port = is_numeric($CONFIG['smtp_port']) ? $CONFIG['smtp_port'] : 25;
$smtp_host_url = parse_url($smtp_host);
// overwrite port
if (isset($smtp_host_url['host']) && isset($smtp_host_url['port'])) {
$smtp_host = $smtp_host_url['host'];
$smtp_port = $smtp_host_url['port'];
}
// re-write smtp host
if (isset($smtp_host_url['host']) && isset($smtp_host_url['scheme'])) {
$smtp_host = sprintf('%s://%s', $smtp_host_url['scheme'], $smtp_host_url['host']);
}
// remove TLS prefix and set flag for use in Net_SMTP::auth()
if (preg_match('#^tls://#i', $smtp_host)) {
$smtp_host = preg_replace('#^tls://#i', '', $smtp_host);
$use_tls = true;
}
if (!empty($CONFIG['smtp_helo_host'])) {
$helo_host = $CONFIG['smtp_helo_host'];
} else {
if (!empty($_SERVER['SERVER_NAME'])) {
$helo_host = preg_replace('/:\\d+$/', '', $_SERVER['SERVER_NAME']);
} else {
$helo_host = 'localhost';
}
}
// IDNA Support
$smtp_host = rcube_idn_to_ascii($smtp_host);
$this->conn = new Net_SMTP($smtp_host, $smtp_port, $helo_host);
if ($RCMAIL->config->get('smtp_debug')) {
$this->conn->setDebug(true, array($this, 'debug_handler'));
}
// register authentication methods
if (!empty($CONFIG['smtp_auth_callbacks']) && method_exists($this->conn, 'setAuthMethod')) {
foreach ($CONFIG['smtp_auth_callbacks'] as $callback) {
$this->conn->setAuthMethod($callback['name'], $callback['function'], isset($callback['prepend']) ? $callback['prepend'] : true);
}
}
// try to connect to server and exit on failure
$result = $this->conn->connect($smtp_timeout);
if (PEAR::isError($result)) {
$this->response[] = "Connection failed: " . $result->getMessage();
$this->error = array('label' => 'smtpconnerror', 'vars' => array('code' => $this->conn->_code));
$this->conn = null;
return false;
}
// workaround for timeout bug in Net_SMTP 1.5.[0-1] (#1487843)
if (method_exists($this->conn, 'setTimeout') && ($timeout = ini_get('default_socket_timeout'))) {
$this->conn->setTimeout($timeout);
}
$smtp_user = str_replace('%u', $_SESSION['username'], $CONFIG['smtp_user']);
$smtp_pass = str_replace('%p', $RCMAIL->decrypt($_SESSION['password']), $CONFIG['smtp_pass']);
$smtp_auth_type = empty($CONFIG['smtp_auth_type']) ? NULL : $CONFIG['smtp_auth_type'];
if (!empty($CONFIG['smtp_auth_cid'])) {
$smtp_authz = $smtp_user;
$smtp_user = $CONFIG['smtp_auth_cid'];
$smtp_pass = $CONFIG['smtp_auth_pw'];
}
// attempt to authenticate to the SMTP server
if ($smtp_user && $smtp_pass) {
// IDNA Support
if (strpos($smtp_user, '@')) {
$smtp_user = rcube_idn_to_ascii($smtp_user);
}
$result = $this->conn->auth($smtp_user, $smtp_pass, $smtp_auth_type, $use_tls, $smtp_authz);
if (PEAR::isError($result)) {
$this->error = array('label' => 'smtpautherror', 'vars' => array('code' => $this->conn->_code));
$this->response[] .= 'Authentication failure: ' . $result->getMessage() . ' (Code: ' . $result->getCode() . ')';
$this->reset();
$this->disconnect();
return false;
}
}
return true;
}
示例8: autoselect_host
/**
* Auto-select IMAP host based on the posted login information
*
* @return string Selected IMAP host
*/
public function autoselect_host()
{
$default_host = $this->config->get('default_host');
$host = null;
if (is_array($default_host)) {
$post_host = get_input_value('_host', RCUBE_INPUT_POST);
// direct match in default_host array
if ($default_host[$post_host] || in_array($post_host, array_values($default_host))) {
$host = $post_host;
}
// try to select host by mail domain
list($user, $domain) = explode('@', get_input_value('_user', RCUBE_INPUT_POST));
if (!empty($domain)) {
foreach ($default_host as $imap_host => $mail_domains) {
if (is_array($mail_domains) && in_array($domain, $mail_domains)) {
$host = $imap_host;
break;
}
}
}
// take the first entry if $host is still an array
if (empty($host)) {
$host = array_shift($default_host);
}
} else {
if (empty($default_host)) {
$host = get_input_value('_host', RCUBE_INPUT_POST);
} else {
$host = rcube_parse_host($default_host);
}
}
return $host;
}
示例9: array
$headers = array('From' => $from, 'To' => $to, 'Subject' => 'Test message from Roundcube');
$body = 'This is a test to confirm that Roundcube can send email.';
$smtp_response = array();
// send mail using configured SMTP server
if ($RCI->getprop('smtp_server')) {
$CONFIG = $RCI->config;
if (!empty($_POST['_smtp_user'])) {
$CONFIG['smtp_user'] = $_POST['_smtp_user'];
}
if (!empty($_POST['_smtp_pass'])) {
$CONFIG['smtp_pass'] = $_POST['_smtp_pass'];
}
$mail_object = new Mail_mime();
$send_headers = $mail_object->headers($headers);
$SMTP = new rcube_smtp();
$SMTP->connect(rcube_parse_host($RCI->getprop('smtp_server')), $RCI->getprop('smtp_port'), $CONFIG['smtp_user'], $CONFIG['smtp_pass']);
$status = $SMTP->send_mail($headers['From'], $headers['To'], $foo = $mail_object->txtHeaders($send_headers), $body);
$smtp_response = $SMTP->get_response();
} else {
// use mail()
$header_str = 'From: ' . $headers['From'];
if (ini_get('safe_mode')) {
$status = mail($headers['To'], $headers['Subject'], $body, $header_str);
} else {
$status = mail($headers['To'], $headers['Subject'], $body, $header_str, '-f' . $headers['From']);
}
if (!$status) {
$smtp_response[] = 'Mail delivery with mail() failed. Check your error logs for details';
}
}
if ($status) {
示例10: autoselect_host
/**
* Auto-select IMAP host based on the posted login information
*
* @return string Selected IMAP host
*/
public function autoselect_host()
{
$default_host = $this->config->get('default_host');
$host = null;
if (is_array($default_host)) {
$post_host = get_input_value('_host', RCUBE_INPUT_POST);
$post_user = get_input_value('_user', RCUBE_INPUT_POST);
list($user, $domain) = explode('@', $post_user);
// direct match in default_host array
if ($default_host[$post_host] || in_array($post_host, $default_host)) {
$host = $post_host;
} else {
if (!empty($domain)) {
foreach ($default_host as $storage_host => $mail_domains) {
if (is_array($mail_domains) && in_array_nocase($domain, $mail_domains)) {
$host = $storage_host;
break;
} else {
if (stripos($storage_host, $domain) !== false || stripos(strval($mail_domains), $domain) !== false) {
$host = is_numeric($storage_host) ? $mail_domains : $storage_host;
break;
}
}
}
}
}
// take the first entry if $host is still not set
if (empty($host)) {
list($key, $val) = each($default_host);
$host = is_numeric($key) ? $val : $key;
}
} else {
if (empty($default_host)) {
$host = get_input_value('_host', RCUBE_INPUT_POST);
} else {
$host = rcube_parse_host($default_host);
}
}
return $host;
}
示例11: managesieve_start
function managesieve_start()
{
$this->rc = rcmail::get_instance();
$this->load_config();
// register UI objects
$this->rc->output->add_handlers(array('filterslist' => array($this, 'filters_list'), 'filtersetslist' => array($this, 'filtersets_list'), 'filterframe' => array($this, 'filter_frame'), 'filterform' => array($this, 'filter_form'), 'filtersetform' => array($this, 'filterset_form')));
require_once $this->home . '/lib/Net/Sieve.php';
require_once $this->home . '/lib/rcube_sieve.php';
$host = rcube_parse_host($this->rc->config->get('managesieve_host', 'localhost'));
$port = $this->rc->config->get('managesieve_port', 2000);
$host = idn_to_ascii($host);
// try to connect to managesieve server and to fetch the script
$this->sieve = new rcube_sieve($_SESSION['username'], $this->rc->decrypt($_SESSION['password']), $host, $port, $this->rc->config->get('managesieve_auth_type'), $this->rc->config->get('managesieve_usetls', false), $this->rc->config->get('managesieve_disabled_extensions'), $this->rc->config->get('managesieve_debug', false), $this->rc->config->get('managesieve_auth_cid'), $this->rc->config->get('managesieve_auth_pw'));
if (!($error = $this->sieve->error())) {
$list = $this->sieve->get_scripts();
$active = $this->sieve->get_active();
$_SESSION['managesieve_active'] = $active;
if (!empty($_GET['_set'])) {
$script_name = get_input_value('_set', RCUBE_INPUT_GET);
} else {
if (!empty($_SESSION['managesieve_current'])) {
$script_name = $_SESSION['managesieve_current'];
} else {
// get active script
if ($active) {
$script_name = $active;
} else {
if ($list) {
$script_name = $list[0];
} else {
// if script not exists build default script contents
$script_file = $this->rc->config->get('managesieve_default');
$script_name = 'roundcube';
if ($script_file && is_readable($script_file)) {
$content = file_get_contents($script_file);
}
// add script and set it active
if ($this->sieve->save_script($script_name, $content)) {
if ($this->sieve->activate($script_name)) {
$_SESSION['managesieve_active'] = $script_name;
}
}
}
}
}
}
if ($script_name) {
$this->sieve->load($script_name);
}
$error = $this->sieve->error();
}
// finally set script objects
if ($error) {
switch ($error) {
case SIEVE_ERROR_CONNECTION:
case SIEVE_ERROR_LOGIN:
$this->rc->output->show_message('managesieve.filterconnerror', 'error');
break;
default:
$this->rc->output->show_message('managesieve.filterunknownerror', 'error');
break;
}
raise_error(array('code' => 403, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Unable to connect to managesieve on {$host}:{$port}"), true, false);
// to disable 'Add filter' button set env variable
$this->rc->output->set_env('filterconnerror', true);
$this->script = array();
} else {
$this->script = $this->sieve->script->as_array();
$this->exts = $this->sieve->get_extensions();
$this->rc->output->set_env('active_set', $_SESSION['managesieve_active']);
$_SESSION['managesieve_current'] = $this->sieve->current;
}
return $error;
}