... | ... |
@@ -21,13 +21,13 @@ require_once("inc/debug.php"); |
21 | 21 |
function customer_may_have_useraccounts() |
22 | 22 |
{ |
23 | 23 |
$customerno = (int) $_SESSION['customerinfo']['customerno']; |
24 |
- $result = db_query("SELECT COUNT(*) FROM system.useraccounts WHERE kunde=?", array($customerno)); |
|
24 |
+ $result = db_query("SELECT COUNT(*) FROM system.useraccounts WHERE kunde=?", [$customerno]); |
|
25 | 25 |
return ($result->rowCount() > 0); |
26 | 26 |
} |
27 | 27 |
|
28 | 28 |
function customer_useraccount($uid) |
29 | 29 |
{ |
30 |
- $args = array(":uid" => $uid, ":customerno" => $_SESSION['customerinfo']['customerno']); |
|
30 |
+ $args = [":uid" => $uid, ":customerno" => $_SESSION['customerinfo']['customerno']]; |
|
31 | 31 |
$result = db_query("SELECT 1 FROM system.useraccounts WHERE kunde=:customerno AND uid=:uid AND kundenaccount=1", $args); |
32 | 32 |
return $result->rowCount() > 0; |
33 | 33 |
} |
... | ... |
@@ -38,7 +38,7 @@ function primary_useraccount() |
38 | 38 |
return null; |
39 | 39 |
} |
40 | 40 |
$customerno = (int) $_SESSION['customerinfo']['customerno']; |
41 |
- $result = db_query("SELECT MIN(uid) AS uid FROM system.useraccounts WHERE kunde=?", array($customerno)); |
|
41 |
+ $result = db_query("SELECT MIN(uid) AS uid FROM system.useraccounts WHERE kunde=?", [$customerno]); |
|
42 | 42 |
$uid = $result->fetch(PDO::FETCH_OBJ)->uid; |
43 | 43 |
DEBUG("primary useraccount: {$uid}"); |
44 | 44 |
return $uid; |
... | ... |
@@ -47,8 +47,8 @@ function primary_useraccount() |
47 | 47 |
|
48 | 48 |
function available_shells() |
49 | 49 |
{ |
50 |
- $result = db_query("SELECT path, name FROM system.shells WHERE usable=?", array(1)); |
|
51 |
- $ret = array(); |
|
50 |
+ $result = db_query("SELECT path, name FROM system.shells WHERE usable=?", [1]); |
|
51 |
+ $ret = []; |
|
52 | 52 |
while ($s = $result->fetch()) { |
53 | 53 |
$ret[$s['path']] = $s['name']; |
54 | 54 |
} |
... | ... |
@@ -60,8 +60,8 @@ function available_shells() |
60 | 60 |
function list_useraccounts() |
61 | 61 |
{ |
62 | 62 |
$customerno = (int) $_SESSION['customerinfo']['customerno']; |
63 |
- $result = db_query("SELECT uid,username,name,erstellungsdatum,quota,shell FROM system.useraccounts WHERE kunde=?", array($customerno)); |
|
64 |
- $ret = array(); |
|
63 |
+ $result = db_query("SELECT uid,username,name,erstellungsdatum,quota,shell FROM system.useraccounts WHERE kunde=?", [$customerno]); |
|
64 |
+ $ret = []; |
|
65 | 65 |
while ($item = $result->fetch()) { |
66 | 66 |
array_push($ret, $item); |
67 | 67 |
} |
... | ... |
@@ -77,7 +77,7 @@ function get_account_details($uid, $customerno=0) |
77 | 77 |
if ($customerno == 0) { |
78 | 78 |
$customerno = $_SESSION['customerinfo']['customerno']; |
79 | 79 |
} |
80 |
- $args = array(":uid" => $uid, ":customerno" => $customerno); |
|
80 |
+ $args = [":uid" => $uid, ":customerno" => $customerno]; |
|
81 | 81 |
$result = db_query("SELECT uid,username,name,shell,server,quota,erstellungsdatum,passwordlogin FROM system.useraccounts WHERE kunde=:customerno AND uid=:uid", $args); |
82 | 82 |
if ($result->rowCount() == 0) { |
83 | 83 |
system_failure("Cannot find the requestes useraccount (for this customer)."); |
... | ... |
@@ -88,8 +88,8 @@ function get_account_details($uid, $customerno=0) |
88 | 88 |
function get_used_quota($uid) |
89 | 89 |
{ |
90 | 90 |
$uid = (int) $uid; |
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=?", array($uid)); |
|
92 |
- $ret = array(); |
|
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 = []; |
|
93 | 93 |
while ($line = $result->fetch()) { |
94 | 94 |
$ret[] = $line; |
95 | 95 |
} |
... | ... |
@@ -110,12 +110,12 @@ function set_account_details($account) |
110 | 110 |
if ($account['name'] == '') { |
111 | 111 |
$account['name'] = null; |
112 | 112 |
} |
113 |
- $args = array(":fullname" => filter_input_oneline($account['name']), |
|
113 |
+ $args = [":fullname" => filter_input_oneline($account['name']), |
|
114 | 114 |
":shell" => filter_input_oneline($account['shell']), |
115 | 115 |
":quota" => $account['quota'], |
116 | 116 |
":uid" => $account['uid'], |
117 | 117 |
":customerno" => $customerno, |
118 |
- ":passwordlogin" => $account['passwordlogin']); |
|
118 |
+ ":passwordlogin" => $account['passwordlogin'], ]; |
|
119 | 119 |
|
120 | 120 |
db_query("UPDATE system.useraccounts SET name=:fullname, quota=:quota, shell=:shell, passwordlogin=:passwordlogin WHERE kunde=:customerno AND uid=:uid", $args); |
121 | 121 |
logger(LOG_INFO, "modules/systemuser/include/useraccounts", "systemuser", "updated details for uid {$args[":uid"]}"); |
... | ... |
@@ -124,7 +124,7 @@ function set_account_details($account) |
124 | 124 |
function get_customer_quota() |
125 | 125 |
{ |
126 | 126 |
$cid = (int) $_SESSION['customerinfo']['customerno']; |
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=?", array($cid)); |
|
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]); |
|
128 | 128 |
$ret = $result->fetch(); |
129 | 129 |
DEBUG($ret); |
130 | 130 |
return $ret; |
... | ... |
@@ -78,7 +78,7 @@ function get_account_details($uid, $customerno=0) |
78 | 78 |
$customerno = $_SESSION['customerinfo']['customerno']; |
79 | 79 |
} |
80 | 80 |
$args = array(":uid" => $uid, ":customerno" => $customerno); |
81 |
- $result = db_query("SELECT uid,username,name,shell,server,quota,erstellungsdatum FROM system.useraccounts WHERE kunde=:customerno AND uid=:uid", $args); |
|
81 |
+ $result = db_query("SELECT uid,username,name,shell,server,quota,erstellungsdatum,passwordlogin FROM system.useraccounts WHERE kunde=:customerno AND uid=:uid", $args); |
|
82 | 82 |
if ($result->rowCount() == 0) { |
83 | 83 |
system_failure("Cannot find the requestes useraccount (for this customer)."); |
84 | 84 |
} |
... | ... |
@@ -114,9 +114,10 @@ function set_account_details($account) |
114 | 114 |
":shell" => filter_input_oneline($account['shell']), |
115 | 115 |
":quota" => $account['quota'], |
116 | 116 |
":uid" => $account['uid'], |
117 |
- ":customerno" => $customerno); |
|
117 |
+ ":customerno" => $customerno, |
|
118 |
+ ":passwordlogin" => $account['passwordlogin']); |
|
118 | 119 |
|
119 |
- db_query("UPDATE system.useraccounts SET name=:fullname, quota=:quota, shell=:shell WHERE kunde=:customerno AND uid=:uid", $args); |
|
120 |
+ db_query("UPDATE system.useraccounts SET name=:fullname, quota=:quota, shell=:shell, passwordlogin=:passwordlogin WHERE kunde=:customerno AND uid=:uid", $args); |
|
120 | 121 |
logger(LOG_INFO, "modules/systemuser/include/useraccounts", "systemuser", "updated details for uid {$args[":uid"]}"); |
121 | 122 |
} |
122 | 123 |
|
... | ... |
@@ -110,8 +110,8 @@ function set_account_details($account) |
110 | 110 |
if ($account['name'] == '') { |
111 | 111 |
$account['name'] = null; |
112 | 112 |
} |
113 |
- $args = array(":fullname" => filter_input_general($account['name']), |
|
114 |
- ":shell" => filter_input_general($account['shell']), |
|
113 |
+ $args = array(":fullname" => filter_input_oneline($account['name']), |
|
114 |
+ ":shell" => filter_input_oneline($account['shell']), |
|
115 | 115 |
":quota" => $account['quota'], |
116 | 116 |
":uid" => $account['uid'], |
117 | 117 |
":customerno" => $customerno); |
... | ... |
@@ -8,7 +8,7 @@ Written 2008-2018 by schokokeks.org Hosting, namely |
8 | 8 |
|
9 | 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 | 10 |
|
11 |
-You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see |
|
11 |
+You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see |
|
12 | 12 |
http://creativecommons.org/publicdomain/zero/1.0/ |
13 | 13 |
|
14 | 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. |
... | ... |
@@ -20,111 +20,111 @@ require_once("inc/debug.php"); |
20 | 20 |
|
21 | 21 |
function customer_may_have_useraccounts() |
22 | 22 |
{ |
23 |
- $customerno = (int) $_SESSION['customerinfo']['customerno']; |
|
24 |
- $result = db_query("SELECT COUNT(*) FROM system.useraccounts WHERE kunde=?", array($customerno)); |
|
25 |
- return ($result->rowCount() > 0); |
|
23 |
+ $customerno = (int) $_SESSION['customerinfo']['customerno']; |
|
24 |
+ $result = db_query("SELECT COUNT(*) FROM system.useraccounts WHERE kunde=?", array($customerno)); |
|
25 |
+ return ($result->rowCount() > 0); |
|
26 | 26 |
} |
27 | 27 |
|
28 |
-function customer_useraccount($uid) { |
|
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); |
|
31 |
- return $result->rowCount() > 0; |
|
28 |
+function customer_useraccount($uid) |
|
29 |
+{ |
|
30 |
+ $args = array(":uid" => $uid, ":customerno" => $_SESSION['customerinfo']['customerno']); |
|
31 |
+ $result = db_query("SELECT 1 FROM system.useraccounts WHERE kunde=:customerno AND uid=:uid AND kundenaccount=1", $args); |
|
32 |
+ return $result->rowCount() > 0; |
|
32 | 33 |
} |
33 | 34 |
|
34 | 35 |
function primary_useraccount() |
35 | 36 |
{ |
36 |
- if (! ($_SESSION['role'] & ROLE_SYSTEMUSER)) |
|
37 |
- return NULL; |
|
38 |
- $customerno = (int) $_SESSION['customerinfo']['customerno']; |
|
39 |
- $result = db_query("SELECT MIN(uid) AS uid FROM system.useraccounts WHERE kunde=?", array($customerno)); |
|
40 |
- $uid = $result->fetch(PDO::FETCH_OBJ)->uid; |
|
41 |
- DEBUG("primary useraccount: {$uid}"); |
|
42 |
- return $uid; |
|
37 |
+ if (! ($_SESSION['role'] & ROLE_SYSTEMUSER)) { |
|
38 |
+ return null; |
|
39 |
+ } |
|
40 |
+ $customerno = (int) $_SESSION['customerinfo']['customerno']; |
|
41 |
+ $result = db_query("SELECT MIN(uid) AS uid FROM system.useraccounts WHERE kunde=?", array($customerno)); |
|
42 |
+ $uid = $result->fetch(PDO::FETCH_OBJ)->uid; |
|
43 |
+ DEBUG("primary useraccount: {$uid}"); |
|
44 |
+ return $uid; |
|
43 | 45 |
} |
44 | 46 |
|
45 | 47 |
|
46 | 48 |
function available_shells() |
47 | 49 |
{ |
48 |
- $result = db_query("SELECT path, name FROM system.shells WHERE usable=?", array(1)); |
|
49 |
- $ret = array(); |
|
50 |
- while ($s = $result->fetch()) |
|
51 |
- { |
|
52 |
- $ret[$s['path']] = $s['name']; |
|
53 |
- } |
|
54 |
- DEBUG($ret); |
|
55 |
- return $ret; |
|
50 |
+ $result = db_query("SELECT path, name FROM system.shells WHERE usable=?", array(1)); |
|
51 |
+ $ret = array(); |
|
52 |
+ while ($s = $result->fetch()) { |
|
53 |
+ $ret[$s['path']] = $s['name']; |
|
54 |
+ } |
|
55 |
+ DEBUG($ret); |
|
56 |
+ return $ret; |
|
56 | 57 |
} |
57 | 58 |
|
58 | 59 |
|
59 | 60 |
function list_useraccounts() |
60 | 61 |
{ |
61 |
- $customerno = (int) $_SESSION['customerinfo']['customerno']; |
|
62 |
- $result = db_query("SELECT uid,username,name,erstellungsdatum,quota,shell FROM system.useraccounts WHERE kunde=?", array($customerno)); |
|
63 |
- $ret = array(); |
|
64 |
- while ($item = $result->fetch()) |
|
65 |
- { |
|
66 |
- array_push($ret, $item); |
|
67 |
- } |
|
68 |
- #DEBUG($ret); |
|
69 |
- return $ret; |
|
62 |
+ $customerno = (int) $_SESSION['customerinfo']['customerno']; |
|
63 |
+ $result = db_query("SELECT uid,username,name,erstellungsdatum,quota,shell FROM system.useraccounts WHERE kunde=?", array($customerno)); |
|
64 |
+ $ret = array(); |
|
65 |
+ while ($item = $result->fetch()) { |
|
66 |
+ array_push($ret, $item); |
|
67 |
+ } |
|
68 |
+ #DEBUG($ret); |
|
69 |
+ return $ret; |
|
70 | 70 |
} |
71 | 71 |
|
72 | 72 |
|
73 | 73 |
function get_account_details($uid, $customerno=0) |
74 | 74 |
{ |
75 |
- $uid = (int) $uid; |
|
76 |
- $customerno = (int) $customerno; |
|
77 |
- if ($customerno == 0) |
|
78 |
- $customerno = $_SESSION['customerinfo']['customerno']; |
|
79 |
- $args = array(":uid" => $uid, ":customerno" => $customerno); |
|
80 |
- $result = db_query("SELECT uid,username,name,shell,server,quota,erstellungsdatum FROM system.useraccounts WHERE kunde=:customerno AND uid=:uid", $args); |
|
81 |
- if ($result->rowCount() == 0) |
|
82 |
- system_failure("Cannot find the requestes useraccount (for this customer)."); |
|
83 |
- return $result->fetch(); |
|
75 |
+ $uid = (int) $uid; |
|
76 |
+ $customerno = (int) $customerno; |
|
77 |
+ if ($customerno == 0) { |
|
78 |
+ $customerno = $_SESSION['customerinfo']['customerno']; |
|
79 |
+ } |
|
80 |
+ $args = array(":uid" => $uid, ":customerno" => $customerno); |
|
81 |
+ $result = db_query("SELECT uid,username,name,shell,server,quota,erstellungsdatum FROM system.useraccounts WHERE kunde=:customerno AND uid=:uid", $args); |
|
82 |
+ if ($result->rowCount() == 0) { |
|
83 |
+ system_failure("Cannot find the requestes useraccount (for this customer)."); |
|
84 |
+ } |
|
85 |
+ return $result->fetch(); |
|
84 | 86 |
} |
85 | 87 |
|
86 | 88 |
function get_used_quota($uid) |
87 | 89 |
{ |
88 |
- $uid = (int) $uid; |
|
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)); |
|
90 |
- $ret = array(); |
|
91 |
- while ($line = $result->fetch()) |
|
92 |
- $ret[] = $line; |
|
93 |
- #DEBUG($ret); |
|
94 |
- return $ret; |
|
90 |
+ $uid = (int) $uid; |
|
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=?", array($uid)); |
|
92 |
+ $ret = array(); |
|
93 |
+ while ($line = $result->fetch()) { |
|
94 |
+ $ret[] = $line; |
|
95 |
+ } |
|
96 |
+ #DEBUG($ret); |
|
97 |
+ return $ret; |
|
95 | 98 |
} |
96 | 99 |
|
97 | 100 |
|
98 | 101 |
function set_account_details($account) |
99 | 102 |
{ |
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 |
- if ($account['name'] == '') { |
|
107 |
- $account['name'] = NULL; |
|
108 |
- } |
|
109 |
- $args = array(":fullname" => filter_input_general($account['name']), |
|
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 |
+ } |
|
113 |
+ $args = array(":fullname" => filter_input_general($account['name']), |
|
110 | 114 |
":shell" => filter_input_general($account['shell']), |
111 | 115 |
":quota" => $account['quota'], |
112 | 116 |
":uid" => $account['uid'], |
113 | 117 |
":customerno" => $customerno); |
114 | 118 |
|
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"]}"); |
|
117 |
- |
|
119 |
+ db_query("UPDATE system.useraccounts SET name=:fullname, quota=:quota, shell=:shell WHERE kunde=:customerno AND uid=:uid", $args); |
|
120 |
+ logger(LOG_INFO, "modules/systemuser/include/useraccounts", "systemuser", "updated details for uid {$args[":uid"]}"); |
|
118 | 121 |
} |
119 | 122 |
|
120 | 123 |
function get_customer_quota() |
121 | 124 |
{ |
122 |
- $cid = (int) $_SESSION['customerinfo']['customerno']; |
|
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)); |
|
124 |
- $ret = $result->fetch(); |
|
125 |
- DEBUG($ret); |
|
126 |
- return $ret; |
|
125 |
+ $cid = (int) $_SESSION['customerinfo']['customerno']; |
|
126 |
+ $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)); |
|
127 |
+ $ret = $result->fetch(); |
|
128 |
+ DEBUG($ret); |
|
129 |
+ return $ret; |
|
127 | 130 |
} |
128 |
- |
|
129 |
- |
|
130 |
-?> |
... | ... |
@@ -65,7 +65,7 @@ function list_useraccounts() |
65 | 65 |
{ |
66 | 66 |
array_push($ret, $item); |
67 | 67 |
} |
68 |
- DEBUG($ret); |
|
68 |
+ #DEBUG($ret); |
|
69 | 69 |
return $ret; |
70 | 70 |
} |
71 | 71 |
|
... | ... |
@@ -90,7 +90,7 @@ function get_used_quota($uid) |
90 | 90 |
$ret = array(); |
91 | 91 |
while ($line = $result->fetch()) |
92 | 92 |
$ret[] = $line; |
93 |
- DEBUG($ret); |
|
93 |
+ #DEBUG($ret); |
|
94 | 94 |
return $ret; |
95 | 95 |
} |
96 | 96 |
|
... | ... |
@@ -45,7 +45,7 @@ function primary_useraccount() |
45 | 45 |
|
46 | 46 |
function available_shells() |
47 | 47 |
{ |
48 |
- $result = db_query("SELECT path, name FROM system.shells WHERE usable=1"); |
|
48 |
+ $result = db_query("SELECT path, name FROM system.shells WHERE usable=?", array(1)); |
|
49 | 49 |
$ret = array(); |
50 | 50 |
while ($s = $result->fetch()) |
51 | 51 |
{ |
... | ... |
@@ -77,7 +77,7 @@ function get_account_details($uid, $customerno=0) |
77 | 77 |
if ($customerno == 0) |
78 | 78 |
$customerno = $_SESSION['customerinfo']['customerno']; |
79 | 79 |
$args = array(":uid" => $uid, ":customerno" => $customerno); |
80 |
- $result = db_query("SELECT uid,username,name,shell,quota,erstellungsdatum FROM system.useraccounts WHERE kunde=:customerno AND uid=:uid", $args); |
|
80 |
+ $result = db_query("SELECT uid,username,name,shell,server,quota,erstellungsdatum FROM system.useraccounts WHERE kunde=:customerno AND uid=:uid", $args); |
|
81 | 81 |
if ($result->rowCount() == 0) |
82 | 82 |
system_failure("Cannot find the requestes useraccount (for this customer)."); |
83 | 83 |
return $result->fetch(); |
... | ... |
@@ -21,14 +21,13 @@ require_once("inc/debug.php"); |
21 | 21 |
function customer_may_have_useraccounts() |
22 | 22 |
{ |
23 | 23 |
$customerno = (int) $_SESSION['customerinfo']['customerno']; |
24 |
- $result = db_query("SELECT COUNT(*) FROM system.useraccounts WHERE kunde={$customerno}"); |
|
24 |
+ $result = db_query("SELECT COUNT(*) FROM system.useraccounts WHERE kunde=?", array($customerno)); |
|
25 | 25 |
return ($result->rowCount() > 0); |
26 | 26 |
} |
27 | 27 |
|
28 | 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"); |
|
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); |
|
32 | 31 |
return $result->rowCount() > 0; |
33 | 32 |
} |
34 | 33 |
|
... | ... |
@@ -37,7 +36,7 @@ function primary_useraccount() |
37 | 36 |
if (! ($_SESSION['role'] & ROLE_SYSTEMUSER)) |
38 | 37 |
return NULL; |
39 | 38 |
$customerno = (int) $_SESSION['customerinfo']['customerno']; |
40 |
- $result = db_query("SELECT MIN(uid) AS uid FROM system.useraccounts WHERE kunde={$customerno}"); |
|
39 |
+ $result = db_query("SELECT MIN(uid) AS uid FROM system.useraccounts WHERE kunde=?", array($customerno)); |
|
41 | 40 |
$uid = $result->fetch(PDO::FETCH_OBJ)->uid; |
42 | 41 |
DEBUG("primary useraccount: {$uid}"); |
43 | 42 |
return $uid; |
... | ... |
@@ -60,7 +59,7 @@ function available_shells() |
60 | 59 |
function list_useraccounts() |
61 | 60 |
{ |
62 | 61 |
$customerno = (int) $_SESSION['customerinfo']['customerno']; |
63 |
- $result = db_query("SELECT uid,username,name,erstellungsdatum,quota,shell FROM system.useraccounts WHERE kunde={$customerno}"); |
|
62 |
+ $result = db_query("SELECT uid,username,name,erstellungsdatum,quota,shell FROM system.useraccounts WHERE kunde=?", array($customerno)); |
|
64 | 63 |
$ret = array(); |
65 | 64 |
while ($item = $result->fetch()) |
66 | 65 |
{ |
... | ... |
@@ -77,7 +76,8 @@ function get_account_details($uid, $customerno=0) |
77 | 76 |
$customerno = (int) $customerno; |
78 | 77 |
if ($customerno == 0) |
79 | 78 |
$customerno = $_SESSION['customerinfo']['customerno']; |
80 |
- $result = db_query("SELECT uid,username,name,shell,quota,erstellungsdatum FROM system.useraccounts WHERE kunde={$customerno} AND uid={$uid}"); |
|
79 |
+ $args = array(":uid" => $uid, ":customerno" => $customerno); |
|
80 |
+ $result = db_query("SELECT uid,username,name,shell,quota,erstellungsdatum FROM system.useraccounts WHERE kunde=:customerno AND uid=:uid", $args); |
|
81 | 81 |
if ($result->rowCount() == 0) |
82 | 82 |
system_failure("Cannot find the requestes useraccount (for this customer)."); |
83 | 83 |
return $result->fetch(); |
... | ... |
@@ -86,7 +86,7 @@ function get_account_details($uid, $customerno=0) |
86 | 86 |
function get_used_quota($uid) |
87 | 87 |
{ |
88 | 88 |
$uid = (int) $uid; |
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}'"); |
|
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)); |
|
90 | 90 |
$ret = array(); |
91 | 91 |
while ($line = $result->fetch()) |
92 | 92 |
$ret[] = $line; |
... | ... |
@@ -97,26 +97,30 @@ function get_used_quota($uid) |
97 | 97 |
|
98 | 98 |
function set_account_details($account) |
99 | 99 |
{ |
100 |
- $uid = (int) $account['uid']; |
|
101 | 100 |
$customerno = NULL; |
102 | 101 |
if ($_SESSION['role'] & ROLE_CUSTOMER) |
103 | 102 |
$customerno = (int) $_SESSION['customerinfo']['customerno']; |
104 | 103 |
else |
105 | 104 |
$customerno = (int) $_SESSION['userinfo']['customerno']; |
106 | 105 |
|
107 |
- $fullname = maybe_null(db_escape_string(filter_input_general($account['name']))); |
|
108 |
- $shell = db_escape_string(filter_input_general($account['shell'])); |
|
109 |
- $quota = (int) $account['quota']; |
|
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); |
|
110 | 114 |
|
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}"); |
|
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"]}"); |
|
113 | 117 |
|
114 | 118 |
} |
115 | 119 |
|
116 | 120 |
function get_customer_quota() |
117 | 121 |
{ |
118 | 122 |
$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}"); |
|
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)); |
|
120 | 124 |
$ret = $result->fetch(); |
121 | 125 |
DEBUG($ret); |
122 | 126 |
return $ret; |
... | ... |
@@ -15,7 +15,6 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r |
15 | 15 |
*/ |
16 | 16 |
|
17 | 17 |
require_once("inc/debug.php"); |
18 |
-require_once("inc/db_connect.php"); |
|
19 | 18 |
|
20 | 19 |
|
21 | 20 |
|
... | ... |
@@ -23,14 +22,14 @@ function customer_may_have_useraccounts() |
23 | 22 |
{ |
24 | 23 |
$customerno = (int) $_SESSION['customerinfo']['customerno']; |
25 | 24 |
$result = db_query("SELECT COUNT(*) FROM system.useraccounts WHERE kunde={$customerno}"); |
26 |
- return (mysql_num_rows($result) > 0); |
|
25 |
+ return ($result->rowCount() > 0); |
|
27 | 26 |
} |
28 | 27 |
|
29 | 28 |
function customer_useraccount($uid) { |
30 | 29 |
$uid = (int) $uid; |
31 | 30 |
$customerno = (int) $_SESSION['customerinfo']['customerno']; |
32 | 31 |
$result = db_query("SELECT 1 FROM system.useraccounts WHERE kunde={$customerno} AND uid={$uid} AND kundenaccount=1"); |
33 |
- return mysql_num_rows($result) > 0; |
|
32 |
+ return $result->rowCount() > 0; |
|
34 | 33 |
} |
35 | 34 |
|
36 | 35 |
function primary_useraccount() |
... | ... |
@@ -39,7 +38,7 @@ function primary_useraccount() |
39 | 38 |
return NULL; |
40 | 39 |
$customerno = (int) $_SESSION['customerinfo']['customerno']; |
41 | 40 |
$result = db_query("SELECT MIN(uid) AS uid FROM system.useraccounts WHERE kunde={$customerno}"); |
42 |
- $uid = mysql_fetch_object($result)->uid; |
|
41 |
+ $uid = $result->fetch(PDO::FETCH_OBJ)->uid; |
|
43 | 42 |
DEBUG("primary useraccount: {$uid}"); |
44 | 43 |
return $uid; |
45 | 44 |
} |
... | ... |
@@ -49,7 +48,7 @@ function available_shells() |
49 | 48 |
{ |
50 | 49 |
$result = db_query("SELECT path, name FROM system.shells WHERE usable=1"); |
51 | 50 |
$ret = array(); |
52 |
- while ($s = mysql_fetch_assoc($result)) |
|
51 |
+ while ($s = $result->fetch()) |
|
53 | 52 |
{ |
54 | 53 |
$ret[$s['path']] = $s['name']; |
55 | 54 |
} |
... | ... |
@@ -63,7 +62,7 @@ function list_useraccounts() |
63 | 62 |
$customerno = (int) $_SESSION['customerinfo']['customerno']; |
64 | 63 |
$result = db_query("SELECT uid,username,name,erstellungsdatum,quota,shell FROM system.useraccounts WHERE kunde={$customerno}"); |
65 | 64 |
$ret = array(); |
66 |
- while ($item = mysql_fetch_assoc($result)) |
|
65 |
+ while ($item = $result->fetch()) |
|
67 | 66 |
{ |
68 | 67 |
array_push($ret, $item); |
69 | 68 |
} |
... | ... |
@@ -79,9 +78,9 @@ function get_account_details($uid, $customerno=0) |
79 | 78 |
if ($customerno == 0) |
80 | 79 |
$customerno = $_SESSION['customerinfo']['customerno']; |
81 | 80 |
$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) |
|
81 |
+ if ($result->rowCount() == 0) |
|
83 | 82 |
system_failure("Cannot find the requestes useraccount (for this customer)."); |
84 |
- return mysql_fetch_assoc($result); |
|
83 |
+ return $result->fetch(); |
|
85 | 84 |
} |
86 | 85 |
|
87 | 86 |
function get_used_quota($uid) |
... | ... |
@@ -89,7 +88,7 @@ function get_used_quota($uid) |
89 | 88 |
$uid = (int) $uid; |
90 | 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}'"); |
91 | 90 |
$ret = array(); |
92 |
- while ($line = mysql_fetch_assoc($result)) |
|
91 |
+ while ($line = $result->fetch()) |
|
93 | 92 |
$ret[] = $line; |
94 | 93 |
DEBUG($ret); |
95 | 94 |
return $ret; |
... | ... |
@@ -105,8 +104,8 @@ function set_account_details($account) |
105 | 104 |
else |
106 | 105 |
$customerno = (int) $_SESSION['userinfo']['customerno']; |
107 | 106 |
|
108 |
- $fullname = maybe_null(mysql_real_escape_string(filter_input_general($account['name']))); |
|
109 |
- $shell = mysql_real_escape_string(filter_input_general($account['shell'])); |
|
107 |
+ $fullname = maybe_null(db_escape_string(filter_input_general($account['name']))); |
|
108 |
+ $shell = db_escape_string(filter_input_general($account['shell'])); |
|
110 | 109 |
$quota = (int) $account['quota']; |
111 | 110 |
|
112 | 111 |
db_query("UPDATE system.useraccounts SET name={$fullname}, quota={$quota}, shell='{$shell}' WHERE kunde={$customerno} AND uid={$uid}"); |
... | ... |
@@ -118,7 +117,7 @@ function get_customer_quota() |
118 | 117 |
{ |
119 | 118 |
$cid = (int) $_SESSION['customerinfo']['customerno']; |
120 | 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}"); |
121 |
- $ret = mysql_fetch_assoc($result); |
|
120 |
+ $ret = $result->fetch(); |
|
122 | 121 |
DEBUG($ret); |
123 | 122 |
return $ret; |
124 | 123 |
} |
... | ... |
@@ -1,4 +1,18 @@ |
1 | 1 |
<?php |
2 |
+/* |
|
3 |
+This file belongs to the Webinterface of schokokeks.org Hosting |
|
4 |
+ |
|
5 |
+Written 2008-2012 by schokokeks.org Hosting, namely |
|
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 |
+*/ |
|
2 | 16 |
|
3 | 17 |
require_once("inc/debug.php"); |
4 | 18 |
require_once("inc/db_connect.php"); |
git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@1990 87cf0b9e-d624-0410-a070-f6ee81989793
... | ... |
@@ -73,7 +73,7 @@ function get_account_details($uid, $customerno=0) |
73 | 73 |
function get_used_quota($uid) |
74 | 74 |
{ |
75 | 75 |
$uid = (int) $uid; |
76 |
- $result = db_query("SELECT s.hostname AS server, used, COALESCE(us.quota, u.quota) AS quota FROM system.usedquota AS uq LEFT JOIN system.useraccounts AS u USING (uid) LEFT JOIN system.servers AS s ON (s.id=uq.server) LEFT JOIN system.user_server AS us ON (us.uid=uq.uid AND us.server=uq.server) WHERE uq.uid='{$uid}'"); |
|
76 |
+ $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}'"); |
|
77 | 77 |
$ret = array(); |
78 | 78 |
while ($line = mysql_fetch_assoc($result)) |
79 | 79 |
$ret[] = $line; |
git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@1722 87cf0b9e-d624-0410-a070-f6ee81989793
... | ... |
@@ -3,7 +3,6 @@ |
3 | 3 |
require_once("inc/debug.php"); |
4 | 4 |
require_once("inc/db_connect.php"); |
5 | 5 |
|
6 |
-require_role(ROLE_CUSTOMER); |
|
7 | 6 |
|
8 | 7 |
|
9 | 8 |
function customer_may_have_useraccounts() |
... | ... |
@@ -59,11 +58,13 @@ function list_useraccounts() |
59 | 58 |
} |
60 | 59 |
|
61 | 60 |
|
62 |
-function get_account_details($uid) |
|
61 |
+function get_account_details($uid, $customerno=0) |
|
63 | 62 |
{ |
64 | 63 |
$uid = (int) $uid; |
65 |
- $customerno = (int) $_SESSION['customerinfo']['customerno']; |
|
66 |
- $result = db_query("SELECT uid,username,name,shell,quota FROM system.useraccounts WHERE kunde={$customerno} AND uid={$uid}"); |
|
64 |
+ $customerno = (int) $customerno; |
|
65 |
+ if ($customerno == 0) |
|
66 |
+ $customerno = $_SESSION['customerinfo']['customerno']; |
|
67 |
+ $result = db_query("SELECT uid,username,name,shell,quota,erstellungsdatum FROM system.useraccounts WHERE kunde={$customerno} AND uid={$uid}"); |
|
67 | 68 |
if (mysql_num_rows($result) == 0) |
68 | 69 |
system_failure("Cannot find the requestes useraccount (for this customer)."); |
69 | 70 |
return mysql_fetch_assoc($result); |
... | ... |
@@ -84,7 +85,12 @@ function get_used_quota($uid) |
84 | 85 |
function set_account_details($account) |
85 | 86 |
{ |
86 | 87 |
$uid = (int) $account['uid']; |
87 |
- $customerno = (int) $_SESSION['customerinfo']['customerno']; |
|
88 |
+ $customerno = NULL; |
|
89 |
+ if ($_SESSION['role'] & ROLE_CUSTOMER) |
|
90 |
+ $customerno = (int) $_SESSION['customerinfo']['customerno']; |
|
91 |
+ else |
|
92 |
+ $customerno = (int) $_SESSION['userinfo']['customerno']; |
|
93 |
+ |
|
88 | 94 |
$fullname = maybe_null(mysql_real_escape_string(filter_input_general($account['name']))); |
89 | 95 |
$shell = mysql_real_escape_string(filter_input_general($account['shell'])); |
90 | 96 |
$quota = (int) $account['quota']; |
git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@1718 87cf0b9e-d624-0410-a070-f6ee81989793
... | ... |
@@ -32,17 +32,29 @@ function primary_useraccount() |
32 | 32 |
} |
33 | 33 |
|
34 | 34 |
|
35 |
+function available_shells() |
|
36 |
+{ |
|
37 |
+ $result = db_query("SELECT path, name FROM system.shells WHERE usable=1"); |
|
38 |
+ $ret = array(); |
|
39 |
+ while ($s = mysql_fetch_assoc($result)) |
|
40 |
+ { |
|
41 |
+ $ret[$s['path']] = $s['name']; |
|
42 |
+ } |
|
43 |
+ DEBUG($ret); |
|
44 |
+ return $ret; |
|
45 |
+} |
|
46 |
+ |
|
35 | 47 |
|
36 | 48 |
function list_useraccounts() |
37 | 49 |
{ |
38 | 50 |
$customerno = (int) $_SESSION['customerinfo']['customerno']; |
39 |
- $result = db_query("SELECT uid,username,name,erstellungsdatum,quota FROM system.useraccounts WHERE kunde={$customerno}"); |
|
51 |
+ $result = db_query("SELECT uid,username,name,erstellungsdatum,quota,shell FROM system.useraccounts WHERE kunde={$customerno}"); |
|
40 | 52 |
$ret = array(); |
41 |
- while ($item = mysql_fetch_object($result)) |
|
53 |
+ while ($item = mysql_fetch_assoc($result)) |
|
42 | 54 |
{ |
43 |
- DEBUG('Useraccount: '.print_r($item, true)); |
|
44 | 55 |
array_push($ret, $item); |
45 | 56 |
} |
57 |
+ DEBUG($ret); |
|
46 | 58 |
return $ret; |
47 | 59 |
} |
48 | 60 |
|
... | ... |
@@ -51,25 +63,45 @@ function get_account_details($uid) |
51 | 63 |
{ |
52 | 64 |
$uid = (int) $uid; |
53 | 65 |
$customerno = (int) $_SESSION['customerinfo']['customerno']; |
54 |
- $result = db_query("SELECT uid,username,name FROM system.useraccounts WHERE kunde={$customerno} AND uid={$uid}"); |
|
66 |
+ $result = db_query("SELECT uid,username,name,shell,quota FROM system.useraccounts WHERE kunde={$customerno} AND uid={$uid}"); |
|
55 | 67 |
if (mysql_num_rows($result) == 0) |
56 | 68 |
system_failure("Cannot find the requestes useraccount (for this customer)."); |
57 |
- return mysql_fetch_array($result); |
|
69 |
+ return mysql_fetch_assoc($result); |
|
58 | 70 |
} |
59 | 71 |
|
72 |
+function get_used_quota($uid) |
|
73 |
+{ |
|
74 |
+ $uid = (int) $uid; |
|
75 |
+ $result = db_query("SELECT s.hostname AS server, used, COALESCE(us.quota, u.quota) AS quota FROM system.usedquota AS uq LEFT JOIN system.useraccounts AS u USING (uid) LEFT JOIN system.servers AS s ON (s.id=uq.server) LEFT JOIN system.user_server AS us ON (us.uid=uq.uid AND us.server=uq.server) WHERE uq.uid='{$uid}'"); |
|
76 |
+ $ret = array(); |
|
77 |
+ while ($line = mysql_fetch_assoc($result)) |
|
78 |
+ $ret[] = $line; |
|
79 |
+ DEBUG($ret); |
|
80 |
+ return $ret; |
|
81 |
+} |
|
60 | 82 |
|
61 | 83 |
|
62 |
-function set_systemuser_details($uid, $fullname, $quota) |
|
84 |
+function set_account_details($account) |
|
63 | 85 |
{ |
64 |
- $uid = (int) $uid; |
|
86 |
+ $uid = (int) $account['uid']; |
|
65 | 87 |
$customerno = (int) $_SESSION['customerinfo']['customerno']; |
66 |
- $fullname = maybe_null(mysql_real_escape_string(filter_input_general($fullname))); |
|
67 |
- $quota = (int) $quota; |
|
88 |
+ $fullname = maybe_null(mysql_real_escape_string(filter_input_general($account['name']))); |
|
89 |
+ $shell = mysql_real_escape_string(filter_input_general($account['shell'])); |
|
90 |
+ $quota = (int) $account['quota']; |
|
68 | 91 |
|
69 |
- db_query("UPDATE system.useraccounts SET name={$fullname} WHERE kunde={$customerno} AND uid={$uid} LIMIT 1"); |
|
70 |
- logger(LOG_INFO, "modules/systemuser/include/useraccounts", "systemuser", "updated real name for uid {$uid}"); |
|
92 |
+ db_query("UPDATE system.useraccounts SET name={$fullname}, quota={$quota}, shell='{$shell}' WHERE kunde={$customerno} AND uid={$uid}"); |
|
93 |
+ logger(LOG_INFO, "modules/systemuser/include/useraccounts", "systemuser", "updated details for uid {$uid}"); |
|
71 | 94 |
|
72 | 95 |
} |
73 | 96 |
|
97 |
+function get_customer_quota() |
|
98 |
+{ |
|
99 |
+ $cid = (int) $_SESSION['customerinfo']['customerno']; |
|
100 |
+ $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}"); |
|
101 |
+ $ret = mysql_fetch_assoc($result); |
|
102 |
+ DEBUG($ret); |
|
103 |
+ return $ret; |
|
104 |
+} |
|
105 |
+ |
|
74 | 106 |
|
75 | 107 |
?> |
git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@1466 87cf0b9e-d624-0410-a070-f6ee81989793
... | ... |
@@ -67,7 +67,7 @@ function set_systemuser_details($uid, $fullname, $quota) |
67 | 67 |
$quota = (int) $quota; |
68 | 68 |
|
69 | 69 |
db_query("UPDATE system.useraccounts SET name={$fullname} WHERE kunde={$customerno} AND uid={$uid} LIMIT 1"); |
70 |
- logger("modules/systemuser/include/useraccounts", "systemuser", "updated real name for uid {$uid}"); |
|
70 |
+ logger(LOG_INFO, "modules/systemuser/include/useraccounts", "systemuser", "updated real name for uid {$uid}"); |
|
71 | 71 |
|
72 | 72 |
} |
73 | 73 |
|
git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@1128 87cf0b9e-d624-0410-a070-f6ee81989793
... | ... |
@@ -67,7 +67,7 @@ function set_systemuser_details($uid, $fullname, $quota) |
67 | 67 |
$quota = (int) $quota; |
68 | 68 |
|
69 | 69 |
db_query("UPDATE system.useraccounts SET name={$fullname} WHERE kunde={$customerno} AND uid={$uid} LIMIT 1"); |
70 |
- logger("modules/systemuser/include/useraccounts.php", "systemuser", "updated real name for uid {$uid}"); |
|
70 |
+ logger("modules/systemuser/include/useraccounts", "systemuser", "updated real name for uid {$uid}"); |
|
71 | 71 |
|
72 | 72 |
} |
73 | 73 |
|
git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@819 87cf0b9e-d624-0410-a070-f6ee81989793
... | ... |
@@ -36,7 +36,7 @@ function primary_useraccount() |
36 | 36 |
function list_useraccounts() |
37 | 37 |
{ |
38 | 38 |
$customerno = (int) $_SESSION['customerinfo']['customerno']; |
39 |
- $result = db_query("SELECT uid,username,name,erstellungsdatum,softquota FROM system.useraccounts WHERE kunde={$customerno}"); |
|
39 |
+ $result = db_query("SELECT uid,username,name,erstellungsdatum,quota FROM system.useraccounts WHERE kunde={$customerno}"); |
|
40 | 40 |
$ret = array(); |
41 | 41 |
while ($item = mysql_fetch_object($result)) |
42 | 42 |
{ |
... | ... |
@@ -51,7 +51,7 @@ function get_account_details($uid) |
51 | 51 |
{ |
52 | 52 |
$uid = (int) $uid; |
53 | 53 |
$customerno = (int) $_SESSION['customerinfo']['customerno']; |
54 |
- $result = db_query("SELECT uid,username,name,softquota FROM system.useraccounts WHERE kunde={$customerno} AND uid={$uid}"); |
|
54 |
+ $result = db_query("SELECT uid,username,name FROM system.useraccounts WHERE kunde={$customerno} AND uid={$uid}"); |
|
55 | 55 |
if (mysql_num_rows($result) == 0) |
56 | 56 |
system_failure("Cannot find the requestes useraccount (for this customer)."); |
57 | 57 |
return mysql_fetch_array($result); |
git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@618 87cf0b9e-d624-0410-a070-f6ee81989793
... | ... |
@@ -13,6 +13,12 @@ function customer_may_have_useraccounts() |
13 | 13 |
return (mysql_num_rows($result) > 0); |
14 | 14 |
} |
15 | 15 |
|
16 |
+function customer_useraccount($uid) { |
|
17 |
+ $uid = (int) $uid; |
|
18 |
+ $customerno = (int) $_SESSION['customerinfo']['customerno']; |
|
19 |
+ $result = db_query("SELECT 1 FROM system.useraccounts WHERE kunde={$customerno} AND uid={$uid} AND kundenaccount=1"); |
|
20 |
+ return mysql_num_rows($result) > 0; |
|
21 |
+} |
|
16 | 22 |
|
17 | 23 |
function primary_useraccount() |
18 | 24 |
{ |
git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@572 87cf0b9e-d624-0410-a070-f6ee81989793
... | ... |
@@ -57,7 +57,7 @@ function set_systemuser_details($uid, $fullname, $quota) |
57 | 57 |
{ |
58 | 58 |
$uid = (int) $uid; |
59 | 59 |
$customerno = (int) $_SESSION['customerinfo']['customerno']; |
60 |
- $fullname = maybe_null(mysql_real_escape_string($fullname)); |
|
60 |
+ $fullname = maybe_null(mysql_real_escape_string(filter_input_general($fullname))); |
|
61 | 61 |
$quota = (int) $quota; |
62 | 62 |
|
63 | 63 |
db_query("UPDATE system.useraccounts SET name={$fullname} WHERE kunde={$customerno} AND uid={$uid} LIMIT 1"); |
git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@566 87cf0b9e-d624-0410-a070-f6ee81989793
... | ... |
@@ -14,6 +14,18 @@ function customer_may_have_useraccounts() |
14 | 14 |
} |
15 | 15 |
|
16 | 16 |
|
17 |
+function primary_useraccount() |
|
18 |
+{ |
|
19 |
+ if (! ($_SESSION['role'] & ROLE_SYSTEMUSER)) |
|
20 |
+ return NULL; |
|
21 |
+ $customerno = (int) $_SESSION['customerinfo']['customerno']; |
|
22 |
+ $result = db_query("SELECT MIN(uid) AS uid FROM system.useraccounts WHERE kunde={$customerno}"); |
|
23 |
+ $uid = mysql_fetch_object($result)->uid; |
|
24 |
+ DEBUG("primary useraccount: {$uid}"); |
|
25 |
+ return $uid; |
|
26 |
+} |
|
27 |
+ |
|
28 |
+ |
|
17 | 29 |
|
18 | 30 |
function list_useraccounts() |
19 | 31 |
{ |
git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@563 87cf0b9e-d624-0410-a070-f6ee81989793
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,57 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+require_once("inc/debug.php"); |
|
4 |
+require_once("inc/db_connect.php"); |
|
5 |
+ |
|
6 |
+require_role(ROLE_CUSTOMER); |
|
7 |
+ |
|
8 |
+ |
|
9 |
+function customer_may_have_useraccounts() |
|
10 |
+{ |
|
11 |
+ $customerno = (int) $_SESSION['customerinfo']['customerno']; |
|
12 |
+ $result = db_query("SELECT COUNT(*) FROM system.useraccounts WHERE kunde={$customerno}"); |
|
13 |
+ return (mysql_num_rows($result) > 0); |
|
14 |
+} |
|
15 |
+ |
|
16 |
+ |
|
17 |
+ |
|
18 |
+function list_useraccounts() |
|
19 |
+{ |
|
20 |
+ $customerno = (int) $_SESSION['customerinfo']['customerno']; |
|
21 |
+ $result = db_query("SELECT uid,username,name,erstellungsdatum,softquota FROM system.useraccounts WHERE kunde={$customerno}"); |
|
22 |
+ $ret = array(); |
|
23 |
+ while ($item = mysql_fetch_object($result)) |
|
24 |
+ { |
|
25 |
+ DEBUG('Useraccount: '.print_r($item, true)); |
|
26 |
+ array_push($ret, $item); |
|
27 |
+ } |
|
28 |
+ return $ret; |
|
29 |
+} |
|
30 |
+ |
|
31 |
+ |
|
32 |
+function get_account_details($uid) |
|
33 |
+{ |
|
34 |
+ $uid = (int) $uid; |
|
35 |
+ $customerno = (int) $_SESSION['customerinfo']['customerno']; |
|
36 |
+ $result = db_query("SELECT uid,username,name,softquota FROM system.useraccounts WHERE kunde={$customerno} AND uid={$uid}"); |
|
37 |
+ if (mysql_num_rows($result) == 0) |
|
38 |
+ system_failure("Cannot find the requestes useraccount (for this customer)."); |
|
39 |
+ return mysql_fetch_array($result); |
|
40 |
+} |
|
41 |
+ |
|
42 |
+ |
|
43 |
+ |
|
44 |
+function set_systemuser_details($uid, $fullname, $quota) |
|
45 |
+{ |
|
46 |
+ $uid = (int) $uid; |
|
47 |
+ $customerno = (int) $_SESSION['customerinfo']['customerno']; |
|
48 |
+ $fullname = maybe_null(mysql_real_escape_string($fullname)); |
|
49 |
+ $quota = (int) $quota; |
|
50 |
+ |
|
51 |
+ db_query("UPDATE system.useraccounts SET name={$fullname} WHERE kunde={$customerno} AND uid={$uid} LIMIT 1"); |
|
52 |
+ logger("modules/systemuser/include/useraccounts.php", "systemuser", "updated real name for uid {$uid}"); |
|
53 |
+ |
|
54 |
+} |
|
55 |
+ |
|
56 |
+ |
|
57 |
+?> |