fe8d7c2025e33349ab1e51c0e906ec3ee69dcff2
bernd Systemuser-Modul hinzugefügt

bernd authored 17 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) 
Hanno Böck Change license from CC0 to...

Hanno Böck authored 2 years ago

5) Written 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) 
Hanno Böck Change license from CC0 to...

Hanno Böck authored 2 years ago

9) This code is published under a 0BSD license.
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

10) 
11) 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.
12) */
bernd Systemuser-Modul hinzugefügt

bernd authored 17 years ago

13) 
14) require_once("inc/debug.php");
15) 
16) 
17) 
18) function customer_may_have_useraccounts()
19) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

20)     $customerno = (int) $_SESSION['customerinfo']['customerno'];
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

21)     $result = db_query("SELECT COUNT(*) FROM system.useraccounts WHERE kunde=?", [$customerno]);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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

bernd authored 17 years ago

23) }
24) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

25) function customer_useraccount($uid)
26) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

27)     $args = [":uid" => $uid, ":customerno" => $_SESSION['customerinfo']['customerno']];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

28)     $result = db_query("SELECT 1 FROM system.useraccounts WHERE kunde=:customerno AND uid=:uid AND kundenaccount=1", $args);
29)     return $result->rowCount() > 0;
bernd nicht mehr der user mit der...

bernd authored 17 years ago

30) }
bernd Systemuser-Modul hinzugefügt

bernd authored 17 years ago

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

bernd authored 17 years ago

32) function primary_useraccount()
33) {
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 1 year ago

34)     if (!($_SESSION['role'] & ROLE_SYSTEMUSER)) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

35)         return null;
36)     }
37)     $customerno = (int) $_SESSION['customerinfo']['customerno'];
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

38)     $result = db_query("SELECT MIN(uid) AS uid FROM system.useraccounts WHERE kunde=?", [$customerno]);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

39)     $uid = $result->fetch(PDO::FETCH_OBJ)->uid;
40)     DEBUG("primary useraccount: {$uid}");
41)     return $uid;
bernd Primärer Useraccount kann d...

bernd authored 17 years ago

42) }
43) 
44) 
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

45) function available_shells()
46) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

47)     $result = db_query("SELECT path, name FROM system.shells WHERE usable=?", [1]);
48)     $ret = [];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

49)     while ($s = $result->fetch()) {
50)         $ret[$s['path']] = $s['name'];
51)     }
52)     DEBUG($ret);
53)     return $ret;
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

54) }
55) 
bernd Systemuser-Modul hinzugefügt

bernd authored 17 years ago

56) 
57) function list_useraccounts()
58) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

59)     $customerno = (int) $_SESSION['customerinfo']['customerno'];
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

60)     $result = db_query("SELECT uid,username,name,erstellungsdatum,quota,shell FROM system.useraccounts WHERE kunde=?", [$customerno]);
61)     $ret = [];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

62)     while ($item = $result->fetch()) {
63)         array_push($ret, $item);
64)     }
65)     #DEBUG($ret);
66)     return $ret;
bernd Systemuser-Modul hinzugefügt

bernd authored 17 years ago

67) }
68) 
69) 
Hanno Böck codingstyle, spaces between...

Hanno Böck authored 1 year ago

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

bernd authored 17 years ago

71) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

72)     $uid = (int) $uid;
73)     $customerno = (int) $customerno;
74)     if ($customerno == 0) {
75)         $customerno = $_SESSION['customerinfo']['customerno'];
76)     }
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

77)     $args = [":uid" => $uid, ":customerno" => $customerno];
Bernd Wurst add feature to disable SSH...

Bernd Wurst authored 4 years ago

78)     $result = db_query("SELECT uid,username,name,shell,server,quota,erstellungsdatum,passwordlogin FROM system.useraccounts WHERE kunde=:customerno AND uid=:uid", $args);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

79)     if ($result->rowCount() == 0) {
80)         system_failure("Cannot find the requestes useraccount (for this customer).");
81)     }
82)     return $result->fetch();
bernd Systemuser-Modul hinzugefügt

bernd authored 17 years ago

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

bernd authored 14 years ago

85) function get_used_quota($uid)
86) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

87)     $uid = (int) $uid;
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

88)     $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]);
89)     $ret = [];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

90)     while ($line = $result->fetch()) {
91)         $ret[] = $line;
92)     }
93)     #DEBUG($ret);
94)     return $ret;
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

95) }
bernd Systemuser-Modul hinzugefügt

bernd authored 17 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 17 years ago

99) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

100)     $customerno = null;
101)     if ($_SESSION['role'] & ROLE_CUSTOMER) {
102)         $customerno = (int) $_SESSION['customerinfo']['customerno'];
103)     } else {
104)         $customerno = (int) $_SESSION['userinfo']['customerno'];
105)     }
106) 
107)     if ($account['name'] == '') {
108)         $account['name'] = null;
109)     }
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

110)     $args = [":fullname" => filter_input_oneline($account['name']),
Hanno Böck Neue codingstyle-rule array...

Hanno Böck authored 9 months ago

111)         ":shell" => filter_input_oneline($account['shell']),
112)         ":quota" => $account['quota'],
113)         ":uid" => $account['uid'],
114)         ":customerno" => $customerno,
115)         ":passwordlogin" => $account['passwordlogin'], ];
bernd Systemuser-Modul hinzugefügt

bernd authored 17 years ago

116) 
Bernd Wurst add feature to disable SSH...

Bernd Wurst authored 4 years ago

117)     db_query("UPDATE system.useraccounts SET name=:fullname, quota=:quota, shell=:shell, passwordlogin=:passwordlogin WHERE kunde=:customerno AND uid=:uid", $args);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

118)     logger(LOG_INFO, "modules/systemuser/include/useraccounts", "systemuser", "updated details for uid {$args[":uid"]}");
bernd Systemuser-Modul hinzugefügt

bernd authored 17 years ago

119) }
120) 
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

121) function get_customer_quota()
122) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

123)     $cid = (int) $_SESSION['customerinfo']['customerno'];
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

124)     $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]);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

125)     $ret = $result->fetch();
126)     DEBUG($ret);
127)     return $ret;