Gossamer Forum
Home : Products : Gossamer Mail : Discussion :

avoiding domains to use some templates

Quote Reply
avoiding domains to use some templates
Hello,

I would like to know if there is anyway to allow only some domains to use a template.

I mean, let's supose I create a very nice template specially for a domain using GM. But, this template could be used for any other domain also using GM. How could I avoid it?

Thanks a lot,

Narcís Vilà
Quote Reply
Re: [narcis] avoiding domains to use some templates In reply to
Hi,

Hmm, you could embed something in the template, or add a global tag:

domain_check =>
Code:
sub {
my $tags = shift;
if ($ENV{HTTP_HOST} ne 'goodhost.com') {
return 'some html here';
}
}

and then put <%domain_check%> in your good templates.

You could make 'some html here' be a meta refresh tag to a login page or something similiar.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] avoiding domains to use some templates In reply to
Hello Alex!

For all the good ideas you have been "thoughtfully spilling" everywhere, isnt there a way to intergrate all of them in the installation itself as "tips and tricks"?

Its like a treasure hunt in your forums :)

Thanks


Quote Reply
Re: [rajani] avoiding domains to use some templates In reply to
Hi,

Bruce is doing this for Links SQL now, and will start on Gossamer Mail afterwards.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] avoiding domains to use some templates In reply to
Hi!

Brilliant!

Three Cheers,


Quote Reply
Re: [Alex] avoiding domains to use some templates In reply to
Hello Alex,

I've tried it, but I can't get it work. That's what I wanted and what I've done.

I wanted to protect templates from domain1.com to be used from any other domains using GM.

So I created a global tag named domain_check with the code below.
-------------
sub {
my $tags = shift;
if ($ENV{HTTP_HOST} ne 'domain1.com') {
return '<meta http-equiv="refresh" content="0;URL=http://www.domain.com">';
}
-------------

Then I inserted <%domain_check%> to the head of the template and accessed to GM using a domain diferent from domain1.com (also tried it inserting it to the body). Then I got this piece of text in the body: <meta http-equiv="refresh" content="0;URL=http://www.domain.com>, but nothing happened.

Then I tried accessing it with domain1.com, but I got the same piece of code.

Please, could you give me a hand?

Thanks a lot,

Narcís Vilà


Post deleted by RedRum In reply to

Last edited by:

RedRum: Nov 1, 2001, 11:30 AM
Quote Reply
Re: [narcis] avoiding domains to use some templates In reply to
Hi,

I may have the environment variable wrong, Try changing that to:

sub {
my $tags = shift;
return "Host: '$ENV{HTTP_HOST}'";
}

and check to see what the host is on the domain you want to protect, and what it is on the other domains. Hopefully they should be different and you can just update my first example.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] avoiding domains to use some templates In reply to
Thanks both, for your fast response :-)

I tried it and I get the same host. All domains using GM are hosted in my server, and they use a shared IP. However, I get the host IP where I have GM installed, not the IP of the domains using GM.

I don't know much (almost anything about programming), but wouldn't it be better to check which domain user is using?

I mean using a code like:

sub {
my $tags = shift;
if (<%domain%> ne 'domain1.com') {
return '<meta http-equiv="refresh" content="5;URL=http://www.domain.net">';
}
}

However, I tried it and it doesn't work, the page is also refreshed when I use domain1.com

Thanks a lot,

Narcís Vilà
Quote Reply
Re: [narcis] avoiding domains to use some templates In reply to
You can't use <%domain%> as the code in the sub is perl and <%domain%> is an internal Links SQL tag so it would cause problems.

Last edited by:

RedRum: Nov 1, 2001, 12:03 PM
Quote Reply
Re: [RedRum] avoiding domains to use some templates In reply to
Then how can I protect the use of templates if the IP host are the same and this is not a valid tag?

Thanks
Quote Reply
Re: [narcis] avoiding domains to use some templates In reply to
Sorry, I meant the tag itself can't be used within perl code, not that it is an invalid tag.

