Subversion Repositories ALCASAR

Rev

Rev 1805 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
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 != '')
1836 raphael.pi 83
	{
84
		$accent = "âêôûéàèùîáâãäçèéêëìíîïñòóôõöùúûü";
85
		$login = preg_replace("/[^\w$accent\.\/\@\:\-]/",'',$login);
86
	}
1805 clement.si 87
	if ($login != '' && $config['general_strip_realms'] == 'yes'){
88
		$realm_del = ($config['general_realm_delimiter'] != '') ? $config['general_realm_delimiter'] : '@';
89
		$realm_for = ($config['general_realm_format'] != '') ? $config['general_realm_format'] : 'suffix';
90
		$new = explode($realm_del,$login,2);
91
		if (count($new) == 2)
92
			$login = ($realm_for == 'suffix') ? $new[0] : $new[1];
93
	}
94
}
95
unset($mappings);
96
if (isset($_SESSION['mappings']))
97
	$mappings = $_SESSION['mappings'];
98
if (!isset($mappings) && $config['general_username_mappings_file'] != ''){
99
	$ARR = file($config['general_username_mappings_file']);
100
	foreach($ARR as $val){
101
		$val=chop($val);
102
		if (preg_match('/^[[:space:]]*#/',$val) || preg_match('/^[[:space:]]*$/',$val))
103
			continue;
104
		list($key,$realm,$v)=preg_split("/:[[:space:]]*/",$val,3);
105
		if ($realm == 'accounting' || $realm == 'userdb' || $realm == 'nasdb' || $realm == 'nasadmin')
106
			$mappings["$key"][$realm] = $v;
107
		if ($realm == 'nasdb'){
108
			$NAS_ARR = array();
109
			$NAS_ARR = explode(',',$v);
110
			foreach ($nas_list as $key => $nas){
111
				foreach ($NAS_ARR as $nas_check){
112
					if ($nas_check == $nas['name'])
113
						unset($nas_list[$key]);
114
				}
115
			}
116
		}
117
	}
118
	if ($config['general_use_session'] == 'yes')
119
		session_register('mappings');
120
}
121
 
122
//Include missing.php if needed
123
if (!function_exists('array_change_key_case'))
124
	include_once('../lib/missing.php');
125
@header('Content-type: text/html; charset='.$config['general_charset'].';');
126
?>