Subversion-Projekte lars-tiefland.medien

Revision

Revision 45 | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
4 lars 1
<?
2
	class User
3
	{
4
		var $u_id;
5
		var $u_name;
6
		var $u_password;
7
		var $u_key;
8
		var $u_active;
9
		var $u_type;
10
		var $u_email;
11
		var $u_lang;
12
 
13
		function User($user)
14
		{
28 lars 15
			global $db, $db_meld, $error, $meld, $prefix;
4 lars 16
			if ($user=="")
17
			{
18
				$this->u_name="";
19
				$this->u_type=0;
20
				$this->u_email="";
21
				$this->u_password=md5("");
22
				$this->u_key="";
23
				$this->u_active=1;
24
				$this->u_lang="en";
25
			}
26
			else
27
			{
28 lars 28
				if (is_numeric($user))
29
				{
30
					$this->u_id=$user;
31
					$sql="SELECT * FROM $prefix"."auth_user WHERE u_id=".$this->u_id;
32
				}
33
				else
34
				{
35
					$this->u_name=$user;
36
					$sql="SELECT * FROM $prefix"."auth_user WHERE u_name='".$this->u_name."'";
37
				}
4 lars 38
				$res=$db->query($sql);
39
				if (true == DB::isError($res))
40
				{
41
					$error="true";
42
					$meld="Ein Fehler ist aufgetreten!";
43
					$db_meld=$res->getUserInfo();
44
					return $error;
45
				}
46
				else
47
				{
48
					$row=$res->fetchRow();
49
					$this->u_id=$row["u_id"];
52 lars 50
					$this->u_name=stripslashes($row["u_name"]);
4 lars 51
					$this->u_type=$row["u_type"];
52 lars 52
					$this->u_email=stripslashes($row["u_email"]);
4 lars 53
					$this->u_password=$row["u_password"];
54
					$this->u_active=$row["u_active"];
55
					$this->u_key=$row["u_key"];
52 lars 56
					$this->u_lang=stripslashes($row["u_lang"]);
4 lars 57
					return $this;
58
				}
59
			}
60
		}
61
 
62
		function UserListe($limit, $start=0)
63
		{
5 lars 64
			$sql="SELECT * FROM $prefix"."auth_user";
4 lars 65
			global $db, $meld, $db_meld, $error;
66
			if ($db->provides('limit') && $limit > 0)
67
			{
68
				$res=$db->limitquery($sql, $start, $limit);
69
			}
70
			else
71
			{
72
				$res=$db->query($sql);
73
			}
74
			if (true == DB::isError($res))
75
			{
76
				$error=true;
77
				$meld="Ein Fehler ist aufgetreten!";
78
				$db_meld=$res->getUserInfo();
79
			}
80
			return $res;
81
		}
82
 
29 lars 83
		function update($u_id, $u_name, $u_email, $u_type, $u_lang, $u_active, $u_key, $u_pw)
4 lars 84
		{
85
			$this->u_name=$u_name;
86
			$this->u_email=$u_email;
87
			$this->u_type=$u_type;
88
			$this->u_lang=$u_lang;
89
			$this->u_id=$u_id;
90
			$this->u_active=$u_active;
91
			$this->u_key=$u_key;
29 lars 92
			if (stripslashes($u_pw))
93
			{
94
				$this->u_password=md5($u_pw);
95
			}
4 lars 96
		}
97
 
98
		function save()
99
		{
5 lars 100
			global $db, $prefix;
29 lars 101
			$sql="UPDATE $prefix"."auth_user SET u_name='$this->u_name', u_email='$this->u_email', u_type=$this->u_type, u_lang='$this->u_lang', u_active=$this->u_active, u_key='$this->u_key', u_password='$this->u_password' WHERE u_id=$this->u_id";
4 lars 102
			return $db->query($sql);
103
		}
104
		function UserData($u_name)
105
		{
5 lars 106
			global $db, $error, $meld, $db_meld, $prefix;
107
			$sql="SELECT * FROM $prefix"."auth_user WHERE u_name='$u_name'";
4 lars 108
			$res=$db->query($sql);
109
			if (true == DB::isError($res))
110
			{
111
				$error="true";
112
				$meld="Ein Fehler ist aufgetreten!";
113
				$db_meld=$res->getUserInfo();
114
				return $error;
115
			}
116
			else
117
			{
118
				$row=$res->fetchRow();
119
				$this->u_id=$row["u_id"];
52 lars 120
				$this->u_name=stripslashes($row["u_name"]);
121
				$this->u_email=stripslashes($row["u_email"]);
4 lars 122
				$this->u_type=$row["u_type"];
123
				$this->u_password=$row["u_password"];
124
				$this->u_active=$row["u_active"];
125
				$this->u_key=$row["u_key"];
52 lars 126
				$this->u_lang=stripslashes($row["u_lang"]);
4 lars 127
				return $this;
128
			}
129
		}
130
	}
131
?>