@@ -44,7 +44,7 @@ public function is_admin() {
4444 return false ;
4545 }
4646 }
47-
47+
4848 public function is_superadmin () {
4949 if ($ _SESSION ['s ' ]['user ' ]['typ ' ] == 'admin ' && $ _SESSION ['s ' ]['user ' ]['userid ' ] == 1 ) {
5050 return true ;
@@ -71,11 +71,11 @@ public function has_clients($userid) {
7171 return false ;
7272 }
7373 }
74-
74+
7575 // Function to check if a client belongs to a reseller
7676 public function is_client_of_reseller ($ userid = 0 ) {
7777 global $ app , $ conf ;
78-
78+
7979 if ($ userid == 0 ) $ userid = $ _SESSION ['s ' ]['user ' ]['userid ' ];
8080
8181 $ client = $ app ->db ->queryOneRecord ("SELECT client.sys_userid, client.sys_groupid FROM sys_user, client WHERE sys_user.userid = ? AND sys_user.client_id = client.client_id " , $ userid );
@@ -98,7 +98,7 @@ public function add_group_to_user($userid, $groupid) {
9898 $ groups = explode (', ' , $ user ['groups ' ]);
9999 if (!in_array ($ groupid , $ groups )) $ groups [] = $ groupid ;
100100 $ groups_string = implode (', ' , $ groups );
101- $ sql = "UPDATE sys_user SET groups = ? WHERE userid = ? " ;
101+ $ sql = "UPDATE sys_user SET ` groups` = ? WHERE userid = ? " ;
102102 $ app ->db ->query ($ sql , $ groups_string , $ userid );
103103 return true ;
104104 } else {
@@ -110,10 +110,10 @@ public function add_group_to_user($userid, $groupid) {
110110 public function get_client_limit ($ userid , $ limitname )
111111 {
112112 global $ app ;
113-
113+
114114 $ userid = $ app ->functions ->intval ($ userid );
115115 if (!preg_match ('/^[a-zA-Z0-9\-\_]{1,64}$/ ' ,$ limitname )) $ app ->error ('Invalid limit name ' .$ limitname );
116-
116+
117117 // simple query cache
118118 if ($ this ->client_limits ===null )
119119 $ this ->client_limits = $ app ->db ->queryOneRecord ("SELECT client.* FROM sys_user, client WHERE sys_user.userid = ? AND sys_user.client_id = client.client_id " , $ userid );
@@ -140,7 +140,7 @@ public function remove_group_from_user($userid, $groupid) {
140140 $ key = array_search ($ groupid , $ groups );
141141 unset($ groups [$ key ]);
142142 $ groups_string = implode (', ' , $ groups );
143- $ sql = "UPDATE sys_user SET groups = ? WHERE userid = ? " ;
143+ $ sql = "UPDATE sys_user SET ` groups` = ? WHERE userid = ? " ;
144144 $ app ->db ->query ($ sql , $ groups_string , $ userid );
145145 return true ;
146146 } else {
@@ -188,11 +188,11 @@ public function check_module_permissions($module) {
188188 exit ;
189189 }
190190 }
191-
191+
192192 public function check_security_permissions ($ permission ) {
193-
193+
194194 global $ app ;
195-
195+
196196 $ app ->uses ('getconf ' );
197197 $ security_config = $ app ->getconf ->get_security_config ('permissions ' );
198198
@@ -202,7 +202,7 @@ public function check_security_permissions($permission) {
202202 if ($ security_check !== true ) {
203203 $ app ->error ($ app ->lng ('security_check1_txt ' ).' ' .$ permission .' ' .$ app ->lng ('security_check2_txt ' ));
204204 }
205-
205+
206206 }
207207
208208 /**
@@ -239,12 +239,12 @@ public function get_random_password($minLength = 8, $special = false) {
239239 if ($ minLength < 8 ) $ minLength = 8 ;
240240 $ maxLength = $ minLength + 5 ;
241241 $ length = random_int ($ minLength , $ maxLength );
242-
242+
243243 $ alphachars = "abcdefghijklmnopqrstuvwxyz " ;
244244 $ upperchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ " ;
245245 $ numchars = "1234567890 " ;
246246 $ specialchars = "!@#_ " ;
247-
247+
248248 $ num_special = 0 ;
249249 if ($ special == true ) {
250250 $ num_special = intval (random_int (0 , round ($ length / 4 ))) + 1 ;
@@ -254,31 +254,31 @@ public function get_random_password($minLength = 8, $special = false) {
254254 $ upperlen = intval ($ alphalen / 2 );
255255 $ alphalen = $ alphalen - $ upperlen ;
256256 $ password = '' ;
257-
257+
258258 for ($ i = 0 ; $ i < $ alphalen ; $ i ++) {
259259 $ password .= substr ($ alphachars , random_int (0 , strlen ($ alphachars ) - 1 ), 1 );
260260 }
261-
261+
262262 for ($ i = 0 ; $ i < $ upperlen ; $ i ++) {
263263 $ password .= substr ($ upperchars , random_int (0 , strlen ($ upperchars ) - 1 ), 1 );
264264 }
265-
265+
266266 for ($ i = 0 ; $ i < $ num_special ; $ i ++) {
267267 $ password .= substr ($ specialchars , random_int (0 , strlen ($ specialchars ) - 1 ), 1 );
268268 }
269-
269+
270270 for ($ i = 0 ; $ i < $ numericlen ; $ i ++) {
271271 $ password .= substr ($ numchars , random_int (0 , strlen ($ numchars ) - 1 ), 1 );
272272 }
273-
273+
274274 return str_shuffle ($ password );
275275 }
276276
277277 public function crypt_password ($ cleartext_password , $ charset = 'UTF-8 ' ) {
278278 if ($ charset != 'UTF-8 ' ) {
279279 $ cleartext_password = mb_convert_encoding ($ cleartext_password , $ charset , 'UTF-8 ' );
280280 }
281-
281+
282282 if (defined ('CRYPT_SHA512 ' ) && CRYPT_SHA512 == 1 ) {
283283 $ salt = '$6$rounds=5000$ ' ;
284284 $ salt_length = 16 ;
@@ -289,7 +289,7 @@ public function crypt_password($cleartext_password, $charset = 'UTF-8') {
289289 $ salt = '$1$ ' ;
290290 $ salt_length = 12 ;
291291 }
292-
292+
293293 if (function_exists ('openssl_random_pseudo_bytes ' )) {
294294 $ salt .= substr (bin2hex (openssl_random_pseudo_bytes ($ salt_length )), 0 , $ salt_length );
295295 } else {
@@ -301,7 +301,7 @@ public function crypt_password($cleartext_password, $charset = 'UTF-8') {
301301 $ salt .= "$ " ;
302302 return crypt ($ cleartext_password , $ salt );
303303 }
304-
304+
305305 public function csrf_token_get ($ form_name ) {
306306 /* CSRF PROTECTION */
307307 // generate csrf protection id and key
@@ -311,24 +311,24 @@ public function csrf_token_get($form_name) {
311311 if (!isset ($ _SESSION ['_csrf_timeout ' ])) $ _SESSION ['_csrf_timeout ' ] = array ();
312312 $ _SESSION ['_csrf ' ][$ _csrf_id ] = $ _csrf_key ;
313313 $ _SESSION ['_csrf_timeout ' ][$ _csrf_id ] = time () + 3600 ; // timeout hash in 1 hour
314-
314+
315315 return array ('csrf_id ' => $ _csrf_id ,'csrf_key ' => $ _csrf_key );
316316 }
317-
317+
318318 public function csrf_token_check ($ method = 'POST ' ) {
319319 global $ app ;
320-
320+
321321 if ($ method == 'POST ' ) {
322322 $ input_vars = $ _POST ;
323323 } elseif ($ method == 'GET ' ) {
324324 $ input_vars = $ _GET ;
325325 } else {
326326 $ app ->error ('Unknown CSRF verification method. ' );
327327 }
328-
328+
329329 //print_r($input_vars);
330330 //die(print_r($_SESSION['_csrf']));
331-
331+
332332 if (isset ($ input_vars ) && is_array ($ input_vars )) {
333333 $ _csrf_valid = false ;
334334 if (isset ($ input_vars ['_csrf_id ' ]) && isset ($ input_vars ['_csrf_key ' ])) {
@@ -346,7 +346,7 @@ public function csrf_token_check($method = 'POST') {
346346 $ _SESSION ['_csrf_timeout ' ][$ _csrf_id ] = null ;
347347 unset($ _SESSION ['_csrf ' ][$ _csrf_id ]);
348348 unset($ _SESSION ['_csrf_timeout ' ][$ _csrf_id ]);
349-
349+
350350 if (isset ($ _SESSION ['_csrf_timeout ' ]) && is_array ($ _SESSION ['_csrf_timeout ' ])) {
351351 $ to_unset = array ();
352352 foreach ($ _SESSION ['_csrf_timeout ' ] as $ _csrf_id => $ timeout ) {
0 commit comments