Subversion Repositories ALCASAR

Rev

Rev 1805 | Details | Compare with Previous | Last modification | View Log

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