source: vhosts/server1.php @ 134

Last change on this file since 134 was 132, checked in by jbarnold, 18 years ago
added virtual host files
  • Property svn:executable set to *
File size: 1.7 KB
Line 
1<?php
2if (isset($_SERVER['SERVER_NAME'])) $name = $_SERVER['SERVER_NAME']; else $name = '';
3if (isset($_SERVER['REQUEST_URI'])) $req = $_SERVER['REQUEST_URI']; else $req = '/';
4if (isset($_SERVER['PATH_INFO'])) $pi = explode('/',$_SERVER['PATH_INFO']);
5if (isset($_SERVER['SERVER_PORT'])) $port = $_SERVER['SERVER_PORT']; else $port = '80';
6
7// catch a docroot from the DocumentRoot directive in an apacheconf
8$documentRoot = str_replace(__FILE__,'',$_SERVER['DOCUMENT_ROOT']);
9if (!empty($documentRoot) && substr($documentRoot,0,1) == '/')
10        $documentRoot = substr($documentRoot, 1);
11if (empty($documentRoot))
12        $documentRoot = array_shift(explode('.',$_SERVER['SERVER_NAME']));
13
14switch($port) {
15        case 443:
16                $myHTTP = 'https';
17                $mySSL = true;
18                break;
19        default:
20                $myHTTP = 'http';
21                $mySSL = false;
22                break;
23}
24
25$myTitle = $name;
26$baseHTTP = 'http://scripts.mit.edu/~'.$documentRoot;
27$baseHTTPS = 'https://scripts.mit.edu/~'.$documentRoot;
28
29$settingsFile1 = '/afs/athena.mit.edu/contrib/scripts/vhosts/settings/'.$name;
30$settingsFile2 = '/afs/athena.mit.edu/contrib/scripts/vhosts/settings/'.$name.'.mit.edu';
31$settings = array();
32file_exists($settingsFile1) && $settings = file($settingsFile1);
33file_exists($settingsFile2) && $settings = file($settingsFile2);
34if (count($settings)) {
35        if (count($settings) >= 0 && '' != trim($settings[0])) $myTitle = trim($settings[0]);
36        if (count($settings) >= 1 && '' != trim($settings[1])) $baseHTTP = trim($settings[1]);
37        if (count($settings) >= 2 && '' != trim($settings[2])) $baseHTTPS = trim($settings[2]);
38}
39
40$baseURL = $mySSL?$baseHTTPS:$baseHTTP;
41?>
42<html>
43<head><title><?=$myTitle?></title></head>
44
45<frameset rows="*">
46        <frame src="<?=$baseURL?><?=$req?>" />
47</frameset>
48
49</html>
Note: See TracBrowser for help on using the repository browser.