Subversion Repositories ALCASAR

Rev

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

Rev Author Line No. Line
703 stephane 1
<?php
2
/*
3
 
4
*/
5
require_once('mysql.class.php');// the mysql class in already OK!
6
 
7
class user // rename to radius_user!
8
{
9
	// public properties
10
	public $username = null;
11
	public $properties = Array();
12
 
13
	// private properties
14
	private $database = null;
15
 
16
	// protected properties
17
 
18
 
19
	// Class constructor
20
	public function __construct($options = Array()) //see later how tp do the mysql init (init value in option or included with this file)
21
	{
22
		$this->database = new mysql("127.0.0.1","root","","radius");
23
 
24
	}
25
	// Class destructor
26
	public function __destruct()
27
	{
28
		//$this->mysql->close();	//is private !
29
		$this->database = null;
30
	}
31
	// public methods
32
	public function find($options = Array(), $escape=false)
33
	{
34
		/*
35
		If the options are not xss clean, escape all options string by calling _escapeDatas() method.
36
		*/
37
		if ($escape == true) { 
38
			//$this->_extractArray($options, true); //create variable from $options array and get xss clean for mysql database
39
			$options = $this->_escapeDatas($options); //create variable from $options array and get xss clean for mysql database
40
		}
41
		/*
42
		The differents $options values are :
43
 
44
		$distinct	-> only distinct response ?
45
		$username	-> only for this username
46
		$fields		-> fields to return (default : username)
47
		$search		-> search value to find
48
		$search_IN	-> search in this/those field(s)(text or array)
49
		$limit		-> to limit the resultset
50
		$offset		-> offset (work with $limit for pagination)
51
		$sortby		-> sort by x field (default : no sorting)
52
		$sortdir	-> sort direction (ASC/DESC) (default : no sorting)
53
		$radius_attr-> radius attribute to find (text or array) if search_IN = radius
54
		*/
55
 
56
		//mysql_real_escape_string
57
 
58
 
59
		$sql = "SELECT ";
60
		// distinct option
61
		if ((isset($distinct))&&($distinct=="distinct"))
62
			$sql .= "DISTINCT ";
63
		// field option (make sure that the field exist!)
64
		if ((isset($options['fields']))&&($options['fields']!='')){
65
			$sql .= $options['fields'].", username ";
66
		}else{
67
			$sql .= "username ";
68
		}
69
		$sql .= "FROM userinfo ";
70
		// search option
71
		if ((isset($options['username']))&&($options['username']!='')){
72
 
73
		}
74
		// where option
75
		if ((isset($options['username']))&&($options['username']!=""))
76
		{
77
			$sql .= "WHERE username='".$options['username']."'";
78
			$this->username = $options['username'];
79
		}
80
		// sort
81
		if ((isset($options['sortby']))&&($options['sortby']!='')){
82
			$sql .= "ORDER BY ".$options['sortby']." ";
83
			if ((isset($options['sortdir']))&&($options['sortdir']!='')){
84
				$sql .= "LIMIT ".$options['sortdir']." ";
85
			}
86
		}
87
		// limit / offset
88
		if ((isset($options['limit']))&&($options['limit']!='')){
89
			if ((isset($options['offset']))&&($options['offset']!='')){
90
				$sql .= "LIMIT $offset $limit ";
91
			} else {
92
				$sql .= "LIMIT $limit ";
93
			}
94
 
95
		}
96
		$sql .= ";";
97
 
98
		// query
99
		$result = $this->database->query($sql);
100
		// return the result values
101
		return $result;
102
	}
103
	public function add($username, $options = array())
104
	{
105
		/*
106
		$username : user to add
107
		$options  : others user infos or attribute to add 
108
			userinfo table : Name, Mail, Departement, WorkPhone, HomePhone, Mobile)
109
			radcheck table : see in attrmap.php (i get it from the "freeradius dialupadmin" package)
110
			radreply table : see in attrmap.php		
111
		*/
112
	}
113
	public function addAttribute($attribute)
114
	{
115
		// add attribute in radcheck or radreply table
116
		// return true or false
117
	}
118
	public function delete($username)
119
	{
120
		// $username : user to delete
121
	}
122
	public function deleteAttribute($attribute)
123
	{
124
		// delete attribute in radcheck or radreply table
125
		// return true or false
126
	}
127
	public function update($username, $options = array())
128
	{
129
		/*
130
		$username : user to update
131
		$options  : user infos or attribute to update 
132
			userinfo table : Name, Mail, Departement, WorkPhone, HomePhone, Mobile)
133
			radcheck table : see in attrmap.php (i get it from the "freeradius dialupadmin" package)
134
			radreply table : see in attrmap.php		
135
		*/
136
	}
137
	public function updateAttribute($attribute)
138
	{
139
		// update attribute in radcheck or radreply table
140
		// return true or false
141
	}
142
	public function passwordCheck($pwd, $username ="") // make it static?
143
	{
144
		//	Check the user password
145
		//	Return true or false
146
	}
147
	public function passwordSet($pwd, $username ="") // make it static?
148
	{
149
		//	Set or change the user password
150
	}
151
 
152
	// private methods
153
 
154
	// protected methods
155
}
156
?>