[132] | 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 | // catch a docroot from the DocumentRoot directive in an apacheconf |
---|
| 8 | $documentRoot = str_replace(__FILE__,'',$_SERVER['DOCUMENT_ROOT']); |
---|
| 9 | if (!empty($documentRoot) && substr($documentRoot,0,1) == '/') |
---|
| 10 | $documentRoot = substr($documentRoot, 1); |
---|
| 11 | if (empty($documentRoot)) |
---|
| 12 | $documentRoot = array_shift(explode('.',$_SERVER['SERVER_NAME'])); |
---|
| 13 | |
---|
| 14 | switch($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(); |
---|
| 32 | file_exists($settingsFile1) && $settings = file($settingsFile1); |
---|
| 33 | file_exists($settingsFile2) && $settings = file($settingsFile2); |
---|
| 34 | if (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> |
---|