Author Topic: Not functioning include_host_config  (Read 12279 times)

Offline ricardo777

  • Jr. Member
  • **
  • Posts: 23
Not functioning include_host_config
« on: February 18, 2016, 03:10:49 PM »
Hello,

As the title says I do not get the function include_host_config to work.

I have tried almost everything like using many hostnames and checking the hostname in the mysql database without success.

The option include_host_config does not work for me.

Using 1.2 beta release.

Does someone know a solution, it looks like the include_host_config ignores and do not use the file I have set like:

Code: [Select]
$config['include_host_config'] = array(
  'mail.domain.nl' => 'filename.inc.php',
    'domain.nl' => 'filename.inc.php'
//);

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,845
Re: Not functioning include_host_config
« Reply #1 on: February 19, 2016, 02:54:14 AM »
those lines are linvalid and would generate a php error but i'm going to assume thats a typo in your post rather than in the config.

the array keys you are using. are they the host name part of the url that you use to access roundcube?
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more…

Offline ricardo777

  • Jr. Member
  • **
  • Posts: 23
Re: Not functioning include_host_config
« Reply #2 on: February 19, 2016, 03:09:03 AM »
Thank you for the reply.

Sorry I had comment out the whole 3 lines but forgot 1 line to remove the // when posting this is the correct lines

Code: [Select]
$config['include_host_config'] = array(
  'mail.domain.nl' => 'filename.inc.php',
    'domain.nl' => 'filename.inc.php'
);

I have also tried using include host config true and created the host name config files but that options did not worked also.

I am failing to understand why it does not work.

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,845
Re: Not functioning include_host_config
« Reply #3 on: February 19, 2016, 05:34:13 AM »
please double check that the file permissions on your config files are correct, that PHP can read them.

else I think you might have to dig around in program/lib/Roundcube/rcube_config.php to see why it isnt loading them because it does not log errors for that. There are 2 functions in there: load_host_config and then right after it load_from_file which do the work.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more…

Offline ricardo777

  • Jr. Member
  • **
  • Posts: 23
Re: Not functioning include_host_config
« Reply #4 on: February 19, 2016, 11:40:26 AM »
Hello,

I see in the code that it merges the config files, is it not a replace thingy?

Meaning when a same config is in the master config and also in the host name config which config options is choosen?

Also file permission is set correctly I have checked it.

Only thing I can think is that it merges and it takes the master file instead of hostname config, I need to check this.

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,845
Re: Not functioning include_host_config
« Reply #5 on: February 20, 2016, 01:38:35 AM »
Quote
Meaning when a same config is in the master config and also in the host name config which config options is choosen?

you do not need to repeat the options in both files. in the host config file you only put what is different from the main one.

one does not replace the other, they are combined. say for example in your main config file you have product_name set to `my webmail` but when people use a certain url you want the name to come up as `company webmail` then you'd add a host config file and put set product_name equal to `company webmail` in it.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more…

Offline ricardo777

  • Jr. Member
  • **
  • Posts: 23
Re: Not functioning include_host_config
« Reply #6 on: February 20, 2016, 11:10:18 AM »
Hello,

Thank you for the help.

I have tested some things but it still do not work I have this in the hostname config:

Code: [Select]
<?php

// ----------------------------------
// IMAP
// ----------------------------------
// The mail host chosen to perform the log-in.
// Leave blank to show a textbox at login, give a list of hosts
// to display a pulldown menu or set one host as string.
// To use SSL/TLS connection, enter hostname with prefix ssl:// or tls://
// Supported replacement variables:
// %n - hostname ($_SERVER['SERVER_NAME'])
// %t - hostname without the first part
// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part)
// %s - domain name after the '@' from e-mail address provided at login screen
// For example %n = mail.domain.tld, %t = domain.tld
// WARNING: After hostname change update of mail_host column in users table is
//          required to match old user data records with the new host.
$config['default_host'] = 'ssldomaintest.%s';

I have also a option default_host in the main config file for all the other domains.

I want to use default_host on 1 domain only for te right ssl hostname but I do not get include_host_config to function.

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,845
Re: Not functioning include_host_config
« Reply #7 on: February 21, 2016, 02:57:55 AM »
can i please check 1 thing:

Code: [Select]
$config['default_host'] = 'ssldomaintest.%s';
the default_host config option holds the address of your IMAP server not the address of your Roundcube installation. Its the server that Roundcube connects to to get your mail.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more…

Offline ricardo777

  • Jr. Member
  • **
  • Posts: 23
Re: Not functioning include_host_config
« Reply #8 on: February 21, 2016, 03:49:38 AM »
I used that for that for testing I have one domain that uses 1 other server for connection the issue that I have is:

Now it connects via mail.hostname

But I want to use SSL the server uses ssl with another hostname so php imap and smtp would not let me connect because the host name is not corresponding with the SSL certificate.

I wanted to use another config file for the domain and set the right imap and smtp hostname that correspond with the right ssl domain and hostname so I can connect. At the moment I am now connection without ssl because it does not work with.

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,845
Re: Not functioning include_host_config
« Reply #9 on: February 21, 2016, 04:09:40 AM »
Cool. Just had to double check.

I think then you have to go back to the code in rcube_config and add some debug lines to identify why your host config file is not being read. You can use `rcube::write_log('debug', 'my message...');`
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more…

Offline ricardo777

  • Jr. Member
  • **
  • Posts: 23
Re: Not functioning include_host_config
« Reply #10 on: February 21, 2016, 04:38:59 AM »
Will try it out, my php skills are not very great :-X

Also I now see you are from the contextmenu plugin, great ;)

