Third Party Contributions > Old Style Plug-Ins

Multiple Domains Login

<< < (3/12) > >>

bpat1434:
It would need to go into index.php either replacing or AFTER you see the default $user = line.

bigpaw:

--- Quote from: coolant ---
I know I could of done it 50 different ways, but this way was easy and quick.



--- End quote ---

i downloaded roundcube version 0.1Beta2 about two months back...testing it with one domain first before i moved it over to the 100+ domains i host....a friend/workmate of mine (Luke Kyohere) did a quick hack on the index.php page and voila.....all the virtual domains i had were logging in with just the user id, without appending @domain.tld.... here is the modification (one of those 50 other ways ;) )

NOTE: all the domains i host are in the form mail.domain.tld


--- Code: ---
diff index.php.orig index.php
165,166c165,170
< if ($_action=='login' && $_task=='mail')
<  {
---
> // try to log in
>  if(isset($_POST['_user']) && $_action == 'login' && $_task == 'mail')
>   {
>    if($_SERVER['SERVER_NAME'] and !preg_match('/(.*)\@(.*)/',$_POST['_user'])){
>        $domain = preg_replace('/^(\w*)\./','',$_SERVER['SERVER_NAME']);
>        $_POST['_user'] = $_POST['_user'].&quot;@&quot;.$domain;
>    }


--- End code ---

Jonn3:
Wouldn't this cause trouble if for some reason there are two equal usernames with different domains?
For example john@domain1.com, john@domain2.com

As it most likely is to cause trouble, there would be no way to get around this without entering @domain.com right?

bpat1434:
It could cause trouble; however, if you have webmail.domain.com point to an IP of where RC is, and webmail.domain2.com point to the same IP of where RC is, then you could conceivably use $_SERVER['HTTP_HOST'], wipe out the 'webmail.' portion, and tack that on. Now, that's not to say it's full-proof. The only full-proof plan is to use the array that's set up in the main.inc.php file, or use multiple installations that could use the same database.

Insanity5902:
Here is what I do, and it seems to have worked so far.

In my main.inc.php, I set the default_host to use localhost:993, then set username_domain as follows


--- Code: (config/main.inc.php) ---$tempDomain = array_reverse(explode(".",$_SERVER['HTTP_HOST']));
$rcmail_config['username_domain'] = $tempDomain[1].".".$tempDomain[0];
--- End code ---

This creates an array in tempDomain with each portion of the domain used to get there has a node, and by reversing it, it puts the TLD in position 0, so postions 1 is the root domain. As long as you don't use log domain e-mail addresses (e.g. user@mail.cs.utexas.edu), then you shouldn't have a problem.

Now if the user logs in with their full e-mail address then roundcube ignores the default domain, and if they don't then it grabs it from the address they used to get there. So you could have http://www.webmail.domain.com, and it would append domain.com to the user name if they don't put one on there.

The other beauty of this setup is that the default Roundcube install does all the work, we are just using what was given to us by the Developers.

The last thing I do, just to make things obvious to the user is to add a small section during the login screen. This is in program/include/main.inc


--- Code: (program/include/main.inc) ---$labels[user]
$fields[user]




@$CONFIG[username_domain]


$labels[pass]
$fields[pass]
--- End code ---

This just adds the detected username_domain under the username field.

You can see what this looks like at http://mail.routedtechnologies.com/roundcube/. You can see the change of domain name by going to http://mail.rsatechnology.net/roundcube/

I think this setup is pretty much fool proof, if someone sees a flaw it please let me know.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version