initial setup of framework code
[cacert-mgr.git] / manager / library / helpers / GetEnv.php
1 <?php
2 /**
3 * @author markus
4 * $Id: GetEnv.php 6 2009-11-18 14:52:50Z markus $
5 */
6 class GetEnv {
7 /**
8 * Get an environment variable with all the REDIRECT_ prefixes stripped off
9 */
10 public static function getEnvVar($var)
11 {
12 // Find out how deep the redirect goes
13 reset($_SERVER);
14 $key = key($_SERVER);
15 $redirectLevel = substr_count($key, 'REDIRECT_');
16
17 $result = '';
18 $prefix = '';
19 for ($i = 0; $i < $redirectLevel + 1; $i++) {
20 if (isset($_SERVER[$prefix . $var])) {
21 $result = $_SERVER[$prefix . $var];
22 }
23 $prefix .= 'REDIRECT_';
24 }
25 return $result;
26 }
27 }
28
29 ?>