[Web4lib] server side includes for off-campus users

Thomas Bennett bennetttm at appstate.edu
Thu Apr 19 10:30:48 EDT 2007


It depends on your WEB server software and do you own an entire range of IPs 
to test on or off campus.

I have a solution that works quite well for us and III proxy but probably 
wouldn't on your server since I assume you are not running Zope and are your 
URLs fed from a database.

In my case:
The campus owns xxx.yyy.000.000 - xxx.yyy.255.255 IP range and is easy to test 
for.

<dtml-comment> CHECK FOR ON OR OFF CAMPUS</dtml-comment>
<dtml-call "REQUEST.set('hostname',ip_add_flag(HTTP_X_FORWARDED_FOR))">
which calls the python script below where hostname is assigned the return 
value.

import string
my_split=string.split(ipnum,'.')
if my_split[0]=='xxx' and my_split[1]=='yyy':  
  match=1
else:
  match=0
return match

Then later in the page fed from a database where both vdb_local_url and 
vdb_proxy_url are selected:
 <dtml-if hostname>
       <A href="http://<dtml-var vdb_local_url>"><dtml-var vdb_title></a>
     <dtml-else>
       <A href="http://<dtml-var vdb_proxy_url>" target="_blank"><dtml-var 
vdb_title></a> <div id="smallfont">(opens in a new window)</div>
     </dtml-if>


The python script parses HTTP_X_FORWARDED_FOR.  Apache listens on port 80 
doing rewrite rules to all Zope instances and REMOTE_ADDR comes across as 
127.0.0.1 but if you serve direct to the Internet from a server without 
forwarding you will probably want to use the latter for finding an IP value.

Again it depends on your setup, you can do something very similar with PHP and 
Perl or Python maybe even with PHP code alone I'm not that versed on PHP.  
You very likely can do something similar with javascript which is dependent 
on the user's browser and javascript settings.   With javascript you can test 
the ip and do an if true document.write "something" else dcoument.write 
"something else".

Thomas


ps: I open a new browser window with the proxy url because when our site is 
view in a frame on the campus portal the user  doesn't get to the site linked 
by the proxy url.  Has something to do with the campus portal or frames.

On Wednesday 18 April 2007 17:05, Liz Kent wrote:
> Dear list:
>
> I searched this topic in the Archives, but didn't come up with much.
>
> Is anyone here using server-side includes on their library web pages
> to direct off-campus traffic to an EZProxy login page? If so, would
> you be willing to share examples of your code with me, off list?
>
> Thank you,
> Liz
>
> ---
> Liz Kent
>
> Reference and Electronic Resources Librarian
> Director, Gifts of Speech Project
> Advisor to Women and Gender Studies
>
> Sweet Briar College
> (434) 381-6315
>
> Gifts of Speech
> http://www.giftsofspeech.org
>
> _______________________________________________
> Web4lib mailing list
> Web4lib at webjunction.org
> http://lists.webjunction.org/web4lib/

-- 
====================================================================
Thomas McMillan Grant Bennett		Appalachian State University
Computer Consultant III			P O Box 32026
University Library				Boone, North Carolina 28608
(828) 262 6587

If it's not as simple as possible to try it, then the barrier to entry is too 
high.

Library Systems Help Desk: http://www.library.appstate.edu/help/
====================================================================


More information about the Web4lib mailing list