SignArtist

Moved

Total Downloads: 39,227 - First Release: Apr 29, 2015 - Last Update: Jan 19, 2018

4.88966/5, 145 likes
  1. So, I have been thinking about a LinkFilter

    This is what I propose:

    Config now has:
    -A list of strings that is the LinkFilter
    -Can be toggled with FilterIsAllow to function as an AllowList (set to true) or DenyList, (set to false)
    -Has two messages. NotInAllowList and InDenyList, for when the user tries a not allowed/denied link.

    There is now a signartist.overridefilter permission to override the LinkFilter available, for use by admins and such. They will have all links allowed.

    The LinkFilter needs some Json to function with the config, so
    Code:
    using Newtonsoft.Json;
    under #region Config | Init | Unload added:

    Code:
            string InDenyList = "Link is in deny list. Try another or ask the admin.";
            string NotInAllowList = "Link is not in allow list. Try another or ask the admin.";
            bool FilterIsAllow = true;
            List<string> LinkFilter=new List<string>();
    In void OnServerInitialized() Added:

    Code:
                permission.RegisterPermission("signartist.overridefilter", this);            CheckCfg("Link in deny list msg", ref InDenyList);
                CheckCfg("Link not in allow list msg", ref NotInAllowList);
                CheckCfg("Link filter is allowlist", ref FilterIsAllow);
                CheckCfg("Link filter list", ref LinkFilter);
    Then, just before 'RaycastHit hit;' in both void sil and void silt, I have:
    Code:
                if (!HasPerm(player, "SignArtist.overridefilter"))//People with overridefilter permission set do not have to filter
                {
                    if(FilterIsAllow)//empty list: allow all
                    {
                        if ((LinkFilter.Count>0) && (!IsUpperStringInList(args[0], LinkFilter)))//have allow list, but link is not in it
                        {
                            player.ChatMessage(NotInAllowList);
                            Console.WriteLine(string.Format("{0}         \nused not allowed link:         \n{1}         \n",player.userID, args[0]));
                            return;
                        }                  
                    }else{//empty list: deny all
                        if ((LinkFilter.Count==0) || (IsUpperStringInList(args[0],LinkFilter)))//list is empty, or link in list
                        {
                            player.ChatMessage(InDenyList);
                            Console.WriteLine(string.Format("{0}         \nused denied link:         \n{1}         \n",player.userID, args[0]));
                            return;
                        }
                    }
                }
               
                RaycastHit hit;
    and some changes to the CheckCfg<T>, to make it convert lists of objects to lists of strings

    Code:
            void CheckCfg<T>(string Key, ref T var)
            {
                if (Config[Key] == null)
                    Config[Key] = var;
                else
                    try
                    {
                        if (typeof(T).ToString()== "System.Collections.Generic.List`1[System.String]")
                        {
                            List<string> temp=new List<string>();
                            temp= JsonConvert.DeserializeObject<List<string>>(JsonConvert.SerializeObject(Config[Key]));
                            var = (T)Convert.ChangeType(temp, typeof(T));
                        }
                        else
                        {
                            var = (T)Convert.ChangeType(Config[Key], typeof(T));
                        }
                    }
                    catch
                    {
                        Config[Key] = var;
                    }
            }
    and a util that does 'contains' but then with uppercase

    Code:
           bool IsUpperStringInList(string s, List<string> l)
            {
                string su = s.ToUpper();
                foreach (string ls in l)
                {
                    if (su.StartsWith(ls.ToUpper())) return true;
                }
                return false;
            }
    
    Note that having an empty LinkFilter and FilterIsAllow=true (which is the default), you will allow all.
    While having an empty LinkFilter and FilterIsAllow=false, you will deny all.

    Links are case insensitive.

    So, what do you think, Nogrod. Add this or something like this to the code?
     
  2. Anyone els since patch cant get it to upload pics? I get no error jsut dosent work
     
  3. how do you gain permition to it
     
  4. Wulf

    Wulf Community Admin

  5. How to grab image from Linux file system?
     
  6. Wulf

    Wulf Community Admin

    /path/to/file/name.png
     
  7. let/me/rephrase.that

    Windows I see your example "/sil file:///C:/Windows/test.png"

    Linux file systems are little different, where do I start the path from?

    Could you give me an example of a png file in the current user's home directory?
     
  8. Wulf

    Wulf Community Admin

    /sil /full/path/to/file/name.png

    or perhaps

    /sil username/path/to/file/name.png
     
  9. you mean "/sil file:///root/home/username/images/file.png"

    Or "....///home/username/images/file.png"

    Or "...///~/images/file.png"
     
  10. Wulf

    Wulf Community Admin

    I mean what I listed. I think file:// is generally Windows only. I've never used it like that though, so I can't guarantee it works.
     
  11. Trial and error. I got it.....

    "/sil file:///home/username/folder(s)/image.png"
     
  12. Is there a permission or way to disable uploading images from the local machine? That is a security risk right there.
     
  13. Wulf

    Wulf Community Admin

    Don't grant the permission for that, instead only grant the signartist.url permission.
     
  14. What is the permission for that? It isn't listed on the overview.
     
  15. Wulf

    Wulf Community Admin

    That is the permission, and it is listed on the Overview at the bottom.
     
  16. ... You're confusing. So what you are saying is signartist.url allows you to use URLs and files on the local machine? What is the permission for files on the local machine? This way I can make sure I don't grant it.
     
  17. Wulf

    Wulf Community Admin

    Sorry, I was wrong. I thought it was split, but apparently there is no way to prevent local files from being loaded.
     
  18. Oh okay, thanks for clarifying. Would you be able to fix this in the next update?
     
  19. Wulf

    Wulf Community Admin

    I'm not the author of this plugin, so that'd be up to @Nogrod.
     
  20. Oops :p. You are the author of half the plugins on here.