当前位置: 首页>>代码示例>>PHP>>正文


PHP rcube_utils::parse_host方法代码示例

本文整理汇总了PHP中rcube_utils::parse_host方法的典型用法代码示例。如果您正苦于以下问题:PHP rcube_utils::parse_host方法的具体用法?PHP rcube_utils::parse_host怎么用?PHP rcube_utils::parse_host使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rcube_utils的用法示例。


在下文中一共展示了rcube_utils::parse_host方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: connect

 /**
  * Establish a connection to the LDAP server
  */
 public function connect($host = null)
 {
     // Net_LDAP3 does not support IDNA yet
     // also parse_host() here is very Roundcube specific
     $host = rcube_utils::idn_to_ascii(rcube_utils::parse_host($host));
     return parent::connect($host);
 }
开发者ID:noikiy,项目名称:roundcubemail,代码行数:10,代码来源:rcube_ldap_generic.php

示例2: authenticate

 /**
  * Authenticate hook handler
  */
 function authenticate($args)
 {
     if (!empty($_SERVER['REMOTE_USER']) && !empty($_SERVER['KRB5CCNAME'])) {
         // Load plugin's config file
         $this->load_config();
         $rcmail = rcmail::get_instance();
         $host = $rcmail->config->get('krb_authentication_host');
         if (is_string($host) && trim($host) !== '' && empty($args['host'])) {
             $args['host'] = rcube_utils::idn_to_ascii(rcube_utils::parse_host($host));
         }
         if (!empty($_SERVER['REMOTE_USER'])) {
             $args['user'] = $_SERVER['REMOTE_USER'];
             $args['pass'] = null;
         }
         $args['cookiecheck'] = false;
         $args['valid'] = true;
     }
     return $args;
 }
开发者ID:jimjag,项目名称:roundcubemail,代码行数:22,代码来源:krb_authentication.php

