Author Topic: Custom Logos and Welcome Text based on domain name.  (Read 14655 times)

Offline Gus

  • Jr. Member
  • **
  • Posts: 16
Custom Logos and Welcome Text based on domain name.
« on: August 08, 2007, 11:24:30 AM »
Folks,

i've customised a few of the pages to allow me to display different welcome text and logos depending on which domain is being used in the URL; i have several domains running from a single roundcube instance and my customers now get their own custom logos when they login

If anyone is interested, i'll post the code changes.

Cheers

Gus

Offline oldschool

  • Sr. Member
  • ****
  • Posts: 406
Re: Custom Logos and Welcome Text based on domain name.
« Reply #1 on: August 08, 2007, 04:11:44 PM »
Yes, i am very interested.

 :)

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,489
    • http://SKaero.com/
Re: Custom Logos and Welcome Text based on domain name.
« Reply #2 on: August 08, 2007, 10:27:00 PM »
Yes this sounds great! :D

Offline Gus

  • Jr. Member
  • **
  • Posts: 16
Re: Custom Logos and Welcome Text based on domain name.
« Reply #3 on: August 09, 2007, 07:23:26 AM »
OK, there are 2 ways to do this.

The first way is to edit each of the files which contain the branding logos/text, these are:

main.inc.php - the welcome text and window titles.
login.html - the login logo
header.html - the logo in the top left of all screens after login.

Each file is edited to first check the domain via javascript, then pick an IMG or text to show based on the result.... but i've realised a far far better way.

Just do this.
(i have several domains named, webmail.domain1.com, webmail.domain2.com etc. All pointing to the the same virtual area on my hosting account, an all reference a single instance of roundcube, single mysql etc.)

Edit the main.inc.php file, and put the following at the start:

Code: [Select]
function getDomain() {
$host=$_SERVER['HTTP_HOST'];
$prefix='webmail';
$arr=explode('.',$host);
if ($arr[0]==$prefix) { unset($arr[0]); $host=implode('.',$arr); }
else { $host=''; }
return $host;
}

I've then added this:
Code: [Select]
$rcmail_config['username_domain'] = getDomain();to allow my users to only use their ID and not the full email address.

then
Code: [Select]
// relative path to the skin folder
$rcmail_config['skin_path'] = 'skins/default/';
if (getDomain()=='domain1.com') {
$rcmail_config['skin_path'] = 'skins/domain1'; }
if (getDomain()=='domain2.com') {
$rcmail_config['skin_path'] = 'skins/domain2'; }
to force a skin based on the domain name.

then
Code: [Select]
// use this name to compose page titles
$rcmail_config['product_name'] = 'WebMail';
if (getDomain()=='domain1.com') { $rcmail_config['product_name']='domain1.com WebMail text'; }
if (getDomain()=='domain2.com') { $rcmail_config['product_name']='domain2.com WebMail text'; }
to change the welcome text at login based on the domain name.

and thats it.

let me know how you get on, it seems to work fine with my setup.


Offline Julio

  • Newbie
  • *
  • Posts: 1
Custom Logos and Welcome Text based on domain name.
« Reply #4 on: June 04, 2009, 02:13:42 PM »
Not sure if it's a version change but I had to alter the variable names to:

// relative path to the skin folder
$rcmail_config['skin'] = 'default';
if (getDomain()=='domain1.com') {
$rcmail_config['skin'] = 'domain1folder'; }
if (getDomain()=='domain2.com') {
$rcmail_config['skin'] = 'domain2folder'; }

Thanks for posting the tip, works a treat

Offline snookey

  • Newbie
  • *
  • Posts: 3
New version ... is this any different ?
« Reply #5 on: November 16, 2009, 11:37:04 PM »
I've been trying to get this little bit of code working ... I'm on the latest version of roundcube 0.3.1 - I don't actually get any error messages ; but nothing happens and neither does the new skins folder appears nor does the code pass the welcome message to the selected domain in the code ...

Could it be that this code needs some sort of change having been done a few months back ? It's listed below ... I've just changed the actual domain name to mydomain.co.uk


--------------------------------------------------------------------------

function getDomain() {
   $host=$_SERVER['HTTP_HOST'];
   $prefix='webmail';
   $arr=explode('.',$host);
   if ($arr[0]==$prefix) { unset($arr[0]); $host=implode('.',$arr); }
   else { $host=''; }
   return $host;
}


$rcmail_config['username_domain'] = getDomain();


// relative path to the skin folder

// relative path to the skin folder
$rcmail_config['skin'] = 'default';
if (getDomain()=='mydomain.co.uk') {
$rcmail_config['skin'] = 'mydomain1folder'; }
if (getDomain()=='mydomain2.co.uk') {
$rcmail_config['skin'] = 'mydomain2folder'; }


// use this name to compose page titles


$rcmail_config['product_name'] = 'WebMail';
if (getDomain()=='mydomain.co.uk') { $rcmail_config['product_name']='welcome to mydomain.co.uk Webmail'; }
if (getDomain()=='mydomain2.co.uk') { $rcmail_config['product_name']='Welcome to mydomain2.co.uk Webmail'; }


--------------------------------------------------------------------------

thanks for looking !

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,489
    • http://SKaero.com/
Custom Logos and Welcome Text based on domain name.
« Reply #6 on: November 16, 2009, 11:53:45 PM »
Are you using webmail.mydomain.co.uk?

Offline snookey

  • Newbie
  • *
  • Posts: 3
Custom Logos and Welcome Text based on domain name.
« Reply #7 on: November 17, 2009, 07:42:30 AM »
Yes, I am using webmail.mydomain.co.uk

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,489
    • http://SKaero.com/
Custom Logos and Welcome Text based on domain name.
« Reply #8 on: November 17, 2009, 08:03:52 AM »
What the output when you add:
echo getDomain();

Offline snookey

  • Newbie
  • *
  • Posts: 3
GetDomain not working
« Reply #9 on: November 17, 2009, 08:39:15 PM »
I've tried all sorts of variations to the code already posted and I just do not get any results ... I tried to narrow down the problem by creating this little script, and as suggested (thanks) put the echo getdomain line in ... nothing shows up !

--------------------------------------------------------------------------

function GetDomain($url)
 {
   $nowww = ereg_replace('www.','',$url);
   $domain = parse_url($nowww);
   if(!empty($domain["host"]))
   {
       return $domain["host"];
   } else
   {
        return $domain["path"];
   }

  }

echo GetDomain($url);


?>

------------------------------------------------------------------------

... Could my server have disabled certain featrures ?
Or is there some settings in phpadmin I need to look at ... Thanks for your interest

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,489
    • http://SKaero.com/
Custom Logos and Welcome Text based on domain name.
« Reply #10 on: November 20, 2009, 04:34:33 AM »
When your putting it into your /config/main.inc.php are you putting in the ""