home *** CD-ROM | disk | FTP | other *** search
/ Internet 1996 World Exposition / park.org.s3.amazonaws.com.7z / park.org.s3.amazonaws.com / bandwidth.cgi next >
Text File  |  2017-09-21  |  9KB  |  297 lines

  1. #!/usr/bin/perl
  2. #
  3. #  file: index.cgi
  4. #  desc: generate default index page based upon browser type
  5. #
  6.  
  7. eval 'exec /usr/local/bin/perl -s $0 ${1+"$@"}'
  8.   if 0;
  9.  
  10. # map of server host names to host.park.org domain
  11. %host2park = (
  12. 'barn',      'parallel.park.org',
  13. 'town',      'park.org',
  14. 'ventus',    'adelaide.park.org',
  15. 'amsterdam', 'amsterdam.park.org',
  16. 'hannover',  'hannover.park.org',
  17. 'phoenix',   'imperial.park.org',
  18. 'iwe',       'japan.park.org',
  19. 'seoul',     'korea.park.org',
  20. 'taiwan',    'taiwan.park.org',
  21. );
  22.  
  23. # get FQDN park.org host name for this particular server
  24. chop($park_host = `/sbin/uname -n`);
  25. $park_host = $host2park{(split(/\./, $park_host))[0]};
  26.  
  27. # non-buffered STDOUT
  28. $| = 1;
  29.  
  30. # attempt to redirect based upon incoming domain
  31. # $rem_host = $ENV{'REMOTE_HOST'};
  32. # $rem_addr = $ENV{'REMOTE_ADDRESS'};
  33. # if ($rem_host) {
  34. #     if ($park_host !~ /japan/ && $rem_host =~ /\.jp$/i) {
  35. #         &redirect("http://japan.park.org/bandwidth.cgi");
  36. #     } elsif ($park_host !~ /imperial/ && $rem_host =~ /\.uk$/i) {
  37. # #    if ($park_host !~ /imperial/ && $rem_host =~ /\.uk$/i) {
  38. #         &redirect("http://imperial.park.org/bandwidth.cgi");
  39. #     } elsif ($park_host !~ /adelaide/ && $rem_host =~ /\.au$/i) {
  40. #         &redirect("http://adelaide.park.org/bandwidth.cgi");
  41. # #    } elsif ($park_host !~ /seoul/ && $rem_host =~ /\.kr$/i) {
  42. # #        &redirect("http://korea.park.org/bandwidth.cgi");
  43. # #    } elsif ($park_host !~ /taiwan/ && $rem_host =~ /\.tw$/i) {
  44. # #        &redirect("http://taiwan.park.org/bandwidth.cgi");
  45. #     } elsif ($park_host !~ /hannover/ && $rem_host =~ /\.de$/i) {
  46. #         &redirect("http://hannover.park.org/bandwidth.cgi");
  47. #     } elsif ($park_host !~ /amsterdam/ &&
  48. #              (
  49. #               ($rem_host =~ /\.al$|\.am$|\.at$|\.az$/i) ||
  50. #               ($rem_host =~ /\.be$|\.bg$|\.by$/i)       ||
  51. #               ($rem_host =~ /\.ch$|\.cy$|\.cz$/i)       ||
  52. #               ($rem_host =~ /\.dz$/i)                   ||
  53. #               ($rem_host =~ /\.eg$|\.es$/i)             ||
  54. #               ($rem_host =~ /\.ge$|\.gr$/i)             ||
  55. #               ($rem_host =~ /\.hr$|\.hu$/i)             ||
  56. #               ($rem_host =~ /\.ie$/i)                   ||
  57. #               ($rem_host =~ /\.li$/i)                   ||
  58. #               ($rem_host =~ /\.ma$|\.md$|\.mk$|\.mt$/i) ||
  59. #               ($rem_host =~ /\.nl$/i)                   ||
  60. #               ($rem_host =~ /\.pt$/i)                   ||
  61. #               ($rem_host =~ /\.ro$|\.ru$/i)             ||
  62. #               ($rem_host =~ /\.si$|\.sk$|\.su$/i)       ||
  63. #               ($rem_host =~ /\.tn$/i)                   ||
  64. #               ($rem_host =~ /\.ua$/i)                   ||
  65. #               ($rem_host =~ /\.va$/i)                   ||
  66. #               ($rem_host =~ /\.yu$/i)
  67. #              ) ) {
  68. #         &redirect("http://amsterdam.park.org/bandwidth.cgi");
  69. #     }
  70. # }
  71.  
  72.  
  73. # make sure we print MIME type
  74. print "Content-Type: text/html\n\n";
  75.  
  76. # who am i?
  77. ($prog = $0) =~ s#.*/##;
  78.  
  79. # which client type?
  80. $_ = $ENV{'HTTP_USER_AGENT'};
  81.  
  82. # generate page based upon browser type
  83. if (
  84.     /^aolbrowser\/1\.0/ ||
  85.     /^Cello/ ||
  86.     /^Chimera\/1/ ||
  87.     /^CyberJack/ ||
  88.     /^IBM WebExplorer/ ||
  89.     /^Lynx/ ||
  90.     /^Midas/ ||
  91.     m#NCSA_Mosaic/.*\(X11# ||
  92.     /NetCruiser/ ||
  93.     /^PRODIGY-WB\/1\.4/ ||
  94.     /TkWWW/
  95.    ) {
  96.  
  97.     &low_bandwidth();    # text-only or brain-dead browsers
  98.  
  99. } elsif (/Explorer\/4\.40\.308/ ) {
  100.  
  101.     &old_microsoft_browser_html();  # older (pre-HTML 3.0) browsers
  102.  
  103. } elsif (/^Mozilla\/1\.0/ ) {
  104.     &old_browser_html();  # older (pre-HTML 2.0) browsers
  105.  
  106. } else {
  107.  
  108.     &high_bandwidth();      # default - HTML 3.0 and netscape 2.x
  109. }
  110.  
  111. exit 0;
  112.  
  113.  
  114. #
  115. # generate html index page for text-only or brain-dead browsers
  116. #
  117. sub low_bandwidth {
  118.  
  119. print <<EoI;
  120.  
  121. <HTML>
  122. <HEAD>
  123. <TITLE>Internet 1996 World Exposition</TITLE>
  124. <base href="http://$park_host/">
  125. </HEAD>
  126.  
  127.  
  128. <BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#97694F" VLINK="#42426f">
  129.  
  130. <a href="/About/index.text.html">
  131. <img align="left" width="533" height=127
  132. ALT="[INTERNET 1996 WORLD EXPOSITION]" 
  133. SRC="/Images/fair_header.gif" border="0">
  134. </a>
  135. <br clear="all">
  136.  
  137.  
  138.  
  139. <p>
  140. <h1><a href="/About/Fair/index.text.html">Welcome to the Fair!</a></h1>
  141. <p>
  142. You've reached the text and simple graphics version of the Internet 1996
  143. World Exposition.  If your browser has support for tables, you might
  144. want to visit the high-bandwidth theater <a href="main.html">version of the fair.</a>
  145.  
  146. <P>
  147. <hr>
  148.  
  149. <img align="left" ALT="[Antique Postcard]" SRC="/Images/postcard_02.jpg" width="200" height="78" border="0"><br>
  150. <p>
  151. <ul>
  152. <li><a href="/Pavilions/index.text.html">Pavilions</a>
  153. <li><a href="/Regions/index.text.html">Regions</a>
  154. <li><a href="/Places/index.text.html">Places</a>
  155. <li><a href="/Events/index.text.html">Events</a>
  156. <li><a href="http://park.org/cgi-bin/form-mail.fairmaster?Feedback">Feedback (Forms)</a>
  157. <li><a href="mailto:fairmaster\@park.org">Feedback (No Forms)</a>
  158. <li><a href="/Letters/index.text.html">Letters of Support</a>
  159. <li><a href="/Sponsors/index.text.html">Our Sponsors</a>
  160. </ul>
  161.  
  162. <a href="/Images/htoolbar.text.map">
  163. <img align="left" width="486" height="101" alt="[Unreadable Image]"
  164. SRC="/Images/htoolbar.gif" ISMAP border="0"></a>
  165. <br clear="all">
  166.  
  167. <a href="/About/index.text.html">[About the Fair]</a> <a href="/Sponsors/index.text.html">[Sponsors]</a>
  168.  <a href="/WhatsNew/index.text.html">[What's New]</a> <a href="http://park.org/Tools/Guestbook/index.text.html">[Guestbook]</a>
  169.  <a href="/Tools/index.text.html">[Toolbox]</a>
  170.  
  171. </body>
  172. </HTML>
  173.  
  174. EoI
  175.  
  176. }
  177.  
  178.  
  179.  
  180. #
  181. # generate html index page for pre HTML 3.0 browsers (e.g., netscape 1.0)
  182. #
  183. sub old_microsoft_browser_html {
  184. print <<EoI;
  185.  
  186. <HTML>
  187. <HEAD>
  188. <TITLE>Internet 1996 World Exposition</TITLE>
  189. <base href="http://$park_host/">
  190. </HEAD>
  191.  
  192. <BODY BGCOLOR="#FFFFFF" background="/Images/expo_bk_main.gif" TEXT="#000000" LINK="#97694F" VLINK
  193. ="#42426f">
  194.  
  195. <a href="/Images/main_masthead.map">
  196. <img SRC="/Images/main_masthead.gif" ismap width="534" height="130" border="0"></a><br clear="all">
  197. <p>
  198.  
  199. <font size="+2"><b>Greetings!</b></font size="+2">
  200.  
  201. <p>
  202. Welcome to the Internet 1996 World Exposition!  We noticed that you are running an
  203. old version of the Microsoft Internet Explorer browser.  Our site will look much
  204. better if you upgrade to the current version, which fixes some problems with how
  205. tables are shown on your screen.
  206.  
  207. <p>
  208. <ul>
  209. <li><a href="http://www.msn.com/ie/ie.htm">Upgrade your software.</a>
  210. <li><a href="/main.html">Visit the fair with your current browser.</a> 
  211. </ul>
  212.  
  213. </body></html>
  214.  
  215. EoI
  216.  
  217. }
  218.  
  219. sub old_browser_html {
  220. print <<EoI;
  221.  
  222. <title>Your Browser Is Old</title>
  223. <h1>Your Browser</h1>
  224. </center>
  225. <p>
  226. Hello!
  227. <p>
  228. Welcome to the Internet 1996 World Exposition.
  229. We noticed that you are using an old version of your browser.
  230. We're terribly sorry, but your browser does not support
  231. the tables and other features that were used in building
  232. the Internet 1996 World Exposition.  Some of the ones we
  233. have tested include current versions of 
  234. <a href="http://home.netscape.com/comprod/mirror/index.html">Netscape Navigator,</a>
  235. <a href="http://www.msn.com/ie/ie.htm">Microsoft Internet Exporer,</a> and
  236. <a href="http://www.qdeck.com/qdeck/demosoft/QMosaic/" >Quarterdeck Mosaic.</a>
  237.  
  238. <p>
  239. We'd like to suggest that you look into upgrading your browser.
  240. In the mean time, please accept our regrets.
  241. If you'd like to try to look at the fair anyway, please
  242. <a href="/main.text.html">press here</a>
  243. for the "low bandwidth" version of the fair.
  244.  
  245. EoI
  246.  
  247. }
  248.  
  249.  
  250. #
  251. # generate default html index page (HTML 3.0 and netscape 2.0 enhancements)
  252. #
  253. sub high_bandwidth {
  254. print <<EoI;
  255. <!DOCTYPE HTML PUBLIC "-//Netscape Comm. Corp.//DTD HTML//EN">
  256. <HTML>
  257. <HEAD>
  258. <TITLE>Internet 1996 World Exposition</TITLE>
  259. <base href="http://park.org">
  260. </HEAD>
  261.  
  262. <BODY  BGCOLOR="#000000" TEXT="#ffffff" LINK="#d98719" VLINK="#97694F">
  263. <center>
  264. <a href="/Images/bandwidth.map">
  265. <img alt="[Try http://$park_host/main.text.html]" ISMAP src="/Images/tunnels.jpg" width="465" height="349" border="0" hspace="30" vspace="30" align="center"></a>
  266. <table cellpadding="5" width="465">
  267. <tr><td align="center" valign="top" width="235">
  268. <font size="-1">Choose <a href="main.html"><b>high</b></a> when connected with permanent Internet access or ISDN.</font>
  269. </td>
  270. <td align="center" valign="top" width="215">
  271. <font size="-1">Choose <a href="main.text.html"><b>low</b></a> when dialing in with a modem.</font>
  272. </td></tr></table>
  273. </center><br clear>
  274.  
  275. </body>
  276. </HTML>
  277. EoI
  278. }
  279.  
  280.  
  281. #
  282. # redirect to specified URL
  283. #
  284. sub redirect {
  285.     local($url) = shift;
  286.     local($logfile) = '/var/log/park-redirect.log';
  287.  
  288.     # keep track of redirected hosts for debugging
  289.     system("/bin/echo \"[`date`]: $rem_host -> $url\" >> $logfile");
  290.  
  291.     print "Status: 302\n";       # redirect status code
  292.     print "Location: $url\n\n";  # where they should go...
  293.  
  294.     exit 0;
  295. }
  296.  
  297.