#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    3
    Rep Power
    0

    Need help, simple request.


    I run Counter Strike game servers and I need a little help.

    The problem is, I need a way to block players from posting other game serves IP addresses. There are several plugins that does this, but players have found a way around them.

    For ex. if a player types "Go to 208.74.66.20:27012 P G N Deathmatch Classic CZ" the plugin will block it, but if the player types "Go to 2 0 8 . 7 4 . 6 6 . 2 0 : 2 7 0 1 2 P G N Deathmatch Classic CZ" the plugin will not block it. So is there a way to block the IP addresses that have spaces in them or other symbols in them. Just to be clear, I want to block all IP addresses other than mines.

    Thanks for reading and I hope someone can help me.
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,054
    Rep Power
    9398
    Run the regex against the chat text after it's been stripped of all whitespace.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    3
    Rep Power
    0
    Thanks for responding, but I don't know alot about regex. What does that mean? Here is the regex that the script uses to block IPs.
    "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"
  6. #4
  7. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Oh god.

    Have you ever thought about checking numbers with actual number functions? I know people love regexes, but it's not the solution for everything.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    3
    Rep Power
    0
    Thanks Jacques1, but can you please explain. I'm new to this and I really don't understand.
  10. #6
  11. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    What I mean is that you should check number ranges with operators like "<", ">", "<=" etc.

    For example, if you want a variable "num" to be between 0 and 255, simply check for
    Code:
    num >= 0 && num <= 255
    (This is just pseudo-code, the actual code depends on what language you're using)

    Your language may even have this check built in. Anyway, everything is better than this unreadable regex.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".

IMN logo majestic logo threadwatch logo seochat tools logo