Do you know what your exact HTTP HOST is?


Quote Reply
Re: [RedRum] avoiding domains to use some templates In reply to
I meant this Tongue

I've just replied to your e-mail Smile
Quote Reply
Re: [narcis] avoiding domains to use some templates In reply to
I didn't send an email. I'm confused. Blush
Quote Reply
Re: [RedRum] avoiding domains to use some templates In reply to
I meant I sent you an e-mail :-)
Quote Reply
Re: [narcis] avoiding domains to use some templates In reply to
Ah ok I got it :)

Try:

Code:
sub {
my $tags = shift;
if ($ENV{HTTP_HOST} ne '209.61.197.20') {
return '<meta http-equiv="refresh" content="5;URL=http://www.domain.net">';
}
}

As it is an IP you may need != instead of ne

I'm still not sure that is right though.

Last edited by:

RedRum: Nov 1, 2001, 12:31 PM
Quote Reply
Re: [RedRum] avoiding domains to use some templates In reply to
but the problem is that the host IP is the same for any domain using GM because $ENV{HTTP_HOST} gets the IP where GM is runing. So independently of which domain I use I allways get the same IP.

As I said don't know much about programming, but what about a javascript? I supose <%domain%> wouldn't be an invalid tag, wouldn't it?

Thanks a lot Redrum Smile
Quote Reply
Re: [narcis] avoiding domains to use some templates In reply to
How about using SERVER_ADMIN instead of HTTP_HOST?

Last edited by:

RedRum: Nov 1, 2001, 1:03 PM
Quote Reply
Re: [RedRum] avoiding domains to use some templates In reply to
Hello RedRum,
I've just tried it but the problem is that I get the admin e-mail of the server where I have GM installed, I don't get the admin e-mail of the domains using GM domains.

The main problem I have is that using this variables I only get information about the server where I run GM, I can't get information about the domains using GM.

Thanks a lot,

Narcís


Quote Reply
Re: [narcis] avoiding domains to use some templates In reply to
If they are virtualhosts you can make each SERVER_ADMIN unique.
Quote Reply
Re: [RedRum] avoiding domains to use some templates In reply to
Yes I know I can do it, in fact I have different e-mails for each one. But I don't get the e-mail admin of each domain, I get the e-mail admin of the domain where I run GM.
Quote Reply
Re: [narcis] avoiding domains to use some templates In reply to
I'm really sorry....I don't understand.

>>But I don't get the e-mail admin of each domain<<

Which domains?

>>I get the e-mail admin of the domain where I run GM.<<

I thought that's what you wanted?

Oh I feel dumb :(

Last edited by:

RedRum: Nov 2, 2001, 11:54 AM
Quote Reply
Re: [RedRum] avoiding domains to use some templates In reply to
>>But I don't get the e-mail admin of each domain<<

I mean the domains using GM. The domains being used for e-mail addresses.


>>I get the e-mail admin of the domain where I run GM.<<

What I want is the e-mail of the domains being used for e-mail addresses. Otherwise, the script you told me won't work because I always get the same output.

Really thanks for your help and patience Smile


Quote Reply
Re: [narcis] avoiding domains to use some templates In reply to
Ah ok....

Well using HTTP_HOST should work then as it will cover all domains if they are on the same server.

I'm not sure why it isn't working for you. I'm afraid I'll have to let Alex or another staff member help you as I've run out of ideas.

Sorry. Unsure

Last edited by:

RedRum: Nov 2, 2001, 1:54 PM
Quote Reply
Re: [RedRum] avoiding domains to use some templates In reply to
It works okay, your solution also worked. But what I need is that different domains of GM (the ones being used for adresses), can't use the same template.

What I want is that customized templates can only be used for the domains they where designed. For example, I have two domains (domain1.com and domain2.com) (the ones being used for adresses) using GM.

Domain1.com will use a template called template1 and domain2.com will use a template called template2. What I want is don't allow domain1.com to use template2 and domain2.com use template1.

Do you have any ideas to avoid that?

Thanks

Smile