1 | <?php |
---|
2 | if (isset($_SERVER['SERVER_NAME'])) $name = $_SERVER['SERVER_NAME']; else $name = ''; |
---|
3 | if (isset($_SERVER['REQUEST_URI'])) $req = $_SERVER['REQUEST_URI']; else $req = '/'; |
---|
4 | if (isset($_SERVER['PATH_INFO'])) $pi = explode('/',$_SERVER['PATH_INFO']); |
---|
5 | if (isset($_SERVER['SERVER_PORT'])) $port = $_SERVER['SERVER_PORT']; else $port = '80'; |
---|
6 | |
---|
7 | if (array_shift(explode('.',$name)) == 'www') { |
---|
8 | $name = explode('.',$name); |
---|
9 | array_shift($name); |
---|
10 | $name = implode('.',$name); |
---|
11 | } |
---|
12 | |
---|
13 | // catch a docroot from the DocumentRoot directive in an apacheconf |
---|
14 | $documentRoot = str_replace(__FILE__,'',$_SERVER['DOCUMENT_ROOT']); |
---|
15 | if (!empty($documentRoot) && substr($documentRoot,0,1) == '/') |
---|
16 | $documentRoot = substr($documentRoot, 1); |
---|
17 | if (empty($documentRoot)) |
---|
18 | $documentRoot = array_shift(explode('.',$_SERVER['SERVER_NAME'])); |
---|
19 | |
---|
20 | switch($port) { |
---|
21 | case 443: |
---|
22 | $myHTTP = 'https'; |
---|
23 | $mySSL = true; |
---|
24 | break; |
---|
25 | default: |
---|
26 | $myHTTP = 'http'; |
---|
27 | $mySSL = false; |
---|
28 | break; |
---|
29 | } |
---|
30 | |
---|
31 | $myTitle = $name; |
---|
32 | $baseHTTP = 'http://scripts.mit.edu/~'.$documentRoot; |
---|
33 | $baseHTTPS = 'https://scripts.mit.edu/~'.$documentRoot; |
---|
34 | |
---|
35 | $settingsFiles[] = '/afs/athena.mit.edu/contrib/scripts/vhosts/settings/'.$name; |
---|
36 | $settingsFiles[] = '/afs/athena.mit.edu/contrib/scripts/vhosts/settings/'.$name.'.mit.edu'; |
---|
37 | $settingsFiles[] = '/afs/athena.mit.edu/contrib/scripts/vhosts/settings/www.'.$name; |
---|
38 | $settings = array(); |
---|
39 | foreach($settingsFiles as $aFile) { |
---|
40 | if (file_exists($aFile)) { |
---|
41 | $settings = file($aFile); |
---|
42 | break; |
---|
43 | } |
---|
44 | } |
---|
45 | if (count($settings)) { |
---|
46 | if (count($settings) >= 0 && '' != trim($settings[0])) $myTitle = trim($settings[0]); |
---|
47 | if (count($settings) >= 1 && '' != trim($settings[1])) $baseHTTP = trim($settings[1]); |
---|
48 | if (count($settings) >= 2 && '' != trim($settings[2])) $baseHTTPS = trim($settings[2]); |
---|
49 | } |
---|
50 | |
---|
51 | $baseURL = $mySSL?$baseHTTPS:$baseHTTP; |
---|
52 | ?> |
---|
53 | <html> |
---|
54 | <head><title><?=$myTitle?></title></head> |
---|
55 | |
---|
56 | <frameset rows="*"> |
---|
57 | <frame src="<?=$baseURL?><?=$req?>" /> |
---|
58 | </frameset> |
---|
59 | |
---|
60 | </html> |
---|