$user_privs=sql_select("SELECT `Privileges`.`name` FROM `User` JOIN `UserGroups` ON (`User`.`UID` = `UserGroups`.`uid`) JOIN `GroupPrivileges` ON (`UserGroups`.`group_id` = `GroupPrivileges`.`group_id`) JOIN `Privileges` ON (`GroupPrivileges`.`privilege_id` = `Privileges`.`id`) WHERE `User`.`UID`=".sql_escape($UID).";");
foreach($user_privsas$user_priv)
$privileges[]=$user_priv['name'];
$msg=array(
'status'=>'success',
'rights'=>$privileges
);
echojson_encode($msg);
die();
}
}
}
echojson_encode(array(
'status'=>'failed',
'error'=>"JSON Service GET syntax: https://engelsystem.de/?auth&user=<user>&pw=<password>&so=<key>, POST is possible too"
));
die();
}
functionprivileges_for_user($user_id){
$privileges=array();
$user_privs=sql_select("SELECT `Privileges`.`name` FROM `User` JOIN `UserGroups` ON (`User`.`UID` = `UserGroups`.`uid`) JOIN `GroupPrivileges` ON (`UserGroups`.`group_id` = `GroupPrivileges`.`group_id`) JOIN `Privileges` ON (`GroupPrivileges`.`privilege_id` = `Privileges`.`id`) WHERE `User`.`UID`=".sql_escape($user_id).";");
foreach($user_privsas$user_priv)
$privileges[]=$user_priv['name'];
return$privileges;
}
functionprivileges_for_group($group_id){
$privileges=array();
$groups_privs=sql_select("SELECT * FROM `GroupPrivileges` JOIN `Privileges` ON (`GroupPrivileges`.`privilege_id` = `Privileges`.`id`) WHERE `group_id`=".sql_escape($group_id));