Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19

Thread: Not added to mysql

  1. #11
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    Quote Originally Posted by Ni3ls View Post
    And how do I check if an IP is banned?
    When the result is 1 then the IP is banned otherwise not banned (e.g. no results).
    PHP Code:
    SELECT 1 FROM bans WHERE ip INET_ATON('" + stripstring(self getip()) + "'LIMIT 1 
    Edit: you can also return the fields (ip, name, reason, admin) for showing the kick message.
    Last edited by Mitch; 18th August 2016 at 08:14.

  2. #12
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    Okay thanks. Switching the int in mysql to varchar did the trick

  3. #13
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    Sorry to bump, but whats the main difference between inet_atom and storing the ip?

    Code:
    inet_aton() converts the Internet host address cp from the IPv4 numbers-and-dots notation into binary form (in network byte order) and stores it in the structure that inp points to. inet_aton() returns nonzero if the address is valid, zero if not.
    Is there performance improvements or does it not affect ip changes?

  4. #14
    Private Whiskas's Avatar
    Join Date
    Jan 2015
    Posts
    84
    Thanks
    69
    Thanked 20 Times in 17 Posts
    Even with few manipulations (inet functions) IP is the same, but it's stored as number.

    Single IP with inet_aton can be saved in database as an integer in 4 bytes.

    If you would like to save an IP as varchar you would need to use varchar(15). If the charset of the text is ASCII it store 15 x 1 byte + 1 byte to save maximum length of text.

    Note: Even if ip would be 1.2.3.4, varchar uses maximum size it has (16 bytes)

    Conclusion: Each stored IP is 4 times larger when using varchar.

    Performance? More data more reading.

    If I'm wrong, correct me xD.

  5. The Following User Says Thank You to Whiskas For This Useful Post:

    Ni3ls (28th August 2016)

  6. #15
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts
    But I doubt it would have any noticable perfomance impact using strings over ints in CoD2

  7. #16
    Private Whiskas's Avatar
    Join Date
    Jan 2015
    Posts
    84
    Thanks
    69
    Thanked 20 Times in 17 Posts
    Yeah, guess we could count the difference in microseconds

  8. #17
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    With inet_aton it's easier to do subnet operations
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  9. #18
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    what kind of subnet operations?

  10. #19
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    like 1.2.3.0/24
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •