f6d569664d6cb732eac3b3f43cac3e3a866c65db
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) 
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'];
Bernd Wurst Weitere Prepared-Statements

Bernd Wurst authored 10 years ago

24)   $result = db_query("SELECT COUNT(*) FROM system.useraccounts WHERE kunde=?", array($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) {
Bernd Wurst Weitere Prepared-Statements

Bernd Wurst authored 10 years ago

29)   $args = array(":uid" => $uid, ":customerno" => $_SESSION['customerinfo']['customerno']);
30)   $result = db_query("SELECT 1 FROM system.useraccounts WHERE kunde=:customerno AND uid=:uid AND kundenaccount=1", $args);
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

32) }
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

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

bernd authored 16 years ago

34) function primary_useraccount()
35) {
36)   if (! ($_SESSION['role'] & ROLE_SYSTEMUSER))
37)     return NULL;
38)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
Bernd Wurst Weitere Prepared-Statements

Bernd Wurst authored 10 years ago

39)   $result = db_query("SELECT MIN(uid) AS uid FROM system.useraccounts WHERE kunde=?", array($customerno));
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

46) function available_shells()
47) {
Bernd Wurst Zwischenversion

Bernd Wurst authored 7 years ago

48)   $result = db_query("SELECT path, name FROM system.shells WHERE usable=?", array(1));
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

58) 
59) function list_useraccounts()
60) {
61)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
Bernd Wurst Weitere Prepared-Statements

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

65)   {
66)     array_push($ret, $item);
67)   }
Bernd Wurst Alten Debug-Output entfernt...

Bernd Wurst authored 6 years ago

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

bernd authored 16 years ago

69)   return $ret;
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) {
75)   $uid = (int) $uid;
bernd Erlaube Änderung von Name u...

bernd authored 14 years ago

76)   $customerno = (int) $customerno;
77)   if ($customerno == 0)
78)     $customerno = $_SESSION['customerinfo']['customerno'];
Bernd Wurst Weitere Prepared-Statements

Bernd Wurst authored 10 years ago

79)   $args = array(":uid" => $uid, ":customerno" => $customerno);
Bernd Wurst Zeige Benutzeraccount-Stamm...

Bernd Wurst authored 10 years ago

80)   $result = db_query("SELECT uid,username,name,shell,server,quota,erstellungsdatum FROM system.useraccounts WHERE kunde=:customerno AND uid=:uid", $args);
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 Wurst Weitere Prepared-Statements

Bernd Wurst authored 10 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=?", array($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;
Bernd Wurst Alten Debug-Output entfernt...

Bernd Wurst authored 6 years ago

93)   #DEBUG($ret);
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

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 Erlaube Änderung von Name u...

bernd authored 14 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) 
Bernd Wurst Weitere Prepared-Statements

Bernd Wurst authored 10 years ago

106)   if ($account['name'] == '') {
107)     $account['name'] = NULL;
108)   }  
109)   $args = array(":fullname" => filter_input_general($account['name']),
110)                 ":shell" => filter_input_general($account['shell']),
111)                 ":quota" => $account['quota'],
112)                 ":uid" => $account['uid'],
113)                 ":customerno" => $customerno);
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

114) 
Bernd Wurst Weitere Prepared-Statements

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

117) 
118) }
119) 
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

120) function get_customer_quota()
121) {
122)   $cid = (int) $_SESSION['customerinfo']['customerno'];
Bernd Wurst Weitere Prepared-Statements

Bernd Wurst authored 10 years ago

123)   $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=?", array($cid));
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

125)   DEBUG($ret);
126)   return $ret;
127) }
128)