96649f21ba18d07757afa9d98998f7a22c0d86a3
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 Copyright year update

Bernd Wurst authored 6 years ago

5) Written 2008-2018 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) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

11) You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

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) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

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

Hanno Böck authored 2 years ago

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

Hanno authored 5 years ago

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

bernd authored 16 years ago

26) }
27) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

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

Hanno Böck authored 2 years ago

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

Hanno authored 5 years ago

31)     $result = db_query("SELECT 1 FROM system.useraccounts WHERE kunde=:customerno AND uid=:uid AND kundenaccount=1", $args);
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) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

37)     if (! ($_SESSION['role'] & ROLE_SYSTEMUSER)) {
38)         return null;
39)     }
40)     $customerno = (int) $_SESSION['customerinfo']['customerno'];
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 2 years ago

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

Hanno authored 5 years ago

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

bernd authored 16 years ago

45) }
46) 
47) 
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

48) function available_shells()
49) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 2 years ago

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

Hanno authored 5 years ago

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

bernd authored 14 years ago

57) }
58) 
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

59) 
60) function list_useraccounts()
61) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

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

Hanno Böck authored 2 years ago

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

Hanno authored 5 years ago

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

bernd authored 16 years ago

70) }
71) 
72) 
bernd Erlaube Änderung von Name u...

bernd authored 14 years ago

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

bernd authored 16 years ago

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

Hanno authored 5 years ago

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

Hanno Böck authored 2 years ago

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

Bernd Wurst authored 3 years ago

81)     $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 5 years ago

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

bernd authored 16 years ago

86) }
87) 
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

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

Hanno authored 5 years ago

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

Hanno Böck authored 2 years ago

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

Hanno authored 5 years ago

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

bernd authored 14 years ago

98) }
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

Hanno authored 5 years ago

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

Hanno Böck authored 2 years ago

113)     $args = [":fullname" => filter_input_oneline($account['name']),
Bernd Wurst Umstellung von filter_input...

Bernd Wurst authored 4 years ago

114)                 ":shell" => filter_input_oneline($account['shell']),
Bernd Wurst Weitere Prepared-Statements

Bernd Wurst authored 10 years ago

115)                 ":quota" => $account['quota'],
116)                 ":uid" => $account['uid'],
Bernd Wurst add feature to disable SSH...

Bernd Wurst authored 3 years ago

117)                 ":customerno" => $customerno,
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 2 years ago

118)                 ":passwordlogin" => $account['passwordlogin'], ];
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

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

Bernd Wurst authored 3 years ago

120)     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 5 years ago

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

bernd authored 16 years ago

122) }
123) 
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

124) function get_customer_quota()
125) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

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

Hanno Böck authored 2 years ago

127)     $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 5 years ago

128)     $ret = $result->fetch();
129)     DEBUG($ret);
130)     return $ret;