Offline ricardo777

  • Jr. Member
  • **
  • Posts: 23
Re: Not functioning include_host_config
« Reply #11 on: February 21, 2016, 04:46:48 AM »
I have changed the config to:

Code: [Select]
    /**
     * Load a host-specific config file if configured
     * This will merge the host specific configuration with the given one
     */
    private function load_host_config()
    {
        if (empty($this->prop['include_host_config'])) {
            return;
        }

        foreach (array('HTTP_HOST', 'SERVER_NAME', 'SERVER_ADDR') as $key) {
            $fname = null;
            $name  = $_SERVER[$key];
rcube::write_log('debug', 'loadhost');

            if (!$name) {
                continue;
rcube::write_log('debug', 'loadhost');
            }

            if (is_array($this->prop['include_host_config'])) {
                $fname = $this->prop['include_host_config'][$name];
rcube::write_log('debug', 'loadhost');
            }
            else {
                $fname = preg_replace('/[^a-z0-9\.\-_]/i', '', $name) . '.inc.php';
rcube::write_log('debug', 'loadhost');
            }

            if ($fname && $this->load_from_file($fname)) {
                return;
rcube::write_log('debug', 'loadhost');
            }
        }
    }

The only thing in the debug file is:

Code: [Select]
[21-Feb-2016 10:42:56 +0100]: loadhost[/code
 No error or anything else.

Am I doing it incorrectly?

Offline ricardo777

  • Jr. Member
  • **
  • Posts: 23
Re: Not functioning include_host_config
« Reply #12 on: February 21, 2016, 05:22:17 AM »
Sorry for the third reply.

I have updated to the latest github version without solution.

I have test rcube::write_log('debug', 'loadhost'); per function if etc..

I looks like the function is running I can see al the debug per function.

Wich hostname I need to use for the domain is it:

mail.domain.nl
or only the domain?

now I use both but is still does not work.

I have checked the table: users>mail_host and that is correct and is in the load_config array.

I also removed the user in the users table but still is uses the standard mail_host and not the one in the hostname config file.

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,845
Re: Not functioning include_host_config
« Reply #13 on: February 21, 2016, 05:23:42 AM »
first i'd change that first log line to `rcube::write_log('debug', $name);` so you can see what its actually looking for. that $name should match a key in your host file config array
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more…

Offline ricardo777

  • Jr. Member
  • **
  • Posts: 23
Re: Not functioning include_host_config
« Reply #14 on: February 21, 2016, 05:32:43 AM »
Hello,

Firstly thank you help really appreciate it.

I have changed it and this is the output:

Code: [Select]
[21-Feb-2016 11:30:57 +0100]: mail.roundcubeinstallation.nl
[21-Feb-2016 11:30:57 +0100]: IP of the roundcubeinstallation

I have changed the domain and IP