bd22f03937341179a1beaf87aafcde8e61882589
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) require_once("inc/db_connect.php");
19) 
20) 
21) 
22) function customer_may_have_useraccounts()
23) {
24)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

25)   $result = db_query("SELECT COUNT(*) FROM system.useraccounts WHERE kunde={$customerno}");
26)   return (mysql_num_rows($result) > 0);
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

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

bernd authored 16 years ago

29) function customer_useraccount($uid) {
30)   $uid = (int) $uid;
31)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

32)   $result = db_query("SELECT 1 FROM system.useraccounts WHERE kunde={$customerno} AND uid={$uid} AND kundenaccount=1");
33)   return mysql_num_rows($result) > 0;
bernd nicht mehr der user mit der...

bernd authored 16 years ago

34) }
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

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

bernd authored 16 years ago

36) function primary_useraccount()
37) {
38)   if (! ($_SESSION['role'] & ROLE_SYSTEMUSER))
39)     return NULL;
40)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

41)   $result = db_query("SELECT MIN(uid) AS uid FROM system.useraccounts WHERE kunde={$customerno}");
42)   $uid = mysql_fetch_object($result)->uid;
bernd Primärer Useraccount kann d...

bernd authored 16 years ago

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

bernd authored 14 years ago

48) function available_shells()
49) {
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

51)   $ret = array();
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

52)   while ($s = mysql_fetch_assoc($result))
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

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

bernd authored 16 years ago

60) 
61) function list_useraccounts()
62) {
63)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

64)   $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

65)   $ret = array();
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

66)   while ($item = mysql_fetch_assoc($result))
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

78)   $customerno = (int) $customerno;
79)   if ($customerno == 0)
80)     $customerno = $_SESSION['customerinfo']['customerno'];
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

83)     system_failure("Cannot find the requestes useraccount (for this customer).");
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

84)   return mysql_fetch_assoc($result);
bernd Systemuser-Modul hinzugefügt

bernd authored 16 years ago

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

bernd authored 14 years ago

87) function get_used_quota($uid)
88) {
89)   $uid = (int) $uid;
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

90)   $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

91)   $ret = array();
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

92)   while ($line = mysql_fetch_assoc($result))
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 14 years ago

102)   $customerno = NULL;
103)   if ($_SESSION['role'] & ROLE_CUSTOMER)
104)     $customerno = (int) $_SESSION['customerinfo']['customerno'];
105)   else
106)     $customerno = (int) $_SESSION['userinfo']['customerno'];
107) 
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

111) 
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

112)   db_query("UPDATE system.useraccounts SET name={$fullname}, quota={$quota}, shell='{$shell}' WHERE kunde={$customerno} AND uid={$uid}");
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

117) function get_customer_quota()
118) {
119)   $cid = (int) $_SESSION['customerinfo']['customerno'];
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

120)   $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}");
121)   $ret = mysql_fetch_assoc($result);
bernd Überarbeitetes Systemuser-M...

bernd authored 14 years ago

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