3 # Things should work even if register_globals is set to off
5 $testVer=intval(str_replace(".", "",'4.1.0'));
6 $curVer=intval(str_replace(".", "",phpversion()));
7 if( $curVer >= $testVer )
8 import_request_variables('GPC');
9 # If using sessions set use_session to 1 to also cache the config file
17 if (isset($_SESSION['config']))
18 $config = $_SESSION['config'];
19 if (isset($_SESSION['nas_list']))
20 $nas_list = $_SESSION['nas_list'];
23 $ARR=file("../conf/admin.conf");
25 foreach($ARR as $val) {
27 if (ereg('^[[:space:]]*#',$val) || ereg('^[[:space:]]*$',$val))
29 list($key,$v)=split(":[[:space:]]*",$val,2);
30 if (preg_match("/%\{(.+)\}/",$v,$matches)){
31 $val=$config[$matches[1]];
32 $v=preg_replace("/%\{$matches[1]\}/",$val,$v);
34 if (preg_match("/^nas(\d+)_(\w+)$/",$key,$matches))
35 $nas_list[$matches[1]][$matches[2]] = $v;
36 if ($key == 'INCLUDE'){
38 array_push($EXTRA_ARR,file($v));
40 echo "<b>Error: File '$v' does not exist or is not readable</b><br>\n";
45 foreach($EXTRA_ARR as $val1) {
46 foreach($val1 as $val){
48 if (ereg('^[[:space:]]*#',$val) || ereg('^[[:space:]]*$',$val))
50 list($key,$v)=split(":[[:space:]]*",$val,2);
51 if (preg_match("/%\{(.+)\}/",$v,$matches)){
52 $val=$config[$matches[1]];
53 $v=preg_replace("/%\{$matches[1]\}/",$val,$v);
55 if (preg_match("/^nas(\d+)_(\w+)$/",$key,$matches))
56 $nas_list[$matches[1]][$matches[2]] = $v;
61 session_register('config');
62 session_register('nas_list');
66 if ($use_session == 0 && $config[general_use_session] == 'yes'){
70 session_register('nas_list');
72 //Make sure we are only passed allowed strings in username
74 $login = preg_replace("/[^\w\.\/\@\:\-]/",'',$login);
76 if ($login != '' && $config[general_strip_realms] == 'yes'){
77 $realm_del = ($config[general_realm_delimiter] != '') ? $config[general_realm_delimiter] : '@';
78 $realm_for = ($config[general_realm_format] != '') ? $config[general_realm_format] : 'suffix';
79 $new = explode($realm_del,$login,2);
81 $login = ($realm_for == 'suffix') ? $new[0] : $new[1];
84 if (isset($_SESSION['mappings']))
85 $mappings = $_SESSION['mappings'];
86 if (!isset($mappings) && $config[general_username_mappings_file] != ''){
87 $ARR = file($config[general_username_mappings_file]);
88 foreach($ARR as $val){
90 if (ereg('^[[:space:]]*#',$val) || ereg('^[[:space:]]*$',$val))
92 list($key,$realm,$v)=split(":[[:space:]]*",$val,3);
93 if ($realm == 'accounting' || $realm == 'userdb' || $realm == 'nasdb' || $realm == 'nasadmin')
94 $mappings["$key"][$realm] = $v;
95 if ($realm == 'nasdb'){
97 $NAS_ARR = split(',',$v);
98 foreach ($nas_list as $key => $nas){
99 foreach ($NAS_ARR as $nas_check){
100 if ($nas_check == $nas[name])
101 unset($nas_list[$key]);
106 if ($config[general_use_session] == 'yes')
107 session_register('mappings');
110 //Include missing.php3 if needed
111 if (!function_exists('array_change_key_case'))
112 include_once('../lib/missing.php3');
113 @header('Content-type: text/html; charset='.$config[general_charset].';');