Solved: Change link when on intranet?

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

DrP

Thread Starter
Joined
Jul 23, 2005
Messages
739
I have a link on a school website which I could do with varying slightly depending whether the user is in school or not.

If people are in school, and can get on the intranet, then I would like the link to be the intranet version of the address, while if they are not in school it will be the normal address.

Could anyone tell me how I could pursue this? If it is relatively straight forward I'll have a go, otherwise I'll just use the external link for both.

I think it could be done with javascript. Is that right?
 

TechGuy

Mike
Administrator
Joined
Feb 12, 1999
Messages
15,029
I'm sure it could be done somehow using Javascript, but I don't know much about it -- it would be pretty easy to do in PHP (in fact, I've done just that for an internal site!)...

For example:
PHP:
<?php
if ($REMOTE_ADDR=="192.168.0.1") {
$addrStart="http://192.168.0.100";
} else {
$addrStart="http://www.cnn.com";
}
print "$addrStart/article.html";
</php>
 

DrP

Thread Starter
Joined
Jul 23, 2005
Messages
739
Thanks Tech Guy,
I'd do that but I've been recommended to leave PHP alone in case I leave and someone has to take over the website!
Anyone any ideas on how I could do it with javascript?
 
Joined
Apr 14, 2001
Messages
2,382
Php is much more reliable, and the code snippet is very small. Place lots of comments above your PHP, so that a new IT person will know what the code is for, and what it effects.


you may be able to edit this page's code, try playing with the var server1 var server2 elements.
http://www.irt.org/script/1231.htm
 

DrP

Thread Starter
Joined
Jul 23, 2005
Messages
739
Ok. Thanks. I'll have a go at doing it in PHP and leaves loads of comments.
 
Joined
Jul 8, 2002
Messages
14,681
Each computer in your school probably has a different IP if the server is also within the network, so you might want to redirect to a different page anytime the IP contains 192.168 with something like
PHP:
<?php
if(strstr($_SERVER['REMOTE_ADDR'],'192.168')) {
header('Location: http://192.168.1.1'); }
?>
 

DrP

Thread Starter
Joined
Jul 23, 2005
Messages
739
Hmmmm.
The server for the intranet isn't in the school.
The intranet is for the whole Education Authority. Presumably each school has an IP address recognisable by the Education Authorities servers to use the intranet.
Is this right? If so, do I just need to get this IP address from the Education Authority?
 
Joined
Apr 14, 2001
Messages
2,382
What is your computers IP within the Intranet or LAN? It will be a subnet of the servers on the intranet. it's most likely assigned by a switch or router using DHCP.
Is it forced, or assigned by DHCP?

In theory, all you need is the DHCP router or switch's IP, and you can assign off that.
 
Joined
Apr 14, 2001
Messages
2,382
THere is a range that you would need to consider for the intranet, they would all be for example, if oyu had say 50 computers on your Intranet, the ip's assigned to them would be 10.10.0.100 - 10.10.0.150

In most intranets there are few autoassigned IP ranges, most are forced or assigned IP's.
 
Joined
Jul 8, 2002
Messages
14,681
He said the server is not within the network, the value of $_SERVER['REMOTE_ADDR'] will be the external IP and not the intranet ones.
 
Joined
Apr 14, 2001
Messages
2,382
No actually he said
DrP said:
The server for the intranet isn't in the school.
Our server for our LAN intranet isnt in our fire hall either, we are connected through fiber optic to it which is in a earthquake/fireproof server room about 25 miles away, yet we are all on the LAN, and assigned ip's by the DHCP server.

Our local area address is 10.10.**.***, the servers is 10.10.***.*** and the switches are the DHCP servers for the network. I assumed, perhaps incorrectly, that their servers are most likey set up as ours are, since this is a standard Intranet configuration.
 
Joined
Jul 8, 2002
Messages
14,681
Hmm, possibly. We will still need to know for sure if we need the script to check for a range of intranet IPs or a single external IP.
 

DrP

Thread Starter
Joined
Jul 23, 2005
Messages
739
How can I find out the IP address of a computer at the school when logged onto one?
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Members online

Top