f1f231f5e074dfa038e70a67d39849e80f2b4b4d
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

1) <?php
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

2) /*
3) This file belongs to the Webinterface of schokokeks.org Hosting
4) 
Bernd Wurst Updated copyright notice (2...

Bernd Wurst authored 11 years ago

5) Written 2008-2013 by schokokeks.org Hosting, namely
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

6)   Bernd Wurst <bernd@schokokeks.org>
7)   Hanno Böck <hanno@schokokeks.org>
8) 
9) To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
10) 
11) You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see 
12) http://creativecommons.org/publicdomain/zero/1.0/
13) 
14) Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
15) */
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

16) 
17) require_once("inc/debug.php");
18) 
19) 
20) 
21) function customer_may_have_useraccounts()
22) {
23)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
24)   $result = db_query("SELECT COUNT(*) FROM system.useraccounts WHERE kunde={$customerno}");
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

25)   return ($result->rowCount() > 0);
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

26) }
27) 
bernd nicht mehr der user mit der...

bernd authored 16 years ago

28) function customer_useraccount($uid) {
29)   $uid = (int) $uid;
30)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
31)   $result = db_query("SELECT 1 FROM system.useraccounts WHERE kunde={$customerno} AND uid={$uid} AND kundenaccount=1");
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

32)   return $result->rowCount() > 0;
bernd nicht mehr der user mit der...

bernd authored 16 years ago

33) }
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

34) 
bernd Primärer Useraccount kann d...

bernd authored 16 years ago

35) function primary_useraccount()
36) {
37)   if (! ($_SESSION['role'] & ROLE_SYSTEMUSER))
38)     return NULL;
39)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
40)   $result = db_query("SELECT MIN(uid) AS uid FROM system.useraccounts WHERE kunde={$customerno}");
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

41)   $uid = $result->fetch(PDO::FETCH_OBJ)->uid;
bernd Primärer Useraccount kann d...

bernd authored 16 years ago

42)   DEBUG("primary useraccount: {$uid}");
43)   return $uid;
44) }
45) 
46) 
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

47) function available_shells()
48) {
49)   $result = db_query("SELECT path, name FROM system.shells WHERE usable=1");
50)   $ret = array();
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

51)   while ($s = $result->fetch())
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

52)   {
53)     $ret[$s['path']] = $s['name'];
54)   }
55)   DEBUG($ret);
56)   return $ret;
57) }
58) 
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

59) 
60) function list_useraccounts()
61) {
62)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

63)   $result = db_query("SELECT uid,username,name,erstellungsdatum,quota,shell FROM system.useraccounts WHERE kunde={$customerno}");
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

64)   $ret = array();
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

65)   while ($item = $result->fetch())
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

66)   {
67)     array_push($ret, $item);
68)   }
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

69)   DEBUG($ret);
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

70)   return $ret;
71) }
72) 
73) 
bernd Erlaube Änderung von Name u...

bernd authored 14 years ago

74) function get_account_details($uid, $customerno=0)
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

75) {
76)   $uid = (int) $uid;
bernd Erlaube Änderung von Name u...

bernd authored 14 years ago

77)   $customerno = (int) $customerno;
78)   if ($customerno == 0)
79)     $customerno = $_SESSION['customerinfo']['customerno'];
80)   $result = db_query("SELECT uid,username,name,shell,quota,erstellungsdatum FROM system.useraccounts WHERE kunde={$customerno} AND uid={$uid}");
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

81)   if ($result->rowCount() == 0)
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

82)     system_failure("Cannot find the requestes useraccount (for this customer).");
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

83)   return $result->fetch();
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

84) }
85) 
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

86) function get_used_quota($uid)
87) {
88)   $uid = (int) $uid;
bernd Mailaccount-Quota auch bei...

bernd authored 13 years ago

89)   $result = db_query("SELECT s.hostname AS server, systemquota, systemquota_used, mailquota, mailquota_used FROM system.v_quota AS q LEFT JOIN system.servers AS s ON (s.id=q.server) WHERE uid='{$uid}'");
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

90)   $ret = array();
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

91)   while ($line = $result->fetch())
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

92)     $ret[] = $line;
93)   DEBUG($ret);
94)   return $ret;
95) }
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

96) 
97) 
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

98) function set_account_details($account)
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

99) {
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

100)   $uid = (int) $account['uid'];
bernd Erlaube Änderung von Name u...

bernd authored 14 years ago

101)   $customerno = NULL;
102)   if ($_SESSION['role'] & ROLE_CUSTOMER)
103)     $customerno = (int) $_SESSION['customerinfo']['customerno'];
104)   else
105)     $customerno = (int) $_SESSION['userinfo']['customerno'];
106) 
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

107)   $fullname = maybe_null(db_escape_string(filter_input_general($account['name'])));
108)   $shell = db_escape_string(filter_input_general($account['shell']));
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

109)   $quota = (int) $account['quota'];
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

110) 
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

111)   db_query("UPDATE system.useraccounts SET name={$fullname}, quota={$quota}, shell='{$shell}' WHERE kunde={$customerno} AND uid={$uid}");
112)   logger(LOG_INFO, "modules/systemuser/include/useraccounts", "systemuser", "updated details for uid {$uid}");
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

113) 
114) }
115) 
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

116) function get_customer_quota()
117) {
118)   $cid = (int) $_SESSION['customerinfo']['customerno'];
119)   $result = db_query("SELECT SUM(u.quota) AS assigned, cq.quota AS max FROM system.customerquota AS cq INNER JOIN system.useraccounts AS u ON (u.kunde=cq.cid) WHERE cq.cid={$cid}");
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

120)   $ret = $result->fetch();
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

121)   DEBUG($ret);
122)   return $ret;
123) }
124)