Subversion Repositories ALCASAR

Rev

Rev 1831 | Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
1805 clement.si 1
<?php
2
require('/etc/freeradius-web/config.php');
3
require_once('../lib/functions.php');
4
 
5
unset($da_name_cache);
6
if (isset($_SESSION['da_name_cache']))
7
	$da_name_cache = $_SESSION['da_name_cache'];
8
if ($config[sql_nas_table] != ''){
9
 
10
	if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php"))
11
		include_once("../lib/sql/drivers/$config[sql_type]/functions.php");
12
	else{
13
		echo "<b>Could not include SQL library</b><br>\n";
14
		exit();
15
	}
16
	$link = da_sql_pconnect($config);
17
	if ($link){
18
		$auth_user = $_SERVER["PHP_AUTH_USER"];
19
		$extra = '';
20
		if (isset($mappings[$auth_user][nasdb])){
21
			$NAS_ARR = array();
22
			$NAS_ARR = preg_split('/,/',$mappings[$auth_user][nasdb]);
23
			$extra = 'WHERE nasname IN (';
24
			foreach ($NAS_ARR as $nas)
25
				$extra .= "'$nasname',";
26
			unset($NAS_ARR);
27
			$extra = rtrim($extra,",");
28
			$extra .= ')';
29
		}
30
		$search = da_sql_query($link,$config,
31
		"SELECT * FROM $config[sql_nas_table] $extra;");
32
		if ($search){
33
			while($row = da_sql_fetch_array($search,$config)){
34
				$num = 0;
35
				$my_nas_name = $row['nasname'];
36
				if ($my_nas_name != ''){
37
					$nas_list[$my_nas_name]['name'] = $my_nas_name;
38
                                	$nas_server = $da_name_cache[$my_nas_name];
39
                                	if (!isset($nas_server)){
40
						if (!check_ip($my_nas_name))
41
	                                        	$nas_server = @gethostbyname($my_nas_name);
42
						else
43
							$nas_server = $my_nas_name;
44
                                        	if (!isset($da_name_cache) && $config[general_use_session] == 'yes'){
45
                                                	$da_name_cache[$my_nas_name] = $nas_server;
46
                                                	session_register('da_name_cache');
47
                                        	}
48
                                	}
49
					if ($nas_server != $my_nas_name || check_ip($nas_server))
50
						$nas_list[$my_nas_name]['ip'] = $nas_server;
51
					$nas_list[$my_nas_name]['port_num'] = $row['ports'];
52
					$nas_list[$my_nas_name]['community'] = $row['community'];
53
					$nas_list[$my_nas_name]['model'] = $row['description'];
54
				}
55
			}
56
		}
57
	}
58
	else
59
		echo "<b>Could not connect to SQL database</b><br>\n";
60
}
61
 
62
?>