diff options
Diffstat (limited to 'inc/mod.php')
| -rw-r--r-- | inc/mod.php | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/inc/mod.php b/inc/mod.php index 78351ba7..0acb3864 100644 --- a/inc/mod.php +++ b/inc/mod.php @@ -14,6 +14,21 @@ return substr(base64_encode(sha1(rand() . time(), true)), 0, $length); } + function hasPermission($action = null, $board = null, $_mod = null) { + if(isset($_mod)) + $mod = &$_mod; + else + global $mod; + + if(isset($action) && $mod['type'] < $action) + return false; + + if(isset($board) && !in_array($board, $mod['boards'])) + return false; + + return true; + } + function login($username, $password, $makehash=true) { global $mod; @@ -22,7 +37,7 @@ $password = sha1($password); } - $query = prepare("SELECT `id`,`type` FROM `mods` WHERE `username` = :username AND `password` = :password LIMIT 1"); + $query = prepare("SELECT `id`,`type`,`boards` FROM `mods` WHERE `username` = :username AND `password` = :password LIMIT 1"); $query->bindValue(':username', $username); $query->bindValue(':password', $password); $query->execute() or error(db_error($query)); @@ -33,7 +48,8 @@ 'type' => $user['type'], 'username' => $username, 'password' => $password, - 'hash' => isset($_SESSION['mod']['hash']) ? $_SESSION['mod']['hash'] : mkhash() + 'hash' => isset($_SESSION['mod']['hash']) ? $_SESSION['mod']['hash'] : mkhash(), + 'boards' => explode(',', $user['boards']) ); } else return false; } @@ -230,4 +246,4 @@ '</fieldset>'; } -?>
\ No newline at end of file +?> |
