Subversion Repositories ALCASAR

Rev

Rev 1805 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 1805 Rev 2381
1
<?php
1
<?php
2
if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php"))
2
if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php"))
3
	include_once("../lib/sql/drivers/$config[sql_type]/functions.php");
3
	include_once("../lib/sql/drivers/$config[sql_type]/functions.php");
4
else{
4
else{
5
	echo "<b>Could not include SQL library</b><br>\n";
5
	echo "<b>Could not include SQL library</b><br>\n";
6
	exit();
6
	exit();
7
}
7
}
8
 
8
 
9
unset($found_users);
9
unset($found_users);
10
 
10
 
11
$link = da_sql_pconnect($config);
11
$link = da_sql_pconnect($config);
12
if ($link){
12
if ($link){
13
	$search = da_sql_escape_string($link, $search);
13
	$search = da_sql_escape_string($link, strtolower($search));
14
	if (!isset($max) || !is_numeric($max))
14
	if (!isset($max) || !is_numeric($max))
15
#		$max = 10;
15
#		$max = 10;
16
# modif by MG fo Alcasar
16
# modif by MG fo Alcasar
17
		$max = 40;
17
		$max = 40;
18
	if ($max > 500)
18
	if ($max > 500)
19
		$max = 10;
19
		$max = 10;
20
 
20
 
21
	if (($search_IN == 'name' || $search_IN == 'department' || $search_IN == 'username') &&
21
	if (($search_IN == 'name' || $search_IN == 'department' || $search_IN == 'username') &&
22
			$config['sql_use_user_info_table'] == 'true'){
22
			$config['sql_use_user_info_table'] == 'true'){
23
		$res = da_sql_query($link,$config,
23
		$res = da_sql_query($link,$config,
24
		"SELECT " . da_sql_limit($max,0,$config) . " username FROM $config[sql_user_info_table] WHERE
24
		"SELECT " . da_sql_limit($max,0,$config) . " username FROM $config[sql_user_info_table] WHERE
25
		lower($search_IN) LIKE '%$search%' " .
25
		lower($search_IN) LIKE '%$search%' " .
26
#		da_sql_limit($max,1,$config) . " " . da_sql_limit($max,2,$config) . " ;");
26
#		da_sql_limit($max,1,$config) . " " . da_sql_limit($max,2,$config) . " ;");
27
# modif by MG for Alcasar
27
# modif by MG for Alcasar
28
		da_sql_limit($max,1,$config) . " " . da_sql_limit($max,1,$config) . " ;");
28
		da_sql_limit($max,1,$config) . " " . da_sql_limit($max,1,$config) . " ;");
29
		if ($res){
29
		if ($res){
30
			while(($row = da_sql_fetch_array($res,$config)))
30
			while(($row = da_sql_fetch_array($res,$config)))
31
				$found_users[] = $row['username'];
31
				$found_users[] = $row['username'];
32
		}
32
		}
33
		else
33
		else
34
			"<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
34
			"<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
35
	}
35
	}
36
	else if ($search_IN == 'radius' && $radius_attr != ''){
36
	else if ($search_IN == 'radius' && $radius_attr != ''){
37
		require("../lib/sql/attrmap.php");
37
		require("../lib/sql/attrmap.php");
38
		if ($attrmap["$radius_attr"] == ''){
38
		if ($attrmap["$radius_attr"] == ''){
39
			$attrmap["$radius_attr"] = $radius_attr;
39
			$attrmap["$radius_attr"] = $radius_attr;
40
			$attr_type["$radius_attr"] = 'replyItem';
40
			$attr_type["$radius_attr"] = 'replyItem';
41
		}
41
		}
42
		$table = ($attr_type[$radius_attr] == 'checkItem') ? $config['sql_check_table'] : $config['sql_reply_table'];
42
		$table = ($attr_type[$radius_attr] == 'checkItem') ? $config['sql_check_table'] : $config['sql_reply_table'];
43
		$attr = $attrmap[$radius_attr];
43
		$attr = $attrmap[$radius_attr];
44
		$attr = da_sql_escape_string($link, $attr);
44
		$attr = da_sql_escape_string($link, $attr);
45
		$res = da_sql_query($link,$config,
45
		$res = da_sql_query($link,$config,
46
		"SELECT " . da_sql_limit($max,0,$config) . " username FROM $table WHERE attribute = '$attr'
46
		"SELECT " . da_sql_limit($max,0,$config) . " username FROM $table WHERE attribute = '$attr'
47
		AND value LIKE '%$search%' " . da_sql_limit($max,1,$config) . " " . da_sql_limit($max,2,$config) . " ;");
47
		AND value LIKE '%$search%' " . da_sql_limit($max,1,$config) . " " . da_sql_limit($max,2,$config) . " ;");
48
		if ($res){
48
		if ($res){
49
			while(($row = da_sql_fetch_array($res,$config)))
49
			while(($row = da_sql_fetch_array($res,$config)))
50
				$found_users[] = $row['username'];
50
				$found_users[] = $row['username'];
51
		}
51
		}
52
		else
52
		else
53
			"<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
53
			"<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
54
	}
54
	}
55
}
55
}
56
else
56
else
57
	echo "<b>Could not connect to SQL database</b><br>\n";
57
	echo "<b>Could not connect to SQL database</b><br>\n";
58
?>
58
?>
59
 
59