1805 |
clement.si |
1 |
<?php
|
|
|
2 |
#
|
|
|
3 |
# Things should work even if register_globals is set to off
|
|
|
4 |
#
|
|
|
5 |
$testVer=intval(str_replace(".", "",'4.1.0'));
|
|
|
6 |
$curVer=intval(str_replace(".", "",phpversion()));
|
|
|
7 |
if( $curVer >= $testVer )
|
|
|
8 |
{
|
|
|
9 |
// import_request_variables('GPC');
|
|
|
10 |
extract($_GET);
|
|
|
11 |
extract($_POST);
|
|
|
12 |
extract($_COOKIE);
|
|
|
13 |
}
|
|
|
14 |
foreach($_POST as $key => $value){
|
|
|
15 |
${$key} = $value;
|
|
|
16 |
}
|
|
|
17 |
# If using sessions set use_session to 1 to also cache the config file
|
|
|
18 |
#
|
|
|
19 |
$use_session = 0;
|
|
|
20 |
unset($config);
|
|
|
21 |
unset($nas_list);
|
|
|
22 |
if ($use_session){
|
|
|
23 |
// Start session
|
|
|
24 |
@session_start();
|
|
|
25 |
if (isset($_SESSION['config']))
|
|
|
26 |
$config = $_SESSION['config'];
|
|
|
27 |
if (isset($_SESSION['nas_list']))
|
|
|
28 |
$nas_list = $_SESSION['nas_list'];
|
|
|
29 |
}
|
|
|
30 |
if (!isset($config)){
|
|
|
31 |
$ARR=file("/etc/freeradius-web/admin.conf");
|
|
|
32 |
$EXTRA_ARR = array();
|
|
|
33 |
foreach($ARR as $val) {
|
|
|
34 |
$val=chop($val);
|
|
|
35 |
if (preg_match('/^[[:space:]]*#/',$val) || preg_match('/^[[:space:]]*$/',$val))
|
|
|
36 |
continue;
|
|
|
37 |
list($key,$v)=preg_split("/:[[:space:]]*/",$val,2);
|
|
|
38 |
if (preg_match("/%\{(.+)\}/",$v,$matches)){
|
|
|
39 |
$val=$config[$matches[1]];
|
|
|
40 |
$v=preg_replace("/%\{$matches[1]\}/",$val,$v);
|
|
|
41 |
}
|
|
|
42 |
if (preg_match("/^nas(\d+)_(\w+)$/",$key,$matches))
|
|
|
43 |
$nas_list[$matches[1]][$matches[2]] = $v;
|
|
|
44 |
if ($key == 'INCLUDE'){
|
|
|
45 |
if (is_readable($v))
|
|
|
46 |
array_push($EXTRA_ARR,file($v));
|
|
|
47 |
else
|
|
|
48 |
echo "<b>Error: File '$v' does not exist or is not readable</b><br>\n";
|
|
|
49 |
}
|
|
|
50 |
else
|
|
|
51 |
$config["$key"]="$v";
|
|
|
52 |
}
|
|
|
53 |
foreach($EXTRA_ARR as $val1) {
|
|
|
54 |
foreach($val1 as $val){
|
|
|
55 |
$val=chop($val);
|
|
|
56 |
if (preg_match('/^[[:space:]]*#/',$val) || preg_match('/^[[:space:]]*$/',$val))
|
|
|
57 |
continue;
|
|
|
58 |
list($key,$v)=preg_split("/:[[:space:]]*/",$val,2);
|
|
|
59 |
if (preg_match("/%\{(.+)\}/",$v,$matches)){
|
|
|
60 |
$val=$config[$matches[1]];
|
|
|
61 |
$v=preg_replace("/%\{$matches[1]\}/",$val,$v);
|
|
|
62 |
}
|
|
|
63 |
if (preg_match("/^nas(\d+)_(\w+)$/",$key,$matches))
|
|
|
64 |
$nas_list[$matches[1]][$matches[2]] = $v;
|
|
|
65 |
$config["$key"]="$v";
|
|
|
66 |
}
|
|
|
67 |
}
|
|
|
68 |
if ($use_session){
|
|
|
69 |
session_register('config');
|
|
|
70 |
session_register('nas_list');
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
}
|
|
|
74 |
if ($use_session == 0 && $config['general_use_session'] == 'yes'){
|
|
|
75 |
// Start session
|
|
|
76 |
@session_start();
|
|
|
77 |
if (isset($nas_list))
|
|
|
78 |
session_register('nas_list');
|
|
|
79 |
}
|
|
|
80 |
//Make sure we are only passed allowed strings in username
|
|
|
81 |
if (isset($login)){
|
|
|
82 |
if ($login != '')
|
|
|
83 |
$login = preg_replace("/[^\w\.\/\@\:\-]/",'',$login);
|
|
|
84 |
if ($login != '' && $config['general_strip_realms'] == 'yes'){
|
|
|
85 |
$realm_del = ($config['general_realm_delimiter'] != '') ? $config['general_realm_delimiter'] : '@';
|
|
|
86 |
$realm_for = ($config['general_realm_format'] != '') ? $config['general_realm_format'] : 'suffix';
|
|
|
87 |
$new = explode($realm_del,$login,2);
|
|
|
88 |
if (count($new) == 2)
|
|
|
89 |
$login = ($realm_for == 'suffix') ? $new[0] : $new[1];
|
|
|
90 |
}
|
|
|
91 |
}
|
|
|
92 |
unset($mappings);
|
|
|
93 |
if (isset($_SESSION['mappings']))
|
|
|
94 |
$mappings = $_SESSION['mappings'];
|
|
|
95 |
if (!isset($mappings) && $config['general_username_mappings_file'] != ''){
|
|
|
96 |
$ARR = file($config['general_username_mappings_file']);
|
|
|
97 |
foreach($ARR as $val){
|
|
|
98 |
$val=chop($val);
|
|
|
99 |
if (preg_match('/^[[:space:]]*#/',$val) || preg_match('/^[[:space:]]*$/',$val))
|
|
|
100 |
continue;
|
|
|
101 |
list($key,$realm,$v)=preg_split("/:[[:space:]]*/",$val,3);
|
|
|
102 |
if ($realm == 'accounting' || $realm == 'userdb' || $realm == 'nasdb' || $realm == 'nasadmin')
|
|
|
103 |
$mappings["$key"][$realm] = $v;
|
|
|
104 |
if ($realm == 'nasdb'){
|
|
|
105 |
$NAS_ARR = array();
|
|
|
106 |
$NAS_ARR = explode(',',$v);
|
|
|
107 |
foreach ($nas_list as $key => $nas){
|
|
|
108 |
foreach ($NAS_ARR as $nas_check){
|
|
|
109 |
if ($nas_check == $nas['name'])
|
|
|
110 |
unset($nas_list[$key]);
|
|
|
111 |
}
|
|
|
112 |
}
|
|
|
113 |
}
|
|
|
114 |
}
|
|
|
115 |
if ($config['general_use_session'] == 'yes')
|
|
|
116 |
session_register('mappings');
|
|
|
117 |
}
|
|
|
118 |
|
|
|
119 |
//Include missing.php if needed
|
|
|
120 |
if (!function_exists('array_change_key_case'))
|
|
|
121 |
include_once('../lib/missing.php');
|
|
|
122 |
@header('Content-type: text/html; charset='.$config['general_charset'].';');
|
|
|
123 |
?>
|