public override WWWResponse ProcessRequest(WWWRequest request)
        {
            string html     = Servers.HTTP.WWW._templates["onlineplayers"];
            string itemHtml = Servers.HTTP.WWW._templates["onlineplayersitem"];

            string itemList = "";

            foreach (EntityPlayer player in PlayerUtils.GetOnlinePlayers())
            {
                string sitem   = itemHtml;
                string steamId = PlayerUtils.GetSteamID(player.entityId.ToString());
                sitem = sitem.Replace("{steam_id}", steamId);
                sitem = sitem.Replace("{display_name}", PlayerUtils.GetDisplayName(player.entityId.ToString()));

                string playerGroupName  = "guest";
                string playerAdminLevel = "1000";

                if (SDTM.API.Permissions.Users.ContainsKey(steamId))
                {
                    playerGroupName = SDTM.API.Permissions.Users [steamId].Group;
                }

                playerAdminLevel = GameManager.Instance.adminTools.GetAdminToolsClientInfo(steamId).PermissionLevel.ToString();

                sitem = sitem.Replace("{experm_group}", playerGroupName);
                sitem = sitem.Replace("{admin_level}", playerAdminLevel);
                string itemTools = "";
                itemTools += "<a href=\"/settings/experm/user?user="******"\" title=\"Security\"><i class=\"fa fa-shield\" aria-hidden=\"true\"></i></a>";
                //itemTools+=" <a href=\"/settings/player/inventory?player="+steamId+"\" title=\"View Player Inventory\"><i class=\"fa fa-suitcase\" aria-hidden=\"true\"></i></a>";
                //itemTools+=" <a href=\"/settings/player/kick?player="+steamId+"\" title=\"Kick/Ban User\"><i class=\"fa fa-ban\" aria-hidden=\"true\"></i></a>";
                sitem     = sitem.Replace("{tools}", itemTools);
                itemList += sitem;
            }

            html = html.Replace("{player_list}", itemList);

            WWWResponse response = new WWWResponse(html);

            return(response);
        }
        public override WWWResponse ProcessRequest(WWWRequest request)
        {
            string steamId     = "";
            string groupName   = "";
            string displayName = "";

            if (request.Form.Count > 0)
            {
                steamId = request.Form ["steam_id"];
            }
            else
            {
                if (request._request.QueryString ["user"] != null)
                {
                    steamId = request._request.QueryString ["user"];
                }
            }

            if (API.Permissions.Users.ContainsKey(steamId))
            {
                groupName   = API.Permissions.Users [steamId].Group;
                displayName = API.Permissions.Users [steamId].DisplayName;
            }
            else
            {
                groupName = "guest";
                //check the online players
                foreach (EntityPlayer player in PlayerUtils.GetOnlinePlayers())
                {
                    if (steamId == PlayerUtils.GetSteamID(player.entityId.ToString()))
                    {
                        displayName = PlayerUtils.GetDisplayName(player.entityId.ToString());
                    }
                }

                if (displayName == "")
                {
                    //persistent data?
                }
            }

            if (request.Form.Count > 0)
            {
                groupName = request.Form ["experm_group"];
                API.Permissions.SetUserGroup(steamId, groupName);
                API.Permissions.Save();
            }

            string html = Servers.HTTP.WWW._templates["expermusereditor"];

            string groupOptions = "";

            foreach (string expermGroupName in API.Permissions.Groups.Keys)
            {
                groupOptions += "<option value=\"" + expermGroupName + "\"";
                if (expermGroupName == groupName)
                {
                    groupOptions += " SELECTED";
                }
                groupOptions += ">" + expermGroupName + "</option>";
            }

            string         userPermList = "";
            PermissionUser pUser        = null;

            if (API.Permissions.Users.ContainsKey(steamId))
            {
                pUser = API.Permissions.Users [steamId];
            }
            if (pUser != null)
            {
                string permissionEntryTemplate        = Servers.HTTP.WWW._templates ["expermpermissionentry"];
                Dictionary <string, bool> permissions = pUser.Permissions.GetAll();

                foreach (KeyValuePair <string, bool> perm in permissions)
                {
                    string permItem = permissionEntryTemplate.Replace("{node_name}", perm.Key);
                    permItem = permItem.Replace("{allowed}", perm.Value.ToString());
                    string toolList = "<a href=\"/settings/experm/user/removenode?steam_id=" + steamId + "&node=" + perm.Key + "\"><i class=\"fa fa-times\" aria-hidden=\"true\"></i></a>";
                    permItem      = permItem.Replace("{tools}", toolList);
                    userPermList += permItem;
                }
            }

            html = html.Replace("{steam_id}", steamId);
            html = html.Replace("{display_name}", displayName);
            html = html.Replace("{experm_groups_options}", groupOptions);
            html = html.Replace("{user_permissions}", userPermList);


            WWWResponse response = new WWWResponse(html);

            return(response);
        }
Beispiel #3
0
        public override WWWResponse ProcessRequest(WWWRequest request)
        {
            string nodeName    = "";
            string steamId     = "";
            string displayName = "";

            if (request.Form.Count > 0)
            {
                steamId = request.Form ["steam_id"];
            }
            else
            {
                if (request._request.QueryString ["steam_id"] != null)
                {
                    steamId = request._request.QueryString ["steam_id"];
                }
            }

            if (API.Permissions.Users.ContainsKey(steamId))
            {
                displayName = API.Permissions.Users [steamId].DisplayName;
            }
            else
            {
                foreach (EntityPlayer player in PlayerUtils.GetOnlinePlayers())
                {
                    if (steamId == PlayerUtils.GetSteamID(player.entityId.ToString()))
                    {
                        displayName = PlayerUtils.GetDisplayName(player.entityId.ToString());
                    }
                }

                if (displayName == "")
                {
                    //persistent data?
                }
            }

            if (request.Form.Count > 0)
            {
                nodeName = request.Form ["node"];
                steamId  = request.Form ["steam_id"];

                if (nodeName == null || nodeName == "" || steamId == null || steamId == "")
                {
                    return(new WWWResponse("/settings/experm", 302));
                }

                if (API.Permissions.Users.ContainsKey(steamId))
                {
                    PermissionUser pUser = API.Permissions.Users [steamId];
                    if (pUser.Permissions.Exists(nodeName))
                    {
                        pUser.Permissions.Remove(nodeName);
                        API.Permissions.Save();
                        return(new WWWResponse("/settings/experm/user?user="******"/settings/experm", 302));
                    }
                }
            }
            else
            {
                if (request._request.QueryString ["node"] != null)
                {
                    nodeName = request._request.QueryString ["node"];
                }

                if (request._request.QueryString ["steam_id"] != null)
                {
                    steamId = request._request.QueryString ["steam_id"];
                }

                if (nodeName == null || nodeName == "" || steamId == null || steamId == "")
                {
                    return(new WWWResponse("/settings/experm", 302));
                }
            }

            string html = Servers.HTTP.WWW._templates["expermuserremovenode"];

            html = html.Replace("{steam_id}", steamId);
            html = html.Replace("{display_name}", displayName);
            html = html.Replace("{node_name}", nodeName);

            return(new WWWResponse(html));
        }