Skip to content

Commit 19b5e01

Browse files
author
Till Brehm
committed
Added function "is_superadmin" in auth library and improved other functions.
1 parent 3ee67a9 commit 19b5e01

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

interface/lib/classes/auth.inc.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ public function is_admin() {
4444
return false;
4545
}
4646
}
47+
48+
public function is_superadmin() {
49+
if($_SESSION['s']['user']['typ'] == 'admin' && $_SESSION['s']['user']['userid'] === 1) {
50+
return true;
51+
} else {
52+
return false;
53+
}
54+
}
4755

4856
public function has_clients($userid) {
4957
global $app, $conf;
@@ -83,6 +91,7 @@ public function get_client_limit($userid, $limitname)
8391
global $app;
8492

8593
$userid = $app->functions->intval($userid);
94+
if(!preg_match('/^[a-zA-Z0-9\-\_]{1,64}$/',$limitname)) $app->error('Invalid limit name '.$limitname);
8695

8796
// simple query cache
8897
if($this->client_limits===null)
@@ -120,7 +129,8 @@ public function remove_group_from_user($userid, $groupid) {
120129

121130
public function check_module_permissions($module) {
122131
// Check if the current user has the permissions to access this module
123-
if(!stristr($_SESSION["s"]["user"]["modules"], $module)) {
132+
$user_modules = explode(',',$_SESSION["s"]["user"]["modules"]);
133+
if(!in_array($module,$user_modules)) {
124134
// echo "LOGIN_REDIRECT:/index.php";
125135
header("Location: /index.php");
126136
exit;

0 commit comments

Comments
 (0)