示例3: 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) !== '' && empty($args['host'])) {
         $args['host'] = rcube_utils::idn_to_ascii(rcube_utils::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;
 }
开发者ID:rasky,项目名称:roundcubemail,代码行数:21,代码来源:http_authentication.php

示例4: save

 public function save($currpass, $newpass)
 {
     $host = rcmail::get_instance()->config->get('password_smb_host', 'localhost');
     $bin = rcmail::get_instance()->config->get('password_smb_cmd', '/usr/bin/smbpasswd');
     $username = $_SESSION['username'];
     $host = rcube_utils::parse_host($host);
     $tmpfile = tempnam(sys_get_temp_dir(), 'smb');
     $cmd = $bin . ' -r ' . $host . ' -s -U "' . $username . '" > ' . $tmpfile . ' 2>&1';
     $handle = @popen($cmd, 'w');
     fputs($handle, $currpass . "\n");
     fputs($handle, $newpass . "\n");
     fputs($handle, $newpass . "\n");
     @pclose($handle);
     $res = file($tmpfile);
     unlink($tmpfile);
     if (strstr($res[count($res) - 1], 'Password changed for user') !== false) {
         return PASSWORD_SUCCESS;
     } else {
         rcube::raise_error(array('code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Password plugin: Unable to execute {$cmd}"), true, false);
     }
     return PASSWORD_ERROR;
 }
开发者ID:yozhi,项目名称:YetiForceCRM,代码行数:22,代码来源:smb.php

示例5: save

 function save($curpass, $passwd)
 {
     $rcmail = rcmail::get_instance();
     $poppassd = new Net_Socket();
     $port = $rcmail->config->get('password_pop_port', 106);
     $host = $rcmail->config->get('password_pop_host', 'localhost');
     $host = rcube_utils::parse_host($host);
     $result = $poppassd->connect($host, $port, null);
     if (is_a($result, 'PEAR_Error')) {
         return $this->format_error_result(PASSWORD_CONNECT_ERROR, $result->getMessage());
     }
     $result = $poppassd->readLine();
     if (!preg_match('/^2\\d\\d/', $result)) {
         $poppassd->disconnect();
         return $this->format_error_result(PASSWORD_ERROR, $result);
     }
     $poppassd->writeLine("user " . $_SESSION['username']);
     $result = $poppassd->readLine();
     if (!preg_match('/^[23]\\d\\d/', $result)) {
         $poppassd->disconnect();
         return $this->format_error_result(PASSWORD_CONNECT_ERROR, $result);
     }
     $poppassd->writeLine("pass " . $curpass);
     $result = $poppassd->readLine();
     if (!preg_match('/^[23]\\d\\d/', $result)) {
         $poppassd->disconnect();
         return $this->format_error_result(PASSWORD_ERROR, $result);
     }
     $poppassd->writeLine("newpass " . $passwd);
     $result = $poppassd->readLine();
     $poppassd->disconnect();
     if (!preg_match('/^2\\d\\d/', $result)) {
         return $this->format_error_result(PASSWORD_ERROR, $result);
     }
     return PASSWORD_SUCCESS;
 }
开发者ID:jimjag,项目名称:roundcubemail,代码行数:36,代码来源:poppassd.php

示例6: start

 /**
  * Loads configuration, initializes plugin (including sieve connection)
  */
 function start($mode = null)
 {
     // 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')));
     // Get connection parameters
     $host = $this->rc->config->get('managesieve_host', 'localhost');
     $port = $this->rc->config->get('managesieve_port');
     $tls = $this->rc->config->get('managesieve_usetls', false);
     $host = rcube_utils::parse_host($host);
     $host = rcube_utils::idn_to_ascii($host);
     // remove tls:// prefix, set TLS flag
     if (($host = preg_replace('|^tls://|i', '', $host, 1, $cnt)) && $cnt) {
         $tls = true;
     }
     if (empty($port)) {
         $port = getservbyname('sieve', 'tcp');
         if (empty($port)) {
             $port = self::PORT;
         }
     }
     $plugin = $this->rc->plugins->exec_hook('managesieve_connect', array('user' => $_SESSION['username'], 'password' => $this->rc->decrypt($_SESSION['password']), 'host' => $host, 'port' => $port, 'usetls' => $tls, 'auth_type' => $this->rc->config->get('managesieve_auth_type'), '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();
         // reset current script when entering filters UI (#1489412)
         if ($this->rc->action == 'plugin.managesieve') {
             $this->rc->session->remove('managesieve_current');
         }
         if ($mode != 'vacation') {
             if (!empty($_GET['_set']) || !empty($_POST['_set'])) {
                 $script_name = rcube_utils::get_input_value('_set', rcube_utils::INPUT_GPC, true);
             } else {
                 if (!empty($_SESSION['managesieve_current'])) {
                     $script_name = $_SESSION['managesieve_current'];
                 }
             }
         }
         if ($script_name === null || $script_name === '') {
             // 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');
                 rcube::raise_error(array('code' => 403, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Unable to connect to managesieve on {$host}:{$port}"), true, false);
                 break;
             default:
                 $this->rc->output->show_message('managesieve.filterunknownerror', 'error');
                 break;
         }
         // reload interface in case of possible error when specified script wasn't found (#1489412)
         if ($script_name !== null && !empty($list) && !in_array($script_name, $list)) {
             $this->rc->output->command('reload', 500);
         }
         // 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->init_script();
         $this->rc->output->set_env('currentset', $this->sieve->current);
         $_SESSION['managesieve_current'] = $this->sieve->current;
     }
     return $error;
 }
开发者ID:zamentur,项目名称:roundcube_ynh,代码行数:99,代码来源:rcube_sieve_engine.php

示例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)
 {
     $rcube = rcube::get_instance();
     // disconnect/destroy $this->conn
     $this->disconnect();
     // reset error/response var
     $this->error = $this->response = null;
     // let plugins alter smtp connection config
     $CONFIG = $rcube->plugins->exec_hook('smtp_connect', array('smtp_server' => $host ? $host : $rcube->config->get('smtp_server'), 'smtp_port' => $port ? $port : $rcube->config->get('smtp_port', 25), 'smtp_user' => $user ? $user : $rcube->config->get('smtp_user'), 'smtp_pass' => $pass ? $pass : $rcube->config->get('smtp_pass'), 'smtp_auth_cid' => $rcube->config->get('smtp_auth_cid'), 'smtp_auth_pw' => $rcube->config->get('smtp_auth_pw'), 'smtp_auth_type' => $rcube->config->get('smtp_auth_type'), 'smtp_helo_host' => $rcube->config->get('smtp_helo_host'), 'smtp_timeout' => $rcube->config->get('smtp_timeout'), 'smtp_auth_callbacks' => array()));
     $smtp_host = rcube_utils::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_utils::idn_to_ascii($smtp_host);
     $this->conn = new Net_SMTP($smtp_host, $smtp_port, $helo_host);
     if ($rcube->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', $rcube->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_utils::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;
 }
开发者ID:netcon-source,项目名称:roundcubemail,代码行数:98,代码来源:rcube_smtp.php

示例8: get_hostlist

 /**
  * Return a list with all imap hosts configured
  *
  * @return array Clean list with imap hosts
  */
 public function get_hostlist()
 {
     $default_hosts = (array) $this->getprop('default_host');
     $out = array();
     foreach ($default_hosts as $key => $name) {
         if (!empty($name)) {
             $out[] = rcube_utils::parse_host(is_numeric($key) ? $name : $key);
         }
     }
     return $out;
 }
开发者ID:jimjag,项目名称:roundcubemail,代码行数:16,代码来源:rcmail_install.php

示例9: rcube_parse_host

function rcube_parse_host($name, $host = '')
{
    return rcube_utils::parse_host($name, $host);
}
开发者ID:noikiy,项目名称:roundcubemail,代码行数:4,代码来源:bc.php

示例10: array

    if (preg_match('/^' . $RCI->email_pattern . '$/i', $from) && preg_match('/^' . $RCI->email_pattern . '$/i', $to)) {
        $headers = array('From' => $from, 'To' => $to, 'Subject' => 'Test message from Roundcube');
        $body = 'This is a test to confirm that Roundcube can send email.';
        // send mail using configured 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);
        $head = $mail_object->txtHeaders($send_headers);
        $SMTP = new rcube_smtp();
        $SMTP->connect(rcube_utils::parse_host($RCI->getprop('smtp_server')), $RCI->getprop('smtp_port'), $CONFIG['smtp_user'], $CONFIG['smtp_pass']);
        $status = $SMTP->send_mail($headers['From'], $headers['To'], $head, $body);
        $smtp_response = $SMTP->get_response();
        if ($status) {
            $RCI->pass('SMTP send');
        } else {
            $RCI->fail('SMTP send', join('; ', $smtp_response));
        }
    } else {
        $RCI->fail('SMTP send', 'Invalid sender or recipient');
    }
    echo '</p>';
}
?>

<table>
开发者ID:jimjag,项目名称:roundcubemail,代码行数:31,代码来源:test.php

示例11: rcube_parse_host

function rcube_parse_host($name, $host = '')
{
    _deprecation_warning(__FUNCTION__);
    return rcube_utils::parse_host($name, $host);
}
开发者ID:JotapePinheiro,项目名称:roundcubemail,代码行数:5,代码来源:bc.php

示例12: _startup

 protected function _startup()
 {
     $rcmail = rcube::get_instance();
     if (!$this->sieve) {
         // Add include path for internal classes
         $include_path = $this->home . '/lib' . PATH_SEPARATOR;
         $include_path .= ini_get('include_path');
         set_include_path($include_path);
         // try to connect to managesieve server and to fetch the script
         $this->sieve = new rcube_sieve($_SESSION['username'], $rcmail->decrypt($_SESSION['password']), rcube_utils::idn_to_ascii(rcube_utils::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), $rcmail->config->get('sieverules_conn_options', 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 ($this->_get_rule_file($rcmail->config->get('sieverules_default_file')) || sizeof($this->sieve->list) > 0) {
                 $rcmail->overwrite_action('plugin.sieverules.setup');
                 $this->action = 'plugin.sieverules.setup';
             }
             // 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
             $this->examples = $this->_get_rule_file($rcmail->config->get('sieverules_example_file'), true);
         }
     } else {
         $this->sieve->set_ruleset($this->current_ruleset);
         $this->script = $this->sieve->script->as_array();
     }
 }
开发者ID:Kofl,项目名称:Roundcube-Plugin-SieveRules-Managesieve,代码行数:47,代码来源:sieverules.php

示例13: _connect

 /**
  * Establish a connection to the LDAP server
  */
 private function _connect()
 {
     $rcube = rcube::get_instance();
     if (!function_exists('ldap_connect')) {
         rcube::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 = rcube_utils::idn_to_ascii(rcube_utils::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)) {
         rcube::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 = $rcube->decrypt($_SESSION['password']);
         }
         // Get the pieces needed for variable replacement.
         if ($fu = $rcube->get_user_name()) {
             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 {
                     rcube::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)) {
//.........这里部分代码省略.........
开发者ID:nmrugg,项目名称:roundcubemail,代码行数:101,代码来源:rcube_ldap.php

示例14: connect

 /**
  * Establish a connection to the LDAP server
  */
 public function connect($host = null)
 {
     if (!function_exists('ldap_connect')) {
         rcube::raise_error(array('code' => 100, 'type' => 'ldap', 'file' => __FILE__, 'line' => __LINE__, 'message' => "No ldap support in this installation of PHP"), true);
         return false;
     }
     if (is_resource($this->conn) && $this->config['host'] == $host) {
         return true;
     }
     if (empty($this->config['ldap_version'])) {
         $this->config['ldap_version'] = 3;
     }
     // iterate over hosts if none specified
     if (!$host) {
         if (!is_array($this->config['hosts'])) {
             $this->config['hosts'] = array($this->config['hosts']);
         }
         foreach ($this->config['hosts'] as $host) {
             if ($this->connect($host)) {
                 return true;
             }
         }
         return false;
     }
     // open connection to the given $host
     $host = rcube_utils::idn_to_ascii(rcube_utils::parse_host($host));
     $hostname = $host . ($this->config['port'] ? ':' . $this->config['port'] : '');
     $this->_debug("C: Connect to {$hostname} [{$this->config['name']}]");
     if ($lc = @ldap_connect($host, $this->config['port'])) {
         if ($this->config['use_tls'] === true) {
             if (!ldap_start_tls($lc)) {
                 return false;
             }
         }
         $this->_debug("S: OK");
         ldap_set_option($lc, LDAP_OPT_PROTOCOL_VERSION, $this->config['ldap_version']);
         $this->config['host'] = $host;
         $this->conn = $lc;
         if (!empty($this->config['network_timeout'])) {
             ldap_set_option($lc, LDAP_OPT_NETWORK_TIMEOUT, $this->config['network_timeout']);
         }
         if (isset($this->config['referrals'])) {
             ldap_set_option($lc, LDAP_OPT_REFERRALS, $this->config['referrals']);
         }
         if (isset($this->config['dereference'])) {
             ldap_set_option($lc, LDAP_OPT_DEREF, $this->config['dereference']);
         }
     } else {
         $this->_debug("S: NOT OK");
     }
     if (!is_resource($this->conn)) {
         rcube::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;
     }
     return true;
 }
开发者ID:bbspike,项目名称:sentora-core,代码行数:59,代码来源:rcube_ldap_generic.php

示例15: 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_utils::parse_host($this->prop['mail_domain']);
         }
     }
     if ($encode) {
         $domain = rcube_utils::idn_to_ascii($domain);
     }
     return $domain;
 }
开发者ID:jimjag,项目名称:roundcubemail,代码行数:25,代码来源:rcube_config.php


注:本文中的rcube_utils::parse_host方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。