mirror of
https://github.com/ZeroDream-CN/SakuraPanel.git
synced 2025-01-12 01:42:52 +08:00
Add isUserHasPermission & isNodeAvailable function
增加判断用户是否有权限使用此节点以及节点是否可用的函数
This commit is contained in:
parent
8a25cedba3
commit
4f2b5c3c45
@ -59,6 +59,28 @@ class NodeManager {
|
||||
return count($rs);
|
||||
}
|
||||
|
||||
public function isUserHasPermission($user, $node)
|
||||
{
|
||||
$um = new SakuraPanel\UserManager();
|
||||
$ns = $this->getNodeInfo($node);
|
||||
$us = $um->getInfoByUser($user);
|
||||
if(is_array($us) && is_array($ns)) {
|
||||
if(stristr($ns['group'], "{$us['group']};")) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function isNodeAvailable($node)
|
||||
{
|
||||
$ns = $this->getNodeInfo($node);
|
||||
return Intval($ns['status']) == 200;
|
||||
}
|
||||
|
||||
public function addNode($data)
|
||||
{
|
||||
return Database::insert("nodes", $data);
|
||||
@ -80,4 +102,4 @@ class NodeManager {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user