MyBB Community Forums

Full Version: How are IPs encoded in Database
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How are IP-Adresses encoded in the Database?

My first idea was that they were splited by dots and every part was converted to hex. Sadly my attempt to change a IP for testing if it works failed.

Then I searched the MyBB-Code (just scanned) and found the my_inet_pton()-Function which returned unreadable results. Is this the function? How to get this values to phpmyadmin?

The $db->escape_binary()-Function seems to have no affect on MySql, has it?

Thanks in advance ...
These are the two ip functions that I can find in /inc/functions.php:

 * Converts a human readable IP address to its packed in_addr representation
 * @param string The IP to convert
 * @return string IP in 32bit or 128bit binary format
function my_inet_pton($ip)

 * Converts a packed internet address to a human readable representation
 * @param string IP in 32bit or 128bit binary format
 * @return string IP in human readable format
function my_inet_ntop($ip)
@Ad Bakker: Thanks, but I already knew that! The one function produces unreadable results and is already mentioned in my first post and the other one should do the opposit.

[english letter ending],
OK, but when I set "Show Posting IP Addresses" to "all users", the correct IP address is shown at the bottom of posts. So the function my_inet_ntop seems to convert the IP address as stored in the database correctly.
PHP documentions covers both functions:
Thanks for answering and sorry, the my_inet_*()-Functions were the key. My fault was that I tried to Copy&Paste binary Codes between phpMyAdmin, Terminal and another phpMyAdmin.

Thanks again for answering!