Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 3 > Tips/Tricks/Mods

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 5th February 2013, 16:17
arty.lv arty.lv is offline
Junior Member
 
Join Date: Feb 2013
Posts: 1
Thanks: 0
Thanked 1 Time in 1 Post
Default Roundcube 0.8.5 login mod for ISPconfig

Hi,

I've made a little mod for roundcube, that would be very useful on ispconfig servers.. My original post: http://www.arty.lv/?p=24

Many of virtual hosting providers are using Roundcube webmail, but it lacks one very useful feature for multiple domains on single server – automatic domain completion in login form. Every user needs to use full e-mail address as login name, and this is very annoying for long domain names… So here is my solution:

1: ) Apache configuration.

I’m assuming you are using alias for every domain to access one single webmail (in case you are not, this patch does not make any use). This is how Apache virtual host should look like:

<VirtualHost *:80>
DocumentRoot /var/www/webmail
ServerName mail.maindomain.lv
ServerAlias mail.domain1.lv mail.domain2.lv mail.*.*
</VirtualHost>

This means every user can access his webmail on “mail” subdomain.

2: ) Setting up roundcube.

I will not go through the Roundcube webmail setup steps. You can find it here: http://trac.roundcube.net/wiki/Howto_Install

Just make sure, there is only one imap host defined in main.inc.php (can be other than localhost) or else there is a better way to map domain to username:

$rcmail_config['default_host'] = 'localhost';

3: ) Roundcube Modifications.

First we need to add a new field to login form for domain. Edit file ./program/include/rcube_template.php. Add folowing line inside “private function loginform($attrib)” function. I placed it between “$input_user = …” and “$input_pass = … ” to maintain the correct order according to login form.

$input_domain = new html_inputfield(array('name' => '_domain', 'id' => 'username_domain') + $attrib);

Next, add folowing lines between “ $table->add(‘input’, $input_user->show(get_input_value(‘_user’, RCUBE_INPUT_GPC)));” and “$table->add(‘title’, html::label(‘rcmloginpwd’, Q(rcube_label(‘password’))));” lines:

$hostStr = $_SERVER['HTTP_HOST'];
$wPos = strPos($hostStr, '.')+1;

$input_domain = new html_inputfield(array('name' => '_domain', 'id' => 'rcmlogindomain', 'value' => substr($hostStr,$wPos))
+ $attrib + $host_attrib);

$table->add('title', html::label('rcmloginuser', Q(rcube_label('atsymbol'))));
$table->add('input', $input_domain->show(get_input_value('_domain', RCUBE_INPUT_GPC)));

Next, add folowing line to your default localization file. In my case its ./program/localization/en_US/labels.inc:

$labels['atsymbol'] = '@';

Save file, and check out your new login page it should look like this:



loginscreenWith automatically filled domain field for every domain (http://mail.domain1.com will show “domain1.com”, http://mail.domain2.com will show “domain2.com” etc.).

Ok, one more thing to do – we need to make roundcube to get this variable and add it to username. Edit file “./index.php” – add folowing between “ ’user’ => trim(get_input_value(‘_user’, RCUBE_INPUT_POST)),” and “‘pass’ => get_input_value(‘_pass’, RCUBE_INPUT_POST, true,” lines:

'username_domain' => trim(get_input_value('_domain', RCUBE_INPUT_POST)),

Next add folowing right before “// Login” line:

if (!($auth['username_domain'])){
$loginvards = $auth['user'];
}else{
$loginvards = $auth['user'] . "@" . $auth['username_domain'];
}

Final thing – replace folowing line “$RCMAIL->login($auth[user], $auth['pass'], $auth['host'], $auth['cookiecheck'])” with this one:

$RCMAIL->login($loginvards, $auth['pass'], $auth['host'], $auth['cookiecheck'])

4: ) Enjoy!

Now every user should be able to log in with his username only, when accessing webmail on his subdomain. You can also manually modify this field and type in a different domain or even leave it blank and log in using full e-mail address as username!

Please feel free to leave any comments or suggestions, and keep in mind, that I’m not a php programmer, so there could be some other (or better) way to achieve this.
Reply With Quote
The Following User Says Thank You to arty.lv For This Useful Post:
onastvar (6th February 2013)
Sponsored Links
  #2  
Old 12th March 2013, 12:59
Horfic Horfic is offline
Senior Member
 
Join Date: Mar 2009
Location: Austria
Posts: 324
Thanks: 55
Thanked 93 Times in 58 Posts
Send a message via Skype™ to Horfic
 
Default

I wouldn't recommend to do this your way. Roundcube can easily be modified with plugins in pretty much everyway. So modifing the source code of roundcube itself is a no go.

I would recommend you to create domain specific files, which roundcube can handle or to use the roundcube user autocompletion.
__________________
web wack creations - We create your custom web application
Mailuser interface for ISPConfig 3
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
postfix problems kwickcut Installation/Configuration 6 5th March 2012 19:19
Fail2ban configuration Captain Installation/Configuration 2 28th June 2011 19:48
F11 courier-imap fails. Nachogrande General 6 1st November 2010 17:55
squirrelmail and postfix witoszek General 12 1st December 2009 18:07
Postfix can't received email from exterior astra2000 Server Operation 5 17th October 2009 23:26


All times are GMT +2. The time now is 02:22.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.