summaryrefslogtreecommitdiff
path: root/inc/mod.php
diff options
context:
space:
mode:
authorSavetheinternet <savetheinternet@tinyboard.org>2011-07-03 23:05:14 +1000
committerSavetheinternet <savetheinternet@tinyboard.org>2011-07-03 23:05:14 +1000
commite3cba2b450bdde8725e31567f761ca9aaa63230a (patch)
treec9e41a4d8a8778712038d21007fb613848610a63 /inc/mod.php
parent1338769d44ef8b2bc78250f8fcf8c259dad95a8f (diff)
per-board moderators
Diffstat (limited to 'inc/mod.php')
-rw-r--r--inc/mod.php22
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
+?>