/[MITgcm]/mitgcm.org/front_content/cmi_redir.php
ViewVC logotype

Annotation of /mitgcm.org/front_content/cmi_redir.php

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (hide annotations) (download)
Thu Jul 29 19:29:03 2004 UTC (17 years, 1 month ago) by edhill
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +2 -2 lines
 o fix for the more secure PHP "no register globals" configuration

1 edhill 1.1 <?php
2     /**
3     *
4 edhill 1.2 * $Header: /u/gcmpack/mitgcm.org/front_content/cmi_redir.php,v 1.1 2004/03/24 23:04:51 edhill Exp $
5 edhill 1.1 *
6     * Ed Hill
7     *
8     * Simple "name"-based redirection for the CMI web pages.
9     *
10     * This file belongs in the mitgcm.org DocumentRoot and it uses all
11     * the readable files in the directory DocumentRoot/redir_mappings
12     * to build the list.
13     *
14     */
15    
16    
17     $code = array();
18    
19     $location = "./redir_mappings";
20     $all = opendir($location);
21     while ($file = readdir($all)) {
22     if (!is_dir($location.'/'.$file)) {
23     if (is_readable($location.'/'.$file)) {
24     $handle = fopen($location.'/'.$file,"r");
25     while ($line = fgets($handle, 4095)) {
26     // list ($code, $url) = $mapinfo;
27     // print $line;
28     $t1 = strtok($line," \n\t");
29     $t2 = strtok(" \n\t");
30     if ($t1 && $t2) {
31     $code[$t1] = $t2;
32     }
33     }
34     fclose($handle);
35     }
36     }
37     }
38     closedir($all);
39    
40 edhill 1.2 $arr=explode('/',$_SERVER['REQUEST_URI']);
41 edhill 1.1 $url=$code[ $arr[2] ];
42    
43     if ( strlen($url) > 4 ) {
44     header ("Location: $url");
45     } else {
46     print "<html><body>";
47     print "Sorry, \"" . $arr[2] . "\" is an unknown redirection code.<br><br>";
48     print "Please contact <a href=\"mailto:eh3@mit.edu\">eh3@mit.edu</a> if you ";
49     print "need help with this site.";
50     print "</body></html>";
51     }
52    
53     ?>

  ViewVC Help
Powered by ViewVC 1.1.22