per-board moderators

This commit is contained in:
Savetheinternet
2011-07-03 23:05:14 +10:00
parent 1338769d44
commit e3cba2b450
5 changed files with 126 additions and 47 deletions

View File

@@ -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>';
}
?>
?>